Skip to content

Commit 8debf27

Browse files
authored
Reworked outline tactic
* Reworked outline and function unification. No longer need to provide left-values, instead use the alias mode via '~'. * more refactoring, using the new code position ranges * slightly more flexible unification
1 parent b3f6888 commit 8debf27

22 files changed

Lines changed: 365 additions & 326 deletions

examples/MEE-CBC/CBC.eca

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ section Random_Ideal.
187187
equiv Random_Ideal: Random.enc ~ Ideal.enc: size p{1} = size p{2} ==> ={res}.
188188
proof.
189189
proc.
190-
outline {2} [1] { r <@ Sampling.Sample.sample(size p + 1); }.
190+
outline {2} 1 by { r <@ Sampling.Sample.sample(size p + 1); }.
191191
rewrite equiv[{2} 1 Sampling.Sample_LoopSnoc_eq].
192192
by inline; wp; while (={i} /\ c{1} = l{2} /\ size p{1} + 1 = n{2}); auto=> /#.
193193
qed.

src/ecMatching.ml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,20 @@ module Zipper = struct
252252

253253
let zipper_of_cpos_range env cpr s =
254254
let top, bot = cpr in
255-
let zpr = zipper_of_cpos env top s in
255+
let zpr, (_, pos) = zipper_of_cpos_r env top s in
256256
match bot with
257-
| `Base cp ->
258-
let path = (zipper_of_cpos env cp s).z_path in
259-
if path <> zpr.z_path then
257+
| `Base cp -> begin
258+
let zpr', (_, pos') = zipper_of_cpos_r env cp s in
259+
(* The two positions should identify the same block *)
260+
if zpr'.z_path <> zpr.z_path then
260261
raise InvalidCPos;
261-
zpr, snd cp
262+
263+
(* The end position should be after the start *)
264+
match pos, pos' with
265+
| (_, `ByPos x), (_, `ByPos y) when x <= y ->
266+
zpr, (0, `ByPos (y - x))
267+
| _ -> raise InvalidCPos
268+
end
262269
| `Offset cp1 -> zpr, cp1
263270

264271
let split_at_cpos1 env cpos1 s =

src/ecParser.mly

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,8 +2904,9 @@ interleave_info:
29042904
{ (s, c1, c2 :: c3, k) }
29052905

29062906
%inline outline_kind:
2907-
| s=brace(stmt) { OKstmt(s) }
2908-
| r=sexpr? LEAT f=loc(fident) { OKproc(f, r) }
2907+
| BY s=brace(stmt) { OKstmt(s) }
2908+
| TILD f=loc(fident) { OKproc(f, true) }
2909+
| f=loc(fident) { OKproc(f, false) }
29092910

29102911
%public phltactic:
29112912
| PROC
@@ -2985,11 +2986,10 @@ interleave_info:
29852986
| INLINE s=side? u=inlineopt? p=codepos
29862987
{ Pinline (`CodePos (s, u, p)) }
29872988

2988-
| OUTLINE s=side LBRACKET st=codepos1 e=option(MINUS e=codepos1 {e}) RBRACKET k=outline_kind
2989+
| OUTLINE s=side cpr=codepos_or_range k=outline_kind
29892990
{ Poutline {
29902991
outline_side = s;
2991-
outline_start = st;
2992-
outline_end = odfl st e;
2992+
outline_range = cpr;
29932993
outline_kind = k }
29942994
}
29952995

src/ecParsetree.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,11 @@ type inline_info = [
665665
(* -------------------------------------------------------------------- *)
666666
type outline_kind =
667667
| OKstmt of pstmt
668-
| OKproc of pgamepath * pexpr option
668+
| OKproc of pgamepath * bool
669669

670670
type outline_info = {
671671
outline_side: side;
672-
outline_start: pcodepos1;
673-
outline_end: pcodepos1;
672+
outline_range: pcodepos_range;
674673
outline_kind: outline_kind;
675674
}
676675

src/ecProofTyping.ml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,27 @@ let tc1_process_Xhl_formula ?side tc pf =
173173
let tc1_process_Xhl_formula_xreal tc pf =
174174
tc1_process_Xhl_form tc txreal pf
175175

176+
(* ------------------------------------------------------------------ *)
177+
let tc1_process_codepos_range tc (side, cpr) =
178+
let me, _ = EcLowPhlGoal.tc1_get_stmt side tc in
179+
let env = FApi.tc1_env tc in
180+
let env = EcEnv.Memory.push_active me env in
181+
EcTyping.trans_codepos_range env cpr
182+
176183
(* ------------------------------------------------------------------ *)
177184
let tc1_process_codepos tc (side, cpos) =
178185
let me, _ = EcLowPhlGoal.tc1_get_stmt side tc in
179186
let env = FApi.tc1_env tc in
180187
let env = EcEnv.Memory.push_active me env in
181188
EcTyping.trans_codepos env cpos
189+
182190
(* ------------------------------------------------------------------ *)
183191
let tc1_process_codepos1 tc (side, cpos) =
184192
let me, _ = EcLowPhlGoal.tc1_get_stmt side tc in
185193
let env = FApi.tc1_env tc in
186194
let env = EcEnv.Memory.push_active me env in
187195
EcTyping.trans_codepos1 env cpos
188-
196+
189197
(* ------------------------------------------------------------------ *)
190198
(* FIXME: factor out to typing module *)
191199
(* FIXME: TC HOOK - check parameter constraints *)

src/ecProofTyping.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ val tc1_process_stmt :
6363
val tc1_process_prhl_stmt :
6464
?map:EcTyping.ismap -> tcenv1 -> side -> pstmt -> stmt
6565

66+
val tc1_process_codepos_range : tcenv1 -> oside * pcodepos_range -> codepos_range
6667
val tc1_process_codepos : tcenv1 -> oside * pcodepos -> codepos
6768
val tc1_process_codepos1 : tcenv1 -> oside * pcodepos1 -> codepos1
6869

src/ecTyping.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ type ismap = (instr list) EcMaps.Mstr.t
230230
val transstmt : ?map:ismap -> env -> EcUnify.unienv -> pstmt -> stmt
231231

232232
(* -------------------------------------------------------------------- *)
233+
val trans_codepos_range : ?memory:EcMemory.memory -> env -> pcodepos_range -> codepos_range
233234
val trans_codepos1 : ?memory:EcMemory.memory -> env -> pcodepos1 -> codepos1
234235
val trans_codepos : ?memory:EcMemory.memory -> env -> pcodepos -> codepos
235236
val trans_dcodepos1 : ?memory:EcMemory.memory -> env -> pcodepos1 doption -> codepos1 doption

0 commit comments

Comments
 (0)