Module Import Prog := Syn.MkProg (BAProg).
Definition rank : function -> nat := ltac:(autorank function_beq ranklist).
(* QI *)
Definition cs (c : constructor) := 1. (* same for all *)
Ltac qif_monotonic_tac :=
repeat (apply forall2_le_suml || apply forall2_le_maxl ||
apply Plus.plus_le_compat_r || apply Plus.plus_le_compat_l || apply Plus.plus_le_compat ||
apply Nat.max_le_compat_r || apply Nat.max_le_compat_l || apply Nat.max_le_compat ||
apply Mult.mult_le_compat_l || apply Mult.mult_le_compat_r
); trivial.
Fixpoint quote_positive (p: positive) : value :=
match p with
| xI p' => c_capply suc1 [quote_positive p']
| xO p' => c_capply suc0 [quote_positive p']
| xH    => c_capply suc1 [c_capply zero []]
end.
Definition quote_value (n: N) : value :=
match n with
| N0     => c_capply zero []
| Npos p => quote_positive p
end.
Hint Resolve succ_correct : eval.

Lemma add_correct m n:
evaluates (fapply addf [term_from_value (quote_value m); term_from_value (quote_value n)]) (quote_value (m + n)) /\
evaluates (fapply addt [term_from_value (quote_value m); term_from_value (quote_value n)]) (quote_value (N.succ( m + n))).