r/AskComputerScience • u/greatrudini • 3d ago
ELI5: If AI is non-deterministic, how is it able to solve complex math proofs?
Admittedly, I'm not sure if I'm even phrasing the question correctly, apologies if I am not. But I hope it makes enough sense...?
Thank you!
Edit: By AI, i meant LLM. Apologies, y'all are really smart. LOL! Just came here to learn.
37
Upvotes
44
u/Te-We 3d ago edited 3d ago
Apart from the other correct answers, you can also consider the following: A human mathematician is random in almost the same way. If you give a skilled human mathematician a moderately difficult task, they will sit down, scribble some formulas and with a 99,9% they will end up with the correct solution. However, on the way they might scratch their head at random times and there might be a 5% probability that they spill their coffee. Sometimes they might have to add two numbers as an in-between step. Probably they can do it, but with with 10% probability they will mess up. But if the mathematician messed up, they can simply double-check and re-do the computation.
20
u/dontwantgarbage 3d ago
I mean, humans are non-deterministic and we solve all sorts of complex problems.
If I give you a map and say “color this using only four colors so that no two adjacent countries have the same color”, and then give you the exact same map tomorrow, there’s a good chance that the two colorings will be different.
5
u/pdpi 3d ago
It doesn't "solve" proofs, it writes them.
Your initial setup is the Lean proof assistant, and a problem statement written in Lean that you write yourself. You then throw stuff at Lean and ask it if that is a proof for that statement you're trying to prove.
From that initial setup, you "just" need to find a way to generate that "stuff" that could be a proof. You could use dice to create random strings of text, and, given enough time, you might actually get lucky and generate a valid proof randomly like that. While LLMs are still random, their randomness is much more targeted.
8
u/__aSquidsBody__ 3d ago
The non determinism is bounded, for all intents and purposes. If you ask an LLM to write you an essay explaining why George Washington wore a wig, it probably isn’t going to output a chocolate chip cookie recipe. You can predict that with certainty even though you cannot predict the exact words it’ll pick for the George Washington essay.
As for the math, i am not an AI employee or researcher, so i don’t know for sure, but i believe there is behavior similar to internal looping, i.e AI produces an answer, but then it re-reads its answer and edits it, and re-reads it again, and so on. Theres “reasoning” in there.
I also believe that the language models are rewarded thinking mathematically. What I mean is that the weights are actively edited if they get a math problem right during training.
Edit: wording
7
u/VirtuteECanoscenza 3d ago
I would argue that it should be easier for it to find proofs being non deterministic.
I mean:
The non deterministic nature of the model may help in trying out paths that a human would disregard or not see.
So a little bit of "hallucination" is good to cover the search space and exit local minima
4
u/0bArcane 3d ago
Humans are not-deterministic and we can solve complex math problems.
LLMS can call deterministic tools (like lean) to verify the proof it came up with. That's done through what is called a "harness", sort-of operating system for an LLM. A harness (simplified) is a loop around an LLM that allows the LLM to use its output to call external functions (e.g. open a file, load a webpage, execute a program etc).
Stochastic algorithms can get deterministic results. For example, some quick sort implementations choose the pivot element at random. That randomness affects runtime, but the result is always a sorted list. No matter which path was taken.
I hope this answers at least part of your questions. I am honestly not sure what exactly you are asking.
3
u/tango_telephone 3d ago
LLMs are deterministic, we introduce randomness on purpose via an entropy parameter. When LLMs work through a formal mathematical proof, they are using a tool like LEAN to formalize the proof. LEAN is like a programming language for writing math proofs.
In the same way LLMs excel at writing code, especially in strict languages that catch their errors, LLMs are also good at writing math proofs. It is the same process.
2
u/peter9477 3d ago
Is there any reason to assume randomness is required in order to "solve a complex math proof"?
2
u/KnirpJr 3d ago
It would be easier to answer this question if you could explain where the confusion comes from.
But stochastic algorithms find exact answers to things all the time, you yourself could probably come up with a toy example, say an algorithm incorporating randomness to sort a list.
If by AI you mean an LLM, how exactly they work so well and can find such solutions is a mystery beyond just randomness, one can come up with a great many advantages Llms have and learn about how they work, but their particular effectiveness doesn’t have a satisfying answer as far as I know.
Other automated proof systems use many other interesting techniques, heuristic searches for example tend to benefit from some randomness, being able to take different “paths” over multiple runs or “shaking” their way out of local extrema.
As a general principle randomness doesn’t imply structureless or completely blind, look into some mathematical statistics and probability theory and indeed at transformers themselves.
3
u/Plus_Comment6547 3d ago
The same way that humans are able to solve complex math-proofs despite being non-deterministic
1
u/TheAncientGeek 3d ago
What would be the problem? Do you think everything is solvable by a detrministic algorithm.
1
u/r2k-in-the-vortex 3d ago
No it is deterministic, exact same input will give the exact same output every time. What you can't expect from LLM is a "correct" answer to your prompt. It's a text predictor at the end of the day and predictions are never ground truth.
But you don't need LLM to reliably output correct proofs, it's sufficient to sometimes output correct steps of proofs, if you have a external proof checker to validate each step and reject incorrect steps. Lean is completely conventionally programmed system to check proofs, you just get LLM to manipulate that to produce effectively proofs.
1
u/OppieT 3d ago
Maybe the LLM asks Wolfram Alpha for answers to math problems?
1
u/Ordinary_Variable 3d ago
I wonder if very precise prompts can nullify the non-deterministic logic in the loop. I could write up an equation. A non-deterministic function given a very carefully crafted input could give a deterministic output.
The prompt would have to depend on the specific function. In this case, the specific model you are using. The same prompt given to a different model wouldn't necessarily give a deterministic reply.
1
u/tmanred 3d ago
Its non determinism is its strength. If it was deterministic it would search for the same wrong answer every time. Because it is non deterministic it can “randomly” with some guardrails search different options and see if they work or not. It needs that non deterministic ability to even have different paths to try.
As others have said humans are also non deterministic. Think about how you think through a problem. I bet if you really observe yourself closely you will see yourself think up “wrong” answers all the time but quickly discard them until you find the right idea.
If you ever have a thought process like “Will this work? No. Will that work? No. How about this? Yes that will work.” Then you have basically done a non deterministic search in your brain without realizing it.
1
u/an0th3rbrick 3d ago
it's a bit like brute-forcing a password. because you can check the proof you can keep coming up with "predictions" and then check them. obviously it's not completely random because the LLM is trained on relevant math and has a human guiding it. it allows for generating and checking ideas way faster than a human.
1
u/Toothpick_Brody 3d ago edited 3d ago
Lean. It’s because of Lean. I think some of the answers on here are missing the point. Without a theorem prover like Lean, LLMs go astray and do incorrect math, due to this non-determinism you mentioned (there is both non-determinism across separate runs, but also during tokenization of words; two identical words may get different tokenizations). But their non-determinism is also their strength. It’s what makes them so versatile.
Lean allows an LLM to convert its non-deterministic, informal output into formal math. A formal language is one that is unambiguous, like a programming language or mathematical logic. An informal language is basically any other kind of communication, including regular LLM output. Informal languages aren’t appropriate for rigorous math because you can use them to make ambiguous arguments.
Now, technically, you could call an LLM deterministic since everything you run on a computer is eventually deterministic. But LLMs are not deterministic in the same way a compiler (for example) is, so I believe that misses the point.
1
u/Embarrassed_Range356 3d ago
LLMs are deterministic in the sense that Same input -> same output every time unless you intentionally change the parameters so that it doesnt pick the next likely token.
Whats probabilistic is exactly that, its still picking the next token on what is most likely to be correct. But because it can review its outputs, it can go into a loop of seeing what was tried, what happened, and iterating on picking the next likely approach based on data.
Id argue humans do the same thing, and there is no better alternative. Unless you alrea know how a problem is solved, you can only attempt your best approach at solving it.
Moreover, you can see basic logic and deductions as being things with 99.99999999% -100% likelihood of being true. So if the training data sees something fit if p then q, p= true then q= true for example a billion times itll learn that with such high confidence that its never going to mistake it
1
u/NomaTyx 3d ago
people have already explained that LLMs are deterministic, but non deterministic just means the output is not the same every time. For an oversimplification, there is an infinite number of correct solutions, and the randomness selects one of them at random and outputs it. The solution is still correct but the correct one was determined randomly
1
u/Vitztlampaehecatl 3d ago
Because with the existence of Lean, math can be expressed as code. Code, unlike AI, is deterministic. So what you do is you get a whole bunch of AI instances to act effectively as well-trained monkeys on very fast typewriters and have them keep writing code and checking it until they come up with a working solution.
1
u/AskRedditOG 3d ago
AI is deterministic. Not sure why you think it's not. They have pseudorandomness built into the weights to prevent them from falling into non-optimal outputs, but they're ultimately deterministic systems.
AI image generation is a prime example of this. If you use the same settings, models, and seed, you will always get the same output.
1
u/CallinCthulhu 3d ago edited 3d ago
Flip the question.
Humans are non-deterministic and can solve complex math proofs, ergo determinism is not a pre-requisite for the reasoning required.
Also LLMs are somewhat deterministic, ish, given no temperature adjustment and identical context windows they will generate the same probabilities for the next token. (Let’s ignore the floating point and hardware shenanigans that break this on occasion)
1
u/Paxtian 3d ago
At least some LLMs have the ability to recognize, "Oh, this is a deterministic problem, I might hallucinate," so they'll call an external tool or build one, if one isn't available, and use that tool to get the answer. When I learned that, i had a momentary freak out.
1
u/RandomLettersJDIKVE 3d ago
AI models being non-deterministic is kinda over stated. The transformer model itself is fully deterministic. The model outputs a sequence of word embeddings that need to be converted to words. That conversion has randomness added to it. There's a 'temperature' parameter on the model that controls how random the word choice is.
1
u/Traveling-Techie 3d ago
Humans are non-deterministic and we can do math proofs.
1
u/flat5 3d ago
I would turn the question around: why do you think non-determinism would be an impediment for solving complex math proofs?
1
u/editor_of_the_beast 3d ago
The math proofs that AI are creating are in a checkable programming language, so it doesn’t matter how they were created. They can be checked.
1
u/green_meklar 3d ago
You can ask the same thing about humans, who are also non-deterministic.
It turns out that in both cases, the system is deterministic enough to statistically clear up its own mistakes and eventually produce a correct output.
1
u/ParseTree 2d ago
the theorem prover harness - lean! the secret sauce to the monkey brain gaining zen wisdom (this is too much overselling math -- I think math should actually be considered as something that is extremely complicated conceptually in contrast to say the most complex pieces of code in the world)
LLMs produce a lot of mass gunks with the lean checking each step whether it makes "rigorous sense"
1
u/Turbulent-Sign-6067 2d ago
AI just like a human uses both trial and error together with intelligence. Not every step needs to be perfect. Errors and creativity are also conceptually related.
1
u/shadow-knight-cz 2d ago
Because of verifiable end goal like a proof in lean.
Also humans are non deterministic as well.
1
u/signeduptomuteantis 1d ago edited 1d ago
it is my assumption that the determinism is delegated to the lean compiler. but I'd rather have someone else confirm or falsify this assumption.
Which would mean that a million moneys on typewriters producing lean source gated by a deterministic checker could prove the Riemann hypothesis
1
u/ImaginaryAd2289 5h ago
Just like people doing math. You can be a bit random coming at a problem, but once you see the solution, a part of your job is to write the proof down in a totally logical, non-stochastic form. Or think of a card game. You might discard randomly among a set of cards you want to get rid of, but your actual goal is to win. And the winner will be decided by a rigid scoring rule, applied completely logically. So your actions are stochastic but the outcome is purely logical and the calculation of all the players’ scores is totally deterministic.
1
u/Gravbar 4h ago edited 4h ago
To be clear, neural networks are deterministic. LLMs are neural networks, and the non-determinism comes from the sampling. the llm runs to get the probability of the next word given context, and then when it finishes, adds that prediction to context and repeats. If it took the most probable next word at each step, it could only ever give one response, so they have it pick a random response weighted by the probabilities it predicted, which may have been tuned to encourage more or less variation from the input data. The most probable next words are still very probable given context though, and so even being non-deterministic it's still limited in how much it can vary given the context it has.
Solving the math proofs in another issue entirely. From what I'm aware of, there's a ton of hand holding that has to be done by experienced mathematicians to lead the LLM to a solution. This can include a condition that the tool outputs into LEAN which is a language for proving mathematics by compiling it. If it can't compile there's a mistake in the proof. So to some extent, if you can break down a big problem into a series of steps and ask it to solve each of the steps, providing certain possibilities for how the solution might be found for each step, and then you gave it enough time and told an agent to keep trying until the LEAN code compiles, and then after each sub problem is solved you repeat this process for the next one, you should be able to solve a more complex math problem. That said, for non-millenium prize problems, the amount of expert guidance has dropped significantly. If you have 10k agents tasked with this constantly failing to solve it by a number of methods, that continue with unlimited resources until the LEAN compiles you can prove something very complex.
1
u/CandiceWoo 3h ago
ai is not nondeterministic. its complicated
0
u/patrlim1 3d ago
LLMs are deterministic. Their output is made random through a "temperature" variable.
LLMs take the current context window of tokens, basically some number of words, and predict the likelihoods for every word they know of to be the next one. Their output is always the same for any given input. With a temperature of 0, AKA no randomization, they will always choose the most likely word. With a higher temperature they have a larger chance to choose less likely words
0
u/[deleted] 3d ago
[deleted] — view deleted comment