Skip to content

Commit 815618e

Browse files
committed
nits + remove dead code
1 parent 2ad7572 commit 815618e

File tree

8 files changed

+6
-193
lines changed

8 files changed

+6
-193
lines changed

src/ecMatching.ml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@ module Position = struct
1919
| `If
2020
| `While
2121
| `Assign of lvmatch
22-
<<<<<<< HEAD
23-
| `Sample
24-
| `Call
25-
=======
2622
| `Sample of lvmatch
2723
| `Call of lvmatch
2824
| `Match
29-
>>>>>>> origin/main
3025
]
3126

3227
and lvmatch = [ `LvmNone | `LvmVar of EcTypes.prog_var ]
@@ -36,16 +31,10 @@ module Position = struct
3631
| `ByMatch of int option * cp_match
3732
]
3833

39-
<<<<<<< HEAD
40-
type codepos1 = int * cp_base
41-
type codepos = (codepos1 * int) list * codepos1
42-
type codeoffset1 = [`ByOffset of int | `ByPosition of codepos1]
43-
=======
4434
type codepos_brsel = [`Cond of bool | `Match of EcSymbols.symbol]
4535
type codepos1 = int * cp_base
4636
type codepos = (codepos1 * codepos_brsel) list * codepos1
4737
type codeoffset1 = [`ByOffset of int | `ByPosition of codepos1]
48-
>>>>>>> origin/main
4938

5039
let shift1 ~(offset : int) ((o, p) : codepos1) : codepos1 =
5140
(o + offset, p)
@@ -115,18 +104,12 @@ module Zipper = struct
115104
match ir.i_node, cm with
116105
| Swhile _, `While -> i-1
117106
| Sif _, `If -> i-1
118-
<<<<<<< HEAD
119-
| Srnd _, `Sample -> i-1
120-
| Scall _, `Call -> i-1
121-
122-
=======
123107
| Smatch _, `Match -> i-1
124108

125109
| Scall (None, _, _), `Call `LvmNone -> i-1
126110

127111
| Scall (Some lv, _, _), `Call lvm
128112
| Srnd (lv, _), `Sample lvm
129-
>>>>>>> origin/main
130113
| Sasgn (lv, _), `Assign lvm -> begin
131114
match lv, lvm with
132115
| _, `LvmNone -> i-1
@@ -207,35 +190,14 @@ module Zipper = struct
207190

