¿Cuál es la diferencia entre no determinismo y aleatoriedad?


38

Hace poco escuché esto
"Una máquina no determinista no es lo mismo que una máquina probabilística. En términos generales, una máquina no determinista es una máquina probabilística en la que no se conocen las probabilidades de transiciones".

Siento como si entendiera el punto, pero realmente no. ¿Podría alguien explicarme esto (en el contexto de las máquinas o en general)?

Edición 1:
Solo para aclarar, la cita estaba en el contexto de un autómata finito, pero la pregunta también tiene sentido para las máquinas de Turing, ya que otros han respondido.

Además, escucho a la gente decir: "... entonces elijo el objeto x del conjunto de manera no determinista". Solía ​​pensar que significaban "al azar". De ahí la confusión.


55
In computer science, people occasionally use the term "deterministic" to emphasise that an algorithm is not randomised. Hence the confusion: deterministic means non-randomised, but non-deterministic does not mean randomised.
Jukka Suomela


This question leads me to this corner of SE...
Troy Woo

Respuestas:


27

Es importante entender que los informáticos usan el término "no determinista" de manera diferente a como se usa típicamente en otras ciencias. Una TM no determinista es en realidad determinista en el sentido de la física, es decir, una NTM siempre produce la misma respuesta en una entrada dada: siempre acepta o siempre rechaza. Un TM probabilístico aceptará o rechazará una entrada con cierta probabilidad, por lo que en una ejecución podría aceptar y en otra podría rechazar.

Más detalladamente: en cada paso del cálculo realizado por una NTM, en lugar de tener una sola regla de transición, hay varias reglas que se pueden invocar. Para determinar si la NTM acepta o rechaza, observe todas las ramas posibles del cálculo. (Entonces, si hay, por ejemplo, exactamente 2 transiciones para elegir en cada paso, y cada rama de cálculo tiene un total de N pasos, entonces habrá 2N total de ramas para considerar). Para una NTM estándar, se acepta una entrada si alguna de las ramas de cómputo acepta.

This last part of the definition can be modified to get other, related types of Turing machines. If you are interested in problems that have a unique solution, you can have the TM accept if exactly one branch accepts. If you are interested in majority behavior, you can define the TM to accept if more than half of the branches accept. And if you randomly (according to some probability distribution) choose one of the possible branches, and accept or reject based on what that branch does, then you've got a probabilistic TM.


Kurt, can you please explain how the 2^N figure was arrived at. If for every branch there are 2 possibilities and there are N stages like that to reach the solution wouldn't that make it 2^(N+1)-1. I am trying to think of it like a graph and I could be wrong. Could you please explain how you arrived at the 2^N number. Thank you.
Gangadhar

Bueno, si representa el cálculo como un árbol, con la raíz representando la configuración inicial como paso 0, luego de N pasos tiene 2 ^ N hojas, y lo que llamo una rama es una ruta desde la raíz hasta una hoja. Es cierto que tendrá 2 ^ (N + 1) -1 nodos totales, que representan todas las configuraciones posibles en algún momento de la computación. ¡Espero que mi terminología esté bien!
Kurt

Todas las ciencias usan la misma definición de no determinismo unificada en el concepto de entropía ilimitada. Los resultados impredecibles en todas las ciencias se deben a la incapacidad de enumerar a priori todas las salidas posibles de un algoritmo (o sistema) porque acepta estados ilimitados, es decir, clase de complejidad NP. Especificar una entrada particular para observar si se detiene y señalar que el resultado es idempotente es equivalente en otras ciencias a mantener constante el resto de la entropía del universo mientras se repite el mismo cambio de estado. La computación permite este aislamiento de entropía, mientras que las ciencias naturales no.
Shelby Moore III

1
@ShelbyMooreIII No. Usted ha entendido mal el concepto de no determinismo que aparece en la informática.
David Richerby

