SlideShare une entreprise Scribd logo
1  sur  92
1
A brief introduction to Logic – part I
Logic
2018.11.03 cs at Unideb
2
A Brief Introduction to Logic - Outline
 Brief historical notes on logic
 Propositional Logic :Syntax
 Propositional Logic :Semantics
 Satisfiability and validity
 Modeling with Propositional logic
 Normal forms
 Deductive proofs and resolution
3
Historical view
 Philosophical Logic
 500 BC to 19th Century
 Symbolic Logic
 Mid to late 19th Century
 Mathematical Logic
 Late 19th
to mid 20th
Century
 Logic in Computer Science
4
Philosophical Logic
 500 B.C – 19th Century
 Logic dealt with arguments in the natural language
used by humans.
 Example
 All men are mortal.
 Socrates is a man
 Therefore, Socrates is mortal.
5
Philosophical Logic
 Natural languages are very ambiguous.
 Eric does not believe that Mary can pass any test.

...does not believe that she can pass some test, or

...does not believe that she can pass all tests
 I only borrowed your car.

And not ‘borrowed and used’, or

And not ‘car and coat’
 Tom hates Jim and he likes Mary.

Tom likes Mary, or

Jim likes Mary
 It led to many paradoxes.
 “This sentence is a lie.” (The Liar’s Paradox)
6
Sophism
(From Wikipedia)
 ... Sophism generally refers to a particularly
confusing, illogical and/or insincere argument
used by someone to make a point, or, perhaps,
not to make a point.
 Sophistry refers to [...] rhetoric that is designed
to appeal to the listener on grounds other than
the strict logical cogency of the statements
being made.
7
The Sophist’s Paradox
 A Sophist is sued for his tuition by the school that
educated him. He argues that he must win, since, if
he loses, the school didn’t educate him well enough,
and doesn’t deserve the money.
 The school argues that he must lose, since, if he wins,
he was educated well enough, and therefore should
pay for it.
8
Logic in Computer Science
 Logic has a profound impact on computer-science.
Some examples:
 Propositional logic – the foundation of computers and
circuitry
 Databases – query languages
 Programming languages (e.g. prolog)
 Design Validation and verification
 AI (e.g. inference systems)
 ...
9
Logic in Computer Science
 Propositional Logic
 First Order Logic
 Higher Order Logic
 Temporal Logic
 ...
 ...
10
Propositional logic
 A proposition – a sentence that can be either true or
false.
 Propositions:
 x is greater than y
 Noam wrote this letter
11
Propositional logic: Syntax
 The symbols of the language:
 Propositional symbols (Prop): A, B, C,…
 Connectives:

∧ and

∨ or

¬ not

→ implies

↔ equivalent to

© xor (different than)

⊥, > False, True
 Parenthesis:(, ).
 Q1: how many different binary symbols can we define ?
 Q2: what is the minimal number of such symbols?
12
Formulas
 Grammar of well-formed propositional formulas
 Formula := prop | (¬Formula) | (Formula o Formula).
 ... where prop 2 Prop and o is one of the binary relations
13
Formulas
 Examples of well-formed formulas:
 (¬A)
 (¬(¬A))
 (A ∧ (B ∧ C))
 (A→ (B→ C))
 Correct expressions of Propositional Logic are full of
unnecessary parenthesis.
14
Formulas
 Abbreviations. We write
A o B o C o …
 in place of
(A o (B o (C o …)))
 Thus, we write
A ∧ B ∧ C, A→B→C, …
 in place of
(A ∧ (B ∧ C)), (A→ (B→ C))
15
Formulas
 We omit parenthesis whenever we may restore them
through operator precedence:
 ¬ binds more strictly than ∧, ∨, and ∧, ∨ bind more
strictly than →, ↔.
 Thus, we write:
¬¬A for (¬(¬A)),
¬A∧B for ((¬A)∧B)
A∧B→ C for ((A∧B) → C), …
16
Propositional Logic: Semantics
 Truth tables define the semantics (=meaning) of the
operators
 Convention: 0 = false, 1 = true
p q p Æ q p Ç q p ! q
0 0 0 0 1
0 1 0 1 1
1 0 0 1 0
1 1 1 1 1
17
Propositional Logic: Semantics
 Truth tables define the semantics (=meaning) of the
operators
p q :p p $ q p © q
0 0 1 1 0
0 1 1 0 1
1 0 0 0 1
1 1 0 1 0
18
Back to Q1
 Q1: How many binary operators can we define that
have different semantic definition ?
 A: 16
19
Assignments
 Definition: A truth-values assignment, α, is an
element of 2Prop
(i.e., α ∈ 2Prop
).
 In other words, ® is a subset of the variables that are
assigned true.
 Equivalently, we can see ® as a mapping from
variables to truth values:
α : Prop  {0,1}
 Example: ®: {A  0, B  1,...}
20
Satisfaction relation (²): intuition
 An assignment can either satisfy or not satisfy a
given formula.
 α ² φ means
 α satisfies φ or

φ holds at α or
 α is a model of φ
 We will first see an example.
 Then we will define these notions formally.
21
Example
 Let Á = (A Ç (B → C))
 Let ® = {A  0, B  0, C  1}
 Q: Does ® satisfy Á?
 (in symbols: does it hold that ® ² Á ? )
 A: (0 Ç (0 → 1)) = (0 Ç 1) = 1
 Hence, ® ² Á.
 Let us now formalize an evaluation process.
22
The satisfaction relation (²): formalities
 ² is a relation: ² µ (2Prop
x Formula)
 Examples:

({a}, a Ç b) // the assignment ® = {a} satisfies a Ç b

({a,b}, a Æ b)
 Alternatively: ² µ ({0,1}Prop
£ Formula)
 Examples:

(01, a Ç b) // the assignment ® = {a  0, b  1} satisfies a Ç b

(11, a Æ b)
23
The satisfaction relation (²): formalities
 ² is defined recursively:
 α ² p if α (p) = true
 α ² ¬φ if α 2 φ.
 α ² φ1 ∧ φ2 if α ² φ1 and α ² φ2
 α ² φ1 ∨ φ2 if α ² φ1 or α ² φ2
 α ² φ
1
→ φ2 if α ² φ1 implies α ² φ2
 α ² φ
1
↔ φ2 if α ² φ1 iff α ² φ2
24
From definition to an evaluation algorithm
 Truth Evaluation Problem
 Given φ ∈ Formula and α∈ 2AP(φ)
, does α ² φ ?
Eval(φ, α){
If φ ≡ A, return α(A).
If φ ≡ (¬φ1) return ¬Eval(φ1, α))
If φ ≡ (φ1 o φ2)
return Eval(φ1, α) o Eval(φ2, α)
}
 Eval uses polynomial time and space.
25
It doesn’t give us more than what we already know...
 Recall our example
 Let Á = (A Ç (B → C))
 Let ® = {A  0, B  0, C  1}
 Eval(Á,®) = Eval(A,α) Ç Eval(B → C,α) =
0 Ç Eval(B,α) → Eval(C,α) =
0 Ç (0 → 1) = 0 Ç 1 = 1
 Hence, ® ² Á.
26
We can now extend the truth table to formulas
p q (p → (q → p)) (p Æ
:p)
p Ç :q
0 0 1 0 1
0 1 1 0 0
1 0 1 0 1
1 1 1 0 1
27
0111
1011
1101
1001
1
0
1
0
x3
110
110
100
100
x1 → (x2 → :x3)x2x1
We can now extend the truth table to formulas
28
Set of assignments
 Intuition: a formula specifies a set of truth
