FORMULAS IN CONJUNCTIVE NORMAL PROPOSITIONAL ...fmv.jku.at/logic/lecture1.pdfPROPOSITIONAL LOGIC:...

Preview:

Citation preview

PROPOSITIONAL LOGIC:FORMULAS IN CONJUNCTIVE NORMALFORM (CNF)

VL Logic, Lecture 1, WS 20/21

Armin Biere, Martina Seidl

Institute for Formal Models and VerificationJohannes Kepler University Linz

A VERY, VERY SHORT PRIMER ON(PROPOSITIONAL) LOGIC

VL LogicPart I: Propositional Logic

Example: Party Planning

We want to plan a party.

Unfortunately, the selection of the guests is not straight forward.

We have to consider the following rules.

1. If two people are married, we have to invite them both or none of them. Alice is married toBob and Cecile is married to David.

2. If we invite Alice then we also have to invite Cecile.Cecile does not care if we invite Alice but not her.

3. David and Eva can’t stand each other, so it is not possible to invite both.

4. We want to invite Bob and Fred.

Question: Can we find a guest list?

1/8

Party Planning with Propositional Logic

� propositional variables:inviteAlice, inviteBob, inviteCecile, inviteDavid, inviteEva, inviteFred

� constraints:1. invite married: inviteAlice↔ inviteBob, inviteCecile↔ inviteDavid2. if Alice then Cecile: inviteAlice→ inviteCecile3. either David or Eva: ¬ (inviteEva↔ inviteDavid)4. invite Bob and Fred: inviteBob ∧ inviteFred

� encoding in propositional logic:

(inviteAlice↔ inviteBob) ∧ (inviteCecile↔ inviteDavid) ∧(inviteAlice→ inviteCecile) ∧ ¬ (inviteEva↔ inviteDavid) ∧inviteBob ∧ inviteFred

2/8

Defining a Language: Syntax

What do expressions (words, sentences) of a language look like?

� set of words: basic building blocks� grammar: rules for composing sentences from words and smaller sentences� sometimes multiple (equivalent) representations

� different goals (user-friendliness vs processability)

example:

� syntactically incorrect formula: ∧(a ∨ ∧b) ∧ (¬a ∨ ¬b)

� syntactically correct propositional formula (over variables a and b):(a ∨ b) ∧ (¬a ∨ ¬b)

� different representation:1 2 0

-1 -2 0

3/8

Defining a Language: Syntax

What do expressions (words, sentences) of a language look like?

� set of words: basic building blocks� grammar: rules for composing sentences from words and smaller sentences� sometimes multiple (equivalent) representations

� different goals (user-friendliness vs processability)

example:

� syntactically incorrect formula: ∧(a ∨ ∧b) ∧ (¬a ∨ ¬b)

� syntactically correct propositional formula (over variables a and b):(a ∨ b) ∧ (¬a ∨ ¬b)

� different representation:1 2 0

-1 -2 0

3/8

Defining a Language: Semantics

What do expressions mean?

� evaluation of syntactically correct expressions

� logic-based languages have a concise semantics� no ambiguities� no vagueness

Let propositional variable a be true and propositional variable b be false.Then the truth value of the propositional formula

(a ∨ b) ∧ (¬a ∨ ¬b)

is true.

4/8

Defining a Language: Semantics

What do expressions mean?

� evaluation of syntactically correct expressions

� logic-based languages have a concise semantics� no ambiguities� no vagueness

Let propositional variable a be true and propositional variable b be false.Then the truth value of the propositional formula

(a ∨ b) ∧ (¬a ∨ ¬b)

is true.

4/8

Using a Language: Pragmatics

What does an expression stand for?

� many application problems can be formulated as logical reasoning problems

� interpretation of expression dependends on context and user1. encoding of an application problem to be solved2. evaluation of expression gives solution for application problem

In the formula(a ∨ b) ∧ (¬a ∨ ¬b)

