Skip to content
This repository was archived by the owner on Nov 13, 2021. It is now read-only.

Commit fe23f91

Browse files
author
msozeau
committed
Improvements on coqdoc by adding more information into .glob
files, about definitions and type of references. - Add missing location information on fixpoints/cofixpoint in topconstr and syntactic definitions in vernacentries for correct dumping. - Dump definition information in vernacentries: defs, constructors, projections etc... - Modify coqdoc/index.mll to use this information instead of trying to scan the file. - Use the type information in latex output, update coqdoc.sty accordingly. - Use the hyperref package to do crossrefs between definition and references to coq objects in latex. Next step is to test and debug it on bigger developments. On the side: - Fix Program Let which was adding a Global definition. - Correct implicits for well-founded Program Fixpoints. - Add new [Method] declaration kind. git-svn-id: svn://scm.gforge.inria.fr/svn/coq/trunk@11024 85f007b7-540e-0410-9357-904b9bb8a0f7
1 parent 505c02a commit fe23f91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+554
-213
lines changed

contrib/funind/g_indfun.ml4

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ VERNAC ARGUMENT EXTEND rec_definition2
183183
| Some an ->
184184
check_exists_args an
185185
in
186-
(id, ni, bl, type_, def) ]
186+
((Util.dummy_loc,id), ni, bl, type_, def) ]
187187
END
188188

189189

contrib/funind/indfun.ml

+11-11
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ let build_newrecursive
160160
in
161161
let (rec_sign,rec_impls) =
162162
List.fold_left
163-
(fun (env,impls) (recname,_,bl,arityc,_) ->
163+
(fun (env,impls) ((_,recname),_,bl,arityc,_) ->
164164
let arityc = Command.generalize_constr_expr arityc bl in
165165
let arity = Constrintern.interp_type sigma env0 arityc in
166166
let impl =
@@ -297,7 +297,7 @@ let generate_principle on_error
297297
is_general do_built fix_rec_l recdefs interactive_proof
298298
(continue_proof : int -> Names.constant array -> Term.constr array -> int ->
299299
Tacmach.tactic) : unit =
300-
let names = List.map (function (name,_,_,_,_) -> name) fix_rec_l in
300+
let names = List.map (function ((_, name),_,_,_,_) -> name) fix_rec_l in
301301
let fun_bodies = List.map2 prepare_body fix_rec_l recdefs in
302302
let funs_args = List.map fst fun_bodies in
303303
let funs_types = List.map (function (_,_,_,types,_) -> types) fix_rec_l in
@@ -318,7 +318,7 @@ let generate_principle on_error
318318
f_R_mut)
319319
in
320320
let fname_kn (fname,_,_,_,_) =
321-
let f_ref = Ident (dummy_loc,fname) in
321+
let f_ref = Ident fname in
322322
locate_with_msg
323323
(pr_reference f_ref++str ": Not an inductive type!")
324324
locate_constant
@@ -351,7 +351,7 @@ let generate_principle on_error
351351

352352
let register_struct is_rec fixpoint_exprl =
353353
match fixpoint_exprl with
354-
| [(fname,_,bl,ret_type,body),_] when not is_rec ->
354+
| [((_,fname),_,bl,ret_type,body),_] when not is_rec ->
355355
Command.declare_definition
356356
fname
357357
(Decl_kinds.Global,Flags.boxed_definitions (),Decl_kinds.Definition)
@@ -475,7 +475,7 @@ let do_generate_principle on_error register_built interactive_proof fixpoint_exp
475475
let recdefs,rec_impls = build_newrecursive fixpoint_exprl in
476476
let _is_struct =
477477
match fixpoint_exprl with
478-
| [((name,Some (Wf (wf_rel,wf_x,using_lemmas)),args,types,body))] ->
478+
| [(((_,name),Some (Wf (wf_rel,wf_x,using_lemmas)),args,types,body))] ->
479479
let pre_hook =
480480
generate_principle
481481
on_error
@@ -488,7 +488,7 @@ let do_generate_principle on_error register_built interactive_proof fixpoint_exp
488488
if register_built
489489
then register_wf name rec_impls wf_rel wf_x using_lemmas args types body pre_hook;
490490
false
491-
| [((name,Some (Mes (wf_mes,wf_x,using_lemmas)),args,types,body))] ->
491+
| [(((_,name),Some (Mes (wf_mes,wf_x,using_lemmas)),args,types,body))] ->
492492
let pre_hook =
493493
generate_principle
494494
on_error
@@ -503,7 +503,7 @@ let do_generate_principle on_error register_built interactive_proof fixpoint_exp
503503
true
504504
| _ ->
505505
let fix_names =
506-
List.map (function (name,_,_,_,_) -> name) fixpoint_exprl
506+
List.map (function ((_,name),_,_,_,_) -> name) fixpoint_exprl
507507
in
508508
let is_one_rec = is_rec fix_names in
509509
let old_fixpoint_exprl =
@@ -535,7 +535,7 @@ let do_generate_principle on_error register_built interactive_proof fixpoint_exp
535535
in
536536
(* ok all the expressions are structural *)
537537
let fix_names =
538-
List.map (function (name,_,_,_,_) -> name) fixpoint_exprl
538+
List.map (function ((_,name),_,_,_,_) -> name) fixpoint_exprl
539539
in
540540
let is_rec = List.exists (is_rec fix_names) recdefs in
541541
if register_built then register_struct is_rec old_fixpoint_exprl;
@@ -724,21 +724,21 @@ let make_graph (f_ref:global_reference) =
724724
nal_tas
725725
)
726726
in
727-
let b' = add_args id new_args b in
727+
let b' = add_args (snd id) new_args b in
728728
(id, Some (Struct rec_id),nal_tas@bl,t,b')
729729
)
730730
fixexprl
731731
in
732732
l
733733
| _ ->
734734
let id = id_of_label (con_label c) in
735-
[(id,None,nal_tas,t,b)]
735+
[((dummy_loc,id),None,nal_tas,t,b)]
736736
in
737737
do_generate_principle error_error false false expr_list;
738738
(* We register the infos *)
739739
let mp,dp,_ = repr_con c in
740740
List.iter
741-
(fun (id,_,_,_,_) -> add_Function false (make_con mp dp (label_of_id id)))
741+
(fun ((_,id),_,_,_,_) -> add_Function false (make_con mp dp (label_of_id id)))
742742
expr_list
743743

