Demonstration of the dependency of Mathematics upon Logic

A while ago I set myself the challenge of replicating the basic mathematical operators in (C++) computer code, without using any of the basic mathematical operators themselves.

Using binary, I was able to reduce addition, subtraction, multiplication and division solely to logical operators and “bit-shifting” (0010 shifted left once is 0100 etc. - any binary digit (bit) shifted in from the right “from nowhere” is always zero).
I observed the same process that you learn in school, writing one number above the other and conducting addition etc. starting with the smallest colomn and working up, “carrying” when appropriate.

Addition was the simplest, requiring only the logical XOR function (exclusive OR) and the logical AND function, bit-shifted left - and repeating the process with the two results until the answer is converged upon.

Relevant logic tables, just to be explicit (using C++ syntax):
[tab]XOR:
0^0 = 0
0^1 = 1
1^0 = 1
1^1 = 0

AND:
0 & 0 = 0
0 & 1 = 0
1 & 0 = 0
1 & 1 = 1[/tab]
Example, 5 + 3 = 8:
[tab]5 in (4-bit) binary is 0101
3 in (4-bit) binary is 0011
8 in (4-bit) binary is 1000

0101
0011+

1000

Using the logical process described above:
Stage 1:
0101 ^ 0011 = 0110 (6 in decimal)
0101 & 0011 = 0001, 0001 << 1 = 0010 (bit shifting the “AND” result once to the left) (2 in decimal)
Stage 2:
0110 ^ 0010 = 0100 (4 in decimal)
0110 & 0010 = 0010, 0010 << 1 = 0100 (also 4 in decimal)
Stage 3:
0100 ^ 0100 = 0000 (obviously 0 in decimal)
0100 & 0100 = 0100, 0100 << 1 = 1000 (8 in decimal)
Stage 4:
0000 ^ 1000 = 1000 (8 in decimal)
0000 & 1000 = 0000 (obviously 0 in decimal, even if bit-shifted)
Any subsequent stages will yield the exact same results indefinitely, so the process terminates here giving the expected answer of 5 + 3 = 8. Different numbers need different numbers of stages before they are complete.[/tab]
Essentially this iterative process re-arranges the two terms into numbers that have no two terms the same for each colomn, with the numbers at each stage adding together to equal the answer.

It is also functionally equivalent to a “logic” table for addition (very similar to XOR):
[tab]0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0 (with this special case actually being “10”, with the “AND” result being shifted left to simulate the “carrying” process when you run out of digits in whatever number base you are operating with).[/tab]
Subtraction is remarkably similar. A “logic” table for subtraction (also very similar to XOR):
[tab]0 - 0 = 0
0 - 1 = 1 (with this special case actually being “1” with 1 deducted from all bits to the left of this 0 that has 1 subtracted from it, until a 1 is reduced to 0. For some reason that I’m not actually quite sure of, the same simulation of the “carrying” process as used in addition amounts to the same effect).
1 - 0 = 1
1 - 1 = 0[/tab]
Basically the same as addition, but with the “AND” operator replaced by a programmer-defined function (let’s call it “?”) that swaps the “1 & 1 = 1” in the AND table with “0 ? 1 = 1” (the others result in zero in just the same way). The same “bit-shift to the left” is applied to the result of this operation after each stage.

Example 5 - 3 = 2:
[tab]Stage 1:
0101 ^ 0011 = 0110 (6 in decimal)
0101 ? 0011 = 0010, 0010 << 1 = 0100 (4 in decimal)
Stage 2:
0110 ^ 0100 = 0010 (2 in decimal)
0110 ? 0100 = 0000 (0 in decimal, even if bit-shifted)
Subsequent stages will yield the exact same results indefinitely, so the process terminates here giving the expected answer of 5 - 3 = 2. Only 2 stages were needed this time.[/tab]
Multiplication is glorified addition: 5 * 3 is the same as 5 + 5 + 5 (5 added to itself 3 times) = 15.
It can obviously be simplified to a further iteration applied to my logical interpretation of addition.
Division is glorified subtraction: 5 / 3 is the same as subtracting 3 from 5 until the next time would result in a negative value, taking the remainder (the modulus) and shifting the digit once to the left, and subtracting the denominator from it again until the next time would result in the negative value - the value is placed in the next decimal (or other base system) place to the right (20 / 3 = 6, remainder 2: this recurs infinitely to equal 1.6 recurring).

