Lecture Slides for MAT-60556 PART II: Propositional logic, - - PowerPoint PPT Presentation

lecture slides for mat 60556 part ii propositional logic
SMART_READER_LITE
LIVE PREVIEW

Lecture Slides for MAT-60556 PART II: Propositional logic, - - PowerPoint PPT Presentation

Lecture Slides for MAT-60556 PART II: Propositional logic, deduction and other topics Henri Hansen September 11, 2014 1 Questions to ponder & review What do completeness and soundness mean in logic? Is it correct to say that a


slide-1
SLIDE 1

Lecture Slides for MAT-60556 PART II: Propositional logic, deduction and other topics

Henri Hansen September 11, 2014

1

slide-2
SLIDE 2

Questions to ponder & review

  • What do completeness and soundness mean in logic?
  • Is it correct to say that a valid propositional formula

is uninformative?

  • Is it correct to say that an unsatisfiable formula is

trivial?

2

slide-3
SLIDE 3

Deductive proofs?

  • Let U = {A1, . . . , An}. We have already shown that

U | = A if and only if A1 ∧ · · · ∧ An → A is valid

  • Tableaux method could be used to show this valid-

ity, but what if the set of axioms is infinite?

  • A decision procedure may not give any information

about the relationship between axioms and theo- rems

  • We may be interested in the intermediate steps

(lemmas)

3

slide-4
SLIDE 4

Deductive systems

  • A deductive system is a set of formulas called ax-

ioms and a set of rules of inference

  • Aproof in a deductive system is a sequence of for-

mulas, A1, . . . , An such that for each i, Ai is either an axiom or inferred from a subset of A1, . . . Ai−1.

  • Given a proof S = A1, . . . , An, An is a theorem and

S is a proof of An.

  • If a formula A has a proof, we say A is provable in

the given system, denoted ⊢ A

4

slide-5
SLIDE 5

Genzen System G

  • An axiom of G is a set of literals U that contains a

complementary pair

  • Rules of inference are similar to the α and β-rules
  • f tableux, but they are ”‘reversed”’ (i.e., α in G is

a β in tableaux, and vice versa)

  • 1. If {α1, α2} ⊆ U1, then (U1 \{α1, α2})∪{α} can be

inferred

  • 2. If {β1} ⊆ U1 and {β2} ⊆ U2 , then we can be infer

(U1 \ {β1} ∪ U2 \ {β2}) ∪ {β}

5

slide-6
SLIDE 6

Genzen System (cont.)

  • The proofs in G can be thought of as ”upside down

tableaux”

  • I.e., a closed tableaux that shows φ is UNSAT cor-

responds to a proof of ¬φ in G

  • 1. axioms correspond to closed leaves (with literals

negated)

  • 2. Every node has a formula that is a negation of

the corresponding formula in the tableaux

  • 3. The ”‘theorem”’ is the negation of the root of

the tableau

6

slide-7
SLIDE 7

Hilbert System H

  • The axioms of H (with the letters denoting arbitrary

formulas) are

  • 1. ⊢ (A → (B → A))
  • 2. ⊢ (A → (B → C)) → ((A → B) → (A → C))
  • 3. ⊢ (¬B → ¬A) → (A → B)
  • The rule of inference of H is modus ponens
  • 1. (⊢ A, ⊢ A → B) ⇒ ⊢ B

7

slide-8
SLIDE 8

Hilbert System (cont.)

  • Proofs in H tend to be complicated, so we may wish

to have additional rules, called derived rules

  • An example of a derived rule is the deduction rule,

which says that (U ∪ {A} ⊢ B) ⇒ U ⊢ (A → B)

  • This is proven by induction over the length of the

proof for U ∪ {A} ⊢ B, to show that the proof can always be transformed into a proof of U ⊢ (A → B)

  • Other important derived rules in H can be found in

the book, such as the contrapositive rule, transitiv- ity rule, etc.

8

slide-9
SLIDE 9

Hilbert System (cont. II)

  • H is sound and complete, i.e., ⊢ A if and only if

| = A

  • Soundness (only if) is proven by structural induc-

tion, i.e., by showing that modus ponens preserves validity

  • Completeness is proven by transforming a closed

tableau for ¬A first into a proof of A in G and then showing that every proof in G can be transformed into a proof in H

9

slide-10
SLIDE 10

