110
Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1 / 40

Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Propositional LogicComputer exercises

Mario Alviano

University of Calabria, Italy

A.Y. 2017/2018

1 / 40

Page 2: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Outline

1 DIMACS format

2 Setup and simple tests

3 Pigeon Hole Problem

4 Chess Piece Independence

5 Hardware correctness

2 / 40

Page 3: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Outline

1 DIMACS format

2 Setup and simple tests

3 Pigeon Hole Problem

4 Chess Piece Independence

5 Hardware correctness

3 / 40

Page 4: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

SAT solvers input: DIMACS format

Standard input format for SAT solversRepresentation of CNF formulas stemming from achallenge run by DIMACS (Center for DiscreteMathematics and Theoretical Computer Science) in 1992

Example

(x1 ∨ x2 ∨ ¬x3) ∧ (¬x2) ∧ (x4 ∨ ¬x3)

DIMACS encoding

c This is a CNF in DIMACScp cnf 4 31 2 -3 0

-2 04 -3 0

4 / 40

Page 5: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

SAT solvers input: DIMACS format

Standard input format for SAT solversRepresentation of CNF formulas stemming from achallenge run by DIMACS (Center for DiscreteMathematics and Theoretical Computer Science) in 1992

Example

(x1 ∨ x2 ∨ ¬x3) ∧ (¬x2) ∧ (x4 ∨ ¬x3)

DIMACS encoding

c This is a CNF in DIMACScp cnf 4 31 2 -3 0

-2 04 -3 0

4 / 40

Page 6: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

DIMACS format in BNF grammar

BNF grammar

<input> ::= <preamble> <formula> EOF

<preamble> ::= [<commentlines>] <problemline><commentlines> ::= <commentline> <commentlines> | <commentline><commentline> ::= c <text> EOL<problemline> ::= p cnf <pnum> <pnum> EOL

<formula> ::= <clauselist><clauselist> ::= <clause> <clauselist> | <clause><clause> ::= <literal> <clause> | <literal> 0<literal> ::= <num>

<text> ::= A sequence of non-special ASCII characters<pnum> ::= A signed integer greater than 0<num> ::= A signed integer different from 0

5 / 40

Page 7: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Outline

1 DIMACS format

2 Setup and simple tests

3 Pigeon Hole Problem

4 Chess Piece Independence

5 Hardware correctness

6 / 40

Page 8: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Setup

1 (I suggest to) Boot Linux

2 Download one of the solvers athttp://minisat.se/MiniSat.html

MiniSat 2.2.0: only sourcesMiniSat 1.14: sources and binary (if you are lazy)

3 Build and have a look at the help$ minisat --help

7 / 40

Page 9: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Setup

1 (I suggest to) Boot Linux2 Download one of the solvers athttp://minisat.se/MiniSat.html

MiniSat 2.2.0: only sourcesMiniSat 1.14: sources and binary (if you are lazy)

3 Build and have a look at the help$ minisat --help

7 / 40

Page 10: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Setup

1 (I suggest to) Boot Linux2 Download one of the solvers athttp://minisat.se/MiniSat.html

MiniSat 2.2.0: only sources

MiniSat 1.14: sources and binary (if you are lazy)

3 Build and have a look at the help$ minisat --help

7 / 40

Page 11: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Setup

1 (I suggest to) Boot Linux2 Download one of the solvers athttp://minisat.se/MiniSat.html

MiniSat 2.2.0: only sourcesMiniSat 1.14: sources and binary (if you are lazy)

3 Build and have a look at the help$ minisat --help

7 / 40

Page 12: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Setup

1 (I suggest to) Boot Linux2 Download one of the solvers athttp://minisat.se/MiniSat.html

MiniSat 2.2.0: only sourcesMiniSat 1.14: sources and binary (if you are lazy)

3 Build and have a look at the help$ minisat --help

7 / 40

Page 13: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Simple test (1)

(x1 ∨ x2) ∧ (x1 ∨ ¬x2) ∧ (¬x1 ∨ ¬x2)

c This is a CNF in DIMACScp cnf 2 31 2 01 -2 0

-1 -2 0

8 / 40

Page 14: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Simple test (1)

(x1 ∨ x2) ∧ (x1 ∨ ¬x2) ∧ (¬x1 ∨ ¬x2)

c This is a CNF in DIMACScp cnf 2 31 2 01 -2 0

-1 -2 0

8 / 40

Page 15: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Simple test (2)

(x1 ∨ x2) ∧ (x1 ∨ ¬x2) ∧ (¬x1 ∨ x2) ∧ (¬x1 ∨ ¬x2)

p cnf 2 41 2 01 -2 0

-1 2 0-1 -2 0

9 / 40

Page 16: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Simple test (2)

(x1 ∨ x2) ∧ (x1 ∨ ¬x2) ∧ (¬x1 ∨ x2) ∧ (¬x1 ∨ ¬x2)

p cnf 2 41 2 01 -2 0

-1 2 0-1 -2 0

9 / 40

Page 17: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

More tests

Example

1 (x1 ∨ x2 ∨ ¬x3) ∧ (¬x2) ∧ (x4 ∨ ¬x3)

2 (x1 ∨ x2 ∨ ¬x3 ∨ ¬x4) ∧ (¬x2) ∧ (x4 ∨ ¬x3)

3 {x1 ∨ x2 ∨ x3, x1 ∨ x2 ∨ ¬x3, x1 ∨ ¬x2 ∨ x3, x1 ∨ ¬x2 ∨ ¬x3,¬x1 ∨ x4, x1 ∨ ¬x4 ∨ ¬x5 ∨ x6, ¬x1 ∨ x7}

10 / 40

Page 18: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

More tests

Example

1 (x1 ∨ x2 ∨ ¬x3) ∧ (¬x2) ∧ (x4 ∨ ¬x3)

2 (x1 ∨ x2 ∨ ¬x3 ∨ ¬x4) ∧ (¬x2) ∧ (x4 ∨ ¬x3)

3 {x1 ∨ x2 ∨ x3, x1 ∨ x2 ∨ ¬x3, x1 ∨ ¬x2 ∨ x3, x1 ∨ ¬x2 ∨ ¬x3,¬x1 ∨ x4, x1 ∨ ¬x4 ∨ ¬x5 ∨ x6, ¬x1 ∨ x7}

10 / 40

Page 19: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

More tests

Example

1 (x1 ∨ x2 ∨ ¬x3) ∧ (¬x2) ∧ (x4 ∨ ¬x3)

2 (x1 ∨ x2 ∨ ¬x3 ∨ ¬x4) ∧ (¬x2) ∧ (x4 ∨ ¬x3)

3 {x1 ∨ x2 ∨ x3, x1 ∨ x2 ∨ ¬x3, x1 ∨ ¬x2 ∨ x3, x1 ∨ ¬x2 ∨ ¬x3,¬x1 ∨ x4, x1 ∨ ¬x4 ∨ ¬x5 ∨ x6, ¬x1 ∨ x7}

10 / 40

Page 20: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Outline

