diff --git a/src/declare_translation.ml b/src/declare_translation.ml index cf96da0..7e9461b 100644 --- a/src/declare_translation.ml +++ b/src/declare_translation.ml @@ -20,6 +20,7 @@ let error = CErrors.user_err let ongoing_translation = Summary.ref false ~name:"parametricity ongoing translation" let ongoing_translation_opacity = Summary.ref false ~name:"parametricity ongoing translation opacity" let check_nothing_ongoing () = + let open Summary.Ref in if !ongoing_translation then error (Pp.str "Some terms are being translated, please prove pending obligations before starting a new one. End them with the command 'Parametricity Done'.") @@ -37,12 +38,14 @@ let obligation_message () = let default_continuation = ignore let parametricity_close_proof ~lemma ~pm = + let open Summary.Ref in let opaque = if !ongoing_translation_opacity then Vernacexpr.Opaque else Transparent in ongoing_translation := false; let pm, _ = Declare.Proof.save ~pm ~proof:lemma ~opaque ~idopt:None in pm let add_definition ~opaque ~hook ~poly ~scope ~kind ~tactic name env evd term typ = + let open Summary.Ref in debug Debug.all "add_definition, term = " env evd (snd (term ( evd))); debug Debug.all "add_definition, typ = " env evd typ; debug_evar_map Debug.all "add_definition, evd = " env evd; @@ -96,7 +99,7 @@ let declare_abstraction ~opaque_access ?(opaque = false) ?(continuation = defaul (try ignore (Relations.get_constant arity (UVars.out_punivs cte)); false with Not_found -> true) -> Declare.Hook.(make (fun { dref ; _ } -> - if !ongoing_translation then error (Pp.str "Please use the 'Debug.Done' command to end proof obligations generated by the parametricity tactic."); + if Summary.Ref.(!ongoing_translation) then error (Pp.str "Please use the 'Debug.Done' command to end proof obligations generated by the parametricity tactic."); Pp.(Flags.if_verbose msg_info (str (Printf.sprintf "'%s' is now a registered translation." (Names.Id.to_string name)))); let cte = (fst cte, EInstance.kind !evdr (snd cte)) in Relations.declare_relation arity (Names.GlobRef.ConstRef (UVars.out_punivs cte)) dref; @@ -138,7 +141,7 @@ let declare_constant ~opaque_access ?(continuation = default_continuation) ~scop else let cte = (cst, u) in Declare.Hook.(make (fun { dref ; _ } -> - if !ongoing_translation then error (Pp.str "Please use the 'Debug.Done' command to end proof obligations generated by the parametricity tactic."); + if Summary.Ref.(!ongoing_translation) then error (Pp.str "Please use the 'Debug.Done' command to end proof obligations generated by the parametricity tactic."); Pp.(Flags.if_verbose msg_info (str (Printf.sprintf "'%s' is now a registered translation." (Names.Id.to_string name)))); let cte = (fst cte, EInstance.kind !evdr (snd cte)) in Relations.declare_relation arity (Names.GlobRef.ConstRef (UVars.out_punivs cte)) dref; @@ -468,7 +471,7 @@ let command_reference_recursive ~opaque_access ?(continuation = default_continua command_reference ~opaque_access ~continuation ~fullname arity gref None) dep_refs () let translate_command ~opaque_access arity c name = - if !ongoing_translation then error (Pp.str "On going translation."); + if Summary.Ref.(!ongoing_translation) then error (Pp.str "On going translation."); (* Same comment as above *) let env = Global.env () in let evd = Evd.from_env env in diff --git a/src/relations.ml b/src/relations.ml index 4bd11d9..28e8d78 100644 --- a/src/relations.ml +++ b/src/relations.ml @@ -27,11 +27,13 @@ let initial_relations = IntMap.empty let relations = Summary.ref initial_relations ~name:"parametricity" let print_relations () = + let open Summary.Ref in IntMap.iter (fun n translations -> GMap.iter (fun gref c -> Feedback.(msg_info (Printer.pr_global gref))) translations ) !relations let add (n : int) f = + let open Summary.Ref in let translations = try IntMap.find n !relations with Not_found -> initial_translations in @@ -65,19 +67,23 @@ let declare_inductive_relation (n : int) (i : inductive) (i_R : inductive) = let declare_variable_relation (n : int) (v : variable) (v_R : Constant.t) = declare_relation n (GlobRef.VarRef v) (GlobRef.ConstRef v_R) -let get_constant n c = +let get_constant n c = + let open Summary.Ref in let map = IntMap.find n !relations in GMap.find (GlobRef.ConstRef c) map let get_inductive n i = + let open Summary.Ref in let map = IntMap.find n !relations in GMap.find (GlobRef.IndRef i) map let get_variable n v = + let open Summary.Ref in let map = IntMap.find n !relations in destConstRef (GMap.find (GlobRef.VarRef v) map) let is_referenced n ref = + let open Summary.Ref in try let map = IntMap.find n !relations in GMap.mem ref map