@@ -173,9 +173,7 @@ end = struct
173173 }
174174end
175175
176-
177176(* -------------------------------------------------------------------- *)
178-
179177type preenv = {
180178 env_top : EcPath .path option ;
181179 env_gstate : EcGState .gstate ;
@@ -191,7 +189,7 @@ type preenv = {
191189 env_rwbase : Sp .t Mip .t ;
192190 env_atbase : (path list Mint .t ) Msym .t ;
193191 env_redbase : mredinfo ;
194- env_ntbase : ( path * env_notation ) list ;
192+ env_ntbase : ntbase Mop .t ;
195193 env_modlcs : Sid .t ; (* declared modules *)
196194 env_item : theory_item list ; (* in reverse order *)
197195 env_norm : env_norm ref ;
@@ -222,6 +220,8 @@ and mredinfo = redinfo Mrd.t
222220
223221and env_notation = ty_params * EcDecl. notation
224222
223+ and ntbase = (path * env_notation) list
224+
225225(* -------------------------------------------------------------------- *)
226226type env = preenv
227227
@@ -309,7 +309,7 @@ let empty gstate =
309309 env_rwbase = Mip. empty;
310310 env_atbase = Msym. empty;
311311 env_redbase = Mrd. empty;
312- env_ntbase = [] ;
312+ env_ntbase = Mop. empty ;
313313 env_modlcs = Sid. empty;
314314 env_item = [] ;
315315 env_norm = ref empty_norm_cache; }
@@ -2837,19 +2837,33 @@ module Op = struct
28372837 let lookup_path name env =
28382838 fst (lookup name env)
28392839
2840- let bind ?(import = import0) name op env =
2841- let env = if import.im_immediate then MC. bind_operator name op env else env in
2842- let op = NormMp. norm_op env op in
2840+ let update_ntbase path (name , op ) base =
28432841 let nt =
28442842 match op.op_kind with
2845- | OB_nott nt ->
2846- Some (EcPath. pqname (root env) name, (op.op_tparams, nt))
2843+ | OB_nott nt -> begin
2844+ let head =
2845+ match nt.ont_body.e_node with
2846+ | Eapp ({ e_node = Eop (p , _ )} , _ ) | Eop (p , _ ) -> Some p
2847+ | _ -> None
2848+ in
2849+ Some (head, (EcPath. pqname path name, (op.op_tparams, nt)))
2850+ end
28472851 | _ -> None
28482852 in
28492853
2854+ ofold
2855+ (fun (hd , nt ) nts ->
2856+ Mop. change (fun nts -> Some (nt :: odfl [] nts)) hd nts)
2857+ base nt
2858+
2859+ let bind ?(import = import0) name op env =
2860+ let env = if import.im_immediate then MC. bind_operator name op env else env in
2861+ let op = NormMp. norm_op env op in
2862+ let env_ntbase = update_ntbase (root env) (name, op) env.env_ntbase in
2863+
28502864 { env with
2851- env_ntbase = ofold List. cons env.env_ntbase nt ;
2852- env_item = mkitem import (Th_operator (name, op)) :: env.env_item; }
2865+ env_ntbase;
2866+ env_item = mkitem import (Th_operator (name, op)) :: env.env_item; }
28532867
28542868 let rebind name op env =
28552869 MC. bind_operator name op env
@@ -2931,8 +2945,8 @@ module Op = struct
29312945
29322946 type notation = env_notation
29332947
2934- let get_notations env =
2935- env.env_ntbase
2948+ let get_notations ~( head : path option ) ( env : env ) =
2949+ Mop. find_def [] head env.env_ntbase
29362950
29372951 let iter ?name f (env : env ) =
29382952 gen_iter (fun mc -> mc.mc_operators) MC. lookup_operators ?name f env
@@ -3214,8 +3228,8 @@ module Theory = struct
32143228 (* ------------------------------------------------------------------ *)
32153229 let bind_nt_th =
32163230 let for1 path base = function
3217- | Th_operator (x , ({ op_kind = OB_nott nt } as op )) ->
3218- Some (( EcPath. pqname path x, (op.op_tparams, nt)) :: base)
3231+ | Th_operator (x , ({ op_kind = OB_nott _ } as op )) ->
3232+ Some (Op. update_ntbase path ( x, op) base)
32193233 | _ -> None
32203234
32213235 in bind_base_th for1
0 commit comments