Skip to content

Foreign handler semantics

A foreign handler's clauses run in a runtime provider. Its declaration states what they compute in its foreign field, and the core provider builds the handler from that statement and from nothing else, in particular never from the handler's name.

  • SemiringSum: a search, resuming once per alternative and answering the semiring sum of its completed shots' weights with their number. The number is the counting semiring's sum of ones, a structural count that no weight changes.
  • SemiringProduct: a collector, multiplying the weights a scope adds, in order.
  • Enumeration: an enumeration of a finite draw.
  • Settlement: the stop of an iteration, answered with its value only when the stop certifies it.
  • DeductionLinearGoal computes the full-span LogWeight of a checked lexical recurrence by span evaluation with certified unary closure. The program binding parse_linear selects this operation.
  • DeductionOutcomes folds a finite packed lexical chart in LogProb and groups full-span goal masses by a structural key.
  • DeductionProofs uses the same chart and returns the supported full-span proofs after an exact budget check. Each row binds its proof's indices and carries its LogProb weight.
  • DeductionOutcomeGrouping groups weighted rows whose checked keys admit exact structural equality. Ordinary QIEC calls compute the keys before this handler runs.
  • DeductionOutcomeLaw turns nominal weighted rows into a normalized Sampleable over their key type. The checked outcome_law binding uses this adapter.

A KernelSemiring names a member of the algebra hierarchy by the subject of its law claims and gives the kernel type of its elements. A search requires its semiring to establish SUM_LAWS and a collector PRODUCT_LAWS, and the provider raises MissingLaw for a member that does not. The operations convert kernel values to float64 tensors, apply the member's own join and tensor_op, and convert back. The conversion is exact or refused: a count is exact below EXACT_COUNT, the bound at which the counting algebra also refuses its closure.

Finite log expectations

Enumeration(reduction="log_expectation") serves an ungrouped Random handler with signature LogWeight -> LogWeight. Each request resumes its continuation once for each positive-weight value of the unbatched finite draw. If the draw has mass \(p(z)\) and the continuation returns \(\ell(z)\) for the value \(z\), its answer is

\[ \operatorname{logsumexp}_{z : p(z)>0} \bigl(\log p(z) + \ell(z)\bigr). \]

A later request inside the continuation returns the same answer type. Induction on the finite tree of draws therefore gives the log of the sum over complete assignments, with each conditional draw mass appearing once along its branch. Work scales with that tree. An execution budget can cap it through the usual reference-machine fuel. The tensor backend preserves score and parameter derivatives on fixed positive support. A subtree whose scores all have zero weight returns \(-\infty\) through the masked LogProb sum.

Settled stops

A deduction whose derivations may repeat an item iterates. A stop is certified when the iteration found no further derivation, so the value sums every derivation, or when the arithmetic is exact and two iterates agree, since a fixed point reached from below is the least one. Any other stop is by a control: the declared tolerance, or two iterates equal in rounded arithmetic while derivations keep growing. Its report names a ControlReached stop, guarantees nothing, and so fails the guarantee of the contract. The settlement refuses it with ContractNotMet, or, when the caller asks for RETURN_UNESTABLISHED, records the report and run_deduction returns the value as Unestablished. A program that calls a deduction can hold no unestablished value, so there the stop is refused.

foreign

What a foreign handler computes, stated as data on its declaration.

A foreign handler's clauses run in a runtime provider, so its declaration says what they compute, and the provider builds them from that statement and from nothing else; in particular never from the handler's name. A search that sums its shots and a collector that multiplies the weights of one derivation carry the semiring they work in as a KernelSemiring: a member of the algebra hierarchy of quivers.core.algebras, named by the subject of its law claims, with the kernel type that holds its elements. The provider asks the member for the laws the handler relies on and refuses a member that does not establish them.

The elements of a kernel semiring are numbers of the machine, so the operations apply the member's own operations to them: a real or log weight in its own dtype, keeping its gradient, and a truth value or a count in float64 and back. The conversion is exact or refused: a natural number is exact in float64 below 2 / eps, the bound beyond which the counting algebra refuses its own closure, and a truth value is 0 or 1.

KERNEL_ALGEBRAS module-attribute