744744

contrib/interface/xlate.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,13 @@ and (xlate_formula:Topconstr.constr_expr -> Ascent.ct_FORMULA) = function
414414
xlate_error "Second order variable not supported"
415415
| CEvar _ -> xlate_error "CEvar not supported"
416416
| CCoFix (_, (_, id), lm::lmi) ->
417-
let strip_mutcorec (fid, bl,arf, ardef) =
417+
let strip_mutcorec ((_, fid), bl,arf, ardef) =
418418
CT_cofix_rec (xlate_ident fid, xlate_binder_list bl,
419419
xlate_formula arf, xlate_formula ardef) in
420420
CT_cofixc(xlate_ident id,
421421
(CT_cofix_rec_list (strip_mutcorec lm, List.map strip_mutcorec lmi)))
422422
| CFix (_, (_, id), lm::lmi) ->
423-
let strip_mutrec (fid, (n, ro), bl, arf, ardef) =
423+
let strip_mutrec ((_, fid), (n, ro), bl, arf, ardef) =
424424
let struct_arg = make_fix_struct (n, bl) in
425425
let arf = xlate_formula arf in
426426
let ardef = xlate_formula ardef in
@@ -1939,7 +1939,7 @@ let rec xlate_vernac =
19391939
(CT_co_ind co_or_ind, CT_ind_spec_list (List.map strip_mutind lmi))
19401940
| VernacFixpoint ([],_) -> xlate_error "mutual recursive"
19411941
| VernacFixpoint ((lm :: lmi),boxed) ->
1942-
let strip_mutrec ((fid, (n, ro), bl, arf, ardef), _ntn) =
1942+
let strip_mutrec (((_,fid), (n, ro), bl, arf, ardef), _ntn) =
19431943
let struct_arg = make_fix_struct (n, bl) in
19441944
let arf = xlate_formula arf in
19451945
let ardef = xlate_formula ardef in
@@ -1952,7 +1952,7 @@ let rec xlate_vernac =
19521952
(CT_fix_rec_list (strip_mutrec lm, List.map strip_mutrec lmi))
19531953
| VernacCoFixpoint ([],boxed) -> xlate_error "mutual corecursive"
19541954
| VernacCoFixpoint ((lm :: lmi),boxed) ->
1955-
let strip_mutcorec ((fid, bl, arf, ardef), _ntn) =
1955+
let strip_mutcorec (((_,fid), bl, arf, ardef), _ntn) =
19561956
CT_cofix_rec (xlate_ident fid, xlate_binder_list bl,
19571957
xlate_formula arf, xlate_formula ardef) in
19581958
CT_cofix_decl
@@ -1974,9 +1974,9 @@ let rec xlate_vernac =
19741974
CT_ind_scheme
19751975
(CT_scheme_spec_list (strip_ind lm, List.map strip_ind lmi))
19761976
| VernacCombinedScheme _ -> xlate_error "TODO: Combined Scheme"
1977-
| VernacSyntacticDefinition (id, ([],c), false, _) ->
1977+
| VernacSyntacticDefinition ((_,id), ([],c), false, _) ->
19781978
CT_syntax_macro (xlate_ident id, xlate_formula c, xlate_int_opt None)
1979-
| VernacSyntacticDefinition (id, _, _, _) ->
1979+
| VernacSyntacticDefinition ((_,id), _, _, _) ->
19801980
xlate_error"TODO: Local abbreviations and abbreviations with parameters"
19811981
(* Modules and Module Types *)
19821982
| VernacInclude (_) -> xlate_error "TODO : Include "