a could stand “invite David” and b could stand for “invite Eva”. The formula is true if onlyone of the two persons is invited.

5/8

Using a Language: Pragmatics

What does an expression stand for?

� many application problems can be formulated as logical reasoning problems

� interpretation of expression dependends on context and user1. encoding of an application problem to be solved2. evaluation of expression gives solution for application problem

In the formula(a ∨ b) ∧ (¬a ∨ ¬b)

a could stand “invite David” and b could stand for “invite Eva”. The formula is true if onlyone of the two persons is invited.

5/8

Automated Reasoning and Inferences

� Logical languages allow the inference of new knowledge (“reasoning”).

� For reasoning, a logic provides various sets of rules (calculi).

� Reasoning is often based on certain syntactical patterns.

example: (modus ponens)

x holds.If x holds, then also y holds.y holds.

6/8

Some Remarks on Inferences

A system is inconsistent if we can infer that a statement holds and that a statement does nothold at the same time.

Assume we have modelled the following system

� A comes to the party.

� B comes to the party.

� If A comes to the party, then B does not come to the party.

With the modus ponens, we can infer that B does not come to the party.So, we have some inconsistency in our party model.

7/8

Logics in this Lecture

In this lecture, we consider different logic-based languages:

� part 1: propositional logic (SAT)� simple language: only atoms and connectives� low expressiveness, low complexity

� part 2: first-order logic (predicate logic)� rich language: predicates, functions, terms, quantifiers� great power of expressiveness, high complexity

� part 3: satisfiability modulo theories (SMT)� customizable language: user decides� as much expressiveness as required

as much complexity as necessary

8/8

Logics in this Lecture

In this lecture, we consider different logic-based languages:

� part 1: propositional logic (SAT)� simple language: only atoms and connectives� low expressiveness, low complexity

� part 2: first-order logic (predicate logic)� rich language: predicates, functions, terms, quantifiers� great power of expressiveness, high complexity

� part 3: satisfiability modulo theories (SMT)� customizable language: user decides� as much expressiveness as required

as much complexity as necessary

8/8

Logics in this Lecture

In this lecture, we consider different logic-based languages:

� part 1: propositional logic (SAT)� simple language: only atoms and connectives� low expressiveness, low complexity

� part 2: first-order logic (predicate logic)� rich language: predicates, functions, terms, quantifiers� great power of expressiveness, high complexity

� part 3: satisfiability modulo theories (SMT)� customizable language: user decides� as much expressiveness as required

as much complexity as necessary

8/8

Logics in this Lecture

In this lecture, we consider different logic-based languages:

� part 1: propositional logic (SAT)� simple language: only atoms and connectives� low expressiveness, low complexity

� part 2: first-order logic (predicate logic)� rich language: predicates, functions, terms, quantifiers� great power of expressiveness, high complexity

� part 3: satisfiability modulo theories (SMT)� customizable language: user decides� as much expressiveness as required

as much complexity as necessary

8/8

SYNTAX OFPROPOSITIONAL FORMULAS IN CNF

VL LogicPart I: Propositional Logic

Truth Constants, Variables, Literals

� truth constant:� true (also verum, top): >� false (also falsum, bottom): ⊥

� propositional variable (also atom, atomic proposition):� proposition without any further internal structure� we denote variables by symbols x, y, z, a, b, c, p, q

(possibly with subscript)

� literal:� (negated) truth constant: >,⊥,¬>,¬⊥� (negated) propositional variable x,¬x, y,¬y, . . .� we denote literals by symbols l, k (possibly with subscript)

1/5

Truth Constants, Variables, Literals

� truth constant:� true (also verum, top): >� false (also falsum, bottom): ⊥

� propositional variable (also atom, atomic proposition):� proposition without any further internal structure� we denote variables by symbols x, y, z, a, b, c, p, q

(possibly with subscript)