KERNEL_ALGEBRAS: Mapping[str, Semiring] = MappingProxyType({member.subject.name: member for member in (LOG_PROB, MAX_PLUS, TROPICAL, BOOLEAN, GODEL, COUNTING, REAL, MARKOV)})

The shipped semirings with a scalar carrier, by the subject of their claims.

KERNEL_CARRIERS module-attribute

KERNEL_CARRIERS: tuple[TypeExpr, ...] = (LOG_WEIGHT, REAL_TYPE, BOOL, INT)

The kernel types that hold the element of a kernel semiring.

EXACT_COUNT module-attribute

EXACT_COUNT = 2.0 / torch.finfo(torch.float64).eps

The bound below which every natural number is exact in float64.

SUM_LAWS module-attribute

SUM_LAWS: tuple[Law, ...] = (PLUS_ASSOCIATIVE, PLUS_COMMUTATIVE, PLUS_UNIT)

What a search relies on: the sum over a set of derivations is defined by commutativity and associativity, whatever the enumeration order and the nesting of choices, and an empty choice contributes the unit of the sum.

PRODUCT_LAWS module-attribute

PRODUCT_LAWS: tuple[Law, ...] = (TIMES_ASSOCIATIVE, TIMES_UNIT)

What a collector relies on: the product of a derivation's weights is taken in premise order from the unit, so it needs associativity and the unit and not commutativity.

KernelValue

KernelValue = bool | int | float

A literal element of a kernel scalar type, as elaboration writes it.

EnumerationReduction

EnumerationReduction = Literal['logsumexp', 'sum', 'mean', 'table', 'log_expectation']

How an enumeration aggregates its shots.

MissingLaw

Bases: ValueError

A handler relies on a law its semiring does not establish.

InexactKernelValue

Bases: ValueError

A kernel value has no exact image in the semiring's tensors.

KernelSemiring didactic-model