1 DIMACS format

2 Setup and simple tests

3 Pigeon Hole Problem

4 Chess Piece Independence

5 Hardware correctness

11 / 40

Page 21: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Pigeons and Holes

Pigeons in their Holes

12 / 40

Page 22: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Pigeon Hole Problem

Pigeon Hole Problem — PHP

The problem PHP(m,n) is whether m pigeons can enter into npigeon holes

Task

Find a family of formulas which are satisfiablewhen PHP(m,n) is

13 / 40

Page 23: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Pigeon Hole Problem

Pigeon Hole Problem — PHP

The problem PHP(m,n) is whether m pigeons can enter into npigeon holes

Task

Find a family of formulas which are satisfiablewhen PHP(m,n) is

13 / 40

Page 24: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP — Modellation

Modellation

m × n propositional variables:xi,j , where i ≤ m and j ≤ nxi,j means that pigeon i is put into hole j

The formula should express:

1 Each pigeon is in some hole2 Each pigeon is in at most one hole3 In each hole there is at most one pigeon

14 / 40

Page 25: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP — Modellation

Modellation

m × n propositional variables:xi,j , where i ≤ m and j ≤ nxi,j means that pigeon i is put into hole j

The formula should express:

1 Each pigeon is in some hole2 Each pigeon is in at most one hole3 In each hole there is at most one pigeon

14 / 40

Page 26: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP — Modellation

Modellation

m × n propositional variables:xi,j , where i ≤ m and j ≤ nxi,j means that pigeon i is put into hole j

The formula should express:1 Each pigeon is in some hole

2 Each pigeon is in at most one hole3 In each hole there is at most one pigeon

14 / 40

Page 27: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP — Modellation

Modellation

m × n propositional variables:xi,j , where i ≤ m and j ≤ nxi,j means that pigeon i is put into hole j

The formula should express:1 Each pigeon is in some hole2 Each pigeon is in at most one hole

3 In each hole there is at most one pigeon

14 / 40

Page 28: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP — Modellation

Modellation

m × n propositional variables:xi,j , where i ≤ m and j ≤ nxi,j means that pigeon i is put into hole j

The formula should express:1 Each pigeon is in some hole2 Each pigeon is in at most one hole3 In each hole there is at most one pigeon

14 / 40

Page 29: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2)

1 Each pigeon is in some hole

x1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one hole

x1,1 → ¬x1,2x1,2 → ¬x1,1x2,1 → ¬x2,2x2,2 → ¬x2,1x3,1 → ¬x3,2x3,2 → ¬x3,1

3 In each hole there is at most one pigeon

x1,1 → ¬x2,1 ∧ ¬x3,1x2,1 → ¬x1,1 ∧ ¬x3,1x3,1 → ¬x1,1 ∧ ¬x2,1x1,2 → ¬x2,2 ∧ ¬x3,2x2,2 → ¬x1,2 ∧ ¬x3,2x3,2 → ¬x1,2 ∧ ¬x2,2

x1,1 → ¬x2,1, x1,1 → ¬x3,1x2,1 → ¬x1,1, x2,1 → ¬x3,1x3,1 → ¬x1,1, x3,1 → ¬x2,1x1,2 → ¬x2,2, x1,2 → ¬x3,2x2,2 → ¬x1,2, x2,2 → ¬x3,2x3,2 → ¬x1,2, x3,2 → ¬x2,2

15 / 40

Page 30: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2)

1 Each pigeon is in some holex1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one hole

x1,1 → ¬x1,2x1,2 → ¬x1,1x2,1 → ¬x2,2x2,2 → ¬x2,1x3,1 → ¬x3,2x3,2 → ¬x3,1

3 In each hole there is at most one pigeon

x1,1 → ¬x2,1 ∧ ¬x3,1x2,1 → ¬x1,1 ∧ ¬x3,1x3,1 → ¬x1,1 ∧ ¬x2,1x1,2 → ¬x2,2 ∧ ¬x3,2x2,2 → ¬x1,2 ∧ ¬x3,2x3,2 → ¬x1,2 ∧ ¬x2,2

x1,1 → ¬x2,1, x1,1 → ¬x3,1x2,1 → ¬x1,1, x2,1 → ¬x3,1x3,1 → ¬x1,1, x3,1 → ¬x2,1x1,2 → ¬x2,2, x1,2 → ¬x3,2x2,2 → ¬x1,2, x2,2 → ¬x3,2x3,2 → ¬x1,2, x3,2 → ¬x2,2

15 / 40

Page 31: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2)

1 Each pigeon is in some holex1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one holex1,1 → ¬x1,2x1,2 → ¬x1,1

x2,1 → ¬x2,2x2,2 → ¬x2,1x3,1 → ¬x3,2x3,2 → ¬x3,1

3 In each hole there is at most one pigeon

x1,1 → ¬x2,1 ∧ ¬x3,1x2,1 → ¬x1,1 ∧ ¬x3,1x3,1 → ¬x1,1 ∧ ¬x2,1x1,2 → ¬x2,2 ∧ ¬x3,2x2,2 → ¬x1,2 ∧ ¬x3,2x3,2 → ¬x1,2 ∧ ¬x2,2

x1,1 → ¬x2,1, x1,1 → ¬x3,1x2,1 → ¬x1,1, x2,1 → ¬x3,1x3,1 → ¬x1,1, x3,1 → ¬x2,1x1,2 → ¬x2,2, x1,2 → ¬x3,2x2,2 → ¬x1,2, x2,2 → ¬x3,2x3,2 → ¬x1,2, x3,2 → ¬x2,2

15 / 40

Page 32: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2)

1 Each pigeon is in some holex1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one holex1,1 → ¬x1,2x1,2 → ¬x1,1x2,1 → ¬x2,2x2,2 → ¬x2,1

x3,1 → ¬x3,2x3,2 → ¬x3,1

3 In each hole there is at most one pigeon

x1,1 → ¬x2,1 ∧ ¬x3,1x2,1 → ¬x1,1 ∧ ¬x3,1x3,1 → ¬x1,1 ∧ ¬x2,1x1,2 → ¬x2,2 ∧ ¬x3,2x2,2 → ¬x1,2 ∧ ¬x3,2x3,2 → ¬x1,2 ∧ ¬x2,2

x1,1 → ¬x2,1, x1,1 → ¬x3,1x2,1 → ¬x1,1, x2,1 → ¬x3,1x3,1 → ¬x1,1, x3,1 → ¬x2,1x1,2 → ¬x2,2, x1,2 → ¬x3,2x2,2 → ¬x1,2, x2,2 → ¬x3,2x3,2 → ¬x1,2, x3,2 → ¬x2,2

15 / 40

Page 33: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2)

1 Each pigeon is in some holex1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one holex1,1 → ¬x1,2x1,2 → ¬x1,1x2,1 → ¬x2,2x2,2 → ¬x2,1x3,1 → ¬x3,2x3,2 → ¬x3,1

3 In each hole there is at most one pigeon

