Skip to content

Commit 510069e

Browse files
committed
Compacting and renaming declare_mutdef.
1 parent 9a3f9fa commit 510069e

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
@@ -1998,7 +1998,7 @@ module MutualEntry : sig
19981998
-> univs:UState.named_universes_entry
19991999
-> Names.GlobRef.t list
20002000

2001-
val declare_mutdef
2001+
val declare_possibly_mutual_definitions
20022002
(* Common to all recthms *)
20032003
: pinfo:Proof_info.t
20042004
-> uctx:UState.t
@@ -2017,43 +2017,30 @@ end = struct
20172017
(body, ctx), eff
20182018
| _ -> assert false
20192019

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

2043-
let declare_mutdef ~pinfo ~uctx ~entry =
2044-
let pe = match pinfo.Proof_info.possible_guard with
2028+
let declare_possibly_mutual_definitions ~pinfo ~uctx ~entry =
2029+
let entries = match pinfo.Proof_info.possible_guard with
20452030
| None ->
20462031
(* Not a recursive statement *)
2047-
entry
2048-
| Some possible_indexes ->
2032+
[entry]
2033+
| Some possible_guard ->
20492034
(* Try all combinations... not optimal *)
20502035
let env = Global.env() in
20512036
let typing_flags = pinfo.Proof_info.info.Info.typing_flags in
20522037
let env = Environ.update_typing_flags ?typing_flags env in
2053-
Internal.map_entry_body entry
2054-
~f:(guess_decreasing env possible_indexes)
2038+
let entry = Internal.map_entry_body entry ~f:(guess_decreasing env possible_guard) in
2039+
List.map_i (fun i CInfo.{typ} -> update_mutual_entry i entry uctx typ) 0 pinfo.Proof_info.cinfo
20552040
in
2056-
let refs = List.map_i (declare_mutdef ~pinfo ~uctx pe) 0 pinfo.Proof_info.cinfo in
2041+
let { Proof_info.info = { Info.hook; scope; clearbody; kind; typing_flags; user_warns; _ } } = pinfo in
2042+
let refs = List.map2 (fun CInfo.{name; impargs} ->
2043+
declare_entry ~name ~scope ~clearbody ~kind ?hook ~impargs ~typing_flags ~user_warns ~uctx) pinfo.Proof_info.cinfo entries in
20572044
let () =
20582045
(* We override the temporary notations used while proving, now using the global names *)
20592046
let local = pinfo.info.scope=Locality.Discharge in
@@ -2199,7 +2186,7 @@ let finalize_proof ~pm proof_obj proof_info =
21992186
match CEphemeron.default proof_info.Proof_info.proof_ending Regular with
22002187
| Regular ->
22012188
let entry, uctx = check_single_entry proof_obj "Proof.save" in
2202-
pm, MutualEntry.declare_mutdef ~entry ~uctx ~pinfo:proof_info
2189+
pm, MutualEntry.declare_possibly_mutual_definitions ~entry ~uctx ~pinfo:proof_info
22032190
| End_obligation oinfo ->
22042191
let entry, uctx = check_single_entry proof_obj "Obligation.save" in
22052192
let entry = Internal.pmap_entry_body ~f:Future.force entry in

0 commit comments

Comments
 (0)