logic - dhbw stuttgarthladik/logik/2015/logic - overlays.pdf · logic, logic, logic... why do...

669
Logic Jan Hladik DHBW Stuttgart Wintersemester 2015/16 Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 1 / 120

Upload: others

Post on 25-Jun-2020

20 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Logic

Jan Hladik

DHBW Stuttgart

Wintersemester 2015/16

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 1 / 120

Page 2: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Introduction

Jan Hladik

Dipl.-Inform.: RWTH Aachen, 2001

Dr. rer. nat.: TU Dresden, 2007

Industry experience: SAP Research

Work in publicly funded research projectsCollaboration with SAP product groupsSupervision of Bachelor, Master, and PhD students

Professor: DHBW Stuttgart, 2014

Research

Semantic Web, Semantic Technologies, Automated Reasoning

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 2 / 120

Page 3: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Introduction

Jan Hladik

Dipl.-Inform.: RWTH Aachen, 2001

Dr. rer. nat.: TU Dresden, 2007

Industry experience: SAP Research

Work in publicly funded research projectsCollaboration with SAP product groupsSupervision of Bachelor, Master, and PhD students

Professor: DHBW Stuttgart, 2014

Research

Semantic Web, Semantic Technologies, Automated Reasoning

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 2 / 120

Page 4: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Outline

1 Why logic?

2 propositional and first-order logic

1 syntax and semantics of propositional logic2 reasoning

1 resolution2 tableaus

3 syntax and semantics of first-order logic4 reasoning

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 3 / 120

Page 5: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Logic, logic, logic. . .

Why do computer scientists need logic?

Mr Spock says:

Logic isthe beginning of wisdom,not the end.

Logic is not the ultimate purpose of a computer science course

but it lays the foundation for other topics

and is necessary to understand what computer science is about

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 4 / 120

Page 6: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Logic, logic, logic. . .

Why do computer scientists need logic?

Mr Spock says:

Logic isthe beginning of wisdom,not the end.

Logic is not the ultimate purpose of a computer science course

but it lays the foundation for other topics

and is necessary to understand what computer science is about

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 4 / 120

Page 7: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Logic, logic, logic. . .

Why do computer scientists need logic?

Mr Spock says:

Logic isthe beginning of wisdom,not the end.

Logic is not the ultimate purpose of a computer science course

but it lays the foundation for other topics

and is necessary to understand what computer science is about

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 4 / 120

Page 8: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

What we need logic for

You can be a hacker without knowing anything about logic

like you can drive a car without knowing about engines

You need to know about the theoretical foundations of computerscience if you want to

understand what’s going on in a computer (Boolean logic)ensure that your program computes the right functiondesign your communication protocol so that it does not allow fordeadlocksensure that your algorithm runs as fast as possible

Without logic, you will only be a

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 5 / 120

Page 9: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

What we need logic for

You can be a hacker without knowing anything about logiclike you can drive a car without knowing about engines

You need to know about the theoretical foundations of computerscience if you want to

understand what’s going on in a computer (Boolean logic)ensure that your program computes the right functiondesign your communication protocol so that it does not allow fordeadlocksensure that your algorithm runs as fast as possible

Without logic, you will only be a

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 5 / 120

Page 10: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

What we need logic for

You can be a hacker without knowing anything about logiclike you can drive a car without knowing about engines

You need to know about the theoretical foundations of computerscience if you want to

understand what’s going on in a computer (Boolean logic)ensure that your program computes the right functiondesign your communication protocol so that it does not allow fordeadlocksensure that your algorithm runs as fast as possible

Without logic, you will only be a

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 5 / 120

Page 11: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

What we need logic for

You can be a hacker without knowing anything about logiclike you can drive a car without knowing about engines

You need to know about the theoretical foundations of computerscience if you want to

understand what’s going on in a computer (Boolean logic)

ensure that your program computes the right functiondesign your communication protocol so that it does not allow fordeadlocksensure that your algorithm runs as fast as possible

Without logic, you will only be a

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 5 / 120

Page 12: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

What we need logic for

You can be a hacker without knowing anything about logiclike you can drive a car without knowing about engines

You need to know about the theoretical foundations of computerscience if you want to

understand what’s going on in a computer (Boolean logic)ensure that your program computes the right function

design your communication protocol so that it does not allow fordeadlocksensure that your algorithm runs as fast as possible

Without logic, you will only be a

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 5 / 120

Page 13: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

What we need logic for

You can be a hacker without knowing anything about logiclike you can drive a car without knowing about engines

You need to know about the theoretical foundations of computerscience if you want to

understand what’s going on in a computer (Boolean logic)ensure that your program computes the right functiondesign your communication protocol so that it does not allow fordeadlocks

ensure that your algorithm runs as fast as possible

Without logic, you will only be a

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 5 / 120

Page 14: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

What we need logic for

You can be a hacker without knowing anything about logiclike you can drive a car without knowing about engines

You need to know about the theoretical foundations of computerscience if you want to

understand what’s going on in a computer (Boolean logic)ensure that your program computes the right functiondesign your communication protocol so that it does not allow fordeadlocksensure that your algorithm runs as fast as possible

Without logic, you will only be a

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 5 / 120

Page 15: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

What we need logic for

You can be a hacker without knowing anything about logiclike you can drive a car without knowing about engines

You need to know about the theoretical foundations of computerscience if you want to

understand what’s going on in a computer (Boolean logic)ensure that your program computes the right functiondesign your communication protocol so that it does not allow fordeadlocksensure that your algorithm runs as fast as possible

Without logic, you will only be a

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 5 / 120

Page 16: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

What we need logic for

You can be a hacker without knowing anything about logiclike you can drive a car without knowing about engines

You need to know about the theoretical foundations of computerscience if you want to

understand what’s going on in a computer (Boolean logic)ensure that your program computes the right functiondesign your communication protocol so that it does not allow fordeadlocksensure that your algorithm runs as fast as possible

Without logic, you will only be a

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 5 / 120

Page 17: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional logic

most basic logic we consider in this course

limited expressivity

easy to understand and use

contains many concepts that are also used in more expressive logics

Propostional variables represent propositions

Example

A ; “it rains”

Operators represent relations between propositions

Example

A→ B ; “if it rains, the ground is wet”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 6 / 120

Page 18: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional logic

most basic logic we consider in this course

limited expressivity

easy to understand and use

contains many concepts that are also used in more expressive logics

Propostional variables represent propositions

Example

A ; “it rains”

Operators represent relations between propositions

Example

A→ B ; “if it rains, the ground is wet”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 6 / 120

Page 19: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional logic

most basic logic we consider in this course

limited expressivity

easy to understand and use

contains many concepts that are also used in more expressive logics

Propostional variables represent propositions

Example

A ; “it rains”

Operators represent relations between propositions

Example

A→ B ; “if it rains, the ground is wet”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 6 / 120

Page 20: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional variables

are referenced by capital letters A,B,X, Y, . . .

represent propositions that can be true or false

“It rains.”“Peter loves Mary.”“Socrates is mortal.”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 7 / 120

Page 21: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)ϕ ∧ ψ (conjunction)ϕ ∨ ψ (disjunction)ϕ→ ψ (material implication)ϕ↔ ψ (material equivalence)(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 22: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)ϕ ∧ ψ (conjunction)ϕ ∨ ψ (disjunction)ϕ→ ψ (material implication)ϕ↔ ψ (material equivalence)(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 23: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)ϕ ∧ ψ (conjunction)ϕ ∨ ψ (disjunction)ϕ→ ψ (material implication)ϕ↔ ψ (material equivalence)(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 24: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)

ϕ ∧ ψ (conjunction)ϕ ∨ ψ (disjunction)ϕ→ ψ (material implication)ϕ↔ ψ (material equivalence)(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 25: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)ϕ ∧ ψ (conjunction)

ϕ ∨ ψ (disjunction)ϕ→ ψ (material implication)ϕ↔ ψ (material equivalence)(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 26: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)ϕ ∧ ψ (conjunction)ϕ ∨ ψ (disjunction)

ϕ→ ψ (material implication)ϕ↔ ψ (material equivalence)(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 27: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)ϕ ∧ ψ (conjunction)ϕ ∨ ψ (disjunction)ϕ→ ψ (material implication)

ϕ↔ ψ (material equivalence)(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 28: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)ϕ ∧ ψ (conjunction)ϕ ∨ ψ (disjunction)ϕ→ ψ (material implication)ϕ↔ ψ (material equivalence)

(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 29: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)ϕ ∧ ψ (conjunction)ϕ ∨ ψ (disjunction)ϕ→ ψ (material implication)ϕ↔ ψ (material equivalence)(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 30: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)ϕ ∧ ψ (conjunction)ϕ ∨ ψ (disjunction)ϕ→ ψ (material implication)ϕ↔ ψ (material equivalence)(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 31: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Syntax of propositional logic

Definition (propositional formula)

every propositional variable is a propositional formula

> and ⊥ are propositional formulas

if ϕ and ψ are propositional formulas, then so are

¬ϕ (negation)ϕ ∧ ψ (conjunction)ϕ ∨ ψ (disjunction)ϕ→ ψ (material implication)ϕ↔ ψ (material equivalence)(ϕ) (brackets indicate precedence)

Examples

A ∧B⊥ ∨A¬>

A ∧ (B ∨ C)

¬(A ∨B)

C → (B ∨D)

A→ (B∧(C ↔ D)∨(D → E))

A↔ (A↔ D)

((A↔ B)↔ (C ↔ D))→ E

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 8 / 120

Page 32: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: syntax of PL

Which of the following are propositional formulas?

a) A→ ⊥b) A ∧ (B ∨ C)

c) A¬Bd) (A→ C) ∧ (¬A→ C)→ C

e) ∨B ∨ C ∧Df) A→ (B ∨ ¬B)(C ∨ ¬C)

g) A→ A

h) A ∧ ¬Ai) A¬ ∧Bj) ¬A ∧Bk) (¬A) ∧Bl) ¬(A ∧B)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 9 / 120

Page 33: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Precedence and associativity of logical operators

Precedence of operators:

operator precedence

¬ 1 (strongest)∧ 2∨ 3→ 4↔ 5 (weakest)

Example

A ∧B → B ∨ C means (A ∧B)→ (B ∨ C)

Operators of the same precedence are left-associative.

Example

A→ B → C means (A→ B)→ C

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 10 / 120

Page 34: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Precedence and associativity of logical operators

Precedence of operators:

operator precedence

¬ 1 (strongest)∧ 2∨ 3→ 4↔ 5 (weakest)

Example

A ∧B → B ∨ C means (A ∧B)→ (B ∨ C)

Operators of the same precedence are left-associative.

Example

A→ B → C means (A→ B)→ C

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 10 / 120

Page 35: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Precedence and associativity of logical operators

Precedence of operators:

operator precedence

¬ 1 (strongest)∧ 2∨ 3→ 4↔ 5 (weakest)

Example

A ∧B → B ∨ C means (A ∧B)→ (B ∨ C)

Operators of the same precedence are left-associative.

Example

A→ B → C means (A→ B)→ C

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 10 / 120

Page 36: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Precedence and associativity of logical operators

Precedence of operators:

operator precedence

¬ 1 (strongest)∧ 2∨ 3→ 4↔ 5 (weakest)

Example

A ∧B → B ∨ C means (A ∧B)→ (B ∨ C)

Operators of the same precedence are left-associative.

Example

A→ B → C means (A→ B)→ C

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 10 / 120

Page 37: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: Precedence and brackets

Remove as many brackets as possible without changing the precedence.

a) ((A ∧B) ∨ ((C ∧D)→ (A ∨ C)))

b) ((((A ∧ (B ∨ C) ∧D))→ A) ∨ C)

