Gas station without pumps

2010 September 3

Equal sign

Filed under: Uncategorized — gasstationwithoutpumps @ 08:25
Tags: ,

SquareCircleZ recently posted on the confusion that US students seem to have with multiple meanings of  the equal sign.  There has been considerable discussion in the comments of that post, because the taxonomy he proposed seem to increase, rather than decrease the confusion.

There are different meanings for equals signs and separating them is useful.  Here is my first stab at a taxonomy:

Math statements:

  • a  predicate.  This can be either a question:  “Is x+y = 7/z?” or a statement: “r+s=12“. In either case it can be assigned a truth value.  Note that this meaning of equality can work for real numbers, for sets, or for any other domain in which equality is meaningful.
  • a definition. When we introduce a new variable, we have to say what it means.  This is not a question or statement that can be assigned a truth value, but the definition of a new symbol.  I like to use a different symbol for this: “Let x =_{\mbox{def}} \sin(\omega)” or “Let x \equiv \sin(\omega).”  I prefer to use =_{\mbox{def}} , because \equiv should be reserved for symmetric relations like equivalence, and definition is never symmetric.
  • abused notation.  I’ve always hated the notation x=y \; (\mbox{mod}\; 4).  The modification of the equal sign is occurring at completely the wrong place.  Personally, I prefer the computer-science approach to modular arithmetic, where “mod” is an operator, and I can say something like x\%4 = y\% 4, but if I need to talk about equality in different groups or fields, I’d prefer to subscript the “=” rather than adding something that looks like multiplication or functional notation at the end.: x =_4 y or  x =_{\mathbb{Z}_4} y, not x=y \; (\mbox{mod}\; 4).  [Side note: many computer languages are very careless about the definition of the % operator, which should be x\%y =_{\mbox{def}} x- \lfloor x/y \rfloor y, where \lfloor a \rfloor is the floor operator (the largest integer less than or equal to a).]

Calculator usage:

  • Conventional notation calculators use “=” to finish computing whatever operations have been queued up.  This has nothing to do with mathematical equality and seems to be one of the main sources of confusion for students.   Personally, I like the RPN notation of the better HP calculators, where operators are not queued, but done immediately (values are queued on a short stack). No equals sign is needed on such calculators.  If one has to have a “finish computing” symbol, it would be better to make it a semicolon.
  • Some scientific calculators allow entering equations and solving them for specific variables.  This is the same as the predicate meaning of equals sign in math, but quite different from the “finish up” meaning usually used on calculators.

Computer programming:

  • Some languages (like C and C++) use “=” for the assignment operator, which sets the current state of a variable.  This is confusing to many beginning programmers, as it has nothing to do with any of the mathematical meanings of “=”.  Other programming languages have adopted “:=” or \leftarrow for this operation, which is much less confusing.  The assignment operator is an extremely handy operation when programming, but the mathematical semantics are a mess, requiring explicit representations of state as a function of time (or even messier state spaces for parallel programming).
  • Some languages use “=” to test whether two expressions are currently the same (C and C++ use “==” for this test, a notation that I like).  This is also not the same as the mathematical predicate use of “=”, since it only tests the current values of the expressions, while the mathematical expression is expressing that the two expressions are always the same.  The problem really arises from the different notions of “variable” in computer programming and mathematics.  If you think of the computer-programming variable as a function of time (or, more accurately, as a function of the state of the system), then “x==y” can be translated as x(t)=y(t), to be evaluated at a specific time t.  There will still be some confusion, as mathematicians routinely omit “obvious” quantifiers, so when a mathematician writes x(t)=y(t), they often really mean \forall t: x(t)=y(t), unless they’ve previously been talking about a specific t, in which case they don’t.  Having to guess what quantifiers are intended makes a lot of math much harder to read than it ought to be.

Some of the meanings of “=” are symmetric, others are not.  All the asymmetric uses (assignment, definition, completion of calculation) should be replaced by different symbols.

5 Comments »

  1. I agree in relation to the mathematical use of =, that it plays an equivalence and an assignment function – which you label as predicate and definition [I like the introduction of linguistic terms here ;-)].

    I agree with regard to the calculator. I think that was carelessness or lack of insight on the part of the original designers. I would prefer that calculator “=” was replaced by “Exe” or “Perf” for execute or perform operation.

    As far as computer programming is concerned, I think much of the confusion or different uses of “=” may have been forced historically by the 128 limit imposed by 8-bit computing. If computer programmers want to redefine the meaning of “=”, fine. After all, * being used for multiply is hardly standard mathematics!

    Confusion can create an opportunity for teaching/learning experiences, but only if it can be clarified. It is our responsibility as educators to make sure that we are using signs and symbols correctly, and consistently.

    P.S. x%4 = y%4 ?

    Comment by colintgraham — 2010 September 3 @ 12:57 | Reply

  2. “x%4 = y%4” mixes “C” notation with standard math. In C, the “%” operator is the remainder operator (so x%4 is the remainder when x is divided by 4. Unfortunately, in C the function is not completely defined, with some parts left up to the hardware designer, so it is usually not the most useful of implementations, other than for non-negative, integer x (where all the legal implementations are identical). The best definition is
    x\%y =_{\mbox{def}} x- \lfloor x/y \rfloor y, where \lfloor a \rfloor is the floor operator (the largest integer less than or equal to a), which can be used for any real x and any non-zero real y (actually, any x and y in which x/y is real).

    Comment by gasstationwithoutpumps — 2010 September 3 @ 14:24 | Reply

    • Thank you. You clarified the point I was trying to hint at with the difference between mathematical uses of “=” and computer programming uses (I was a programmer in a past life!). The mathematician in me says why is “%” even being used here? But that is maybe another blog post about symbols… ;-)

      Sometimes, computer programmers (or the language developers) can make life difficult for themselves!

      There is, however, an elegance to well-structured programs in the same way as there is with mathematical proofs, and the concomitant satisfaction in producing them.

      Comment by colintgraham — 2010 September 3 @ 18:29 | Reply

  3. Another problem with equals signs in imperative languages is that it introduces the distinction between l-values and r-values, so that the meaning of a variable depends on whether it’s on the left or right side of the equals sign. This is one of the reasons that I’m teaching introductory programming using the Racket dialect of Scheme (http://www.racket-lang.org). Variables are bound to values, not to locations, so if you want mutation and all the complications that come with it, you have to explicitly create a box into which you put values. The curriculum I’m using doesn’t even introduce the concept of mutation until quite late in the course.

    Comment by Justin — 2010 September 3 @ 16:11 | Reply

    • My son had a course using Dr.Scheme that delayed discussing assignment until quite late in the semester. Although it is a carefully thought-out pedagogic approach, I don’t care for it much myself. I think that sequencing and iteration are more fundamental to computation than recursion, and the mathematical elegance of the semantics of LISP do not compensate for the very ugly code that gets written in LISP. The Scheme-based approach to programming instruction has always seemed to me a theoretician’s approach, rather than a practical one.

      While I agree that the semantics of assignment are complex, they are also very powerful, and avoiding assignment does not result in clean programming.

      I do agree that Kernighan’s choice of “=” for the assignment operator in C was a poor one and I would prefer an asymmetric symbol for the operator.

      Comment by gasstationwithoutpumps — 2010 September 3 @ 18:29 | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: