Skip to content

Theory Engine Records

Every answer of the theory engine is a typed record: the provenance of a composition, its check report, the conflict a refused composition names, the obligations of a view with their equality witnesses, rewrite-system reports, finite models and their verification, and the classification of a change of theory.

records

Typed records of what panproto's theory engine computes.

Every value the engine returns about a theory, a morphism, a composition, a rewrite system, or a model is mirrored here as a didactic model, so it can be compared, hashed, serialized, and shown without holding a handle to the native object. The records are filled by quivers.gat.engine; nothing in this module calls panproto.

The records fall into six groups:

  • symbols and provenance: SymbolRef, ProvenanceEntry, AddedEquation, Provenance;
  • composition reports and conflicts: CheckSubject, CheckOutcome, CheckRecord, Freshening, CompositionReport, CompositionConflict and its variants;
  • morphisms and their obligations: MorphismRecord, Witness, Obligation and its variants, ViewCheck;
  • rewriting: CriticalPair, RuleViolation, RewriteSystemReport, NormalForm;
  • models: Value and its variants, Carrier, TableEntry, OperationTable, FiniteModel, EquationViolation, ModelVerification, SigmaExtension;
  • theory change: TheoryChange, TheoryChangeReport.

SYMBOL_KINDS module-attribute

SYMBOL_KINDS: tuple[SymbolKind, ...] = ('sort', 'op', 'eq', 'directed_eq', 'policy')

Every symbol kind, in panproto's declaration order.

CHANGE_KINDS module-attribute

CHANGE_KINDS: tuple[ChangeKind, ...] = ('added_sort', 'removed_sort', 'changed_sort', 'added_op', 'removed_op', 'changed_op', 'added_equation', 'removed_equation', 'changed_equation', 'added_directed_equation', 'removed_directed_equation', 'changed_directed_equation')

Every change kind.

SymbolKind

SymbolKind = Literal['sort', 'op', 'eq', 'directed_eq', 'policy']

The kind of a symbol of a theory, as panproto names it.

CompositionMode

CompositionMode = Literal['explicit_identity', 'amalgamate']

Which symbols a composition identifies: exactly the related ones, or also same-name ones.

ClashPolicy

ClashPolicy = Literal['reject', 'freshen']

What a composition does when two distinct classes would share a name.

CheckStatus

CheckStatus = Literal['passed', 'failed', 'incomplete']

The verdict of a check: established, refuted, or neither.

ChangeClassification

ChangeClassification = Literal['fully-compatible', 'backward-compatible', 'breaking']

How a change of theory affects its dependents.

WitnessKind

WitnessKind = Literal['reflexivity', 'axiom', 'symmetry', 'transitivity', 'congruence', 'runtime_checked']

How an equality witness justifies its equation.

ChangeKind

ChangeKind = Literal['added_sort', 'removed_sort', 'changed_sort', 'added_op', 'removed_op', 'changed_op', 'added_equation', 'removed_equation', 'changed_equation', 'added_directed_equation', 'removed_directed_equation', 'changed_directed_equation']

The kind of one change between two theories.

SymbolRef didactic-model

SymbolRef(*, node: str, name: str)

Bases: Model

A symbol of one node of a diagram.

PARAMETER DESCRIPTION
node

The label of the node that declares (or uses) the symbol.

TYPE: str

name

The symbol's name in that node's theory.

TYPE: str

ProvenanceEntry didactic-model

ProvenanceEntry(*, symbol_kind: SymbolKind, source: SymbolRef, image: str)

Bases: Model

Where one source symbol of a composition went.

PARAMETER DESCRIPTION
symbol_kind

The kind of the symbol.

TYPE: SymbolKind

source

The symbol in its node.

TYPE: SymbolRef

image

The name of its image in the composed theory.

TYPE: str

AddedEquation didactic-model

AddedEquation(*, name: str, edge: int, op: SymbolRef)

Bases: Model

An equation a composition added for an operation sent to a derived term.

PARAMETER DESCRIPTION
name

The equation's name in the composed theory.

TYPE: str

edge

The edge's position in panproto's canonical edge order.

TYPE: int

op

The operation the edge sends to a term.

TYPE: SymbolRef

Provenance didactic-model

Provenance(*, entries: tuple[ProvenanceEntry, ...] = (), added_equations: tuple[AddedEquation, ...] = ())

Bases: Model

Where every source symbol of a composition went.

The entries are total: every sort, operation, equation, directed equation, and policy of every node has exactly one entry.

PARAMETER DESCRIPTION
entries

One entry per source symbol, ascending by kind, node, name.

TYPE: tuple of ProvenanceEntry DEFAULT: ()

added_equations

The equations the composition added, ascending by name.

TYPE: tuple of AddedEquation DEFAULT: ()

image

image(symbol_kind: SymbolKind, node: str, name: str) -> str | None

The image of one source symbol.

PARAMETER DESCRIPTION
symbol_kind

The kind of the symbol.

TYPE: SymbolKind

node

The label of its node.

TYPE: str

name

Its name in that node.

TYPE: str

RETURNS DESCRIPTION
str or None

The name of its image, or None when the composition has no such source symbol.

