Class DebuggingFormulaManager

java.lang.Object
org.sosy_lab.java_smt.delegate.debugging.DebuggingFormulaManager
All Implemented Interfaces:
FormulaManager

public class DebuggingFormulaManager extends Object implements FormulaManager
  • Constructor Details

    • DebuggingFormulaManager

      public DebuggingFormulaManager(FormulaManager pDelegate, org.sosy_lab.java_smt.delegate.debugging.DebuggingAssertions pDebugging)
  • Method Details

    • getIntegerFormulaManager

      public IntegerFormulaManager getIntegerFormulaManager()
      Description copied from interface: FormulaManager
      Returns the Integer-Theory. Because most SAT-solvers support automatic casting between Integer- and Rational-Theory, the Integer- and the RationalFormulaManager both return the same Formulas for numeric operations like ADD, SUBTRACT, TIMES, LESSTHAN, EQUAL and others.
      Specified by:
      getIntegerFormulaManager in interface FormulaManager
    • getRationalFormulaManager

      public RationalFormulaManager getRationalFormulaManager()
      Description copied from interface: FormulaManager
      Returns the Rational-Theory. Because most SAT-solvers support automatic casting between Integer- and Rational-Theory, the Integer- and the RationalFormulaManager both return the same Formulas for numeric operations like ADD, SUBTRACT, TIMES, LESSTHAN, EQUAL, etc.
      Specified by:
      getRationalFormulaManager in interface FormulaManager
    • getBooleanFormulaManager

      public BooleanFormulaManager getBooleanFormulaManager()
      Description copied from interface: FormulaManager
      Returns the Boolean-Theory.
      Specified by:
      getBooleanFormulaManager in interface FormulaManager
    • getArrayFormulaManager

      public ArrayFormulaManager getArrayFormulaManager()
      Description copied from interface: FormulaManager
      Returns the Array-Theory.
      Specified by:
      getArrayFormulaManager in interface FormulaManager
    • getBitvectorFormulaManager

      public BitvectorFormulaManager getBitvectorFormulaManager()
      Description copied from interface: FormulaManager
      Returns the Bitvector-Theory.
      Specified by:
      getBitvectorFormulaManager in interface FormulaManager
    • getFloatingPointFormulaManager

      public FloatingPointFormulaManager getFloatingPointFormulaManager()
      Description copied from interface: FormulaManager
      Returns the Floating-Point-Theory.
      Specified by:
      getFloatingPointFormulaManager in interface FormulaManager
    • getUFManager

      public UFManager getUFManager()
      Description copied from interface: FormulaManager
      Returns the function for dealing with uninterpreted functions (UFs).
      Specified by:
      getUFManager in interface FormulaManager
    • getSLFormulaManager

      public SLFormulaManager getSLFormulaManager()
      Description copied from interface: FormulaManager
      Returns the Seperation-Logic-Theory.
      Specified by:
      getSLFormulaManager in interface FormulaManager
    • getQuantifiedFormulaManager

      public QuantifiedFormulaManager getQuantifiedFormulaManager()
      Description copied from interface: FormulaManager
      Returns the interface for handling quantifiers.
      Specified by:
      getQuantifiedFormulaManager in interface FormulaManager
    • getStringFormulaManager

      public StringFormulaManager getStringFormulaManager()
      Description copied from interface: FormulaManager
      Returns the String Theory.
      Specified by:
      getStringFormulaManager in interface FormulaManager
    • getEnumerationFormulaManager

      public EnumerationFormulaManager getEnumerationFormulaManager()
      Description copied from interface: FormulaManager
      Returns the Enumeration Theory, e.g., also known as 'limited domain'.
      Specified by:
      getEnumerationFormulaManager in interface FormulaManager
    • makeVariable

      public <T extends Formula> T makeVariable(FormulaType<T> formulaType, String name)
      Description copied from interface: FormulaManager
      Create variable of the type equal to formulaType.
      Specified by:
      makeVariable in interface FormulaManager
      Parameters:
      formulaType - the type of the variable.
      name - the name of the variable.
      Returns:
      the created variable.
    • makeApplication

      public <T extends Formula> T makeApplication(FunctionDeclaration<T> declaration, List<? extends Formula> args)
      Description copied from interface: FormulaManager
      Create a function application to the given list of arguments.
      Specified by:
      makeApplication in interface FormulaManager
      Parameters:
      declaration - Function declaration
      args - List of arguments
      Returns:
      Constructed formula
    • makeApplication

      public <T extends Formula> T makeApplication(FunctionDeclaration<T> declaration, Formula... args)
      Description copied from interface: FormulaManager
      Create a function application to the given list of arguments.
      Specified by:
      makeApplication in interface FormulaManager
      Parameters:
      declaration - Function declaration
      args - List of arguments
      Returns:
      Constructed formula
    • getFormulaType

      public <T extends Formula> FormulaType<T> getFormulaType(T formula)
      Description copied from interface: FormulaManager
      Returns the type of the given Formula.
      Specified by:
      getFormulaType in interface FormulaManager
    • parse

      Description copied from interface: FormulaManager
      Parse a boolean formula given as a String in an SMTLIB file format. We expect exactly one assertion to be contained in the query.

      Example: (declare-fun x () Int)(assert (= 0 x))

      It depends on the used SMT solver whether the given query must be self-contained and include declarations for all used symbols or not, and also whether the query is allowed to contain symbols with equal name, but different type/sort than existing symbols. The safest way is to always declare all used symbols and to avoid conflicting types for them.

      The behavior of the SMT solver is undefined if commands are provided in the SMTLIB-based String that are different from declarations or an assertion, such as push/pop or set-info. Most solvers just ignore those commands.

      Variables that are defined, but not used in the assertion, might be ignored by the SMT solver and they might not be available for later usage.

      Specified by:
      parse in interface FormulaManager
      Returns:
      A single formula from the assertion in the internal representation.
      Throws:
      IllegalArgumentException - If the string cannot be parsed.
    • dumpFormula

      public Appender dumpFormula(BooleanFormula pT)
      Description copied from interface: FormulaManager
      Serialize an input formula to an SMT-LIB format. Very useful when passing formulas between different solvers.

      To get a String, simply call Object.toString() on the returned object. This method is lazy and does not create an output string until the returned object is actually used.

      Specified by:
      dumpFormula in interface FormulaManager
      Returns:
      SMT-LIB formula serialization.
    • applyTactic

      public BooleanFormula applyTactic(BooleanFormula input, Tactic tactic) throws InterruptedException
      Description copied from interface: FormulaManager
      Apply a tactic which performs formula transformation. The available tactics depend on the used solver.
      Specified by:
      applyTactic in interface FormulaManager
      Throws:
      InterruptedException
    • simplify

      public <T extends Formula> T simplify(T input) throws InterruptedException
      Description copied from interface: FormulaManager
      Simplify an input formula, while ensuring equivalence.

      For solvers that do not provide a simplification API, an original formula is returned.

      Specified by:
      simplify in interface FormulaManager
      Parameters:
      input - The input formula
      Returns:
      Simplified version of the formula
      Throws:
      InterruptedException
    • visit

      public <R> R visit(Formula f, FormulaVisitor<R> rFormulaVisitor)
      Description copied from interface: FormulaManager
      Visit the formula with a given visitor.

      This method does not recursively visit sub-components of a formula its own, so the given FormulaVisitor needs to call such visitation on its own.

      Please be aware that calling this method might cause extensive stack usage depending on the nesting of the given formula and the given FormulaVisitor. Additionally, sub-formulas that are used several times in the formula might be visited several times. For an efficient formula traversing, we also provide FormulaManager.visitRecursively(Formula, FormulaVisitor).

      Specified by:
      visit in interface FormulaManager
      Parameters:
      f - formula to be visited
      rFormulaVisitor - an implementation that provides steps for each kind of formula.
    • visitRecursively

      public void visitRecursively(Formula f, FormulaVisitor<TraversalProcess> rFormulaVisitor)
      Description copied from interface: FormulaManager
      Visit the formula recursively with a given FormulaVisitor. This method traverses sub-components of a formula automatically, depending on the return value of the TraversalProcess in the given FormulaVisitor.

      This method guarantees that the traversal is done iteratively, without using Java recursion, and thus is not prone to StackOverflowErrors.

      Furthermore, this method also guarantees that every equal part of the formula is visited only once. Thus, it can be used to traverse DAG-like formulas efficiently.

      The traversal is done in PRE-ORDER manner with regard to caching identical subtrees, i.e., a parent will be visited BEFORE its children. The unmodified child-formulas are passed as argument to the parent's visitation.

      Specified by:
      visitRecursively in interface FormulaManager
    • transformRecursively

      public <T extends Formula> T transformRecursively(T f, FormulaTransformationVisitor pFormulaVisitor)
      Description copied from interface: FormulaManager
      Visit the formula recursively with a given FormulaVisitor.

      This method guarantees that the traversal is done iteratively, without using Java recursion, and thus is not prone to StackOverflowErrors.

      Furthermore, this method also guarantees that every equal part of the formula is visited only once. Thus, it can be used to traverse DAG-like formulas efficiently.

      The traversal is done in POST-ORDER manner with regard to caching identical subtrees, i.e., a parent will be visited AFTER its children. The result of the child-visitation is passed as argument to the parent's visitation.

      Specified by:
      transformRecursively in interface FormulaManager
      pFormulaVisitor - Transformation described by the user.
    • extractVariables

      public ImmutableMap<String,Formula> extractVariables(Formula f)
      Description copied from interface: FormulaManager
      Extract the names of all free variables and UFs in a formula.
      Specified by:
      extractVariables in interface FormulaManager
      Parameters:
      f - The input formula
      Returns:
      Map from variable names to the corresponding formulas.
    • extractVariablesAndUFs

      public ImmutableMap<String,Formula> extractVariablesAndUFs(Formula f)
      Description copied from interface: FormulaManager
      Extract the names of all free variables and UFs in a formula.
      Specified by:
      extractVariablesAndUFs in interface FormulaManager
      Parameters:
      f - The input formula
      Returns:
      Map from variable names to the corresponding formulas. If an UF occurs multiple times in the input formula, an arbitrary instance of an application of this UF is in the map.
    • substitute

      public <T extends Formula> T substitute(T f, Map<? extends Formula,? extends Formula> fromToMapping)
      Description copied from interface: FormulaManager
      Substitute every occurrence of any item from changeFrom in formula f to the corresponding occurrence from changeTo.

      E.g. if changeFrom contains a variable a and changeTo contains a variable b all occurrences of a will be changed to b in the returned formula.

      Specified by:
      substitute in interface FormulaManager
      Parameters:
      f - Formula to change.
      fromToMapping - Mapping of old and new formula parts.
      Returns:
      Formula with parts replaced.
    • translateFrom

      public BooleanFormula translateFrom(BooleanFormula formula, FormulaManager otherManager)
      Description copied from interface: FormulaManager
      Translates the formula from another context into the context represented by this. Default implementation relies on string serialization (FormulaManager.dumpFormula(BooleanFormula) and FormulaManager.parse(String)), but each solver may implement more efficient translation between its own contexts.
      Specified by:
      translateFrom in interface FormulaManager
      Parameters:
      formula - Formula belonging to otherContext.
      otherManager - Formula manager belonging to the other context.
      Returns:
      Formula belonging to this context.
    • isValidName

      public boolean isValidName(String variableName)
      Description copied from interface: FormulaManager
      Check whether the given String can be used as symbol/name for variables or undefined functions.

      We explicitly state that with further development of SMT solvers and the SMTLib specification, the list of forbidden variable names may change in the future. Users should if possible not use logical or mathematical operators, or keywords strongly depending on SMTlib.

      If a variable name is rejected, a possibility is escaping, e.g. either substituting the whole variable name or just every invalid character with an escaped form. We recommend using an escape sequence based on the token "JAVASMT", because it might be unusual enough to appear when encoding a user's problem in SMT. Please note that you might also have to handle escaping the escape sequence. Examples:

      • the invalid variable name "=" (logical operator for equality) can be replaced with a string "JAVASMT_EQUALS".
      • the invalid SMTlib-escaped variable name "|test|" (the solver SMTInterpol does not allow the pipe symbol "|" in names) can be replaced with "JAVASMT_PIPEtestJAVASMT_PIPE".
      Specified by:
      isValidName in interface FormulaManager
    • escape

      public String escape(String variableName)
      Description copied from interface: FormulaManager
      Get an escaped symbol/name for variables or undefined functions, if necessary.

      See FormulaManager.isValidName(String) for further details.

      Specified by:
      escape in interface FormulaManager
    • unescape

      public String unescape(String variableName)
      Description copied from interface: FormulaManager
      Unescape the symbol/name for variables or undefined functions, if necessary.

      The result is undefined for Strings that are not properly escaped.

      See FormulaManager.isValidName(String) for further details.

      Specified by:
      unescape in interface FormulaManager