c) (A ∧ (B ∨ (C ∧ (D → (A ∨ C)))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 11 / 120

Page 38: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Semantics of propositional logic

assigning meaning to a logical formula.

assigning 0 or 1 to the variables

making the formula true or false

An interpretation assigns a truth value to variables (and thus formulas)

Definition (interpretation)

Function I : V → B where

V is a set of propositional variables

B is the binary set {0, 1}

Example

A 7→ 0 ; “it does not rain”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 12 / 120

Page 39: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Semantics of propositional logic

assigning meaning to a logical formula.

assigning 0 or 1 to the variables

making the formula true or false

An interpretation assigns a truth value to variables (and thus formulas)

Definition (interpretation)

Function I : V → B where

V is a set of propositional variables

B is the binary set {0, 1}

Example

A 7→ 0 ; “it does not rain”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 12 / 120

Page 40: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Semantics of propositional logic

assigning meaning to a logical formula.

assigning 0 or 1 to the variables

making the formula true or false

An interpretation assigns a truth value to variables (and thus formulas)

Definition (interpretation)

Function I : V → B where

V is a set of propositional variables

B is the binary set {0, 1}

Example

A 7→ 0 ; “it does not rain”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 12 / 120

Page 41: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Interpretation of complex formulas

⊥I >I0 1

ϕI 0 1

(¬ϕ)I 1 0

(ϕ ∧ ψ)I

ϕI 0 1ψI

0 0 01 0 1

(ϕ ∨ ψ)I

ϕI 0 1ψI

0 0 11 1 1

(ϕ→ ψ)I

ϕI 0 1ψI

0 1 01 1 1

(ϕ↔ ψ)I

ϕI 0 1ψI

0 1 01 0 1

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 13 / 120

Page 42: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Interpretation of complex formulas

⊥I >I0 1

ϕI 0 1

(¬ϕ)I 1 0

(ϕ ∧ ψ)I

ϕI 0 1ψI

0 0 01 0 1

(ϕ ∨ ψ)I

ϕI 0 1ψI

0 0 11 1 1

(ϕ→ ψ)I

ϕI 0 1ψI

0 1 01 1 1

(ϕ↔ ψ)I

ϕI 0 1ψI

0 1 01 0 1

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 13 / 120

Page 43: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Interpretation of complex formulas

⊥I >I0 1

ϕI 0 1

(¬ϕ)I 1 0

(ϕ ∧ ψ)I

ϕI 0 1ψI

0 0 01 0 1

(ϕ ∨ ψ)I

ϕI 0 1ψI

0 0 11 1 1

(ϕ→ ψ)I

ϕI 0 1ψI

0 1 01 1 1

(ϕ↔ ψ)I

ϕI 0 1ψI

0 1 01 0 1

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 13 / 120

Page 44: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Interpretation of complex formulas

⊥I >I0 1

ϕI 0 1

(¬ϕ)I 1 0

(ϕ ∧ ψ)I

ϕI 0 1ψI

0 0 01 0 1

(ϕ ∨ ψ)I

ϕI 0 1ψI

0 0 11 1 1

(ϕ→ ψ)I

ϕI 0 1ψI

0 1 01 1 1

(ϕ↔ ψ)I

ϕI 0 1ψI

0 1 01 0 1

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 13 / 120

Page 45: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Interpretation of complex formulas

⊥I >I0 1

ϕI 0 1

(¬ϕ)I 1 0

(ϕ ∧ ψ)I

ϕI 0 1ψI

0 0 01 0 1

(ϕ ∨ ψ)I

ϕI 0 1ψI

0 0 11 1 1

(ϕ→ ψ)I

ϕI 0 1ψI

0 1 01 1 1

(ϕ↔ ψ)I

ϕI 0 1ψI

0 1 01 0 1

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 13 / 120

Page 46: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Interpretation of complex formulas

⊥I >I0 1

ϕI 0 1

(¬ϕ)I 1 0

(ϕ ∧ ψ)I

ϕI 0 1ψI

0 0 01 0 1

(ϕ ∨ ψ)I

ϕI 0 1ψI

0 0 11 1 1

(ϕ→ ψ)I

ϕI 0 1ψI

0 1 01 1 1

(ϕ↔ ψ)I

ϕI 0 1ψI

0 1 01 0 1

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 13 / 120

Page 47: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretations

The interpretation I = {A 7→ 1, B 7→ 1, C 7→ 0} makes the formula

B true;

A ∧B true;

A ∧ C false;

(A ∧B) ∨ (A ∧ C) true;

((A ∧B) ∨ (A ∧ C))→ C false.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 14 / 120

Page 48: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Basic equivalences

Definition (equivalent)

Two propisitional formulas ϕ and ψ are equivalent if every interpretationassigns the same truth value to both formulas, i.e.

ϕI = ψI for every I

Due to the semantics, one can express some operators by using other ones

Theorem (equivalences)

ϕ↔ ψ is equivalent to (ϕ→ ψ) ∧ (ψ → ϕ) or (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

ϕ→ ψ is equivalent to ¬ϕ ∨ ψϕ ∧ ψ is equivalent to ¬(¬ϕ ∨ ¬ψ)

ϕ ∨ ψ is equivalent to ¬(¬ϕ ∧ ¬ψ)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 15 / 120

Page 49: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Basic equivalences

Definition (equivalent)

Two propisitional formulas ϕ and ψ are equivalent if every interpretationassigns the same truth value to both formulas, i.e.

ϕI = ψI for every I

Due to the semantics, one can express some operators by using other ones

Theorem (equivalences)

ϕ↔ ψ is equivalent to (ϕ→ ψ) ∧ (ψ → ϕ) or (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

ϕ→ ψ is equivalent to ¬ϕ ∨ ψϕ ∧ ψ is equivalent to ¬(¬ϕ ∨ ¬ψ)

ϕ ∨ ψ is equivalent to ¬(¬ϕ ∧ ¬ψ)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 15 / 120

Page 50: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Basic equivalences

Definition (equivalent)

Two propisitional formulas ϕ and ψ are equivalent if every interpretationassigns the same truth value to both formulas, i.e.

ϕI = ψI for every I

Due to the semantics, one can express some operators by using other ones

Theorem (equivalences)

ϕ↔ ψ is equivalent to (ϕ→ ψ) ∧ (ψ → ϕ) or (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

ϕ→ ψ is equivalent to ¬ϕ ∨ ψ

ϕ ∧ ψ is equivalent to ¬(¬ϕ ∨ ¬ψ)

ϕ ∨ ψ is equivalent to ¬(¬ϕ ∧ ¬ψ)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 15 / 120

Page 51: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Basic equivalences

Definition (equivalent)

Two propisitional formulas ϕ and ψ are equivalent if every interpretationassigns the same truth value to both formulas, i.e.

ϕI = ψI for every I

Due to the semantics, one can express some operators by using other ones

Theorem (equivalences)

ϕ↔ ψ is equivalent to (ϕ→ ψ) ∧ (ψ → ϕ) or (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

ϕ→ ψ is equivalent to ¬ϕ ∨ ψϕ ∧ ψ is equivalent to ¬(¬ϕ ∨ ¬ψ)

ϕ ∨ ψ is equivalent to ¬(¬ϕ ∧ ¬ψ)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 15 / 120

Page 52: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Basic equivalences

Definition (equivalent)

Two propisitional formulas ϕ and ψ are equivalent if every interpretationassigns the same truth value to both formulas, i.e.

ϕI = ψI for every I

Due to the semantics, one can express some operators by using other ones

Theorem (equivalences)

ϕ↔ ψ is equivalent to (ϕ→ ψ) ∧ (ψ → ϕ) or (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

ϕ→ ψ is equivalent to ¬ϕ ∨ ψϕ ∧ ψ is equivalent to ¬(¬ϕ ∨ ¬ψ)

ϕ ∨ ψ is equivalent to ¬(¬ϕ ∧ ¬ψ)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 15 / 120

Page 53: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: interpretations

Find two interpretations for each of the following formulas

one that makes them true

one that makes them false

a) A ∧B → C

b) (A ∨B) ∧ (A ∨ C)→ (B ∧ C)

c) A→ B ↔ ¬B → ¬A

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 16 / 120

Page 54: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tautologies

Definition (tautology)

A tautology is a formula which is true in every interpretation.

Examples (tautologies)

A↔ A (identity)

¬(A ∧ ¬A) (noncontradiction)

A ∨ ¬A (excluded middle)

A→ B ↔ ¬B → ¬A (contraposition)

(A→ B) ∧ (A→ ¬B)→ ¬A (reductio ad absurdum)

(A→ B) ∧ (B → C)→ (A→ C) (syllogism)

(A ∨B) ∧ (A→ C) ∧ (B → C)→ C (proof by cases)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 17 / 120

Page 55: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tautologies

Definition (tautology)

A tautology is a formula which is true in every interpretation.

Examples (tautologies)

A↔ A (identity)

¬(A ∧ ¬A) (noncontradiction)

A ∨ ¬A (excluded middle)

A→ B ↔ ¬B → ¬A (contraposition)

(A→ B) ∧ (A→ ¬B)→ ¬A (reductio ad absurdum)

(A→ B) ∧ (B → C)→ (A→ C) (syllogism)

(A ∨B) ∧ (A→ C) ∧ (B → C)→ C (proof by cases)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 17 / 120

Page 56: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tautologies

Definition (tautology)

A tautology is a formula which is true in every interpretation.

Examples (tautologies)

A↔ A (identity)

¬(A ∧ ¬A) (noncontradiction)

A ∨ ¬A (excluded middle)

A→ B ↔ ¬B → ¬A (contraposition)

(A→ B) ∧ (A→ ¬B)→ ¬A (reductio ad absurdum)

(A→ B) ∧ (B → C)→ (A→ C) (syllogism)

(A ∨B) ∧ (A→ C) ∧ (B → C)→ C (proof by cases)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 17 / 120

Page 57: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tautologies

Definition (tautology)

A tautology is a formula which is true in every interpretation.

Examples (tautologies)

A↔ A (identity)

¬(A ∧ ¬A) (noncontradiction)

A ∨ ¬A (excluded middle)

A→ B ↔ ¬B → ¬A (contraposition)

(A→ B) ∧ (A→ ¬B)→ ¬A (reductio ad absurdum)

(A→ B) ∧ (B → C)→ (A→ C) (syllogism)

(A ∨B) ∧ (A→ C) ∧ (B → C)→ C (proof by cases)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 17 / 120

Page 58: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tautologies

Definition (tautology)

A tautology is a formula which is true in every interpretation.

Examples (tautologies)

A↔ A (identity)

¬(A ∧ ¬A) (noncontradiction)

A ∨ ¬A (excluded middle)

A→ B ↔ ¬B → ¬A (contraposition)

(A→ B) ∧ (A→ ¬B)→ ¬A (reductio ad absurdum)

(A→ B) ∧ (B → C)→ (A→ C) (syllogism)

(A ∨B) ∧ (A→ C) ∧ (B → C)→ C (proof by cases)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 17 / 120

Page 59: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tautologies

Definition (tautology)

A tautology is a formula which is true in every interpretation.

Examples (tautologies)

A↔ A (identity)

¬(A ∧ ¬A) (noncontradiction)

A ∨ ¬A (excluded middle)

A→ B ↔ ¬B → ¬A (contraposition)

(A→ B) ∧ (A→ ¬B)→ ¬A (reductio ad absurdum)

(A→ B) ∧ (B → C)→ (A→ C) (syllogism)

(A ∨B) ∧ (A→ C) ∧ (B → C)→ C (proof by cases)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 17 / 120

Page 60: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tautologies

Definition (tautology)

A tautology is a formula which is true in every interpretation.

Examples (tautologies)

A↔ A (identity)

¬(A ∧ ¬A) (noncontradiction)

A ∨ ¬A (excluded middle)

A→ B ↔ ¬B → ¬A (contraposition)

(A→ B) ∧ (A→ ¬B)→ ¬A (reductio ad absurdum)

(A→ B) ∧ (B → C)→ (A→ C) (syllogism)

(A ∨B) ∧ (A→ C) ∧ (B → C)→ C (proof by cases)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 17 / 120

Page 61: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tautologies

Definition (tautology)

A tautology is a formula which is true in every interpretation.

Examples (tautologies)

A↔ A (identity)

¬(A ∧ ¬A) (noncontradiction)

A ∨ ¬A (excluded middle)

A→ B ↔ ¬B → ¬A (contraposition)

(A→ B) ∧ (A→ ¬B)→ ¬A (reductio ad absurdum)

(A→ B) ∧ (B → C)→ (A→ C) (syllogism)

(A ∨B) ∧ (A→ C) ∧ (B → C)→ C (proof by cases)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 17 / 120

Page 62: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Further tautologies

(A ∧B) ∨ C ↔ (A ∨ C) ∧ (B ∨ C) (distributivity)

(A ∧B) ∧ C ↔ A ∧ (B ∧ C) (associativity)

A ∧B ↔ B ∧A (commutativity)

¬(A ∧B)↔ ¬A ∨ ¬B (de Morgan’s law)

A ∧A↔ A; A ∨A↔ A (idempotence)

A ∧ > ↔ A; A ∨ ⊥ ↔ A (neutral element)

A ∧ ⊥ ↔ ⊥; A ∨ > ↔ > (absorbing element)

¬¬A↔ A (double negation)

Distributivity, associativity, commutativity, and deMorgan’s law also hold if∧ is replaced with ∨ and vice versa.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 18 / 120

Page 63: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Further tautologies

(A ∧B) ∨ C ↔ (A ∨ C) ∧ (B ∨ C) (distributivity)

(A ∧B) ∧ C ↔ A ∧ (B ∧ C) (associativity)

A ∧B ↔ B ∧A (commutativity)

¬(A ∧B)↔ ¬A ∨ ¬B (de Morgan’s law)

A ∧A↔ A; A ∨A↔ A (idempotence)

A ∧ > ↔ A; A ∨ ⊥ ↔ A (neutral element)

A ∧ ⊥ ↔ ⊥; A ∨ > ↔ > (absorbing element)

¬¬A↔ A (double negation)

Distributivity, associativity, commutativity, and deMorgan’s law also hold if∧ is replaced with ∨ and vice versa.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 18 / 120

Page 64: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Further tautologies

(A ∧B) ∨ C ↔ (A ∨ C) ∧ (B ∨ C) (distributivity)

(A ∧B) ∧ C ↔ A ∧ (B ∧ C) (associativity)

A ∧B ↔ B ∧A (commutativity)

¬(A ∧B)↔ ¬A ∨ ¬B (de Morgan’s law)

A ∧A↔ A; A ∨A↔ A (idempotence)

A ∧ > ↔ A; A ∨ ⊥ ↔ A (neutral element)

A ∧ ⊥ ↔ ⊥; A ∨ > ↔ > (absorbing element)

¬¬A↔ A (double negation)

Distributivity, associativity, commutativity, and deMorgan’s law also hold if∧ is replaced with ∨ and vice versa.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 18 / 120

Page 65: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Further tautologies

(A ∧B) ∨ C ↔ (A ∨ C) ∧ (B ∨ C) (distributivity)

(A ∧B) ∧ C ↔ A ∧ (B ∧ C) (associativity)

A ∧B ↔ B ∧A (commutativity)

¬(A ∧B)↔ ¬A ∨ ¬B (de Morgan’s law)

A ∧A↔ A; A ∨A↔ A (idempotence)

A ∧ > ↔ A; A ∨ ⊥ ↔ A (neutral element)

A ∧ ⊥ ↔ ⊥; A ∨ > ↔ > (absorbing element)

¬¬A↔ A (double negation)

Distributivity, associativity, commutativity, and deMorgan’s law also hold if∧ is replaced with ∨ and vice versa.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 18 / 120

Page 66: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Further tautologies

(A ∧B) ∨ C ↔ (A ∨ C) ∧ (B ∨ C) (distributivity)

(A ∧B) ∧ C ↔ A ∧ (B ∧ C) (associativity)

A ∧B ↔ B ∧A (commutativity)

¬(A ∧B)↔ ¬A ∨ ¬B (de Morgan’s law)

A ∧A↔ A; A ∨A↔ A (idempotence)

A ∧ > ↔ A; A ∨ ⊥ ↔ A (neutral element)

A ∧ ⊥ ↔ ⊥; A ∨ > ↔ > (absorbing element)

¬¬A↔ A (double negation)

Distributivity, associativity, commutativity, and deMorgan’s law also hold if∧ is replaced with ∨ and vice versa.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 18 / 120

Page 67: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Further tautologies

(A ∧B) ∨ C ↔ (A ∨ C) ∧ (B ∨ C) (distributivity)

(A ∧B) ∧ C ↔ A ∧ (B ∧ C) (associativity)

A ∧B ↔ B ∧A (commutativity)

¬(A ∧B)↔ ¬A ∨ ¬B (de Morgan’s law)

A ∧A↔ A; A ∨A↔ A (idempotence)

A ∧ > ↔ A; A ∨ ⊥ ↔ A (neutral element)

A ∧ ⊥ ↔ ⊥; A ∨ > ↔ > (absorbing element)

¬¬A↔ A (double negation)

Distributivity, associativity, commutativity, and deMorgan’s law also hold if∧ is replaced with ∨ and vice versa.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 18 / 120

Page 68: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Further tautologies

(A ∧B) ∨ C ↔ (A ∨ C) ∧ (B ∨ C) (distributivity)

(A ∧B) ∧ C ↔ A ∧ (B ∧ C) (associativity)

A ∧B ↔ B ∧A (commutativity)

¬(A ∧B)↔ ¬A ∨ ¬B (de Morgan’s law)

A ∧A↔ A; A ∨A↔ A (idempotence)

A ∧ > ↔ A; A ∨ ⊥ ↔ A (neutral element)

A ∧ ⊥ ↔ ⊥; A ∨ > ↔ > (absorbing element)

¬¬A↔ A (double negation)

Distributivity, associativity, commutativity, and deMorgan’s law also hold if∧ is replaced with ∨ and vice versa.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 18 / 120

Page 69: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Further tautologies

(A ∧B) ∨ C ↔ (A ∨ C) ∧ (B ∨ C) (distributivity)

(A ∧B) ∧ C ↔ A ∧ (B ∧ C) (associativity)

A ∧B ↔ B ∧A (commutativity)

¬(A ∧B)↔ ¬A ∨ ¬B (de Morgan’s law)

A ∧A↔ A; A ∨A↔ A (idempotence)

A ∧ > ↔ A; A ∨ ⊥ ↔ A (neutral element)

A ∧ ⊥ ↔ ⊥; A ∨ > ↔ > (absorbing element)

¬¬A↔ A (double negation)

Distributivity, associativity, commutativity, and deMorgan’s law also hold if∧ is replaced with ∨ and vice versa.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 18 / 120

Page 70: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Further tautologies

(A ∧B) ∨ C ↔ (A ∨ C) ∧ (B ∨ C) (distributivity)

(A ∧B) ∧ C ↔ A ∧ (B ∧ C) (associativity)

A ∧B ↔ B ∧A (commutativity)

¬(A ∧B)↔ ¬A ∨ ¬B (de Morgan’s law)

A ∧A↔ A; A ∨A↔ A (idempotence)

A ∧ > ↔ A; A ∨ ⊥ ↔ A (neutral element)

A ∧ ⊥ ↔ ⊥; A ∨ > ↔ > (absorbing element)

¬¬A↔ A (double negation)

Distributivity, associativity, commutativity, and deMorgan’s law also hold if∧ is replaced with ∨ and vice versa.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 18 / 120

Page 71: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Further tautologies

(A ∧B) ∨ C ↔ (A ∨ C) ∧ (B ∨ C) (distributivity)

(A ∧B) ∧ C ↔ A ∧ (B ∧ C) (associativity)

A ∧B ↔ B ∧A (commutativity)

¬(A ∧B)↔ ¬A ∨ ¬B (de Morgan’s law)

A ∧A↔ A; A ∨A↔ A (idempotence)

A ∧ > ↔ A; A ∨ ⊥ ↔ A (neutral element)

A ∧ ⊥ ↔ ⊥; A ∨ > ↔ > (absorbing element)

¬¬A↔ A (double negation)

Distributivity, associativity, commutativity, and deMorgan’s law also hold if∧ is replaced with ∨ and vice versa.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 18 / 120

Page 72: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Models, validity, satisfiability

Definition (model)

A model for a formula ϕ is an interpretation I that makes ϕ true (I |= ϕ).

I = {A 7→ 1, B 7→ 0} is a model for A ∨B, but not for A ∧B.

Definition (satisfiable, valid)

A formula ϕ is called satisfiable if it has a model.A formula ϕ is called valid (|= ϕ) if every interpretation is a model (i.e. ifit is a tautology).

satisfiable A, A ∨B, A ∧ ¬B, A↔ B

valid A ∨ ¬A, A→ A, A↔ ¬(¬A)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 19 / 120

Page 73: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Models, validity, satisfiability

Definition (model)

A model for a formula ϕ is an interpretation I that makes ϕ true (I |= ϕ).

I = {A 7→ 1, B 7→ 0} is a model for A ∨B, but not for A ∧B.

Definition (satisfiable, valid)

A formula ϕ is called satisfiable if it has a model.A formula ϕ is called valid (|= ϕ) if every interpretation is a model (i.e. ifit is a tautology).

satisfiable A, A ∨B, A ∧ ¬B, A↔ B

valid A ∨ ¬A, A→ A, A↔ ¬(¬A)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 19 / 120

Page 74: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Models, validity, satisfiability

Definition (model)

A model for a formula ϕ is an interpretation I that makes ϕ true (I |= ϕ).

I = {A 7→ 1, B 7→ 0} is a model for A ∨B, but not for A ∧B.

Definition (satisfiable, valid)

A formula ϕ is called satisfiable if it has a model.

A formula ϕ is called valid (|= ϕ) if every interpretation is a model (i.e. ifit is a tautology).

satisfiable A, A ∨B, A ∧ ¬B, A↔ B

valid A ∨ ¬A, A→ A, A↔ ¬(¬A)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 19 / 120

Page 75: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Models, validity, satisfiability

Definition (model)

A model for a formula ϕ is an interpretation I that makes ϕ true (I |= ϕ).

I = {A 7→ 1, B 7→ 0} is a model for A ∨B, but not for A ∧B.

Definition (satisfiable, valid)

A formula ϕ is called satisfiable if it has a model.A formula ϕ is called valid (|= ϕ) if every interpretation is a model (i.e. ifit is a tautology).

satisfiable A, A ∨B, A ∧ ¬B, A↔ B

valid A ∨ ¬A, A→ A, A↔ ¬(¬A)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 19 / 120

Page 76: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Models, validity, satisfiability

Definition (model)

A model for a formula ϕ is an interpretation I that makes ϕ true (I |= ϕ).

I = {A 7→ 1, B 7→ 0} is a model for A ∨B, but not for A ∧B.

Definition (satisfiable, valid)

A formula ϕ is called satisfiable if it has a model.A formula ϕ is called valid (|= ϕ) if every interpretation is a model (i.e. ifit is a tautology).

satisfiable A, A ∨B, A ∧ ¬B, A↔ B

valid A ∨ ¬A, A→ A, A↔ ¬(¬A)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 19 / 120

Page 77: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Models, validity, satisfiability

Definition (model)

A model for a formula ϕ is an interpretation I that makes ϕ true (I |= ϕ).

I = {A 7→ 1, B 7→ 0} is a model for A ∨B, but not for A ∧B.

Definition (satisfiable, valid)

A formula ϕ is called satisfiable if it has a model.A formula ϕ is called valid (|= ϕ) if every interpretation is a model (i.e. ifit is a tautology).

satisfiable A, A ∨B, A ∧ ¬B, A↔ B

valid A ∨ ¬A, A→ A, A↔ ¬(¬A)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 19 / 120

Page 78: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Outline

1 propositional and first-order logic

1 syntax and semantics of propositional logic2 reasoning

1 resolution2 tableaus

3 syntax and semantics of first-order logic4 reasoning

2 Prolog

3 modal and description logics

4 Semantic Web

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 20 / 120

Page 79: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Reasoning in propositional logic

Determine if a formula ϕ is

valid (a tautology, i.e. every interpretation is a model)satisfiable (there is a model)unsatisfiable (there are no models)

Determine if a formula ϕ implies another formula ψ (ϕ |= ψ),i.e every model for ϕ is a model for ψ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 21 / 120

Page 80: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Reasoning in propositional logic

Determine if a formula ϕ is

valid (a tautology, i.e. every interpretation is a model)satisfiable (there is a model)unsatisfiable (there are no models)

Determine if a formula ϕ implies another formula ψ (ϕ |= ψ),i.e every model for ϕ is a model for ψ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 21 / 120

Page 81: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

A formula can be shown to be a tautology by using known equivalences:

Example: reductio ad absurdum

(A→ B) ∧ (A→ ¬B)→ ¬A

definition of → (twice)(¬A ∨B) ∧ (¬A ∨ ¬B)→ ¬A definition of →¬((¬A ∨B) ∧ (¬A ∨ ¬B)) ∨ ¬A De Morgan¬(¬A ∨B) ∨ ¬(¬A ∨ ¬B) ∨ ¬A De Morgan (twice)

(A ∧ ¬B) ∨ (A ∧B) ∨ ¬A distributivity(A ∧ (¬B ∨B)) ∨ ¬A excluded middle

(A ∧ >) ∨ ¬A > is neutral element for ∧A ∨ ¬A excluded middle>

Drawbacks:

One has to guess which transformation to use.

Failure to prove ϕ does not imply that ϕ is not valid.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 22 / 120

Page 82: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

A formula can be shown to be a tautology by using known equivalences:

Example: reductio ad absurdum

(A→ B) ∧ (A→ ¬B)→ ¬A definition of → (twice)(¬A ∨B) ∧ (¬A ∨ ¬B)→ ¬A

definition of →¬((¬A ∨B) ∧ (¬A ∨ ¬B)) ∨ ¬A De Morgan¬(¬A ∨B) ∨ ¬(¬A ∨ ¬B) ∨ ¬A De Morgan (twice)

(A ∧ ¬B) ∨ (A ∧B) ∨ ¬A distributivity(A ∧ (¬B ∨B)) ∨ ¬A excluded middle

(A ∧ >) ∨ ¬A > is neutral element for ∧A ∨ ¬A excluded middle>

Drawbacks:

One has to guess which transformation to use.

Failure to prove ϕ does not imply that ϕ is not valid.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 22 / 120

Page 83: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

A formula can be shown to be a tautology by using known equivalences:

Example: reductio ad absurdum

(A→ B) ∧ (A→ ¬B)→ ¬A definition of → (twice)(¬A ∨B) ∧ (¬A ∨ ¬B)→ ¬A definition of →¬((¬A ∨B) ∧ (¬A ∨ ¬B)) ∨ ¬A

De Morgan¬(¬A ∨B) ∨ ¬(¬A ∨ ¬B) ∨ ¬A De Morgan (twice)

(A ∧ ¬B) ∨ (A ∧B) ∨ ¬A distributivity(A ∧ (¬B ∨B)) ∨ ¬A excluded middle

(A ∧ >) ∨ ¬A > is neutral element for ∧A ∨ ¬A excluded middle>

Drawbacks:

One has to guess which transformation to use.

Failure to prove ϕ does not imply that ϕ is not valid.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 22 / 120

Page 84: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

A formula can be shown to be a tautology by using known equivalences:

Example: reductio ad absurdum

(A→ B) ∧ (A→ ¬B)→ ¬A definition of → (twice)(¬A ∨B) ∧ (¬A ∨ ¬B)→ ¬A definition of →¬((¬A ∨B) ∧ (¬A ∨ ¬B)) ∨ ¬A De Morgan¬(¬A ∨B) ∨ ¬(¬A ∨ ¬B) ∨ ¬A

De Morgan (twice)(A ∧ ¬B) ∨ (A ∧B) ∨ ¬A distributivity

(A ∧ (¬B ∨B)) ∨ ¬A excluded middle(A ∧ >) ∨ ¬A > is neutral element for ∧

A ∨ ¬A excluded middle>

Drawbacks:

One has to guess which transformation to use.

Failure to prove ϕ does not imply that ϕ is not valid.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 22 / 120

Page 85: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

A formula can be shown to be a tautology by using known equivalences:

Example: reductio ad absurdum

(A→ B) ∧ (A→ ¬B)→ ¬A definition of → (twice)(¬A ∨B) ∧ (¬A ∨ ¬B)→ ¬A definition of →¬((¬A ∨B) ∧ (¬A ∨ ¬B)) ∨ ¬A De Morgan¬(¬A ∨B) ∨ ¬(¬A ∨ ¬B) ∨ ¬A De Morgan (twice)

(A ∧ ¬B) ∨ (A ∧B) ∨ ¬A

distributivity(A ∧ (¬B ∨B)) ∨ ¬A excluded middle

(A ∧ >) ∨ ¬A > is neutral element for ∧A ∨ ¬A excluded middle>

Drawbacks:

One has to guess which transformation to use.

Failure to prove ϕ does not imply that ϕ is not valid.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 22 / 120

Page 86: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

A formula can be shown to be a tautology by using known equivalences:

Example: reductio ad absurdum

(A→ B) ∧ (A→ ¬B)→ ¬A definition of → (twice)(¬A ∨B) ∧ (¬A ∨ ¬B)→ ¬A definition of →¬((¬A ∨B) ∧ (¬A ∨ ¬B)) ∨ ¬A De Morgan¬(¬A ∨B) ∨ ¬(¬A ∨ ¬B) ∨ ¬A De Morgan (twice)

(A ∧ ¬B) ∨ (A ∧B) ∨ ¬A distributivity(A ∧ (¬B ∨B)) ∨ ¬A

excluded middle(A ∧ >) ∨ ¬A > is neutral element for ∧

A ∨ ¬A excluded middle>

Drawbacks:

One has to guess which transformation to use.

Failure to prove ϕ does not imply that ϕ is not valid.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 22 / 120

Page 87: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

A formula can be shown to be a tautology by using known equivalences:

Example: reductio ad absurdum

(A→ B) ∧ (A→ ¬B)→ ¬A definition of → (twice)(¬A ∨B) ∧ (¬A ∨ ¬B)→ ¬A definition of →¬((¬A ∨B) ∧ (¬A ∨ ¬B)) ∨ ¬A De Morgan¬(¬A ∨B) ∨ ¬(¬A ∨ ¬B) ∨ ¬A De Morgan (twice)

(A ∧ ¬B) ∨ (A ∧B) ∨ ¬A distributivity(A ∧ (¬B ∨B)) ∨ ¬A excluded middle

(A ∧ >) ∨ ¬A

> is neutral element for ∧A ∨ ¬A excluded middle>

Drawbacks:

One has to guess which transformation to use.

Failure to prove ϕ does not imply that ϕ is not valid.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 22 / 120

Page 88: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

A formula can be shown to be a tautology by using known equivalences:

Example: reductio ad absurdum

(A→ B) ∧ (A→ ¬B)→ ¬A definition of → (twice)(¬A ∨B) ∧ (¬A ∨ ¬B)→ ¬A definition of →¬((¬A ∨B) ∧ (¬A ∨ ¬B)) ∨ ¬A De Morgan¬(¬A ∨B) ∨ ¬(¬A ∨ ¬B) ∨ ¬A De Morgan (twice)

(A ∧ ¬B) ∨ (A ∧B) ∨ ¬A distributivity(A ∧ (¬B ∨B)) ∨ ¬A excluded middle

(A ∧ >) ∨ ¬A > is neutral element for ∧A ∨ ¬A

excluded middle>

Drawbacks:

One has to guess which transformation to use.

Failure to prove ϕ does not imply that ϕ is not valid.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 22 / 120

Page 89: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

A formula can be shown to be a tautology by using known equivalences:

Example: reductio ad absurdum

(A→ B) ∧ (A→ ¬B)→ ¬A definition of → (twice)(¬A ∨B) ∧ (¬A ∨ ¬B)→ ¬A definition of →¬((¬A ∨B) ∧ (¬A ∨ ¬B)) ∨ ¬A De Morgan¬(¬A ∨B) ∨ ¬(¬A ∨ ¬B) ∨ ¬A De Morgan (twice)

(A ∧ ¬B) ∨ (A ∧B) ∨ ¬A distributivity(A ∧ (¬B ∨B)) ∨ ¬A excluded middle

(A ∧ >) ∨ ¬A > is neutral element for ∧A ∨ ¬A excluded middle>

Drawbacks:

One has to guess which transformation to use.

Failure to prove ϕ does not imply that ϕ is not valid.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 22 / 120

Page 90: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

A formula can be shown to be a tautology by using known equivalences:

Example: reductio ad absurdum

(A→ B) ∧ (A→ ¬B)→ ¬A definition of → (twice)(¬A ∨B) ∧ (¬A ∨ ¬B)→ ¬A definition of →¬((¬A ∨B) ∧ (¬A ∨ ¬B)) ∨ ¬A De Morgan¬(¬A ∨B) ∨ ¬(¬A ∨ ¬B) ∨ ¬A De Morgan (twice)

(A ∧ ¬B) ∨ (A ∧B) ∨ ¬A distributivity(A ∧ (¬B ∨B)) ∨ ¬A excluded middle

(A ∧ >) ∨ ¬A > is neutral element for ∧A ∨ ¬A excluded middle>

Drawbacks:

One has to guess which transformation to use.

Failure to prove ϕ does not imply that ϕ is not valid.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 22 / 120

Page 91: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

The same result can be shown using a truth table:

Example: reductio ad absurdum

A B C := A→ B D := A→ ¬B C ∧D ¬A C ∧D → ¬A0 0 1 1 1 1 1

0 1 1 1 1 1 11 0 0 1 0 0 11 1 1 0 0 0 1

Problems:

inefficient, especially with many propositional variables

redundant, since many valuation changes do not affect results

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 23 / 120

Page 92: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

The same result can be shown using a truth table:

Example: reductio ad absurdum

A B C := A→ B D := A→ ¬B C ∧D ¬A C ∧D → ¬A0 0 1 1 1 1 10 1 1 1 1 1 1

1 0 0 1 0 0 11 1 1 0 0 0 1

Problems:

inefficient, especially with many propositional variables

redundant, since many valuation changes do not affect results

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 23 / 120

Page 93: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

The same result can be shown using a truth table:

Example: reductio ad absurdum

A B C := A→ B D := A→ ¬B C ∧D ¬A C ∧D → ¬A0 0 1 1 1 1 10 1 1 1 1 1 11 0 0 1 0 0 1

1 1 1 0 0 0 1

Problems:

inefficient, especially with many propositional variables

redundant, since many valuation changes do not affect results

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 23 / 120

Page 94: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

The same result can be shown using a truth table:

Example: reductio ad absurdum

A B C := A→ B D := A→ ¬B C ∧D ¬A C ∧D → ¬A0 0 1 1 1 1 10 1 1 1 1 1 11 0 0 1 0 0 11 1 1 0 0 0 1

Problems:

inefficient, especially with many propositional variables

redundant, since many valuation changes do not affect results

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 23 / 120

Page 95: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Showing that a formula is valid

The same result can be shown using a truth table:

Example: reductio ad absurdum

A B C := A→ B D := A→ ¬B C ∧D ¬A C ∧D → ¬A0 0 1 1 1 1 10 1 1 1 1 1 11 0 0 1 0 0 11 1 1 0 0 0 1

Problems:

inefficient, especially with many propositional variables

redundant, since many valuation changes do not affect results

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 23 / 120

Page 96: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: reasoning

Prove that the following formula is a tautology

A ∧B → C ↔ A→ (B → C)

using

a) known equivalences,

b) a truth table.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 24 / 120

Page 97: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Outline

1 propositional and first-order logic

1 syntax and semantics of propositional logic2 reasoning

1 resolution2 tableaus

3 syntax and semantics of first-order logic4 reasoning

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 25 / 120

Page 98: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution

method to test satisfiability of a propositional formula ϕ

introduced in 1965 by John Robinson

can also be used to test

validity: |= ϕ holds iff ¬ϕ is usatisfiable.(logical) implication: ϕ |= ψ holds iff ϕ ∧ ¬ψ is unsatisfiable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 26 / 120

Page 99: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution

method to test satisfiability of a propositional formula ϕ

introduced in 1965 by John Robinson

can also be used to test

validity: |= ϕ holds iff ¬ϕ is usatisfiable.(logical) implication: ϕ |= ψ holds iff ϕ ∧ ¬ψ is unsatisfiable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 26 / 120

Page 100: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution principle

Find contradiction in ϕ

operate on set of disjunctions (clauses)

find pairs of contradictory literals L,L in clauses C1, C2

generate resolvent C3 by joining C1 and C2 (parent clauses) andeliminating L and L

C3 is not equivalent to C1 ∧ C2!C1 ∧ C2 satisfiable ; C3 satisfiableC3 unsatisfiable ; C1 ∧ C2 unsatisfiable

empty clause 2: contradiction

Example (ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X)

X ∨ Y ¬Y ∨ Z ¬Z ¬X

X ∨ ZX

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 27 / 120

Page 101: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution principle

Find contradiction in ϕ

operate on set of disjunctions (clauses)

find pairs of contradictory literals L,L in clauses C1, C2

generate resolvent C3 by joining C1 and C2 (parent clauses) andeliminating L and L

C3 is not equivalent to C1 ∧ C2!C1 ∧ C2 satisfiable ; C3 satisfiableC3 unsatisfiable ; C1 ∧ C2 unsatisfiable

empty clause 2: contradiction

Example (ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X)

X ∨ Y ¬Y ∨ Z ¬Z ¬X

X ∨ ZX

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 27 / 120

Page 102: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution principle

Find contradiction in ϕ

operate on set of disjunctions (clauses)

find pairs of contradictory literals L,L in clauses C1, C2

generate resolvent C3 by joining C1 and C2 (parent clauses) andeliminating L and L

C3 is not equivalent to C1 ∧ C2!C1 ∧ C2 satisfiable ; C3 satisfiableC3 unsatisfiable ; C1 ∧ C2 unsatisfiable

empty clause 2: contradiction

Example (ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X)

X ∨ Y ¬Y ∨ Z ¬Z ¬X

X ∨ ZX

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 27 / 120

Page 103: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution principle

Find contradiction in ϕ

operate on set of disjunctions (clauses)

find pairs of contradictory literals L,L in clauses C1, C2

generate resolvent C3 by joining C1 and C2 (parent clauses) andeliminating L and L

C3 is not equivalent to C1 ∧ C2!C1 ∧ C2 satisfiable ; C3 satisfiableC3 unsatisfiable ; C1 ∧ C2 unsatisfiable

empty clause 2: contradiction

Example (ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X)

X ∨ Y ¬Y ∨ Z ¬Z ¬XX ∨ Z

X2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 27 / 120

Page 104: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution principle

Find contradiction in ϕ

operate on set of disjunctions (clauses)

find pairs of contradictory literals L,L in clauses C1, C2

generate resolvent C3 by joining C1 and C2 (parent clauses) andeliminating L and L

C3 is not equivalent to C1 ∧ C2!

C1 ∧ C2 satisfiable ; C3 satisfiableC3 unsatisfiable ; C1 ∧ C2 unsatisfiable

empty clause 2: contradiction

Example (ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X)

X ∨ Y ¬Y ∨ Z ¬Z ¬XX ∨ Z

X2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 27 / 120

Page 105: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution principle

Find contradiction in ϕ

operate on set of disjunctions (clauses)

find pairs of contradictory literals L,L in clauses C1, C2

generate resolvent C3 by joining C1 and C2 (parent clauses) andeliminating L and L

C3 is not equivalent to C1 ∧ C2!C1 ∧ C2 satisfiable ; C3 satisfiable

C3 unsatisfiable ; C1 ∧ C2 unsatisfiable

empty clause 2: contradiction

Example (ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X)

X ∨ Y ¬Y ∨ Z ¬Z ¬XX ∨ Z

X2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 27 / 120

Page 106: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution principle

Find contradiction in ϕ

operate on set of disjunctions (clauses)

find pairs of contradictory literals L,L in clauses C1, C2

generate resolvent C3 by joining C1 and C2 (parent clauses) andeliminating L and L

C3 is not equivalent to C1 ∧ C2!C1 ∧ C2 satisfiable ; C3 satisfiableC3 unsatisfiable ; C1 ∧ C2 unsatisfiable

empty clause 2: contradiction

Example (ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X)

X ∨ Y ¬Y ∨ Z ¬Z ¬XX ∨ Z

X2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 27 / 120

Page 107: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution principle

Find contradiction in ϕ

operate on set of disjunctions (clauses)

find pairs of contradictory literals L,L in clauses C1, C2

generate resolvent C3 by joining C1 and C2 (parent clauses) andeliminating L and L

C3 is not equivalent to C1 ∧ C2!C1 ∧ C2 satisfiable ; C3 satisfiableC3 unsatisfiable ; C1 ∧ C2 unsatisfiable

empty clause 2: contradiction

Example (ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X)

X ∨ Y ¬Y ∨ Z ¬Z ¬XX ∨ Z

X

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 27 / 120

Page 108: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution principle

Find contradiction in ϕ

operate on set of disjunctions (clauses)

find pairs of contradictory literals L,L in clauses C1, C2

generate resolvent C3 by joining C1 and C2 (parent clauses) andeliminating L and L

C3 is not equivalent to C1 ∧ C2!C1 ∧ C2 satisfiable ; C3 satisfiableC3 unsatisfiable ; C1 ∧ C2 unsatisfiable

empty clause 2: contradiction

Example (ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X)

X ∨ Y ¬Y ∨ Z ¬Z ¬XX ∨ Z

X2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 27 / 120

Page 109: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution principle

Find contradiction in ϕ

operate on set of disjunctions (clauses)

find pairs of contradictory literals L,L in clauses C1, C2

generate resolvent C3 by joining C1 and C2 (parent clauses) andeliminating L and L

C3 is not equivalent to C1 ∧ C2!C1 ∧ C2 satisfiable ; C3 satisfiableC3 unsatisfiable ; C1 ∧ C2 unsatisfiable

empty clause 2: contradiction

Example (ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X)

X ∨ Y ¬Y ∨ Z ¬Z ¬XX ∨ Z

X2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 27 / 120

Page 110: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Literals and their negations

Definition (Literal)

A literal is a (possibly negated) propositional variable.

Example

For the set of variables {A,B}, the set of possible literals is{A,¬A,B,¬B}.

Definition (Negation of a literal)

The negation L of a literal L is defined as follows

for a variable A: A = ¬A;

for a negated variable ¬A: ¬A = A

Example

B = ¬B; ¬C = C, . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 28 / 120

Page 111: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Literals and their negations

Definition (Literal)

A literal is a (possibly negated) propositional variable.

Example

For the set of variables {A,B}, the set of possible literals is{A,¬A,B,¬B}.

Definition (Negation of a literal)

The negation L of a literal L is defined as follows

for a variable A: A = ¬A;

for a negated variable ¬A: ¬A = A

Example

B = ¬B; ¬C = C, . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 28 / 120

Page 112: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Literals and their negations

Definition (Literal)

A literal is a (possibly negated) propositional variable.

Example

For the set of variables {A,B}, the set of possible literals is{A,¬A,B,¬B}.

Definition (Negation of a literal)

The negation L of a literal L is defined as follows

for a variable A: A = ¬A;

for a negated variable ¬A: ¬A = A

Example

B = ¬B; ¬C = C, . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 28 / 120

Page 113: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Literals and their negations

Definition (Literal)

A literal is a (possibly negated) propositional variable.

Example

For the set of variables {A,B}, the set of possible literals is{A,¬A,B,¬B}.

Definition (Negation of a literal)

The negation L of a literal L is defined as follows

for a variable A: A = ¬A;

for a negated variable ¬A: ¬A = A

Example

B = ¬B; ¬C = C, . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 28 / 120

Page 114: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Conjunctive Normal Form

Conjunctive Normal Form

A propositional formula ϕ is in conjunctive normal form (CNF) if ϕ is aconjunction of disjunctions of literals.

Example

(X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X is in CNF;(X ∧ Y ) ∨ ¬(¬Y ∨ Z) is not in CNF.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 29 / 120

Page 115: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Conjunctive Normal Form

Conjunctive Normal Form

A propositional formula ϕ is in conjunctive normal form (CNF) if ϕ is aconjunction of disjunctions of literals.

Example

(X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X is in CNF;

(X ∧ Y ) ∨ ¬(¬Y ∨ Z) is not in CNF.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 29 / 120

Page 116: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Conjunctive Normal Form

Conjunctive Normal Form

A propositional formula ϕ is in conjunctive normal form (CNF) if ϕ is aconjunction of disjunctions of literals.

Example

(X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X is in CNF;(X ∧ Y ) ∨ ¬(¬Y ∨ Z) is not in CNF.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 29 / 120

Page 117: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Transformation into CNF

Theorem

Every propositional formula can be transformed into an equivalent formulain CNF.

Goal: (L1 ∨ L2 ∨ L3) ∧ (L4 ∨ L5) ∧ L6 . . .

1. eliminate material implication ϕ→ ψ ; ¬ϕ ∨ ψ1. and material equivalence ϕ↔ ψ ; ϕ ∧ ψ ∨ ¬ϕ ∧ ¬ψ2. De Morgan’s laws ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ3. eliminate double negation ¬¬ϕ ; ϕ4. distributivity ϕ ∨ (ψ ∧ χ) ; (ϕ ∨ ψ) ∧ (ϕ ∨ χ)5. associativity ϕ ∨ (ψ ∨ χ) ; ϕ ∨ ψ ∨ χ

Example

(X ∧ Y )∨¬(¬Y ∨Z) ; (X ∨ Y )∧ (Y ∨ Y )∧ (X ∨¬Z)∧ (Y ∨¬Z)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 30 / 120

Page 118: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Transformation into CNF

Theorem

Every propositional formula can be transformed into an equivalent formulain CNF.

Goal: (L1 ∨ L2 ∨ L3) ∧ (L4 ∨ L5) ∧ L6 . . .

1. eliminate material implication ϕ→ ψ ; ¬ϕ ∨ ψ1. and material equivalence ϕ↔ ψ ; ϕ ∧ ψ ∨ ¬ϕ ∧ ¬ψ2. De Morgan’s laws ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ3. eliminate double negation ¬¬ϕ ; ϕ4. distributivity ϕ ∨ (ψ ∧ χ) ; (ϕ ∨ ψ) ∧ (ϕ ∨ χ)5. associativity ϕ ∨ (ψ ∨ χ) ; ϕ ∨ ψ ∨ χ

Example

(X ∧ Y )∨¬(¬Y ∨Z) ; (X ∨ Y )∧ (Y ∨ Y )∧ (X ∨¬Z)∧ (Y ∨¬Z)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 30 / 120

Page 119: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Transformation into CNF

Theorem

Every propositional formula can be transformed into an equivalent formulain CNF.

Goal: (L1 ∨ L2 ∨ L3) ∧ (L4 ∨ L5) ∧ L6 . . .

1. eliminate material implication ϕ→ ψ ; ¬ϕ ∨ ψ1. and material equivalence ϕ↔ ψ ; ϕ ∧ ψ ∨ ¬ϕ ∧ ¬ψ

2. De Morgan’s laws ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ3. eliminate double negation ¬¬ϕ ; ϕ4. distributivity ϕ ∨ (ψ ∧ χ) ; (ϕ ∨ ψ) ∧ (ϕ ∨ χ)5. associativity ϕ ∨ (ψ ∨ χ) ; ϕ ∨ ψ ∨ χ

Example

(X ∧ Y )∨¬(¬Y ∨Z) ; (X ∨ Y )∧ (Y ∨ Y )∧ (X ∨¬Z)∧ (Y ∨¬Z)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 30 / 120

Page 120: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Transformation into CNF

Theorem

Every propositional formula can be transformed into an equivalent formulain CNF.

Goal: (L1 ∨ L2 ∨ L3) ∧ (L4 ∨ L5) ∧ L6 . . .

1. eliminate material implication ϕ→ ψ ; ¬ϕ ∨ ψ1. and material equivalence ϕ↔ ψ ; ϕ ∧ ψ ∨ ¬ϕ ∧ ¬ψ2. De Morgan’s laws ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ

3. eliminate double negation ¬¬ϕ ; ϕ4. distributivity ϕ ∨ (ψ ∧ χ) ; (ϕ ∨ ψ) ∧ (ϕ ∨ χ)5. associativity ϕ ∨ (ψ ∨ χ) ; ϕ ∨ ψ ∨ χ

Example

(X ∧ Y )∨¬(¬Y ∨Z) ; (X ∨ Y )∧ (Y ∨ Y )∧ (X ∨¬Z)∧ (Y ∨¬Z)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 30 / 120

Page 121: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Transformation into CNF

Theorem

Every propositional formula can be transformed into an equivalent formulain CNF.

Goal: (L1 ∨ L2 ∨ L3) ∧ (L4 ∨ L5) ∧ L6 . . .

1. eliminate material implication ϕ→ ψ ; ¬ϕ ∨ ψ1. and material equivalence ϕ↔ ψ ; ϕ ∧ ψ ∨ ¬ϕ ∧ ¬ψ2. De Morgan’s laws ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ3. eliminate double negation ¬¬ϕ ; ϕ

4. distributivity ϕ ∨ (ψ ∧ χ) ; (ϕ ∨ ψ) ∧ (ϕ ∨ χ)5. associativity ϕ ∨ (ψ ∨ χ) ; ϕ ∨ ψ ∨ χ

Example

(X ∧ Y )∨¬(¬Y ∨Z) ; (X ∨ Y )∧ (Y ∨ Y )∧ (X ∨¬Z)∧ (Y ∨¬Z)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 30 / 120

Page 122: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Transformation into CNF

Theorem

Every propositional formula can be transformed into an equivalent formulain CNF.

Goal: (L1 ∨ L2 ∨ L3) ∧ (L4 ∨ L5) ∧ L6 . . .

1. eliminate material implication ϕ→ ψ ; ¬ϕ ∨ ψ1. and material equivalence ϕ↔ ψ ; ϕ ∧ ψ ∨ ¬ϕ ∧ ¬ψ2. De Morgan’s laws ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ3. eliminate double negation ¬¬ϕ ; ϕ4. distributivity ϕ ∨ (ψ ∧ χ) ; (ϕ ∨ ψ) ∧ (ϕ ∨ χ)

5. associativity ϕ ∨ (ψ ∨ χ) ; ϕ ∨ ψ ∨ χ

Example

(X ∧ Y )∨¬(¬Y ∨Z) ; (X ∨ Y )∧ (Y ∨ Y )∧ (X ∨¬Z)∧ (Y ∨¬Z)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 30 / 120

Page 123: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Transformation into CNF

Theorem

Every propositional formula can be transformed into an equivalent formulain CNF.

Goal: (L1 ∨ L2 ∨ L3) ∧ (L4 ∨ L5) ∧ L6 . . .

1. eliminate material implication ϕ→ ψ ; ¬ϕ ∨ ψ1. and material equivalence ϕ↔ ψ ; ϕ ∧ ψ ∨ ¬ϕ ∧ ¬ψ2. De Morgan’s laws ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ3. eliminate double negation ¬¬ϕ ; ϕ4. distributivity ϕ ∨ (ψ ∧ χ) ; (ϕ ∨ ψ) ∧ (ϕ ∨ χ)5. associativity ϕ ∨ (ψ ∨ χ) ; ϕ ∨ ψ ∨ χ

Example

(X ∧ Y )∨¬(¬Y ∨Z) ; (X ∨ Y )∧ (Y ∨ Y )∧ (X ∨¬Z)∧ (Y ∨¬Z)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 30 / 120

Page 124: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Transformation into CNF

Theorem

Every propositional formula can be transformed into an equivalent formulain CNF.

Goal: (L1 ∨ L2 ∨ L3) ∧ (L4 ∨ L5) ∧ L6 . . .

1. eliminate material implication ϕ→ ψ ; ¬ϕ ∨ ψ1. and material equivalence ϕ↔ ψ ; ϕ ∧ ψ ∨ ¬ϕ ∧ ¬ψ2. De Morgan’s laws ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ3. eliminate double negation ¬¬ϕ ; ϕ4. distributivity ϕ ∨ (ψ ∧ χ) ; (ϕ ∨ ψ) ∧ (ϕ ∨ χ)5. associativity ϕ ∨ (ψ ∨ χ) ; ϕ ∨ ψ ∨ χ

Example

(X ∧ Y )∨¬(¬Y ∨Z) ; (X ∨ Y )∧ (Y ∨ Y )∧ (X ∨¬Z)∧ (Y ∨¬Z)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 30 / 120

Page 125: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: Conjunctive Normal Form

Transform the following formulas into CNF:

(X ∨ Y ) ∧ (A ∧B)

(X ∨ Y )→ (A ∨B)

X ∨ (¬A ∧ ¬(B ∧ ¬C))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 31 / 120

Page 126: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Clauses

Definition (Clause)

A clause is a disjunction of literals, written as a set.

Example

(X ∨ ¬Y ∨ Z) ; {X,¬Y,Z}

Every propositional formula can be written as a set of clauses.

ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬XK(ϕ) = {{X,Y }, {¬Y, Z}, {¬Z}, {¬X}}

Intuitively:

∧ between the sets

∨ between the elements of the sets

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 32 / 120

Page 127: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Clauses

Definition (Clause)

A clause is a disjunction of literals, written as a set.

Example

(X ∨ ¬Y ∨ Z) ; {X,¬Y,Z}

Every propositional formula can be written as a set of clauses.

ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬XK(ϕ) = {{X,Y }, {¬Y, Z}, {¬Z}, {¬X}}

Intuitively:

∧ between the sets

∨ between the elements of the sets

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 32 / 120

Page 128: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Clauses

Definition (Clause)

A clause is a disjunction of literals, written as a set.

Example

(X ∨ ¬Y ∨ Z) ; {X,¬Y,Z}

Every propositional formula can be written as a set of clauses.

ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬X

K(ϕ) = {{X,Y }, {¬Y, Z}, {¬Z}, {¬X}}

Intuitively:

∧ between the sets

∨ between the elements of the sets

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 32 / 120

Page 129: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Clauses

Definition (Clause)

A clause is a disjunction of literals, written as a set.

Example

(X ∨ ¬Y ∨ Z) ; {X,¬Y,Z}

Every propositional formula can be written as a set of clauses.

ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬XK(ϕ) = {{X,Y }, {¬Y, Z}, {¬Z}, {¬X}}

Intuitively:

∧ between the sets

∨ between the elements of the sets

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 32 / 120

Page 130: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Clauses

Definition (Clause)

A clause is a disjunction of literals, written as a set.

Example

(X ∨ ¬Y ∨ Z) ; {X,¬Y,Z}

Every propositional formula can be written as a set of clauses.

ϕ = (X ∨ Y ) ∧ (¬Y ∨ Z) ∧ ¬Z ∧ ¬XK(ϕ) = {{X,Y }, {¬Y, Z}, {¬Z}, {¬X}}

Intuitively:

∧ between the sets

∨ between the elements of the sets

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 32 / 120

Page 131: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution of clauses

We have two clauses C1 = {X,Y } and C2 = {¬Y , Z}.We are looking for a model for C1 ∧ C2.

In an interpretation I, Y I is either 0 or 1.

if Y I = 1 holds, then CI1 = 1 and CI2 = 1 iff ZI = 1;

if Y I = 0 holds, then CI2 = 1 and CI1 = 1 iff XI = 1.

Every model for C1 and C2 is also a model for C3 = {X,Z}.If {C1, C2} is satisfiable, then {C1, C2, C3} is also satisfiable.

Definition (Resolvent)

Let C1 = {L1, L2, L3, . . .} and C2 = {L1, L6, L7, . . .} be propositionalclauses. Then C3 = {L2, L3, . . . , L6, L7, . . .} is called the resolvent of C1

and C2 ({C1, C2} ` C3).

If a clause C can be obtained from a clause set S using several resolutionsteps, we write S `∗ C.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 33 / 120

Page 132: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution of clauses

We have two clauses C1 = {X,Y } and C2 = {¬Y , Z}.We are looking for a model for C1 ∧ C2.

In an interpretation I, Y I is either 0 or 1.

if Y I = 1 holds, then CI1 = 1 and CI2 = 1 iff ZI = 1;

if Y I = 0 holds, then CI2 = 1 and CI1 = 1 iff XI = 1.

Every model for C1 and C2 is also a model for C3 = {X,Z}.If {C1, C2} is satisfiable, then {C1, C2, C3} is also satisfiable.

Definition (Resolvent)

Let C1 = {L1, L2, L3, . . .} and C2 = {L1, L6, L7, . . .} be propositionalclauses. Then C3 = {L2, L3, . . . , L6, L7, . . .} is called the resolvent of C1

and C2 ({C1, C2} ` C3).

If a clause C can be obtained from a clause set S using several resolutionsteps, we write S `∗ C.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 33 / 120

Page 133: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution of clauses

We have two clauses C1 = {X,Y } and C2 = {¬Y , Z}.We are looking for a model for C1 ∧ C2.

In an interpretation I, Y I is either 0 or 1.

if Y I = 1 holds, then CI1 = 1 and CI2 = 1 iff ZI = 1;

if Y I = 0 holds, then CI2 = 1 and CI1 = 1 iff XI = 1.

Every model for C1 and C2 is also a model for C3 = {X,Z}.

If {C1, C2} is satisfiable, then {C1, C2, C3} is also satisfiable.

Definition (Resolvent)

Let C1 = {L1, L2, L3, . . .} and C2 = {L1, L6, L7, . . .} be propositionalclauses. Then C3 = {L2, L3, . . . , L6, L7, . . .} is called the resolvent of C1

and C2 ({C1, C2} ` C3).

If a clause C can be obtained from a clause set S using several resolutionsteps, we write S `∗ C.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 33 / 120

Page 134: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution of clauses

We have two clauses C1 = {X,Y } and C2 = {¬Y , Z}.We are looking for a model for C1 ∧ C2.

In an interpretation I, Y I is either 0 or 1.

if Y I = 1 holds, then CI1 = 1 and CI2 = 1 iff ZI = 1;

if Y I = 0 holds, then CI2 = 1 and CI1 = 1 iff XI = 1.

Every model for C1 and C2 is also a model for C3 = {X,Z}.If {C1, C2} is satisfiable, then {C1, C2, C3} is also satisfiable.

Definition (Resolvent)

Let C1 = {L1, L2, L3, . . .} and C2 = {L1, L6, L7, . . .} be propositionalclauses. Then C3 = {L2, L3, . . . , L6, L7, . . .} is called the resolvent of C1

and C2 ({C1, C2} ` C3).

If a clause C can be obtained from a clause set S using several resolutionsteps, we write S `∗ C.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 33 / 120

Page 135: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution of clauses

We have two clauses C1 = {X,Y } and C2 = {¬Y , Z}.We are looking for a model for C1 ∧ C2.

In an interpretation I, Y I is either 0 or 1.

if Y I = 1 holds, then CI1 = 1 and CI2 = 1 iff ZI = 1;

if Y I = 0 holds, then CI2 = 1 and CI1 = 1 iff XI = 1.

Every model for C1 and C2 is also a model for C3 = {X,Z}.If {C1, C2} is satisfiable, then {C1, C2, C3} is also satisfiable.

Definition (Resolvent)

Let C1 = {L1, L2, L3, . . .} and C2 = {L1, L6, L7, . . .} be propositionalclauses. Then C3 = {L2, L3, . . . , L6, L7, . . .} is called the resolvent of C1

and C2 ({C1, C2} ` C3).

If a clause C can be obtained from a clause set S using several resolutionsteps, we write S `∗ C.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 33 / 120

Page 136: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution of clauses

We have two clauses C1 = {X,Y } and C2 = {¬Y , Z}.We are looking for a model for C1 ∧ C2.

In an interpretation I, Y I is either 0 or 1.

if Y I = 1 holds, then CI1 = 1 and CI2 = 1 iff ZI = 1;

if Y I = 0 holds, then CI2 = 1 and CI1 = 1 iff XI = 1.

Every model for C1 and C2 is also a model for C3 = {X,Z}.If {C1, C2} is satisfiable, then {C1, C2, C3} is also satisfiable.

Definition (Resolvent)

Let C1 = {L1, L2, L3, . . .} and C2 = {L1, L6, L7, . . .} be propositionalclauses. Then C3 = {L2, L3, . . . , L6, L7, . . .} is called the resolvent of C1

and C2 ({C1, C2} ` C3).

If a clause C can be obtained from a clause set S using several resolutionsteps, we write S `∗ C.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 33 / 120

Page 137: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: Resolution

Find as many resolvents as possible for the clause set S.

S = {{A,B,¬C}, {B,C,D}, {¬D}, {¬A,D}, {¬B,¬E}, {D,E}}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 34 / 120

Page 138: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Using resolution to test satisfiability

Let S ` C.

Every model for S is also a model for C.

If S is satisfiable, then so is S ∪ {C}.If S ∪ {C} is unsatisfiable, then so is S.

The empty clause 2 is unsatisfiable.(It is obtained by resolving A and ¬A for some A.)

Theorem (soundness of resolution)

Let S be a set of clauses.If 2 can be obtained from S by resolution, then S is unsatisfiable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 35 / 120

Page 139: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Using resolution to test satisfiability

Let S ` C.

Every model for S is also a model for C.

If S is satisfiable, then so is S ∪ {C}.

If S ∪ {C} is unsatisfiable, then so is S.

The empty clause 2 is unsatisfiable.(It is obtained by resolving A and ¬A for some A.)

Theorem (soundness of resolution)

Let S be a set of clauses.If 2 can be obtained from S by resolution, then S is unsatisfiable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 35 / 120

Page 140: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Using resolution to test satisfiability

Let S ` C.

Every model for S is also a model for C.

If S is satisfiable, then so is S ∪ {C}.If S ∪ {C} is unsatisfiable, then so is S.

The empty clause 2 is unsatisfiable.(It is obtained by resolving A and ¬A for some A.)

Theorem (soundness of resolution)

Let S be a set of clauses.If 2 can be obtained from S by resolution, then S is unsatisfiable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 35 / 120

Page 141: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Using resolution to test satisfiability

Let S ` C.

Every model for S is also a model for C.

If S is satisfiable, then so is S ∪ {C}.If S ∪ {C} is unsatisfiable, then so is S.

The empty clause 2 is unsatisfiable.(It is obtained by resolving A and ¬A for some A.)

Theorem (soundness of resolution)

Let S be a set of clauses.If 2 can be obtained from S by resolution, then S is unsatisfiable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 35 / 120

Page 142: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Using resolution to test satisfiability

Let S ` C.

Every model for S is also a model for C.

If S is satisfiable, then so is S ∪ {C}.If S ∪ {C} is unsatisfiable, then so is S.

The empty clause 2 is unsatisfiable.(It is obtained by resolving A and ¬A for some A.)

Theorem (soundness of resolution)

Let S be a set of clauses.If 2 can be obtained from S by resolution, then S is unsatisfiable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 35 / 120

Page 143: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Using resolution to test satisfiability

Let S ` C.

Every model for S is also a model for C.

If S is satisfiable, then so is S ∪ {C}.If S ∪ {C} is unsatisfiable, then so is S.

The empty clause 2 is unsatisfiable.(It is obtained by resolving A and ¬A for some A.)

Theorem (soundness of resolution)

Let S be a set of clauses.If 2 can be obtained from S by resolution, then S is unsatisfiable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 35 / 120

Page 144: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: transform ϕ into CNF2: initialise C with disjunctions of ϕ3: while there is C3 = res(C1, C2) with C3 /∈ C do4: if C3 = 2 then5: output “unsatisfiable”6: else7: C := C ∪ {C3}8: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 36 / 120

Page 145: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: transform ϕ into CNF

2: initialise C with disjunctions of ϕ3: while there is C3 = res(C1, C2) with C3 /∈ C do4: if C3 = 2 then5: output “unsatisfiable”6: else7: C := C ∪ {C3}8: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 36 / 120

Page 146: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: transform ϕ into CNF2: initialise C with disjunctions of ϕ

3: while there is C3 = res(C1, C2) with C3 /∈ C do4: if C3 = 2 then5: output “unsatisfiable”6: else7: C := C ∪ {C3}8: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 36 / 120

Page 147: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: transform ϕ into CNF2: initialise C with disjunctions of ϕ3: while there is C3 = res(C1, C2) with C3 /∈ C do

4: if C3 = 2 then5: output “unsatisfiable”6: else7: C := C ∪ {C3}8: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 36 / 120

Page 148: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: transform ϕ into CNF2: initialise C with disjunctions of ϕ3: while there is C3 = res(C1, C2) with C3 /∈ C do4: if C3 = 2 then5: output “unsatisfiable”

6: else7: C := C ∪ {C3}8: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 36 / 120

Page 149: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: transform ϕ into CNF2: initialise C with disjunctions of ϕ3: while there is C3 = res(C1, C2) with C3 /∈ C do4: if C3 = 2 then5: output “unsatisfiable”6: else7: C := C ∪ {C3}

8: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 36 / 120

Page 150: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: transform ϕ into CNF2: initialise C with disjunctions of ϕ3: while there is C3 = res(C1, C2) with C3 /∈ C do4: if C3 = 2 then5: output “unsatisfiable”6: else7: C := C ∪ {C3}8: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 36 / 120

Page 151: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Properties of the resolution algorithm

Theorem (soundness)

K(ϕ) `∗ 2 implies unsatisfiability of ϕ.

Theorem (refutation completeness)

If ϕ is unsatisfiable, then K(ϕ) `∗ 2 holds.

Theorem (termination)

The resolution algorithm terminates for every input.

Proof.

Only new clauses are added.

New clauses contain only literals from the input.

Clauses are never removed.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 37 / 120

Page 152: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Properties of the resolution algorithm

Theorem (soundness)

K(ϕ) `∗ 2 implies unsatisfiability of ϕ.

Theorem (refutation completeness)

If ϕ is unsatisfiable, then K(ϕ) `∗ 2 holds.

Theorem (termination)

The resolution algorithm terminates for every input.

Proof.

Only new clauses are added.

New clauses contain only literals from the input.

Clauses are never removed.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 37 / 120

Page 153: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Properties of the resolution algorithm

Theorem (soundness)

K(ϕ) `∗ 2 implies unsatisfiability of ϕ.

Theorem (refutation completeness)

If ϕ is unsatisfiable, then K(ϕ) `∗ 2 holds.

Theorem (termination)

The resolution algorithm terminates for every input.

Proof.

Only new clauses are added.

New clauses contain only literals from the input.

Clauses are never removed.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 37 / 120

Page 154: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Properties of the resolution algorithm

Theorem (soundness)

K(ϕ) `∗ 2 implies unsatisfiability of ϕ.

Theorem (refutation completeness)

If ϕ is unsatisfiable, then K(ϕ) `∗ 2 holds.

Theorem (termination)

The resolution algorithm terminates for every input.

Proof.

Only new clauses are added.

New clauses contain only literals from the input.

Clauses are never removed.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 37 / 120

Page 155: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Properties of the resolution algorithm

Theorem (soundness)

K(ϕ) `∗ 2 implies unsatisfiability of ϕ.

Theorem (refutation completeness)

If ϕ is unsatisfiable, then K(ϕ) `∗ 2 holds.

Theorem (termination)

The resolution algorithm terminates for every input.

Proof.

Only new clauses are added.

New clauses contain only literals from the input.

Clauses are never removed.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 37 / 120

Page 156: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Properties of the resolution algorithm

Theorem (soundness)

K(ϕ) `∗ 2 implies unsatisfiability of ϕ.

Theorem (refutation completeness)

If ϕ is unsatisfiable, then K(ϕ) `∗ 2 holds.

Theorem (termination)

The resolution algorithm terminates for every input.

Proof.

Only new clauses are added.

New clauses contain only literals from the input.

Clauses are never removed.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 37 / 120

Page 157: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and non-determinism

If several possibilities for new resolvents exist:

the algorithm will terminate for every choice

. . . but some choices will be faster than others

Definition (don’t-care-nondeterminism)

An algorithm is called don’t-care-nondeterministic if at any point withseveral choices every choice will lead to a solution.

no backtracking required

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 38 / 120

Page 158: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and non-determinism

If several possibilities for new resolvents exist:

the algorithm will terminate for every choice

. . . but some choices will be faster than others

Definition (don’t-care-nondeterminism)

An algorithm is called don’t-care-nondeterministic if at any point withseveral choices every choice will lead to a solution.

no backtracking required

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 38 / 120

Page 159: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and non-determinism

If several possibilities for new resolvents exist:

the algorithm will terminate for every choice

. . . but some choices will be faster than others

Definition (don’t-care-nondeterminism)

An algorithm is called don’t-care-nondeterministic if at any point withseveral choices every choice will lead to a solution.

no backtracking required

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 38 / 120

Page 160: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and non-determinism

If several possibilities for new resolvents exist:

the algorithm will terminate for every choice

. . . but some choices will be faster than others

Definition (don’t-care-nondeterminism)

An algorithm is called don’t-care-nondeterministic if at any point withseveral choices every choice will lead to a solution.

no backtracking required

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 38 / 120

Page 161: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Turning natural language into propositional formulas

1 If John is not sick and he is invited to the meeting, he attends it.¬S ∧ I → A ; S ∨ ¬I ∨A

2 If the boss wants John at the meeting, he invites him.B → I ; ¬B ∨ I

3 If the boss does not want John at the meeting, John will be fired.¬B → F ; B ∨ F

4 John did not attend the meeting. ¬A5 John is not sick. ¬S6 Conjecture: John will be fired. F

To test if the conjecture is valid, we check if the premises together withthe negation of the conjecture are satisfiable.

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 39 / 120

Page 162: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Turning natural language into propositional formulas

1 If John is not sick and he is invited to the meeting, he attends it.¬S ∧ I → A ; S ∨ ¬I ∨A

2 If the boss wants John at the meeting, he invites him.B → I ; ¬B ∨ I

3 If the boss does not want John at the meeting, John will be fired.¬B → F ; B ∨ F

4 John did not attend the meeting. ¬A5 John is not sick. ¬S6 Conjecture: John will be fired. F

To test if the conjecture is valid, we check if the premises together withthe negation of the conjecture are satisfiable.

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 39 / 120

Page 163: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Turning natural language into propositional formulas

1 If John is not sick and he is invited to the meeting, he attends it.¬S ∧ I → A ; S ∨ ¬I ∨A

2 If the boss wants John at the meeting, he invites him.B → I ; ¬B ∨ I

3 If the boss does not want John at the meeting, John will be fired.¬B → F ; B ∨ F

4 John did not attend the meeting. ¬A5 John is not sick. ¬S6 Conjecture: John will be fired. F

To test if the conjecture is valid, we check if the premises together withthe negation of the conjecture are satisfiable.

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 39 / 120

Page 164: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Turning natural language into propositional formulas

1 If John is not sick and he is invited to the meeting, he attends it.¬S ∧ I → A ; S ∨ ¬I ∨A

2 If the boss wants John at the meeting, he invites him.B → I ; ¬B ∨ I

3 If the boss does not want John at the meeting, John will be fired.¬B → F ; B ∨ F

4 John did not attend the meeting. ¬A

5 John is not sick. ¬S6 Conjecture: John will be fired. F

To test if the conjecture is valid, we check if the premises together withthe negation of the conjecture are satisfiable.

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 39 / 120

Page 165: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Turning natural language into propositional formulas

1 If John is not sick and he is invited to the meeting, he attends it.¬S ∧ I → A ; S ∨ ¬I ∨A

2 If the boss wants John at the meeting, he invites him.B → I ; ¬B ∨ I

3 If the boss does not want John at the meeting, John will be fired.¬B → F ; B ∨ F

4 John did not attend the meeting. ¬A5 John is not sick. ¬S

6 Conjecture: John will be fired. F

To test if the conjecture is valid, we check if the premises together withthe negation of the conjecture are satisfiable.

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 39 / 120

Page 166: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Turning natural language into propositional formulas

1 If John is not sick and he is invited to the meeting, he attends it.¬S ∧ I → A ; S ∨ ¬I ∨A

2 If the boss wants John at the meeting, he invites him.B → I ; ¬B ∨ I

3 If the boss does not want John at the meeting, John will be fired.¬B → F ; B ∨ F

4 John did not attend the meeting. ¬A5 John is not sick. ¬S6 Conjecture: John will be fired. F

To test if the conjecture is valid, we check if the premises together withthe negation of the conjecture are satisfiable.

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 39 / 120

Page 167: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Turning natural language into propositional formulas

1 If John is not sick and he is invited to the meeting, he attends it.¬S ∧ I → A ; S ∨ ¬I ∨A

2 If the boss wants John at the meeting, he invites him.B → I ; ¬B ∨ I

3 If the boss does not want John at the meeting, John will be fired.¬B → F ; B ∨ F

4 John did not attend the meeting. ¬A5 John is not sick. ¬S6 Conjecture: John will be fired. F

To test if the conjecture is valid, we check if the premises together withthe negation of the conjecture are satisfiable.

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 39 / 120

Page 168: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining John’s future by resolution

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

S,¬I, A ¬A

S,¬I

¬B, I B, F

I, F

S, F ¬S

F ¬F

2

So unfortunately, the conjecture is valid and John will be fired . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 40 / 120

Page 169: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining John’s future by resolution

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

S,¬I, A ¬A

S,¬I

¬B, I B, F

I, F

S, F ¬S

F ¬F

2

So unfortunately, the conjecture is valid and John will be fired . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 40 / 120

Page 170: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining John’s future by resolution

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

S,¬I, A ¬A

S,¬I

¬B, I B, F

I, F

S, F ¬S

F ¬F

2

So unfortunately, the conjecture is valid and John will be fired . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 40 / 120

Page 171: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining John’s future by resolution

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

S,¬I, A ¬A

S,¬I

¬B, I B, F

I, F

S, F

¬S

F ¬F

2

So unfortunately, the conjecture is valid and John will be fired . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 40 / 120

Page 172: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining John’s future by resolution

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

S,¬I, A ¬A

S,¬I

¬B, I B, F

I, F

S, F ¬S

F ¬F

2

So unfortunately, the conjecture is valid and John will be fired . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 40 / 120

Page 173: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining John’s future by resolution

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

S,¬I, A ¬A

S,¬I

¬B, I B, F

I, F

S, F ¬S

F

¬F

2

So unfortunately, the conjecture is valid and John will be fired . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 40 / 120

Page 174: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining John’s future by resolution

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

S,¬I, A ¬A

S,¬I

¬B, I B, F

I, F

S, F ¬S

F ¬F

2

So unfortunately, the conjecture is valid and John will be fired . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 40 / 120

Page 175: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining John’s future by resolution

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

S,¬I, A ¬A

S,¬I

¬B, I B, F

I, F

S, F ¬S

F ¬F

2

So unfortunately, the conjecture is valid and John will be fired . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 40 / 120

Page 176: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining John’s future by resolution

{{S,¬I, A}, {¬B, I}, {B,F}, {¬A}, {¬S}, {¬F}}

S,¬I, A ¬A

S,¬I

¬B, I B, F

I, F

S, F ¬S

F ¬F

2

So unfortunately, the conjecture is valid and John will be fired . . .

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 40 / 120

Page 177: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining the answer using a truth table

1 S,¬I, A2 ¬B, I3 B,F

4 ¬A5 ¬S6 F

S I A B F 1 2 3 4 5 6 1 ∧ . . . ∧ 5 ∧ ¬6

0 0 0 0 0 1 1 0 1 1 0 00 0 0 0 1 1 1 1 1 1 1 0

......

...1 0 1 0 0 1 1 0 0 0 0 0

......

...1 1 1 1 1 1 1 1 0 0 1 0

The only valuation that makes clauses 1–5 true also makes clause 6true (line 2).

The last column always remains 0.

The conjecture follows from the premises.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 41 / 120

Page 178: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining the answer using a truth table

1 S,¬I, A2 ¬B, I3 B,F

4 ¬A5 ¬S6 F

S I A B F 1 2 3 4 5 6 1 ∧ . . . ∧ 5 ∧ ¬6

0 0 0 0 0 1 1 0 1 1 0 00 0 0 0 1 1 1 1 1 1 1 0

......

...1 0 1 0 0 1 1 0 0 0 0 0

......

...1 1 1 1 1 1 1 1 0 0 1 0

The only valuation that makes clauses 1–5 true also makes clause 6true (line 2).

The last column always remains 0.

The conjecture follows from the premises.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 41 / 120

Page 179: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining the answer using a truth table

1 S,¬I, A2 ¬B, I3 B,F

4 ¬A5 ¬S6 F

S I A B F 1 2 3 4 5 6 1 ∧ . . . ∧ 5 ∧ ¬6

0 0 0 0 0 1 1 0 1 1 0 0

0 0 0 0 1 1 1 1 1 1 1 0...

......

1 0 1 0 0 1 1 0 0 0 0 0...

......

1 1 1 1 1 1 1 1 0 0 1 0

The only valuation that makes clauses 1–5 true also makes clause 6true (line 2).

The last column always remains 0.

The conjecture follows from the premises.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 41 / 120

Page 180: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining the answer using a truth table

1 S,¬I, A2 ¬B, I3 B,F

4 ¬A5 ¬S6 F

S I A B F 1 2 3 4 5 6 1 ∧ . . . ∧ 5 ∧ ¬6

0 0 0 0 0 1 1 0 1 1 0 00 0 0 0 1 1 1 1 1 1 1 0

......

...1 0 1 0 0 1 1 0 0 0 0 0

......

...1 1 1 1 1 1 1 1 0 0 1 0

The only valuation that makes clauses 1–5 true also makes clause 6true (line 2).

The last column always remains 0.

The conjecture follows from the premises.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 41 / 120

Page 181: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Determining the answer using a truth table

1 S,¬I, A2 ¬B, I3 B,F

4 ¬A5 ¬S6 F

S I A B F 1 2 3 4 5 6 1 ∧ . . . ∧ 5 ∧ ¬6

0 0 0 0 0 1 1 0 1 1 0 00 0 0 0 1 1 1 1 1 1 1 0

......

...1 0 1 0 0 1 1 0 0 0 0 0

......

...1 1 1 1 1 1 1 1 0 0 1 0

The only valuation that makes clauses 1–5 true also makes clause 6true (line 2).

The last column always remains 0.

The conjecture follows from the premises.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 41 / 120

Page 182: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: resolution algorithm

Inspector Craig is called to a jewelry store that has been subject to arobbery where three suspects, Austin, Brian, and Colin, were arrested.After evaluation of all facts, this is known:

1 At least one of the suspects is guilty.

2 If Austin is guilty he had exactly one accomplice.

3 If Brian is innocent, so is Colin.

4 If exactly two suspects are guilty, Colin is one of them.

5 If Colin is innocent then Austin is guilty.

6 Conjecture: Brian and Colin are guilty.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 42 / 120

Page 183: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Optimisation of the resolution procedure

Choosing the right parent clauses is crucial for practical efficiency.

Heuristics:

prioritise short clauses

prioritise clauses with high derivation depth ; depth-first search

ignore tautologies {X,¬X, . . .}ignore C1 if C2 ⊆ C1 exists

perform resolution with more than two clauses (hyperresolution)

Restriction to special cases, e.g. Horn formulas

Horn clause: at most one positive literal

X ∧ Y ∧ Z . . .→W

useful for rule-based systems (Prolog)

polynomial runtime

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 43 / 120

Page 184: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Optimisation of the resolution procedure

Choosing the right parent clauses is crucial for practical efficiency.

Heuristics:

prioritise short clauses

prioritise clauses with high derivation depth ; depth-first search

ignore tautologies {X,¬X, . . .}ignore C1 if C2 ⊆ C1 exists

perform resolution with more than two clauses (hyperresolution)

Restriction to special cases, e.g. Horn formulas

Horn clause: at most one positive literal

X ∧ Y ∧ Z . . .→W

useful for rule-based systems (Prolog)

polynomial runtime

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 43 / 120

Page 185: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Optimisation of the resolution procedure

Choosing the right parent clauses is crucial for practical efficiency.

Heuristics:

prioritise short clauses

prioritise clauses with high derivation depth ; depth-first search

ignore tautologies {X,¬X, . . .}ignore C1 if C2 ⊆ C1 exists

perform resolution with more than two clauses (hyperresolution)

Restriction to special cases, e.g. Horn formulas

Horn clause: at most one positive literal

X ∧ Y ∧ Z . . .→W

useful for rule-based systems (Prolog)

polynomial runtime

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 43 / 120

Page 186: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Optimisation of the resolution procedure

Choosing the right parent clauses is crucial for practical efficiency.

Heuristics:

prioritise short clauses

prioritise clauses with high derivation depth ; depth-first search

ignore tautologies {X,¬X, . . .}

ignore C1 if C2 ⊆ C1 exists

perform resolution with more than two clauses (hyperresolution)

Restriction to special cases, e.g. Horn formulas

Horn clause: at most one positive literal

X ∧ Y ∧ Z . . .→W

useful for rule-based systems (Prolog)

polynomial runtime

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 43 / 120

Page 187: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Optimisation of the resolution procedure

Choosing the right parent clauses is crucial for practical efficiency.

Heuristics:

prioritise short clauses

prioritise clauses with high derivation depth ; depth-first search

ignore tautologies {X,¬X, . . .}ignore C1 if C2 ⊆ C1 exists

perform resolution with more than two clauses (hyperresolution)

Restriction to special cases, e.g. Horn formulas

Horn clause: at most one positive literal

X ∧ Y ∧ Z . . .→W

useful for rule-based systems (Prolog)

polynomial runtime

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 43 / 120

Page 188: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Optimisation of the resolution procedure

Choosing the right parent clauses is crucial for practical efficiency.

Heuristics:

prioritise short clauses

prioritise clauses with high derivation depth ; depth-first search

ignore tautologies {X,¬X, . . .}ignore C1 if C2 ⊆ C1 exists

perform resolution with more than two clauses (hyperresolution)

Restriction to special cases, e.g. Horn formulas

Horn clause: at most one positive literal

X ∧ Y ∧ Z . . .→W

useful for rule-based systems (Prolog)

polynomial runtime

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 43 / 120

Page 189: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Optimisation of the resolution procedure

Choosing the right parent clauses is crucial for practical efficiency.

Heuristics:

prioritise short clauses

prioritise clauses with high derivation depth ; depth-first search

ignore tautologies {X,¬X, . . .}ignore C1 if C2 ⊆ C1 exists

perform resolution with more than two clauses (hyperresolution)

Restriction to special cases, e.g. Horn formulas

Horn clause: at most one positive literal

X ∧ Y ∧ Z . . .→W

useful for rule-based systems (Prolog)

polynomial runtime

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 43 / 120

Page 190: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Optimisation of the resolution procedure

Choosing the right parent clauses is crucial for practical efficiency.

Heuristics:

prioritise short clauses

prioritise clauses with high derivation depth ; depth-first search

ignore tautologies {X,¬X, . . .}ignore C1 if C2 ⊆ C1 exists

perform resolution with more than two clauses (hyperresolution)

Restriction to special cases, e.g. Horn formulas

Horn clause: at most one positive literal

X ∧ Y ∧ Z . . .→W

useful for rule-based systems (Prolog)

polynomial runtime

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 43 / 120

Page 191: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Optimisation of the resolution procedure

Choosing the right parent clauses is crucial for practical efficiency.

Heuristics:

prioritise short clauses

prioritise clauses with high derivation depth ; depth-first search

ignore tautologies {X,¬X, . . .}ignore C1 if C2 ⊆ C1 exists

perform resolution with more than two clauses (hyperresolution)

Restriction to special cases, e.g. Horn formulas

Horn clause: at most one positive literal

X ∧ Y ∧ Z . . .→W

useful for rule-based systems (Prolog)

polynomial runtime

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 43 / 120

Page 192: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Outline

1 propositional and first-order logic

1 syntax and semantics of propositional logic2 reasoning

1 resolution2 tableaus

3 syntax and semantics of first-order logic4 reasoning

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 44 / 120

Page 193: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithms

Different method to test satisfiability of propositional formulas

resolution: try to find the contradiction

tableau: try to build a model

Properties of tableau algorithms

rules: break down complex formulas into simpler ones“If you have ϕ ∧ ψ but not both ϕ and ψ, add ϕ and ψ.”

clash triggers: define cases when a contradiction has been found“If you have ϕ and ¬ϕ, there is a contradiction.”

tableau: table of formulas that have to be satisfied

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 45 / 120

Page 194: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithms

Different method to test satisfiability of propositional formulas

resolution: try to find the contradiction

tableau: try to build a model

Properties of tableau algorithms

rules: break down complex formulas into simpler ones“If you have ϕ ∧ ψ but not both ϕ and ψ, add ϕ and ψ.”

clash triggers: define cases when a contradiction has been found“If you have ϕ and ¬ϕ, there is a contradiction.”

tableau: table of formulas that have to be satisfied

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 45 / 120

Page 195: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithms

Different method to test satisfiability of propositional formulas

resolution: try to find the contradiction

tableau: try to build a model

Properties of tableau algorithms

rules: break down complex formulas into simpler ones“If you have ϕ ∧ ψ but not both ϕ and ψ, add ϕ and ψ.”

clash triggers: define cases when a contradiction has been found“If you have ϕ and ¬ϕ, there is a contradiction.”

tableau: table of formulas that have to be satisfied

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 45 / 120

Page 196: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithms

Different method to test satisfiability of propositional formulas

resolution: try to find the contradiction

tableau: try to build a model

Properties of tableau algorithms

rules: break down complex formulas into simpler ones“If you have ϕ ∧ ψ but not both ϕ and ψ, add ϕ and ψ.”

clash triggers: define cases when a contradiction has been found“If you have ϕ and ¬ϕ, there is a contradiction.”

tableau: table of formulas that have to be satisfied

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 45 / 120

Page 197: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithms: rules

precondition: describes which kind of formula is processed“If you have ϕ ∧ ψ . . . ”

applicability condition: describes when a rule is not applicable anymore, toensure termination“. . . and not both ϕ and ψ, . . . ”

postcondition: describes what to do to process the formula“. . . add ϕ and ψ.”

Rules can require testing different alternatives:

“If you have ϕ ∨ ψ . . . , add ϕ or ψ”

This means: split the current table column,try ϕ in one column, ψ in the other one

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 46 / 120

Page 198: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithms: rules

precondition: describes which kind of formula is processed“If you have ϕ ∧ ψ . . . ”

applicability condition: describes when a rule is not applicable anymore, toensure termination“. . . and not both ϕ and ψ, . . . ”

postcondition: describes what to do to process the formula“. . . add ϕ and ψ.”

Rules can require testing different alternatives:

“If you have ϕ ∨ ψ . . . , add ϕ or ψ”

This means: split the current table column,try ϕ in one column, ψ in the other one

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 46 / 120

Page 199: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithms: rules

precondition: describes which kind of formula is processed“If you have ϕ ∧ ψ . . . ”

applicability condition: describes when a rule is not applicable anymore, toensure termination“. . . and not both ϕ and ψ, . . . ”

postcondition: describes what to do to process the formula“. . . add ϕ and ψ.”

Rules can require testing different alternatives:

“If you have ϕ ∨ ψ . . . , add ϕ or ψ”

This means: split the current table column,try ϕ in one column, ψ in the other one

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 46 / 120

Page 200: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithms: rules

precondition: describes which kind of formula is processed“If you have ϕ ∧ ψ . . . ”

applicability condition: describes when a rule is not applicable anymore, toensure termination“. . . and not both ϕ and ψ, . . . ”

postcondition: describes what to do to process the formula“. . . add ϕ and ψ.”

Rules can require testing different alternatives:

“If you have ϕ ∨ ψ . . . , add ϕ or ψ”

This means: split the current table column,try ϕ in one column, ψ in the other one

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 46 / 120

Page 201: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithms: termination

The algorithm terminates if

there is one clash-free column where no rules are applicable; satisfiable

all columns contain to a clash; unsatisfiable

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 47 / 120

Page 202: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: initialise S with {ϕ}2: while there is a formula ϕ in S to which a rule R is applicable do3: apply R to ϕ4: if every column contains a clash then5: output “unsatisfiable”6: else7: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 48 / 120

Page 203: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: initialise S with {ϕ}

2: while there is a formula ϕ in S to which a rule R is applicable do3: apply R to ϕ4: if every column contains a clash then5: output “unsatisfiable”6: else7: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 48 / 120

Page 204: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: initialise S with {ϕ}2: while there is a formula ϕ in S to which a rule R is applicable do3: apply R to ϕ

4: if every column contains a clash then5: output “unsatisfiable”6: else7: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 48 / 120

Page 205: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for propositional logic

input: propositional formula ϕoutput: “satisfiable” or “unsatisfiable”

1: initialise S with {ϕ}2: while there is a formula ϕ in S to which a rule R is applicable do3: apply R to ϕ4: if every column contains a clash then5: output “unsatisfiable”6: else7: output “satisfiable”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 48 / 120

Page 206: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules for propositional logic

∧ If ϕ ∧ ψ ∈ S and {ϕ,ψ} * Sthen S := S ∪ {ϕ,ψ}

∨ If ϕ ∨ ψ ∈ S and {ϕ,ψ} ∩ S = ∅then S := S ∪ {ϕ} or S := S ∪ {ψ}

→ If ϕ→ ψ ∈ S and {¬ϕ,ψ} ∩ S = ∅then S := S ∪ {¬ϕ} or S := S ∪ {ψ}

↔ If ϕ↔ ψ ∈ S and {ϕ,ψ} ∩ S = ∅ and {¬ϕ,¬ψ} ∩ S = ∅then S := S ∪ {ϕ,ψ} or S := S ∪ {¬ϕ,¬ψ}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 49 / 120

Page 207: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules for propositional logic

∧ If ϕ ∧ ψ ∈ S and {ϕ,ψ} * Sthen S := S ∪ {ϕ,ψ}

∨ If ϕ ∨ ψ ∈ S and {ϕ,ψ} ∩ S = ∅then S := S ∪ {ϕ} or S := S ∪ {ψ}

→ If ϕ→ ψ ∈ S and {¬ϕ,ψ} ∩ S = ∅then S := S ∪ {¬ϕ} or S := S ∪ {ψ}

↔ If ϕ↔ ψ ∈ S and {ϕ,ψ} ∩ S = ∅ and {¬ϕ,¬ψ} ∩ S = ∅then S := S ∪ {ϕ,ψ} or S := S ∪ {¬ϕ,¬ψ}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 49 / 120

Page 208: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules for propositional logic

∧ If ϕ ∧ ψ ∈ S and {ϕ,ψ} * Sthen S := S ∪ {ϕ,ψ}

∨ If ϕ ∨ ψ ∈ S and {ϕ,ψ} ∩ S = ∅then S := S ∪ {ϕ} or S := S ∪ {ψ}

→ If ϕ→ ψ ∈ S and {¬ϕ,ψ} ∩ S = ∅then S := S ∪ {¬ϕ} or S := S ∪ {ψ}

↔ If ϕ↔ ψ ∈ S and {ϕ,ψ} ∩ S = ∅ and {¬ϕ,¬ψ} ∩ S = ∅then S := S ∪ {ϕ,ψ} or S := S ∪ {¬ϕ,¬ψ}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 49 / 120

Page 209: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules for propositional logic

∧ If ϕ ∧ ψ ∈ S and {ϕ,ψ} * Sthen S := S ∪ {ϕ,ψ}

∨ If ϕ ∨ ψ ∈ S and {ϕ,ψ} ∩ S = ∅then S := S ∪ {ϕ} or S := S ∪ {ψ}

→ If ϕ→ ψ ∈ S and {¬ϕ,ψ} ∩ S = ∅then S := S ∪ {¬ϕ} or S := S ∪ {ψ}

↔ If ϕ↔ ψ ∈ S and {ϕ,ψ} ∩ S = ∅ and {¬ϕ,¬ψ} ∩ S = ∅then S := S ∪ {ϕ,ψ} or S := S ∪ {¬ϕ,¬ψ}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 49 / 120

Page 210: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules: negated formulas

¬∧ If ¬(ϕ ∧ ψ) ∈ S and {¬ϕ,¬ψ} ∩ S = ∅then S := S ∪ {¬ϕ} or S := S ∪ {¬ψ}

¬∨ If ¬(ϕ ∨ ψ) ∈ S and {¬ϕ,¬ψ} * Sthen S := S ∪ {¬ϕ,¬ψ}

¬ → If ¬(ϕ→ ψ) ∈ S and {ϕ,¬ψ} * Sthen S := S ∪ {ϕ,¬ψ}

¬ ↔ If ¬(ϕ↔ ψ) ∈ S and {ϕ ∨ ψ,¬ϕ ∨ ¬ψ} * Sthen S := S ∪ {ϕ ∨ ψ,¬ϕ ∨ ¬ψ}

¬¬ If ¬(¬ϕ) ∈ S and ϕ /∈ Sthen S := S ∪ {ϕ}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 50 / 120

Page 211: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules: negated formulas

¬∧ If ¬(ϕ ∧ ψ) ∈ S and {¬ϕ,¬ψ} ∩ S = ∅then S := S ∪ {¬ϕ} or S := S ∪ {¬ψ}

¬∨ If ¬(ϕ ∨ ψ) ∈ S and {¬ϕ,¬ψ} * Sthen S := S ∪ {¬ϕ,¬ψ}

¬ → If ¬(ϕ→ ψ) ∈ S and {ϕ,¬ψ} * Sthen S := S ∪ {ϕ,¬ψ}

¬ ↔ If ¬(ϕ↔ ψ) ∈ S and {ϕ ∨ ψ,¬ϕ ∨ ¬ψ} * Sthen S := S ∪ {ϕ ∨ ψ,¬ϕ ∨ ¬ψ}

¬¬ If ¬(¬ϕ) ∈ S and ϕ /∈ Sthen S := S ∪ {ϕ}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 50 / 120

Page 212: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules: negated formulas

¬∧ If ¬(ϕ ∧ ψ) ∈ S and {¬ϕ,¬ψ} ∩ S = ∅then S := S ∪ {¬ϕ} or S := S ∪ {¬ψ}

¬∨ If ¬(ϕ ∨ ψ) ∈ S and {¬ϕ,¬ψ} * Sthen S := S ∪ {¬ϕ,¬ψ}

¬ → If ¬(ϕ→ ψ) ∈ S and {ϕ,¬ψ} * Sthen S := S ∪ {ϕ,¬ψ}

¬ ↔ If ¬(ϕ↔ ψ) ∈ S and {ϕ ∨ ψ,¬ϕ ∨ ¬ψ} * Sthen S := S ∪ {ϕ ∨ ψ,¬ϕ ∨ ¬ψ}

¬¬ If ¬(¬ϕ) ∈ S and ϕ /∈ Sthen S := S ∪ {ϕ}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 50 / 120

Page 213: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules: negated formulas

¬∧ If ¬(ϕ ∧ ψ) ∈ S and {¬ϕ,¬ψ} ∩ S = ∅then S := S ∪ {¬ϕ} or S := S ∪ {¬ψ}

¬∨ If ¬(ϕ ∨ ψ) ∈ S and {¬ϕ,¬ψ} * Sthen S := S ∪ {¬ϕ,¬ψ}

¬ → If ¬(ϕ→ ψ) ∈ S and {ϕ,¬ψ} * Sthen S := S ∪ {ϕ,¬ψ}

¬ ↔ If ¬(ϕ↔ ψ) ∈ S and {ϕ ∨ ψ,¬ϕ ∨ ¬ψ} * Sthen S := S ∪ {ϕ ∨ ψ,¬ϕ ∨ ¬ψ}

¬¬ If ¬(¬ϕ) ∈ S and ϕ /∈ Sthen S := S ∪ {ϕ}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 50 / 120

Page 214: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules: negated formulas

¬∧ If ¬(ϕ ∧ ψ) ∈ S and {¬ϕ,¬ψ} ∩ S = ∅then S := S ∪ {¬ϕ} or S := S ∪ {¬ψ}

¬∨ If ¬(ϕ ∨ ψ) ∈ S and {¬ϕ,¬ψ} * Sthen S := S ∪ {¬ϕ,¬ψ}

¬ → If ¬(ϕ→ ψ) ∈ S and {ϕ,¬ψ} * Sthen S := S ∪ {ϕ,¬ψ}

¬ ↔ If ¬(ϕ↔ ψ) ∈ S and {ϕ ∨ ψ,¬ϕ ∨ ¬ψ} * Sthen S := S ∪ {ϕ ∨ ψ,¬ϕ ∨ ¬ψ}

¬¬ If ¬(¬ϕ) ∈ S and ϕ /∈ Sthen S := S ∪ {ϕ}

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 50 / 120

Page 215: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules

Effectively, only two kinds of rules exist:

deterministic rules that add formulas to the corresponding column

∧, ¬¬, ¬∨, . . .

non-deterministic rules that split the column

∨, →, ↔, . . .

For efficiency reasons, deterministic rules should be applied first.Otherwise, they have to be applied separately in each column.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 51 / 120

Page 216: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules

Effectively, only two kinds of rules exist:

deterministic rules that add formulas to the corresponding column

∧, ¬¬, ¬∨, . . .

non-deterministic rules that split the column

∨, →, ↔, . . .

For efficiency reasons, deterministic rules should be applied first.Otherwise, they have to be applied separately in each column.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 51 / 120

Page 217: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules

Effectively, only two kinds of rules exist:

deterministic rules that add formulas to the corresponding column

∧, ¬¬, ¬∨, . . .

non-deterministic rules that split the column

∨, →, ↔, . . .

For efficiency reasons, deterministic rules should be applied first.Otherwise, they have to be applied separately in each column.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 51 / 120

Page 218: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules

Effectively, only two kinds of rules exist:

deterministic rules that add formulas to the corresponding column

∧, ¬¬, ¬∨, . . .

non-deterministic rules that split the column

∨, →, ↔, . . .

For efficiency reasons, deterministic rules should be applied first.Otherwise, they have to be applied separately in each column.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 51 / 120

Page 219: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules

Effectively, only two kinds of rules exist:

deterministic rules that add formulas to the corresponding column

∧, ¬¬, ¬∨, . . .

non-deterministic rules that split the column

∨, →, ↔, . . .

For efficiency reasons, deterministic rules should be applied first.Otherwise, they have to be applied separately in each column.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 51 / 120

Page 220: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules

Effectively, only two kinds of rules exist:

deterministic rules that add formulas to the corresponding column

∧, ¬¬, ¬∨, . . .

non-deterministic rules that split the column

∨, →, ↔, . . .

For efficiency reasons, deterministic rules should be applied first.Otherwise, they have to be applied separately in each column.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 51 / 120

Page 221: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: determining John’s future with a tableau

Premises: (¬S ∧ I → A); (B → I); (¬B → F ); ¬A; ¬SConjecture: F

Test if premises together with negation of conjecture are satisfiable.(¬S ∧ I → A) ∧ (B → I) ∧ (¬B → F ) ∧ ¬A ∧ ¬S ∧ ¬F

. . . ∧ . . . ∧ . . .(¬S ∧ I → A); (B → I); (¬B → F );¬A;¬S;¬F ¬S ∧ I → A

¬(¬S ∧ I) A ¬(¬S ∧ I)¬¬S ¬I ¬¬SS B → I

¬B I ¬B → F¬¬B F ¬¬BB

all columns contain a clash; ϕ is unsatisfiable; conjecture follows from premises

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 52 / 120

Page 222: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: determining John’s future with a tableau

Premises: (¬S ∧ I → A); (B → I); (¬B → F ); ¬A; ¬SConjecture: F

Test if premises together with negation of conjecture are satisfiable.(¬S ∧ I → A) ∧ (B → I) ∧ (¬B → F ) ∧ ¬A ∧ ¬S ∧ ¬F . . . ∧ . . . ∧ . . .

(¬S ∧ I → A); (B → I); (¬B → F );¬A;¬S;¬F

¬S ∧ I → A¬(¬S ∧ I) A ¬(¬S ∧ I)

¬¬S ¬I ¬¬SS B → I

¬B I ¬B → F¬¬B F ¬¬BB

all columns contain a clash; ϕ is unsatisfiable; conjecture follows from premises

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 52 / 120

Page 223: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: determining John’s future with a tableau

Premises: (¬S ∧ I → A); (B → I); (¬B → F ); ¬A; ¬SConjecture: F

Test if premises together with negation of conjecture are satisfiable.(¬S ∧ I → A) ∧ (B → I) ∧ (¬B → F ) ∧ ¬A ∧ ¬S ∧ ¬F . . . ∧ . . . ∧ . . .

(¬S ∧ I → A); (B → I); (¬B → F );¬A;¬S;¬F ¬S ∧ I → A¬(¬S ∧ I) A

¬(¬S ∧ I)¬¬S ¬I ¬¬SS B → I

¬B I ¬B → F¬¬B F ¬¬BB

all columns contain a clash; ϕ is unsatisfiable; conjecture follows from premises

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 52 / 120

Page 224: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: determining John’s future with a tableau

Premises: (¬S ∧ I → A); (B → I); (¬B → F ); ¬A; ¬SConjecture: F

Test if premises together with negation of conjecture are satisfiable.(¬S ∧ I → A) ∧ (B → I) ∧ (¬B → F ) ∧ ¬A ∧ ¬S ∧ ¬F . . . ∧ . . . ∧ . . .

(¬S ∧ I → A); (B → I); (¬B → F );¬A;¬S;¬F ¬S ∧ I → A¬(¬S ∧ I) A ¬(¬S ∧ I)

¬¬S ¬I

¬¬SS B → I

¬B I ¬B → F¬¬B F ¬¬BB

all columns contain a clash; ϕ is unsatisfiable; conjecture follows from premises

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 52 / 120

Page 225: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: determining John’s future with a tableau

Premises: (¬S ∧ I → A); (B → I); (¬B → F ); ¬A; ¬SConjecture: F

Test if premises together with negation of conjecture are satisfiable.(¬S ∧ I → A) ∧ (B → I) ∧ (¬B → F ) ∧ ¬A ∧ ¬S ∧ ¬F . . . ∧ . . . ∧ . . .

(¬S ∧ I → A); (B → I); (¬B → F );¬A;¬S;¬F ¬S ∧ I → A¬(¬S ∧ I) A ¬(¬S ∧ I)

¬¬S ¬I ¬¬SS

B → I¬B I ¬B → F

¬¬B F ¬¬BB

all columns contain a clash; ϕ is unsatisfiable; conjecture follows from premises

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 52 / 120

Page 226: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: determining John’s future with a tableau

Premises: (¬S ∧ I → A); (B → I); (¬B → F ); ¬A; ¬SConjecture: F

Test if premises together with negation of conjecture are satisfiable.(¬S ∧ I → A) ∧ (B → I) ∧ (¬B → F ) ∧ ¬A ∧ ¬S ∧ ¬F . . . ∧ . . . ∧ . . .

(¬S ∧ I → A); (B → I); (¬B → F );¬A;¬S;¬F ¬S ∧ I → A¬(¬S ∧ I) A ¬(¬S ∧ I)

¬¬S ¬I ¬¬SS B → I

¬B I

¬B → F¬¬B F ¬¬BB

all columns contain a clash; ϕ is unsatisfiable; conjecture follows from premises

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 52 / 120

Page 227: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: determining John’s future with a tableau

Premises: (¬S ∧ I → A); (B → I); (¬B → F ); ¬A; ¬SConjecture: F

Test if premises together with negation of conjecture are satisfiable.(¬S ∧ I → A) ∧ (B → I) ∧ (¬B → F ) ∧ ¬A ∧ ¬S ∧ ¬F . . . ∧ . . . ∧ . . .

(¬S ∧ I → A); (B → I); (¬B → F );¬A;¬S;¬F ¬S ∧ I → A¬(¬S ∧ I) A ¬(¬S ∧ I)

¬¬S ¬I ¬¬SS B → I

¬B I ¬B → F¬¬B F

¬¬BB

all columns contain a clash; ϕ is unsatisfiable; conjecture follows from premises

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 52 / 120

Page 228: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: determining John’s future with a tableau

Premises: (¬S ∧ I → A); (B → I); (¬B → F ); ¬A; ¬SConjecture: F

Test if premises together with negation of conjecture are satisfiable.(¬S ∧ I → A) ∧ (B → I) ∧ (¬B → F ) ∧ ¬A ∧ ¬S ∧ ¬F . . . ∧ . . . ∧ . . .

(¬S ∧ I → A); (B → I); (¬B → F );¬A;¬S;¬F ¬S ∧ I → A¬(¬S ∧ I) A ¬(¬S ∧ I)

¬¬S ¬I ¬¬SS B → I

¬B I ¬B → F¬¬B F ¬¬BB

all columns contain a clash; ϕ is unsatisfiable; conjecture follows from premises

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 52 / 120

Page 229: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: determining John’s future with a tableau

Premises: (¬S ∧ I → A); (B → I); (¬B → F ); ¬A; ¬SConjecture: F

Test if premises together with negation of conjecture are satisfiable.(¬S ∧ I → A) ∧ (B → I) ∧ (¬B → F ) ∧ ¬A ∧ ¬S ∧ ¬F . . . ∧ . . . ∧ . . .

(¬S ∧ I → A); (B → I); (¬B → F );¬A;¬S;¬F ¬S ∧ I → A¬(¬S ∧ I) A ¬(¬S ∧ I)

¬¬S ¬I ¬¬SS B → I

¬B I ¬B → F¬¬B F ¬¬BB

all columns contain a clash; ϕ is unsatisfiable; conjecture follows from premises

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 52 / 120

Page 230: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules and negation normal form

Definition (NNF)

A propostional formula is in negation normal form (NNF) if the only binaryconnectives that appear are ∧ and ∨ and negation only appearsimmediately before propositional variables.

Every propositional formula can be transformed into NNF by

1 eliminating → and ↔2 applying deMorgan’s laws

3 removing double negation

as for CNF.

For formulas in NNF, the only tableau rules that are needed are those forconjunction and disjunction.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 53 / 120

Page 231: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules and negation normal form

Definition (NNF)

A propostional formula is in negation normal form (NNF) if the only binaryconnectives that appear are ∧ and ∨ and negation only appearsimmediately before propositional variables.

Every propositional formula can be transformed into NNF by

1 eliminating → and ↔

2 applying deMorgan’s laws

3 removing double negation

as for CNF.

For formulas in NNF, the only tableau rules that are needed are those forconjunction and disjunction.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 53 / 120

Page 232: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules and negation normal form

Definition (NNF)

A propostional formula is in negation normal form (NNF) if the only binaryconnectives that appear are ∧ and ∨ and negation only appearsimmediately before propositional variables.

Every propositional formula can be transformed into NNF by

1 eliminating → and ↔2 applying deMorgan’s laws

3 removing double negation

as for CNF.

For formulas in NNF, the only tableau rules that are needed are those forconjunction and disjunction.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 53 / 120

Page 233: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules and negation normal form

Definition (NNF)

A propostional formula is in negation normal form (NNF) if the only binaryconnectives that appear are ∧ and ∨ and negation only appearsimmediately before propositional variables.

Every propositional formula can be transformed into NNF by

1 eliminating → and ↔2 applying deMorgan’s laws

3 removing double negation

as for CNF.

For formulas in NNF, the only tableau rules that are needed are those forconjunction and disjunction.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 53 / 120

Page 234: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules and negation normal form

Definition (NNF)

A propostional formula is in negation normal form (NNF) if the only binaryconnectives that appear are ∧ and ∨ and negation only appearsimmediately before propositional variables.

Every propositional formula can be transformed into NNF by

1 eliminating → and ↔2 applying deMorgan’s laws

3 removing double negation

as for CNF.

For formulas in NNF, the only tableau rules that are needed are those forconjunction and disjunction.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 53 / 120

Page 235: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules and negation normal form

Definition (NNF)

A propostional formula is in negation normal form (NNF) if the only binaryconnectives that appear are ∧ and ∨ and negation only appearsimmediately before propositional variables.

Every propositional formula can be transformed into NNF by

1 eliminating → and ↔2 applying deMorgan’s laws

3 removing double negation

as for CNF.

For formulas in NNF, the only tableau rules that are needed are those forconjunction and disjunction.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 53 / 120

Page 236: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau rules and negation normal form

Definition (NNF)

A propostional formula is in negation normal form (NNF) if the only binaryconnectives that appear are ∧ and ∨ and negation only appearsimmediately before propositional variables.

Every propositional formula can be transformed into NNF by

1 eliminating → and ↔2 applying deMorgan’s laws

3 removing double negation

as for CNF.

For formulas in NNF, the only tableau rules that are needed are those forconjunction and disjunction.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 53 / 120

Page 237: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: tableau algorithm

Prove that Brian and Colin are guilty using a tableau.

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

(¬B → ¬C) ∧¬(A ∧B ∧ ¬C) ∧

(¬C → A) ∧¬(B ∧ C)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 54 / 120

Page 238: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus and nondeterminism

if several rules are applicable, the choice which one to apply isdon’t-care-nondeterministic

reminder: every choice leads to a solution

if a rule is nondeterministic (like the ∨-rule), the choice whichalternative to take is don’t-know-nondeterministic

finding of a solution may depend on the choiceall alternatives must be tested

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 55 / 120

Page 239: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus and nondeterminism

if several rules are applicable, the choice which one to apply isdon’t-care-nondeterministic

reminder: every choice leads to a solution

if a rule is nondeterministic (like the ∨-rule), the choice whichalternative to take is don’t-know-nondeterministic

finding of a solution may depend on the choiceall alternatives must be tested

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 55 / 120

Page 240: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus and nondeterminism

if several rules are applicable, the choice which one to apply isdon’t-care-nondeterministic

reminder: every choice leads to a solution

if a rule is nondeterministic (like the ∨-rule), the choice whichalternative to take is don’t-know-nondeterministic

finding of a solution may depend on the choiceall alternatives must be tested

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 55 / 120

Page 241: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus and nondeterminism

if several rules are applicable, the choice which one to apply isdon’t-care-nondeterministic

reminder: every choice leads to a solution

if a rule is nondeterministic (like the ∨-rule), the choice whichalternative to take is don’t-know-nondeterministic

finding of a solution may depend on the choice

all alternatives must be tested

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 55 / 120

Page 242: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus and nondeterminism

if several rules are applicable, the choice which one to apply isdon’t-care-nondeterministic

reminder: every choice leads to a solution

if a rule is nondeterministic (like the ∨-rule), the choice whichalternative to take is don’t-know-nondeterministic

finding of a solution may depend on the choiceall alternatives must be tested

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 55 / 120

Page 243: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Practical application of tableaus

the tree generated by the TA can be exponential in the size of theinput

example: (A ∨B) ∧ (C ∨D) ∧ (E ∨ F )

to save time and space, the TA is created depth-first:

only operate on one branchapply every rule in this branchno clash: abort and output “satisfiable”clash: try next branch

requires storing backtracking information for every application of anon-deterministic rule

another reason to delay application of non-deterministic rules as longas possible

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 56 / 120

Page 244: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Practical application of tableaus

the tree generated by the TA can be exponential in the size of theinput

example: (A ∨B) ∧ (C ∨D) ∧ (E ∨ F )

to save time and space, the TA is created depth-first:

only operate on one branchapply every rule in this branchno clash: abort and output “satisfiable”clash: try next branch

requires storing backtracking information for every application of anon-deterministic rule

another reason to delay application of non-deterministic rules as longas possible

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 56 / 120

Page 245: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Practical application of tableaus

the tree generated by the TA can be exponential in the size of theinput

example: (A ∨B) ∧ (C ∨D) ∧ (E ∨ F )

to save time and space, the TA is created depth-first:

only operate on one branchapply every rule in this branchno clash: abort and output “satisfiable”clash: try next branch

requires storing backtracking information for every application of anon-deterministic rule

another reason to delay application of non-deterministic rules as longas possible

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 56 / 120

Page 246: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Practical application of tableaus

the tree generated by the TA can be exponential in the size of theinput

example: (A ∨B) ∧ (C ∨D) ∧ (E ∨ F )

to save time and space, the TA is created depth-first:

only operate on one branch

apply every rule in this branchno clash: abort and output “satisfiable”clash: try next branch

requires storing backtracking information for every application of anon-deterministic rule

another reason to delay application of non-deterministic rules as longas possible

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 56 / 120

Page 247: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Practical application of tableaus

the tree generated by the TA can be exponential in the size of theinput

example: (A ∨B) ∧ (C ∨D) ∧ (E ∨ F )

to save time and space, the TA is created depth-first:

only operate on one branchapply every rule in this branch

no clash: abort and output “satisfiable”clash: try next branch

requires storing backtracking information for every application of anon-deterministic rule

another reason to delay application of non-deterministic rules as longas possible

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 56 / 120

Page 248: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Practical application of tableaus

the tree generated by the TA can be exponential in the size of theinput

example: (A ∨B) ∧ (C ∨D) ∧ (E ∨ F )

to save time and space, the TA is created depth-first:

only operate on one branchapply every rule in this branchno clash: abort and output “satisfiable”

clash: try next branch

requires storing backtracking information for every application of anon-deterministic rule

another reason to delay application of non-deterministic rules as longas possible

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 56 / 120

Page 249: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Practical application of tableaus

the tree generated by the TA can be exponential in the size of theinput

example: (A ∨B) ∧ (C ∨D) ∧ (E ∨ F )

to save time and space, the TA is created depth-first:

only operate on one branchapply every rule in this branchno clash: abort and output “satisfiable”clash: try next branch

requires storing backtracking information for every application of anon-deterministic rule

another reason to delay application of non-deterministic rules as longas possible

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 56 / 120

Page 250: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Practical application of tableaus

the tree generated by the TA can be exponential in the size of theinput

example: (A ∨B) ∧ (C ∨D) ∧ (E ∨ F )

to save time and space, the TA is created depth-first:

only operate on one branchapply every rule in this branchno clash: abort and output “satisfiable”clash: try next branch

requires storing backtracking information for every application of anon-deterministic rule

another reason to delay application of non-deterministic rules as longas possible

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 56 / 120

Page 251: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Practical application of tableaus

the tree generated by the TA can be exponential in the size of theinput

example: (A ∨B) ∧ (C ∨D) ∧ (E ∨ F )

to save time and space, the TA is created depth-first:

only operate on one branchapply every rule in this branchno clash: abort and output “satisfiable”clash: try next branch

requires storing backtracking information for every application of anon-deterministic rule

another reason to delay application of non-deterministic rules as longas possible

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 56 / 120

Page 252: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus vs. resolution

Advantages of tableaus

fast for satisfiable inputs

no preprocessing necessary (CNF)

generates a model (justification) for satisfiable inputs

Advantages of resolution

fast for unsatisfiable inputs

don’t-care-nondeterministic procedure (no backtracking)

only one operation, easy to optimise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 57 / 120

Page 253: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus vs. resolution

Advantages of tableaus

fast for satisfiable inputs

no preprocessing necessary (CNF)

generates a model (justification) for satisfiable inputs

Advantages of resolution

fast for unsatisfiable inputs

don’t-care-nondeterministic procedure (no backtracking)

only one operation, easy to optimise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 57 / 120

Page 254: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus vs. resolution

Advantages of tableaus

fast for satisfiable inputs

no preprocessing necessary (CNF)

generates a model (justification) for satisfiable inputs

Advantages of resolution

fast for unsatisfiable inputs

don’t-care-nondeterministic procedure (no backtracking)

only one operation, easy to optimise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 57 / 120

Page 255: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus vs. resolution

Advantages of tableaus

fast for satisfiable inputs

no preprocessing necessary (CNF)

generates a model (justification) for satisfiable inputs

Advantages of resolution

fast for unsatisfiable inputs

don’t-care-nondeterministic procedure (no backtracking)

only one operation, easy to optimise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 57 / 120

Page 256: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus vs. resolution

Advantages of tableaus

fast for satisfiable inputs

no preprocessing necessary (CNF)

generates a model (justification) for satisfiable inputs

Advantages of resolution

fast for unsatisfiable inputs

don’t-care-nondeterministic procedure (no backtracking)

only one operation, easy to optimise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 57 / 120

Page 257: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableaus vs. resolution

Advantages of tableaus

fast for satisfiable inputs

no preprocessing necessary (CNF)

generates a model (justification) for satisfiable inputs

Advantages of resolution

fast for unsatisfiable inputs

don’t-care-nondeterministic procedure (no backtracking)

only one operation, easy to optimise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 57 / 120

Page 258: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Outline

1 propositional and first-order logic

1 syntax and semantics of propositional logic2 reasoning

1 resolution2 tableaus

3 syntax and semantics of first-order logic4 reasoning

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 58 / 120

Page 259: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Limitations of propositional logic

PL can only deal with propositions as a whole

propositions can only be true or false

structure of propositions cannot be analysed

Example

Some chickens cannot fly.

All chickens are birds.

Conjecture: Some birds cannot fly.

Translation into PL:

C → ¬F ?

C → B

B → ¬F ?

formalisation is questionable; inference cannot be proved

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 59 / 120

Page 260: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Limitations of propositional logic

PL can only deal with propositions as a whole

propositions can only be true or false

structure of propositions cannot be analysed

Example

Some chickens cannot fly.

All chickens are birds.

Conjecture: Some birds cannot fly.

Translation into PL:

C → ¬F ?

C → B

B → ¬F ?

formalisation is questionable; inference cannot be proved

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 59 / 120

Page 261: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Limitations of propositional logic

PL can only deal with propositions as a whole

propositions can only be true or false

structure of propositions cannot be analysed

Example

Some chickens cannot fly.

All chickens are birds.

Conjecture: Some birds cannot fly.

Translation into PL:

C → ¬F ?

C → B

B → ¬F ?

formalisation is questionable; inference cannot be proved

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 59 / 120

Page 262: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Limitations of propositional logic

PL can only deal with propositions as a whole

propositions can only be true or false

structure of propositions cannot be analysed

Example

Some chickens cannot fly.

All chickens are birds.

Conjecture: Some birds cannot fly.

Translation into PL:

C → ¬F ?

C → B

B → ¬F ?

formalisation is questionable; inference cannot be proved

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 59 / 120

Page 263: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Limitations of propositional logic

PL can only deal with propositions as a whole

propositions can only be true or false

structure of propositions cannot be analysed

Example

Some chickens cannot fly.

All chickens are birds.

Conjecture: Some birds cannot fly.

Translation into PL:

C → ¬F ?

C → B

B → ¬F ?

formalisation is questionable; inference cannot be proved

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 59 / 120

Page 264: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Limitations of propositional logic

PL can only deal with propositions as a whole

propositions can only be true or false

structure of propositions cannot be analysed

Example

Some chickens cannot fly.

All chickens are birds.

Conjecture: Some birds cannot fly.

Translation into PL:

C → ¬F ?

C → B

B → ¬F ?

formalisation is questionable; inference cannot be proved

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 59 / 120

Page 265: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Limitations of propositional logic

PL can only deal with propositions as a whole

propositions can only be true or false

structure of propositions cannot be analysed

Example

Some chickens cannot fly.

All chickens are birds.

Conjecture: Some birds cannot fly.

Translation into PL:

C → ¬F ?

C → B

B → ¬F ?

formalisation is questionable; inference cannot be proved

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 59 / 120

Page 266: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Limitations of propositional logic

PL can only deal with propositions as a whole

propositions can only be true or false

structure of propositions cannot be analysed

Example

Some chickens cannot fly.

All chickens are birds.

Conjecture: Some birds cannot fly.

Translation into PL:

C → ¬F ?

C → B

B → ¬F ?

formalisation is questionable; inference cannot be proved

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 59 / 120

Page 267: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Limitations of propositional logic

PL can only deal with propositions as a whole

propositions can only be true or false

structure of propositions cannot be analysed

Example

Some chickens cannot fly.

All chickens are birds.

Conjecture: Some birds cannot fly.

Translation into PL:

C → ¬F ?

C → B

B → ¬F ?

formalisation is questionable; inference cannot be proved

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 59 / 120

Page 268: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Limitations of propositional logic

PL can only deal with propositions as a whole

propositions can only be true or false

structure of propositions cannot be analysed

Example

Some chickens cannot fly.

All chickens are birds.

Conjecture: Some birds cannot fly.

Translation into PL:

C → ¬F ?

C → B

B → ¬F ?

formalisation is questionable; inference cannot be proved

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 59 / 120

Page 269: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order predicate logic: syntax

constructor notation real-life domain math domain

variables x, y (people) (numbers)

constant a, b, c Calvin, Hobbes 1, 2, πsymbols

function f(x), h(x, y) has-mother, married-to x+ y, sqrt(x),symbols log(x, b)

predicate R(x), S(x, y) has-daughter, has-friend, x > y, x = y,symbols likes prime(x)

quantifiers ∀,∃operators ∧,∨,¬,→

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 60 / 120

Page 270: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order predicate logic: syntax

constructor notation real-life domain math domain

variables x, y (people) (numbers)

constant a, b, c Calvin, Hobbes 1, 2, πsymbols

function f(x), h(x, y) has-mother, married-to x+ y, sqrt(x),symbols log(x, b)

predicate R(x), S(x, y) has-daughter, has-friend, x > y, x = y,symbols likes prime(x)

quantifiers ∀,∃operators ∧,∨,¬,→

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 60 / 120

Page 271: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order predicate logic: syntax

constructor notation real-life domain math domain

variables x, y (people) (numbers)

constant a, b, c Calvin, Hobbes 1, 2, πsymbols

function f(x), h(x, y) has-mother, married-to x+ y, sqrt(x),symbols log(x, b)

predicate R(x), S(x, y) has-daughter, has-friend, x > y, x = y,symbols likes prime(x)

quantifiers ∀,∃

operators ∧,∨,¬,→

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 60 / 120

Page 272: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order predicate logic: syntax

constructor notation real-life domain math domain

variables x, y (people) (numbers)

constant a, b, c Calvin, Hobbes 1, 2, πsymbols

function f(x), h(x, y) has-mother, married-to x+ y, sqrt(x),symbols log(x, b)

predicate R(x), S(x, y) has-daughter, has-friend, x > y, x = y,symbols likes prime(x)

quantifiers ∀,∃operators ∧,∨,¬,→

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 60 / 120

Page 273: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Functions and their arity

Function symbols come with an arity

an n-ary function symbol has exactly n arguments

+ is binary (x+ y)

sqrt() is unary (sqrt(x))

has-mother and married-to are unary

nullary function symbols are constant symbols

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 61 / 120

Page 274: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Functions and their arity

Function symbols come with an arity

an n-ary function symbol has exactly n arguments

+ is binary (x+ y)

sqrt() is unary (sqrt(x))

has-mother and married-to are unary

nullary function symbols are constant symbols

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 61 / 120

Page 275: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Functions and their arity

Function symbols come with an arity

an n-ary function symbol has exactly n arguments

+ is binary (x+ y)

sqrt() is unary (sqrt(x))

has-mother and married-to are unary

nullary function symbols are constant symbols

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 61 / 120

Page 276: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Functions and their arity

Function symbols come with an arity

an n-ary function symbol has exactly n arguments

+ is binary (x+ y)

sqrt() is unary (sqrt(x))

has-mother and married-to are unary

nullary function symbols are constant symbols

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 61 / 120

Page 277: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Functions and their arity

Function symbols come with an arity

an n-ary function symbol has exactly n arguments

+ is binary (x+ y)

sqrt() is unary (sqrt(x))

has-mother and married-to are unary

nullary function symbols are constant symbols

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 61 / 120

Page 278: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Terms

Variables and function symbols (and thus also constant symbols) can beused to build terms.

Definition (term)

Terms are defined inductively as follows:

every variable is a term.

if f is n-ary and t1, . . . , tn are terms, then f(t1, . . . , tn) is a term.

every constant is a termbinary functions are often written in infix notation:x+ y rather than +(x, y)

terms without variables are called ground terms

Note: terms denote elements of the domain.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 62 / 120

Page 279: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Terms

Variables and function symbols (and thus also constant symbols) can beused to build terms.

Definition (term)

Terms are defined inductively as follows:

every variable is a term.

if f is n-ary and t1, . . . , tn are terms, then f(t1, . . . , tn) is a term.

every constant is a termbinary functions are often written in infix notation:x+ y rather than +(x, y)

terms without variables are called ground terms

Note: terms denote elements of the domain.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 62 / 120

Page 280: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Terms

Variables and function symbols (and thus also constant symbols) can beused to build terms.

Definition (term)

Terms are defined inductively as follows:

every variable is a term.

if f is n-ary and t1, . . . , tn are terms, then f(t1, . . . , tn) is a term.

every constant is a termbinary functions are often written in infix notation:x+ y rather than +(x, y)

terms without variables are called ground terms

Note: terms denote elements of the domain.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 62 / 120

Page 281: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Terms

Variables and function symbols (and thus also constant symbols) can beused to build terms.

Definition (term)

Terms are defined inductively as follows:

every variable is a term.

if f is n-ary and t1, . . . , tn are terms, then f(t1, . . . , tn) is a term.

every constant is a term

binary functions are often written in infix notation:x+ y rather than +(x, y)

terms without variables are called ground terms

Note: terms denote elements of the domain.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 62 / 120

Page 282: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Terms

Variables and function symbols (and thus also constant symbols) can beused to build terms.

Definition (term)

Terms are defined inductively as follows:

every variable is a term.

if f is n-ary and t1, . . . , tn are terms, then f(t1, . . . , tn) is a term.

every constant is a termbinary functions are often written in infix notation:x+ y rather than +(x, y)

terms without variables are called ground terms

Note: terms denote elements of the domain.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 62 / 120

Page 283: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Terms

Variables and function symbols (and thus also constant symbols) can beused to build terms.

Definition (term)

Terms are defined inductively as follows:

every variable is a term.

if f is n-ary and t1, . . . , tn are terms, then f(t1, . . . , tn) is a term.

every constant is a termbinary functions are often written in infix notation:x+ y rather than +(x, y)

terms without variables are called ground terms

Note: terms denote elements of the domain.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 62 / 120

Page 284: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Terms

Variables and function symbols (and thus also constant symbols) can beused to build terms.

Definition (term)

Terms are defined inductively as follows:

every variable is a term.

if f is n-ary and t1, . . . , tn are terms, then f(t1, . . . , tn) is a term.

every constant is a termbinary functions are often written in infix notation:x+ y rather than +(x, y)

terms without variables are called ground terms

Note: terms denote elements of the domain.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 62 / 120

Page 285: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Terms

Variables and function symbols (and thus also constant symbols) can beused to build terms.

Definition (term)

Terms are defined inductively as follows:

every variable is a term.

if f is n-ary and t1, . . . , tn are terms, then f(t1, . . . , tn) is a term.

every constant is a termbinary functions are often written in infix notation:x+ y rather than +(x, y)

terms without variables are called ground terms

Note: terms denote elements of the domain.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 62 / 120

Page 286: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: terms

Let

x, y be variables,

c, d be constant symbols,

f be a unary function symbol,

+ be a binary function symbol.

Example (ground terms)

c

f(d)

c+ f(c) or +(c, f(c))

+(c,+(d,+(f(c), f(f(d)))))

Example (non-ground terms)

x

f(y)

c+ f(y)

+(c,+(y,+(f(x), f(y))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 63 / 120

Page 287: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: terms

Let

x, y be variables,

c, d be constant symbols,

f be a unary function symbol,

+ be a binary function symbol.

Example (ground terms)

c

f(d)

c+ f(c) or +(c, f(c))

+(c,+(d,+(f(c), f(f(d)))))

Example (non-ground terms)

x

f(y)

c+ f(y)

+(c,+(y,+(f(x), f(y))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 63 / 120

Page 288: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: terms

Let

x, y be variables,

c, d be constant symbols,

f be a unary function symbol,

+ be a binary function symbol.

Example (ground terms)

c

f(d)

c+ f(c) or +(c, f(c))

+(c,+(d,+(f(c), f(f(d)))))

Example (non-ground terms)

x

f(y)

c+ f(y)

+(c,+(y,+(f(x), f(y))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 63 / 120

Page 289: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: terms

Let

x, y be variables,

c, d be constant symbols,

f be a unary function symbol,

+ be a binary function symbol.

Example (ground terms)

c

f(d)

c+ f(c) or +(c, f(c))

+(c,+(d,+(f(c), f(f(d)))))

Example (non-ground terms)

x

f(y)

c+ f(y)

+(c,+(y,+(f(x), f(y))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 63 / 120

Page 290: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: terms

Let

x, y be variables,

c, d be constant symbols,

f be a unary function symbol,

+ be a binary function symbol.

Example (ground terms)

c

f(d)

c+ f(c) or +(c, f(c))

+(c,+(d,+(f(c), f(f(d)))))

Example (non-ground terms)

x

f(y)

c+ f(y)

+(c,+(y,+(f(x), f(y))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 63 / 120

Page 291: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: terms

Let

x, y be variables,

c, d be constant symbols,

f be a unary function symbol,

+ be a binary function symbol.

Example (ground terms)

c

f(d)

c+ f(c) or +(c, f(c))

+(c,+(d,+(f(c), f(f(d)))))

Example (non-ground terms)

x

f(y)

c+ f(y)

+(c,+(y,+(f(x), f(y))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 63 / 120

Page 292: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: terms

Let

x, y be variables,

c, d be constant symbols,

f be a unary function symbol,

+ be a binary function symbol.

Example (ground terms)

c

f(d)

c+ f(c) or +(c, f(c))

+(c,+(d,+(f(c), f(f(d)))))

Example (non-ground terms)

x

f(y)

c+ f(y)

+(c,+(y,+(f(x), f(y))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 63 / 120

Page 293: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: terms

Let

x, y be variables,

c, d be constant symbols,

f be a unary function symbol,

+ be a binary function symbol.

Example (ground terms)

c

f(d)

c+ f(c) or +(c, f(c))

+(c,+(d,+(f(c), f(f(d)))))

Example (non-ground terms)

x

f(y)

c+ f(y)

+(c,+(y,+(f(x), f(y))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 63 / 120

Page 294: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: terms

Let

x, y be variables,

c, d be constant symbols,

f be a unary function symbol,

+ be a binary function symbol.

Example (ground terms)

c

f(d)

c+ f(c) or +(c, f(c))

+(c,+(d,+(f(c), f(f(d)))))

Example (non-ground terms)

x

f(y)

c+ f(y)

+(c,+(y,+(f(x), f(y))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 63 / 120

Page 295: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: terms

Let

x, y be variables,

c, d be constant symbols,

f be a unary function symbol,

+ be a binary function symbol.

Example (ground terms)

c

f(d)

c+ f(c) or +(c, f(c))

+(c,+(d,+(f(c), f(f(d)))))

Example (non-ground terms)

x

f(y)

c+ f(y)

+(c,+(y,+(f(x), f(y))))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 63 / 120

Page 296: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Predicates and their arity

Predicate symbols also come with an arity.

an n-ary predicate symbol has exactly n arguments

> is binary (x > y)

prime() is unary (prime(x))

has-daughter and likes are binary

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 64 / 120

Page 297: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Predicates and their arity

Predicate symbols also come with an arity.

an n-ary predicate symbol has exactly n arguments

> is binary (x > y)

prime() is unary (prime(x))

has-daughter and likes are binary

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 64 / 120

Page 298: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Predicates and their arity

Predicate symbols also come with an arity.

an n-ary predicate symbol has exactly n arguments

> is binary (x > y)

prime() is unary (prime(x))

has-daughter and likes are binary

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 64 / 120

Page 299: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Predicates and their arity

Predicate symbols also come with an arity.

an n-ary predicate symbol has exactly n arguments

> is binary (x > y)

prime() is unary (prime(x))

has-daughter and likes are binary

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 64 / 120

Page 300: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Atoms

Predicate symbols and terms can be used to build atoms.

Definition (Atom)

Atoms are defined as follows:

if R is an n-ary predicate symbol and t1, . . . , tn are terms, thenR(t1, . . . , tn) is an atom

binary relations are often written in infix notation:x > y rather than > (x, y)

atoms without variables are called ground atoms

Note: Atoms are either true or false.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 65 / 120

Page 301: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Atoms

Predicate symbols and terms can be used to build atoms.

Definition (Atom)

Atoms are defined as follows:

if R is an n-ary predicate symbol and t1, . . . , tn are terms, thenR(t1, . . . , tn) is an atom

binary relations are often written in infix notation:x > y rather than > (x, y)

atoms without variables are called ground atoms

Note: Atoms are either true or false.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 65 / 120

Page 302: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Atoms

Predicate symbols and terms can be used to build atoms.

Definition (Atom)

Atoms are defined as follows:

if R is an n-ary predicate symbol and t1, . . . , tn are terms, thenR(t1, . . . , tn) is an atom

binary relations are often written in infix notation:x > y rather than > (x, y)

atoms without variables are called ground atoms

Note: Atoms are either true or false.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 65 / 120

Page 303: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Atoms

Predicate symbols and terms can be used to build atoms.

Definition (Atom)

Atoms are defined as follows:

if R is an n-ary predicate symbol and t1, . . . , tn are terms, thenR(t1, . . . , tn) is an atom

binary relations are often written in infix notation:x > y rather than > (x, y)

atoms without variables are called ground atoms

Note: Atoms are either true or false.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 65 / 120

Page 304: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Atoms

Predicate symbols and terms can be used to build atoms.

Definition (Atom)

Atoms are defined as follows:

if R is an n-ary predicate symbol and t1, . . . , tn are terms, thenR(t1, . . . , tn) is an atom

binary relations are often written in infix notation:x > y rather than > (x, y)

atoms without variables are called ground atoms

Note: Atoms are either true or false.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 65 / 120

Page 305: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Atoms

Predicate symbols and terms can be used to build atoms.

Definition (Atom)

Atoms are defined as follows:

if R is an n-ary predicate symbol and t1, . . . , tn are terms, thenR(t1, . . . , tn) is an atom

binary relations are often written in infix notation:x > y rather than > (x, y)

atoms without variables are called ground atoms

Note: Atoms are either true or false.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 65 / 120

Page 306: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: atoms

Let

> be a binary predicate symbol

P be a unary predicate symbol

Example (ground atoms)

P (c)

c > f(c) or > (c, f(c))

c > c

P (c+ f(c))

Example (non-ground atoms)

x > y

f(y) > c+ f(x)

P (f(c+ y))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 66 / 120

Page 307: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: atoms

Let

> be a binary predicate symbol

P be a unary predicate symbol

Example (ground atoms)

P (c)

c > f(c) or > (c, f(c))

c > c

P (c+ f(c))

Example (non-ground atoms)

x > y

f(y) > c+ f(x)

P (f(c+ y))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 66 / 120

Page 308: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: atoms

Let

> be a binary predicate symbol

P be a unary predicate symbol

Example (ground atoms)

P (c)

c > f(c) or > (c, f(c))

c > c

P (c+ f(c))

Example (non-ground atoms)

x > y

f(y) > c+ f(x)

P (f(c+ y))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 66 / 120

Page 309: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: atoms

Let

> be a binary predicate symbol

P be a unary predicate symbol

Example (ground atoms)

P (c)

c > f(c) or > (c, f(c))

c > c

P (c+ f(c))

Example (non-ground atoms)

x > y

f(y) > c+ f(x)

P (f(c+ y))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 66 / 120

Page 310: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: atoms

Let

> be a binary predicate symbol

P be a unary predicate symbol

Example (ground atoms)

P (c)

c > f(c) or > (c, f(c))

c > c

P (c+ f(c))

Example (non-ground atoms)

x > y

f(y) > c+ f(x)

P (f(c+ y))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 66 / 120

Page 311: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: atoms

Let

> be a binary predicate symbol

P be a unary predicate symbol

Example (ground atoms)

P (c)

c > f(c) or > (c, f(c))

c > c

P (c+ f(c))

Example (non-ground atoms)

x > y

f(y) > c+ f(x)

P (f(c+ y))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 66 / 120

Page 312: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: atoms

Let

> be a binary predicate symbol

P be a unary predicate symbol

Example (ground atoms)

P (c)

c > f(c) or > (c, f(c))

c > c

P (c+ f(c))

Example (non-ground atoms)

x > y

f(y) > c+ f(x)

P (f(c+ y))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 66 / 120

Page 313: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: atoms

Let

> be a binary predicate symbol

P be a unary predicate symbol

Example (ground atoms)

P (c)

c > f(c) or > (c, f(c))

c > c

P (c+ f(c))

Example (non-ground atoms)

x > y

f(y) > c+ f(x)

P (f(c+ y))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 66 / 120

Page 314: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: atoms

Let

> be a binary predicate symbol

P be a unary predicate symbol

Example (ground atoms)

P (c)

c > f(c) or > (c, f(c))

c > c

P (c+ f(c))

Example (non-ground atoms)

x > y

f(y) > c+ f(x)

P (f(c+ y))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 66 / 120

Page 315: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Boolean operators, quantifiers, and formulas

Atoms can be used to build complex formulas.

Definition (formula)

Formulas are defined recursively as follows:

every atom is a formula

if ϕ and ψ are formulas and x is a variable, then the following are alsoformulas:

¬ϕ, >, ⊥ϕ ∧ ψ, ϕ ∨ ψ, ϕ→ ψ, ϕ↔ ψ∀xϕ, ∃xϕ

if x appears in ϕ, it is called bound by the quantifierotherwise, it is called free

a formula with free variables is called an open formula

a formula without free variables is called a closed formula or asentence

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 67 / 120

Page 316: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Boolean operators, quantifiers, and formulas

Atoms can be used to build complex formulas.

Definition (formula)

Formulas are defined recursively as follows:

every atom is a formula

if ϕ and ψ are formulas and x is a variable, then the following are alsoformulas:

¬ϕ, >, ⊥ϕ ∧ ψ, ϕ ∨ ψ, ϕ→ ψ, ϕ↔ ψ∀xϕ, ∃xϕ

if x appears in ϕ, it is called bound by the quantifierotherwise, it is called free

a formula with free variables is called an open formula

a formula without free variables is called a closed formula or asentence

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 67 / 120

Page 317: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Boolean operators, quantifiers, and formulas

Atoms can be used to build complex formulas.

Definition (formula)

Formulas are defined recursively as follows:

every atom is a formula

if ϕ and ψ are formulas and x is a variable, then the following are alsoformulas:

¬ϕ, >, ⊥

ϕ ∧ ψ, ϕ ∨ ψ, ϕ→ ψ, ϕ↔ ψ∀xϕ, ∃xϕ

if x appears in ϕ, it is called bound by the quantifierotherwise, it is called free

a formula with free variables is called an open formula

a formula without free variables is called a closed formula or asentence

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 67 / 120

Page 318: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Boolean operators, quantifiers, and formulas

Atoms can be used to build complex formulas.

Definition (formula)

Formulas are defined recursively as follows:

every atom is a formula

if ϕ and ψ are formulas and x is a variable, then the following are alsoformulas:

¬ϕ, >, ⊥ϕ ∧ ψ, ϕ ∨ ψ, ϕ→ ψ, ϕ↔ ψ

∀xϕ, ∃xϕ

if x appears in ϕ, it is called bound by the quantifierotherwise, it is called free

a formula with free variables is called an open formula

a formula without free variables is called a closed formula or asentence

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 67 / 120

Page 319: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Boolean operators, quantifiers, and formulas

Atoms can be used to build complex formulas.

Definition (formula)

Formulas are defined recursively as follows:

every atom is a formula

if ϕ and ψ are formulas and x is a variable, then the following are alsoformulas:

¬ϕ, >, ⊥ϕ ∧ ψ, ϕ ∨ ψ, ϕ→ ψ, ϕ↔ ψ∀xϕ, ∃xϕ

if x appears in ϕ, it is called bound by the quantifierotherwise, it is called free

a formula with free variables is called an open formula

a formula without free variables is called a closed formula or asentence

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 67 / 120

Page 320: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Boolean operators, quantifiers, and formulas

Atoms can be used to build complex formulas.

Definition (formula)

Formulas are defined recursively as follows:

every atom is a formula

if ϕ and ψ are formulas and x is a variable, then the following are alsoformulas:

¬ϕ, >, ⊥ϕ ∧ ψ, ϕ ∨ ψ, ϕ→ ψ, ϕ↔ ψ∀xϕ, ∃xϕ

if x appears in ϕ, it is called bound by the quantifier

otherwise, it is called free

a formula with free variables is called an open formula

a formula without free variables is called a closed formula or asentence

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 67 / 120

Page 321: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Boolean operators, quantifiers, and formulas

Atoms can be used to build complex formulas.

Definition (formula)

Formulas are defined recursively as follows:

every atom is a formula

if ϕ and ψ are formulas and x is a variable, then the following are alsoformulas:

¬ϕ, >, ⊥ϕ ∧ ψ, ϕ ∨ ψ, ϕ→ ψ, ϕ↔ ψ∀xϕ, ∃xϕ

if x appears in ϕ, it is called bound by the quantifierotherwise, it is called free

a formula with free variables is called an open formula

a formula without free variables is called a closed formula or asentence

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 67 / 120

Page 322: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Boolean operators, quantifiers, and formulas

Atoms can be used to build complex formulas.

Definition (formula)

Formulas are defined recursively as follows:

every atom is a formula

if ϕ and ψ are formulas and x is a variable, then the following are alsoformulas:

¬ϕ, >, ⊥ϕ ∧ ψ, ϕ ∨ ψ, ϕ→ ψ, ϕ↔ ψ∀xϕ, ∃xϕ

if x appears in ϕ, it is called bound by the quantifierotherwise, it is called free

a formula with free variables is called an open formula

a formula without free variables is called a closed formula or asentence

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 67 / 120

Page 323: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Boolean operators, quantifiers, and formulas

Atoms can be used to build complex formulas.

Definition (formula)

Formulas are defined recursively as follows:

every atom is a formula

if ϕ and ψ are formulas and x is a variable, then the following are alsoformulas:

¬ϕ, >, ⊥ϕ ∧ ψ, ϕ ∨ ψ, ϕ→ ψ, ϕ↔ ψ∀xϕ, ∃xϕ

if x appears in ϕ, it is called bound by the quantifierotherwise, it is called free

a formula with free variables is called an open formula

a formula without free variables is called a closed formula or asentence

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 67 / 120

Page 324: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 325: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 326: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 327: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 328: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 329: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 330: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 331: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 332: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 333: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 334: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Formulas

Example (open formulas)

P (x)

f(y) > c+ f(x)

P (y) ∨ x > c

x > y → ¬∀x(x > y)

∀xP (x) ∨ x > c (!)

Example (sentences)

∀xx > c

∀x∀y(x > y∨y > x∨x = y)

∃xP (x)

∃x(P (x) ∨ x > d)

∃x(P (x)→ ∀y(y + c > x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 68 / 120

Page 335: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Operator precedence in predicate logic

∀ and ∃ are stronger than all boolean operators

∀xR(x, y) ∧ S(x) means (∀xR(x, y)) ∧ S(x)∃xR(x, y)→ S(y) means (∃xR(x, y))→ S(y)

functions and predicates are stronger than quantifiers

∀x∀yx+ y = y + x means ∀x∀y(x+ y = y + x)otherwise, it would not be a formula anymore: (∀x∀yx) + y = y + xin prefix notation, this is obvious: ∀x∀y = (+(x, y),+(y, x))

functions are stronger than predicates

x+ y > c+ d means (x+ y) > (c+ d)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 69 / 120

Page 336: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Operator precedence in predicate logic

∀ and ∃ are stronger than all boolean operators

∀xR(x, y) ∧ S(x) means (∀xR(x, y)) ∧ S(x)

∃xR(x, y)→ S(y) means (∃xR(x, y))→ S(y)

functions and predicates are stronger than quantifiers

∀x∀yx+ y = y + x means ∀x∀y(x+ y = y + x)otherwise, it would not be a formula anymore: (∀x∀yx) + y = y + xin prefix notation, this is obvious: ∀x∀y = (+(x, y),+(y, x))

functions are stronger than predicates

x+ y > c+ d means (x+ y) > (c+ d)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 69 / 120

Page 337: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Operator precedence in predicate logic

∀ and ∃ are stronger than all boolean operators

∀xR(x, y) ∧ S(x) means (∀xR(x, y)) ∧ S(x)∃xR(x, y)→ S(y) means (∃xR(x, y))→ S(y)

functions and predicates are stronger than quantifiers

∀x∀yx+ y = y + x means ∀x∀y(x+ y = y + x)otherwise, it would not be a formula anymore: (∀x∀yx) + y = y + xin prefix notation, this is obvious: ∀x∀y = (+(x, y),+(y, x))

functions are stronger than predicates

x+ y > c+ d means (x+ y) > (c+ d)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 69 / 120

Page 338: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Operator precedence in predicate logic

∀ and ∃ are stronger than all boolean operators

∀xR(x, y) ∧ S(x) means (∀xR(x, y)) ∧ S(x)∃xR(x, y)→ S(y) means (∃xR(x, y))→ S(y)

functions and predicates are stronger than quantifiers

∀x∀yx+ y = y + x means ∀x∀y(x+ y = y + x)otherwise, it would not be a formula anymore: (∀x∀yx) + y = y + xin prefix notation, this is obvious: ∀x∀y = (+(x, y),+(y, x))

functions are stronger than predicates

x+ y > c+ d means (x+ y) > (c+ d)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 69 / 120

Page 339: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Operator precedence in predicate logic

∀ and ∃ are stronger than all boolean operators

∀xR(x, y) ∧ S(x) means (∀xR(x, y)) ∧ S(x)∃xR(x, y)→ S(y) means (∃xR(x, y))→ S(y)

functions and predicates are stronger than quantifiers

∀x∀yx+ y = y + x means ∀x∀y(x+ y = y + x)

otherwise, it would not be a formula anymore: (∀x∀yx) + y = y + xin prefix notation, this is obvious: ∀x∀y = (+(x, y),+(y, x))

functions are stronger than predicates

x+ y > c+ d means (x+ y) > (c+ d)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 69 / 120

Page 340: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Operator precedence in predicate logic

∀ and ∃ are stronger than all boolean operators

∀xR(x, y) ∧ S(x) means (∀xR(x, y)) ∧ S(x)∃xR(x, y)→ S(y) means (∃xR(x, y))→ S(y)

functions and predicates are stronger than quantifiers

∀x∀yx+ y = y + x means ∀x∀y(x+ y = y + x)otherwise, it would not be a formula anymore: (∀x∀yx) + y = y + x

in prefix notation, this is obvious: ∀x∀y = (+(x, y),+(y, x))

functions are stronger than predicates

x+ y > c+ d means (x+ y) > (c+ d)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 69 / 120

Page 341: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Operator precedence in predicate logic

∀ and ∃ are stronger than all boolean operators

∀xR(x, y) ∧ S(x) means (∀xR(x, y)) ∧ S(x)∃xR(x, y)→ S(y) means (∃xR(x, y))→ S(y)

functions and predicates are stronger than quantifiers

∀x∀yx+ y = y + x means ∀x∀y(x+ y = y + x)otherwise, it would not be a formula anymore: (∀x∀yx) + y = y + xin prefix notation, this is obvious: ∀x∀y = (+(x, y),+(y, x))

functions are stronger than predicates

x+ y > c+ d means (x+ y) > (c+ d)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 69 / 120

Page 342: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Operator precedence in predicate logic

∀ and ∃ are stronger than all boolean operators

∀xR(x, y) ∧ S(x) means (∀xR(x, y)) ∧ S(x)∃xR(x, y)→ S(y) means (∃xR(x, y))→ S(y)

functions and predicates are stronger than quantifiers

∀x∀yx+ y = y + x means ∀x∀y(x+ y = y + x)otherwise, it would not be a formula anymore: (∀x∀yx) + y = y + xin prefix notation, this is obvious: ∀x∀y = (+(x, y),+(y, x))

functions are stronger than predicates

x+ y > c+ d means (x+ y) > (c+ d)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 69 / 120

Page 343: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Operator precedence in predicate logic

∀ and ∃ are stronger than all boolean operators

∀xR(x, y) ∧ S(x) means (∀xR(x, y)) ∧ S(x)∃xR(x, y)→ S(y) means (∃xR(x, y))→ S(y)

functions and predicates are stronger than quantifiers

∀x∀yx+ y = y + x means ∀x∀y(x+ y = y + x)otherwise, it would not be a formula anymore: (∀x∀yx) + y = y + xin prefix notation, this is obvious: ∀x∀y = (+(x, y),+(y, x))

functions are stronger than predicates

x+ y > c+ d means (x+ y) > (c+ d)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 69 / 120

Page 344: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: syntax of predicate logic

Determine if the following are

(ground) terms,

(ground) atoms,

formulas,

sentences,

nonsense.

Determine which appearances of variables are bound and which are free.

a) x+ y

b) x+ y > c

c) P (c, d)

d) x > P (d)

e) ∀x(x+ c > x)

f) ∀x > (+(x, c), x)

g) ∀x, y(x > y)

h) ∃x∃y(x+ y)

i) P (∀x(x = x))

j) x > y ∧ x+ y

k) ∀x(x > c ∨ c > x) ∨ x = c

l) c > f(d)

m) P (P (x))

n) f(f(x))

o) ∀x∀y(P (x) > P (y))

p) ∃xP (x)→ ∀xP (x)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 70 / 120

Page 345: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: interpretation

An interpretation I gives meaning to the symbols of a formal language.

determines the universe or domain

assigns to every n-ary function symbol f an n-ary function fI overthe universe

assigns to every n-ary predicate symbol n-ary relation RI over theuniverse

The interpretation is extended to complex terms in the natural way: for aterm t = f(t1, . . . , tn), tI is obtained by

recursively interpreting the terms t1, . . . , tn

and finally the interpretation fI

tI = fI(tI1 , . . . , tIn)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 71 / 120

Page 346: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: interpretation

An interpretation I gives meaning to the symbols of a formal language.

determines the universe or domain

assigns to every n-ary function symbol f an n-ary function fI overthe universe

assigns to every n-ary predicate symbol n-ary relation RI over theuniverse

The interpretation is extended to complex terms in the natural way: for aterm t = f(t1, . . . , tn), tI is obtained by

recursively interpreting the terms t1, . . . , tn

and finally the interpretation fI

tI = fI(tI1 , . . . , tIn)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 71 / 120

Page 347: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: interpretation

An interpretation I gives meaning to the symbols of a formal language.

determines the universe or domain

assigns to every n-ary function symbol f an n-ary function fI overthe universe

assigns to every n-ary predicate symbol n-ary relation RI over theuniverse

The interpretation is extended to complex terms in the natural way: for aterm t = f(t1, . . . , tn), tI is obtained by

recursively interpreting the terms t1, . . . , tn

and finally the interpretation fI

tI = fI(tI1 , . . . , tIn)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 71 / 120

Page 348: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: interpretation

An interpretation I gives meaning to the symbols of a formal language.

determines the universe or domain

assigns to every n-ary function symbol f an n-ary function fI overthe universe

assigns to every n-ary predicate symbol n-ary relation RI over theuniverse

The interpretation is extended to complex terms in the natural way: for aterm t = f(t1, . . . , tn), tI is obtained by

recursively interpreting the terms t1, . . . , tn

and finally the interpretation fI

tI = fI(tI1 , . . . , tIn)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 71 / 120

Page 349: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: interpretation

An interpretation I gives meaning to the symbols of a formal language.

determines the universe or domain

assigns to every n-ary function symbol f an n-ary function fI overthe universe

assigns to every n-ary predicate symbol n-ary relation RI over theuniverse

The interpretation is extended to complex terms in the natural way: for aterm t = f(t1, . . . , tn), tI is obtained by

recursively interpreting the terms t1, . . . , tn

and finally the interpretation fI

tI = fI(tI1 , . . . , tIn)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 71 / 120

Page 350: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: interpretation

An interpretation I gives meaning to the symbols of a formal language.

determines the universe or domain

assigns to every n-ary function symbol f an n-ary function fI overthe universe

assigns to every n-ary predicate symbol n-ary relation RI over theuniverse

The interpretation is extended to complex terms in the natural way: for aterm t = f(t1, . . . , tn), tI is obtained by

recursively interpreting the terms t1, . . . , tn

and finally the interpretation fI

tI = fI(tI1 , . . . , tIn)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 71 / 120

Page 351: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: interpretation

An interpretation I gives meaning to the symbols of a formal language.

determines the universe or domain

assigns to every n-ary function symbol f an n-ary function fI overthe universe

assigns to every n-ary predicate symbol n-ary relation RI over theuniverse

The interpretation is extended to complex terms in the natural way: for aterm t = f(t1, . . . , tn), tI is obtained by

recursively interpreting the terms t1, . . . , tn

and finally the interpretation fI

tI = fI(tI1 , . . . , tIn)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 71 / 120

Page 352: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation

ϕ = ∀xR(x, f(x))

Example: Interpretation I with people domain

Universe ∆I : P = {Alice,Bob,Clara,Don}Function fI : married-toP = {Alice 7→ Bob, Bob 7→ Alice, Clara 7→Don, Don 7→ Clara}Relation RI : likesP = {(Alice,Bob), (Alice,Clara), (Bob,Alice),(Bob,Don), (Clara,Don), (Don,Alice), (Don,Bob)}I makes ϕ false (because Don does not like Clara)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 72 / 120

Page 353: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation

ϕ = ∀xR(x, f(x))

Example: Interpretation I with people domain

Universe ∆I : P = {Alice,Bob,Clara,Don}

Function fI : married-toP = {Alice 7→ Bob, Bob 7→ Alice, Clara 7→Don, Don 7→ Clara}Relation RI : likesP = {(Alice,Bob), (Alice,Clara), (Bob,Alice),(Bob,Don), (Clara,Don), (Don,Alice), (Don,Bob)}I makes ϕ false (because Don does not like Clara)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 72 / 120

Page 354: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation

ϕ = ∀xR(x, f(x))

Example: Interpretation I with people domain

Universe ∆I : P = {Alice,Bob,Clara,Don}Function fI : married-toP = {Alice 7→ Bob, Bob 7→ Alice, Clara 7→Don, Don 7→ Clara}

Relation RI : likesP = {(Alice,Bob), (Alice,Clara), (Bob,Alice),(Bob,Don), (Clara,Don), (Don,Alice), (Don,Bob)}I makes ϕ false (because Don does not like Clara)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 72 / 120

Page 355: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation

ϕ = ∀xR(x, f(x))

Example: Interpretation I with people domain

Universe ∆I : P = {Alice,Bob,Clara,Don}Function fI : married-toP = {Alice 7→ Bob, Bob 7→ Alice, Clara 7→Don, Don 7→ Clara}Relation RI : likesP = {(Alice,Bob), (Alice,Clara), (Bob,Alice),(Bob,Don), (Clara,Don), (Don,Alice), (Don,Bob)}

I makes ϕ false (because Don does not like Clara)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 72 / 120

Page 356: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation

ϕ = ∀xR(x, f(x))

Example: Interpretation I with people domain

Universe ∆I : P = {Alice,Bob,Clara,Don}Function fI : married-toP = {Alice 7→ Bob, Bob 7→ Alice, Clara 7→Don, Don 7→ Clara}Relation RI : likesP = {(Alice,Bob), (Alice,Clara), (Bob,Alice),(Bob,Don), (Clara,Don), (Don,Alice), (Don,Bob)}I makes ϕ false (because Don does not like Clara)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 72 / 120

Page 357: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation (cont’)

ϕ = ∀xR(x, f(x))

Example: Interpretation J with number domain

Universe ∆J : N = {0, 1, 2, . . .}

Function fJ : sN (successor) = {0 7→ 1, 1 7→ 2, . . .}Relation RJ : <N (less-than) = {(0, 1), (0, 2), . . . , (1, 2), (1, 3), . . .}J makes ϕ true (because every number is less than its successor)

It depends on the interpretation if a sentence is evaluated to true or false

the interpretation of the function and predicate symbolsIf J ′ interprets R as >N, then ϕ is evaluated as false

the universe∀x∃y(y < x) is true in Z, but false in N.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 73 / 120

Page 358: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation (cont’)

ϕ = ∀xR(x, f(x))

Example: Interpretation J with number domain

Universe ∆J : N = {0, 1, 2, . . .}Function fJ : sN (successor) = {0 7→ 1, 1 7→ 2, . . .}

Relation RJ : <N (less-than) = {(0, 1), (0, 2), . . . , (1, 2), (1, 3), . . .}J makes ϕ true (because every number is less than its successor)

It depends on the interpretation if a sentence is evaluated to true or false

the interpretation of the function and predicate symbolsIf J ′ interprets R as >N, then ϕ is evaluated as false

the universe∀x∃y(y < x) is true in Z, but false in N.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 73 / 120

Page 359: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation (cont’)

ϕ = ∀xR(x, f(x))

Example: Interpretation J with number domain

Universe ∆J : N = {0, 1, 2, . . .}Function fJ : sN (successor) = {0 7→ 1, 1 7→ 2, . . .}Relation RJ : <N (less-than) = {(0, 1), (0, 2), . . . , (1, 2), (1, 3), . . .}

J makes ϕ true (because every number is less than its successor)

It depends on the interpretation if a sentence is evaluated to true or false

the interpretation of the function and predicate symbolsIf J ′ interprets R as >N, then ϕ is evaluated as false

the universe∀x∃y(y < x) is true in Z, but false in N.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 73 / 120

Page 360: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation (cont’)

ϕ = ∀xR(x, f(x))

Example: Interpretation J with number domain

Universe ∆J : N = {0, 1, 2, . . .}Function fJ : sN (successor) = {0 7→ 1, 1 7→ 2, . . .}Relation RJ : <N (less-than) = {(0, 1), (0, 2), . . . , (1, 2), (1, 3), . . .}J makes ϕ true (because every number is less than its successor)

It depends on the interpretation if a sentence is evaluated to true or false

the interpretation of the function and predicate symbolsIf J ′ interprets R as >N, then ϕ is evaluated as false

the universe∀x∃y(y < x) is true in Z, but false in N.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 73 / 120

Page 361: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation (cont’)

ϕ = ∀xR(x, f(x))

Example: Interpretation J with number domain

Universe ∆J : N = {0, 1, 2, . . .}Function fJ : sN (successor) = {0 7→ 1, 1 7→ 2, . . .}Relation RJ : <N (less-than) = {(0, 1), (0, 2), . . . , (1, 2), (1, 3), . . .}J makes ϕ true (because every number is less than its successor)

It depends on the interpretation if a sentence is evaluated to true or false

the interpretation of the function and predicate symbolsIf J ′ interprets R as >N, then ϕ is evaluated as false

the universe∀x∃y(y < x) is true in Z, but false in N.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 73 / 120

Page 362: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation (cont’)

ϕ = ∀xR(x, f(x))

Example: Interpretation J with number domain

Universe ∆J : N = {0, 1, 2, . . .}Function fJ : sN (successor) = {0 7→ 1, 1 7→ 2, . . .}Relation RJ : <N (less-than) = {(0, 1), (0, 2), . . . , (1, 2), (1, 3), . . .}J makes ϕ true (because every number is less than its successor)

It depends on the interpretation if a sentence is evaluated to true or false

the interpretation of the function and predicate symbolsIf J ′ interprets R as >N, then ϕ is evaluated as false

the universe∀x∃y(y < x) is true in Z, but false in N.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 73 / 120

Page 363: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: interpretation (cont’)

ϕ = ∀xR(x, f(x))

Example: Interpretation J with number domain

Universe ∆J : N = {0, 1, 2, . . .}Function fJ : sN (successor) = {0 7→ 1, 1 7→ 2, . . .}Relation RJ : <N (less-than) = {(0, 1), (0, 2), . . . , (1, 2), (1, 3), . . .}J makes ϕ true (because every number is less than its successor)

It depends on the interpretation if a sentence is evaluated to true or false

the interpretation of the function and predicate symbolsIf J ′ interprets R as >N, then ϕ is evaluated as false

the universe∀x∃y(y < x) is true in Z, but false in N.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 73 / 120

Page 364: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: Interpretation

Letϕ = ∀x∀y((¬(x = y) ∧R(x, y))→ ∃z((¬(z = x)) ∧ (¬(z = y)) ∧ P (z)))and I be as follows:

∆I is given by the set of all human beings;

RI = quarrel;

P I = rejoice.

What is ϕI? What is the meaning of ϕI?

Let ψ = ∀x∃yf(x, y) = c and J be as follows:

∆I = Z;

fI = +Z, i.e. addition for integers;

cI = 0Z, i.e. zero (in the set of integers).

What is ψI? What is the meaning of ψI?

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 74 / 120

Page 365: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Interpretation of free variables and open formulas

What happens to free variables?

each free variable is mapped to an element of the domain

similar to variable assignment in propositional logic

each propositional variable mapped to an element of Bextended to complex terms in the natural way

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 75 / 120

Page 366: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Interpretation: formal definition

Definition (FOL interpretation)

For a formula ϕ with free variables V , an interpretation I is a triple(∆I , ·I , µ)

∆I is a set,

·I assigns

an n-ary function fI over ∆I to each n-ary function symbol f(including constants),an n-ary relation RI over ∆I to each n-ary predicate R.

µ : V → ∆I assigns an element of ∆I to each free variable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 76 / 120

Page 367: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Interpretation: formal definition

Definition (FOL interpretation)

For a formula ϕ with free variables V , an interpretation I is a triple(∆I , ·I , µ)

∆I is a set,

·I assigns

an n-ary function fI over ∆I to each n-ary function symbol f(including constants),

an n-ary relation RI over ∆I to each n-ary predicate R.

µ : V → ∆I assigns an element of ∆I to each free variable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 76 / 120

Page 368: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Interpretation: formal definition

Definition (FOL interpretation)

For a formula ϕ with free variables V , an interpretation I is a triple(∆I , ·I , µ)

∆I is a set,

·I assigns

an n-ary function fI over ∆I to each n-ary function symbol f(including constants),an n-ary relation RI over ∆I to each n-ary predicate R.

µ : V → ∆I assigns an element of ∆I to each free variable.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 76 / 120

Page 369: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: model

Definition (model)

An interpretation I = (∆I , ·I , µ) satisfies a formula ϕ (is a model for ϕ,I |= ϕ) if the following holds:

ϕ = P (t1, . . . , tn) is an atom and ((µ(t1))I , . . . , (µ(tn))I) ∈ P I ,

ϕ is a formula involving logical operators (e.g., ϕ = ¬ϕ1,ϕ = ϕ1 ∧ ϕ2) and evaluates to > according to the truth table,

ϕ = ∀xψ(x), and for every x ∈ ∆I , ψ(x) evaluates to >ϕ = ∃xψ(x), and there is an x ∈ ∆I for which ψ(x) evaluates to >

Definition (logical implication)

A formula ϕ is the logical implication of a set of formulas Φ, Φ |= ϕ, ifevery model of Φ is also a model of ϕ.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 77 / 120

Page 370: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: model

Definition (model)

An interpretation I = (∆I , ·I , µ) satisfies a formula ϕ (is a model for ϕ,I |= ϕ) if the following holds:

ϕ = P (t1, . . . , tn) is an atom and ((µ(t1))I , . . . , (µ(tn))I) ∈ P I ,

ϕ is a formula involving logical operators (e.g., ϕ = ¬ϕ1,ϕ = ϕ1 ∧ ϕ2) and evaluates to > according to the truth table,

ϕ = ∀xψ(x), and for every x ∈ ∆I , ψ(x) evaluates to >ϕ = ∃xψ(x), and there is an x ∈ ∆I for which ψ(x) evaluates to >

Definition (logical implication)

A formula ϕ is the logical implication of a set of formulas Φ, Φ |= ϕ, ifevery model of Φ is also a model of ϕ.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 77 / 120

Page 371: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: model

Definition (model)

An interpretation I = (∆I , ·I , µ) satisfies a formula ϕ (is a model for ϕ,I |= ϕ) if the following holds:

ϕ = P (t1, . . . , tn) is an atom and ((µ(t1))I , . . . , (µ(tn))I) ∈ P I ,

ϕ is a formula involving logical operators (e.g., ϕ = ¬ϕ1,ϕ = ϕ1 ∧ ϕ2) and evaluates to > according to the truth table,

ϕ = ∀xψ(x), and for every x ∈ ∆I , ψ(x) evaluates to >ϕ = ∃xψ(x), and there is an x ∈ ∆I for which ψ(x) evaluates to >

Definition (logical implication)

A formula ϕ is the logical implication of a set of formulas Φ, Φ |= ϕ, ifevery model of Φ is also a model of ϕ.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 77 / 120

Page 372: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: model

Definition (model)

An interpretation I = (∆I , ·I , µ) satisfies a formula ϕ (is a model for ϕ,I |= ϕ) if the following holds:

ϕ = P (t1, . . . , tn) is an atom and ((µ(t1))I , . . . , (µ(tn))I) ∈ P I ,

ϕ is a formula involving logical operators (e.g., ϕ = ¬ϕ1,ϕ = ϕ1 ∧ ϕ2) and evaluates to > according to the truth table,

ϕ = ∀xψ(x), and for every x ∈ ∆I , ψ(x) evaluates to >

ϕ = ∃xψ(x), and there is an x ∈ ∆I for which ψ(x) evaluates to >

Definition (logical implication)

A formula ϕ is the logical implication of a set of formulas Φ, Φ |= ϕ, ifevery model of Φ is also a model of ϕ.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 77 / 120

Page 373: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: model

Definition (model)

An interpretation I = (∆I , ·I , µ) satisfies a formula ϕ (is a model for ϕ,I |= ϕ) if the following holds:

ϕ = P (t1, . . . , tn) is an atom and ((µ(t1))I , . . . , (µ(tn))I) ∈ P I ,

ϕ is a formula involving logical operators (e.g., ϕ = ¬ϕ1,ϕ = ϕ1 ∧ ϕ2) and evaluates to > according to the truth table,

ϕ = ∀xψ(x), and for every x ∈ ∆I , ψ(x) evaluates to >ϕ = ∃xψ(x), and there is an x ∈ ∆I for which ψ(x) evaluates to >

Definition (logical implication)

A formula ϕ is the logical implication of a set of formulas Φ, Φ |= ϕ, ifevery model of Φ is also a model of ϕ.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 77 / 120

Page 374: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order semantics: model

Definition (model)

An interpretation I = (∆I , ·I , µ) satisfies a formula ϕ (is a model for ϕ,I |= ϕ) if the following holds:

ϕ = P (t1, . . . , tn) is an atom and ((µ(t1))I , . . . , (µ(tn))I) ∈ P I ,

ϕ is a formula involving logical operators (e.g., ϕ = ¬ϕ1,ϕ = ϕ1 ∧ ϕ2) and evaluates to > according to the truth table,

ϕ = ∀xψ(x), and for every x ∈ ∆I , ψ(x) evaluates to >ϕ = ∃xψ(x), and there is an x ∈ ∆I for which ψ(x) evaluates to >

Definition (logical implication)

A formula ϕ is the logical implication of a set of formulas Φ, Φ |= ϕ, ifevery model of Φ is also a model of ϕ.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 77 / 120

Page 375: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: interpretations

For each of the following sentences, find one interpretation that makesthem true and one that makes them false.

a) ∀x∀y(R(x, y)→ ∃z(R(x, z) ∧R(z, y)))

b) ¬∃x(f(x) = c)

c) ∀x∀y(f(x) = f(y)→ x = y)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 78 / 120

Page 376: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

FOL in algebra

Example (field axioms)

Closure under addition ∀x∀y∃z(x+ y = z)

Associativity of addition ∀x∀y∀z((x+ (y + z)) = ((x+ y) + z))

Commutativity of addition ∀x∀y(x+ y = y + x)

Neutral element for addition ∀x(x+ 0 = x)

Inverse element for addition ∀x∃y(x+ y = 0)

(same for multiplication)

Distributivity of multiplication over addition∀x∀y∀z(x · (y + z) = (x · y) + (x · z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 79 / 120

Page 377: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

FOL in algebra

Example (field axioms)

Closure under addition ∀x∀y∃z(x+ y = z)

Associativity of addition ∀x∀y∀z((x+ (y + z)) = ((x+ y) + z))

Commutativity of addition ∀x∀y(x+ y = y + x)

Neutral element for addition ∀x(x+ 0 = x)

Inverse element for addition ∀x∃y(x+ y = 0)

(same for multiplication)

Distributivity of multiplication over addition∀x∀y∀z(x · (y + z) = (x · y) + (x · z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 79 / 120

Page 378: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

FOL in algebra

Example (field axioms)

Closure under addition ∀x∀y∃z(x+ y = z)

Associativity of addition ∀x∀y∀z((x+ (y + z)) = ((x+ y) + z))

Commutativity of addition ∀x∀y(x+ y = y + x)

Neutral element for addition ∀x(x+ 0 = x)

Inverse element for addition ∀x∃y(x+ y = 0)

(same for multiplication)

Distributivity of multiplication over addition∀x∀y∀z(x · (y + z) = (x · y) + (x · z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 79 / 120

Page 379: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

FOL in algebra

Example (field axioms)

Closure under addition ∀x∀y∃z(x+ y = z)

Associativity of addition ∀x∀y∀z((x+ (y + z)) = ((x+ y) + z))

Commutativity of addition ∀x∀y(x+ y = y + x)

Neutral element for addition ∀x(x+ 0 = x)

Inverse element for addition ∀x∃y(x+ y = 0)

(same for multiplication)

Distributivity of multiplication over addition∀x∀y∀z(x · (y + z) = (x · y) + (x · z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 79 / 120

Page 380: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

FOL in algebra

Example (field axioms)

Closure under addition ∀x∀y∃z(x+ y = z)

Associativity of addition ∀x∀y∀z((x+ (y + z)) = ((x+ y) + z))

Commutativity of addition ∀x∀y(x+ y = y + x)

Neutral element for addition ∀x(x+ 0 = x)

Inverse element for addition ∀x∃y(x+ y = 0)

(same for multiplication)

Distributivity of multiplication over addition∀x∀y∀z(x · (y + z) = (x · y) + (x · z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 79 / 120

Page 381: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

FOL in algebra

Example (field axioms)

Closure under addition ∀x∀y∃z(x+ y = z)

Associativity of addition ∀x∀y∀z((x+ (y + z)) = ((x+ y) + z))

Commutativity of addition ∀x∀y(x+ y = y + x)

Neutral element for addition ∀x(x+ 0 = x)

Inverse element for addition ∀x∃y(x+ y = 0)

(same for multiplication)

Distributivity of multiplication over addition∀x∀y∀z(x · (y + z) = (x · y) + (x · z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 79 / 120

Page 382: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

FOL in algebra

Example (field axioms)

Closure under addition ∀x∀y∃z(x+ y = z)

Associativity of addition ∀x∀y∀z((x+ (y + z)) = ((x+ y) + z))

Commutativity of addition ∀x∀y(x+ y = y + x)

Neutral element for addition ∀x(x+ 0 = x)

Inverse element for addition ∀x∃y(x+ y = 0)

(same for multiplication)

Distributivity of multiplication over addition∀x∀y∀z(x · (y + z) = (x · y) + (x · z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 79 / 120

Page 383: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Why “first-order”?

first-order quantification of elements (∃xP (x))

second-order quantification of predicates (∃P∀xP (x))

third-order quantification of predicates over predicates (∃R∀P (R(P )))

. . .

first-order logic suffices for rational numbers (; algebra)

second-order is needed for real numbers (; analysis)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 80 / 120

Page 384: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Why “first-order”?

first-order quantification of elements (∃xP (x))

second-order quantification of predicates (∃P∀xP (x))

third-order quantification of predicates over predicates (∃R∀P (R(P )))

. . .

first-order logic suffices for rational numbers (; algebra)

second-order is needed for real numbers (; analysis)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 80 / 120

Page 385: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Why “first-order”?

first-order quantification of elements (∃xP (x))

second-order quantification of predicates (∃P∀xP (x))

third-order quantification of predicates over predicates (∃R∀P (R(P )))

. . .

first-order logic suffices for rational numbers (; algebra)

second-order is needed for real numbers (; analysis)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 80 / 120

Page 386: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Why “first-order”?

first-order quantification of elements (∃xP (x))

second-order quantification of predicates (∃P∀xP (x))

third-order quantification of predicates over predicates (∃R∀P (R(P )))

. . .

first-order logic suffices for rational numbers (; algebra)

second-order is needed for real numbers (; analysis)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 80 / 120

Page 387: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Why “first-order”?

first-order quantification of elements (∃xP (x))

second-order quantification of predicates (∃P∀xP (x))

third-order quantification of predicates over predicates (∃R∀P (R(P )))

. . .

first-order logic suffices for rational numbers (; algebra)

second-order is needed for real numbers (; analysis)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 80 / 120

Page 388: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Why “first-order”?

first-order quantification of elements (∃xP (x))

second-order quantification of predicates (∃P∀xP (x))

third-order quantification of predicates over predicates (∃R∀P (R(P )))

. . .

first-order logic suffices for rational numbers (; algebra)

second-order is needed for real numbers (; analysis)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 80 / 120

Page 389: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Formalisation in second-order logic

Definition (Dedekind completeness)

A set M is Dedekind complete if every non-empty subset S ⊆M with anupper bound has a least upper bound.

S = {x | x · x ≤ 2}. Least upper bound of S:√

2

Example (Dedekind completenes in SOL)

∀S 〈[∃xS(x) ∧ ∃x∀y(S(y)→ y < x)]→∃x[∀y(S(y)→ y ≤ x) ∧ ∀z(z < x→ ∃t(z < t ∧ S(t)))]〉

“For every set S the following holds: if S has at least one member andthere exists an x that is greater than every member y of S, then there alsoexists an x that is greater (or equal) than every member y of S and forevery z that is smaller than x, there a t that is greater than z and in S.”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 81 / 120

Page 390: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Formalisation in second-order logic

Definition (Dedekind completeness)

A set M is Dedekind complete if every non-empty subset S ⊆M with anupper bound has a least upper bound.

S = {x | x · x ≤ 2}. Least upper bound of S:√

2

Example (Dedekind completenes in SOL)

∀S 〈[∃xS(x) ∧ ∃x∀y(S(y)→ y < x)]→∃x[∀y(S(y)→ y ≤ x) ∧ ∀z(z < x→ ∃t(z < t ∧ S(t)))]〉

“For every set S the following holds: if S has at least one member andthere exists an x that is greater than every member y of S, then there alsoexists an x that is greater (or equal) than every member y of S and forevery z that is smaller than x, there a t that is greater than z and in S.”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 81 / 120

Page 391: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Formalisation in second-order logic

Definition (Dedekind completeness)

A set M is Dedekind complete if every non-empty subset S ⊆M with anupper bound has a least upper bound.

S = {x | x · x ≤ 2}. Least upper bound of S:√

2

Example (Dedekind completenes in SOL)

∀S 〈[∃xS(x) ∧ ∃x∀y(S(y)→ y < x)]→∃x[∀y(S(y)→ y ≤ x) ∧ ∀z(z < x→ ∃t(z < t ∧ S(t)))]〉

“For every set S the following holds: if S has at least one member andthere exists an x that is greater than every member y of S, then there alsoexists an x that is greater (or equal) than every member y of S and forevery z that is smaller than x, there a t that is greater than z and in S.”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 81 / 120

Page 392: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Formalisation in second-order logic

Definition (Dedekind completeness)

A set M is Dedekind complete if every non-empty subset S ⊆M with anupper bound has a least upper bound.

S = {x | x · x ≤ 2}. Least upper bound of S:√

2

Example (Dedekind completenes in SOL)

∀S 〈[∃xS(x) ∧ ∃x∀y(S(y)→ y < x)]→∃x[∀y(S(y)→ y ≤ x) ∧ ∀z(z < x→ ∃t(z < t ∧ S(t)))]〉

“For every set S the following holds: if S has at least one member andthere exists an x that is greater than every member y of S, then there alsoexists an x that is greater (or equal) than every member y of S and forevery z that is smaller than x, there a t that is greater than z and in S.”

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 81 / 120

Page 393: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Translating natural language into FOL

FOL is more powerful in expressingnatural language than PL . . .

Chickens revisited

Some chickens cannot fly.∃x(C(x) ∧ ¬F (x))

All chickens are birds.∀x(C(x)→ B(x))

Some birds cannot fly.∃x(B(x) ∧ ¬F (x))

. . . but reasoning requires moreattention than for PL.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 82 / 120

Page 394: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Translating natural language into FOL

FOL is more powerful in expressingnatural language than PL . . .

Chickens revisited

Some chickens cannot fly.∃x(C(x) ∧ ¬F (x))

All chickens are birds.∀x(C(x)→ B(x))

Some birds cannot fly.∃x(B(x) ∧ ¬F (x))

. . . but reasoning requires moreattention than for PL.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 82 / 120

Page 395: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Translating natural language into FOL

FOL is more powerful in expressingnatural language than PL . . .

Chickens revisited

Some chickens cannot fly.∃x(C(x) ∧ ¬F (x))

All chickens are birds.∀x(C(x)→ B(x))

Some birds cannot fly.∃x(B(x) ∧ ¬F (x))

. . . but reasoning requires moreattention than for PL.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 82 / 120

Page 396: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Translating natural language into FOL

FOL is more powerful in expressingnatural language than PL . . .

Chickens revisited

Some chickens cannot fly.∃x(C(x) ∧ ¬F (x))

All chickens are birds.∀x(C(x)→ B(x))

Some birds cannot fly.∃x(B(x) ∧ ¬F (x))

. . . but reasoning requires moreattention than for PL.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 82 / 120

Page 397: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: translation of natural language into FOL

Using

the unary predicates Student, Professor, and Course, and

the binary predicates likes, supervises, teaches,

translate the following sentences into FOL:

a) Every student likes some professor.

b) Every professor likes every student.

c) Students are only supervised by professors.

d) Every professor teaches at least two courses.

e) Each professor only supervises students that like him.

f) There is a course that is only taught by one professor.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 83 / 120

Page 398: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Outline

1 propositional and first-order logic

1 syntax and semantics of propositional logic2 reasoning

1 resolution2 tableaus

3 syntax and semantics of first-order logic4 reasoning

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 84 / 120

Page 399: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution in first-order logic

How can the resolution principle be transferred from PL to FOL?

Example (naive resolution in FOL)

∀x(H(x)→ ∃yM(x, y)) H(c)

?

Difficulties:

contradictions between quantifiers:∀xϕ(x),∀x¬ϕ(x) vs. ∃xϕ(x),∃x¬ϕ(x)

interaction of variables and constants

generation of CNF in the presence of quantifiers

Approach:

elimination of existential quantification

replacement of variables with terms to make atoms equal

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 85 / 120

Page 400: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution in first-order logic

How can the resolution principle be transferred from PL to FOL?

Example (naive resolution in FOL)

∀x(H(x)→ ∃yM(x, y)) H(c)

?

Difficulties:

contradictions between quantifiers:∀xϕ(x),∀x¬ϕ(x) vs. ∃xϕ(x),∃x¬ϕ(x)

interaction of variables and constants

generation of CNF in the presence of quantifiers

Approach:

elimination of existential quantification

replacement of variables with terms to make atoms equal

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 85 / 120

Page 401: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution in first-order logic

How can the resolution principle be transferred from PL to FOL?

Example (naive resolution in FOL)

∀x(H(x)→ ∃yM(x, y)) H(c)

?

Difficulties:

contradictions between quantifiers:∀xϕ(x),∀x¬ϕ(x) vs. ∃xϕ(x),∃x¬ϕ(x)

interaction of variables and constants

generation of CNF in the presence of quantifiers

Approach:

elimination of existential quantification

replacement of variables with terms to make atoms equal

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 85 / 120

Page 402: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution in first-order logic

How can the resolution principle be transferred from PL to FOL?

Example (naive resolution in FOL)

∀x(H(x)→ ∃yM(x, y)) H(c)

?

Difficulties:

contradictions between quantifiers:∀xϕ(x),∀x¬ϕ(x) vs. ∃xϕ(x),∃x¬ϕ(x)

interaction of variables and constants

generation of CNF in the presence of quantifiers

Approach:

elimination of existential quantification

replacement of variables with terms to make atoms equal

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 85 / 120

Page 403: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution in first-order logic

How can the resolution principle be transferred from PL to FOL?

Example (naive resolution in FOL)

∀x(H(x)→ ∃yM(x, y)) H(c)

?

Difficulties:

contradictions between quantifiers:∀xϕ(x),∀x¬ϕ(x) vs. ∃xϕ(x),∃x¬ϕ(x)

interaction of variables and constants

generation of CNF in the presence of quantifiers

Approach:

elimination of existential quantification

replacement of variables with terms to make atoms equal

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 85 / 120

Page 404: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution in first-order logic

How can the resolution principle be transferred from PL to FOL?

Example (naive resolution in FOL)

∀x(H(x)→ ∃yM(x, y)) H(c)

?

Difficulties:

contradictions between quantifiers:∀xϕ(x),∀x¬ϕ(x) vs. ∃xϕ(x),∃x¬ϕ(x)

interaction of variables and constants

generation of CNF in the presence of quantifiers

Approach:

elimination of existential quantification

replacement of variables with terms to make atoms equal

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 85 / 120

Page 405: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Negation normal form

Similar to propositonal logic: allow negation only for atoms

1 eliminate → and ↔

ϕ→ ψ ; ¬ϕ ∨ ψϕ↔ ψ ; (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

2 apply de Morgan rules and their equivalents for quantifiers

¬(ϕ ∧ ψ) ; ¬ϕ ∨ ¬ψ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ¬∀xϕ ; ∃x¬ϕ¬∃xϕ ; ∀x¬ϕ

3 remove double negation

¬¬ϕ ; ϕ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 86 / 120

Page 406: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Negation normal form

Similar to propositonal logic: allow negation only for atoms

1 eliminate → and ↔ϕ→ ψ ; ¬ϕ ∨ ψ

ϕ↔ ψ ; (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

2 apply de Morgan rules and their equivalents for quantifiers

¬(ϕ ∧ ψ) ; ¬ϕ ∨ ¬ψ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ¬∀xϕ ; ∃x¬ϕ¬∃xϕ ; ∀x¬ϕ

3 remove double negation

¬¬ϕ ; ϕ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 86 / 120

Page 407: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Negation normal form

Similar to propositonal logic: allow negation only for atoms

1 eliminate → and ↔ϕ→ ψ ; ¬ϕ ∨ ψϕ↔ ψ ; (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

2 apply de Morgan rules and their equivalents for quantifiers

¬(ϕ ∧ ψ) ; ¬ϕ ∨ ¬ψ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ¬∀xϕ ; ∃x¬ϕ¬∃xϕ ; ∀x¬ϕ

3 remove double negation

¬¬ϕ ; ϕ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 86 / 120

Page 408: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Negation normal form

Similar to propositonal logic: allow negation only for atoms

1 eliminate → and ↔ϕ→ ψ ; ¬ϕ ∨ ψϕ↔ ψ ; (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

2 apply de Morgan rules and their equivalents for quantifiers

¬(ϕ ∧ ψ) ; ¬ϕ ∨ ¬ψ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ¬∀xϕ ; ∃x¬ϕ¬∃xϕ ; ∀x¬ϕ

3 remove double negation

¬¬ϕ ; ϕ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 86 / 120

Page 409: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Negation normal form

Similar to propositonal logic: allow negation only for atoms

1 eliminate → and ↔ϕ→ ψ ; ¬ϕ ∨ ψϕ↔ ψ ; (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

2 apply de Morgan rules and their equivalents for quantifiers

¬(ϕ ∧ ψ) ; ¬ϕ ∨ ¬ψ

¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ¬∀xϕ ; ∃x¬ϕ¬∃xϕ ; ∀x¬ϕ

3 remove double negation

¬¬ϕ ; ϕ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 86 / 120

Page 410: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Negation normal form

Similar to propositonal logic: allow negation only for atoms

1 eliminate → and ↔ϕ→ ψ ; ¬ϕ ∨ ψϕ↔ ψ ; (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

2 apply de Morgan rules and their equivalents for quantifiers

¬(ϕ ∧ ψ) ; ¬ϕ ∨ ¬ψ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ

¬∀xϕ ; ∃x¬ϕ¬∃xϕ ; ∀x¬ϕ

3 remove double negation

¬¬ϕ ; ϕ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 86 / 120

Page 411: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Negation normal form

Similar to propositonal logic: allow negation only for atoms

1 eliminate → and ↔ϕ→ ψ ; ¬ϕ ∨ ψϕ↔ ψ ; (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

2 apply de Morgan rules and their equivalents for quantifiers

¬(ϕ ∧ ψ) ; ¬ϕ ∨ ¬ψ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ¬∀xϕ ; ∃x¬ϕ

¬∃xϕ ; ∀x¬ϕ3 remove double negation

¬¬ϕ ; ϕ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 86 / 120

Page 412: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Negation normal form

Similar to propositonal logic: allow negation only for atoms

1 eliminate → and ↔ϕ→ ψ ; ¬ϕ ∨ ψϕ↔ ψ ; (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

2 apply de Morgan rules and their equivalents for quantifiers

¬(ϕ ∧ ψ) ; ¬ϕ ∨ ¬ψ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ¬∀xϕ ; ∃x¬ϕ¬∃xϕ ; ∀x¬ϕ

3 remove double negation

¬¬ϕ ; ϕ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 86 / 120

Page 413: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Negation normal form

Similar to propositonal logic: allow negation only for atoms

1 eliminate → and ↔ϕ→ ψ ; ¬ϕ ∨ ψϕ↔ ψ ; (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

2 apply de Morgan rules and their equivalents for quantifiers

¬(ϕ ∧ ψ) ; ¬ϕ ∨ ¬ψ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ¬∀xϕ ; ∃x¬ϕ¬∃xϕ ; ∀x¬ϕ

3 remove double negation

¬¬ϕ ; ϕ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 86 / 120

Page 414: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Negation normal form

Similar to propositonal logic: allow negation only for atoms

1 eliminate → and ↔ϕ→ ψ ; ¬ϕ ∨ ψϕ↔ ψ ; (ϕ ∧ ψ) ∨ (¬ϕ ∧ ¬ψ)

2 apply de Morgan rules and their equivalents for quantifiers

¬(ϕ ∧ ψ) ; ¬ϕ ∨ ¬ψ¬(ϕ ∨ ψ) ; ¬ϕ ∧ ¬ψ¬∀xϕ ; ∃x¬ϕ¬∃xϕ ; ∀x¬ϕ

3 remove double negation

¬¬ϕ ; ϕ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 86 / 120

Page 415: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Prenex normal form: separation of quantifiers

Definition (prenex normal form)

A formula is in PNF if it has the shape Q1x1 . . . Qnxnϕ(x1, . . . , xn) with

prefix Q1x1 . . . Qnxn mit Qi ∈ {∀, ∃}matrix quantifier-free formula ϕ with variables x1 . . . xn.

Algorithm for transformation into PNF:

1 rename variables so they are distinct

2 move quantifiers to the front, maintaining original order

Example (PNF)

people have mother and father ∀x(H(x)→ ∃yM(x, y) ∧ ∃yF (x, y))transform into NNF ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃yF (x, y))replace second y with z ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃zF (x, z))move quantifiers to the front ∀x∃y∃z(¬H(x) ∨M(x, y) ∧ F (x, z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 87 / 120

Page 416: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Prenex normal form: separation of quantifiers

Definition (prenex normal form)

A formula is in PNF if it has the shape Q1x1 . . . Qnxnϕ(x1, . . . , xn) with

prefix Q1x1 . . . Qnxn mit Qi ∈ {∀, ∃}matrix quantifier-free formula ϕ with variables x1 . . . xn.

Algorithm for transformation into PNF:

1 rename variables so they are distinct

2 move quantifiers to the front, maintaining original order

Example (PNF)

people have mother and father ∀x(H(x)→ ∃yM(x, y) ∧ ∃yF (x, y))transform into NNF ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃yF (x, y))replace second y with z ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃zF (x, z))move quantifiers to the front ∀x∃y∃z(¬H(x) ∨M(x, y) ∧ F (x, z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 87 / 120

Page 417: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Prenex normal form: separation of quantifiers

Definition (prenex normal form)

A formula is in PNF if it has the shape Q1x1 . . . Qnxnϕ(x1, . . . , xn) with

prefix Q1x1 . . . Qnxn mit Qi ∈ {∀, ∃}matrix quantifier-free formula ϕ with variables x1 . . . xn.

Algorithm for transformation into PNF:

1 rename variables so they are distinct

2 move quantifiers to the front, maintaining original order

Example (PNF)

people have mother and father ∀x(H(x)→ ∃yM(x, y) ∧ ∃yF (x, y))transform into NNF ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃yF (x, y))replace second y with z ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃zF (x, z))move quantifiers to the front ∀x∃y∃z(¬H(x) ∨M(x, y) ∧ F (x, z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 87 / 120

Page 418: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Prenex normal form: separation of quantifiers

Definition (prenex normal form)

A formula is in PNF if it has the shape Q1x1 . . . Qnxnϕ(x1, . . . , xn) with

prefix Q1x1 . . . Qnxn mit Qi ∈ {∀, ∃}matrix quantifier-free formula ϕ with variables x1 . . . xn.

Algorithm for transformation into PNF:

1 rename variables so they are distinct

2 move quantifiers to the front, maintaining original order

Example (PNF)

people have mother and father ∀x(H(x)→ ∃yM(x, y) ∧ ∃yF (x, y))

transform into NNF ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃yF (x, y))replace second y with z ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃zF (x, z))move quantifiers to the front ∀x∃y∃z(¬H(x) ∨M(x, y) ∧ F (x, z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 87 / 120

Page 419: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Prenex normal form: separation of quantifiers

Definition (prenex normal form)

A formula is in PNF if it has the shape Q1x1 . . . Qnxnϕ(x1, . . . , xn) with

prefix Q1x1 . . . Qnxn mit Qi ∈ {∀, ∃}matrix quantifier-free formula ϕ with variables x1 . . . xn.

Algorithm for transformation into PNF:

1 rename variables so they are distinct

2 move quantifiers to the front, maintaining original order

Example (PNF)

people have mother and father ∀x(H(x)→ ∃yM(x, y) ∧ ∃yF (x, y))transform into NNF ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃yF (x, y))

replace second y with z ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃zF (x, z))move quantifiers to the front ∀x∃y∃z(¬H(x) ∨M(x, y) ∧ F (x, z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 87 / 120

Page 420: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Prenex normal form: separation of quantifiers

Definition (prenex normal form)

A formula is in PNF if it has the shape Q1x1 . . . Qnxnϕ(x1, . . . , xn) with

prefix Q1x1 . . . Qnxn mit Qi ∈ {∀, ∃}matrix quantifier-free formula ϕ with variables x1 . . . xn.

Algorithm for transformation into PNF:

1 rename variables so they are distinct

2 move quantifiers to the front, maintaining original order

Example (PNF)

people have mother and father ∀x(H(x)→ ∃yM(x, y) ∧ ∃yF (x, y))transform into NNF ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃yF (x, y))replace second y with z ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃zF (x, z))

move quantifiers to the front ∀x∃y∃z(¬H(x) ∨M(x, y) ∧ F (x, z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 87 / 120

Page 421: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Prenex normal form: separation of quantifiers

Definition (prenex normal form)

A formula is in PNF if it has the shape Q1x1 . . . Qnxnϕ(x1, . . . , xn) with

prefix Q1x1 . . . Qnxn mit Qi ∈ {∀, ∃}matrix quantifier-free formula ϕ with variables x1 . . . xn.

Algorithm for transformation into PNF:

1 rename variables so they are distinct

2 move quantifiers to the front, maintaining original order

Example (PNF)

people have mother and father ∀x(H(x)→ ∃yM(x, y) ∧ ∃yF (x, y))transform into NNF ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃yF (x, y))replace second y with z ∀x(¬H(x) ∨ ∃yM(x, y) ∧ ∃zF (x, z))move quantifiers to the front ∀x∃y∃z(¬H(x) ∨M(x, y) ∧ F (x, z))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 87 / 120

Page 422: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Skolem normal form: elimination of existential quantifier

Idea: replacement of existentially quantified variables with terms

Example (Skolemisation)

”There is a president.“∃xP (x) ; P (c) c is new!

”Every human being has a mother.“∀x∃y(H(x)→M(x, y)) ; ∀x(H(x)→M(x, c))

f is new!

Definition (Skolemisation)

For a formula ϕ = ∀x1 . . . ∀xn∃yϕ(x1, . . . , xn, y) in PNF, the Skolemnormal form is obtained by replacing each existentially quantified variable,which is in the scope of n universal quantifiers, by a new n-ary functionsymbol f : ∀x1 . . . ∀xnϕ(x1, . . . , xn, f(x1, . . . , xn))

A formula ϕ and its SNF are not equivalent, but equisatisfiable.All variables are universally quantified ; ∀x not needed anymore.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 88 / 120

Page 423: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Skolem normal form: elimination of existential quantifier

Idea: replacement of existentially quantified variables with terms

Example (Skolemisation)

”There is a president.“∃xP (x)

; P (c) c is new!

”Every human being has a mother.“∀x∃y(H(x)→M(x, y)) ; ∀x(H(x)→M(x, c))

f is new!

Definition (Skolemisation)

For a formula ϕ = ∀x1 . . . ∀xn∃yϕ(x1, . . . , xn, y) in PNF, the Skolemnormal form is obtained by replacing each existentially quantified variable,which is in the scope of n universal quantifiers, by a new n-ary functionsymbol f : ∀x1 . . . ∀xnϕ(x1, . . . , xn, f(x1, . . . , xn))

A formula ϕ and its SNF are not equivalent, but equisatisfiable.All variables are universally quantified ; ∀x not needed anymore.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 88 / 120

Page 424: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Skolem normal form: elimination of existential quantifier

Idea: replacement of existentially quantified variables with terms

Example (Skolemisation)

”There is a president.“∃xP (x) ; P (c) c is new!

”Every human being has a mother.“∀x∃y(H(x)→M(x, y)) ; ∀x(H(x)→M(x, c))

f is new!

Definition (Skolemisation)

For a formula ϕ = ∀x1 . . . ∀xn∃yϕ(x1, . . . , xn, y) in PNF, the Skolemnormal form is obtained by replacing each existentially quantified variable,which is in the scope of n universal quantifiers, by a new n-ary functionsymbol f : ∀x1 . . . ∀xnϕ(x1, . . . , xn, f(x1, . . . , xn))

A formula ϕ and its SNF are not equivalent, but equisatisfiable.All variables are universally quantified ; ∀x not needed anymore.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 88 / 120

Page 425: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Skolem normal form: elimination of existential quantifier

Idea: replacement of existentially quantified variables with terms

Example (Skolemisation)

”There is a president.“∃xP (x) ; P (c) c is new!

”Every human being has a mother.“∀x∃y(H(x)→M(x, y))

; ∀x(H(x)→M(x, c))

f is new!

Definition (Skolemisation)

For a formula ϕ = ∀x1 . . . ∀xn∃yϕ(x1, . . . , xn, y) in PNF, the Skolemnormal form is obtained by replacing each existentially quantified variable,which is in the scope of n universal quantifiers, by a new n-ary functionsymbol f : ∀x1 . . . ∀xnϕ(x1, . . . , xn, f(x1, . . . , xn))

A formula ϕ and its SNF are not equivalent, but equisatisfiable.All variables are universally quantified ; ∀x not needed anymore.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 88 / 120

Page 426: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Skolem normal form: elimination of existential quantifier

Idea: replacement of existentially quantified variables with terms

Example (Skolemisation)

”There is a president.“∃xP (x) ; P (c) c is new!

”Every human being has a mother.“∀x∃y(H(x)→M(x, y)) ; ∀x(H(x)→M(x, c))

f is new!

Definition (Skolemisation)

For a formula ϕ = ∀x1 . . . ∀xn∃yϕ(x1, . . . , xn, y) in PNF, the Skolemnormal form is obtained by replacing each existentially quantified variable,which is in the scope of n universal quantifiers, by a new n-ary functionsymbol f : ∀x1 . . . ∀xnϕ(x1, . . . , xn, f(x1, . . . , xn))

A formula ϕ and its SNF are not equivalent, but equisatisfiable.All variables are universally quantified ; ∀x not needed anymore.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 88 / 120

Page 427: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Skolem normal form: elimination of existential quantifier

Idea: replacement of existentially quantified variables with terms

Example (Skolemisation)

”There is a president.“∃xP (x) ; P (c) c is new!

”Every human being has a mother.“∀x∃y(H(x)→M(x, y)) ; ∀x(H(x)→M(x, f(x)))

f is new!

Definition (Skolemisation)

For a formula ϕ = ∀x1 . . . ∀xn∃yϕ(x1, . . . , xn, y) in PNF, the Skolemnormal form is obtained by replacing each existentially quantified variable,which is in the scope of n universal quantifiers, by a new n-ary functionsymbol f : ∀x1 . . . ∀xnϕ(x1, . . . , xn, f(x1, . . . , xn))

A formula ϕ and its SNF are not equivalent, but equisatisfiable.All variables are universally quantified ; ∀x not needed anymore.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 88 / 120

Page 428: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Skolem normal form: elimination of existential quantifier

Idea: replacement of existentially quantified variables with terms

Example (Skolemisation)

”There is a president.“∃xP (x) ; P (c) c is new!

”Every human being has a mother.“∀x∃y(H(x)→M(x, y)) ; ∀x(H(x)→M(x, f(x))) f is new!

Definition (Skolemisation)

For a formula ϕ = ∀x1 . . . ∀xn∃yϕ(x1, . . . , xn, y) in PNF, the Skolemnormal form is obtained by replacing each existentially quantified variable,which is in the scope of n universal quantifiers, by a new n-ary functionsymbol f : ∀x1 . . . ∀xnϕ(x1, . . . , xn, f(x1, . . . , xn))

A formula ϕ and its SNF are not equivalent, but equisatisfiable.All variables are universally quantified ; ∀x not needed anymore.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 88 / 120

Page 429: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Skolem normal form: elimination of existential quantifier

Idea: replacement of existentially quantified variables with terms

Example (Skolemisation)

”There is a president.“∃xP (x) ; P (c) c is new!

”Every human being has a mother.“∀x∃y(H(x)→M(x, y)) ; ∀x(H(x)→M(x, f(x))) f is new!

Definition (Skolemisation)

For a formula ϕ = ∀x1 . . . ∀xn∃yϕ(x1, . . . , xn, y) in PNF, the Skolemnormal form is obtained by replacing each existentially quantified variable,which is in the scope of n universal quantifiers, by a new n-ary functionsymbol f : ∀x1 . . . ∀xnϕ(x1, . . . , xn, f(x1, . . . , xn))

A formula ϕ and its SNF are not equivalent, but equisatisfiable.All variables are universally quantified ; ∀x not needed anymore.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 88 / 120

Page 430: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Skolem normal form: elimination of existential quantifier

Idea: replacement of existentially quantified variables with terms

Example (Skolemisation)

”There is a president.“∃xP (x) ; P (c) c is new!

”Every human being has a mother.“∀x∃y(H(x)→M(x, y)) ; ∀x(H(x)→M(x, f(x))) f is new!

Definition (Skolemisation)

For a formula ϕ = ∀x1 . . . ∀xn∃yϕ(x1, . . . , xn, y) in PNF, the Skolemnormal form is obtained by replacing each existentially quantified variable,which is in the scope of n universal quantifiers, by a new n-ary functionsymbol f : ∀x1 . . . ∀xnϕ(x1, . . . , xn, f(x1, . . . , xn))

A formula ϕ and its SNF are not equivalent, but equisatisfiable.

All variables are universally quantified ; ∀x not needed anymore.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 88 / 120

Page 431: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Skolem normal form: elimination of existential quantifier

Idea: replacement of existentially quantified variables with terms

Example (Skolemisation)

”There is a president.“∃xP (x) ; P (c) c is new!

”Every human being has a mother.“∀x∃y(H(x)→M(x, y)) ; ∀x(H(x)→M(x, f(x))) f is new!

Definition (Skolemisation)

For a formula ϕ = ∀x1 . . . ∀xn∃yϕ(x1, . . . , xn, y) in PNF, the Skolemnormal form is obtained by replacing each existentially quantified variable,which is in the scope of n universal quantifiers, by a new n-ary functionsymbol f : ∀x1 . . . ∀xnϕ(x1, . . . , xn, f(x1, . . . , xn))

A formula ϕ and its SNF are not equivalent, but equisatisfiable.All variables are universally quantified ; ∀x not needed anymore.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 88 / 120

Page 432: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: Skolem normal form

Transform the following formulas into SNF:

a) ∀x(∃yR(x, y) ∧ ∃y¬R(x, y)) ∧ ∀xR(x, x) ∧ ∃y∃z¬R(y, z)

b) ∃x∀y(R(x, y)∨R(y, x))∧¬∀y¬(R(y, y)∧¬R(y, f(y)))∨¬(∀xR(x, x)→∃xR(x, x))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 89 / 120

Page 433: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

SNF: Optimisation

Computing PNF first and Skolemizing afterwards has drawbacks

Example (unnecessarily complex Skolem function)

∀xP (x)∧∃yQ(y) ; ∀x∃y(P (x)∧Q(y)) ; ∀x(P (x)∧Q(f(x)))

Since y does not appear in the scope of ∀x, y could be replaced by aconstant rather than a unary function.

Standard procedure:

1 negation normal form

eliminate → and ↔apply de Morgan ruleseliminate double negation

2 rename variables

3 prenex normal form

4 Skolem normal form

More complex procedure leading tosimpler Skolem functions:

1 NNF

2 miniscoping

3 rename variables

4 Skolemise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 90 / 120

Page 434: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

SNF: Optimisation

Computing PNF first and Skolemizing afterwards has drawbacks

Example (unnecessarily complex Skolem function)

∀xP (x)∧∃yQ(y) ; ∀x∃y(P (x)∧Q(y)) ; ∀x(P (x)∧Q(f(x)))Since y does not appear in the scope of ∀x, y could be replaced by aconstant rather than a unary function.

Standard procedure:

1 negation normal form

eliminate → and ↔apply de Morgan ruleseliminate double negation

2 rename variables

3 prenex normal form

4 Skolem normal form

More complex procedure leading tosimpler Skolem functions:

1 NNF

2 miniscoping

3 rename variables

4 Skolemise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 90 / 120

Page 435: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

SNF: Optimisation

Computing PNF first and Skolemizing afterwards has drawbacks

Example (unnecessarily complex Skolem function)

∀xP (x)∧∃yQ(y) ; ∀x∃y(P (x)∧Q(y)) ; ∀x(P (x)∧Q(f(x)))Since y does not appear in the scope of ∀x, y could be replaced by aconstant rather than a unary function.

Standard procedure:

1 negation normal form

eliminate → and ↔apply de Morgan ruleseliminate double negation

2 rename variables

3 prenex normal form

4 Skolem normal form

More complex procedure leading tosimpler Skolem functions:

1 NNF

2 miniscoping

3 rename variables

4 Skolemise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 90 / 120

Page 436: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

SNF: Optimisation

Computing PNF first and Skolemizing afterwards has drawbacks

Example (unnecessarily complex Skolem function)

∀xP (x)∧∃yQ(y) ; ∀x∃y(P (x)∧Q(y)) ; ∀x(P (x)∧Q(f(x)))Since y does not appear in the scope of ∀x, y could be replaced by aconstant rather than a unary function.

Standard procedure:

1 negation normal form

eliminate → and ↔apply de Morgan ruleseliminate double negation

2 rename variables

3 prenex normal form

4 Skolem normal form

More complex procedure leading tosimpler Skolem functions:

1 NNF

2 miniscoping

3 rename variables

4 Skolemise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 90 / 120

Page 437: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

SNF: Optimisation

Computing PNF first and Skolemizing afterwards has drawbacks

Example (unnecessarily complex Skolem function)

∀xP (x)∧∃yQ(y) ; ∀x∃y(P (x)∧Q(y)) ; ∀x(P (x)∧Q(f(x)))Since y does not appear in the scope of ∀x, y could be replaced by aconstant rather than a unary function.

Standard procedure:

1 negation normal form

eliminate → and ↔apply de Morgan ruleseliminate double negation

2 rename variables

3 prenex normal form

4 Skolem normal form

More complex procedure leading tosimpler Skolem functions:

1 NNF

2 miniscoping

3 rename variables

4 Skolemise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 90 / 120

Page 438: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

SNF: Optimisation

Computing PNF first and Skolemizing afterwards has drawbacks

Example (unnecessarily complex Skolem function)

∀xP (x)∧∃yQ(y) ; ∀x∃y(P (x)∧Q(y)) ; ∀x(P (x)∧Q(f(x)))Since y does not appear in the scope of ∀x, y could be replaced by aconstant rather than a unary function.

Standard procedure:

1 negation normal form

eliminate → and ↔apply de Morgan ruleseliminate double negation

2 rename variables

3 prenex normal form

4 Skolem normal form

More complex procedure leading tosimpler Skolem functions:

1 NNF

2 miniscoping

3 rename variables

4 Skolemise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 90 / 120

Page 439: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

SNF: Optimisation

Computing PNF first and Skolemizing afterwards has drawbacks

Example (unnecessarily complex Skolem function)

∀xP (x)∧∃yQ(y) ; ∀x∃y(P (x)∧Q(y)) ; ∀x(P (x)∧Q(f(x)))Since y does not appear in the scope of ∀x, y could be replaced by aconstant rather than a unary function.

Standard procedure:

1 negation normal form

eliminate → and ↔apply de Morgan ruleseliminate double negation

2 rename variables

3 prenex normal form

4 Skolem normal form

More complex procedure leading tosimpler Skolem functions:

1 NNF

2 miniscoping

3 rename variables

4 Skolemise

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 90 / 120

Page 440: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Miniscoping

Goal: minimise the scope of quantifiers while maintaining equivalence

Definition (miniscoping)

Assumption: x occurs freely in ϕ and ψ, but not in χ

Qx(ϕ ∧ χ) ; Qxϕ ∧ χ for Q ∈ {∀,∃}Qx(ϕ ∨ χ) ; Qxϕ ∨ χ for Q ∈ {∀,∃}∀x(ϕ ∧ ψ) ; ∀xϕ ∧ ∀xψ∃x(ϕ ∨ ψ) ; ∃xϕ ∨ ∃xψ

Example (miniscoping)

Miniscoping:∀x∃y(P (x) ∧Q(y)) ; ∀x(P (x) ∧ ∃yQ(y)) ; ∀xP (x) ∧ ∃yQ(y)Skolemisation:∀xP (x) ∧ ∃yQ(y) ; ∀xP (x) ∧Q(c)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 91 / 120

Page 441: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Miniscoping

Goal: minimise the scope of quantifiers while maintaining equivalence

Definition (miniscoping)

Assumption: x occurs freely in ϕ and ψ, but not in χ

Qx(ϕ ∧ χ) ; Qxϕ ∧ χ for Q ∈ {∀,∃}

Qx(ϕ ∨ χ) ; Qxϕ ∨ χ for Q ∈ {∀,∃}∀x(ϕ ∧ ψ) ; ∀xϕ ∧ ∀xψ∃x(ϕ ∨ ψ) ; ∃xϕ ∨ ∃xψ

Example (miniscoping)

Miniscoping:∀x∃y(P (x) ∧Q(y)) ; ∀x(P (x) ∧ ∃yQ(y)) ; ∀xP (x) ∧ ∃yQ(y)Skolemisation:∀xP (x) ∧ ∃yQ(y) ; ∀xP (x) ∧Q(c)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 91 / 120

Page 442: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Miniscoping

Goal: minimise the scope of quantifiers while maintaining equivalence

Definition (miniscoping)

Assumption: x occurs freely in ϕ and ψ, but not in χ

Qx(ϕ ∧ χ) ; Qxϕ ∧ χ for Q ∈ {∀,∃}Qx(ϕ ∨ χ) ; Qxϕ ∨ χ for Q ∈ {∀,∃}

∀x(ϕ ∧ ψ) ; ∀xϕ ∧ ∀xψ∃x(ϕ ∨ ψ) ; ∃xϕ ∨ ∃xψ

Example (miniscoping)

Miniscoping:∀x∃y(P (x) ∧Q(y)) ; ∀x(P (x) ∧ ∃yQ(y)) ; ∀xP (x) ∧ ∃yQ(y)Skolemisation:∀xP (x) ∧ ∃yQ(y) ; ∀xP (x) ∧Q(c)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 91 / 120

Page 443: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Miniscoping

Goal: minimise the scope of quantifiers while maintaining equivalence

Definition (miniscoping)

Assumption: x occurs freely in ϕ and ψ, but not in χ

Qx(ϕ ∧ χ) ; Qxϕ ∧ χ for Q ∈ {∀,∃}Qx(ϕ ∨ χ) ; Qxϕ ∨ χ for Q ∈ {∀,∃}∀x(ϕ ∧ ψ) ; ∀xϕ ∧ ∀xψ

∃x(ϕ ∨ ψ) ; ∃xϕ ∨ ∃xψ

Example (miniscoping)

Miniscoping:∀x∃y(P (x) ∧Q(y)) ; ∀x(P (x) ∧ ∃yQ(y)) ; ∀xP (x) ∧ ∃yQ(y)Skolemisation:∀xP (x) ∧ ∃yQ(y) ; ∀xP (x) ∧Q(c)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 91 / 120

Page 444: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Miniscoping

Goal: minimise the scope of quantifiers while maintaining equivalence

Definition (miniscoping)

Assumption: x occurs freely in ϕ and ψ, but not in χ

Qx(ϕ ∧ χ) ; Qxϕ ∧ χ for Q ∈ {∀,∃}Qx(ϕ ∨ χ) ; Qxϕ ∨ χ for Q ∈ {∀,∃}∀x(ϕ ∧ ψ) ; ∀xϕ ∧ ∀xψ∃x(ϕ ∨ ψ) ; ∃xϕ ∨ ∃xψ

Example (miniscoping)

Miniscoping:∀x∃y(P (x) ∧Q(y)) ; ∀x(P (x) ∧ ∃yQ(y)) ; ∀xP (x) ∧ ∃yQ(y)Skolemisation:∀xP (x) ∧ ∃yQ(y) ; ∀xP (x) ∧Q(c)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 91 / 120

Page 445: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Miniscoping

Goal: minimise the scope of quantifiers while maintaining equivalence

Definition (miniscoping)

Assumption: x occurs freely in ϕ and ψ, but not in χ

Qx(ϕ ∧ χ) ; Qxϕ ∧ χ for Q ∈ {∀,∃}Qx(ϕ ∨ χ) ; Qxϕ ∨ χ for Q ∈ {∀,∃}∀x(ϕ ∧ ψ) ; ∀xϕ ∧ ∀xψ∃x(ϕ ∨ ψ) ; ∃xϕ ∨ ∃xψ

Example (miniscoping)

Miniscoping:∀x∃y(P (x) ∧Q(y)) ; ∀x(P (x) ∧ ∃yQ(y)) ; ∀xP (x) ∧ ∃yQ(y)Skolemisation:∀xP (x) ∧ ∃yQ(y) ; ∀xP (x) ∧Q(c)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 91 / 120

Page 446: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Miniscoping

Goal: minimise the scope of quantifiers while maintaining equivalence

Definition (miniscoping)

Assumption: x occurs freely in ϕ and ψ, but not in χ

Qx(ϕ ∧ χ) ; Qxϕ ∧ χ for Q ∈ {∀,∃}Qx(ϕ ∨ χ) ; Qxϕ ∨ χ for Q ∈ {∀,∃}∀x(ϕ ∧ ψ) ; ∀xϕ ∧ ∀xψ∃x(ϕ ∨ ψ) ; ∃xϕ ∨ ∃xψ

Example (miniscoping)

Miniscoping:∀x∃y(P (x) ∧Q(y)) ; ∀x(P (x) ∧ ∃yQ(y)) ; ∀xP (x) ∧ ∃yQ(y)

Skolemisation:∀xP (x) ∧ ∃yQ(y) ; ∀xP (x) ∧Q(c)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 91 / 120

Page 447: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Miniscoping

Goal: minimise the scope of quantifiers while maintaining equivalence

Definition (miniscoping)

Assumption: x occurs freely in ϕ and ψ, but not in χ

Qx(ϕ ∧ χ) ; Qxϕ ∧ χ for Q ∈ {∀,∃}Qx(ϕ ∨ χ) ; Qxϕ ∨ χ for Q ∈ {∀,∃}∀x(ϕ ∧ ψ) ; ∀xϕ ∧ ∀xψ∃x(ϕ ∨ ψ) ; ∃xϕ ∨ ∃xψ

Example (miniscoping)

Miniscoping:∀x∃y(P (x) ∧Q(y)) ; ∀x(P (x) ∧ ∃yQ(y)) ; ∀xP (x) ∧ ∃yQ(y)Skolemisation:∀xP (x) ∧ ∃yQ(y) ; ∀xP (x) ∧Q(c)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 91 / 120

Page 448: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 449: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 450: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 451: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 452: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀

6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 453: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 454: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 455: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 456: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 457: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 458: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 459: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 460: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀

6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 461: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 462: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Preprocessing for FOL resolution: overview

Standard:

1 negation normal form

2 rename variables

3 prenex normal form

4 Skolem normal form

5 drop ∀6 conjunctive normal form

as for propositional logic

Alternative:

1 negation normal form

2 miniscoping

3 rename variables

4 Skolemize

5 drop ∀6 conjunctive normal form

as for propositional logic

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 92 / 120

Page 463: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and variables

Example (FOL resolution)

formula ∃xH(x) ∧ ∀x(H(x)→ ∃yM(x, y))

NNF ∃xH(x) ∧ ∀x(¬H(x) ∨ ∃yM(x, y)) → eliminated

SNF ∀x(H(c) ∧ (¬H(x) ∨M(x, f(x)))) ∃ eliminated

CNF H(c) ∧ (¬H(x) ∨M(x, f(x))) FOL atoms instead of PL variables

H(c) ¬H(x),M(x, f(x))

?

find variable assignment that makes atoms syntactically equal

replace variables in entire clause

create resolvent

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 93 / 120

Page 464: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and variables

Example (FOL resolution)

formula ∃xH(x) ∧ ∀x(H(x)→ ∃yM(x, y))

NNF ∃xH(x) ∧ ∀x(¬H(x) ∨ ∃yM(x, y)) → eliminated

SNF ∀x(H(c) ∧ (¬H(x) ∨M(x, f(x)))) ∃ eliminated

CNF H(c) ∧ (¬H(x) ∨M(x, f(x))) FOL atoms instead of PL variables

H(c) ¬H(x),M(x, f(x))

?

find variable assignment that makes atoms syntactically equal

replace variables in entire clause

create resolvent

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 93 / 120

Page 465: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and variables

Example (FOL resolution)

formula ∃xH(x) ∧ ∀x(H(x)→ ∃yM(x, y))

NNF ∃xH(x) ∧ ∀x(¬H(x) ∨ ∃yM(x, y)) → eliminated

SNF ∀x(H(c) ∧ (¬H(x) ∨M(x, f(x)))) ∃ eliminated

CNF H(c) ∧ (¬H(x) ∨M(x, f(x))) FOL atoms instead of PL variables

H(c) ¬H(x),M(x, f(x))

?

find variable assignment that makes atoms syntactically equal

replace variables in entire clause

create resolvent

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 93 / 120

Page 466: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and variables

Example (FOL resolution)

formula ∃xH(x) ∧ ∀x(H(x)→ ∃yM(x, y))

NNF ∃xH(x) ∧ ∀x(¬H(x) ∨ ∃yM(x, y)) → eliminated

SNF ∀x(H(c) ∧ (¬H(x) ∨M(x, f(x)))) ∃ eliminated

CNF H(c) ∧ (¬H(x) ∨M(x, f(x))) FOL atoms instead of PL variables

H(c) ¬H(x),M(x, f(x))

?

find variable assignment that makes atoms syntactically equal

replace variables in entire clause

create resolvent

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 93 / 120

Page 467: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and variables

Example (FOL resolution)

formula ∃xH(x) ∧ ∀x(H(x)→ ∃yM(x, y))

NNF ∃xH(x) ∧ ∀x(¬H(x) ∨ ∃yM(x, y)) → eliminated

SNF ∀x(H(c) ∧ (¬H(x) ∨M(x, f(x)))) ∃ eliminated

CNF H(c) ∧ (¬H(x) ∨M(x, f(x))) FOL atoms instead of PL variables

H(c) ¬H(x),M(x, f(x))

?

find variable assignment that makes atoms syntactically equal

replace variables in entire clause

create resolvent

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 93 / 120

Page 468: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and variables

Example (FOL resolution)

formula ∃xH(x) ∧ ∀x(H(x)→ ∃yM(x, y))

NNF ∃xH(x) ∧ ∀x(¬H(x) ∨ ∃yM(x, y)) → eliminated

SNF ∀x(H(c) ∧ (¬H(x) ∨M(x, f(x)))) ∃ eliminated

CNF H(c) ∧ (¬H(x) ∨M(x, f(x))) FOL atoms instead of PL variables

H(c) ¬H(x),M(x, f(x))

?

find variable assignment that makes atoms syntactically equal

replace variables in entire clause

create resolvent

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 93 / 120

Page 469: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and variables

Example (FOL resolution)

formula ∃xH(x) ∧ ∀x(H(x)→ ∃yM(x, y))

NNF ∃xH(x) ∧ ∀x(¬H(x) ∨ ∃yM(x, y)) → eliminated

SNF ∀x(H(c) ∧ (¬H(x) ∨M(x, f(x)))) ∃ eliminated

CNF H(c) ∧ (¬H(x) ∨M(x, f(x))) FOL atoms instead of PL variables

H(c) ¬H(x),M(x, f(x))

M(c, f(c)) [x/c]

find variable assignment that makes atoms syntactically equal

replace variables in entire clause

create resolvent

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 93 / 120

Page 470: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and variables

Example (FOL resolution)

formula ∃xH(x) ∧ ∀x(H(x)→ ∃yM(x, y))

NNF ∃xH(x) ∧ ∀x(¬H(x) ∨ ∃yM(x, y)) → eliminated

SNF ∀x(H(c) ∧ (¬H(x) ∨M(x, f(x)))) ∃ eliminated

CNF H(c) ∧ (¬H(x) ∨M(x, f(x))) FOL atoms instead of PL variables

H(c) ¬H(x),M(x, f(x))

M(c, f(c)) [x/c]

find variable assignment that makes atoms syntactically equal

replace variables in entire clause

create resolvent

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 93 / 120

Page 471: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Resolution and variables

Example (FOL resolution)

formula ∃xH(x) ∧ ∀x(H(x)→ ∃yM(x, y))

NNF ∃xH(x) ∧ ∀x(¬H(x) ∨ ∃yM(x, y)) → eliminated

SNF ∀x(H(c) ∧ (¬H(x) ∨M(x, f(x)))) ∃ eliminated

CNF H(c) ∧ (¬H(x) ∨M(x, f(x))) FOL atoms instead of PL variables

H(c) ¬H(x),M(x, f(x))

M(c, f(c)) [x/c]

find variable assignment that makes atoms syntactically equal

replace variables in entire clause

create resolventJan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 93 / 120

Page 472: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Substitutions

Definition (substitution)

A substition is a mapping from variables to terms.

Example (substitution)

The substitutionσ = ([x/f(y)], [y/m(c, d)])

maps x to f(y) and y to m(c, d).Sequence is important:

([x/y], [y/z]) is different from ([y/z], [x/y])

σ(g(x)) = g(f(m(c, d)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 94 / 120

Page 473: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Substitutions

Definition (substitution)

A substition is a mapping from variables to terms.

Example (substitution)

The substitutionσ = ([x/f(y)], [y/m(c, d)])

maps x to f(y) and y to m(c, d).Sequence is important:

([x/y], [y/z]) is different from ([y/z], [x/y])

σ(g(x)) = g(f(m(c, d)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 94 / 120

Page 474: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unifiers

Definition (unifier)

A unifier is a substitution mapping two formulas to the same formula.

Example (unifier of R(a, y) and R(x, f(a)))

ϕ = R(a, y) ψ = R(x, f(a)) σ = ([x/a], [y/f(a)])σ(ϕ) = R(a, f(a)) = σ(ψ)

Resolution of C1 und C2 is possible if two atoms ϕ,ψ and a substitution σexist such that

ϕ ∈ C1 and ¬ψ ∈ C2

σ is unifier of ϕ and ψ.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 95 / 120

Page 475: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unifiers

Definition (unifier)

A unifier is a substitution mapping two formulas to the same formula.

Example (unifier of R(a, y) and R(x, f(a)))

ϕ = R(a, y) ψ = R(x, f(a)) σ = ([x/a], [y/f(a)])

σ(ϕ) = R(a, f(a)) = σ(ψ)

Resolution of C1 und C2 is possible if two atoms ϕ,ψ and a substitution σexist such that

ϕ ∈ C1 and ¬ψ ∈ C2

σ is unifier of ϕ and ψ.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 95 / 120

Page 476: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unifiers

Definition (unifier)

A unifier is a substitution mapping two formulas to the same formula.

Example (unifier of R(a, y) and R(x, f(a)))

ϕ = R(a, y) ψ = R(x, f(a)) σ = ([x/a], [y/f(a)])σ(ϕ) = R(a, f(a)) = σ(ψ)

Resolution of C1 und C2 is possible if two atoms ϕ,ψ and a substitution σexist such that

ϕ ∈ C1 and ¬ψ ∈ C2

σ is unifier of ϕ and ψ.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 95 / 120

Page 477: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unifiers

Definition (unifier)

A unifier is a substitution mapping two formulas to the same formula.

Example (unifier of R(a, y) and R(x, f(a)))

ϕ = R(a, y) ψ = R(x, f(a)) σ = ([x/a], [y/f(a)])σ(ϕ) = R(a, f(a)) = σ(ψ)

Resolution of C1 und C2 is possible if two atoms ϕ,ψ and a substitution σexist such that

ϕ ∈ C1 and ¬ψ ∈ C2

σ is unifier of ϕ and ψ.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 95 / 120

Page 478: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: variable renaming and occur check

Example (one variable appears in several clauses)

problem no unifier for P (x, c) and P (d, x)

solution rename variables so they are disjointP (x, c), P (d, y), σ = ([x/d], [y/c])

Example (mapping from x to f(x))

problem unification of P (x) and P (f(x)) results in σ = [x/f(x)]

solution occur check: x cannot be mapped to a term containing x

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 96 / 120

Page 479: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: variable renaming and occur check

Example (one variable appears in several clauses)

problem no unifier for P (x, c) and P (d, x)

solution rename variables so they are disjointP (x, c), P (d, y), σ = ([x/d], [y/c])

Example (mapping from x to f(x))

problem unification of P (x) and P (f(x)) results in σ = [x/f(x)]

solution occur check: x cannot be mapped to a term containing x

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 96 / 120

Page 480: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: variable renaming and occur check

Example (one variable appears in several clauses)

problem no unifier for P (x, c) and P (d, x)

solution rename variables so they are disjointP (x, c), P (d, y), σ = ([x/d], [y/c])

Example (mapping from x to f(x))

problem unification of P (x) and P (f(x)) results in σ = [x/f(x)]

solution occur check: x cannot be mapped to a term containing x

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 96 / 120

Page 481: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: variable renaming and occur check

Example (one variable appears in several clauses)

problem no unifier for P (x, c) and P (d, x)

solution rename variables so they are disjointP (x, c), P (d, y), σ = ([x/d], [y/c])

Example (mapping from x to f(x))

problem unification of P (x) and P (f(x)) results in σ = [x/f(x)]

solution occur check: x cannot be mapped to a term containing x

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 96 / 120

Page 482: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: unification

Let

w, x, y, z be variables,

c, d be constant symbols,

f be a unary and g be a binary function symbol,

N and P be unary, R be a binary, and S be a ternary relation symbol.

Try to find unifiers for the following pairs of atoms.

a) P (x) and P (f(g(y, z)))

b) P (x) and N(f(x))

c) R(x, f(x)) and R(f(y), z)

d) R(x, f(x)) and R(f(y), y)

e) R(x, f(x)) and R(f(c), d)

f) S(x, f(g(x, y)), g(x, f(d)) and S(g(c, d), f(z), g(g(c, y), w))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 97 / 120

Page 483: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Most general unifiers

Example: several possible unifiers

P (x), R(x) ¬P (y) ¬R(c)

R(x) R(d)

2

[y/x]

[x/c]

[x/d][y/d]

problem some unifiers prevent resolution

solution most general unifier (MGU): only substitute as much asneeded

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 98 / 120

Page 484: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Most general unifiers

Example: several possible unifiers

P (x), R(x) ¬P (y) ¬R(c)

R(x)

R(d)

2

[y/x]

[x/c]

[x/d][y/d]

problem some unifiers prevent resolution

solution most general unifier (MGU): only substitute as much asneeded

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 98 / 120

Page 485: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Most general unifiers

Example: several possible unifiers

P (x), R(x) ¬P (y) ¬R(c)

R(x)

R(d)

2

[y/x]

[x/c]

[x/d][y/d]

problem some unifiers prevent resolution

solution most general unifier (MGU): only substitute as much asneeded

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 98 / 120

Page 486: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Most general unifiers

Example: several possible unifiers

P (x), R(x) ¬P (y) ¬R(c)

R(x)

R(d)

2

[y/x]

[x/c]

[x/d][y/d]

problem some unifiers prevent resolution

solution most general unifier (MGU): only substitute as much asneeded

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 98 / 120

Page 487: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Most general unifiers

Example: several possible unifiers

P (x), R(x) ¬P (y) ¬R(c)

R(x)

R(d)

2

[y/x]

[x/c]

[x/d][y/d]

problem some unifiers prevent resolution

solution most general unifier (MGU): only substitute as much asneeded

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 98 / 120

Page 488: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Most general unifiers

Example: several possible unifiers

P (x), R(x) ¬P (y) ¬R(c)

R(x)

R(d)

2

[y/x]

[x/c]

[x/d][y/d]

problem some unifiers prevent resolution

solution most general unifier (MGU): only substitute as much asneeded

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 98 / 120

Page 489: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification algorithm

input: terms s, toutput: mgu(s, t), if s and t are unifiable

”not unifiable“, otherwise

1: σ := ()2: while σ(s) 6= σ(t) do3: let i be the first position where σ(s) and σ(t) differ4: if σ(s)|i oder σ(t)|i is a predicate symbol then5: output

”not unifiable“

6: else if neither σ(s)|i nor σ(t)|i is a variable then7: output

”not unifiable“

8: else9: let x be the variable, y the other term

10: if x is proper subterm of y then11: output

”not unifiable“

12: else13: σ := σ · ([x/y])14: output σ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 99 / 120

Page 490: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification algorithm

input: terms s, toutput: mgu(s, t), if s and t are unifiable

”not unifiable“, otherwise

1: σ := ()

2: while σ(s) 6= σ(t) do3: let i be the first position where σ(s) and σ(t) differ4: if σ(s)|i oder σ(t)|i is a predicate symbol then5: output

”not unifiable“

6: else if neither σ(s)|i nor σ(t)|i is a variable then7: output

”not unifiable“

8: else9: let x be the variable, y the other term

10: if x is proper subterm of y then11: output

”not unifiable“

12: else13: σ := σ · ([x/y])14: output σ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 99 / 120

Page 491: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification algorithm

input: terms s, toutput: mgu(s, t), if s and t are unifiable

”not unifiable“, otherwise

1: σ := ()2: while σ(s) 6= σ(t) do3: let i be the first position where σ(s) and σ(t) differ

4: if σ(s)|i oder σ(t)|i is a predicate symbol then5: output

”not unifiable“

6: else if neither σ(s)|i nor σ(t)|i is a variable then7: output

”not unifiable“

8: else9: let x be the variable, y the other term

10: if x is proper subterm of y then11: output

”not unifiable“

12: else13: σ := σ · ([x/y])14: output σ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 99 / 120

Page 492: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification algorithm

input: terms s, toutput: mgu(s, t), if s and t are unifiable

”not unifiable“, otherwise

1: σ := ()2: while σ(s) 6= σ(t) do3: let i be the first position where σ(s) and σ(t) differ4: if σ(s)|i oder σ(t)|i is a predicate symbol then5: output

”not unifiable“

6: else if neither σ(s)|i nor σ(t)|i is a variable then7: output

”not unifiable“

8: else9: let x be the variable, y the other term

10: if x is proper subterm of y then11: output

”not unifiable“

12: else13: σ := σ · ([x/y])14: output σ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 99 / 120

Page 493: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification algorithm

input: terms s, toutput: mgu(s, t), if s and t are unifiable

”not unifiable“, otherwise

1: σ := ()2: while σ(s) 6= σ(t) do3: let i be the first position where σ(s) and σ(t) differ4: if σ(s)|i oder σ(t)|i is a predicate symbol then5: output

”not unifiable“

6: else if neither σ(s)|i nor σ(t)|i is a variable then7: output

”not unifiable“

8: else9: let x be the variable, y the other term

10: if x is proper subterm of y then11: output

”not unifiable“

12: else13: σ := σ · ([x/y])14: output σ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 99 / 120

Page 494: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification algorithm

input: terms s, toutput: mgu(s, t), if s and t are unifiable

”not unifiable“, otherwise

1: σ := ()2: while σ(s) 6= σ(t) do3: let i be the first position where σ(s) and σ(t) differ4: if σ(s)|i oder σ(t)|i is a predicate symbol then5: output

”not unifiable“

6: else if neither σ(s)|i nor σ(t)|i is a variable then7: output

”not unifiable“

8: else9: let x be the variable, y the other term

10: if x is proper subterm of y then11: output

”not unifiable“

12: else13: σ := σ · ([x/y])14: output σ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 99 / 120

Page 495: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification algorithm

input: terms s, toutput: mgu(s, t), if s and t are unifiable

”not unifiable“, otherwise

1: σ := ()2: while σ(s) 6= σ(t) do3: let i be the first position where σ(s) and σ(t) differ4: if σ(s)|i oder σ(t)|i is a predicate symbol then5: output

”not unifiable“

6: else if neither σ(s)|i nor σ(t)|i is a variable then7: output

”not unifiable“

8: else9: let x be the variable, y the other term

10: if x is proper subterm of y then11: output

”not unifiable“

12: else13: σ := σ · ([x/y])14: output σ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 99 / 120

Page 496: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification algorithm

input: terms s, toutput: mgu(s, t), if s and t are unifiable

”not unifiable“, otherwise

1: σ := ()2: while σ(s) 6= σ(t) do3: let i be the first position where σ(s) and σ(t) differ4: if σ(s)|i oder σ(t)|i is a predicate symbol then5: output

”not unifiable“

6: else if neither σ(s)|i nor σ(t)|i is a variable then7: output

”not unifiable“

8: else9: let x be the variable, y the other term

10: if x is proper subterm of y then11: output

”not unifiable“

12: else13: σ := σ · ([x/y])

14: output σ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 99 / 120

Page 497: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification algorithm

input: terms s, toutput: mgu(s, t), if s and t are unifiable

”not unifiable“, otherwise

1: σ := ()2: while σ(s) 6= σ(t) do3: let i be the first position where σ(s) and σ(t) differ4: if σ(s)|i oder σ(t)|i is a predicate symbol then5: output

”not unifiable“

6: else if neither σ(s)|i nor σ(t)|i is a variable then7: output

”not unifiable“

8: else9: let x be the variable, y the other term

10: if x is proper subterm of y then11: output

”not unifiable“

12: else13: σ := σ · ([x/y])14: output σ

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 99 / 120

Page 498: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(x, z, g(x, f(y)))ψ = R(f(c), x, g(y, f(g(x, y))))

x / f(c) occur checku / z MGUw / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 499: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(x, z, g(x, f(y)))ψ = R(f(c), x, g(y, f(g(x, y))))

x / f(c) occur checku / z MGUw / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 500: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(x, z, g(x, f(y)))ψ = R(f(c), u, g(y, f(g(u, y))))

x / f(c) occur checku / z MGUw / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 501: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(x, z, g(x, f(y)))ψ = R(f(c), u, g(w, f(g(u,w))))

x / f(c) occur checku / z MGUw / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 502: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(x, z, g(x, f(y)))ψ = R(f(c), u, g(w, f(g(u,w))))

x / f(c) occur checku / z MGUw / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 503: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(x, z, g(x, f(y)))ψ = R(f(c), u, g(w, f(g(u,w))))

x / f(c) occur check

u / z MGUw / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 504: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(x, z, g(x, f(y)))ψ = R(f(c), u, g(w, f(g(u,w))))

x / f(c) occur check

u / z MGUw / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 505: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(f(c), z, g(f(c), f(y)))ψ = R(f(c), u, g(w, f(g(u,w))))

x / f(c) occur check

u / z MGUw / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 506: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(f(c), z, g(f(c), f(y)))ψ = R(f(c), u, g(w, f(g(u,w))))

x / f(c) occur checku / z MGU

w / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 507: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(f(c), z, g(f(c), f(y)))ψ = R(f(c), z, g(w, f(g(z, w))))

x / f(c) occur checku / z MGU

w / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 508: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(f(c), z, g(f(c), f(y)))ψ = R(f(c), z, g(w, f(g(z, w))))

x / f(c) occur checku / z MGU

w / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 509: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(f(c), z, g(f(c), f(y)))ψ = R(f(c), z, g(w, f(g(z, w))))

x / f(c) occur checku / z MGUw / f(c)

y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 510: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(f(c), z, g(f(c), f(y)))ψ = R(f(c), z, g(f(c), f(g(z, f(c)))))

x / f(c) occur checku / z MGUw / f(c)

y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 511: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(f(c), z, g(f(c), f(y)))ψ = R(f(c), z, g(f(c), f(g(z, f(c)))))

x / f(c) occur checku / z MGUw / f(c)

y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 512: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(f(c), z, g(f(c), f(y)))ψ = R(f(c), z, g(f(c), f(g(z, f(c)))))

x / f(c) occur checku / z MGUw / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 513: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Unification: example

ϕ = R(f(c), z, g(f(c), f(g(z, f(c)))))ψ = R(f(c), z, g(f(c), f(g(z, f(c)))))

x / f(c) occur checku / z MGUw / f(c)y / g(z, f(c))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 100 / 120

Page 514: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: unification algorithm

Let

v, w, x, y, z be variables,

c, d be constants,

f be a unary, g be a binary, and h be a ternary function symbol,

S and T be ternary relation symbols.

Use the unification algorithm to find most general unifiers for the followingpairs of terms:

a) S(x, f(y), g(z, d)) and S(c, f(x), g(f(z), z))

b) T (x, f(x), h(f(y), z, d)) and T (c, f(y), h(z, f(v), w))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 101 / 120

Page 515: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween

1 Tim buys a pumpkin.

∃x(Buys(tim, x) ∧ Pumpkin(x))

2 Whoever buys a pumpkin eats it or carves a Jack-O-Lantern.

∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))

3 Children don’t eat pumpkins.

∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y))))

4 Conjecture: if Tim is a child, then he carves a Jack-O-Lantern.

Child(tim)→ ∃xCarves(tim, x)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 102 / 120

Page 516: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween

1 Tim buys a pumpkin.

∃x(Buys(tim, x) ∧ Pumpkin(x))

2 Whoever buys a pumpkin eats it or carves a Jack-O-Lantern.

∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))

3 Children don’t eat pumpkins.

∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y))))

4 Conjecture: if Tim is a child, then he carves a Jack-O-Lantern.

Child(tim)→ ∃xCarves(tim, x)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 102 / 120

Page 517: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween

1 Tim buys a pumpkin.

∃x(Buys(tim, x) ∧ Pumpkin(x))

2 Whoever buys a pumpkin eats it or carves a Jack-O-Lantern.

∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))

3 Children don’t eat pumpkins.

∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y))))

4 Conjecture: if Tim is a child, then he carves a Jack-O-Lantern.

Child(tim)→ ∃xCarves(tim, x)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 102 / 120

Page 518: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween

1 Tim buys a pumpkin.

∃x(Buys(tim, x) ∧ Pumpkin(x))

2 Whoever buys a pumpkin eats it or carves a Jack-O-Lantern.

∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))

3 Children don’t eat pumpkins.

∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y))))