� literal:� (negated) truth constant: >,⊥,¬>,¬⊥� (negated) propositional variable x,¬x, y,¬y, . . .� we denote literals by symbols l, k (possibly with subscript)

1/5

Truth Constants, Variables, Literals

� truth constant:� true (also verum, top): >� false (also falsum, bottom): ⊥

� propositional variable (also atom, atomic proposition):� proposition without any further internal structure� we denote variables by symbols x, y, z, a, b, c, p, q

(possibly with subscript)

� literal:� (negated) truth constant: >,⊥,¬>,¬⊥� (negated) propositional variable x,¬x, y,¬y, . . .� we denote literals by symbols l, k (possibly with subscript)

1/5

Clauses

A clause is a disjunction (∨) of literals.

� examples: x ∨ y x ∨ y ∨ ¬z ¬⊥ ∨ x ∨ a ∨ > ∨ ¬x

� size of a clause: number of its literals

� special clauses

empty clause (size 0): also written as ⊥ or ∅unary clause (size 1): ¬⊥ x ¬zbinary clauses (size 2): x ∨ yternary clauses (size 3): x ∨ y ∨ ¬z

� for (l1 ∨ . . . ∨ ln) we also write∨n

i=1 li

� we denote clauses by symbols C,D (possibly with subscript)

2/5

Clauses

A clause is a disjunction (∨) of literals.

� examples: x ∨ y x ∨ y ∨ ¬z ¬⊥ ∨ x ∨ a ∨ > ∨ ¬x

� size of a clause: number of its literals

� special clauses

empty clause (size 0): also written as ⊥ or ∅unary clause (size 1): ¬⊥ x ¬zbinary clauses (size 2): x ∨ yternary clauses (size 3): x ∨ y ∨ ¬z

� for (l1 ∨ . . . ∨ ln) we also write∨n

i=1 li

� we denote clauses by symbols C,D (possibly with subscript)

2/5

Clauses

A clause is a disjunction (∨) of literals.

� examples: x ∨ y x ∨ y ∨ ¬z ¬⊥ ∨ x ∨ a ∨ > ∨ ¬x

� size of a clause: number of its literals

� special clauses

empty clause (size 0): also written as ⊥ or ∅unary clause (size 1): ¬⊥ x ¬zbinary clauses (size 2): x ∨ yternary clauses (size 3): x ∨ y ∨ ¬z

� for (l1 ∨ . . . ∨ ln) we also write∨n

i=1 li

� we denote clauses by symbols C,D (possibly with subscript)

2/5

Clauses

A clause is a disjunction (∨) of literals.

� examples: x ∨ y x ∨ y ∨ ¬z ¬⊥ ∨ x ∨ a ∨ > ∨ ¬x

� size of a clause: number of its literals

� special clauses

empty clause (size 0): also written as ⊥ or ∅unary clause (size 1): ¬⊥ x ¬zbinary clauses (size 2): x ∨ yternary clauses (size 3): x ∨ y ∨ ¬z

� for (l1 ∨ . . . ∨ ln) we also write∨n

i=1 li

� we denote clauses by symbols C,D (possibly with subscript)

2/5

Clauses

A clause is a disjunction (∨) of literals.

� examples: x ∨ y x ∨ y ∨ ¬z ¬⊥ ∨ x ∨ a ∨ > ∨ ¬x

� size of a clause: number of its literals

� special clauses

empty clause (size 0): also written as ⊥ or ∅unary clause (size 1): ¬⊥ x ¬zbinary clauses (size 2): x ∨ yternary clauses (size 3): x ∨ y ∨ ¬z

� for (l1 ∨ . . . ∨ ln) we also write∨n

i=1 li

� we denote clauses by symbols C,D (possibly with subscript)

2/5

Clauses

A clause is a disjunction (∨) of literals.

� examples: x ∨ y x ∨ y ∨ ¬z ¬⊥ ∨ x ∨ a ∨ > ∨ ¬x

� size of a clause: number of its literals

