Averest


Types Module

Module Types implements the data types of the Quartz language.

Types

Type Description

QType

QType represents the data types that are available in the Quartz language. Qbool and Qreal implement booleans and real numbers (NOT floats), respectively. Qbtv, Qnat, and Qint represent bitvectors, natural numbers, and integer numbers that can be bounded or unbounded. The unbounded case is indicated with argument "None", while Qbtv(Some len) denotes bitvectors with "len" bits, and Qnat(Some bl) and Qint(Some bl) represent the numbers {0,...,N-1} {-N,...,N-1}, respectively, where bl is the radix-2 representation of N. Qarr(dim,qty) represents arrays with dimension dim whose elements have type qty, and Qtup tyL represents tuples consisting of elements (e1,...,en) having types tyL=[ty1;...;tyn].

Functions and values

Function or value Description

BaseOfQarr qty

Full Usage: BaseOfQarr qty

Parameters:
Returns: QType

get qty of Qarr(dim,qty); fails if applied to other types

qty : QType
Returns: QType

DimOfQarr qty

Full Usage: DimOfQarr qty

Parameters:
Returns: int

get dim of Qarr(dim,qty); fails if applied to other types

qty : QType
Returns: int

GetQarrArgs ty

Full Usage: GetQarrArgs ty

Parameters:
Returns: int * QType

GetQarrArgs(Qarr(dim,qty)) = (dim,qty), and fails otherwise

ty : QType
Returns: int * QType

GetQbtvLen ty

Full Usage: GetQbtvLen ty

Parameters:
Returns: int option

GetQbtvLen(Qbtv len) = len, and fails otherwise

ty : QType
Returns: int option

GetQintRng ty

Full Usage: GetQintRng ty

Parameters:
Returns: bool list option

GetQintRng(Qint rg) = rg, and fails otherwise

ty : QType
Returns: bool list option

GetQnatRng ty

Full Usage: GetQnatRng ty

Parameters:
Returns: bool list option

GetQnatRng(Qnat rg) = rg, and fails otherwise

ty : QType
Returns: bool list option

GetQtupTyL ty

Full Usage: GetQtupTyL ty

Parameters:
Returns: QType list

GetQtupTyL(Qtup tyL) = tyL, and fails otherwise

ty : QType
Returns: QType list

IsSubType qty1 qty2

Full Usage: IsSubType qty1 qty2

Parameters:
Returns: bool

Check whether qty1 is a subset of qty2; we identify Qbool with Qbtv(Some 1), view Qnat rg and Qint rg as subsets of Qreal, and embed Qnat rg in Qint rg. Clearly, Qnat rg1 is a subtype of Qnat rg2 if rg1<=rg2, and the same holds for Qint. However, Qbtv(Some 5) is not a subtype of Qbtv(Some 19).

qty1 : QType
qty2 : QType
Returns: bool

PrnQType ty

Full Usage: PrnQType ty

Parameters:
Returns: Printer

ty : QType
Returns: Printer

QTypeOkay qty

Full Usage: QTypeOkay qty

Parameters:
Returns: bool

check that the given type is not the empty set, i.e., that it contains some elements. This means that bitvectors must have a size>0, and the ranges of finite types Qnat and Qint must also be greater than 0. Moreover, each dimension of an array must be >1, and tuples must consist of more than one type.

qty : QType
Returns: bool

SizeOfType qty

Full Usage: SizeOfType qty

Parameters:
Returns: int option

computes the number of bits required to store elements of type qty; returns None if infinitely many are required

qty : QType
Returns: int option

SupremumType ty1 ty2

Full Usage: SupremumType ty1 ty2

Parameters:
Returns: QType option

Determine the supremum type of two types if that exists.

ty1 : QType
ty2 : QType
Returns: QType option

prnQType ty

Full Usage: prnQType ty

Parameters:
Returns: int -> Printer

ty : QType
Returns: int -> Printer