4 Conjecture: if Tim is a child, then he carves a Jack-O-Lantern.

Child(tim)→ ∃xCarves(tim, x)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 102 / 120

Page 519: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween

1 Tim buys a pumpkin.

∃x(Buys(tim, x) ∧ Pumpkin(x))

2 Whoever buys a pumpkin eats it or carves a Jack-O-Lantern.

∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))

3 Children don’t eat pumpkins.

∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y))))

4 Conjecture: if Tim is a child, then he carves a Jack-O-Lantern.

Child(tim)→ ∃xCarves(tim, x)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 102 / 120

Page 520: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween

1 Tim buys a pumpkin.

∃x(Buys(tim, x) ∧ Pumpkin(x))

2 Whoever buys a pumpkin eats it or carves a Jack-O-Lantern.

∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))

3 Children don’t eat pumpkins.

∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y))))

4 Conjecture: if Tim is a child, then he carves a Jack-O-Lantern.

Child(tim)→ ∃xCarves(tim, x)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 102 / 120

Page 521: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween

1 Tim buys a pumpkin.

∃x(Buys(tim, x) ∧ Pumpkin(x))

2 Whoever buys a pumpkin eats it or carves a Jack-O-Lantern.

∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))

3 Children don’t eat pumpkins.

∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y))))