� special clauses

empty clause (size 0): also written as ⊥ or ∅unary clause (size 1): ¬⊥ x ¬zbinary clauses (size 2): x ∨ yternary clauses (size 3): x ∨ y ∨ ¬z

� for (l1 ∨ . . . ∨ ln) we also write∨n

i=1 li

� we denote clauses by symbols C,D (possibly with subscript)

2/5

Propositional Formulas in CNF

A propositional formula in conjunctive normal form is a conjunction (∧) of clauses.

� examples:

� (x ∨ >) ∧ (y ∨ ¬z) ∧ (¬y ∨ ¬x)� (¬x ∨ y ∨ ¬z) ∧ z� (x ∨ ¬y) ∧ (x ∨ ¬y ∨ z) ∧ (y ∨ ¬z)� ((l11 ∨ . . . ∨ l1m1 ) ∧ . . . ∧ (ln1 ∨ . . . ∨ lnmn ))

� for (C1 ∧ . . . ∧Cn) we also write∧n

i=1 Ci.

� we denote formulas by symbols φ, ψ (possibly with subscript)

3/5

Propositional Formulas in CNF

A propositional formula in conjunctive normal form is a conjunction (∧) of clauses.

� examples:

� (x ∨ >) ∧ (y ∨ ¬z) ∧ (¬y ∨ ¬x)� (¬x ∨ y ∨ ¬z) ∧ z� (x ∨ ¬y) ∧ (x ∨ ¬y ∨ z) ∧ (y ∨ ¬z)� ((l11 ∨ . . . ∨ l1m1 ) ∧ . . . ∧ (ln1 ∨ . . . ∨ lnmn ))

� for (C1 ∧ . . . ∧Cn) we also write∧n

i=1 Ci.

� we denote formulas by symbols φ, ψ (possibly with subscript)

3/5

Propositional Formulas in CNF

A propositional formula in conjunctive normal form is a conjunction (∧) of clauses.

� examples:

� (x ∨ >) ∧ (y ∨ ¬z) ∧ (¬y ∨ ¬x)� (¬x ∨ y ∨ ¬z) ∧ z� (x ∨ ¬y) ∧ (x ∨ ¬y ∨ z) ∧ (y ∨ ¬z)� ((l11 ∨ . . . ∨ l1m1 ) ∧ . . . ∧ (ln1 ∨ . . . ∨ lnmn ))

� for (C1 ∧ . . . ∧Cn) we also write∧n

i=1 Ci.

� we denote formulas by symbols φ, ψ (possibly with subscript)

3/5

Propositional Formulas in CNF

A propositional formula in conjunctive normal form is a conjunction (∧) of clauses.

� examples:

� (x ∨ >) ∧ (y ∨ ¬z) ∧ (¬y ∨ ¬x)� (¬x ∨ y ∨ ¬z) ∧ z� (x ∨ ¬y) ∧ (x ∨ ¬y ∨ z) ∧ (y ∨ ¬z)� ((l11 ∨ . . . ∨ l1m1 ) ∧ . . . ∧ (ln1 ∨ . . . ∨ lnmn ))

� for (C1 ∧ . . . ∧Cn) we also write∧n

i=1 Ci.

� we denote formulas by symbols φ, ψ (possibly with subscript)

3/5

Alternative Notations

in the literature, different symbols might be used for building propositional formulas

in this lecture alternative notationstruth constant “true” > 1 t truetruth constant “false” ⊥ 0 f falsenegation ¬x !x x −x NOTxdisjunction k ∨ l l || k l + k l OR kconjunction C ∧ D C && D C ∗ D C AND D

4/5

Summary

We introduced a sublanguage of the language of propositional logic:propositional formulas in conjunctive normal form (CNF)

� formula in CNF: conjunction of clauses

� clause: disjunction of literals

� literal: (negated) variable / (negated) truth constant

Any propositional formula can be translated into CNF.