208191
let zipper_at_nm_cpos1
209192
(env : EcEnv.env)
210-
<<<<<<< HEAD
211-
((cp1, sub) : codepos1 * int)
212-
(s : stmt)
213-
(zpr : ipath)
214-
: (ipath * stmt) * (codepos1 * int)
215-
=======
216193
((cp1, sub) : codepos1 * codepos_brsel)
217194
(s : stmt)
218195
(zpr : ipath)
219196
: (ipath * stmt) * (codepos1 * codepos_brsel)
220-
>>>>>>> origin/main
221197
=
222198
let (s1, i, s2) = find_by_cpos1 env cp1 s in
223199
let zpr =
224200
match i.i_node, sub with
225-
<<<<<<< HEAD
226-
| Swhile (e, sw), 0 ->
227-
(ZWhile (e, ((s1, s2), zpr)), sw)
228-
229-
| Sif (e, ifs1, ifs2), 0 ->
230-
(ZIfThen (e, ((s1, s2), zpr), ifs2), ifs1)
231-
232-
| Sif (e, ifs1, ifs2), 1 ->
233-
(ZIfElse (e, ifs1, ((s1, s2), zpr)), ifs2)
234-
235-
| _ -> raise InvalidCPos
236-
in zpr, ((0, `ByPos (1 + List.length s1)), sub)
237-
238-
=======
239201
| Swhile (e, sw), `Cond true ->
240202
(ZWhile (e, ((s1, s2), zpr)), sw)
241203

@@ -259,7 +221,6 @@ module Zipper = struct
259221
| _ -> raise InvalidCPos
260222
in zpr, ((0, `ByPos (1 + List.length s1)), sub)
261223

262-
>>>>>>> origin/main
263224
let zipper_of_cpos_r (env : EcEnv.env) ((nm, cp1) : codepos) (s : stmt) =
264225
let (zpr, s), nm =
265226
List.fold_left_map

src/ecMatching.mli

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,10 @@ module Position : sig
1414
type cp_match = [
1515
| `If
1616
| `While
17-
<<<<<<< HEAD
18-
| `Assign of lvmatch
19-
| `Sample
20-
| `Call
21-
=======
2217
| `Match
2318
| `Assign of lvmatch
2419
| `Sample of lvmatch
2520
| `Call of lvmatch
26-
>>>>>>> origin/main
2721
]
2822

2923
and lvmatch = [ `LvmNone | `LvmVar of EcTypes.prog_var ]
@@ -33,16 +27,10 @@ module Position : sig
3327
| `ByMatch of int option * cp_match
3428
]
3529

36-
<<<<<<< HEAD
37-
type codepos1 = int * cp_base
38-
type codepos = (codepos1 * int) list * codepos1
39-
type codeoffset1 = [`ByOffset of int | `ByPosition of codepos1]
40-
=======
4130
type codepos_brsel = [`Cond of bool | `Match of EcSymbols.symbol]
4231
type codepos1 = int * cp_base
4332
type codepos = (codepos1 * codepos_brsel) list * codepos1
4433
type codeoffset1 = [`ByOffset of int | `ByPosition of codepos1]
45-
>>>>>>> origin/main
4634

4735
val shift1 : offset:int -> codepos1 -> codepos1
4836
val shift : offset:int -> codepos -> codepos
@@ -54,15 +42,12 @@ end
5442
module Zipper : sig
5543
open Position
5644

57-
<<<<<<< HEAD
58-
=======
5945
type spath_match_ctxt = {
6046
locals : (EcIdent.t * ty) list;
6147
prebr : ((EcIdent.t * ty) list * stmt) list;
6248
postbr : ((EcIdent.t * ty) list * stmt) list;
6349
}
6450

65-
>>>>>>> origin/main
6651
type ipath =
6752
| ZTop
6853
| ZWhile of expr * spath
@@ -127,18 +112,11 @@ module Zipper : sig
127112
*)
128113
val fold : env -> 'a -> codepos -> ('a, 'state) folder -> 'state -> stmt -> 'state * stmt
129114

130-
<<<<<<< HEAD
131-
(* [map cpos f s] is a special case of [fold] where the state and the
132-
* out-of-band data are absent
133-
*)
134-
val map : env -> codepos -> (instr -> 'a * instr list) -> stmt -> 'a * stmt
135-
=======
136115
(* [map cpos env f s] is a special case of [fold] where the state and the
137116
* out-of-band data are absent
138117
*)
139118
val map : env -> codepos -> (instr -> 'a * instr list) -> stmt -> 'a * stmt
140119

141-
>>>>>>> origin/main
142120
end
143121

144122
(* -------------------------------------------------------------------- *)

src/ecParser.mly

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,13 +1459,8 @@ lvalue_u:
14591459
| LPAREN p=plist2(qident, COMMA) RPAREN
14601460
{ PLvTuple p }
14611461

1462-
<<<<<<< HEAD
1463-
| x=lvalue_var DLBRACKET ti=tvars_app? es=plist1(expr, COMMA) RBRACKET
1464-
{ PLvMap (x, ti, es) }
1465-
=======
14661462
| x=lvalue_var DLBRACKET ti=tvars_app? e=plist1(expr, COMMA) RBRACKET
14671463
{ PLvMap (x, ti, e) }
1468-
>>>>>>> origin/main
14691464

14701465
%inline lvalue:
14711466
| x=loc(lvalue_u) { x }
@@ -2623,16 +2618,10 @@ tac_dir:
26232618
icodepos_r:
26242619
| IF { (`If :> pcp_match) }
26252620
| WHILE { (`While :> pcp_match) }
2626-
<<<<<<< HEAD
2627-
| LESAMPLE { (`Sample :> pcp_match) }
2628-
| LEAT { (`Call :> pcp_match) }
2629-
2630-
=======
26312621
| MATCH { (`Match :> pcp_match) }
26322622

26332623
| lvm=lvmatch LESAMPLE { (`Sample lvm :> pcp_match) }
26342624
| lvm=lvmatch LEAT { (`Call lvm :> pcp_match) }
2635-
>>>>>>> origin/main
26362625
| lvm=lvmatch LARROW { (`Assign lvm :> pcp_match) }
26372626

26382627
lvmatch:
@@ -3293,7 +3282,6 @@ interleave_info:
32933282

32943283
| PROC REWRITE side=side? pos=codepos SLASHEQ
32953284
{ Pprocrewrite (side, pos, `Simpl) }
3296-
<<<<<<< HEAD
32973285

32983286
| PROC CHANGE CIRCUIT o=codepos PLUS w=word s=brace(stmt)
32993287
{ Prwprgm (`Change (o, w, s)) }
@@ -3334,8 +3322,6 @@ bdepeq_out_info:
33343322

33353323
| BDEP BITSTRING
33363324
{ Pcirc }
3337-
=======
3338-
>>>>>>> origin/main
33393325

33403326
bdhoare_split:
33413327
| b1=sform b2=sform b3=sform?

src/ecProofTyping.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ let tc1_process_Xhl_formula_xreal tc pf =
175175

176176
(* ------------------------------------------------------------------ *)
177177
let tc1_process_codepos tc (side, cpos) =
178-
let me, _ = EcLowPhlGoal.tc1_get_stmt side tc in
178+
let me, _ = EcLowPhlGoal.tc1_get_stmt_with_memory side tc in
179179
let env = FApi.tc1_env tc in
180180
let env = EcEnv.Memory.push_active me env in
181181
EcTyping.trans_codepos env cpos
182182
(* ------------------------------------------------------------------ *)
183183
let tc1_process_codepos1 tc (side, cpos) =
184-
let me, _ = EcLowPhlGoal.tc1_get_stmt side tc in
184+
let me, _ = EcLowPhlGoal.tc1_get_stmt_with_memory side tc in
185185
let env = FApi.tc1_env tc in
186186
let env = EcEnv.Memory.push_active me env in
187187
EcTyping.trans_codepos1 env cpos

src/phl/ecPhlCodeTx.ml

Lines changed: 2 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,7 @@ let set_match_stmt (id : symbol) ((ue, mev, ptn) : _ * _ * form) =
178178
with EcProofTerm.FindOccFailure _ ->
179179
tc_error pe "cannot find an occurrence of the pattern"
180180

181-
<<<<<<< HEAD
182-
let t_set_match_r (side : oside) (cpos : EcMatching.Position.codepos) (id : symbol) pattern tc =
183-
=======
184181
let t_set_match_r (side : oside) (cpos : Position.codepos) (id : symbol) pattern tc =
185-
>>>>>>> origin/main
186182
let tr = fun side -> `SetMatch (side, cpos) in
187183
t_code_transform side ~bdhoare:true cpos tr
188184
(t_zip (set_match_stmt id pattern)) tc
@@ -363,7 +359,7 @@ let process_set (side, cpos, fresh, id, e) tc =
363359

364360
let process_set_match (side, cpos, id, pattern) tc =
365361
let cpos = EcProofTyping.tc1_process_codepos tc (side, cpos) in
366-
let me, _ = tc1_get_stmt side tc in
362+
let me, _ = tc1_get_stmt_with_memory side tc in
367363
let hyps = LDecl.push_active me (FApi.tc1_hyps tc) in
368364
let ue = EcProofTyping.unienv_of_hyps hyps in
369365
let ptnmap = ref Mid.empty in
@@ -472,115 +468,9 @@ let process_case ((side, pos) : side option * pcodepos) (tc : tcenv1) =
472468
if not (EcLowPhlGoal.is_program_logic concl kinds) then
473469
assert false;
474470

475-
let _, s = EcLowPhlGoal.tc1_get_stmt side tc in
471+
let s = EcLowPhlGoal.tc1_get_stmt side tc in
476472
let pos = EcProofTyping.tc1_process_codepos tc (side, pos) in
477473
let goals, s = EcMatching.Zipper.map env pos change s in
478474
let concl = EcLowPhlGoal.hl_set_stmt side concl s in
479475

480476
FApi.xmutate1 tc `ProcCase (goals @ [concl])
481-
482-
(* -------------------------------------------------------------------- *)
483-
(* Start of Code Cryogenic Vault: *)
484-
(* -------------------------------------------------------------------- *)
485-
let subst_array env (me: memenv) (insts) : memenv * instr list =
486-
let cache : (prog_var, prog_var array * ty) Map.t = Map.empty in
487-
488-
let size_of_array (arr_e: expr) = match arr_e.e_ty.ty_node with
489-
| Tconstr (p, _) -> begin match (EcPath.toqsymbol p) with
490-
| ["Top"; "Array256"; _], _ -> Some 256
491-
| ["Top"; "Array32"; _], _ -> Some 32
492-
| _, "ipoly" -> Some 256
493-
| h,t -> Format.eprintf "Unknown array type %s@." (List.fold_right (fun a b -> a ^ "." ^ b) h t);
494-
assert false
495-
end
496-
| _ -> None
497-
in
498-
let is_arr_read (e: expr) : bool =
499-
match e.e_node with
500-
| Eop (p, _) -> begin
501-
match (EcPath.toqsymbol p) with
502-
| _, "_.[_]" -> true
503-
| _ -> Format.eprintf "Unknown arr read %a@." (EcPrinting.pp_expr (EcPrinting.PPEnv.ofenv env)) e; false
504-
end
505-
| _ -> false
506-
in
507-
let is_arr_write (e: expr) : bool =
508-
match e.e_node with
509-
| Eop (p, _) -> begin
510-
match (EcPath.toqsymbol p) with
511-
| _, "_.[_<-_]" -> true
512-
| _ -> Format.eprintf "Unknown arr write %a@." (EcPrinting.pp_expr (EcPrinting.PPEnv.ofenv env)) e; false
513-
end
514-
| _ -> false
515-
in
516-
517-
let vars_of_array (arr_e : expr) : prog_var array option =
518-
let name_from_array (arr_e : expr) : string =
519-
match arr_e.e_node with
520-
| Evar (PVloc v) -> v
521-
| _ -> assert false
522-
in
523-
let name = name_from_array arr_e in
524-
match size_of_array arr_e with
525-
| None -> assert false
526-
| Some size -> Some (
527-
Array.init size (fun i ->
528-
pv_loc @@ name ^ "_" ^ (string_of_int i)))
529-
in
530-
let array_of_vars (ty:ty) (vars: prog_var array) : expr =
531-
let vars = Array.map (fun v -> e_var v ty) vars in
532-
let vars = Array.map (form_of_expr (fst me)) vars in
533-
let arr = Array.fold_left
534-
(fun acc v -> EcTypesafeFol.f_app_safe env EcCoreLib.CI_List.p_cons [v; acc])
535-
(fop_empty ty)
536-
(Array.rev vars)
537-
in
538-
let () = Format.eprintf "type of list :%a @." (EcPrinting.pp_type (EcPrinting.PPEnv.ofenv env)) arr.f_ty in
539-
let p_of_list, o_of_list = EcEnv.Op.lookup (["Array" ^ (string_of_int @@ Array.length vars)], "of_list") env in
540-
let arr = EcTypesafeFol.f_app_safe env p_of_list [Array.get vars 0; arr] in
541-
let () = Format.eprintf "type of arr :%a @." (EcPrinting.pp_type (EcPrinting.PPEnv.ofenv env)) arr.f_ty in
542-
expr_of_form (fst me) arr
543-
544-
in
545-
let rec subst_expr cache (e: expr) =
546-
match e.e_node with
547-
| Eapp (op, [{e_node=Evar arr_v} as arr_e; {e_node=Eint idx}]) when is_arr_read op ->
548-
begin match Map.find_opt arr_v cache with
549-
| Some (vars, ty) -> (cache, e_var (Array.get vars (BI.to_int idx)) e.e_ty)
550-
| None -> let vars = vars_of_array arr_e |> Option.get in
551-
(Map.add arr_v (vars, e.e_ty) cache, e_var (Array.get vars (BI.to_int idx)) e.e_ty)
552-
end
553-
| Eapp (op, args) -> let cache, args = List.fold_left_map (fun cache e -> subst_expr cache e) cache args in
554-
(cache, e_app op args e.e_ty)
555-
| _ -> (cache, e)
556-
in
557-
558-
let subst_instr cache (i: instr) =
559-
match i.i_node with
560-
| Sasgn (lv, e) -> begin match e.e_node with
561-
| Eapp (op, [{e_node=Evar arr_v} as arr_e; {e_node = Eint idx}; v])
562-
when is_arr_write op -> let cache, v = subst_expr cache v in
563-
let cache, var = match Map.find_opt arr_v cache with
564-
| Some (vars, ty) -> (cache, Array.get vars (BI.to_int idx))
565-
| None -> let vars = vars_of_array arr_e |> Option.get in
566-
(Map.add arr_v (vars, v.e_ty) cache, Array.get vars (BI.to_int idx)) in
567-
(cache, i_asgn (LvVar (var, v.e_ty), v))
568-
| Eapp _ -> let cache, e = subst_expr cache e in
569-
(cache, i_asgn (lv, e))
570-
| _ -> (cache, i)
571-
end
572-
| _ -> (cache, i)
573-
in
574-
let cache, insts = List.fold_left_map subst_instr cache insts in
575-
let arr_defs = Map.to_seq cache
576-
|> List.of_seq
577-
|> List.map (fun (arr, (vars, ty)) -> i_asgn (LvVar (arr, ty), array_of_vars ty vars))
578-
in
579-
let me = Map.fold (fun (vars, ty) me ->
580-
let vars = Array.map (fun v -> match v with | PVloc v -> {ov_name = Some v; ov_type=ty} | _ -> assert false ) vars in
581-
EcMemory.bindall (Array.to_list vars) me) cache me in
582-
(me, insts @ arr_defs)
583-
584-
(* -------------------------------------------------------------------- *)
585-
(* End of Code Cryogenic Vault: *)
586-
(* -------------------------------------------------------------------- *)

src/phl/ecPhlEqobs.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,6 @@ let t_eqobs_inS_ (info : sim_info) (tc : tcenv1) =
454454
(FApi.t_try (FApi.t_seq EcPhlSkip.t_skip t_trivial))
455455
(t_eqobs_inS sim eqo tc)
456456
| Some(p1,p2) ->
457-
let p1 = EcProofTyping.tc1_process_codepos1 tc (Some `Left , p1) in
458-
let p2 = EcProofTyping.tc1_process_codepos1 tc (Some `Right, p2) in
459457
let _,sl2 = s_split env p1 es.es_sl in
460458
let _,sr2 = s_split env p2 es.es_sr in
461459
let _, eqi =

src/phl/ecPhlRewrite.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let t_change
4141
"conclusion should be a program logic \
4242
(hoare | ehoare | phoare | equiv)";
4343

44-
let m, s = EcLowPhlGoal.tc1_get_stmt side tc in
44+
let m, s = EcLowPhlGoal.tc1_get_stmt_with_memory side tc in
4545
let (data, goals), s =
4646
EcMatching.Zipper.map (FApi.tc1_env tc) pos (change m) s in
4747
let concl = EcLowPhlGoal.hl_set_stmt side concl s in

src/phl/ecPhlRwEquiv.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ open EcMatching.Position
99
val t_rewrite_equiv :
1010
side ->
1111
[`LtoR | `RtoL ] ->
12-
pcodepos1 ->
12+
codepos1 ->
1313
equivF ->
1414
proofterm ->
1515
(expr list * lvalue option) option ->

0 commit comments

Comments
 (0)