4 Conjecture: if Tim is a child, then he carves a Jack-O-Lantern.

Child(tim)→ ∃xCarves(tim, x)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 102 / 120

Page 522: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween

1 Tim buys a pumpkin.

∃x(Buys(tim, x) ∧ Pumpkin(x))

2 Whoever buys a pumpkin eats it or carves a Jack-O-Lantern.

∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))

3 Children don’t eat pumpkins.

∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y))))

4 Conjecture: if Tim is a child, then he carves a Jack-O-Lantern.

Child(tim)→ ∃xCarves(tim, x)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 102 / 120

Page 523: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))) ∧(∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y)))))

)

→(Child(tim)→ ∃xCarves(tim, x)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 524: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))) ∧(∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y)))))

)

→(Child(tim)→ ∃xCarves(tim, x)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 525: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬

¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))) ∧(∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y)))))

)

→(Child(tim)→ ∃xCarves(tim, x)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 526: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬

¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀x∀y((Buys(x, y) ∧ Pumpkin(y))→ (Eats(x, y) ∨ Carves(x, y)))) ∧(∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y)))))

)

→(Child(tim)→ ∃xCarves(tim, x)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 527: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬

¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((Buys(y, z) ∧ Pumpkin(z))→ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀x(Child(x)→ (∀y(Pumpkin(y)→ ¬Eats(x, y)))))

)