5/5

SEMANTICS OFPROPOSITIONAL FORMULAS IN CNF

VL LogicPart I: Propositional Logic

Truth Constants and Variables

� a variable can be assigned one of two values from the two-valued domain B, whereB = {1, 0}

� the mapping ν : P → B is called assignment, where P is the set of variables of a formula

� we sometimes write an assignment ν as set V with V ⊆ P ∪ {¬x | x ∈ P} such that� x ∈ V iff ν(x) = 1� ¬x ∈ V iff ν(x) = 0

� for n variables, there are 2n assignments possible

� > is always true and ⊥ is always false

1/11

Truth Constants and Variables

� a variable can be assigned one of two values from the two-valued domain B, whereB = {1, 0}

� the mapping ν : P → B is called assignment, where P is the set of variables of a formula

� we sometimes write an assignment ν as set V with V ⊆ P ∪ {¬x | x ∈ P} such that� x ∈ V iff ν(x) = 1� ¬x ∈ V iff ν(x) = 0

� for n variables, there are 2n assignments possible

� > is always true and ⊥ is always false

1/11

Truth Constants and Variables

� a variable can be assigned one of two values from the two-valued domain B, whereB = {1, 0}

� the mapping ν : P → B is called assignment, where P is the set of variables of a formula

� we sometimes write an assignment ν as set V with V ⊆ P ∪ {¬x | x ∈ P} such that� x ∈ V iff ν(x) = 1� ¬x ∈ V iff ν(x) = 0

� for n variables, there are 2n assignments possible

� > is always true and ⊥ is always false

1/11

Truth Constants and Variables

� a variable can be assigned one of two values from the two-valued domain B, whereB = {1, 0}

� the mapping ν : P → B is called assignment, where P is the set of variables of a formula

� we sometimes write an assignment ν as set V with V ⊆ P ∪ {¬x | x ∈ P} such that� x ∈ V iff ν(x) = 1� ¬x ∈ V iff ν(x) = 0

� for n variables, there are 2n assignments possible

� > is always true and ⊥ is always false

1/11

Truth Constants and Variables

� a variable can be assigned one of two values from the two-valued domain B, whereB = {1, 0}

� the mapping ν : P → B is called assignment, where P is the set of variables of a formula

� we sometimes write an assignment ν as set V with V ⊆ P ∪ {¬x | x ∈ P} such that� x ∈ V iff ν(x) = 1� ¬x ∈ V iff ν(x) = 0

� for n variables, there are 2n assignments possible

� > is always true and ⊥ is always false

1/11

Negation Operator

� unary connective ¬ (operator with exactly one operand)

� semantics: flipping the truth value of its operand (under a given assignment)

truth table:x ¬x0 11 0

examples:� ¬⊥ is true.

� ¬> is false.

� Given assignment ν and variable a with ν(a) = 1 then ¬a is false under ν.

� Given assignment ν and variable a with ν(a) = 0 then ¬a is true under ν.

2/11

Binary Disjunction Operator

� binary operator ∨ (operator with exactly two operands)

� semantics: true iff at least one operand is true

truth table:

l k l ∨ k0 0 00 1 11 0 11 1 1

examples:� (a ∨ ¬a) is always true.

� (> ∨ a) is always true.

� The truth value of (⊥ ∨ a) depends on the truth value of a.

3/11

Properties of Disjunction

� commutative: k ∨ l is true iff l ∨ k is true, i.e.,

k ∨ l and l ∨ k are equivalent : k ∨ l⇔ l ∨ k

� idempotent: l ∨ l is true iff l is true, i.e.,

l ∨ l and l are equivalent : l ∨ l⇔ l

� associative: l1 ∨ (l2 ∨ l3) is true iff (l1 ∨ l2) ∨ l3 is true, i.e.,

l1 ∨ (l2 ∨ l3) and (l1 ∨ l2) ∨ l3 are equivalent : l1 ∨ (l2 ∨ l3)⇔ (l1 ∨ l2) ∨ l3