assignments.
 Function models: Formula  22Prop
(a formula  set of satisfying assignments)
 Recursive definition:
 models(A) = {α |α(A) = 1}, A ∈ Prop
 models(¬φ1) = 2Prop
– models(φ1)
 models(φ1∧φ2) = models(φ1) ∩ models(φ2)
 models(φ1∨φ2) = models(φ1) ∪ models(φ2)
 models(φ1→φ2) = (2Prop
– models(φ1)) ∪ models(φ2)
29
Example
 models (A Ç B) = {{10},{01},{11}}
 This is compatible with the recursive definition:
models(A Ç B) =
models(A) [ models (B) =
{{10},{11}} [ {{01},{11}} =
{{10},{01},{11}}
30
Theorem
 Let φ ∈ Formula and α ∈ 2Prop
, then the following
statements are equivalent:
1. α ² φ
2. α ∈ models(φ)
31
Only the projected assignment matters...
 AP(φ) – the Atomic Propositions in φ.
 Clearly AP(φ) µ Prop.
 Let α1, α2 ∈ 2Prop
, φ ∈ Formula.
 Lemma: if α1|AP(φ)= α2|AP(φ) , then
α1² φ iff α2 ² φ
Corollary: α ² φ iff α|AP(φ)² φ
 We will assume, for simplicity, that Prop = AP(φ).
Projection
32
Extension of ²to sets of assignments
 Let φ2 Formula
 Let T be a set of assignments, i.e., T ⊆ 22Prop
 Definition.
T ² φ if T ⊆ models(φ)

i.e., ² ⊆ 22Prop
£ Formula
33
Extension of ² to formulas
 ² ⊆ 2Formula
£ 2Formula
 Definition. Let Γ1, Γ2be prop. formulas.
Γ1 ² Γ2
iff models(Γ1) ⊆ models(Γ2)
iff for all α ∈ 2Prop
if α ² Γ1 then α ² Γ2
Examples:
x1 Æ x2 ² x1 Ç x2
x1 Æ x2 ² x2 Ç x3
34
Semantic Classification of formulas
 A formula φ is called valid if models(φ) = 2Prop
.
(also called a tautology).
 A formula φ is called satisfiable if models(φ) ≠ ;.
 A formula φ is called unsatisfiable if models(φ) = ;.
(also called a contradiction).
unsatisfiable
satisfiable
valid
35
Validity, satisfiability... in truth tables
p q (p → (q → q)) (p Æ
:p)
p Ç :q
0 0 1 0 1
0 1 1 0 0
1 0 1 0 1
1 1 1 0 1
36
Characteristics of valid/sat. formulas...
 Lemma
 A formula φ is valid iff ¬φ is unsatisfiable
 φ is satisfiable iff ¬φ is not valid
Satisfiability
checker
Is φ valid?
yes
no
?
37
Look what we can do now...
 We can write:
 ² Á when Á is valid
 2 Á when Á is not valid
 2 :Á when Á is satisfiable
 ² :Á when Á is unsatisfiable
38
Examples
 (x1 Æ x2) → (x1 Ç x2) is
 (x1 Ç x2) → x1 is
 (x1 Æ x2) Æ :x1 is
valid
satisfiable
unsatisfiable
39
Time for equivalences
 Here are some valid formulas:
 ² A Æ 1 $ A
 ² A Æ 0 $ 0
 ² ::A $ A // The double-negation rule
 ² A Æ (B Ç C) $ (A Æ B) Ç (A Æ C)
 Some more (De-Morgan rules):
 ² :(A Æ B) $ (:A Ç :B)
 ²:(A Ç B) $ (:A Æ :B)
40
A minimal set of binary operators
 Recall the question: what is the minimal set of
operators necessary?
 A: Through such equivalences all Boolean operators
can be written with a single operator (NAND).
 Indeed, typically industrial circuits only use one type of
logical gate
 We’ll see how two are enough: : and Æ
 Or: ² (A Ç B) $ :(:A Æ :B)
 Implies: ² (A → B) $ (:A Ç B)
 Equivalence: ² (A $B) $(A → B) Æ (B → A)
 ...
41
The decision problem of formulas
 The decision problem:
Given a propositional formula Á, is Á satisfiable ?
 An algorithm that always terminates with a correct
answer to this problem is called a decision
procedure for propositional logic.
42
A Brief Introduction to Logic - Outline
 Brief historical notes on logic
 Propositional Logic :Syntax
 Propositional Logic :Semantics
 Satisfiability and validity
 Modeling with Propositional logic
 Normal forms
 Deductive proofs and resolution
43
Before we solve this problem...
 Q: Suppose we can solve the satisfiability problem...
how can this help us?
 A: There are numerous problems in the industry that
are solved via the satisfiability problem of
propositional logic
 Logistics...
 Planning...
 Electronic Design Automation industry...
 Cryptography...
 ... (every NP-P problem...)
46
Example 2: placement of wedding guests
 Three chairs in a row: 1,2,3
 We need to place Aunt, Sister and Father.
 Constraints:
 Aunt doesn’t want to sit near Father
 Aunt doesn’t want to sit in the left chair
 Sister doesn’t want to sit to the right of Father
 Q: Can we satisfy these constraints?
47
Example 2 (cont’d)
 Denote: Aunt = 1, Sister = 2, Father = 3
 Introduce a propositional variable for each pair
(person, place).
 xij = person i is sited in place j, for 1 ·i,j · 3
 Constraints:
 Aunt doesn’t want to sit near Father:
((x1,1 Ç x1,3) → :x3,2) Æ(x1,2 → (:x3,1 Æ :x3,3))
 Aunt doesn’t want to sit in the left chair
:x1,1
 Sister doesn’t want to sit to the right of Father
x3,1→ :x2,2 Æ x3,2 → :x2,3
48
Example 2 (cont’d)
 More constraints:
 Each person is placed:
(x1,1 Ç x1,2 Ç x1,3) Æ
(x2,1 Ç x2,2 Ç x2,3) Æ
(x3,1 Ç x3,2 Ç x3,3)
 Or, more concisely:
 Not more than one person per chair:
 Overall 9 variables, 23 conjoined constraints.
49
Example 3: assignment of frequencies
 n radio stations
 For each assign one of k transmission frequencies, k < n.
 E -- set of pairs of stations, that are too close to have the
same frequency.
 Q: which graph problem does this remind you of ?
50
Example 3 (cont’d)
 xi,j – station i is assigned frequency j, for 1 · i · n, 1
· j · k.
 Every station is assigned at least one frequency:
 Every station is assigned not more than one frequency:
 Close stations are not assigned the same frequency.
For each (i,j) 2 E,
51
Two classes of algorithms for validity
 Q: Is φ satisfiable (/:φ is valid) ?
 Complexity: NP-Complete (the first-ever! – Cook’s
theorem)
 Two classes of algorithms for finding out:
1. Enumeration of possible solutions (Truth tables etc).
2. Deduction
 More generally (beyond propositional logic):
 Enumeration is possible only in some logics.
 Deduction cannot necessarily be fully automated.
52
The satisfiability problem: enumeration
 Given a formula φ, is φ satisfiable?
Boolean SAT(φ) {
B:=false
for all α ∈ 2AP(φ)
B = B ∨ Eval(φ,α)
end
return B
}
 There must be a better way to do that in practice.
53
A Brief Introduction to Logic - Outline
 Brief historical notes on logic
 Propositional Logic :Syntax
 Propositional Logic :Semantics
 Satisfiability and validity
 Modeling with Propositional logic
 Normal forms
 Deductive proofs and resolution
54
Definitions…
 Definition: A literal is either an atom or a negation of
an atom.
 Let φ = :(A Ç :B). Then:
 Atoms: AP(φ) = {A,B}
 Literals: lit(φ) = {A, :B}
 Equivalent formulas can have different literals
 φ = :(A Ç :B) = :A Æ B
 Now lit(φ) = {:A, B}
55
Definitions…
 Definition: a term is a conjunction of literals
 Example: (A Æ :B Æ C)
 Definition: a clause is a disjunction of literals
 Example: (A Ç :B Ç C)
56
Negation Normal Form (NNF)
 Definition: A formula is said to be in Negation
Normal Form (NNF) if it only contains :, Æ and Ç
connectives and only atoms can be negated.
 Examples:
 φ1 = :(A Ç :B) is not in NNF
 φ2 = :A Æ B is in NNF
57
Converting to NNF
 Every formula can be converted to NNF in linear
time:
 Eliminate all connectives other than Æ, Ç, :
 Use De Morgan and double-negation rules to push
negations to the right
 Example: φ = :(A ! :B)
 Eliminate ‘!’: φ = :(:A Ç :B)
 Push negation using De Morgan: φ = (::A Æ ::B)
 Use Double negation rule: φ = (A Æ B)
58
Disjunctive Normal Form (DNF)
 Definition: A formula is said to be in Disjunctive
Normal Form (DNF) if it is a disjunction of terms.
 In other words, it is a formula of the form
where li,jis the j-th literal in the i-th term.
 Examples
 φ = (A Æ :B Æ C) Ç (:A Æ D) Ç (B) is in
DNF
 DNF is a special case of NNF
59
Converting to DNF
 Every formula can be converted to DNF in
exponential time and space:
 Convert to NNF
 Distribute disjunctions following the rule:
² A Æ (B Ç C) $ ((A Æ B) Ç (A Æ C))
 Example:
 φ = (A Ç B) Æ (:C Ç D) =
((A Ç B) Æ (:C)) Ç ((A Ç B) Æ D) =
(A Æ :C) Ç (B Æ :C) Ç (A Æ D) Ç (B Æ D)
 Q: how many clauses would the DNF have had we started
from a conjunction of n clauses ?
60
Satisfiability of DNF
 Is the following DNF formula satisfiable?
(x1 Æ x2 Æ :x1) Ç (x2 Æ x1) Ç (x2 Æ :x3 Æ x3)
 What is the complexity of satisfiability of DNF
formulas?
61
Conjunctive Normal Form (CNF)
 Definition: A formula is said to be in Conjunctive
Normal Form (CNF) if it is a conjunction of clauses.
 In other words, it is a formula of the form
where li,jis the j-th literal in the i-th term.
 Examples
 φ = (A Ç :B Ç C) Æ (:A Ç D) Æ (B) is in
CNF
 CNF is a special case of NNF
62
Converting to CNF
 Every formula can be converted to CNF:
 in exponential time and space with the same set of atoms
 in linear time and space if new variables are added.

In this case the original and converted formulas are “equi-
satisfiable”.

This technique is called Tseitin’s encoding.
63
Converting to CNF: the exponential way
CNF(φ) {
case
φ is a literal: return φ
φ is ψ1 Æ ψ2: return CNF(ψ1) Æ CNF(ψ2)
φ is ψ1 Ç ψ2: return Dist(CNF(ψ1),CNF(ψ2))
}
Dist(ψ1,ψ2) {
case
ψ1 is φ11 Æ φ12: return Dist(φ11,ψ2) Æ Dist(ψ12,ψ2)
ψ2 is φ21 Æ φ22: return Dist(ψ1,φ21) Æ Dist(ψ1,φ22)
else: return ψ1 Ç ψ2
64
Converting to CNF: the exponential way
 Consider the formula
φ = (x1 Æ y1) Ç (x2 Æ y2)
 CNF(φ)=
(x1 Ç x2) Æ
(x1 Ç y2) Æ
(y1 Ç x2) Æ
(y1 Ç y2)
 Now consider: φn = (x1 Æ y1) Ç (x2 Æ y2) Ç  Ç (xn Æ yn)
 Q: How many clauses CNF(φ) returns ?
 A: 2n
65
Converting to CNF: Tseitin’s encoding
 Consider the formula φ = (A ! (B Æ C))
 The parse tree:
 Associate a new auxiliary variable with each gate.
 Add constraints that define these new variables.
 Finally, enforce the root node.
A Æ
B C
! a1
a2
66
Converting to CNF: Tseitin’s encoding
 Need to satisfy:
(a1 $ (A ! a2)) Æ
(a2 $ (B Æ C)) Æ
(a1)
 Each such constraint has a CNF representation with 3
or 4 clauses.
A Æ
B C
! a1
a2
67
Converting to CNF: Tseitin’s encoding
 Need to satisfy:
(a1 $ (A ! a2)) Æ
(a2 $ (B Æ C)) Æ
(a1)
 First: (a1 Ç A) Æ (a1 Ç :a2) Æ (:a1 Ç :A Ç a2)
 Second: (:a2 Ç B) Æ (:a2 Ç C) Æ (a2 Ç :B Ç :C)
68
Converting to CNF: Tseitin’s encoding
 Let’s go back to
φn = (x1 Æ y1) Ç (x2 Æ y2) Ç  Ç (xn Æ yn)
 With Tseitin’s encoding we need:
 n auxiliary variables a1,…,an.
 Each adds 3 constraints.
 Top clause: (a1 Ç  Ç an)
 Hence, we have
 3n + 1 clauses, instead of 2n
.
 3n variables rather than 2n.
69
What now?
 Time to solve the decision problem for propositional
logic.
 The only algorithm we saw so far was building truth tables.
70
Two classes of algorithms for validity
 Q: Is φ valid ?
 Equivalently: is :φ satisfiable?
 Two classes of algorithm for finding out:
1. Enumeration of possible solutions (Truth tables etc).
2. Deduction
 In general (beyond propositional logic):
 Enumeration is possible only in some theories.
 Deduction typically cannot be fully automated.
71
The satisfiability Problem: enumeration
 Given a formula φ, is φ satisfiable?
Boolean SAT(φ) {
B:=false
for all α ∈ 2AP(φ)
B = B ∨ Eval(φ,α)
end
return B
}
 NP-Complete (the first-ever! – Cook’s theorem)
72
A Brief Introduction to Logic - Outline
 Brief historical notes on logic
 Propositional Logic :Syntax
 Propositional Logic :Semantics
 Satisfiability and validity
 Modeling with Propositional logic
 Normal forms
 Deductive proofs and resolution
73
Deduction requires axioms and Inference rules
 Inference rules:
Antecedents
Consequent
 Examples:
A ! B B ! C
A ! C
A ! B A
B
)rule-name(
)trans(
)M.P.(
74
Axioms
 Axioms are inference rules with no antecedents, e.g.,
 We can turn an inference rule into an axiom if we
have ‘→’ in the logic.
 So the difference between them is not sharp.
)H1(
A ! )B ! A(
75
Proofs
 A proof uses a given set of inference rules and axioms.
 This is called the proof system.
 Let H be a proof system.
 Γ `H φ means: there is a proof of φ in system H whose
premises are included in Γ
 `His called the provability relation.
76
Example
 Let H be the proof system comprised of the rules
Trans and M.P. that we saw earlier.
 Does the following relation holds?
a ! b,b ! c, c ! d, d ! e, a `H e
77
Deductive proof: example
1. a ! b premise
2. b ! c premise
3. a ! c 1,2,Trans
4. c ! d premise
5. d ! e premise
6. c ! e 4,5, Trans
7. a ! e 3,6, Trans
8. a premise
9. e 7,8.M.P.
a ! b, b ! c, c ! d, d ! e, a `H e
78
Proof graph (DAG)
a ! b b ! c c ! d d ! e
a ! c c ! e
a ! e
a
e
)trans(
)trans(
)trans(
)M.P.(
Roots: premises
79
Proofs
 The problem: ` is a relation defined by syntactic
transformations of the underlying proof system.
 For a given proof system H,
 does ` conclude “correct” conclusions from premises ?
 Can we conclude all true statements with H?
 Correct with respect to what ?
 With respect to the semantic definition of the logic. In the
case of propositional logic truth tables gives us this.
80
Soundness and completeness
 Let Hbe a proof system
 Soundness of H: if `H φ then ² φ
 Completeness of H : if ²φ then `H φ
 How to prove soundness and completeness ?
81
Soundness and completeness of procedures
 The definitions so far referred to proof systems
 What does soundness and completeness mean for
general decision algorithms ?
82
Soundness and Completeness
 Definition [soundness]: A procedure for the decision
problem is sound if
 when it returns “Valid”...
 ... the input formula is valid.
 Definition [completeness]: A procedure for the
decision problem is complete if
 it always terminates, and
 it returns “Valid” when the input formula is valid.
83
Decidability
 Definition [decidability]
A logic is decidable if there is a sound and complete
algorithm that decides if a well-formed expression in
this logic is valid.
84
Soundness and Completeness
 Soundness: “when I say that it rains, it rains”
 Completeness: “If asked, I always reply (in a finite
time…). When it rains, I say that it rains”
85
Soundness and Completeness (cont’d)
 Algorithm #1: for checking if it rains outside:
“stand right outside the door and say ‘it rains’”
 It is not sound because you might say it rains when it doesn’t.
 But it is complete: you always get an answer in a finite time,
and when it rains you say it rains.
86
Soundness and Completeness (cont’d)
 Algorithm #2 for checking if it rains outside:
“stand right outside the door and say ‘it rains’ if and only if
you feel the rain”
 It is sound because you say it rains only if it actually rains.
 It is incomplete because you do not say anything if it doesn’t
rain (we do not know whether it doesn’t rain, or it takes the
person too long to answer…).
87
Soundness and Completeness (cont’d)
 Algorithm #2 for checking if it rains outside:
“stand right outside the door and say ‘it rains’ if and only if
you feel the rain, after a second”
 It is sound because you say it rains only if it actually rains.
 It is complete.
88
 Now let’s go back to proof systems...
89
Example: Hilbert axiom system (H)
 Let H be (M.P) + the following axiom schemas:
(H1)
A ! (B ! A)
(H2)
((A !(B ! C)) !((A! B)!(A! C))
(H3)
(:B !:A) !(A ! B)
 H is sound and complete
90
Soundness and completeness
 To prove soundness of H, prove the soundness of its axioms
and inference rules (easy with truth-tables). For example:
 Completeness – harder, but possible.
A B A ! (B ! A)
0 0 1
0 1 1
1 0 1
1 1 1
91
The resolution inference system
 The resolution inference rule for CNF:
 Example:
92
Proof by resolution
 Let ϕ = (1 3) Æ (-1 2 5) Æ (-1 4) Æ (-1 -4) Æ(1 -2)
 We’ll try to prove ϕ → (3 5)
)13( -)125(
(2 3 5) (1 -2)
(1 3 5)
(-1 4) (-1 -4)
(-1)
(3 5)
93
Resolution
 Resolution is a sound and complete inference system
for CNF
 If the input formula is unsatisfiable, there exists a
proof of the empty clause
94
Example
 Let ϕ = (1 3) Æ (-1 2) Æ (-1 4) Æ (-1 -4) Æ (1 -2) Æ(-3)
)13( (-1 2)
(2 3) (1 -2)
(1 3)
(-1 4) (-1 -4)
(-1)
(3) (-3)
()

Contenu connexe

Tendances

Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computation
prasadmvreddy
 
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
taimoor iftikhar
 
Algorithm chapter 1
Algorithm chapter 1Algorithm chapter 1
Algorithm chapter 1
chidabdu
 

Tendances (20)

AI-09 Logic in AI
AI-09 Logic in AIAI-09 Logic in AI
AI-09 Logic in AI
 
First Order Logic resolution
First Order Logic resolutionFirst Order Logic resolution
First Order Logic resolution
 
Recurrence relation
Recurrence relationRecurrence relation
Recurrence relation
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
Text Similarity
Text SimilarityText Similarity
Text Similarity
 
Fuzzy logic Notes AI CSE 8th Sem
Fuzzy logic Notes AI CSE 8th SemFuzzy logic Notes AI CSE 8th Sem
Fuzzy logic Notes AI CSE 8th Sem
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computation
 
Grammar
GrammarGrammar
Grammar
 
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
 
Chapter1p1
Chapter1p1Chapter1p1
Chapter1p1
 
AI PPT-ALR_Unit-3-1.pdf
AI PPT-ALR_Unit-3-1.pdfAI PPT-ALR_Unit-3-1.pdf
AI PPT-ALR_Unit-3-1.pdf
 
First order logic
First order logicFirst order logic
First order logic
 
Unit I discrete mathematics lecture notes
Unit I  discrete mathematics lecture notesUnit I  discrete mathematics lecture notes
Unit I discrete mathematics lecture notes
 
First order predicate logic (fopl)
First order predicate logic (fopl)First order predicate logic (fopl)
First order predicate logic (fopl)
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
First order logic
First order logicFirst order logic
First order logic
 
Regular expression to NFA (Nondeterministic Finite Automata)
Regular expression to NFA (Nondeterministic Finite Automata)Regular expression to NFA (Nondeterministic Finite Automata)
Regular expression to NFA (Nondeterministic Finite Automata)
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
 
NLP_KASHK:POS Tagging
NLP_KASHK:POS TaggingNLP_KASHK:POS Tagging
NLP_KASHK:POS Tagging
 
Algorithm chapter 1
Algorithm chapter 1Algorithm chapter 1
Algorithm chapter 1
 

Similaire à C2.0 propositional logic

Discrete Mathematics - All chapters
Discrete Mathematics - All chapters Discrete Mathematics - All chapters
Discrete Mathematics - All chapters
Omnia A. Abdullah
 
Boolean Programs and Quantified Propositional Proof System -
Boolean Programs and Quantified Propositional Proof System - Boolean Programs and Quantified Propositional Proof System -
Boolean Programs and Quantified Propositional Proof System -
Michael Soltys
 
Poggi analytics - star - 1a
Poggi   analytics - star - 1aPoggi   analytics - star - 1a
Poggi analytics - star - 1a
Gaston Liberman
 

Similaire à C2.0 propositional logic (20)

Discrete Mathematics - All chapters
Discrete Mathematics - All chapters Discrete Mathematics - All chapters
Discrete Mathematics - All chapters
 
Boolean Programs and Quantified Propositional Proof System -
Boolean Programs and Quantified Propositional Proof System - Boolean Programs and Quantified Propositional Proof System -
Boolean Programs and Quantified Propositional Proof System -
 
dma_ppt.pdf
dma_ppt.pdfdma_ppt.pdf
dma_ppt.pdf
 
Stochastic Processes Homework Help
Stochastic Processes Homework HelpStochastic Processes Homework Help
Stochastic Processes Homework Help
 
Discrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order LogicDiscrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order Logic
 
Algorithmic foundations.docx
Algorithmic foundations.docxAlgorithmic foundations.docx
Algorithmic foundations.docx
 
Probability Cheatsheet.pdf
Probability Cheatsheet.pdfProbability Cheatsheet.pdf
Probability Cheatsheet.pdf
 
P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2
 
Math Assignment Help
Math Assignment HelpMath Assignment Help
Math Assignment Help
 
The Chase in Database Theory
The Chase in Database TheoryThe Chase in Database Theory
The Chase in Database Theory
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
2015 CMS Winter Meeting Poster
2015 CMS Winter Meeting Poster2015 CMS Winter Meeting Poster
2015 CMS Winter Meeting Poster
 
Probability cheatsheet
Probability cheatsheetProbability cheatsheet
Probability cheatsheet
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment Help
 
Probability theory
Probability theoryProbability theory
Probability theory
 
Graph Methods for Generating Test Cases with Universal and Existential Constr...
Graph Methods for Generating Test Cases with Universal and Existential Constr...Graph Methods for Generating Test Cases with Universal and Existential Constr...
Graph Methods for Generating Test Cases with Universal and Existential Constr...
 
Lemh1a1
Lemh1a1Lemh1a1
Lemh1a1
 
Lemh1a1
Lemh1a1Lemh1a1
Lemh1a1
 
Poggi analytics - star - 1a
Poggi   analytics - star - 1aPoggi   analytics - star - 1a
Poggi analytics - star - 1a
 
AI Lesson 15
AI Lesson 15AI Lesson 15
AI Lesson 15
 

Plus de Melaku Bayih Demessie

Plus de Melaku Bayih Demessie (10)

Chapter 4 computer network and the internet2
Chapter 4 computer network and the internet2Chapter 4 computer network and the internet2
Chapter 4 computer network and the internet2
 
Introduction to Cloud computing
Introduction to Cloud computingIntroduction to Cloud computing
Introduction to Cloud computing
 
Selected topics in Computer Science
Selected topics in Computer Science Selected topics in Computer Science
Selected topics in Computer Science
 
Turingmachines
Turingmachines Turingmachines
Turingmachines
 
Greencomputing
GreencomputingGreencomputing
Greencomputing
 
Reed solomon code
Reed solomon codeReed solomon code
Reed solomon code
 
Chapter 5 of 1
Chapter 5 of 1Chapter 5 of 1
Chapter 5 of 1
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
minimum spanning tree
minimum spanning tree minimum spanning tree
minimum spanning tree
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 

Dernier

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Dernier (20)

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

C2.0 propositional logic

  • 1. 1 A brief introduction to Logic – part I Logic 2018.11.03 cs at Unideb
  • 2. 2 A Brief Introduction to Logic - Outline  Brief historical notes on logic  Propositional Logic :Syntax  Propositional Logic :Semantics  Satisfiability and validity  Modeling with Propositional logic  Normal forms  Deductive proofs and resolution
  • 3. 3 Historical view  Philosophical Logic  500 BC to 19th Century  Symbolic Logic  Mid to late 19th Century  Mathematical Logic  Late 19th to mid 20th Century  Logic in Computer Science
  • 4. 4 Philosophical Logic  500 B.C – 19th Century  Logic dealt with arguments in the natural language used by humans.  Example  All men are mortal.  Socrates is a man  Therefore, Socrates is mortal.
  • 5. 5 Philosophical Logic  Natural languages are very ambiguous.  Eric does not believe that Mary can pass any test.  ...does not believe that she can pass some test, or  ...does not believe that she can pass all tests  I only borrowed your car.  And not ‘borrowed and used’, or  And not ‘car and coat’  Tom hates Jim and he likes Mary.  Tom likes Mary, or  Jim likes Mary  It led to many paradoxes.  “This sentence is a lie.” (The Liar’s Paradox)
  • 6. 6 Sophism (From Wikipedia)  ... Sophism generally refers to a particularly confusing, illogical and/or insincere argument used by someone to make a point, or, perhaps, not to make a point.  Sophistry refers to [...] rhetoric that is designed to appeal to the listener on grounds other than the strict logical cogency of the statements being made.
  • 7. 7 The Sophist’s Paradox  A Sophist is sued for his tuition by the school that educated him. He argues that he must win, since, if he loses, the school didn’t educate him well enough, and doesn’t deserve the money.  The school argues that he must lose, since, if he wins, he was educated well enough, and therefore should pay for it.
  • 8. 8 Logic in Computer Science  Logic has a profound impact on computer-science. Some examples:  Propositional logic – the foundation of computers and circuitry  Databases – query languages  Programming languages (e.g. prolog)  Design Validation and verification  AI (e.g. inference systems)  ...
  • 9. 9 Logic in Computer Science  Propositional Logic  First Order Logic  Higher Order Logic  Temporal Logic  ...  ...
  • 10. 10 Propositional logic  A proposition – a sentence that can be either true or false.  Propositions:  x is greater than y  Noam wrote this letter
  • 11. 11 Propositional logic: Syntax  The symbols of the language:  Propositional symbols (Prop): A, B, C,…  Connectives:  ∧ and  ∨ or  ¬ not  → implies  ↔ equivalent to  © xor (different than)  ⊥, > False, True  Parenthesis:(, ).  Q1: how many different binary symbols can we define ?  Q2: what is the minimal number of such symbols?
  • 12. 12 Formulas  Grammar of well-formed propositional formulas  Formula := prop | (¬Formula) | (Formula o Formula).  ... where prop 2 Prop and o is one of the binary relations
  • 13. 13 Formulas  Examples of well-formed formulas:  (¬A)  (¬(¬A))  (A ∧ (B ∧ C))  (A→ (B→ C))  Correct expressions of Propositional Logic are full of unnecessary parenthesis.
  • 14. 14 Formulas  Abbreviations. We write A o B o C o …  in place of (A o (B o (C o …)))  Thus, we write A ∧ B ∧ C, A→B→C, …  in place of (A ∧ (B ∧ C)), (A→ (B→ C))
  • 15. 15 Formulas  We omit parenthesis whenever we may restore them through operator precedence:  ¬ binds more strictly than ∧, ∨, and ∧, ∨ bind more strictly than →, ↔.  Thus, we write: ¬¬A for (¬(¬A)), ¬A∧B for ((¬A)∧B) A∧B→ C for ((A∧B) → C), …
  • 16. 16 Propositional Logic: Semantics  Truth tables define the semantics (=meaning) of the operators  Convention: 0 = false, 1 = true p q p Æ q p Ç q p ! q 0 0 0 0 1 0 1 0 1 1 1 0 0 1 0 1 1 1 1 1
  • 17. 17 Propositional Logic: Semantics  Truth tables define the semantics (=meaning) of the operators p q :p p $ q p © q 0 0 1 1 0 0 1 1 0 1 1 0 0 0 1 1 1 0 1 0
  • 18. 18 Back to Q1  Q1: How many binary operators can we define that have different semantic definition ?  A: 16
  • 19. 19 Assignments  Definition: A truth-values assignment, α, is an element of 2Prop (i.e., α ∈ 2Prop ).  In other words, ® is a subset of the variables that are assigned true.  Equivalently, we can see ® as a mapping from variables to truth values: α : Prop  {0,1}  Example: ®: {A  0, B  1,...}
  • 20. 20 Satisfaction relation (²): intuition  An assignment can either satisfy or not satisfy a given formula.  α ² φ means  α satisfies φ or  φ holds at α or  α is a model of φ  We will first see an example.  Then we will define these notions formally.
  • 21. 21 Example  Let Á = (A Ç (B → C))  Let ® = {A  0, B  0, C  1}  Q: Does ® satisfy Á?  (in symbols: does it hold that ® ² Á ? )  A: (0 Ç (0 → 1)) = (0 Ç 1) = 1  Hence, ® ² Á.  Let us now formalize an evaluation process.
  • 22. 22 The satisfaction relation (²): formalities  ² is a relation: ² µ (2Prop x Formula)  Examples:  ({a}, a Ç b) // the assignment ® = {a} satisfies a Ç b  ({a,b}, a Æ b)  Alternatively: ² µ ({0,1}Prop £ Formula)  Examples:  (01, a Ç b) // the assignment ® = {a  0, b  1} satisfies a Ç b  (11, a Æ b)
  • 23. 23 The satisfaction relation (²): formalities  ² is defined recursively:  α ² p if α (p) = true  α ² ¬φ if α 2 φ.  α ² φ1 ∧ φ2 if α ² φ1 and α ² φ2  α ² φ1 ∨ φ2 if α ² φ1 or α ² φ2  α ² φ 1 → φ2 if α ² φ1 implies α ² φ2  α ² φ 1 ↔ φ2 if α ² φ1 iff α ² φ2
  • 24. 24 From definition to an evaluation algorithm  Truth Evaluation Problem  Given φ ∈ Formula and α∈ 2AP(φ) , does α ² φ ? Eval(φ, α){ If φ ≡ A, return α(A). If φ ≡ (¬φ1) return ¬Eval(φ1, α)) If φ ≡ (φ1 o φ2) return Eval(φ1, α) o Eval(φ2, α) }  Eval uses polynomial time and space.
  • 25. 25 It doesn’t give us more than what we already know...  Recall our example  Let Á = (A Ç (B → C))  Let ® = {A  0, B  0, C  1}  Eval(Á,®) = Eval(A,α) Ç Eval(B → C,α) = 0 Ç Eval(B,α) → Eval(C,α) = 0 Ç (0 → 1) = 0 Ç 1 = 1  Hence, ® ² Á.
  • 26. 26 We can now extend the truth table to formulas p q (p → (q → p)) (p Æ :p) p Ç :q 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 1 0 1
  • 27. 27 0111 1011 1101 1001 1 0 1 0 x3 110 110 100 100 x1 → (x2 → :x3)x2x1 We can now extend the truth table to formulas
  • 28. 28 Set of assignments  Intuition: a formula specifies a set of truth assignments.  Function models: Formula  22Prop (a formula  set of satisfying assignments)  Recursive definition:  models(A) = {α |α(A) = 1}, A ∈ Prop  models(¬φ1) = 2Prop – models(φ1)  models(φ1∧φ2) = models(φ1) ∩ models(φ2)  models(φ1∨φ2) = models(φ1) ∪ models(φ2)  models(φ1→φ2) = (2Prop – models(φ1)) ∪ models(φ2)
  • 29. 29 Example  models (A Ç B) = {{10},{01},{11}}  This is compatible with the recursive definition: models(A Ç B) = models(A) [ models (B) = {{10},{11}} [ {{01},{11}} = {{10},{01},{11}}
  • 30. 30 Theorem  Let φ ∈ Formula and α ∈ 2Prop , then the following statements are equivalent: 1. α ² φ 2. α ∈ models(φ)
  • 31. 31 Only the projected assignment matters...  AP(φ) – the Atomic Propositions in φ.  Clearly AP(φ) µ Prop.  Let α1, α2 ∈ 2Prop , φ ∈ Formula.  Lemma: if α1|AP(φ)= α2|AP(φ) , then α1² φ iff α2 ² φ Corollary: α ² φ iff α|AP(φ)² φ  We will assume, for simplicity, that Prop = AP(φ). Projection
  • 32. 32 Extension of ²to sets of assignments  Let φ2 Formula  Let T be a set of assignments, i.e., T ⊆ 22Prop  Definition. T ² φ if T ⊆ models(φ)  i.e., ² ⊆ 22Prop £ Formula
  • 33. 33 Extension of ² to formulas  ² ⊆ 2Formula £ 2Formula  Definition. Let Γ1, Γ2be prop. formulas. Γ1 ² Γ2 iff models(Γ1) ⊆ models(Γ2) iff for all α ∈ 2Prop if α ² Γ1 then α ² Γ2 Examples: x1 Æ x2 ² x1 Ç x2 x1 Æ x2 ² x2 Ç x3
  • 34. 34 Semantic Classification of formulas  A formula φ is called valid if models(φ) = 2Prop . (also called a tautology).  A formula φ is called satisfiable if models(φ) ≠ ;.  A formula φ is called unsatisfiable if models(φ) = ;. (also called a contradiction). unsatisfiable satisfiable valid
  • 35. 35 Validity, satisfiability... in truth tables p q (p → (q → q)) (p Æ :p) p Ç :q 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 1 0 1
  • 36. 36 Characteristics of valid/sat. formulas...  Lemma  A formula φ is valid iff ¬φ is unsatisfiable  φ is satisfiable iff ¬φ is not valid Satisfiability checker Is φ valid? yes no ?
  • 37. 37 Look what we can do now...  We can write:  ² Á when Á is valid  2 Á when Á is not valid  2 :Á when Á is satisfiable  ² :Á when Á is unsatisfiable
  • 38. 38 Examples  (x1 Æ x2) → (x1 Ç x2) is  (x1 Ç x2) → x1 is  (x1 Æ x2) Æ :x1 is valid satisfiable unsatisfiable
  • 39. 39 Time for equivalences  Here are some valid formulas:  ² A Æ 1 $ A  ² A Æ 0 $ 0  ² ::A $ A // The double-negation rule  ² A Æ (B Ç C) $ (A Æ B) Ç (A Æ C)  Some more (De-Morgan rules):  ² :(A Æ B) $ (:A Ç :B)  ²:(A Ç B) $ (:A Æ :B)
  • 40. 40 A minimal set of binary operators  Recall the question: what is the minimal set of operators necessary?  A: Through such equivalences all Boolean operators can be written with a single operator (NAND).  Indeed, typically industrial circuits only use one type of logical gate  We’ll see how two are enough: : and Æ  Or: ² (A Ç B) $ :(:A Æ :B)  Implies: ² (A → B) $ (:A Ç B)  Equivalence: ² (A $B) $(A → B) Æ (B → A)  ...
  • 41. 41 The decision problem of formulas  The decision problem: Given a propositional formula Á, is Á satisfiable ?  An algorithm that always terminates with a correct answer to this problem is called a decision procedure for propositional logic.
  • 42. 42 A Brief Introduction to Logic - Outline  Brief historical notes on logic  Propositional Logic :Syntax  Propositional Logic :Semantics  Satisfiability and validity  Modeling with Propositional logic  Normal forms  Deductive proofs and resolution
  • 43. 43 Before we solve this problem...  Q: Suppose we can solve the satisfiability problem... how can this help us?  A: There are numerous problems in the industry that are solved via the satisfiability problem of propositional logic  Logistics...  Planning...  Electronic Design Automation industry...  Cryptography...  ... (every NP-P problem...)
  • 44. 46 Example 2: placement of wedding guests  Three chairs in a row: 1,2,3  We need to place Aunt, Sister and Father.  Constraints:  Aunt doesn’t want to sit near Father  Aunt doesn’t want to sit in the left chair  Sister doesn’t want to sit to the right of Father  Q: Can we satisfy these constraints?
  • 45. 47 Example 2 (cont’d)  Denote: Aunt = 1, Sister = 2, Father = 3  Introduce a propositional variable for each pair (person, place).  xij = person i is sited in place j, for 1 ·i,j · 3  Constraints:  Aunt doesn’t want to sit near Father: ((x1,1 Ç x1,3) → :x3,2) Æ(x1,2 → (:x3,1 Æ :x3,3))  Aunt doesn’t want to sit in the left chair :x1,1  Sister doesn’t want to sit to the right of Father x3,1→ :x2,2 Æ x3,2 → :x2,3
  • 46. 48 Example 2 (cont’d)  More constraints:  Each person is placed: (x1,1 Ç x1,2 Ç x1,3) Æ (x2,1 Ç x2,2 Ç x2,3) Æ (x3,1 Ç x3,2 Ç x3,3)  Or, more concisely:  Not more than one person per chair:  Overall 9 variables, 23 conjoined constraints.
  • 47. 49 Example 3: assignment of frequencies  n radio stations  For each assign one of k transmission frequencies, k < n.  E -- set of pairs of stations, that are too close to have the same frequency.  Q: which graph problem does this remind you of ?
  • 48. 50 Example 3 (cont’d)  xi,j – station i is assigned frequency j, for 1 · i · n, 1 · j · k.  Every station is assigned at least one frequency:  Every station is assigned not more than one frequency:  Close stations are not assigned the same frequency. For each (i,j) 2 E,
  • 49. 51 Two classes of algorithms for validity  Q: Is φ satisfiable (/:φ is valid) ?  Complexity: NP-Complete (the first-ever! – Cook’s theorem)  Two classes of algorithms for finding out: 1. Enumeration of possible solutions (Truth tables etc). 2. Deduction  More generally (beyond propositional logic):  Enumeration is possible only in some logics.  Deduction cannot necessarily be fully automated.
  • 50. 52 The satisfiability problem: enumeration  Given a formula φ, is φ satisfiable? Boolean SAT(φ) { B:=false for all α ∈ 2AP(φ) B = B ∨ Eval(φ,α) end return B }  There must be a better way to do that in practice.
  • 51. 53 A Brief Introduction to Logic - Outline  Brief historical notes on logic  Propositional Logic :Syntax  Propositional Logic :Semantics  Satisfiability and validity  Modeling with Propositional logic  Normal forms  Deductive proofs and resolution
  • 52. 54 Definitions…  Definition: A literal is either an atom or a negation of an atom.  Let φ = :(A Ç :B). Then:  Atoms: AP(φ) = {A,B}  Literals: lit(φ) = {A, :B}  Equivalent formulas can have different literals  φ = :(A Ç :B) = :A Æ B  Now lit(φ) = {:A, B}
  • 53. 55 Definitions…  Definition: a term is a conjunction of literals  Example: (A Æ :B Æ C)  Definition: a clause is a disjunction of literals  Example: (A Ç :B Ç C)
  • 54. 56 Negation Normal Form (NNF)  Definition: A formula is said to be in Negation Normal Form (NNF) if it only contains :, Æ and Ç connectives and only atoms can be negated.  Examples:  φ1 = :(A Ç :B) is not in NNF  φ2 = :A Æ B is in NNF
  • 55. 57 Converting to NNF  Every formula can be converted to NNF in linear time:  Eliminate all connectives other than Æ, Ç, :  Use De Morgan and double-negation rules to push negations to the right  Example: φ = :(A ! :B)  Eliminate ‘!’: φ = :(:A Ç :B)  Push negation using De Morgan: φ = (::A Æ ::B)  Use Double negation rule: φ = (A Æ B)
  • 56. 58 Disjunctive Normal Form (DNF)  Definition: A formula is said to be in Disjunctive Normal Form (DNF) if it is a disjunction of terms.  In other words, it is a formula of the form where li,jis the j-th literal in the i-th term.  Examples  φ = (A Æ :B Æ C) Ç (:A Æ D) Ç (B) is in DNF  DNF is a special case of NNF
  • 57. 59 Converting to DNF  Every formula can be converted to DNF in exponential time and space:  Convert to NNF  Distribute disjunctions following the rule: ² A Æ (B Ç C) $ ((A Æ B) Ç (A Æ C))  Example:  φ = (A Ç B) Æ (:C Ç D) = ((A Ç B) Æ (:C)) Ç ((A Ç B) Æ D) = (A Æ :C) Ç (B Æ :C) Ç (A Æ D) Ç (B Æ D)  Q: how many clauses would the DNF have had we started from a conjunction of n clauses ?
  • 58. 60 Satisfiability of DNF  Is the following DNF formula satisfiable? (x1 Æ x2 Æ :x1) Ç (x2 Æ x1) Ç (x2 Æ :x3 Æ x3)  What is the complexity of satisfiability of DNF formulas?
  • 59. 61 Conjunctive Normal Form (CNF)  Definition: A formula is said to be in Conjunctive Normal Form (CNF) if it is a conjunction of clauses.  In other words, it is a formula of the form where li,jis the j-th literal in the i-th term.  Examples  φ = (A Ç :B Ç C) Æ (:A Ç D) Æ (B) is in CNF  CNF is a special case of NNF
  • 60. 62 Converting to CNF  Every formula can be converted to CNF:  in exponential time and space with the same set of atoms  in linear time and space if new variables are added.  In this case the original and converted formulas are “equi- satisfiable”.  This technique is called Tseitin’s encoding.
  • 61. 63 Converting to CNF: the exponential way CNF(φ) { case φ is a literal: return φ φ is ψ1 Æ ψ2: return CNF(ψ1) Æ CNF(ψ2) φ is ψ1 Ç ψ2: return Dist(CNF(ψ1),CNF(ψ2)) } Dist(ψ1,ψ2) { case ψ1 is φ11 Æ φ12: return Dist(φ11,ψ2) Æ Dist(ψ12,ψ2) ψ2 is φ21 Æ φ22: return Dist(ψ1,φ21) Æ Dist(ψ1,φ22) else: return ψ1 Ç ψ2
  • 62. 64 Converting to CNF: the exponential way  Consider the formula φ = (x1 Æ y1) Ç (x2 Æ y2)  CNF(φ)= (x1 Ç x2) Æ (x1 Ç y2) Æ (y1 Ç x2) Æ (y1 Ç y2)  Now consider: φn = (x1 Æ y1) Ç (x2 Æ y2) Ç  Ç (xn Æ yn)  Q: How many clauses CNF(φ) returns ?  A: 2n
  • 63. 65 Converting to CNF: Tseitin’s encoding  Consider the formula φ = (A ! (B Æ C))  The parse tree:  Associate a new auxiliary variable with each gate.  Add constraints that define these new variables.  Finally, enforce the root node. A Æ B C ! a1 a2
  • 64. 66 Converting to CNF: Tseitin’s encoding  Need to satisfy: (a1 $ (A ! a2)) Æ (a2 $ (B Æ C)) Æ (a1)  Each such constraint has a CNF representation with 3 or 4 clauses. A Æ B C ! a1 a2
  • 65. 67 Converting to CNF: Tseitin’s encoding  Need to satisfy: (a1 $ (A ! a2)) Æ (a2 $ (B Æ C)) Æ (a1)  First: (a1 Ç A) Æ (a1 Ç :a2) Æ (:a1 Ç :A Ç a2)  Second: (:a2 Ç B) Æ (:a2 Ç C) Æ (a2 Ç :B Ç :C)
  • 66. 68 Converting to CNF: Tseitin’s encoding  Let’s go back to φn = (x1 Æ y1) Ç (x2 Æ y2) Ç  Ç (xn Æ yn)  With Tseitin’s encoding we need:  n auxiliary variables a1,…,an.  Each adds 3 constraints.  Top clause: (a1 Ç  Ç an)  Hence, we have  3n + 1 clauses, instead of 2n .  3n variables rather than 2n.
  • 67. 69 What now?  Time to solve the decision problem for propositional logic.  The only algorithm we saw so far was building truth tables.
  • 68. 70 Two classes of algorithms for validity  Q: Is φ valid ?  Equivalently: is :φ satisfiable?  Two classes of algorithm for finding out: 1. Enumeration of possible solutions (Truth tables etc). 2. Deduction  In general (beyond propositional logic):  Enumeration is possible only in some theories.  Deduction typically cannot be fully automated.
  • 69. 71 The satisfiability Problem: enumeration  Given a formula φ, is φ satisfiable? Boolean SAT(φ) { B:=false for all α ∈ 2AP(φ) B = B ∨ Eval(φ,α) end return B }  NP-Complete (the first-ever! – Cook’s theorem)
  • 70. 72 A Brief Introduction to Logic - Outline  Brief historical notes on logic  Propositional Logic :Syntax  Propositional Logic :Semantics  Satisfiability and validity  Modeling with Propositional logic  Normal forms  Deductive proofs and resolution
  • 71. 73 Deduction requires axioms and Inference rules  Inference rules: Antecedents Consequent  Examples: A ! B B ! C A ! C A ! B A B )rule-name( )trans( )M.P.(
  • 72. 74 Axioms  Axioms are inference rules with no antecedents, e.g.,  We can turn an inference rule into an axiom if we have ‘→’ in the logic.  So the difference between them is not sharp. )H1( A ! )B ! A(
  • 73. 75 Proofs  A proof uses a given set of inference rules and axioms.  This is called the proof system.  Let H be a proof system.  Γ `H φ means: there is a proof of φ in system H whose premises are included in Γ  `His called the provability relation.
  • 74. 76 Example  Let H be the proof system comprised of the rules Trans and M.P. that we saw earlier.  Does the following relation holds? a ! b,b ! c, c ! d, d ! e, a `H e
  • 75. 77 Deductive proof: example 1. a ! b premise 2. b ! c premise 3. a ! c 1,2,Trans 4. c ! d premise 5. d ! e premise 6. c ! e 4,5, Trans 7. a ! e 3,6, Trans 8. a premise 9. e 7,8.M.P. a ! b, b ! c, c ! d, d ! e, a `H e
  • 76. 78 Proof graph (DAG) a ! b b ! c c ! d d ! e a ! c c ! e a ! e a e )trans( )trans( )trans( )M.P.( Roots: premises
  • 77. 79 Proofs  The problem: ` is a relation defined by syntactic transformations of the underlying proof system.  For a given proof system H,  does ` conclude “correct” conclusions from premises ?  Can we conclude all true statements with H?  Correct with respect to what ?  With respect to the semantic definition of the logic. In the case of propositional logic truth tables gives us this.
  • 78. 80 Soundness and completeness  Let Hbe a proof system  Soundness of H: if `H φ then ² φ  Completeness of H : if ²φ then `H φ  How to prove soundness and completeness ?
  • 79. 81 Soundness and completeness of procedures  The definitions so far referred to proof systems  What does soundness and completeness mean for general decision algorithms ?
  • 80. 82 Soundness and Completeness  Definition [soundness]: A procedure for the decision problem is sound if  when it returns “Valid”...  ... the input formula is valid.  Definition [completeness]: A procedure for the decision problem is complete if  it always terminates, and  it returns “Valid” when the input formula is valid.
  • 81. 83 Decidability  Definition [decidability] A logic is decidable if there is a sound and complete algorithm that decides if a well-formed expression in this logic is valid.
  • 82. 84 Soundness and Completeness  Soundness: “when I say that it rains, it rains”  Completeness: “If asked, I always reply (in a finite time…). When it rains, I say that it rains”
  • 83. 85 Soundness and Completeness (cont’d)  Algorithm #1: for checking if it rains outside: “stand right outside the door and say ‘it rains’”  It is not sound because you might say it rains when it doesn’t.  But it is complete: you always get an answer in a finite time, and when it rains you say it rains.
  • 84. 86 Soundness and Completeness (cont’d)  Algorithm #2 for checking if it rains outside: “stand right outside the door and say ‘it rains’ if and only if you feel the rain”  It is sound because you say it rains only if it actually rains.  It is incomplete because you do not say anything if it doesn’t rain (we do not know whether it doesn’t rain, or it takes the person too long to answer…).
  • 85. 87 Soundness and Completeness (cont’d)  Algorithm #2 for checking if it rains outside: “stand right outside the door and say ‘it rains’ if and only if you feel the rain, after a second”  It is sound because you say it rains only if it actually rains.  It is complete.
  • 86. 88  Now let’s go back to proof systems...
  • 87. 89 Example: Hilbert axiom system (H)  Let H be (M.P) + the following axiom schemas: (H1) A ! (B ! A) (H2) ((A !(B ! C)) !((A! B)!(A! C)) (H3) (:B !:A) !(A ! B)  H is sound and complete
  • 88. 90 Soundness and completeness  To prove soundness of H, prove the soundness of its axioms and inference rules (easy with truth-tables). For example:  Completeness – harder, but possible. A B A ! (B ! A) 0 0 1 0 1 1 1 0 1 1 1 1
  • 89. 91 The resolution inference system  The resolution inference rule for CNF:  Example:
  • 90. 92 Proof by resolution  Let ϕ = (1 3) Æ (-1 2 5) Æ (-1 4) Æ (-1 -4) Æ(1 -2)  We’ll try to prove ϕ → (3 5) )13( -)125( (2 3 5) (1 -2) (1 3 5) (-1 4) (-1 -4) (-1) (3 5)
  • 91. 93 Resolution  Resolution is a sound and complete inference system for CNF  If the input formula is unsatisfiable, there exists a proof of the empty clause
  • 92. 94 Example  Let ϕ = (1 3) Æ (-1 2) Æ (-1 4) Æ (-1 -4) Æ (1 -2) Æ(-3) )13( (-1 2) (2 3) (1 -2) (1 3) (-1 4) (-1 -4) (-1) (3) (-3) ()

Notes de l'éditeur

  1. Answer 1: the generalization of truth tables. Every predicate and function symbol has a definition. A truth table is the definition for the Boolean predicates. Answer 2: a deduction system is a special case of an algorithm. The algorithm is: try all possible deductions and stop if you reach the goal. So if the algorithm always terminates -&amp;gt; the deduction system is complete, and vice-a-versa.