→(Child(tim)→ ∃xCarves(tim, x)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 528: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬

¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((Buys(y, z) ∧ Pumpkin(z))→ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(Child(u)→ (∀w(Pumpkin(w)→ ¬Eats(u,w)))))

)

→(Child(tim)→ ∃xCarves(tim, x)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 529: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬

¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((Buys(y, z) ∧ Pumpkin(z))→ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(Child(u)→ (∀w(Pumpkin(w)→ ¬Eats(u,w)))))

)

→(Child(tim)→ ∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 530: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ

4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬

¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((Buys(y, z) ∧ Pumpkin(z))→ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(Child(u)→ (∀w(Pumpkin(w)→ ¬Eats(u,w)))))

)

→(Child(tim)→ ∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 531: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ

4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬(¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((Buys(y, z) ∧ Pumpkin(z))→ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(Child(u)→ (∀w(Pumpkin(w)→ ¬Eats(u,w)))))) ∨(Child(tim)→ ∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 532: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ

4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬(¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z(¬(Buys(y, z) ∧ Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(Child(u)→ (∀w(Pumpkin(w)→ ¬Eats(u,w)))))) ∨(Child(tim)→ ∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 533: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ

4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬(¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z(¬(Buys(y, z) ∧ Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(Pumpkin(w)→ ¬Eats(u,w)))))) ∨(Child(tim)→ ∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 534: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ

4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬(¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z(¬(Buys(y, z) ∧ Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))) ∨(Child(tim)→ ∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 535: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ

4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬(¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z(¬(Buys(y, z) ∧ Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))) ∨(¬Child(tim) ∨ ∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 536: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬(¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z(¬(Buys(y, z) ∧ Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))) ∨(¬Child(tim) ∨ ∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 537: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z(¬(Buys(y, z) ∧ Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))

)

∧¬(¬Child(tim) ∨ ∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 538: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((¬Buys(y, z) ∨ ¬Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))

)

∧¬(¬Child(tim) ∨ ∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 539: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((¬Buys(y, z) ∨ ¬Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))

)

∧(¬¬Child(tim) ∧ ¬∃tCarves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 540: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((¬Buys(y, z) ∨ ¬Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))

)

∧(¬¬Child(tim) ∧ ∀t¬Carves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 541: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬¬((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((¬Buys(y, z) ∨ ¬Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))

)

∧(¬¬Child(tim) ∧ ∀t¬Carves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 542: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((¬Buys(y, z) ∨ ¬Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))

)

∧(¬¬Child(tim) ∧ ∀t¬Carves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 543: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((¬Buys(y, z) ∨ ¬Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))

)

∧(Child(tim) ∧ ∀t¬Carves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 544: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 1: preprocessing

1 negation

2 renaming of variables

3 replacement of ϕ→ ψ by ¬ϕ ∨ ψ4 De Morgan rules

5 double negation

6 prenex normal form . . .

¬¬

((∃x(Buys(tim, x) ∧ Pumpkin(x))) ∧(∀y∀z((¬Buys(y, z) ∨ ¬Pumpkin(z)) ∨ (Eats(y, z) ∨ Carves(y, z)))) ∧(∀u(¬Child(u) ∨ (∀w(¬Pumpkin(w) ∨ ¬Eats(u,w)))))

)

∧(Child(tim) ∧ ∀t¬Carves(tim, t)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 103 / 120

Page 545: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 2: Skolem normal form and clauses

1 prenex normal form

2 Skolemisation

3 drop universal quantifiers

4 CNF

∃x∀y∀z∀u∀w∀t(Buys(tim, x)∧Pumpkin(x) ∧(¬Buys(y, z) ∨ ¬Pumpkin(z) ∨ Eats(y, z) ∨ Carves(y, z)) ∧(¬Child(u) ∨ ¬Pumpkin(w) ∨ ¬Eats(u,w)) ∧Child(tim)∧¬Carves(tim, t))¬Carves(tim, t)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 104 / 120

Page 546: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 2: Skolem normal form and clauses

1 prenex normal form

2 Skolemisation

3 drop universal quantifiers

4 CNF

∃x∀y∀z∀u∀w∀t(Buys(tim, x)∧Pumpkin(x) ∧(¬Buys(y, z) ∨ ¬Pumpkin(z) ∨ Eats(y, z) ∨ Carves(y, z)) ∧(¬Child(u) ∨ ¬Pumpkin(w) ∨ ¬Eats(u,w)) ∧Child(tim)∧¬Carves(tim, t))¬Carves(tim, t)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 104 / 120

Page 547: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 2: Skolem normal form and clauses

1 prenex normal form

2 Skolemisation

3 drop universal quantifiers

4 CNF

∀y∀z∀u∀w∀t(Buys(tim, p)∧Pumpkin(p) ∧(¬Buys(y, z) ∨ ¬Pumpkin(z) ∨ Eats(y, z) ∨ Carves(y, z)) ∧(¬Child(u) ∨ ¬Pumpkin(w) ∨ ¬Eats(u,w)) ∧Child(tim)∧¬Carves(tim, t))¬Carves(tim, t)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 104 / 120

Page 548: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 2: Skolem normal form and clauses

1 prenex normal form

2 Skolemisation

3 drop universal quantifiers

4 CNF

∀y∀z∀u∀w∀t(Buys(tim, p)∧Pumpkin(p) ∧(¬Buys(y, z) ∨ ¬Pumpkin(z) ∨ Eats(y, z) ∨ Carves(y, z)) ∧(¬Child(u) ∨ ¬Pumpkin(w) ∨ ¬Eats(u,w)) ∧Child(tim)∧¬Carves(tim, t))¬Carves(tim, t)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 104 / 120

Page 549: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 2: Skolem normal form and clauses

1 prenex normal form

2 Skolemisation

3 drop universal quantifiers

4 CNF

∀y∀z∀u∀w∀t

Buys(tim, p)∧Pumpkin(p) ∧(¬Buys(y, z) ∨ ¬Pumpkin(z) ∨ Eats(y, z) ∨ Carves(y, z)) ∧(¬Child(u) ∨ ¬Pumpkin(w) ∨ ¬Eats(u,w)) ∧Child(tim)∧¬Carves(tim, t)

)

¬Carves(tim, t)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 104 / 120

Page 550: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 2: Skolem normal form and clauses

1 prenex normal form

2 Skolemisation

3 drop universal quantifiers

4 CNF

∀y∀z∀u∀w∀t

Buys(tim, p)∧Pumpkin(p) ∧(¬Buys(y, z) ∨ ¬Pumpkin(z) ∨ Eats(y, z) ∨ Carves(y, z)) ∧(¬Child(u) ∨ ¬Pumpkin(w) ∨ ¬Eats(u,w)) ∧Child(tim)∧¬Carves(tim, t)

)

¬Carves(tim, t)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 104 / 120

Page 551: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 2: Skolem normal form and clauses

1 prenex normal form

2 Skolemisation

3 drop universal quantifiers

4 CNF

∀y∀z∀u∀w∀t

Buys(tim, p) ∧Pumpkin(p) ∧(¬Buys(y, z) ∨ ¬Pumpkin(z) ∨ Eats(y, z) ∨ Carves(y, z)) ∧(¬Child(u) ∨ ¬Pumpkin(w) ∨ ¬Eats(u,w)) ∧Child(tim)∧¬Carves(tim, t)

)

¬Carves(tim, t)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 104 / 120

Page 552: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 2: Skolem normal form and clauses

1 prenex normal form

2 Skolemisation

3 drop universal quantifiers

4 CNF

∀y∀z∀u∀w∀t

Buys(tim, p) ∧Pumpkin(p) ∧(¬Buys(y, z) ∨ ¬Pumpkin(z) ∨ Eats(y, z) ∨ Carves(y, z)) ∧(¬Child(u) ∨ ¬Pumpkin(w) ∨ ¬Eats(u,w)) ∧Child(tim) ∧¬Carves(tim, t)

)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 104 / 120

Page 553: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 3: resolution

¬Child(u),¬Pumpkin(w),¬Eats(u,w) Child(tim)

Pumpkin(p)

¬Buys(y, z),¬Pumpkin(z),Eats(y, z),Carves(y, z)

Buys(tim, p)

¬Carves(tim, t)

¬Pumpkin(w),¬Eats(tim, w)

¬Eats(tim, p)

¬Buys(tim, p),¬Pumpkin(p),Carves(tim, p)

¬Buys(tim, p),Carves(tim, p)

Carves(tim, p)

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 105 / 120

Page 554: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 3: resolution

¬Child(u),¬Pumpkin(w),¬Eats(u,w) Child(tim)

Pumpkin(p)

¬Buys(y, z),¬Pumpkin(z),Eats(y, z),Carves(y, z)

Buys(tim, p)

¬Carves(tim, t)

¬Pumpkin(w),¬Eats(tim, w)

¬Eats(tim, p)

¬Buys(tim, p),¬Pumpkin(p),Carves(tim, p)

¬Buys(tim, p),Carves(tim, p)

Carves(tim, p)

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 105 / 120

Page 555: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 3: resolution

¬Child(u),¬Pumpkin(w),¬Eats(u,w) Child(tim)

Pumpkin(p)

¬Buys(y, z),¬Pumpkin(z),Eats(y, z),Carves(y, z)

Buys(tim, p)

¬Carves(tim, t)

¬Pumpkin(w),¬Eats(tim, w)

¬Eats(tim, p)

¬Buys(tim, p),¬Pumpkin(p),Carves(tim, p)

¬Buys(tim, p),Carves(tim, p)

Carves(tim, p)

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 105 / 120

Page 556: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 3: resolution

¬Child(u),¬Pumpkin(w),¬Eats(u,w) Child(tim)

Pumpkin(p)

¬Buys(y, z),¬Pumpkin(z),Eats(y, z),Carves(y, z)

Buys(tim, p)

¬Carves(tim, t)

¬Pumpkin(w),¬Eats(tim, w)

¬Eats(tim, p)

¬Buys(tim, p),¬Pumpkin(p),Carves(tim, p)

¬Buys(tim, p),Carves(tim, p)

Carves(tim, p)

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 105 / 120

Page 557: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 3: resolution

¬Child(u),¬Pumpkin(w),¬Eats(u,w) Child(tim)

Pumpkin(p)

¬Buys(y, z),¬Pumpkin(z),Eats(y, z),Carves(y, z)

Buys(tim, p)

¬Carves(tim, t)

¬Pumpkin(w),¬Eats(tim, w)

¬Eats(tim, p)

¬Buys(tim, p),¬Pumpkin(p),Carves(tim, p)

¬Buys(tim, p),Carves(tim, p)

Carves(tim, p)

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 105 / 120

Page 558: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 3: resolution

¬Child(u),¬Pumpkin(w),¬Eats(u,w) Child(tim)

Pumpkin(p)

¬Buys(y, z),¬Pumpkin(z),Eats(y, z),Carves(y, z)

Buys(tim, p)

¬Carves(tim, t)

¬Pumpkin(w),¬Eats(tim, w)

¬Eats(tim, p)

¬Buys(tim, p),¬Pumpkin(p),Carves(tim, p)

¬Buys(tim, p),Carves(tim, p)

Carves(tim, p)

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 105 / 120

Page 559: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Step 3: resolution

¬Child(u),¬Pumpkin(w),¬Eats(u,w) Child(tim)

Pumpkin(p)

¬Buys(y, z),¬Pumpkin(z),Eats(y, z),Carves(y, z)

Buys(tim, p)

¬Carves(tim, t)

¬Pumpkin(w),¬Eats(tim, w)

¬Eats(tim, p)

¬Buys(tim, p),¬Pumpkin(p),Carves(tim, p)

¬Buys(tim, p),Carves(tim, p)

Carves(tim, p)

2

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 105 / 120

Page 560: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

First-order resolution: exercise

Prove the following conjecture using resolution:

1 All dogs howl at night.

2 Anyone who has any cats will not have any mice.

3 Light sleepers do not have anything which howls at night.

4 John has a cat or a dog.

5 Conjecture: If John is a light sleeper, then John does not have anymice.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 106 / 120

Page 561: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Incompleteness of algorithm described so far

Example (Resolution of {P (w), P (x)} and {(¬P (y),¬P (z)})P (w), P (x) ¬P (y),¬P (z)

P (x),¬P (z)

[w/y]

¬P (u),¬P (z)

[t/y]

...

reason:

redundant literals

∀x∀y(P (x) ∨ P (y))is equivalent to ∀xP (x)

solution:

eliminate redundancy

perform unification within aclause

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 107 / 120

Page 562: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Incompleteness of algorithm described so far

Example (Resolution of {P (w), P (x)} and {(¬P (y),¬P (z)})P (w), P (x) ¬P (y),¬P (z)

P (x),¬P (z)

[w/y]

¬P (u),¬P (z)

[t/y]

...

reason:

redundant literals

∀x∀y(P (x) ∨ P (y))is equivalent to ∀xP (x)

solution:

eliminate redundancy

perform unification within aclause

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 107 / 120

Page 563: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Incompleteness of algorithm described so far

Example (Resolution of {P (w), P (x)} and {(¬P (y),¬P (z)})P (w), P (x) ¬P (y),¬P (z)

P (t),¬P (u)

[w/y]

¬P (u),¬P (z)

[t/y]

...

reason:

redundant literals

∀x∀y(P (x) ∨ P (y))is equivalent to ∀xP (x)

solution:

eliminate redundancy

perform unification within aclause

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 107 / 120

Page 564: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Incompleteness of algorithm described so far

Example (Resolution of {P (w), P (x)} and {(¬P (y),¬P (z)})P (w), P (x) ¬P (y),¬P (z)

P (t),¬P (u)

[w/y]

¬P (u),¬P (z)

[t/y]

...

reason:

redundant literals

∀x∀y(P (x) ∨ P (y))is equivalent to ∀xP (x)

solution:

eliminate redundancy

perform unification within aclause

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 107 / 120

Page 565: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Incompleteness of algorithm described so far

Example (Resolution of {P (w), P (x)} and {(¬P (y),¬P (z)})P (w), P (x) ¬P (y),¬P (z)

P (t),¬P (u)

[w/y]

¬P (r),¬P (s)

[t/y]

...

reason:

redundant literals

∀x∀y(P (x) ∨ P (y))is equivalent to ∀xP (x)

solution:

eliminate redundancy

perform unification within aclause

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 107 / 120

Page 566: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Incompleteness of algorithm described so far

Example (Resolution of {P (w), P (x)} and {(¬P (y),¬P (z)})P (w), P (x) ¬P (y),¬P (z)

P (t),¬P (u)

[w/y]

¬P (r),¬P (s)

[t/y]

...

reason:

redundant literals

∀x∀y(P (x) ∨ P (y))is equivalent to ∀xP (x)

solution:

eliminate redundancy

perform unification within aclause

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 107 / 120

Page 567: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Incompleteness of algorithm described so far

Example (Resolution of {P (w), P (x)} and {(¬P (y),¬P (z)})P (w), P (x) ¬P (y),¬P (z)

P (t),¬P (u)

[w/y]

¬P (r),¬P (s)

[t/y]

...

reason:

redundant literals

∀x∀y(P (x) ∨ P (y))is equivalent to ∀xP (x)

solution:

eliminate redundancy

perform unification within aclause

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 107 / 120

Page 568: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Incompleteness of algorithm described so far

Example (Resolution of {P (w), P (x)} and {(¬P (y),¬P (z)})P (w), P (x) ¬P (y),¬P (z)

P (t),¬P (u)

[w/y]

¬P (r),¬P (s)

[t/y]

...

reason:

redundant literals

∀x∀y(P (x) ∨ P (y))is equivalent to ∀xP (x)

solution:

eliminate redundancy

perform unification within aclause

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 107 / 120

Page 569: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Factors

Definition (Factor)

Let C = {L1, L2, L3, . . .}; σ be MGU of L1 and L2.Then σ(C) is a factor of C.

Example (factors)

{P (y)} is a factor of {P (x), P (y)}.{P (c)} is a factor of {P (x), P (c)}.{P (c), R(c, y)} is a factor of {P (x), P (c), R(x, y)}.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 108 / 120

Page 570: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Factors

Definition (Factor)

Let C = {L1, L2, L3, . . .}; σ be MGU of L1 and L2.Then σ(C) is a factor of C.

Example (factors)

{P (y)} is a factor of {P (x), P (y)}.

{P (c)} is a factor of {P (x), P (c)}.{P (c), R(c, y)} is a factor of {P (x), P (c), R(x, y)}.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 108 / 120

Page 571: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Factors

Definition (Factor)

Let C = {L1, L2, L3, . . .}; σ be MGU of L1 and L2.Then σ(C) is a factor of C.

Example (factors)

{P (y)} is a factor of {P (x), P (y)}.{P (c)} is a factor of {P (x), P (c)}.

{P (c), R(c, y)} is a factor of {P (x), P (c), R(x, y)}.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 108 / 120

Page 572: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Factors

Definition (Factor)

Let C = {L1, L2, L3, . . .}; σ be MGU of L1 and L2.Then σ(C) is a factor of C.

Example (factors)

{P (y)} is a factor of {P (x), P (y)}.{P (c)} is a factor of {P (x), P (c)}.{P (c), R(c, y)} is a factor of {P (x), P (c), R(x, y)}.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 108 / 120

Page 573: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Factorisation

New rule:

Derive C2 from C1 if C2 is factor of C1.

Example (factorisation)

P (w), P (x) ¬P (y),¬P (z)

P (x)

[w/x]

¬P (y)

[z/y]

2 [x/y]

Factorisation can be performed by introducing a new rule or by integratingit with resolution, i.e. checking the resolvent for factors.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 109 / 120

Page 574: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Factorisation

New rule:

Derive C2 from C1 if C2 is factor of C1.

Example (factorisation)

P (w), P (x) ¬P (y),¬P (z)

P (x)

[w/x]

¬P (y)

[z/y]

2 [x/y]

Factorisation can be performed by introducing a new rule or by integratingit with resolution, i.e. checking the resolvent for factors.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 109 / 120

Page 575: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Factorisation

New rule:

Derive C2 from C1 if C2 is factor of C1.

Example (factorisation)

P (w), P (x) ¬P (y),¬P (z)

P (x)

[w/x]

¬P (y)

[z/y]

2 [x/y]

Factorisation can be performed by introducing a new rule or by integratingit with resolution, i.e. checking the resolvent for factors.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 109 / 120

Page 576: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Factorisation

New rule:

Derive C2 from C1 if C2 is factor of C1.

Example (factorisation)

P (w), P (x) ¬P (y),¬P (z)

P (x)

[w/x]

¬P (y)

[z/y]

2 [x/y]

Factorisation can be performed by introducing a new rule or by integratingit with resolution, i.e. checking the resolvent for factors.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 109 / 120

Page 577: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Factorisation

New rule:

Derive C2 from C1 if C2 is factor of C1.

Example (factorisation)

P (w), P (x) ¬P (y),¬P (z)

P (x)

[w/x]

¬P (y)

[z/y]

2 [x/y]

Factorisation can be performed by introducing a new rule or by integratingit with resolution, i.e. checking the resolvent for factors.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 109 / 120

Page 578: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Factorisation

New rule:

Derive C2 from C1 if C2 is factor of C1.

Example (factorisation)

P (w), P (x) ¬P (y),¬P (z)

P (x)

[w/x]

¬P (y)

[z/y]

2 [x/y]

Factorisation can be performed by introducing a new rule or by integratingit with resolution, i.e. checking the resolvent for factors.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 109 / 120

Page 579: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Properties of the FOL resolution algorithm

Theorem (soundness of FOL resolution)

K(ϕ) `∗ 2 implies unsatisfiability of ϕ.

Theorem (refutation completeness of FOL resolution)

If ϕ is unsatisfiable, then K(ϕ) `∗ 2 holds.

Termination?

Does the algorithm terminate for every input?

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 110 / 120

Page 580: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Properties of the FOL resolution algorithm

Theorem (soundness of FOL resolution)

K(ϕ) `∗ 2 implies unsatisfiability of ϕ.

Theorem (refutation completeness of FOL resolution)

If ϕ is unsatisfiable, then K(ϕ) `∗ 2 holds.

Termination?

Does the algorithm terminate for every input?

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 110 / 120

Page 581: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Properties of the FOL resolution algorithm

Theorem (soundness of FOL resolution)

K(ϕ) `∗ 2 implies unsatisfiability of ϕ.

Theorem (refutation completeness of FOL resolution)

If ϕ is unsatisfiable, then K(ϕ) `∗ 2 holds.

Termination?

Does the algorithm terminate for every input?

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 110 / 120

Page 582: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Termination of FOL Resolution

Example (non-terminating set of clauses)

P (x),¬Q(f(x)) ¬P (f(y)), Q(f(y))

¬Q(f(f(y))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(x)))

[y/x]

¬Q(f(f(f(y)))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(f(x))))

[y/x]

...

Since the satisfiability problem for FOL formulas is undecidable,termination cannot be achieved.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 111 / 120

Page 583: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Termination of FOL Resolution

Example (non-terminating set of clauses)

P (x),¬Q(f(x)) ¬P (f(y)), Q(f(y))

¬Q(f(f(y))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(x)))

[y/x]

¬Q(f(f(f(y)))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(f(x))))

[y/x]

...

Since the satisfiability problem for FOL formulas is undecidable,termination cannot be achieved.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 111 / 120

Page 584: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Termination of FOL Resolution

Example (non-terminating set of clauses)

P (x),¬Q(f(x)) ¬P (f(y)), Q(f(y))

¬Q(f(f(y))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(x)))

[y/x]

¬Q(f(f(f(y)))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(f(x))))

[y/x]

...

Since the satisfiability problem for FOL formulas is undecidable,termination cannot be achieved.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 111 / 120

Page 585: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Termination of FOL Resolution

Example (non-terminating set of clauses)

P (x),¬Q(f(x)) ¬P (f(y)), Q(f(y))

¬Q(f(f(y))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(x)))

[y/x]

¬Q(f(f(f(y)))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(f(x))))

[y/x]

...

Since the satisfiability problem for FOL formulas is undecidable,termination cannot be achieved.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 111 / 120

Page 586: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Termination of FOL Resolution

Example (non-terminating set of clauses)

P (x),¬Q(f(x)) ¬P (f(y)), Q(f(y))

¬Q(f(f(y))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(x)))

[y/x]

¬Q(f(f(f(y)))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(f(x))))

[y/x]

...

Since the satisfiability problem for FOL formulas is undecidable,termination cannot be achieved.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 111 / 120

Page 587: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Termination of FOL Resolution

Example (non-terminating set of clauses)

P (x),¬Q(f(x)) ¬P (f(y)), Q(f(y))

¬Q(f(f(y))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(x)))

[y/x]

¬Q(f(f(f(y)))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(f(x))))

[y/x]

...

Since the satisfiability problem for FOL formulas is undecidable,termination cannot be achieved.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 111 / 120

Page 588: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Termination of FOL Resolution

Example (non-terminating set of clauses)

P (x),¬Q(f(x)) ¬P (f(y)), Q(f(y))

¬Q(f(f(y))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(x)))

[y/x]

¬Q(f(f(f(y)))), Q(f(y))

[x/f(y)]

P (x),¬Q(f(f(f(x))))

[y/x]

...

Since the satisfiability problem for FOL formulas is undecidable,termination cannot be achieved.

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 111 / 120

Page 589: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for FOL

basic algorithm remains unchanged

rulesclash triggers

no preprocessing necessary

. . . but NNF makes things easier

additional rules to deal with quantifiers

∀-rule∃-rule

definition of clash extended to first-order formulas

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 112 / 120

Page 590: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for FOL

basic algorithm remains unchanged

rules

clash triggers

no preprocessing necessary

. . . but NNF makes things easier

additional rules to deal with quantifiers

∀-rule∃-rule

definition of clash extended to first-order formulas

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 112 / 120

Page 591: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for FOL

basic algorithm remains unchanged

rulesclash triggers

no preprocessing necessary

. . . but NNF makes things easier

additional rules to deal with quantifiers

∀-rule∃-rule

definition of clash extended to first-order formulas

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 112 / 120

Page 592: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for FOL

basic algorithm remains unchanged

rulesclash triggers

no preprocessing necessary

. . . but NNF makes things easier

additional rules to deal with quantifiers

∀-rule∃-rule

definition of clash extended to first-order formulas

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 112 / 120

Page 593: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for FOL

basic algorithm remains unchanged

rulesclash triggers

no preprocessing necessary

. . . but NNF makes things easier

additional rules to deal with quantifiers

∀-rule∃-rule

definition of clash extended to first-order formulas

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 112 / 120

Page 594: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for FOL

basic algorithm remains unchanged

rulesclash triggers

no preprocessing necessary

. . . but NNF makes things easier

additional rules to deal with quantifiers

∀-rule∃-rule

definition of clash extended to first-order formulas

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 112 / 120

Page 595: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for FOL

basic algorithm remains unchanged

rulesclash triggers

no preprocessing necessary

. . . but NNF makes things easier

additional rules to deal with quantifiers

∀-rule

∃-rule

definition of clash extended to first-order formulas

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 112 / 120

Page 596: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for FOL

basic algorithm remains unchanged

rulesclash triggers

no preprocessing necessary

. . . but NNF makes things easier

additional rules to deal with quantifiers

∀-rule∃-rule

definition of clash extended to first-order formulas

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 112 / 120

Page 597: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm for FOL

basic algorithm remains unchanged

rulesclash triggers

no preprocessing necessary

. . . but NNF makes things easier

additional rules to deal with quantifiers

∀-rule∃-rule

definition of clash extended to first-order formulas

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 112 / 120

Page 598: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Additional tableau rules for FOL

∃ If ∃xϕ(x) ∈ Sand there is no ground term t with ϕ(t) ∈ Sthen S := S ∪ ϕ(c) for a new constant symbol c

use Skolemisation to eliminate ∃analogous for ¬∀xϕ(x): add ¬ϕ(c)only constants are needed (no function symbols of higher arity)

∀ quantifiers are processed previously by ∀-rule

∀ If ∀xϕ(x) ∈ Sand t is an arbitrary ground termthen S := S ∪ ϕ(t)

analogous for ¬∃xϕ(x): add ¬ϕ(t)applicable to infinite number of ground terms

always applicable!termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 113 / 120

Page 599: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Additional tableau rules for FOL

∃ If ∃xϕ(x) ∈ Sand there is no ground term t with ϕ(t) ∈ Sthen S := S ∪ ϕ(c) for a new constant symbol c

use Skolemisation to eliminate ∃

analogous for ¬∀xϕ(x): add ¬ϕ(c)only constants are needed (no function symbols of higher arity)

∀ quantifiers are processed previously by ∀-rule

∀ If ∀xϕ(x) ∈ Sand t is an arbitrary ground termthen S := S ∪ ϕ(t)

analogous for ¬∃xϕ(x): add ¬ϕ(t)applicable to infinite number of ground terms

always applicable!termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 113 / 120

Page 600: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Additional tableau rules for FOL

∃ If ∃xϕ(x) ∈ Sand there is no ground term t with ϕ(t) ∈ Sthen S := S ∪ ϕ(c) for a new constant symbol c

use Skolemisation to eliminate ∃analogous for ¬∀xϕ(x): add ¬ϕ(c)

only constants are needed (no function symbols of higher arity)

∀ quantifiers are processed previously by ∀-rule

∀ If ∀xϕ(x) ∈ Sand t is an arbitrary ground termthen S := S ∪ ϕ(t)

analogous for ¬∃xϕ(x): add ¬ϕ(t)applicable to infinite number of ground terms

always applicable!termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 113 / 120

Page 601: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Additional tableau rules for FOL

∃ If ∃xϕ(x) ∈ Sand there is no ground term t with ϕ(t) ∈ Sthen S := S ∪ ϕ(c) for a new constant symbol c

use Skolemisation to eliminate ∃analogous for ¬∀xϕ(x): add ¬ϕ(c)only constants are needed (no function symbols of higher arity)

∀ quantifiers are processed previously by ∀-rule

∀ If ∀xϕ(x) ∈ Sand t is an arbitrary ground termthen S := S ∪ ϕ(t)

analogous for ¬∃xϕ(x): add ¬ϕ(t)applicable to infinite number of ground terms

always applicable!termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 113 / 120

Page 602: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Additional tableau rules for FOL

∃ If ∃xϕ(x) ∈ Sand there is no ground term t with ϕ(t) ∈ Sthen S := S ∪ ϕ(c) for a new constant symbol c

use Skolemisation to eliminate ∃analogous for ¬∀xϕ(x): add ¬ϕ(c)only constants are needed (no function symbols of higher arity)

∀ quantifiers are processed previously by ∀-rule

∀ If ∀xϕ(x) ∈ Sand t is an arbitrary ground termthen S := S ∪ ϕ(t)

analogous for ¬∃xϕ(x): add ¬ϕ(t)applicable to infinite number of ground terms

always applicable!termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 113 / 120

Page 603: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Additional tableau rules for FOL

∃ If ∃xϕ(x) ∈ Sand there is no ground term t with ϕ(t) ∈ Sthen S := S ∪ ϕ(c) for a new constant symbol c

use Skolemisation to eliminate ∃analogous for ¬∀xϕ(x): add ¬ϕ(c)only constants are needed (no function symbols of higher arity)

∀ quantifiers are processed previously by ∀-rule

∀ If ∀xϕ(x) ∈ Sand t is an arbitrary ground termthen S := S ∪ ϕ(t)

analogous for ¬∃xϕ(x): add ¬ϕ(t)applicable to infinite number of ground terms

always applicable!termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 113 / 120

Page 604: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Additional tableau rules for FOL

∃ If ∃xϕ(x) ∈ Sand there is no ground term t with ϕ(t) ∈ Sthen S := S ∪ ϕ(c) for a new constant symbol c

use Skolemisation to eliminate ∃analogous for ¬∀xϕ(x): add ¬ϕ(c)only constants are needed (no function symbols of higher arity)

∀ quantifiers are processed previously by ∀-rule

∀ If ∀xϕ(x) ∈ Sand t is an arbitrary ground termthen S := S ∪ ϕ(t)

analogous for ¬∃xϕ(x): add ¬ϕ(t)

applicable to infinite number of ground terms

always applicable!termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 113 / 120

Page 605: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Additional tableau rules for FOL

∃ If ∃xϕ(x) ∈ Sand there is no ground term t with ϕ(t) ∈ Sthen S := S ∪ ϕ(c) for a new constant symbol c

use Skolemisation to eliminate ∃analogous for ¬∀xϕ(x): add ¬ϕ(c)only constants are needed (no function symbols of higher arity)

∀ quantifiers are processed previously by ∀-rule

∀ If ∀xϕ(x) ∈ Sand t is an arbitrary ground termthen S := S ∪ ϕ(t)

analogous for ¬∃xϕ(x): add ¬ϕ(t)applicable to infinite number of ground terms

always applicable!termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 113 / 120

Page 606: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Additional tableau rules for FOL

∃ If ∃xϕ(x) ∈ Sand there is no ground term t with ϕ(t) ∈ Sthen S := S ∪ ϕ(c) for a new constant symbol c

use Skolemisation to eliminate ∃analogous for ¬∀xϕ(x): add ¬ϕ(c)only constants are needed (no function symbols of higher arity)

∀ quantifiers are processed previously by ∀-rule

∀ If ∀xϕ(x) ∈ Sand t is an arbitrary ground termthen S := S ∪ ϕ(t)

analogous for ¬∃xϕ(x): add ¬ϕ(t)applicable to infinite number of ground terms

always applicable!

termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 113 / 120

Page 607: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Additional tableau rules for FOL

∃ If ∃xϕ(x) ∈ Sand there is no ground term t with ϕ(t) ∈ Sthen S := S ∪ ϕ(c) for a new constant symbol c

use Skolemisation to eliminate ∃analogous for ¬∀xϕ(x): add ¬ϕ(c)only constants are needed (no function symbols of higher arity)

∀ quantifiers are processed previously by ∀-rule

∀ If ∀xϕ(x) ∈ Sand t is an arbitrary ground termthen S := S ∪ ϕ(t)

analogous for ¬∃xϕ(x): add ¬ϕ(t)applicable to infinite number of ground terms

always applicable!termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 113 / 120

Page 608: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau

ϕ = ∃x(Buys(tim, x) ∧ Pumpkin(x)) ∧∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y)) ∧∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y)))) ∧¬(Child(tim) → ∃xCarves(tim, x))