clauses are also written as sets

� (l1 ∨ l2 ∨ . . . ∨ ln−1 ∨ ln) = {l1, l2, . . . , ln−1, ln}

� to add a literal l to clause C, we write C ∪ {l}

� to remove a literal l from clause C, we write C\{l}

4/11

Properties of Disjunction

� commutative: k ∨ l is true iff l ∨ k is true, i.e.,

k ∨ l and l ∨ k are equivalent : k ∨ l⇔ l ∨ k

� idempotent: l ∨ l is true iff l is true, i.e.,

l ∨ l and l are equivalent : l ∨ l⇔ l

� associative: l1 ∨ (l2 ∨ l3) is true iff (l1 ∨ l2) ∨ l3 is true, i.e.,

l1 ∨ (l2 ∨ l3) and (l1 ∨ l2) ∨ l3 are equivalent : l1 ∨ (l2 ∨ l3)⇔ (l1 ∨ l2) ∨ l3

clauses are also written as sets

� (l1 ∨ l2 ∨ . . . ∨ ln−1 ∨ ln) = {l1, l2, . . . , ln−1, ln}

� to add a literal l to clause C, we write C ∪ {l}

� to remove a literal l from clause C, we write C\{l}

4/11

Properties of Disjunction

� commutative: k ∨ l is true iff l ∨ k is true, i.e.,

k ∨ l and l ∨ k are equivalent : k ∨ l⇔ l ∨ k

� idempotent: l ∨ l is true iff l is true, i.e.,

l ∨ l and l are equivalent : l ∨ l⇔ l

� associative: l1 ∨ (l2 ∨ l3) is true iff (l1 ∨ l2) ∨ l3 is true, i.e.,

l1 ∨ (l2 ∨ l3) and (l1 ∨ l2) ∨ l3 are equivalent : l1 ∨ (l2 ∨ l3)⇔ (l1 ∨ l2) ∨ l3

clauses are also written as sets

� (l1 ∨ l2 ∨ . . . ∨ ln−1 ∨ ln) = {l1, l2, . . . , ln−1, ln}

� to add a literal l to clause C, we write C ∪ {l}

� to remove a literal l from clause C, we write C\{l}

4/11

Properties of Disjunction

� commutative: k ∨ l is true iff l ∨ k is true, i.e.,

k ∨ l and l ∨ k are equivalent : k ∨ l⇔ l ∨ k

� idempotent: l ∨ l is true iff l is true, i.e.,

l ∨ l and l are equivalent : l ∨ l⇔ l

� associative: l1 ∨ (l2 ∨ l3) is true iff (l1 ∨ l2) ∨ l3 is true, i.e.,

l1 ∨ (l2 ∨ l3) and (l1 ∨ l2) ∨ l3 are equivalent : l1 ∨ (l2 ∨ l3)⇔ (l1 ∨ l2) ∨ l3

clauses are also written as sets

� (l1 ∨ l2 ∨ . . . ∨ ln−1 ∨ ln) = {l1, l2, . . . , ln−1, ln}

� to add a literal l to clause C, we write C ∪ {l}

� to remove a literal l from clause C, we write C\{l}

4/11

Clause

� a clause is true iff at least one of the literals is true

truth table:

l1 . . . ln l1 ∨ l2 ∨ . . . ∨ ln0 . . . 0 00 . . . 1 1

. . . 11 . . . 0 11 . . . 1 1

� the empty clause is always false

5/11

Clause

� a clause is true iff at least one of the literals is true

truth table:

l1 . . . ln l1 ∨ l2 ∨ . . . ∨ ln0 . . . 0 00 . . . 1 1

. . . 11 . . . 0 11 . . . 1 1

� the empty clause is always false

5/11

Binary Conjunction Operator

� binary operator ∧ (operator with exactly two operands)

