From QuickChick.stlc Require Import lambda.
Open Scope coq_nat.
(* Note : Some tactic automation would improve our proofs *)
Inductive Const_leq (s : nat) : term -> Prop :=
| IdLe : forall x, Const_leq s (Id x)
| ConstLe : forall n, n <= s -> Const_leq s (Const n)
| AppLe :
forall t1 t2,
Const_leq s t1 -> Const_leq s t2 ->
Const_leq s (App t1 t2)
| AbsLe :
forall t,
Const_leq s t -> Const_leq s (Abs t).
Fixpoint max_const (t : term) : nat :=
match t with
| Id _ => 0
| Const n => n
| App t1 t2 => max (max_const t1) (max_const t2)
| Abs t => max_const t
end.

Lemma max_const_Const_leq :
forall t, Const_leq (max_const t) t.