Source code in src/quivers/gat/records.py
def image(self, symbol_kind: SymbolKind, node: str, name: str) -> str | None:
    """The image of one source symbol.

    Parameters
    ----------
    symbol_kind : SymbolKind
        The kind of the symbol.
    node : str
        The label of its node.
    name : str
        Its name in that node.

    Returns
    -------
    str or None
        The name of its image, or ``None`` when the composition has
        no such source symbol.
    """
    for entry in self.entries:
        if (
            entry.symbol_kind == symbol_kind
            and entry.source.node == node
            and entry.source.name == name
        ):
            return entry.image
    return None

members

members(symbol_kind: SymbolKind, image: str) -> tuple[SymbolRef, ...]

Every source symbol of one kind whose image is image.

PARAMETER DESCRIPTION
symbol_kind

The kind.

TYPE: SymbolKind

image

The name in the composed theory.

TYPE: str

RETURNS DESCRIPTION
tuple of SymbolRef

The sources, ascending.

Source code in src/quivers/gat/records.py
def members(self, symbol_kind: SymbolKind, image: str) -> tuple[SymbolRef, ...]:
    """Every source symbol of one kind whose image is ``image``.

    Parameters
    ----------
    symbol_kind : SymbolKind
        The kind.
    image : str
        The name in the composed theory.

    Returns
    -------
    tuple of SymbolRef
        The sources, ascending.
    """
    return tuple(
        entry.source
        for entry in self.entries
        if entry.symbol_kind == symbol_kind and entry.image == image
    )

of_node

of_node(node: str) -> tuple[ProvenanceEntry, ...]

Every entry whose source lies in one node.

PARAMETER DESCRIPTION
node

The node label.

TYPE: str

RETURNS DESCRIPTION
tuple of ProvenanceEntry

The node's entries, in entry order.

Source code in src/quivers/gat/records.py
def of_node(self, node: str) -> tuple[ProvenanceEntry, ...]:
    """Every entry whose source lies in one node.

    Parameters
    ----------
    node : str
        The node label.

    Returns
    -------
    tuple of ProvenanceEntry
        The node's entries, in entry order.
    """
    return tuple(entry for entry in self.entries if entry.source.node == node)

CheckSubject didactic-model

CheckSubject()

Bases: TaggedUnion

What a composition check is about.

DiagramSubject didactic-model

DiagramSubject(*, kind: Literal['diagram'] = 'diagram')

Bases: CheckSubject

The diagram as a whole.

PARAMETER DESCRIPTION
kind

The discriminator; always "diagram".

TYPE: str DEFAULT: 'diagram'

NodeSubject didactic-model

NodeSubject(*, label: str, kind: Literal['node'] = 'node')

Bases: CheckSubject

One node of the diagram.

PARAMETER DESCRIPTION
label

The node's label.

TYPE: str

kind

The discriminator; always "node".

TYPE: str DEFAULT: 'node'

EdgeSubject didactic-model

EdgeSubject(*, index: int, kind: Literal['edge'] = 'edge')

Bases: CheckSubject

One edge of the diagram.

PARAMETER DESCRIPTION
index

The edge's position in the diagram's edge list.

TYPE: int

kind

The discriminator; always "edge".

TYPE: str DEFAULT: 'edge'

CoconeSubject didactic-model

CoconeSubject(*, index: int, kind: Literal['cocone'] = 'cocone')

Bases: CheckSubject

One leg of an alternative cocone.

PARAMETER DESCRIPTION
index

The leg's position.

TYPE: int

kind

The discriminator; always "cocone".

TYPE: str DEFAULT: 'cocone'

CheckOutcome didactic-model

CheckOutcome()

Bases: TaggedUnion

The outcome of one composition check.

Passed didactic-model

Passed(*, kind: Literal['passed'] = 'passed')

Bases: CheckOutcome

The check passed.

PARAMETER DESCRIPTION
kind

The discriminator; always "passed".

TYPE: str DEFAULT: 'passed'

PassedByEquation didactic-model

PassedByEquation(*, equation: str, kind: Literal['passed_by_equation'] = 'passed_by_equation')

Bases: CheckOutcome

The check passed because an equation the composition added makes it hold.

PARAMETER DESCRIPTION
equation

That equation's name.

TYPE: str

kind

The discriminator; always "passed_by_equation".

TYPE: str DEFAULT: 'passed_by_equation'

Failed didactic-model

Failed(*, detail: str, kind: Literal['failed'] = 'failed')

Bases: CheckOutcome

The check failed.

PARAMETER DESCRIPTION
detail

Why.

TYPE: str

kind

The discriminator; always "failed".

TYPE: str DEFAULT: 'failed'

Inapplicable didactic-model

Inapplicable(*, reason: Literal['open_theory', 'no_equations'], missing_sorts: tuple[str, ...] = (), kind: Literal['inapplicable'] = 'inapplicable')

Bases: CheckOutcome

The check did not apply.

PARAMETER DESCRIPTION
reason

"open_theory" when some node uses undeclared sorts, or "no_equations".

TYPE: str

missing_sorts

The undeclared sort names, for "open_theory".

