TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

For mathematicians, = does not mean equality

289 点作者 hds大约 7 年前

33 条评论

kps大约 7 年前
(I assume this was inspired by <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16803874" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16803874</a>)<p>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<p><pre><code> 𝑚𝑣² 𝐾 = ─── 2 </code></pre> Why isn&#x27;t it written 2<i>K</i>=<i>m</i><i>v</i>², which expresses the same mathematical equality in a smaller, simpler form? Or any of the other equivalent rearrangements? It&#x27;s because formulas have a convention, where the LHS is a single term naming the value you <i>want</i>, and the RHS contains the terms for values you <i>have</i>. That is, a formula doesn&#x27;t just state an equality, it states a <i>method for calculating</i> something. That usage predates programming, and was explicitly copied by early programming languages like For[<i>mula</i>]tran[<i>slator</i>] that were designed for scientific &amp; engineering calculations.
评论 #16835098 未加载
评论 #16834379 未加载
评论 #16836712 未加载
评论 #16836366 未加载
评论 #16837035 未加载
评论 #16837067 未加载
评论 #16836033 未加载
评论 #16837813 未加载
lou1306大约 7 年前
Some more food for thought on the meaning of =, from Girard&#x27;s &quot;Proofs and Types&quot; [0]:<p>&gt; There is a standard procedure for multiplication, which yields for the inputs 27 and 37 the result 999. What can we say about that? A first attempt is to say that we have an equality &quot;27 x 37 = 999&quot;. This equality makes sense in the mainstream of mathematics by saying that the two sides denote the same integer [...] but it misses the essential point: There is a finite computation process which shows that the denotations are equal.<p>&gt; [...] if the two things we have were <i>the same</i> then we would never feel the need to state their equality. Concretely we ask a question, 27 x 37, and get an answer, 999. The two expressions have different senses and we must do something (make a proof or a calculation, or at least look in an encyclopedia) to show that these two <i>senses</i> have the same <i>denotation</i>.<p>[0]: <a href="http:&#x2F;&#x2F;www.paultaylor.eu&#x2F;stable&#x2F;prot.pdf" rel="nofollow">http:&#x2F;&#x2F;www.paultaylor.eu&#x2F;stable&#x2F;prot.pdf</a>
评论 #16834850 未加载
评论 #16838518 未加载
smadge大约 7 年前
I agree that “=“ as interpreted by people doing math requires context, but in most situations they are able to translate it into a “correct” or formal notion of equality. For example, translating on the fly these ad hoc notions of equality into precise notions of equality in first order logic and&#x2F;or set theory. For example,<p><pre><code> f(x) = 2x + 3 </code></pre> Might be translate into something like,<p><pre><code> For all x in the domain of f, f(x) = 2x + 3 </code></pre> Or maybe further,<p><pre><code> f = { (x, y) in Cartesian product of domain and codomain | y = 2x + 3 } </code></pre> Where equality is, I think, strictly defined here as set equality.<p>The articles other point in this example is that we might way “when x = 2, f(x) = 7.” Claiming that x is used both as an indeterminate value and a concrete value. Again, I think the ambiguity is resolved when translate using the correct quantifies, something like “for all x in the domain of f, if x = 2, then f(x) = 7.”<p>Or perhaps you might claim, “there exists an x in the domain of f such that f(x) = 7.” The important point being that the function f is formally NOT the formula f(x) = 2x + 3, but a particular set of ordered pairs, of which you can make formal statements about in first order logic.<p>Another example used was<p><pre><code> A = {n^2 | n = 1, 2, ... 100} </code></pre> But again this is just “syntactic sugar” that a reader would translate into perhaps<p><pre><code> A = { n^2 | n in {1, 2, ..., 100}}</code></pre>
评论 #16836600 未加载
评论 #16836980 未加载
xg15大约 7 年前
Fully agreed, though to nitpick:<p>&gt; <i>Rather than precisely say, f(2) = 7, we say that for x=2, f(x) = 7. So x is simultaneously an indeterminate input and a concrete value</i><p>This seems like a perfectly by-the-book piece of second-order logic with two equality predicates.<p>i.e., the statement asserts that if you look at the space of all possible values for x, then for each value where the predicate &quot;x = 2&quot; holds, the other predicate &quot;f(x) = 7&quot; will also hold. It happens there is only a single value that will satisfy &quot;x = 2&quot;, but that&#x27;s not the equality&#x27;s problem.<p>So both = signs really <i>are</i> equality here.
评论 #16834159 未加载
harrygallagher4大约 7 年前
I noticed this recently when I was trying to define a note-taking syntax for my math classes. I thought it would be smart to use := for definitions and = for equality, but then I was frustrated when = didn&#x27;t always mean equals in the same way, and some things didn&#x27;t really fit into either category. I ended up just giving up and switching back to abusing = in all situations. I think math has a really cool human aspect, it&#x27;s very rigorous but also relies on the fact that your notes&#x2F;proofs&#x2F;whatevers are going to be read by a person.
giomasce大约 7 年前
The author itself admits in the postscript that he has embellished a bit the article, but allow me to take it at its face value: to me, it seems that the article confuses mathematics with its notation (and the same for computer science, but at this level CS is just a branch of mathematics). All the funny stuff he goes on describing follow from this confusion. When a mathematician does mathematics, they have very well defined concepts for &quot;equality&quot;, &quot;equality up to some equivalent relation&quot; (my preferred: &quot;equality up to diffeomorphisms that are isotopic to the identity&quot;) and so on. However notation is chosen saving on clarity and conciseness, sometimes at the expense of the direct mapping with underlying mathematical concepts. Thus in some case the sign &quot;=&quot; is meant to mean equality (in a certain sense), in some other cases it is not.<p>Computer languages make no exception: they are nothing else than formalisms to express computations. As for every other formalism, the meaning of signs is chosen to be what appears most comfortable in that context by the formalism designer. The statement &quot;x = x+1&quot; has very different interpretations depending on whether you consider it written in C or in standard polynomial equation theory; but in both cases there is a well known meaning for it. In exactly the same way the word &quot;case&quot; has different meaning depending on whether your are reading in English or in Italian.
评论 #16840123 未加载
评论 #16836473 未加载
raphlinus大约 7 年前
There are few more examples that come to mind, like statements about intervals (π = 3.14 ± 0.01) and the usual notation for modular arithmetic; 3 * 3 = 1 (mod 4).<p>Oh, and the wonderful notation for integrals, ∫ 2x dx = x² + C
评论 #16834221 未加载
评论 #16835076 未加载
评论 #16834177 未加载
评论 #16834237 未加载
rsp1984大约 7 年前
This. It&#x27;s even more obvious in linear algebra where mathematicians routinely start with the premise &quot;Ax = b&quot;, even if there is no solution x that would satisfy the equation exactly.
评论 #16834043 未加载
评论 #16834651 未加载
allthenews大约 7 年前
Operators in mathematics are overloaded in a very similar way to operators in computer science (in languages that permit overloading).<p>I think the author hints toward a good point: there is no use arguing over the meaning of &quot;=&quot; in a general sense, because the meaning is contextual.<p>I think this whole discussion is merely indicative of inexperience on the part of computer scientists attempting to navigate mathematics.
评论 #16834101 未加载
评论 #16835259 未加载
评论 #16834065 未加载
victorNicollet大约 7 年前
Interestingly, when using mathematics to describe the semantics of programming languages (say, operational structural semantics for an imperative language), the assignment tends to use an arrow, i.e.<p>S[ x ↦ V ]<p>indicates that the new state is equal to old state S, but with variable x now bound to value V.
评论 #16835513 未加载
grosjona大约 7 年前
I remember thinking the same thing after reading <a href="https:&#x2F;&#x2F;www.hillelwayne.com&#x2F;post&#x2F;equals-as-assignment&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.hillelwayne.com&#x2F;post&#x2F;equals-as-assignment&#x2F;</a><p>Math symbols and expressions are inconsistent just like regular languages. But, unlike math, other languages don&#x27;t claim to be consistent.<p>It&#x27;s not surprising that John von Neumann said &quot;in mathematics you don&#x27;t understand things. You just get used to them.&quot; - I&#x27;ve never heard a software developer say this about coding.<p>For example, I did not enjoy integrals at school because of the &#x27;dx&#x27; at the end which means &#x27;with respect to x&#x27; but which actually looks like a multiplication (* d * x).<p>I think that the reason why I never got deep into math is because the language of math is too inconsistent and has too many logical shortcuts and I can&#x27;t operate in such environment.
评论 #16838200 未加载
评论 #16840140 未加载
howling大约 7 年前
All these discussions of &quot;=&quot; are missing the point.<p>The notation &quot;x = x + 1&quot; is awful because at lhs x denotes a reference to an integer while at rhs x denotes the value hold by the reference. If you know C, it is similar to the difference between an integer pointer *x and an integer x. As an illustration, here are two programs that are doing the same thing, one in C and one in Haskell.<p><pre><code> #include &lt;stdio.h&gt; int main() { int x = 0; x = x + 1; printf(&quot;%d\n&quot;, x); return 0; } import Data.IORef main :: IO () main = do xref &lt;- newIORef 0 x1 &lt;- readIORef xref writeIORef xref (x1 + 1) x2 &lt;- readIORef xref print x2</code></pre>
评论 #16835577 未加载
hyperpallium大约 7 年前
Geometry distinguishes between equivalence and value. An &quot;angle&quot; isn&#x27;t its degrees, but the geometric figure (two rays or segments meeting at an end-point of each). It&#x27;s the <i>measure</i> of the angle that is the degrees.<p>You don&#x27;t say &quot;angles are equal&quot; - you say they are <i>congruent</i>. It&#x27;s their <i>measures</i> that are &quot;equal&quot;.<p>Although congruency implies measure equality, it doesn&#x27;t really mean that, but that the shapes are the same (can be rotated&#x2F;translated to coincide).
评论 #16840165 未加载
评论 #16836526 未加载
ChrisSD大约 7 年前
I agree with the thoughts on the = sign but I&#x27;m not so sure about mutations.<p>&gt; If mutation is so great, why do mathematicians use recursion so much? Huh? Huh?<p>&gt; 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.<p>Most high level languages try to avoid making the programmer describe the most efficient way to handle variables. The idea is to describe your algorithms and how they connect and allow the compiler (or interpreter) to figure out how to use registers etc to implement it. Of course that ideal breaks down sometimes but most high level programmers don&#x27;t normally need to stress the low level details too much.<p>&gt; My second point is that mathematical notation is so flexible and adaptable that it doesn’t need mutation the same way programming languages need it. In mathematics we have no stack overflows, no register limits or page swaps, no limitations on variable names or memory allocation, our brains do the continuation passing for us, and we can rewrite history ad hoc and pile on abstractions as needed to achieve a particular goal.<p>It&#x27;s true that there&#x27;s a limit to abstractions even the highest level languages can make if they want to remain general purpose. However I think languages can handle immutable variables as a default.<p>That&#x27;s not to say I agree that programming should always follow mathematical notation. But I also don&#x27;t think it&#x27;s a bad ideal in many cases.
评论 #16835986 未加载
评论 #16836012 未加载
评论 #16834228 未加载
cconroy大约 7 年前
Alan Kay had a good answer on quora for this.<p><i>Let me confess that I’ve not read every answer. But the ones that I did read were all very concerned with “squaring” etc.<p>The simplest answer — and I think the reason many people have difficulty with both arithmetic and especially algebra — is that you need to deeply internalize just what the “=” sign symbolizes and asserts: that there is the very same number on each side.<p>In other words don’t be distracted by the symbols and operations. One way to think about this is that “a number is all the ways you can make it” (i.e. it can be thought of as “processes” (an infinite number of them) as well as a “value”).<p>This means whatever you can do to any number can be done on both sides of the “=” because there is just the same number underneath the gobblydegook on both sides.<p>This is what “=” actually means. And it’s why algebra is actually quite easy rather than mysterious or difficult.</i> [0]<p>[0] <a href="http:&#x2F;&#x2F;qr.ae&#x2F;TU1SxJ" rel="nofollow">http:&#x2F;&#x2F;qr.ae&#x2F;TU1SxJ</a>
评论 #16835371 未加载
sykh大约 7 年前
Think about the equation<p>x + 3 = 1<p>Typically we write that the solution is &quot;x = –2&quot;. This to me is the most abusive form of usage for &quot;=&quot; in mathematics. The solution to the equation is –2. The solution to the equation x = –2 is also –2.<p>Solving the equation x = –2 is very easy. We can solve it just by looking at the equation. What we are really doing when solving an equation is transforming the original equation into a simpler equation with the same solution set. Tt gets tedious to write this all out so we just say things like &quot;the solution is x = -2&quot; when we&#x27;ve transformed the original equation to x = –2. This is weird because x is not the number -2. x is a variable that can assume a myriad of values. The only value of x that solves the equation is –2.<p>As the article states the abuse of the = sign in mathematics is rampant. We do it mostly without realizing it. In this sense mathematical language mimics human languages. All human languages are prone to abuse of rules and to shifting with the times.<p>The notation in mathematics, while much more precise than spoken human languages, is abused frequently and the purpose is to make things cognitively easier. The ancient Greeks didn&#x27;t have symbols for numbers and in their mathematics they wrote everything out in Greek. This makes it very hard to do tedious calculations. Using symbols in lieu of writing out all the minutia makes doing math easier provided you learn the contextual meaning of the symbols. Over the centuries symbols have been introduced as a shorthand for complex ideas&#x2F;objects&#x2F;operations. If you want everything precisely stated then reading Principia Mathematica ought to cure you of this desire. Mathematics is written by humans for humans.<p>Code is written by humans for computers and hence the notation needs to be rigorously defined in the language you are using and why your code needs to be commented.
评论 #16834846 未加载
评论 #16834772 未加载
评论 #16834781 未加载
评论 #16837900 未加载
评论 #16834992 未加载
waynecochran大约 7 年前
Lisp has many flavors of &quot;equal&quot;:<p><pre><code> = eq eql equal equalp string= ... </code></pre> Because equivalence mean many things in both the mathematical and programming world.
评论 #16834360 未加载
评论 #16834125 未加载
nilanp大约 7 年前
Jeremy – I’m a mega fan of your work.<p>But think going deeper into this is quite fun<p>Your post goes to the point at the heart of philsophical number theory.<p>What does equality mean ?<p>Yup – you got functinal equivalence, isomorphism, and temporary assignment of values.<p>But I think you could prove – that all these types of equality – are “instances” of “different implementations” of “equivalence.<p>They are no more equivalent than 1 = 1 is equivalent.<p>I.e. 1 = 1 means I think we can define a bijective “counting function” that proves there’s the “same number” of “elemetns” in the “sets”<p>I think (not sure) – if you define – counting fucntion &#x2F; same number &#x2F; elements &#x2F; sets differently – you get the differing definitions of equivalence you enumerate.<p>The interesting thing for me is that 1 = 1 is defined clear in 4 of peano’s axioms<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Peano_axioms#Formulation" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Peano_axioms#Formulation</a><p>And you could mentally – try to develop different (and potentially) – more powerful notions of “equivalence” – with differing axioms<p>A final point… the prevalence of several “similar” concepts of equivalence in computer science – may point to an underlying “platonic idea” of equivalence – that either exists dormant in the world awaiting for us to discover it; or is a useful “technologocial” construct – that has accelerated “progress”
qxmat大约 7 年前
I have an engineers understanding of higher maths - overly general and very patchy. Short of taking an undergraduate math course, are there any resources to help me parse math notation? For example, while brushing up on endogeneity&#x2F;exogeneity, E[B&#x27;|X] = 0 completely threw me - I had to search Google for the use cases of a bar&#x2F;pipe aka latex vert&#x2F;mid. I usually lose interest in a paper if I get stuck trying to decode the syntax.
评论 #16836552 未加载
ttctciyf大约 7 年前
&gt; The usual way to get half an apple is to chop one into &quot;two equal parts&quot;. Of course, the parts are actually NOT EQUAL - if they were, there would be only one part! They are merely ISOMORPHIC.<p>- John Baez ( <a href="http:&#x2F;&#x2F;math.ucr.edu&#x2F;home&#x2F;baez&#x2F;week147.html" rel="nofollow">http:&#x2F;&#x2F;math.ucr.edu&#x2F;home&#x2F;baez&#x2F;week147.html</a> )
smadge大约 7 年前
Some authors might prefer<p><pre><code> -- \ &#x2F; -- 0 &lt; i &lt; n </code></pre> Ass opposed to<p><pre><code> n -- \ &#x2F; -- i = 1</code></pre>
评论 #16834919 未加载
评论 #16836564 未加载
评论 #16834510 未加载
vinchuco大约 7 年前
Humans are compilers of math.<p>&#x27;=&#x27;, like number, means that concept, regardless of instantiation.<p>Beyond that note, I don&#x27;t see the value in listing all the ways you could interpret notation.<p>Maybe you would also find it entertaining to list all the ways a program can interpret a binary string?
jovial_cavalier大约 7 年前
When you say &#x27;i=0&#x27;, what you mean is that that is the base case, and the sigma specifies a bunch of other cases.<p>i_1 =&#x2F;= i_2.<p>As xg15 noted, it&#x27;s perfectly fine to say (x=2) =&gt; (x + 3 = 5). The problem the first example really addresses is that in mathematics, the namespaces are loosely defined, but in programming they aren&#x27;t. &#x27;i&#x27; can mean several things at once, and it doesn&#x27;t really matter because those things never really interact in the same context. In programming, you need to specify the name &#x27;i&#x27; every time you want to reference it, so it&#x27;s important that you have a stricter namespace rule.
OscarCunningham大约 7 年前
One can at least say that in formal ZFC the symbol &quot;=&quot; has exactly one interpretation. And it&#x27;s this interpretation that people talking about Haskell are referring to.
jasonkostempski大约 7 年前
Aren&#x27;t we all taught to write &quot;y = 3&quot; as the answer to algebra questions? That&#x27;s how I always thought of it, not as assignment, but as a declaration of truth.
thetruthseeker1大约 7 年前
When I learnt programming, i was confused by x=x+1;<p>After I understood what it really meant, I wondered why they didn’t use some other symbol to capture this semantic. Say something like x &lt;- x+1 ; Which implies assignment rather than equality - That way this would be unambiguous and I feel is more clear. I now guess the choice of using ‘=‘ was probably an attempt at making a (compromised) choice given the limited symbols that were available back when High level languages were first written?
评论 #16834855 未加载
评论 #16834484 未加载
评论 #16834716 未加载
评论 #16834486 未加载
评论 #16834689 未加载
nothrabannosir大约 7 年前
Minor note:<p><i>&gt; A = { n^2 : n = 1, 2, …, 100 }</i><p><i>&gt; In Python, or interpreting the expression literally, the value of n would be a tuple, producing a type error. (In Javascript, it produces 2.[link] How could it be Javascript if it didn’t?)</i><p>That linked JS code uses ^, which is xor, not pow. Math.pow([], 2) = NaN. Or maybe that was the joke and it flew completely over my head.
评论 #16834985 未加载
theparanoid大约 7 年前
A succinct summary is that mathematics is about understanding a thing and computing is about describing a concrete process.
评论 #16834086 未加载
mabbo大约 7 年前
Title could use a touch up. On mobile chrome at least, I&#x27;m not seeing the &quot;=&quot; in the title.
评论 #16833888 未加载
评论 #16833870 未加载
abhishekjha大约 7 年前
Also the asymptotic notation where f(n) = O(n^2) means a set membership operation.
评论 #16834742 未加载
评论 #16835575 未加载
amelius大约 7 年前
I think of mathematical = as similar to a let-binding: it&#x27;s valid within a certain context.
MaxLeiter大约 7 年前
Can someone explain why the JavaScript example equals 2?
评论 #16834447 未加载
评论 #16834465 未加载
internetman55大约 7 年前
I don&#x27;t mean to be rude cause this seems like a really interesting and well researched article, but my question is what an I gonna gain by reading it