From QuickChick.stlc Require Import lambda.
Open Scope coq_nat.
(* Note : Some tactic automation would improve our proofs *)

(* Specifications: *)
(* This could be turned into a more generic lemma, but for now it works *)
Lemma vars_with_type_shift:
forall e x tau n,
In (Id (S x))
(map (fun p : type * var => Id (snd p))
(filter
(fun p : type * nat =>
proj1_sig (Sumbool.bool_of_sumbool (type_eq_dec tau (fst p))))
(combine e (seq (S n) (length e))))) <->
In (Id x)
(map (fun p : type * var => Id (snd p))
(filter
(fun p : type * nat =>
proj1_sig (Sumbool.bool_of_sumbool (type_eq_dec tau (fst p))))
(combine e (seq n (length e))))).
Lemma vars_with_type_le:
forall e x tau n,
In (Id x)
(map (fun p : type * var => Id (snd p))
(filter
(fun p : type * nat =>
proj1_sig (Sumbool.bool_of_sumbool (type_eq_dec tau (fst p))))
(combine e (seq n (length e))))) -> n <= x.
Lemma vars_with_type_le_length_aux:
forall e x tau n,
In (Id x)
(map (fun p : type * var => Id (snd p))
(filter
(fun p : type * nat =>
proj1_sig (Sumbool.bool_of_sumbool (type_eq_dec tau (fst p))))
(combine e (seq n (length e))))) -> x < n + (length e).
Lemma vars_with_type_le_length:
forall e x tau,
In (Id x) (vars_with_type e tau) -> x < (length e).
Lemma vars_with_type_Id :
forall e tau t,
In t (vars_with_type e tau) -> exists x, t = Id x.
Lemma type_var :
forall e x tau, In (Id x) (vars_with_type e tau) <-> typing e (Id x) tau.
Lemma app_free_app_no_0 :
forall (t : term),
app_free t <-> app_no t = 0.