x1,1 → ¬x2,1 ∧ ¬x3,1x2,1 → ¬x1,1 ∧ ¬x3,1x3,1 → ¬x1,1 ∧ ¬x2,1x1,2 → ¬x2,2 ∧ ¬x3,2x2,2 → ¬x1,2 ∧ ¬x3,2x3,2 → ¬x1,2 ∧ ¬x2,2

x1,1 → ¬x2,1, x1,1 → ¬x3,1x2,1 → ¬x1,1, x2,1 → ¬x3,1x3,1 → ¬x1,1, x3,1 → ¬x2,1x1,2 → ¬x2,2, x1,2 → ¬x3,2x2,2 → ¬x1,2, x2,2 → ¬x3,2x3,2 → ¬x1,2, x3,2 → ¬x2,2

15 / 40

Page 34: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2)

1 Each pigeon is in some holex1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one holex1,1 → ¬x1,2x1,2 → ¬x1,1x2,1 → ¬x2,2x2,2 → ¬x2,1x3,1 → ¬x3,2x3,2 → ¬x3,1

3 In each hole there is at most one pigeonx1,1 → ¬x2,1 ∧ ¬x3,1x2,1 → ¬x1,1 ∧ ¬x3,1x3,1 → ¬x1,1 ∧ ¬x2,1

x1,2 → ¬x2,2 ∧ ¬x3,2x2,2 → ¬x1,2 ∧ ¬x3,2x3,2 → ¬x1,2 ∧ ¬x2,2

x1,1 → ¬x2,1, x1,1 → ¬x3,1x2,1 → ¬x1,1, x2,1 → ¬x3,1x3,1 → ¬x1,1, x3,1 → ¬x2,1x1,2 → ¬x2,2, x1,2 → ¬x3,2x2,2 → ¬x1,2, x2,2 → ¬x3,2x3,2 → ¬x1,2, x3,2 → ¬x2,2

15 / 40

Page 35: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2)

1 Each pigeon is in some holex1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one holex1,1 → ¬x1,2x1,2 → ¬x1,1x2,1 → ¬x2,2x2,2 → ¬x2,1x3,1 → ¬x3,2x3,2 → ¬x3,1

3 In each hole there is at most one pigeonx1,1 → ¬x2,1 ∧ ¬x3,1x2,1 → ¬x1,1 ∧ ¬x3,1x3,1 → ¬x1,1 ∧ ¬x2,1x1,2 → ¬x2,2 ∧ ¬x3,2x2,2 → ¬x1,2 ∧ ¬x3,2x3,2 → ¬x1,2 ∧ ¬x2,2

x1,1 → ¬x2,1, x1,1 → ¬x3,1x2,1 → ¬x1,1, x2,1 → ¬x3,1x3,1 → ¬x1,1, x3,1 → ¬x2,1x1,2 → ¬x2,2, x1,2 → ¬x3,2x2,2 → ¬x1,2, x2,2 → ¬x3,2x3,2 → ¬x1,2, x3,2 → ¬x2,2

15 / 40

Page 36: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2)

1 Each pigeon is in some holex1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one holex1,1 → ¬x1,2x1,2 → ¬x1,1x2,1 → ¬x2,2x2,2 → ¬x2,1x3,1 → ¬x3,2x3,2 → ¬x3,1

3 In each hole there is at most one pigeonx1,1 → ¬x2,1 ∧ ¬x3,1x2,1 → ¬x1,1 ∧ ¬x3,1x3,1 → ¬x1,1 ∧ ¬x2,1x1,2 → ¬x2,2 ∧ ¬x3,2x2,2 → ¬x1,2 ∧ ¬x3,2x3,2 → ¬x1,2 ∧ ¬x2,2

x1,1 → ¬x2,1, x1,1 → ¬x3,1x2,1 → ¬x1,1, x2,1 → ¬x3,1x3,1 → ¬x1,1, x3,1 → ¬x2,1x1,2 → ¬x2,2, x1,2 → ¬x3,2x2,2 → ¬x1,2, x2,2 → ¬x3,2x3,2 → ¬x1,2, x3,2 → ¬x2,2

15 / 40

Page 37: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2)

1 Each pigeon is in some holex1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one holex1,1 → ¬x1,2x1,2 → ¬x1,1x2,1 → ¬x2,2x2,2 → ¬x2,1x3,1 → ¬x3,2x3,2 → ¬x3,1

3 In each hole there is at most one pigeonx1,1 → ¬x2,1 ∧ ¬x3,1x2,1 → ¬x1,1 ∧ ¬x3,1x3,1 → ¬x1,1 ∧ ¬x2,1x1,2 → ¬x2,2 ∧ ¬x3,2x2,2 → ¬x1,2 ∧ ¬x3,2x3,2 → ¬x1,2 ∧ ¬x2,2

x1,1 → ¬x2,1, x1,1 → ¬x3,1x2,1 → ¬x1,1, x2,1 → ¬x3,1x3,1 → ¬x1,1, x3,1 → ¬x2,1

x1,2 → ¬x2,2, x1,2 → ¬x3,2x2,2 → ¬x1,2, x2,2 → ¬x3,2x3,2 → ¬x1,2, x3,2 → ¬x2,2

15 / 40

Page 38: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2)

1 Each pigeon is in some holex1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one holex1,1 → ¬x1,2x1,2 → ¬x1,1x2,1 → ¬x2,2x2,2 → ¬x2,1x3,1 → ¬x3,2x3,2 → ¬x3,1

3 In each hole there is at most one pigeonx1,1 → ¬x2,1 ∧ ¬x3,1x2,1 → ¬x1,1 ∧ ¬x3,1x3,1 → ¬x1,1 ∧ ¬x2,1x1,2 → ¬x2,2 ∧ ¬x3,2x2,2 → ¬x1,2 ∧ ¬x3,2x3,2 → ¬x1,2 ∧ ¬x2,2

x1,1 → ¬x2,1, x1,1 → ¬x3,1x2,1 → ¬x1,1, x2,1 → ¬x3,1x3,1 → ¬x1,1, x3,1 → ¬x2,1x1,2 → ¬x2,2, x1,2 → ¬x3,2x2,2 → ¬x1,2, x2,2 → ¬x3,2x3,2 → ¬x1,2, x3,2 → ¬x2,2

15 / 40

Page 39: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP(m,n) — Formula

m∧i=1

n∨j=1

xi,j

∧m∧

i=1

n∧j=1

(xi,j →n∧

k=1k 6=j

¬xi,k ) ∧m∧

i=1

n∧j=1

(xi,j →m∧

k=1k 6=i

¬xk ,j)

CNF Formula

m∧i=1

n∨j=1

xi,j

∧m∧

i=1

n∧j=1

n∧k=1k 6=j

(¬xi,j ∨ ¬xi,k ) ∧m∧

i=1

n∧j=1

m∧k=1k 6=i

(¬xi,j ∨ ¬xk ,j)

16 / 40

Page 40: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP(m,n) — Formula

m∧i=1

n∨j=1

xi,j

∧m∧

