Class FOQueries

java.lang.Object
fr.inria.rules.integraal.util.FOQueries

public class FOQueries extends Object
Utility class for First Order Queries
  • Constructor Details

    • FOQueries

      public FOQueries()
      Creates the FO-query utility.
  • Method Details

    • createImageWith

      @Deprecated public static <Formula extends FOFormula> FOQuery<Formula> createImageWith(FOQuery<Formula> query, Substitution s)
      Deprecated.
      constants or literals affected to answer variables by the given substitution are put in the equalities variable renaming is directly applied
      Type Parameters:
      Formula - the formula type contained in the query
      Parameters:
      query - query to create the image from
      s - substitution to apply
      Returns:
      a new FOFormula corresponding to the given FOFormula in which the given substitution have been applied
    • isConsistent

      public static boolean isConsistent(FOQuery<?> query, Substitution s)
      A query is consistent with a given substitution iff the query equalities and the substitution are compatible.
      They are said compatible if one cannot infer equality between two constants.

      This means that :

      • the equalities are valid (no 2 constant on the same equality-class)
      • a variable equal to a constant by the equalities cannot be affected to another term by the substitution
      • two variables equal by the equalities cannot be affected to two different terms by the substitution

      The variables in the equalities and domain of the substitution belong to the query.
      The variables in the range of the substitution are different from the variables of the query (even if they have the same String representation)

      Parameters:
      query - the query
      s - the substitution
      Returns:
      true iff the query is consistent with the substitution
    • replaceEvaluableParts

      public static <Formula extends FOFormula> FOQueries.EvaluableQueriesReplacementResult<Formula> replaceEvaluableParts(Collection<FOQuery<? extends FOFormula>> queries)
      Replaces every EvaluableFunction and ComputedAtom appearing in any query of queries. The same placeholder is reused across the full collection so that identical evaluable constructs are mapped consistently.
      Type Parameters:
      Formula - concrete subtype of FOFormula contained in each query
      Parameters:
      queries - collection of queries to transform
      Returns:
      record containing:
      • the transformed queries (same iteration order),
      • a bijective map EvaluableFunction → LogicalFunctionalTerm,
      • a map Predicate → Invoker for each ComputedAtom.
    • restoreEvaluableParts

      public static <Formula extends FOFormula> List<FOQuery<Formula>> restoreEvaluableParts(Collection<FOQuery<? extends FOFormula>> queries, com.google.common.collect.BiMap<EvaluableFunction, LogicalFunctionalTerm> functionReplacement, com.google.common.collect.BiMap<Predicate, Invoker> atomReplacement)
      Restores evaluable parts in each query of queries.
      Type Parameters:
      Formula - concrete subtype of FOFormula
      Parameters:
      queries - collection previously transformed with replaceEvaluableParts(Collection)
      functionReplacement - bijective map returned by the replacement step
      atomReplacement - map returned by the replacement step
      Returns:
      list of queries in which evaluable constructs have been reinstated
      Throws:
      IllegalStateException - if a TermSequenceCompound encountered during restoration is neither LogicalFunctionalTerm nor EvaluableFunction