TYPE: tuple of str DEFAULT: ()

kind

The discriminator; always "inapplicable".

TYPE: str DEFAULT: 'inapplicable'

Incomplete didactic-model

Incomplete(*, reason: Literal['rewrite_budget_exhausted', 'no_terminating_rewrite_system'], equation: str | None = None, steps: int | None = None, kind: Literal['incomplete'] = 'incomplete')

Bases: CheckOutcome

The check did not complete.

PARAMETER DESCRIPTION
reason

"rewrite_budget_exhausted" or "no_terminating_rewrite_system".

TYPE: str

equation

The equation being decided when the budget ran out.

TYPE: str or None DEFAULT: None

steps

The budget spent.

TYPE: int or None DEFAULT: None

kind

The discriminator; always "incomplete".

TYPE: str DEFAULT: 'incomplete'

CheckRecord didactic-model

CheckRecord(*, check: str, subject: CheckSubject, outcome: CheckOutcome)

Bases: Model

One check a composition ran, and its outcome.

PARAMETER DESCRIPTION
check

The check, as panproto names it ("leg_is_morphism", "cocone_commutes", "name_clash_free", ...).

TYPE: str

subject

What it was about.

TYPE: CheckSubject

outcome

Its outcome.

TYPE: CheckOutcome

Freshening didactic-model

Freshening(*, symbol_kind: SymbolKind, members: tuple[SymbolRef, ...], candidate: str, result: str)

Bases: Model

One renaming the freshen clash policy made.

PARAMETER DESCRIPTION
symbol_kind

The kind of the renamed class.

TYPE: SymbolKind

members

The class's members, ascending.

TYPE: tuple of SymbolRef

candidate

The name the naming rule chose before the clash.

TYPE: str

result

The name the class got.

TYPE: str

CompositionReport didactic-model

CompositionReport(*, mode: CompositionMode, status: CheckStatus, name_clash_free: bool, checks: tuple[CheckRecord, ...] = (), freshened: tuple[Freshening, ...] = ())

Bases: Model

Every check a composition ran, and the verdict they add up to.

PARAMETER DESCRIPTION
mode

The mode the composition ran in.

TYPE: CompositionMode

status

The conjunction of every record's verdict.

TYPE: CheckStatus

name_clash_free

Whether no two nodes share a same-kind name that the diagram's morphisms do not relate.

TYPE: bool

checks

The records, sorted by check then subject.

TYPE: tuple of CheckRecord DEFAULT: ()

freshened

Every renaming the freshen policy made.

TYPE: tuple of Freshening DEFAULT: ()

records

records(check: str) -> tuple[CheckRecord, ...]

The records of one check.

PARAMETER DESCRIPTION
check

The check's name.

TYPE: str

RETURNS DESCRIPTION
tuple of CheckRecord

Its records, in subject order.

Source code in src/quivers/gat/records.py
def records(self, check: str) -> tuple[CheckRecord, ...]:
    """The records of one check.

    Parameters
    ----------
    check : str
        The check's name.

    Returns
    -------
    tuple of CheckRecord
        Its records, in subject order.
    """
    return tuple(record for record in self.checks if record.check == check)

SignatureDefect didactic-model

SignatureDefect(*, defect: str, site: str, sort: str | None = None, payload: str = '{}')

Bases: Model

A defect of a theory's signature, as panproto's typechecker reports it.

PARAMETER DESCRIPTION
defect

The defect's kind ("undeclared_sort", "sort_arity", "param_ill_typed", ...).

TYPE: str

site

Where it sits, rendered ("op_input id 0", "op_output f", "sort_param Hom 1").

TYPE: str

sort

The sort the defect is about, when it names one.

TYPE: str or None DEFAULT: None

payload

The defect's remaining fields, as canonical JSON.

TYPE: str DEFAULT: '{}'

CompositionConflict didactic-model

CompositionConflict()

Bases: TaggedUnion

Why a composition was refused.

One variant per refusal of panproto's compose. Conflicts between symbols carry both sources, so a caller can show where each came from.

DuplicateNodeLabel didactic-model

DuplicateNodeLabel(*, label: str, kind: Literal['duplicate_node_label'] = 'duplicate_node_label')

Bases: CompositionConflict

Two nodes share a label.

PARAMETER DESCRIPTION
label

The label.

TYPE: str

kind

The discriminator.

TYPE: str DEFAULT: 'duplicate_node_label'

InvalidNodeLabel didactic-model

InvalidNodeLabel(*, label: str, kind: Literal['invalid_node_label'] = 'invalid_node_label')

Bases: CompositionConflict

A label is empty or contains . or #.

PARAMETER DESCRIPTION
label

The label.

TYPE: str

kind

The discriminator.

TYPE: str DEFAULT: 'invalid_node_label'

UnknownNodeLabel didactic-model

UnknownNodeLabel(*, label: str, kind: Literal['unknown_node_label'] = 'unknown_node_label')

Bases: CompositionConflict

An edge names a node the diagram does not have.

PARAMETER DESCRIPTION
label

The label.

TYPE: str

kind

The discriminator.

TYPE: str DEFAULT: 'unknown_node_label'

InvalidNode didactic-model

