Class FOQueries
java.lang.Object
fr.inria.rules.integraal.util.FOQueries
Utility class for First Order Queries
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordGroups transformed queries together with the replacements used for evaluable parts. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateImageWith(FOQuery<Formula> query, Substitution s) Deprecated.static booleanisConsistent(FOQuery<?> query, Substitution s) A query is consistent with a given substitution iff the query equalities and the substitution are compatible.static <Formula extends FOFormula>
FOQueries.EvaluableQueriesReplacementResult<Formula> replaceEvaluableParts(Collection<FOQuery<? extends FOFormula>> queries) 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 ofqueries.
-
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 froms- substitution to apply- Returns:
- a new FOFormula corresponding to the given FOFormula in which the given substitution have been applied
-
isConsistent
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 querys- 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 everyEvaluableFunctionandComputedAtomappearing in any query ofqueries. The same placeholder is reused across the full collection so that identical evaluable constructs are mapped consistently.- Type Parameters:
Formula- concrete subtype ofFOFormulacontained 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 → Invokerfor eachComputedAtom.
-
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 ofqueries.- Type Parameters:
Formula- concrete subtype ofFOFormula- Parameters:
queries- collection previously transformed withreplaceEvaluableParts(Collection)functionReplacement- bijective map returned by the replacement stepatomReplacement- map returned by the replacement step- Returns:
- list of queries in which evaluable constructs have been reinstated
- Throws:
IllegalStateException- if aTermSequenceCompoundencountered during restoration is neitherLogicalFunctionalTermnorEvaluableFunction
-