� semantics: a conjunction is true iff both operands are true

truth table:

C D C ∧ D0 0 00 1 01 0 01 1 1

examples:� (a ∧ ¬a) is always false.

� (> ∧ a) is true if a is true. (⊥ ∧ φ) is always false.

� If (a ∨ b) is true and (¬c ∨ d) is true then (a ∨ b) ∧ (¬c ∨ d) is true.

6/11

Properties of Conjunction

� commutative:C ∧ D⇔ D ∧C

� idempotent:C ∧C ⇔ C

� associative:C1 ∧ (C2 ∧C3)⇔ (C1 ∧C2) ∧C3

formulas in CNF are also written as sets of sets

� ((l11 ∨ . . . ∨ l1m1 ) ∧ . . . ∧ (ln1 ∨ . . . ∨ lnmn )) = {{l11, . . . l1m1 }, . . . , {ln1, . . . lnmn }}

� to add a clause C to CNF φ, we write φ ∪ {C}

� to remove a clause C from CNF φ, we write φ\{C}

7/11

Properties of Conjunction

� commutative:C ∧ D⇔ D ∧C

� idempotent:C ∧C ⇔ C

� associative:C1 ∧ (C2 ∧C3)⇔ (C1 ∧C2) ∧C3

formulas in CNF are also written as sets of sets

� ((l11 ∨ . . . ∨ l1m1 ) ∧ . . . ∧ (ln1 ∨ . . . ∨ lnmn )) = {{l11, . . . l1m1 }, . . . , {ln1, . . . lnmn }}

� to add a clause C to CNF φ, we write φ ∪ {C}

� to remove a clause C from CNF φ, we write φ\{C}

7/11

CNF Formulas

� a formula in CNF is true iff all of its clauses are true

truth table:

C1 . . . Cn C1 ∧C2 ∧ . . . ∧Cn

0 . . . 0 00 . . . 1 0

. . . 01 . . . 0 01 . . . 1 1

� the empty CNF formula is always true

8/11

CNF Formulas

� a formula in CNF is true iff all of its clauses are true

truth table:

C1 . . . Cn C1 ∧C2 ∧ . . . ∧Cn

0 . . . 0 00 . . . 1 0

. . . 01 . . . 0 01 . . . 1 1

� the empty CNF formula is always true

8/11

Truth Table: Example

the truth table of CNF formula (x ∨ y) ∧ ¬z:

x y z x ∨ y ¬z (x ∨ y) ∧ ¬z0 0 0 0 1 00 0 1 0 0 00 1 0 1 1 10 1 1 1 0 0

1 0 0 1 1 11 0 1 1 0 01 1 0 1 1 11 1 1 1 0 0

� one assignment: ν(x) = 1, ν(y) = 0, ν(z) = 0� alternative notation: V = {x,¬y,¬z}

9/11

Truth Table: Example

the truth table of CNF formula (x ∨ y) ∧ ¬z:

x y z x ∨ y ¬z (x ∨ y) ∧ ¬z0 0 0 0 1 00 0 1 0 0 00 1 0 1 1 10 1 1 1 0 0

→ 1 0 0 1 1 11 0 1 1 0 01 1 0 1 1 11 1 1 1 0 0

� one assignment: ν(x) = 1, ν(y) = 0, ν(z) = 0� alternative notation: V = {x,¬y,¬z}

9/11

Rules of Precedence

� ¬ binds stronger than ∧

� ∧ binds stronger than ∨

example:

� ¬a ∨ b ∧ ¬c ∨ d� is the same as (¬a) ∨ (b ∧ (¬c)) ∨ d,� but not as ((¬a) ∨ b) ∧ ((¬c) ∨ d)

⇒ put clauses into parentheses!

10/11

Rules of Precedence

� ¬ binds stronger than ∧

� ∧ binds stronger than ∨

example:

