Deduction elaboration¶
These functions elaborate a deduction declaration into Quivers Indexed Effect Core (QIEC) families, handlers, and computations (generated effects). The QIEC developer note lists what a deduction elaborates to.
Internal module
This module is an implementation detail of the compiler and its
tooling. Its __all__ is empty, so none of the names below are
part of the public API, and they may change without notice.
deduction_elaboration
¶
Elaborate deduction declarations into kernel computations.
A weighted deductive system is a closed data family of items, a
computation enumerating its derivations, and a pair of handlers
aggregating them. The family declares one nullary constructor per atom
and one constructor per applied symbol the rules and lexicon mention,
with a slot typed Int where the system uses it as a position and
Item otherwise. Rules become branches of a recursive computation
that performs choose on the deduction's Search instance to pick
an axiom or a rule, derives each premise by recursion, matches the
derived item against the premise pattern by case analysis (a shared
pattern variable is checked by the family's structural equality
computation), instantiates the conclusion, and adds the rule's weight
on the deduction's Weight[K] instance, where K is the carrier of
the declared semiring. A failed match performs an empty choice, which
the search handler answers by resuming nobody.
The entry computation handles the Weight instance with a collecting
handler and the Search instance with a handler that resumes once per
alternative and combines the shots by the semiring's addition, so the
answer is the semiring sum over derivations of the goal of the product
of the weights along each: the inside weight of the goal. Learned
weights are read through the module's params instance of Param,
under names the classic engine keys its parameters by, so a program
that calls the deduction and scores its answer leaves params in its
row for the run to serve.
A system whose rules all relate span items enumerates by span: the
derivation of span(i, j, ...) chooses split positions for the
premise positions the conclusion leaves free and derives each premise
over its own smaller span, so the search is bounded by the sentence.
Unary rules, which keep the span, extend a derived item in chains; when
a chain could revisit an item, the chain carries the items it visited,
a bound limits how often it may revisit one, and the entry raises the
bound until the goal's weight settles within the declared
tolerance, as the chart's Kleene-star aggregation settles. The
depth option bounds the constructor depth of every rule's
conclusion category, as the agenda engine's side condition does, and
never the number of rules a derivation applies. A system with a lexicon whose items are not all
spans, such as a multiple context-free grammar, derives an item from its
head symbol and the positions of its yield, read in pairs as the
components the item covers, when its rules are linear (each conclusion
component a concatenation of premise components, so a rule with several
premises derives each over fewer tokens), every item has a head, and
neither its unary rules nor its rules among items without positions form
a cycle. Every other system iterates a finite weighted chart: one without a
lexicon takes its axioms and their weights as input, and one whose
derivations no search bounds reads its axioms off the sentence through
its lexicon. Each round adds the axioms to the rule contributions from the
preceding chart, until the chart settles. Constructor depth does not
impose a proof-height limit.