0

In programming language if we use the 'assignment' or 'defining' symbol '=' which is equivalent to $:=$ and use it to define for our variable $x$ that:

$x:=2y$

and later define that

$x:=2z$

instead of $y$ (or $z$) changing to allow both definitions to be true, the second will simply overwrite the first, so if $z=2$ $y=4$ and will no longer necessarily be the same as $2y$.

In using of this 'definition' symbol is this also the case in mathematics where $x$ is re-used as an almost different variable? If I use regular equals both can be true, but since this symbol comes from 'computer science' I ask if this is treated the same.

If we use two 'definitions' with the symbol $x$ can $x$ be the same 'variable' unlike in languages like Python where such a concept doesn't exist and a symbol is pointed to new parts of memory again and again.

  • 3
    Not used in mathematics. – Mauro ALLEGRANZA Oct 10 '22 at 10:13
  • 1
    I doubt that there is a formal rule. i think most authors would say something like "Let $x=2y$" when introducing $x$ for the first time, and just "$x=2y$" when deducing the value of $x$ from some other condition. If you have two let bindings in the text, it should be obvious from context which expressions they apply to (if not, then the text is probably poorly written). – preferred_anon Oct 10 '22 at 10:17
  • 2
    It's not common, but you do see $:=$, or sometimes $\overset{\Delta}{=}$ for definition. It's not good practice to re-use and re-define variable names, however. – Theo Bendit Oct 10 '22 at 10:35
  • @TheoBendit I don't like it as you could be 'defining' two things to be true, for example $x=2y=2z$ could be $x:=2y$, $x=2z$. In programming you cannot do that, so I'm not sure if you can use it twice and have essentially two 'variables' with the same name, or if you can 'define' two things to be true? Is a variable given one 'definition' upon introduction? –  Oct 10 '22 at 10:53
  • As long as it is clear what is defined , I see no problem with "$:=$" , whether commonly used or not , in the case were we want to define a function , say , $f(n):=...$ to have less work to describe this function in future analysis. We could of course omit ":" , but this way we make clear that this is a "self-made" definition. – Peter Oct 10 '22 at 11:07
  • @Peter can we write two 'definitions' and have them both true? So $x:=2y$ and $x:=2z$ means $x=2y=2z$? by definition? –  Oct 10 '22 at 11:12
  • @user1007028 This would be very strange indeed. We should still care about consistent definitions which does not seem to be the case here. – Peter Oct 10 '22 at 11:14
  • Not in all programming languages – Claude Leibovici Oct 10 '22 at 11:19
  • @Peter so it would be better to just say $x=2y$ and $x=2z$ and that $2y=2z$ using standard equality? Or maybe say $x:=2y$ and hence $x=2z$ as $2y=2z$ or something? –  Oct 10 '22 at 11:22
  • @user1007028 IMHO, in good mathematical writing, defining a new variable must always be accompanied by extra exposition, such as ”We define…”, “Let…”, “We denote…”, or even “We write…”. The following lines should only define one new symbol per line. Triple equalities should generally be avoided, but writing, say “We denote $\mu = (\alpha +1)^2 + 1= \alpha^2+2\alpha+2$ is sufficiently clear. – Theo Bendit Oct 10 '22 at 11:44
  • @TheoBendit I will do that, is it incorrect to use a definition like: We define that $x=2y$ and $x=2z$. I assume the confusion with using '$x:=$ twice it seems that I am 'redefining' $x$ as different from before? –  Oct 10 '22 at 12:39
  • @user1007028 Indeed. That would be confusing. – Theo Bendit Oct 10 '22 at 19:05

1 Answers1

0

The symbol "=" in mathematics, as you are probably aware, is equivalent to "==" in programming (rather than "="), so basically it's just a function that takes two parameters of any type and returns a boolean value. The symbol "=" as used in programming is very uncommon in mathematics. Even when defining variables for the first time in mathematics, e.g. "let $x=2y$", what really happens technically speaking, is everything that is written below is under the premise that $x==2y$ returns a true value. So technically speaking, even here we are not using the "definition" operator in mathematics (i.e. ":=").

Just think about the expression "$x=x+1$" in programming. It makes perfect sense, it just increments the value of x by 1. Even so, I can't think of a single field of mathematics where this expression would make sense, just like you would never write "$x==x+1$" in programming, but rather just simply "false".

For this reason, redefining variables in the same exercise/formula/context is also not possible. The closest you can get to "redefining" a variable in mathematics, is passing it as an argument in a recursive function.

For example, let's consider a function in programming that returns the sum of the first 10 natural numbers, where the "iterator" and "sum" variable get redefined 9 times.

int f(){
    int i = 1, sum = 0;
    while(i<=10){
        sum += i; //i.e. sum = sum + 1;
        i++; //i.e. i = i + 1;
    }
    return sum;
}

The above function, as simple as it is, is impossible to "translate" into mathematical language. The only way to do such a translation is to define the function in such a way that, whenever you have to redefine a variable, you return the entire function with modified arguments:

//note that when calling the function for the first time, both arguments must be 0
int f(int i = 0, int sum = 0){
    if(i<=10) return f(i + 1, sum + i);
    return sum;
}
//print(f(0, 0)); will print 55

In the above function, TECHNICALLY speaking, both the "i" and "sum" variables are only defined once per function call (so we have no redefinitions). The following mey not be directly related to the question, but such a function would be "translated" in mathematical language as follows:

$\forall i\forall sum:i\leq10\implies f(i, sum)=f(i+1, sum+i)$

$\forall sum:f(10, sum)=sum$

Both of the above are just true boolean statements, so TECHNICALLY not definitions. Same thing goes for the statement below;

$f(0, 0)=55$