Upload
willem-van-onsem
View
217
Download
0
Embed Size (px)
Citation preview
7/28/2019 Computational Logic: definitions and Theorems [Work in Progress]
http://slidepdf.com/reader/full/computational-logic-definitions-and-theorems-work-in-progress 1/8
Computational Logic:
Definitions and Theorems
Willem Van Onsem
June 2013
Contents
1 Definite Programs 1
1.1 First order Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Logic Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Semantics of First Order Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4 Substitutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.5 Unifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 SLD-proof procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.7 Semantics of SLD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.7.1 Soundness of SLD-resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.7.2 Herbrand Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.7.3 Fixpoint Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.7.4 Completeness of SLD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.8 Constraint Logic Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 General Programs 7
3 Termination 7
4 Specialization 7
5 Abstraction 7
1 Definite Programs
1.1 First order Languages
Definition 1 (First Order Language). A First Order Language is a language containing both language dependent and independent parts. The language independent parts consist out of Variables ( x, y, L, ...), Propositional constants (true and false), punctuation symbols (“(”, “)” and “,”) and Connectives ( ¬, ∧, ∨, ← and →). The language dependent parts consists out of Constants ( a, b, ...), Functional symbols or Functors ( f , g, ...), Predicate symbols ( p, q , ...),Terms (a composition of variables, constants and functors) and Formulas (atoms and compositions of atoms).
1.2 Logic Programs
Definition 2 (Literal). A Literal is a predicate with the appropriate number of terms.
Definition 3 (Positive literal). A Positive literal is a Literal with no negation before the Predicate.
Definition 4 (Negative literal). A Negative literal is a Literal with a negation before the Predicate.
Definition 5 (Clause). A Clause is a Disjunction of Literals. One implicitly defines Universal quantification over all Variables.
Definition 6 (Theory). A Theory is a Conjunction of Clauses.
Definition 7 (Logic Program). A Logic Program is a theory proposed in the Clausal form notated as head ← body.The Head is a Disjunction of Atoms and the Body a Conjunction of Atoms.
7/28/2019 Computational Logic: definitions and Theorems [Work in Progress]
http://slidepdf.com/reader/full/computational-logic-definitions-and-theorems-work-in-progress 2/8
Definition 8 (Definite clause). A Definite clause is a Clause with one Literal in the Head.
Definition 9 (Definite goal). A Definite goal is a Clause with no Literal in the Head.
Definition 10 (Normal clause). A Normal clause is an extension on a Definite clause where negative literals are allowed in the Body.
Definition 11 (Disjunctive clause). A Disjunctive clause is an extension on a Normal clause where Disjunctions are allowed in the Head.
Definition 12 (Fact). A Fact is a Clause with an empty Body.
Definition 13 (Unit clause). A Unit clause is a Clause with only one literal.
1.3 Semantics of First Order Logic
Definition 14 (Interpretation). An Interpretation is a mapping between Symbols and Meaning. This means Terms are mapped to Objects and Atoms to Truth. It specifies a Domain of objects together with functions and relations over this domain. More formally an Interpretation of a Theory L has a Pre-interpretation: a non-empty DomainD, for each Constant c in L an assignment cI ∈ D and for each n-ary Functor an assignment f I : Dn → D. An interpretation proposes a n-ary relation 1 over Dn for each n-ary Predicate p/n.
Definition 15 (Truth). The truth of an Atom p (t1, . . . , tn) is true if V (t1) , . . . , V (tn) is in the relation pI . This is notated as I V p (t1, . . . , tn). The Truth of a compound formula is defined as follows:
• I V ¬F if and only if ¬ (I V F )
• I V F ∨ G if and only if (I V F ) ∨ (I V G)
• I V ∀x : F if and only if I V [x/d] F for all x ∈ D.
Other forms can be reduced by logical rewrite rules.
Definition 16 (Empty formula). A Empty formula is a Clause with an empty Head and Body. The Empty formulais always false. The Empty formula is sometimes notated as .
Definition 17 (True formula). A True formula F is true in Interpretation if and only if F is true for all Variableassignments V .
Definition 18 (Program). A Program is a set of Formulas.
Definition 19 (Model). A Model is an Interpretation I for a Program P where I F for all F ∈ S .
Definition 20 (Satisfiable program). A program S is consistent if and only if S has a Model.
Definition 21 (Unsatisfiable program). A program S is inconsistent if and only if S has no Models.
Definition 22 (Valid program). A program S is valid if and only if S has only Models.
1.4 Substitutions
Definition 23 (Substitution). A Substitution is a function mapping Expressions to Expressions by replacing Variables by Terms. Substitutions are represented in the following form: θ = {x1/t1, . . . , xn/tn} where xi is a Variable and ti a
Term. When one applies a Substitution to an expression all occurrences of the Variables are replaced simultaneously.This is notated as Eθ.
Definition 24 (Renaming substitution). A Renaming substitution is a form of Substitution where one changes the names of the variables in a reversible way. The motivation of such substitutions is that names are often irrelevant.Different formalizations are possible including Apt renaming substitution and Lloyd renaming substitution.
Definition 25 (Apt renaming substitution). The Apt renaming substitution is a Renaming substitution where one maps Variables to a permutation of these Variables. For example: θ = {y/y,z/z, y/y,z/z}.
Definition 26 (Variant). We call E a Variant of E if E = θE with θ a Variant.
Lemma 1 (Apt renaming substitution lemma). If E is a Variant of F , E is an Instance of F and F an Instance of E .
1With n = 0, there are two relations, the empty relation and the relation with the empty tuple.
7/28/2019 Computational Logic: definitions and Theorems [Work in Progress]
http://slidepdf.com/reader/full/computational-logic-definitions-and-theorems-work-in-progress 3/8
Definition 27 (Lloyd renaming substitution). The Lloyd renaming substitution states that two expressions E and F are Variants if they are Instances of each other. Therefore a renaming substitution is of the form θ = {x1/y1, . . . , xn/yn}where xi ∈ Var (E ) and yi /∈ Var (E ) \ {x1, . . . , xn} where yi = yj for all i¬ j.
Lemma 2 (Lloyd renaming substitution lemma). If E and F are Variants, then a Lloyd renaming substitution exists.
Definition 28 (Substitution composition). Given two Substitutions θ = {x1/t1, . . . , xn/tn} and σ = {y1/s1, . . . , ym/sm},then the composition θσ = {x1/t1σ , . . . , xn/tnσ, y1/s1, ym/sm} \ ({xi/tiσ|xi = tiσ} ∪ {yi/si|yi ∈ {x1, . . . , xn}}).
Lemma 3 (Substitution composition associativity). For each three Substitutions θ,σ,γ and an Expression E , it holds that (Eθ) σ = E (θσ) and (θσ) γ = θ (σγ ).
Definition 29 (More general substitution). A Substitution θ is more general than a Substitution σ if ∃γ : σ = θγ .One can define such relation between equivalence classes of terms. This relation is Reflexive and Transitive. The Variant relation is Transitive, Reflexive and Symmetric, therefore it is an Equivalence relation. Another solution is to use a reference domain V where θ ≥V σ if and only if ∃γ : θγ |V = σ|V .
1.5 Unifiers
Definition 30 (Unifier). θ is a Unifier of A and B if and only if Aθ = Bθ.
Definition 31 (Most general unifier). The Most general unifier is an Unifier more general than any other. Algorithm than can calculate the Most general unifier are Robinson’s algorithm, Paterson and Wegman’s algorithm and the
Martelli-Montanari algorithm.
Definition 32 (Robinson’s algorithm). Robinson’s algorithm is an algorithm that computes the Most general unifiergiven two expressions. The algorithm uses a Disagreement set containing the first pair of sub-terms in the expression which are still different. The algorithm adds this to the unifier and substitutes one of the expressions by this mapping.Algorithm ?? lists the entire algorithm. The algorithm can be quite expensive since substitutions can blow up the expressions.
Definition 33 (Paterson and Wegman’s algorithm). The Paterson and Wegman’s algorithm is an algorithm that computes the Most general unifier. The algorithm works with tree structures of the expressions where differences are propagated downwards in the trees. Algorithm ?? lists the entire algorithm. The algorithm works linear in the input size. Potential optimizations to the algorithm are the fact that each class should only propagate once and thus one always selects the Root class for propagation: a class such that the classes of parent nodes have been propagated.
Definition 34 (Martelli-Montanari algorithm). The Martelli-Montanari algorithm is an algorithm that computes the Most general unifier. It manipulates a set of expressions until the set has a trivial Most General Unifier. Basically their are four operations: remove, peel, switch and substitute. The termination can be proven by counting the number of elements in the set.
Definition 35 (Relevant unifier). A Unifier of terms A and B is relevant if and only if it contains only Variables from A and B.
Lemma 4 (Idempotent substitution). For each Substitution θ = {x1/t1, . . . , xn/tn}, θθ = θ if and only if for all i, j : xi /∈ Var (tj).
Lemma 5 (Unification algorithm). Unification algorithms produce always an Most General Unifier who is idempotent and relevant.
Lemma 6 (Substitution variable elimination). An Idempotent substitution eliminates all the variables from the domain of the substitution.
1.6 SLD-proof procedure
Definition 36 (SLD). SLD SLD is an abbreviation of Selection Rule, Linear and Definite program. It is a collection of procedures to derive a linear resolution for Definite programs using a Selection rule.
Definition 37 (SLD-resolution). SLD-resolution is a procedure were given a Definite program P and a Definitegoal N =← A1, . . . , An and a clause C = A ← B1, . . . , Bk ∈ P , one replaces the initial goal with N =←(A1, . . . , Ai−1, B1, . . . , Bk, Ai+1, . . . , An) θ with θ = mgu (A, Ai). The procedure consists out of four steps:
1. Select Ai
2. Unify A and Ai
7/28/2019 Computational Logic: definitions and Theorems [Work in Progress]
http://slidepdf.com/reader/full/computational-logic-definitions-and-theorems-work-in-progress 4/8
3. If successful, then replace Ai by B1, . . . , Bk
4. Apply θ on the resolvent
The SLD-resolution is a sound inference rule.
Definition 38 (SLD-derivation). SLD-derivation is a process where one repeats the SLD-proof procedure until no further rule can be derived. The procedure works with the following variables:
1. C i: a standardized apart Variant of a Clause in P where the variables have not been used in the derivation so
far.
2. N i+1 the Resolvent of N i and C i
3. θi the Most general unifier obtained from unifying the Head of C i and the selected Atom in N i.
. The process ends with SLD-refutation if a finite SLD-derivation ends with . Otherwise when a finite SLD-derivation does not result in a refutation but the last goal is not empty (but one cannot derive any rules anymore) the answer is SLD-failure. When SLD-refutation is derived P ∧ N is an Inconsistent theory (assuming P us consistent. Therefore ¬N is true in every model of P : P ¬N ). The Composition of θ0θ1 . . . θl gives bindings for the variables of the goal such that N θ0 . . . θl is a Valid theory. This composition is also called the Computed answer substitution. In order tocompute such answer, we restrict the substitutions to variables of the initial goal.
Definition 39 (Computation rule). A Computation rule is a mechanism that selects the derivation rule C i given the
current goal N k and the history of the previous selections.Lemma 7 (Disjunction of SLD-derivations). For all n > m, Var (N n) ∩ Dom (θm) = ∅ and Var (N nθn) ∩ Dom (θ) = ∅.This can be proven by induction using the fact that the substitutions are idempotent and relevant.
Lemma 8 (Variant lemma). Consider a partial SLD-derivation N 0, . . . , N i and consider a second derivation N 0, . . . , N iwith N 0 a Variant of N 0. With each step: the derivation selects the atom at the same position as the first and C i is a variant of C i, then N i is a Variant of N i more the resultants at level i are also variants.
Corollary 1. Consider an SLD-derivation N 0 . . . with Computed answer substitution θ and a second derivation starting from N 0 as well. If the second methods selects the atoms at the same positions but uses other Variants of the Clauses C i, and which has Computed answer set σ, then N 0θ and N 0σ are Variants. This however does not mean that θ and σ are Variants in general.
1.7 Semantics of SLD
1.7.1 Soundness of SLD-resolution
Lemma 9 (Soundness of the SLD-resolution step). Given a goal N =← A =← A1, . . . An and a clause C = A ←B1, . . . , Bk. Then the resolvent R =← B =← A1θ, Ai−1θ, B1θ , . . . , Bkθ, Ai+1θ , . . . , Anθ with θ = mgu (Ai, A), then C B → Aθ.
Proof. We will show that I (B → Aθ) is true for every interpretation I for which I (C ) is true. We consider two cases:
• If I (B ) is false, then I (B → Aθ) is clearly true (definition of Implication ).
• If I (B ) is true and I (A1θ , . . . , Ai−1θ, Ai+1θ , . . . , Anθ) is true. Since I is a model of C then I (Aθ) is true, butAθ = Aiθ, so I (Aiθ) is true. Thus I (A1θ , . . . , Anθ)=I (Aθ) is true. Thus I (B → Aθ) is true.
Lemma 10 (Soundness of SLD-resolution). Given a program P and a goal N =← A =← A1, . . . , An, then there exists an SLD-refutation of P ∪ {← A} with Substitutions θ0, . . . , θm−1 (the Computed answer set), then P (A1 ∧ . . . ∧ An) θ0 . . . θm−1.
Proof. We define the refutation as ← A0 =← A and therefore ← A1, . . . , ← Am = =← true. Since we can applyLemma 9 we can state that P Ai → Ai−1θi−1. By applying the Modus Ponens we can state that P Ai →A0A0θ0 . . . θm−1. Since A0 = (A1 ∧ . . . ∧ An) θ0 . . . θm−1, we can state that P (A1 ∧ . . . ∧ An) θ0 . . . θm−1
Corollary 2. If there exists an SLD-refutation of P ∪ {← A}, then P ∪ {← A} is inconsistent.
Proof. According to Lemma 10, P Aθ0 . . . θm−1, thus P ∃xA. Therefore P ∪ {¬∃xA} is inconsistent and P ∪
{∀x¬A} as well. Thus P ∪ {∀x (← A)} is inconsistent and therefore P ∪ {← A}.
7/28/2019 Computational Logic: definitions and Theorems [Work in Progress]
http://slidepdf.com/reader/full/computational-logic-definitions-and-theorems-work-in-progress 5/8
1.7.2 Herbrand Models
Definition 40 (Herbrand universe). The Herbrand universe U L of a Language L (with at least one constant) is the set of all ground terms.
Definition 41 (Herbrand interpretation). The Herbrand interpretation is an Interpretation with a fixed Pre-interpretation:the domain is the Herbrand Universe and constants c are preinterpreted as J (c) = c as well as functions: J (f (t1, . . . , tn)) =f (J (t1) , . . . , J (tn)). Variable assignments happens by mapping the variables to the ground terms U L. Term assign-ment maps the term to the ground term of U L. Predicates are interpreted as a set of ground tuples in U nL thus
p (t1, . . . , tn) is true under variable assignment V if V (t1) , . . . , V (tn) belongs to I ( p/n).Definition 42 (Herbrand base). A Herbrand base BL is the set of all ground atoms in the Language L. Therefore a Herbrand interpretation is a subset of the Herbrand base.
Definition 43 (Herbrand model). A Herbrand model is a Herbrand interpretation which is a Model.
Lemma 11. Completeness of the Herbrand modelGiven S is a set of universal formulas, thus of the form ∀x : F ,with F quantifier free. If S has a Model, it has a Herbrand model. Therefore for proving validity or inconsistency of a set of clauses, it suffices to check Herbrand interpretations. The lemma however does not hold for all formula’s: for instance existential formulas with negations need to introduce Skolem constants.
Proof. Given an interpretation I , constructs I H as follows:
I H = { p (t1, . . . , tn) |ground( p (t1, . . . , tn)) ∧ pI (I (t1) , . . . , I (tn))} (1)
For every formula, one can show, by induction over the structure, if I F , then I H F .
Lemma 12 (Herbrand model intersection property). The intersection of Herbrand models is a Herbrand model.Therefore there exists a least model: the subset of all others and what is true in the least model is true in all models.One can construct the minimal model with the Immediate consequence operator T P .
1.7.3 Fixpoint Semantics
Definition 44 (Immediate consequence operator). The Immediate consequence operator T P is an operator which transforms given a herbrand interpretation with ground atoms and clauses from the ground atoms P this set in a new set of ground atoms. More formally A ∈ T P (I ) if and only if A ← B1, . . . , Bn is a ground instance of a clause in P and {B1, . . . , Bn} ⊆ I .
Lemma 13 (Monotonicity of the immediate consequence operator). T P is monotonic: ∀I , J , P : I ⊆ J → T P (I ) ⊆T (J ).
Lemma 14 (Continuity of the immediate consequence operator). For an infinite sequence I 0 ⊆ I 1 ⊆ . . ., T P (∪∞i=0I i) =∪∞i=0T P (I i)
Lemma 15 (Immediate consequence operator model). I H is a model of P if and only if T P (I H ) ⊆ I H with I H a pre-fixpoint of T P .
Proof. Consider all ground clauses A ← B .
⇒ Assume I H is a model, thus: A ∈ T P (I H ) if B ⊆ I H . Since I H is a model, also A ∈ I H hence T P (I H ) ⊆ I H .
⇐ Assume T P (I H ), then B implies A ∈ T P (I H ) and by assumption A ∈ I H , hence I H is a model of the clause.
Lemma 16 (Powerset of the Herbrand base is a complete lattice). The set of all subsets of the Herbrand base BP is a Complete lattice under the partial order ⊆ with Least upper bound lub (I, J ) = I ∪ J and the Greatest lower boundglb (I, J ) = I ∩ J .
Lemma 17 (Upwards continuity of a complete lattice). Consider x0 ≤ x1 ≤ . . ., then T P (lub (x0, x1, . . .)) =lub (T P (x0) , T P (x1) , . . .).
Lemma 18 (Downwards continuity of a complete lattice). Consider x0 ≥ x1 ≥ . . ., then T P (glb (x0, x1, . . .)) =glb (T P (x0) , T P (x1) , . . .).
Definition 45 (Fixpoint). I is a Fixpoint of T if T (I ) = I .
Definition 46 (Pre-fixpoint). I is a Pre-fixpoint of T if T (I ) ⊆ I .
7/28/2019 Computational Logic: definitions and Theorems [Work in Progress]
http://slidepdf.com/reader/full/computational-logic-definitions-and-theorems-work-in-progress 6/8
Definition 47 (Post-fixpoint). I is a Post-fixpoint of T if T (I ) ⊇ I .
Lemma 19 (Fixpoint theorem from Knaster and Tarski). A Monotonic operator T over a Complete lattice has a Least fixpoint lfp (T ) which is also the Least pre-fixpoint and the Greatest fixpoint gfp (T ) which is also the Greatestpost-fixpoint.
Definition 48 (Upwards powers of monotonic operators). We define the n-th upward power of T with respect to I recursively as follows:
T ↑ 0 (I ) = I
T ↑ (n + 1) (I ) = T (T ↑ n (I ))T ↑ ω (I ) = ∪n<ωT ↑ n (I ) (2)
With ω the First infinite ordinal: the limit of 0, 1, . . .. In this document we will abbreviate T P ↑ n = T P ↑ n (∅).
Definition 49 (Downwards powers of monotonic operators). We define the n-th downward power of T with respect to I recursively as follows:
T ↓ 0 (I ) = I T ↓ (n + 1) (I ) = T (T ↓ n (I ))T ↓ ω (I ) = ∩n<ωT ↓ n (I )
(3)
With ω the First infinite ordinal: the limit of 0, 1, . . .. In this document we will abbreviate T P ↓ n = T P ↓ n (BP ).
Lemma 20 (Kleene fixed point). If T is Upwards continuous then T P ↑ ω is the Least fixpoint and the Least pre-fixpoint of T P . If T is Downwards continuous then T P ↓ ω is the Greatest fixpoint and Greatest post-fixpoint. T P is
not Downwards continuous.
Lemma 21 (Characterization theorem Van Emden-Kowalski). A Definite program P has Herbrand model M P which satisfies:
• M P is the Least Herbrand model of P .
• M P is the Least pre-fixpoint of T P .
• M P is the Least fixpoint of T P .
• M P = T P ↑ ω.
.
1.7.4 Completeness of SLD
Definition 50 (Success set). The Success set of P is the set of all Ground atoms A such that P ∪ {← A} has an SLD-refutation.
Corollary 3. The Success set is contained in M P .
Proof. SLD is sound so P A, so every model of P is a model of A, so also M P is, and I H (A) so A ∈ M P .
Lemma 22 (Lifting lemma). If there exists a refutation of P ∪ {← Aθ}, then also for P ∪ {← A}.
Lemma 23 (Completeness results for SDL). The Success set of a program is equal to M P .
Lemma 24 (SLD-refutation for an inconsistent set). If P ∪ {← A} is inconsistent then an SLD-refutation starting
from ← A exists.Proof. The set is inconsistent if false ← A is false in the minimal model M P . Since there exists a Variable assignment θ, ← Aθ is false in M P as well and Aθ = (. . . , Ai, . . .) θ is true in M P . Aiθ ∈ M P is ground, so a refutation of Ai
exists. By using the Lifting lemma , there exists a refutation for ← A.
Lemma 25 (Genaral refutation). If P Aτ then there exists an SLD-refutation of ← A with Computed answer setσ such that Aσ is more general than Aσ is more general than Aτ . This does not mean that σ is more general than τ .
Lemma 26 (Independence of the computation rule). If P ∪ {← A} is inconsistent, then in every SLD-tree for P ∪ {← A}, there exists a refutation of P ∪ {← A}. The selection of the literal in a resolution step does not matter.But one selection can cause infinite brances, another keeps the tree finite.
Lemma 27 (Switching lema). If steps are reordered, the resolvent obtained after the reordered steps is identical up torenaming. In other words you can completely reshuffle a derivation.
7/28/2019 Computational Logic: definitions and Theorems [Work in Progress]
http://slidepdf.com/reader/full/computational-logic-definitions-and-theorems-work-in-progress 7/8
1.8 Constraint Logic Programming
Definition 51 (Resolution step in constraint logic programming). Constraint logic programming works with a set of equations E i which is initially empty. In a resolution step, one selects an Atom Aj and a clause A ← B1, . . . , Bk where pred (A) = pred (Aj). If E i+1 = E i∪{A = Aj} is solvable. Then one derives the resolvent A1, . . . , Aj−1, B1, . . . , Bk, Aj+1, . . .
2 General Programs
3 Termination
4 Specialization
5 Abstraction