InvalidNode(*, label: str, defects: tuple[SignatureDefect, ...], kind: Literal['invalid_node'] = 'invalid_node')

Bases: CompositionConflict

A node's signature is ill formed beyond using undeclared sorts.

PARAMETER DESCRIPTION
label

The node.

TYPE: str

defects

Its defects.

TYPE: tuple of SignatureDefect

kind

The discriminator.

TYPE: str DEFAULT: 'invalid_node'

InvalidLeg didactic-model

InvalidLeg(*, edge: int, detail: str, kind: Literal['invalid_leg'] = 'invalid_leg')

Bases: CompositionConflict

An edge's morphism is not a morphism between its endpoints.

PARAMETER DESCRIPTION
edge

The edge's position.

TYPE: int

detail

The morphism check's error.

TYPE: str

kind

The discriminator.

TYPE: str DEFAULT: 'invalid_leg'

SortSignatureMismatch didactic-model

SortSignatureMismatch(*, first: SymbolRef, second: SymbolRef, mismatch: str, detail: str = '{}', kind: Literal['sort_signature_mismatch'] = 'sort_signature_mismatch')

Bases: CompositionConflict

Two sorts the diagram identifies disagree on their signatures.

PARAMETER DESCRIPTION
first

One member.

TYPE: SymbolRef

second

Another member.

TYPE: SymbolRef

mismatch

How they disagree: "arity", "param_sort", "kind", or "closure".

TYPE: str

detail

The mismatch's fields, as canonical JSON.

TYPE: str DEFAULT: '{}'

kind

The discriminator.

TYPE: str DEFAULT: 'sort_signature_mismatch'

OpSignatureMismatch didactic-model

OpSignatureMismatch(*, first: SymbolRef, second: SymbolRef, kind: Literal['op_signature_mismatch'] = 'op_signature_mismatch')

Bases: CompositionConflict

Two operations the diagram identifies disagree on their signatures.

PARAMETER DESCRIPTION
first

One member.

TYPE: SymbolRef

second

Another member.

TYPE: SymbolRef

kind

The discriminator.

TYPE: str DEFAULT: 'op_signature_mismatch'

QuotientNotRepresentable didactic-model

QuotientNotRepresentable(*, first: SymbolRef, second: SymbolRef, reason: str, kind: Literal['quotient_not_representable'] = 'quotient_not_representable')

Bases: CompositionConflict

An identification needs a sort equation, which a theory cannot state.

PARAMETER DESCRIPTION
first

One member.

TYPE: SymbolRef

second

Another member.

TYPE: SymbolRef

reason

What would be needed.

TYPE: str

kind

The discriminator.

TYPE: str DEFAULT: 'quotient_not_representable'

NameConflict didactic-model

NameConflict(*, symbol_kind: SymbolKind, name: str, first: SymbolRef, second: SymbolRef, kind: Literal['name_conflict'] = 'name_conflict')

Bases: CompositionConflict

Under amalgamation, two same-name symbols are incompatible.

PARAMETER DESCRIPTION
symbol_kind

Their kind.

TYPE: SymbolKind

name

Their name.

TYPE: str

first

One of them.

TYPE: SymbolRef

second

The other.

TYPE: SymbolRef

kind

The discriminator.

TYPE: str DEFAULT: 'name_conflict'

NameClash didactic-model

NameClash(*, symbol_kind: SymbolKind, name: str, classes: tuple[tuple[SymbolRef, ...], ...], kind: Literal['name_clash'] = 'name_clash')

Bases: CompositionConflict

Distinct classes would get the same name.

PARAMETER DESCRIPTION
symbol_kind

Their kind.

TYPE: SymbolKind

name

The name.

TYPE: str

classes

The clashing classes, each ascending.

TYPE: tuple of tuple of SymbolRef

kind

The discriminator.

TYPE: str DEFAULT: 'name_clash'

IllTypedTransport didactic-model

IllTypedTransport(*, source: SymbolRef, detail: str, kind: Literal['ill_typed_transport'] = 'ill_typed_transport')

Bases: CompositionConflict

A translated equation does not typecheck in the composed theory.

PARAMETER DESCRIPTION
source

The source equation, or the operation an added equation identifies.

TYPE: SymbolRef

detail

The typechecker's error.

TYPE: str

kind

The discriminator.

TYPE: str DEFAULT: 'ill_typed_transport'

IllTypedResult didactic-model

IllTypedResult(*, defects: tuple[SignatureDefect, ...] = (), kind: Literal['ill_typed_result'] = 'ill_typed_result')

Bases: CompositionConflict

The composed theory is ill typed.

PARAMETER DESCRIPTION
defects

Its signature defects; empty when a check beyond the signature failed.

TYPE: tuple of SignatureDefect DEFAULT: ()

kind

The discriminator.

TYPE: str DEFAULT: 'ill_typed_result'

NotACocone didactic-model

NotACocone(*, members: tuple[SymbolRef, ...] = (), kind: Literal['not_a_cocone'] = 'not_a_cocone')

Bases: CompositionConflict

An alternative cocone sends the members of one class to different images.

PARAMETER DESCRIPTION
members