i=1

n∧j=1

(xi,j →n∧

k=1k 6=j

¬xi,k ) ∧m∧

i=1

n∧j=1

(xi,j →m∧

k=1k 6=i

¬xk ,j)

CNF Formula

m∧i=1

n∨j=1

xi,j

∧m∧

i=1

n∧j=1

n∧k=1k 6=j

(¬xi,j ∨ ¬xi,k ) ∧m∧

i=1

n∧j=1

m∧k=1k 6=i

(¬xi,j ∨ ¬xk ,j)

16 / 40

Page 41: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2) in CNF

1 Each pigeon is in some holex1,1 ∨ x1,2, x2,1 ∨ x2,2, x3,1 ∨ x3,2

2 Each pigeon is in at most one hole¬x1,1 ∨ ¬x1,2¬x1,2 ∨ ¬x1,1¬x2,1 ∨ ¬x2,2¬x2,2 ∨ ¬x2,1¬x3,1 ∨ ¬x3,2¬x3,2 ∨ ¬x3,1

3 In each hole there is at most one pigeon¬x1,1 ∨ ¬x2,1, ¬x1,1 ∨ ¬x3,1¬x2,1 ∨ ¬x1,1, ¬x2,1 ∨ ¬x3,1¬x3,1 ∨ ¬x1,1, ¬x3,1 ∨ ¬x2,1¬x1,2 ∨ ¬x2,2, ¬x1,2 ∨ ¬x3,2¬x2,2 ∨ ¬x1,2, ¬x2,2 ∨ ¬x3,2¬x3,2 ∨ ¬x1,2, ¬x3,2 ∨ ¬x2,2

17 / 40

Page 42: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP in DIMACS

We must convert the variables to positive integers

x1,1 7→ 1...

xm,1 7→ m

x1,2 7→ m + 1...

xm,2 7→ 2×m...

x1,n 7→ (n − 1)×m + 1...

xm,n 7→ n ×m

Therefore, xi,j will be represented by (j − 1)×m + i

18 / 40

Page 43: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP in DIMACS

We must convert the variables to positive integers

x1,1 7→ 1...

xm,1 7→ mx1,2 7→ m + 1

...xm,2 7→ 2×m

...x1,n 7→ (n − 1)×m + 1

...xm,n 7→ n ×m

Therefore, xi,j will be represented by (j − 1)×m + i

18 / 40

Page 44: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP in DIMACS

We must convert the variables to positive integers

x1,1 7→ 1...

xm,1 7→ mx1,2 7→ m + 1

...xm,2 7→ 2×m

...x1,n 7→ (n − 1)×m + 1

...xm,n 7→ n ×m

Therefore, xi,j will be represented by (j − 1)×m + i

18 / 40

Page 45: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP in DIMACS

We must convert the variables to positive integers

x1,1 7→ 1...

xm,1 7→ mx1,2 7→ m + 1

...xm,2 7→ 2×m

...x1,n 7→ (n − 1)×m + 1

...xm,n 7→ n ×m

Therefore, xi,j will be represented by (j − 1)×m + i

18 / 40

Page 46: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: PHP(3,2) in DIMACS

1 x1,1∨x1,2, x2,1∨x2,2, x3,1∨x3,2

2 ¬x1,1 ∨ ¬x1,2¬x1,2 ∨ ¬x1,1¬x2,1 ∨ ¬x2,2¬x2,2 ∨ ¬x2,1¬x3,1 ∨ ¬x3,2¬x3,2 ∨ ¬x3,1

3 ¬x1,1 ∨ ¬x2,1, ¬x1,1 ∨ ¬x3,1¬x2,1 ∨ ¬x1,1, ¬x2,1 ∨ ¬x3,1¬x3,1 ∨ ¬x1,1, ¬x3,1 ∨ ¬x2,1¬x1,2 ∨ ¬x2,2, ¬x1,2 ∨ ¬x3,2¬x2,2 ∨ ¬x1,2, ¬x2,2 ∨ ¬x3,2¬x3,2 ∨ ¬x1,2, ¬x3,2 ∨ ¬x2,2

p cnf 6 211 4 0 -1 -2 02 5 0 -1 -3 03 6 0 -4 -5 0

-1 -4 0 -4 -6 0-4 -1 0 -2 -1 0-2 -5 0 -2 -3 0-5 -2 0 -5 -4 0-3 -6 0 -5 -6 0-6 -3 0 -3 -1 0-3 -2 0-6 -4 0-6 -5 0

19 / 40

Page 47: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP — Why?

Hard problem for SAT solvers

PHP(m,n) is unsatisfiable if and only if m > n

SAT solvers have an exponential behaviorSymmetries tend to mess up backtracking algorithmsTry it with the PHP(m,n) formula generator!

20 / 40

Page 48: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP — Why?

Hard problem for SAT solvers

PHP(m,n) is unsatisfiable if and only if m > nSAT solvers have an exponential behavior

Symmetries tend to mess up backtracking algorithmsTry it with the PHP(m,n) formula generator!

20 / 40

Page 49: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP — Why?

Hard problem for SAT solvers

PHP(m,n) is unsatisfiable if and only if m > nSAT solvers have an exponential behaviorSymmetries tend to mess up backtracking algorithms

Try it with the PHP(m,n) formula generator!

20 / 40

Page 50: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

PHP — Why?

Hard problem for SAT solvers

PHP(m,n) is unsatisfiable if and only if m > nSAT solvers have an exponential behaviorSymmetries tend to mess up backtracking algorithmsTry it with the PHP(m,n) formula generator!

20 / 40

Page 51: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Outline

1 DIMACS format

2 Setup and simple tests

3 Pigeon Hole Problem

4 Chess Piece Independence

5 Hardware correctness

21 / 40

Page 52: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Rook Independence Problem

Rook Independence Problem — RIP(m,n)

Place m rooks on an n × n chessboard so that they do notthreaten each other

Reminder: Rook moves

8 0Z0Z0Z0Z7 Z0Z0Z0Z06 0Z0Z0Z0Z5 Z0Z0Z0Z04 0Z0ZrZ0Z3 Z0Z0Z0Z02 0Z0Z0Z0Z1 Z0Z0Z0Z0

1 2 3 4 5 6 7 8

Example. RIP(2,2)

2 rZ1 Zr

1 2

22 / 40

Page 53: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Rook Independence Problem

Rook Independence Problem — RIP(m,n)

Place m rooks on an n × n chessboard so that they do notthreaten each other

Reminder: Rook moves

8 0Z0Z0Z0Z7 Z0Z0Z0Z06 0Z0Z0Z0Z5 Z0Z0Z0Z04 0Z0ZrZ0Z3 Z0Z0Z0Z02 0Z0Z0Z0Z1 Z0Z0Z0Z0

1 2 3 4 5 6 7 8

Example. RIP(2,2)

2 rZ1 Zr

1 2

22 / 40

Page 54: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Rook Independence Problem

Rook Independence Problem — RIP(m,n)

