@@ -27,39 +27,134 @@ let build_induction_scheme_in_type env dep sort ind =
2727 let sigma, pind = Evd. fresh_inductive_instance ~rigid: UState. univ_rigid env sigma ind in
2828 let sigma, sort = Evd. fresh_sort_in_quality ~rigid: UnivRigid sigma sort in
2929 let sigma, c = build_induction_scheme env sigma pind dep sort in
30- EConstr. to_constr sigma c, Evd. ustate sigma
30+ Some (EConstr. to_constr sigma c, Evd. ustate sigma)
31+
32+ let build_mutual_induction_scheme_in_type env dep sort isrec l =
33+ let ind,_ = match l with | x ::_ -> x | [] -> assert false in
34+ let sigma, inst =
35+ let _, ctx = Typeops. type_of_global_in_context env (Names.GlobRef. IndRef (ind,0 )) in
36+ let u, ctx = UnivGen. fresh_instance_from ctx None in
37+ let u = EConstr.EInstance. make u in
38+ let sigma = Evd. from_ctx (UState. of_context_set ctx) in
39+ sigma, u
40+ in
41+ let n = List. length l in
42+ let sigma, lrecspec =
43+ let rec loop i n sigma ll =
44+ if i> = n then (sigma,ll)
45+ else
46+ let new_sigma, new_sort = Evd. fresh_sort_in_quality ~rigid: UnivRigid sigma sort in
47+ let (indd,ii) = List. nth l i in
48+ let new_l = List. append ll [(((indd,ii),inst),dep,new_sort)] in
49+ loop (i + 1 ) n new_sigma new_l
50+ in
51+ loop 0 n sigma []
52+ in
53+ let sigma, listdecl =
54+ if isrec then Indrec. build_mutual_induction_scheme env sigma ~force_mutual: false lrecspec
55+ else
56+ List. fold_left_map (fun sigma (ind ,dep ,sort ) ->
57+ let sigma, c = Indrec. build_case_analysis_scheme env sigma ind dep sort in
58+ let c, _ = Indrec. eval_case_analysis c in
59+ sigma, c)
60+ sigma lrecspec
61+ in
62+ let array = Array. of_list listdecl in
63+ let l = Array. map (fun x -> EConstr. to_constr sigma x) array in
64+ Some (l, Evd. ustate sigma)
65+
66+ let make_suff_sort one_ind suff dep =
67+ match one_ind with
68+ | None -> suff
69+ | Some i ->
70+ let sort = i.mind_sort
71+ in
72+ match sort with
73+ | Prop -> if dep then (Names.Id. to_string i.mind_typename) ^ " _" ^ suff ^ " _dep"
74+ else (Names.Id. to_string i.mind_typename) ^ " _" ^ suff
75+ | Type _ | SProp | Set -> if dep then (Names.Id. to_string i.mind_typename) ^ " _" ^ suff
76+ else (Names.Id. to_string i.mind_typename) ^ " _" ^ suff ^ " _nodep"
77+ | QSort _ -> (Names.Id. to_string i.mind_typename) ^ " _" ^ suff
3178
3279let rect_dep =
33- declare_individual_scheme_object " rect_dep"
34- (fun env _ x -> build_induction_scheme_in_type env true QualityOrSet. qtype x)
80+ declare_individual_scheme_object ([" Induction" ], Some QualityOrSet. qtype)
81+ (fun id -> make_suff_sort id " rect" true )
82+ (fun env _ x _ -> build_induction_scheme_in_type env true QualityOrSet. qtype x)
83+
84+ let mutual_rect_dep =
85+ declare_mutual_scheme_object ([" Induction" ], Some QualityOrSet. qtype)
86+ (fun id -> make_suff_sort id " rect" true )
87+ (fun env _ x _ -> build_mutual_induction_scheme_in_type env true QualityOrSet. qtype true x)
3588
3689let rec_dep =
37- declare_individual_scheme_object " rec_dep"
38- (fun env _ x -> build_induction_scheme_in_type env true QualityOrSet. set x)
90+ declare_individual_scheme_object ([" Induction" ], Some QualityOrSet. set)
91+ (fun id -> make_suff_sort id " rec" true )
92+ (fun env _ x _ -> build_induction_scheme_in_type env true QualityOrSet. set x)
93+
94+ let mutual_rec_dep =
95+ declare_mutual_scheme_object ([" Induction" ], Some QualityOrSet. set)
96+ (fun id -> make_suff_sort id " rec" true )
97+ (fun env _ x _ -> build_mutual_induction_scheme_in_type env true QualityOrSet. set true x)
3998
4099let ind_dep =
41- declare_individual_scheme_object " ind_dep"
42- (fun env _ x -> build_induction_scheme_in_type env true QualityOrSet. prop x)
100+ declare_individual_scheme_object ([" Induction" ], Some QualityOrSet. prop)
101+ (fun id -> make_suff_sort id " ind" true )
102+ (fun env _ x _ -> build_induction_scheme_in_type env true QualityOrSet. prop x)
103+
104+ let mutual_ind_dep =
105+ declare_mutual_scheme_object ([" Induction" ], Some QualityOrSet. prop)
106+ (fun id -> make_suff_sort id " ind" true )
107+ (fun env _ x _ -> build_mutual_induction_scheme_in_type env true QualityOrSet. prop true x)
43108
44109let sind_dep =
45- declare_individual_scheme_object " sind_dep"
46- (fun env _ x -> build_induction_scheme_in_type env true QualityOrSet. sprop x)
110+ declare_individual_scheme_object ([" Induction" ], Some QualityOrSet. sprop)
111+ (fun id -> make_suff_sort id " inds" true )
112+ (fun env _ x _ -> build_induction_scheme_in_type env true QualityOrSet. sprop x)
113+
114+ let mutual_sind_dep =
115+ declare_mutual_scheme_object ([" Induction" ], Some QualityOrSet. sprop)
116+ (fun id -> make_suff_sort id " inds" true )
117+ (fun env _ x _ -> build_mutual_induction_scheme_in_type env true QualityOrSet. sprop true x)
47118
48119let rect_nodep =
49- declare_individual_scheme_object " rect_nodep"
50- (fun env _ x -> build_induction_scheme_in_type env false QualityOrSet. qtype x)
120+ declare_individual_scheme_object ([" Minimality" ], Some QualityOrSet. qtype)
121+ (fun id -> make_suff_sort id " rect" false )
122+ (fun env _ x _ -> build_induction_scheme_in_type env false QualityOrSet. qtype x)
123+
124+ let mutual_rect_nodep =
125+ declare_mutual_scheme_object ([" Minimality" ], Some QualityOrSet. qtype)
126+ (fun id -> make_suff_sort id " rect" false )
127+ (fun env _ x _ -> build_mutual_induction_scheme_in_type env false QualityOrSet. qtype true x)
51128
52129let rec_nodep =
53- declare_individual_scheme_object " rec_nodep"
54- (fun env _ x -> build_induction_scheme_in_type env false QualityOrSet. set x)
130+ declare_individual_scheme_object ([" Minimality" ], Some QualityOrSet. set)
131+ (fun id -> make_suff_sort id " rec" false )
132+ (fun env _ x _ -> build_induction_scheme_in_type env false QualityOrSet. set x)
133+
134+ let mutual_rec_nodep =
135+ declare_mutual_scheme_object ([" Minimality" ], Some QualityOrSet. set)
136+ (fun id -> make_suff_sort id " rec" false )
137+ (fun env _ x _ -> build_mutual_induction_scheme_in_type env false QualityOrSet. set true x)
55138
56139let ind_nodep =
57- declare_individual_scheme_object " ind_nodep"
58- (fun env _ x -> build_induction_scheme_in_type env false QualityOrSet. prop x)
140+ declare_individual_scheme_object ([" Minimality" ], Some QualityOrSet. prop)
141+ (fun id -> make_suff_sort id " ind" false )
142+ (fun env _ x _ -> build_induction_scheme_in_type env false QualityOrSet. prop x)
143+
144+ let mutual_ind_nodep =
145+ declare_mutual_scheme_object ([" Minimality" ], Some QualityOrSet. prop)
146+ (fun id -> make_suff_sort id " ind" false )
147+ (fun env _ x _ -> build_mutual_induction_scheme_in_type env false QualityOrSet. prop true x)
59148
60149let sind_nodep =
61- declare_individual_scheme_object " sind_nodep"
62- (fun env _ x -> build_induction_scheme_in_type env false QualityOrSet. sprop x)
150+ declare_individual_scheme_object ([" Minimality" ], Some QualityOrSet. sprop)
151+ (fun id -> make_suff_sort id " inds" false )
152+ (fun env _ x _ -> build_induction_scheme_in_type env false QualityOrSet. sprop x)
153+
154+ let mutual_sind_nodep =
155+ declare_mutual_scheme_object ([" Minimality" ], Some QualityOrSet. sprop)
156+ (fun id -> make_suff_sort id " inds" false )
157+ (fun env _ x _ -> build_mutual_induction_scheme_in_type env false QualityOrSet. sprop true x)
63158
64159let elim_scheme ~dep ~to_kind =
65160 let open QualityOrSet in
@@ -118,7 +213,7 @@ let lookup_eliminator_by_name env ind_sp s =
118213let deprecated_lookup_by_name =
119214 CWarnings. create ~name: " deprecated-lookup-elim-by-name" ~category: Deprecation.Version. v9_1
120215 Pp. (fun (env ,ind ,to_kind ,r ) ->
121- let pp_scheme () s = str (scheme_kind_name s) in
216+ let pp_scheme () s = str (match scheme_kind_name s with ( ss , _ , _ ) -> String. concat " " ss ) in
122217 fmt " Found unregistered eliminator %t for %t by name.@ \
123218 Use \" Register Scheme\" with it instead@ \
124219 (\" as %a\" if dependent or \" as %a\" if non dependent)."
@@ -156,20 +251,44 @@ let build_case_analysis_scheme_in_type env dep sort ind =
156251 let sigma, sort = Evd. fresh_sort_in_quality ~rigid: UnivRigid sigma sort in
157252 let (sigma, c) = build_case_analysis_scheme env sigma indu dep sort in
158253 let (c, _) = Indrec. eval_case_analysis c in
159- EConstr.Unsafe. to_constr c, Evd. ustate sigma
254+ Some ( EConstr.Unsafe. to_constr c, Evd. ustate sigma)
160255
161256let case_dep =
162- declare_individual_scheme_object " case_dep"
163- (fun env _ x -> build_case_analysis_scheme_in_type env true QualityOrSet. qtype x)
164-
165- let case_nodep =
166- declare_individual_scheme_object " case_nodep"
167- (fun env _ x -> build_case_analysis_scheme_in_type env false QualityOrSet. qtype x)
257+ declare_individual_scheme_object ([" Elimination" ], Some QualityOrSet. qtype)
258+ (fun id -> make_suff_sort id " caset" true )
259+ (fun env _ x _ -> build_case_analysis_scheme_in_type env true QualityOrSet. qtype x)
168260
169261let casep_dep =
170- declare_individual_scheme_object " casep_dep"
171- (fun env _ x -> build_case_analysis_scheme_in_type env true QualityOrSet. prop x)
262+ declare_individual_scheme_object ([" Elimination" ], Some QualityOrSet. prop)
263+ (fun id -> make_suff_sort id " case" true )
264+ (fun env _ x _ -> build_case_analysis_scheme_in_type env true QualityOrSet. prop x)
265+
266+ let cases_dep =
267+ declare_individual_scheme_object ([" Elimination" ], Some QualityOrSet. sprop)
268+ (fun id -> make_suff_sort id " cases" true )
269+ (fun env _ x _ -> build_case_analysis_scheme_in_type env true QualityOrSet. sprop x)
270+
271+ let casep_dep_set =
272+ declare_individual_scheme_object ([" Elimination" ], Some QualityOrSet. set)
273+ (fun id -> make_suff_sort id " case" true )
274+ (fun env _ x _ -> build_case_analysis_scheme_in_type env true QualityOrSet. set x)
275+
276+ let case_nodep =
277+ declare_individual_scheme_object ([" Case" ], Some QualityOrSet. qtype)
278+ (fun id -> make_suff_sort id " caset" false )
279+ (fun env _ x _ -> build_case_analysis_scheme_in_type env false QualityOrSet. qtype x)
172280
173281let casep_nodep =
174- declare_individual_scheme_object " casep_nodep"
175- (fun env _ x -> build_case_analysis_scheme_in_type env false QualityOrSet. prop x)
282+ declare_individual_scheme_object ([" Case" ], Some QualityOrSet. prop)
283+ (fun id -> make_suff_sort id " case" false )
284+ (fun env _ x _ -> build_case_analysis_scheme_in_type env false QualityOrSet. prop x)
285+
286+ let cases_nodep =
287+ declare_individual_scheme_object ([" Case" ], Some QualityOrSet. sprop)
288+ (fun id -> make_suff_sort id " cases" false )
289+ (fun env _ x _ -> build_case_analysis_scheme_in_type env false QualityOrSet. sprop x)
290+
291+ let case_nodep_set =
292+ declare_individual_scheme_object ([" Case" ], Some QualityOrSet. set)
293+ (fun id -> make_suff_sort id " case" false )
294+ (fun env _ x _ -> build_case_analysis_scheme_in_type env false QualityOrSet. set x)
0 commit comments