0% found this document useful (0 votes)
35 views36 pages

2-Propositional Logic

The document covers propositional logic including syntax, semantics, interpretations, satisfiability, validity, and normal forms. It discusses constructing truth tables and a procedure for deciding satisfiability of formulas in propositional logic.

Uploaded by

facenord.sud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views36 pages

2-Propositional Logic

The document covers propositional logic including syntax, semantics, interpretations, satisfiability, validity, and normal forms. It discusses constructing truth tables and a procedure for deciding satisfiability of formulas in propositional logic.

Uploaded by

facenord.sud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

IN.

6011 Formal Methods

Prof. Ulrich Ultes-Nitsche

Department of Informatics

BSc course – Lecture on Propositional Logic

University of Fribourg
I N F O R M AT I C S
Why Study Propositional Logic?

When looking at elementary software verification, we applied logic.

Up to now we have evaluated the truth of a formula by ourselves.

It would be very handy, if our computer could do this job.

To teach our computer evaluate logical formulas, we first must


understand the “mechanics” of reasoning in logic.

University of Fribourg
I N F O R M AT I C S
Syntax of Propositional Logic

A formula in propositional logic can be constructed as follows:


I the truth values ⊥ (false) and > (true) as well as
propositional variables are formulas of propositional logic

I if F and G are formulas of propositional logic, then so are:


I (F )
I ¬F
I F ∧G
I F ∨G
I F →G
I F ↔G

If P is a variable, then P and ¬P are called literals.

University of Fribourg
I N F O R M AT I C S
Interpretations of Propositional Variables

An interpretation I is a truth-value assignment to propositional


variables P, Q, . . .. For example:

I : {P 7→ true, Q 7→ false, . . .}

The truth value of variable P under interpretation I is denoted by


I [P]. For the example interpretation we have

I [P] = true, I [Q] = false, . . .

University of Fribourg
I N F O R M AT I C S
Semantics of Propositional Variables (1)

For an interpretation I we write

I |= F

if and only if propositional formula F is true under interpretation I .

We have (P being a propositional variable):


I I |= >
I I 6|= ⊥
I I |= P if and only if I [P] = true
I I 6|= P if and only if I [P] = false

University of Fribourg
I N F O R M AT I C S
Semantics of Propositional Variables (2)

We have further (F and G being propositional formulas):


I I |= (F ) if and only if I |= F
I I |= ¬F if and only if I 6|= F
I I |= F ∧ G if and only if I |= F and I |= G
I I |= F ∨ G if and only if I |= F or I |= G (or both)
I I |= F → G if and only if I 6|= F or I |= G (or both)
I I |= F ↔ G if and only if I |= F → G and I |= G → F

University of Fribourg
I N F O R M AT I C S
Proof Rules (1)

I |= ¬F I |6 = ¬F
I 6|= F I |= F

I |= F ∧ G I 6|= F ∧ G
I |= F I 6|= F | I 6|= G
I |= G

I |= F ∨ G I 6|= F ∨ G
I |= F | I |= G I 6|= F
I 6|= G

University of Fribourg
I N F O R M AT I C S
Proof Rules (2)

I |= F → G I 6|= F → G
I 6|= F | I |= G I |= F
I 6|= G

I |= F ↔ G I 6|= F ↔ G
I |= F ∧ G | I 6|= F ∨ G I |= ¬F ∧ G | I |= F ∧ ¬G

I |= F
I 6|= F
I |= ⊥

University of Fribourg
I N F O R M AT I C S
Satisfiability and Validity

A propositional formula F is satisfiable if and only if there exists an


interpretation I such that I |= F .

A propositional formula F is valid if and only if for all


interpretations I we have I |= F .

University of Fribourg
I N F O R M AT I C S
The Duality of Satisfiability and Validity

F is valid if and only if ¬F is not satisfiable.

F is satisfiable if and only if ¬F is not valid.

University of Fribourg
I N F O R M AT I C S
An example

Prove the validity of

(P ∧ (P → Q)) → Q

University of Fribourg
I N F O R M AT I C S
Equivalence and Implication of Formulas

Two formulas F and G are equivalent (written: “F ⇔ G ”) if and


only if F ↔ G is a valid formula.

Formula F implies formula G (written: “F ⇒ G ”) if and only if


F → G is a valid formula.

University of Fribourg
I N F O R M AT I C S
An example

Does
P ∧ (P → Q)
imply
Q
?

