Sunteți pe pagina 1din 72

Logic is a study of methods and principles used to distinguish correct from incorrect reasoning.

Formally it deals with the notion of truth in an abstract sense and is concerned with the principles of valid inferencing. A proposition in logic is a declarative statements such as Jack is a male, "Jack loves Mary" etc. which are either true or false (but not both) in a given context.

Propositional Logic Concepts

If we are given some propositions to be true in a given context, then logic helps in inferencing new proposition, which is also true in the same context. For example, if we are given a set of propositions such as It is hot today" and If it is hot it will rain", then we can infer that It will rain today". Propositional Calculus (PC) is a language of propositions basically refers to set of rules used to combine the propositions to form compound propositions using logical operators often called connectives such as , V, ~, ,

Well-formed formula in PC is defined as


An atom is a well-formed formula. If is a well-formed formula, then ~ is a well-formed formula. If and are well formed formulae, then ( ), ( V ), ( ), ( ) are also well-formed formulae. A propositional expression is a well-formed formula if and only if it can be obtained by using above conditions.

Truth table gives us operational definitions of important logical operators. By using truth table, the truth values of wellformed formulae are calculated. Truth table elaborates all possible truth values of a formula. The meanings of the logical operators are given by the following truth table
P Q ~P PQ PVQ P Q P Q

T T F F

T F T F

F F T T

T F F F

T T T F

T F T T

T F F T

Equivalence Laws
Commutation 1. P Q 2. P V Q Association 1. P (Q R) 2. P V (Q V R) Double Negation ~ (~ P) Distributive Laws 1. P ( Q V R) 2. P V ( Q R) De Morgans Laws 1. ~ (P Q) 2. ~ (P V Q) Law of Excluded Middle P V ~P Law of Contradiction P ~P Q P Q V P (P Q) R (P V Q) V R P (P Q) V (P R) (P V Q) (P V R) ~P V~Q ~P ~Q T (true) F (false)

Idempotence 1. P P 2. P V P Absorption 1. P (P V Q) 2. P V (P Q) 3. P V ( ~ P Q) 4. P ( ~ P V Q)

P P P P P V Q P Q

