Live data from Hacker News

For mathematicians, = does not mean equality

jeremykun.com

111–120 of 206 posts

Re: For mathematicians, = does not mean equality

#111
post #19

I agree with the thoughts on the = sign but I'm not so sure about mutations. > If mutation is so great, why do mathematicians use recursion so much? Huh? Huh? > Well, I’ve got two counterpoints. The first is that the goal here is to reason about the sequence, not to describe it in a way that can be efficiently carried out by a computer. Most high level languages try to avoid making the programmer describe the most ef…

The thing that blew my mind was that there are some mathematical programming languages where the point is not to ever actually run the program. Just type-checking it is enough to prove the result. (In the "programs are proofs" sense.) In these languages, it's important not to allow infinite loops because you will never test the code.

Even though there's a correspondence, there's always going to be a difference between writing a program so that you can actually run it and writing proofs, where you don't, and ridiculously inefficient algorithms don't matter at all, so long as they don't diverge.

Re: For mathematicians, = does not mean equality

#112
post #19

I agree with the thoughts on the = sign but I'm not so sure about mutations. > If mutation is so great, why do mathematicians use recursion so much? Huh? Huh? > Well, I’ve got two counterpoints. The first is that the goal here is to reason about the sequence, not to describe it in a way that can be efficiently carried out by a computer. Most high level languages try to avoid making the programmer describe the most ef…

> To achieve the same result with recursion requires a whole other can of worms: memoization and tail recursive style and compiler optimizations to shed stack frames. It’s a lot more work to understand all that (to get to an equivalent solution) than it is to understand mutation!

It's true, you can't rely on tail call optimizations on every language. But practically all modern compilers for imperative languages transform your code into SSA form[1] in one of their intermediate stages, so the code:

  int x = 1
  x = x + 1
will invariably be transformed into:

  int x0 = 1
  int x1 = x0 + 1
in one of the intermediate stages - before applying further optimizations and finally converting it to stack-based bytecode or register-based machine code.

This means that mutating a variable, at least when dealing with local primitive values, is equivalent to assigning the value to a new variable.

Even in other cases, in-place mutation is not necessarily more efficient than copying and modifying values. For multi-threaded code, mutation often requires relying on synchronization which can be more expensive than copying around data.

> Simply stated, the goals of mathematics and programming are quite differently aligned. The former is about understanding a thing, and the latter is more often about describing a concrete process under threat of limited resources.

In the current day and age, if a programmer would wants to write the most efficient code, they need to understand a lot about their multi-stage optimizing compiler, Out-of-order CPUs, OS threads and so on - and they would still need to benchmark their implementation against others. It is not clear anymore that mutation is always faster.

I think that in 99% of the cases, clear, safe and maintainable code trump the micro-optimizations that may (and often may not) be gained from using mutable data. Immutable data is generally easier to reason about, always safer from data races and other bugs, and - in most languages languages - more maintainable.

The age of limited resources and straightforward compilers is long over, but it left mutable variables as its heritage. I'd argue they're still common not because they are necessary to deal with hardware limitations, but just because generations of programmers have gotten so used to them, it's hard to give up on them.

[1] https://en.wikipedia.org/wiki/Static_single_assignment_form

Re: For mathematicians, = does not mean equality

#113
post #31

