is_Recursive_byTape from a computable decider #
This file builds, from a total computable decider f : List T → Bool for a
language L, an always-halting TM0 over Option (T ⊕ Γ) that leaves a
designated acceptSym under the head exactly on the words of L, i.e.
is_Recursive_byTape L.
The construction threads the Mathlib Code → TM2 → TM1 → TM0 translation chain,
but unlike the .Dom-only bridge code_implies_isTM_direct, it tracks the final
tape (not just halting), because acceptance is read off the head symbol.
SPIKE: Computable f → ToPartrec.Code with characterized output #
Given f : List T → Bool computable, we produce a ToPartrec.Code bitCode
with bitCode.eval [Encodable.encode w] = some [if f w then 1 else 0].
The unary ℕ → ℕ function: decode the input as a word and return the bit.
Equations
- ByTapeFromComputable.bitFn f n = if (Option.map f (Encodable.decode n)).getD false = true then 1 else 0
Instances For
A ToPartrec.Code computing bitFn f (as a singleton output).
Equations
- ByTapeFromComputable.bitCode₀ f hf = ⋯.choose
Instances For
Output shaping: bit → [] / [0] #
Code.case Code.zero Code.nil maps [0] ↦ [0] (reject) and [1] ↦ [] (accept).
Composed with bitCode₀, the full code outputs [] exactly when f w = true.
The full decider code on the encoded input. Outputs [] iff f w = true.
Equations
Instances For
TM2 final configuration #
By PartrecToTM2.tr_eval, the TM2 machine reaches halt v where v is the
output of the code.
The composed code (with list-encoding prefix) on shiftedEncoding w
evaluates to outWord f w.
Generic chain tape descent (TM2 halt v → TM0 tape) #
For any code c and input v such that the TM2 reaches halt v, the chain TM0
ChainTM0 reaches a configuration whose tape head is the embedded final-tape
head. We track the full configuration via the Mathlib Respects relations.
The chain TM1 initial config (matches partrec_init_trCfg).
Equations
- One or more equations did not get rendered due to their size.
Instances For
TM1 descent: the chain TM1 reaches some config with TrCfg (halt vOut) cfg₁,
where vIn is the input and vOut the reached output.
TM0 descent: the chain TM0 reaches a config whose tape is the TM1 final tape,
starting from TM1to0.trCfg ChainTM1 (chainTM1Init c v).
Tape-tracking eval lemmas for reroot / restrict / alphabet-lift #
Each underlying Respects relation preserves the tape, so Turing.tr_eval
transports a final config of known tape.
Re-rooted TM0: a final config with tape T is reached, given the original
reaches a final config with tape T from ⟨q₀, Tape.mk₁ l⟩.
Restricted TM0: tape-tracking version of restrict_eval_dom_iff.
Restrict+reroot TM0: tape-tracking version of tm0RestrictReroot_eval_dom.
Alphabet-lifted TM0: tape-tracking version of lift_eval_dom.
The final TM1 tape head for a halt v config #
From TrCfg (halt v) cfg₁, the TM1 tape head is (true, L.head) where each
stack component is the head of the reversed encoded stack.
The TM1 final tape head for the accepting output [].
The TM1 final tape head for the rejecting output [0].
directBlankEmb is injective (it has the left inverse directBlankInv).
The accepting symbol: the embedding of the accept TM1 head.
Equations
Instances For
A reject head (whose main component is some cons) embeds to something
different from acceptSym.
Chain TM0 with Fintype states and final tape #
The analogue of code_to_tm0_fintype_general, but additionally producing the
final tape (the embedded addBottom L head).
Final assembly #
The chain input tape (over ChainΓ) for word w.
Equations
Instances For
is_Recursive_byTape from a computable decider.
The assembled TM0 over Option (T ⊕ ChainΓ) is
compose M_conv (directEmbedTM0 M), where M_conv writes the chain input from
w, M is the chain decider, and the alphabet is lifted via directBlankEmb.
It always halts and its final head is acceptSym exactly on words of L.
is_Recursive_byTape from a computable decider (top-level form).
A total computable Boolean decision procedure yields a recursive language.
Combining the tape-output decider construction with the tape-vs-state acceptance
equivalence is_Recursive_of_byTape.