Documentation

ExistentialRules.AtomsAndFacts.SubstitutionsAndHomomorphisms

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.

@[reducible, inline]
abbrev TermMapping (S : Type u) (T : Type v) :
Type (max u v)

A TermMapping is nothing more than a function from one term type to another.

Equations
Instances For
    def TermMapping.apply_generalized_atom {sig : Signature} [DecidableEq sig.P] {S : Type u_4} {T : Type u_5} (h : TermMapping S T) (a : GeneralizedAtom sig S) :

    A TermMapping is applied to a GeneralizedAtom by simply applying it to each term.

    Equations
    Instances For
      def TermMapping.apply_generalized_atom_list {sig : Signature} [DecidableEq sig.P] {S : Type u_4} {T : Type u_5} (h : TermMapping S T) (l : List (GeneralizedAtom sig S)) :

      A TermMapping is applied to a list of GeneralizedAtoms by applying it to each atom.

      Equations
      Instances For
        def TermMapping.apply_generalized_atom_set {sig : Signature} [DecidableEq sig.P] {S : Type u_4} {T : Type u_5} (h : TermMapping S T) (s : Set (GeneralizedAtom sig S)) :

        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.

          theorem TermMapping.apply_generalized_atom_congr_left {sig : Signature} [DecidableEq sig.P] {S : Type u_1} {T : Type u_2} (g h : TermMapping S T) (a : GeneralizedAtom sig S) :
          (∀ (t : S), t a.termsg t = h t)g.apply_generalized_atom a = h.apply_generalized_atom a

          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.

          theorem TermMapping.apply_generalized_atom_eq_self_of_id_on_terms {sig : Signature} [DecidableEq sig.P] {T : Type u_1} (h : TermMapping T T) (a : GeneralizedAtom sig T) (id_on_terms : ∀ (t : T), t a.termsh t = t) :

          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.

          @[reducible, inline]
          abbrev GroundSubstitution (sig : Signature) [DecidableEq sig.C] [DecidableEq sig.V] :
          Type (max u_2 u_3 u_2)

          A GroundSubstitution is merely a TermMapping from variables to GroundTerms.

          Equations
          Instances For

            We lift GroundSubstitutions to mappings from SkolemTerm to GroundTerm in the obvious way.

            Equations
            Instances For
              theorem GroundSubstitution.apply_skolem_term_injective_on_func_of_frontier_eq {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] {a : SkolemFS sig} {frontier : List sig.V} {arity_a : frontier.length = a.arity} {b : SkolemFS sig} {arity_b : frontier.length = b.arity} (subs : GroundSubstitution sig) (s t : SkolemTerm sig) (hs : s = SkolemTerm.func a frontier arity_a) (ht : t = SkolemTerm.func b frontier arity_b) :
              subs.apply_skolem_term s = subs.apply_skolem_term ts = t

              On functional SkolemTerms that share the same frontier, applying a GroundSubstitution is injective.

              @[reducible, inline]
              abbrev GroundSubstitution.apply_atom {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] (σ : GroundSubstitution sig) :
              Atom sigFact sig

              Using the standard functionality of TermMapping, we can apply GroundSubstitutions directly to an Atom yielding a Fact.

              Equations
              Instances For
                @[reducible, inline]

                Using the standard functionality of TermMapping, we can apply GroundSubstitutions directly to a FunctionFreeAtom yielding a Fact.

                Equations
                Instances For
                  @[reducible, inline]

                  Using the standard functionality of TermMapping, we can apply GroundSubstitutions directly to a FunctionFreeConjunction yielding a list of Facts.

                  Equations
                  Instances For

                    GroundTermMapping #

                    A GroundTermMapping maps GroundTerms to GroundTerms and is used to define homomorphisms over FactSets.

                    @[reducible, inline]
                    abbrev GroundTermMapping (sig : Signature) [DecidableEq sig.C] [DecidableEq sig.V] :
                    Type (max u_3 u_2)

                    A GroundTermMapping is merely a TermMapping over GroundTerms.

                    Equations
                    Instances For
                      @[reducible, inline]
                      abbrev GroundTermMapping.applyFact {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] (h : GroundTermMapping sig) :
                      Fact sigFact sig

                      Using the standard functionality of TermMapping, we can list GroundTermMappings to Facts.

                      Equations
                      Instances For
                        @[reducible, inline]

                        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
                          Instances For

                            The terms in a mapped FactSet are the same as the mapped terms from the original FactSet.

                            theorem GroundTermMapping.isHomomorphism_compose {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] (g h : GroundTermMapping sig) (A B C : FactSet sig) :
                            g.isHomomorphism A Bh.isHomomorphism B CisHomomorphism (h g) A C

                            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.