Sections 5.3 to 5.6 gave the four quantifier rules,
and with them every logical symbol of the language of
Section 5.2 (the connectives, , the quantifiers,
and equality) has rules, except one. So far the equals
sign has been treated like a predicate symbol: was an atomic
formula like ,
and no rule looked inside it. Yet almost every
calculation in mathematics is a chain of equations, and
every use of “the” (the limit, the supremum, the
inverse) quietly asserts that something is unique. This
section adds the two rules for equality, and , which
say together that equals may be replaced by
equals. Section 5.8 applies them to the phrase
“there is exactly one”, which is an existential
statement together with an equation. This section ends
by completing the table of rules, phrases, and Lean
tactics that Chapter 1 began.
What the
rules so far cannot do with an equation
Here is the first line of a calculation any reader
has written:
Since and
, we have
.
Nothing could be simpler, and nothing in Sections
5.3–5.6 derives it: so far the rules treat as they treat any
two-place predicate symbol, and from and no rule gives . Reading as and as over , with and , both premises are
true and is
false.
What makes the step correct is what means: and are names of
the same object. Any statement true of
the object is true of it whichever name is used. Two
things follow, and they are the two rules of this
section.
- Every term names the same object as itself. Nothing
needs to be assumed to write .
- If and
name the same
object, then a statement about may be rewritten as
the same statement about .
The first rule is unusual: it cites no earlier line
at all. Chapter 1 anticipated this when it defined rules
(Section 1.2): the definition of a rule schema (Definition 1.2.1)
was worded so that a rule of Chapter 5 could have no
given lines at all. This is that rule.
The rules
for equality
Everything is equal to itself, and equals may be
replaced by equals.
Definition
5.7.1 (Rules for Equality)
,
The rule
(equality introduction, or reflexivity)
writes for
any term , at any line, citing
nothing. The rule
(equality elimination, or substitution
of equals) cites an equation on line and a line of the form , both
available at line , and writes on line
. Here is
any formula and any variable, subject
to one side condition: both and are free for in (Definition 5.2.6).
In words: says that
every term equals itself. says that
when is
known, a line that says something about may be rewritten as
the same thing said about . The formula is the
“something”: a statement with a hole , which line fills with and line fills with .
Mark the holes first. To use with
, write
down the line you have and draw a box round each
occurrence of
you want to replace. The boxes are the holes: is the line with
a variable in each box, and the new line puts in every box. With
: Occurrences without a box stay as they
are.
Read the definition clause by clause.
- cites
nothing.
- Schema: the left block above, , citing
nothing.
- Reading: every term equals itself, so the
line may stand anywhere, even first in a derivation with
no premises.
- Example: “ — ”, the
first line of every chain below.
- The equation is read from left to
right. The cited equation licenses
replacing by
, and not the
other way round. From and , the rule does
not give , because is for , and the
equation would have to be . The reverse direction needs one more step,
symmetry, which we derive below.
- Some or all occurrences. The choice
of decides
which occurrences of are replaced: exactly
those that
marks with (the
boxes above). Occurrences of that writes out are
left alone. Choosing is the whole art
of using the rule.
- Free for . Neither term
may have a variable captured by a quantifier of , the condition of
Definition 5.2.6
that the rules of Sections 5.3 and 5.5 also carry. The
nonexample below shows what goes wrong without it.
One line, many readings. Take the
equation and
the line . The term occurs three times in
the line, and may mark any of
them. Some of the choices:
|
|
|
|
|
|
|
|
|
|
|
|
Each of the three occurrences is marked or not, so
there are
choices in all, and each is a legal step. The fourth row
is the step of the opening calculation.
↺Second readingDegenerate
choices
One more row belongs to the table:
This row is the degenerate choice:
contains no
, so and are both
, and the
rule copies the line unchanged. It is legal and useless,
and it shows that “some occurrences” includes “none”.
Another degenerate case: the equation may be itself, and then
again returns the cited line.
Quick check. From the equation
and the
line , which formula makes give
?
Which gives ?
Solution. For , take
, with a variable that appears nowhere
else: is the
cited line and is . For
,
take . The hole has to be a variable other
than , since the
occurrences of
that stay must be written out in .
Quick check. From and the line , which
occurrences do you box to get ?
Solution. The second and the third
: , and is the given
line,
the new one.
A nonexample: capture. Take the
equation ,
with a variable,
and the line . It is tempting to “substitute for ” and write .
With , the cited line is , and the new
line would be . But is not
free for in : the sits inside , and the put there would be
captured. The side condition fails, and rightly. Read
over , with
and both naming , the premises say
“” (true) and
“some integer is less than ” (true), while
says that some integer is less than itself (false).
1
2
3 1, 2
Line 3 breaks the side condition of Definition 5.7.1.
What the argument meant to say needs a different name
for the bound variable: ,
which is the same sentence up to renaming (Section 5.2),
becomes , which is true when names .
Why these two rules. They are exactly the
two facts about “same object” listed above, and nothing
else about equality needs to be assumed. Symmetry ( gives ), transitivity
( and give ), and “applying the
same function to both sides” are all derived below. So
the two rules play for the part that the
introduction and elimination rules played for each
connective: one builds an equation, one uses it.
Warning. A bound variable
is not a place to substitute. From and , the
line does not follow: the ’s of are
bound, and replaces
only free occurrences. Over , with naming , the premises are true
and is false.
↺Second readingWhy
no choice of the hole works
To write as , either
does not occur
free in ,
and then is the
unchanged line, or occurs free in (for instance,
is ), and
then every free
lies inside , so is
not free for in
and the
side condition fails.
Symmetry,
transitivity and congruence
Everything we expect of equality now follows from the
two rules. Each derivation below is short, and the only
thought in each is the choice of .
It turns out that the equation in may be
read in either direction after all, at the cost of two
extra lines (an and an
;
after the abbreviation (sym) below, just one), and that
equations chain:
Proposition
5.7.1 (Equality Is Symmetric and
Transitive)
For all terms ,
, :
- (a) ;
- (b) .
Idea. For (a), the goal must be the last
line of an that uses
the premise
(it is the only equation available), so it has the form
, and
the cited line must already
be on a line. Try : then is , the goal, and
is
, which supplies
for free. For (b), rewrite the of the first premise
using the second: .
Proof.
- (a) With , for a variable that occurs in neither
nor , the line is and the goal
is . Both terms
are free for in
, since
has no
quantifier. So the following is a derivation:
- (b) With , for a variable that does not occur in
, the first
premise is
and
the goal is
; again
has no
quantifier. So the following is a derivation:
Line 3 of (b) cites the equation on line 2 as the
rule’s line , and
on line 1 as
its line . This
proves (a) and (b).
Notice where the “reflexivity” line went in (a): the
equation was
not rewritten at all. It was the tool,
and the line it rewrote, , was manufactured for the purpose. This is
the typical use of : it
supplies a line for to work
on.
From now on, symmetry and transitivity may be used as
one line, with the justifications “(sym)” and “(trans)”:
each abbreviates the three-line derivation above with
the given terms in place of , , . This is the license of
Definition 2.3.1,
extended from statement letters to terms. The extension
is harmless for the same reason: the derivations above
used nothing about , , except that they are
terms, so they can be pasted in with any terms.
The next derivation is the rule behind “apply to both sides”. Let
be a one-place
function symbol, and , constants.
1
2
3 1, 2
Here : it keeps the first and marks the second.
With instead, the same two lines would give
, which
is true and useless. Nothing is special about : the same three lines
give from
, or , or . Every
“do the same thing to both sides of an equation” is this
derivation.
The last result of this group has no premises. It
says that equals share every property, and it is called
Leibniz’s Law.
Proposition
5.7.2 (Leibniz’s Law)
For every one-place predicate symbol , .
In words: whatever is true of is true of anything
equal to it. The rule is this
law for every formula at once; the seven-line derivation
is in the fold below.
↺Second readingLeibniz’s
Law, derived
Proof. Finding it. The
goal is ,
so the search method of Section 3.1, with the step of
Section 5.4, opens a flagged box for ; the new goal opens
a second flagged box, for . The goal is an implication, so a box opens with
, and the
new goal opens another, with . Now the goal is
, the
resources are and , and one with
finishes. Every line but one was written by a
goal-directed step.
1asm, for
2asm, for
3 1, 2
4 2–3
5 1–4
6 1–5
7 1–6
The two lines cite the flagged boxes as and : each
flagged box immediately contains another box, so its
range starts at that box’s first line (the convention of
Section 5.4). At line 6 the name appears in no premise
(there are none), in no open assumption (the boxes on
lines 1 and 2 have closed), and not in the conclusion;
at line 7 the same holds for . The derivation has 7
lines.
The claim is one of the classical “axioms of
equality”, often taken as a starting point in place of
.
Here it is a consequence. Conversely, with the claim as
a premise, twice and twice
would do the work of for the
formula ; the
rule does it for every formula at once.
Warning. Words about
knowledge are not formulas. rewrites
formulas of the language, and “it is obvious that …”,
“the pupil checked that …”, “it is known that …” are not
among its connectives. A pupil checked that , and
indeed . Replacing by inside the report
gives “the pupil checked that ”, a different
claim about what the pupil did. Inside a formula every
free occurrence of a term may be rewritten, subject to
the side condition of Definition 5.7.1;
inside words about what someone knows or checked, none
may.
Equal sets
have the same elements
Example
(Equal Sets Have the Same Elements)
Read the domain as consisting of sets, with a two-place predicate
symbol written between its terms (shorthand rule 1 of
Section 5.2). Show that .
Solution.
1asm, for
2asm, for
3asm, for
4 2–2, 3–3
5 1, 4
6 2–5
7 1–6
8 1–7
9 1–8
The two boxes of line 4 are one-line boxes, as is shown, and
each flagged box immediately contains another box and is
cited from its first line. Line 5 is with
: line 4 is , and the
equation of line 1 refills the hole with ; as in the proof of
symmetry,
manufactured a line for to
rewrite.
The converse, ,
breaks. Here is a counter-reading to it: two dots and , with nothing an
element of anything. With naming and naming , both sides of are false for every , so the hypothesis is
true; and is
false. For sets, the converse is taken as an axiom, the
axiom of extensionality: a set is determined by its
elements.
Calculations are chains of substitutions
A calculation in a proof looks like this:
written under the premises and . The chain is a
single statement to the eye, but logically it is several
equations, each obtained from the last. Here is the
derivation it abbreviates, with one line of arithmetic,
justified “arith” as in Section 5.3.
A chain as a derivation. From and , derive
.
1
2
3
4 2, 3
5 1, 4
6arith
7 6, 5
The choices of , with a variable not
occurring in the terms:
- line 4: , rewriting the on the
right of line 3 and keeping the one on
the left;
- line 5: , rewriting
both remaining ’s on the right at
once;
- line 7: , rewriting the whole right-hand side by
the equation of line 6.
The pattern is general. A chain
starts with by , keeps
fixed on the
left, and rewrites the right-hand side once per link,
each time by with the
equation that justifies the link. Each link is either a
premise, as on lines 4 and 5, or an arithmetic fact, as
on line 7. The last line is . Transitivity
(Proposition 5.7.1
(b)) is the same move made once; a chain makes it times.
A mixed chain, such as
with , is not
made of alone.
Its links are
steps as above, and a link needs a fact
about : here
that , so
that adding
does not decrease a number. The link before it then
carries over by one more , with
and the equation turned round
by symmetry (Proposition 5.7.1
(a)); transitivity of is needed only where
two links meet,
as in . Those are facts about order, not about
equality. They enter derivations as “arith” lines, one
per link.
Quick check. Line 5 of the chain
rewrites both ’s
on the right of line 4 at once. Which would rewrite
only the inside
, and what
line would it give? How would the chain then reach line
5?
Solution. Take . Then line 4 is , and 1, 4
gives ,
the line . One more with the
same equation
and then gives ,
which is line 5. Marking both occurrences at once saves
that line.
Quick check. Under the premise
, the chain
has three links. Which is an step, and
which are “arith” lines?
Solution. The first link is : from
()
and , with
, it writes . The links and are facts of
school arithmetic, written as “arith” lines, and each is
then carried into the chain by one more (with
, then with and
the equation turned round); the last link is about
order, not equality.
What
equality sounds like in a proof
In a written proof, is the
word “substituting”, or no word at all: the chain is
read as a sequence of substitutions, and the reader
supplies the of each link. “By
symmetry” or “rewriting the equation as ” is Proposition 5.7.1
(a). “Applying to
both sides”, “squaring both sides”, “adding to both sides” are the
congruence derivation above. And is almost
never written, because goes without saying; it is visible only in
the first line of a formal chain, and in a proof
assistant, where rfl proves .
Here is a proof from school algebra, read link by
link.
Claim. If and , then .
Proof. .
The first link is the fact for every , applied at (an instance by
) and read from right to left: the chain
needs ,
which is the instance turned round by symmetry. The second link
rewrites the by
the premise , again turned round, since the chain needs
to become . The third and
fourth are instances of associativity and commutativity.
The fifth rewrites by the premise in the direction written. The last is
the instance . So the claim says that a number has
at most one additive inverse; the facts
it uses are the field axioms, here school algebra.
The search
method: one more step
Each of Sections 5.3 to 5.6 added a step to the
search method of Section 3.1. Equality adds one.
- An equation. When an equation is available
and the goal differs from an available line only in some
occurrences of
and , look for
the that
makes one turn the
line into the goal: mark with exactly the places
where they differ. If the equation points the wrong way,
turn it round first (sym). If no available line will do,
make one with , as the
proof of Proposition 5.7.1
did.
In the Givens/Goal table, turns a
Given into a new Given with some holes refilled, and
adds to the
Givens at no cost.
Example
(Instances of )
In each row the hole is ; the cited line fills
it with the left side of the equation, the new line with
the right side.
|
|
|
|
|
|
|
|
|
|
|
|
In the first row the inside is written out
in and
stays; in the third the hole sits under , and both terms
are free for
because neither contains .
Not an instance. From and the line
, the line
, which treats the digit of as an occurrence of
the term , is not
written by : the
numeral is one
constant, with no occurrence of the term inside it;
gives only .
The rule,
phrase and Lean table, completed
Chapter 1 began a table that pairs each rule with the
sentence that performs it in a written proof and, for
readers who use a proof assistant, with the Lean code
that does the same (Sections 1.2–1.6), and Chapter 2
added the rows for negation, the biconditional, and the
classical rules (Sections 2.1–2.5). Sections 5.3–5.6
added a row for each quantifier rule, and this section
adds the two rows for equality. Here is the whole table
for the calculus of this volume.
|
, |
“We show , and
we show .” |
|
(or ) |
“In particular, .” |
|
, |
“Since
implies , and
holds, .” |
|
box …
|
“Assume . …
Hence .” |
|
(available) , copied |
“As shown above, .” |
|
(or
) |
“So or holds.” |
|
, box … , box … |
“Case 1: . …
so . Case 2: . … so . In either case, .” |
|
, |
“…, which contradicts …” |
|
any |
“This case cannot occur.” “So there is nothing to
prove.” |
|
box …
|
“Suppose . … This is a
contradiction. Hence not .” |
|
box …
, box … |
“
Suppose . … so
. Suppose
. … so .” |
|
, (or with , ) |
“Since holds
if and only if
does, and holds,
so does .” |
|
box
… |
“Suppose, for a contradiction, that fails. … This is
impossible. Hence .” |
|
|
“In particular, for , …”; “applying the hypothesis to , …” |
|
box …
|
“Let be
arbitrary. … Since was arbitrary, …” |
|
|
“Take .
Then …” |
|
, box … |
“Choose with
… . Then …” |
|
nothing |
(usually unwritten) “.” |
|
,
|
“Substituting for , …”; a chain |
Of the derived rules of Chapter 2, , and have their
rows in Section 2.3, and and
in
Section 2.5; the derived sequents that searches use most
are collected in Section 3.1. With the two equality
rows, every rule of the calculus has its phrase.
Warning (Not allowed: ).
Each step breaks the clause of the reading of Definition 5.7.1,
or the warning, shown.
- “From
and , write
”: the equation
is read left to right and rewrites into ; turn it round
first, by (sym) (clause 2).
- “From and
, write ”: only free occurrences are
replaced, and both ’s of are bound (the
warning “A bound variable is not a place to
substitute”).
- “From
and , write ”: with , the
of is
captured (clause 4).
- “Rewrite a term inside ‘it is obvious that …’”: that
is not a formula (the warning “Words about knowledge are
not formulas”).
Exercises
A. Check your
understanding
Exercise
(A1)
(a) State and as
schemas, with the side condition of .
(b) In the
derivation below, name for each of lines 4, 5, 6, and 8
the rule, the cited lines, and the formula (with a variable
as its hole).
1
2
3
4 1, 3
5 1, 4
6 2, 5
7arith
8 7, 6
(c) In the same
derivation, could lines 4 and 5 be replaced by one line?
With which ?
(d) True or
false, with a reason: from the lines and , one application of
gives .
(e) True or
false, with a reason: from and the line , one application of gives
.
Solution. (a) : at any
line , write , for any term , citing nothing. : from
on line
and on line
, both available
at line , write
on
line ; side
condition: and
are both free
for in .
(b) Line 4: 1, 3,
with , which rewrites the first on the right. Line 5:
1,
4, with . Line 6: 2, 5,
with , which rewrites both
’s at once. Line
8:
7, 6, with . In each case the left-hand side
is
written out in , so it is
kept.
(c) Yes: 1, 3 with
gives in one step,
rewriting both ’s
on the right and keeping the two on the left.
(d) False. With the equation , passes
from
to .
The line is
for
, so
the rule would need the equation . One application of
symmetry first (Proposition 5.7.1
(a)) gives ,
and then gives
.
(e) True. Take : the cited line is and the new
line is . The terms
and are constants, so both
are free for ,
although the hole lies under .
Exercise
(A2: Drill)
Each part takes a line or two. The parts run from
single steps, through a missing line and a justification
column, to judging steps and short derivations. Letters
are
constants.
- (a) What does
cite?
- (b) From and , box the holes to
get .
- (c) From and the line
,
write the line that
rewrites only the last .
- (d) From and , which
gives ?
- (e) Line 6 is , justified
“ 2,
5”, and line 2 is . Give two possible lines 5.
- (f) Justify each
line: 1 ,
premise; 2 , premise; 3 , premise; 4 ; 5 ; 6 ; 7 ; 8 .
- (g) From and , does one give
?
- (h) From and ,
is a legal
line?
- (i) From and the line
, is a legal line?
From and the
same line, is ?
- (j) Derive .
- (k) Derive in one step.
- (l) Derive .
Solution.
(a)
Nothing.
(b) Box the
second only:
.
(c) ,
with .
(d) .
(e) Any two of
(), (), (); and the degenerate
itself.
(f) 4 2
(at ); 5 4, 3; 6
; 7
1,
6 (); 8 5, 7
().
(g) No, clause 2:
the equation rewrites into . Turn it round first
(sym), then .
(h) No, clause 4:
the put in would
be captured by .
(i) The first is
legal: , and is free for . The second is not:
with , the term of the equation is not
free for in (clause 4); the
would be
captured.
(j) 2 , ; 3 , 1, 2,
with .
(k) 3 , 2, 1,
with .
(l) A flagged box
, inside it a
flagged box : 2
,
assumption; 3 , 1; 4
, 2, 3
(); 5 , 2–4; 6
, 2–5;
7 , 2–6.
(A reflexive relation contains equality.)
B. Practice
Exercise
(B1: The identity is unique)
A set with an operation has an
identity if and for every
. Derive where
and are
constants. Which half of “there is exactly one identity”
does this prove?
Hint: look at the one element that both premises
can say something about.
Solution. The goal is an equation
between and , and the only term
that both premises can connect to both is the product
.
Instantiate the first premise at and the second at
(,
reading the terms off the goal):
1
2
3 1
4 3
5 2
6 5
7 6, 4
Line 7 uses the equation of
line 6 to rewrite the left side of line 4, with :
is line 4, and is . In prose:
, the first equation because is an identity and
the second because is.
This is the “at most one” half: any two identities
are equal. It says nothing about whether an identity
exists. Section 5.8 shows how such an argument combines
with existence.
Exercise
(B2: Rewrite, and turn round)
A search for has reached
the stage below. Name the move, then complete it,
giving for each line its
holes.
Solution. The move is the search
step “An equation” of this section: mark the holes, and
turn the equation round with an line if
it points the wrong way.
1
2
3
4 1, 3
5 2, 4
6 2, 1
7
8 6, 7
9 5, 8
Lines 4 and 5: . Line 6: , so
line 1 is and the
equation
refills the hole with . Line 8: ; line 7
is ,
and the equation refills the box with . Lines 7–8 are (sym)
written out; with the abbreviation of the text, line 8
is “ (sym)
6”.
Exercise
(B3: Derive or break)
For each claim, derive it with the rules of Chapters
1–2 and of this chapter, or break it with a
counter-reading.
- (a) .
- (b) .
- (c) .
- (d) .
- (e) .
- (f) .
- (g) .
- (h) .
Solution.
- (a) Derive. One
,
with :
1
2
3 2, 1
(b) Break.
Counter-reading: the domain , sending both to , naming and naming . Then , and
is
false.
(c) Derive.
Instantiate at the compound term as well as at :
1
2 1
3 1
4 3, 2
Line 4 has .
- (d) Derive.
1
2
3 1
4 3
5 4, 2
(e) Break.
Counter-reading: the domain , and naming , naming . Then and are true, and
is false:
two different letters, one object.
(f) Derive.
1
2
3asm, for
4 1, 3
5 4, 2
6 3–5
Line 4 has .
- (g) Derive.
1
2
3 1, 2
4 1, 3
Line 3 has , and line 4 has .
(h) Break.
Counter-reading: the domain , exchanging and , naming . Then , so
the premise is true, and , so is
false.
(i) and (d)
differ by the premise that is one-to-one; (e) and
(f) look alike, and is not transitive,
since different letters may name one object; (g) and (h)
are converses. Worked example types: Proposition 5.7.1;
the chain derivation of “Calculations are chains of
substitutions”; the congruence derivation.
Marking scheme. (10 points) 1 for
each of the eight claims (a derivation with every named, or a
counter-reading with the domain and every symbol’s
value); 2 for the closing comparison, with the point
about (e) and (f) stated. Fatal errors (0 for the
claim): an with the
equation read right to left; a counter-reading in which
two letters that must differ (by a premise) name one
object.
C. Going deeper
Exercise
(C1: Two different objects)
- (a) Derive , and
name the line that uses a classical rule.
- (b) Read both
formulas aloud. Derive the converse, or break it.
Solution.
- (a) Read off the
goal and the premise. The premise is an existential
(twice), so both
boxes open first, with names and . The goal is
universal, so a flagged box opens inside them.
The new goal is postponed, and no available line
decides whether
is , so the
search splits by :
1
2asm, for
3asm, for
4
5asm, for
6asm, for
7 5, 6
8 7, 3
9 6–8
10 9
11asm, for
12 11
13 4, 5–10, 11–12
14 4–13
15 2, 3–14
16 1, 2–15
Line 7 is with
: line 6 is , and the
equation
refills the hole with . The classical line
is line 4, , a derived
rule whose derivation uses (Section
2.5). At line 14, appears in no
premise, in neither open assumption (lines 2 and 3) and
not in line 14. At lines 15 and 16 the witnesses and appear neither in the
last lines, nor in the existentials, nor in the open
assumptions.
- (b) The premise says
“there are two different objects”; the conclusion says
“every object has one different from it”. The converse
derives: 2 , 1
(at ); 3 , 2
(witness ). Over a
one-element domain both are false; over larger ones both
are true.
Marking scheme. (10 points) 2: two
boxes with different names, each aimed at
the goal it must reach. 2: a flagged box for the (inside or
outside the
boxes), and the goal postponed. 3: the split on , with the first
case reaching by and
,
and the second giving the witness at once. 1: the
classical line named, with the reason. 2: (b), the
converse derived, with both readings. An box on
in place of the split
earns full marks if correct, its line then
named as the classical one. Fatal errors (0 for the
step): the flag
chosen as ; an
box closed on a line that mentions its
witness.