Documentation

ExistentialRules.ChaseSequence.Nontermination.CyclicityPrefix

Cyclicity Prefixes #

This is section 5 of the [GC23a] paper. A CyclicityPrefix is a finite sequence of triggers that are all unblockable according to a RepeatableUnblockability condition. This allows to repeat the prefix indefinitely, which yields a CyclicityBranch. This is of course something that we need to prove here. Then the existence of a CyclicityPrefix directly implies that the underlying RuleSet.neverTerminates.

@[reducible, inline]

We can extend a signature with a type for fresh constants by setting the constants to be a Sum type of the original constants and the fresh type.

Equations
Instances For
    @[instance_reducible]
    Equations
    @[reducible, inline]

    In particular, we can simply use the variables as fresh constants. Think of this as constants that just happen to have the same name as the variables.

    Equations
    Instances For

      Change the constant of a Rule into the Sum type of Signature.withFreshConstants.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        The constants of the cast rule are exactly the constants of the original rule (mapped to the left part of the sum type).

        When calling Rule.cast_withFreshConstantsForVars, the variables in each head disjunct remain untouched.

        @[simp]

        When calling Rule.cast_withFreshConstantsForVars, the variables in the body remain untouched.

        @[simp]

        The frontier of the cast rule remains unchanged.

        @[simp]

        The cast rule isDatalog if and only if the original rule isDatalog.

        The constants of the cast rule set are exactly the constants of the original rule set (mapped to the left part of the sum type).

        The body_database of a rule is the body where each variable is replaced by a fresh constant. We achieve this by extending the signature and mapping all terms in the body using VarOrConst.cast_withFreshConstantsForVars.

        Equations
        Instances For

          The body_kb consists of the cast rule set and the body_database.

          Equations
          Instances For

            The trigger for a rule that matches its body_database.

            Equations
            Instances For

              The mapped_frontier of the body_database_trigger results from turning every frontier variable into its unique constant.

              The ChaseNodeOrigin for a rule that matches its body_database.

              Equations
              Instances For

                The body_database_origin adheres to the head choice.

                structure PreCyclicityPrefix {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] (obs : ObsolescenceCondition sig.withFreshConstantsForVars) {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} (hc_consistent : hc.consistent_for_same_rule) {rule : Rule sig} (rule_mem : rule ∈ rules) (rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []) :
                Type (max (max u_1 u_2) u_3)

                We define a structure, which is almost a CyclicityPrefix (missing some last conditions). We split this mainly to add some auxiliary definitions that we can use to express the remaining conditions more easily.

                Instances For
                  theorem PreCyclicityPrefix.triggers_ne_nil {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} {cp : PreCyclicityPrefix obs ⋯ rule_mem rule_hc_exis} :

                  The triggers are not empty.

                  def PreCyclicityPrefix.last_trigger {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} (cp : PreCyclicityPrefix obs ⋯ rule_mem rule_hc_exis) :

                  Since the trigger list is not empty, we can get the last trigger.

                  Equations
                  Instances For
                    theorem PreCyclicityPrefix.last_trigger_mem {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} {cp : PreCyclicityPrefix obs ⋯ rule_mem rule_hc_exis} :

                    The last_trigger occurs in triggers.

                    theorem PreCyclicityPrefix.rule_last_trigger {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} {obc : ObsolescenceCondition sig.withFreshConstantsForVars} {cp : PreCyclicityPrefix obc ⋯ rule_mem rule_hc_exis} :

                    The ex_last_trigger property expressed for the last_trigger shortcut.

                    In the end, we want to repeat the prefix using a constant mapping expressing the mapping from the database trigger to the last trigger. This mapping is what is defined here.

                    Equations
                    Instances For

                      The constantMappingForRepetition and repetitions thereof do not alter constants occurring in rules.

                      The last_trigger os exactly the initial database trigger with the constantMappingForRepetition applied. (Because this is essentially how the constantMappingForRepetition is defined.)

                      theorem PreCyclicityPrefix.result_last_trigger {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} {cp : PreCyclicityPrefix obs ⋯ rule_mem rule_hc_exis} :

                      The last_trigger result is the result of the initial trigger with the constantMappingForRepetition applied afterwards.

                      The last_trigger is loaded for the fact set immediately preceeding it.

                      def PreCyclicityPrefix.ithRepetition {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} (cp : PreCyclicityPrefix obs ⋯ rule_mem rule_hc_exis) (i : Nat) :

                      Returns the ith repetition of the trigger list obtained by extending the triggers with the constantMappingForRepetition i times. This is used for constructing an infinite list of finite trigger lists.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        theorem PreCyclicityPrefix.ithRepetition_zero {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} {cp : PreCyclicityPrefix obs ⋯ rule_mem rule_hc_exis} :

                        The 0-th repetition is the original trigger list.

                        Every following repetition results from extending the triggers with a single application of the constantMappingForRepetition.

                        @[simp]

                        The length of every repetition matches the length of the original trigger list.

                        The result of a trigger in the ithRepetition can be obtained by applying the constant mapping to the original trigger result.

                        We can arrange the i-th repetitions into an infinite list.

                        Equations
                        Instances For
                          def PreCyclicityPrefix.infiniteTriggerList {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} (cp : PreCyclicityPrefix obs ⋯ rule_mem rule_hc_exis) :

                          Then, we can turn the infinite list of i-th repetitions into a single infinite list and also prepend the initial trigger.

                          Equations
                          Instances For
                            theorem PreCyclicityPrefix.infiniteTriggerList_adheres {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} {cp : PreCyclicityPrefix obs ⋯ rule_mem rule_hc_exis} :

                            The infiniteTriggerList adheres to the head choice because the PreCyclicityPrefix does.

                            The infinite list of triggers can be turned into a regularChaseDerivationSkeleton.

                            Equations
                            Instances For
                              theorem PreCyclicityPrefix.infiniteRegularChaseDerivationSkeleton_next_eq {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} {cp : PreCyclicityPrefix obs ⋯ rule_mem rule_hc_exis} :
                              cp.infiniteRegularChaseDerivationSkeleton_next = { facts := rule.body_database.toFactSet.val ∪ CustomBasicDatastructures.List.toSet (Rule.body_database_origin obs rules hc rule rule_mem).result, origin := some (Rule.body_database_origin obs rules hc rule rule_mem), facts_contain_origin_result := ⋯ }

                              The "next" node of the infiniteRegularChaseDerivationSkeleton is the result of Rule.body_database_origin of the initial rule.

                              The head of the infiniteRegularChaseDerivationSkeleton contains only finitely many facts because the head is the rule database.

                              The head of the infiniteRegularChaseDerivationSkeleton is not empty because there is at least one existential variable in the initial rule.

                              structure CyclicityPrefix {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] (obs : ObsolescenceCondition sig.withFreshConstantsForVars) (obs_propagates : obs.propagates_under_term_mapping_of_no_fresh_term_occurs) (unblk : RepeatableUnblockability obs) {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} (hc_consistent : hc.consistent_for_same_rule) {rule : Rule sig} (rule_mem : rule ∈ rules) (rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []) extends PreCyclicityPrefix obs ⋯ rule_mem rule_hc_exis :
                              Type (max (max u_1 u_2) u_3)

                              The actual CyclicityPrefix definition based on PreCyclicityPrefix with extra conditions.

                              Instances For

                                Every functional term that occurs in the triggers of the CyclicityPrefix can only feature constants that occur in the frontier of the initial trigger. This is the case since a functional term can only come from an existential rule. But by the above result, the frontier of this rule then needs to feature a functional term from the original trigger, which in turn features all constants from the original frontier.

                                There is a constant in the initial mapped frontier that is mapped to a functional term by constantMappingForRepetition such that the constant occurs again in this functional term. This is used to show that applying the mapping repeatedly will therefore grow the term indefinitely.

                                There is a term in the database origin result that keeps growing along the constantMappingForRepetition.

                                For each n, the last trigger in the n-th sequence produces a term of depth at least n + 2.

                                For each n, we can find a trigger in the generated infinite list that yields a term of depth at least n.

                                For each number n, we can find a node in the generated chase derivation that has a term of depth at least n.

                                Every trigger in each repetition is unblockable.

                                theorem CyclicityPrefix.infiniteTriggerList_unblockable {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {obs_propagates : obs.propagates_under_term_mapping_of_no_fresh_term_occurs} {unblk : RepeatableUnblockability obs} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} {cp : CyclicityPrefix obs ⋯ unblk ⋯ rule_mem rule_hc_exis} (orig : ChaseNodeOrigin obs rules.cast_withFreshConstantsForVars) :
                                orig ∈ cp.infiniteTriggerList → Trigger.kbUnblockable (rule.body_kb rules) hc orig.fst.val

                                Every trigger in the PreCyclicityPrefix.infiniteTriggerList is unblockable.

                                def CyclicityPrefix.to_cyclicityBranch {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] [DecidableEq sig.P] [Inhabited sig.C] {obs : ObsolescenceCondition sig.withFreshConstantsForVars} {obs_propagates : obs.propagates_under_term_mapping_of_no_fresh_term_occurs} {unblk : RepeatableUnblockability obs} {rules : RuleSet sig} {hc : HeadChoice sig.withFreshConstantsForVars} {hc_consistent : hc.consistent_for_same_rule} {rule : Rule sig} {rule_mem : rule ∈ rules} {rule_hc_exis : rule.body_database_trigger.rule.existential_vars_for_head_disjunct ↑(hc rule.body_database_trigger) ⋯ ≠ []} (cp : CyclicityPrefix obs ⋯ unblk ⋯ rule_mem rule_hc_exis) :
                                CyclicityBranch obs (rule.body_kb rules) hc

                                By repeating the CyclicityPrefix indefinitely, we obtain a CyclicityBranch.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  If a rule set admist a CyclicityPrefix, then we can also build a CyclicityBranch and therefore we witness that the RuleSet.neverTerminates.