mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-12-17 13:01:31 +03:00
Merge branch 'master' of github.com:GaloisInc/cryptol
This commit is contained in:
commit
a9edd7a389
@ -64,7 +64,7 @@ library
|
||||
random >= 1.0.1,
|
||||
sbv >= 7.0,
|
||||
smtLib >= 1.0.7,
|
||||
simple-smt >= 0.7.0,
|
||||
simple-smt >= 0.7.1,
|
||||
strict,
|
||||
syb >= 0.4,
|
||||
text >= 1.1,
|
||||
|
@ -107,12 +107,12 @@ Operator Associativity
|
||||
`==>` right
|
||||
`\/` right
|
||||
`/\` right
|
||||
`||` right
|
||||
`&&` right
|
||||
`->` (types) right
|
||||
`!=` `==` not associative
|
||||
`>` `<` `<=` `>=` `<$` `>$` `<=$` `>=$` not associative
|
||||
`||` right
|
||||
`^` left
|
||||
`&&` right
|
||||
`#` right
|
||||
`>>` `<<` `>>>` `<<<` `>>$` left
|
||||
`+` `-` left
|
||||
@ -168,11 +168,11 @@ Operator Associativity Description
|
||||
`==>` right Short-cut implication
|
||||
`\/` right Short-cut or
|
||||
`/\` right Short-cut and
|
||||
`||` right Logical or
|
||||
`&&` right Logical and
|
||||
`!=` `==` none Not equals, equals
|
||||
`>` `<` `<=` `>=` `<$` `>$` `<=$` `>=$` none Comparisons
|
||||
`||` right Logical or
|
||||
`^` left Exclusive-or
|
||||
`&&` right Logical and
|
||||
`~` right Logical negation
|
||||
|
||||
Table: Bit operations.
|
||||
|
BIN
docs/Syntax.pdf
BIN
docs/Syntax.pdf
Binary file not shown.
50
tests/issues/Karatsuba.cry
Normal file
50
tests/issues/Karatsuba.cry
Normal file
@ -0,0 +1,50 @@
|
||||
module Karatsuba where
|
||||
|
||||
kmult : {limb,n} (fin n, fin limb, limb >= 6, n>=1) => [n] -> [n] -> [2*n]
|
||||
kmult x y =
|
||||
if `n <= (demote`{limb, max (width limb) (width n)}) then
|
||||
(zero#x)*(zero#y)
|
||||
else
|
||||
take (splitmult`{limb} (make_atleast`{limb} x) (make_atleast`{limb} y))
|
||||
|
||||
make_atleast : {n, m, a} (fin n, fin m, Zero a) => [m]a -> [max n m]a
|
||||
make_atleast x = zero#x
|
||||
|
||||
splitmult : {limb,n} (fin n, fin limb, limb >= 6, n>=6)
|
||||
=> [n] -> [n] -> [2*n]
|
||||
|
||||
splitmult x y = (ac # bd) + (zero # ad_bc # (zero:[low]))
|
||||
where
|
||||
type hi = n/2
|
||||
type low = n - hi
|
||||
|
||||
(a,b) = splitAt`{hi} x
|
||||
(c,d) = splitAt`{hi} y
|
||||
|
||||
ac : [2*hi]
|
||||
ac = kmult`{limb,hi} a c
|
||||
|
||||
bd : [2*low]
|
||||
bd = kmult`{limb,low} b d
|
||||
|
||||
a_b = (zext a) + (zext b)
|
||||
c_d = (zext c) + (zext d)
|
||||
|
||||
ad_bc : [2*(low+1)]
|
||||
ad_bc = (kmult`{limb,low+1} a_b c_d) - (zext ac) - (zext bd)
|
||||
|
||||
|
||||
property splitmult_correct_tiny (x:[9]) (y:[9]) =
|
||||
zext x * zext y == splitmult`{limb=7} x y
|
||||
|
||||
property splitmult_correct_small (x:[11]) (y:[11]) =
|
||||
zext x * zext y == splitmult`{limb=7} x y
|
||||
|
||||
property splitmult_correct_medium(x:[17]) (y:[17]) =
|
||||
zext x * zext y == splitmult`{limb=7} x y
|
||||
|
||||
property splitmult_correct_large (x:[59]) (y:[59]) =
|
||||
zext x * zext y == splitmult`{limb=7} x y
|
||||
|
||||
property splitmult_correct_huge (x:[511]) (y:[511]) =
|
||||
zext x * zext y == splitmult`{limb=63} x y
|
@ -1 +1,2 @@
|
||||
Known problem. See #146.
|
||||
See also #323, which seems to be another instance of the same problem.
|
||||
|
3
tests/issues/issue325.icry
Normal file
3
tests/issues/issue325.icry
Normal file
@ -0,0 +1,3 @@
|
||||
:set tests=100
|
||||
:l Karatsuba.cry
|
||||
:check splitmult_correct_large
|
6
tests/issues/issue325.icry.stdout
Normal file
6
tests/issues/issue325.icry.stdout
Normal file
@ -0,0 +1,6 @@
|
||||
Loading module Cryptol
|
||||
Loading module Cryptol
|
||||
Loading module Karatsuba
|
||||
Using random testing.
|
||||
testing...passed 100 tests.
|
||||
Coverage: 0.00% (100 of 2^^118 values)
|
7
tests/issues/issue389.cry
Normal file
7
tests/issues/issue389.cry
Normal file
@ -0,0 +1,7 @@
|
||||
pad : {n, m, b} (64>=width(n), b==512-((n+65)%512), m==65+n+b) => [n]->[m]
|
||||
pad message = (message#[True])#(0:[b])#sz
|
||||
where
|
||||
sz : [64]
|
||||
sz = width message
|
||||
|
||||
test = pad
|
3
tests/issues/issue389.icry
Normal file
3
tests/issues/issue389.icry
Normal file
@ -0,0 +1,3 @@
|
||||
:l issue389.cry
|
||||
pad (join "a")
|
||||
test (join "a")
|
5
tests/issues/issue389.icry.stdout
Normal file
5
tests/issues/issue389.icry.stdout
Normal file
@ -0,0 +1,5 @@
|
||||
Loading module Cryptol
|
||||
Loading module Cryptol
|
||||
Loading module Main
|
||||
0x61800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008
|
||||
0x61800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008
|
6
tests/issues/issue78.cry
Normal file
6
tests/issues/issue78.cry
Normal file
@ -0,0 +1,6 @@
|
||||
unique : {a,b} (fin a, fin b, a>=1) => [a][b] -> Bit
|
||||
unique xs = [ exist x (i+1) | x <- xs | i <- [0..(a-1)] ] == 0
|
||||
where exist : [b] -> [width a] -> Bit
|
||||
exist x i = if(i>=`a) then False
|
||||
else if(x==(xs@i)) then True
|
||||
else exist x (i+1)
|
2
tests/issues/issue78.icry
Normal file
2
tests/issues/issue78.icry
Normal file
@ -0,0 +1,2 @@
|
||||
:l issue78.cry
|
||||
:t unique
|
4
tests/issues/issue78.icry.stdout
Normal file
4
tests/issues/issue78.icry.stdout
Normal file
@ -0,0 +1,4 @@
|
||||
Loading module Cryptol
|
||||
Loading module Cryptol
|
||||
Loading module Main
|
||||
unique : {a, b} (fin a, fin b, a >= 1) => [a][b] -> Bit
|
Loading…
Reference in New Issue
Block a user