Say $a=b$. Is “Do the same thing to both sides of an equation, and it still holds” an axiom? [duplicate]

Recently I have started reviewing mathematical notions, that I have always just accepted. Today it is one of the fundamental ones used in equations:

If we have an equation, then the equation holds if we do the same to both sides.

This seems perfectly obvious, but it must be stated as an axiom somewhere, presumably in formal logic(?). Only, I don't know what it would be called, or indeed how to search for it - does anybody knw?

marked as duplicate by Tanner Swett, Xander Henderson, Namaste logic StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Jun 6 '18 at 19:41

• Euclid's Elements included statements about adding equals to equals and subtracting equals from equals in his common notions. – N. F. Taussig Jun 5 '18 at 10:37
• Perhaps this might help – The Integrator Jun 5 '18 at 10:39
• That's not quite precise enough - e.g. it doesn't exclude division by zero (not in the domain of the function f(x) = 1/x). You need to be careful that both sides of the equation are actually valid "arguments" for your operation. And "do the same" gives you way too many options that aren't valid - e.g. "erase all the x's" isn't a valid operation, and will break the equality. You might think these are nitpicks, but they are actually serious problems that are at the root of many miscalculations (especially with beginners :) ). – Luaan Jun 6 '18 at 6:04
• Depends on what 'the same thing' is. For example, a stupid 'doubling each number' surpisingly holds for a sum: $a+b=c \iff 2a+2b=2c$ but not for a product: $a\cdot b=c$ does not imply $(2a)\cdot(2b)=2c$... – CiaPan Jun 6 '18 at 12:37
• Start with $1+1=2$ and now "do the same thing" on both sides, namely "count symbols". This leads to $3=1$ ... – Hagen von Eitzen Jun 6 '18 at 13:45

This axiom is known as the substitution property of equality. It states that if $f$ is a function, and $x = y$, then $f(x) = f(y)$. See, for example, Wikipedia.

For example, if your equation is $4x = 2$, then you can apply the function $f(x) = x/2$ to both sides, and the axiom tells you that $f(4x) = f(2)$, or in other words, that $2x = 1$. You could then apply the axiom again (with the same function, even) to conclude that $x = 1/2$.

• As a practical matter, this is often misapplied, however: there is a very strong condition hidden in the statement, namely, that $f$ must be a function, and that the $x$ in your equation must be in the domain of that function. (Indeed, its misapplication is the basis of about half the mistakes in a typical algebra class.) If I were writing this answer, which I basically like, I'd have extended it with examples of the misapplication so that OP would better understand how stringent those conditions are. – John Hughes Jun 5 '18 at 11:00
• @Mauro: I don't see where in this answer it is stated that $x$ and $y$ are variables and not terms. – Rahul Jun 5 '18 at 11:13
• @Rahul: It is not stated explicitly, but there's a reasonably strong convention that $x$ and $y$ are much more likely to be variables than placeholders for entire terms. Though it doesn't matter that much, because the common rules of first-order logic will let us derive instances of the version with terms from the version with variables. – Henning Makholm Jun 5 '18 at 11:19
• I totally agree with @JohnHughes, and probably the most common mistake is to forget that $0$ is not in the domain of the function $f(x)=1/x$ which leads the infamous division by $0$. – Surb Jun 5 '18 at 14:28
• I would say this is part of the definition of a function, not really part of the definition of equality. – Steven Gubkin Jun 5 '18 at 14:31

"Do the same to both sides" is rather vague. What we can say is that if $f:A \rightarrow B$ is a bijection between sets $A$ and $B$ then, by definition

$\forall \space x,y \in A \space x=y \iff f(x)=f(y)$

The operation of adding $c$ (and its inverse subtracting $c$) is a bijection in groups, rings and fields, so we can conclude that

$x=y \iff x+c=y+c$

However, multiplication by $c$ is only a bijection for certain values of $c$ ($c \ne 0$ in fields, $\gcd(c,n)=1$ in $\mathbb{Z}_n$ etc.), so although we can conclude

$x=y \Rightarrow xc = yc$

it is not safe to assume the converse i.e. in general

$xc=yc \nRightarrow x = y$

