From Undecidability.L Require Import Tactics.LTactics Functions.Encoding Prelim.LoopSum Functions.LoopSum Functions.UnboundIteration.
From Undecidability.L.Datatypes Require Import Lists.
(* ** Extracted size of terms *)
Instance term_size' : computable size'.
Definition sizeTR' '(stack,res) : (list term * nat) + nat :=
match stack with
[] => inr res
| s::stack =>
match s with
var n => inl (stack,S (n + res))
| app s t => inl (s::t::stack,S res)
| lam s => inl (s::stack,S res)
end
end.
Fixpoint sizeTR'_fuel (s:term) : nat :=
match s with
var _ => 1
| app s t => 1 + (sizeTR'_fuel s + sizeTR'_fuel t)
| lam s => 1 + sizeTR'_fuel s
end.
Instance termT_sizeTR' : computableTime' sizeTR'
(fun x _ => (let '(stack,res) := x in
match stack with
var n ::_ =>  n*11
| _ => 0
end + 35,tt)).

Lemma sizeTR'_fuel_leq_size s : sizeTR'_fuel s <= size s.