p q ~p p and q p or q p implies q p equiv q T T F T T T T T F F F T F F F T T F T T F F F T F F T T

Propositional logic Propositions: p: the sky is blue p q ~p T T F F T F T F F F T T p and q p or q T F F F T T T F q: it is raining p implie...
Author: Dylan Craig
17 downloads 5 Views 127KB Size
Propositional logic Propositions: p: the sky is blue p

q

~p

T T F F

T F T F

F F T T

p and q

p or q

T F F F

T T T F

q: it is raining p implies q p equiv q T F T T

T F F T

A proposition can take one of two (True or False) truth values. Logical operators: negation (not), and (conjunction), (inclusive) or (disjunction), implication, equivalence, (exclusive) or, many others.

Logical equivalences

T and x = x F or x = x x and x = x x or x = x x and (y or z) = (x and y) or (x and z) x or (y and z) = (x or y) and (x or z) ~~x=x ~ (x or y) = ~x and ~y ~(x and y) = ~x or ~y x implies y = ~x or y x equiv y = (x implies y) and (y implies x)

There are 16 propositional logic operators: p T T F F

q T F T F

1 T T T T

2 T T T F

3 T T F T

4 T T F F

5 T F T T

6 T F T F

7 T F F T

8 9 T F F T F T F T

10 F T T F

11 F T F T

12 F T F F

13 F F T T

14 F F T F

15 F F F T

16 F F F F

Question: what is the minimal set of logical operators required to represent all of them? Candidates: Disjunction, Conjunction, negation? Are these sufficient to represent all operators? (yes, see later discussion of CNF and DNF). Do we need all of them? (no) (x and y) = ~(~x or ~y) – that is, and can be expressed as or and ~, so or and ~ are sufficient minimal set (x or y) = ~(~x and ~y) – that is, or can be expressed as and and ~, so and and ~ are sufficient minimal set A smaller minimal set is nand : p nand q = ~(p and q) and another minimal set is nor: p nor q = ~(p or q) Show that each of the following is a minimal set of operators: {and, ~}, {or, ~}, {nand}, {nor}, {à, ~}, and that {~, ßà} is not a minimal set.

Logical equivalences can be verified using truth tables: x equiv y = (x implies y) and (y implies x) x y xày yàx T T F F

T F T F

T F T T

T T F T

(xày) and (y à x)

x ßà y

T F F T

T F F T

Columns are identical

Using equivalences to simplify propositional formulas (e.g., reduce the number literals or the number of terms, etc.)

p or (~p and q) = (p or ~p) and (p or q) = T and (p or q) = p or q (p and q) or (~p and r) or (q and r) = (p and q) or (~p and r) or ((q and r) and T) = (p and q) or (~p and r) or ((q and r) and (p or ~p)) = (p and q) or (~p and r) or ((q and r) and p) or ((q and r) and ~p) =… = ((p and q) and (T or r)) or ((~p and r) and (T or q)) =… = (p and q) or (~p and r)

A propositional formula or sentence is satisfiable iff there is at least one assignment of truth values to its propositions/literals that makes the sentence true. ((p and q) or (~p implies q)) and p p

q

x p and q

T T F F

T F T F

T F F F

~p

y ~p implies q

x or y

F F T T

T T T F

T T T F

(x or y) and p T T F F

At least on row is T

A propositional sentence is unsatisfiable (a contradiction) if no assignment of truth values to the propositions make the sentence true. ~ (((p or q) and ~q) implies p)) is unsatisfiable p

q

p or q

~q

T T F F

T F T F

T T T F

F T F T

x y ((p or q) and ~q) x à p F T F F

T T T T

((p or q) and ~q) implies p is valid (a tautology)

~y F F F F

Inference rules Modus ponens: x à y, x |- y Whenever both x and xày are T, y is also T x T T F F

y T F T F

xà y T F T T

x and xày T Modus ponens is sound F F F

Modus tolens: x à y, ~y |- ~x

Modus tolens is sound

Proof: Suppose that we are given the following axioms: p r pà q

