Skip to content

Declarations

A family declaration declares an inductive family of types (Dybjer, 1994), and its constructor declarations say how values are formed. A vector family may be indexed by its element type and its length. Each constructor declaration records the indices and fields its values have, so that checking recovers those facts when a value is matched.

declarations

Indexed-family and constructor declarations for the QIEC kernel.

FieldDef didactic-model

FieldDef(*, name: str, type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

One named, typed field of a constructor.

PARAMETER DESCRIPTION
name

The field's display name.

TYPE: str

type

The field's type, which may mention the constructor's telescope.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

FamilyDecl didactic-model

FamilyDecl(*, id: FamilyId = field(opaque=True, extras=OPAQUE_BY_VALUE), name: str, parameters: Telescope = field(opaque=True, extras=OPAQUE_BY_VALUE), indices: Telescope = field(opaque=True, extras=OPAQUE_BY_VALUE), constructors: tuple[ConstructorId, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), closed: bool = True)

Bases: QiecModel

A closed or opaque indexed data family.

parameters are uniform across every constructor. indices may be refined by constructor results and therefore are kept separate even when both are represented by index binders.

PARAMETER DESCRIPTION
id

Stable identity.

TYPE: FamilyId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

name

Source name, used for display and for the derived type constructor.

TYPE: str

parameters

Binders uniform across every constructor.

TYPE: Telescope DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

indices

Binders a constructor result may refine. Each must be marked refinable, which is what separates them from parameters.

TYPE: Telescope DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

constructors

The constructors this family declares, without repetition.

TYPE: tuple[ConstructorId, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

closed

Whether the constructor list is exhaustive. A closed family admits coverage checking; an opaque one does not.

TYPE: bool DEFAULT: True

type_constructor property

type_constructor: TypeConstructorRef

The type constructor this family introduces.

RETURNS DESCRIPTION
TypeConstructorRef

A constructor whose identity is derived from the family's, taking the parameters and indices together as its telescope. Deriving rather than storing it keeps the two from drifting apart.

ConstructorDecl didactic-model

ConstructorDecl(*, id: ConstructorId = field(opaque=True, extras=OPAQUE_BY_VALUE), family: FamilyId = field(opaque=True, extras=OPAQUE_BY_VALUE), name: str, telescope: Telescope = field(opaque=True, extras=OPAQUE_BY_VALUE), fields: tuple[FieldDef, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), result_indices: tuple[StaticArgument, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

One GADT constructor.

Constructor-local telescope binders are rigid skolems while a branch is checked. result_indices may mention those binders and thereby refine the scrutinee indices.

PARAMETER DESCRIPTION
id

Stable identity.

TYPE: ConstructorId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

family

The family this constructor belongs to, which must list it.

TYPE: FamilyId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

name

Source name.

TYPE: str

telescope

Binders local to the constructor. These become rigid skolems while a branch matching it is checked.

TYPE: Telescope DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

fields

The values the constructor carries, uniquely named.

TYPE: tuple[FieldDef, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_indices

What the constructor fixes the family's indices to. One per family index, and may mention the local telescope, which is how matching refines the scrutinee's type.

TYPE: tuple[StaticArgument, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

Cited sources

Peter Dybjer. Inductive Families. Formal Aspects of Computing, 6(4):440–465, 1994. doi:10.1007/BF01211308.