Class StructuralCausalModel

java.lang.Object
org.tweetyproject.causal.syntax.StructuralCausalModel
All Implemented Interfaces:
Iterable<PlFormula>, Collection<PlFormula>, BeliefBase

public class StructuralCausalModel extends Object implements BeliefBase, Collection<PlFormula>
This class describes a structural causal model in the sense of Pearl.
Author:
Julian Sander, Lars Bengel
See Also:
  • "Judea Pearl, 'Causality: models, reasoning and inference', 2000"
  • Constructor Details

    • StructuralCausalModel

      public StructuralCausalModel()
      Initializes an empty causal model
    • StructuralCausalModel

      public StructuralCausalModel(Collection<PlFormula> equations) throws StructuralCausalModel.CyclicDependencyException
      Initializes a causal model based on the given structural equations. Every structural equation must be a logical equivalence of the form: e <=> f(...) where 'e' is a literal and f(...) is some logical formula representing the 'cause' of 'e'. The equations must be non-cyclic.
      Parameters:
      equations - the set of structural equations
      Throws:
      StructuralCausalModel.CyclicDependencyException - iff the equations are cyclic
  • Method Details

    • getBackgroundAtoms

      public Collection<Proposition> getBackgroundAtoms()
      Returns the set of background atoms of the causal model
      Returns:
      the set of background atoms
    • getExplainableAtoms

      public Collection<Proposition> getExplainableAtoms()
      Returns the set of explainable atoms of the causal model
      Returns:
      the set of background atoms
    • getAtoms

      public Collection<Proposition> getAtoms()
      Returns the set of all atoms of the causal model
      Returns:
      the set of all atoms
    • getStructuralEquations

      public Collection<PlFormula> getStructuralEquations()
      Returns the structural equations of the causal model
      Returns:
      the structural equations
    • getCause

      public PlFormula getCause(Proposition atom)
      Get the cause of the given atom
      Parameters:
      atom - some atom of the causal model
      Returns:
      the cause of the atom
    • addBackgroundAtom

      public boolean addBackgroundAtom(Proposition atom)
      Adds a background atom to the model
      Parameters:
      atom - some new background atom
      Returns:
      true iff added successfully
    • addBackgroundAtoms

      public boolean addBackgroundAtoms(Collection<Proposition> atoms)
      Add new background atoms to the model
      Parameters:
      atoms - a set of new background atoms
      Returns:
      true iff added successfully
    • addExplainableAtom

      public boolean addExplainableAtom(PlFormula atom, PlFormula cause) throws StructuralCausalModel.CyclicDependencyException
      Adds a new explainable atom together with its cause to the causal model
      Parameters:
      atom - some new explainable atom
      cause - the cause of the new atom
      Returns:
      true iff added successfully
      Throws:
      StructuralCausalModel.CyclicDependencyException - iff the new equation introduces a cyclic dependency
    • getCounterfactualCopy

      public Proposition getCounterfactualCopy(Proposition proposition)
      Converts the given causal atom to a counterfactual copy
      Parameters:
      proposition - some causal atom
      Returns:
      the counterfactual copy of the given causal atom
    • getTwinModel

      public StructuralCausalModel getTwinModel()
      Constructs the twin model for this causal model, i.e., it creates for each structural equation a copy where all explainable atoms X are replaced by a twin version X*
      Returns:
      the twin model
    • intervene

      public StructuralCausalModel intervene(Proposition v, boolean x)
      Performs an intervention on the explainable atom 'v' by setting it to a given truth value. Removes the original cause of the atom and thus permanently changes the causal model
      Parameters:
      v - some explainable atom
      x - Truth value of the intervention
      Returns:
      newModel TODO should this be in-place instead?
    • prettyPrint

      public String prettyPrint()
      Returns a human-readable string representation of this causal model.
      Returns:
      a pretty-printed representation
    • toString

      public String toString()
      Specified by:
      toString in interface BeliefBase
      Overrides:
      toString in class Object
    • clone

      public StructuralCausalModel clone()
    • getMinimalSignature

      public Signature getMinimalSignature()
      Description copied from interface: BeliefBase
      Returns the signature of the language of this knowledge base.
      Specified by:
      getMinimalSignature in interface BeliefBase
      Returns:
      the signature of the language of this knowledge base.
    • size

      public int size()
      Specified by:
      size in interface Collection<PlFormula>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<PlFormula>
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<PlFormula>
    • iterator

      public Iterator<PlFormula> iterator()
      Specified by:
      iterator in interface Collection<PlFormula>
      Specified by:
      iterator in interface Iterable<PlFormula>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<PlFormula>
    • toArray

      public <T> T[] toArray(T[] a)
      Specified by:
      toArray in interface Collection<PlFormula>
    • add

      public boolean add(PlFormula plFormula)
      Specified by:
      add in interface Collection<PlFormula>
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<PlFormula>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<PlFormula>
    • addAll

      public boolean addAll(Collection<? extends PlFormula> c)
      Specified by:
      addAll in interface Collection<PlFormula>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<PlFormula>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<PlFormula>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<PlFormula>