KernelSemiring(*, algebra: ClaimSubject, carrier: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

A semiring of the algebra hierarchy acting on one kernel type.

PARAMETER DESCRIPTION
algebra

The semiring, named by the subject its law claims are about; a key of KERNEL_ALGEBRAS.

TYPE: ClaimSubject

carrier

The kernel type of its elements, one of KERNEL_CARRIERS.

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

RAISES DESCRIPTION
ValidationError

If the subject names no shipped semiring with a scalar carrier, the carrier is not a kernel scalar type, or the semiring's zero or unit has no exact element of the carrier.

member property

member: Semiring

The semiring.

RETURNS DESCRIPTION
Semiring

The shipped member the record names.

exact property

exact: bool

Whether the carrier's arithmetic is exact.

RETURNS DESCRIPTION
bool

True for truth values and natural numbers, whose operations are exact within EXACT_COUNT; false for real and log weights, whose operations round.

log_weights property

log_weights: bool

Whether the elements are log weights, so a learned log weight is one.

RETURNS DESCRIPTION
bool

True when the carrier is LogWeight.

of classmethod

of(member: Semiring, carrier: TypeExpr) -> KernelSemiring

The kernel semiring of a shipped member on a carrier.

PARAMETER DESCRIPTION
member

A value of KERNEL_ALGEBRAS.

TYPE: Semiring

carrier

The kernel type of its elements.

TYPE: TypeExpr

RETURNS DESCRIPTION
KernelSemiring

The record.

Source code in src/quivers/qiec/foreign.py
@classmethod
def of(cls, member: Semiring, carrier: TypeExpr) -> KernelSemiring:
    """The kernel semiring of a shipped member on a carrier.

    Parameters
    ----------
    member : Semiring
        A value of `KERNEL_ALGEBRAS`.
    carrier : TypeExpr
        The kernel type of its elements.

    Returns
    -------
    KernelSemiring
        The record.
    """
    return cls(algebra=member.subject, carrier=carrier)

require

require(laws: Sequence[Law], what: str) -> None

Require the semiring to establish the laws a handler relies on.

PARAMETER DESCRIPTION
laws

The laws.

TYPE: Sequence of Law

what

The handler, for the diagnostic.

TYPE: str

RAISES DESCRIPTION
MissingLaw

If a law is not claimed with a proved or decided status.

Source code in src/quivers/qiec/foreign.py
def require(self, laws: Sequence[Law], what: str) -> None:
    """Require the semiring to establish the laws a handler relies on.

    Parameters
    ----------
    laws : Sequence of Law
        The laws.
    what : str
        The handler, for the diagnostic.

    Raises
    ------
    MissingLaw
        If a law is not claimed with a proved or decided status.
    """
    member = self.member
    for law in laws:
        if not member.establishes(law):
            status = (
                member.claim(law).status.value
                if law in member.laws()
                else "not claimed"
            )
            raise MissingLaw(
                f"{what} relies on {law.name!r}, which {member.name} "
                f"does not establish ({status})"
            )

tensor

tensor(value: Tensor) -> Tensor

An element as the member's operations take it.

PARAMETER DESCRIPTION
value

An element of the carrier, or a tensor of them, as the machine holds it.

TYPE: Tensor

RETURNS DESCRIPTION
Tensor

The same numbers: a real or log weight in its own dtype, so its gradient is kept; a truth value or a count in float64, exact below EXACT_COUNT.

RAISES DESCRIPTION
InexactKernelValue

If the value is not a tensor of the carrier's kind, a count reaches EXACT_COUNT, or an entry is not in the semiring's carrier.

Source code in src/quivers/qiec/foreign.py
def tensor(self, value: torch.Tensor) -> torch.Tensor:
    """An element as the member's operations take it.

    Parameters
    ----------
    value : torch.Tensor
        An element of the carrier, or a tensor of them, as the
        machine holds it.

    Returns
    -------
    torch.Tensor
        The same numbers: a real or log weight in its own dtype, so
        its gradient is kept; a truth value or a count in ``float64``,
        exact below `EXACT_COUNT`.

    Raises
    ------
    InexactKernelValue
        If the value is not a tensor of the carrier's kind, a count
        reaches `EXACT_COUNT`, or an entry is not in the semiring's
        carrier.
    """
    if not isinstance(value, torch.Tensor):
        raise InexactKernelValue(f"{value!r} is not a number of the machine")
    if self.carrier in (BOOL, INT):
        if value.is_floating_point():
            raise InexactKernelValue(f"{value!r} is not a truth value or a count")
        found = value.to(torch.float64)
        if self.carrier == INT:
            demand(
                found.abs() < EXACT_COUNT,
                lambda: InexactKernelValue(
                    f"a count reaches {EXACT_COUNT:.0f}, beyond which it is "
                    "not exact"
                ),
            )
    else:
        if not value.is_floating_point():
            raise InexactKernelValue(f"{value!r} is not a real number")
        found = value
    member = self.member
    demand(
        member.contains(found),
        lambda: InexactKernelValue(f"an entry is not an element of {member.name}"),
    )
    return found

value

value(found: Tensor, numbers: NumberDomain) -> Tensor

The element of the carrier a tensor of the member holds.

PARAMETER DESCRIPTION
found

Elements of the semiring.

TYPE: Tensor

numbers

The run's numbers.

TYPE: NumberDomain

RETURNS DESCRIPTION
Tensor

The elements in the carrier's dtype: bool for truth values, int64 for counts, and the run's real dtype otherwise, which keeps the gradient.

RAISES DESCRIPTION
InexactKernelValue

If an entry has no exact element of the carrier: a truth value other than 0 or 1, or a number that is not a natural number below EXACT_COUNT.

Source code in src/quivers/qiec/foreign.py
def value(self, found: torch.Tensor, numbers: NumberDomain) -> torch.Tensor:
    """The element of the carrier a tensor of the member holds.

    Parameters
    ----------
    found : torch.Tensor
        Elements of the semiring.
    numbers : NumberDomain
        The run's numbers.

    Returns
    -------
    torch.Tensor
        The elements in the carrier's dtype: ``bool`` for truth values,
        ``int64`` for counts, and the run's real dtype otherwise, which
        keeps the gradient.

    Raises
    ------
    InexactKernelValue
        If an entry has no exact element of the carrier: a truth value
        other than ``0`` or ``1``, or a number that is not a natural
        number below `EXACT_COUNT`.
    """
    if self.carrier == BOOL:
        demand(
            (found == 0) | (found == 1),
            lambda: InexactKernelValue("an entry is not a truth value"),
        )
        return found != 0
    if self.carrier == INT:
        demand(
            (found == torch.round(found)) & (found.abs() < EXACT_COUNT),
            lambda: InexactKernelValue(
                f"an entry is not a count below {EXACT_COUNT:.0f}"
            ),
        )
        return found.to(torch.int64)
    return numbers.real_of(found)

zero

zero() -> KernelValue

The additive identity, as a literal of the carrier.

RETURNS DESCRIPTION
KernelValue

The semiring's zero.

Source code in src/quivers/qiec/foreign.py
def zero(self) -> KernelValue:
    """The additive identity, as a literal of the carrier.

    Returns
    -------
    KernelValue
        The semiring's zero.
    """
    return self._literal(self.member.zero)

unit

unit() -> KernelValue

The multiplicative identity, as a literal of the carrier.

RETURNS DESCRIPTION
KernelValue

The semiring's unit.

Source code in src/quivers/qiec/foreign.py
def unit(self) -> KernelValue:
    """The multiplicative identity, as a literal of the carrier.

    Returns
    -------
    KernelValue
        The semiring's unit.
    """
    return self._literal(self.member.unit)

plus

plus(values: Sequence[Tensor], numbers: NumberDomain) -> Tensor

The sum of elements in their order.

PARAMETER DESCRIPTION
values

Elements of one shape.

TYPE: Sequence of torch.Tensor

numbers

The run's numbers.

TYPE: NumberDomain

RETURNS DESCRIPTION
Tensor

Their sum, by the member's join; the zero for none.

Source code in src/quivers/qiec/foreign.py
def plus(
    self, values: Sequence[torch.Tensor], numbers: NumberDomain
) -> torch.Tensor:
    """The sum of elements in their order.

    Parameters
    ----------
    values : Sequence of torch.Tensor
        Elements of one shape.
    numbers : NumberDomain
        The run's numbers.

    Returns
    -------
    torch.Tensor
        Their sum, by the member's ``join``; the zero for none.
    """
    if not values:
        zero = machine_value(self.carrier, self.zero(), numbers)
        assert isinstance(zero, torch.Tensor)
        return zero
    stacked = torch.stack([self.tensor(value) for value in values])
    return self.value(self.member.join(stacked, 0), numbers)

times

times(left: Tensor, right: Tensor, numbers: NumberDomain) -> Tensor

The product of two elements, entrywise over tensors of them.

PARAMETER DESCRIPTION
left

The left factor; a scalar broadcasts over a tensor.

TYPE: Tensor

right

The right factor.

TYPE: Tensor

numbers

The run's numbers.

TYPE: NumberDomain

RETURNS DESCRIPTION
Tensor

left * right by the member's tensor_op.

Source code in src/quivers/qiec/foreign.py
def times(
    self, left: torch.Tensor, right: torch.Tensor, numbers: NumberDomain
) -> torch.Tensor:
    """The product of two elements, entrywise over tensors of them.

    Parameters
    ----------
    left : torch.Tensor
        The left factor; a scalar broadcasts over a tensor.
    right : torch.Tensor
        The right factor.
    numbers : NumberDomain
        The run's numbers.

    Returns
    -------
    torch.Tensor
        ``left * right`` by the member's ``tensor_op``.
    """
    return self.value(
        self.member.tensor_op(self.tensor(left), self.tensor(right)), numbers
    )

SemiringSum didactic-model

SemiringSum(*, semiring: KernelSemiring = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['semiring-sum'] = 'semiring-sum')

Bases: QiecModel

A search: resume once per alternative and sum what the shots answer.

The handled computation answers its value with the product a collector inside it accumulated; a completed shot answers that product with the count one, an empty choice answers the zero with the count zero, and a choice answers the sum of its shots' weights with the sum of their counts. The answer is thus the semiring sum over the completed derivations and their number, the second being the counting semiring's sum of ones: a structural count that no weight can change.

PARAMETER DESCRIPTION
semiring

The semiring of the sum.

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

tag

Always "semiring-sum".

TYPE: str DEFAULT: 'semiring-sum'

laws property

laws: tuple[Law, ...]

The laws the handler relies on.

RETURNS DESCRIPTION
tuple of Law

SUM_LAWS.

SemiringProduct didactic-model

SemiringProduct(*, semiring: KernelSemiring = field(opaque=True, extras=OPAQUE_BY_VALUE), forkable: bool = False, tag: Literal['semiring-product'] = 'semiring-product')

Bases: QiecModel

A collector: multiply every weight added in the scope, in order.

PARAMETER DESCRIPTION
semiring

The semiring of the product, applied entrywise to tensors of its elements.

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

forkable

Whether an unrestricted resumption may capture an installation, each shot continuing from its own copy of the product so far; a search inside the scope needs it.

TYPE: bool DEFAULT: False

tag

Always "semiring-product".

TYPE: str DEFAULT: 'semiring-product'

laws property

laws: tuple[Law, ...]

The laws the handler relies on.

RETURNS DESCRIPTION
tuple of Law

PRODUCT_LAWS.

Enumeration didactic-model

Enumeration(*, grouped: bool = False, reduction: EnumerationReduction = 'logsumexp', tag: Literal['enumeration'] = 'enumeration')

Bases: QiecModel

An enumeration of a finite draw: resume once per support value.

PARAMETER DESCRIPTION
grouped

Whether the handler answers one weight per group position.

TYPE: bool DEFAULT: False

reduction

"logsumexp" for the log of the summed weights, "sum" or "mean" for those of the shots' values, "table" for the shots themselves, one per support value. "log_expectation" aggregates scalar log scores, with LogWeight as both the scope's input and output type.

TYPE: EnumerationReduction DEFAULT: 'logsumexp'

tag

Always "enumeration".

TYPE: str DEFAULT: 'enumeration'

Settlement didactic-model

Settlement(*, semiring: KernelSemiring = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['settlement'] = 'settlement')

Bases: QiecModel

A stop of an iteration: answer its value only when the stop certifies it.

The handled operation carries the value, whether the stop certifies it, and the residual of the last two iterates. A certified stop is answered with the value; any other is a stop by a control, which the provider refuses or reports as unestablished, as the caller's failure policy says.

PARAMETER DESCRIPTION
semiring

The semiring of the value, which fixes its metric.

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

tag

Always "settlement".

TYPE: str DEFAULT: 'settlement'

DeductionLinearGoal didactic-model

DeductionLinearGoal(*, presentation: QiecModel = field(opaque=True, extras=OPAQUE_BY_VALUE), lexicon: tuple[tuple[str, str], ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), parameters: tuple[ParameterId, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), start: str | None, tag: Literal['deduction-linear-goal'] = 'deduction-linear-goal')

Bases: QiecModel

Solve the full-span weight of one checked lexical linear system.

PARAMETER DESCRIPTION
presentation

The nominal span rules. The native adapter admits unary cycles and binary rules whose two spans concatenate. Lexical spans have width one and the presentation has no other axiom widths.

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

lexicon

The ordered pairs of token and atomic category. Their live log weights occupy the first slots of the operation's weight vector.

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

parameters

The distinct nominal rule-weight slots, in their vector order.

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

start

The requested final category, or None to sum all full-span items.

TYPE: str | None

plan cached property

plan: Plan

Select the existing exact span executor for the checked recurrence.

RETURNS DESCRIPTION
Plan

The rule and accuracy contract shared by successive runs.

RAISES DESCRIPTION
ValueError

If the presentation cannot use the checked linear span closure.

DeductionOutcomes didactic-model

DeductionOutcomes(*, presentation: QiecModel = field(opaque=True, extras=OPAQUE_BY_VALUE), words: tuple[str, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), parameters: tuple[ParameterId, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), span: str, start: str | None = None, item_type: TypeApplication = field(opaque=True, extras=OPAQUE_BY_VALUE), item_constructors: tuple[tuple[str, ConstructorId], ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), empty: ConstructorId = field(opaque=True, extras=OPAQUE_BY_VALUE), entry: ConstructorId = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['deduction-outcomes'] = 'deduction-outcomes')

Bases: QiecModel

A finite lexical LogProb chart returning typed weighted outcomes.

The operation receives a token tensor, the corresponding lexical entries' category and optional form values in lexicon order, the log weights of those entries and the listed rule parameters, and the structural key and normalization choices. Lexical occurrences have positive width one. Ground rules may supply fixed ordered spans, including empty spans. Other rules concatenate contiguous spans, and any edge preserving width advances in an acyclic graph on category keys. The pair of span width and category rank increases strictly along every edge.

PARAMETER DESCRIPTION
presentation

The checked RulePresentation. Its model base in the annotation keeps the rule checker's dependency on effects acyclic at import.

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

words

One word per lexical row, preserving distinct occurrences.

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

parameters

Rule parameters supplied after the lexical weights, in order.

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

span

The name of the single lexical judgment and corresponding item constructor, whose fields are the endpoints, category, and any form.

TYPE: str

start

The start category, or None to accept all full-span items.

TYPE: str | None DEFAULT: None

item_type

The runtime constructor family for the span and its data fields.

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

item_constructors

Source names and constructor identities of that family.

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

empty

The constructors of the result family. An entry has a key of item_type, its log weight as Real, and the remaining entries.

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

entry

The constructors of the result family. An entry has a key of item_type, its log weight as Real, and the remaining entries.

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

span_order cached property

span_order: SpanOrder

Certify finite grounding of this presentation.

RETURNS DESCRIPTION
SpanOrder

The strict endpoint-width and category-rank order.

unary_height property

unary_height: int

Measure chains using only unary transitions.

RETURNS DESCRIPTION
int

The longest chain in the certified unary category graph.

DeductionProofs didactic-model

DeductionProofs(*, chart: DeductionOutcomes = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['deduction-proofs'] = 'deduction-proofs')

Bases: QiecModel

Return supported full-span proofs under one exact proof budget.

Each result entry binds its proof's indexed family arguments. The entry holds that proof, its log weight, and the next entry. The operation accepts a structural proof limit and a normalization choice. Different derivations keep their own weights.

PARAMETER DESCRIPTION
chart

The existing lexical chart descriptor and its result constructors. Its lexical span syntax and grammar parameters remain unchanged.

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

proof_presentation cached property

proof_presentation: RulePresentation

Rename the chart's proof declarations into the calling module.

RETURNS DESCRIPTION
RulePresentation

The same rule, axiom and judgment identities at renamed sorts, with proof constructors named by the deduction.

DeductionBooleanOutcomes didactic-model

DeductionBooleanOutcomes(*, chart: DeductionOutcomes = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['deduction-boolean-outcomes'] = 'deduction-boolean-outcomes')

Bases: QiecModel

Push finite lexical proof mass to a Boolean interpretation.

An input truth table contains one axiom result per distinct lexical word in first occurrence order, followed by each rule's truth table in presentation order. Each rule table enumerates premise outcomes left to right, with false before true. An arity bound of two keeps every rule table at most four entries.

PARAMETER DESCRIPTION
chart

The shared weighted span presentation and its Boolean result row constructors.

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

lexical_words cached property

lexical_words: tuple[str, ...]

Count one axiom evaluation for every distinct lexical word.

RETURNS DESCRIPTION
tuple of str

The words in first lexical occurrence order.

table_size cached property

table_size: int

Count entries of the axiom and ordered rule tables.

RETURNS DESCRIPTION
int

The length of the input truth vector.

DeductionOutcomeGrouping didactic-model

DeductionOutcomeGrouping(*, key_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), empty: ConstructorId = field(opaque=True, extras=OPAQUE_BY_VALUE), entry: ConstructorId = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['deduction-outcome-grouping'] = 'deduction-outcome-grouping')

Bases: QiecModel

Group a typed list of finite log masses by exact structural equality.

PARAMETER DESCRIPTION
key_type

The checked type of each key. The module verifies that the type admits exact structural equality before the reducer can run.

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

empty

The constructors of the typed row list. An entry contains a key, its log mass, and the rest of the list.

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

entry

The constructors of the typed row list. An entry contains a key, its log mass, and the rest of the list.

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

DeductionOutcomeLaw didactic-model

DeductionOutcomeLaw(*, layout: DeductionOutcomeGrouping = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['deduction-outcome-law'] = 'deduction-outcome-law')

Bases: QiecModel

Normalize checked deduction outcome rows as one finite sampleable.

PARAMETER DESCRIPTION
layout

The original key type and the two constructors of the weighted rows.

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