1 ϕ

2 ∃x(Buys(tim, x) ∧ Pumpkin(x)) 1: ∧3 ∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y))4 ∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y))))5 ¬(Child(tim) → ∃xCarves(tim, x))

6 Child(tim) 5: ¬ →7 ¬∃xCarves(tim, x))

8 Buys(tim, p) ∧ Pumpkin(p) 2: ∃(x/p)

9 Buys(tim, p) 8: ∧10 Pumpkin(p)

11 Buys(tim, p) ∧ Pumpkin(p) → Eats(tim, p) ∨ Carves(tim, p) 3: ∀(x/tim, y/p)

12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p)) 4: ∀(x/tim, y/p)

13 ¬Carves(tim, p) 7: ¬∃(x/p)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 114 / 120

Page 609: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau

ϕ = ∃x(Buys(tim, x) ∧ Pumpkin(x)) ∧∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y)) ∧∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y)))) ∧¬(Child(tim) → ∃xCarves(tim, x))

1 ϕ

2 ∃x(Buys(tim, x) ∧ Pumpkin(x)) 1: ∧3 ∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y))4 ∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y))))5 ¬(Child(tim) → ∃xCarves(tim, x))

6 Child(tim) 5: ¬ →7 ¬∃xCarves(tim, x))

8 Buys(tim, p) ∧ Pumpkin(p) 2: ∃(x/p)

