Substitutions and other mappings on Terms #
In this file, we define mainly GroundSubstitution and GroundTermMapping. The latter is used to define homomorphisms on FactSets.
Both kinds of mapping are based on a (very general) TermMapping.
TermMapping #
The TermMapping is really just a function between two types but we
define a bit of machinery on it that captures how remapping terms in such a general way behaves in the context of a GeneralizedAtom or lists or sets thereof.
A TermMapping is nothing more than a function from one term type to another.
Equations
- TermMapping S T = (S → T)
Instances For
A TermMapping is applied to a GeneralizedAtom by simply applying it to each term.
Equations
Instances For
A TermMapping is applied to a list of GeneralizedAtoms by applying it to each atom.
Equations
Instances For
A TermMapping is applied to a set of GeneralizedAtoms by applying it to each atom.
Equations
Instances For
Applying a TermMapping to a GeneralizedAtom does not change the number of terms.
We can split the application of a composed TermMapping on an atom.
We can split the application of a composed TermMapping on an atom.
To show that applying two TermMappings on the same atom yields the same result, it is enough to show that the mappings behave identical on each term.
Applying a TermMapping on a GeneralizedAtom is the identity if the mapping is the identity on each term.
We can split the application of a composed TermMapping on a list of atoms.
We can split the application of a composed TermMapping on a list of atoms.
We can split the application of a composed TermMapping on a set of atoms.
We can split the application of a composed TermMapping on a set of atoms.
Applying a TermMapping to both an atom and a set of atoms retains membership of the atom in the set.
Applying the same TermMapping to two sets of atoms retains their subset relation.
When mapping a set of atoms that results from the list, we can instead map on the list and then convert to the set.
GroundSubstitution #
GroundSubstitution is used mainly on rules to map the variables to some actual ground terms.
This is a key ingredient of PrTriggers that model "rule applications" in the chase.
A GroundSubstitution is merely a TermMapping from variables to GroundTerms.
Equations
- GroundSubstitution sig = TermMapping sig.V (GroundTerm sig)
Instances For
We lift GroundSubstitutions to mappings from VarOrConst to GroundTerm in the obvious way.
Equations
- σ.apply_var_or_const (VarOrConst.var v) = σ v
- σ.apply_var_or_const (VarOrConst.const c) = GroundTerm.const c
Instances For
We lift GroundSubstitutions to mappings from SkolemTerm to GroundTerm in the obvious way.
Equations
- σ.apply_skolem_term (SkolemTerm.var v) = σ v
- σ.apply_skolem_term (SkolemTerm.const c) = GroundTerm.const c
- σ.apply_skolem_term (SkolemTerm.func fs frontier arity_ok) = GroundTerm.func fs (List.map (fun (fv : sig.V) => σ fv) frontier) ⋯
Instances For
On functional SkolemTerms that share the same frontier, applying a GroundSubstitution is injective.
Using the standard functionality of TermMapping, we can apply GroundSubstitutions directly to an Atom yielding a Fact.
Equations
Instances For
Using the standard functionality of TermMapping, we can apply GroundSubstitutions directly to a FunctionFreeAtom yielding a Fact.
Instances For
Using the standard functionality of TermMapping, we can apply GroundSubstitutions directly to a FunctionFreeConjunction yielding a list of Facts.
Instances For
GroundTermMapping #
A GroundTermMapping maps GroundTerms to GroundTerms and is used to define homomorphisms over FactSets.
A GroundTermMapping is merely a TermMapping over GroundTerms.
Equations
- GroundTermMapping sig = TermMapping (GroundTerm sig) (GroundTerm sig)
Instances For
Equations
- h.isIdOnConstants = ∀ {c : sig.C}, h (GroundTerm.const c) = GroundTerm.const c
Instances For
Using the standard functionality of TermMapping, we can list GroundTermMappings to Facts.
Equations
Instances For
Using the standard functionality of TermMapping, we can list GroundTermMappings to FactSets.
Equations
Instances For
A GroundTermMapping is a homomorphisms from FactSet A to B if each constant is mapped to itself and mapping A results in a subset of B.
Equations
- h.isHomomorphism A B = (h.isIdOnConstants ∧ h.applyFactSet A ⊆ B)
Instances For
The terms in a mapped FactSet are the same as the mapped terms from the original FactSet.
We can compose homomorphisms. That is, given a homomorphism from A to B and from B to C, we can combine both to obtain a homomorphisms from A to C.
Interactions of GroundSubstitution and GroundTermMapping #
Sometimes, a GroundSubstitution and GroundTermMapping might be composed into a single GroundSubstitution.
In such a case, it can be useful to be able to split them apart. But this is generally only possible if the GroundTermMapping leaves the relevant constants untouched.
The application of a composed substitution on a VarOrConst can be split if the involved GroundTermMapping maps the VarOrConst to itself, in the case where it is a constant.
This is a special case of the above theorem where the GroundTermMapping is simply the id on all constants.
The application of a composed substitution on a FunctionFreeAtom can be split if the involved GroundTermMapping maps all constants from the atom to themselves.
This is a special case of the above theorem where the GroundTermMapping is simply the id on all constants.
The application of a composed substitution on a FunctionFreeConjunction can be split if the involved GroundTermMapping maps all constants from the conjucntion to themselves.
This is a special case of the above theorem where the GroundTermMapping is simply the id on all constants.