1 What Is Logic in Computer Science?
1 What Is Logic in Computer Science?
Lecture 1
Antonina Kolokolova
Sep 8th, 2011
Why do we study mathematical logic? Natural languages (such as English) are too ambiguous:
Every student knows this and Any student knows this have the same meaning.
Shed be happy if she passes every course and Shed be happy if she passes
any course mean very different things.
Mathematical logic is a kind of language, where everything is designed to have a precise
meaning. This is the language of unambiguous reasoning. So this course is somewhat like
a foreign language course: there will be a lot of vocabulary to memorize. Also, like in a
language course, you need to practice speaking logic language for it to become natural.
Logic comes into computer science in many different ways:
Digital circuit logic
Proof of correctness of programs, verification
Automated reasoning in artificial intelligence
The material in this set of notes came from many sources, in particular Discrete mathematics with
applications by Susanne Epp, several books by Raymond Smallian, course notes of U. of Toronto CS 238
by Vassos Hadzilacos.
Propositional logic
The basic unit of our reasoning is a sentence that can have a truth value, that is it can be
either true or false. We call such a sentence a proposition. For example, it is raining is
a proposition. It is true or false at any particular point in time and space. So is I am a
dolphin (which happens to be false, as far as I know), or 2 is a prime number. When
referring to a proposition, we often will give it a short name (a variable); for example, we
can use a variable p to denote the sentence it is raining. Now, if we say p is true we will
mean that it is, indeed, raining. Such variables denoting propositions are called propositional
variables. A propositional variable can have a truth value of exactly one of true or false.
Simple propositions can be combined. For example, we can say if it is raining, then it must
be cloudy. Here, we mean that raining (that is, our proposition p) implies that it is also
cloudy. If we use a propositional variable q to mean it is cloudy then in the language of
propositional logic we say that p implies q. Implication is one of logical connectives that
allow us to make more complicated statements, propositional formulas, out of propositions.
The following table lists several common logical connectives.
Meaning
both p and q are true
at least one of p, q is true
opposite of p is true
if p is true then q is true
Name
conjunction
disjunction
negation
implication
Notation
pq
pq
p
pq
Pronunciation
p and q
p or q
not p
p implies q
We will also use logical connectives (p q is p only if q, where if q is true then p must
also be true) and meaning that p and q are either both true or both false, p if and only if
q (sometimes pronounced as p iff q). Note that the last one has the meaning opposite to
the exclusive-OR ; we would not be using much.
Instead of p and q we could have whole propositional formulas which are themselves made
out of propositions, logical connectives and parentheses (to specify what logical connectives
apply to). For example, if we denote I am a dolphin by a propositional variable r, then
the following is a propositional formula: (p q) r, which reads as It is not raining or it
is cloudy and, besides, I am a dolphin. Here, the precedence order is first , then , then
, and then : that is, q p q r is parenthesized as (q) ((p) (q r)). It
may help to think of , and as unary , and + in arithmetic formulas: we will show
2