@DavidRicherby lo siento, David. Ve al otro hilo y verás que te he refutado rotundamente. Puedes intentar refutar la lógica que he presentado allí. Simplemente afirmar sin pruebas y explicaciones no te da ninguna verdad.
Shelby Moore III

18

En el contexto de las máquinas de Turing, "no determinista" realmente significa "paralelo". Un algoritmo aleatorio puede explorar aleatoriamente las ramas del árbol de cómputo de una máquina de Turing no determinista, pero una máquina de Turing no determinista puede explorarlas -todas- al mismo tiempo, que es lo que le da su poder.

En otros contextos (no puedo decir por su cita si está hablando de Turing Machines), un algoritmo aleatorio podría estar utilizando la aleatoriedad intencionalmente, mientras que un algoritmo que desea ser determinista podría terminar exhibiendo no determinismo debido a un error ...

In response to your edit, when people say "choose an element from a set non-deterministically", its possible they might just mean "randomly". However, it is also possible that they mean "magically choose the -right- element from the set". A common way to view non-deterministic turing machines is that they first magically "guess" a solution, and then check its correctness. Of course, you can view this magic guess as just the result of checking all possibilities in parallel.


Related to "magically choose the right element": When the word 'nondeterminism' is used in this sense people sometimes qualify it with 'angelic'. There's also 'demonic' nondeterminism. (Still, as you say, the essence is that stuff happens in parallel.)
Radu GRIGore

13

There are several different contexts where “deterministic”, “random” and “non-deterministic” mean three different things. In contexts where there are multiple participants, such as security and concurrency, the intuition is often something like:

  • deterministic means “I get to choose”

  • non-deterministic means “someone else gets to choose”

  • random means “no one gets to choose”

A few examples:

  1. [concurrency, random] Consider a networking protocol such as Ethernet, where multiple nodes can send a message at any time. If two nodes send a message at very close intervals, there is a collision: the messages overlap and are unreadable. If a collision happens, both nodes must try sending the messages again later. Imagine you're writing the specification of Ethernet. How do you specify the delay between retries? (The delays had better be different or there'll be a collision again!)

    • deterministic: define an algorithm that both nodes must use. This is not done for Ethernet because in order to give different results, the algorithm would have to privilege one node over the other (for any given message content), and Ethernet avoids doing that.

    • non-deterministic: let each implementer decides. This is no good because the implementers on both nodes may choose the same algorithm.

    • random: each node must select a delay value at random (with a specified distribution). That's how it works. There is a small probability that the two nodes choose the same delay and there's another collision, but the probability of success increases asymptotically towards 1 as the number of retries increases.

  2. [concurrency, nondeterministic] You write a concurrent algorithm. In a specific situation, there can be a deadlock. How can you prevent the deadlock from occurring? That depends on what kind of scheduling your concurrency environment has.

    • deterministic: the scheduler always switches between threads at certain well-defined points, e.g. only when the code yields explicitly. Then you simply arrange for the threads not to yield at bad times.

    • random: the scheduler is guaranteed to switch threads randomly. Then a viable strategy can be to detect the deadlock if it occurs, and restart the algorithm from the start.

    • non-deterministic (most schedulers are like this): you don't know when the scheduler will switch between threads. So you really have to avoid the deadlock. If you tried to detect and restart like in the random case, you run the risk that the scheduler will schedule your threads in exactly the same way again and again.

  3. [security, random] You write an application with a password prompt. How do you model an attacker?

    • deterministic: the attacker always tries the same passwords. That's not a useful model of an attacker at all — attackers are not predictable by definition.

    • nondeterministic: the attacker knows your password somehow and enters it. This shows the limitation of passwords: they must be kept secret. If your password is secret, this attacker is unrealistic.

    • random: the attacker tries passwords at random. In this case, this is a realistic model of attacker. You can study how long it would take for the attacker to guess your password depending on what random distribution he uses. A good password is one that takes long for any realistic distribution.

  4. [security, nondeterministic] You write an application, and you worry that it may have a security hole. How do you model an attacker?

    • deterministic: the attacker knows everything you know. Again, that's not a useful model of an attacker.

    • random: the attacker throws random garbage and hopes to make your program crash. That can be useful sometimes (fuzzing), but the attacker might be more clever than that.

    • non-deterministic: if there's a hole, the attacker will find it eventually. So you'd better harden your application (raise the intelligence requirement for the attacker; note that since it's an intelligence requirement rather than a computation requirement, this counts as non-deterministic until AI comes along), or better, prove that there is no security hole and therefore such an attacker doesn't exist.


Correction revolves around the missing word prove in your statements: Deterministic is “I can prove I am choosing (i.e. fully specifying the result which terminates on my input in the P complexity class)”, Nondeterministic is “I can't prove I am choosing (i.e. proof of termination is undecideable in NP complexity class)”, and random is “I can prove that I get to choose ½ of the time (i.e. ZPP complexity class)”.
Shelby Moore III

@ShelbyMooreIII I don't understand where you're getting at. Determinism is not, in general, about proving that something is indeed deterministic, or about some problem being in a certain complexity class. Furthermore, complexity classes aren't about the system itself being able to prove something about its determinism (most problems don't even have a notion of proving inside the system!).
Gilles 'SO- stop being evil'