9 Buys(tim, p) 8: ∧10 Pumpkin(p)

11 Buys(tim, p) ∧ Pumpkin(p) → Eats(tim, p) ∨ Carves(tim, p) 3: ∀(x/tim, y/p)

12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p)) 4: ∀(x/tim, y/p)

13 ¬Carves(tim, p) 7: ¬∃(x/p)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 114 / 120

Page 610: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau

ϕ = ∃x(Buys(tim, x) ∧ Pumpkin(x)) ∧∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y)) ∧∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y)))) ∧¬(Child(tim) → ∃xCarves(tim, x))

1 ϕ

2 ∃x(Buys(tim, x) ∧ Pumpkin(x)) 1: ∧3 ∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y))4 ∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y))))5 ¬(Child(tim) → ∃xCarves(tim, x))

6 Child(tim) 5: ¬ →7 ¬∃xCarves(tim, x))

8 Buys(tim, p) ∧ Pumpkin(p) 2: ∃(x/p)

9 Buys(tim, p) 8: ∧10 Pumpkin(p)

11 Buys(tim, p) ∧ Pumpkin(p) → Eats(tim, p) ∨ Carves(tim, p) 3: ∀(x/tim, y/p)

12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p)) 4: ∀(x/tim, y/p)

13 ¬Carves(tim, p) 7: ¬∃(x/p)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 114 / 120

