Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
13 views

Notes Cse Basics File21

This document contains lecture notes for a course on propositional logic for computer science students. It is divided into 9 parts that cover topics such as informal and formal propositional logic, semantics, natural deduction, normal forms, and resolution. The notes were produced by professors Stefan Ciobâcă, Andrei Arusoaie, Rodica Condurache, and Cristian Masalagiu at Alexandru Ioan Cuza University for the 2023-2024 academic year. Each part contains sections on specific logic concepts and exercises for students.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Notes Cse Basics File21

This document contains lecture notes for a course on propositional logic for computer science students. It is divided into 9 parts that cover topics such as informal and formal propositional logic, semantics, natural deduction, normal forms, and resolution. The notes were produced by professors Stefan Ciobâcă, Andrei Arusoaie, Rodica Condurache, and Cristian Masalagiu at Alexandru Ioan Cuza University for the 2023-2024 academic year. Each part contains sections on specific logic concepts and exercises for students.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 84

Logic for Computer Science - Lecture Notes

Alexandru Ioan Cuza University, Ias, i


Faculty of Computer Science
University Year 2023-2024

S, tefan Ciobâcă
Andrei Arusoaie
Rodica Condurache
Cristian Masalagiu
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Part I - Propositional Logic 2 Lecture notes - to print in color


Contents

1 Introduction 7

2 Informal Propositional Logic 9


2.1 Propositions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Atomic Propositions . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Conjunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Disjunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.5 Implications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.6 Negations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.7 Equivalences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.8 Logical Connectives . . . . . . . . . . . . . . . . . . . . . . . . 14
2.9 Ambiguities in Natural Language . . . . . . . . . . . . . . . . . 15
2.10 Exercise Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3 The Formal Syntax of Propositional Logic 17


3.1 Alphabets in Computer Science . . . . . . . . . . . . . . . . . . 17
3.2 The Alphabet of Propositional Logic . . . . . . . . . . . . . . . 18
3.3 Propositional Formulae . . . . . . . . . . . . . . . . . . . . . . 18
3.4 Showing That a Word Is In PL . . . . . . . . . . . . . . . . . . 19
3.5 The Main Connective of a Formula . . . . . . . . . . . . . . . . 20
3.6 Showing That a Word Is Not in PL . . . . . . . . . . . . . . . . 20
3.7 Unique Readability . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.8 Object-language and meta-language . . . . . . . . . . . . . . . 22
3.9 Exercise Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

4 Functions Defined Recursively on PL 25


4.1 The Abstract Syntax Tree of a Formula . . . . . . . . . . . . . 26
4.2 Other Examples of Recursively Defined Functions . . . . . . . . 28
4.3 Proofs by Structural Induction . . . . . . . . . . . . . . . . . . 29
4.4 Exercise Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

3
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

5 Semantics of Propositional Logic 33


5.1 Boolean Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.2 Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.3 Truth Value of A Formula in An Assignment . . . . . . . . . . 34
5.4 Satisfiability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.5 Valid Formulae . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.6 Contingent Formulae . . . . . . . . . . . . . . . . . . . . . . . . 37
5.7 Equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.8 Semantical Consequence . . . . . . . . . . . . . . . . . . . . . . 38
5.9 Consistent set of formulae . . . . . . . . . . . . . . . . . . . . . 39
5.10 Application 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.11 Exercise Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

6 Logical Connectives 45
6.1 Several Propositional Logics . . . . . . . . . . . . . . . . . . . . 45
6.2 The relation between implications and semantical consequence 46
6.3 Translating propositions from English into PL . . . . . . . . . . 47
6.4 Application 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.5 Exercise sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

7 Natural Deduction 51
7.1 Sequents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.2 Inference Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.3 Proof system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.4 Formal Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.5 Natural Deduction . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.5.1 The Rules for Conjunction . . . . . . . . . . . . . . . . 55
7.5.2 The Rules for Implications . . . . . . . . . . . . . . . . 56
7.5.3 Rules for Disjunctions . . . . . . . . . . . . . . . . . . . 58
7.5.4 The Rules for Negations . . . . . . . . . . . . . . . . . . 60
7.5.5 Alte reguli . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7.6 Natural Deduction . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.7 Derived Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.8 Soundness and Completeness for Natural Deduction . . . . . . 64
7.9 Exercise Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

8 Normal Forms 67
8.1 Notations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
8.2 Replacement Theorem . . . . . . . . . . . . . . . . . . . . . . . 69
8.3 Literal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
8.4 Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
8.5 Conjunctive Normal Form . . . . . . . . . . . . . . . . . . . . . 70
8.6 Bringing a Formula into CNF . . . . . . . . . . . . . . . . . . . 71

Part I - Propositional Logic 4 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

8.7 Disjunctive Normal Form . . . . . . . . . . . . . . . . . . . . . 72


8.8 The Link between DNF and CNF . . . . . . . . . . . . . . . . . 73
8.9 Exercise Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

9 Resolution in Propositional Logic 75


9.1 Clauses as Sets of Literals . . . . . . . . . . . . . . . . . . . . . 75
9.2 CNFs as Sets of Clauses . . . . . . . . . . . . . . . . . . . . . . 77
9.3 Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
9.4 Formal Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
9.5 Soundness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
9.6 Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
9.7 Proving Validity and Logical Consequences by Resolution . . . 82
9.8 Exercise Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

Part I - Propositional Logic 5 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Part I - Propositional Logic 6 Lecture notes - to print in color


Chapter 1

Introduction

If Arithmetic is the science that studies numbers and operations with num-
bers, then Logic is the science that studies propositions and operations with
propositions.
For example, if in Arithmetic we notice that the sum of two even numbers
is an even number, then in Logic we could notice that the disjunction of two
true sentences is also true.
Logic sits at the intersection of philosophy, mathematics and computer
science and has experienced its greatest development starting with the 1950s,
because of its numerous applications in Computer Science.
In this course, we will study at an introductory level propositional logic
and first-order logic.
Propositional logic is extremely simple, but the concepts that we study, the
methods that we learn and the issues that we face in propositional logic gener-
alize to other more complex logics. Moreover, propositional logic corresponds
intimately to the internal organization of computers at an abstract level, in
the sense that electronic circuits can be modeled as formulae in propositional
logic. Propositional logic has a rich and mathematically interesting theory
(examples: compactness theorem, Craig’s interpolation theorem). The sat-
isfiability problem for propositional logic has many applications in computer
science. It is especially important both from a theoretical viewpoint (being
the canonical NP-complete problem) and from a practical viewpoint as well
(with applications in program verification, circuit verification, combinatorial
optimization, and others).
First-order logic is an extension of propositional logic and also has numer-
ous application in computer science, but also in mathematics. For example,
all of the math that you have studied in highschool is based on a so-called first-
order logic theory called ZFC (the Zermelo–Fraenkel set theory, together with
the Axiom of Choice). In Computer Science, applications of first-order logic

7
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

appear in the fields of descriptive complexity, relational databases, software


and hardware verification, and others. Additionally, several other logics (for
example, higher-order logics) have applications in programming languages,
the fundamentals of mathematics, type theory, etc.

Part I - Propositional Logic 8 Lecture notes - to print in color


Chapter 2

Informal Propositional
Logic

Propositional logic is the logic of propositions, connected among themselves


by logical connectives such as or, and and not. In this chapter, we study the
basics of propositional logic.

2.1 Propositions
A proposition is a statement that is either true or false. Propositions are
sometimes called sentences. Here are examples of propositions:

1. I wear a blue shirt.


2. You own a laptop computer and a tablet computer, but no smartphone.
3. 2 + 2 = 4. (Two plus two is four.)
4. 1 + 1 = 1. (One plus one is one.)
5. 1 + 1 6= 1. (One plus one is not one.)
6. If 1 + 1 = 1, then I’m a banana.
7. All natural numbers are integers.
8. All rational numbers are integers.

Here are examples of things that are not propositions:

1. Red and Black (not a statement);

9
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

2. π (not a statement);
3. Is it raining? (question, not a statement);
4. Go fish! (imperative);
5. x is greater than 7 (we have here a predicate of x; once we set a value
for x, the predicate becomes a proposition);
6. This sentence is false. (although a statement, it is not a proposition,
since it is not either true or false: if it were true, it would need to be
false and vice-versa).

Sometimes it is debatable whether something is truly a proposition. For


example, we generally agree that Snow is white is true, but someone might
argue that they have seen black snow, so the truth value of Snow is white is
put in question. Arguing about whether something is a proposition or not is
more a matter of philosophical logic than computer science logic and we will
therefore not be too concerned about these sort of issues.

2.2 Atomic Propositions


Some propositions are atomic, in that they cannot be decomposed further
into smaller propositions:

1. I wear a blue shirt.


2. You own a laptop computer.
3. 2 + 2 = 4. (Two plus two is four.)

2.3 Conjunctions
Others however seem to be composed of smaller parts. For example, the
proposition I play games often and I study very well is composed of two
smaller propositions: I play games often and I study very well, joined together
by and. When two propositions ϕ and ψ are joined by an and, the resulting
proposition ϕ and ψ is called a conjunction (the conjunction of ϕ and ψ).
The propositions ϕ and ψ are called the conjuncts of the proposition ϕ and
ψ.
A conjunction is true if both of its conjuncts are true. For example, the
proposition I play games often and I study very well. is true if both I play
games often and I study very well are true. In particular, as I do not play
games often, this proposition is false (when I say it).

Part I - Propositional Logic 10 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Note that a conjunction need not use explicitly the word and. For ex-
ample, the proposition It is raining outside, but I have an umbrella is also a
conjunction, and it conjuncts are It is raining outside and I have an umbrella.
This particular conjunction uses the adversative conjunction but.
Exercise 1. Find the conjuncts of I play at home and I study at school..
Exercise 2. Give an example of a conjunction that is false and an example
of a conjunction that is true.

2.4 Disjunctions
Disjunctions are propositions linked together by or. For example, I can install
the software on my smartphone or on my tablet is a disjunction between I can
install the software on my smartphone and I can install the software on my
tablet. The two parts of the disjunction are called the disjuncts.
In the example above, note that the English grammar allows us to omit
I can install the software . . . in the second disjunct, as it is implicit in our
understanding of the language. However, when we find the disjuncts, is helps
to state them explicitly.
Exercise 3. Find the disjuncts of I will buy a laptop or a tablet. Pay
attention! The two disjuncts must be propositions (some words in them could
be implicit and not appear in the text).
A disjunction is true if at least one of the disjuncts is true. For example,
I am Darth Vader or I teach is true because I teach is true (I do not have to
worry about being Darth Vader). I teach or I program is also true (it happens
that both disjuncts are true).
This meaning of disjunctions is called the inclusive or. It is standard in
mathematics. Sometimes people use or in natural language to mean exclusive
or. For example Either white wins or black wins in a game of go is an example
where the or is exclusive. The meaning of the sentence is that white wins or
black wins, but not both. Here is an example of a false proposition that uses
exclusive or : Either I program or I teach (hint: false because I do both).
When you see either in a sentence, it is a sign that you are dealing with an
exclusive or.
In the following, by disjunction we will understand inclusive or (the stan-
dard interpretation in mathematics).
Exercise 4. Give an example of a false disjunction and an example of a true
disjunction.
Exercise 5. When is a disjunction ϕ or ψ false (depending on the truth value
of ϕ and ψ)?

Part I - Propositional Logic 11 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

2.5 Implications
Implications are propositions of the form if ϕ then ψ. The proposition ϕ
is called the antecedent and the proposition ψ is called the conclusion (or
consequent) of the implication.
An example of an implication is If I get a passing grade in Logic, I will
buy everyone beer. The antecedent is I get a passing grade in Logic. and the
conclusion is I will buy everyone beer. When is an implication true? Actually,
it is easier to say when it is false. An implication is false if and only if the
antecedent is true, but the conclusion is false. Assume that I got a passing
grade in Logic. Therefore, the proposition I get a passing grade in Logic is
true. However, I will not buy beer for everyone (just a few select friends).
Therefore the proposition I will buy everyone beer is false. Therefore the
implication If I get a passing grade in Logic, I will buy everyone beer as a
whole is false (antecedent is true, but conclusion is false).
The meaning of implications is worth a more detailed discussion as it is
somewhat controversial. This is mostly because implication as we understand
it in mathematics can sometimes be subtly different from implication as we
understand it in everyday life. In everyday life, when we say If I pass Logic,
I buy beer, we understand that there is a cause-and-effect relation between
passing Logic and buying beer. This subtle cause-and-effect relation is evident
in a number of if-then statements that we use in real life: If I have money, I
will buy a car, If you help me, I will help you, etc. We would never connect
two unrelated sentences with an implication: the proposition If the Earth is
round, then 2+2=4 would not be very helpful, even though it is true (both
the antecedent and the conclusion are true).
This implication that we use in mathematics is called material implication
or truth functional implication, because the truth value of the implication as a
whole depends only on the truth values of the antecedent and the conclusion,
not on the antecedent and the conclusion itself. This meaning of implication
sometimes does not correspond to the meaning of natural language implica-
tions, but it turns out that it is the only sensible interpretation of implications
in mathematics (and computer science).
In particular, we will take both the propositions If the Earth is flat, then
2 + 2 = 5 and If the Earth is flat, then 2 + 2 = 4 to be true, because the
antecedent is false. Implications that are true because the antecedent is false
are called vacuously true.
Exercise 6. What are the truth values of If 2 + 2 = 4, then the Earth is flat
and If 2 + 2 = 5, then the Earth is flat?
The truth value of an implication if ϕ then ψ, depending on the truth
values of its antecedent ϕ and its conclusion ψ, is summarized in the truth-
table below:

Part I - Propositional Logic 12 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

ϕ ψ if ϕ then ψ
false false true
false true true
true false false
true true true
The following example aims at convincing you that the truth table above
is the only reasonable one. You must agree that every natural number is
also an integer. Otherwise put, the proposition for any number x, if x is a
natural, then x is an integer is true. In particular, you will agree that the
proposition above holds for x = −10, x = 10 and x = 1.2. In particular, the
propositions If −10 is a natural, then −10 is an integer, If 10 is a natural,
then 10 is an integer and If 1.2 is a natural, then 1.2 is an integer must all
be true. This accounts for the first, second and fourth lines of the truth table
above (typically, the second line is controversial). As for the third line, false
is the only reasonable truth value for an implication if ϕ then ψ where ϕ is
true but ψ is false. Otherwise, we would have to accept propositions such as
If 2 + 2 = 4, then 2 + 2 = 5 (antecedent 2 + 2 = 4 true, conclusion 2 + 2 = 5
false) as being true.
Implications are sometimes subtle to spot and identify correctly. For ex-
ample, in the proposition I will pass Logic only if I study hard (emphasis on
only if ), the antecedent is I will pass Logic and the conclusion is I study hard.
In particular, the above proposition does not have the same meaning as If I
study hard, then I will pass Logic.

Pay attention! In propositions of the form I will pass Logic only


if I study, the antecedent is I will pass Logic, and the consequent
is I study. This proposition does not have the same meaning as if
I study, then I will pass Logic.

Implications can sometimes not make use of if. For example, take the
proposition I will pass Logic or I will drop school (apparently a disjunction).
This most likely meaning of this proposition is If I do not pass Logic, then I
will drop school. Thankfully, both of these propositions are equivalent, in a
sense that we shall study in the following lectures.

2.6 Negations
A proposition of the form it is not the case that ϕ (or simply not ψ) is the
negation of ϕ. For example, It is not raining is the negation of It is raining.

Part I - Propositional Logic 13 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

The negation of a proposition takes the opposite truth value. For example,
as I am writing this text, the proposition It is raining is false, and therefore
the proposition It is not raining is true.
Exercise 7. Give an example of a false proposition that uses both a negation
and a conjunction.

2.7 Equivalences
A proposition of the form ϕ if and only if ψ is called an equivalence or double
implication. Such a proposition, as a whole, is true if ϕ and ψ have the same
truth value (both false or both true).
For example, when I am writing this text, It is raining if and only if it is
snowing is true. Why? Because both of the propositions It is raining and It
is snowing are false.
Exercise 8. What is the truth value of the proposition The number 7 is odd
if and only if 7 is a prime.?
Equivalences are, semantically speaking, conjunctions of two implications:
ϕ if and only if ψ gives the same information as
ϕ if ψ and ϕ only if ψ .
| {z } | {z }
the reverse implication the direct implication
The proposition ϕ if ψ is the same as if ψ, then ϕ (but it has a different
topic). The proposition ϕ only if ψ has the same meaning as if ϕ, then ψ, as
we dicussed in the previous section on implications.

