Class FormulaUnLet

java.lang.Object

public class FormulaUnLet
extends TermTransformer
This class removes all let terms from the formula. It's a term transformer that transforms a term with lets into an equivalent term without let. A tricky issue here are variable name clashes that can appear when renaming. This class will check whether renaming is necessary, i.e., if a let makes a variable with the same name as a bounded variable visible inside the quantifier. A simple example is (let ((y x)) (exists ((x Int)) (= x y))). In this case the variable of the inner quantifier is renamed by adding dots in front of it. Note that symbols starting with a dot are reserved for solver use. By renaming in a consistent manner and by only renaming if there is a name clash, the unletted form of an assumed term in a proof should be equal to the unletted asserted term.
Author:
Jochen Hoenicke
  • Constructor Details

    • FormulaUnLet

      public FormulaUnLet()
      Create a FormulaUnLet with the standard SMT-LIB semantics for let.
    • FormulaUnLet

      public FormulaUnLet​(FormulaUnLet.UnletType type)
      Create a FormulaUnLet.
      Parameters:
      type - The type of the unletter.
  • Method Details

    • addSubstitutions

      public void addSubstitutions​(java.util.Map<TermVariable,​Term> termSubst)
      Add user defined substitutions. This allows to map variables to terms, without adding a surrounding let term first. Note that these substitutions are then used for all formulas unletted by this class.
      Parameters:
      termSubst - The substitution, which maps term variables to the term with which they should be substituted.
    • unlet

      public Term unlet​(Term term)
      Unlet a term, i.e., remove all LetTerm and replace the term variables accordingly.
      Parameters:
      term - the term to unlet
      Returns:
      the resulting let-free term.
    • startVarScope

      public void startVarScope​(Term body, TermVariable[] vars)
      This is called for each quantifier, lambda term, or match term that introduces new bound variables. It determines if there is a name clash and renamed the bound variables accordingly. It adds the corresponding renaming to the let map. This also adds a new scope to the let map.
      Parameters:
      body - The term that contains the bounded variables.
      vars - The bounded variables that may need to be renamed.
    • endVarScope

      public TermVariable[] endVarScope​(TermVariable[] vars)
      Ends a variable scope and determines the renamed bounded variables.
      Parameters:
      vars - the bounded variables of the exists, lambda or match term.
      Returns:
      the renamed variables in case renaming bounded variables were necessary (returns vars if no renaming was necessary).
    • convert

      public void convert​(Term term)
      Description copied from class: TermTransformer
      The function that does the transformation. Override this function if you build your own term transformer. It does not return the result but instead it puts it on the converted stack using setResult(). Instead it can also enqueue some Builders that will in the end put the result on the converted stack. You can always call super.convert() if you do not need to convert the term. It will still convert the sub-terms. If you do not want to convert the sub terms, call setResult(term) instead.
      Overrides:
      convert in class TermTransformer
      Parameters:
      term - The term to convert.
    • preConvertLet

      public void preConvertLet​(LetTerm oldLet, Term[] newValues)
      Overrides:
      preConvertLet in class TermTransformer
    • postConvertLet

      public void postConvertLet​(LetTerm oldLet, Term[] newValues, Term newBody)
      Overrides:
      postConvertLet in class TermTransformer
    • postConvertLambda

      public void postConvertLambda​(LambdaTerm old, Term newBody)
      Build the converted formula for a lambda term. This also ends the scope of the lambda term. It stores the converted quantifier using TermTransformer.setResult(Term).
      Overrides:
      postConvertLambda in class TermTransformer
      Parameters:
      old - the quantifier to convert.
      newBody - the converted sub formula.
    • postConvertQuantifier

      public void postConvertQuantifier​(QuantifiedFormula old, Term newBody)
      Build the converted formula for a quantified formula. This also ends the scope of the quantifier. It stores the converted quantifier using TermTransformer.setResult(Term).
      Overrides:
      postConvertQuantifier in class TermTransformer
      Parameters:
      old - the quantifier to convert.
      newBody - the converted sub formula.
    • preConvertMatchCase

      public void preConvertMatchCase​(MatchTerm oldMatch, int caseNr)
      Overrides:
      preConvertMatchCase in class TermTransformer
    • postConvertMatch

      public void postConvertMatch​(MatchTerm oldMatch, Term newDataTerm, Term[] newCases)
      Overrides:
      postConvertMatch in class TermTransformer