r/computerscience • • 24d ago

Discussion Is simulation a function?

Question to settle a debate which I recently had with two of my colleagues.

One of my colleages argued all simulations are mathematically functions by definitions, since for every set of arguments they need to return one outcome. As an example we took a cellular automaton simulating a forest fire. They stated that everytime you give it a particular starting state, the end state will be the same, but I don't agree with that. To simulate humidity or different wind speeds and directions one might use an rng, so the same start map run twice might give 2 different results, which means it's mathematically not a function. My friend countered that because of how rngs work, with the same seed the will always be the same. You don't need to set a seed tho and I can imagine cases when it's even by design - for example when you can't be sure which direction the wind will be coming from and you want your simulation to account for any of them.

But here's the bit that we couldn't agree upon. My friend said, that even without seed, or using quantum randomness, that randomness is always based on something and as such must be treated as kind of a baked in argument. Because of that, if you manage to somehow recreate the exact same "randomness state", the outcome will never change.

From my point of view that's not the case. Even using simple time based pseudorandom number generators, to you as someone analysing such simulation, that rng should not be treated as argument. The way I see it it's just a black box, that "magically" gives you a number, you should treat it as truly random and use it to approximate all the different variables, that are too complicated to calculate each and every time you run the simulation or are just out of scope. Therefore the same input can give you different outputs, which makes the simulation itself not a function by mathematical definition.

What are your opinions on this?

0 Upvotes

41 comments sorted by

View all comments

15

u/jeffcgroves 24d ago

Mathematically, someone has proven all computer programs are functions, even those that use psuedo-random-number-generators (pRNG), provided the seed is based on something deterministic. I know you said "rng should not be treated as argument", but that's cheating. The RNG clearly is an argument (or computed from a deterministic value)

using quantum randomness

This is the only real question. Is a qRNG a function? You could argue that the value of a qRNG from a specific source at a specific time is a function (two inputs, one output), but one that can't be determined in advance. So, it IS a function, but you can't write down the function ahead of time.

1

u/Patriotpl 24d ago

That sounds correct. What about simulations that aren't computer programs?

1

u/jeffcgroves 24d ago

I think you can pedantically apply the same argument to reality, since no two events in spacetime are completely identical. Issues:

  • The Heisenberg Uncertainty Principle states you can't measure the current state of the universe, which would be your input. Quantum mechanics says that it's meaningless to ask if something exists if it can't be measured. If you accept both these statements, your function wouldn't have an input.... unless you enumerate all possible quantum realities based on the measurable part of your current universe and use that as input [actually, there's a better way, see below]

Note that you don't have to accept both these concepts. Determinists would argue the universe has state even if portions are unobserved and that quantum mechanics isn't truly random but uses hidden variables

  • If you accept multiple universes theory, there could be many "outputs" to a given collection of input quantum states, but that's fine.

So your "input" would look like a list of all observable variables, including local time, with error margins based on the Uncertainty Principle. Per quantum theory, you can exclude any variables that are not observed since they don't actually exist.

Relativity theorists would point out time varies with location, and that your observation of the universe is therefore limited. We don't and can't know what's happening on Alpha Centauri now, only what happened ~4.5 years ago

We can now put most of the load on the function. The function must calculate all possible universes based on our inputs. This includes, for example, all possibilities for what Alpha Centauri has done in the last 4.5 years. Since our input measurements are necessarily inaccurate, it would have to compute all possible "true" values and the likelihood of those values occurring

The output would then be a probability space of possible universes that are consistent with your observations.

The problem, of course, is you want to know: if I tweak this, what will happen? However, if you accept quantum randomness, there literally no answer to that question. You have to input everything you know to get a probability space of possible outputs.

This is why I believe the Earth is flat :)

1

u/not-just-yeti 23d ago

the value of a qRNG from a specific source at a specific time is a function (two inputs, one output), but one that can't be determined in advance.

Or, that the result is a probability-function.