(we can interpret this as (p and r and (p implies q))

p

Prove (q and r): 1. p, pàq |- q 2. r, q |- q and r

(modus ponens) (and-introduction)

pàq

r

q q and r

There are some things that are true that we may not be able to prove with modus ponens (for example): modus ponens is not complete.

Consider two axioms: xày, yàz . Prove xàz x

y

z

xày

yàz

T T T T F F F F

T T F F T T F F

T F T F T F T F

T T F F T T T T

T F T T T F T T

xàz T F T F T T T T

Can we prove this with modus ponens (along with and-introduction, modus tolens, equivalences, etc.)? Modus ponens in not complete (that is we cannot prove everything that logically follows from the axioms with modus ponens alone.)

Resolution x or y, ~y or z |- x or z

(x and/or z may by NULL)

If y=T then z; if y=F then x Resolution subsumes modus tolens and modus ponens and some inference rules. Resolution is sound. Modus ponens can be reexpressed (remember xày = ~x or y): xày, x |- y

è ~x or y, x |- y (resolve ~x and x)

Modus Tolens can be reexpressed: xày, ~y |- ~x è ~x or y, ~y |- ~x (resolve y and ~y)

Proof by resolution: Convert KB into clause form (and break into clauses) e.g., convert ~(pàq) or (r à p) a. Eliminate implication signs by using equivalent or expression ~(pàq) or (rà p) = ~(~p or q) or (~r or p) b. push negations in and eliminate ~(~p or q) or (~r or p) = (~~p and ~q) or (~r or p) = (p and ~q) or (~r or p) c. Convert to CNF by using associate and distributive laws (p and ~q) or (~r or p) = (p or ~r or p) and (~q or ~r or p) = (p or ~r) and (~q or ~r or p) d. Write as a list (conjunction) of clauses: (p or ~r), (~q or ~r or p)

A proof by resolution: Given axioms: p (p and q) à r (s or t) à q

axioms in clause form: p ~p or ~q or r ~s or q ~t or q t

t

Prove r using resolution only: p

~p or ~q or r

~t or q

~q or r resolvants (theorems)

~t or r r

t

Axioms used in proof

Axioms(KB): ~s or p Prove: p and (q or r)

~u or s

u

~w or r

w

We cannot prove with resolution alone without refutation, since we have no way of introducing q, though we can make use use of resolution and other inference rules to show that that it must be true. p must be true: ~u or s

u

~s or p r must be true: ~w or r

s

w

r p

so (q or r) is true by the inference rule of or-introduction so p and (q or r) is true by inference rule of and-introduction

Axioms(KB): ~s or p ~u or s u ~w or r w Prove: p and (q or r) (prove with resolution alone under refutation) Negate (p and (q or r)) and convert to clause form: ~(p and (q or r)) = ~p or ~(q or r) = ~p or (~q and ~r) = (~p or ~q) and (~p or ~r) two clauses: (~p or ~q), (~p or ~r) ~w or r ~p or ~r

~s or p

~u or s

u

w

~w or ~p

Is there a simpler proof?

~w or ~s ~w or ~u ~w {} Contradiction

Axioms = {~s or p, ~u or s, u, ~w or r, w} NegatedSentence = {~p or ~q, ~p or ~r } Search for a resolution-refutation proof {~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants

(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)

Axioms = {~s or p, ~u or s, u, ~w or r, w} NegatedSentence = {~p or ~q, ~p or ~r } Search for a resolution-refutation proof {~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants

(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)

(p or ~s or ~u) (p or ~u or s) p … (p or ~s) (p or ~u or ~s or ~w or r) …. ~r ……………..

Axioms = {~s or p, ~u or s, u, ~w or r, w} NegatedSentence = {~p or ~q, ~p or ~r } Search for a resolution-refutation proof {~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants

(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)

(p or ~s or ~u) (p or ~u or s) p … (p or ~s) (p or ~u or ~s or ~w or r) …. ~r ……………..

(p or ~s or ~u) ……. (p or ~u) …………………………………………… ~w ……………..

Axioms = {~s or p, ~u or s, u, ~w or r, w} NegatedSentence = {~p or ~q, ~p or ~r } Search for a resolution-refutation proof {~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants

(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)

(p or ~s or ~u) (p or ~u or s) p … (p or ~s) (p or ~u or ~s or ~w or r) …. ~r ……………..

(p or ~s or ~u) ……. (p or ~u) …………………………………………… ~w ……………..

NULL (Contradiction)

Breadth-first search: start with 0-level resolvants, I = -1 do I=I+1 Initialize I+1 level resolvants for each I-level resolvant, R if R is contradiction then exit (proposition true) for each other J-level resolvant (J