Nondeterminism is always the result of unbounded entropy, thus another way of say this is that I can't prove I am choosing the result (because I can't prove my choice will terminate). All I can do is try, which means I must enumerate every choice I want to make before I know if it will terminate. Whereas with determinism, I can prove I choose the result bcz it must terminate. Randomization is where I can prove I only get to choose a random amount of the time because some of the entropy is not under my control. If I know the amount not under my control, I can prove precise the statistics of.
Shelby Moore III

Agreed it is not the complexity class NP that gives rise to nondeterminism, rather NP is a dependency. Turing-complete is an example of nondeterminism. Plz see my comment under Kurt's answer, as well my answer on the related thread. My point to you is about what precisely is proven & unpredictable for the terms deterministic, nondeterministic, & random. It is all about the entropy (& not about the bass)
Shelby Moore III

9

An example to make things clearer:

Say you have to pick a door to open among 10000 doors (say there is a prize behind one of the doors). Choosing randomly means you would choose one out of the 10000 doors and enter it. If there is a prize behind only one door, you will most probably not find it. A non-deterministic machine would enter all 10000 doors simultaneously. If there is a prize anywhere, the non-deterministic machine will find it.


8
Alternately, a non-deterministic machine would only open one door, but it would always be the right one.
Jeffε

3
Yes, exactly. That would be the "luckiest possible guesser" characterization of non-deterministic machines.
Robin Kothari

@RobinKothari:"Alternately, a non-deterministic machine would only open one door, but it would always be the right one".And "A non-deterministic machine would enter all 10000 doors simultaneously"?--Which one is correct?
tanmoy

3
@tan: Both are correct interpretations. Unlike deterministic and randomized machines, which are physically realizable, a non-deterministic machine is an imaginary object. So you can imagine it however you like, the point is that it always finds the right door. Maybe it's the best guesser, maybe someone secretly told the machine where the prize was, maybe it just checks all doors magically, etc.
Robin Kothari

5

Definition of Non-Deterministic Turing Machine: A Turing machine which has more than one next state for some combinations of contents of the current cell and current state. An input is accepted if any move sequence leads to acceptance.

Definition of Probabilitistic Turing Machine: A nondeterministic Turing Machine (TM) which randomly chooses between available transitions at each point according to some probability distribution.

Probabilistic Turing Machine is a Non-Deterministic Turing Machine that can make mistakes.

PPT I found helpful.


5

I prefer the following definition:

There is no such thing as a probabilistic Turing machine! There are only deterministic machines (in every step a single possible follow-up state) and non-deterministic machines (in every step a constant number of possible follow-up states).

