From Undecidability.L Require Import LTactics Datatypes.Lists Datatypes.LNat Datatypes.LBool.
From Undecidability.TM Require TM.
From Undecidability.TM Require Import TM_facts SizeBounds.
From Undecidability.L.Complexity  Require Import UpToCNary.
From Undecidability.L.AbstractMachines Require Import FlatPro.Programs.
Unset Printing Coercions.
From Undecidability.TM.L Require Alphabets.
Definition enc_bool_perElem (b:bool) := [lamT;lamT;varT 0;lamT; lamT; varT (if b then 1 else 0); retT; retT;appT].
Definition enc_bool_nil := [lamT; lamT; varT 1; retT; retT].
Definition enc_bool_closing :=  [appT; retT; retT].

Lemma enc_boollist_helper bs :
flat_map enc_bool_perElem bs ++ enc_bool_nil
= [lamT;lamT;varT (match bs with [] => 1 | _ => 0 end)]++ skipn 3 (flat_map enc_bool_perElem bs ++ enc_bool_nil).