Skip to content

Commit 6c63978

Browse files
committed
[TC] compilation of primitive projections to their compatibility constants
1 parent 5dc187f commit 6c63978

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

apps/tc/elpi/ho_compile.elpi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace tc {
2121
decompile-term-aux (pglobal _ _ as T) L T' L :- !, copy T T', !.
2222
decompile-term-aux (sort _ as T) L T' L :- !, copy T T', !.
2323
decompile-term-aux (uvar as X) L X L :- !.
24-
decompile-term-aux (primitive _ as X) L X L :- !.
24+
decompile-term-aux (primitive (proj P _)) L (global (const Y)) L :- !, coq.env.primitive-projection? P Y.
2525
decompile-term-aux (tc.canonical-projection T S _) (pr [X|Xs] L1) Y (pr Xs' L3) :- !,
2626
name Y X S,
2727
decompile-term-aux T (pr Xs L1) T' (pr Xs' L2),
@@ -332,7 +332,8 @@ namespace tc {
332332
get-uva-pair-arity Y L Z.
333333

334334
pred decompile-problematic-term i:term, i:list prop, o:term, o:list prop.
335-
decompile-problematic-term (primitive _ as C) A C A :- !.
335+
decompile-problematic-term (primitive (proj P _)) A (global (const Y)) A :- !,
336+
coq.env.primitive-projection? P Y.
336337

337338
decompile-problematic-term (tc.maybe-eta-tm T S) L V [tc.link.eta V T' | L2] :-
338339
prune V S, !, fold-map T L T' L2.

apps/tc/tests/canonical_struct.v

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,23 @@ Module CS5.
9999
Unshelve.
100100
apply (ofe_any nat).
101101
Qed.
102-
End CS5.
102+
End CS5.
103+
104+
Module CS6.
105+
#[projections(primitive=yes)]
106+
Structure ofe := Ofe { ofe_car : Type; }.
107+
108+
#[projections(primitive=no)] (* TODO: Putting primitive to yes leads to a unification error. Why? *)
109+
Structure cmra := { cmra_car :> Type; }.
110+
Canonical Structure cmra_ofeO (A : cmra) : ofe := Ofe A.
111+
112+
Class C (I : Type).
113+
Instance c : forall (A : ofe), C ((A).(ofe_car)) := {}.
114+
115+
Section s.
116+
Context {cmra : cmra}.
117+
Goal C (cmra_car cmra).
118+
apply _.
119+
Qed.
120+
End s.
121+
End CS6.

0 commit comments

Comments
 (0)