Non-determinism works as follows: Consider a non-deterministic machine which halts on each input (possible if problem is decidable), where each possible computation uses the same number of steps, and where each step has exactly 2 possible follow-up states (both not really a restriction). As in the definition of NP, a nondeterministic machine accepts an input if there exists at least one possible accepting computation, and it rejects the input if all computations reject.

Randomness comes into play as follows: You can choose uniformly at random a single path of computation from such a non-deterministic machine as stated above. You accept if and only if this randomly chosen path of computation accepts. This randomized approach "solves" your problem if, with overwhelming probability, this answer is correct.

So the difference between non-determinism and randomness is whether you are looking for the mere existence of a correct Yes-answer (and reliable No-answers), or whether you are interested in solving your problem "most of the time".


-1 Errors in your first paragraph. Probabilistic Turing machines exist and sample a coin toss from external entropy, c.f. the ZPP complexity class. Non-determinism has an unbounded not a finite number of alternative states, c.f. the NP complexity class. Determinism is the P complexity class and you did get that correct.
Shelby Moore III

I think you are misreading my answer. I argue that you do not need any different machine (with coin-tossing or other capabilities) than an "ordinary" non-deterministic TM to define probabilistic complexity classes. You may just as well make use of an NTM and just use a different definition of acceptance, namely a definition where "most computational paths accept the input", as opposed to "there exists at least a single accepting path for the input".
MRA

3

To keep it simple: a non-deterministic machine can optimally choose the outcome of each coin flip (if you like the analogy with a probabilistic machine). You might also imagine that it executes the computation for each outcome of the coin flip in parallel.


1

Stepping backwards during debugging as a motivation for non-determinism

The notion of a non-deterministic machine suggests itself when you wish to step backward (in time) through a program while debugging. In a typical computer, each step modifies only a finite amount of memory. If you always save this information for the previous 10000 steps, then you can nicely step both forward and backward in the program, and this possibility is not limited to toy programs. If you try to remove the asymmetry between forward steps and backward steps, then you end up with the notion of a non-deterministic machine.

Similarities and differences between non-determinism and randomness

While probabilistic machines shares some characteristics with non-deterministic machines, this symmetry between forward steps and backward steps is not shared. To see this, let's model the steps or transitions of a deterministic machine by (total or partial) functions, the transitions of a non-deterministic machine by (finite) relations, and the transitions of a probabilistic machine by (sub)stochastic matrices. For example, here are corresponding definitions for finite automata

  • a finite set of states Q
  • a finite set of input symbols Σ
  • deterministic: a transition function δ:Q×ΣQ
  • non-deterministic: a transition function Δ:Q×ΣP(Q)
  • non-deterministic: a transition relation ΔQ×Σ×Q
  • non-deterministic: a function Δ:ΣP(Q×Q)
  • probabilistic: a function δ:ΣssM(Q)

Here P(Q) is the power set of Q and ssM(Q) is the space of substochatic matrices on Q. A right substochastic matrix is a nonnegative real matrix, with each row summing to at most 1.

There are many different reasonable acceptance conditions