The class, ascending; empty when the legs do not match the diagram.

TYPE: tuple of SymbolRef DEFAULT: ()

kind

The discriminator.

TYPE: str DEFAULT: 'not_a_cocone'

MorphismRecord didactic-model

MorphismRecord(*, name: str, domain: str, codomain: str, sort_map: dict[str, str] = {}, op_renames: dict[str, str] = {}, derived_terms: dict[str, str] = {})

Bases: Model

A theory morphism: sorts to sorts, operations to operations or terms.

PARAMETER DESCRIPTION
name

The morphism's name.

TYPE: str

domain

The domain theory's name.

TYPE: str

codomain

The codomain theory's name.

TYPE: str

sort_map

Domain sort to codomain sort.

TYPE: dict of str to str DEFAULT: {}

op_renames

Domain operation to the codomain operation it is renamed to.

TYPE: dict of str to str DEFAULT: {}

derived_terms

Domain operation to the codomain term it is sent to, in the theory-DSL term syntax; its free variables are the domain operation's parameter names.

TYPE: dict of str to str DEFAULT: {}

NodeInclusion didactic-model

NodeInclusion(*, label: str, morphism: MorphismRecord)

Bases: Model

The inclusion of one diagram node into a composition.

PARAMETER DESCRIPTION
label

The node's label.

TYPE: str

morphism

Its inclusion into the composed theory.

TYPE: MorphismRecord

DiagramEdge didactic-model

DiagramEdge(*, source: str, target: str, morphism: MorphismRecord)

Bases: Model

One edge of a theory diagram.

PARAMETER DESCRIPTION
source

The label of the morphism's domain node.

TYPE: str

target

The label of the morphism's codomain node.

TYPE: str

morphism

The morphism.

TYPE: MorphismRecord

Witness didactic-model

Witness(*, lhs: str, rhs: str, witness_kind: WitnessKind, axiom: str | None = None, op: str | None = None, description: str | None = None, premises: tuple[Witness, ...] = ())

Bases: Model

A witness that two terms are equal in a theory.

PARAMETER DESCRIPTION
lhs

The left-hand side.

TYPE: str

rhs

The right-hand side.

TYPE: str

witness_kind

How the equality is justified.

TYPE: WitnessKind

axiom

The axiom used, for "axiom".

TYPE: str or None DEFAULT: None

op

The operation applied, for "congruence".

TYPE: str or None DEFAULT: None

description

What was checked, for "runtime_checked".

TYPE: str or None DEFAULT: None

premises

The witnesses this one is built from.

TYPE: tuple of Witness DEFAULT: ()

is_certified property

is_certified: bool

Whether no step of the witness is a trusted runtime check.

RETURNS DESCRIPTION
bool

True when the witness is a derivation from axioms alone.

Obligation didactic-model

Obligation()

Bases: TaggedUnion

The status of one domain equation under a view.

Every equation of a view's domain is a proof obligation in its codomain: the image of the equation must hold there.

Discharged didactic-model

Discharged(*, equation: str, lhs: str, rhs: str, image_lhs: str, image_rhs: str, witness: Witness, kind: Literal['discharged'] = 'discharged')

Bases: Obligation

The image holds, by a derivation from the codomain's axioms.

PARAMETER DESCRIPTION
equation

The domain equation's name.

TYPE: str

lhs

Its left-hand side.

TYPE: str

rhs

Its right-hand side.

TYPE: str

image_lhs

The image of the left-hand side.

TYPE: str

image_rhs

The image of the right-hand side.

TYPE: str

witness

The derivation.

TYPE: Witness

kind

The discriminator.

TYPE: str DEFAULT: 'discharged'

Derivable didactic-model

Derivable(*, equation: str, lhs: str, rhs: str, image_lhs: str, image_rhs: str, witness: Witness, kind: Literal['derivable'] = 'derivable')

Bases: Obligation

The image holds by congruence closure, which panproto trusts but does not certify.

PARAMETER DESCRIPTION
equation

The domain equation's name.

TYPE: str

lhs

Its left-hand side.

TYPE: str

rhs

Its right-hand side.

TYPE: str

image_lhs

The image of the left-hand side.

TYPE: str

image_rhs

The image of the right-hand side.

TYPE: str

witness

The witness, which has a runtime-checked step.

TYPE: Witness

kind

The discriminator.

TYPE: str DEFAULT: 'derivable'

Assumed didactic-model

Assumed(*, equation: str, lhs: str, rhs: str, image_lhs: str, image_rhs: str, reason: str, kind: Literal['assumed'] = 'assumed')

Bases: Obligation

The checker could not decide the image, so it holds only by assumption.

PARAMETER DESCRIPTION
equation

The domain equation's name.

TYPE: str

lhs

Its left-hand side.

TYPE: str

rhs

Its right-hand side.

TYPE: str

image_lhs

The image of the left-hand side.

TYPE: str

image_rhs

The image of the right-hand side.

TYPE: str

reason

Why the check was inconclusive.

TYPE: str

kind

The discriminator.

TYPE: str DEFAULT: 'assumed'

Refused didactic-model

