Equational Logic. Part 1

1
Equational Logic. Part 1
Roland Backhouse
February 6th, 2001
2
Outline
• The Logical Connectives.
• Properties of Equality.
• Properties of Equivalence.
• Negation
3
Logical Connectives
Proofs involve two components:
• Reasoning dependent on properties of the data.
• Reasoning that is independent of properties of the data: logical
reasoning.
For example, if the goal is to prove that
l ≤ (l+r−1) ÷ 2 < r
⇐
0≤l<r≤N
logical reasoning justifies splitting the proof into two parts, a proof
that
l ≤ (l+r−1) ÷ 2 ⇐ 0 ≤ l < r
and a proof that
(l+r−1) ÷ 2 < r
⇐
0≤l<r .
Logic is the glue that binds together the properties of the data.
4
Propositions
A proposition is a statement that is either true or false.
Examples: It is raining. The moon is made of cheese. Roses are red.
True and false are called boolean values (after George Boole).
Propositions thus have boolean values.
Propositions are combined using the logical connectives. The logical
connectives are functions from booleans to booleans.
5
And and (Inclusive) Or
In English (and other natural languages) the logical connectives are
expressed in many ways:
Conjunction (∧) — “and”, “yet”, “but”, “however”, “moreover”,
etc.
The sky is blue and the clouds are grey.
It is raining yet the sun is shining.
It is nice outside but we have to stay inside.
Disjunction (∨) — “or”, “and/or”, “either . . . or ”.
Roses are red or they are yellow.
6
If and Only-If
Follows-from (⇐) — “if”, “when”, etc.
k is positive if l is positive.
k is positive when l is positive.
For k to be positive it is sufficient that l be positive.
k≥0 ⇐ l≥0 .
Implies (⇒) — “if . . . then . . . ”, “only if”, etc.
If l is positive then k is positive.
l is positive only if k is positive.
A necessary condition for l to be positive is that k be positive.
l≥0 ⇒ k≥0 .
7
Truth Tables
p
true
false
p
true
true
false
false
true
true
true
q
true
false
true
false
p
true
false
¬p
false
true
true
true
true
true
true
p=q
p≡q
true
false
false
true
false
false
false
p 6= q
p 6≡ q
false
true
true
false
p∧q
true
false
false
false
p∨q
true
true
true
false
p⇐q
true
true
false
true
p⇒q
true
false
true
true
false
false
false
false
false
8
Equality of Booleans
p
true
true
false
false
q
true
false
true
false
p=q
p≡q
true
false
false
true
9
Logical Equivalence
≡, = — “iff”, “whenever”, “exactly when”
Equivalence is the equality operator on boolean values.
Equality is the most basic and most important operator on any type.
Equivalence is the most important of the logical connectives.
In English we don’t really have a short name for it.
Often equivalence is meant but “if” is stated:
The work-force will go on strike if redundancies are
announced.
The fact that equivalence is rarely directly expressed in natural
language has the consequence that we are unused to reasoning about
or exploiting equivalences. One of the mathematical skills I want to
convey is reasoning with equivalences.
10
Example — A Property of Integers
l ≤ r−1
=
{
l and r are integers.
}
{
l and r are integers.
}
l<r
=
l+1 ≤ r .
11
Properties of Equality
Equality is reflexive.
That is x = x whatever the value (or type) of x.
Equality is symmetric.
That is, x = y is the same as y = x.
Equality is transitive.
If x = y and y = z then x = z.
Substitution of equals for equals (Leibniz’s rule).
If x = y and f is any function then f.x = f.y (where the infix dot
denotes function application).
12
Associativity
Equality is a binary operator with range the boolean values true and
false.
This raises the question whether equality is associative. That is, is it
the case that for arbitrary x, y and z,
((x = y) = z) = (x = (y = z)) ?
Answer:
1. The question doesn’t usually make sense. Eg. for numbers x, y
and z,
(x = y) = z
doesn’t make sense because x = y is a boolean and z is a
number.
2. The question does make sense for booleans x, y and z.
13
Equivalence is Associative!
For all booleans p, q and r,
((p = q) = r) = (p = (q = r)) .
14
A Notational Dilemma.
We write
0≤l≤r≤N .
We also write
m+n+p+q .
Syntactically these two formulae have the same shape. But the
notational convention that is being used is quite different.
In the first case the convention is that the formula means
0≤l ∧ l≤r ∧ r≤N .
The formula is read conjunctionally.
In the second case the convention is that the formula means
whichever of the following one cares to choose:
((m+n)+p)+q
(m+n)+(p+q)
m+(n+(p+q))
The formula is read associatively.
15
A Notational Dilemma (Continued).
“If” is a transitive relation. To exploit this property, we write
p⇐q⇐r
with the conjunctional meaning
(p ⇐ q) ∧ (q ⇐ r) .
(Beware: not everyone uses this convention.)
“And” is an associative operator. To exploit this property, we write
p∧q∧r
with the associative meaning that it can be read either as
(p ∧ q) ∧ r
or as
p ∧ (q ∧ r)
whichever is the most useful at the time.
16
A Notational Dilemma (Continued).
In order to be able to exploit the transitivity and associativity of
equivalence we introduce a second symbol to denote equivalence of
propositions.
We write
with the same meaning as
p≡q
p=q .
For booleans p, q and r, the formula
is read (as usual) conjunctionally, thus
p=q=r
(p = q) ∧ (q = r) .
However, an expression of the form
p≡q≡r
is read associatively,
i.e. as either
(p ≡ q) ≡ r
or as
p ≡ (q ≡ r)
whichever being the most convenient at the time.
17
Example
m+n is even ≡ m is even ≡ n is even .
We refer to whether or not a number is even or odd as the parity of
the number. Then if we parenthesise the statement as
m+n is even ≡ (m is even ≡ n is even)
it states that the number m+n is even exactly when the parities of
m and n are both the same.
Parenthesising it as
(m+n is even ≡ m is even) ≡ n is even
it states that the operation of adding a number n to a number m
does not change the parity of m exactly when n is even.
18
Example (Continued)
Another way of reading the statement is to use the fact that, in
general, the equivalence p ≡ q ≡ r is true exactly when an odd number
of p, q and r is true. So the property captures four different cases:
(m+n is even ∧ m is even ∧ n is even)
∨ (m+n is odd ∧ m is odd ∧ n is even)
∨ (m+n is odd ∧ m is even ∧ n is odd)
∨ (m+n is even ∧ m is odd ∧ n is odd)
19
Axioms
Constant true
The associativity of equivalence is exploited in almost all of the laws
of the propositional calculus. A first example is the law
true ≡ p ≡ p .
There are two ways to parenthesise this formula. Reading it as
true ≡ (p ≡ p), which we write in the form
true = (p ≡ p)
for greater emphasis, the law states that equivalence is a reflexive
relation. According to the other parenthesisation,
(true ≡ p) = p ,
the law states that true is a unit of the equivalence operator.
(1)
20
Simplifying Continued Equivalences
Example: suppose we want to simplify
p ≡ p ≡ q ≡ p ≡ r ≡ q .
Symmetry of equivalence allows us to rearrange all the terms so that
repeated occurrences of “p” and “q” are grouped together. Thus we
get
p ≡ p ≡ p ≡ q ≡ q ≡ r .
Now we can replace occurrences of “p ≡ p” and “q ≡ q” by “true”
obtaining
true ≡ p ≡ true ≡ r .
Finally, we replace “true ≡ x” by “x”. The result is that the original
formula is simplified to
p≡r .
21
Simplifying Continued Equivalences
An expression of the form
p1 ≡ p2 ≡ . . . ≡ pn
is simplified by replacing any term that is repeated an odd number of
times by a single occurrence of the term, and removing any term that
is repeated an even number of times. Thus, the expression
p≡p≡q≡p≡r≡q≡q≡r≡p
is simplified to q.
If all terms in the original expression are repeated an even number of
times as in, for example,
p≡p≡p≡r≡q≡q≡r≡p
the expression reduces to true.
Compare continued addition. The expression
p+p+q+p+r+q+q+r+p
is simplified to
4p + 3q + 2r .
22
Exercise 2
Simplify the following.
(a) p ≡ p ≡ p ≡ p ≡ p
(b) p ≡ true ≡ q ≡ p
(c) q ≡ p ≡ q ≡ p ≡ q ≡ p
(d) false ≡ false ≡ false
(e) p = p = p
(f ) (false ≡ false) = false = false
(g) (p = p) = p = p
2
23
Negation
¬p ≡ p ≡ false .
(3)
Reading this as
¬p = (p ≡ false)
it functions as a definition of negation (denoted by the prefix
operator “¬”). Reading it the other way:
(¬p ≡ p) = false
it provides a way of simplifying propositional expressions. In
addition, the symmetry of equivalence means that we can rearrange
the terms in a continued equivalence in any order we like. So we also
get the property:
p = (¬p ≡ false) .
24
Simplification
To simplify
¬p ≡ p ≡ q ≡ ¬p ≡ r ≡ ¬q .
begin by rearranging all the terms so that repeated occurrences of
“p” and “q” are grouped together.
¬p ≡ ¬p ≡ p ≡ q ≡ ¬q ≡ r .
Now use (1) and (3) to reduce the number of occurrences of “p” and
“q” to at most one (possibly negated).
true ≡ p ≡ false ≡ r .
Finally, we use (1) and (3) again. The result is that the original
formula is simplified to
¬p ≡ r .
Compare simplification of
p + (−p) + q + (−p) + r + q + (−q) + r + p
to
q + 2r .
25
Some Rules
¬false ≡ true .
(4)
¬(p ≡ q) ≡ p ≡ ¬q .
(5)
p ≡ q ≡ ¬p ≡ ¬q .
(6)
26
Example Calculation.
The propostion ¬(p ≡ q) is usually written p 6≡ q. The operator is
called inequivalence (or exclusive-or, abbreviated xor). As a final
worked example we show that inequivalence associates with
equivalence:
(p 6≡ q) ≡ r
=
{
expanding the definition of p 6≡ q
}
¬(p ≡ q) ≡ r
=
{
¬(p ≡ q) ≡ p ≡ ¬q
}
p ≡ ¬q ≡ r
=
{
the law (5) is applied in the form
¬(p ≡ q) ≡ ¬q ≡ p with p,q := q,r
p ≡ ¬(q ≡ r)
=
{
definition of q 6≡ r }
p ≡ (q 6≡ r) .
}
27
Exercise 7 Simplify the following. (Note that in each case it does
not matter in which order you evaluate the subexpressions. Also
rearranging the variables and/or constants doesn’t make any
difference.)
(a) false 6≡ false 6≡ false
(b) true 6≡ true 6≡ true 6≡ true
(c) false 6≡ true 6≡ false 6≡ true
(d) p ≡ p ≡ ¬p ≡ p ≡ ¬p
(e) p 6≡ q ≡ q ≡ p
(f ) p 6≡ q ≡ r ≡ p
(g) p ≡ p 6≡ ¬p 6≡ p ≡ ¬p
(h) p ≡ p 6≡ ¬p 6≡ p ≡ ¬p 6≡ ¬p
2