Questions tagged [non-deterministic]

Nondeterminism refers either to a computing system where the result may be one of many specified results or to a theoretical construct in which a computing system is allowed to try many options in parallel to search for a result.

Nondeterminism has several meanings in computing. In theoretical CS, nondeterministic computations are computations that have multiple options specified at various points and allows the computing machine to choose any of them. In programming, a nondeterministic computation is one where the result may vary from run to run due to factors such as thread timing or values from external devices.

238 questions
15
votes
1 answer

Why is the non-deterministic choice function in Curry's std lib not defined straightforwardly but rather with a helper 2-argument function?

Consider a function choose in Curry programming language with the specification that "(choose xs) non-deterministically chooses one element from the list xs". I'd implement it straighforwardly through two alternative non-deterministic rules: choose…
15
votes
2 answers

Has the notion of 'semidet' in Prolog been settled?

Being new to Prolog, I came across a very interesting discussion that happened in late 2012. What I noticed was that there were, at the time, two notions of 'semidet' in Prolog community, namely: A computation that succeeds at most once. A…
15
votes
4 answers

Nondeterminism for infinite inputs

Using lists to model nondeterminism is problematic if the inputs can take infinitely many values. For example pairs = [ (a,b) | a <- [0..], b <- [0..] ] This will return [(0,1),(0,2),(0,3),...] and never get around to showing you any pair whose…
Chris Taylor
  • 46,912
  • 15
  • 110
  • 154
13
votes
3 answers

Is C floating-point non-deterministic?

I have read somewhere that there is a source of non-determinism in C double-precision floating point as follows: The C standard says that 64-bit floats (doubles) are required to produce only about 64-bit accuracy. Hardware may do floating point…
Lucas Membrane
  • 359
  • 2
  • 7
13
votes
2 answers

Can I model a list of successes with short circuiting failure via the composition of applicative functors?

The user 'singpolyma' asked on reddit if there was some general structure underlying: data FailList a e = Done | Next a (FailList a e) | Fail e A free monad was suggested, but I wondered if this could be modeled more generally via applicative…
ocharles
  • 6,172
  • 2
  • 35
  • 46
12
votes
8 answers

Can a multi-threaded program ever be deterministic?

Normally it is said that multi threaded programs are non-deterministic, meaning that if it crashes it will be next to impossible to recreate the error that caused the condition. One doesn't ever really know what thread is going to run next, and…
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
12
votes
12 answers

Sources of non-determinism

My supposedly deterministic program produces one of a few slightly different outputs on different runs. The input, compiler and computer are unchanging. I'm not sure which output is right because it always looks reasonable. Besides a stray call to…
zoo
  • 1,901
  • 1
  • 17
  • 25
12
votes
2 answers

Deterministic python script behaves in non-deterministic way

I have a script which uses no randomisation that gives me different answers when I run it. I expect the answer to be the same, every time I run the script. The problem appears to only happen for certain (ill-conditioned) input data. The snippet…
mwmwm
  • 195
  • 1
  • 12
10
votes
7 answers

Alter SQL Function Referenced by Computed Column

If you set up a table's column to be a computed column whose Formula calls a Function, it becomes a pain to change that underlying Function. With every change, you have to find every single column whose Formula that references the Function, remove…
9
votes
3 answers

Creating Nondeterministic functions in SQL Server using RAND()

After a bit of searching and reading the documentation, it's clear that you can write user defined functions in SQL Server that are marked as either deterministic or nondeterministic depending on which built-infunctions are used within the…
BG100
  • 4,481
  • 2
  • 37
  • 64
8
votes
2 answers

Prolog : avoid redundant choice points (non-determinism) with and without cut operator

Firstly, I have read all other posts on SO regarding the usage of cuts in Prolog and definitely see the issues related to using them. However, there's still some unclarity for me and I'd like to settle this once and for all. In the trivial example…
SND
  • 1,552
  • 2
  • 16
  • 29
8
votes
3 answers

Seeded Python RNG showing non-deterministic behavior with sets

I'm seeing non-deterministic behavior when trying to select a pseudo-random element from sets, even though the RNG is seeded (example code shown below). Why is this happening, and should I expect other Python data types to show similar…
Amac26629
  • 83
  • 3
8
votes
10 answers

Why is malloc really non-deterministic? (Linux/Unix)

malloc is not guaranteed to return 0'ed memory. The conventional wisdom is not only that, but that the contents of the memory malloc returns are actually non-deterministic, e.g. openssl used them for extra randomness. However, as far as I know,…
Oleg2718281828
  • 1,039
  • 7
  • 17
7
votes
4 answers

In C++ and C# are multiple condition checks performed in a predetermined or random sequence?

Situation: condition check in C++ or C# with many criteria: if (condition1 && condition2 && condition3) { // Do something } I've always believed the sequence in which these checks are performed is not guaranteed. So it is not necessarily first…
User
  • 30,403
  • 22
  • 79
  • 107
7
votes
1 answer

Smuggling `self` out of a `deinit`

What happens if I smuggle self out of my deinit, by assigning it to some external strong reference? This code below is clearly not well formed: class C: CustomStringConvertible { let s = "abc" var description: String { return "C(id:…
Alexander
  • 59,041
  • 12
  • 98
  • 151
1
2
3
15 16