Backchaining procedure for Horn clauses, and toy Prolog implementation.
Function or value | Description | ||||
Full Usage:
backchain rules n k env goals
Parameters:
(formula<fol> list * formula<fol>) list
-
The list of input rules.
n : int
-
The maximum number of rule applications permitted.
k : int
-
The counter for variables renaming.
env : func<string, term>
-
An environment of mappings (represented as a finite partial function) from variables to terms, used as an accumulator for the final result of the unification procedure. .
goals : formula<fol> list
-
The input goals.
Returns: func<string, term>
The current instantiation env , if the list of goals is
empty; otherwise, recursively searches through the rules one
whose consequent can be unified with the current goal and such that the
new subgoals together with the original ones can be solved under that
instantiation.
|
Example
Evaluates to [("_0", ``x``); ("_1", ``S(x)``); ("_2", ``_1``); ("x", ``0``)] .
|
||||
|
|||||
|
Note
Prints to the Example
val inst: obj
val level: obj
Evaluates to ([("_0", ``c_x``); ("_1", ``_0``); ("_2", ``_0``); ("_3", ``_2``)], 8) .
Example
Throws System.Exception: non-Horn clause .
|
||||
Full Usage:
renamerule k (asm, c)
Parameters:
int
-
The counter for variables renaming.
asm : formula<fol> list
-
The assumptions of the input rule.
c : formula<fol>
-
The conclusion of the input rule.
Returns: (formula<fol> list * formula<fol>) * int
The input rule with the variables renamed schematically starting with
_k
|
Example
Evaluates to (([`P(_0)`; `Q(_1)`], `P(f(_0))`), 2) .
|
Function or value | Description | ||
|
Example
Evaluates to ([`X <= Y`], `S(X) <= S(Y)`) .
Example
Throws System.Exception: Extra material after rule .
|
||
|
Example
val lerules: string list
Evaluates to [`x = 0`] .
Example
Throws System.Exception: tryfind .
|
||
|
Example
val lerules: string list
Evaluates to [("_0", ``S(0)``); ("_1", ``S(S(0))``); ("_2", ``0``); ("_3", ``S(0)``); ("_4", ``_3``)] .
Example
Throws System.Exception: tryfind .
|