Refused(*, equation: str, lhs: str, rhs: str, image_lhs: str, image_rhs: str, reason: str, kind: Literal['refused'] = 'refused')

Bases: Obligation

The image does not hold: the view breaks the equation.

PARAMETER DESCRIPTION
equation

The domain equation's name.

TYPE: str

lhs

Its left-hand side.

TYPE: str

rhs

Its right-hand side.

TYPE: str

image_lhs

The image of the left-hand side.

TYPE: str

image_rhs

The image of the right-hand side.

TYPE: str

reason

The checker's refusal.

TYPE: str

kind

The discriminator.

TYPE: str DEFAULT: 'refused'

ViewCheck didactic-model

ViewCheck(*, morphism: MorphismRecord, obligations: tuple[Obligation, ...] = ())

Bases: Model

A view whose signature is a theory morphism, with one obligation per equation.

PARAMETER DESCRIPTION
morphism

The view.

TYPE: MorphismRecord

obligations

One per domain equation, in declaration order.

TYPE: tuple of Obligation DEFAULT: ()

status property

status: CheckStatus

The verdict the obligations add up to.

RETURNS DESCRIPTION
CheckStatus

"failed" when some obligation is refused, "incomplete" when none is refused and some is assumed, "passed" otherwise.

refused

refused() -> tuple[Refused, ...]

The obligations the view breaks.

RETURNS DESCRIPTION
tuple of Refused

In declaration order.

Source code in src/quivers/gat/records.py
def refused(self) -> tuple[Refused, ...]:
    """The obligations the view breaks.

    Returns
    -------
    tuple of Refused
        In declaration order.
    """
    return tuple(o for o in self.obligations if isinstance(o, Refused))

assumed

assumed() -> tuple[Assumed, ...]

The obligations held only by assumption.

RETURNS DESCRIPTION
tuple of Assumed

In declaration order.

Source code in src/quivers/gat/records.py
def assumed(self) -> tuple[Assumed, ...]:
    """The obligations held only by assumption.

    Returns
    -------
    tuple of Assumed
        In declaration order.
    """
    return tuple(o for o in self.obligations if isinstance(o, Assumed))

ComposedTheory didactic-model

ComposedTheory(*, name: str, theory_json: str, inclusions: tuple[NodeInclusion, ...], provenance: Provenance, report: CompositionReport, sort_names: tuple[str, ...] = (), op_names: tuple[str, ...] = (), equation_names: tuple[str, ...] = ())

Bases: Model

A colimit of a theory diagram, with its cocone, provenance, and report.

PARAMETER DESCRIPTION
name

The composed theory's name.

TYPE: str

theory_json

The composed theory in panproto's serialized theory shape.

TYPE: str

inclusions

One inclusion per diagram node, in node order.

TYPE: tuple of NodeInclusion

provenance

Where every source symbol went.

TYPE: Provenance

report

Every check the composition ran.

TYPE: CompositionReport

sort_names

The composed theory's sorts, ascending.

TYPE: tuple of str DEFAULT: ()

op_names

Its operations, ascending.

TYPE: tuple of str DEFAULT: ()

equation_names

Its equations, ascending.

TYPE: tuple of str DEFAULT: ()

inclusion

inclusion(label: str) -> MorphismRecord

The inclusion of one node.

PARAMETER DESCRIPTION
label

The node's label.

TYPE: str

RETURNS DESCRIPTION
MorphismRecord

The node's inclusion into the composed theory.

RAISES DESCRIPTION
KeyError

If the composition has no node with that label.

Source code in src/quivers/gat/records.py
def inclusion(self, label: str) -> MorphismRecord:
    """The inclusion of one node.

    Parameters
    ----------
    label : str
        The node's label.

    Returns
    -------
    MorphismRecord
        The node's inclusion into the composed theory.

    Raises
    ------
    KeyError
        If the composition has no node with that label.
    """
    for inclusion in self.inclusions:
        if inclusion.label == label:
            return inclusion.morphism
    raise KeyError(f"composition {self.name!r} has no node labeled {label!r}")

CriticalPair didactic-model

CriticalPair(*, rule_a: str, rule_b: str, left: str, right: str, joins: bool)

Bases: Model

A critical pair between two directed equations.

PARAMETER DESCRIPTION
rule_a

The outer rule.

TYPE: str

rule_b

The inner rule.

TYPE: str

left

The left reduct.

TYPE: str

right

The right reduct.

TYPE: str

joins

Whether the reducts normalize to the same term within the budget.

TYPE: bool

RuleViolation didactic-model

RuleViolation(*, rule: str, reason: str)

Bases: Model

A directed equation the lexicographic path ordering does not decrease.

PARAMETER DESCRIPTION
rule

The rule.

TYPE: str

reason

Why the comparison failed.

TYPE: str

RewriteSystemReport didactic-model

RewriteSystemReport(*, critical_pairs: tuple[CriticalPair, ...] = (), termination_violations: tuple[RuleViolation, ...] = (), warnings: tuple[str, ...] = ())

Bases: Model

Local confluence and LPO termination of a theory's directed equations.

PARAMETER DESCRIPTION
critical_pairs

Every critical pair found.

TYPE: tuple of CriticalPair DEFAULT: ()

