Skip to main content

CausalExprArena

Struct CausalExprArena 

Source
pub struct CausalExprArena { /* private fields */ }
Expand description

Arena for causal expressions with interned variable sets.

Implementations§

Source§

impl CausalExprArena

Source

pub fn compile(&self, root: ExprId) -> Result<CompiledEvaluator, EvalError>

Compile root into a topological evaluation plan.

Continuous ExprNode::IntegralOut compiles successfully; evaluation uses DistributionProvider::quadrature or discrete DistributionProvider::support.

Source§

impl CausalExprArena

Source

pub fn new() -> Self

Empty arena.

Source

pub fn intern_var_set( &mut self, vars: impl IntoIterator<Item = VariableId>, ) -> VarSetId

Intern a sorted variable set (sorts and dedups input).

Source

pub fn intern_intervention_assignments( &mut self, assignments: impl IntoIterator<Item = InterventionAssignment>, ) -> InterventionSetId

Intern a hard-intervention assignment set (sorted by variable id).

Source

pub fn intern_intervention_set( &mut self, vars: impl IntoIterator<Item = VariableId>, ) -> InterventionSetId

Intern an intervention over variables only (value unspecified / placeholder).

Source

pub fn empty_var_set(&mut self) -> VarSetId

Empty var set.

Source

pub fn empty_intervention_set(&mut self) -> InterventionSetId

Empty intervention set.

Source

pub fn var_set(&self, id: VarSetId) -> &[VariableId]

Look up a var set.

Source

pub fn intervention_assignments( &self, id: InterventionSetId, ) -> &[InterventionAssignment]

Look up intervention assignments.

Source

pub fn intervention_set(&self, id: InterventionSetId) -> Vec<VariableId>

Variables appearing in an intervention set (legacy helper).

Source

pub fn intern_list( &mut self, exprs: impl IntoIterator<Item = ExprId>, ) -> ExprListId

Intern an expression list.

Source

pub fn list(&self, id: ExprListId) -> &[ExprId]

Borrow an interned expression list.

Source

pub fn intern(&mut self, node: ExprNode) -> ExprId

Hash-cons an expression node.

Source

pub fn set_derivation(&mut self, id: ExprId, meta: DerivationMeta)

Attach derivation metadata (does not affect semantic equality).

Source

pub fn set_derivation_if_absent(&mut self, id: ExprId, meta: DerivationMeta)

Attach derivation metadata only when absent (never overwrites ID rules).

Source

pub fn simplify(&mut self, root: ExprId) -> Result<ExprId, SimplifyError>

Simplify root with worklist-style bottom-up rewrite + memoization.

§Errors

SimplifyError if a SumOut/IntegralOut binds a variable absent from its body’s free variables — an ill-formed estimand. See SimplifyError docs.

Source

pub fn derivation(&self, id: ExprId) -> Option<&DerivationMeta>

Borrow derivation metadata.

Source

pub fn node(&self, id: ExprId) -> &ExprNode

Borrow a node.

Source

pub fn len(&self) -> usize

Number of nodes.

Source

pub fn is_empty(&self) -> bool

Whether empty.

Source

pub fn var_set_count(&self) -> usize

Number of interned variable sets (for serialization).

Source

pub fn intervention_set_count(&self) -> usize

Number of interned intervention sets (for serialization).

Source

pub fn list_count(&self) -> usize

Number of interned expression lists (for serialization).

Source

pub fn backdoor_ate( &mut self, treatment: VariableId, outcome: VariableId, adjustment: &[VariableId], active: Value, control: Value, ) -> ExprId

Build the backdoor adjustment functional for ATE: E[Y | do(T=active)] − E[Y | do(T=control)] under adjustment by Z.

Source

pub fn frontdoor_ate( &mut self, treatment: VariableId, outcome: VariableId, mediators: &[VariableId], active: Value, control: Value, ) -> ExprId

Build the front-door functional for ATE: E[Y | do(T=active)] − E[Y | do(T=control)], mediated through M via sum_m P(m | t) * sum_t' P(y | m, t') P(t') (FD condition 2 reduces P(m | do(t)) to the observational P(m | t)).

Source

pub fn temporal_mediation_ate( &mut self, treatment: VariableId, outcome: VariableId, mediators: &[VariableId], active: Value, control: Value, ) -> ExprId

Linear temporal-mediation path-product ATE contrast (same product-of-coefficients geometry as front-door under a linear SEM, tagged temporal_mediation — not front-door).

Source

pub fn iv_wald( &mut self, treatment: VariableId, outcome: VariableId, instruments: &[VariableId], active: &Value, control: &Value, ) -> ExprId

Build the Wald IV functional for binary instrument Z: (E[Y|Z=1] − E[Y|Z=0]) / (E[T|Z=1] − E[T|Z=0]).

active / control are recorded in derivation metadata (treatment contrast scaling); the ratio itself conditions on instrument levels 1 and 0.

Source

pub fn pretty(&self, id: ExprId) -> String

Pretty-print an expression (diagnostics only; not an equality key).

Source

pub fn latex(&self, id: ExprId) -> String

Render an expression as LaTeX (diagnostics only; not an equality key).

Trait Implementations§

Source§

impl Clone for CausalExprArena

Source§

fn clone(&self) -> CausalExprArena

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CausalExprArena

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CausalExprArena

Source§

fn default() -> CausalExprArena

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.