University of Fribourg
I N F O R M AT I C S
Substitutions (1)

A substitution σ is a mapping from formulas to formulas:

{F1 7→ G1 , F2 7→ G2 , . . . , Fn 7→ Gn }

domain(σ) = {F1 , F2 , . . . , Fn } is σ’s domain.

range(σ) = {G1 , G2 , . . . , Gn } is σ’s range.

If σ’s domain consists solely of single variables, σ is called a


variable substitution.

University of Fribourg
I N F O R M AT I C S
Substitutions (2)

If we apply σ = {F1 7→ G1 , F2 7→ G2 , . . . , Fn 7→ Gn } to formula F ,


written as F σ, then each occurrence of sub-formula Fi in F is
replaced by Gi .

If F contains sub-formulas Fi and Fj , and Fj is larger than Fi , then


we substitute Fj first.

University of Fribourg
I N F O R M AT I C S
Substitutions (3)

Let σ = {F1 7→ G1 , F2 7→ G2 , . . . , Fn 7→ Gn } be a substitution.

If σ is a variable substitution and F is valid, then F σ is valid.

If Fi ⇔ Gi for all i, then F ⇔ F σ.

University of Fribourg
I N F O R M AT I C S
An example

Prove the validity of


((P ↔ ¬R) ∧ ((P ↔ ¬R) → (P ↔ ¬(R ∧ ¬Q)))) → (P ↔ ¬(R ∧ ¬Q))

University of Fribourg
I N F O R M AT I C S
Negation Normal Form

A formula F is in negation normal-form, if and only if negations


“¬” appear only directly in front of variables, i.e. they appear only
in literals, and the formulas contain only disjunctions and
conjunctions.

We can use the following equivalences:

¬¬F ⇔ F
¬> ⇔ ⊥
¬⊥ ⇔ >
¬(F ∧ G) ⇔ (¬F ∨ ¬G )
¬(F ∨ G) ⇔ (¬F ∧ ¬G )
F →G ⇔ ¬F ∨ G
F ↔G ⇔ (F → G ) ∧ (G → F )

University of Fribourg
I N F O R M AT I C S
Disjunctive Normal Form

A formula F is in disjunctive normal-form, if and only if it is in


negation normal-form and it is the disjunction (OR) of
conjunctions (AND).
WV
That means: F = Lij where the Lij are literals.
i j

We can use the following additional equivalences:

(F ∨ G ) ∧ H ⇔ (F ∧ H) ∨ (G ∧ H)
F ∧ (G ∨ H) ⇔ (F ∧ G ) ∨ (F ∧ H)

University of Fribourg
I N F O R M AT I C S
Conjunctive Normal Form

A formula F is in conjunctive normal-form, if and only if it is in


negation normal-form and it is the conjunction (AND) of
disjunctions (OR).
VW
That means: F = ( Lij ) where the Lij are literals.
i j

We can use the following additional equivalences:

(F ∧ G ) ∨ H ⇔ (F ∨ H) ∧ (G ∨ H)
F ∨ (G ∧ H) ⇔ (F ∨ G ) ∧ (F ∨ H)

University of Fribourg
I N F O R M AT I C S
An example

Turn
(P ∧ (P → Q)) → Q
into CNF.

University of Fribourg
I N F O R M AT I C S
Deciding Satisfiability (1)

If formula F contains n propositional variables, then we can try out


all value assignments to the variables to see whether or not F is
satisfiable.

We can construct the truth table for the formula.

The table will have size O(2n ). However, we can check this more
(space) efficiently.

University of Fribourg
I N F O R M AT I C S
Deciding Satisfiability (2)

Here is the space-efficient algorithm (constructing truth-table rows


on the fly):

SAT(F ) {
if (F = >) return true;
elsif (F = ⊥) return false;
else{
P = choose vars(F );
return( SAT(F {P 7→ >}) ∨ SAT(F {P 7→ ⊥}) );
}
}

University of Fribourg
I N F O R M AT I C S
An example

Show that
(P ∧ (P → Q)) → Q
is satisfiable and that it is valid by using the procedure SAT of the
previous slide.

University of Fribourg
I N F O R M AT I C S
Resolution (1)

The resolution method aims again at deciding satisfiability.

It requires that the formula is in conjunctive normal-form (CNF).

What is the result of turning


n
_
(Pi ∧ Qi )
i=1

into CNF?

University of Fribourg
I N F O R M AT I C S
Equisatisfiability (1)

