@@ -143,7 +143,7 @@ module PPEnv = struct
143143 (fun env x -> EcEnv.Mod. bind_param x mty env)
144144 ppe.ppe_env xs; }
145145
146- let p_shorten cond p =
146+ let p_shorten cond ( nm , x ) =
147147 let rec shorten prefix (nm , x ) =
148148 match cond (nm, x) with
149149 | true -> (nm, x)
@@ -154,36 +154,35 @@ module PPEnv = struct
154154 end
155155 in
156156
157- let (nm, x) = P. toqsymbol p in
158157 shorten (List. rev nm) ([] , x)
159158
160159 let ty_symb (ppe : t ) p =
161160 let exists sm =
162161 try EcPath. p_equal (EcEnv.Ty. lookup_path ~unique: true sm ppe.ppe_env) p
163162 with EcEnv. LookupFailure _ -> false
164163 in
165- p_shorten exists p
164+ p_shorten exists ( P. toqsymbol p)
166165
167166 let tc_symb (ppe : t ) p =
168167 let exists sm =
169168 try EcPath. p_equal (EcEnv.TypeClass. lookup_path sm ppe.ppe_env) p
170169 with EcEnv. LookupFailure _ -> false
171170 in
172- p_shorten exists p
171+ p_shorten exists ( P. toqsymbol p)
173172
174173 let rw_symb (ppe : t ) p =
175174 let exists sm =
176175 try EcPath. p_equal (EcEnv.BaseRw. lookup_path sm ppe.ppe_env) p
177176 with EcEnv. LookupFailure _ -> false
178177 in
179- p_shorten exists p
178+ p_shorten exists ( P. toqsymbol p)
180179
181180 let ax_symb (ppe : t ) p =
182181 let exists sm =
183182 try EcPath. p_equal (EcEnv.Ax. lookup_path sm ppe.ppe_env) p
184183 with EcEnv. LookupFailure _ -> false
185184 in
186- p_shorten exists p
185+ p_shorten exists ( P. toqsymbol p)
187186
188187 let op_symb (ppe : t ) p info =
189188 let specs = [1 , EcPath. pqoname (EcPath. prefix EcCoreLib.CI_Bool. p_eq) " <>" ] in
@@ -221,21 +220,21 @@ module PPEnv = struct
221220 (* FIXME: for special operators, do check `info` *)
222221 if List. exists (fun (_ , sp ) -> EcPath. p_equal sp p) specs
223222 then ([] , EcPath. basename p)
224- else p_shorten exists p
223+ else p_shorten exists ( P. toqsymbol p)
225224
226225 let ax_symb (ppe : t ) p =
227226 let exists sm =
228227 try EcPath. p_equal (EcEnv.Ax. lookup_path sm ppe.ppe_env) p
229228 with EcEnv. LookupFailure _ -> false
230229 in
231- p_shorten exists p
230+ p_shorten exists ( P. toqsymbol p)
232231
233232 let th_symb (ppe : t ) p =
234233 let exists sm =
235234 try EcPath. p_equal (EcEnv.Theory. lookup_path sm ppe.ppe_env) p
236235 with EcEnv. LookupFailure _ -> false
237236 in
238- p_shorten exists p
237+ p_shorten exists ( P. toqsymbol p)
239238
240239 let rec mod_symb (ppe : t ) mp : EcSymbols.msymbol =
241240 let (nm, x, p2) =
@@ -361,6 +360,18 @@ module PPEnv = struct
361360end
362361
363362(* -------------------------------------------------------------------- *)
363+ let shorten_path (cond : P.path -> qsymbol -> bool ) (p : P.path ) : qsymbol * qsymbol option =
364+ let (nm, x) = EcPath. toqsymbol p in
365+ let nm =
366+ match nm with
367+ | top :: nm when top = EcCoreLib. i_top -> nm
368+ | _ -> nm in
369+ let nm', x' = PPEnv. p_shorten (cond p) (nm, x) in
370+ let plong, pshort = (nm, x), (nm', x') in
371+
372+ (plong, if plong = pshort then None else Some pshort)
373+
374+ (* -------------------------------------xz------------------------------- *)
364375let pp_id pp fmt x = Format. fprintf fmt " %a" pp x
365376
366377(* -------------------------------------------------------------------- *)
@@ -434,33 +445,16 @@ let pp_path fmt p =
434445 Format. fprintf fmt " %s" (P. tostring p)
435446
436447(* -------------------------------------------------------------------- *)
437- let pp_long_short_path (lk : qsymbol -> (EcPath.path * 'a) option ) fmt p =
438- let rec doit prefix (nm , x ) =
439- match lk (nm, x) with
440- | Some (p' , _ ) when EcPath. p_equal p p' ->
441- (nm, x)
442- | _ -> begin
443- match prefix with
444- | [] -> (nm, x)
445- | n :: prefix -> doit prefix (n :: nm, x)
446- end
447- in
448+ let pp_shorten_path (cond : P.path -> qsymbol -> bool ) (fmt : Format.formatter ) (p : P.path ) =
449+ let plong, pshort = shorten_path cond p in
448450
449- let (nm, x) = EcPath. toqsymbol p in
450- let nm =
451- match nm with
452- | top :: nm when top = EcCoreLib. i_top ->
453- nm
454- | _ -> nm in
455-
456- let nm', x' = doit (List. rev nm) ([] , x) in
457- let plong, pshort = (nm, x), (nm', x') in
458- match plong, pshort with
459- | plong , pshort when plong = pshort -> Format. fprintf fmt " %a" EcSymbols. pp_qsymbol plong
460- | plong , pshort ->
461- Format. fprintf fmt " %a (shorten name: %a)"
462- EcSymbols. pp_qsymbol plong
463- EcSymbols. pp_qsymbol pshort
451+ match pshort with
452+ | None ->
453+ Format. fprintf fmt " %a" EcSymbols. pp_qsymbol plong
454+ | Some pshort ->
455+ Format. fprintf fmt " %a (shorten name: %a)"
456+ EcSymbols. pp_qsymbol plong
457+ EcSymbols. pp_qsymbol pshort
464458
465459(* -------------------------------------------------------------------- *)
466460let rec pp_msymbol (fmt : Format.formatter ) (mx : msymbol ) =
0 commit comments