Comp231 Logic 231219
Comp231 Logic 231219
Comp231 Logic 231219
Discrete Structures
Logic
Reference Books:
• Mathematical Structures For Computer Science, 7th ed, Judith Gersting,
Freeman, 2014.
• Discrete Mathematical Structures, 6th ed, Sharon Ross, Bernard Kolman,
Robert Busby, Pearson, 2015.
Truth Table
Example:
Truth Table
Example:
Example: If we replace
OR, in the previous example
by XOR, then we have
Today it is either Friday or it is raining
Truth Table:
Note that the implication is false only
when p is true and q is false, and is true otherwise.
is false. We will see later that the computer’s if is equivalent in logic to iff.
Pk: The cause-effect connotation of the “if” of ordinary English may be missing in
the “if” of mathematical logic. The latter is purely of a formal structure.
Mathematical: (conclusion[proposition]) IF (hypothesis[proposition]),
English : (effect[result]) IF (cause[predicate]),
Take the example of: you will pass the exam IF you study well -> (pass IF study)
hypothesis is sufficient for conclusion, and conclusion is sufficient for hypothesis
Logic: study sufficient for pass: verifiable (via TT), pass necessary for study: verifiable (via TT)
English: study sufficient for pass : understandable as study precedes passing, thus causes it.
pass necessary for study : NOT understandable as passing does not precede study to be
necessary for it Prof. H. Nassar, BAU
Example on the variations of “if”
if you eat well, your health improves = your health improves if you eat well
Eating well is sufficient for your health improvement
you had eaten well, only if your health has improved
Your health improvement is necessary to judge you have eaten well
This last statement is confusing if it is read with the “English” usage in mind, as
health improvement follows eating well. In English, a is necessary for b, if a
precedes b. Here, health improvement does not precede eating well, but rather
follows it. So, where is the catch? The catch is that in logic, we have in mind
only the truth values of the propositions considered in the TT of “IF”, i.e.:
Eating well is true (in the TT), only if your health improvement is true (in the TT)
a = eating well b = health improvement if a then b (a only if b)
T T T
T F F
F T T
F F T
Excluding the 2nd case (where the whole IF statement is False), of all the cases where the
whole IF statement is True, the only case where a is True is only if b is True.
Prof. H. Nassar, BAU
Converse, Contra-positive, and Inverse
Proposition Equivalence:
Example:
“If you eat well, your health will improve”
IS EQUVALENT TO its contrapositive
“If your health does not improve, you have not eaten well”
Example:
“If you eat well, your health will improve”
IS NOT EQIV TO its converse
“If your health improves, you are have eaten well”
Example:
“If you eat well, your health will improve”
IS NOT EQUIVALENT TO its inverse
“If you do not eat well, your health will not improve”
Truth Table:
Example:
Using iff in conditioning, tells that the condition is indispensible and is unique. That is,
nothing else will achieve the occurrence of the result. The condition a if b, is not as
strong. It is true here that b will still achieve the occurrence of a, but it is dispensable
and other conditions (or even none) can achieve theProf. occurrence of the a.
H. Nassar, BAU
An informal word on iff
A if B: means B is sufficient for A
but also means that A can be true without B being true
(i.e. B will do it but can also be dispensed with)
That is why we add only if to emphasize the
indispensability of B. Thus
A iff B: means B will do it and it is the only thing that
will do it (cannot be dispensed with).
Ex: Ahmed will pass the exam if he studies
(study is a DISPENSIBLE condition, i.e. Ahmed can pass without studying!)
You can look at the “only if”, in “iff”, as a sort of “insistence”,
much like the “only one” in “one and only one”.
Definition:
Ex:
Note 1: See the word “compound”, i.e. equivalence is between comp prop
Note 2: and and are not the same, but and are.
Note 3: Logical equivalence is usually established using TT.
Ex. (De Morgan’s Law):
Ex:
Ex:
Ex:
Ex:
Ex:
Ex.:
To show the equivalence, we need to show that these two implications are true:
·x(P(x)¥Q(x)) ! ·xP(x)¥·xQ(x)), and
·xP(x)¥·xQ(x)) ! ·x(P(x)¥Q(x))
We will use now a “standard” proof technique commonly used in such situations.
To prove the first, assume that ·x(P(x)¥Q(x)) is true and let a be a point in the domain.
Then, P(a)¥Q(a)) is true, which implies (from the properties of ¥) that P(a) is true and Q(a) is true.
And since a is any point in the domain, then ·xP(x)¥·xQ(x)) which is the first part.
To prove the second, assume that ·xP(x)¥·xQ(x) is true and let a be a point in the domain.
Then, P(a) is true and Q(a) is true, which implies (from the properties of ¥) that P(a)¥Q(a)is true.
And since a is any point in the domain, then ·x(P(x)¥Q(x))Prof.
which is the second part.
H. Nassar, BAU
Negation of logical quantifiers
Each of the two logical quantifiers can be negated.
Actually, each quantifier is used in the negative of
the other. Namely, the negative of “For all x P(x)”
is “There exist x ¦P(x).” and vice versa. The table
below details on this.
Problem.: Write the logical expression and its negation for each of the following
two statements:
“There is an honest politician”,
“all Arabs eat chicken..”
Prof. H. Nassar, BAU
Homework: Problems: 4, 6, 10, 14, 20, 24, 30, 32, 34, 36
Ex: (argument = premises + conclusion)