Place m rooks on an n × n chessboard so that they do notthreaten each other

Reminder: Rook moves

8 0Z0Z0Z0Z7 Z0Z0Z0Z06 0Z0Z0Z0Z5 Z0Z0Z0Z04 0Z0ZrZ0Z3 Z0Z0Z0Z02 0Z0Z0Z0Z1 Z0Z0Z0Z0

1 2 3 4 5 6 7 8

Example. RIP(2,2)

2 rZ1 Zr

1 2

22 / 40

Page 55: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — Modellation

Modellation

m × n × n propositional variables:xi,j,k , where i ≤ n, j ≤ n, k ≤ mxi,j,k means that rook k is put onto field (i , j)

The formula should express:

1 Each rook is placed on some field2 Each rook is placed on at most one field3 Each field holds at most one rook4 No rook threatens another rook

23 / 40

Page 56: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — Modellation

Modellation

m × n × n propositional variables:xi,j,k , where i ≤ n, j ≤ n, k ≤ mxi,j,k means that rook k is put onto field (i , j)

The formula should express:

1 Each rook is placed on some field2 Each rook is placed on at most one field3 Each field holds at most one rook4 No rook threatens another rook

23 / 40

Page 57: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — Modellation

Modellation

m × n × n propositional variables:xi,j,k , where i ≤ n, j ≤ n, k ≤ mxi,j,k means that rook k is put onto field (i , j)

The formula should express:1 Each rook is placed on some field

2 Each rook is placed on at most one field3 Each field holds at most one rook4 No rook threatens another rook

23 / 40

Page 58: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — Modellation

Modellation

m × n × n propositional variables:xi,j,k , where i ≤ n, j ≤ n, k ≤ mxi,j,k means that rook k is put onto field (i , j)

The formula should express:1 Each rook is placed on some field2 Each rook is placed on at most one field

3 Each field holds at most one rook4 No rook threatens another rook

23 / 40

Page 59: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — Modellation

Modellation

m × n × n propositional variables:xi,j,k , where i ≤ n, j ≤ n, k ≤ mxi,j,k means that rook k is put onto field (i , j)

The formula should express:1 Each rook is placed on some field2 Each rook is placed on at most one field3 Each field holds at most one rook

4 No rook threatens another rook

23 / 40

Page 60: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — Modellation

Modellation

m × n × n propositional variables:xi,j,k , where i ≤ n, j ≤ n, k ≤ mxi,j,k means that rook k is put onto field (i , j)

The formula should express:1 Each rook is placed on some field2 Each rook is placed on at most one field3 Each field holds at most one rook4 No rook threatens another rook

23 / 40

Page 61: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (1)

1 Each rook is placed on some field

x1,1,1 ∨ x1,2,1 ∨ x2,1,1 ∨ x2,2,1x1,1,2 ∨ x1,2,2 ∨ x2,1,2 ∨ x2,2,2x1,1,3 ∨ x1,2,3 ∨ x2,1,3 ∨ x2,2,3

2 Each rook is placed on at most one fieldx1,1,1 → ¬x1,2,1 ∧ ¬x2,1,1 ∧ ¬x2,2,1x1,2,1 → ¬x1,1,1 ∧ ¬x2,1,1 ∧ ¬x2,2,1x2,1,1 → ¬x1,1,1 ∧ ¬x1,2,1 ∧ ¬x2,2,1x2,2,1 → ¬x1,1,1 ∧ ¬x1,2,1 ∧ ¬x2,1,1

...x1,1,3 → ¬x1,2,3 ∧ ¬x2,1,3 ∧ ¬x2,2,3x1,2,3 → ¬x1,1,3 ∧ ¬x2,1,3 ∧ ¬x2,2,3x2,1,3 → ¬x1,1,3 ∧ ¬x1,2,3 ∧ ¬x2,2,3x2,2,3 → ¬x1,1,3 ∧ ¬x1,2,3 ∧ ¬x2,1,3

24 / 40

Page 62: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (1)

1 Each rook is placed on some fieldx1,1,1 ∨ x1,2,1 ∨ x2,1,1 ∨ x2,2,1x1,1,2 ∨ x1,2,2 ∨ x2,1,2 ∨ x2,2,2x1,1,3 ∨ x1,2,3 ∨ x2,1,3 ∨ x2,2,3

2 Each rook is placed on at most one fieldx1,1,1 → ¬x1,2,1 ∧ ¬x2,1,1 ∧ ¬x2,2,1x1,2,1 → ¬x1,1,1 ∧ ¬x2,1,1 ∧ ¬x2,2,1x2,1,1 → ¬x1,1,1 ∧ ¬x1,2,1 ∧ ¬x2,2,1x2,2,1 → ¬x1,1,1 ∧ ¬x1,2,1 ∧ ¬x2,1,1

...x1,1,3 → ¬x1,2,3 ∧ ¬x2,1,3 ∧ ¬x2,2,3x1,2,3 → ¬x1,1,3 ∧ ¬x2,1,3 ∧ ¬x2,2,3x2,1,3 → ¬x1,1,3 ∧ ¬x1,2,3 ∧ ¬x2,2,3x2,2,3 → ¬x1,1,3 ∧ ¬x1,2,3 ∧ ¬x2,1,3

24 / 40

Page 63: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (1)

1 Each rook is placed on some fieldx1,1,1 ∨ x1,2,1 ∨ x2,1,1 ∨ x2,2,1x1,1,2 ∨ x1,2,2 ∨ x2,1,2 ∨ x2,2,2x1,1,3 ∨ x1,2,3 ∨ x2,1,3 ∨ x2,2,3

2 Each rook is placed on at most one fieldx1,1,1 → ¬x1,2,1 ∧ ¬x2,1,1 ∧ ¬x2,2,1x1,2,1 → ¬x1,1,1 ∧ ¬x2,1,1 ∧ ¬x2,2,1x2,1,1 → ¬x1,1,1 ∧ ¬x1,2,1 ∧ ¬x2,2,1x2,2,1 → ¬x1,1,1 ∧ ¬x1,2,1 ∧ ¬x2,1,1

...x1,1,3 → ¬x1,2,3 ∧ ¬x2,1,3 ∧ ¬x2,2,3x1,2,3 → ¬x1,1,3 ∧ ¬x2,1,3 ∧ ¬x2,2,3x2,1,3 → ¬x1,1,3 ∧ ¬x1,2,3 ∧ ¬x2,2,3x2,2,3 → ¬x1,1,3 ∧ ¬x1,2,3 ∧ ¬x2,1,3

24 / 40

Page 64: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (1)

1 Each rook is placed on some fieldx1,1,1 ∨ x1,2,1 ∨ x2,1,1 ∨ x2,2,1x1,1,2 ∨ x1,2,2 ∨ x2,1,2 ∨ x2,2,2x1,1,3 ∨ x1,2,3 ∨ x2,1,3 ∨ x2,2,3