� ¬a ∨ b ∧ ¬c ∨ d� is the same as (¬a) ∨ (b ∧ (¬c)) ∨ d,� but not as ((¬a) ∨ b) ∧ ((¬c) ∨ d)

⇒ put clauses into parentheses!

10/11

Rules of Precedence

� ¬ binds stronger than ∧

� ∧ binds stronger than ∨

example:

� ¬a ∨ b ∧ ¬c ∨ d� is the same as (¬a) ∨ (b ∧ (¬c)) ∨ d,� but not as ((¬a) ∨ b) ∧ ((¬c) ∨ d)

⇒ put clauses into parentheses!

10/11

Semantics of Propositional Logic

Let P be a set of atoms and L be the set of all CNFs over P.

Given assignment ν : P → B, we define the interpretation function [.]ν : L → B by:

� [>]ν = 1, [⊥]ν = 0

� [x]ν = ν(x) (where x ∈ P, i.e., x is a variable)

� [¬p]ν = 1 iff [p]ν = 0 (where p ∈ P ∪ {>,⊥})

� [C]ν = 1 (where C is a clause) iffthere is at least one literal l with l ∈ C and [l]ν = 1

� [φ]ν = 1 (where φ is in CNF) ifffor all clauses C ∈ φ it holds that [C]ν = 1

11/11

SAT: THE SATISFIABLITY PROBLEM

VL LogicPart I: Propositional Logic

Satisfying/Falsifying Assignments

� an assignment ν is called� satisfying a formula φ iff [φ]ν = 1� falsifying a formula φ iff [φ]ν = 0

� a satisfying assignment for φ is a model of φ

� a falsifying assignment for φ is a counter-model of φ

example:

For formula ((x ∨ y) ∧ ¬z),

� {x, y, z} is a counter-model,

� {x, y,¬z} is a model.

1/5

Properties of Propositional Formulas (1/2)

� formula φ is satisfiable iffthere exists an assignment ν with [φ]ν = 1

� formula φ is valid ifffor all assignments ν it holds that [φ]ν = 1

� formula φ is refutable iffthere exists an assignment ν with [φ]ν = 0

� formula φ is unsatisfiable ifffor all assignments ν it holds that [φ]ν = 0

2/5

Properties of Propositional Formulas (2/2)

� a valid formula is called tautology

� an unsatisfiable formula is called contradiction

example:

� > is valid.

� a ∨ ¬a is a tautology.

� (a ∨ ¬b) ∧ (¬a ∨ b) is refutable.

� ⊥ is unsatisfiable.

� a ∧ ¬a is a contradiction.

� (a ∨ ¬b) ∧ (¬a ∨ b) is satisfiable.

3/5

SAT: The Boolean Satisfiability Problem

Given a propositional formula φ.Is there an assignment that satisfies φ?

formulation for formulas in CNF: can we find an assignment such that each clause containsat least one true literal?

4/5

SAT: The Boolean Satisfiability Problem

Given a propositional formula φ.Is there an assignment that satisfies φ?

formulation for formulas in CNF: can we find an assignment such that each clause containsat least one true literal?

4/5

Satisfiability Checking

� oldest NP-complete problem� checking a solution (does the assignment satisfies the formula?) is easy (polynomial effort)� finding a solution is difficult (probably exponential in the worst case)

� many practical applications (used in industry)

� efficient SAT solvers (solving tools) are available

5/5

THE SAT SOLVER LIMBOOLE

VL LogicPart I: Propositional Logic

SAT-Solver Limboole

� available at http://fmv.jku.at/limboole

� input:1

� variables are strings over letters, digits and – _ . [ ] $ @� negation symbol ¬ is !� disjunction symbol ∨ is |� conjunction symbol ∧ is &

example

(a ∨ b ∨ ¬c) ∧ (¬a ∨ b) ∧ c is represented as(a | b | !c) & (!a | b) & c

1For now, we will only use subset of the language supported by Limboole.

1/2

Tool Demo

2/2

Recommended