Lec7-PropLogic

advertisement

Propositional Logic

Reasoning correctly computationally

Chapter 7 or 8

Natural Reasoning

John plays tennis if sunny and weekend day.

If John plays tennis, Mary goes shopping.

It is Saturday.

It is sunny.

Specific: Does John play tennis?

All: what may one conclude?

State-Space Model?

• What are the States?

• What are the legal operators?

• What is an appropriate search?

• What do we want?

States

• Collection of boolean formula in boolean variables.

Proposition variables stand for a statement that may be either true or false.

• Ex. It is the weekend. Q

• Ex. It is Saturday. P

• Ex. It is Saturday implies is weekend:

P =>Q

Initial State: what you know

{ P, P=>Q} meaning clauses are true.

Operators

• Operators take a previous state (collection of formula) and add new formula.

• Modus Ponens: If A is true, and A implies

B, then B is true.

• Model:

A = it is Saturday, B = it is weekend and A is true, and A=>B is true, then B is true.

What are the right operators?

• If some A are B, and some B are C, then some A are C.

• If A implies B, and B is false, then A is false.

A model

• Models are particular instantiations of the variables.

• If some A are B, and some B are C, then some A are C.

• A = women, B= students, C = men

• If some women are students, and some students are men, then ….

• Bad Rule.

Concerns

• What does it mean to say a statement is true?

• What are a good set of operators?

• What can we say in propositional logic?

• What is the efficiency?

• Can we guarantee to infer all true conclusions?

Semantic definition of Truth

• Model = possible world

• x+y = 4 is true in the world x=3, y=1.

• x+y = 4 is false in the world x=3, y = 2.

Entailment S1,S2,..Sn |= S means in every world where S1…Sn are true, S is true.

• Careful: No mention of proof – just checking all the worlds.

• Some cognitive scientists argue that this is the way people reason.

Reasoning or Inference Systems

• Proof is a syntactic property.

• Rules for deriving new sentences from old ones.

Sound : any derived sentence is true.

Complete : any true sentence is derivable.

• NOTE: Logical Inference is monotonic.

Can’t change your mind.

Proposition Logic: Syntax

• See text for complete rules

• Atomic Sentence: true, false, variable

• Complex Sentence: connective applied to atomic or complex sentence.

• Connectives: not, and, or, implies, equivalence, etc.

• Defined by tables.

Propositional Logic: Semantics

• Truth tables: p =>q |= ~p or q t t t t p t f t t q t f t t p =>q t f t t

~p or q

Beware: Implies =>

• If 2+2 = 5 then monkeys are cows. TRUE

• If 2+2 = 5 then cows are animals. TRUE

• Indicates a difference with natural reasoning. Single incorrect or false belief will destroy reasoning. No weight of evidence.

Inference

• Does s1,..sk entail s?

• Say variables (symbols) v1…vn.

• Check all 2^n possible worlds.

• In each world, check if s1..sk is true, that s is true.

• Complexity: approximately O(2^n).

• Complete: possible worlds finite for propositional logic, unlike for arithmetic.

Translation into Propositional Logic

• If it rains, then the game will be cancelled.

• If the game is cancelled, then we clean house.

• Can we conclude?

– If it rains, then we clean house.

• p = it rains, q = game cancelled r = we clean house.

• If p then q. not p or q

• If q then r. not q or r

• if p then r. not p or r (resolution)

Concepts

Equivalence : two sentences are equivalent if they are true in same models or worlds.

Validity : a sentence is valid if it is true in all models. (tautology) e.g. P or not P.

– Sign: Members or not Members only.

– Berra: It’s not over till its over.

Satisfiability : a sentence is satisfied if it true in some model.

Validity != Provability

• Goldbach’s conjecture: Every even number

(>2) is the sum of 2 primes.

• This is either valid or not.

• It may not be provable.

• Godel: No axiomization of arithmetic will be complete, i.e. always valid statements that are not provable.

Natural Inference Rules

• Modus Ponens: p, p=>q |-- q.

– Sound

• Resolution example (sound)

– p or q, not p or r |-- q or r

• Abduction (unsound, but common)

– q, p=>q |-- p

– ground wet, rained => ground wet |-- rained

– medical diagnosis

Natural Inference Systems

• Typically have dozen of rules.

• Difficult for people to use.

• Expensive for computation.

– e.g. a |-- a or b

– a and b |-- a

• All known systems take exponential time in worse case. (co-np complete)

Full Propositional Resolution

• clause 1: x1 +x2+..xn+y (+ = or)

• clause 2: -y + z1 + z2 +… zm

• clauses contain complementary literals.

• x1 +.. xn +z1 +… zm

• y and not y are complementary literals.

• Theorem: If s1,…sn |= s then s1,…sn |-- s by resolution.

Refutation Completeness.

Factoring: (simplifying: x or x goes to x)

Horn Clauses = Prolog program

• Horn clauses have 1 positive literal.

• They have the form a,b,c,…=> d

• Modus Ponens is “Horn Clause” complete.

• Means: If KB is a set of horn clauses, and

KB => horn clause c, then KB -> c by modus ponens.

• Resolution is also “horn clause” complete since it yields modus ponens.

Conjunctive Normal Form

• To apply resolution we need to write what we know as a conjunct of disjuncts.

• Pg 215 contains the rules for doing this transformation.

• Basically you remove all  and => and move “not’s” inwards. Then you may need to apply distributive laws.

Proposition -> CNF

Goal: Proving R

• P

• (P&Q) =>R

• (S or T) => Q

• T

• Distributive laws:

• (-s&-t) or q 

(-s or q)&(-t or q).

• P

• -P or –Q or R

• -S or Q

• -T or Q

• T

• Remember: implicit adding.

Resolution Proof

• P (1)

• -P or –Q or R (2)

• -S or Q (3)

• -T or Q (4)

• T (5)

• ~R (6)

• -P or –Q : 7 by 2 & 6

• -Q : 8 by 7 & 1.

• -T : 9 by 8 & 4

• empty: by 9 and 5.

• Done: order only effects efficiency.

Resolution Algorithm

To prove s1, s2..sn |-- s

1. Put s1,s2,..sn & not s into cnf.

2. Resolve any 2 clauses that have complementary literals

3. If you get empty, done

4. Continue until set of clauses doesn’t grow.

Search can be expensive (exponential).

Forward and Backward Reasoning

Prolog only allows Horn clauses.

• if a, b, c then d => not a or not b or not c or d

• Prolog writes this:

– d :- a, b, c.

• Prolog thinks: to prove d, set up subgoals a, b, c and prove/verify each subgoal.

Forward Reasoning

• From facts to conclusions

• Given s1: p, s2: q, s3: p&q=>r

• Rewrite in clausal form: s3 = (-p+-q+r)

• s1 resolve with s3 = -q+r (s4)

• s2 resolve with s4 = r

• Generally used for processing sensory information.

Backwards Reasoning: what prolog does

• From Negative of Goal to data

• Given s1: p, s2: q, s3: p&q=>r

• Goal: s4 = r

• Rewrite in clausal form: s3 = (-p+-q+r)

• Resolve s4 with s3 = -p +-q (s5)

• Resolve s5 with s2 = -p (s6)

• Resolve s6 with s1 = empty. Eureka r is true.

What can’t we say?

• Quantification: every student has a father.

• Relations: If X is married to Y, then Y is married to X.

• Probability: There is an 80% chance of rain.

• Combine Evidence: This car is better than that one because…

• Uncertainty: Maybe John is playing golf.

• Changing world: actions

Download