Lesson 16
Lesson 16
Lesson 16
Inference in FOL - II
Version 2 CSE IIT, Kharagpur
[NOTE 3: One may decide, instead of resolving C on its ith literal with all possible element of OTHERS, to select one compatible element of OTHERS and to resolve C with it, putting this resolvent and C back into OPEN. We would call a rule for selecting an element of OTHERS a Search Rule.] Repeat from 2. In this proof procedure we have left indetermined:
The sets INITIAL and OTHERS of clauses The function SELECT by which we choose which node to expand The function NEXT-OPEN for computing the next value of OPEN The function NEXT-OTHERS for computing the next value of OTHERS
There is no guaranty that for any choice of INITIAL, OTHERS, SELECT, NEXT-OPEN and NEXT-OTHERS the resulting theorem prover will be "complete", i.e. that everything that is provable will be provable with this theorem prover.
Example
Suppose that we want to prove that 1. NOT P(x) OR NOT R(x) is inconsistent with the set of clauses: 2. NOT S(x) OR H(x) 3. NOT S(x) OR R(x) 4. S(b) 5. P(b) The following are possible selections for the indeterminates: INITIAL: {1.}, that is, it consists of the clauses representing the negation of the goal. OTHERS: {2. 3. 4. 5.}, that is, it consists of the non-logical axioms. SELECT: We use OPEN as a FIFO queue, i.e. we do breadth-first search. NEXT-OPEN: It sets NEXT-OPEN(OPEN, C, {D1, .., Dp}) to the union of OPEN, {C}, and {D1, .., Dp}. NEXT-OTHERS: It leaves OTHERS unchanged
The Proof Tree is then (we underline AND nodes and all their outgoing arcs are assumed to form a single hyperlink)
START | | NOT P(x) OR NOT R(x) /---------------\ / \ NOT P(x) OR NOT R(x) NOT P(x) OR NOT R(x) | | | | NOT R(B) NOT P(x) OR NOT S(x) | /----------- \ | / \ NOT S(B) NOT S(B) NOT P(B) | | | | | | {} {} {}
At an OR node we apply resolution between the current clause at its selected literal and all the compatible elements of OTHERS.
Example
The following example uses Horn clauses in propositional logic. I use the notation that is common in Prolog: we represent the implication: A1 AND A2 AND .. AND An IMPLIES A as A < = A1, A2, .. , An Our problem is: 1. 2. 3. 4. 5. 6. 7. 8. 9. A, This is what we want to prove A < = B, C A<=D B < = D, E B<=F C<= C < = D, F D<= F<=
We now partially represent the proof tree. We do not apply breadth first because we want to see how great is the impact of the choice of SELECT.
A / / / B, C /------\ \ \ \ D | | {}
You can keep on expanding the tree and see how depth first would generate a large tree while breadth first rapidly derives D from A, and {} from D. In other circumstances other strategies would be appropriate as we see below.
The OTHERS set of clauses is satisfiable. That is the case when we are given a satisfiable set of non-logical axioms and we use it as OTHERS.
INITIAL consists of the union of the negation of the "theorem" and of the set of non-logical axioms. OTHERS usually is the set of non-logical axioms. NEXT-OPEN(OPEN, C, {D1,..,Dp}) is the union of OPEN and {C}, that is, OPEN does not change in successive iterations NEXT-OTHERS(OTHERS, C, {D1,..,Dp}) is the union of OTHERS, {C}, and {D1,..,Dp}.
In other words, in each resolution one of the premises is one of the original clauses. In general Input Resolution is incomplete, as it can be seen with the following unsatisfiable set of clauses (from Nilsson) from which we are unable to derive FALSE using Input Resolution:
Q(u) OR P(A) NOT Q(w) OR P(w) NOT Q(x) OR NOT P(x) Q(y) OR NOT P(y)
[You can use this set of clauses as both OPEN and OTHERS.] Input resolution is complete in the case that all the clauses are Horn clauses.
6.2.10.5 SLD-Resolution
Selected Linear Resolution for Definite Clauses, or simply SLD-Resolution, is the basis for a proof procedure for theorems that are in the form of conjunctions of positive literals (this conjunction is called a Goal) given non-logical axioms that are definite clauses. More precisely:
A Goal is the conjunction of positive literals A Selection Rule is a method for selecting one of the literals of a goal (the first literal, or the last literal, etc.)
In SLD-Resolution, given a goal G = A1 .. An, a definite clause C: A < = B1 .. Bm, and a subgoal Ai selected from G using a Selection Rule S, where Ai and A are unifiable with MGU s, the Resolvent of G and C under S is
An SLD-Derivation of a goal G given a selection rule S and a set P of definite clauses, is a sequence of triples (Gi, Ci, si), for i from 0 to k, where o G0 is G o for each i > 0, Ci is obtained from a clause in P by replacement of all of its variables with new variables o Gi+1 is the SLD-Resolvent of Gi and Ci by use of S and with MGU si. A Refutation of a goal G given definite clauses P and selection rule S, is a finite SLD-derivation of G given S and P whose last goal is the null clause. If s1 .. sk are the MGUs used in the refutation, then s = si.s2....sk is a substitution that, restricted to the variables of G, makes G true whenever the clauses of P are true. The goal G succeeds for given selection rule S and set of definite clauses P if it has a refutation for P and S; otherwise it Fails.
Theorem: SLD-Resolution is Sound and Complete for conjunctive positive goals and definite clauses.
An important consequence of this theorem is that it remains true no matter the selection rule we use to select literals in goals. Thus we can select literals as we please, for instance left-to right. An other important aspect is that the substitution s = s1.s2...sn gives us a method for finding the individuals that satisfy the goal in the structures that satisfy the clauses in P. Nothing has been said in SLD-Resolution about what rule should be used to select the clause of P to resolve with the current literal of the current goal (such a rule is called a Search rule).
Example
Suppose that we are given the following clauses:
WOMAN(MOTHER(v)) ; Every mother is a woman GOOD(HUSBAND(ANN)) ; The husband of Ann is good GOOD(z) < = LIKES(MOTHER(z), z); if z likes his mother then z is good
we need to jump to conclusions in order to plan and, more basically, survive. o we cannot anticipate all possible outcomes of our plan. o we must make assumptions about things we do not specifically know about.
DO NOT get confused about the label Non-Monotonic and Default being applied to reasoning and a particular logic. Non-Monotonic reasoning is generic descriptions of a class of reasoning. Non-Monotonic logic is a specific theory. The same goes for Default reasoning and Default logic.
Non-Monotonic Logic
This is basically an extension of first-order predicate logic to include a modal operator, M. The purpose of this is to allow for consistency. For example: : plays_instrument(x) improvises(x) jazz_musician(x)
states that for all x is x plays an instrument and if the fact that x can improvise is consistent with all other knowledge then we can conclude that x is a jazz musician. How do we define consistency? One common solution (consistent with PROLOG notation) is to show that fact P is true attempt to prove is false). (since . If we fail we may say that P is consistent
However consider the famous set of assertions relating to President Nixon. : Republican(x) : Quaker(x) Pacifist(x) Pacifist(x) Pacifist(x)
Pacifist(x)
Now this states that Quakers tend to be pacifists and Republicans tend not to be. BUT Nixon was both a Quaker and a Republican so we could assert: Quaker(Nixon) Republican(Nixon) This now leads to our total knowledge becoming inconsistent.
Default Logic
Default logic introduces a new inference rule:
which states if A is deducible and it is consistent to assume B then conclude C. Now this is similar to Non-monotonic logic but there are some distinctions: Version 2 CSE IIT, Kharagpur
New inference rules are used for computing the set of plausible extensions. So in the Nixon example above Default logic can support both assertions since is does not say anything about how choose between them -- it will depend on the inference being made. In Default logic any nonmonotonic expressions are rules of inference rather than expressions
6.2.11.2 Circumscription
Circumscription is a rule of conjecture that allows you to jump to the conclusion that the objects you can show that posses a certain property, p, are in fact all the objects that posses that property. Circumscription can also cope with default reasoning. Suppose we know: bird(tweety) : penguin(x) : penguin(x) bird(x) flies(x)
and we wish to add the fact that typically, birds fly. In circumscription this phrase would be stated as: A bird will fly if it is not abnormal and can thus be represented by: : bird(x) abnormal(x) flies(x).
However, this is not sufficient We cannot conclude flies(tweety) since we cannot prove abnormal(tweety). This is where we apply circumscription and, in this case, we will assume that those things that are shown to be abnormal are the only things to be abnormal Version 2 CSE IIT, Kharagpur
Thus we can rewrite our default rule as: : bird(x) flies(x) abnormal(x)
and add the following : abnormal(x) since there is nothing that cannot be shown to be abnormal. If we now add the fact: penguin(tweety) Clearly we can prove abnormal(tweety). If we circumscribe abnormal now we would add the sentence, a penguin (tweety) is the abnormal thing: : abnormal(x) penguin(x).
Note the distinction between Default logic and circumscription: Defaults are sentences in language itself not additional inference rules.
all do some form of dependency directed backtracking assertions are connected via a network of dependencies.
This is a simple TMS in that it does not know anything about the structure of the assertions themselves. Each supported belief (assertion) in has a justification. Each justification has two parts: Version 2 CSE IIT, Kharagpur
o o
An IN-List -- which supports beliefs held. An OUT-List -- which supports beliefs not held.
An assertion is connected to its justification by an arrow. One assertion can feed another justification thus creating the network. Assertions may be labelled with a belief status. An assertion is valid if every assertion in the IN-List is believed and none in the OUT-List are believed. An assertion is non-monotonic is the OUT-List is not empty or if any assertion in the IN-List is non-monotonic.
Nodes (assertions) assume no relationships among them except ones explicitly stated in justifications. JTMS can represent P and P simultaneously. An LTMS would throw a contradiction here. If this happens network has to be reconstructed.
JTMS and LTMS pursue a single line of reasoning at a time and backtrack (dependency-directed) when needed -- depth first search. ATMS maintain alternative paths in parallel -- breadth-first search Backtracking is avoided at the expense of maintaining multiple contexts. However as reasoning proceeds contradictions arise and the ATMS can be pruned o Simply find assertion with no valid justification.
Questions
1.a. Consider a first-order logical system which uses two 1-place predicates namely, Big and Small. The set of object constants is given by {A, B}. Enumerate all possible models in this case.
1.b. For each of the following sentences, identify the models in which the given sentence is true. a. Big(A) Big(B) b. Big(A) Big(B) c. x Big(x) d. x Big(x) e. x Big(x) f. x Big(x) g. x Big(x) Small(x) h. x Big(x) Small(x) i. x Big(x) Small(x) 1.c Determine whether the expressions p and q unify with each other in each of the following cases. If so, give the most general unifier; If not, give a brief explanation (Assume that the upper case letters are (object, predicate, or function) constants and that the lower case letters are variables). a. p = F(G(v), H(u, v)); q = F(w, J(x, y)) b. p = F(x, F(u, x)); q = F(F(y, A), F(z, F(B, z))) c. p = F(x1, G(x2, x3), x2, B); q = F(G(H(A, x5), x2), x1, H(A, x4), x4) 1.d. Put the following FOL formulas into conjunctive form (CNF): a. b. x x y ((P(x) Q(y)) z R(x ,y ,z)) y z (P(x) (Q(y) R(z)))
2. Convert the following English statements to statements in first order logic a. b. c. d. e. every boy or girl is a child every child gets a doll or a train or a lump of coal no boy gets any doll no child who is good gets any lump of coal Jack is a boy
3. Using the above five axioms construct a proof by refutation by resolution of the statement
if Jack doesn't get a train, then Jack is not a good boy 4. Consider the following set of axioms i. Everyone who loves someone who loves them back is happy ii. Mary loves everyone. iii. There is someone who loves Mary. From the above statements conclude that: Mary is happy.
Solution
1.a. Possible models are:
1.b Answers:
1.c. Answers:
1.d Answers
2. The FOL statements are a. b. c. d. e. forall x ((boy(x) or girl(x)) -> child(x)) forall y (child(y) -> (gets(y,doll) or gets(y,train) or gets(y,coal))) forall w (boy(w) -> !gets(w,doll)) forall z ((child(z) and good(z)) -> !gets(z,coal)) boy(Jack)
3. The statement to be proved can be written in FOL as: !gets(Jack,train) -> !good(Jack) The proof consists of three steps: Negate the conclusion. Translate all statements to clausal form. Apply resolution to the clauses until you obtain the empty clause
Transform axioms into clause form: 1. forall x ((boy(x) or girl(x)) -> child(x)) !(boy(x) or girl(x)) or child(x) (!boy(x) and !girl(x)) or child(x) (!boy(x) or child(x)) and (!girl(x) or child(x)) 2. forall y (child(y) -> (gets(y,doll) or gets(y,train) or gets(y,coal))) !child(y) or gets(y,doll) or gets(y,train) or gets(y,coal) 3. forall w (boy(w) -> !gets(w,doll)) !boy(w) or !gets(w,doll) 4. forall z ((child(z) and good(z)) -> !gets(z,coal)) !(child(z) and good(z)) or !gets(z,coal) !child(z) or !good(z) or !gets(z,coal) 5. boy(Jack) 6. !(!gets(Jack,train) -> !good(Jack)) negated conclusion !(gets(Jack,train) or !good(Jack)) !gets(Jack,train) and good(Jack) The set of CNF clauses: 1. (a) !boy(x) or child(x) (b) !girl(x) or child(x) 2. !child(y) or gets(y,doll) or gets(y,train) or gets(y,coal) 3. !boy(w) or !gets(w,doll) 4. !child(z) or !good(z) or !gets(z,coal) 5. boy(Jack) Version 2 CSE IIT, Kharagpur
6. (a) !gets(Jack,train) (b) good(Jack) Resolution: o 4. !child(z) or !good(z) or !gets(z,coal) 6.(b). good(Jack) ------------------------------------------------------7. !child(Jack) or !gets(Jack,coal) (substituting z by Jack) o 1.(a). !boy(x) or child(x) 5. boy(Jack) ------------------------------------------------------8. child(Jack) (substituting x by Jack) o 7. !child(Jack) or !gets(Jack,coal) 8. child(Jack) ------------------------------------------------------9. !gets(Jack,coal) o 2. !child(y) or gets(y,doll) or gets(y,train) or gets(y,coal) 8. child(Jack) ------------------------------------------------------10. gets(Jack,doll) or gets(Jack,train) or gets(Jack,coal) (substituting y by Jack) o 9. !gets(Jack,coal) 10. gets(Jack,doll) or gets(Jack,train) or gets(Jack,coal) ------------------------------------------------------11. gets(Jack,doll) or gets(Jack,train) o 3. !boy(w) or !gets(w,doll) 5. boy(Jack) ------------------------------------------------------12. !gets(Jack,doll) (substituting w by Jack) o 11. gets(Jack,doll) or gets(Jack,train) 12. !gets(Jack,doll) ------------------------------------------------------13. gets(Jack,train) o 6.(a). !gets(Jack,train) 13. gets(Jack,train) ------------------------------------------------------14. empty clause
A1: for-all x, for-all y, [loves(x,y) & loves(y,x) = > happy(x)] A2: for-all z, [loves(mary,z)] A3: there-is w, [loves(w,mary)] Version 2 CSE IIT, Kharagpur
Translate the axioms and the negation of the conclusion into clausal form. Show each step of the translation (remember that the order in which you apply the steps is crucial). 1. A1: !loves(x,y) || !loves(y,x) || happy(x) note that p = > q is equivalent to !p || q and that !(r & s) is equivalent to !r || !s 2. A2: loves(mary,z) 3. A3: loves(a,mary), where a is a new constant symbol 4. !C: ! happy(mary)
Apply resolution (state explicitly what clauses are resolved and which substitutions are made) until the empty clause is found.
!C: ! happy(mary) A1: !loves(x,y) || !loves(y,x) || happy(x) __________________________________________________ with x=mary A4: !loves(mary,y) || !loves(y,mary) A2: loves(mary,z) __________________________________________________ with z=y A5: !loves(y,mary) A3: loves(a,mary) __________________________________________________ with y=a empty clause
Since assuming that "mary is not happy" yields a contradiction in the presence of A1, A2, A3, then the statement "mary is happy" is a logical consequence of A1, A2, and A3.