# Determinism

## What is Determinism?

**Determinism** **means that when you run a program or code multiple times with the same inputs and conditions, you will always get the same result.**&#x20;

### Challenges

* A program running in a Turing machine is non-deterministic by default. Given some input, it is only possible to tell if a program will end by running it firs&#x74;**.** That is known as [the halting problem](https://en.wikipedia.org/wiki/Halting_problem).&#x20;
* A program running an infinitely recursive function will consume the whole stack memory even before its infinite recursion gets noticed by the time it takes to execute.
* The way floating-point hardware is implemented can lead to inconsistencies in the task execution results.

### How Do We Manage Those Challenges?

To manage those challenges, Truebit [instruments](https://devs.truebit.io/developing-truebit-tasks/how-to-create-function-tasks/key-concepts/task-instrumentation) the [WebAssembly](https://devs.truebit.io/developing-truebit-tasks/how-to-create-function-tasks/key-concepts/webassembly) program to:&#x20;

* **Limit** the number of executed instructions (Gas metering).
* **Restrict** the available execution stack memory (Stack limit).
* **Constrain** the depth of nested calls assigned to the task execution (Call limit).

In addition to that, it also performs the following tasks:

* Replaces the the default WASI implementation with a customized WASI interface developed by Truebit.
* Replaces FPU instructions with deterministic functions created by Truebit.