(I assume this was inspired by https://news.ycombinator.com/item?id=16803874 ) The use of ‘=’ for assignment in programming languages comes, not directly from mathematics, but indirectly from the use of mathematics in science and engineering. As an example, consider the formula for kinetic energy, commonly written 𝑚𝑣² 𝐾 = ─── 2 Why isn't it written 2 K = m v ², which expresses the same mathematical equality in a s…

> It's because formulas have a convention, where the LHS is a single term naming the value you want, and the RHS contains the terms for values you have.

This is simply not true.

Re: For mathematicians, = does not mean equality

#114
post #31

(I assume this was inspired by https://news.ycombinator.com/item?id=16803874 ) The use of ‘=’ for assignment in programming languages comes, not directly from mathematics, but indirectly from the use of mathematics in science and engineering. As an example, consider the formula for kinetic energy, commonly written 𝑚𝑣² 𝐾 = ─── 2 Why isn't it written 2 K = m v ², which expresses the same mathematical equality in a s…

> It's because formulas have a convention, where the LHS is a single term naming the value you want, and the RHS contains the terms for values you have. This is simply not true.

I agree this is not entirely true, I have often heard physicists express similar formulas in the way the parent described (I.e. 2K = mv^2)

Re: For mathematicians, = does not mean equality

#115
post #70

Earlier quoted context omitted.

Sure; I think we’re in violent agreement here, it’s absolutely the case that people write the simpler version when the meaning is clear from context. I’ve definitely done that a bunch.

Piling on with a bit more pedantry, my experience is a bit different. In my current ring theory course, we have indeed written things like 3 * 3 = 1 when working in |F_5 (not sure that notation is going to work as well as I hope, looks alright in the app I use), but it's not the equality symbol is overloaded, but the numbers themselves. Rather than using = to mean numeric equality and equality w.r.t. equivalence clas…

That seems odd to me. I don't think I've read any ring/algebra/module theory text that doesn't explicitly denote equivalence classes with, for example, square brackets.

Re: For mathematicians, = does not mean equality

#116
post #107

Earlier quoted context omitted.

Only if you take x=(0,1,0,...) and adopt the convention that any member q of the base field Q is assumed to represent qx^0 = (q,0,0,...). That is to say, x+3 only meets the definition of a polynomial because you insist on interpenetrating it as such. That’s what we mathematicians do. In the context of the original post it is absolutely clear that x+3 is a polynomial. There is no other reasonable interpretation. When…

>The second sentence I quoted is not true. I assume you are refering to the sentence: > If we wanted to consider x+3 a polynomial, we would be asking for the t value such that (x+3)[t] = (-1)[t] Bearing in mind that the example I have in mind is the equation "x+3=-1" with the solution of "2", in what sense in the above sentence not true? >When presented with the equation x+3=-1 x+3 is a polynomial. -1 is a polynomial…

One of the points of my original comment was that when it comes to equations the = does not mean equal in the sense of stating two objects are the same. In the context of an algebraic equation to solve the = sign is really a question. It’s asking, what is the set of values that make the statement true?

I know of no mathematician who thinks x^2-x+1=0 is anything other than a polynomial equation. Specifically it’s shorthand notation for the variety of the ideal generated by x^2-x+1. And in general you don’t look associate this variety with the quotient ring of the ideal generated by the polynomial. You look at the quotient of the radical of that ideal.

Without any further information the only reasonable interpretation of x+3 is that it is a polynomial. Without any further context in an algebraic equation x is a variable and is not assumed to be an element of the base ring.

In the context of function spaces like C(R) it’s a different matter. And viewing x+3 as an element of C(R) the only reasonable interpretation of x+3=1 is that we are finding the pre-image of 1. And to do this for a complicated function means solving an equation. And solving an equation by hand, the context of my original comment, means reducing the equation to a simpler one. In the case I gave this means reducing x+3=1 to the simpler equation x=-2 whose solution is obtained by inspection. That’s the goal of all the algebraic manipulations we bore beginning algebra students with. Reduce complicated equation to simpler equation. One whose solution is obtained by inspection.

Your view of how to interpret x^3+4x is too simplistic because the only to way to algebraically manipulate that object is by considering it as an R[x] or R(x). You have to view the x as an indeterminate in some larger ring than the base ring.

Re: For mathematicians, = does not mean equality

#117

Operators in mathematics are overloaded in a very similar way to operators in computer science (in languages that permit overloading). I think the author hints toward a good point: there is no use arguing over the meaning of "=" in a general sense, because the meaning is contextual. I think this whole discussion is merely indicative of inexperience on the part of computer scientists attempting to navigate mathematics…

CS already abuses equality all the time with big-O notation. Often you see stuff like f(n) = O(N²), when they mean that f ∈ O(N²). It's fine because everyone knows what's going on, but it's not using it in the sense of equality.

I was taught to use tilde in big-O notation. Your use of "set element" operator is not quite correct either, because of the limit that's going on there.

Re: For mathematicians, = does not mean equality

#118
post #6

This. It's even more obvious in linear algebra where mathematicians routinely start with the premise "Ax = b", even if there is no solution x that would satisfy the equation exactly.

The supposition in instances like these is one expressing a notion of equivalence, whether or not an equality results in a contradiction doesnt mean that the meaning of the symbol has changed.

I vaguely remember writing question marks over equality signs when one was using an equals sign as a proposition.

Re: For mathematicians, = does not mean equality

#119
post #116

Earlier quoted context omitted.

>The second sentence I quoted is not true. I assume you are refering to the sentence: > If we wanted to consider x+3 a polynomial, we would be asking for the t value such that (x+3)[t] = (-1)[t] Bearing in mind that the example I have in mind is the equation "x+3=-1" with the solution of "2", in what sense in the above sentence not true? >When presented with the equation x+3=-1 x+3 is a polynomial. -1 is a polynomial…

One of the points of my original comment was that when it comes to equations the = does not mean equal in the sense of stating two objects are the same. In the context of an algebraic equation to solve the = sign is really a question. It’s asking, what is the set of values that make the statement true? I know of no mathematician who thinks x^2-x+1=0 is anything other than a polynomial equation. Specifically it’s shor…

>It’s asking, what is the set of values that make the statement true?

For this to be the case, there would need to be a statement in the first place. And that statement would involve the =, so you necessarily still have the = symbol representing something other than questioness. I would further say that the equation itself is still just a statement, and any "question" interpretation is based entirely on the context where the equation is presented.

Further, lets take seriously the notion that "x+1" is a polynomial in the formal sense. What does it mean to find the set of values for which x+1=2 is true? Normally, I would say that we are looking for the set of x values which makes that equation true. However, we are insisting that the LHS is a polynomial (again, in the formal sense). This means that there is no variable. The "x" in the LHS is literally a value. It makes no sense to ask what values of (0,1,0,0,...) make that equation true. The fact that we give (0,1,0,...) a standard name of x does not suddenly make the question sensical. Nor does the fact x is often used to represent variables.

>I know of no mathematician who thinks x^2-x+1=0 is anything other than a polynomial equation.

To be clear, outside of very particular contexts I would still call x^2-x+1=0 a polynomial equation, because it is extremly useful to talk about polynomials without invoking all of the machinery of formal polynomials.

>And viewing x+3 as an element of C(R) the only reasonable interpretation of x+3=1 is that we are finding the pre-image of 1.

I disagree. Viewing x+3 as an element of C(R), the only reasonable interpretation of x+3=1 is the statement (x↦x+3)=(x↦1).

Viewing x+3 as an element of R would allow us to treat the equation x+3=1 in the "obvious" way. We can prove that the statement x+3=1 implies that x=-2.

Further, I would agree with you that, absent other context, when given an equation which contains an "x" in it, there is some implication that we are supposed to solve for x.

>Your view of how to interpret x^3+4x is too simplistic because the only to way to algebraically manipulate that object is by considering it as an R[x] or R(x).

Why? Suppose I don't know what R[x] or R(x) is. We certainly don't teach highschoolers what either of those are, and they seem to be able to do "algebra" just fine.

Here is a simple approach to dealing with x^3+4x without considering it a member of R[x]. For concreteness, I want to solve x^3+4x=0.

Suppose x \in R such that x^3 +4x = 0.

By the distributive property, this equation is true iff x(x^2 +4x)=0.

By direct calculation, we can verify that x=0 is consistent with this equation, and therefore consistent with the original equation.

Consider the case where x != 0.

Note that the function f(n) = n/x is a bijection. Therefore, we have x(x^2 + 4)=0 iff f(x(x^2+4)) = f(0).

By direct computation, we get that this is true iff x^2+4 = 0.

We know that x^2 >=0, and 4>0.

Therefore, x^2+4 > 0.

This is a contradiction, which means that the case where x!=0 is impossible.

This means that we have proven that x=0.

Now, suppose we were working over C.

Continuing from x^2 + 4 = 0, we can show that:

x^2+4 = 0 iff

(x+2i)(x-2i) = 0 iff

x+2i = 0 OR x-2i = 0 iff

x=2i OR x=-2i

Since the cases x=0 and x!=0 are exhaustive, we have proven the statement x \in {0, 2i, -2i}.

I solved this using the method we teach school children and without invoking any notion of polynomials.

Re: For mathematicians, = does not mean equality

#120
post #117

Earlier quoted context omitted.

CS already abuses equality all the time with big-O notation. Often you see stuff like f(n) = O(N²), when they mean that f ∈ O(N²). It's fine because everyone knows what's going on, but it's not using it in the sense of equality.

I was taught to use tilde in big-O notation. Your use of "set element" operator is not quite correct either, because of the limit that's going on there.

I don't think the limit is really an issue here. Most CS textbooks define big-O with the limit ->infinity part baked into the definition. So, this is more of an issue of different people using different definitions than an issue of abuse of notation.
Post reply on HN