contrib/subtac/subtac.ml

+26-6
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ let solve_tccs_in_type env id isevars evm c typ =
5656
(** Make all obligations transparent so that real dependencies can be sorted out by the user *)
5757
let obls = Array.map (fun (id, t, l, op, d) -> (id, t, l, false, d)) obls in
5858
match Subtac_obligations.add_definition stmt_id c' typ obls with
59-
Subtac_obligations.Defined cst -> constant_value (Global.env()) cst
59+
Subtac_obligations.Defined cst -> constant_value (Global.env())
60+
(match cst with ConstRef kn -> kn | _ -> assert false)
6061
| _ ->
6162
errorlabstrm "start_proof"
6263
(str "The statement obligations could not be resolved automatically, " ++ spc () ++
@@ -105,9 +106,24 @@ let declare_assumption env isevars idl is_coe k bl c nl =
105106
errorlabstrm "Command.Assumption"
106107
(str "Cannot declare an assumption while in proof editing mode.")
107108

108-
let vernac_assumption env isevars kind l nl =
109-
List.iter (fun (is_coe,(idl,c)) -> declare_assumption env isevars idl is_coe kind [] c nl) l
109+
let dump_definition (loc, id) s =
110+
Flags.dump_string (Printf.sprintf "%s %d %s\n" s (fst (unloc loc)) (string_of_id id))
111+
112+
let dump_constraint ty ((loc, n), _, _) =
113+
match n with
114+
| Name id -> dump_definition (loc, id) ty
115+
| Anonymous -> ()
110116

117+
let dump_variable lid = ()
118+
119+
let vernac_assumption env isevars kind l nl =
120+
let global = fst kind = Global in
121+
List.iter (fun (is_coe,(idl,c)) ->
122+
if !Flags.dump then
123+
List.iter (fun lid ->
124+
if global then dump_definition lid "ax"
125+
else dump_variable lid) idl;
126+
declare_assumption env isevars idl is_coe kind [] c nl) l
111127

112128
let subtac (loc, command) =
113129
check_required_library ["Coq";"Init";"Datatypes"];
@@ -118,6 +134,7 @@ let subtac (loc, command) =
118134
try
119135
match command with
120136
VernacDefinition (defkind, (_, id as lid), expr, hook) ->
137+
dump_definition lid "def";
121138
(match expr with
122139
| ProveBody (bl, t) ->
123140
if Lib.is_modtype () then
@@ -126,12 +143,14 @@ let subtac (loc, command) =
126143
start_proof_and_print env isevars (Some lid) (Global, DefinitionBody Definition) (bl,t)
127144
(fun _ _ -> ())
128145
| DefineBody (bl, _, c, tycon) ->
129-
ignore(Subtac_pretyping.subtac_proof env isevars id bl c tycon))
146+
ignore(Subtac_pretyping.subtac_proof defkind env isevars id bl c tycon))
130147
| VernacFixpoint (l, b) ->
148+
List.iter (fun ((lid, _, _, _, _), _) -> dump_definition lid "fix") l;
131149
let _ = trace (str "Building fixpoint") in
132150
ignore(Subtac_command.build_recursive l b)
133151