termination_violations

Every rule that fails the ordering.

TYPE: tuple of RuleViolation DEFAULT: ()

warnings

One description per non-joining pair and per violation.

TYPE: tuple of str DEFAULT: ()

is_locally_confluent property

is_locally_confluent: bool

Whether every critical pair joins.

RETURNS DESCRIPTION
bool

True when no pair is non-joining.

is_lpo_terminating property

is_lpo_terminating: bool

Whether every rule decreases in the ordering.

RETURNS DESCRIPTION
bool

True when there is no violation.

is_sound property

is_sound: bool

Whether the system is locally confluent and terminating.

RETURNS DESCRIPTION
bool

Both checks hold.

NormalForm didactic-model

NormalForm(*, term: str, exhausted: bool)

Bases: Model

The result of rewriting a term by a theory's directed equations.

PARAMETER DESCRIPTION
term

The term reached.

TYPE: str

exhausted

Whether the step budget ran out first, so that term need not be normal.

TYPE: bool

Value didactic-model

Value()

Bases: TaggedUnion

An element of a carrier of a set-theoretic model.

IntValue didactic-model

IntValue(*, value: int, kind: Literal['int'] = 'int')

Bases: Value

An integer.

PARAMETER DESCRIPTION
value

The integer.

TYPE: int

kind

The discriminator.

TYPE: str DEFAULT: 'int'

StrValue didactic-model

StrValue(*, value: str, kind: Literal['str'] = 'str')

Bases: Value

A string.

PARAMETER DESCRIPTION
value

The string.

TYPE: str

kind

The discriminator.

TYPE: str DEFAULT: 'str'

BoolValue didactic-model

BoolValue(*, value: bool, kind: Literal['bool'] = 'bool')

Bases: Value

A boolean.

PARAMETER DESCRIPTION
value

The boolean.

TYPE: bool

kind

The discriminator.

TYPE: str DEFAULT: 'bool'

NullValue didactic-model

NullValue(*, kind: Literal['null'] = 'null')

Bases: Value

The absent value.

PARAMETER DESCRIPTION
kind

The discriminator.

TYPE: str DEFAULT: 'null'

ListValue didactic-model

ListValue(*, items: tuple[Value, ...] = (), kind: Literal['list'] = 'list')

Bases: Value

A list of values.

PARAMETER DESCRIPTION
items

The items.

TYPE: tuple of Value DEFAULT: ()

kind

The discriminator.

TYPE: str DEFAULT: 'list'

MapEntry didactic-model

MapEntry(*, key: str, value: Value)

Bases: Model

One entry of a map value.

PARAMETER DESCRIPTION
key

The key.

TYPE: str

value

The value.

TYPE: Value

MapValue didactic-model

MapValue(*, entries: tuple[MapEntry, ...] = (), kind: Literal['map'] = 'map')

Bases: Value

A map from strings to values.

PARAMETER DESCRIPTION
entries

The entries, ascending by key.

TYPE: tuple of MapEntry DEFAULT: ()

kind

The discriminator.

TYPE: str DEFAULT: 'map'

ConstructorValue didactic-model

ConstructorValue(*, tag: str, args: tuple[Value, ...] = (), kind: Literal['constructor'] = 'constructor')

Bases: Value

A constructor-tagged value.

PARAMETER DESCRIPTION
tag

The constructor's name.

TYPE: str

args

Its arguments.

TYPE: tuple of Value DEFAULT: ()

kind

The discriminator.

TYPE: str DEFAULT: 'constructor'

Carrier didactic-model

Carrier(*, sort: str, elements: tuple[Value, ...] = ())

Bases: Model

The carrier set of one sort.

PARAMETER DESCRIPTION
sort

The sort.

TYPE: str

elements

Its elements.

TYPE: tuple of Value DEFAULT: ()

TableEntry didactic-model

TableEntry(*, args: tuple[Value, ...], result: Value)

Bases: Model

One row of an operation's table.

PARAMETER DESCRIPTION
args

The arguments.

TYPE: tuple of Value

result

The operation's value on them.

TYPE: Value

OperationTable didactic-model

OperationTable(*, op: str, entries: tuple[TableEntry, ...] = ())

Bases: Model

The finite table of one operation.

PARAMETER DESCRIPTION
op

The operation.

TYPE: str

entries

One row per tuple of arguments from the input carriers.

TYPE: tuple of TableEntry DEFAULT: ()

FiniteModel didactic-model

FiniteModel(*, theory: str, carriers: tuple[Carrier, ...] = (), tables: tuple[OperationTable, ...] = ())

Bases: Model

A finite set-theoretic model of a theory, given by carriers and tables.

PARAMETER DESCRIPTION
theory

The name of the theory it interprets.

TYPE: str

carriers

One carrier per sort.

TYPE: tuple of Carrier DEFAULT: ()

tables

One table per operation.

TYPE: tuple of OperationTable DEFAULT: ()

carrier

carrier(sort: str) -> tuple[Value, ...]

The carrier of one sort.

PARAMETER DESCRIPTION
sort

The sort.

TYPE: str

RETURNS DESCRIPTION
tuple of Value