2.8 Logical Connectives


The words and, or, if-then, not, only if, if-and-only-if (and other similar
phrases) are called logical connectives, as they can be used to connect smaller
propositions in order to obtain larger propositions.
Pay attention! A proposition is atomic in propositional logic only if it
cannot be decomposed into smaller propositions separated by the connectives
discussed above. For example, the proposition every natural number is an
integer is an atomic proposition (in propositional logic).
The same proposition is not necessarily atomic in other logics. For exam-
ple, in first-order logic (which we study in the second half of the semester),
we have additional logical connectives called quantifiers that can be used
to construct every natural number is an integer from smaller propositions.
Therefore, every natural number is an integer is not atomic in first-order
logic.

Part I - Propositional Logic 14 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

2.9 Ambiguities in Natural Language


We have described above the language of propositional logic: atomic propo-
sitions connected by and, or, not, etc. So far, our approach has used English.
However, English (or any other natural language) is not suitable for our pur-
poses because it exhibits imprecisions in the form of ambiguitites.
Here are a few examples of ambigious propositions:

1. John and Mary are married (meaning 1: John and Mary are married to
each other; meaning 2: John and Mary are married, but not necessarily
to each other).
2. It is not true that John is tall and Jane is short (meaning 1: John is
not tall and Jane is short; meaning 2: the conjunction John is tall and
Jane is short is false).

In the study of the laws of logic, such ambiguities can get in the way, just
like a wrong computation could impact the resistance of buildings or bridges
in civil engineering.
The state of the art in Logic for over 2.000 years, from Aristotle up to the
development of Symbolic Logic in the 19th century, has been to use natural
language. Symbolic logic (formal logic) has changed the game by introducing
languages so precise that there is no risk of misunderstandings.
Such ambiguities impede the study of propositional logic. Therefore we
will design a formal language, the language of propositional logic, where no
ambiguity can occur. The first such language that we study will be the lan-
guage of propositional logic.
Normally, when people say formal, they mean it in a bad way, such as
having to dress or act formally to go to dinner.
However, in computer science (and in mathematics), formal is a good
thing: it means making things so precise that there is no possibility of mis-
understanding.

2.10 Exercise Sheet


Exercise 9. Establish which of the following phrases are propositions:

1. You own a laptop computer.


2. Snow is white.
3. Snow is not white.
4. My father goes to work and I go to school.

Part I - Propositional Logic 15 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

5. It is raining outside, but I have an umbrella.


6. Either it will rain tomorrow, or it won’t rain.
7. If I get a passing grade in Logic, I will celebrate.

8. 2 + 2 = 4. ( Two plus two is four.)


9. Red and Black.
10. π.
11. Is it raining?

12. Let’s go fishing!


13. x is greater than 7.
14. This sentence is false.

Exercise 10. For all propositions that you identified, establish whether they
are atomic or not. If not, establish if they are conjunctions, disjunctions,
implications, negations, etc.).

Exercise 11. Determine whether the sentences below are atomic or not. If
they are not atomic, identify their types (conjunctions, disjunctions, implica-
tions, negations, equivalences). For each such sentence, discuss their truth
values based on the truth values of their components.

1. I ate so much that I felt sick.


2. I have neither a dress nor shoes.

3. I’m going home or to my friend’s place.


4. I’ll go outside if it’s not raining.
5. I’ll go to him only if he doesn’t listen to me.
6. If I don’t go fishing, then the sun isn’t round.

7. If the sun isn’t round, then I’ll go fishing.

Exercise 12. Reformulate the examples in Section 2.9 so that ambiguities


are avoided. You can choose any interpretation.

Part I - Propositional Logic 16 Lecture notes - to print in color


Chapter 3

The Formal Syntax of


Propositional Logic

Next, we will study the formal language of propositional logic.


By syntax we generally understand a set of rules for writing correctly. As
mentioned previously, in this chapter we develop an artificial language, that
we call formal propositional logic (or simply propositional logic). The formal
syntax of propositional logic refers to the rules for writing correctly in this
language.

3.1 Alphabets in Computer Science


A set is called an alphabet in computer science if we use the elements of the
set to make up words. The elements of an alphabet are called symbols. Most
of the time, an alphabet is a finite set (but not in the case of propositional
logic).
What is the difference between an alphabet and a set? A priori, none.
The intention matters – what we plan on doing with the elements of the
set/alphabet. We use the elements of an alphabet to create words. A word
over an alphabet is a sequence of symbols in the alphabet.

Example 13. Consider the alphabet X = {0, 1}. The strings/sequences of


symbols 001010, 101011 and 1 are examples of words of the alphabet X.

The empty word, formed of 0 symbols of the alphabet, is usually denoted


by .

17
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

3.2 The Alphabet of Propositional Logic


The language of propositional logic is made of propositional formulae, which
model propositions, as discussed in the previous chapter.
Propositional formulae are strings (sequences of characters) over the al-
phabet of propositional logic.
The alphabet of propositional logic is the union of the following sets:

1. A = {p, q, r, p0 , q1 , . . .} is an infinite set of propositional variables that we


fix from the very beginning;
2. {¬, ∧, ∨} is the set of logical connectives;
3. {(, )} is the set of auxiliary symbols; in our case, it consists of two symbols
called brakets.

The set L = A ∪ {¬, ∧, ∨} ∪ {(, )} is the alphabet of propositional logic.


Here are a few examples of words over L:

1. ))p ∨ ∧;
2. ∨ ∨ ¬(p);
3. p;
4. ppp;
5. ¬(p ∨ q).

Words, or strings, are simply sequences of symbols of the alphabet L.


Some of these words will be formulae or, equivalently, well-formed formulae
(wff). Some authors prefer to use the terminology wff, but we will simply use
formula by default in these lecture notes.
As an example, the last word above, ¬(p ∨ q) is a formula of propositional
logic, but ∨ ∨ ¬(p) is not. The following definition captures exactly the set
of propositional formulae.

3.3 Propositional Formulae


Definition 14 (The Set of Propositional Formulae (PL)). The set of formulae
of propositional logic, denoted PL from hereon, is the smallest set of words
over L satisfying the following conditions:

• Base Case. Any propositional variable, seen as a 1-symbol word, is in PL


(equivalently, A ⊆ PL);

Part I - Propositional Logic 18 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

• Inductive Step i. If ϕ ∈ PL, then ¬ϕ ∈ PL (equivalently, if the word ϕ is


a propositional formula, then so is the word starting with the symbol ¬ and
continuing with the symbols in ϕ);
• Inductive Step ii. If ϕ1 , ϕ2 ∈ PL, then (ϕ1 ∧ ϕ2 ) ∈ PL (equivalently, exer-
cise);
• Inductive Step iii. If ϕ1 , ϕ2 ∈ PL, then (ϕ1 ∨ ϕ2 ) ∈ PL (equivalently, ex-
ercise);

Here are examples of elements of PL:

p q ¬p ¬q ¬p0 ¬¬p1 (p ∨ q) (p ∧ q)

¬(p ∨ q) (¬p ∧ ¬q) ¬(¬¬p ∨ p) ((p ∨ q) ∧ r) (p ∨ (q ∧ r))

Here are examples of words not in PL:

pp q¬q q ∧ ¬p p+q

The definition of the set PL is an example of an inductive definition. Such


definitions are really important in computer science and it is a must to un-
derstand them very well. In inductive definitions of sets, there are usually
some base cases, which say what base elements are part of the set and some
inductive cases, which explain how to obtain new elements of the set from old
elements. Another important part of an inductive definition is the minimality
constraint, which says that nothing other than what is provable by the base
case(s) and the inductive case(s) belongs to the set. It can be shown that the
above set PL exists and is unique, but the proof is beyond the scope of this
course.

3.4 Showing That a Word Is In PL


We can show that a word belongs to PL by explaining how the rules of
the inductive definition were applied. Here is an example of a proof that
¬(p ∨ q) ∈ PL:

1. p ∈ PL (by the Base Case, because p ∈ A);


2. q ∈ PL (by the Base Case, as q ∈ A);
3. (p ∨ q) ∈ PL (by the Inductive Case iii, with ϕ1 = p and ϕ2 = q);
4. ¬(p ∨ q) ∈ PL (by the Inductive Case i, with ϕ = (p ∨ q)).

Part I - Propositional Logic 19 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

We can rearrange the above into an equivalent annotated construction tree


for the formula ¬(p ∨ q):

Base Case Base Case


p ∈ PL q ∈ PL
Inductive Case iii
(p ∨ q) ∈ PL
Inductive Case i
¬(p ∨ q) ∈ PL
You will often see this notation in Computer Science and it is worth getting
to know it. Each line is called an inference; below each line is the conclusion
of the inference and above the lines are the hypotheses (0, 1 or more). Besides
each line is the name of the rule that was applied.
If we drop all annotation, we obtain the following bare construction tree
for the formula:

p q
(p ∨ q)
¬(p ∨ q)
It is easy to see that a word belongs to PL iff there is a construction tree
for it.

3.5 The Main Connective of a Formula


A formula that consists of a single propositional variable, such as p or q,
is called an atomic formula. This explains why the set A of propositional
variables is called A (A stands for atomic).
More complex formulae, such as ¬p or p ∨ q, are called molecular (to
distinguish them from atomic formulae).
Each molecular formula has a main connective, which is given by the last
inference in its construction tree. For example, the main connective of the
formula ¬(p ∨ q) is ¬ (the negation), while the main connective of the fomrula
(¬p ∨ q), is ∨ (the disjunction). We call formulae whose main connective is
∧ conjunctions. Similarly, if the main connective of a formula is a ∨, it is a
disjunction and if the main connective is ¬, then it is a negation.

3.6 Showing That a Word Is Not in PL


It is somewhat more difficult (or rather more verbose) to show that a word is
not in PL.

Part I - Propositional Logic 20 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

