Asking an assumed solver questions #
This file lets a tape program ask an assumed solver for answers to a yes/no problem. Such a solver is called an oracle. The program asks about the word under the tape head, ending at the first blank. Its answer is recorded in the machine state, so later branches and loops can depend on it.
A request costs one time step and leaves the tape and head unchanged. Head moves also cost one time step. Every instruction and loop test uses fuel. The solver's own work is outside this count.
Main definitions and results #
- OracleInterface chooses distinct states for requests, yes answers, and no answers.
- queryWord reads the word being asked about.
- ask issues a request.
- interpreter supplies the rules for executing requests to the shared runner.
- execute_ask_succ describes the answer and cost of a request.
- execute_cellsAllocated counts the cells added to the recorded tape range during execution.
This interface chooses three distinct machine states for issuing a request and recording a yes or no answer.
- request : tm.State
Setting this state with an update instruction asks the solver about the word under the head.
- yes : tm.State
The interpreter sets this state when the solver answers yes.
- no : tm.State
The interpreter sets this state when the solver answers no.
The request state differs from the yes state.
The request state differs from the no state.
The yes and no states differ, so the program can distinguish the answers.
Instances For
The question is the word starting under the head and ending before the first blank.
Equations
- Algolean.Algorithms.OracleInterface.queryWord contents = match contents.head with | none => [] | some bit => bit :: List.filterMap id (List.takeWhile Option.isSome contents.right.toList)
Instances For
Reading a word placed on the initial tape gives back exactly that word.
This program issues a request and leaves the answer in the machine state.
Equations
- interface.ask = Cslib.FreeM.lift (Algolean.Algorithms.TMQuery.update interface.request)
Instances For
One instruction follows the ordinary rules, except that setting the request state obtains an answer from the solver.
Equations
- One or more equations did not get rendered due to their size.
- interface.step oracle (Algolean.Algorithms.TMQuery.write symbol) next_2 s = (Algolean.Algorithms.TMQuery.write symbol).step next_2 s
- interface.step oracle (Algolean.Algorithms.TMQuery.move direction) next_2 s = (Algolean.Algorithms.TMQuery.move direction).step next_2 s
- interface.step oracle (Algolean.Algorithms.TMQuery.branchCode condition yes no) next_2 s = (Algolean.Algorithms.TMQuery.branchCode condition yes no).step next_2 s
- interface.step oracle (Algolean.Algorithms.TMQuery.whileCode condition body) next_2 s = (Algolean.Algorithms.TMQuery.whileCode condition body).step next_2 s
Instances For
These execution rules use the shared runner to handle fuel, program sequencing, and costs. Requests work inside branches and loops.
Equations
Instances For
This model records the results and costs of executing programs with access to the solver.
Equations
- interface.model oracle = (interface.interpreter oracle).toModel
Instances For
The shared execution function runs the program with the supplied solver, starting state, and fuel.
Equations
- interface.execute oracle fuel p s = Algolean.Algorithms.FuelExecMonad.execute (interface.model oracle) fuel p s
Instances For
A request costs one time step and one unit of fuel. The answer is recorded in the machine state, while the tape and head position stay unchanged.
One instruction counts exactly the cells it adds to the recorded tape range.
The final number of recorded tape cells is the initial number plus the cells newly counted during execution. Requests preserve this accounting.