There are some commonly used equivalence relations listed below: P F F P T P P V F P P V T T PQ ~PVQ PQ (P Q) (Q P) (P Q) V (~ P ~ Q

These laws can be verified using truth table approach. Let us verify A V (A B) A using truth table approach.
Showing A V (A B) A
A
T T F F

B
T F T F

AB
T F F F

AVA B
T T F F

Propositional Logic
It basically deals with the validity, satisfiability and unsatisfiability of a formula and derivation of a new formula using equivalence laws. Each row of a truth table for a given formula is called its interpretation under which a formula can be true or false. A formula is called tautology if and only if is true for all interpretations. A formula is also called valid if and only if it is a tautology.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Let be a formula and if there exist at least one interpretation for which is true, then is said to be consistent (satisfiable) i.e., if a model for , then is said to be consistent . A formula is said to be inconsistent (unsatisfiable), if and only if is always false under all interpretations. We can translate simple declarative and conditional (if .. then) sentences of natural language into its corresponding propositional formulae.

Example: Show that "If it is humid then it will rain and it is humid today then it will rain" is a valid argument. Solution: Let us symbolize English sentences by propositional atoms as follows: A B : : It is humid It will rain

Formula corresponding to a text: : ((A B) A) B Using truth table approach, one can see that is true under all four interpretations and hence is valid argument.

Truth Table for ((A B) A) B


A T T F F B T F T F A B=X T F T T XA= Y T F F F Y B T T T T

Natural Deduction Systems in PL


Truth table method for problem solving is simple and straightforward and is very good at presenting a survey of all the truth possibilities in a given situation. It is an easy method of evaluating a consistency, inconsistency or validity of a formula, but the size of truth table grows exponentially. If a formula contains n atoms, then the truth table will contain 2n entries. Truth table method is good for small values of n.

Example: If we have to show that a formula : (P Q R) ( Q V S) is valid using truth table, then we have to construct a table of 16 rows for which the truth values of are to be computed. If we carefully analyze , we realize that if P Q R is false, then is bound to be true because of the definition of . Since P Q R is false for 14 entries out of 16, we are left only with two entries to be tested for which P Q R. Therefore, we may find that in order to prove the validity of a formula, all the entries in the truth table are not relevant in this case. There are other methods where we will be concerned with proofs and deductions of logical formula.
Natural Deductive System Axiomatic System Semantic Tableaux Method Resolution Refutation Method

Natural deduction method


It is based on the set of few deductive inference rules. The name natural deductive system is given because it mimics the pattern of natural reasoning. It has about 10 deductive inference rules. Conventions:
E for Elimination. P, Pk , (1 k n) are atoms. k, (1 k n) and are formulae.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Rule 1: I- (Introducing ) I- : If P1, P2, , Pn then P1 P2 Pn Interpretation: If we have hypothesized or proved P1, P2, and Pn , then their conjunction P1 P2 Pn is also proved or derived.

Rule 2: E- ( Eliminating ) E- : If P1 P2 Pn then Pi ( 1 i n) Interpretation: If we have proved P1 P2 Pn , then any Pi is also proved or derived. This rule shows that can be eliminated to yield one of its conjuncts. Rule 3: I-V (Introducing V) I-V : If Pi ( 1 i n) then P1V P2 V V Pn Interpretation: If any Pi (1 i n) is proved, then P1 V V Pn is also proved. Rule 4: E-V ( Eliminating V) E-V : If P1 V V Pn, P1 P, , Pn P then P Interpretation: If P1 VV Pn , P1 P, P2 P and Pn P are proved, then P is proved.

Rule 5: I- (Introducing ) I- : If from 1, , n infer is proved then 1 n is proved Interpretation: If given 1, 2, and n to be proved and from these we deduce then 1 2 n is also proved. Rule 6: E- (Eliminating ) - Modus Ponen E- : If P1 P, P1 then P Rule 7: I- (Introducing ) I- : If P1 P2, P2 P1 then P1 P2 Rule 8: E- (Elimination ) E- : If P1 P2 then P1 P2 , P2 P1 Rule 9: I- ~ (Introducing ~) I- ~ : If from P infer P1 ~ P1 is proved then ~P is proved Rule 10: E- ~ (Eliminating ~) E- ~ : If from ~ P infer P1 ~ P1 is proved then P is proved

NDS Rules Table


Rule Name Introduce Symbol (I:) Rule If A1, A2, , An then A1 A2 An If A1 A2 An Ai ( 1 i n) If Ai ( 1 i n) then A1V A2 V V An If A1 V V An, A1 A, , An A then A If from 1, , n infer is proved then 1 n is proved If A1 A, A1 Description If A1, A2, and An are true, then their conjunction A1 A2 An is also true. then If A1 A2 An is true, then any Ai is also true. If any Ai (1 i n) is true, then A1 V V An is also true. If A1 VV An , A1 A, A2 A and An A are proved to be true, then A is proved to be true. If given that 1, 2, and n are true and from these we deduce then 1 2 n is also proved to be true. If A1 A and A1 are true then A is also true. This is called Modus Ponen rule If A1 A2 and A2 A1 are true then A1 A2 is also true. If A1 A2 is true then A1 A2 and A2 A1 are true If from A, a contradiction is proved then truth of ~A is also proved If from ~A, a contradiction is proved then truth of A is also proved

Eliminate

(E:)

Introducing V

(I:V)

Eliminating V

(E:V)

Introducing

(I : )

Eliminating

(E: )

then A

Introducing Elimination

(I: ) (E: )

If A1 A2, then A1 A2

A2 A1

If A1 A2 then A1 A2 , A2

A1

Introducing ~

(I: ~ )

If from A infer A1 ~ A1 is proved then ~A is proved If from ~ A infer A1 ~A1 is proved then A is proved

Eliminating ~

(E: ~)

If a formula is derived / proved from a set of premises / hypotheses { 1,, n }, then one can write it as from 1, , n infer . In natural deductive system, a theorem to be proved should have a form from 1, , n infer If we write infer , then it means that there are no premises and is true under all interpretations i.e., is a tautology or valid.

Example: Prove that P (Q V R) follows from P Q . Solution: This problem is restated in natural deductive system as "from
P Q infer P (Q V R)". The formal proof is given as follows:

{Theorem} from P Q infer P (Q V R) { premise} PQ (1) { E- , (1)} P (2) { E- , (1)} Q (3) { I-V , (3) } QVR (4) { I-, ( 2, 4)} P (Q V R) Conclusion If we assume that is a premise, then we conclude that is proved if is given i.e., if from infer is a theorem then is concluded. The converse of this is also true. Deduction Theorem: To prove a formula 1 2 n , it is sufficient to prove a theorem from 1, 2, , n infer .

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Example: Prove the following theorem: infer ((Q P) (Q R)) (Q (P R)) Solution: In order to prove infer ((Q P) (Q R)) (Q (P

R)), we prove a theorem from {Q P, Q R} infer Q (P R). Further, for proving Q (P R), we have to prove a sub theorem from Q infer P R

{Theorem} from Q P, Q R infer Q (P R) { premise 1} Q P (1) { premise 2} Q R (2) { sub theorem} from Q infer P R (3) { premise } Q (3.1) { E- , (1, 3.1) } P (3.2) {E- , (2, 3.1) } R (3.3) { I-, (3.2,3.3) } P R (3.4) { I- , ( 3 )} Q (P R) Conclusion

Axiomatic System for PL


It is based on the set of only three axioms and one rule of deduction. It is minimal in structure but as powerful as the truth table and natural deduction approaches. The proofs of the theorems are often difficult and require a guess in selection of appropriate axiom(s) and rules. These methods basically require forward chaining strategy where we start with the given hypotheses and prove the goal. Axiom1 (A1): ( ) Axiom2 (A2): ( ()) (( ) ( )) Axiom3 (A3): (~ ~ ) ( ) Modus Ponen (MP) defined as follows: Hypotheses: and Consequent:

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Example: Establish the following: 1. {Q} |- (P Q) i.e., P Q is a deductive consequence of {Q}. {Hypothesis} Q (1) {Axiom A1} Q (P Q) (2) {MP, (1,2)} P Q proved 2. { P Q, Q R } |- ( P R ) i.e., P R is a deductive consequence of { P Q, Q R }. {Hypothesis} P Q (1) {Hypothesis} Q R (2) {Axiom A1} (Q R) (P (Q R)) (3) {MP, (2, 3)} P (Q R) (4) {Axiom A2} (P (Q R)) ((P Q) (P R)) (5) {MP , (4, 5)} (P Q) (P R) (6) {MP, (1, 6)} P R proved

1. Useful tip Given , we can easily prove for any well-formed formulae and . Deduction Theorem: If is a set of hypotheses and and are well-formed formulae , then { } |- implies |- ( ). Converse of deduction theorem: Given |- ( ), we can prove { } |- . 2. Useful tip If is to be proved, then include in the set of hypotheses and derive from the set { }. Then using deduction theorem, we conclude . Example: Prove ~ P (P Q) using deduction theorem. Proof: We prove {~ P} |- (P Q) and |- ~ P (P Q) follows from deduction theorem.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Semantic Tableaux System in PL


Earlier approaches require construction of proof of a formula from given set of formulae and are called direct methods. In semantic tableaux, the set of rules are applied systematically on a formula or set of formulae to establish its consistency or inconsistency. Semantic tableau is a binary tree constructed by using semantic rules with a formula as a root

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Semantic Tableaux Rules


Assume and be any two formulae.

Rule 1: A tableau for a formula ( ) is constructed by adding both and to the same path (branch). This can be represented as follows: Rule 2: A tableau for a formula ~ ( ) is constructed by adding two alternative paths one containing ~ and other containing ~. ~ ( ) ~ ~

Rule 3: A tableau for a formula ( V ) is constructed by adding two new paths one containing and other containing . V Rule 4: A tableau for a formula ~ ( V ) is constructed by adding both ~ and ~ to the same path. This can be expressed as follows: ` ~ ( V ) ~ ~

Rule 5:

Rule 6:

Semantic tableau for ~ ~ ~ ~ Semantic tableau for ~ Semantic tableau for ~ ( ) ~ ( ) ~

Rule 7:

Rule 8:

Semantic tableau for


( ) V (~ ~ ) ~ ~

Rule 9:
~ (

Semantic tableau for ~ ( )

) ( ~ ) V (~ ) ~ ( ) ~ ~

Consistency and Inconsistency


Whenever an atom P and ~ P appear on a same path of a semantic tableau, then inconsistency is indicated and such path is said to be contradictory or closed (finished) path. Even if one path remains non contradictory or unclosed (open), then the formula at the root of a tableau is consistent. Contradictory tableau (or finished tableau) is defined to be a tableau in which all the paths are contradictory or closed (finished). If a tableau for a formula at the root is a contradictory tableau, then a formula is said to be inconsistent.

Example: Show that : ( Q ~ R) ( R P) is consistent and find its model.


{Tableau root} {Apply rule 1 to 1} ( Q ~ R) ( R P) (Q ~ R) ( R P) {Apply rule 1 to 2} Q {Apply rule 6 to 3} ~R ~R P open open (1) (2) (3)

{ Q = T, R = F } and { P = T , Q = T, R = F } are models of .

Example: Show that : (P Q R) ( ~P S) Q ~ R ~ S is inconsistent using tableaux method. (Root} (P Q R) ( P S) Q ~R ~S (1) {Apply rule 1 to 1} P Q R (2) ~P S (3) Q ~R ~S {Apply rule 6 to 3} ~ ~P = P S Closed: {S, ~ S} on the path {Apply rule 6 to 2)} ~ (P Q) R Closed { R, ~ R} ~P ~Q Closed {P, ~ P} Closed{Q, ~ Q}

Resolution Refutation in PL
Resolution refutation is another simple method to prove a formula by contradiction. Here negation of goal to be proved is added to given set of clauses and shown that there is a refutation in new set using resolution principle. During resolution we need to identify two clauses, one with positive atom (P) and other with negative atom (~ P) for the application of resolution rule. It is based on modus ponen inference rule.

Conjunctive and Disjunctive Normal Forms


In Disjunctive Normal Form (DNF), a formula is represented in the form (L11 .. L1n ) V .. V (Lm1 .. Lmk ), where all Lij are literals. Disjunctive Normal Form is disjunction of conjunction. Conjunctive Normal Form (CNF) is conjunction of disjunction. The formula is represented in the form (L11 V .. V L1n ) (Lp1 V .. V Lpm ) , where all Lij are literals. A clause is a formula of the form (L1V V Lm), where each Lk is a positive or negative atom.

Conversion of a Formula to its CNF


Each formula in Propositional Logic can be easily transformed into its equivalent DNF or CNF representation using equivalence laws .
Eliminate and by using the following equivalence laws. P Q ~P V Q PQ ( P Q) ( Q P) Eliminate double negation signs by using ~~P P

Use De Morgans laws to push ~ (negation) immediately before atomic formula. ~ ( P Q) ~ P V ~ Q ~ ( P V Q) ~ P ~ Q Use distributive law to get CNF. P V (Q R) (P V Q) (P V R)

We notice that CNF representation of a formula is of the form (C1 .. Cn ) , where each Ck , (1 k n ) is a clause which is disjunction of literals.

Resolvent of Clauses
If two clauses C1 and C2 contain a complementary pair of literals {L, ~L}, then these clauses may be resolved together by deleting L from C1 and ~ L from C2 and constructing a new clause by the disjunction of the remaining literals in C1 and C2. The new clause thus generated is called resolvent of C1 and C2 . Here C1 and C2 are called parents of resolved clause. Inverted binary tree is generated with the last node of the binary tree to be a resolvent. This is also called resolution tree.

Example: Find resolvent of:


C1 = P V Q V R; C2 = ~ Q V W; C3 = P V ~ W

Inverted Resolution Tree P V Q V R {Q, ~ Q} P V R V W {W, ~ W} PVR Resolvent(C1,C2, C3) = P V R

~Q V W

P V ~W

Theorem: If C is a resolvent of two clauses C1 and C2 , then C is a logical consequence of {C1 , C2 }. A deduction of an empty clause from a set S of clauses is called a resolution refutation of S.
Theorem: Let S be a set of clauses. A clause C is a logical consequence of S iff the set S= S {~ C} is unsatisfiable. In otherwords, C is a logical consequence of a given set S iff an empty clause is deduced from the set S'.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Example: Show that C V D is a logical consequence of S ={AVB, ~ AVD, C V~ B} using resolution refutation principle.

First we will add negation of logical consequence i.e., ~ (C V D) ~C ~D to the set S. Get S = {A V B, ~ A V D, C V~ B, ~C, ~D}. Now we show that S is unsatisfiable by deriving contradiction using resolution principle.

AVB

~A V D

CV~B

~C

~D

BVD CVD D

Since we get contradiction from S, we can conclude that (C V D) is a logical consequence of S = {AVB, ~ AVD, CV~ B}.

First Order Predicate Logic


Limitation of Propositional Logic: The facts: peter is a man, paul is a man, john is a man can be symbolized by P, Q and R, respectively , in PL. But we would not be able to draw any conclusions about similarities between P, Q and R. It would be much better to represent these facts as MAN(peter), MAN(paul) and MAN(john). Further, we are even in more difficulty, if we try to represent sentences like All men are mortal in Propositional Logic.

In Predicate Logic, such sentences can be easily represented and the limitations of propositional logic are removed to some extent. The predicate logic is logical extension of propositional logic. The first order predicate logic is one where the quantification is over simple variables.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Predicate Calculus
It has three more logical notions as compared to propositional calculus.
Terms, Predicates and Quantifiers (universal or existential quantifiers i.e. for all' and there exists)

A term is a constant (single individual or concept


i.e.,5, john etc.), a variable that stands for different individuals and n-place function f(t1, , tn) where t1, , tn are terms. A function is a mapping that maps n terms to a term. A predicate is a relation that maps n terms to a truth value true (T) or false (F). Examples: A statement x is greater than y is represented in predicate calculus as GREATER(x, y). It is defined as follows: GREATER( x, y) = T , if x > y = F , otherwise

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

A statement x loves y is represented as LOVE(x, y) which maps it to true or false when x and y get instantiated to actual values. A statement johns father loves john is represented as LOVE(father(john), john). Here father is a function that maps john to his father. The predicate names GREATER and LOVE take two terms and map to T or F depending upon the values of their terms.

Quantifiers: Variables are used in conjunction with


quantifiers. There are two types of quantifiers viz.., there exist () and for all ().

Example: Translate the text "Every man is mortal. John is a man. Therefore, John is mortal" into Predicate Calculus formula. Solution: Let MAN(x), MORTAL(x) represent x is a man and x is mortal respectively. Every man is mortal :(x) (MAN(x) MORTAL(x)) John is a man : MAN(john) John is mortal : MORTAL(john) The whole text can be represented by the following formula. (x) ((MAN(x) MORTAL(x)) MAN(john)) MORTAL(john)

First Order Predicate Logic (FOL)


First order predicate calculus becomes First Order Predicate Logic if inference rules are added to it. Using inference rules one can derive new formula using the existing ones.

Interpretations of Formulae in FOL


In PL, an interpretation is simply an assignment of truth values to the atoms. In FOL, there are variables, so we have to do more than that. An interpretation of a formula in FOL consists of a non empty domain D and an assignment of values to each constant, function symbol and predicate symbol.

Example: Let : (x) ( y) P(x, y) be a formula. Evaluate it under the following interpretation I.

D = {1, 2} I[P(1, 1)] = F, I[P(1, 2)] = T, I[P(2, 1)] = T, I[P(2, 2)] = F

We

use notation I[] = T (or F), which means that is evaluated to be true or false under interpretation I over a domain D. Let and are formulae and I is an interpretation over any domain D. The following holds true. I[ ] = I[] I[] I[ V ] = I[] V I[] I[ ] = I[] I[] I[~] = ~ I[] = T iff I[] = F

A formula is said to be consistent (satisfiable) if and only if there exists an interpretation I such that I[] = T. Alternatively we say that I is a model of or I satisfies . A formula is said to be inconsistent (unsatisfiable) if and only if no interpretation that satisfies or there exists no model for . A formula is valid if and only if for every interpretation I, I[] = T. A formula is a logical consequence of a set of formulae {1, 2, ..., n } if and only if for every interpretation I, if I[1 n ] = T, then I[] = T.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Prenex Normal Form


In FOL, there are infinite number of domains and consequently infinite number of interpretations of a formula. Therefore, unlike PL, it is not possible to verify a validity and inconsistency of a formula by evaluating it under all possible interpretations. We will discuss the formalism for verifying inconsistency and validity in FOL. In FOL, there is also a third type of normal form called Prenex Normal Form.

Contd..
A closed formula of FOL is said to be in Prenex Normal Form (PNF) if and only if is represented as (q1 x1) (q2 x2) (qn xn) (M), where, qk , (1 k n ) quant ( or ) and M is a formula free from quantifiers. A list of quantifiers [(q1 x1) (qn xn)] is called prefix and M is called the matrix of a formula . Here M is represented in CNF.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Transformation of Formula into PNF A formula can be easily tranformed into PNF using various equivalence laws. We use the following conventions: [x] - a formula , which contains a variable x. - a formula without a variable x. q Quantifier ( or ).

Equivalence Laws: There are following pairs of logically equivalent formulae called equivalence laws in addition to the equivalence laws given for PL. 1. 2. 3. 4. 5. 6. (q x) [x] V V (q x) [x] (q x) [x] (q x) [x] ~ ((x) [x]) ~ ((x) [x]) (q x) ( [x] V ) (q x) ( V [x]) (q x) ( [x] ) (q x) ( [x]) (x) (~ [x]) (x) (~ [x])

Skolemisation (Standard Form)


Prenex normal form of a formula is further transformed into special form called Skolemisation or Standard Form. This form is used in resolution of clauses. The process of eliminating existential quantifiers and replacing the corresponding variable by a constant or a function is called skolemisation. A constant or a function is called skolem constant or function.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Convertion of PNF to its Standard Form


Scan prefix from left to right. If q1 is the first existential quantifier then choose a new constant c Matrix. Replace all occurrence of x1 appearing in Matrix by c and delete (q1 x1) from the prefix to obtain new prefix and matrix. If qr is an existential quantifier and q1.qr-1 are universal quantifiers appearing before qr , then choose a new (r-1) place function symbol 'f ' Matrix. Replace all occurrence of xr in Matrix by f(x1, ,xr-1 ) and remove (qr xr ). Repeat the process till all existential quantifiers are removed from matrix.

Any formula in FOL can be transformed into its standard form. Matrix of standard formula is in CNF and prefix is free from existential quantifiers. Formula in standard form is expressed as: (x1) (xn) (C1 Cm), Since all the variables in prefix are universally quantified, we omit prefix part from the standard form for the sake of convenience and write standard form as (C1 Cm). A clause is a closed formula of the form (x1) (xn) (L1V V Lm), where each Lk is a literal and x1,,xn are variables occurring in L1, , Lm. Since all the variables in a clause are universally quantified, we omit them and write clause as (L1V V Lm ) for the sake of simplicity.
where Ck ,(1 k m) is formula in disjunctive normal form.
Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

The standard form of any formula is of the form (C1 Cm), where each Ci , (1 i m) is a clause. We define S = { C1, ,Cm } to be a set of clauses that represents a standard form of a formula . S is said to be unsatisfiable (inconsistent) if and only if there no interpretation that satisfies all the clauses of S simultaneously. A formula is unsatisfiable (inconsistent) if and only if its corresponding set S is unsatisfiable. S is said to be satisfiable (consistent) if and only if each clause is consistent i.e., an interpretation that satisfies all the clauses of S simultaneously. Alternatively, an interpretation I models S if and only if I models each clause of S.

Resolution in Predicate Logic


Resolution method is used to test unsatisfiability of a set S of clauses in Predicate Logic. It is an extension of resolution method for PL. The resolution principle basically checks whether empty clause is contained or derived from S. Resolution for the clauses containing no variables is very simple and is similar to prop logic. It becomes complicated when clauses contain variables. In such case, two complementary literals are resolved after proper substitutions so that both the literals have same arguments.

Example:

Consider two clauses C1 and C2 as follows: C1 = P(x) V Q(x) C2 = ~ P(f(x)) V R(x) Substitute 'f(a)' for 'x' in C1 and 'a' for 'x' in C2 , where 'a' is a new constant from the domain, then C3 = P(f(a)) V Q(f(a)) C4 = ~ P(f(a)) V R(a) Resolvent C of C3 and C4 is [Q(f(a)) V R(a)] Here C3 and C4 do not have variables. They are called ground instances of C1 and C2 . In general, if we substitute 'f(x)' for 'x' in C1 , then C'1 = P(f(x)) V Q(f(x)) Resolvent C' of C'1 and C2 is [Q(f(x)) V R(x)] We notice that C is an instance of C' .

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Theorem: L is a logical consequence of S iff {S ~L} = { C1,.... , Cn , ~ L} is unsatisfiable. A deduction of an empty clause from a set S of clauses is called a resolution refutation of S. Theorem: (Soundness and completeness of resolution): There is a resolution refutation of S if and only if S is unsatisfiable (inconsistent). Theorem: L is a logical consequence of S if and only if there is a resolution refutation of S {~L}. We can summarize that in order to show L to be a logical consequence the of set of formulae {1, , n }, use the following procedure.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Procedure:
Obtain a set S of all the clauses by converting each k to its corresponding standard form and then to the clauses. Show that a set S { ~ L} is unsatisfiable i.e., the set S { ~ L} contains either empty clause or empty clause can be derived in finite steps using resolution method. If so, then report 'Yes' and conclude that L is a logical consequence of S and subsequently of formulae 1, , n otherwise report 'No'. If the choice of clauses to resolve at each step is made in a systematic ways, then resolution algorithm will find a contradiction if one exists. There exist various strategies for making the right choice that can speed up the process considerably.

Useful Tips:
Initially choose a clause from the negated goal clauses as one of the parents to be resolved ( This corresponds to intuition that the contradiction we are looking for must be because of the formula we are trying to prove) . Choose a resolvent and some existing clause if both contain complementary literals. If such clauses do not exists, then resolve any pairs of clauses that contain complementary literals. Whenever possible, resolve with the clauses with single literal. Such resolution generate new clauses with fewer literals than the larger of their parent clauses and thus probably algorithm terminates faster. Eliminate tautologies and clauses that are subsumed by other clauses as soon as they are generated.

Logic Programming
Logic programming is based on first order predicate logic. Clauses are very common in logic programming which are special forms of FOL. Program in logic programming is a collection of clauses. Clause in logic programming adopts a special clausal notation. Queries are solved using resolution principle. A clause in logic programming is represented in a clausal notation as A1, , Ak B1,, Bt , where Aj are positive literals and Bk are negative literals.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Conversion of a Clause into Clausal Notation


A clause in FOL is a closed formula of the form, (x1) (xn) (L1V V Lm), where each Lk , (1 k n) is a literal and xk , (1 k n) are all the variables occurring in L1, , Lm . Remove the prefix (x1) (xn) for the sake of simplicity because all the variables appearing in a clause are universally quantified . Now a clause is represented as L1V V Lm, where Lk , (1 k n) are literals free from quant.

Separate positive and negative literals in the clause as follows:


(L1V L2 V V Lm) (A1 V VAk V ~ B1 V V~ Bt), where m = k + t, Aj, (1 j k) are positive literals and Bj , (1 j t) are negative literals. (A1 V VAk ) V ~ (B1 Bt) (B1 Bt) (A1 V VAk ) {since P Q ~ P V Q}

Clausal notation is written in the form :


(A1 V VAk ) (B1 Bt) Or A1, , Ak B1,, Bt .

Here Aj , (1 j k) are positive literals and Bi , (1 i t) are negative literals. It must be noted that interpretation of A B is same as B A In clausal notation, all variables are assumed to be universally quantified. Bi , (1 i t) (negative literals) are called antecedents and Aj , (1 j k) (positive literals) are called consequents. Commas in antecedent and consequent denote conjunction and disjunction respectively.

Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

Applying the results of FOL to the logic programs, a goal G with respect to a program P (finite set of clauses) is solved by showing that the set of clauses P { ~ G} is unsatisfiable or there is a resolution refutation of P { ~ G}. If so, then G is logical consequence of a program P. The basic constructs of logic programming are inherited from FOL. There are three basic statements: facts, rules and queries. These are special forms of clauses.

Example:

Consider the following logic program.

GRANDFATHER (x, y) FATHER (x, z) , PARENT (z, y) PARENT (x, y) FATHER (x, y) PARENT (x, y) MOTHER (x, y) FATHER ( abraham, robert) FATHER ( robert, mike)

In FOL above program is represented as a set of clauses as: S = { GRANDFATHER (x, y) V ~ FATHER (x, z) V ~ PARENT
(z, y), PARENT(x, y) V ~ FATHER (x, y), PARENT(x, y) V ~ MOTHER (x, y), FATHER ( abraham, robert), FATHER ( robert, mike) }

Let us number the clauses of S as follows:


i.
ii. iii. iv. v. GRANDFATHER (x, y) V ~ FATHER (x, z) V ~ PARENT(z, y) PARENT(x, y) V ~ FATHER (x, y) PARENT(x, y) V ~ MOTHER (x, y), FATHER ( abraham, robert) FATHER ( robert, mike)

Simple queries : (a)Ground Query Query: Is abraham a grandfather of mike ?" GRANDFATHER (abraham, mike). In FOL, ~ GRANDFATHER (abraham, mike) is negation of goal { GRANDFATHER (abraham, mike). Include {~goal} in the set S and show using resolution refutation that S {~ goal} is unsatisfiable in order to conclude the goal. Let ~ goal is numbered as ( vi) in continuation of first five clauses of S listed above. vi. ~ GRANDFATHER (abraham, mike) Resolution tree is given as follows:

(i)
{x / abraham, y / mike}

( vi )

( iv) ~ FATHER (abraham, z) V ~ PARENT (z, mike)


Edited by Foxit Reader Copyright(C) by Foxit Software Company,2005-2008 For Evaluation Only.

{z / robert}

~ PARENT (robert, mike) ~ FATHER (robert, mike)

( ii)

(v)

Answer:

Yes

(b)

Non ground queries Query: Does there exist x such that x is a father of robert ? {Who is father of robert?} FATHER (x, robert). Query: Does there exist x such that abraham is a father of x?" {abraham is father of whom?} FATHER (abraham, x). Query : Do there exist x and y such that x is a father of y?" { who is father of whom?} FATHER (x, y).

Assignment 4
Write a program in language of your choice for Checkers game. Use - pruning concept. Last date of submission: 5th Nov.
Late submission : 6th Nov. (with penalty)

S-ar putea să vă placă și