2 Each rook is placed on at most one fieldx1,1,1 → ¬x1,2,1 ∧ ¬x2,1,1 ∧ ¬x2,2,1x1,2,1 → ¬x1,1,1 ∧ ¬x2,1,1 ∧ ¬x2,2,1x2,1,1 → ¬x1,1,1 ∧ ¬x1,2,1 ∧ ¬x2,2,1x2,2,1 → ¬x1,1,1 ∧ ¬x1,2,1 ∧ ¬x2,1,1

...x1,1,3 → ¬x1,2,3 ∧ ¬x2,1,3 ∧ ¬x2,2,3x1,2,3 → ¬x1,1,3 ∧ ¬x2,1,3 ∧ ¬x2,2,3x2,1,3 → ¬x1,1,3 ∧ ¬x1,2,3 ∧ ¬x2,2,3x2,2,3 → ¬x1,1,3 ∧ ¬x1,2,3 ∧ ¬x2,1,3

24 / 40

Page 65: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (2)

3 Each field holds at most one rook

x1,1,1 → ¬x1,1,2 ∧ ¬x1,1,3x1,1,2 → ¬x1,1,1 ∧ ¬x1,1,3x1,1,3 → ¬x1,1,1 ∧ ¬x1,1,2

x1,2,1 → ¬x1,2,2 ∧ ¬x1,2,3x1,2,2 → ¬x1,2,2 ∧ ¬x1,2,3x1,2,3 → ¬x1,2,1 ∧ ¬x1,2,2

x2,1,1 → ¬x2,1,2 ∧ ¬x2,1,3x2,1,2 → ¬x2,1,1 ∧ ¬x2,1,3x2,1,3 → ¬x2,1,1 ∧ ¬x2,1,2

x2,2,1 → ¬x2,2,2 ∧ ¬x2,2,3x2,2,2 → ¬x2,2,1 ∧ ¬x2,2,3x2,2,3 → ¬x2,2,1 ∧ ¬x2,2,2

25 / 40

Page 66: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (2)

3 Each field holds at most one rookx1,1,1 → ¬x1,1,2 ∧ ¬x1,1,3x1,1,2 → ¬x1,1,1 ∧ ¬x1,1,3x1,1,3 → ¬x1,1,1 ∧ ¬x1,1,2

x1,2,1 → ¬x1,2,2 ∧ ¬x1,2,3x1,2,2 → ¬x1,2,2 ∧ ¬x1,2,3x1,2,3 → ¬x1,2,1 ∧ ¬x1,2,2

x2,1,1 → ¬x2,1,2 ∧ ¬x2,1,3x2,1,2 → ¬x2,1,1 ∧ ¬x2,1,3x2,1,3 → ¬x2,1,1 ∧ ¬x2,1,2

x2,2,1 → ¬x2,2,2 ∧ ¬x2,2,3x2,2,2 → ¬x2,2,1 ∧ ¬x2,2,3x2,2,3 → ¬x2,2,1 ∧ ¬x2,2,2

25 / 40

Page 67: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (2)

3 Each field holds at most one rookx1,1,1 → ¬x1,1,2 ∧ ¬x1,1,3x1,1,2 → ¬x1,1,1 ∧ ¬x1,1,3x1,1,3 → ¬x1,1,1 ∧ ¬x1,1,2

x1,2,1 → ¬x1,2,2 ∧ ¬x1,2,3x1,2,2 → ¬x1,2,2 ∧ ¬x1,2,3x1,2,3 → ¬x1,2,1 ∧ ¬x1,2,2

x2,1,1 → ¬x2,1,2 ∧ ¬x2,1,3x2,1,2 → ¬x2,1,1 ∧ ¬x2,1,3x2,1,3 → ¬x2,1,1 ∧ ¬x2,1,2

x2,2,1 → ¬x2,2,2 ∧ ¬x2,2,3x2,2,2 → ¬x2,2,1 ∧ ¬x2,2,3x2,2,3 → ¬x2,2,1 ∧ ¬x2,2,2

25 / 40

Page 68: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (2)

3 Each field holds at most one rookx1,1,1 → ¬x1,1,2 ∧ ¬x1,1,3x1,1,2 → ¬x1,1,1 ∧ ¬x1,1,3x1,1,3 → ¬x1,1,1 ∧ ¬x1,1,2

x1,2,1 → ¬x1,2,2 ∧ ¬x1,2,3x1,2,2 → ¬x1,2,2 ∧ ¬x1,2,3x1,2,3 → ¬x1,2,1 ∧ ¬x1,2,2

x2,1,1 → ¬x2,1,2 ∧ ¬x2,1,3x2,1,2 → ¬x2,1,1 ∧ ¬x2,1,3x2,1,3 → ¬x2,1,1 ∧ ¬x2,1,2

x2,2,1 → ¬x2,2,2 ∧ ¬x2,2,3x2,2,2 → ¬x2,2,1 ∧ ¬x2,2,3x2,2,3 → ¬x2,2,1 ∧ ¬x2,2,2

25 / 40

Page 69: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (2)

3 Each field holds at most one rookx1,1,1 → ¬x1,1,2 ∧ ¬x1,1,3x1,1,2 → ¬x1,1,1 ∧ ¬x1,1,3x1,1,3 → ¬x1,1,1 ∧ ¬x1,1,2

x1,2,1 → ¬x1,2,2 ∧ ¬x1,2,3x1,2,2 → ¬x1,2,2 ∧ ¬x1,2,3x1,2,3 → ¬x1,2,1 ∧ ¬x1,2,2

x2,1,1 → ¬x2,1,2 ∧ ¬x2,1,3x2,1,2 → ¬x2,1,1 ∧ ¬x2,1,3x2,1,3 → ¬x2,1,1 ∧ ¬x2,1,2

x2,2,1 → ¬x2,2,2 ∧ ¬x2,2,3x2,2,2 → ¬x2,2,1 ∧ ¬x2,2,3x2,2,3 → ¬x2,2,1 ∧ ¬x2,2,2

25 / 40

Page 70: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (3)

4 No rook threatens another rook

x1,1,1 → ¬x1,2,2 ∧ ¬x1,2,3 ∧ ¬x2,1,2 ∧ ¬x2,1,3x1,1,2 → ¬x1,2,1 ∧ ¬x1,2,3 ∧ ¬x2,1,1 ∧ ¬x2,1,3x1,1,3 → ¬x1,2,1 ∧ ¬x1,2,2 ∧ ¬x2,1,1 ∧ ¬x2,1,2

x2,1,1 → ¬x2,2,2 ∧ ¬x2,2,3 ∧ ¬x1,1,2 ∧ ¬x1,1,3...

x1,2,1 → ¬x1,1,2 ∧ ¬x1,1,3 ∧ ¬x2,2,2 ∧ ¬x2,2,3...

x2,2,1 → ¬x2,1,2 ∧ ¬x2,1,3 ∧ ¬x1,2,2 ∧ ¬x1,2,3...

26 / 40

Page 71: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (3)

