Presentation is loading. Please wait.

Presentation is loading. Please wait.

Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.

Similar presentations


Presentation on theme: "Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and."— Presentation transcript:

1 Inference and Reasoning

2 Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and it has feathers- we can conclude that it is a bird since this logically follows from our premises.

3 We have already seen this In expert systems we had backward and forward chaining. Based on our set of rules we concluded that something held based on the chain of rules that followed from our initial facts.

4 In logic There are two main kinds of inference 1: Term rewriting 2: Resolution. Both start with an initial set of statements and try to show that the hypothesis or new statement is consistent with the existing set.

5 Consistency Recall our definitions of satisfaction

6 Satisfaction A predicate calculus expressions S1 is satisfied. Definition If there exists an Interpretation I and a variable assignment under I which returns a value T for S1 then S1 is said to be satisfied under I. A set of predicate calculus expressions S is satisfied. Definition For any interpretation I and variable assignment where a value T is returned for every element in S the the set S is said to be satisfied,

7 Consistency Given a set of statements S and a new statement S1 Then for any interpretation I and variable assignment where set S is satisfied, if S1 is also assigned T under I and the same variable assignment then S1 is said to be consistent with S under this interpretation and variable assignment.

8 Term Rewriting In logic there are many valid statements that is statements that are true under any Interpretation and variable assignment Sometimes these are called tautologies Many are based around equivalences For example the law of the double negative   (A) = A These truths are sometimes called the laws of logic

9 Examples of these Laws of logic Modus Ponens A  B ==  A  B,  De Morgans Laws  (A  B) ==  A   B  (A  B) ==  A   B Or Reduction A  T = T, A  F = A,A   A = T

10 More Examples of these Laws of logic And Reduction A  T = A, A  F = F,A   A = F Commutativity A  B == B  A A  B == B  A Distribution A  (B  C) = (A  B)  (A  C) A  (B  C) = (A  B)  (A  C)

11 Laws around Quantifiers  x  y is the same as  y  x  x  y is the same as  y  x  x  y is not the same as  y  x  x  y Loves(x,y) –“There is a person who loves everyone in the world”  y  x Loves(x,y) –“Everyone in the world is loved by at least one person” Quantifier duality: each can be expressed using the other  x Likes(x,IceCream)  x  Likes(x,IceCream)  x Likes(x,Broccoli)  x  Likes(x,Broccoli)

12 Term Rewriting This shows that a new sentence is consistent with the existing set of sentences by showing it is equivalent to a sentence that is known to be true It does this by replacing sub-phrases of existing sentences by equivalences defined by the laws of logic

13 Term rewriting example To show that Given  (A  B)  B is T Prove that A is either T or F using Term Rewriting  (A  B)  B ==  (A  B)  B Modus Ponens From De Morgans  (A  B)  B ==  (  A)   B  B From law of Double Negation  (  A)   B  B == A   B  B

14 Continued A   B  B == A  T from Laws of OR reduction and Finally A  T = T also from Laws of OR reduction whether A is T or F QED

15 Another example of Term Rewriting Conversion to Clause form See attached Document

16 Resolution Another approach to Inference is Resolution due to Robinson Resolution works on the principle of Proof By Refutation

17 Proof by Refutation In order to show that a statement S1 is consistent with a set of statements S take  S1(i.e refute S1) and show that  S1 is inconsistent with S. If  S1 is inconsistent with S then it follows that S1 must be consistent. Proof by refutation turns an important property of inference on its head.

18 Semi -Decidability In the theory of computation Inference(Theorem Proving) has been shown to be a semi decidable process. That is we can show that something is not consistent with our set of premises (“decide”)but we cannot guarantee demonstrating its consistency That is why resolution tries to show inconsistency (which can be guaranteed to be shown) of the refutation

19 Resolution Resolution theorem proving works by showing the negation of the theorem, to be proved cannot be true. This is called proof by refutation. To use resolution, the axioms involved in the proof must be expressed in a logic form called clause form. Logic sentences in clause form contain no quantifiers, implications or conjunctions. Clause 1:Not(Hairy(X))  Dog(X) is an example of a sentence in clause form.

20 Resolvents Resolution theorem proving works by producing resolvents. Two clauses can be resolved to produce a new clause(i.e. its resolvent), if one clause contains the negation of a predicate in the other formula. The resolvent consists of those literals in both clauses less the opposing literals. The following clause Clause 2: Hairy(X) could be resolved with Clause 1. to produce the resolvent Dog(X).

21 Unification It might be that two literals are not quite direct opposites but only can be matched by appropriate substitutions. Finding appropriate substitutions is called unification and the substitution is called a unifier. For example, if clause 2 were Hairy(Y) then it could only be resolved with clause 1 using the unifier {Y / X} i.e. Y substituted by X.

22 To illustrate Resolution theorem proving we use clause 1 and the latter version of clause 2, i.e. Hairy(Y). The theorem we want to prove is that X is a dog, i.e. Dog(X). So we negate this clause to produce clause 3, Not(Dog(X)). Resolving clause 1 and clause 2 using the unifier {Y/ X} we get clause 4, Dog(X). Adding this and clause 3 to the set of clauses we get:

