Skip to content

Commit 56f3b1d

Browse files
committed
[TC] compilation of primitive projections to their compatibility constants
1 parent b6a2eaa commit 56f3b1d

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
@@ -23,7 +23,7 @@ namespace tc {
2323
decompile-term-aux (pglobal _ _ as T) L T' L :- !, copy T T', !.
2424
decompile-term-aux (sort _ as T) L T' L :- !, copy T T', !.
2525
decompile-term-aux (uvar as X) L X L :- !.
26-
decompile-term-aux (primitive _ as X) L X L :- !.
26+
decompile-term-aux (primitive (proj P _)) L (global (const Y)) L :- !, coq.env.primitive-projection? P Y.
2727
decompile-term-aux (tc.canonical-projection T S _) (pr [X|Xs] L1) Y (pr Xs' L3) :- !,
2828
name Y X S,
2929
decompile-term-aux T (pr Xs L1) T' (pr Xs' L2),
@@ -334,7 +334,8 @@ namespace tc {
334334
get-uva-pair-arity Y L Z.
335335

336336
pred decompile-problematic-term i:term, i:list prop, o:term, o:list prop.
337-
decompile-problematic-term (primitive _ as C) A C A :- !.
337+
decompile-problematic-term (primitive (proj P _)) A (global (const Y)) A :- !,
338+
coq.env.primitive-projection? P Y.
338339

339340
decompile-problematic-term (tc.maybe-eta-tm T S) L V [tc.link.eta V T' | L2] :-
340341
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)