Skip to content

Commit 1ab788b

Browse files
authored
Merge pull request #1188 from MetaRocq/fix-fresh-univ-ind
Fix handling of fresh_universes after tmMkInductive by restarting fro…
2 parents 227922d + c837d81 commit 1ab788b

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

template-rocq/src/run_template_monad.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,9 @@ let rec run_template_program_rec ~poly ?(intactic=false) (k : Constr.t Plugin_co
535535
then not_in_tactic "tmMkInductive"
536536
else
537537
let infer_univs = unquote_bool (reduce_all env evm b) in
538-
let evm = declare_inductive env evm infer_univs mind in
538+
let _evm = declare_inductive env evm infer_univs mind in
539539
let env = Global.env () in
540+
let evm = Evd.from_env env in
540541
k ~st env evm (Lazy.force unit_tt)
541542
| TmUnquote t ->
542543
begin
@@ -569,7 +570,7 @@ let rec run_template_program_rec ~poly ?(intactic=false) (k : Constr.t Plugin_co
569570
(* Typecheck. *)
570571
let evm = Typing.check env evm (EConstr.of_constr t') (EConstr.of_constr typ) in
571572
(* Solve evars. *)
572-
let evm = Typeclasses.resolve_typeclasses env evm in
573+
let evm = Typeclasses.resolve_typeclasses env evm in
573574
let t' = Evarutil.nf_evars_universes evm t' in
574575
k ~st env evm t'
575576
| TmFreshName name ->

test-suite/_RocqProject.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@ tmVariable.v
5555
unfold.v
5656
univ.v
5757
vs.v
58+
ind_fresh_univ.v
59+

test-suite/ind_fresh_univ.v

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
From MetaRocq.Utils Require Import utils.
2+
From MetaRocq.Template Require Import All.
3+
From MetaRocq.Template Require Import Checker.
4+
Import MRMonadNotation.
5+
6+
(** MWE du bug sur les niveaux d'univers frais.*)
7+
8+
Notation nameAnon := {| binder_name := nAnon; binder_relevance := Relevant |}.
9+
10+
(* Inductive Ind (T : Type) : Prop :=. *)
11+
(* MetaRocq Run (tmQuote Ind >>= tmPrint). *)
12+
(* Modify this based on the current file. *)
13+
Definition ind : term :=
14+
tInd {| inductive_mind := (MPfile ["ind_fresh_univ";"TestSuite";"MetaRocq"], "Ind") ; inductive_ind := 0 |} [].
15+
16+
(* AST of [Inductive Ind (T : Type) : Prop :=.]. *)
17+
Definition AST_Ind := {|
18+
ind_finite := Finite;
19+
ind_npars := 1;
20+
ind_params := [{|
21+
decl_name := {| binder_name := nNamed "T"; binder_relevance := Relevant |};
22+
decl_body := None;
23+
decl_type := tSort (sType fresh_universe)
24+
|}];
25+
ind_bodies := [{|
26+
ind_name := "Ind";
27+
ind_indices := [];
28+
ind_sort := sProp;
29+
ind_type :=
30+
tProd {| binder_name := nNamed "T"; binder_relevance := Relevant |}
31+
(tSort (sType fresh_universe)) (tSort sProp);
32+
ind_kelim := IntoPropSProp;
33+
ind_ctors :=[];
34+
ind_projs := [];
35+
ind_relevance := Relevant
36+
|}];
37+
ind_universes := Monomorphic_ctx;
38+
ind_variance := None
39+
|}.
40+
41+
(* AST of [fun T : Type => Ind T]. *)
42+
Definition AST_fun :=
43+
tLambda
44+
{| binder_name := nNamed "T"; binder_relevance := Relevant |}
45+
(tSort (sType fresh_universe))
46+
(tApp ind [tRel 0]).
47+
48+
Definition define_ind : TemplateMonad unit :=
49+
tmMkInductive true (mind_body_to_entry AST_Ind).
50+
51+
Definition define_fun : TemplateMonad unit :=
52+
tmMkDefinition "def" AST_fun.
53+
54+
55+
56+
Unset MetaRocq Strict Unquote Universe Mode.
57+
58+
MetaRocq Run (_ <- define_ind;;
59+
define_fun).

0 commit comments

Comments
 (0)