Skip to content

Commit 448449d

Browse files
daejunparkrv-jenkins
authored andcommitted
data: improve element access to have constant amortized cost (#567)
* data: improve element access to have constant amortized cost * data: drop concrete version of #drop
1 parent b09338c commit 448449d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

data.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ A cons-list is used for the EVM wordstack.
421421
// ---------------------------------------------------------------------
422422
rule #drop(N, WS) => WS requires notBool N >Int 0
423423
rule #drop(N, .WordStack) => .WordStack
424-
rule #drop(N, (W : WS)) => #drop(N -Int 1, WS) requires N >Int 0
424+
rule #drop(N, (W : WS)) => #drop(1, #drop(N -Int 1, (W : WS))) requires N >Int 1
425+
rule #drop(1, (_ : WS)) => WS
425426
```
426427

427428
### Element Access
@@ -432,8 +433,8 @@ A cons-list is used for the EVM wordstack.
432433
```k
433434
syntax Int ::= WordStack "[" Int "]" [function]
434435
// -----------------------------------------------
435-
rule (W0 : WS) [N] => W0 requires N ==Int 0
436-
rule (W0 : WS) [N] => WS[N -Int 1] requires N >Int 0
436+
rule (W : _) [ N ] => W requires N ==Int 0
437+
rule WS [ N ] => #drop(N, WS) [ 0 ] requires N >Int 0
437438
438439
syntax WordStack ::= WordStack "[" Int ":=" Int "]" [function]
439440
// --------------------------------------------------------------

0 commit comments

Comments
 (0)