Instead of turning the formula F into an equivalent formula in


CNF, we can simply turn it into an equisatisfiable formula F 0 in
CNF.

An equisatisfiable formula F 0 to F is satisfiable if and only if F is


satisfiable. (This is not equivalence!!!)

If L1 and L2 are literals and P is a variable, then L1 ∨ L2 and


(L1 ∨ P) ∧ (L2 ∨ ¬P) are equisatisfiable.

University of Fribourg
I N F O R M AT I C S
Equisatisfiability (2)

We define propositional variables rep(F ) that represent formulas F :

I rep(>) = >
I rep(⊥) = ⊥
I rep(P) = P for variables P
I rep(F ) = PF for all other formulas F

University of Fribourg
I N F O R M AT I C S
Equisatisfiability (3)

We define formulas enc(F ) that make sure that rep(F ) represents


formulas F :
I enc(>) = >
I enc(⊥) = >
I enc(P) = >
I enc(¬F ) = (¬P¬F ∨ ¬rep(F )) ∧ (P¬F ∨ rep(F ))
I enc(F ∧G ) = (¬PF ∧G ∨rep(F ))∧(¬PF ∧G ∨rep(G ))∧(PF ∧G ∨¬rep(F )∨¬rep(G ))
I enc(F ∨G ) = (PF ∨G ∨¬rep(F ))∧(PF ∨G ∨¬rep(G ))∧(¬PF ∨G ∨rep(F )∨rep(G ))
I enc(F → G ) =
(PF →G ∨ rep(F )) ∧ (PF →G ∨ ¬rep(G )) ∧ (¬PF →G ∨ ¬rep(F ) ∨ rep(G ))
I enc(F ↔ G ) =
(¬PF ↔G ∨ ¬rep(F ) ∨ rep(G )) ∧ (¬PF ↔G ∨ rep(F ) ∨ ¬rep(G ))∧
(PF ↔G ∨ rep(F ) ∨ rep(G )) ∧ (PF ↔G ∨ ¬rep(F ) ∨ ¬rep(G ))

University of Fribourg
I N F O R M AT I C S
Equisatisfiability (4)

Finally, we replace formula F with the equisatisfiable formula:


^
rep(F ) ∧ enc(G )
G ∈subformulas(F )

where subformulas(F ) is the set of all sub-formulas of F including


F itself.

University of Fribourg
I N F O R M AT I C S
Resolution (2)

Let F be a formula in CNF, i.e. it is the conjunction of clauses


(disjunction of literals). Let C1 and C2 be two clauses in F both
containing, but disagreeing on variable P.

Assume (without loss of generality) that C1 contains P in its


positive and C2 contains P in its negative form (we write: “C1 [P]
and C2 [¬P]”).

Then we get the rule (resolution step):

C1 C2
C1 {P 7→ ⊥} ∨ C2 {¬P →
7 ⊥}

(“C1 {P 7→ ⊥} ∨ C2 {¬P 7→ ⊥}” is the resolvent of C1 and C2 .)

University of Fribourg
I N F O R M AT I C S
Resolution (3)

As long as we can, we apply the resolution step.

In case we ever derive ⊥ in a resolution step, F is not satisfiable.

Otherwise, if no more resolution steps can be executed, F is


satisfiable.

University of Fribourg
I N F O R M AT I C S
An example

Show that
P ∧ (P → Q) → Q
is satisfiable by using resolution.

University of Fribourg
I N F O R M AT I C S
Boolean Constraint Propagation (BCP)

BCP on formula F uses unit resolution (resolution against literals).

Let P be a propositional variable. We get the rules:

P C [¬P] ¬P C [P]
C {¬P 7→ ⊥} C {P 7→ ⊥}

University of Fribourg
I N F O R M AT I C S
Davis Putnam Logemann Loveland

Here is a satisfiability algorithm (DPLL-algorithm) used in practice:

DPLL(F ) {
F 0 = BCP(F );
if (F 0 = >) return true;
elsif (F 0 = ⊥) return false;
else {
P = choose vars(F 0 );
return(DPLL(F 0 {P 7→ >}) ∨ DPLL(F 0 {P 7→ ⊥}));
}
}

University of Fribourg
I N F O R M AT I C S
An example

Show that
P ∧ (P → Q) → Q
is satisfiable by using DPLL.

University of Fribourg
I N F O R M AT I C S
That’s all

Do you have questions?

University of Fribourg
I N F O R M AT I C S

You might also like