-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1911 from GaloisInc/bb/constraint-guards
Add support for translating Cryptol constraint guards
- Loading branch information
Showing
6 changed files
with
153 additions
and
5 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
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,21 @@ | ||
module Test where | ||
|
||
// Exhaustive constraint guards with some overlapping branches | ||
guard : {w} [w] -> Integer | ||
guard x | ||
| (w == 32) => 0 | ||
| (w >= 32) => 1 | ||
| (w < 8) => 2 | ||
| (w != 8, w != 9) => 3 | ||
| () => 4 | ||
|
||
// Non-exhaustive constraint guard | ||
incomplete : {w} [w] -> Bool | ||
incomplete x | ||
| (w == 32) => True | ||
|
||
// More dependently typed case | ||
dependent : {n} [n] | ||
dependent | ||
| n == 1 => [True] | ||
| () => repeat False |
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,18 @@ | ||
import "Test.cry"; | ||
|
||
// Test exhaustive constraint guards | ||
prove_print z3 {{ \(x : [32]) -> guard x == 0 }}; | ||
prove_print z3 {{ \(x : [34]) -> guard x == 1 }}; | ||
prove_print z3 {{ \(x : [4]) -> guard x == 2 }}; | ||
prove_print z3 {{ \(x : [16]) -> guard x == 3 }}; | ||
prove_print z3 {{ \(x : [8]) -> guard x == 4}}; | ||
prove_print z3 {{ \(x : [9]) -> guard x == 4}}; | ||
|
||
// Test non-exhaustive constraint guards | ||
prove_print z3 {{ \(x : [32]) -> incomplete x }}; | ||
fails (prove_print z3 {{ \(x : [64]) -> incomplete x }}); | ||
|
||
// Test more dependently typed constraint guards | ||
prove_print z3 {{ dependent`{1} == [True] }}; | ||
prove_print z3 {{ dependent`{3} == [False, False, False] }}; | ||
prove_print z3 {{ dependent`{0} == [] }}; |
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,3 @@ | ||
set -e | ||
|
||
$SAW test.saw |