-
Notifications
You must be signed in to change notification settings - Fork 69
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 #1609 from GaloisInc/cryptol-abstract-types
Mr Solver support for monadic Cryptol specs
- Loading branch information
Showing
14 changed files
with
327 additions
and
49 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
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,10 @@ | ||
|
||
/* The definition of the Either type as an abstract type in Cryptol */ | ||
|
||
module Either where | ||
|
||
primitive type Either : * -> * -> * | ||
|
||
primitive Left : {a, b} a -> Either a b | ||
primitive Right : {a, b} b -> Either a b | ||
primitive either : {a, b, c} (a -> c) -> (b -> c) -> Either a b -> c |
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,15 @@ | ||
/* Helper SAW script for defining the Either type in Cryptol */ | ||
|
||
eith_tp <- parse_core "\\ (a b:sort 0) -> Either a b"; | ||
cryptol_add_prim_type "Either" "Either" eith_tp; | ||
|
||
left_fun <- parse_core "\\ (a b:sort 0) (x:a) -> Left a b x"; | ||
cryptol_add_prim "Either" "Left" left_fun; | ||
|
||
right_fun <- parse_core "\\ (a b:sort 0) (x:b) -> Right a b x"; | ||
cryptol_add_prim "Either" "Right" right_fun; | ||
|
||
either_fun <- parse_core "either"; | ||
cryptol_add_prim "Either" "either" either_fun; | ||
|
||
import "Either.cry"; |
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,14 @@ | ||
|
||
module LinkedList where | ||
|
||
import Either | ||
|
||
primitive type List : * -> * | ||
|
||
primitive foldList : {a} Either () (a, List a) -> List a | ||
primitive unfoldList : {a} List a -> Either () (a, List a) | ||
|
||
is_elem_spec : [64] -> List [64] -> [64] | ||
is_elem_spec x l = | ||
either (\ _ -> 0) (\ (y,l') -> if x == y then 1 else is_elem_spec x l') | ||
(unfoldList l) |
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
Oops, something went wrong.