Skip to content

Commit a7f1a02

Browse files
authored
Merge pull request #406 from mattam82/8.13-beta2
8.13 beta2
2 parents 00ab9ba + 142d3d4 commit a7f1a02

19 files changed

+97
-121
lines changed

.travis.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Changes in Equations 1.3beta2:
33

44
- Fix #399: allow simplification in indices when splitting a variable,
55
to expose the head of the index.
6+
- Fix #389: error derving EqDec in HoTT variant.
7+
- Allow universe binder annotations @{} on Equations definitions.
68
- Fix "struct" parsing issue that required a reset of Coq sometimes
79
- Pattern enhancements: no explicit shadowing of pattern variables
810
is allowed anymore. Fix numerous bugs where generated implicit names

_HoTTProject

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,5 @@ theories/HoTT/Telescopes.v
7272
theories/HoTT/WellFoundedInstances.v
7373
theories/HoTT/All.v
7474

75-
test-suite/BasicsHoTT.v
75+
test-suite/BasicsHoTT.v
76+
test-suite/issues/issue389.v

doc/equations.pdf

479 Bytes
Binary file not shown.

doc/manual.tex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ \subsection{Syntax of programs}
2323
\texttt{mutual programs} & mutual & \Coloneqq & \coqdockw{with}~p `| where \\
2424
\texttt{where clause} & where & \Coloneqq & \coqdockw{where}~p `| \coqdockw{where}~not\\
2525
\texttt{notation} & not & \Coloneqq & \texttt{''}string\texttt{''}~\textcoloneq~t~(\texttt{:}~scope)?\\
26-
\texttt{program} & p, prog & \Coloneqq & \coqdoccst{f}~Γ~\texttt{:}~τ~(\coqdockw{by}~\textit{annot})?~\textcoloneq~clauses \\
26+
\texttt{program} & p, prog & \Coloneqq & \coqdoccst{f}(\texttt{@\{} univ\_decl \texttt{\}})?~Γ~\texttt{:}~τ~(\coqdockw{by}~\textit{annot})?~\textcoloneq~clauses \\
2727
\texttt{annotation} & annot & \Coloneqq & \kw{struct}~\var{x}? `| \kw{wf}~t~R? \\
2828
\texttt{user clauses} & clauses & \Coloneqq & \vecplus{cl} `| \texttt{\{}\,\vec{cl}\,\texttt{\}} \\
2929
\texttt{user clause} & cl & \Coloneqq & \coqdoccst{f}~\vec{up}~n?~\texttt{;} `|
@@ -44,11 +44,11 @@ \subsection{Syntax of programs}
4444
\label{fig:usergram}
4545
\end{figure}
4646
The syntax allows the definition of toplevel mutual (\kw{with}) and
47-
nested (\kw{where}) structurally recursive definitions. Notations can be
48-
used globally to attach a syntax to a recursive definition, or locally
49-
inside a user node. A single program is given as a tuple of a (globally
50-
fresh) identifier, a signature and a list of user clauses (order
51-
matters), along with an optional recursion annotation (see next
47+
nested (\kw{where}) structurally recursive definitions.
48+
Notations can be used globally to attach a syntax to a
49+
recursive definition, or locally inside a user node. A single program is given as a tuple of a (globally
50+
fresh) identifier, an optional universe annotation,
51+
a signature and a list of user clauses (order matters), along with an optional recursion annotation (see next
5252
section). The signature is simply a list of bindings and a result
5353
type. The expected type of the function \cst{f} is then $∀~Γ, τ$.
5454
An empty set of clauses denotes that one of the variables has an empty type.

src/covering.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ let compute_fixdecls_data env evd ?data programs =
727727
List.map2 (fun i (relevance, fixprot) -> of_tuple (make_annot (Name i) relevance, None, fixprot)) names fixprots in
728728
data, List.rev fixdecls, fixprots
729729

730-
let interp_arity env evd ~poly ~is_rec ~with_evars notations (((loc,i),rec_annot,l,t,by),clauses as ieqs) =
730+
let interp_arity env evd ~poly ~is_rec ~with_evars notations (((loc,i),udecl,rec_annot,l,t,by),clauses as ieqs) =
731731
let ienv, ((env', sign), impls) = Equations_common.evd_comb1 (interp_context_evars env) evd l in
732732
let (arity, impls') =
733733
let ty = match t with
@@ -1523,7 +1523,7 @@ and interp_wheres env0 ctx evars path data s lets
15231523
(w : (pre_prototype * pre_equation list) list * Vernacexpr.decl_notation list) =
15241524
let notations = snd w in
15251525
let aux (data,lets,nlets,coverings,env)
1526-
(((loc,id),nested,b,t,reca),clauses as eqs) =
1526+
(((loc,id),udecl,nested,b,t,reca),clauses as eqs) =
15271527

15281528
let is_rec = is_recursive id ([eqs], notations) in
15291529
let p = interp_arity env evars ~poly:false ~is_rec ~with_evars:true notations eqs in

src/eqdec.ml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,39 +112,42 @@ let derive_eq_dec ~pm env sigma ~poly ind =
112112
let app =
113113
let xname = Context.nameR (Id.of_string "x") in
114114
let yname = Context.nameR (Id.of_string "y") in
115-
mkProd (xname, indapp,
116-
mkProd (yname, lift 1 indapp,
117-
mkApp (lift 2 app, [| mkRel 2; mkRel 1 |])))
115+
mkProd (xname, indapp,
116+
mkProd (yname, lift 1 indapp,
117+
mkApp (lift 2 app, [| mkRel 2; mkRel 1 |])))
118118
in
119119
let typ = it_mkProd_or_LetIn app ind.ind_args in
120120
let full = it_mkNamedProd_or_LetIn typ ctx in
121121
let tc gr =
122122
let b, ty =
123-
Typeclasses.instance_constructor
123+
Typeclasses.instance_constructor
124124
cl
125125
[indapp; mkapp (Global.env ()) evdref (Lazy.from_val gr)
126126
(Array.append (vars_of_pars ctx) argsvect) ] in
127127
let body =
128-
it_mkNamedLambda_or_LetIn
129-
(it_mkLambda_or_LetIn (Option.get b) ind.ind_args) ctx
128+
it_mkNamedLambda_or_LetIn
129+
(it_mkLambda_or_LetIn (Option.get b) ind.ind_args) ctx
130130
in
131+
let types = it_mkNamedProd_or_LetIn (it_mkProd_or_LetIn ty ind.ind_args) ctx in
132+
let evm, _ = Typing.solve_evars (Global.env ()) !evdref (mkCast (body, Constr.DEFAULTcast, types)) in
133+
let () = evdref := evm in
134+
let types = to_constr !evdref types in
135+
let body = to_constr !evdref body in
131136
let univs = Evd.univ_entry ~poly !evdref in
132-
let types = to_constr !evdref (it_mkNamedProd_or_LetIn (it_mkProd_or_LetIn ty ind.ind_args) ctx) in
133-
let ce = Declare.definition_entry ~univs ~types (to_constr !evdref body) in
137+
let ce = Declare.definition_entry ~univs ~types body in
134138
ce
135139
in full, tc
136140
in
137141
let indsl = Array.to_list info.mutind_inds in
138142
let indsl = List.map (fun ind -> ind, info_of ind) indsl in
139143
let hook { Declare.Hook.S.dref; _ } =
140144
List.iter (fun (ind, (stmt, tc)) ->
141-
let ce = tc dref in
142-
let kind = Decls.(IsDefinition Instance) in
143-
let entry = Declare.DefinitionEntry ce in
144-
let inst = Declare.declare_constant ~name:(add_suffix ind.ind_name "_EqDec") ~kind entry in
145-
let inst =
146-
Classes.mk_instance (fst cl) Hints.empty_hint_info true (GlobRef.ConstRef inst)
147-
in Classes.add_instance inst)
145+
let ce = tc dref in
146+
let kind = Decls.(IsDefinition Instance) in
147+
let entry = Declare.DefinitionEntry ce in
148+
let inst = Declare.declare_constant ~name:(add_suffix ind.ind_name "_EqDec") ~kind entry in
149+
let inst = Classes.mk_instance (fst cl) Hints.empty_hint_info true (GlobRef.ConstRef inst) in
150+
Classes.add_instance inst)
148151
indsl
149152
in
150153
let hook = Declare.Hook.make hook in

src/equations.ml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,14 @@ let define_by_eqs ~pm ~poly ~program_mode ~tactic ~open_proof opts eqs nt =
145145
let env = Global.env () in
146146
let flags = { polymorphic = poly; with_eqns; with_ind; allow_aliases = false;
147147
tactic; open_proof } in
148-
let evd = ref (Evd.from_env env) in
149-
let programs = List.map (fun (((loc,i),rec_annot,l,t,by),clauses as ieqs) ->
148+
let evm, udecl =
149+
match eqs with
150+
| (((loc, i), udecl, _, _, _, _), _) :: _ ->
151+
Constrintern.interp_univ_decl_opt env udecl
152+
| _ -> assert false
153+
in
154+
let evd = ref evm in
155+
let programs = List.map (fun (((loc,i),udecl,rec_annot,l,t,by),clauses as ieqs) ->
150156
let is_rec = is_recursive i (eqs, nt) in
151157
interp_arity env evd ~poly ~is_rec ~with_evars:open_proof nt ieqs) eqs in
152158
let rec_type = compute_rec_type [] programs in
@@ -186,7 +192,7 @@ let define_by_eqs ~pm ~poly ~program_mode ~tactic ~open_proof opts eqs nt =
186192
else pm
187193
in
188194
let hook ~pm i p info = (), hook ~pm i p info in
189-
define_programs ~pm env evd rec_type fixdecls flags programs hook
195+
define_programs ~pm env evd udecl rec_type fixdecls flags programs hook
190196

191197
let interp_tactic = function
192198
| Some qid ->
@@ -201,7 +207,7 @@ let interp_tactic = function
201207
| None -> !Declare.Obls.default_tactic
202208

203209
let equations ~pm ~poly ~program_mode ?tactic opts eqs nt =
204-
List.iter (fun (((loc, i), nested, l, t, by),eqs) -> Dumpglob.dump_definition CAst.(make ~loc i) false "def") eqs;
210+
List.iter (fun (((loc, i), _udecl, nested, l, t, by),eqs) -> Dumpglob.dump_definition CAst.(make ~loc i) false "def") eqs;
205211
let tactic = interp_tactic tactic in
206212
let pm, pstate =
207213
define_by_eqs ~pm ~poly ~program_mode ~tactic ~open_proof:false opts eqs nt in
@@ -211,7 +217,7 @@ let equations ~pm ~poly ~program_mode ?tactic opts eqs nt =
211217
CErrors.anomaly Pp.(str"Equation.equations leaving a proof open")
212218

213219
let equations_interactive ~pm ~poly ~program_mode ?tactic opts eqs nt =
214-
List.iter (fun (((loc, i), nested, l, t, by),eqs) -> Dumpglob.dump_definition CAst.(make ~loc i) false "def") eqs;
220+
List.iter (fun (((loc, i), _udecl, nested, l, t, by),eqs) -> Dumpglob.dump_definition CAst.(make ~loc i) false "def") eqs;
215221
let tactic = interp_tactic tactic in
216222
let pm, lemma = define_by_eqs ~pm ~poly ~program_mode ~tactic ~open_proof:true opts eqs nt in
217223
match lemma with

src/g_equations.mlg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ GRAMMAR EXTEND Gram
325325
] ]
326326
;
327327
proto:
328-
[ [ id = lident; l = binders2; ":"; t = Constr.lconstr;
329-
reca = wf_annot; ":="; eqs = sub_equations -> { (fun r -> ((id, r, l, Some t, reca), eqs)) }
328+
[ [ id = lident; d = OPT univ_decl; l = binders2; ":"; t = Constr.lconstr;
329+
reca = wf_annot; ":="; eqs = sub_equations -> { (fun r -> ((id, d, r, l, Some t, reca), eqs)) }
330330
] ]
331331
;
332332

src/noconf_hom.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ let derive_no_confusion_hom ~pm env sigma0 ~poly (ind,u as indu) =
278278
~prefix:"Hom" ~tactic:(noconf_hom_tac ()) program_cst
279279
in
280280
let prog = Splitting.make_single_program env evd data.Covering.flags p ctxmap splitting None in
281-
Splitting.define_programs ~pm env evd [None] [] data.Covering.flags [prog] hook
281+
Splitting.define_programs ~pm env evd UState.default_univ_decl [None] [] data.Covering.flags [prog] hook
282282

283283
let () =
284284
let derive_no_confusion_hom ~pm env sigma ~poly v =

0 commit comments

Comments
 (0)