4 No rook threatens another rookx1,1,1 → ¬x1,2,2 ∧ ¬x1,2,3 ∧ ¬x2,1,2 ∧ ¬x2,1,3x1,1,2 → ¬x1,2,1 ∧ ¬x1,2,3 ∧ ¬x2,1,1 ∧ ¬x2,1,3x1,1,3 → ¬x1,2,1 ∧ ¬x1,2,2 ∧ ¬x2,1,1 ∧ ¬x2,1,2

x2,1,1 → ¬x2,2,2 ∧ ¬x2,2,3 ∧ ¬x1,1,2 ∧ ¬x1,1,3...

x1,2,1 → ¬x1,1,2 ∧ ¬x1,1,3 ∧ ¬x2,2,2 ∧ ¬x2,2,3...

x2,2,1 → ¬x2,1,2 ∧ ¬x2,1,3 ∧ ¬x1,2,2 ∧ ¬x1,2,3...

26 / 40

Page 72: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (3)

4 No rook threatens another rookx1,1,1 → ¬x1,2,2 ∧ ¬x1,2,3 ∧ ¬x2,1,2 ∧ ¬x2,1,3x1,1,2 → ¬x1,2,1 ∧ ¬x1,2,3 ∧ ¬x2,1,1 ∧ ¬x2,1,3x1,1,3 → ¬x1,2,1 ∧ ¬x1,2,2 ∧ ¬x2,1,1 ∧ ¬x2,1,2

x2,1,1 → ¬x2,2,2 ∧ ¬x2,2,3 ∧ ¬x1,1,2 ∧ ¬x1,1,3...

x1,2,1 → ¬x1,1,2 ∧ ¬x1,1,3 ∧ ¬x2,2,2 ∧ ¬x2,2,3...

x2,2,1 → ¬x2,1,2 ∧ ¬x2,1,3 ∧ ¬x1,2,2 ∧ ¬x1,2,3...

26 / 40

Page 73: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (3)

4 No rook threatens another rookx1,1,1 → ¬x1,2,2 ∧ ¬x1,2,3 ∧ ¬x2,1,2 ∧ ¬x2,1,3x1,1,2 → ¬x1,2,1 ∧ ¬x1,2,3 ∧ ¬x2,1,1 ∧ ¬x2,1,3x1,1,3 → ¬x1,2,1 ∧ ¬x1,2,2 ∧ ¬x2,1,1 ∧ ¬x2,1,2

x2,1,1 → ¬x2,2,2 ∧ ¬x2,2,3 ∧ ¬x1,1,2 ∧ ¬x1,1,3...

x1,2,1 → ¬x1,1,2 ∧ ¬x1,1,3 ∧ ¬x2,2,2 ∧ ¬x2,2,3...

x2,2,1 → ¬x2,1,2 ∧ ¬x2,1,3 ∧ ¬x1,2,2 ∧ ¬x1,2,3...

26 / 40

Page 74: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Example: RIP(3,2) (3)

4 No rook threatens another rookx1,1,1 → ¬x1,2,2 ∧ ¬x1,2,3 ∧ ¬x2,1,2 ∧ ¬x2,1,3x1,1,2 → ¬x1,2,1 ∧ ¬x1,2,3 ∧ ¬x2,1,1 ∧ ¬x2,1,3x1,1,3 → ¬x1,2,1 ∧ ¬x1,2,2 ∧ ¬x2,1,1 ∧ ¬x2,1,2

x2,1,1 → ¬x2,2,2 ∧ ¬x2,2,3 ∧ ¬x1,1,2 ∧ ¬x1,1,3...

x1,2,1 → ¬x1,1,2 ∧ ¬x1,1,3 ∧ ¬x2,2,2 ∧ ¬x2,2,3...

x2,2,1 → ¬x2,1,2 ∧ ¬x2,1,3 ∧ ¬x1,2,2 ∧ ¬x1,2,3...

26 / 40

Page 75: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP(m,n) — Formula

1

m∧k=1

n∨i=1

n∨j=1

xi,j,k

2

n∧i=1

n∧j=1

m∧k=1

(xi,j,k →

nn∧

l=1h=1

(l,h)6=(i,j)

¬xl,h,k )

3

n∧i=1

n∧j=1

m∧k=1

(xi,j,k →m∧

l=1l 6=k

¬xi,j,l)

4

n∧i=1

n∧j=1

m∧k=1

(xi,j,k →

mn∧

l=1h=1

(l,h)6=(i,k)

¬xl,j,h ∧

mn∧

l=1h=1

(l,h)6=(j,k)

¬xi,l,h)

27 / 40

Page 76: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — CNF Formula

Your turn!

1 Figure out CNF2 Use variable enumeration as in the following slide

Or trick with some hashmap, associative array, dictionary, ...

3 Copy php.pl to rip.pl and modify accordingly

Or start with php.py if you like pythonic solutions!

4 Try it with MiniSat for some m,n

28 / 40

Page 77: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — CNF Formula

Your turn!

1 Figure out CNF

2 Use variable enumeration as in the following slide

Or trick with some hashmap, associative array, dictionary, ...

3 Copy php.pl to rip.pl and modify accordingly

Or start with php.py if you like pythonic solutions!

4 Try it with MiniSat for some m,n

28 / 40

Page 78: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — CNF Formula

Your turn!

1 Figure out CNF2 Use variable enumeration as in the following slide

Or trick with some hashmap, associative array, dictionary, ...3 Copy php.pl to rip.pl and modify accordingly

Or start with php.py if you like pythonic solutions!

4 Try it with MiniSat for some m,n

28 / 40

Page 79: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — CNF Formula

Your turn!

1 Figure out CNF2 Use variable enumeration as in the following slide

Or trick with some hashmap, associative array, dictionary, ...

3 Copy php.pl to rip.pl and modify accordingly

Or start with php.py if you like pythonic solutions!

4 Try it with MiniSat for some m,n

28 / 40

Page 80: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — CNF Formula

Your turn!

1 Figure out CNF2 Use variable enumeration as in the following slide

Or trick with some hashmap, associative array, dictionary, ...3 Copy php.pl to rip.pl and modify accordingly

Or start with php.py if you like pythonic solutions!

4 Try it with MiniSat for some m,n

28 / 40

Page 81: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — CNF Formula

Your turn!

1 Figure out CNF2 Use variable enumeration as in the following slide

Or trick with some hashmap, associative array, dictionary, ...3 Copy php.pl to rip.pl and modify accordingly

Or start with php.py if you like pythonic solutions!

4 Try it with MiniSat for some m,n

28 / 40

Page 82: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — CNF Formula

Your turn!

1 Figure out CNF2 Use variable enumeration as in the following slide

Or trick with some hashmap, associative array, dictionary, ...3 Copy php.pl to rip.pl and modify accordingly

Or start with php.py if you like pythonic solutions!

4 Try it with MiniSat for some m,n

28 / 40

Page 83: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

RIP — Variable enumeration

x1,1,1 7→ 1...

xn,1,1 7→ nx1,2,1 7→ n + 1

...xn,2,1 7→ 2× n

...x1,n,1 7→ (n − 1)× n + 1