and we have to take care about which values of $c$ we can "cancel" from both sides of the equation.

Some polynomial functions are bijections in $\mathbb{R}$ e.g.

$x=y \iff x^3=y^3$

but others are not e.g.

$x^2=y^2 \nRightarrow x = y$

unless we restrict the domain of $f(x)=x^2$ to, for example, non-negative reals. Similarly

$\sin(x) = \sin(y) \nRightarrow x = y$

unless we restrict the domain of $\sin(x)$.

So in general we can only "cancel" a function from both sides of an equation if we are sure it is a bijection, or if we have restricted its domain or range to create a bijection.

• The statement $$x=y \iff x^3=y^3,$$ is not true for all (groups,) rings and fields. The only polynomials that are bijections over all rings are the translations. – Servaes Jun 5 '18 at 12:04
• @Servaes - true - I was thinking in $\mathbb{R}$ which is a narrow context. I stand corrected. I have edited my answer. – gandalf61 Jun 5 '18 at 13:07
• The question asks about (a=b)->(f(a)=f(b)), not the converse. – Acccumulation Jun 6 '18 at 4:19
• @Accumulation If the operations involved here were all functions then there would be no problem. But errors arise when operations such as division, square root, arcsin etc. are applied to both sides of an equation without realising that they are not functions unless their domain and/or range is restricted in some way. – gandalf61 Jun 6 '18 at 7:57
• It’s not that easy at all. Take $x+\frac1x=1$ for example and raise it to the third power gaining in $x^3+\frac{1}{x^3}= -2\iff x=-1$ which is obviously no solution to the first equation. – Michael Hoppe Jun 6 '18 at 11:51

There is a way in which it is an axiom, and another in which it isn't. I'll try to describe both.

When you do formal logic and start with variables ($x_1,...,x_n,...$), relation symbols ($R_i, i\in I$) and function symbols ($f_j, j\in J$). You build out your formulas with these. An important notion is that of a term in this language. A term is defined recursively as either a variable, or a string of the form $f_j(t_1,...,t_n)$ where $f_j$ is a function symbol of arity $n$ and $t_1,...,t_n$ are terms (this is purely syntactical).

Then you build a deduction system that consists in rules that you may apply in certain situations (for instance if you proved $A$ and $B$, you can prove $A\land B$).

One of these rules is the substitution rule: one way to define it is the following : for any terms $t_1,...,t_n, u_1,...,u_n$ and any function symbol $f$ of arity $n$, if for all $i$, $t_i = u_i$ is proved then one may deduce $f(t_1,...,t_n) = f(u_1,...,u_n)$

In this situation it is an axiom.

However in the common situation of algebra and "the working mathematician", it is a consequence of another substitution rule, the substitution rule for relation symbols. Indeed, all maths can be built from set theory with no function symbol and only one relation symbol ($\in$). In this setting a function $A\to B$ is defined (for instance) as a subset $f$ of $A\times B$ such that for all $x\in A$, there is a unique $b\in B$ such that $(a,b)\in f$. $f(a)$ is then defined as this unique $b$

Now if $x=y \in A$, $f:A\to B$ is a function, then $(x,f(x)) \in f$ and $(y,f(y))\in f$ and so by the substitution rule for relation symbols $(x,f(y))\in f$, so that $f(x)=f(y)$ (by uniqueness).

The substitution rule for relation symbols is very similar to the one for function symbols and is, again an axiom: it can be described as: if $t_1,...,t_n,u_1...,u_n$ are terms, $R$ is a relation symbol of arity $n$; if for all $i$, $t_i= u_i$ has been proved and $R(t_1,...,t_n)$ has been proved, then one may deduce $R(u_1,...,u_n)$

