Skip to content

Commit aa23b15

Browse files
committed
Compacting and renaming declare_mutdef.
1 parent 59e468b commit aa23b15

File tree

1 file changed

+15
-28
lines changed

1 file changed

+15
-28
lines changed

vernac/declare.ml

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,7 @@ module MutualEntry : sig
19961996
-> univs:UState.named_universes_entry
19971997
-> Names.GlobRef.t list
19981998

1999-
val declare_mutdef
1999+
val declare_possibly_mutual_definitions
20002000
(* Common to all recthms *)
20012001
: pinfo:Proof_info.t
20022002
-> uctx:UState.t
@@ -2015,43 +2015,30 @@ end = struct
20152015
(body, ctx), eff
20162016
| _ -> assert false
20172017

2018-
let declare_mutdef ~uctx ~pinfo pe i CInfo.{ name; impargs; typ; _} =
2019-
let { Proof_info.info; possible_guard; _ } = pinfo in
2020-
let { Info.hook; scope; clearbody; kind; typing_flags; user_warns; _ } = info in
2018+
let update_mutual_entry i entry uctx typ =
20212019
(* if i = 0 , we don't touch the type; this is for compat
20222020
but not clear it is the right thing to do.
20232021
*)
2024-
let pe =
2025-
if i > 0 && Option.has_some possible_guard
2026-
then
2027-
let typ = UState.nf_universes uctx typ in
2028-
Internal.map_entry_type pe ~f:(fun _ -> Some typ)
2029-
else pe
2030-
in
2031-
(* We when possible_guard was [] in the previous step we should not
2032-
substitute the body *)
2033-
let pe = match possible_guard with
2034-
| None -> pe
2035-
| _ ->
2036-
Internal.map_entry_body pe
2037-
~f:(fun ((body, ctx), eff) -> (select_body i body, ctx), eff)
2038-
in
2039-
declare_entry ~name ~scope ~clearbody ~kind ?hook ~impargs ~typing_flags ~user_warns ~uctx pe
2022+
{ entry with
2023+
proof_entry_body = Future.chain entry.proof_entry_body (fun ((body, uctx), eff) -> ((select_body i body, uctx), eff));
2024+
proof_entry_type = if i > 0 then Some (UState.nf_universes uctx typ) else entry.proof_entry_type }
20402025

2041-
let declare_mutdef ~pinfo ~uctx ~entry =
2042-
let pe = match pinfo.Proof_info.possible_guard with
2026+
let declare_possibly_mutual_definitions ~pinfo ~uctx ~entry =
2027+
let entries = match pinfo.Proof_info.possible_guard with
20432028
| None ->
20442029
(* Not a recursive statement *)
2045-
entry
2046-
| Some possible_indexes ->
2030+
[entry]
2031+
| Some possible_guard ->
20472032
(* Try all combinations... not optimal *)
20482033
let env = Global.env() in
20492034
let typing_flags = pinfo.Proof_info.info.Info.typing_flags in
20502035
let env = Environ.update_typing_flags ?typing_flags env in
2051-
Internal.map_entry_body entry
2052-
~f:(guess_decreasing env possible_indexes)
2036+
let entry = Internal.map_entry_body entry ~f:(guess_decreasing env possible_guard) in
2037+
List.map_i (fun i CInfo.{typ} -> update_mutual_entry i entry uctx typ) 0 pinfo.Proof_info.cinfo
20532038
in
2054-
let refs = List.map_i (declare_mutdef ~pinfo ~uctx pe) 0 pinfo.Proof_info.cinfo in
2039+
let { Proof_info.info = { Info.hook; scope; clearbody; kind; typing_flags; user_warns; _ } } = pinfo in
2040+
let refs = List.map2 (fun CInfo.{name; impargs} ->
2041+
declare_entry ~name ~scope ~clearbody ~kind ?hook ~impargs ~typing_flags ~user_warns ~uctx) pinfo.Proof_info.cinfo entries in
20552042
let () =
20562043
(* We override the temporary notations used while proving, now using the global names *)
20572044
let local = pinfo.info.scope=Locality.Discharge in
@@ -2197,7 +2184,7 @@ let finalize_proof ~pm proof_obj proof_info =
21972184
match CEphemeron.default proof_info.Proof_info.proof_ending Regular with
21982185
| Regular ->
21992186
let entry, uctx = check_single_entry proof_obj "Proof.save" in
2200-
pm, MutualEntry.declare_mutdef ~entry ~uctx ~pinfo:proof_info
2187+
pm, MutualEntry.declare_possibly_mutual_definitions ~entry ~uctx ~pinfo:proof_info
22012188
| End_obligation oinfo ->
22022189
let entry, uctx = check_single_entry proof_obj "Obligation.save" in
22032190
let entry = Internal.pmap_entry_body ~f:Future.force entry in

0 commit comments

Comments
 (0)