450 likes | 797 Views
Chapter 6 Logical Reasoning. Xiu-jun GONG (Ph. D) School of Computer Science and Technology, Tianjin University gongxj@tju.edu.cn http:// cs.tju.edu.cn/faculties/gongxj/course/ai /. Outline. Intro to logic reasoning Preparation for resolution Stand form clauses (9 steps)
E N D
Chapter 6Logical Reasoning Xiu-jun GONG (Ph. D) School of Computer Science and Technology, Tianjin University gongxj@tju.edu.cn http://cs.tju.edu.cn/faculties/gongxj/course/ai/
Outline • Intro to logic reasoning • Preparation for resolution • Stand form clauses (9 steps) • Substitution and unify • Control strategies • Resolution reasoning • In propositional logic • In Predicate logic • In particular interrogative sentence • Summary Logic is the Calculus of Computer Science The central role of logic in computer science is comparable to the role of differential equations in the natural sciences
Intro to logic • Logic is the study of the principles of valid demonstration and inference. • Consistency, which means that none of the theorems of the system contradict one another. • Soundness, which means that the system's rules of proof will never allow a false inference from a true premise. If a system is sound and its axioms are true then its theorems are also guaranteed to be true. • Completeness, which means that there are no true sentences in the system that cannot, at least in principle, be proved in the system.
Classifications of logic • Informal logic is the study of natural language arguments. • Formal logic is the study of inference with purely formal content • Symbolic logic is the study of symbolic abstractions that capture the formal features of logical inference • Mathematical logic is an extension of symbolic logic into other areas(model theory, proof theory, set theory, and recursion theory)
Symbolic logic • Two languages • Propositional logic • Predicate logic • Components • Syntax • Rules • Semantic
Syntax • Elements • Atoms: {A,B, …, T,F} • Literal: atoms and a sign in front of them • Connectives: , , , and • Sentences: Syntax of well-formed formula(wff), • Any atom is a wff. • If w1 and w2 are wffs, so are w1w2, w1w2, w1w2, w1. • There are no other wffs. • Universal sign: x • Quantifier sign: x
Inference • Reasoning is the cognitive process of looking for reasons for beliefs, conclusions, actions or feelings. • Inference is the act or process of deriving a conclusion based solely on what one knows. • Logic reasoning • Deduction: determining the conclusion • Induction: determining the rule. • Abduction: determining the precondition.
Semantics • Semantics • associating elements of a logical language with elements of a domain of discourse • Interpretation • the proposition associated with an atom (value) • Propositional Truth Table • Given the values of atoms under some interpretation, use a truth table to compute a value for any wff under that same interpretation.
Standard Form Clauses (1) • Clause: a disjunction of literals. • Conjunctive Normal Form: CNF • Disjunctive Normal Form: DNF • CNFDNF
Standard Form Clauses (2) • Prenex Normal Form: A wff of predicate logic is in prenex normal form, iff • all its quantifiers are clustered at the left • no quantifier is negated • the scope of each quantifier extends to the end of the wff • no two quantifiers quantify the same variable • every quantified variable occurs in the matrix of the wff
Standard Form Clauses (3) • Skolem Standard Form: • A formula is in SSF if it is in conjunctive prenex normal form with only universal first-order quantifiers • Removing existential quantifiers from formal logic statements • Standard Form Clauses: • Clauses in SSF P(c)
Convert WFF to SFCs (1) • Eliminate implication signs, > • Reduce the scopes of ~ • Rename variables
Convert WFF to SFC (2) • Forward quantifiers • Skolemtransfer • Eliminate existential quantifiers
Convert WFF to SFC (3) • Get CNF with Skolem standard form • Eliminate universal quantifiers
Convert WFF to SFC (4) • Get clauses • Rename variables again
Resolution reasoning of propositional logic • Resolution is a rule of inference leading to a refutation theorem-proving technique for sentences in propositional logic and first-order logic. • Procedure • Choose two clauses that have exactly one pair of literals that are complementary • Produce a new clause by deleting the complementary literals and combining the remaining literals
General form of resolution Proof: Show that if C1 and C2 are true for explanation I, then R is true for I. 1. Under I, if P=false, then C1’ =true, so R=C1’VC2’=true 2. Under I, if P=true, then C2’ =true, so R=C1’VC2’=true
Resolution on propositional logic • Convert all the expressions (facts, rules and the negation of conclusion) into standard form clauses • Resolve on all the clauses until reaches contradict (nil) resolution refutation
Example Conditions: Conclusion: (6) (2) (1) (4) (5) (6) (2) (7) (1) (8) (4) (9) (5)
Example cont. Lucky enough
Substitution and Unify • Preparing for predicate logic resolution • Universal quantifications for all variables. • If two clauses have matching but complementary literals, it is possible to resolve them literal Clause
Substitution • Any substitution can be represented by a set of ordered pairs
Unify • F1 and F2are predicate formula ,θ is a substitution.if F1θ=F2θ,then θ is the Unifier of F1and F2 • P(c,y,b)and P(x,a,b),θ={c/x,a/y} • P(x,y,b)and P(z,u,b)θ={z/x,u/y} other else? • P(f(y),a)and P(x,a)θ={f(y)/x} • Three types of unifier • Constant/variable ——变量实例化 • Variable/variable ——变量一致化 • Function/variable ——变量函数化
Most General Unifier: MGU • σ is a MGU between F1 and F2 if for any θ be one of unifiers between F1 and F2, there exists a λ such that θ=σ·λ • i.e. F1 =P(x), F2 =P(f(y)) • θ1 ={f(a)/x,a/y},θ2 ={f(b)/x,b/y} • θ1 ,θ2are unifiers , but not MGUs • σ = {f(y)/x}is a MGU, where • θ1=σ· {a/y}, λ= {a/y} • θ2=σ· {b/y}, λ= {b/y}
Algorithms looking for a MGU • Steps • Find out the difference sets of variables between two clauses • Identify the substitutions for each set • Ex1. F1= P(x,y,z)F2= P(x,f(a),h(b)) • Difference set: D1={y,f(a)}, D2={z,h(b)} • MGU= {f(a)/ y, h(b)/z} • Ex2. F1= P(x), F2= P(y) • Difference set: D={x,y} • MGU={x/y} or {y/x}
Resolution Reasoning of Predicate Logic • F1 and F2 are clauses, P1 in F1 and~ P2 in F2 are literals such that P1 and P2 have a MGU μ, then • These two clauses have a resolvent ρ. • The resolvent is obtained by applying the substitution μ to the union of F1 and F2, leaving out the complementary literals. • Ρ=[(F1-{P1}) ∨(F1-{~P2})] μ
Example • Problem • Marcus is a man • Caesar is a ruler • A person trying to assassinate its ruler is not loyal • Marcus want to assassinate Caesar • Step1 Convert to logic expression • man (marcus) • ruler (caesar) • person(X)∧rule(Y)∧tryassassinate(X,Y) →~loyalto(X,Y) • tryassassinate (marcus, caesar) • man(X) → person(X) • Show that Marcus is not loyal to Caesar ~loyalto(marcus,caesar)
Example cont. • Step2, build standard form clauses (1) man(m) (2) ruler(c) (3) ~person(X)∨~ruler(Y)∨~trya (X,Y)∨~loyalto(X,Y) (4) trya (m,c) (5) ~man(Z) ∨person(Z) (6) loyalto(m,c) • Step3, resolution reasoning (7) ~person(m)∨~ruler(c)∨~trya (m,c) (6) (3) {m/X, c/Y} (8) ~person(m)∨~ruler(c) (7) (4) (9) ~person(m) (8) (2) (10) ~man(m) (9) (5) {m/Z} (11) NIL (10)(1)
Control Strategy (1) • Problem • How to pick up clauses to resolve? • Quick and completeness • Strategies • Breadth-first resolution: completeness, time-consuming • Unit resolution: with priority with literals • Input resolution: each resolvent at lease involves a input clause
Control strategies (2) • Linear resolution: Start from an initiate clause, then resolve continue linearly. • ~P ∨S • P ∨Q • ~P ∨R • ~Q ∨R • ~R • Q ∨R (2)(3) • R (6)(4) • NIL (7)(5) The point is how to choose the initiate clause
Control strategies (3) • Supported set resolution: for each resolvent, one of clause must be in “supported set” • The supported set includes negation of the conclusion and its resolvents • ~P ∨S • P ∨Q • ~P ∨R • ~Q ∨R • ~R
Control strategies (4) • One occurrence literal deletion • ~P ∨S • P ∨Q • ~P ∨R • ~Q ∨R • ~R
Resolution for Particular Interrogative Sentence • Answers for who,what,when,where,how Known as: pompeian(x)->died(x,70) pompeian(marcus) Ask: died(marcus,?) Clause set: (1) ~pompeian(x) ∨ died(x,70) (2) pompeian(marcus) (3) ~died(marcus,t) ∨died(marus,t) (ever-true expression is added for conclusion)
Example cont. (1) ~pompeian(x) ∨ died(x,70) (2) pompeian(marcus) (3) ~died(marcus,t) ∨died(marus,t)
Summary • Preparation for resolution • Stand form clauses (9 steps) • Substitution and unify • Control strategies • Resolution reasoning • In propositional logic • In Predicate logic • In particular interrogative sentence