formalizing propositional logic

66
Formalizing propositional logic Joris Roos University of Wisconsin-Madison Sommerakademie Leysin 2018 August 14, 2018 Joris Roos Propositional logic August 14, 2018 1 / 22

Upload: others

Post on 10-May-2022

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Formalizing propositional logic

Formalizing propositional logic

Joris Roos

University of Wisconsin-Madison

Sommerakademie Leysin 2018

August 14, 2018

Joris Roos Propositional logic August 14, 2018 1 / 22

Page 2: Formalizing propositional logic

Overview

1 Introduction

2 Syntax and semantics

3 Normal forms

Joris Roos Propositional logic August 14, 2018 2 / 22

Page 3: Formalizing propositional logic

Introduction

Consider a propositional formula

((A ∨ D)→ (D ∨ ¬B)) ∧ ¬(A← (B ∨ C ∧ D)

Is it satisfiable? (“SAT”)

Is it a tautology?

In principle, “trivially” decidable by truth tables.

Goal: Formalize the problem and program a computer to solve it (provablycorrectly and “efficiently”, if possible).

Joris Roos Propositional logic August 14, 2018 3 / 22

Page 4: Formalizing propositional logic

Introduction

Consider a propositional formula

((A ∨ D)→ (D ∨ ¬B)) ∧ ¬(A← (B ∨ C ∧ D)

Is it satisfiable? (“SAT”)

Is it a tautology?

In principle, “trivially” decidable by truth tables.

Goal: Formalize the problem and program a computer to solve it (provablycorrectly and “efficiently”, if possible).

Joris Roos Propositional logic August 14, 2018 3 / 22

Page 5: Formalizing propositional logic

Introduction

Consider a propositional formula

((A ∨ D)→ (D ∨ ¬B)) ∧ ¬(A← (B ∨ C ∧ D)

Is it satisfiable? (“SAT”)

Is it a tautology?

In principle, “trivially” decidable by truth tables.

Goal: Formalize the problem and program a computer to solve it (provablycorrectly and “efficiently”, if possible).

Joris Roos Propositional logic August 14, 2018 3 / 22

Page 6: Formalizing propositional logic

Introduction

Consider a propositional formula

((A ∨ D)→ (D ∨ ¬B)) ∧ ¬(A← (B ∨ C ∧ D)

Is it satisfiable? (“SAT”)

Is it a tautology?

In principle, “trivially” decidable by truth tables.

Goal: Formalize the problem and program a computer to solve it (provablycorrectly and “efficiently”, if possible).

Joris Roos Propositional logic August 14, 2018 3 / 22

Page 7: Formalizing propositional logic

Why?

Logic puzzles: knights and knaves and co.

Circuit design: circuits are propositional formulas!

Surprisingly many problems can be rephrased as SAT: e.g. primality

SAT is a computationally hard problem (NP-complete).

Classical first-order theorem provers rely on SAT algorithms

Joris Roos Propositional logic August 14, 2018 4 / 22

Page 8: Formalizing propositional logic

Why?

Logic puzzles: knights and knaves and co.

Circuit design: circuits are propositional formulas!

Surprisingly many problems can be rephrased as SAT: e.g. primality

SAT is a computationally hard problem (NP-complete).

Classical first-order theorem provers rely on SAT algorithms

Joris Roos Propositional logic August 14, 2018 4 / 22

Page 9: Formalizing propositional logic

Why?

Logic puzzles: knights and knaves and co.

Circuit design: circuits are propositional formulas!

Surprisingly many problems can be rephrased as SAT: e.g. primality

SAT is a computationally hard problem (NP-complete).

Classical first-order theorem provers rely on SAT algorithms

Joris Roos Propositional logic August 14, 2018 4 / 22

Page 10: Formalizing propositional logic

Why?

Logic puzzles: knights and knaves and co.

Circuit design: circuits are propositional formulas!

Surprisingly many problems can be rephrased as SAT: e.g. primality

SAT is a computationally hard problem (NP-complete).

Classical first-order theorem provers rely on SAT algorithms

Joris Roos Propositional logic August 14, 2018 4 / 22

Page 11: Formalizing propositional logic

Why?

Logic puzzles: knights and knaves and co.

Circuit design: circuits are propositional formulas!

Surprisingly many problems can be rephrased as SAT: e.g. primality

SAT is a computationally hard problem (NP-complete).

Classical first-order theorem provers rely on SAT algorithms

Joris Roos Propositional logic August 14, 2018 4 / 22

Page 12: Formalizing propositional logic

1 Introduction

2 Syntax and semantics

3 Normal forms

Joris Roos Propositional logic August 14, 2018 5 / 22

Page 13: Formalizing propositional logic

Syntax

A propositional formula is a string (i.e. a list of symbols from a certainalphabet).

Admissible symbols are:

Constants: > (true), ⊥ (false)

Atomic propositions/literals: P,Q,R, · · ·Logical operators: ¬,∧,∨Punctuation: brackets ( ) and ,

Definition

The set of propositional formulas is the smallest set P of strings such that

1 >,⊥,P,Q,R, · · · ∈ P.

2 If X ∈ P, then ¬X ∈ P.

3 If X ,Y ∈ P, then ∨(X ,Y ) ∈ P and ∧(X ,Y ) ∈ P.

Joris Roos Propositional logic August 14, 2018 6 / 22

Page 14: Formalizing propositional logic

Syntax

A propositional formula is a string (i.e. a list of symbols from a certainalphabet).Admissible symbols are:

Constants: > (true), ⊥ (false)

Atomic propositions/literals: P,Q,R, · · ·Logical operators: ¬,∧,∨Punctuation: brackets ( ) and ,

Definition

The set of propositional formulas is the smallest set P of strings such that

1 >,⊥,P,Q,R, · · · ∈ P.

2 If X ∈ P, then ¬X ∈ P.

3 If X ,Y ∈ P, then ∨(X ,Y ) ∈ P and ∧(X ,Y ) ∈ P.

Joris Roos Propositional logic August 14, 2018 6 / 22

Page 15: Formalizing propositional logic

Syntax

A propositional formula is a string (i.e. a list of symbols from a certainalphabet).Admissible symbols are:

Constants: > (true), ⊥ (false)

Atomic propositions/literals: P,Q,R, · · ·

Logical operators: ¬,∧,∨Punctuation: brackets ( ) and ,

Definition

The set of propositional formulas is the smallest set P of strings such that

1 >,⊥,P,Q,R, · · · ∈ P.

2 If X ∈ P, then ¬X ∈ P.

3 If X ,Y ∈ P, then ∨(X ,Y ) ∈ P and ∧(X ,Y ) ∈ P.

Joris Roos Propositional logic August 14, 2018 6 / 22

Page 16: Formalizing propositional logic

Syntax

A propositional formula is a string (i.e. a list of symbols from a certainalphabet).Admissible symbols are:

Constants: > (true), ⊥ (false)

Atomic propositions/literals: P,Q,R, · · ·Logical operators: ¬,∧,∨

Punctuation: brackets ( ) and ,

Definition

The set of propositional formulas is the smallest set P of strings such that

1 >,⊥,P,Q,R, · · · ∈ P.

2 If X ∈ P, then ¬X ∈ P.

3 If X ,Y ∈ P, then ∨(X ,Y ) ∈ P and ∧(X ,Y ) ∈ P.

Joris Roos Propositional logic August 14, 2018 6 / 22

Page 17: Formalizing propositional logic

Syntax

A propositional formula is a string (i.e. a list of symbols from a certainalphabet).Admissible symbols are:

Constants: > (true), ⊥ (false)

Atomic propositions/literals: P,Q,R, · · ·Logical operators: ¬,∧,∨Punctuation: brackets ( ) and ,

Definition

The set of propositional formulas is the smallest set P of strings such that

1 >,⊥,P,Q,R, · · · ∈ P.

2 If X ∈ P, then ¬X ∈ P.

3 If X ,Y ∈ P, then ∨(X ,Y ) ∈ P and ∧(X ,Y ) ∈ P.

Joris Roos Propositional logic August 14, 2018 6 / 22

Page 18: Formalizing propositional logic

Syntax

A propositional formula is a string (i.e. a list of symbols from a certainalphabet).Admissible symbols are:

Constants: > (true), ⊥ (false)

Atomic propositions/literals: P,Q,R, · · ·Logical operators: ¬,∧,∨Punctuation: brackets ( ) and ,

Definition

The set of propositional formulas is the smallest set P of strings such that

1 >,⊥,P,Q,R, · · · ∈ P.

2 If X ∈ P, then ¬X ∈ P.

3 If X ,Y ∈ P, then ∨(X ,Y ) ∈ P and ∧(X ,Y ) ∈ P.

Joris Roos Propositional logic August 14, 2018 6 / 22

Page 19: Formalizing propositional logic

Syntax

A propositional formula is a string (i.e. a list of symbols from a certainalphabet).Admissible symbols are:

Constants: > (true), ⊥ (false)

Atomic propositions/literals: P,Q,R, · · ·Logical operators: ¬,∧,∨Punctuation: brackets ( ) and ,

Definition

The set of propositional formulas is the smallest set P of strings such that

1 >,⊥,P,Q,R, · · · ∈ P.

2 If X ∈ P, then ¬X ∈ P.

3 If X ,Y ∈ P, then ∨(X ,Y ) ∈ P and ∧(X ,Y ) ∈ P.

Joris Roos Propositional logic August 14, 2018 6 / 22

Page 20: Formalizing propositional logic

Syntactic sugar

Not part of the basic formal syntax. Just convenience.

Write (X ∨ Y ) for ∨(X ,Y ) and (X ∧ Y ) for ∧(X ,Y ).

Brackets are ignored whenever possible according to usual operatorprecedence conventions (¬ � ∧ � ∨ ).

(X → Y ) is short for (¬X ∨ Y ).

may include other common logical operators, ←,↔, 6↔, · · ·

Joris Roos Propositional logic August 14, 2018 7 / 22

Page 21: Formalizing propositional logic

Syntactic sugar

Not part of the basic formal syntax. Just convenience.

Write (X ∨ Y ) for ∨(X ,Y ) and (X ∧ Y ) for ∧(X ,Y ).

Brackets are ignored whenever possible according to usual operatorprecedence conventions (¬ � ∧ � ∨ ).

(X → Y ) is short for (¬X ∨ Y ).

may include other common logical operators, ←,↔, 6↔, · · ·

Joris Roos Propositional logic August 14, 2018 7 / 22

Page 22: Formalizing propositional logic

Syntactic sugar

Not part of the basic formal syntax. Just convenience.

Write (X ∨ Y ) for ∨(X ,Y ) and (X ∧ Y ) for ∧(X ,Y ).

Brackets are ignored whenever possible according to usual operatorprecedence conventions (¬ � ∧ � ∨ ).

(X → Y ) is short for (¬X ∨ Y ).

may include other common logical operators, ←,↔, 6↔, · · ·

Joris Roos Propositional logic August 14, 2018 7 / 22

Page 23: Formalizing propositional logic

Syntactic sugar

Not part of the basic formal syntax. Just convenience.

Write (X ∨ Y ) for ∨(X ,Y ) and (X ∧ Y ) for ∧(X ,Y ).

Brackets are ignored whenever possible according to usual operatorprecedence conventions (¬ � ∧ � ∨ ).

(X → Y ) is short for (¬X ∨ Y ).

may include other common logical operators, ←,↔, 6↔, · · ·

Joris Roos Propositional logic August 14, 2018 7 / 22

Page 24: Formalizing propositional logic

Syntactic sugar

Not part of the basic formal syntax. Just convenience.

Write (X ∨ Y ) for ∨(X ,Y ) and (X ∧ Y ) for ∧(X ,Y ).

Brackets are ignored whenever possible according to usual operatorprecedence conventions (¬ � ∧ � ∨ ).

(X → Y ) is short for (¬X ∨ Y ).

may include other common logical operators, ←,↔, 6↔, · · ·

Joris Roos Propositional logic August 14, 2018 7 / 22

Page 25: Formalizing propositional logic

Example:

∨(P,¬ ∧ (Q,P))

is in P (written sugarfree).

Same formula with sugar:

P ∨ ¬(Q ∧ P)

We will always use sugar.Non-example:

∧ ∨ (P,¬Q())

is not in P.

So far, formulas do not have any meaning!A propositional formula is just a string with a certain structure.

Joris Roos Propositional logic August 14, 2018 8 / 22

Page 26: Formalizing propositional logic

Example:

∨(P,¬ ∧ (Q,P))

is in P (written sugarfree).Same formula with sugar:

P ∨ ¬(Q ∧ P)

We will always use sugar.

Non-example:∧ ∨ (P,¬Q())

is not in P.

So far, formulas do not have any meaning!A propositional formula is just a string with a certain structure.

Joris Roos Propositional logic August 14, 2018 8 / 22

Page 27: Formalizing propositional logic

Example:

∨(P,¬ ∧ (Q,P))

is in P (written sugarfree).Same formula with sugar:

P ∨ ¬(Q ∧ P)

We will always use sugar.Non-example:

∧ ∨ (P,¬Q())

is not in P.

So far, formulas do not have any meaning!A propositional formula is just a string with a certain structure.

Joris Roos Propositional logic August 14, 2018 8 / 22

Page 28: Formalizing propositional logic

Example:

∨(P,¬ ∧ (Q,P))

is in P (written sugarfree).Same formula with sugar:

P ∨ ¬(Q ∧ P)

We will always use sugar.Non-example:

∧ ∨ (P,¬Q())

is not in P.

So far, formulas do not have any meaning!A propositional formula is just a string with a certain structure.

Joris Roos Propositional logic August 14, 2018 8 / 22

Page 29: Formalizing propositional logic

Structural induction

Say we want to prove that every formula F ∈ P has a certain property Q.

Then it suffices to show:

1 >,⊥, p, q, r , . . . have property Q.

2 If F has property Q, then ¬F has property Q.

3 If F and F ′ have property Q, then F ∨F ′ and F ∧F ′ have property Q.

This is a theorem! [Exercise: Prove it.]Example.Exercise: Prove that no propositional formula consists entirely of thesymbol ¬.

Joris Roos Propositional logic August 14, 2018 9 / 22

Page 30: Formalizing propositional logic

Structural induction

Say we want to prove that every formula F ∈ P has a certain property Q.Then it suffices to show:

1 >,⊥, p, q, r , . . . have property Q.

2 If F has property Q, then ¬F has property Q.

3 If F and F ′ have property Q, then F ∨F ′ and F ∧F ′ have property Q.

This is a theorem! [Exercise: Prove it.]Example.Exercise: Prove that no propositional formula consists entirely of thesymbol ¬.

Joris Roos Propositional logic August 14, 2018 9 / 22

Page 31: Formalizing propositional logic

Structural induction

Say we want to prove that every formula F ∈ P has a certain property Q.Then it suffices to show:

1 >,⊥, p, q, r , . . . have property Q.

2 If F has property Q, then ¬F has property Q.

3 If F and F ′ have property Q, then F ∨F ′ and F ∧F ′ have property Q.

This is a theorem! [Exercise: Prove it.]

Example.Exercise: Prove that no propositional formula consists entirely of thesymbol ¬.

Joris Roos Propositional logic August 14, 2018 9 / 22

Page 32: Formalizing propositional logic

Structural induction

Say we want to prove that every formula F ∈ P has a certain property Q.Then it suffices to show:

1 >,⊥, p, q, r , . . . have property Q.

2 If F has property Q, then ¬F has property Q.

3 If F and F ′ have property Q, then F ∨F ′ and F ∧F ′ have property Q.

This is a theorem! [Exercise: Prove it.]Example.Exercise: Prove that no propositional formula consists entirely of thesymbol ¬.

Joris Roos Propositional logic August 14, 2018 9 / 22

Page 33: Formalizing propositional logic

Semantics: Introducing meaning

Definition

A valuation v is a map that assigns each atomic proposition P,Q, · · · oneof the truth values true or false:

v(P) ∈ {true, false}

(Given n atomic propositions we have 2n possible valuations.)

Joris Roos Propositional logic August 14, 2018 10 / 22

Page 34: Formalizing propositional logic

Semantics: Introducing meaning

Definition

A valuation v is a map that assigns each atomic proposition P,Q, · · · oneof the truth values true or false:

v(P) ∈ {true, false}

(Given n atomic propositions we have 2n possible valuations.)

Joris Roos Propositional logic August 14, 2018 10 / 22

Page 35: Formalizing propositional logic

Semantics: Introducing meaning

Definition

A valuation v is a map that assigns each atomic proposition P,Q, · · · oneof the truth values true or false:

v(P) ∈ {true, false}

(Given n atomic propositions we have 2n possible valuations.)

Joris Roos Propositional logic August 14, 2018 10 / 22

Page 36: Formalizing propositional logic

Semantics: Introducing meaning

Let v be a valuation. We extend v to all propositional formulas:

v(>) := true, v(⊥) := false,

v(¬F ) is true iff v(F ) is false.

v(F ∨ F ′) is true iff at least one of v(F ), v(F ′) is true.

v(F ∧ F ′) is true iff both, v(F ) and v(F ′) are true.

By a structural induction this uniquely defines v(F ) for every F ∈ P.

Joris Roos Propositional logic August 14, 2018 11 / 22

Page 37: Formalizing propositional logic

Semantics: Introducing meaning

Let v be a valuation. We extend v to all propositional formulas:

v(>) := true, v(⊥) := false,

v(¬F ) is true iff v(F ) is false.

v(F ∨ F ′) is true iff at least one of v(F ), v(F ′) is true.

v(F ∧ F ′) is true iff both, v(F ) and v(F ′) are true.

By a structural induction this uniquely defines v(F ) for every F ∈ P.

Joris Roos Propositional logic August 14, 2018 11 / 22

Page 38: Formalizing propositional logic

Semantics: Introducing meaning

Let v be a valuation. We extend v to all propositional formulas:

v(>) := true, v(⊥) := false,

v(¬F ) is true iff v(F ) is false.

v(F ∨ F ′) is true iff at least one of v(F ), v(F ′) is true.

v(F ∧ F ′) is true iff both, v(F ) and v(F ′) are true.

By a structural induction this uniquely defines v(F ) for every F ∈ P.

Joris Roos Propositional logic August 14, 2018 11 / 22

Page 39: Formalizing propositional logic

Semantics: Introducing meaning

Let v be a valuation. We extend v to all propositional formulas:

v(>) := true, v(⊥) := false,

v(¬F ) is true iff v(F ) is false.

v(F ∨ F ′) is true iff at least one of v(F ), v(F ′) is true.

v(F ∧ F ′) is true iff both, v(F ) and v(F ′) are true.

By a structural induction this uniquely defines v(F ) for every F ∈ P.

Joris Roos Propositional logic August 14, 2018 11 / 22

Page 40: Formalizing propositional logic

Semantics: Introducing meaning

Let v be a valuation. We extend v to all propositional formulas:

v(>) := true, v(⊥) := false,

v(¬F ) is true iff v(F ) is false.

v(F ∨ F ′) is true iff at least one of v(F ), v(F ′) is true.

v(F ∧ F ′) is true iff both, v(F ) and v(F ′) are true.

By a structural induction this uniquely defines v(F ) for every F ∈ P.

Joris Roos Propositional logic August 14, 2018 11 / 22

Page 41: Formalizing propositional logic

Semantics: Introducing meaning

Let v be a valuation. We extend v to all propositional formulas:

v(>) := true, v(⊥) := false,

v(¬F ) is true iff v(F ) is false.

v(F ∨ F ′) is true iff at least one of v(F ), v(F ′) is true.

v(F ∧ F ′) is true iff both, v(F ) and v(F ′) are true.

By a structural induction this uniquely defines v(F ) for every F ∈ P.

Joris Roos Propositional logic August 14, 2018 11 / 22

Page 42: Formalizing propositional logic

Semantics: Example

Consider the formulaF := ¬P ∨ Q

Define a valuation by v(P) := false and v(Q) := false.Then

v(F ) = true.

Joris Roos Propositional logic August 14, 2018 12 / 22

Page 43: Formalizing propositional logic

Semantics: Example

Consider the formulaF := ¬P ∨ Q

Define a valuation by v(P) := false and v(Q) := false.

Then

v(F ) = true.

Joris Roos Propositional logic August 14, 2018 12 / 22

Page 44: Formalizing propositional logic

Semantics: Example

Consider the formulaF := ¬P ∨ Q

Define a valuation by v(P) := false and v(Q) := false.Then

v(F ) = true.

Joris Roos Propositional logic August 14, 2018 12 / 22

Page 45: Formalizing propositional logic

Satisfiability and tautology

Definition

A formula F ∈ P is called satisfiable if there exists a valuation v such thatv(F ) = true.

Definition

A formula F ∈ P is called a tautology or valid if for every valuation v wehave v(F ) = true.

Exercise: Show that F is satisfiable if and only if ¬F is not valid.

Joris Roos Propositional logic August 14, 2018 13 / 22

Page 46: Formalizing propositional logic

Satisfiability and tautology

Definition

A formula F ∈ P is called satisfiable if there exists a valuation v such thatv(F ) = true.

Definition

A formula F ∈ P is called a tautology or valid if for every valuation v wehave v(F ) = true.

Exercise: Show that F is satisfiable if and only if ¬F is not valid.

Joris Roos Propositional logic August 14, 2018 13 / 22

Page 47: Formalizing propositional logic

Satisfiability and tautology

Definition

A formula F ∈ P is called satisfiable if there exists a valuation v such thatv(F ) = true.

Definition

A formula F ∈ P is called a tautology or valid if for every valuation v wehave v(F ) = true.

Exercise: Show that F is satisfiable if and only if ¬F is not valid.

Joris Roos Propositional logic August 14, 2018 13 / 22

Page 48: Formalizing propositional logic

Examples

For each of the following formulas decide satisfiability and validity:

1 ¬(P ∧ Q) ∨ Q ∨ R

2 ¬P ∧ (Q ∨ R ∨ P)

3 ((P → Q)→ P) ∧ ¬P

Joris Roos Propositional logic August 14, 2018 14 / 22

Page 49: Formalizing propositional logic

Substitution theorem

Definition

Two formulas F ,F ′ ∈ P are called logically equivalent if v(F ) = v(F ′) forall valuations v . (Equivalently, if F ↔ F ′ is a tautology.) We write F ≡ F ′.

For formulas F ,X and an atomic proposition P we define F [P 7→ X ] to bethe formula where every occurrence of P in F is replaced by X .

Theorem

Let X ,Y ∈ P be logically equivalent, F ∈ P and P an atomic proposition.Then,

v(F [P 7→ X ]) = v(F [P 7→ Y ])

for every valuation v .

Together with a list of basic tautologies this enables simplification andtransformation to normal forms.

Joris Roos Propositional logic August 14, 2018 15 / 22

Page 50: Formalizing propositional logic

Substitution theorem

Definition

Two formulas F ,F ′ ∈ P are called logically equivalent if v(F ) = v(F ′) forall valuations v . (Equivalently, if F ↔ F ′ is a tautology.) We write F ≡ F ′.

For formulas F ,X and an atomic proposition P we define F [P 7→ X ] to bethe formula where every occurrence of P in F is replaced by X .

Theorem

Let X ,Y ∈ P be logically equivalent, F ∈ P and P an atomic proposition.Then,

v(F [P 7→ X ]) = v(F [P 7→ Y ])

for every valuation v .

Together with a list of basic tautologies this enables simplification andtransformation to normal forms.

Joris Roos Propositional logic August 14, 2018 15 / 22

Page 51: Formalizing propositional logic

Substitution theorem

Definition

Two formulas F ,F ′ ∈ P are called logically equivalent if v(F ) = v(F ′) forall valuations v . (Equivalently, if F ↔ F ′ is a tautology.) We write F ≡ F ′.

For formulas F ,X and an atomic proposition P we define F [P 7→ X ] to bethe formula where every occurrence of P in F is replaced by X .

Theorem

Let X ,Y ∈ P be logically equivalent, F ∈ P and P an atomic proposition.Then,

v(F [P 7→ X ]) = v(F [P 7→ Y ])

for every valuation v .

Together with a list of basic tautologies this enables simplification andtransformation to normal forms.

Joris Roos Propositional logic August 14, 2018 15 / 22

Page 52: Formalizing propositional logic

Substitution theorem

Definition

Two formulas F ,F ′ ∈ P are called logically equivalent if v(F ) = v(F ′) forall valuations v . (Equivalently, if F ↔ F ′ is a tautology.) We write F ≡ F ′.

For formulas F ,X and an atomic proposition P we define F [P 7→ X ] to bethe formula where every occurrence of P in F is replaced by X .

Theorem

Let X ,Y ∈ P be logically equivalent, F ∈ P and P an atomic proposition.Then,

v(F [P 7→ X ]) = v(F [P 7→ Y ])

for every valuation v .

Together with a list of basic tautologies this enables simplification andtransformation to normal forms.

Joris Roos Propositional logic August 14, 2018 15 / 22

Page 53: Formalizing propositional logic

1 Introduction

2 Syntax and semantics

3 Normal forms

Joris Roos Propositional logic August 14, 2018 16 / 22

Page 54: Formalizing propositional logic

NNF

Definition

A formula is in negation normal form (NNF) if the symbol ¬ only appearsdirectly in front of literals.

Every propositional formula can be transformed into a logically equivalentformula in NNF.Example.

¬(P ∧ ¬Q) ∧ (P ∨ R)

≡ ¬P ∨ Q ∧ (P ∨ R)

Joris Roos Propositional logic August 14, 2018 17 / 22

Page 55: Formalizing propositional logic

NNF

Definition

A formula is in negation normal form (NNF) if the symbol ¬ only appearsdirectly in front of literals.

Every propositional formula can be transformed into a logically equivalentformula in NNF.

Example.¬(P ∧ ¬Q) ∧ (P ∨ R)

≡ ¬P ∨ Q ∧ (P ∨ R)

Joris Roos Propositional logic August 14, 2018 17 / 22

Page 56: Formalizing propositional logic

NNF

Definition

A formula is in negation normal form (NNF) if the symbol ¬ only appearsdirectly in front of literals.

Every propositional formula can be transformed into a logically equivalentformula in NNF.Example.

¬(P ∧ ¬Q) ∧ (P ∨ R)

≡ ¬P ∨ Q ∧ (P ∨ R)

Joris Roos Propositional logic August 14, 2018 17 / 22

Page 57: Formalizing propositional logic

NNF

Definition

A formula is in negation normal form (NNF) if the symbol ¬ only appearsdirectly in front of literals.

Every propositional formula can be transformed into a logically equivalentformula in NNF.Example.

¬(P ∧ ¬Q) ∧ (P ∨ R)

≡ ¬P ∨ Q ∧ (P ∨ R)

Joris Roos Propositional logic August 14, 2018 17 / 22

Page 58: Formalizing propositional logic

NNF

Definition

A formula is in negation normal form (NNF) if the symbol ¬ only appearsdirectly in front of literals.

Every propositional formula can be transformed into a logically equivalentformula in NNF.Example.

¬(P ∧ ¬Q) ∧ (P ∨ R)

≡ ¬P ∨ Q ∧ (P ∨ R)

Joris Roos Propositional logic August 14, 2018 17 / 22

Page 59: Formalizing propositional logic

DNF and CNF

Definition

A formula is in disjunctive normal form (DNF) if it is of the form

D1 ∨ D2 ∨ · · · ∨ Dn

where each Di is of the form

Pi1 ∧ · · · ∧ Pimi

with Pij being literals or negated literals.

A DNF is “a disjunction of conjunctions”, or an “OR of ANDs”.Dually, conjunctive normal form (CNF) is “a conjunction of disjunctions”.Every formula can be transformed into DNF and CNF.

Joris Roos Propositional logic August 14, 2018 18 / 22

Page 60: Formalizing propositional logic

DNF and CNF

Definition

A formula is in disjunctive normal form (DNF) if it is of the form

D1 ∨ D2 ∨ · · · ∨ Dn

where each Di is of the form

Pi1 ∧ · · · ∧ Pimi

with Pij being literals or negated literals.

A DNF is “a disjunction of conjunctions”, or an “OR of ANDs”.

Dually, conjunctive normal form (CNF) is “a conjunction of disjunctions”.Every formula can be transformed into DNF and CNF.

Joris Roos Propositional logic August 14, 2018 18 / 22

Page 61: Formalizing propositional logic

DNF and CNF

Definition

A formula is in disjunctive normal form (DNF) if it is of the form

D1 ∨ D2 ∨ · · · ∨ Dn

where each Di is of the form

Pi1 ∧ · · · ∧ Pimi

with Pij being literals or negated literals.

A DNF is “a disjunction of conjunctions”, or an “OR of ANDs”.Dually, conjunctive normal form (CNF) is “a conjunction of disjunctions”.Every formula can be transformed into DNF and CNF.

Joris Roos Propositional logic August 14, 2018 18 / 22

Page 62: Formalizing propositional logic

DNF and CNF

Definition

A formula is in disjunctive normal form (DNF) if it is of the form

D1 ∨ D2 ∨ · · · ∨ Dn

where each Di is of the form

Pi1 ∧ · · · ∧ Pimi

with Pij being literals or negated literals.

A DNF is “a disjunction of conjunctions”, or an “OR of ANDs”.Dually, conjunctive normal form (CNF) is “a conjunction of disjunctions”.Every formula can be transformed into DNF and CNF.

Joris Roos Propositional logic August 14, 2018 18 / 22

Page 63: Formalizing propositional logic

DNF and SAT

It is very efficient to check a DNF formula for satisfiability:

A formula in DNF is satisfiable if and only if in at least one of thedisjuncts there is no literal that appears negated and unnegated.

Example. The DNF

P ∧ Q ∧ R ∨ P ∧ ¬Q ∨ ¬R ∧ Q ∧ R

is satisfiable.

Joris Roos Propositional logic August 14, 2018 19 / 22

Page 64: Formalizing propositional logic

Clausal form

Clausal form is the same as CNF.

A clause is a disjunction: P1 ∨ · · · ∨ Pm with Pi literals or negated literals.It is often convenient to represent CNF as a list of lists, for example,

(P ∨ Q ∨ ¬R) ∧ P ∧ ¬Q ∧ (R ∨ Q)

becomes

[[P,Q,¬R], [P], [¬Q], [R,Q]]

Joris Roos Propositional logic August 14, 2018 20 / 22

Page 65: Formalizing propositional logic

To be continued..

Next step: first-order logic!

FOL satisfiability is only semi-decidable.

Syntax and semantics will much more involved.

We will also need more sophisticated (propositional) SAT methods.

Joris Roos Propositional logic August 14, 2018 21 / 22

Page 66: Formalizing propositional logic

References

Melvin Fitting. First-order Logic and Automated Theorem Proving. (Springer, 1996)

John Harrison. Handbook of Practical Logic and Automated Reasoning.(Cambridge, 2009)

Joris Roos Propositional logic August 14, 2018 22 / 22