statement stringlengths 1 746 | proof stringlengths 0 19.5k | type stringclasses 7
values | symbolic_name stringlengths 1 36 | library stringclasses 13
values | filename stringclasses 70
values | imports listlengths 0 23 | deps listlengths 0 14 | docstring stringclasses 1
value | source_url stringclasses 1
value | commit stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|
fromToDownByGreaterThan : {first, bound, stride, a}
(fin first, fin stride, stride >= 1, first >= bound, Literal first a) =>
[(first - bound)/^stride]a
/**
* A finite arithmetic sequence starting with 'first' and 'next',
* stopping when the values reach or would skip over 'last'.
*
* '[x,y..z]' is syntactic su... | primitive | fromToDownByGreaterThan | lib | lib/Cryptol.cry | [] | [
">=",
"Literal",
"fin",
"first"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
fromThenTo : {first, next, last, a, len}
( fin first, fin next, fin last
, Literal first a, Literal next a, Literal last a
, first != next
, lengthFromThenTo first next last == len) => [len]a
// Fractional Literals ------------... | primitive | fromThenTo | lib | lib/Cryptol.cry | [] | [
"!=",
"==",
"Literal",
"fin",
"first",
"last"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
FLiteral : # -> # -> # -> * -> Prop
/** A fractional literal corresponding to 'm/n' */ | primitive type | FLiteral | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
fraction : { m, n, r, a } FLiteral m n r a => a
// The Zero class -------------------------------------------------------
/** Value types that have a notion of 'zero'. */ | primitive | fraction | lib | lib/Cryptol.cry | [] | [
"FLiteral"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Zero : * -> Prop
/**
* Gives an arbitrary shaped value whose bits are all False.
* ~zero likewise gives an arbitrary shaped value whose bits are all True.
*/ | primitive type | Zero | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
zero : {a} (Zero a) => a
// The Logic class ------------------------------------------------------
/** Value types that support logical operations. */ | primitive | zero | lib | lib/Cryptol.cry | [] | [
"Zero"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Logic : * -> Prop
/**
* Logical 'and' over bits. Extends element-wise over sequences, tuples.
*/ | primitive type | Logic | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(&&) : {a} (Logic a) => a -> a -> a
/**
* Logical 'or' over bits. Extends element-wise over sequences, tuples.
*/ | primitive | && | lib | lib/Cryptol.cry | [] | [
"Logic"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(||) : {a} (Logic a) => a -> a -> a
/**
* Logical 'exclusive or' over bits. Extends element-wise over sequences, tuples.
*/ | primitive | || | lib | lib/Cryptol.cry | [] | [
"Logic"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(^) : {a} (Logic a) => a -> a -> a
/**
* Bitwise complement. The prefix notation '~ x'
* is syntactic sugar for 'complement x'.
*/ | primitive | ^ | lib | lib/Cryptol.cry | [] | [
"Logic"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
complement : {a} (Logic a) => a -> a
// The Ring class -------------------------------------------------------
/**
* Value types that support ring addition and multiplication.
*
* Floating-point values are only approximately a ring, but
* nonetheless inhabit this class.
*/ | primitive | complement | lib | lib/Cryptol.cry | [] | [
"Logic"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Ring : * -> Prop
/**
* Converts an unbounded integer to a value in a Ring using the following rules:
* * to bitvector type [n]:
* the value is reduced modulo 2^^n,
* * to Z n:
* the value is reduced modulo n,
* * floating point types:
* the value is rounded to the nearest representable value,
... | primitive type | Ring | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
fromInteger : {a} (Ring a) => Integer -> a
/**
* Add two values.
* * For type [n], addition is modulo 2^^n.
* * Structured values are added element-wise.
*/ | primitive | fromInteger | lib | lib/Cryptol.cry | [] | [
"Integer",
"Ring"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(+) : {a} (Ring a) => a -> a -> a
/**
* Subtract two values.
* * For type [n], subtraction is modulo 2^^n.
* * Structured values are subtracted element-wise.
* * Satisfies 'a - b = a + negate b'.
* See also: 'negate'.
*/ | primitive | + | lib | lib/Cryptol.cry | [] | [
"Ring"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(-) : {a} (Ring a) => a -> a -> a
/**
* Multiply two values.
* * For type [n], multiplication is modulo 2^^n.
* * Structured values are multiplied element-wise.
*/ | primitive | - | lib | lib/Cryptol.cry | [] | [
"Ring"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(*) : {a} (Ring a) => a -> a -> a
/**
* Returns the additive inverse of its argument.
* Over structured values, operates element-wise.
* The prefix notation '- x' is syntactic sugar
* for 'negate x'.
*
* Satisfies 'a + negate a = 0'.
* Satisfies 'negate a = ~a + 1' for bitvector values.
*/ | primitive | * | lib | lib/Cryptol.cry | [] | [
"Ring"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
negate : {a} (Ring a) => a -> a
// The Integral class -------------------------------------------------
/**
* Value types that correspond to a segment of the
* integers. These types support integer division and
* modulus, indexing into sequences, and enumeration.
*/ | primitive | negate | lib | lib/Cryptol.cry | [] | [
"Ring"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Integral : * -> Prop
/**
* Divide two values, rounding down (toward negative infinity).
* * For type [n], the arguments are treated as unsigned.
* * Division by zero is undefined.
*/ | primitive type | Integral | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(/) : {a} (Integral a) => a -> a -> a
/**
* Compute the remainder from dividing two values.
* * For type [n], the arguments are treated as unsigned.
* * Remainder of division by zero is undefined.
* * Satisfies 'x % y == x - (x / y) * y'.
*/ | primitive | / | lib | lib/Cryptol.cry | [] | [
"Integral"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(%) : {a} (Integral a) => a -> a -> a
/**
* Converts a value of an integral type to an integer.
*/ | primitive | % | lib | lib/Cryptol.cry | [] | [
"Integral"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
toInteger : {a} (Integral a) => a -> Integer
/**
* Compute the exponentiation of a value in a ring.
* * For type [n], the exponent is treated as unsigned.
* * It is an error to raise a value to a negative integer exponent.
* * Satisfies: 'x ^^ 0 == fromInteger 1'
* * Satisfies: 'x ^^ e == x * x ^^ (e-1)' when... | primitive | toInteger | lib | lib/Cryptol.cry | [] | [
"Integer",
"Integral"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(^^) : {a, e} (Ring a, Integral e) => a -> e -> a
/**
* An infinite sequence counting up from the given starting value.
* '[x...]' is syntactic sugar for 'infFrom x'.
*/ | primitive | ^^ | lib | lib/Cryptol.cry | [] | [
"Integral",
"Ring"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
infFrom : {a} (Integral a) => a -> [inf]a
/**
* An infinite arithmetic sequence starting with the given two values.
* '[x,y...]' is syntactic sugar for 'infFromThen x y'.
*/ | primitive | infFrom | lib | lib/Cryptol.cry | [] | [
"Integral"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
infFromThen : {a} (Integral a) => a -> a -> [inf]a
// The Field class -------------------------------------------------
/**
* Value types that correspond to a field; that is,
* a ring also possessing multiplicative inverses for
* non-zero elements.
*
* Floating-point values are only approximately a field,
* bu... | primitive | infFromThen | lib | lib/Cryptol.cry | [] | [
"Integral"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Field : * -> Prop
/**
* Reciprocal
*
* Compute the multiplicative inverse of an element of a field.
* The reciprocal of 0 is undefined.
*/ | primitive type | Field | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
recip : {a} (Field a) => a -> a
/**
* Field division
*
* The division operation in a field.
* Satisfies 'x /. y == x * (recip y)'
*
* Field division by 0 is undefined.
*/ | primitive | recip | lib | lib/Cryptol.cry | [] | [
"Field"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(/.) : {a} (Field a) => a -> a -> a
// The Round class -------------------------------------------------
/** Value types that can be rounded to integer values. */ | primitive | /. | lib | lib/Cryptol.cry | [] | [
"Field"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Round : * -> Prop
/**
* Ceiling function.
*
* Given 'x', compute the smallest integer 'i'
* such that 'x <= i'.
*/ | primitive type | Round | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
ceiling : {a} (Round a) => a -> Integer
/**
* Floor function.
*
* Given 'x', compute the largest integer 'i'
* such that 'i <= x'.
*/ | primitive | ceiling | lib | lib/Cryptol.cry | [] | [
"Integer",
"Round"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
floor : {a} (Round a) => a -> Integer
/**
* Truncate the value toward 0.
*
* Given 'x' compute the nearest integer between
* 'x' and 0. For nonnegative 'x', this is floor,
* and for negative 'x' this is ceiling.
*/ | primitive | floor | lib | lib/Cryptol.cry | [] | [
"Integer",
"Round"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
trunc : {a} (Round a) => a -> Integer
/**
* Round to the nearest integer, ties away from 0.
*
* Ties are broken away from 0. For nonnegative 'x'
* this is 'floor (x + 0.5)'. For negative 'x' this
* is 'ceiling (x - 0.5)'.
*/ | primitive | trunc | lib | lib/Cryptol.cry | [] | [
"Integer",
"Round"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
roundAway : {a} (Round a) => a -> Integer
/**
* Round to the nearest integer, ties to even.
*
* Ties are broken to the nearest even integer.
*/ | primitive | roundAway | lib | lib/Cryptol.cry | [] | [
"Integer",
"Round"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
roundToEven : {a} (Round a) => a -> Integer
// The Eq class ----------------------------------------------------
/** Value types that support equality comparisons. */ | primitive | roundToEven | lib | lib/Cryptol.cry | [] | [
"Integer",
"Round"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Eq : * -> Prop
/**
* Compares any two values of the same type for equality.
*/ | primitive type | Eq | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(==) : {a} (Eq a) => a -> a -> Bit
/**
* Compares any two values of the same type for inequality.
*/ | primitive | == | lib | lib/Cryptol.cry | [] | [
"Bit",
"Eq"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(!=) : {a} (Eq a) => a -> a -> Bit
/**
* Compare the outputs of two functions for equality.
*/ | primitive | != | lib | lib/Cryptol.cry | [] | [
"Bit",
"Eq"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Cmp : * -> Prop
/**
* Less-than. Only works on comparable arguments.
*
* Bitvectors are compared using unsigned arithmetic.
*/ | primitive type | Cmp | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(<) : {a} (Cmp a) => a -> a -> Bit
/**
* Greater-than of two comparable arguments.
*
* Bitvectors are compared using unsigned arithmetic.
*/ | primitive | < | lib | lib/Cryptol.cry | [] | [
"Bit",
"Cmp"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(>) : {a} (Cmp a) => a -> a -> Bit
/**
* Less-than or equal of two comparable arguments.
*
* Bitvectors are compared using unsigned arithmetic.
*/ | primitive | > | lib | lib/Cryptol.cry | [] | [
"Bit",
"Cmp"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(<=) : {a} (Cmp a) => a -> a -> Bit
/**
* Greater-than or equal of two comparable arguments.
*
* Bitvectors are compared using unsigned arithmetic.
*/ | primitive | <= | lib | lib/Cryptol.cry | [] | [
"Bit",
"Cmp"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(>=) : {a} (Cmp a) => a -> a -> Bit
/**
* Returns the smaller of two comparable arguments.
* Bitvectors are compared using unsigned arithmetic.
*/ | primitive | >= | lib | lib/Cryptol.cry | [] | [
"Bit",
"Cmp"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
SignedCmp : * -> Prop
/**
* 2's complement signed less-than.
*/ | primitive type | SignedCmp | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(<$) : {a} (SignedCmp a) => a -> a -> Bit
/**
* 2's complement signed greater-than.
*/ | primitive | <$ | lib | lib/Cryptol.cry | [] | [
"Bit",
"SignedCmp"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
True : Bit
/**
* The constant False. Corresponds to the bit value 0.
*/ | primitive | True | lib | lib/Cryptol.cry | [] | [
"Bit"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
False : Bit
/**
* Short-cutting boolean conjunction function.
* If the first argument is False, the second argument
* is not evaluated.
*/ | primitive | False | lib | lib/Cryptol.cry | [] | [
"Bit"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(/$) : {n} (fin n, n >= 1) => [n] -> [n] -> [n]
/**
* 2's complement signed remainder. Division rounds toward 0.
* Division by 0 is undefined. Satisfies the following for 'y != 0'
*
* * 'x %$ y == x - (x /$ y) * y'.
* * 'x >=$ 0 ==> x %$ y >=$ 0'
* * 'x <=$ 0 ==> x %$ y <=$ 0'
*/ | primitive | /$ | lib | lib/Cryptol.cry | [] | [
">=",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(%$) : {n} (fin n, n >= 1) => [n] -> [n] -> [n]
/**
* Unsigned carry. Returns true if the unsigned addition of the given
* bitvector arguments would result in an unsigned overflow.
*/ | primitive | %$ | lib | lib/Cryptol.cry | [] | [
">=",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(>>$) : {n, ix} (fin n, n >= 1, Integral ix) => [n] -> ix -> [n]
/**
* The ceiling of the base-2 logarithm of an unsigned bitvector.
* We set 'lg2 0 = 0'.
*/ | primitive | >>$ | lib | lib/Cryptol.cry | [] | [
">=",
"Integral",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
lg2 : {n} (fin n) => [n] -> [n]
/**
* Convert a signed 2's complement bitvector to an integer.
*/ | primitive | lg2 | lib | lib/Cryptol.cry | [] | [
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
toSignedInteger : {n} (fin n, n >= 1) => [n] -> Integer
// Rational specific operations ----------------------------------------------
/**
* Compute the ratio of two integers as a rational.
* Ratio is undefined if the denominator is 0.
*
* 'ratio x y = (fromInteger x /. fromInteger y) : Rational'
*/ | primitive | toSignedInteger | lib | lib/Cryptol.cry | [] | [
">=",
"Integer",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
ratio : Integer -> Integer -> Rational
// Zn specific operations ----------------------------------------------------
/**
* Converts an integer modulo n to an unbounded integer in the range 0 to n-1.
*/ | primitive | ratio | lib | lib/Cryptol.cry | [] | [
"Integer",
"Rational"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
fromZ : {n} (fin n, n >= 1) => Z n -> Integer
// Sequence operations -------------------------------------------------------
/**
* Concatenates two sequences. On bitvectors, the most-significant bits
* are in the left argument, and the least-significant bits are in the right.
*/ | primitive | fromZ | lib | lib/Cryptol.cry | [] | [
">=",
"Integer",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(#) : {front, back, a} (fin front) => [front]a -> [back]a
-> [front + back] a
/**
* Splits a sequence into a pair of sequences.
* 'splitAt z = (x, y)' iff 'x # y = z'.
*/ | primitive | # | lib | lib/Cryptol.cry | [] | [
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
join : {parts, each, a} (fin each) => [parts][each]a
-> [parts * each]a
/**
* Splits a sequence into 'parts' groups with 'each' elements.
* 'split' is the inverse function to 'join'.
*/ | primitive | join | lib | lib/Cryptol.cry | [] | [
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
split : {parts, each, a} (fin each) => [parts * each]a
-> [parts][each]a
/**
* Reverses the elements in a sequence.
*/ | primitive | split | lib | lib/Cryptol.cry | [] | [
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
reverse : {n, a} (fin n) => [n]a -> [n]a
/**
* Transposes a matrix.
* Satisfies the property 'transpose m @ i @ j == m @ j @ i'.
*/ | primitive | reverse | lib | lib/Cryptol.cry | [] | [
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
transpose : {rows, cols, a} [rows][cols]a -> [cols][rows]a
/**
* Select the first (left-most) 'front' elements of a sequence.
*/ | primitive | transpose | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
take : {front, back, a} [front + back]a -> [front]a
/**
* Select all the elements after (to the right of) the 'front' elements of a sequence.
*/ | primitive | take | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
drop : {front, back, a} (fin front) => [front + back]a -> [back]a
/**
* Drop the first (left-most) element of a sequence.
*/ | primitive | drop | lib | lib/Cryptol.cry | [] | [
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(<<) : {n, ix, a} (Integral ix, Zero a) => [n]a -> ix -> [n]a
/**
* Right shift. The first argument is the sequence to shift, the second is the
* number of positions to shift by.
*/ | primitive | << | lib | lib/Cryptol.cry | [] | [
"Integral",
"Zero"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(>>) : {n, ix, a} (Integral ix, Zero a) => [n]a -> ix -> [n]a
/**
* Left rotate. The first argument is the sequence to rotate, the second is the
* number of positions to rotate by.
*/ | primitive | >> | lib | lib/Cryptol.cry | [] | [
"Integral",
"Zero"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(<<<) : {n, ix, a} (fin n, Integral ix) => [n]a -> ix -> [n]a
/**
* Right rotate. The first argument is the sequence to rotate, the second is
* the number of positions to rotate by.
*/ | primitive | <<< | lib | lib/Cryptol.cry | [] | [
"Integral",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(>>>) : {n, ix, a} (fin n, Integral ix) => [n]a -> ix -> [n]a
/**
* Index operator. The first argument is a sequence. The second argument is
* the zero-based index of the element to select from the sequence.
*/ | primitive | >>> | lib | lib/Cryptol.cry | [] | [
"Integral",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(@) : {n, a, ix} (Integral ix) => [n]a -> ix -> a
/**
* Bulk index operator. The first argument is a sequence. The second argument
* is a sequence of the zero-based indices of the elements to select.
*/ | primitive | @ | lib | lib/Cryptol.cry | [] | [
"Integral"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(!) : {n, a, ix} (fin n, Integral ix) => [n]a -> ix -> a
/**
* Bulk reverse index operator. The first argument is a finite sequence. The
* second argument is a sequence of the zero-based indices of the elements to
* select, starting from the end of the sequence.
*/ | primitive | ! | lib | lib/Cryptol.cry | [] | [
"Integral",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
update : {n, a, ix} (Integral ix) => [n]a -> ix -> a -> [n]a
/**
* Update the given sequence with new value at the given index position.
* The first argument is a sequence. The second argument is the zero-based
* index of the element to update, starting from the end of the sequence.
* The third argument is the new... | primitive | update | lib | lib/Cryptol.cry | [] | [
"Integral"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
updateEnd : {n, a, ix} (fin n, Integral ix) => [n]a -> ix -> a -> [n]a
/**
* Perform a series of updates to a sequence. The first argument is
* the initial sequence to update. The second argument is a sequence
* of indices, and the third argument is a sequence of values.
* This function applies the 'update' func... | primitive | updateEnd | lib | lib/Cryptol.cry | [] | [
"Integral",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
pmult : {u, v} (fin u, fin v) => [1 + u] -> [1 + v] -> [1 + u + v]
/**
* Performs division of polynomials over GF(2).
*/ | primitive | pmult | lib | lib/Cryptol.cry | [] | [
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
pdiv : {u, v} (fin u, fin v) => [u] -> [v] -> [u]
/**
* Performs modulus of polynomials over GF(2).
*/ | primitive | pdiv | lib | lib/Cryptol.cry | [] | [
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
pmod : {u, v} (fin u, fin v) => [u] -> [1 + v] -> [v]
// Experimental primitives ------------------------------------------------------------
/**
* Parallel map. The given function is applied to each element in the
* given finite sequence, and the results are computed in parallel.
* The values in the resulting se... | primitive | pmod | lib | lib/Cryptol.cry | [] | [
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
parmap : {a, b, n} (Eq b, fin n) => (a -> b) -> [n]a -> [n]b
// Utility operations -----------------------------------------------------------------
/**
* A strictness-increasing operation. The first operand
* is reduced to normal form before evaluating the second
* argument.
*
* The Eq constraint restricts th... | primitive | parmap | lib | lib/Cryptol.cry | [] | [
"Eq",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
deepseq : {a, b} Eq a => a -> b -> b
/**
* Reduce to normal form.
*
* The Eq constraint restricts this operation to types
* where reduction to normal form makes sense.
*/ | primitive | deepseq | lib | lib/Cryptol.cry | [] | [
"Eq"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
error : {a, n} (fin n) => String n -> a
/**
* Raise a run-time error with a generic message.
* This function can be called at any type.
*/ | primitive | error | lib | lib/Cryptol.cry | [] | [
"String",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
random : {a} [256] -> a
/**
* Debugging function for tracing. The first argument is a string,
* which is prepended to the printed value of the second argument.
* This combined string is then printed when the trace function is
* evaluated. The return value is equal to the third argument.
*
* The exact timing an... | primitive | random | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
trace : {n, a, b} (fin n) => String n -> a -> b -> b
/**
* Debugging function for tracing values. The first argument is a string,
* which is prepended to the printed value of the second argument.
* This combined string is then printed when the trace function is
* evaluated. The return value is equal to the secon... | primitive | trace | lib | lib/Cryptol.cry | [] | [
"String",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
foldl : {n, a, b} (fin n) => (a -> b -> a) -> a -> [n]b -> a
/**
* Functional left fold, with strict evaluation of the accumulator value.
* The accumulator is reduced to normal form at each step. The Eq constraint
* restricts the accumulator to types where reduction to normal form makes sense.
*
* foldl' (+) 0 [... | primitive | foldl | lib | lib/Cryptol.cry | [] | [
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
foldl' : {n, a, b} (fin n, Eq a) => (a -> b -> a) -> a -> [n]b -> a
/**
* Functional right fold.
*
* foldr (-) 0 [1,2,3] = 0 - (1 - (2 - 3))
*/ | primitive | foldl' | lib | lib/Cryptol.cry | [] | [
"Eq",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
scanl : {n, a, b} (a -> b -> a) -> a -> [n]b -> [1+n]a
/**
* Scan right is like a foldr that also emits the intermediate values.
*/ | primitive | scanl | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
demote : {val, rep} Literal val rep => rep | demote = number`{val}
/**
* Return the length of a sequence. Note that the result depends only
* on the type of the argument, not its value.
*/ | function | demote | lib | lib/Cryptol.cry | [] | [
"Literal"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
length : {n, a, b} (fin n, Literal n b) => [n]a -> b | length _ = `n
/**
* A finite sequence counting up from 'first' to 'last'.
*
* '[x .. y]' is syntactic sugar for 'fromTo`{first=x,last=y}'.
*/ | function | length | lib | lib/Cryptol.cry | [] | [
"Literal",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
(===) : {a, b} (Eq b) => (a -> b) -> (a -> b) -> (a -> Bit) | function | === | lib | lib/Cryptol.cry | [] | [
"Bit",
"Eq"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(!==) : {a, b} (Eq b) => (a -> b) -> (a -> b) -> (a -> Bit) | function | !== | lib | lib/Cryptol.cry | [] | [
"Bit",
"Eq"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
min : {a} (Cmp a) => a -> a -> a | min x y = if x < y then x else y
/**
* Returns the greater of two comparable arguments.
* Bitvectors are compared using unsigned arithmetic.
*/ | function | min | lib | lib/Cryptol.cry | [] | [
"Cmp"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
max : {a} (Cmp a) => a -> a -> a | max x y = if x > y then x else y
/**
* Compute the absolute value of a value from an ordered ring.
* Bitvector values are considered unsigned, so this is
* the identity function on [n].
*/ | function | max | lib | lib/Cryptol.cry | [] | [
"Cmp"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
abs : {a} (Cmp a, Ring a) => a -> a | abs x = if x < fromInteger 0 then negate x else x
// The SignedCmp class ----------------------------------------------
/** Value types that support signed comparisons. */ | function | abs | lib | lib/Cryptol.cry | [] | [
"Cmp",
"Ring",
"fromInteger",
"negate"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
(>$) : {a} (SignedCmp a) => a -> a -> Bit | function | >$ | lib | lib/Cryptol.cry | [] | [
"Bit",
"SignedCmp"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(<=$) : {a} (SignedCmp a) => a -> a -> Bit | function | <=$ | lib | lib/Cryptol.cry | [] | [
"Bit",
"SignedCmp"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(>=$) : {a} (SignedCmp a) => a -> a -> Bit | function | >=$ | lib | lib/Cryptol.cry | [] | [
"Bit",
"SignedCmp"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(/\) : Bit -> Bit -> Bit | function | /\ | lib | lib/Cryptol.cry | [] | [
"Bit"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(\/) : Bit -> Bit -> Bit | function | \/ | lib | lib/Cryptol.cry | [] | [
"Bit"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(==>) : Bit -> Bit -> Bit | function | ==> | lib | lib/Cryptol.cry | [] | [
"Bit"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
carry : {n} (fin n) => [n] -> [n] -> Bit | carry x y = (x + y) < x
/**
* Signed carry. Returns true if the 2's complement signed addition of the
* given bitvector arguments would result in a signed overflow.
*/ | function | carry | lib | lib/Cryptol.cry | [] | [
"Bit",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
scarry : {n} (fin n, n >= 1) => [n] -> [n] -> Bit | scarry x y = (sx == sy) && (sx != sz)
where
z = x + y
sx = head x
sy = head y
sz = head z
/**
* Signed borrow. Returns true if the 2's complement signed subtraction of the
* given bitvector arguments would result in a signed overflow.
*/ | function | scarry | lib | lib/Cryptol.cry | [] | [
"!=",
"&&",
"==",
">=",
"Bit",
"fin",
"head"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
sborrow : {n} (fin n, n >= 1) => [n] -> [n] -> Bit | sborrow x y = ( x <$ (x-y) ) ^ head y
/**
* Zero extension of a bitvector.
*/ | function | sborrow | lib | lib/Cryptol.cry | [] | [
"<$",
">=",
"Bit",
"fin",
"head"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
zext : {m, n} (fin m, m >= n) => [n] -> [m] | zext x = zero # x
/**
* Sign extension of a bitvector.
*/ | function | zext | lib | lib/Cryptol.cry | [] | [
">=",
"fin",
"zero"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
sext : {m, n} (fin m, m >= n, n >= 1) => [n] -> [m] | sext x = newbits # x
where newbits = if head x then ~zero else zero
/**
* 2's complement signed (arithmetic) right shift. The first argument
* is the sequence to shift (considered as a signed value),
* the second argument is the number of positions to shift
* by (considered as an unsigned value).
*/ | function | sext | lib | lib/Cryptol.cry | [] | [
">=",
"fin",
"head",
"zero"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
splitAt : {front, back, a} (fin front) => [front + back]a
-> ([front]a, [back]a) | splitAt xs = (take`{front,back} xs, drop`{front,back} xs)
/**
* Concatenates a list of sequences.
* 'join' is the inverse function to 'split'.
*/ | function | splitAt | lib | lib/Cryptol.cry | [] | [
"fin",
"xs"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
tail : {n, a} [1 + n]a -> [n]a | tail xs = drop`{1} xs
/**
* Return the first (left-most) element of a sequence.
*/ | function | tail | lib | lib/Cryptol.cry | [] | [
"xs"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
head : {n, a} [1 + n]a -> a | head xs = xs @ (0 : Integer)
/**
* Return the right-most element of a sequence.
*/ | function | head | lib | lib/Cryptol.cry | [] | [
"Integer",
"xs"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
last : {n, a} (fin n) => [1 + n]a -> a | last xs = xs ! (0 : Integer)
/**
* Same as 'split', but with a different type argument order.
* Take a sequence of elements and break it into 'parts' sequences
* of 'each' elements.
*/ | function | last | lib | lib/Cryptol.cry | [] | [
"Integer",
"fin",
"xs"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.