Debian Codegraph @

test-suite/ssr/primproj.v

raw
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11
12
13 Require Import Setoid.
14 Set Primitive Projections.
15
16
17 Module CoqBug.
18 Record foo A := Foo { foo_car : A }.
19
20 Definition bar : foo _ := Foo nat 10.
21
22 Parameter alias : forall A, foo A -> A.
23
24 Parameter e : @foo_car = alias.
25
26 Goal foo_car _ bar = alias _ bar.
27 Proof.
28 (* Coq equally fails *)
29 Fail rewrite -> e.
30 Fail rewrite e at 1.
31 Fail setoid_rewrite e.
32 Fail setoid_rewrite e at 1.
33 Set Keyed Unification.
34 Fail rewrite -> e.
35 Fail rewrite e at 1.
36 Fail setoid_rewrite e.
37 Fail setoid_rewrite e at 1.
38 Admitted.
39
40 End CoqBug.
41
42 (* ----------------------------------------------- *)
43 Require Import ssreflect.
44
45 Set Primitive Projections.
46
47 Module T1.
48
49 Record foo A := Foo { foo_car : A }.
50
51 Definition bar : foo _ := Foo nat 10.
52
53 Goal foo_car _ bar = 10.
54 Proof.
55 match goal with
56 | |- foo_car _ bar = 10 => idtac
57 end.
58 rewrite /foo_car.
59 (*
60 Fail match goal with
61 | |- foo_car _ bar = 10 => idtac
62 end.
63 *)
64 Admitted.
65
66 End T1.
67
68
69 Module T2.
70
71 Record foo {A} := Foo { foo_car : A }.
72
73 Definition bar : foo := Foo nat 10.
74
75 Goal foo_car bar = 10.
76 match goal with
77 | |- foo_car bar = 10 => idtac
78 end.
79 rewrite /foo_car.
80 (*
81 Fail match goal with
82 | |- foo_car bar = 10 => idtac
83 end.
84 *)
85 Admitted.
86
87 End T2.
88
89
90 Module T3.
91
92 Record foo {A} := Foo { foo_car : A }.
93
94 Definition bar : foo := Foo nat 10.
95
96 Goal foo_car bar = 10.
97 Proof.
98 rewrite -[foo_car _]/(id _).
99 match goal with |- id _ = 10 => idtac end.
100 Admitted.
101
102 Goal foo_car bar = 10.
103 Proof.
104 set x := foo_car _.
105 match goal with |- x = 10 => idtac end.
106 Admitted.
107
108 End T3.
109
110 Module T4.
111
112 Inductive seal {A} (f : A) := { unseal : A; seal_eq : unseal = f }.
113 Arguments unseal {_ _} _.
114 Arguments seal_eq {_ _} _.
115
116 Record uPred : Type := IProp { uPred_holds :> Prop }.
117
118 Definition uPred_or_def (P Q : uPred) : uPred :=
119 {| uPred_holds := P \/ Q |}.
120 Definition uPred_or_aux : seal (@uPred_or_def). by eexists. Qed.
121 Definition uPred_or := unseal uPred_or_aux.
122 Definition uPred_or_eq: @uPred_or = @uPred_or_def := seal_eq uPred_or_aux.
123
124 Lemma foobar (P1 P2 Q : uPred) :
125 (P1 <-> P2) -> (uPred_or P1 Q) <-> (uPred_or P2 Q).
126 Proof.
127 rewrite uPred_or_eq. (* This fails. *)
128 Admitted.
129
130 End T4.
131
132
133 Module DesignFlaw.
134
135 Record foo A := Foo { foo_car : A }.
136 Definition bar : foo _ := Foo nat 10.
137
138 Definition app (f : foo nat -> nat) x := f x.
139
140 Goal app (foo_car _) bar = 10.
141 Proof.
142 unfold app. (* mkApp should produce a Proj *)
143 Fail set x := (foo_car _ _).
144 Admitted.
145
146 End DesignFlaw.
147
148
149 Module Bug.
150
151 Record foo A := Foo { foo_car : A }.
152
153 Definition bar : foo _ := Foo nat 10.
154
155 Parameter alias : forall A, foo A -> A.
156
157 Parameter e : @foo_car = alias.
158
159 Goal foo_car _ bar = alias _ bar.
160 Proof.
161 Fail rewrite e. (* Issue: #86 *)
162 Admitted.
163
164 End Bug.