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.
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.
Instances For
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
- sig.withFreshConstantsForVars = sig.withFreshConstants sig.V
Instances For
This turns a VarOrConst into the constant Sum type of Signature.withFreshConstants.
Equations
Instances For
Change the constant of a VarOrConst into the Sum type of Signature.withFreshConstants.
Equations
Instances For
Calling VarOrConst.filterConsts after cast_withFreshConstantsForVars can be simplified to simply mapping over the original filtered constants.
Calling VarOrConst.filterVars after cast_withFreshConstantsForVars is the same as only calling VarOrConst.filterVars.
Then applying cast_withFreshConstantsForVars to a conjunction, the variables remain unchanged.
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).
The length of the Rule.head is not changed by cast_withFreshConstantsForVars.
When calling Rule.cast_withFreshConstantsForVars, the variables in each head disjunct remain untouched.
When calling Rule.cast_withFreshConstantsForVars, the variables in the body remain untouched.
The frontier of the cast rule remains unchanged.
The cast rule isDatalog if and only if the original rule isDatalog.
Change the constant of a RuleSet into the Sum type of Signature.withFreshConstants.
Equations
Instances For
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
- r.body_kb rules = { db := r.body_database, rules := rules.cast_withFreshConstantsForVars }
Instances For
The trigger for a rule that matches its body_database.
Equations
- r.body_database_trigger = { rule := r.cast_withFreshConstantsForVars, subs := GroundTerm.const ∘ Sum.inr }
Instances For
The mapped_body of the body_database_trigger is exactly the body_database.
The body_database_trigger is loaded for the body_database.
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
- Rule.body_database_origin obs rules hc r r_mem = ⟨⟨Trigger.fromPreTrigger r.body_database_trigger { cond := obs.cond, monotone := ⋯ }, ⋯⟩, hc r.body_database_trigger⟩
Instances For
The body_database_origin adheres to the head choice.
For a signature withFreshConstantsForVars, we can turn a GroundSubstitution into a ConstantMapping.
Equations
Instances For
Applying GroundSubstitution.toConstantMapping_for_sig_withFreshConstantsForVars after turning a variable into its unique constant behaves the same as the original substitution.
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.
- body_database_trigger_unblockable : Trigger.kbUnblockable (rule.body_kb rules) hc (Trigger.fromPreTrigger rule.body_database_trigger { cond := obs.cond, monotone := ⋯ })
- triggers : FiniteTriggerList obs rules.cast_withFreshConstantsForVars
- adheres_to_headChoice : self.triggers.adheres_to_headChoice hc
- triggers_loaded : FiniteTriggerList.loaded (rule.body_database.toFactSet.val ∪ CustomBasicDatastructures.List.toSet (Rule.body_database_origin obs rules hc rule rule_mem).result) self.triggers
- ex_last_trigger : ∃ (last : ChaseNodeOrigin obs rules.cast_withFreshConstantsForVars), last ∈ List.getLast? self.triggers ∧ last.fst.val.rule = rule.cast_withFreshConstantsForVars
Instances For
The triggers are not empty.
We can cast the triggers into a FiniteNonEmptyTriggerList.
Equations
Instances For
Since the trigger list is not empty, we can get the last trigger.
Equations
- cp.last_trigger = List.getLast cp.triggers ⋯
Instances For
The last_trigger occurs in triggers.
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.)
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.
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
The 0-th repetition is the original trigger list.
Every following repetition results from extending the triggers with a single application of the constantMappingForRepetition.
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
- cp.infiniteList_of_finiteLists i = cp.ithRepetition i
Instances For
Each repetition adheres to the headChoice.
Each repetition is loaded.
Then, we can turn the infinite list of i-th repetitions into a single infinite list and also prepend the initial trigger.
Equations
- cp.infiniteTriggerList = InfiniteList.cons (Rule.body_database_origin obs rules hc rule rule_mem) (InfiniteTriggerList.fromFiniteLists cp.infiniteList_of_finiteLists)
Instances For
The infiniteTriggerList adheres to the head choice because the PreCyclicityPrefix does.
The infiniteTriggerList is loaded because the PreCyclicityPrefix is.
The infinite list of triggers can be turned into a regularChaseDerivationSkeleton.
Equations
Instances For
Since the infiniteRegularChaseDerivationSkeleton is infinite, every suffix has a next value.
A shortcut for unwrapping the next element of the infiniteRegularChaseDerivationSkeleton.
Equations
Instances For
The above shortcut behaves as expected.
The head of the infiniteRegularChaseDerivationSkeleton is the Rule.body_database of the initial rule.
The head of the infiniteRegularChaseDerivationSkeleton has no origin.
The "next" node of the infiniteRegularChaseDerivationSkeleton is the result of Rule.body_database_origin of the initial rule.
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.
Every node in the infiniteRegularChaseDerivationSkeleton has a finite fact set.
The head of the infiniteRegularChaseDerivationSkeleton is not empty because there is at least one existential variable in the initial rule.
Every node in the infiniteRegularChaseDerivationSkeleton has a non-empty fact set.
The infiniteRegularChaseDerivationSkeleton also adheres to the head choice since the infiniteTriggerList does. (This holds by definition.)
The actual CyclicityPrefix definition based on PreCyclicityPrefix with extra conditions.
- body_database_trigger_unblockable : Trigger.kbUnblockable (rule.body_kb rules) hc (Trigger.fromPreTrigger rule.body_database_trigger { cond := obs.cond, monotone := ⋯ })
- triggers : FiniteTriggerList obs rules.cast_withFreshConstantsForVars
- triggers_loaded : FiniteTriggerList.loaded (rule.body_database.toFactSet.val ∪ CustomBasicDatastructures.List.toSet (Rule.body_database_origin obs rules hc rule rule_mem).result) self.triggers
- ex_last_trigger : ∃ (last : ChaseNodeOrigin obs rules.cast_withFreshConstantsForVars), last ∈ List.getLast? self.triggers ∧ last.fst.val.rule = rule.cast_withFreshConstantsForVars
- triggers_unblockable (orig : ChaseNodeOrigin obs rules.cast_withFreshConstantsForVars) : orig ∈ self.triggers → unblk.trigger_unblockable rules.cast_withFreshConstantsForVars hc orig.fst.val
- constantMapping_reversible_in_each_step (i : Nat) (orig : ChaseNodeOrigin obs rules.cast_withFreshConstantsForVars) : orig ∈ self.triggers → (self.constantMappingForRepetition.repeat_fun i).isReversible (CustomBasicDatastructures.List.toSet orig.fst.val.termSkeleton)
- exis_triggers_feature_function_in_frontier (orig : ChaseNodeOrigin obs rules.cast_withFreshConstantsForVars) : orig ∈ self.triggers → orig.fst.val.rule.existential_vars_for_head_disjunct ↑orig.snd ⋯ ≠ [] → ∃ (func : SkolemFS sig.withFreshConstantsForVars), ∃ (ts : List (GroundTerm sig.withFreshConstantsForVars)), ∃ (arity_ok : ts.length = func.arity), GroundTerm.func func ts arity_ok ∈ orig.fst.val.mapped_frontier
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.
Every trigger in the PreCyclicityPrefix.infiniteTriggerList is unblockable.
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.