134152
| VernacStartTheoremProof (thkind, [Some id, (bl, t)], lettop, hook) ->
153+
if !Flags.dump then dump_definition id "prf";
135154
if not(Pfedit.refining ()) then
136155
if lettop then
137156
errorlabstrm "Subtac_command.StartProof"
@@ -146,11 +165,12 @@ let subtac (loc, command) =
146165
vernac_assumption env isevars stre l nl
147166

148167
| VernacInstance (glob, sup, is, props, pri) ->
168+
if !Flags.dump then dump_constraint "inst" is;
149169
ignore(Subtac_classes.new_instance ~global:glob sup is props pri)
150170

151171
| VernacCoFixpoint (l, b) ->
152-
let _ = trace (str "Building cofixpoint") in
153-
ignore(Subtac_command.build_corecursive l b)
172+
List.iter (fun ((lid, _, _, _), _) -> dump_definition lid "cofix") l;
173+
ignore(Subtac_command.build_corecursive l b)
154174

155175
(*| VernacEndProof e ->
156176
subtac_end_proof e*)

contrib/subtac/subtac_classes.ml

+6-4
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ let new_instance ?(global=false) ctx (instid, bk, cl) props ?(on_free_vars=Class
173173
List.fold_left
174174
(fun (props, rest) (id,_,_) ->
175175
try
176-
let (_, c) = List.find (fun ((_,id'), c) -> id' = id) rest in
176+
let ((loc, mid), c) = List.find (fun ((_,id'), c) -> id' = id) rest in
177177
let rest' = List.filter (fun ((_,id'), c) -> id' <> id) rest in
178+
Constrintern.add_glob loc (ConstRef (List.assoc mid k.cl_projs));
178179
c :: props, rest'
179180
with Not_found -> (CHole (Util.dummy_loc, None) :: props), rest)
180181
([], props) k.cl_props
@@ -198,12 +199,13 @@ let new_instance ?(global=false) ctx (instid, bk, cl) props ?(on_free_vars=Class
198199
(* ExplByPos (i, Some na), (true, true)) *)
199200
(* 1 ctx *)
200201
(* in *)
201-
let hook cst =
202+
let hook gr =
203+
let cst = match gr with ConstRef kn -> kn | _ -> assert false in
202204
let inst = Typeclasses.new_instance k pri global cst in
203-
Impargs.declare_manual_implicits false (ConstRef cst) false imps;
205+
Impargs.declare_manual_implicits false gr false imps;
204206
Typeclasses.add_instance inst
205207
in
206208
let evm = Subtac_utils.evars_of_term (Evd.evars_of !isevars) Evd.empty term in
207209
let obls, constr, typ = Eterm.eterm_obligations env id !isevars evm 0 term termtype in
208-
ignore(Subtac_obligations.add_definition id constr typ ~kind:Instance ~hook obls);
210+
ignore(Subtac_obligations.add_definition id constr typ ~kind:(Global,false,Instance) ~hook obls);
209211
id

contrib/subtac/subtac_command.ml

+6-12
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ let interp_gen kind isevars env
5858
?(impls=([],[])) ?(allow_patvar=false) ?(ltacvars=([],[]))
5959
c =
6060
let c' = Constrintern.intern_gen (kind=IsType) ~impls ~allow_patvar ~ltacvars (Evd.evars_of !isevars) env c in
61-
(* (try trace (str "Pretyping " ++ my_print_constr_expr c) with _ -> ()); *)
6261
let c' = SPretyping.pretype_gen isevars env ([],[]) kind c' in
6362
evar_nf isevars c'
64-
63+
6564
let interp_constr isevars env c =
6665
interp_gen (OfType None) isevars env c
6766

@@ -276,11 +275,6 @@ let build_wellfounded (recname, n, bl,arityc,body) r measure notation boxed =
276275
(* str "Intern body " ++ pr intern_body_lam) *)
277276
with _ -> ()
278277
in
279-
let _impl =
280-
if Impargs.is_implicit_args()
281-
then Impargs.compute_implicits top_env top_arity
282-
else []
283-
in
284278
let prop = mkLambda (Name argid, argtyp, it_mkProd_or_LetIn top_arity after) in
285279
(* Lift to get to constant arguments *)
286280
let lift_cst = List.length after + 1 in
@@ -309,7 +303,7 @@ let build_wellfounded (recname, n, bl,arityc,body) r measure notation boxed =
309303
let evm = evars_of_term (Evd.evars_of !isevars) evm fullcoqc in
310304
let evm = non_instanciated_map env isevars evm in
311305
let evars, evars_def, evars_typ = Eterm.eterm_obligations env recname !isevars evm 0 fullcoqc fullctyp in
312-
Subtac_obligations.add_definition recname evars_def evars_typ evars
306+
Subtac_obligations.add_definition recname evars_def evars_typ ~implicits:impls evars
313307

314308
let nf_evar_context isevars ctx =
315309
List.map (fun (n, b, t) ->
@@ -436,22 +430,22 @@ let out_n = function
436430
let build_recursive l b =
437431
let g = List.map (fun ((_,wf,_,_,_),_) -> wf) l in
438432
match g, l with
439-
[(n, CWfRec r)], [((id,_,bl,typ,def),ntn)] ->
433+
[(n, CWfRec r)], [(((_,id),_,bl,typ,def),ntn)] ->
440434
ignore(build_wellfounded (id, out_n n, bl, typ, def) r false ntn false)
441435

442-
| [(n, CMeasureRec r)], [((id,_,bl,typ,def),ntn)] ->
436+
| [(n, CMeasureRec r)], [(((_,id),_,bl,typ,def),ntn)] ->
443437
ignore(build_wellfounded (id, out_n n, bl, typ, def) r true ntn false)
444438

445439
| _, _ when List.for_all (fun (n, ro) -> ro = CStructRec) g ->
446-
let fixl = List.map (fun ((id,_,bl,typ,def),ntn) ->
440+
let fixl = List.map (fun (((_,id),_,bl,typ,def),ntn) ->
447441
({Command.fix_name = id; Command.fix_binders = bl; Command.fix_body = def; Command.fix_type = typ},ntn)) l
448442
in interp_recursive (Command.IsFixpoint g) fixl b
449443
| _, _ ->
450444
errorlabstrm "Subtac_command.build_recursive"
451445
(str "Well-founded fixpoints not allowed in mutually recursive blocks")
452446

453447
let build_corecursive l b =
454-
let fixl = List.map (fun ((id,bl,typ,def),ntn) ->
448+
let fixl = List.map (fun (((_,id),bl,typ,def),ntn) ->
455449
({Command.fix_name = id; Command.fix_binders = bl; Command.fix_body = def; Command.fix_type = typ},ntn))
456450
l in
457451
interp_recursive Command.IsCoFixpoint fixl b

0 commit comments

Comments
 (0)