-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
loops.ec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
ECARGS ?= -I Jasmin:../../../eclib | ||
|
||
JASMIN2EC := ../../jasmin2ec | ||
|
||
.SUFFIXES: .jazz .ec | ||
|
||
all: loops.ec proofs.ec | ||
easycrypt runtest $(ECARGS) ec.config $@ | ||
|
||
clean: | ||
$(RM) loops.ec | ||
|
||
%.ec: %.jazz | ||
$(JASMIN2EC) -o $@ $^ | ||
|
||
.PHONY: all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[default] | ||
bin = easycrypt | ||
|
||
[test-all] | ||
okdirs = . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* Tests bounds of decreasing for loops */ | ||
export | ||
fn forty() -> reg u32 { | ||
inline int i j = 0; | ||
for i = 10 downto 5 { | ||
j += i; | ||
} | ||
reg u32 r = j; | ||
return r; | ||
} | ||
|
||
/* Tests nested for loops with non-immediate bounds */ | ||
param int a = 10; | ||
export | ||
fn for_nest() -> reg u32 { | ||
inline int i j k = 0; | ||
for i = 0 to a + a { | ||
for j = 0 to a * a { | ||
k += 1; | ||
} | ||
} | ||
reg u32 r = k; | ||
return r; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require import AllCore. | ||
from Jasmin require import JWord. | ||
|
||
require Loops. | ||
|
||
lemma loops_forty_correct : hoare [ Loops.M.forty: true ==> res = W32.of_int 40 ]. | ||
proof. by proc; unroll for ^while; auto. qed. | ||
|
||
lemma loops_for_nest_correct : hoare [ Loops.M.for_nest: true ==> res = W32.of_int 2000 ]. | ||
proof. | ||
proc; wp. | ||
while (0 <= i <= inc /\ k = 100 * i). | ||
- wp. | ||
while (0 <= j <= inc_0 /\ k = 100 * i + j); by auto => /#. | ||
auto => /#. | ||
qed. |