Page 611: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau

ϕ = ∃x(Buys(tim, x) ∧ Pumpkin(x)) ∧∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y)) ∧∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y)))) ∧¬(Child(tim) → ∃xCarves(tim, x))

1 ϕ

2 ∃x(Buys(tim, x) ∧ Pumpkin(x)) 1: ∧3 ∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y))4 ∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y))))5 ¬(Child(tim) → ∃xCarves(tim, x))

6 Child(tim) 5: ¬ →7 ¬∃xCarves(tim, x))

8 Buys(tim, p) ∧ Pumpkin(p) 2: ∃(x/p)

9 Buys(tim, p) 8: ∧10 Pumpkin(p)

11 Buys(tim, p) ∧ Pumpkin(p) → Eats(tim, p) ∨ Carves(tim, p) 3: ∀(x/tim, y/p)

12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p)) 4: ∀(x/tim, y/p)

13 ¬Carves(tim, p) 7: ¬∃(x/p)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 114 / 120

Page 612: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau

ϕ = ∃x(Buys(tim, x) ∧ Pumpkin(x)) ∧∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y)) ∧∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y)))) ∧¬(Child(tim) → ∃xCarves(tim, x))

1 ϕ

2 ∃x(Buys(tim, x) ∧ Pumpkin(x)) 1: ∧3 ∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y))4 ∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y))))5 ¬(Child(tim) → ∃xCarves(tim, x))

6 Child(tim) 5: ¬ →7 ¬∃xCarves(tim, x))

8 Buys(tim, p) ∧ Pumpkin(p) 2: ∃(x/p)

9 Buys(tim, p) 8: ∧10 Pumpkin(p)

11 Buys(tim, p) ∧ Pumpkin(p) → Eats(tim, p) ∨ Carves(tim, p) 3: ∀(x/tim, y/p)

12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p)) 4: ∀(x/tim, y/p)

13 ¬Carves(tim, p) 7: ¬∃(x/p)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 114 / 120

Page 613: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau

ϕ = ∃x(Buys(tim, x) ∧ Pumpkin(x)) ∧∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y)) ∧∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y)))) ∧¬(Child(tim) → ∃xCarves(tim, x))

1 ϕ

2 ∃x(Buys(tim, x) ∧ Pumpkin(x)) 1: ∧3 ∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y))4 ∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y))))5 ¬(Child(tim) → ∃xCarves(tim, x))

6 Child(tim) 5: ¬ →7 ¬∃xCarves(tim, x))

8 Buys(tim, p) ∧ Pumpkin(p) 2: ∃(x/p)

9 Buys(tim, p) 8: ∧10 Pumpkin(p)

11 Buys(tim, p) ∧ Pumpkin(p) → Eats(tim, p) ∨ Carves(tim, p) 3: ∀(x/tim, y/p)

12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p)) 4: ∀(x/tim, y/p)

13 ¬Carves(tim, p) 7: ¬∃(x/p)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 114 / 120

Page 614: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau

ϕ = ∃x(Buys(tim, x) ∧ Pumpkin(x)) ∧∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y)) ∧∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y)))) ∧¬(Child(tim) → ∃xCarves(tim, x))

1 ϕ

2 ∃x(Buys(tim, x) ∧ Pumpkin(x)) 1: ∧3 ∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y))4 ∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y))))5 ¬(Child(tim) → ∃xCarves(tim, x))

6 Child(tim) 5: ¬ →7 ¬∃xCarves(tim, x))

8 Buys(tim, p) ∧ Pumpkin(p) 2: ∃(x/p)

9 Buys(tim, p) 8: ∧10 Pumpkin(p)

11 Buys(tim, p) ∧ Pumpkin(p) → Eats(tim, p) ∨ Carves(tim, p) 3: ∀(x/tim, y/p)

12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p)) 4: ∀(x/tim, y/p)

13 ¬Carves(tim, p) 7: ¬∃(x/p)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 114 / 120

Page 615: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau

ϕ = ∃x(Buys(tim, x) ∧ Pumpkin(x)) ∧∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y)) ∧∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y)))) ∧¬(Child(tim) → ∃xCarves(tim, x))

1 ϕ

2 ∃x(Buys(tim, x) ∧ Pumpkin(x)) 1: ∧3 ∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y))4 ∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y))))5 ¬(Child(tim) → ∃xCarves(tim, x))

6 Child(tim) 5: ¬ →7 ¬∃xCarves(tim, x))

8 Buys(tim, p) ∧ Pumpkin(p) 2: ∃(x/p)

9 Buys(tim, p) 8: ∧10 Pumpkin(p)

11 Buys(tim, p) ∧ Pumpkin(p) → Eats(tim, p) ∨ Carves(tim, p) 3: ∀(x/tim, y/p)

12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p)) 4: ∀(x/tim, y/p)

13 ¬Carves(tim, p) 7: ¬∃(x/p)

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 114 / 120

Page 616: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau

ϕ = ∃x(Buys(tim, x) ∧ Pumpkin(x)) ∧∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y)) ∧∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y)))) ∧¬(Child(tim) → ∃xCarves(tim, x))

1 ϕ

2 ∃x(Buys(tim, x) ∧ Pumpkin(x)) 1: ∧3 ∀x∀y(Buys(x, y) ∧ Pumpkin(y) → Eats(x, y) ∨ Carves(x, y))4 ∀x(Child(x) → (∀y(Pumpkin(y) → ¬Eats(x, y))))5 ¬(Child(tim) → ∃xCarves(tim, x))

6 Child(tim) 5: ¬ →7 ¬∃xCarves(tim, x))

8 Buys(tim, p) ∧ Pumpkin(p) 2: ∃(x/p)

9 Buys(tim, p) 8: ∧10 Pumpkin(p)

11 Buys(tim, p) ∧ Pumpkin(p) → Eats(tim, p) ∨ Carves(tim, p) 3: ∀(x/tim, y/p)

12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p)) 4: ∀(x/tim, y/p)

13 ¬Carves(tim, p) 7: ¬∃(x/p)Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 114 / 120

Page 617: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)

14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 618: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →

15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 619: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →

16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 620: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →

17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 621: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧

18 Eats(tim, p) Carves(tim, p) 16: ∨ 6 10 9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 622: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 623: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6

10 9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 624: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10

9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 625: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9

10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 626: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9 10

15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 627: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9 10 15

13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 628: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 629: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 630: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: Halloween tableau (cont’)

6 Child(tim)9 Buys(tim, p)10 Pumpkin(p)11 (Buys(tim, p) ∧ Pumpkin(p)) → (Eats(tim, p) ∨ Carves(tim, p))12 Child(tim) → (Pumpkin(p) → ¬Eats(tim, p))13 ¬Carves(tim, p)14 ¬Child(tim) Pumpkin(p) → ¬Eats(tim, p) 12: →15 ¬Pumpkin(p) ¬Eats(tim, p) 14: →16 ¬(Buys(tim, p) ∧ Pumpkin(p)) Eats(tim, p) ∨ Carves(tim, p) 11: →17 ¬Buys(tim, p) ¬Pumpkin(p) 16: ¬∧18 Eats(tim, p) Carves(tim, p) 16: ∨

6 10 9 10 15 13

all columns contain a clash

ϕ is unsatisfiable

premises imply conjecture

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 115 / 120

Page 631: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Exercise: First-order tableau

Prove that John does not have any mice using a tableau.

ϕ = ∀x(D(x)→ HAN(x)) ∧∀x(∃y(H(x, y) ∧ C(y))→ ¬∃z(H(x, z) ∧M(z))) ∧∀x(L(x)→ ¬∃y(H(x, y) ∧HAN(y))) ∧∃x(H(j, x) ∧ (C(x) ∨D(x))) ∧¬(L(j)→ ¬∃x(H(j, x) ∧M(x)))

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 116 / 120

Page 632: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Problems with naive tableau algorithm

efficiency depends highly on choice of terms for ∀-rule

we intuitively used the right constants in our examplesalgorithm needs to try all possible combinationsassume a vocabulary with 4 constant symbols a formula with 5universally quantified variables: 45 = 1024 possible applicationsas soon as function symbols are available, the number is infinite

heuristics: start with ground terms that appear in other atoms

modify algorithm itself: tableau algorithm with unification

delay substitutionuse unification to find substition that leads to a clash

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 117 / 120

Page 633: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Problems with naive tableau algorithm

efficiency depends highly on choice of terms for ∀-rule

we intuitively used the right constants in our examples

algorithm needs to try all possible combinationsassume a vocabulary with 4 constant symbols a formula with 5universally quantified variables: 45 = 1024 possible applicationsas soon as function symbols are available, the number is infinite

heuristics: start with ground terms that appear in other atoms

modify algorithm itself: tableau algorithm with unification

delay substitutionuse unification to find substition that leads to a clash

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 117 / 120

Page 634: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Problems with naive tableau algorithm

efficiency depends highly on choice of terms for ∀-rule

we intuitively used the right constants in our examplesalgorithm needs to try all possible combinations

assume a vocabulary with 4 constant symbols a formula with 5universally quantified variables: 45 = 1024 possible applicationsas soon as function symbols are available, the number is infinite

heuristics: start with ground terms that appear in other atoms

modify algorithm itself: tableau algorithm with unification

delay substitutionuse unification to find substition that leads to a clash

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 117 / 120

Page 635: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Problems with naive tableau algorithm

efficiency depends highly on choice of terms for ∀-rule

we intuitively used the right constants in our examplesalgorithm needs to try all possible combinationsassume a vocabulary with 4 constant symbols a formula with 5universally quantified variables: 45 = 1024 possible applications

as soon as function symbols are available, the number is infinite

heuristics: start with ground terms that appear in other atoms

modify algorithm itself: tableau algorithm with unification

delay substitutionuse unification to find substition that leads to a clash

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 117 / 120

Page 636: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Problems with naive tableau algorithm

efficiency depends highly on choice of terms for ∀-rule

we intuitively used the right constants in our examplesalgorithm needs to try all possible combinationsassume a vocabulary with 4 constant symbols a formula with 5universally quantified variables: 45 = 1024 possible applicationsas soon as function symbols are available, the number is infinite

heuristics: start with ground terms that appear in other atoms

modify algorithm itself: tableau algorithm with unification

delay substitutionuse unification to find substition that leads to a clash

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 117 / 120

Page 637: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Problems with naive tableau algorithm

efficiency depends highly on choice of terms for ∀-rule

we intuitively used the right constants in our examplesalgorithm needs to try all possible combinationsassume a vocabulary with 4 constant symbols a formula with 5universally quantified variables: 45 = 1024 possible applicationsas soon as function symbols are available, the number is infinite

heuristics: start with ground terms that appear in other atoms

modify algorithm itself: tableau algorithm with unification

delay substitutionuse unification to find substition that leads to a clash

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 117 / 120

Page 638: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Problems with naive tableau algorithm

efficiency depends highly on choice of terms for ∀-rule

we intuitively used the right constants in our examplesalgorithm needs to try all possible combinationsassume a vocabulary with 4 constant symbols a formula with 5universally quantified variables: 45 = 1024 possible applicationsas soon as function symbols are available, the number is infinite

heuristics: start with ground terms that appear in other atoms

modify algorithm itself: tableau algorithm with unification

delay substitutionuse unification to find substition that leads to a clash

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 117 / 120

Page 639: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Problems with naive tableau algorithm

efficiency depends highly on choice of terms for ∀-rule

we intuitively used the right constants in our examplesalgorithm needs to try all possible combinationsassume a vocabulary with 4 constant symbols a formula with 5universally quantified variables: 45 = 1024 possible applicationsas soon as function symbols are available, the number is infinite

heuristics: start with ground terms that appear in other atoms

modify algorithm itself: tableau algorithm with unification

delay substitution

use unification to find substition that leads to a clash

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 117 / 120

Page 640: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Problems with naive tableau algorithm

efficiency depends highly on choice of terms for ∀-rule

we intuitively used the right constants in our examplesalgorithm needs to try all possible combinationsassume a vocabulary with 4 constant symbols a formula with 5universally quantified variables: 45 = 1024 possible applicationsas soon as function symbols are available, the number is infinite

heuristics: start with ground terms that appear in other atoms

modify algorithm itself: tableau algorithm with unification

delay substitutionuse unification to find substition that leads to a clash

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 117 / 120

Page 641: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm with unification

∀u If ∀xϕ(x) ∈ Sthen S := S ∪ ϕ(y) for a new variable symbol y

y is a free variable!always applicable

∃u If ∃xϕ(x) ∈ Sand there is no term t with ϕ(t) ∈ Sand ϕ contains the free variables y1, . . . , ynthen S := S ∪ ϕ(f(y1, . . . , yn)) for a new n-ary function symbol f

complex Skolem functions are needed

S If there are formulas ϕ and ψ in one branch such thatthere exists a unifier σ for the free variables with σ(ϕ) = ¬σ(ψ)then apply σ to the entire tableau

not only the current branch!we have to act as if we had used σ from the startfree variables have to be replaced everywhere

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 118 / 120

Page 642: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm with unification

∀u If ∀xϕ(x) ∈ Sthen S := S ∪ ϕ(y) for a new variable symbol y

y is a free variable!

always applicable

∃u If ∃xϕ(x) ∈ Sand there is no term t with ϕ(t) ∈ Sand ϕ contains the free variables y1, . . . , ynthen S := S ∪ ϕ(f(y1, . . . , yn)) for a new n-ary function symbol f

complex Skolem functions are needed

S If there are formulas ϕ and ψ in one branch such thatthere exists a unifier σ for the free variables with σ(ϕ) = ¬σ(ψ)then apply σ to the entire tableau

not only the current branch!we have to act as if we had used σ from the startfree variables have to be replaced everywhere

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 118 / 120

Page 643: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm with unification

∀u If ∀xϕ(x) ∈ Sthen S := S ∪ ϕ(y) for a new variable symbol y

y is a free variable!always applicable

∃u If ∃xϕ(x) ∈ Sand there is no term t with ϕ(t) ∈ Sand ϕ contains the free variables y1, . . . , ynthen S := S ∪ ϕ(f(y1, . . . , yn)) for a new n-ary function symbol f

complex Skolem functions are needed

S If there are formulas ϕ and ψ in one branch such thatthere exists a unifier σ for the free variables with σ(ϕ) = ¬σ(ψ)then apply σ to the entire tableau

not only the current branch!we have to act as if we had used σ from the startfree variables have to be replaced everywhere

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 118 / 120

Page 644: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm with unification

∀u If ∀xϕ(x) ∈ Sthen S := S ∪ ϕ(y) for a new variable symbol y

y is a free variable!always applicable

∃u If ∃xϕ(x) ∈ Sand there is no term t with ϕ(t) ∈ Sand ϕ contains the free variables y1, . . . , ynthen S := S ∪ ϕ(f(y1, . . . , yn)) for a new n-ary function symbol f

complex Skolem functions are needed

S If there are formulas ϕ and ψ in one branch such thatthere exists a unifier σ for the free variables with σ(ϕ) = ¬σ(ψ)then apply σ to the entire tableau

not only the current branch!we have to act as if we had used σ from the startfree variables have to be replaced everywhere

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 118 / 120

Page 645: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm with unification

∀u If ∀xϕ(x) ∈ Sthen S := S ∪ ϕ(y) for a new variable symbol y

y is a free variable!always applicable

∃u If ∃xϕ(x) ∈ Sand there is no term t with ϕ(t) ∈ Sand ϕ contains the free variables y1, . . . , ynthen S := S ∪ ϕ(f(y1, . . . , yn)) for a new n-ary function symbol f

complex Skolem functions are needed

S If there are formulas ϕ and ψ in one branch such thatthere exists a unifier σ for the free variables with σ(ϕ) = ¬σ(ψ)then apply σ to the entire tableau

not only the current branch!we have to act as if we had used σ from the startfree variables have to be replaced everywhere

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 118 / 120

Page 646: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm with unification

∀u If ∀xϕ(x) ∈ Sthen S := S ∪ ϕ(y) for a new variable symbol y

y is a free variable!always applicable

∃u If ∃xϕ(x) ∈ Sand there is no term t with ϕ(t) ∈ Sand ϕ contains the free variables y1, . . . , ynthen S := S ∪ ϕ(f(y1, . . . , yn)) for a new n-ary function symbol f

complex Skolem functions are needed

S If there are formulas ϕ and ψ in one branch such thatthere exists a unifier σ for the free variables with σ(ϕ) = ¬σ(ψ)then apply σ to the entire tableau

not only the current branch!we have to act as if we had used σ from the startfree variables have to be replaced everywhere

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 118 / 120

Page 647: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm with unification

∀u If ∀xϕ(x) ∈ Sthen S := S ∪ ϕ(y) for a new variable symbol y

y is a free variable!always applicable

∃u If ∃xϕ(x) ∈ Sand there is no term t with ϕ(t) ∈ Sand ϕ contains the free variables y1, . . . , ynthen S := S ∪ ϕ(f(y1, . . . , yn)) for a new n-ary function symbol f

complex Skolem functions are needed

S If there are formulas ϕ and ψ in one branch such thatthere exists a unifier σ for the free variables with σ(ϕ) = ¬σ(ψ)then apply σ to the entire tableau

not only the current branch!

we have to act as if we had used σ from the startfree variables have to be replaced everywhere

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 118 / 120

Page 648: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm with unification

∀u If ∀xϕ(x) ∈ Sthen S := S ∪ ϕ(y) for a new variable symbol y

y is a free variable!always applicable

∃u If ∃xϕ(x) ∈ Sand there is no term t with ϕ(t) ∈ Sand ϕ contains the free variables y1, . . . , ynthen S := S ∪ ϕ(f(y1, . . . , yn)) for a new n-ary function symbol f

complex Skolem functions are needed

S If there are formulas ϕ and ψ in one branch such thatthere exists a unifier σ for the free variables with σ(ϕ) = ¬σ(ψ)then apply σ to the entire tableau

not only the current branch!we have to act as if we had used σ from the start

free variables have to be replaced everywhere

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 118 / 120

Page 649: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Tableau algorithm with unification

∀u If ∀xϕ(x) ∈ Sthen S := S ∪ ϕ(y) for a new variable symbol y

y is a free variable!always applicable

∃u If ∃xϕ(x) ∈ Sand there is no term t with ϕ(t) ∈ Sand ϕ contains the free variables y1, . . . , ynthen S := S ∪ ϕ(f(y1, . . . , yn)) for a new n-ary function symbol f

complex Skolem functions are needed

S If there are formulas ϕ and ψ in one branch such thatthere exists a unifier σ for the free variables with σ(ϕ) = ¬σ(ψ)then apply σ to the entire tableau

not only the current branch!we have to act as if we had used σ from the startfree variables have to be replaced everywhere

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 118 / 120

Page 650: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(r, y) ∨ f(r, y)) 2: ∀u(x/r)

5 m(r, p(r)) ∨ f(r, p(r)) 4: ∃u(y/p(r))

6 ¬m(c, s) ∧ ¬f(c, s) 3: ∀u(z/s)

7 ¬m(c, s) 6: ∧8 ¬f(c, s)

9 m(r, p(r)) f(r, p(r)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 651: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(r, y) ∨ f(r, y)) 2: ∀u(x/r)

5 m(r, p(r)) ∨ f(r, p(r)) 4: ∃u(y/p(r))

6 ¬m(c, s) ∧ ¬f(c, s) 3: ∀u(z/s)

7 ¬m(c, s) 6: ∧8 ¬f(c, s)

9 m(r, p(r)) f(r, p(r)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 652: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(r, y) ∨ f(r, y)) 2: ∀u(x/r)

5 m(r, p(r)) ∨ f(r, p(r)) 4: ∃u(y/p(r))

6 ¬m(c, s) ∧ ¬f(c, s) 3: ∀u(z/s)

7 ¬m(c, s) 6: ∧8 ¬f(c, s)

9 m(r, p(r)) f(r, p(r)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 653: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(r, y) ∨ f(r, y)) 2: ∀u(x/r)

5 m(r, p(r)) ∨ f(r, p(r)) 4: ∃u(y/p(r))

6 ¬m(c, s) ∧ ¬f(c, s) 3: ∀u(z/s)

7 ¬m(c, s) 6: ∧8 ¬f(c, s)

9 m(r, p(r)) f(r, p(r)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 654: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(r, y) ∨ f(r, y)) 2: ∀u(x/r)

5 m(r, p(r)) ∨ f(r, p(r)) 4: ∃u(y/p(r))

6 ¬m(c, s) ∧ ¬f(c, s) 3: ∀u(z/s)

7 ¬m(c, s) 6: ∧8 ¬f(c, s)

9 m(r, p(r)) f(r, p(r)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 655: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(r, y) ∨ f(r, y)) 2: ∀u(x/r)

5 m(r, p(r)) ∨ f(r, p(r)) 4: ∃u(y/p(r))

6 ¬m(c, s) ∧ ¬f(c, s) 3: ∀u(z/s)

7 ¬m(c, s) 6: ∧8 ¬f(c, s)

9 m(r, p(r)) f(r, p(r)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 656: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(r, y) ∨ f(r, y)) 2: ∀u(x/r)

5 m(r, p(r)) ∨ f(r, p(r)) 4: ∃u(y/p(r))

6 ¬m(c, s) ∧ ¬f(c, s) 3: ∀u(z/s)

7 ¬m(c, s) 6: ∧8 ¬f(c, s)

9 m(r, p(r)) f(r, p(r)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 657: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(r, y) ∨ f(r, y)) 2: ∀u(x/r)

5 m(r, p(r)) ∨ f(r, p(r)) 4: ∃u(y/p(r))

6 ¬m(c, s) ∧ ¬f(c, s) 3: ∀u(z/s)

7 ¬m(c, s) 6: ∧8 ¬f(c, s)

9 m(r, p(r)) f(r, p(r)) 5: ∨

S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 658: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(r, y) ∨ f(r, y)) 2: ∀u(x/r)

5 m(r, p(r)) ∨ f(r, p(r)) 4: ∃u(y/p(r))

6 ¬m(c, s) ∧ ¬f(c, s) 3: ∀u(z/s)

7 ¬m(c, s) 6: ∧8 ¬f(c, s)

9 m(r, p(r)) f(r, p(r)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 659: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(c, y) ∨ f(c, y)) 2: ∀u(x/r)

5 m(c, p(c)) ∨ f(c, p(c)) 4: ∃u(y/p(r))

6 ¬m(c, s) ∧ ¬f(c, s) 3: ∀u(z/s)

7 ¬m(c, s) 6: ∧8 ¬f(c, s)

9 m(c, p(c)) f(c, p(c)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 660: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(c, y) ∨ f(c, y)) 2: ∀u(x/r)

5 m(c, p(c)) ∨ f(c, p(c)) 4: ∃u(y/p(r))

6 ¬m(c, p(c)) ∧ ¬f(c, p(c)) 3: ∀u(z/s)

7 ¬m(c, p(c)) 6: ∧8 ¬f(c, p(c))

9 m(c, p(c)) f(c, p(c)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 661: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(c, y) ∨ f(c, y)) 2: ∀u(x/r)

5 m(c, p(c)) ∨ f(c, p(c)) 4: ∃u(y/p(r))

6 ¬m(c, p(c)) ∧ ¬f(c, p(c)) 3: ∀u(z/s)

7 ¬m(c, p(c)) 6: ∧8 ¬f(c, p(c))

9 m(c, p(c)) f(c, p(c)) 5: ∨S ([r/c], [s/p(c)])

7

8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 662: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Example: tableau with unification

ϕ = ∀x∃y(m(x, y) ∨ f(x, y)) ∧ ∀z(¬m(c, z) ∧ ¬f(c, z))

1 ϕ

2 MM ∀x∃y(m(x, y) ∨ f(x, y)) MM 1: ∧3 ∀z(¬m(c, z) ∧ ¬f(c, z))

4 ∃y(m(c, y) ∨ f(c, y)) 2: ∀u(x/r)

5 m(c, p(c)) ∨ f(c, p(c)) 4: ∃u(y/p(r))

6 ¬m(c, p(c)) ∧ ¬f(c, p(c)) 3: ∀u(z/s)

7 ¬m(c, p(c)) 6: ∧8 ¬f(c, p(c))

9 m(c, p(c)) f(c, p(c)) 5: ∨S ([r/c], [s/p(c)])

7 8

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 119 / 120

Page 663: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional and first-order logic: summary

PL: ∧,∨,¬,→,↔limited expressivity

resolution and TA terminate

best algorithm depends on context

FOL: also ∀, ∃, variables, functions, relations

higher expressivity

both resolution and TA can be adapted

reasoning more complex

Skolemisationfactorsunification

termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 120 / 120

Page 664: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional and first-order logic: summary

PL: ∧,∨,¬,→,↔limited expressivity

resolution and TA terminate

best algorithm depends on context

FOL: also ∀, ∃, variables, functions, relations

higher expressivity

both resolution and TA can be adapted

reasoning more complex

Skolemisationfactorsunification

termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 120 / 120

Page 665: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional and first-order logic: summary

PL: ∧,∨,¬,→,↔limited expressivity

resolution and TA terminate

best algorithm depends on context

FOL: also ∀, ∃, variables, functions, relations

higher expressivity

both resolution and TA can be adapted

reasoning more complex

Skolemisationfactorsunification

termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 120 / 120

Page 666: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional and first-order logic: summary

PL: ∧,∨,¬,→,↔limited expressivity

resolution and TA terminate

best algorithm depends on context

FOL: also ∀, ∃, variables, functions, relations

higher expressivity

both resolution and TA can be adapted

reasoning more complex

Skolemisationfactorsunification

termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 120 / 120

Page 667: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional and first-order logic: summary

PL: ∧,∨,¬,→,↔limited expressivity

resolution and TA terminate

best algorithm depends on context

FOL: also ∀, ∃, variables, functions, relations

higher expressivity

both resolution and TA can be adapted

reasoning more complex

Skolemisationfactorsunification

termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 120 / 120

Page 668: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional and first-order logic: summary

PL: ∧,∨,¬,→,↔limited expressivity

resolution and TA terminate

best algorithm depends on context

FOL: also ∀, ∃, variables, functions, relations

higher expressivity

both resolution and TA can be adapted

reasoning more complex

Skolemisationfactorsunification

termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 120 / 120

Page 669: Logic - DHBW Stuttgarthladik/Logik/2015/logic - overlays.pdf · Logic, logic, logic... Why do computer scientists need logic? Mr Spock says: Logic is the beginning of wisdom, not

Propositional and first-order logic: summary

PL: ∧,∨,¬,→,↔limited expressivity

resolution and TA terminate

best algorithm depends on context

FOL: also ∀, ∃, variables, functions, relations

higher expressivity

both resolution and TA can be adapted

reasoning more complex

Skolemisationfactorsunification

termination cannot be ensured

Jan Hladik (DHBW Stuttgart) Logic Wintersemester 2015/16 120 / 120