Theorems · Definition · logic and foundations
Turing.ToPartrec.Code.eval
Turing.ToPartrec.Code → List ℕ →. List ℕ
The semantics of the Code primitives, as partial functions List ℕ →. List ℕ.
By convention, functions that return a single result return a singleton [n],
or in some cases n :: v where v will be ignored by a subsequent function.
* zero' appends a 0 to the input. That is, zero' v = 0 :: v.
* succ returns the successor of the head of the input, defaulting to zero if there is no head:
* succ [] = [1]
* succ (n :: v) = [n + 1]
* tail returns the tail of the input
* tail [] = []
* tail (n :: v) = v
* cons f fs calls f and fs on the input and conses the results:
* cons f fs v = (f v).head :: fs v
* comp f g calls f on the output of g:
* comp f g v = f (g v)
* case f g cases on the head of the input, calling f or g depending on whether it is zero or
a successor (similar to Nat.casesOn).
* case f g [] = f []
* case f g (0 :: v) = f v
* case f g (n+1 :: v) = g (n :: v)
* fix f calls f repeatedly, using the head of the result of f to decide whether to call f
again or finish:
* fix f v = [] if f v = []
* fix f v = w if f v = 0 :: w
* fix f v = fix f w if f v = n+1 :: w (the exact value of n is discarded)
- Cited by
- 23 results in Mathlib
- Foundations
- Depth 13 from the axioms · uses no axioms
Around this declaration
Dashed lines are statement dependencies; solid lines are citations in proofs.
Cites3
Mathlib declarations this one mentions in its statement or cites explicitly in its proof. Plumbing is filtered out.
- PFunstatement · cited by 207
- Turing.ToPartrec.Codestatement and proof · cited by 83
- Turing.ToPartrec.Code.brecOnproof · cited by 1
Cited by24
Results whose statement or proof uses this declaration.
- Turing.ToPartrec.Code.nil_evalstatement · cited by 4
- Turing.ToPartrec.Code.comp_evalstatement and proof · cited by 4
- Turing.ToPartrec.Code.cons_evalstatement and proof · cited by 4
- Turing.ToPartrec.Code.tail_evalstatement · cited by 3
- Turing.ToPartrec.Code.zero'_evalstatement · cited by 3
- Turing.ToPartrec.Code.Okproof · cited by 3
- Turing.ToPartrec.Code.head_evalstatement · cited by 2
- Turing.ToPartrec.Code.id_evalstatement · cited by 2
- Turing.ToPartrec.Code.succ_evalstatement · cited by 2
- Turing.ToPartrec.code_is_okproof · cited by 2
- Turing.ToPartrec.cont_eval_fixstatement and proof · cited by 2
- Turing.ToPartrec.Code.case_evalstatement and proof · cited by 2