StaticEvaluation Module
Module StaticEvaluation implements static evaluation of constant expressions of scalar types. To this end, all scalar types are assumed to be reduced to boolean lists, and depending on the operator, these boolean lists may simply be bitvectors, radix-2 numbers or 2-complement numbers. It is always assumed that radix-2 numbers have no redundant leading zeros, and that 2-complement numbers do not have redundant signs. In addition to the static evaluation functions, the module also provides translations of constants of Quartz expressions given as strings to boolean lists as given by functions NatConstStr2BL for nat-constants, BinBitConst2BL for binary bv-constants, OctBitConst2BL for octal bv-constants, and HexBitConst2BL for hexadecimal bv-constants. Functions NatDecStr2BL, BL2NatDecStr, Nat2BL, BL2Nat convert between natural numbers and their radix-2 representations (as boolean lists) and analogously IntDecStr2BL, BL2IntDecStr, Int2BL, BL2Int convert between integers and their 2-complement representations (as boolean lists) Finally, the module provides some additional arithmetic operators like Div, Mod, FloorLog2, and CeilLog2.
Functions and values
Function or value | Description |
Full Usage:
BL2Int bl
Parameters:
bool list
Returns: int
|
BL2Int converts boolean lists that are viewed as 2-complement representations of an integer to an F# integer i. Caution: The function may fail if bl cannot be represented with 32-bits.
|
|
|
|
"BL2IntDecStrSign plus minus bl" expects a boolean list bl that is interpreted as 2-complement representation of an integer number X. The function then determines the radix-10 representation of X in terms of a string consisting of decimal digits 0,...,0. In addition, two strings "plus" and "minus" must be given that are used to prefix the generated string in case the number is non-negative or negative, respectively.
|
Full Usage:
BL2Nat bl
Parameters:
bool list
Returns: int
|
BL2Nat converts boolean lists that are viewed as radix-2 representations to a non-negative integer i. Caution: The function may fail if bl cannot be represented as a 32-bit integer.
|
|
Given a boolean list bl that is understood as binary representation of a natural number, BL2NatDecStr(bl) computes a string s that consists of decimal digits 0,...,9 that is the radix-10 representation of the the considered natural number.
|
Full Usage:
BinBitConst2BL bvs
Parameters:
string
Returns: bool list
|
BinBitConst2BL s expects a string like "0b1011" that represents a binary bitvector constant in Quartz. The prefix "0b" is then removed and the remaining string is converted to a boolean list by mapping 0 and 1 to false and true, respectively.
|
Full Usage:
CeilLog2 n
Parameters:
int
Returns: int
|
CeilLog2(n) is the least integer greater than or equal to log2(n). i.e., CeilLog2 n = int (ceil ((log (double n)) / (log 2.0)))
|
Full Usage:
Div (x, y)
Parameters:
int
y : int
Returns: int
|
Div implements the mathematical definition of integer division, i.e.
Div(x,y) is that number q where an integer r exists such that
(1) x=q*y+r, (2) abs(r)
|
Full Usage:
FloorLog2 n
Parameters:
int
Returns: int
|
FloorLog2(n) is the greatest integer less than or equal to log2(n). i.e., FloorLog2 n = int (floor ((log (double n)) / (log 2.0)))
|
Full Usage:
HexBitConst2BL bvs
Parameters:
string
Returns: bool list
|
HexBitConst2BL s expects a string like "0x7342" that represents an hexadecimal bitvector constant in Quartz. The prefix "0x" is then removed and the remaining string is converted to a boolean list by mapping the hexadecimal digits to their corresponding radix-2 representations.
|
Full Usage:
Int2BL i
Parameters:
int
Returns: bool list
|
Int2BL converts any non-negative integer i to its 2-complement representation given as a boolean list.
|
Full Usage:
IntDecStr2BL s
Parameters:
string
Returns: bool list
|
IntDecStr2BL(s) expects a string s that must start with '+' or '-' and consists of decimal digits 0,...,9 otherwise. The string is is viewed as explicit sign radix-10 representation of an integer that is converted to its binary 2-complement representation.
|
Full Usage:
Mod (x, y)
Parameters:
int
y : int
Returns: int
|
Mod implements the positive remainder of integer division, i.e.
Mod(x,y) is that number r where an integer q exists such that
(1) x=q*y+r, (2) abs(r)
|
Full Usage:
Nat2BL i
Parameters:
int
Returns: bool list
|
Nat2BL converts a non-negative integer i to its radix-2 representation given as a boolean list.
|
Full Usage:
NatConstStr2BL s
Parameters:
string
Returns: bool list
|
NatConstStr2BL s expects a string like "123u" that represents an unsigned integer in Quartz. The suffix "u" is then removed and the remaining string is converted by NatDecStr2BL to a radix-2 representation.
|
Full Usage:
NatDecStr2BL s
Parameters:
string
Returns: bool list
|
NatDecStr2BL(s) converts any string s that consists of decimal digits 0,...,9 that is viewed as radix-10 representation of a natural number to a boolean list such that is the radix-2 representation of the decimal number s.
|
Full Usage:
OctBitConst2BL bvs
Parameters:
string
Returns: bool list
|
OctBitConst2BL s expects a string like "0o7342" that represents an octal bitvector constant in Quartz. The prefix "0o" is then removed and the remaining string is converted to a boolean list by mapping the octal digits to their corresponding radix-2 representations.
|
|
|
|
|
|
|
Full Usage:
StaticBoolBitOfBtv (bl, n)
Parameters:
bool list
n : int
Returns: bool
|
extract the n-th bit of bitvector bl=[bL;...;b0] and fails if out of range
|
Full Usage:
StaticBoolCase (cL, b)
Parameters:
(bool * bool) list
b : bool
Returns: bool
|
evaluate StaticBoolCase([(c1,b1);...,(cn,bn)],b), i.e. if one of the ci is true, then return the leftmost bi whose ci is true, otherwise return b
|
Full Usage:
StaticBoolConj (b1, b2)
Parameters:
bool
b2 : bool
Returns: bool
|
perform boolean conjunction: StaticBoolConj(b1,b2) = b1 && b2
|
Full Usage:
StaticBoolDisj (b1, b2)
Parameters:
bool
b2 : bool
Returns: bool
|
perform boolean disjunction: StaticBoolDisj(b1,b2) = b1 || b2
|
Full Usage:
StaticBoolEqu (b1, b2)
Parameters:
bool
b2 : bool
Returns: bool
|
perform boolean equivalence: StaticBoolEqu(b1,b2) = (b1=b2)
|
Full Usage:
StaticBoolImpl (b1, b2)
Parameters:
bool
b2 : bool
Returns: bool
|
perform boolean implication: StaticBoolImpl(b1,b2) = (not b1) || b2
|
Full Usage:
StaticBoolIte (b1, b2, b3)
Parameters:
bool
b2 : bool
b3 : bool
Returns: bool
|
evaluate BoolIte: StaticBoolIte(b1,b2,b3) = if b1 then b2 else b3
|
Full Usage:
StaticBoolNeg b
Parameters:
bool
Returns: bool
|
perform boolean negation: StaticBoolNeg b = not b
|
Full Usage:
StaticBoolNext b
Parameters:
bool
Returns: bool
|
perform boolean next: StaticBoolNext b = b
|
Full Usage:
StaticBtvAppend (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool list
|
perform bitvector concatenation: StaticBtvAppend(bl1,bl2) = bl1@bl2
|
Full Usage:
StaticBtvCase (caseList, bl)
Parameters:
(bool * bool list) list
bl : bool list
Returns: bool list
|
evaluate StaticBtvCase([(c1,bl1);...,(cn,bln)],bl), i.e. if one of the ci is true, then return the leftmost bli whose ci is true, otherwise return bl
|
Full Usage:
StaticBtvConj (arg1, arg2)
Parameters:
bool list
arg1 : bool list
Returns: bool list
|
perform bitwise boolean conjunction, argument lists must have same length
|
Full Usage:
StaticBtvDisj (arg1, arg2)
Parameters:
bool list
arg1 : bool list
Returns: bool list
|
perform bitwise boolean disjunction, argument lists must have same length
|
Full Usage:
StaticBtvEqu (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool
|
perform bitvector equality: StaticBtvEqu(bl1,bl2) = (bl1=bl2)
|
Full Usage:
StaticBtvEqv (arg1, arg2)
Parameters:
bool list
arg1 : bool list
Returns: bool list
|
perform bitwise boolean equivalence, argument lists must have same length
|
Full Usage:
StaticBtvImpl (arg1, arg2)
Parameters:
bool list
arg1 : bool list
Returns: bool list
|
perform bitwise boolean implication, argument lists must have same length
|
Full Usage:
StaticBtvIte (b, bl1, bl2)
Parameters:
bool
bl1 : bool list
bl2 : bool list
Returns: bool list
|
StaticBtvIte(b,bl1,bl2) = if b then bl1 else bl2
|
Full Usage:
StaticBtvNeg bl
Parameters:
bool list
Returns: bool list
|
perform bitwise boolean negation
|
Full Usage:
StaticBtvNext bl
Parameters:
bool list
Returns: bool list
|
perform bitvector next: StaticBtvNext bl = bl
|
Full Usage:
StaticBtvOfInt (bl, n)
Parameters:
bool list
n : int
Returns: bool list
|
convert int constant to bitvector constant of given length (note that int constants are already stored as 2-complement bitvectors)
|
Full Usage:
StaticBtvOfNat (bl, n)
Parameters:
bool list
n : int
Returns: bool list
|
convert nat constant to bitvector constant of given length (note that nat constants are already stored as radix-2 bitvectors)
|
Full Usage:
StaticBtvReplicate (b, n)
Parameters:
bool
n : int
Returns: bool list
|
replicate a boolean constant to a bitvector: StaticBtvReplicate(b,n) = [b;...;b], where the generated bitvector has length n
|
Full Usage:
StaticBtvReverse B
Parameters:
bool list
Returns: bool list
|
perform bitvector reversal: StaticBtvReverse([bL;...;b0]) = [b0;...;bL]
|
Full Usage:
StaticBtvSegment (B, n2, n1)
Parameters:
bool list
n2 : int
n1 : int
Returns: bool list
|
extract a segment of a bitvector: StaticBtvSegment([bL;...;b0],n2,n1) = [bn2;...;bn1] where L>=n2>=n1>=0 must hold
|
Full Usage:
StaticBtvSignAdjust (n, bv)
Parameters:
int
bv : bool list
Returns: bool list
|
sign-adjust length of bitector bv to n, i.e. first remove all redundant sign bits (i.e. bits that are equal to their right neighbor) to obtain a bitvector bv', then either replicate the leftmost bit to extend bv' to length n or remove further leading bits to reduce the size to n (which modifies int-constants)
|
Full Usage:
StaticBtvSignReduct bl
Parameters:
bool list
Returns: bool list
|
perform sign-bit reduction, ie. remove all leading sign bits ie leftmost elements equal to their right neighbor
|
Full Usage:
StaticBtvZeroAdjust (n, bv)
Parameters:
int
bv : bool list
Returns: bool list
|
zero-adjust length of bitector bv to n, i.e. first remove all leading zero bits to obtain a bitvector bv', then either add zero bits to extend bv' to length n or remove further leading bits to reduce the size to n (which modifies nat-constants)
|
Full Usage:
StaticBtvZeroReduct bl
Parameters:
bool list
Returns: bool list
|
perform zero-bit reduction, ie. remove all leading zero bits (of course [false] is maintained as it is)
|
Full Usage:
StaticIntAbs bl
Parameters:
bool list
Returns: bool list
|
compute the absolute value of a 2-complement number which is given as radix-2 number representation, since used as NatExpr
|
Full Usage:
StaticIntAdd (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool list
|
addition of the 2-complement numbers bl1 and bl2
|
Full Usage:
StaticIntCase (caseList, bl)
Parameters:
(bool * bool list) list
bl : bool list
Returns: bool list
|
evaluate StaticIntCase([(c1,bl1);...,(cn,bln)],bl), i.e. if one of the ci is true, then return the leftmost bli whose ci is true, otherwise return bl
|
Full Usage:
StaticIntDiv (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool list
|
quotient of division of the 2-complement numbers bl1 and bl2 has meaningless value when bl2 is [false]
|
Full Usage:
StaticIntEqu (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool
|
StaticIntEqu(bl1,bl2) checks whether bl1 and bl2 represent the same the 2-complement number
|
Full Usage:
StaticIntIte (b, bl1, bl2)
Parameters:
bool
bl1 : bool list
bl2 : bool list
Returns: bool list
|
StaticIntIte(b,bl1,bl2) = if b then bl1 else bl2
|
Full Usage:
StaticIntLeq (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool
|
StaticIntLeq(bl1,bl2) checks whether bl1 is less than or equal to bl2 when these are evaluated as 2-complement numbers
|
Full Usage:
StaticIntLes (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool
|
StaticIntLes(bl1,bl2) checks whether bl1 is less than bl2 when these are evaluated as 2-complement numbers
|
Full Usage:
StaticIntMod (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool list
|
remainder of division of the 2-complement numbers bl1 and bl2 has meaningless value when bl2 is [false]
|
Full Usage:
StaticIntMul (A, B)
Parameters:
bool list
B : bool list
Returns: bool list
|
multiplication of the 2-complement numbers bl1 and bl2
|
Full Usage:
StaticIntNext bl
Parameters:
bool list
Returns: bool list
|
perform IntExpr next: StaticIntNext bl = bl
|
Full Usage:
StaticIntOfBtv bl
Parameters:
bool list
Returns: bool list
|
convert IntExpr constant to bitvector (note that IntExpr constants are already stored in 2-complement representation
|
Full Usage:
StaticIntSat (blBound, bl)
Parameters:
bool list
bl : bool list
Returns: bool list
|
bind 2-complement number, i.e. return bl if -blBound<=bl
|
Full Usage:
StaticIntSub (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool list
|
subtraction of the 2-complement numbers bl1 and bl2
|
Full Usage:
StaticNatAdd (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool list
|
addition of the radix-2 numbers bl1 and bl2
|
Full Usage:
StaticNatCase (caseList, bl)
Parameters:
(bool * bool list) list
bl : bool list
Returns: bool list
|
evaluate StaticNatCase([(c1,bl1);...,(cn,bln)],bl), i.e. if one of the ci is true, then return the leftmost bli whose ci is true, otherwise return bl
|
Full Usage:
StaticNatDiv (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool list
|
quotient of division of the radix-2 numbers bl1 and bl2 has meaningless value when bl2 is [false]
|
Full Usage:
StaticNatEqu (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool
|
StaticNatEqu(bl1,bl2) checks whether bl1 and bl2 represent the same the radix-2 number
|
Full Usage:
StaticNatExp (A, B)
Parameters:
bool list
B : bool list
Returns: bool list
|
exponentiation of the radix-2 numbers bl1 and bl2
|
Full Usage:
StaticNatIte (b, bl1, bl2)
Parameters:
bool
bl1 : bool list
bl2 : bool list
Returns: bool list
|
StaticNatIte(b,bl1,bl2) = if b then bl1 else bl2
|
Full Usage:
StaticNatLeq (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool
|
StaticNatLeq(bl1,bl2) checks whether bl1 is less than or equal to bl2 when these are evaluated as radix-2 numbers
|
Full Usage:
StaticNatLes (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool
|
StaticNatLes(bl1,bl2) checks whether bl1 is less than bl2 when these are evaluated as radix-2 numbers
|
Full Usage:
StaticNatLog2 bl
Parameters:
bool list
Returns: bool list
|
log2 of a radix-2 number: it's the number of bits minus one after zero-reduction; this number is returned as radix-2 number; note that log2(0) is not defined
|
Full Usage:
StaticNatMod (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool list
|
remainder of division of the radix-2 numbers bl1 and bl2 has meaningless value when bl2 is [false]
|
Full Usage:
StaticNatMul (A, B)
Parameters:
bool list
B : bool list
Returns: bool list
|
multiplication of the radix-2 numbers bl1 and bl2
|
Full Usage:
StaticNatNext bl
Parameters:
bool list
Returns: bool list
|
perform NatExpr next: StaticNatNext bl = bl
|
Full Usage:
StaticNatOfBtv bl
Parameters:
bool list
Returns: bool list
|
convert NatExpr constant to bitvector (note that NatExpr constants are already stored in radix-2 representations
|
Full Usage:
StaticNatSat (blBound, bl)
Parameters:
bool list
bl : bool list
Returns: bool list
|
bind radix-2 number, i.e. return bl if bl
|
Full Usage:
StaticNatSub (bl1, bl2)
Parameters:
bool list
bl2 : bool list
Returns: bool list
|
subtraction of the radix-2 numbers bl1 and bl2; has meaningless values when the radix-2 value of bl1 is less than bl2
|
Full Usage:
StaticRealAdd (r1, r2)
Parameters:
double
r2 : double
Returns: double
|
|
Full Usage:
StaticRealCos r
Parameters:
float
Returns: float
|
|
Full Usage:
StaticRealDiv (r1, r2)
Parameters:
double
r2 : double
Returns: double
|
|
Full Usage:
StaticRealEqu (r1, r2)
Parameters:
double
r2 : double
Returns: bool
|
|
Full Usage:
StaticRealExp (r1, r2)
Parameters:
float
r2 : float
Returns: float
|
|
Full Usage:
StaticRealLeq (r1, r2)
Parameters:
double
r2 : double
Returns: bool
|
|
Full Usage:
StaticRealLes (r1, r2)
Parameters:
double
r2 : double
Returns: bool
|
|
Full Usage:
StaticRealLog2 r
Parameters:
float
Returns: float
|
|
Full Usage:
StaticRealMul (r1, r2)
Parameters:
double
r2 : double
Returns: double
|
|
Full Usage:
StaticRealOfInt bl
Parameters:
bool list
Returns: float
|
|
Full Usage:
StaticRealOfNat bl
Parameters:
bool list
Returns: float
|
|
Full Usage:
StaticRealSin r
Parameters:
float
Returns: float
|
|
Full Usage:
StaticRealSub (r1, r2)
Parameters:
double
r2 : double
Returns: double
|
|
|
|
|
|
|
|