Section CBV.
Variables variable function constructor : Type.
Variable max_arity : nat.
Notation value := (Syntax.value constructor).
Notation term := (Syntax.term variable function constructor).
Notation pattern := (Syntax.pattern variable constructor).
Notation rule := (Syntax.rule variable function constructor).
(* proof tree *)
Inductive cbv : Type :=
| cbv_constr : list cbv -> term -> value -> cbv
| cbv_split : list cbv -> cbv -> term -> value -> cbv
| cbv_function : nat -> (variable -> value) -> cbv -> term -> value -> cbv.
(* Smarter induction principle than the one automatically generated *)
(* Being a subtree of *)
Fixpoint InCBV p proof_tree : Prop :=
p = proof_tree \/
match proof_tree with
| cbv_constr lp _ _ => orl (map (InCBV p) lp)
| cbv_split lp p' _ _ => InCBV p p' \/ orl (map (InCBV p) lp)
| cbv_function _ _ p' _ _ => InCBV p p'
end.
(* Reverse induction on proof trees *)

Lemma cbv_reverse_induction :
forall (P : cbv -> Prop) proof_tree,
P proof_tree ->
(forall lp t v, InCBV (cbv_constr lp t v) proof_tree -> P (cbv_constr lp t v) -> forall p, In p lp -> P p) ->
(forall lp p t v, InCBV (cbv_split lp p t v) proof_tree -> P (cbv_split lp p t v) -> forall p', (p' = p \/ In p' lp) -> P p') ->
(forall i s p t v, InCBV (cbv_function i s p t v) proof_tree -> P (cbv_function i s p t v) -> P p) ->
forall p, InCBV p proof_tree -> P p.