If the word is not over the right alphabet, such as the three-symbol word
p + q, which uses a foreign symbol +, then we can easily dismiss it as PL
only contains words over L.
However, if the word is over the right alphabet and we want to show that
it is not part of PL, we must make use of the minimality condition. Here is
an example showing that (p¬q) 6∈ PL:
Let’s assume (by contradiction) that (p¬q) ∈ PL. Then, by the minimal-
ity condition, it follows that (p¬q) ∈ PL must be explained by one of the
rules Base Case, Inductive Case i – iii.
But we cannot apply the Base Case to show that (p¬q) 6∈ PL, since
(p¬q) 6∈ A.
But we cannot apply the Inductive Case i either, because there is no
formula ϕ such that (p¬q) = ¬ϕ (no matter how we would choose ϕ ∈ PL,
the first symbol of the word on the lhs would be (, while the first symbol of
the word on the rhs would be ¬).
But we cannot apply the Inductive Case ii either, because there are no
formulae ϕ1 , ϕ2 ∈ PL such that (p¬q) = (ϕ1 ∨ ϕ2 ) (no matter how we would
choose ϕ1 , ϕ2 ∈ PL, the word on the lhs would not contain the symbol ¬,
while while the the word on the rhs would contain it).
By similar reasons, we cannot apply Inductive Case iii either.
But this contradicts our assumption and therefore it must be the case that
(p¬q) 6∈ PL.

3.7 Unique Readability


The definition of PL has an important property called unique readability:
Theorem 15 (Unique Readability of Propositional Formulae). For any word
ϕ ∈ PL, there is a unique construction tree.
The property above is also sometimes called unambiguity of the grammar.
Proving the Unique Readability Theorem is beyond the scope of the present
lecture notes. Instead we will try to understand the importance of the prop-
erty above by showing how an alternative, fictive, definition of the set PL
would be ambiguous:
Beginning of Wrong Definition of PL.
Imagine that the Inductive Case ii would read:
..
.

3. (Inductive Step ii) If ϕ1 , ϕ2 ∈ PL, then ϕ1 ∨ ϕ2 ∈ PL.

Part I - Propositional Logic 21 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

..
.
The only difference would be that we do not place parantheses around
disjunctions. With this alternative, fictive, definition of PL, we have that
the word ¬p ∨ q ∈ PL. However, this word has two different construction
trees:

p q p
p∨q ¬p q
¬p ∨ q ¬p ∨ q
Such an ambiguity would be very troubling, because we would not know
if ¬p ∨ q is a disjunction (if we would use the construction tree on the right)
or a negation (the construction tree on the left). In fact, avoiding such
syntactic ambiguities was the main reason why we left natural language
and began studying formal logic.
End of Wrong Definition of PL.
I hope that you can now see that the Unique Readability Theorem is non-
trivial (as an exercise to the more mathematically inclined students, I suggest
that you try to prove it) and that it is a very important property of our
definition of formulae, since it essential says that any propositional formula
can be read unambiguously.

3.8 Object-language and meta-language


A peculiarity in logic is that we study propositions (we analyse, for example,
their truth values), but in order to perform such study, we use a form of
reasoning that also uses propositions. For example, in our study, we could
make the following argument:

The proposition I do not go to school is false if the proposition I


go to school is true.

Note that the sentences that are the object of our study (I do not go to
school and I go to school) are propositions, but so is the entire statement The
proposition I do not go to school is false if the proposition I go to school is
true. In this way, it seems that we are performing a circular reasoning, in
which we study our own method of study.
This apparent difficulty does not occur in the case of arithmetic, for ex-
ample. In arithmetic, we study numbers and operations over numbers, and
we reason about numbers using propositions.

Part I - Propositional Logic 22 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

The difficulty can be solved by strictly separating the object language from
the meta-language. The object language is the language that we study (PL),
and the meta-language is the language that we use to perform the study
(English).

The object language is the language that represents the object of


our study (in our case, propositional logic). The meta-language
is the language that we use to communicate about the object of
our study (in our case, English).

In this course, to more easily differentiate between the two, we make the
following convention: all elements in the object language are written in sans-
serif blue font (for example, (p ∧ q)), and the statement in the meta-language
are written using a regular black font (for example, any atomic formulae is a
formula).

It is extremly important to differentiate correctly between object


language and meta-language. To this effect, the lecture notes use
a typographic convention. The elements of the meta-language are
written in regular black font. The elements of the object-language
are writte as follows: (p ∧ q). For this reason, if you print out
the lecture notes, please print them in color.

3.9 Exercise Sheet


Exercise 16. Show that the following words are propositional formulae (i.e.,
element of PL), by explaining which are the construction steps (base case,
respectively one of the three inductive steps):

1. ¬q;

2. (p1 ∧ q);

3. ¬(p ∨ q);

4. (¬p ∨ ¬q);

5. ¬(¬p ∨ (q ∧ ¬q)).

Part I - Propositional Logic 23 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Exercise 17. Show that the following words over the alphabet L are not
elements of PL(hint: show that none of the four construction rules applies):

1. ((¬)q);
2. q ∧ ¬;
3. pq;

4. p ∧ q;
5. (p¬q);
6. (p) ∧ (q).

Exercise 18. Which of the following are formulae (in PL) and which are
not:

1. p1 ;
2. p1 ∨ q1 ;
3. (p1 ∨ q1 );

4. (¬p1 ∨ q1 );
5. ¬(p1 ∨ q1 );
6. ((¬p1 ) ∨ q1 );

7. (¬p)?

Exercise 19. Please provide 5 examples of interesting formulae (with many


variables/operators, etc.).

Part I - Propositional Logic 24 Lecture notes - to print in color


Chapter 4

Functions Defined
Recursively on PL

Reminder. Recall that when X is a set, by 2X we denote the powerset of


X, that is, the set of all subsets of X. For example, if X = {1, 2, 3}, then
2X = {∅, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}. When X is finite, note
that |2X | = 2|X| , which partly explains this notation. You might have used the
notation P(X) instead of 2X in highschool.
Whenever a set is inductively defined, we can define recursive functions
that operate on the elements of the set, function which make use of the struc-
ture of the elements.
Here is an example of a function computing the set of subformulae of a
formula:
subf : PL → 2PL , defined by:


 {ϕ}, if ϕ ∈ A;



  

{ϕ} ∪ subf ϕ0 , if ϕ = ¬ϕ0 and ϕ0 ∈ PL;








      
subf ϕ = {ϕ} ∪ subf ϕ1 ∪ subf ϕ2 ,




 if ϕ = (ϕ1 ∧ ϕ2 ) and ϕ1 , ϕ2 ∈ PL;



    

{ϕ} ∪ subf ϕ ∪ subf ϕ2 ,

1




if ϕ = (ϕ1 ∨ ϕ2 ) and ϕ1 , ϕ2 ∈ PL.

25
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

 
Here is how we can compute subf ϕ when ϕ = ¬(p ∨ q):

   
subf ¬(p ∨ q) = {¬(p ∨ q)} ∪ subf (p ∨ q)
   
= {¬(p ∨ q)} ∪ {(p ∨ q)} ∪ subf p ∪ subf q
= {¬(p ∨ q)} ∪ {(p ∨ q)} ∪ {p} ∪ {q}
= {¬(p ∨ q), (p ∨ q), p, q}.

Notice that we use two different types of brackets in the computation


above. On one hand, we have the brackets that surround the argument to
the function subf, and on the other hand we have the usual brackets that
are part of the alphabet L. The former brackets are the usual brakets in
mathematics, while the later brackets are simply symbols in our alphabet. In
order to differentiate between them, we adopt the convention to use bigger
brakets for the function call and the usual brackets in blue for the auxiliary
symbols.
Note
 that
 both are important.
 For
 example, it would be an error to write
subf p ∨ q instead of subf (p ∨ q) , as the word p ∨ q 6∈ PL is not a formula.

   
It is an error to write subf p ∨ q instead of subf (p ∨ q) , as
the word p ∨ q 6∈ PL is not a formula.

The function subf is the first in a long line of functions defined recursively
on the structure of a formula ϕ ∈ PL. These functions are called structurally
recursive. It is very important to understand how such functions operate in
order to understand the remainder of this course. In the following sections
we provide more examples of such functions.

4.1 The Abstract Syntax Tree of a Formula


Here is an example of a function which computes the abstract syntax tree of
a formula:
ast : PL → Trees, defined by:

Part I - Propositional Logic 26 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University




 ϕ , if ϕ ∈ A;





¬





if ϕ = ¬ϕ0 and ϕ0 ∈ PL;

 ,



0

ast ϕ












  
ast ϕ =    ,


 ast ϕ1 ast ϕ2


if ϕ = (ϕ1 ∧ ϕ2 ) and ϕ1 , ϕ2 ∈ PL;
















 ,



  
ast ϕ ast ϕ2

1





if ϕ = (ϕ1 ∨ ϕ2 ) and ϕ1 , ϕ2 ∈ PL.

Here is the computation of the abstract syntax tree of the formula ((p ∧ ¬q) ∧ r).

  ∧
ast ((p ∧ ¬q) ∧ r) =    
ast (p ∧ ¬q) ast r

= ∧ r
   
ast p ast ¬q

∧ r
=
p ¬
 
ast q

Part I - Propositional Logic 27 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

∧ r .
=
p ¬

Note that Trees is the set of labeled, rooted trees.


The abstract syntax trees are very important because, conceptually, a
propositional formula is its abstract syntax tree. Because writing trees is
cumbersome for humans, we use the more conventional left-to-right notation.
However, when implementing various algorithms as computer programs we
prefer the tree representation, which is way more convenient.

Conceptually, a formula is its abstract syntax tree.

4.2 Other Examples of Recursively Defined Func-


tions
Here are other examples of functions defined by structural recursion on for-
mulae.
The first function, height : PL → N, computes the height of the ast o
formula:


 1, if ϕ ∈ A;



  

1 + height ϕ0 , if ϕ = ¬ϕ0 and ϕ0 ∈ PL;







        
height ϕ = 1 + max height ϕ1 , height ϕ2 ,




 if ϕ = (ϕ1 ∧ ϕ2 ) and ϕ1 , ϕ2 ∈ PL;



     

 1 + max height ϕ1 , height ϕ2 ,




if ϕ = (ϕ1 ∨ ϕ2 ) and ϕ1 , ϕ2 ∈ PL.

The function max : N × N → N, which occurs in the definition of height,


is the well-known function that computes the maximum between two natural
numbers.

Part I - Propositional Logic 28 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

The next function, size : PL → N, computes the size of the abstract syn-
tax tree of a formula (i.e., the number of nodes):


 1, if ϕ ∈ A;



  

1 + size ϕ0 , if ϕ = ¬ϕ0 and ϕ0 ∈ PL;








      
size ϕ = 1 + size ϕ1 + size ϕ2 ,




 if ϕ = (ϕ1 ∧ ϕ2 ) and ϕ1 , ϕ2 ∈ PL;



    

1 + size ϕ1 + size ϕ2 ,





if ϕ = (ϕ1 ∨ ϕ2 ) and ϕ1 , ϕ2 ∈ PL.

The final example function, prop : PL → 2A , compute the set of proposi-


tional variables occurring in a formula:


 {ϕ}, if ϕ ∈ A;



  

prop ϕ0 , if ϕ = ¬ϕ0 and ϕ0 ∈ PL;








    
prop = prop ϕ1 ∪ prop ϕ2 ,




 if ϕ = (ϕ1 ∧ ϕ2 ) and ϕ1 , ϕ2 ∈ PL;



    

prop ϕ ∪ prop ϕ2 ,

1




if ϕ = (ϕ1 ∨ ϕ2 ) and ϕ1 , ϕ2 ∈ PL.

Make sure that you are proficient at understanding, defining and comput-
ing with functions such as those given above.

4.3 Proofs by Structural Induction


We will sometimes do proofs by structural induction. You are already familiar
with proofs by induction on the naturals.
In order to prove a theorem of the form

For all n ∈ N, it is true that P (n),

the mathematical induction principle postulates that it is sufficient to show


that:

1. (Base Case) P (0) holds;

Part I - Propositional Logic 29 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

2. (Induction Case) P (k) implies P (k + 1), for all k ∈ N.


Proofs by structural induction generalize the principle above to any in-
ductively defined set such as PL.
For the case of PL, the structural induction principle is that, in order to
show a theorem of the form
 
For any propositional formula ϕ ∈ PL, it is true that P ϕ ,

it is sufficient to prove that:


 
1. (Base Case) P ϕ0 holds for any atomic formula ϕ0 ∈ A (otherwise put,
the property P holds of every atomic formula);
   
2. (Inductive Case i) P ¬ϕ0 holds whenever P ϕ0 holds;
     
3. (Inductive Case ii) P (ϕ1 ∧ ϕ2 ) holds whenever P ϕ1 and P ϕ2
hold;
     
4. (Inductive Case iii) P (ϕ1 ∨ ϕ2 ) holds whenever P ϕ1 and P ϕ2
hold.
Here is an example of a theorem and its proof by structural induction:
Theorem 20 (Example of Theorem Provable byStructural
 Induction).
 For
any propositional formula ϕ, we have that height ϕ ≤ size ϕ .

Proof: We  proceed
 bystructural induction (the property P (ϕ) is simply
that height ϕ ≤ size ϕ ). It is sufficient to show that:
   
1. (Base Case) height ϕ0 ≤ size ϕ0 for any propositional variable ϕ0 ∈
A.    
But by definition, height ϕ0 = 1 and size ϕ0 = 1 when ϕ0 ∈ A. And
1 ≤ 1, which is what we had to show.
   
2. (Inductive Case i) Assuming that height ϕ0 ≤ size ϕ0 , we show that
   
height ¬ϕ0 ≤ size ¬ϕ0 .
     
But by definition, height ¬ϕ0 = 1 + height ϕ0 and size ¬ϕ0 =
     
1 + size ϕ0 . And 1 + height ϕ0 ≤ 1 + size ϕ0 (what we had to
   
show), as we already know height ϕ0 ≤ size ϕ0 .

Part I - Propositional Logic 30 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

     
3. (Inductive Case ii) Assuming that height ϕ1 ≤ size ϕ1 and height ϕ2 ≤
     
size ϕ2 , we show height (ϕ1 ∨ ϕ2 ) ≤ size (ϕ1 ∨ ϕ2 ) .
      
But, by definition, height (ϕ1 ∨ ϕ2 ) = 1+max height ϕ1 , height ϕ2
 max(a, b) ≤ a + b (forany naturals a, b∈ N), we have
and, as  that

height (ϕ1 ∨ ϕ2 ) ≤ 1 + height ϕ1 + height ϕ2 . But height ϕi ≤
   
size ϕi (1 ≤ i ≤ 2) by our hypothesis, and therefore height (ϕ1 ∨ ϕ2 ) ≤
     
1 + size ϕ1 + size ϕ2 . But, by definition, size (ϕ1 ∨ ϕ2 ) = 1 +
       
size ϕ1 +size ϕ2 , and therefore height (ϕ1 ∨ ϕ2 ) ≤ size (ϕ1 ∨ ϕ2 ) ,
what we had to prove.
4. (Inductive Case iii) Similar to Inductive Case ii.

q.e.d.

4.4 Exercise Sheet


Exercise 21. Compute, using the function subf, the set of subformulae of the
following formulae:
1. ((p ∧ ¬q) ∧ r); 2. ((p ∨ ¬q) ∧ r); 3. ¬((p ∨ ¬q) ∧ r).
Exercise 22. Compute the abstract syntax trees of the following formulae:

1. ((p ∧ ¬q) ∧ r);


2. ((p ∨ ¬q) ∧ r);
3. ¬((p ∨ ¬q) ∧ r);
4. (¬(p ∨ ¬q) ∧ r).

Exercise 23. Recall the recursive definition of the function height : PL →


N, which computes, given a formula, the height of its abstract syntax tree.
Compute the height of the formulae shown in Exercise 22.
Exercise 24. Recall the recursive definition of the function size : PL → N,
which computes the number of nodes in abstract syntax tree of a formula.
Compute the size of the formulae shown in Exercise 22.
Exercise 25. Recall the recursive definition of the function prop : PL → 2A ,
which computes, given a formula, the set of propositional variables occuring
in the formula. Compute the set of propositional variables occuring in the
formulae shown in Exercise 22.

Part I - Propositional Logic 31 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Exercise 26. Show by structural induction that height(ϕ) < size(ϕ) + 1 for
any formula ϕ ∈ PL.

Part I - Propositional Logic 32 Lecture notes - to print in color


Chapter 5

Semantics of Propositional
Logic

5.1 Boolean Algebra


The set B = {0, 1} is called the set of boolean values (also called truth values).
The value 0 denotes falsehood and the value 1 denotes truth.
The function : B → B is called logical negation and is defined as follows:
0 = 1 and 1 = 0.
The function + : B × B → B is called logical disjunction and is defined as
follows: 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 1.
The function · : B × B → B is called logical conjunction and is defined as
follows: 0 · 0 = 0, 0 · 1 = 0, 1 · 0 = 1, 1 · 1 = 1.
The tuple (B, +, ·, ) is a boolean algebra.

5.2 Assignments
A truth assignment (or simply assignment from hereon) is any function τ :
A → B. In other words, an assignment is a function that associates to any
propositional variable a truth value.

Example 27. Let τ1 : A → B be a function defined as follows:

1. τ1 (p) = 1;

2. τ1 (q) = 0;

3. τ1 (r) = 1;

33
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

4. τ1 (a) = 0 for all a ∈ A \ {p, q, r}.

As it is a function from A to B, τ1 is a truth assignment.


Example 28. Let τ2 : A → B be a function defined as follows:

1. τ2 (p) = 0;
2. τ2 (q) = 0;
3. τ2 (r) = 1;
4. τ2 (a) = 1 for all a ∈ A \ {p, q, r}.

As it is a function from A to B, τ2 is also a truth assignment.


Example 29. Let τ3 : A → B be a function defined as follows:

1. τ3 (a) = 0 for all a ∈ A.

As it is a function from A to B, τ3 is also a truth assignment.

5.3 Truth Value of A Formula in An Assign-


ment
 
The truth value of a formula ϕ in an assignment τ is denoted by τ̂ ϕ and is
defined recursively as follows:

 τ (ϕ),
 if ϕ ∈ A;



  

τ̂ ϕ0 , if ϕ = ¬ϕ0 and ϕ0 ∈ PL;







       
τ̂ ϕ = τ̂ ϕ1 · τ̂ ϕ2 ,

if ϕ = (ϕ1 ∧ ϕ2 ) and ϕ1 , ϕ2 ∈ PL;







    

 τ̂ ϕ1 + τ̂ ϕ2 ,




if ϕ = (ϕ1 ∨ ϕ2 ) and ϕ1 , ϕ2 ∈ PL.

In fact τ̂ : PL → B is a function called the homomorphic extension of


the assignment τ : A → B to the entire set of formulae PL, but do not feel
obligated to recall this name.
Here is an example of how to compute the truth value of the formula
(p ∨ q) in the truth assignment τ1 :

Part I - Propositional Logic 34 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

     
τ̂1 (p ∨ q) = τ̂1 p + τ̂1 q = τ1 (p) + τ1 (q) = 1 + 0 = 1.
We conclude that the truth value of (p ∨ q) in τ̂1 is 1.
Here is another example, where we compute the truth value of the formula
¬(p ∧ q) in the truth assignment τ1 :
       
τ̂1 ¬(p ∧ q) = τ̂1 (p ∧ q) = τ̂1 p · τ̂1 q = τ1 (p) · τ1 (q) = 1 · 0 = 0 = 1.
We conclude that the truth value of the formula ¬(p ∧ q) in τ1 is 1.
Here is yet another example, where we compute the truth value of the
formula ¬¬q in the truth assignment τ2 :
     
τ̂2 ¬¬q = τ̂2 ¬q = τ̂2 q = τ2 (q) = 0 = 1 = 0. So the truth value of
¬¬q in τ2 is 0.

Remark. It does not make sense to say “the truth value of a formula”. It
makes sense to say “the truth value of a formula in an assignment”.
Also, it does not make sense to say “the formula is true” or “the formula
is false”. Instead, it makes sense to say “this formula is true/false in this
assignment”.
This is because a formula could be true in an assignment but false in
another. For example, the formula ¬¬p is true in τ1 , but false in τ2 .

In general, it does not make sense to say the truth value of a


formula because a formula can be true for an assignment and
false for another assignment. It only makes sense to say the truth
value of a formula in an assignment.

 
Definition 30 (Satisfaction). An assignment τ satisfies ϕ if τ̂ ϕ = 1.

Instead of τ satisfies ϕ, we may equivalently say any of the following:

1. τ is a model of ϕ;

2. τ is true of ϕ;

3. ϕ holds in/at τ ;

4. τ makes ϕ true;

Example 31. The assignment τ1 defined above is a model for ¬(p ∧ q). The
assignment τ1 is not a model of the formula (¬p ∧ q).

Part I - Propositional Logic 35 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

We write τ |=
 ϕ (and we read: τ is a model of the formula ϕ; or: τ satisfies
ϕ, etc.) iff τ̂ ϕ = 1. We write τ 6|= ϕ (and we read: τ is not a model of the
 
formula ϕ; or: τ does not satisfy ϕ) iff τ̂ ϕ = 0.

Definition 32 (The satisfaction relation (written |=)). The relation |=, be-
tween assignments and formulae,  is called the satisfaction relation. It is de-
fined as follows: τ |= ϕ iff τ̂ ϕ = 1.

 
The satisfaction relation |= is defined as: τ |= ϕ iff τ̂ ϕ = 1.

5.4 Satisfiability
Definition 33. A formula ϕ is satisfiable if, by definition, there exists at
least an assignment τ such that τ |= ϕ (i.e., if there exists at least a model of
ϕ).
Example 34. The formula (p ∨ q) is satisfiable, since it has a model (for
example τ1 above).
Example 35. The formula ¬p is also satisfiable: for example, the assignment
τ3 above makes the formula true.
Example 36. The formula (p ∧ ¬p) is not satisfiable, since it is false in any
assignment.

Proof: Let us consider an arbitrary assignment τ : A → B.


       
We have that τ̂ (p ∧ ¬p) = τ̂ p · τ̂ ¬p = τ (p) · τ̂ p = τ (p) · τ (p).
But τ (p) can be either 0 or 1:
 
1. in the first case (τ (p) = 0), we have that τ̂ (p ∧ ¬p) = . . . = τ (p) ·
τ (p) = 0 · 0 = 0 · 1 = 0;
 
2. in the second case (τ (p) = 1) , we have that τ̂ (p ∧ ¬p) = . . . =
τ (p) · τ (p) = 1 · 1 = 1 · 0 = 0.
 
So, in both situations (i.e., τ (p) is either 0 or 1) we have τ̂ (p ∧ ¬p) =
0. But τ was chosen arbitrarily, and therefore the result must hold for any

Part I - Propositional Logic 36 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

assignment τ : (p ∧ ¬p) is false in any assignment, which means that it is


not satisfiable.
q.e.d.

Definition 37 (Contradiction). A formula that is not satisfiable is called a


contradiction.

Example 38. As we have seen above, (p ∧ ¬p) is a contradiction.

5.5 Valid Formulae


Definition 39. A formula
 ϕ is valid if, by definition, any assignment τ has
the property that τ̂ ϕ = 1 (any assignment is a model of the formula).

Definition 40 (Tautology). A valid formula is also called a tautology.

Example 41. The formula (p ∨ ¬p) is valid, because it is true


 in anyas-
signment: let τ be an arbitrary assignment; we have that τ̂ (p ∨ ¬p) =
τ (p) + τ (¬p), which is either 0 + 1 or 1 + 0, which is 1 in any case.

Notation. We sometimes write |= ϕ instead of ϕ is valid.

Example 42. The formula p is not valid (because there is an assignment (for
example τ3 ) that makes it false).

5.6 Contingent Formulae


Definition 43. A formula that is neither a contradiction nor a tautology is
called contingent.

Example 44. Examples of formulas of each type are shown here:

1. (p ∧ ¬p) is a contradiction.

2. p is contingent.

3. (p ∨ ¬p) is a tautology.

5.7 Equivalence
Definition 45. We say that two formulae ϕ1 , ϕ2 ∈ PL  are
 equivalent
  and
we write ϕ1 ≡ ϕ2 if, for any assignment τ : A → B, τ̂ ϕ1 = τ̂ ϕ2 .

Part I - Propositional Logic 37 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Intuitively, formulae that are equivalent have the same meaning (express
the same thing).

Example 46. At the start of the course, someone asked whether p and ¬¬p
are equal. Of course not, I said, since one has 1 symbol and the other 3
symbols from the alphabet.
However, we are now ready to understand the relation between them: p ≡
¬¬p. In other words, even if they are not equal, they are equivalent: they
express the same thing.
To prove p 𠪪p, we have to show they have the same truth value in
any assignment. Let τ be an arbitrary assignment. We have that τ̂ ¬¬p =
     
τ (p) = τ (p) = τ̂ p . In summary, τ̂ ¬¬p = τ̂ p . As τ was chosen
   
arbitrarily, it follows that τ̂ ¬¬p = τ̂ p for any assignment τ and therefore
p is equivalent to ¬¬p.

Example 47. The following equivalence holds: (p ∨ q) ≡ ¬(¬p ∧ ¬q) (check


it).

Here are two more equivalences, known as De Morgan’s laws:

Theorem 48. For any formulae ϕ1 , ϕ2 ∈ PL, we have that:

1. ¬(ϕ1 ∨ ϕ2 ) ≡ (¬ϕ1 ∧ ¬ϕ2 );

2. ¬(ϕ1 ∧ ϕ2 ) ≡ (¬ϕ1 ∨ ¬ϕ2 ).

5.8 Semantical Consequence


Definition 49. Let Γ = {ϕ1 , . . . , ϕn , . . .} be a set of formulae. We say that
ϕ is a semantical consequence of Γ and we write Γ |= ϕ, if is any model of
all formulae in Γ is a model of ϕ as well.

We also say that ϕ is a logical consequence of Γ or that ϕ is a tautological


consequence of Γ instead of ϕ is a semantical consequence of Γ.

Example 50. Let Γ = {p, (¬p ∨ q)}. We have that Γ |= q.


Indeed, let τ be a model of p and of (¬p ∨ q). As τ is a model of p, by
definition, we have that τ (p) = 1.  
As τ is a model of (¬p ∨ q), it follows that τ̂ (¬p ∨ q) = 1. But
   
τ̂ (¬p ∨ q) τ (p) + τ (q). But τ (p) = 1, and therefore τ̂ (¬p ∨ q) = 0 +
τ (q) = τ (q). This means that τ (q) = 1.

Part I - Propositional Logic 38 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

This means that τ is a model of q. We assumed that τ is a model of p


and of (¬p ∨ q) and we show that necessarily τ is a model of q. But this is
exactly the definition of {p, (¬p ∨ q)} |= q which is exactly what we want to
prove.
Example 51. We have that p, (p ∨ q) 6|= ¬q, that is ¬q is not a logical
consequence of p, (p ∨ q). To show this “unconsequence”, it is sufficient to
find a model of p and (p ∨ q) that is not a model of q. Any assignment τ
with τ (p) = 1 and τ (q) = 0 will do.
Notation. We sometimes write

ϕ1 , . . . , ϕn |= ϕ

instead of
{ϕ1 , . . . , ϕn } |= ϕ.
Remark. When n = 0, the notation above allows us to we write |= ϕ instead
of {} |= ϕ. This is consistent will the notation for validity, since a formula
which is a logical consequence of the empty set is valid (and vice-versa).

5.9 Consistent set of formulae


Another semantical notion is that occurs relatively often in practice and is
strongly related to the ∧ is the notion of (in)consistent set of formulae.
Definition 52 (Consistent set of formulae). A set {ϕ1 , ϕ2 , . . . , ϕn } of formu-
lae is consistent if there is an assignment τ that satisfies all ϕi (1 ≤ i ≤ n).
Remark. Important: the assignment τ must be the same for each formula in
the set (not a different assignment τ for each formula ϕi , where 1 ≤ i ≤ n)!
A set of formulae is inconsistent if it is not consistent.
Lemma 53 (The link between consistent sets and the logical connector ∧).
A set of formulae {ϕ1 , ϕ2 , . . . , ϕn } is consistent if and only if the formula

(((ϕ1 ∧ ϕ2 ) ∧ . . .) ∧ ϕn )

is satisfiable.
Lemma 54 (The link between inconsistent sets and the logical connector ∧).
A set of formulae {ϕ1 , ϕ2 , . . . , ϕn } is inconsistent if and only if the formula

(((ϕ1 ∧ ϕ2 ) ∧ . . .) ∧ ϕn )

is not satisfiable.

Part I - Propositional Logic 39 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Exercise 55. Show that, for any formula ϕ, if {ϕ1 , ϕ2 , . . . , ϕn } is inconsistent


then
{ϕ1 , ϕ2 , . . . , ϕn } |= ϕ.
Exercise 56. Show that if

{ϕ1 , ϕ2 , . . . , ϕn } |= (p ∧ ¬p),

then {ϕ1 , ϕ2 , . . . , ϕn } is inconsistent.

5.10 Application 1
John writes the following code:

if (((y % 4 == 0) && (y % 100!= 0)) || (y%400 == 0))


printf("%d is a leap y", y);
else
printf("%d is not a leap y", y);

Jill simplifies the code:

if (((y % 4 != 0) || (y % 100 == 0)) && (y%400 != 0))


printf("%d is not a leap y", y);
else
printf("%d is a leap y", y);

Is Jill right? It is difficult to tell just by looking at the code, but we can
use our logic-fu to model the problem above and to determine whether the
two programs behave in the same manner.
First of all, we will “translate” the conditions in the if-else statements into
propositional logic. Supposed the value of y is fixed. We identify the “atomic
propositions” and we replace them with propositional variables as follows:

1. the propositional variable p will stand for (y % 4 == 0);


2. the propositional variable q will stand for (y % 100 = 0);
3. the propositional variable r will stand for (y % 400 == 0).

Taking into account the translation key above, we can see that John’s
condition is, in propositional logic speak, ((p ∧ ¬q) ∨ r).
Jill’s formula is, in propositional logic speak,((¬p ∨ q) ∧ ¬r).
Also notice that the branches in the two programs are reversed (the if
branch of John’s program is the else branch of Jill’s program and vice-versa).
In order for the two programs to have the same behaviour, it is sufficient for

Part I - Propositional Logic 40 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

the negation of John’s formula to be equivalent to Jill’s formula. Is this the


case? I.e., is it the case that

¬((p ∧ ¬q) ∨ r) ≡ ((¬p ∨ q) ∧ ¬r)?

By applying De Morgan’s laws, we can see that the equivalence does hold
and therefore the two programs have the same behaviour. So Jill’s changes
do not break the program – they are correct.

5.11 Exercise Sheet


Exercise 57. Let τ : A → B be the truth assignment defined as follows:
τ (p) = 1, τ (q) = 0, τ (r) = 0, τ (a) = 0 for any other propositional variable
a ∈ A \ {p, q, r}.
Find the truth value of the following formulae in the assignment τ :

1. (p ∧ q);
2. (q ∧ p);
3. ¬q;
4. (¬q ∧ r);
5. ((¬q ∧ r) ∨ ¬p).

Exercise 58. Find an assignment τ that is a model for the following formulae
(one assignment for each formula):

1. (p ∧ q);
2. (p ∧ ¬q);
3. ((p ∧ ¬q) ∨ q).

Is there a single assignment that makes all these formulas true?


Exercise 59. Find an assignment τ in which the following formulae are false
(one assignment per formula):

1. (p ∨ q);
2. (q ∧ (p ∨ ¬q));
3. ((p ∧ ¬q) ∨ q).

Exercise 60. Which of the following formulae are satisfiable?

Part I - Propositional Logic 41 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

1. (p ∧ ¬p);
2. (p ∨ ¬p);
3. ((p ∨ ¬p) ∧ ¬q);
4. ((p ∨ ¬p) ∧ (¬p ∧ q));
5. ((p ∨ ¬q) ∧ (¬p ∨ r)).

Exercise 61. Which of the following formulae are valid?

1. (p ∧ ¬p);
2. (p ∨ ¬p);
3. p;
4. ((p ∨ ¬p) ∧ ¬q);
5. (p → ¬p);
6. ((p ∧ q) ∨ (¬p ∧ r)).

Exercise 62. Give 5 examples of contradictions.


Exercise 63. Give 5 examples of tautologies.
Exercise 64. Prove that, for any formulae ϕ1 , ϕ2 , ϕ3 ∈ PL, the following
equivalences hold:

1. (ϕ1 ∧ (ϕ2 ∧ ϕ3 )) ≡ ((ϕ1 ∧ ϕ2 ) ∧ ϕ3 );


2. (ϕ1 ∧ ϕ2 ) ≡ (ϕ2 ∧ ϕ1 );
3. (ϕ1 ∨ (ϕ2 ∨ ϕ3 )) ≡ ((ϕ1 ∨ ϕ2 ) ∨ ϕ3 );
4. (ϕ1 ∨ ϕ2 ) ≡ (ϕ2 ∨ ϕ1 );
5. (¬(¬ϕ1 )) ≡ ϕ1 ;
6. (¬(ϕ1 ∧ ϕ2 )) ≡ ((¬ϕ1 ) ∨ (¬ϕ2 ));
7. (¬(ϕ1 ∨ ϕ2 )) ≡ ((¬ϕ1 ) ∧ (¬ϕ2 )).

Exercise 65. Can you prove that, for any formulae ϕ1 , ϕ2 ∈ PL, (ϕ1 ∨ ϕ2 ) ≡
ϕ1 if and only if ϕ1 ∈ PL is a tautology?
Exercise 66. Can you prove that, for any formulae ϕ1 , ϕ2 ∈ PL, (ϕ1 ∧ ϕ2 ) ≡
ϕ2 if and only if ϕ1 ∈ PL is a tautology?

Part I - Propositional Logic 42 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Exercise 67. Can you prove that, for any formulae ϕ1 , ϕ2 ∈ PL, (ϕ1 ∧ ϕ2 ) ≡
ϕ1 if and only if ϕ1 ∈ PL is a contradiction?
Exercise 68. Can you prove that, for any formulae ϕ1 , ϕ2 ∈ PL, (ϕ1 ∨ ϕ2 ) ≡
ϕ2 if and only if ϕ1 ∈ PL is a contradiction?

Exercise 69. Show that ¬p is a semantical consequence of (¬p ∨ ¬p).


Exercise 70. Show that p is not a semantical consequence of (¬q ∨ p).
Exercise 71. Show that p is a semantical consequence of (¬q ∨ p) and q.
Exercise 72. Show that p3 is a logical consequence of the formulae (¬p1 ∨ (p2 ∨ p3 )),
((¬¬p2 ∨ ¬p4 ) ∧ (¬¬p4 ∨ ¬p2 )) and (p1 ∧ ¬p4 ).

Part I - Propositional Logic 43 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Part I - Propositional Logic 44 Lecture notes - to print in color


Chapter 6

Logical Connectives

There are two more important connectives in propositional logic: the condi-
tional (implication) and the equivalence (double implication).
We use the syntax (ϕ1 → ϕ2 ) for an implication and (ϕ1 ↔ ϕ2 ) for a
double implication.
The semantics of an implication (ϕ1 → ϕ2 ) is given by
     
τ̂ (ϕ1 → ϕ2 ) = τ̂ ϕ1 + τ̂ ϕ2 ,

for any truth assignment τ .


It is easy to see that (ϕ1 → ϕ2 ) ≡ (¬ϕ1 ∨ ϕ2 ).
Similarly, the semantics of a double implication (ϕ1 ↔ ϕ2 ) is defined such
that
(ϕ1 ↔ ϕ2 ) ≡ ((ϕ1 → ϕ2 ) ∧ (ϕ2 → ϕ1 )).

Example 73. We have that (p → p) is a valid formula. Why? The formula


(p → p) is equivalent to (¬p ∨ p), and this formulae is obviously valid.

6.1 Several Propositional Logics


Up to this point, we have studied the propositional logic of the connectives
¬, ∧, ∨, and we have denoted its set of formulae by PL. In fact, depending
on the set of logical connectives that we need, there are several propositional
logics. The logic that we have studied up to this point is PL¬,∧,∨ = PL.
Depending on the logical connectives that are allowed, we can obtain other
interesting propositional logics:

1. PL¬,∨ is the propositional logic that allows as connectives ¬ and ∨.

45
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

2. PL⊥,→ is the propositional logic in which that only connectives are ⊥ (an
arity 0 connective) and →. The formula ⊥ (read as: bottom) is false in any
truth assignment.
3. PL∨,∧ is a logic in which the only connectives are ∨ and ∧.
Exercise 74. Write the definition of the formal syntax for each of the logics
above.
What do PL, PL¬,∨ , PL⊥,→ have in common? They are equiexpressive
(equally expressive). This means that for any formula ϕ ∈ PL there is a
formula ϕ0 ∈ PL¬,∨ so that ϕ ≡ ϕ0 (and vice-versa, for any formula ϕ0 ∈
PL¬,∨ there is an equivalent formula in PL).
How can we show that PL and PL¬,∨ are equally expressive? For one of
the directions, it is sufficient to translate all conjunctions in PL as follows:

(ϕ ∧ ϕ0 ) ≡ ¬(¬ϕ ∨ ¬ϕ0 ).
At the end we will obtain an equivalent formula that does not contain
conjunctions (and is therefore in PL¬,∨ ). Vice-versa, any formula in PL¬,∨
is already a formula in PL.
How can we show that PL¬,∨ and PL⊥,→ are equally expressive?
We translate all disjunctions and negations using the following equiva-
lences:
1. (ϕ ∨ ϕ0 ) ≡ (¬ϕ → ϕ0 );
2. ¬ϕ ≡ (ϕ → ⊥).
The translation operation stops after a finite number of steps and the re-
sult is a formula equivalent to the starter formula, but which uses only the
connectives ⊥ and →.
The logic PL∨,∧ is strictly less expressive. For example, in this logic there
are no unsatisfiable formulae.
Exercise 75. Explain why in PL∨,∧ all formulae are satisfiable.
Remark. By propositional logic we understand any logic that is as expressive
as PL. For example, PL¬,∧ , PL¬,∨ , PL¬,→ are all propositional logics, but
PL¬ and PL∧,∨ are not propositional logics (they are less expressive).

6.2 The relation between implications and se-


mantical consequence
There is a strong link between implications and the concept of semantical
consequence, link which is formalized in the following theorem.

Part I - Propositional Logic 46 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Theorem 76 (The relation between implications and logical consequences).


For any two formulae ϕ1 , ϕ2 ∈ PL, we have that ϕ1 |= ϕ2 if an only if the
formula (ϕ1 → ϕ2 ) is valid.

The following more general theorem also holds:

Theorem 77 (The generalized relation between implications and logical con-


sequence). For any formulae ϕ1 , ϕ2 , . . . , ϕn , ϕ ∈ PL, we have that ϕ1 , ϕ2 , . . . , ϕn |=
ϕ if and only if the formula (((ϕ1 ∧ ϕ2 ) ∧ . . .) ∧ ϕn ) → ϕ is valid.

A similar relation exists between the double implication logical connective


and the concept of semantical equivalence:

Theorem 78 (The relation between double implication and semantic equiv-


alence). For any two formulae ϕ1 , ϕ2 ∈ PL, we have that ϕ1 ≡ ϕ2 if and only
if the formula (ϕ1 ↔ ϕ2 ) is valid.

6.3 Translating propositions from English into


PL
By translation we understand modeling an English proposition as a formula
of propositional logic. The purpose of this modeling could be: clarifying
the meaning of a proposition by eliminating possible syntactical ambiguities,
checking whether the proposition is valid, etc.
To translate propositions from English into propositional logic, we should
perform the following steps:

1. Identifying the atomic propositions and associating propositional vari-


ables to them;

2. Identifying the logical connectives and their relative order.

For example, let us translate the proposition I want to learn Logic and
pass the examination if the subject is interesting into propositional logic.
The first step is to identify the atomic propositions. In our case, we find
three atomic propositions:

1. I want to learn Logic;

2. I want to pass the examination; (note that the words I want do not
appear explicitly in the proposition, but they are implied )

3. the subject is interesting.

Part I - Propositional Logic 47 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Pay attention! The connectives themselves are not part of the


atomic propositions. For example, the third atomic proposition is
not if the subject is interesting.

We associate a propositional variable to each atomic proposition:

propositional variable atomic proposition


p I want to learn Logic
q I want to pass the examination
r the subject is interesting.

Pay attention! For an accurate translation, if a proposition occurs


several times (even if it does not use exactly the same words), we
should associate to all of its occurences the same propositional
variable.

The next step is to identify the logical connectives. In the example above,
there are two logical connectives:

1. the connective and in the context [...] Logic and pass [...], which indi-
cates a conjunction;

2. the connective if-then (even if the word then does not appear explicitly)
in the context [...] the examination if the subject [...], which indicates
an implication.

What is the order of the two connectives? In other words, it the entire
proposition a conjunction or an implication? What is the main connective?
Our English-language intuition tells us that it is more likely an implication
(for example, because the verb want is implied (not explicit) in the proposition
I want to pass the examination). The translation is therefore

(r → (p ∧ q)),

because the proposition associated to the propositional variable r is the an-


tecedent of the implication, even if syntactically it appears at the end of the
sentence.

Part I - Propositional Logic 48 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Pay attention! In spite of the name, propositional variables are


not variables in a mathematical sense. A frequent mistake is to
write
p = I want to learn Logic,
which is not correct, because p is only equal to p and nothing
else. Any variable (in a mathematical sense) in the lecture is
written with a regular black font. For example, we often use the
mathematical variable ϕ for propositional formulae.

Exercise 79. Translate the following proposition into propositional logic: Ei-
ther I pass Logic, or I don’t.
Pay attention to the words that do not explictly appear in the atomic propo-
sitions. Pay attention to the meaning of the connective either-or (hint: it
is not among the connectives that we discussed so far, but it can be emu-
lated/ simulated).

6.4 Application 2
The following puzzle is from the book Peter Smith. An Introduction to Formal
Logic. Either the butler or the cook committed the murder. The victim died
from poison if the cook did the murder. The butler did the murder only if the
victim was stabbed. The victim didn’t die from poison.
Does it follow that the victim was stabbed?
We associate to every atomic proposition a propositional variable as fol-
lows:

1. For the proposition “the butler commited the murder” the propositional
variable p;

2. For the proposition “the cook commited the murder” the propositional
variable q;

3. For the proposition “the victim died of posion” the propositional vari-
able r1 ;

4. For the proposition “the victim was stabbed” the propositional variable
r2 .

The hypotheses of the puzzle are modeled as propositional formulae in


propositional logic as follows:

Part I - Propositional Logic 49 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

1. ((p ∨ q) ∧ ¬(p ∧ q)) (exclusive disjunction between p and q);


2. (q → r1 );
3. (p → r2 ) (mind the direction of the implication);

4. ¬r1 .

The question of the puzzle is simply the formula r2 .


To answer the puzzle with yes or no, it is sufficient to check whether
n o
((p ∨ q) ∧ ¬(p ∧ q)), (q → r1 ), (p → r2 ), ¬r1 |= r2 .

The logical consequences does hold (left as an exercise to the reader).

6.5 Exercise sheet


Exercise 80. Associate to each of the following statements a formula in PL
that models its meaning in English.

1. If it rains outside, I stay inside or go to the mall. I don’t stay inside


unless I’m bored. It rains and I’m not bored.
2. I study logic only if it is not possible to go outside. It is possible to go
outside if it is not raining and if it is hot. As I am not studying logic
and outside is hot, it means it is raining.

3. Thing go well in the country if the leaders of the country are not thiefs
and if the economy is healthy. People go abroad if and only if things
do not go well in the country. The economy is healthy, but people leave
abroad.

Part I - Propositional Logic 50 Lecture notes - to print in color


Chapter 7

Natural Deduction

In the previous lecture we have discussed some important notions about the
semantics of propositional logic.

1. the truth value of a formula in an assignment;


2. satisfiability;
3. validity;
4. equivalence;
5. semantical consequence.

We have seen that in order to establish that two formulae are equivalent,
a semantical reasoning process is necessary (meaning an argument that uses
semantical notions such as truth values, assignments etc).
One of the main purposes of logic in computer science is to design mechan-
ical models (meaning models that are suitable to computer implementation)
for reasoning instead of semantical-based reasoning.
In this lecture, we will study a method for mechanizing the notion of se-
mantical consequence. By mechnization, we understand a method for proving
consequeneces with the following properties:

1. we should be able to convince someone that the consequence does take


place, without the person having to following a semantical argument;
2. in particular, each proof step should be easy to check (mechanically, no
RI needed);
3. the method must be so precise as to allow the reasoning to be performed
by a computer.

51
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

7.1 Sequents
Definition 81 (Sequent). A sequent is a pair consisting of a set of formulae
{ϕ1 , . . . , ϕn } and a formula ϕ, pair denoted by

{ϕ1 , . . . , ϕn } ` ϕ.

The word sequent does not really exist in English. It is borrowed from the
German word Sequentz.
Sometimes we read {ϕ1 , . . . , ϕn } ` ϕ as ϕ is a syntactical consequence of
{ϕ1 , . . . , ϕn }. We will often use Γ to denote the set of premisses {ϕ1 , . . . , ϕn }
of the sequent and in this case we will write Γ ` ϕ. Also, the usual notion
in the literature permits the writing ϕ1 , . . . , ϕn ` ϕ (without curly braces)
instead of {ϕ1 , . . . , ϕn } ` ϕ, but we have to keep in mind that to the left
hand side of the ` symbol we always have a set of formulae.
Example 82. Here are some examples of sequents:
1. {p, q} ` (p ∧ q);
2. {p, (q ∧ ¬r)} ` (p ∨ q);
3. {(p ∧ q), (p ∨ q)} ` (p ∧ r).
Later on, we shall see that the first two sequents are valid, and the last
sequent is not.

7.2 Inference Rules


Definition 83. An inference rule is a tuple consisting of:

1. a set of sequents S1 , . . . , Sn , called the hypotheses of the rule;


2. a sequent S that is called the conclusion of the rule;
3. a possible condition for applying the rule;
4. a name.

An inference rule is denoted as follows:

S1 ... Sn
name condition.
S
Remark. It is possible for a sequent to have n = 0 hypotheses. Such inference
rules, having 0 hypotheses, are called axioms.

Part I - Propositional Logic 52 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Remark. Furthermore, the condition in an inference rule is optional.


Example 84. Here are some examples of inference rules:

Γ`ϕ Γ ` ϕ0 Γ ` (ϕ ∧ ϕ0 )
∧i ∧e1
Γ ` (ϕ ∧ ϕ0 ), Γ ` ϕ,

Γ ` (ϕ ∧ ϕ0 )
∧e2
Γ ` ϕ0 .
All three rules above are sound, in a sense that we will define later. None
of the three rules above has a condition. Here is an example of a rule with
n = 0 hypotheses, but having a condition:

Premiss ϕ ∈ Γ.
Γ`ϕ
Here is an example of an unsound inference rule (we will see later in what
sense it is unsound):

Γ ` ϕ0
unsound rule
Γ ` (ϕ ∧ ϕ0 ).
Remark. To be precise, the hypotheses of the inference rule, as well as the
conclusion, are really sequent schemes and not sequents. This means that
an inference rules might have several instances, obtained by replacing the
mathematical variables ϕ, ϕ0 , Γ with actual formulae. For example, here are
two instances of the rule ∧i above:

{p, q} ` p {p, q} ` q {p, q, r} ` (p ∧ q) {p, q, r} ` p


∧i ∧i
{p, q} ` (p ∧ q); {p, q, r} ` ((p ∧ q) ∧ p).
In the first instance, we have replaced the mathematical variable Γ by the
set of formulae {p, q}, the mathematical variable ϕ by the formula p and the
mathematical variable ϕ0 by the formula q.
Exercise 85. Determine what each variable was replaced with in the second
instance.
Exercise 86. Explain why the following rule is not an instance of the ∧i rule:

{p, q} ` p {p, q} ` q
∧i
{p, q} ` (p ∧ p).

Part I - Propositional Logic 53 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

7.3 Proof system


Definition 87. A proof system is a set of inference rules.

Example 88. Consider the proof system D1 , containing the following infer-
ence rules:
Γ`ϕ Γ ` ϕ0 Γ ` (ϕ ∧ ϕ0 )
Premiss ϕ∈Γ ∧i ∧e1
Γ ` ϕ, Γ ` (ϕ ∧ ϕ0 ), Γ ` ϕ,

Γ ` (ϕ ∧ ϕ0 )
∧e2
Γ ` ϕ0 .

7.4 Formal Proofs


Definition 89 (Formal Proof). A formal proof in a proof system is a list of
sequents

1. S1 ;

2. S2 ;

...

n. Sn

such that for each 1 ≤ i ≤ n,

the sequent Si is justified by an inference rule in the proof system


from the previous sequents (S1 , . . . , Si−1 ), in the sense that Si is
the conclusion of an instance of an inference rule in the proof
system that uses hypotheses only among the sequents S1 , . . . , Si−1
and such that the condition of the inference rule is true (if the
inference rule has a condition).

Example 90. Here is an example of a formal proof in the proof system D1


defined above:

1. {p, q} ` p; ( Premiss)

2. {p, q} ` q; ( Premiss)

3. {p, q} ` (p ∧ q); ( ∧i, 1, 2)

4. {p, q} ` (q ∧ (p ∧ q)). ( ∧i, 2, 3)

Part I - Propositional Logic 54 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Note that each line is annotated by the name of the inference rule that was
applied, plus the lines where the hypotheses of the rule are found.
Definition 91 (Valid Sequent). A sequent Γ ` ϕ is valid in a proof system
D if there exists a formal proof S1 , . . . , Sn in D such that Sn = Γ ` ϕ.
Example 92. The sequent {p, q} ` (p ∧ q) is valid in the proof system D1
above, because it is the last sequent in the following formal proof:
1. {p, q} ` p; ( Premiss)
2. {p, q} ` q; ( Premiss)
3. {p, q} ` (p ∧ q). ( ∧i, 1, 2)
Remark. Do not mistake the notion of sequent valid in a proof system for
the notion of valid formula.

7.5 Natural Deduction


Natural deduction is a proof system for PL¬,∧,∨,→,⊥ . In this proof system,
each logical connective has one or more introduction rules and one or more
elimination rules.

7.5.1 The Rules for Conjunction


We have already seen the introduction and elimination rules for the connective
and :

Γ`ϕ Γ ` ϕ0 Γ ` (ϕ ∧ ϕ0 ) Γ ` (ϕ ∧ ϕ0 )
∧i ∧e1 ∧e2
Γ ` (ϕ ∧ ϕ0 ), Γ ` ϕ, Γ ` ϕ0 .
The proof system is called natural deduction because it mimics the human
reasoning process:
• The rule for introducing and indicates that we can prove a conjunction
(ϕ ∧ ϕ0 ) from the antecedents Γ if we know that each conjunct, ϕ and ϕ0
respectively, is a consequence of Γ.
In other words, to show that a conjunction follows from Γ, it is enough to
show individually that each conjunct follows from Γ.
• There are two elimination rules for and. The first elimination rule indicates
that if we have already established that a conjunction (ϕ ∧ ϕ0 ) follows from
Γ, then the left-hand side conjunct, ϕ, also follows from Γ.
The second elimination rule is symmetrical.

Part I - Propositional Logic 55 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Here is an example of a formal proof that uses the inference rules for and :

1. {(p ∧ q), r} ` (p ∧ q); (Premiss)

2. {(p ∧ q), r} ` r; (Premiss)

3. {(p ∧ q), r} ` p; (∧e1 , 1)

4. {(p ∧ q), r} ` (p ∧ r). (∧i, 3, 2)

Exercise 93. Show that the following sequents are valid:

1. {((p ∧ q) ∧ r)} ` (q ∧ r);

2. {((p ∧ q) ∧ r), r0 } ` (r0 ∧ q);

3. {((p ∧ q) ∧ r)} ` ((r ∧ q) ∧ p).

7.5.2 The Rules for Implications


The rule for eliminating implications, also known as modus ponens in latin,
is one of the most important inference rules.

Γ ` (ϕ → ϕ0 ) Γ`ϕ
→e
Γ ` ϕ0 .

The rule tells us that, assuming that we already know that ϕ → ϕ0 follows
from Γ and that ϕ follows from Γ, then we also have that ϕ0 follows from Γ.
Here is an example of formal proof that uses the modus ponens rule:

1. {(p → r), (p ∧ q)} ` (p ∧ q); (Premiss)

2. {(p → r), (p ∧ q)} ` p; (∧e1 , 1)

3. {(p → r), (p ∧ q)} ` (p → r); (Premiss)

4. {(p → r), (p ∧ q)} ` r. (→ e, 3, 2)

This formal proof shows that the sequent {(p → r), (p ∧ q)} ` r is valid,
meaning that the formula r is a consequence of the formulae (p → r) and
(p ∧ q). Note the order of the line numbers 3 and 2 in the annotation for line
4 (they follow the order in the inference rule).

Exercise 94. Show that the following sequents are valid:

1. {((p ∧ q) → r), p, q} ` r;

Part I - Propositional Logic 56 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

2. {(p → r), p, q} ` (q ∧ r).

The rule for introducing implication is more subtle. To show that an


implication (ϕ → ϕ0 ) follows from Γ, we assume ϕ (in addition to Γ) and we
show ϕ0 . In other words, in the hypothesis of the rule, we add the formula ϕ
to the formulae in Γ. The rule can be written in two equivalent ways, that
differ only in their use of the convention regarding the curly braces:

Γ, ϕ ` ϕ0 Γ ∪ {ϕ} ` ϕ0
→i →i
Γ ` (ϕ → ϕ0 ), Γ ` (ϕ → ϕ0 ).

What is important to note and understand for the rule for introducing
implication is that the premisses of the sequent in the hypotheses are different
from the premisses of the sequent in the conclusion. Whereas in the conclusion
we have that the formula (ϕ → ϕ0 ) follows from Γ, in the hypothesis we have
to show that ϕ0 follows from Γ ∪ {ϕ}. In other words, intuitively speaking, to
prove an implication (ϕ → ϕ0 ), we assume the antecedent ϕ and we show the
consequent ϕ0 .
Example 95. Let us show that the sequent {} ` (p → p) is valid:

1. {p} ` p; ( Premiss)
2. {} ` (p → p). ( → i, 1)

Example 96. Let us show that the sequent {(p → q)} ` (p → q) is valid.
A simple proof is:

1. {(p → q)} ` (p → q). ( Premiss)

A longer proof is:

1. {(p → q), p} ` (p → q); ( Premiss)


2. {(p → q), p} ` p; ( Premiss)
3. {(p → q), p} ` q; ( → e, 1, 2)
4. {(p → q)} ` (p → q). ( → i, 3)

Example 97. Let us show that the sequent {(p → q), (q → r)} ` (p → r)
is valid:

1. {(p → q), (q → r), p} ` (p → q); ( Premiss)


2. {(p → q), (q → r), p} ` p; ( Premiss)

Part I - Propositional Logic 57 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

3. {(p → q), (q → r), p} ` q; ( → e, 1, 2)

4. {(p → q), (q → r), p} ` (q → r); ( Premiss)

5. {(p → q), (q → r), p} ` r; ( → e, 4, 3)

6. {(p → q), (q → r)} ` (p → r). ( → i, 5)

Exercise 98. Show that the following sequents are valid:

1. {((p ∧ q) → r), p, q} ` r;

2. {((p ∧ q) → r)} ` (p → (q → r));

3. {(p → (q → r))} ` ((p ∧ q) → r).

7.5.3 Rules for Disjunctions


The connective or has two introduction rules:

Γ ` ϕ1 Γ ` ϕ2
∨i1 ∨i2
Γ ` (ϕ1 ∨ ϕ2 ), Γ ` (ϕ1 ∨ ϕ2 ).

The first rule indicates that if we already know ϕ1 follows from Γ, then
(ϕ1 ∨ ϕ2 ) must also follow from Γ, what ϕ2 is. In other words, intuitively
speaking, if we know ϕ1 , then we also know (ϕ1 ∨ whatever else). The second
introduction rule for disjunction is symmetrical.

Example 99. Let us show that the sequent {(p ∧ q)} ` (p ∨ q) is valid:

1. {(p ∧ q)} ` (p ∧ q); ( Premiss)

2. {(p ∧ q)} ` p; ( ∧e1 , 1)

3. {(p ∧ q)} ` (p ∨ q). ( ∨i1 , 2)

Another formal proof for the same sequent is:

1. {(p ∧ q)} ` (p ∧ q); ( Premiss)

2. {(p ∧ q)} ` q; ( ∧e2 , 1)

3. {(p ∧ q)} ` (p ∨ q). ( ∨21 , 2)

Exercise 100. Show that the sequent {(p ∧ q)} ` (r ∨ p) is valid.

Part I - Propositional Logic 58 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

The rule for eliminating disjunctions is slightly more complicated, being


another rule where the set of premisses of the sequents changes from hypothe-
ses to conclusion:

Γ ` (ϕ1 ∨ ϕ2 ) Γ, ϕ1 ` ϕ0 Γ, ϕ2 ` ϕ0
∨e
Γ ` ϕ0

The first hypothesis of the rule, Γ ` (ϕ1 ∨ ϕ2 ), is easy to understand:


to eliminate a disjunction, we must have such a disjunction among the hy-
potheses (disjunction that we will eliminate in the conclusion). The following
two hypotheses for disjunction elimination must be understood intuitively as
follows. From the first hypothesis, we have that (ϕ1 ∨ ϕ2 ) follows from Γ;
in other words, at least one of the formulae ϕ1 and ϕ2 follows from Γ. The
hypotheses 2 and 3 indicate that, no matter which of ϕ1 and ϕ2 would hold,
in any case ϕ0 holds. Meaning that if we assume ϕ1 (in addition to Γ), ϕ0
holds, and if we assume ϕ2 (in addition to Γ), ϕ0 still holds. And then the
conclusion indicates that ϕ0 holds independently of which of ϕ1 and ϕ2 holds.

Example 101. Let us show that the sequent {(p ∨ q)} ` (q ∨ p) is valid:

1. {(p ∨ q), p} ` p; ( Premiss)

2. {(p ∨ q), p} ` (q ∨ p); ( ∨i2 , 1)

3. {(p ∨ q), q} ` q; ( Premiss)

4. {(p ∨ q), q} ` (q ∨ p); ( ∨i1 , 3)

5. {(p ∨ q)} ` (p ∨ q); ( Premiss)

6. {(p ∨ q)} ` (q ∨ p). ( ∨e, 5, 2, 4)

Note that way in which the set of premisses varies from one sequent to
another along the formal proof, obbeying the inference rules.

Exercise 102. Show that the sequent {(p ∨ q), (p → r), (q → r)} ` r is
valid.

Exercise 103. Show that the sequent {(p → r), (q → r)} ` ((p ∨ q) → r)
is valid.

Part I - Propositional Logic 59 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

7.5.4 The Rules for Negations


The rules for introducing and respectively eliminating negations must be pre-
sented at the same time as the rules for ⊥:

Γ, ϕ ` ⊥ Γ`ϕ Γ ` ¬ϕ Γ`⊥
¬i ¬e ⊥e
Γ ` ¬ϕ, Γ ` ⊥, Γ ` ϕ.

Recall that ⊥ is a nullary logical connective (it has arity 0), meaning that
⊥ connects 0 formulae among themselves. In other words, the connective ⊥
is by itself a formula. The semantics of ⊥ is that it is false in any assignment.
In other words, ⊥ is a contradiction.
The first rule above is that for introducing negations. It is easy to explain
intuitively: how can we show that a formula of the form¬ϕ follows from Γ?
We assume ϕ in addition to Γ and we show that from Γ and ϕ follows a
contradiction (Γ, ϕ ` ⊥). In this way, we have that ¬ϕ follows from Γ.
The second rule, for eliminating negations, indicates that if both a formula,
ϕ, and its negation, ¬ϕ, follow from the same set of premisses Γ, then from
Γ follows a contradiction, ⊥. A set Γ from which a contradiction follows is
called inconsistent.
The third rule indicates that, if Γ is an inconsistent set, then any formula
ϕ follows from Γ.
There is no rule for introducing ⊥ (or, equivallently, the rule for eliminat-
ing negation can be considered as the rule for introducing ⊥).
Example 104. Let us show that the sequent {p} ` ¬¬p is valid:

1. {p, ¬p} ` p; ( Premiss)


2. {p, ¬p} ` ¬p; ( Premiss)
3. {p, ¬p} ` ⊥; ( ¬e, 1, 2)
4. {p} ` ¬¬p. ( ¬i, 3)

Example 105. Let us show that the sequent {p, ¬p} ` r is valid:

1. {p, ¬p} ` p; ( Premiss)


2. {p, ¬p} ` ¬p; ( Premiss)
3. {p, ¬p} ` ⊥; ( ¬e, 1, 2)
4. {p, ¬p} ` r. ( ⊥e, 3)

Exercise 106. Show that the following sequents are valid:

Part I - Propositional Logic 60 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

1. {(p ∨ q)} ` ¬(¬p ∧ ¬q);

2. {(p ∧ q)} ` ¬(¬p ∨ ¬q);

3. {(¬p ∨ ¬q)} ` ¬(p ∧ q);

4. {(¬p ∧ ¬q)} ` ¬(p ∨ q);

5. {¬(p ∨ q)} ` (¬p ∧ ¬q).

7.5.5 Alte reguli


Another useful rule (especially when proving derived rules – which we will
discuss shortly), that is not related to any given connective is the Extend
rule:

Γ`ϕ
Extend
Γ, ϕ0 ` ϕ

This rule indicates that, if ϕ is a consequence of a set of formulae Γ, then


ϕ is also a consequence of Γ ∪ {ϕ0 } (whatever ϕ0 is). In other words, we can
extend the set of premisses of a valid sequent and still get a valid sequent.

Example 107. Let us show that the sequent {p, ¬q, r, (q1 ∧ q2 )} ` ¬¬p is
valid:

1. {p, ¬p} ` p; ( Premiss)

2. {p, ¬p} ` ¬p; ( Premiss)

3. {p, ¬p} ` ⊥; ( ¬e, 1, 2)

4. {p} ` ¬¬p; ( ¬i, 3)

5. {p, ¬q} ` ¬¬p; ( Extend, 4)

6. {p, ¬q, r} ` ¬¬p; ( Extend, 5)

7. {p, ¬q, r, (q1 ∧ q2 )} ` ¬¬p. ( Extend, 6)

The rules above are natural deduction for a logic that is called intuitionistic
propositional logic. In this lecture, we study classical propositional logic. The
two logics have the same syntax, but their semantics are different. Intuitionist
logic is important in computer science, because formal proofs in this logic are
in a 1-to-1 correspondence with computer programs. Meaning that to each
intuitionistic proof we can associate a program, and to each program, an

Part I - Propositional Logic 61 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

intuitionistic proof. This mean essentially that each intuitionistic proof is a


program. Intuitionistic logic is a constructive logic, meaning a logic where any
proof gives an algorithm.
To obtain a proof system for classical propositional logic, which is the
object of our study, we need one more rule:

Γ ` ¬¬ϕ
¬¬e
Γ ` ϕ.
Example 108. Let us show that the sequent {(¬p → q), ¬q} ` p is valid:
1. {(¬p → q), ¬q, ¬p} ` ¬p; ( Premiss)
2. {(¬p → q), ¬q, ¬p} ` (¬p → q); ( Premiss)
3. {(¬p → q), ¬q, ¬p} ` q; ( → e, 2, 1)
4. {(¬p → q), ¬q, ¬p} ` ¬q; ( Premiss)
5. {(¬p → q), ¬q, ¬p} ` ⊥; ( ¬i, 4, 3)
6. {(¬p → q), ¬q} ` ¬¬p; ( ¬i, 5)
7. {(¬p → q), ¬q} ` p. ( ¬¬e, 6)
Example 109. Let us show that the sequent {} ` (p ∨ ¬p) is valid:
1. {¬(p ∨ ¬p), p} ` ¬(p ∨ ¬p); ( Premiss)
2. {¬(p ∨ ¬p), p} ` p; ( Premiss)
3. {¬(p ∨ ¬p), p} ` (p ∨ ¬p); ( ∨i1 , 2)
4. {¬(p ∨ ¬p), p} ` ⊥; ( ¬e, 1, 3)
5. {¬(p ∨ ¬p)} ` ¬p; ( ¬i, 4)
6. {¬(p ∨ ¬p)} ` (p ∨ ¬p); ( ∨i2 , 5)
7. {¬(p ∨ ¬p)} ` ¬(p ∨ ¬p); ( Premiss)
8. {¬(p ∨ ¬p)} ` ⊥; ( ¬e, 7, 6)
9. {} ` ¬¬(p ∨ ¬p); ( ¬i, 8)
10. {} ` (p ∨ ¬p). ( ¬¬e, 9)
Exercise 110. Show that the following sequents are valid:
1. {¬(p ∧ q)} ` (¬p ∨ ¬q);
2. {¬(¬p ∨ ¬q)} ` (p ∧ q);
3. {¬(¬p ∧ ¬q)} ` (p ∨ q).

Part I - Propositional Logic 62 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

7.6 Natural Deduction


Natural deduction is the proof system containing all rules above. Here is a
summary of all rules:

Γ`ϕ Γ ` ϕ0 Γ ` (ϕ ∧ ϕ0 )
∧i ∧e1
Γ ` (ϕ ∧ ϕ0 ), Γ ` ϕ,

Γ ` (ϕ ∧ ϕ0 ) Γ ` (ϕ → ϕ0 ) Γ`ϕ Γ, ϕ ` ϕ0
∧e2 →e →i
Γ ` ϕ0 , Γ ` ϕ0 , Γ ` (ϕ → ϕ0 ),

Γ ` ϕ1 Γ ` ϕ2
∨i1 ∨i2
Γ ` (ϕ1 ∨ ϕ2 ), Γ ` (ϕ1 ∨ ϕ2 ),

Γ ` (ϕ1 ∨ ϕ2 ) Γ, ϕ1 ` ϕ0 Γ, ϕ2 ` ϕ0
∨e
Γ ` ϕ0 ,

Γ`ϕ Γ ` ¬ϕ Γ, ϕ ` ⊥ Γ`⊥
¬e ¬i ⊥e
Γ ` ⊥, Γ ` ¬ϕ, Γ ` ϕ,

Γ`ϕ Γ ` ¬¬ϕ
Premiss ϕ ∈ Γ, Extend ¬¬e
Γ`ϕ Γ, ϕ0 ` ϕ, Γ ` ϕ.

7.7 Derived Rules


A derived rule is a proof rule that we can prove using the other proof rules in
a given proof system, through a formal proof.
An example of a derived rule is the rule for introducing double negation:

Γ`ϕ
¬¬i
Γ ` ¬¬ϕ.

Here is a formal proof for the rule for introducing double negation. We
start with the hypotheses of the rule, and the last sequent in the proof must
be the conclusion of the rule.

1. Γ ` ϕ; (hypothesis of the derived rule)


2. Γ, ¬ϕ ` ϕ; (Extend, 1)
3. Γ, ¬ϕ ` ¬ϕ; (Premiss)

Part I - Propositional Logic 63 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

4. Γ, ¬ϕ ` ⊥; (¬e, 2, 3)

5. Γ ` ¬¬ϕ. (¬i, 4)

After having been shown derived (as above), such a proof rule can be used
to shorten other proofs, similarly to how we shorten code by writing subpro-
grams (functions) in certain programming languages. Here is an example of
a formal proof that uses the derived rule ¬¬i:

1. {(¬¬p → q), p} ` p; (Premiss)

2. {(¬¬p → q), p} ` ¬¬p; (¬¬i, 1)

3. {(¬¬p → q), p} ` (¬¬p → q); (Premiss)

4. {(¬¬p → q), p} ` q. (→ e, 3, 2)

In the absence of the derived rule, our proof would have been longer:

1. {(¬¬p → q), p} ` p; (Premiss)

2. {(¬¬p → q), p, ¬p} ` p; (Extend, 1)

3. {(¬¬p → q), p, ¬p} ` ¬p; (Premiss)

4. {(¬¬p → q), p, ¬p} ` ⊥; (¬e, 2, 3)

5. {(¬¬p → q), p} ` ¬¬p. (¬i, 4)

6. {(¬¬p → q), p} ` (¬¬p → q); (Premiss)

7. {(¬¬p → q), p} ` q. (→ e, 6, 5)

Note that the lines 1–5 in the longer proof are an instance of the formal
proof for the derived rule.

7.8 Soundness and Completeness for Natural


Deduction
Theorem 111 (Soundness of Natural Deduction). For any set of formulae
Γ and any formula ϕ, if the sequent Γ ` ϕ is valid, then Γ |= ϕ.

Exercise: prove this theorem.

Theorem 112 (Completeness of Natural Deduction). For any set of formulae


Γ and any formula ϕ, if Γ |= ϕ then the sequent Γ ` ϕ is valid.

Part I - Propositional Logic 64 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

The proof of the completeness theorem is complex and we do not address


it in this course.
Remark. Note that, due to the soundness and completeness theorems, the
relation ` coincides with the relation |=, even if they have totally different
definitions.
Exercise 113. Using the above theorems, prove that a set {ϕ1 , ϕ2 , . . . , ϕn }
of formulae is inconsistent if the sequent {ϕ1 , ϕ2 , . . . , ϕn } ` ⊥ is valid.

7.9 Exercise Sheet


Exercise 114. Give a formal proof of (p ∧ r) from {((q ∧ r) ∧ q), (p ∧ p)}.
Exercise 115. Show the validity of the following sequents:
1. (p ∧ q), r ` (p ∧ (r ∨ r0 ));
2. (p → (q → r)) ` ((p ∧ q) → r);
3. ((p ∧ ¬r) → q), ¬q, p ` r;
Exercise 116. Finish the game at https: // profs. info. uaic. ro/ ~ stefan.
ciobaca/ lnd. html . Do not cheat. It is considered cheating if you change
the JavaScript source code, if someone else solves a level for you or if you
prove the derived rules using the derived rules themselves.
Exercise 117. Prove that the following inference rules are derivable:
1. ¬¬i;

Lem
2. LEM (law of excluded middle): Γ ` (ϕ ∨ ¬ϕ);
Γ, ¬ϕ ` ⊥
Pbc
3. PBC (proof by contradiction): Γ ` ϕ;
Γ ` (ϕ → ϕ0 ) Γ ` ¬ϕ0
MT
4. MT (modus tollens): Γ ` ¬ϕ.
Exercise 118. Prove the soundness theorem for natural deduction (by induc-
tion on the number of sequents in the formal proof ).
Exercise 119. Show that the rule ¬¬e is derivable using the LEM (i.e., you
may use LEM in the derivation, but not ¬¬e).
Exercise 120. Prove, using the soundness and completeness theorems, that
ϕ1 a` ϕ2 if and only if ϕ1 ≡ ϕ2 .

Part I - Propositional Logic 65 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Part I - Propositional Logic 66 Lecture notes - to print in color


Chapter 8

Normal Forms

So far, we have discussed the syntax and the semantics of propositional logic,
and in the last chapter, we introduced a first method for mechanizing formal
proofs, namely natural deduction.
An essential concern in Logic is automated proof, which means automatic
search for formal proofs by a computer for a specific conjecture/theorem.
Natural deduction is a deductive system with certain features (for instance,
formal proofs can be theoretically verified and easily understood). However,
the performance of automated provers using natural deduction is lacking in
practice.
For this reason, we will study another deductive system called resolution,
which allows for practical and efficient implementations, even though resolu-
tion proofs may not be as elegant as natural deduction proofs.
Unlike natural deduction, which works with arbitrary formulae, resolution
is limited to formulae in a specific form, known as clausal normal form. The
goal of this chapter is to study clausal normal forms.

8.1 Notations
In practice, when we write formulae in PL, we only use parentheses when
strictly necessary.
Just as when we write 5 × −3 + 2, we understand it as (5 × (−3)) + 2,
similarly, instead of p ∧ ¬q ∨ r, we will understand ((p ∧ ¬q) ∨ r). In this
sense, the negation ¬ has the highest priority, followed by ∧ and then ∨. We
can remember this convention by associating:

1. ¬ with unary minus;

2. ∧ with multiplication; and

67
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

3. ∨ with addition.

Furthermore, the operators ∧ and ∨ are both associative and commuta-


tive. For this reason, we allow writing p ∧ q ∧ r instead of ((p ∧ q) ∧ r) or
(p ∧ (q ∧ r)).
In the rest of the course, we will allow to write formulae without explicit
brackets, respecting the following priority order of the logical connectives:

⊥, ¬, ∧, ∨, →, ↔.

For example, by

¬¬p ∨ ⊥ ∧ p → ¬p ∧ q ↔ q

we will understand the formula

(((¬¬p ∨ (⊥ ∧ p)) →(¬p ∧ q)) ↔ q).

We will also write ((ϕ1 ∨ ϕ2 ) ∨ ϕ3 ) as ϕ1 ∨ ϕ2 ∨ ϕ3 (meaning that a


series of ∨ will be implicitly left-associated).
We will also write ((ϕ1 ∧ ϕ2 ) ∧ ϕ3 ) as ϕ1 ∧ ϕ2 ∧ ϕ3 (meaning that a
series of ∧s will also be implicitly left-associated).

Example 121. We write

p ∧ q ∧ r ∨ ¬p ∧ ¬q ∧ ¬r

for the formula

(((p ∧ q) ∧ r) ∨ ((¬p ∧ ¬q) ∧ ¬r)).

Example 122. We write

p1 ∧ p2 ∧ p3 ∧ p4

for the
(((p1 ∧ p2 ) ∧ p3 ) ∧ p4 ).

Example 123. We write

p1 ∨ p2 ∨ p3 ∨ p4

for the formula


(((p1 ∨ p2 ) ∨ p3 ) ∨ p4 ).

Part I - Propositional Logic 68 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

8.2 Replacement Theorem


We present a theorem that we have used implicitly so far:

Theorem 124 (The Replacement Theorem). Let ϕ, ϕ0 be two formulae such


that ϕ ≡ ϕ0 . Let ϕ1 be a formula that contains ϕ as a subformula. Let ϕ2 be
the formula obtained from ϕ1 by replacing one occurence of ϕ by ϕ0 .
Then ϕ1 ≡ ϕ2 .

In other words, the relation ≡ is a congruence.

Example 125. Let ϕ = p and ϕ0 = ¬¬p.


Let ϕ1 = (p ∨ q) and ϕ2 = (¬¬p ∨ q).
By the replacement theorem, we obtain ϕ1 ≡ ϕ2 . In other words, by
replacing a subformula with an equivalent one, the new formula is equivalent
to the initial formula.

8.3 Literal
Definition 126 (Literal). A formula ϕ is called a literal if there exists a
propositional variable a ∈ A such that

ϕ=a or ϕ = ¬a.

Example 127. The formulae p, q, ¬p, ¬p0 , q1 are literals, but the formulae
(p ∨ q), ¬¬p, ¬¬¬q1 , (¬p ∧ q) are not literals.

8.4 Clauses
Definition 128. A formula ϕ is called a clause if there exist n literals
ϕ1 , . . . , ϕn such that
ϕ = ϕ1 ∨ϕ2 ∨ . . . ∨ϕn .

In other words, a clause is a disjunction of literals.

Example 129. The following formulae are clauses:

1. p ∨ q ∨ r;

2. p ∨ ¬q ∨ ¬r;

3. ¬p ∨ ¬q ∨ ¬r;

4. ¬p1 ∨ p1 ∨ p2 ∨ ¬q ∨ ¬r;

Part I - Propositional Logic 69 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

5. ¬p1 ∨ p1 ;
6. ¬p1 (n = 1).
7. p (n = 1).

The following formulae are not clauses:

1. p ∧ r; (conjunction instead of disjunction)


2. p ∨ ¬¬q ∨ ¬r; (not a disjunction of literals)
3. ¬¬p ∨ p ∧ ¬p1 . (we have ¬¬, so no literals; we also have ∧)

Remark. Definition 128 explicitly states that we require n literals, where


n ≥ 1. However, for the particular case when n = 0, we get a special clause
called the empty clause, which has a dedicated notation: . We consider that
 represents an unsatisfiable formula (semantically, the empty clause has the
same meaning as ⊥). This clause is used in a later chapter which will discuss
about resolution in propositional logic.

8.5 Conjunctive Normal Form


Definition 130 (CNF). A formula ϕ is in CNF if there exist n ≥ 1 clauses
ϕ1 , . . . , ϕn such that
ϕ = ϕ1 ∧ϕ2 ∧ . . . ∧ϕn .
In other words, a formula in CNF is a conjunction of disjunctions of lit-
erals. Or, a formula in CNF is a conjunction of clauses. CNF is conveniently
also an abbreviation of clausal normal form, which means the same thing as
conjunctive normal form.
Example 131. The following formulae are in CNF:

1. (¬p ∨ q) ∧ (r ∨ ¬p ∨ r0 ) ∧ (¬p ∨ ¬r);


2. ¬p ∧ (r ∨ ¬p ∨ r0 ) ∧ ¬r;
3. ¬p ∧ r ∧ ¬r;
4. ¬p;
5. p.

The following formulae are not in CNF:

1. ¬(¬p ∨ q) ∧ (r ∨ ¬p ∨ r0 ) ∧ (¬p ∨ ¬r); (the first clause is negated)

Part I - Propositional Logic 70 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

2. ¬p ∧ ¬(r ∨ ¬p ∨ r0 ); (second clause is negated)


3. ¬p ∨ (r ∧ ¬p ∧ r0 ); (the main connective is the disjunction, instead
of a conjunction)
4. ¬¬p; (we have ¬¬, so no literals)
5. p ∨ (q ∧ r). (disjunction of conjunctions, not a conjunction of
disjunctions (of literals))

8.6 Bringing a Formula into CNF


Theorem 132 (Theorem for Bringing a Formula into CNF). For any formula
ϕ ∈ PL, there exists a formula ϕ0 ∈ PL that is in CNF such that ϕ ≡ ϕ0 .

Proof: [Proof Sketch]


By repeatedly applying the replacement theorem using the following equiv-
alences:

1. (ϕ1 ↔ ϕ2 ) ≡ ((ϕ1 → ϕ2 ) ∧ (ϕ2 → ϕ1 ));


2. (ϕ1 → ϕ2 ) ≡ (¬ϕ1 ∨ ϕ2 );
3. (ϕ1 ∨ (ϕ2 ∧ ϕ3 )) ≡ ((ϕ1 ∨ ϕ2 ) ∧ (ϕ1 ∨ ϕ3 ));
4. ((ϕ2 ∧ ϕ3 ) ∨ ϕ1 ) ≡ ((ϕ2 ∨ ϕ1 ) ∧ (ϕ3 ∨ ϕ1 ));
5. (ϕ1 ∨ (ϕ2 ∨ ϕ3 )) ≡ ((ϕ1 ∨ ϕ2 ) ∨ ϕ3 );
6. (ϕ1 ∧ (ϕ2 ∧ ϕ3 )) ≡ ((ϕ1 ∧ ϕ2 ) ∧ ϕ3 );
7. ¬(ϕ1 ∨ ϕ2 ) ≡ (¬ϕ1 ∧ ¬ϕ2 );
8. ¬(ϕ1 ∧ ϕ2 ) ≡ (¬ϕ1 ∨ ¬ϕ2 );
9. ¬¬ϕ ≡ ϕ.

The first two equivalences ensure the fact that all double implications and
all implications disappear from the formula.
The third and the fourth equivalence ensure that in the tree of the formula,
all disjunctions “go under” the conjunctions.
Equivalences 5 and 6 ensure the associativity of the chains of disjunctions
and conjunctions, respectively (it allows us to write ϕ1 ∨ ϕ2 ∨ ϕ3 ∨ . . . ∨ ϕn
instead of ((((ϕ1 ∨ ϕ2 ) ∨ ϕ3 ) ∨ . . .) ∨ ϕn ).
Equivalences 7 and 8 ensure that the negations end up “under” the con-
junctions and disjunctions in the tree of the formula.

Part I - Propositional Logic 71 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

The last equivalence ensures that there are no double negations “one under
the other” in the abstract syntax tree.
Applying the equivalences above eventually stops (they cannot be applied
ad infinitum – why?).
The result will be a formula in which all conjunctions are “above” all
disjunctions, which are “above” all possible negations, meaning a formula in
CNF. q.e.d.

Example 133. Let us bring the formula ((¬p → ¬q) ↔ (q → p)) into CNF

((¬p → ¬q) ↔ (q → p))


1
   
≡ (¬p → ¬q) →(q → p) ∧ (q → p) →(¬p → ¬q)
2
   
≡ (¬¬p ∨ ¬q) →(¬q ∨ p) ∧ (¬q ∨ p) →(¬¬p ∨ ¬q)
2
   
≡ ¬(¬¬p ∨ ¬q) ∨ (¬q ∨ p) ∧ ¬(¬q ∨ p) ∨ (¬¬p ∨ ¬q)
7
   
≡ (¬¬¬p ∧ ¬¬q) ∨ (¬q ∨ p) ∧ (¬¬q ∧ ¬p) ∨ (¬¬p ∨ ¬q)
9
   
≡ (¬p ∧ q) ∨ (¬q ∨ p) ∧ (q ∧ ¬p) ∨ (p ∨ ¬q)
4
     
≡ ¬p ∨ (¬q ∨ p) ∧ q ∨ (¬q ∨ p) ∧ q ∨ (p ∨ ¬q) ∧ ¬p ∨ (p ∨ ¬q)
5
     
≡ (¬p ∨ ¬q) ∨ p ∧ (q ∨ ¬q) ∨ p ∧ (q ∨ p) ∨ ¬q ∧ (¬p ∨ p) ∨ ¬q
 
=
6
(¬p ∨ ¬q ∨ p) ∧ (q ∨ ¬q ∨ p) ∧ (q ∨ p ∨ ¬q) ∧ (¬p ∨ p ∨ ¬q)
≡ (¬p ∨ ¬q ∨ p) ∧ (q ∨ ¬q ∨ p) ∧ (q ∨ p ∨ ¬q) ∧ (¬p ∨ p ∨ ¬q)
= (¬p ∨ ¬q ∨ p) ∧ (q ∨ ¬q ∨ p) ∧ (q ∨ p ∨ ¬q) ∧ (¬p ∨ p ∨ ¬q).

8.7 Disjunctive Normal Form


Definition 134 (DNF). A formula is in DNF if it is a disjunction of con-
junctions of literals.

Example 135. The following formulae are in DNF:

1. (¬p ∧ q) ∨ (r ∧ ¬p ∧ r0 ) ∨ (¬p ∧ ¬r);

2. ¬p ∨ (r ∧ ¬p ∧ r0 ) ∨ ¬r;

3. ¬p ∨ r ∨ ¬r;

4. ¬p;

5. p.

The following formulae are not in DNF:

Part I - Propositional Logic 72 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

1. ¬(¬p ∧ q) ∨ (r ∧ ¬p ∧ r0 ) ∨ (¬p ∧ ¬r);


2. ¬p ∨ ¬(r ∧ ¬p ∧ r0 );
3. ¬p ∧ (r ∨ ¬p ∨ r0 );
4. ¬¬p;
5. p ∧ (q ∨ r).
Exercise 136. State and sketch the proof of a constructive theorem to bring
a formula into DNF.

8.8 The Link between DNF and CNF


Definition 137. The complement of a formula ϕ ∈ PL¬,∨,∧ is denoted by ϕc
and is defined as follows:
1. ac = ¬a, for any a ∈ A;
2. (¬ϕ)c = ϕ, for any ϕ ∈ PL;
3. ((ϕ1 ∨ ϕ2 ))c = (ϕ1 c ∧ ϕ2 c ), for any ϕ1 , ϕ2 ∈ PL;
4. ((ϕ1 ∧ ϕ2 ))c = (ϕ1 c ∨ ϕ2 c ), for any ϕ1 , ϕ2 ∈ PL.
Example 138. 1. (¬p)c = p (the complement of ¬p is not ¬¬p);
2. (¬(¬p ∧ q)∨(r ∧ ¬p ∧ r0 )∨(¬p ∧ ¬r))c =
(¬p ∧ q)∧(¬r ∨ p ∨ ¬r0 )∧(p ∨ r);
3. ((¬p ∨ q) ∧ (r ∨ ¬p ∨ r0 ) ∧ (¬p ∨ ¬r))c =
(p ∧ ¬q) ∨ (¬r ∧ p ∧ ¬r0 ) ∨ (p ∧ r).
Theorem 139 (The Complement is Equivalent to the Negation). For any
formula ϕ ∈ PL¬,∧,∨ , we have that
ϕc ≡ ¬ϕ.
Exercise 140. Prove the theorem above by structural induction.
c
Example 141. (p ∧ (q ∨ ¬r)) = (¬p ∨ (¬q ∧ r)) ≡ ¬(p ∧ (q ∨ ¬r)).
Theorem 142 (The Link between CNFs and DNFs). Let ϕ1 be a formula in
CNF and ϕ2 a formula in DNF. Then
ϕ1 c is in DNF
and

ϕ2 c is in CNF.

Part I - Propositional Logic 73 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

8.9 Exercise Sheet


Exercise 143. Write the following formulae with as few brackets as possible:
1. ((p ∧ ¬q) ∧ r); 2. ((p ∨ ¬q) ∧ r); 3. ¬((p ∨ ¬q) ∧ r).
Exercise 144. Compute the abstract syntax tree for the following formulae
(pay attention to the priority of the logical connectives):
1. p ∧ q ∨ r; 2. ¬p ∧ ¬q ∨ ¬r; 3. p ∧ ¬q ∨ r; 4. ¬p ∧ ¬(q ∨ r);
5. p ∨ ¬p ∧ ¬(q ∨ r).

Exercise 145. Bring the following formulae into CNF:

1. ((p ∧ q) ∨ r);

2. ((p ∨ q) ∧ r);
3. ¬((p ∨ q) ∧ r);
4. ¬((p ∧ q) ∨ r);

5. ((p ∧ q) ∨ (¬p ∧ ¬q));


6. ((p ∧ (q ∧ r)) ∨ ¬p);
7. ¬(¬(p ∧ q) ∨ (p ∨ q));
8. (¬(p ∧ q) →(¬p ∧ ¬q));

9. (p ↔ (q →(¬p ∧ ¬q)));
10. ((p → q) ↔ (¬q → ¬p));
11. (p1 ∧ q1 ) ∨ (p2 ∧ q2 ) ∨ . . . ∨ (pn ∧ qn ) (first solve the cases n = 2 and
n = 3, then generalize);

Exercise 146. Bring into CNF the formula p ∨ q → p ∧ ¬r (mind the pri-
ority of the logical connectives).

Exercise 147. Compute the complement of the formulae in CNF computed


above.

Part I - Propositional Logic 74 Lecture notes - to print in color


Chapter 9

Resolution in Propositional
Logic

Natural deduction is a proof system that was invented by Gentzen to be as


close as possible to actual reasoning.
However, a downside of natural deduction is that, given a sequent

ϕ1 , ϕ2 , . . . , ϕn ` ϕ,

it is difficult for a computer program to find a formal proof of the sequent


(i.e., it is not terribly efficient) due to the multitude of potential rules that
can be applied.
Resolution is a proof system, just like natural deduction, but tailored
to computers and not humans. In particular, it is easy for computers to
find resolution proofs (at least, easier than finding natural deduction proofs).
However, resolution proofs do not resemble human reasoning very well. There
are programming languages (Prolog) that use (a variant of) resolution as their
basic execution step.

9.1 Clauses as Sets of Literals


We have that disjunction is:

1. associative: for all ϕ1 , ϕ2 , ϕ3 ∈ PL,


(ϕ1 ∨ (ϕ2 ∨ ϕ3 )) ≡ ((ϕ1 ∨ ϕ2 ) ∨ ϕ3 );

2. commutative: for all ϕ1 , ϕ2 ∈ PL,


(ϕ1 ∨ ϕ2 ) ≡ (ϕ2 ∨ ϕ1 );

75
Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

3. idempotent: for all ϕ ∈ PL, (ϕ ∨ ϕ) ≡ ϕ.


Exercise 148. Prove the three equivalences above.
This means, for example, that the clauses p ∨ p ∨ p ∨ ¬q ∨ ¬q, ¬q ∨ p ∨ ¬q ∨ p,
p ∨ ¬q are all equivalent. The three equivalences above justify the use of the
notation:
Notation. For any literals ϕ1 , . . . , ϕn the set
{ϕ1 , ϕ2 , . . . , ϕn }
is a representation of the following formula:
ϕ1 ∨ ϕ2 ∨ . . . ∨ ϕn .
That is, a clause is the set of its literals.
Example 149. The clause p ∨ q ∨ ¬r is represented by the set {p, q, ¬r}.
This set of literals, { p, q, ¬r }, also represents the following clauses:
1. q ∨ p ∨ ¬r;
2. q ∨ p ∨ ¬r ∨ p;
3. p ∨ q ∨ p ∨ ¬r ∨ p;
4. etc.
(Due to the fact that disjunction is associative, commutative, and idempo-
tent, all these formulas are equivalent.)
Remark. Attention! A set of literals represents multiple clauses, but all these
clauses are equivalent.
Exercise 150. Make sure you understand the notations above and can easily
switch between notations.
Remark. Furthermore, we will allow a slight abuse of language and say
clause to refer to a set of literals.
Also, we will allow using clauses seen as sets of literals instead of formulas
when it is not relevant to which of the formulas represented by the set of literals
we are referring.
For example, using the language abuse explained above, we have the fact
that the clause { p, ¬p } is valid. Why? Because any formula represented
by the clause { p, ¬p } (for example, (p ∨ ¬p) or ((p ∨ ¬p) ∨ p)) is true in
any assignment.
Remark. Recall that the notation  is called the empty clause and repre-
sents the particular case of a disjunction of 0 literals, thus representing any
contradiction.

Part I - Propositional Logic 76 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

9.2 CNFs as Sets of Clauses


Similarly to disjunction, conjunction also enjoys the following three properties:

1. associative: for all ϕ1 , ϕ2 , ϕ3 ∈ PL,


(ϕ1 ∧ (ϕ2 ∧ ϕ3 )) ≡ ((ϕ1 ∧ ϕ2 ) ∧ ϕ3 );
2. commutative: for all ϕ1 , ϕ2 ∈ PL,
(ϕ1 ∧ ϕ2 ) ≡ (ϕ2 ∧ ϕ1 );
3. idempotent: for all ϕ ∈ PL, (ϕ ∧ ϕ) ≡ ϕ.

Exercise 151. Prove the three equivalences above.


The three equivalences above justify the following notation:
Notation. Given clauses ϕ1 , . . . , ϕn , we write

{ϕ1 , . . . , ϕn }

instead of the CNF formula

ϕ1 ∧ . . . ∧ϕn .

For example, we write {p ∨ ¬q, q ∨ r ∨ p} instead of (p ∨ ¬q) ∧ (q ∨ r ∨ p).


Going further, we will combine the two notations above and write, for
example, {{p, ¬q}, {q, r, p}} for (p ∨ ¬q) ∧ (q ∨ r ∨ p). That is, we write a
CNF formula as a set of sets of literals.
Exercise 152. Write the CNF formula (p ∨ q) as a set of sets of literals.
Write the CNF formula (p ∧ q) as a set of sets of literals.

9.3 Resolution
Resolution is a proof system with only one inference rule. The hypotheses and
the conclusion of the inference rule are all clauses (unlike natural deduction,
where the hypotheses and the conclusion were sequents).
Here is the resolution rule:

C ∪ {a} D ∪ {¬a}
Binary Resolution
C ∪D

In the rule above, C and D denote arbitrary clauses and a ∈ A denotes an


arbitrary propositional variable. As C is a clause and a ∈ A is a propositional

Part I - Propositional Logic 77 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

variable, it follows that C ∪ {a} is also a clause. In fact C ∪ {a} is the first
hypothesis of the inference rule.
The second hypothesis is the clause D ∪{¬a}. The conclusion is the clause
C ∪ D.
Here is an example of applying the resolution rule:
1. {p, q}; (premiss)
2. {¬p, ¬r}; (premiss)
3. {q, ¬r}. (by Resolution, lines 1, 2, a = p)
Definition 153. The clause C ∪D resulting from applying resolution is called
the resolvent of C ∪ {a} and D ∪ {¬a}.
Note that the resolvent of two clauses is not unique. For example, the
clauses {p, q} and {¬p, ¬q, r} have two resolvents: {p, ¬p, r} and respectively
{q, ¬q, r}. We may distinguish among the various resolvents by stating on
which propositional variable a we have performed the resolution:
Definition 154. The clause C ∪D resulting from applying resolution is called
the resolvent of C ∪ {a} and D ∪ {¬a} on a.
For example, {p, ¬p, r} is the resolvent on q of the clauses {p, q} and
{¬p, ¬q, r}, while {q, ¬q, r} is their resolvent on p.
Remark. Note that when we apply inference rules, we must follow them to
the letter. For example, a common mistake in applying resolution is:
1. {p, q, r}; (premiss)
2. {¬p, ¬q}; (premiss)
3. {r}. (wrong application of resolution)
On line 3, we may conclude either the resolvent on p or on q, but it makes
no sense to mix the two in order to have a single resolvent on both p and q.
Make sure you understand this point very well.
Here is the first correct variant:
1. {p, q, r}; (premiss)
2. {¬p, ¬q}; (premiss)
3. {q, r, ¬q}; (resolvent of 1, 2 on a = p)
and the second one:
1. {p, q, r}; (premiss)
2. {¬p, ¬q}; (premiss)
3. {p, r, ¬p}. (resolvent of 1, 2 on a = q)

Part I - Propositional Logic 78 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

9.4 Formal Proofs


Just as in the case of natural deduction,
Definition 155. A formal proof of a clause ϕ from a set of clauses ϕ1 , ϕ2 , . . . , ϕn
is a sequence of clauses ψ1 , ψ2 , . . . , ψm such that, for all 1 ≤ i ≤ m:

• either ψi ∈ {ϕ1 , . . . , ϕn },
• or ψi is obtained by resolution from some clauses ψj , ψk that appear
earlier in the formal proof: 1 ≤ j, k < i.

Furthermore ψm must be the same as ϕ.


The clauses ϕ1 , . . . , ϕn are called the premisses of the formal proof and ϕ
is the conclusion.
Example 156. Here is an example of a proof of {p, ¬q} from {¬r, p, ¬r0 },
{r, p} and {r0 , ¬q}:

1. {¬r, p, ¬r0 }; (premiss)


2. {r, p}; (premiss)
3. {r0 , ¬q}; (premiss)
4. {p, ¬r0 }; (B.R., 2, 1, a = r)
5. {p, ¬q}. (resolution, 3, 4, a = r0 )

We sometimes also say derivation (by resolution) of ϕ instead of formal


proof of ϕ.
Example 157. Here is a derivation of the empty clause from {p, ¬q}, q, ¬p:

1. {p, ¬q}; (premiss)


2. {q}; (premiss)
3. {¬p}; (premiss)
4. {p}; (B.R., 2, 1, a = q)
5. . (B.R., 4, 3, a = p)

Definition 158 (Refutation). A derivation of  from ϕ1 , . . . , ϕn is some-


times also called a refutation of ϕ1 , . . . , ϕn .
Exercise 159. Starting with the same premisses, find a different proof by
resolution of .

Part I - Propositional Logic 79 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

9.5 Soundness
Like natural deduction, resolution is sound. This section shows that this is
indeed the case.

Lemma 160. Let ϕ ∈ {ϕ1 , . . . , ϕn }. We have that

ϕ1 , . . . ϕn |= ϕ.

Exercise 161. Prove Lemma 160.

Lemma 162. Let C, D be two clauses and let a ∈ A be a propositional vari-


able. We have that
C ∪ {a}, D ∪ {¬a} |= C ∪ D.

Exercise 163. Prove Lemma 162.

Theorem 164 (Soundness of Resolution). If there is a proof by resolution of


ϕ from ϕ1 , . . . , ϕn , then
ϕ1 , . . . , ϕn |= ϕ.

Proof: Let ψ1 , . . . , ψm be a proof by resolution of ϕ from ϕ1 , . . . , ϕn .


We will prove by induction on i ∈ {1, 2, . . . , m} that

ϕ1 , . . . , ϕn |= ψi .

Let i ∈ {1, 2, . . . , m} be an integer. We assume by the induction hypothesis


that
ϕ1 , . . . , ϕn |= ψl for any l ∈ {1, 2, . . . , i − 1}
and we prove that
ϕ1 , . . . , ϕn |= ψi .
By the definition of a formal proof by resolution, we must be in one of the
following two cases:

1. ψi ∈ {ϕ1 , . . . , ϕn }. In this case we have

ϕ1 , . . . , ϕn |= ψi

by Lemma 160, which is what we had to show.

2. ψi was obtained by resolution from ψj , ψk with 1 ≤ j, k < i. In this


case, ψj must be of the form ψj = C ∪ {a}, ψk must be of the form
ψk = D ∪ {¬a} and ψi = C ∪ D, where C, D are clauses and a ∈ A is a
propositional variable.

Part I - Propositional Logic 80 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

By the induction hypotheses that ϕ1 , . . . , ϕn |= ψj and that ϕ1 , . . . , ϕn |=


ψk . Replacing ψj and ψk as detailed above, we have that

ϕ1 , . . . , ϕn |= C ∪ {a}

and that
ϕ1 , . . . , ϕn |= D ∪ {¬a}.

We prove that
ϕ1 , . . . , ϕn |= C ∪ D.
Let τ be a model of ϕ1 , . . ., and ϕn . We have that τ is a model of
C ∪ {a} and of D ∪ {¬a} by the semantical consequences above. By
Lemma 162, it follows that τ is a model of C ∪ D. But ψi = C ∪ D and
therefore τ is a model ψi . As τ was any model of all of ϕ1 , . . ., and ϕn ,
it follows that
ϕ1 , . . . , ϕn |= ψi ,
which is what we had to prove.

In both cases, we have established

ϕ1 , . . . , ϕn |= ψi

for all 1 ≤ i ≤ m. As ψ1 , . . . , ψm is a proof of ϕ, it follows that ψm = ϕ and


therefore, for i = m, we have

ϕ1 , . . . , ϕn |= ϕ,

which is what we had to prove.


q.e.d.

9.6 Completeness
A proof system must be sound in order to be of any use (otherwise, we could
use it to prove something false).
However, it is also nice when a proof system is complete, in the sense of
allowing to prove any true statement.
Unfortunately, resolution is not complete, as shown by the following ex-
ample:
Theorem 165 (Incompleteness of Resolution). There exist clauses ϕ1 , . . . , ϕn , ϕ
such that
ϕ1 , . . . , ϕn |= ϕ,
but there is no resolution proof of ϕ from ϕ1 , . . . , ϕn .

Part I - Propositional Logic 81 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

Proof: Let n = 2, ϕ1 = p, ϕ2 = q and ϕ = {p, q}. We clearly have that


p, q|=(p ∨ q), but there is no way to continue the following resolution proof:
1. {p}; (premiss)
2. {q}; (premiss)
3. · · ·
because there is no negative literal anywhere. Therefore, only p and q can be
derived by resolution from p, q. q.e.d.
However, resolution still has a weaker form of completeness called refuta-
tional completeness:
Theorem 166 (Refutational Completeness of Resolution). If the CNF for-
mula ϕ1 ∧ . . . ∧ ϕn is unsatisfiable, then there is a derivation by resolution
of  starting from the clauses ϕ1 , ϕ2 , . . ., ϕn .
The proof is beyond the scope of the course, but it is not too complicated
in case you want to prove it yourself and I recommend this exercise for the
more curious minds among you.

9.7 Proving Validity and Logical Consequences


by Resolution
We may use the soundness and refutational completeness of resolution to
construct an algorithm for validity checking and logical consequence testing.

Validity Testing Here is an example of how to test the validity of the


formula p ∨ q → q ∨ p.
First of all, recall that:
Theorem 167. A formula is valid iff its negation is a contradiction.
Exercise 168. Prove the theorem above.
Therefore, establishing validity of p ∨ q → q ∨ p is equivalent to estab-
lishing unsatisfiability of ¬(p ∨ q → q ∨ p).
A formula is satisfiable iff its CNF is satisfiable.
Let us compute a CNF of ¬(p ∨ q → q ∨ p):

¬(p ∨ q → q ∨ p) ≡ ¬(¬(p ∨ q) ∨ (q ∨ p))


≡ ¬¬(p ∨ q) ∧ ¬(q ∨ p)
≡ (p ∨ q) ∧ (¬q) ∧ (¬p).

Part I - Propositional Logic 82 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

We have reached a CNF. Starting with the clauses that make up the CNF,
we can derive :

1. {p, q}; (premiss)


2. {¬q}; (premiss)
3. {¬p}; (premiss)
4. {p}; (resolution, 1, 2, a = q)
5. . (resolution, 4, 3, a = p)

We may reason by applying the following corrolary of the soundness the-


orem:
Corollary 169. If  is derivable by resolution from ϕ1 , . . . , ϕn , then the set
of clauses {ϕ1 , . . . , ϕn } is inconsistent.

Proof: By the soundness theorem, we have that ϕ1 , . . . ϕn |= . Assume by


  that {ϕ1 , . . . , ϕn } is consistent; then there is a τ : A → B
contradiction  such

that τ̂ ϕ1 = . . . = τ̂ ϕn = 1. As ϕ1 , . . . ϕn |= , we also have that τ̂  =
1. But, by definition, there is no such assignment (that makes  true), and
therefore our assumption must have been false. Therefore {ϕ1 , . . . , ϕn } is not
consistent. q.e.d.
Continuing our example, our set of clauses is inconsistent, which means
that ¬(p ∨ q → q ∨ p) is unsatisfiable, which further means that the formula
(p ∨ q → q ∨ p) is valid (what we had to show in the first place).

Testing Logical Consequence How to prove by resolution that ϕ1 , . . . , ϕn |=


ϕ?
We use the following theorem, which reduces logical consequence to valid-
ity:
Theorem 170. Let ϕ1 , . . . , ϕn , ϕ be any propositional formulae. We have
that
ϕ1 , . . . , ϕn |= ϕ
iff
ϕ1 ∧ . . . ∧ ϕn → ϕ
is valid.
Exercise 171. Prove the theorem above.
To establish a logical consequence by resolution, first apply the theorem
above and then apply the method shown above for proving validity.

Part I - Propositional Logic 83 Lecture notes - to print in color


Logic for Computer Science 2023-2024 Alexandru Ioan Cuza University

9.8 Exercise Sheet


Exercise 172. Using resolution, show that the following formulae are valid:

1. ((p ∧ q) → (p ∨ q));
2. (p → (q → p));

3. ((p → q) → (¬q → ¬p));

Exercise 173. Using resolution, show the following semantical consequences:

1. p |= (p ∨ q);

2. (p ∧ q) |= (p ∨ q);
3. ((p ∧ q) → r) |= (p → (q → r));
4. (p → p0 ), (q → q0 ) |= ((p ∧ q) → (p0 ∨ q0 )).

Part I - Propositional Logic 84 Lecture notes - to print in color

You might also like