(you may see that the rule is not so far from an axiom, but technically it's not one in this second situation)

• It seems you use substitutability to get from $(y,f(y)) \in f$ to $(x,f(y)) \in f$, whether we call that a principle or an axiom. And the first time I was introduced to ZF as a basis for mathematics, the teacher said that equality is not defined, it simply means sameness, and that substitution of equal things is not an axiom, just a result of sameness, but I never understood why we would want to make that distinction in an otherwise rather formal system. – aschepler Jun 6 '18 at 2:13
• @aschepler : never heard of "sameness". All I know is that in a formal deductive system, since equality has no a priori meaning, you have to have a rule that allows you to essentially replace one variable (more generally term) with another when they have been proved to be equal and you can't just do it like that; otherwise the whole point of having a formal, syntactic deductive system goes away – Max Jun 6 '18 at 6:05
• Hmm. Maybe in that context the point was we were taking a predicate logic as a given, including modus ponens, $\lnot \forall v P(v) \Leftrightarrow \exists v \lnot P(v)$, etc., and that equality implies substitutability was part of that starting point. So if you talk about both, you could have some formal logic axioms, followed by some set axioms? – aschepler Jun 6 '18 at 11:25
• @aschepler : But at some point one of the axioms has to be that equal things have the same properties. Otherwise it's just handwaving and having a formal system serves no purpose at all – Max Jun 6 '18 at 11:28

Any deterministic process that is performed on the same inputs will result in the same output. That is the definition of "deterministic". If two things are equal, then you're applying the same process to the same thing, so you get the same output. The expression "x = 5" is claiming that the symbol "x" and the symbol "5" represent the same value. Thus, "f(x)" and "f(5)" also must represent the same value, since they are both f applied to the same value.

In CS, the term "function" is sometimes used to refer to nondeterministic processes; for instance, "choose a random number from between 1 and n" might be considered a "function" of n by some programmers (though not functional programmers), even though the process applied to the same number can result in different outputs. So you do have to be sure that your process is deterministic.

Another issue one has to be careful abut is that the process takes values as inputs, not expressions. For instance, if $f$ represents the process "subtract 1 from the numerator and denominator", then $f(\frac{2}{3}) =\frac{1}{2}$ while $f(\frac{4}{6}) =\frac{3}{5}$ ; although the expressions $\frac{2}{3}$ and $\frac{4}{6}$ represent the same value, $f$ applied to them do not result in expressions that represent the same value, because $f$ is acting on the representations of those values, and not the values themselves. Sometimes, a process that is expressed as acting on the representation can still be well-defined as a function of the value. For instance, squaring the numerator and denominator results in the same value, regardless of what representation of a rational number you pick.

A final issue is that although a = b implies f(a) = f(b), f(a) = f(b) does not imply a = b. This means that not only do you have to be careful about "canceling" an operation that's been done to both sides, you also have to be careful about getting extraneous solutions.

• Not sure I make sense, but your definition here of "deterministic" seems to be that of the definition of a function in mathematics. Sometimes people take deterministic to mean non-random, which might not be the same. E.g. imagine a c++ routine c() that has internal state, and returns the number of times its been called. – ntg Jun 6 '18 at 9:21

I remember being confused about the difference between arguments that were written in the "do the same thing to both sides" format, e.g. \begin{align} 7x &= 3 - 5x \\ 12x &= 3 \\ x &= 3/12, \end{align} and arguments that were written down in a sort of "chain of equalities" format, e.g. \begin{align} x = \frac{1}{12}{(12x)} = \frac{1}{12}(7x + 5x) = \frac{1}{12}(3 - 5x + 5x) = \frac{3}{12}. \end{align} With such a simple example, the latter looks a bit silly but I think I would say that in the end, the more mathematically mature type of writing is the latter. Somehow it became clearer to me when I realized that if you are manipulating an equation then there is only one number there (it's just, let's say, written down in two different ways).

So the format where you write an equation and do the same thing to both sides is sort of a suspension of disbelief until you find $x$ at the end, i.e. you are sort of not-fully-willing to accept the equality until you find an $x$ for which it is true, but to find an $x$ for which it is true you are assuming that there is one. This is completely natural. This 'suspension of disbelief' allows you to solve the equation... you can't actually start with $x = ....$ and just intuit what to write in the "chain of equalities" format, you can only do that because you've already worked it out. And yet after you've worked it out and written it down in this way, it's actually surprisingly easy to read because each step in the chain of equalities is just a re-writing of exactly the same number . I'm not 'doing' anything to 'sides' of some abstract entity called an 'equation'.

• – T_M Jun 10 '18 at 22:55