Proof of A → A in H

  • 1. ⊢ (A → ((A → A) → A)) → ((A → (A → A) → (A →

A)) (axiom 2)

  • 2. ⊢ A → ((A → A) → A) (axiom 1)
  • 3. ⊢ (A → (A → A)) → (A → A) (MP 1, 2)
  • 4. ⊢ A → (A → A) (axiom 1)
  • 5. ⊢ A → A (MP 3, 4)

10

slide-11
SLIDE 11

Proving derived rules for H

  • Let us prove the deduction rule, i.e.:

(U ∪ {A} ⊢ B) ⇒ U ⊢ (A → B) – This is done on the induction on the length of (U ∪ {A} ⊢ B) (which we call ”‘the proof”’) – For n = 1, B is proved in one step, so B must be an element of U ∪ {A}, an axiom, or a previously proved theorem – If B = A then ⊢ A → A by the previous theorem – Otherwise U ⊢ B is an axiom or theorem, U ⊢ B → (A → B) by axiom 1, and U ⊢ A → B by modus ponens

11

slide-12
SLIDE 12
  • if n > 1, the last step of the proof is either one-step

inference of B or the use of modus ponens. In the first case, it is equivalent to n = 1

  • If MP is used, there must be a formula C such that

U ∪ {A} ⊢ C and U ∪ {A} ⊢ C → B have been proven before B

  • By inductive hypothesis, U ⊢ A → C and U ⊢ A →

(C → B).

  • We can then construct a proof of U ⊢ A → B:
  • 1. U ⊢ A → C (inductive hypothesis)
slide-13
SLIDE 13
  • 2. U ⊢ A → (C → B) (inductive hypothesis)
  • 3. U ⊢ (A → (C → B)) → ((A → C) → (A → B))

(axiom 2)

  • 4. U ⊢ (A → C) → (A → B) (MP 2, 3)
  • 5. U ⊢ A → B (MP 1, 4)
slide-14
SLIDE 14

Consistency

  • A set of formulas U is inconsistent if there exists a

formula A such that U ⊢ A and U ⊢ ¬A

  • U is inconsistent if and only if U ⊢ A for every for-

mula A

  • U is consistent if and only if there exists some for-

mula A such that U ⊢ A

  • U ⊢ A if and only if U ∪ {¬A} is inconsistent

12

slide-15
SLIDE 15

Strong completenes and Compactness

  • A set of formulas S = {A1, . . .} is unsatisfiable if and
  • nly if some tableau for S closes
  • Let U be a countable set of formulas and A an

arbitrary formula. If U | = A, then U ⊢ A

  • If S is a countable set of formulas such that every

finite subset of S is satisfiable, then S is satisfiable

  • These (infinitary) properties of propositional logic

will become important with first order logic

13

slide-16
SLIDE 16

Conjuctive normal form

  • A formula is in conjunctive normal form iff it is a

conjunction of a disjunction of literals.

  • For example (p ∨ ¬q ∨ r) ∧ (¬p ∨ q ∨ r) is CNF
  • Every formula in propositional logic can be given

in CNF. This can be proven by giving rules that transform other operators to ∧ and ∨, and then showing that these can be arranged into CNF

  • Conjunctive normal form is perhaps the most com-

mon normal form; others exist

14

slide-17
SLIDE 17

Clausal form

  • 1. A clause is a set of literals, considered as a disjunc-
  • tion. A unit clause is a single literal, and the empty

clause is the empty set of literals, denoted . If the clause contains a literal and its negation it is trivial

  • 2. A formula in clausal form is given as a set of clauses,

and the formula is considered to be the conjunction

  • f its clauses, and the empty set of clauses is de-

noted ∅

  • Every formula in propositional logic can be trans-

formed into clausal form (like CNF)

15

slide-18
SLIDE 18

Clausal form notation

  • We denote a clause as a concatenation of literals

so that an overbar denotes negation. For example p¯ qr is a clause for (p ∨ ¬q ∨ r)

  • The clausal form for a formula is given as a set of

such clauses. For instance {p¯ qr, ¯ pqr}

  • if l is a literal, we denote its complement with lc,

i.e., if l = p then lc = ¯ p and vice versa

  • we generalize the concept of interpretation to clauses

in the natural way

16

slide-19
SLIDE 19

Resolution

  • Resolution is a refutation procedure used to check

if a clausal formula is unsatisfiable

  • The resolution rule: Let C1 and C2 be clauses such

that l ∈ C1 and lc ∈ C2. We say that C1 and C2 are clashing clauses, and they clash on l, lc.

  • The resolvent of clauses C1 and C2 that clash on l

amd lc is the clause (C1 \ {l}) ∪ (C2 \ {lc})

  • If two clauses clash on more than one literal, their

resolvent is a trivial clause!

17

slide-20
SLIDE 20

Resolution (cont.)

  • The resolvent is satisfiable iff the parent clauses are

satisfiable

  • Resolution algorithm for a set of clauses S:
  • 1. Find clashing clauses {C1, C2} ⊆ S and compute

their resolvent C

  • 2. Discard C if trivial, otherwise add it to S (DO

not remove C1 and C2!!)

  • 3. Terminate if C = or no more clashing clauses,
  • therwise goto 1

18

slide-21
SLIDE 21

Example of resolution

  • Consider the formula

(p ∨ q) ∧ (p ∨ r) ∧ (q ∨ r) ∧ (¬p ∨ q) ∧ (¬r ∨ ¬p) ∧ (r ∨ ¬p)

  • In clausal form, this is {pq, pr, qr, ¯

pq, ¯ r¯ p, ¯ pr}

  • Resolution:
  • 1. pq and ¯

pq clash on p, the resolvent is q: {pq, pr, qr, ¯ pq, ¯ r¯ p, ¯ pr, q}

19

slide-22
SLIDE 22
  • 2. q and ¯

p¯ q resolve into p, {pq, pr, qr, ¯ pq, ¯ r¯ p, ¯ pr, q, p}

  • 3. p and ¯

pr resolve into r, {pq, pr, qr, ¯ pq, ¯ r¯ p, ¯ pr, q, p, r}

  • 4. r and ¯

r¯ p resolve into ¯ p, {pq, pr, qr, ¯ pq, ¯ r¯ p, ¯ pr, q, p, r, ¯ p}

  • 5. p and ¯

p resolve into , so the formula is unsat.

slide-23
SLIDE 23

Resolution (cont. II)

  • We can think of the resolution algorithm as pro-

ducing an “upside down” tree: The root is the last resolvent

  • Given two clashing clauses resolved, they are the

children and the resolvent is the parent

  • The derivation of from a set of clauses proves

that the set is not satisfiable

  • Soundness and completeness are a bit hard to prove

20

slide-24
SLIDE 24

Binary Decision Diagrams

  • We make the distinction here: a formula is a tree,

but the semantics (i.e., the meaning) of the formula is a boolean function

  • Binary decision diagram, or BDD, is data structure

for representing the semantics of a formula

  • A formula is represented by a directed graph and an

algorithm is used for reducing the graph

  • A formula is valid iff the BDD represents trivial T

and unsatisfiable iff the BDD represents trivial F

21

slide-25
SLIDE 25

BDDs (cont.)

  • A BDD for a formula A ∈ F is a directed acyclic

graph.

  • 1. Each leaf of the graph is labelled with T or F
  • 2. Each interior node is labelled with a proposition

symbol

  • 3. Each interior node has two outgoing edges: true-

edge and false-edge

  • 4. No proposition appears more than once in a branch

from the root to a leaf

22

slide-26
SLIDE 26

BDD interpretation

  • A BDD represents a boolean function
  • Given an intrpretation I, we choose the appropriate
  • utgoing edge from each interior node
  • When we reach a leaf, we have the value of the

boolean function

  • In general, the BDD can be very large (2n nodes

for n propositions)

  • In parctice, BDDs can often be made smaller

23

slide-27
SLIDE 27

BDD reduction

  • BDDs can be reduced because some interior nodes

are redundant, by repeating the following steps

  • 1. Only two leaves are needed (one for T and one

for F)

  • 2. If both outgoing edges from an interior node p

point to the same node p′, then p can be removed and all its incoming edges made to point to p′

  • 3. if two nodes with the same label are roots of

identical sub-BDDs, one can be removed and all its incoming edges made to point to the one that was left

24

slide-28
SLIDE 28

Ordered BDDs

  • The definition of BDDs does not impose any restric-

tion on the representation order of interior nodes

  • Let O = {O1

A, . . . , On A} where for each i, Oi A is an

  • rdered sequence of elements of PA
  • O is compatible with PA if for all i = j, there are

no atoms p and p′ so that p appears before p′ in Oi

A

and vice versa in Oj

A

  • A BDD is an ordered BDD (OBDD) if the set of

sequences from its root to the leaves are compatible

25

slide-29
SLIDE 29

Ordered BDDs (cont.)

  • Given two formulas A and B that have the same

propositions, we have

  • 1. A is satisfiable iff T is reachable in its reduced

OBDD

  • 2. A is falsifiable iff F is reachable in its reduced

OBDD

  • 3. A is valid iff its reduced OBDD contains only the

single node T

  • 4. If the reduced OBDDs of A and B are identical,

A ≡ B

26

slide-30
SLIDE 30

Ordered BDDs (cont. II)

  • OBDD size for a given formula is sensitive to the
  • rdering:

(p1 ∧ p2) ∨ · · · ∨ (p2n−1, p2n) has 2n + 2 nodes for the ordering p1, . . . p2n, but 2n+1 nodes under the ordering p1, pn+1, p2, pn+2, . . . , pn, p2n

  • There are heuristics for choosing a good ordering
  • Unfortunately, there are formulas for which the re-

duced OBDD has at least 2cn nodes, for some c > 0

  • We will next look at how (O)BDDs can be com-

bined corresponding to logical operators

27

slide-31
SLIDE 31

Operators and BDDs

  • Given b1, a BDD for formula A1 and b2, a BDD for

formula A2, a compatible ordering for {PA1, PA2}, and an operator ◦, we construct a BDD for A1 ◦ A2 as follows

  • 1. If the BDDs are leaves w1 and w2, return a leaf

w1 ◦ w2

  • 2. If the roots of b1 and b2 have the same label p,

construct the BDD such that (a), the root is la- belled p; (b) the false (true) sub-tree is obtained by constructing b′

1 ◦b′ 2 where b′ i is the false (true)

sub-tree of bi

28

slide-32
SLIDE 32
  • 3. If the roots have different labels p1 and p2, such

that p1 < p2, then p1 becomes the root and the false (true) subtree is b′

1 ◦ b2 like before (and

symmetrically if p2 < p1, p2 becomes the root)

slide-33
SLIDE 33

Other Operations on BDDS

  • Restriction replaces an atom p in a formula with a

particular truth-value w; this is very easy to imple- ment on BDDS. Restriction is denoted A |p=w

  • Quantification replaces the formula A with either

∃pA ≡ (A |p=T ∨A |p=F) or ∀pA ≡ (A |p=T ∧A |p=F)

  • Quantification can be implemented by using restric-

tion and either ∨ or ∧

29

slide-34
SLIDE 34

SAT solvers

  • Deciding satisfiability (SAT) of a formula is a classic

NP-complete problem

  • There are, however, algorithms that have proven to

be practical even if they might sometimes be too slow

  • A computer program that searches for a model for

a given formula, is called a SAT solver.

  • We discuss some algorithms for SAT solving

30

slide-35
SLIDE 35

Operations on Clauses

  • Let S and S′ be sets of clauses. S ≈ S′ means that

S is satisfiable iff S′ is satisfiable

  • A pure literal in S is a literal l that appears in at

least one clause, but whose complement does not appear in any clause

  • Deleting all clauses from S that contain pure liter-

als, results in a formula S′ such that S ≈ S′

  • if l is a unit clause of S then deleting all clauses that

contain l and removing lc from the other clauses of S results in a formula S′ such that S ≈ S′

31

slide-36
SLIDE 36

Operations on Clauses (cont.)

  • Let C1 ⊆ C2 be two clauses.

The clause C1 sub- sumes the clause C2. If S contains both C1 and C2, then S ≈ S \ {C2}

  • Let U ⊆ P.

We denote with RU(S) the formula

  • btained from S by replacing every literal l, whose

proposition is in U, with lc. Then S ≈ RU(S)

  • These properties directly give operations that can

be used to manipulate a clausal form so that its satisfiability is easier to establish

32

slide-37
SLIDE 37

Davis-Putnam Algorithm

  • Let A be a formula in clausal form. We decide SAT

by the following procedure

  • 1. Eliminate unit clauses
  • 2. Delete clauses containing pure literal
  • 3. Only if the above two rules cannot be applied:

Eliminate some atom p by resolution: Perform all resolutions of clauses that clash on p and ¯ p

  • The process terminates when the empty clause is

produce (UNSAT) or when none of the above rules can be applied (SAT)

33

slide-38
SLIDE 38

DPLL Algorithm

  • Let A be a set of clauses and let I be a partial inter-

pretation for A. Given a clause C ∈ A, if νI(C) = T, I satisfies C and if νI(C) = F, we say C is a conflict clause for I

  • The DPLL algorithm recursively extends a partial

interpretation by adding an assignment of some atom not yet assigned. If there is a conflict clause, the algorithm backtracks and otherwise it uses the unit rules to simplify the formula

  • The algorithm is nondeterministic in the way it chooses

the assignment

34

slide-39
SLIDE 39
  • There are various heuristics that can be used to

improve the running time