Section Correctness.
(* The first parameter of [bisimilar] is unnecessary for this development. The return type is heterogeneous, the singleton type [F 1] on one side and [unit] on the other, hence we instantiate the parameter with the trivial relation. *)
Definition TT {A B}: A -> B -> Prop  := fun _ _ => True.
Hint Unfold TT.
Definition equivalent (s:stmt) (t:asm 1 1) : Prop :=
bisimilar TT (denote_imp s) (denote_asm t f0).
Inductive RI : (unit + unit) -> (unit + unit + unit) -> Prop :=
| RI_inl : RI (inl tt) (inl (inl tt))
| RI_inr : RI (inr tt) (inr tt).
Definition to_itree' {E A} (f : ktree_fin E 1 A) : itree E (fin A) := f f0.
Notation Inr_Kleisli := Inr_Kleisli.

(** Correctness of the compiler. After interpretation of the [Locals], the source _Imp_ statement denoted as an [itree] and the compiled _Asm_ program denoted as an [itree] are equivalent up-to-taus. The correctness is termination sensitive, but nonetheless a simple induction on statements. We are only left with reasoning about the functional correctness of the compiler, all control-flow related reasoning having been handled in isolation. *)
Theorem compile_correct (s : stmt) :
equivalent s (compile s).