Let test_stack_unification_interaction_with_delta A
: (if negb _ then true else false) = if orb false (negb A) then true else false
:= eq_refl.
(* Test patterns unification *)
(* Feature introduced June 2011 *)
(* Example submitted for Zenon *)
(* Must infer "P := fun x => x=x" in zenon_notall *)
Check (fun _h1 => (zenon_notall nat _ (fun _T_0 =>
(fun _h2 => (zenon_noteq _ _T_0 _h2))) _h1)).
(* Core of an example submitted by Ralph Matthes (BZ#849)  It used to fail because of the K-variable x in the type of "sum_rec ..." which was not in the scope of the evar ?B. Solved by a head beta-reduction of the type "(fun _ : unit + unit => L unit) x" of "sum_rec ...". Shall we used more reduction when solving evars (in real_clean)?? Is there a risk of starting too long reductions?  Note that the example originally came from a non re-typable pretty-printed term (the checked term is actually re-printed the same form it is checked). *)
Set Implicit Arguments.
Inductive L (A:Set) : Set := c : A -> L A.
Parameter f: forall (A:Set)(B:Set), (A->B) -> L A -> L B.
Parameter t: L (unit + unit).
Check (f (fun x : unit + unit =>
sum_rec (fun _ : unit + unit => L unit)
(fun y => c y) (fun y => c y) x) t).
(* Test patterns unification in apply *)
Parameter x y : nat.
Parameter G:x=y->x=y->Prop.
Parameter K:x<>y->x<>y->Prop.
(* Test unification modulo eta-expansion (if possible) *)
(* In this example, two instances for ?P (argument of hypothesis H) can be inferred (one is by unifying the type [Q true] and [?P true] of the goal and type of [H]; the other is by unifying the argument of [f]); we need to unify both instances up to allowed eta-expansions of the instances (eta is allowed if the meta was applied to arguments)  This used to fail before revision 9389 in trunk *)

Lemma l5 :
forall f : (forall P, P true), (forall P, f P = f P) ->
forall Q, f (fun x => Q x) = f (fun x => Q x).