...xn,n,1 7→ n × n

x1,1,2 7→ n × n + 1...

x1,n,2 7→ n × n + (n − 1)× n + 1...

xn,n,2 7→ 2× n × n...

xn,n,m 7→ m × n × n

xi,j,k 7→ (k − 1)× n × n + (j − 1)× n + i

29 / 40

Page 84: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem

Queen Independence Problem — QIP(m,n)

Place m queens on an n × n chessboard so that they do notthreaten each other

Reminder: Queen moves

8 0Z0Z0Z0Z7 Z0Z0Z0Z06 0Z0Z0Z0Z5 Z0Z0Z0Z04 0Z0ZqZ0Z3 Z0Z0Z0Z02 0Z0Z0Z0Z1 Z0Z0Z0Z0

1 2 3 4 5 6 7 8

30 / 40

Page 85: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (1)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,4 1,3 1,2

1,1

2,1 3,1 4,12,4 2,3

2,2

3,2 4,23,4

3,3

4,3

4,4

31 / 40

Page 86: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (1)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,4 1,3

1,2 1,1

2,1 3,1 4,12,4

2,3 2,2

3,2 4,2

3,4 3,3

4,3

4,4

31 / 40

Page 87: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (1)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,4

1,3 1,2 1,1

2,1 3,1 4,1

2,4 2,3 2,2

3,2 4,2

3,4 3,3

4,3

4,4

31 / 40

Page 88: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (1)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,4 1,3 1,2 1,1

2,1 3,1 4,1

2,4 2,3 2,2

3,2 4,2

3,4 3,3

4,3

4,4

31 / 40

Page 89: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (1)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,4 1,3 1,2 1,1 2,1

3,1 4,1

2,4 2,3 2,2 3,2

4,2

3,4 3,3 4,34,4

31 / 40

Page 90: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (1)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,4 1,3 1,2 1,1 2,1 3,1

4,1

2,4 2,3 2,2 3,2 4,23,4 3,3 4,3

4,4

31 / 40

Page 91: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (1)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,4 1,3 1,2 1,1 2,1 3,1 4,12,4 2,3 2,2 3,2 4,2

3,4 3,3 4,34,4

31 / 40

Page 92: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (2)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,1 1,2 1,3

1,4

2,4 3,4 4,42,1 2,2

2,3

3,3 4,33,1

3,2

4,2

4,1

32 / 40

Page 93: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (2)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,1 1,2

1,3 1,4

2,4 3,4 4,42,1

2,2 2,3

3,3 4,3

3,1 3,2

4,2

4,1

32 / 40

Page 94: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (2)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,1

1,2 1,3 1,4

2,4 3,4 4,4

2,1 2,2 2,3

3,3 4,3

3,1 3,2

4,2

4,1

32 / 40

Page 95: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (2)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,1 1,2 1,3 1,4

2,4 3,4 4,4

2,1 2,2 2,3

3,3 4,3

3,1 3,2

4,2

4,1

32 / 40

Page 96: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (2)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,1 1,2 1,3 1,4 2,4

3,4 4,4

2,1 2,2 2,3 3,3

4,3

3,1 3,2 4,24,1

32 / 40

Page 97: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (2)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,1 1,2 1,3 1,4 2,4 3,4

4,4

2,1 2,2 2,3 3,3 4,33,1 3,2 4,2

4,1

32 / 40

Page 98: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Queen Independence Problem: Diagonals (2)

4 0Z0Z3 Z0Z02 0Z0Z1 Z0Z0

1 2 3 4

1,1 1,2 1,3 1,4 2,4 3,4 4,42,1 2,2 2,3 3,3 4,3

3,1 3,2 4,24,1

32 / 40

Page 99: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Homework (1)

1 Write a CNF formula generator for the BishopIndependence Problem

2 Write a CNF formula generator for the King IndependenceProblem

33 / 40

Page 100: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Homework (2)

Latin Square

http://mathworld.wolfram.com/LatinSquare.html

1 Model the Latin Square problemStart with a few examplesThen, work out a general formulaFinally, transform the formula in CNF

2 Write a CNF generator for Latin Square3 Test your CNF with a SAT solver!

34 / 40

Page 101: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Homework (2)

Latin Square

http://mathworld.wolfram.com/LatinSquare.html

1 Model the Latin Square problemStart with a few examplesThen, work out a general formulaFinally, transform the formula in CNF

2 Write a CNF generator for Latin Square

3 Test your CNF with a SAT solver!

34 / 40

Page 102: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Homework (2)

Latin Square

http://mathworld.wolfram.com/LatinSquare.html

1 Model the Latin Square problemStart with a few examplesThen, work out a general formulaFinally, transform the formula in CNF

2 Write a CNF generator for Latin Square3 Test your CNF with a SAT solver!

34 / 40

Page 103: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Homework (3)

1 Represent a 4× 4 Sudoku with 2× 2 squares using apropositional logic formula. This means that there is a4× 4 grid of fields, each of which should be filled withexactly one number between 1 and 4. The grid is dividedinto 4 non-overlapping regions of dimension 2× 2.

2 Generalize the formula for grids of n2 × n2 fields, into eachof which a number between 1 and n2 should be written.The grid is divided into n2 non-overlapping square regionsof dimension n × n. Here n is an arbitrary positive integer(so the previous example was a special case for n = 2).

35 / 40

Page 104: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Outline

1 DIMACS format

2 Setup and simple tests

3 Pigeon Hole Problem

4 Chess Piece Independence

5 Hardware correctness

36 / 40

Page 105: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Full Adder

Standard circuit

Alternative circuit

Full Adder Equivalence Problem

Do these two circuits implement the same functionality?

37 / 40

Page 106: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Full Adder

Standard circuit Alternative circuit

Full Adder Equivalence Problem

Do these two circuits implement the same functionality?

37 / 40

Page 107: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Full Adder

Standard circuit Alternative circuit

Full Adder Equivalence Problem

Do these two circuits implement the same functionality?

37 / 40

Page 108: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Homework (1)Represent the following Boolean circuit using a set of wffs:

Each component of the circuit has inputs at its left-hand side andoutput at its right-hand side. The output of a component is 1 if andonly if the sum of its inputs satisfies the condition written inside thecomponent; so if the sum of the inputs does not satisfy the condition,the output is 0. The inputs and outputs of the circuit (A, B, C, D, E, F)may have values 1 or 0. Bifurcations are indicated using a dot;crossing wires without a dot.The modelled formula must have models that correspond exactly tothe admissible input and output values of the circuit. 38 / 40

Page 109: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

Homework (2)

1 In the previous exercise, how can you find out whether thevalue of F can ever be 1 in an admissible state of thecircuit?

2 Whether the value of E can ever be equal to the value of A?3 Whether the value of F is 1 if and only if the value of D is 0?

39 / 40

Page 110: Propositional Logic Computer exercises€¦ · Propositional Logic Computer exercises Mario Alviano University of Calabria, Italy A.Y. 2017/2018 1/40

END OF THELECTURE

40 / 40