The transitions are only one part of a machine, initial and final states, possible output and acceptance conditions are also important. However, there are only very few non-eqivalent acceptance conditions for deterministic machines, a number of reasonable acceptance conditions for non-deterministic machines (NP, coNP, #P, ...), and many possible acceptance conditions for probabilistic machines. Hence this answer focuses primarily on the transitions.

Reversibility is non-trivial for probabilistic machines

A partial function is reversible iff it is injective. A relation is always reversible in a certain sense, by taking the opposite relation (i.e. reversing the direction of the arrows). For a substochastic matrix, taking the transposed matrix is analogous to taking the opposite relation. In general, the transposed matrix is not a substochastic matrix. If it is, then the matrix is said to be doubly substochastic. In general PPTPP, even for a doubly substochastic matrix P, so one can wonder whether this is a reasonable notion of reversibility at all. It is reasonable, because the probability to reach state B from state A in k forward steps is identical to the probability to reach state A from state B in k backward steps. Each path from A to B has the same probability forward and backward. If suitable acceptance conditions (and other boundary conditions) are selected, then doubly substochastic matrices are an appropriate notion of reversibility for probabilistic machines.

Reversibility is tricky even for non-deterministic machines

Just like in general PPTPP, in general RRopRR for a binary relation R. If R describes a partial function, then RRopR=R and RopRRop=Rop. Even if relations P and Q should be strictly reversible in this sense, this doesn't imply that PQ will be strictly reversible too. So let's ignore strict reversibility now (even so it feels interesting), and focus on reversal by taking the opposite relation. A similar explanation like for the probabilistic case shows that this reversal works fine if suitable acceptance conditions are used.

These considerations also make sense for pushdown automata

This post suggests that one motivation for non-determinism is to remove that asymmetry between forward steps and backward steps. Is this symmetry of non-determinism limited to finite automata? Here are corresponding symmetric definitions for pushdown automata

  • a finite set of states Q
  • a finite set of input symbols Σ
  • a finite set of stack symbols Γ
  • deterministic: a partial transition function δ:Q×Γ×(Σ{ϵ})Q×Γ{0,2} such that δ(q,γ,ϵ)ϵ only if δ(q,γ,σ)=ϵ for all σΣ
  • non-deterministic: a transition function Δ:Q×Γ{0,1}×(Σ{ϵ})P(Q×Γ{0,1})
  • non-deterministic: a transition relation ΔQ×Γ{0,1}×(Σ{ϵ})×Q×Γ{0,1}
  • non-deterministic: a function Δ:Σ{ϵ}P(Q×Γ{0,1} × Q×Γ{0,1})
  • probabilistic: a function δ:Σ{ϵ}ssM(Q×Γ{0,1}) such that δ(ϵ)+δ(σ)ssM(Q×Γ{0,1}) for all σΣ

Here ϵ is the empty string, Γ{0,2}={ϵ}Γ(Γ×Γ) and Γ{0,1}={ϵ}Γ. This notation is used because it is similar to Γ, which is used in many definitions for pushdown automata.

Diagramed verification of reversal for (non)advancing input and stack operations

An advancing input operation with bΣΣ{ϵ} gets reversed as follows

a|bca|bcab|c
a|bcab|cab|c
c|bac|bacb|a

A non advancing input operation with ϵΣ{ϵ} that doesn't read any input can be reversed

a|bca|bca|bc
a|bca|bca|bc
cb|acb|acb|a

Here is a diagram of an advancing input operation whose reversal would look bad

a|bca|bcab|ca|bcab|cab|cc|bac|bacb|a

For a stack operation (s,t)Γ{0,1}×Γ{0,1}, there are the three cases (s,t)=(a,ϵ), (s,t)=(ϵ,a), and (s,t)=(a,b). The stack operation (a,ϵ) gets reversed to (ϵ,a) as follows

abab|b
ab|bb
b|bab

The stack operation (a,b) gets reversed to (b,a) as follows

acacbc
acbcbc
bcbcac

A generalized stack operation (ab,cde)Γ×Γ would be reversed to (cde,ab)

abfabfcdef
abfcdefcdef
cdefcdefabf

Reversibility for Turing machines

A machine with more than one stack is equivalent to a Turing machine, and stack operations can easily be reversed. The motivation at the beginning also suggests that reversal (of a Turing machine) should not be difficult. A Turing machine with a typical instruction set is not so great for reversal, because the symbol under the head can influence whether the tape will move left or right. But if the instruction set is modified appropriately (without reducing the computational power of the machine), then reversal is nearly trivial again.

A reversal can also be constructed without modifying the instruction set, but it is not canonical and a bit ugly. It might seem that the existence of a reversal is just as difficult to decide as many other question pertaining to Turing machines, but a reversal is a local construction and the difficult questions often have a global flavor, so pessimism would probably be unjustified here.

The urge to switch to equivalent instruction sets (easier to reverse) shows that these questions are less obvious than they first appear. A more subtle switch happened in this post before, when total functions and stochastic matrices were replaced by partial functions and substochastic matrices. This switch is not strictly necessary, but the reversal is ugly otherwise. The switch to the substochastic matrices was actually the point where it became obvious that reversibility is not so trivial after all, and that one should write down details (as done above) instead of taking just a high level perspective (as presented in the motivation at the beginning). The questions raised by Niel de Beaudrap also contributed to the realization that the high level perspective is slightly shaky.

Conclusion

Non-deterministic machines allow a finite number of deterministic transitions at each step. For probabilistic machines, these transitions additionally have a probability. This post conveys a different perspective on non-determinism and randomness. Ignoring global acceptance conditions, it focuses on local reversibility (as a local symmetry) instead. Because randomness preserves some local symmetries which are not preserved by determinism, this perspective reveals non-trivial differences between non-deterministic and probabilistic machines.


Are you assuming that non-deterministic transitions are one-to-many relations? What if two different configurations can transition to a common configuration, among others? — It seems to me that the difference between randomness and nondeterminism is not reversibility (neither are, without further constraint), but rather how one attributes significance to branches according to the result: perfectly democratic for randomness, or preferentially sensitive to "yes" or "no" answers for nondeterminism.
Niel de Beaudrap

@NieldeBeaudrap I assume that non-deterministic transitions are "arbitrary" relations (one for each symbol from the input alphabet). I can reverse them, swap start and end state, and get again a non-deterministic finite state machine, which accepts the reversed input string. This is what I call "run the machine backwards in time". (The machine accepts if there is at least one path from start to end state in the non-deterministic case, and this condition doesn't change when reversing time.) Please try to convince yourself that this works at least for a finite state machine.
Thomas Klimpel

So, you refer to the dual of the machine. For NFAs this seems a meaningful notion of reversibility. It's also clear that the dual of an NTM (with a single accept state) is another NTM, but I would hesitate to say that it is the same machine being run in reverse. Does your answer amount just to "Nondeterminism allows you to obtain closure under duals, random (and deterministic) machines aren't"?
Niel de Beaudrap

@NieldeBeaudrap My idea is certainly to run backwards in time, but I know that this isn't satisfied perfectly (because the conditions for a generalized inverse of an inverse semigroup are not satisfied). But what I tried to convey is that random (and deterministic) machines don't always allow this sort of reversal.
Thomas Klimpel


0

In the context of Turing Machines (TMs) and automata theory, a non-deterministic machine is one in which any instantiation of the machine which accepts is fine. In this sense, it is like running multiple deterministic machines in parallel and take the output of any instances that accept the input. In fact there is a (deterministic) algorithm to transform any non-deterministic automaton (with n states) into an equivalent deterministic one (with 2n states, exponential) by considering equivalence classes of states, no matter if the algorithm implemented in the machine involves randomisation or probabilities (see below).

But if the algorithm implemented in the machine, involves randomisation or probabilities (intrinsic in the algorithm), then it is a randomised (or probabilistic) machine.

In general, it is always possible to remove non-determinism from a machine and construct a deterministic equivalent (see algorithm above), but the same cannot be done (in general) to remove randomisation (in the context of the above) because it is intrinsic to the algorithm implemented.

Note that in the light of the above, both a deterministic machine and a non-deterministic machine can be probabilistic if the algorithm (involved) uses randomisation (or probabilities) in this way.

To sum up, non-determinism in automata (in this context) refers to classes of similar automata, while randomisation or probabilistic machines refer to the (intrinsic application of randomisation in the) actual algorithms implemented by these automata.

Al usar nuestro sitio, usted reconoce que ha leído y comprende nuestra Política de Cookies y Política de Privacidad.
Licensed under cc by-sa 3.0 with attribution required.