Maths (Lectures 1 & 2 The Foundations Logic and Proofs)
Maths (Lectures 1 & 2 The Foundations Logic and Proofs)
UNIT I
Automated reasoning systems have been created to allow computers to
construct their own proofs.
Many people find it surprising, how important proofs are in computer science?
In fact, proofs are used to verify that computer programs,
to artificial intelligence;
to computer programming;
to programming languages;
and to other areas of computer science, as well as to many other fields of study.
Precision is important when communicating with computers, but the English
language is rife with ambiguities.
We begin with an introduction to the basic building blocks
of logic — propositions.
Propositions
A proposition or statement is a declarative sentence that is either true or false,
but not both.
Example: Which of the following are statements?
(a) The earth is round.
(b) 2 + 3 = 5
(c) Do you speak English?
(d) 3 − x = 5
(e) Take two aspirins.
(f) The temperature on the surface of the planet Venus is 8000 F.
(g) The sun will come out tomorrow.
Solution:
(a) and (b) are statements that happen to be true.
(c) is a question, so it is not a statement.
(d) is a declarative sentence, but not a statement, since it is true or false depending
(f) is a declarative sentence whose truth or falsity we do not know at this time;
however, we can in principle determine if it is true or false, so it is a statement.
(g) is a statement since it is either true or false, but not both, although we would
We’ll use symbols such as p, q, and r as propositional variables—that is,
variables that represent propositions, in the same way that in ordinary algebra
use variables such as x and y to represent numbers.
Propositional variables may also be called atomic propositions, as opposed to
compound propositions,
which are composed from other propositions using “and,” “or,” and the like.
The truth value of a proposition is true, denoted by T, if it is a true proposition,
in other words, for every proposition p, either p is true or ¬ p is true but not
both.
If r is the statement that all hens are black, then ¬ r is the statement that there is
This table has a row for each of the two possible truth values of a proposition p.
Each row shows the truth value of ¬ p corresponding to the truth value of p for
that row.
Definition 2: Let p and q be propositions. The conjunction of p and q, denoted
by p ∧ q, is the proposition “p and q.”
The conjunction p ∧ q is true when both p and q are true and is false otherwise.
Truth table for the “and” operator.
Solution
(a) p ∧ q : It is snowing and I am cold.
The disjunction p ∨ q is false when both p and q are false and is true otherwise.
Suppose that we say “I left for Spain on Monday or I left for Spain on Friday.”
Both could not have occurred, so the connective or is being used in an exclusive
sense.
On the other hand, consider the disjunction
Note that the statement p → q is true when both p and q are true and when p is
false (no matter what truth value q has).
For example, the pledge many politicians make when running for office is
If the politician is elected, voters would expect this politician to lower taxes.
Furthermore, if the politician is not elected, then voters will not have any
expectation that this person will lower taxes,
although the person may have sufficient influence to cause those in power to
lower taxes.
It is only when the politician is elected but does not lower taxes that voters can say
that the politician has broken the campaign pledge.
This last scenario corresponds to the case when p is true but q is false, in p → q.
A variety of terminology is used to express p → q, in most if not all of the
following ways to express p → q :
“if p, then q” “p implies q”
“if p, q” “p only if q”
“q if p” “q whenever p”
“q unless ¬ p”
Of the various ways to express the conditional statement p → q,
the two that seem to cause the most confusion are “p only if q” and “q unless ¬
p.”
To remember that “p only if q” expresses the same thing as “if p, then q,”
To see this, note that the true values of “q only if p” and p → q are different
That is, the statement “q unless ¬ p” is false when p is true but q is false,
but it is true otherwise.
To see this, note that the contrapositive is false only when ¬ p is false
“If the home team does not win, then it is not raining.”
The original statement can be rewritten as
“If the home team does not win, then it is not raining.”
The converse is
“If the home team wins, then it is raining.”
The inverse is
“If it is not raining, then the home team does not win.”
has the same truth value as p → q for all possible truth values of p and q.
Note that when p is true and q is false, the original conditional statement is false,
The biconditional statement p ↔ q is true when p and q have the same truth
values, and is false otherwise.
The biconditional statement p ↔ q uses the abbreviation “iff” for “if and only if.”
That is why we use the words “if and only if” to express this logical connective and
“p iff q.”
Example: Let p be the statement “You can take the flight,” and let q be the
statement “You buy a ticket.”
Then p ↔ q is the statement “You can take the flight if and only if you buy a
ticket.”
This statement is true if p and q are either both true or both false, that is, if you buy
a ticket and can take the flight
or if you do not buy a ticket and you cannot take the flight.
It is false when p and q have opposite truth values, that is, when you do not buy a
ticket, but you can take the flight (such as when you get a free trip)
and when you buy a ticket but you cannot take the flight (such as when the airline
dumps you).
IMPLICIT USE OF BICONDITIONALS
You should be aware that biconditionals are not always explicit in natural language.
In particular, the “if and only if” construction used in biconditionals is rarely used in
common language.
Instead, biconditionals are often expressed using an “if, then” or an “only if”
construction.
The other part of the “if and only if” is implicit. That is, the converse is implied, but
not stated.
For example, consider the statement in English
“If you finish your meal, then you can have dessert.”
“You can have dessert if and only if you finish your meal.”
“If you finish your meal, then you can have dessert” and “You can have dessert
only if you finish your meal.”
biconditional statement p ↔ q.
Logic and Bit Operations
A bit is a symbol with two possible values, namely, 0 (zero) and 1 (one).
because zeros and ones are the digits used in binary representations of numbers.
A bit can be used to represent a truth value, because there are two truth values,
namely, true and false.
By replacing true by a one and false by a zero in the truth tables for the operators
∧, ∨, and ⊕, for the corresponding bit operations.
We will also use the notation OR, AND, and XOR for the operators ∨,∧, and ⊕, as
is done in various programming languages.
When this is done, operations on the bit strings can be used to manipulate this
information.
Definition: A bit string is a sequence of zero or more bits. The length of this
string is the number of bits in the string.
We use the symbols ∨, ∧, and ⊕ to represent the bitwise OR, bitwise AND, and
bitwise XOR operations, respectively.
Example: Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings
0110110110 and 1100011101.
Solution: The bitwise OR, bitwise AND, and bitwise XOR of these strings are
obtained by taking the OR, AND, and XOR of the corresponding bits,
respectively. This gives us
0110110110
1100011101
1110111111 bitwise OR