# 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](/developing-truebit-tasks/how-to-create-function-tasks/key-concepts/task-instrumentation.md) the [WebAssembly](/developing-truebit-tasks/how-to-create-function-tasks/key-concepts/webassembly.md) 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devs.truebit.io/developing-truebit-tasks/how-to-create-function-tasks/key-concepts/determinism.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
