(Disjunctive) (Existential) Rule #
A disjunctive existential rule, or simply Rule, formally is an expression of the form
$$∀ \vec{x}, \vec{y}. B(x, y) \to \bigvee_{i = 1}^{k} \exists \vec{z}_i. H_i(y_i, z_i)$$
where $B,H_1,\dots,H_k$ are conjunctions of function free atoms, $y$ is exactly the union of all $y_i$
and $x$, $y$, and all $z_i$ are disjoint lists of variables. $y$ is called frontier. $B$ is called body and the $H_i$ are called heads.
We call a rule determinstic if $k = 1$ so if the head is merely a conjunction.
For an overview on such rules (without disjunction) consider for example [BLMS11].
To represent this formal definition in Lean, we use a structure with a FunctionFreeConjunction for the body and a list of FunctionFreeConjunctions for the disjunction in the head. That's it!
The frontier variables can simply be defined as the variables occurring both in body and head and the existential variables can be indentified as the variables that occur only in the head, without the need for explicit quantification.
The definition of a Rule as discussed above.
- body : FunctionFreeConjunction sig
- head : List (FunctionFreeConjunction sig)
Instances For
Equations
Instances For
This function returns the frontier variables that occur in a given head disjunct. This is a sublist of all the frontier variables.
Equations
Instances For
This returns all the frontier variables of the rule, i.e. the variables that occur in both body and some head.
Equations
Instances For
The pure_body_vars are the variables from the body that are not in the frontier.
Equations
- r.pure_body_vars = List.filter (fun (x : sig.V) => decide ¬x ∈ r.frontier) r.body.vars
Instances For
We call a rule isDatalog if it does not contain existential variables, i.e. if all head variables occur in the body.
Equations
Instances For
We call a rule isDeterministic if it has exactly one head disjunct.
Instances For
The predicate symbols of a rule are just the predicate symbols from the body and all heads.
Equations
Instances For
The constants of a rule are just the constants from the body and all heads.
Equations
- r.constants = r.body.consts ++ List.flatMap (fun (conj : FunctionFreeConjunction sig) => conj.consts) r.head
Instances For
Sometimes we require only the constants from the heads and therefore we define them here.
Equations
- r.head_constants = List.flatMap (fun (conj : FunctionFreeConjunction sig) => conj.consts) r.head
Instances For
The existential variables for a given head are simply the variables from the head that are not in the frontier.
Equations
Instances For
A variable is a frontier variable if and only if it is a frontier variable in some head disjunct.
A variable is in the frontier of a head if it is in the frontier of the rule and occurs as a term in the given head.
All frontier variables occur in the body.
The frontier variables in a given head occur in the list of variables for the same head.
The head constants of the rule are also constants of the whole rule.
Each existential variable is in the head.
Each existential variable is not in the frontier.
A variable that is in a head but not existential must be in the frontier.
A variable that is in a head but not in the frontier must be existential.