| 1 |
Module S. |
| 2 |
#[local] Set Printing Unfolded Projection As Match. |
| 3 |
#[projections(primitive=yes)] |
| 4 |
Record r (u : unit) := { r_car : Type }. |
| 5 |
|
| 6 |
Axiom u : unit. |
| 7 |
|
| 8 |
Definition rO : r u -> r u := fun o => {| r_car := option (r_car u o) |}. |
| 9 |
|
| 10 |
Goal forall o, exists M, M (r_car u o)= r_car u (rO o). |
| 11 |
Proof. |
| 12 |
intros. eexists _. |
| 13 |
Timeout 1 refine (eq_refl _). |
| 14 |
Qed. |
| 15 |
End S. |
| 16 |
|
| 17 |
Module T. |
| 18 |
#[local] Set Printing Unfolded Projection As Match. |
| 19 |
#[projections(primitive=yes)] |
| 20 |
Record r (u : unit) := { r_car : Type }. |
| 21 |
|
| 22 |
Axiom u : unit. |
| 23 |
Axiom v : forall i : nat, r u. |
| 24 |
|
| 25 |
Goal forall i, exists P, P (v i) = r_car u (v i). |
| 26 |
Proof. |
| 27 |
intros. eexists _. |
| 28 |
(* Unable to unify "r (v i)" with "?P (v i)". *) |
| 29 |
refine (eq_refl _). |
| 30 |
Qed. |
| 31 |
End T. |
| 32 |
|
| 33 |
(* Here we test that CS inference happens even if the projection is |
| 34 |
primitive and the projected term has a type that is not an inductive |
| 35 |
(but rather an evar). We exploit the fact that Coq considers are |
| 36 |
well typed terms containing evars for which a suspended |
| 37 |
unif problem exists. *) |
| 38 |
Require Import Ltac2.Ltac2 Ltac2.Unification Ltac2.Constr Ltac2.Printf. |
| 39 |
|
| 40 |
Module U. |
| 41 |
|
| 42 |
#[projections(primitive=yes)] Record r := R { r_car : Type }. |
| 43 |
#[projections(primitive=yes)] Record s := S { s_car : Type }. |
| 44 |
|
| 45 |
(* The type of the CS instance will help unification make a choice |
| 46 |
for the (_ : _ r) problem below *) |
| 47 |
Canonical Structure foo (x : s): (fun x=>x) r := R (s_car x). |
| 48 |
|
| 49 |
Axiom a : s. |
| 50 |
|
| 51 |
Goal True. |
| 52 |
Ltac2 Eval |
| 53 |
let t1 := open_constr:( ( _ : _ r ).(r_car) ) in (* the problem mentioned above *) |
| 54 |
let t2 := constr:( (a).(s_car) ) in |
| 55 |
(* safeguard against parser *) |
| 56 |
match (Constr.Unsafe.kind t1) with |
| 57 |
| Constr.Unsafe.Proj _ _ _ => () |
| 58 |
| _ => fail |
| 59 |
end; |
| 60 |
match (Constr.Unsafe.kind t2) with |
| 61 |
| Constr.Unsafe.Proj _ _ _ => () |
| 62 |
| _ => fail |
| 63 |
end; |
| 64 |
(* printf "%t = %t" t1 t2; *) |
| 65 |
unify_with_full_ts t1 t2; (* fails before #19358 *) |
| 66 |
(* printf "%t = %t" t1 t2. *) |
| 67 |
(). |
| 68 |
Abort. |
| 69 |
|
| 70 |
End U. |