23 Set of Clauses Clause 1:Not(Hairy(X))  Dog(X). Clause 2:Hairy(Y). Clause 3:Not(Dog(X). Clause 4: Dog(X).

24 Inconsistency Now, all these clauses are supposed to be true but we have a contradiction between clause 3 and clause 4, so the refutation of the theorem, i.e. clause 3 is inconsistent with the original set of clauses. Therefore we can assume the theorem to be proved.

25 Another Example Given the following set of clauses use resolution to prove the axiom : expensive(f1car) 1: fast(X)  big(X) 2:  big(Y)  economical(Y)  showy(f1car) 3:  fast(U)  new(U) 4:  showy(T)  high_tax(T) 5:  new(G) 6:  high_tax(S) 7:  economical(Z)  expensive(Z) (8 marks)

26 To Prove expensive(f1car) ADD 8:  expensive(f1car) Set of Clauses Now 1: fast(X)  big(X) 2:  big(Y)  economical(Y)  showy(f1car) 3:  fast(U)  new(U) 4:  showy(T)  high_tax(T) 5:  new(G) 6:  high_tax(S) 7:  economical(Z)  expensive(Z) 8:  expensive(f1car)

27 Resolve 1: fast(X)  big(X) with 2:  big(Y)  economical(Y)  showy(f1car) with {X/Y} to get 9: fast(X)  economical(X)  showy(f1car)

28 Resolve 9: fast(X)  economical(X)  showy(f1car) with 3:  fast(U)  new(U) with {X/U} to get 10 economical(X)  showy(f1car)  new(X)

29 Resolve 10 economical(X)  showy(f1car)  new(X) with 5:  new(G) with {X/G} to get 11 economical(X)  showy(f1car)

30 Resolve 11 economical(X)  showy(f1car) with 7:  economical(Z)  expensive(Z) with {X/Z} to get 12 showy(f1car)  expensive(X)

31 Resolve 12 showy(f1car)  expensive(X) With 8:  expensive(f1car) with {f1car/X} to get 13 showy(f1car)

32 Resolve 13 showy(f1car) With 4:  showy(T)  high_tax(T) With {f1car/T} to get 14 high_tax(f1car)

33 Resolve 14 high_tax(f1car) with 6:  high_tax(S) With {f1car/S} to get 15 [] QED

34 Unification Note in the above example we made many substitutions This was done by a process of legal substitutions called legal substitutions which will be described in the following.

35 An algorithm for performing unification Function Unify(E1, E2); begin case both E1 and E2 are constants or the empty list if E1 = E2 then return {} else return FAIL E1 is a variable: if E1 occurs in E2 then return FAIL else return {E2/E1}; E2 is a variable: if E2 occurs in E1 then return FAIL else return {E1/E2}; otherwise begin HE1:= head of E1 HE2:= head of E2 SUBS1 = UNIFY(HE1,HE2); IF SUBS1 = FAIL THEN RETURN FAIL; TE1 := APPLY( SUBS1, REST OF E1) TE2 := APPLY( SUBS1, REST OF E2) SUBS2:= UNIFY(TE1,TE2); IF SUBS2 = FAIL THEN RETURN FAIL; ELSE RETURN THE COMPOSITION OF SUBS1 AND SUBS2. END end end.

36 Example of the algorithm p(X,a,Y) with p(Z,Z,b) Basically the algorithm processes from left to right including the function symbols E1 is p(X,a,Y) in list form E1 is (p X a Y) E2 is p(Z,Z,b) in list form E2 is (p Z Z b) Constants in lowercase, Variables in upper The algorithm starts with the head of E1 and E2

37 Head of E1 = p Head of E2 = p p = p so return nothing {} Next apply algorithm to rest of list Start with head of rest of list Tail E1 = (X a Y) Tail E2 = (Z Z b) Head of tail E1 = ( X| a Y) = X Head of tail E2 = ( Z |Z b) = Z X is a variable and so is Z so according to algorithm Appropriate substitution is {X/Z} Next apply algorithm to rest of list Start with head of rest of list {X/Z, a/X,bY}

38 Apply substitution X/Z to both tails to get Tail E1 = (a Y) Tail E2 = (X b) Head of tail E1 = ( a| Y) = a Head of tail E2 = ( X | b) = X a is a constant and X is a variable so according to algorithm Appropriate substitution is {a/X} Next apply algorithm to rest of list Start with head of rest of list

39 Apply substitution a/X to both tails to get Tail E1 = (Y) Tail E2 = (b) Head of tail E1 = (Y) = Y Head of tail E2 = ( b) = b b is a constant and Y is a variable so according to algorithm Appropriate substitution is {b/Y} Now there is nothing left on either list so we get

40 Our Unifier {X/Z, a/X,bY}

41 Note In our algorithm we have something called an occurs check. We see if one expression occurs in the other. For example if we have X in E and F(E) in another then if we replaced E by F(E) we would get F(E). Replacing the E in this by F(E) we get F(F(E)) and so on ad infinitum to get F(F(F(F…………(F(E)))))))) and still have to make the substitution. This cannot happen so we stop it by failing the unification on nan occurs check.

42 See this in the following example password( mary, favourite(Y,X)) with password(X, favourite(toy,f(X)) Representing these in list form E1 = (password mary (favourite Y Z)) E2 = (password X (favourite Y (f Z))) Following the algorithm through this password matches so {}

43 Next Tail E1 = (mary (favourite Y Z)) Tail E2 = (X (favourite Y (f Z))) Following the algorithm through this Substitution recommended by algorithm for mary and X is {mary/X} So moving on through the rest of the lists

44 Tail E1 = (favourite Y Z) Tail E2 = (favourite Y (f Z)) The next 2 steps of the algorithm see favourite and favourite matched and Y and Y matched So no need for substitutions Next comes the problem

45 Tail E1 = (Z) Tail E2 = ((f Z)) We see that Z occurs in (f Z) so our occurs check fails and we FAIL the unification


Download ppt "Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and."

Similar presentations


Ads by Google