Module Translation.
Definition to_St(x:Q):St :=
match x with
| BB52.A => St0
| BB52.B => St1
| BB52.C => St2
| BB52.D => St3
| BB52.E => St4
end.
Definition of_St(x:St):Q :=
match x with
| St0 => BB52.A
| St1 => BB52.B
| St2 => BB52.C
| St3 => BB52.D
| St4 => BB52.E
end.
Definition to_Σ(x:Sym):Σ :=
match x with
| BB52.S0 => Σ0
| BB52.S1 => Σ1
end.
Definition of_Σ(x:Σ):Sym :=
match x with
| Σ0 => BB52.S0
| Σ1 => BB52.S1
end.
Definition to_Dir(x:TM.dir):Dir :=
match x with
| TM.L => Dneg
| TM.R => Dpos
end.
Definition to_halftape(x:side):nat->Σ :=
fun n => to_Σ (Streams.Str_nth n x).
Definition to_tape(x:tape):BinInt.Z->Σ :=
let '(l0,m0,r0):=x in
make_tape (to_halftape l0) (to_Σ m0) (to_halftape r0).
Definition to_ExecState(x:Q*tape):ExecState Σ :=
let (s0,t0):=x in
(to_St s0,to_tape t0).
Definition to_oTrans(x:option (Sym*TM.dir*Q)):option (Trans Σ) :=
match x with
| None => None
| Some (o,d,s) => Some {| nxt:=to_St s; dir:=to_Dir d; out:=to_Σ o |}
end.
Definition to_TM(tm:TM):BB52Statement.TM Σ :=
fun s0 i0 =>
to_oTrans (tm (of_St s0,of_Σ i0)).
Ltac translate_nonhalt x2 x3 :=
match goal with
| |- ~HaltsFromInit Σ Σ0 ?x1 =>
replace x1 with (to_TM x2);
[ apply to_NonHalt,x3
| fext; fext;
match goal with
| x:St, x0:Σ |- _ => destruct x,x0; reflexivity
end ]
end.
End Translation.
Definition tm_holdouts_13 :=
Finned1::Finned2::Finned3::Finned4::Finned5::
Skelet1::Skelet10::Skelet15::Skelet17::Skelet26::Skelet33::Skelet34::Skelet35::
nil.
Definition Trans_eqb(tr1 tr2:Trans Σ):bool :=
let (s1,d1,o1):=tr1 in
let (s2,d2,o2):=tr2 in
St_eqb s1 s2 &&&
Dir_eqb d1 d2 &&&
Σ_eqb o1 o2.
Ltac Trans_eq_dec s1 s2 := eq_dec Trans_eqb_spec Trans_eqb s1 s2.
Definition option_eqb {T}(f:T->T->bool) (t1 t2:option T):bool :=
match t1,t2 with
| Some c1,Some c2 => f c1 c2
| None,None => true
| _,_ => false
end.
Ltac option_eq_dec f f_spec o1 o2 := eq_dec (option_eqb_spec f f_spec) (option_eqb f) o1 o2.
Definition tm_eqb(tm0 tm1:TM Σ):bool :=
forallb_St (fun s0 =>
forallb_Σ (fun i0 =>
option_eqb Trans_eqb (tm0 s0 i0) (tm1 s0 i0))).
Fixpoint find_tm(tm:TM Σ)(ls:list (TM Σ)):bool :=
match ls with
| nil => false
| h::t => tm_eqb tm h ||| find_tm tm t
end.
Definition holdout_checker tm := if find_tm tm tm_holdouts_13 then Result_NonHalt else Result_Unknown.
Inductive DeciderType :=
| NG(hlen len:nat)
| NG_LRU(len:nat)
| RWL(len m:nat)
| DNV(n:nat)(f:nat->Σ->nat)
| WA(max_d:BinNums.Z)(n_l:nat)(f_l:nat->Σ->(nat*BinNums.Z))(n_r:nat)(f_r:nat->Σ->(nat*BinNums.Z))
| Ha
| Lp1
| Holdout.
Definition getDecider(x:DeciderType) :=
match x with
| NG hlen len =>
match hlen with
| O => NGramCPS_decider_impl2 len len 5000001
| _ => NGramCPS_decider_impl1 hlen len len 5000001
end
| NG_LRU len =>
NGramCPS_LRU_decider len len 5000001
| RWL len mnc => RepWL_ES_decider len mnc 320 150001
| DNV n f => dfa_nfa_verifier n f
| WA max_d n_l f_l n_r f_r => MITM_WDFA_verifier max_d n_l f_l n_r f_r 10000000
| Ha => halt_decider_max
| Lp1 => loop1_decider 1050000 (4096::8192::16384::32768::65536::131072::262144::524288::nil)
| Holdout => holdout_checker
end.

Lemma getDecider_spec x:
HaltDecider_WF (N.to_nat BB) (getDecider x).