Powers are glorified multiplication and roots are glorified division etc. All mathematical operators boil down to these basic logical steps.

Mathematics is built on logic.

I think I heard elsewhere on this forum that the opposite were true. If anyone believed this to be so, is this still so despite my demonstration? If so, why?

Mathematics seems to be easily defined as that pertaining to quantities, logic varies depending on the use the user has for it. A certain type of logic is symbiotic with math, if math seems dependent on it, it is only because that logic evolved or was developed to be its bases. Then their is logic that has nothing to do with math or quantities. It also relies on the synthesis of 1s and 0s, but in a way I will describe using the loaded term “existentially”; is and isn’t, being the best way I can think of to describe this, I don’t believe quantity can come into this (but, it would be interesting to see if someone could try to prove all I’ve said wrong by attempting to integrate quantity into it).

I would argue that logic that isn’t limited to this association with quantities is the most difficult (not being firmly rooted in the mind-numbing and base desire to count everything) and why we find idiot savants brilliant at math and terrible with logic unassociated with it.

How does ‘carrying’ relate to logic?

So Sil has reinvented the ALU for us. =D>

…now we can all tell our PCs that they can start working properly. 8-[

Emmm…??

Can you demonstrate that?

That seems to be entirely incorrect. But I’ll wait to see the above demonstration.

I already did, see my above post. The use I had for logic was to show the dependency of logic upon the user and his use for it.

I guess you could claim that illogical math came before logical math; thus implying that a particular logic was invented to justify the illogical math. It seems unlikely, but it’s all the same to me.

I’m still not seeing what you are talking about, nor any demonstration (example) of “varying logic”…??? :confusion-scratchheadyellow:

What is it that you are calling “Logic”?? :-k

Math logic: If A (can somehow possibly) equals B and B (can somehow possibly) equals C, then A equals C (within the highly presumptuous idea that A equals B and B equals C).

Another form of logic: A seems like B (but, I may over-confidently state it as if it were a fact that they equate, to save time) and B seems like C (but, I may over-confidently state it as if it were a fact that they equate, to save time), then A seems like C (but, I may over-confidently state it as if it were a fact that they equate, to save time).

Yet another form of logic: A seems like B (but, I may over-confidently state it as if it were a fact that they equate, to save time) and B seems like C (but, I may over-confidently state it as if it were a fact that they equate, to save time), then while A may have a passing resemblance to C, we haven’t proven that they have anything to do with each other besides their mutual relation to B.

Math logic relies on the idea that things can equate (whether it be based on other quantifiable aspects such as weight or because at least two objects are classified as belonging to the same group, thereby rendering them (somehow) equal), thus making it possibly to count those things within a framework, that seems consistent as long as one is willing to continually ignore the shaky bases that the original equivocations were founded on.

Furthermore, math logic seems to avoid the “is and isn’t” of other logic, because it relies on an equally fantastical idea that an object can be destroyed completely or passed to someone/somewhere else rendering it non existent (0) or even somehow in a negative realm (negative numbers).

I see. So if a driver doesn’t follow the map or a chef doesn’t follow a recipe, then the fault is in the map or the recipe. It couldn’t have anything to do with someone being a bad driver or a bad cook.

I’m pretty sure that Sil wasn’t using that definition for logic (ie “whatever some idiot puts forth as his attempt at logic”). The kind of logic that he was referring to doesn’t vary in the slightest. And he is absolutely correct concerning math and logic, just as you were correct about math being about quantities (the logic involved in quantities).

Math also almost entirely covers quaLities with one exception. Calculus and hyperreal numbers cover the scope of infinities and infinitesimals and thus value quality rather than just discrete quantities, but common math assumes that absolute zero quality can exist. Their hyperreals could be used to prove that it doesn’t.

One can have absolute zero of something that comes in wholes, like marbles in the jar. But one cannot have absolute zero of qualities like length or anything that indiscreetly varies.

A good question.

Whilst “carrying” is performed with the use of logical AND, the reason it is performed at all is purely due to issues of presentation.

Consider a theoretical number system of “base infinity” where there are infinite individual digits available to denote every possible quantity with just a single digit, no carrying would be necessary.
Contrasting this number system with binary, base 2 can obviously denote only 2 numbers with single digits before requiring some alternative measure in order to allow for higher numbers to be represented. Carrying is one solution, using a combination of logical AND, and the reasonable (though not inherently logical) aesthetic transference of a digit to factor into the calculation of any adjacent term in the next colomn along (denoting the next highest order of magnitude).

Going back to “base infinity”, 2 represents exactly the same quantity as 10 in binary, 3 as 11, 4 as 100 etc. - the actual mathematics performed on these quantities is all logical, despite any illogical aesthetical issues of how to denote them. Only the logical nature is most fundamentally demonstrable using binary. You take this logical result and illogically choose whatever base number system you want to use to represent this logically derived outcome.

Incidentally, @everyone else, this should clear up any issues of quantities being perfectly logical in their calculation and mathematical manipulation, despite the illogical choice of any given base number system to represent such a quantity.

To address issues of whether mathematics applies perfectly to the concrete world outside of its abstract realm, of course I hold the position that it does not - it’s just a useful (reasonable) tool. And concerning what “0” is supposed to represent, it’s not supposed to imply anything has been completely destroyed, or any notion of absolute nothingness, just a realistic “lack of 1-ness/somethingness”. Existence continues, it just doesn’t take the form of whatever the “1” is intended to denote in the context being addressed at the time.
Finally, to address issues of negative or complex numbers, and numbers with decimal points, the former are just the same thing but in a different “direction” and the latter are just the same thing but with a floating point that can be decimal, binary or any number system, with its position determined by multiplication by the relevant order of magnitude, a certain number of times (x10^n). And multiplication is, as already covered, just glorified addition (and powers just glorified multiplication).

:-k Such a system would be purely based on definitions. All numbers would need to be defined in a math dictionary. Mathematical operations would need to be in the form of a table where you look up the answer given a pair of numbers. While other systems can generate new numbers from the base symbols using an algorithm, no algorithm would be possible in ‘base infinity’. Logic, as you have described, would not apply.

As far as I can see, the logical operators only work for base 2, where 0 and 1 correspond to the logical values ‘true’ and ‘false’. How would AND and OR and XOR work with other bases without doing a conversion to base 2 somewhere?

???

Carrying is entirely logical. The representation of the number is what is being logically constructed. Carrying is what fills the higher order digit space.

All of mathematics other than chosen conventions is entirely logic with the one exception of absolute zero quality.

Absolute infinite is a square circle.
1 / “square circle” is not logical.
1 / “absolute infinity” is also not logical
but
absolute zero quality = 1 / “absolute infinity”
The inverse of a square circle is a round square.

…and Hewitt’s hyperreals cover the “base infinity” issues.

I would argue that it is reasonable, but not logical. It’s reasonable to allow the quantity to be completely represented in some way, for any non-infinite number base that requires “carrying”, but the reason why we choose carrying and number colomns (of increasing orders of magnitude according to the number base being used), rather than anything else, is aesthetic. It makes reasonable sense but is not the single necessary form of presentation that must be arrived at by using pure logic only.

I’m not saying it would be a practical number base. It’s only a theoretical one anyway, which I only used to demonstrate my point that “carrying” isn’t a fundamental aspect of mathematics. As such, logic can underlie mathematics without “carrying” needing to be entirely logical. It’s just something that happens to partially involve logic, through the logical AND operation, when it is implemented. The rest is just presentation.

Perhaps you’re forgetting that the numbers themselves are just symbols. The quantities are what they denote, regardless of what symbol(s) you use, and the foundation of quantity is in the difference between 0 and 1, which is a matter of logic - notably in the XOR operator. XOR essentially founds the concept of change: either combination of different digits returns true (change), and either combination of the same digits returns false (no change). AND determines which of these combinations also results in an increase in quantity beyond the scope of the current number(s) of 0s and 1s. This is all purely logical. The “bit-shifting” (or “carrying” in any number system) is the aesthetic element. All of the resulting symbols (numbers) and their combinations can be denoted in all sorts of different number bases, but they are the same quantity. This is why all the numbers even in “base infinity” would be ultimately founded on this same logic, just with alternative representation of these same quantities.

This should also answer your question:

How do I use XOR and AND when I am adding 5 sticks and 3 sticks?

How do I use XOR and AND with the symbols ‘5’ and ‘3’?

I still don’t get that part. The logical operators only only seem to work when there is a binary representation of quantities. And even in that case, the concept of ‘carrying’ makes it feel very artificial.

XOR and AND functions are Binary tools to use on binary representations, thus they produce binary results. The language (or representation of the concepts) with which you choose to represent those results has nothing to do with the logic used to form them.

…and a carry function is merely another AND gate (been there, done that, literally).