Its elements.

RAISES DESCRIPTION
KeyError

If the model has no carrier for the sort.

Source code in src/quivers/gat/records.py
def carrier(self, sort: str) -> tuple[Value, ...]:
    """The carrier of one sort.

    Parameters
    ----------
    sort : str
        The sort.

    Returns
    -------
    tuple of Value
        Its elements.

    Raises
    ------
    KeyError
        If the model has no carrier for the sort.
    """
    for carrier in self.carriers:
        if carrier.sort == sort:
            return carrier.elements
    raise KeyError(f"model of {self.theory!r} has no carrier for sort {sort!r}")

lookup

lookup(op: str, args: tuple[Value, ...]) -> Value

The value of one operation on one tuple of arguments.

PARAMETER DESCRIPTION
op

The operation.

TYPE: str

args

The arguments.

TYPE: tuple of Value

RETURNS DESCRIPTION
Value

The table's entry.

RAISES DESCRIPTION
KeyError

If the model has no table for the operation, or the table has no row for the arguments.

Source code in src/quivers/gat/records.py
def lookup(self, op: str, args: tuple[Value, ...]) -> Value:
    """The value of one operation on one tuple of arguments.

    Parameters
    ----------
    op : str
        The operation.
    args : tuple of Value
        The arguments.

    Returns
    -------
    Value
        The table's entry.

    Raises
    ------
    KeyError
        If the model has no table for the operation, or the table
        has no row for the arguments.
    """
    for table in self.tables:
        if table.op == op:
            for entry in table.entries:
                if entry.args == args:
                    return entry.result
            raise KeyError(f"table of {op!r} has no row for {args!r}")
    raise KeyError(f"model of {self.theory!r} has no table for operation {op!r}")

EquationViolation didactic-model

EquationViolation(*, equation: str, assignment: tuple[MapEntry, ...], lhs_value: Value, rhs_value: Value)

Bases: Model

A variable assignment under which an equation fails in a model.

PARAMETER DESCRIPTION
equation

The equation.

TYPE: str

assignment

The assignment, ascending by variable.

TYPE: tuple of MapEntry

lhs_value

The value of the left-hand side.

TYPE: Value

rhs_value

The value of the right-hand side.

TYPE: Value

ModelVerification didactic-model

ModelVerification(*, status: CheckStatus, violations: tuple[EquationViolation, ...] = (), incomplete: str | None = None)

Bases: Model

What checking a model against its theory established.

PARAMETER DESCRIPTION
status

"passed" when every equation was checked exhaustively and holds, "failed" when some equation was refuted, "incomplete" when the check did not finish.

TYPE: CheckStatus

violations

The counterexamples found.

TYPE: tuple of EquationViolation DEFAULT: ()

incomplete

Why the check did not finish.

TYPE: str or None DEFAULT: None

UnitPair didactic-model

UnitPair(*, sort: str, element: Value, image: Value)

Bases: Model

One component of the unit of the free extension.

PARAMETER DESCRIPTION
sort

The domain sort.

TYPE: str

element

An element of the original model.

TYPE: Value

image

Its image in the reduct of the free extension.

TYPE: Value

SigmaExtension didactic-model

SigmaExtension(*, model: FiniteModel, unit: tuple[UnitPair, ...] = ())

Bases: Model

The free extension of a model along a theory morphism.

PARAMETER DESCRIPTION
model

The free extension, a model of the codomain.

TYPE: FiniteModel

unit

The unit, from the original model into the reduct of model.

TYPE: tuple of UnitPair DEFAULT: ()

TheoryChange didactic-model

TheoryChange(*, change: ChangeKind, name: str, breaks_clients: bool, breaks_models: bool)

Bases: Model

One change between two versions of a theory.

PARAMETER DESCRIPTION
change

What changed.

TYPE: ChangeKind

name

The symbol it concerns.

TYPE: str

breaks_clients

Whether it breaks clients of the old theory: terms and views over it no longer transport along the inclusion into the new one.

TYPE: bool

breaks_models

Whether it breaks models of the old theory: they are no longer models of the new one.

TYPE: bool

TheoryChangeReport didactic-model

TheoryChangeReport(*, classification: ChangeClassification, clients: CheckStatus, models: CheckStatus, changes: tuple[TheoryChange, ...] = (), client_error: str | None = None, model_error: str | None = None)

Bases: Model

How a change of theory affects its clients and its models.

PARAMETER DESCRIPTION
classification

"fully-compatible" when both inclusions are morphisms, "backward-compatible" when the old theory includes into the new one, "breaking" otherwise.

TYPE: ChangeClassification

clients

Whether the identity-on-names inclusion old into new is a theory morphism, so every term and view over the old theory transports.

TYPE: CheckStatus

models

Whether the inclusion new into old is a theory morphism, so every model of the old theory is a model of the new one.

TYPE: CheckStatus

changes

The changes, in panproto's order.

TYPE: tuple of TheoryChange DEFAULT: ()

client_error

Why the old-into-new inclusion is not established.

TYPE: str or None DEFAULT: None

model_error

Why the new-into-old inclusion is not established.

TYPE: str or None DEFAULT: None