Deductive Systems, Rule Schemas, and Span Components¶
A chart parser stores partial conclusions and combines them with inference rules (Shieber et al., 1995; Goodman, 1999). In a categorial grammar, for instance, an expression that needs a noun phrase on its right combines with a noun phrase to give a sentence (Lambek, 1958). The interfaces below separate the initial facts, the inference steps, the goals, and the schedule, and the semiring fixes what is accumulated across derivations. The module holds the abstract deductive system, the rule schemas with their bundles and presets, and the components of CKY parsing over spans.
Deductive Systems¶
Five abstract primitives for weighted deductive parsing, of which the parsers in this package are instances:
Axiom: Creates and populates the initial chart from input.Deduction: A weighted inference step (chart → chart).Goal: Extracts the result from a completed chart.Schedule: Evaluation strategy (CKY bottom-up, Earley, agenda-based).DeductiveSystem: Ties axiom, deductions, goal, schedule, and semiring into a singlenn.Module.
The deduction package exposes these primitives alongside fitting and sampling operations.
Rule Schemas¶
A rule schema is a function from a finite inventory of syntactic categories (CategorySystem) to a
set of rules (RuleSystem). Each schema states one structural rule pattern, and its rules are the
instances of that pattern over the inventory.
Schemas compose via | (union) and can carry default weights via .weighted(w). Grammar formalisms are specific compositions:
CCG = EVALUATION | HARMONIC_COMPOSITION | CROSSED_COMPOSITIONLAMBEK = EVALUATION | ADJUNCTION_UNITS | TENSOR_INTRODUCTION | TENSOR_PROJECTIONNL = EVALUATIONLP = EVALUATION | COMMUTATIVE_EVALUATION | ADJUNCTION_UNITS
About twenty atomic schemas, such as ForwardApplication and BackwardApplication, compose into
twelve bundled schemas, such as EVALUATION and HARMONIC_COMPOSITION, which compose into the
grammar presets CCG, LAMBEK, NL, and LP.
schema
¶
Rule schemas: composable functors from CategorySystem to RuleSystem.
A RuleSchema is a functor that maps a CategorySystem to a
RuleSystem. Schemas are the abstract building blocks of grammar
formalisms: each schema defines a structural rule pattern, and
concrete rule instances are generated by instantiating the pattern
over a finite category inventory.
The two atomic schema types are:
BinaryRuleSchema: defined by a match predicate on category pairs:match(left, right) -> result | None.UnaryRuleSchema: defined by a match predicate on single categories:match(cat, system) -> list[result].
Schemas compose via | (union) and can carry default weights
via .weighted(w). Grammar formalisms are specific compositions::
CCG = EVALUATION | HARMONIC_COMPOSITION | CROSSED_COMPOSITION
LAMBEK = EVALUATION | ADJUNCTION_UNITS | TENSOR_INTRODUCTION | TENSOR_PROJECTION
The 13 bundled schemas (EVALUATION, HARMONIC_COMPOSITION, etc.) are themselves composed from ~20 atomic schemas (ForwardApplication, BackwardApplication, etc.), giving fine-grained control::
# only forward application, no backward
MY_GRAMMAR = ForwardApplication() | ForwardComposition()
RuleSchema
¶
Bases: ABC
A functor CategorySystem -> RuleSystem.
Schemas are the abstract specification of structural rules.
They compose via | (union) and + (alias for |).
weighted
¶
weighted(weight: float) -> RuleSchema
Attach a default weight to all rules from this schema.
| PARAMETER | DESCRIPTION |
|---|---|
weight
|
The weight every binary and unary rule receives.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuleSchema
|
A |
Source code in src/quivers/stochastic/schema.py
UnionSchema
¶
UnionSchema(left: RuleSchema, right: RuleSchema)
Bases: RuleSchema
Union of two schemas (composes their rule systems via +).
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The first schema.
TYPE:
|
right
|
The second schema.
TYPE:
|
Source code in src/quivers/stochastic/schema.py
WeightedSchema
¶
WeightedSchema(inner: RuleSchema, weight: float)
Bases: RuleSchema
Schema wrapper that attaches a default weight to all rules.
| PARAMETER | DESCRIPTION |
|---|---|
inner
|
The schema whose rules are weighted.
TYPE:
|
weight
|
The weight every rule of
TYPE:
|
Source code in src/quivers/stochastic/schema.py
BinaryRuleSchema
¶
Bases: RuleSchema
Schema for binary rules, defined by a match predicate.
Subclasses implement match(left, right) -> result | None.
The schema iterates over all category pairs and collects matches.
match
abstractmethod
¶
Test whether (left, right) triggers this rule.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
Left antecedent.
TYPE:
|
right
|
Right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
Result category if the pair matches, else None. |
Source code in src/quivers/stochastic/schema.py
UnaryRuleSchema
¶
Bases: RuleSchema
Schema for unary rules, defined by a match predicate.
Subclasses implement match(cat, system) -> list[result].
The schema iterates over all categories and collects matches.
match
abstractmethod
¶
match(cat: Category, system: CategorySystem) -> list[Category]
Find all valid results for a given input category.
| PARAMETER | DESCRIPTION |
|---|---|
cat
|
Input category.
TYPE:
|
system
|
The full category inventory (needed for some schemas that must check existence of intermediate categories).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Category]
|
Valid result categories. |
Source code in src/quivers/stochastic/schema.py
ForwardApplication
¶
Bases: BinaryRuleSchema
C/B ⊗ B → C (right evaluation / forward application).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
BackwardApplication
¶
Bases: BinaryRuleSchema
A ⊗ A\C → C (left evaluation / backward application).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
ForwardComposition
¶
Bases: BinaryRuleSchema
C/B ⊗ B/A → C/A (right harmonic composition).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
BackwardComposition
¶
Bases: BinaryRuleSchema
A\B ⊗ B\C → A\C (left harmonic composition).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
ForwardCrossedComposition
¶
Bases: BinaryRuleSchema
C/B ⊗ B\A → C\A (right-left crossed composition).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
BackwardCrossedComposition
¶
Bases: BinaryRuleSchema
A/B ⊗ B\C → A/C (left-right crossed composition).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
CommutativeForwardApplication
¶
Bases: BinaryRuleSchema
B ⊗ C/B → C (commutative right evaluation).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
CommutativeBackwardApplication
¶
Bases: BinaryRuleSchema
A\C ⊗ A → C (commutative left evaluation).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
TensorIntroduction
¶
Bases: BinaryRuleSchema
A ⊗ B → A⊗B (product formation).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
LeftUnitElimination
¶
Bases: BinaryRuleSchema
I ⊗ A → A (left unitor).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
RightUnitElimination
¶
Bases: BinaryRuleSchema
A ⊗ I → A (right unitor).
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
ModalApplication
¶
Bases: BinaryRuleSchema
◇(C/B) ⊗ ◇B → ◇C (modal function application).
| PARAMETER | DESCRIPTION |
|---|---|
modality
|
The modality symbol (e.g. "◇", "□").
TYPE:
|
Source code in src/quivers/stochastic/schema.py
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
RightLifting
¶
Bases: UnaryRuleSchema
A → C/(A\C) (right adjunction unit / type raising).
match
¶
match(cat: Category, system: CategorySystem) -> list[Category]
Return the conclusions this rule derives from a category.
| PARAMETER | DESCRIPTION |
|---|---|
cat
|
The antecedent category.
TYPE:
|
system
|
The category inventory; conclusions outside it are dropped.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of Category
|
The conclusion categories, empty when the rule does not apply. |
Source code in src/quivers/stochastic/schema.py
LeftLifting
¶
Bases: UnaryRuleSchema
A → (C/A)\C (left adjunction unit / type raising).
match
¶
match(cat: Category, system: CategorySystem) -> list[Category]
Return the conclusions this rule derives from a category.
| PARAMETER | DESCRIPTION |
|---|---|
cat
|
The antecedent category.
TYPE:
|
system
|
The category inventory; conclusions outside it are dropped.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of Category
|
The conclusion categories, empty when the rule does not apply. |
Source code in src/quivers/stochastic/schema.py
LeftProjection
¶
Bases: UnaryRuleSchema
A⊗B → A (left tensor projection).
match
¶
match(cat: Category, system: CategorySystem) -> list[Category]
Return the conclusions this rule derives from a category.
| PARAMETER | DESCRIPTION |
|---|---|
cat
|
The antecedent category.
TYPE:
|
system
|
The category inventory; conclusions outside it are dropped.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of Category
|
The conclusion categories, empty when the rule does not apply. |
Source code in src/quivers/stochastic/schema.py
RightProjection
¶
Bases: UnaryRuleSchema
A⊗B → B (right tensor projection).
match
¶
match(cat: Category, system: CategorySystem) -> list[Category]
Return the conclusions this rule derives from a category.
| PARAMETER | DESCRIPTION |
|---|---|
cat
|
The antecedent category.
TYPE:
|
system
|
The category inventory; conclusions outside it are dropped.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of Category
|
The conclusion categories, empty when the rule does not apply. |
Source code in src/quivers/stochastic/schema.py
UnitCoercion
¶
Bases: UnaryRuleSchema
A → I (unit elimination / weakening).
match
¶
match(cat: Category, system: CategorySystem) -> list[Category]
Return the conclusions this rule derives from a category.
| PARAMETER | DESCRIPTION |
|---|---|
cat
|
The antecedent category.
TYPE:
|
system
|
The category inventory; conclusions outside it are dropped.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of Category
|
The conclusion categories, empty when the rule does not apply. |
Source code in src/quivers/stochastic/schema.py
ModalInjection
¶
Bases: UnaryRuleSchema
A → ◇A (modal introduction).
| PARAMETER | DESCRIPTION |
|---|---|
modality
|
The modality symbol (e.g. "◇", "□").
TYPE:
|
Source code in src/quivers/stochastic/schema.py
match
¶
match(cat: Category, system: CategorySystem) -> list[Category]
Return the conclusions this rule derives from a category.
| PARAMETER | DESCRIPTION |
|---|---|
cat
|
The antecedent category.
TYPE:
|
system
|
The category inventory; conclusions outside it are dropped.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of Category
|
The conclusion categories, empty when the rule does not apply. |
Source code in src/quivers/stochastic/schema.py
ModalProjection
¶
Bases: UnaryRuleSchema
◇A → A (modal elimination).
| PARAMETER | DESCRIPTION |
|---|---|
modality
|
The modality symbol (e.g. "◇", "□").
TYPE:
|
Source code in src/quivers/stochastic/schema.py
match
¶
match(cat: Category, system: CategorySystem) -> list[Category]
Return the conclusions this rule derives from a category.
| PARAMETER | DESCRIPTION |
|---|---|
cat
|
The antecedent category.
TYPE:
|
system
|
The category inventory; conclusions outside it are dropped.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of Category
|
The conclusion categories, empty when the rule does not apply. |
Source code in src/quivers/stochastic/schema.py
GeneralizedComposition
¶
Bases: RuleSchema
Generalized composition through nested slashes (B^n).
C/B ⊗ (B|₁Z₁)|₂Z₂...|ₙZₙ → (C|₁Z₁)|₂Z₂...|ₙZₙ
This is a special schema because the match recurses into nested slash structure. At depth 1 it is ordinary harmonic composition; this schema only generates rules for depth >= 2.
| PARAMETER | DESCRIPTION |
|---|---|
max_depth
|
Maximum nesting depth to traverse.
TYPE:
|
Source code in src/quivers/stochastic/schema.py
PatternBinarySchema
¶
PatternBinarySchema(left_pattern, right_pattern, conclusion_pattern, variables: frozenset[str], name: str = '')
Bases: BinaryRuleSchema
Binary rule schema from a DSL rule declaration.
Matches category pairs against two premise patterns and instantiates the conclusion pattern with bound variables.
| PARAMETER | DESCRIPTION |
|---|---|
left_pattern
|
Category pattern for the left antecedent.
TYPE:
|
right_pattern
|
Category pattern for the right antecedent.
TYPE:
|
conclusion_pattern
|
Category pattern for the consequent.
TYPE:
|
variables
|
Universally quantified pattern variables.
TYPE:
|
name
|
The rule's name (for description).
TYPE:
|
Source code in src/quivers/stochastic/schema.py
match
¶
Return the conclusion this rule derives from a pair, if any.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The left antecedent.
TYPE:
|
right
|
The right antecedent.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Category or None
|
The conclusion category, or |
Source code in src/quivers/stochastic/schema.py
PatternUnarySchema
¶
Bases: UnaryRuleSchema
Unary rule schema from a DSL rule declaration.
Matches a single category against a premise pattern and instantiates the conclusion pattern with bound variables.
| PARAMETER | DESCRIPTION |
|---|---|
premise_pattern
|
Category pattern for the antecedent.
TYPE:
|
conclusion_pattern
|
Category pattern for the consequent.
TYPE:
|
variables
|
Universally quantified pattern variables.
TYPE:
|
name
|
The rule's name (for description).
TYPE:
|
Source code in src/quivers/stochastic/schema.py
match
¶
match(cat: Category, system: CategorySystem) -> list[Category]
Return the conclusions this rule derives from a category.
| PARAMETER | DESCRIPTION |
|---|---|
cat
|
The antecedent category.
TYPE:
|
system
|
The category inventory; conclusions outside it are dropped.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of Category
|
The conclusion categories, empty when the rule does not apply. |
Source code in src/quivers/stochastic/schema.py
generalized_composition
¶
generalized_composition(max_depth: int = 2) -> RuleSchema
Create a generalized composition schema.
| PARAMETER | DESCRIPTION |
|---|---|
max_depth
|
Maximum nesting depth.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuleSchema
|
The generalized composition schema. |
Source code in src/quivers/stochastic/schema.py
schema_presentation
¶
schema_presentation(schema: RuleSchema, system: CategorySystem, name: str) -> RulePresentation
The rule presentation of a schema instantiated over categories.
Each category is a constructor of one closed sort; the judgment
span(c, i, j) says that category c covers the input from
i to j. A ground binary rule result -> left right is the
rule span(left, i, k), span(right, k, j) |- span(result, i, j) and
a ground unary rule result -> input is
span(input, i, j) |- span(result, i, j), each in the order the
schema generates them; a lexical entry is an occurrence of the
word slot, which carries its word.
| PARAMETER | DESCRIPTION |
|---|---|
schema
|
The schema.
TYPE:
|
system
|
The categories it is instantiated over.
TYPE:
|
name
|
The presentation's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RulePresentation
|
The presentation; a rule's weight parameter is named by its position among the rules of its arity. |
Source code in src/quivers/stochastic/schema.py
1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 | |
Bundled schemas¶
Stochastic morphisms: Markov kernels over finite sets.
This module provides the probabilistic layer for quivers, implementing the category FinStoch of finite sets and stochastic maps (Markov kernels). This is the Kleisli category of the Giry monad restricted to finite sets, where:
- Objects are finite sets (same as the base category).
- Morphisms A -> B are stochastic matrices: tensors of shape (|A|, |B|) whose rows sum to 1.
- Composition is standard matrix multiplication.
- Identity is the Kronecker delta.
The package also re-exports MarkovAlgebra and its singleton
MARKOV from quivers.core.algebras, the algebra these morphisms
compose under.
Submodules
morphisms : StochasticMorphism, CategoricalMorphism families : Discretized distribution families transforms : condition, mix, factor, normalize queries : prob, marginal_prob, expectation giry : GiryMonad, FinStoch categories : Category types including atoms, slashes, products, unit, modals semiring : Chart semiring abstractions (LogProb, Viterbi, Boolean, Counting) schema : Composable rule schemas (functors CategorySystem -> RuleSystem) rules : Rule systems and the CCG / Lambek presets span : Span-based CKY components (LexicalAxiom, BinarySpanDeduction, etc.) parsers, ccg, lambek : Chart parsers inside : The inside algorithm over a rule system agenda : The agenda-driven weighted-deduction engine indexed : Charts indexed on the argument positions rule joins look up joins : Worst-case optimal joins and variable elimination for rule bodies planning : Plans for queries over rule presentations forest : Packed forests of derivations and folds over them recursion : Linear cyclic systems solved through the algebra's closure tries : Tries of relations and the intersection step of Generic Join productions : A grammar's productions grouped by left-hand side effect_lifts : Effect-lifted rule schemas for deduction systems deduction : Abstract weighted deductive system framework and its operations stdlib : Pre-registered deduction systems
EVALUATION
module-attribute
¶
EVALUATION = ForwardApplication() | BackwardApplication()
Forward and backward application, the evaluation maps of a biclosed category.
HARMONIC_COMPOSITION
module-attribute
¶
HARMONIC_COMPOSITION = ForwardComposition() | BackwardComposition()
Forward and backward harmonic composition.
CROSSED_COMPOSITION
module-attribute
¶
CROSSED_COMPOSITION = ForwardCrossedComposition() | BackwardCrossedComposition()
Forward and backward crossed composition.
COMMUTATIVE_EVALUATION
module-attribute
¶
COMMUTATIVE_EVALUATION = CommutativeForwardApplication() | CommutativeBackwardApplication()
Application with the argument on either side, for commutative (LP) grammars.
ADJUNCTION_UNITS
module-attribute
¶
ADJUNCTION_UNITS = RightLifting() | LeftLifting()
Right and left type raising, the units of the slash adjunctions.
TENSOR_INTRODUCTION
module-attribute
¶
TENSOR_INTRODUCTION = TensorIntroduction()
Product formation, A, B -> A*B.
TENSOR_PROJECTION
module-attribute
¶
TENSOR_PROJECTION = LeftProjection() | RightProjection()
Left and right projections out of a product category.
UNIT_INTRODUCTION
module-attribute
¶
UNIT_INTRODUCTION = LeftUnitElimination() | RightUnitElimination()
The left and right unitors, I*A -> A and A*I -> A.
UNIT_ELIMINATION
module-attribute
¶
UNIT_ELIMINATION = UnitCoercion()
Coercion of any category to the monoidal unit, A -> I.
MODAL_INTRODUCTION
module-attribute
¶
MODAL_INTRODUCTION = ModalInjection()
Modal injection, A -> <>A.
MODAL_ELIMINATION
module-attribute
¶
MODAL_ELIMINATION = ModalProjection()
Modal projection, <>A -> A.
MODAL_APPLICATION
module-attribute
¶
MODAL_APPLICATION = ModalApplication()
Function application under a modality.
Grammar presets and the schema registry¶
Stochastic morphisms: Markov kernels over finite sets.
This module provides the probabilistic layer for quivers, implementing the category FinStoch of finite sets and stochastic maps (Markov kernels). This is the Kleisli category of the Giry monad restricted to finite sets, where:
- Objects are finite sets (same as the base category).
- Morphisms A -> B are stochastic matrices: tensors of shape (|A|, |B|) whose rows sum to 1.
- Composition is standard matrix multiplication.
- Identity is the Kronecker delta.
The package also re-exports MarkovAlgebra and its singleton
MARKOV from quivers.core.algebras, the algebra these morphisms
compose under.
Submodules
morphisms : StochasticMorphism, CategoricalMorphism families : Discretized distribution families transforms : condition, mix, factor, normalize queries : prob, marginal_prob, expectation giry : GiryMonad, FinStoch categories : Category types including atoms, slashes, products, unit, modals semiring : Chart semiring abstractions (LogProb, Viterbi, Boolean, Counting) schema : Composable rule schemas (functors CategorySystem -> RuleSystem) rules : Rule systems and the CCG / Lambek presets span : Span-based CKY components (LexicalAxiom, BinarySpanDeduction, etc.) parsers, ccg, lambek : Chart parsers inside : The inside algorithm over a rule system agenda : The agenda-driven weighted-deduction engine indexed : Charts indexed on the argument positions rule joins look up joins : Worst-case optimal joins and variable elimination for rule bodies planning : Plans for queries over rule presentations forest : Packed forests of derivations and folds over them recursion : Linear cyclic systems solved through the algebra's closure tries : Tries of relations and the intersection step of Generic Join productions : A grammar's productions grouped by left-hand side effect_lifts : Effect-lifted rule schemas for deduction systems deduction : Abstract weighted deductive system framework and its operations stdlib : Pre-registered deduction systems
CCG
module-attribute
¶
The combinatory categorial grammar preset: application plus harmonic and crossed composition.
LAMBEK
module-attribute
¶
LAMBEK = EVALUATION | ADJUNCTION_UNITS | TENSOR_INTRODUCTION | TENSOR_PROJECTION
The Lambek calculus preset: application, type raising, and the product rules.
LP
module-attribute
¶
The Lambek calculus with permutation preset: application in both orders and type raising.
SCHEMA_REGISTRY
module-attribute
¶
SCHEMA_REGISTRY: dict[str, RuleSchema] = {'evaluation': EVALUATION, 'harmonic_composition': HARMONIC_COMPOSITION, 'crossed_composition': CROSSED_COMPOSITION, 'generalized_composition': GeneralizedComposition(), 'adjunction_units': ADJUNCTION_UNITS, 'tensor_introduction': TENSOR_INTRODUCTION, 'tensor_projection': TENSOR_PROJECTION, 'commutative_evaluation': COMMUTATIVE_EVALUATION, 'unit_introduction': UNIT_INTRODUCTION, 'unit_elimination': UNIT_ELIMINATION, 'modal_introduction': MODAL_INTRODUCTION, 'modal_elimination': MODAL_ELIMINATION, 'modal_application': MODAL_APPLICATION}
The bundled schemas by the name a DSL rules clause uses for each.
CKY Components over Spans¶
Instantiation over spans of the abstract deductive framework for CKY chart parsing:
LexicalAxiom: Populates length-1 spans from a learnable lexicon.BinarySpanDeduction: Applies binary structural rules with learnable weights.UnarySpanDeduction: Applies unary rules to convergence.SpanGoal: Extracts the score of the start symbol over the full span.CKYSchedule: Bottom-up evaluation by span length.
span
¶
Span-based CKY components for the deductive system framework.
This module instantiates the abstract deduction primitives
(Axiom, Deduction, Goal, Schedule) for span-indexed
chart parsing (CKY). Items are indexed by (i, j, A) where
[i, j) is a string span and A is a category index.
The chart tensor has shape (batch, n_categories, seq_len, seq_len+1)
(categories-first for efficient indexing of the start symbol).
Components
LexicalAxiom Populates length-1 spans from a learnable lexicon. BinarySpanDeduction Applies binary rules: chart[i,k,L] ⊗ chart[k,j,R] → chart[i,j,A]. UnarySpanDeduction Closes a cell under the unary rules by their Kleene star. SpanGoal Extracts chart[start_cat, 0, seq_len]. CKYSchedule Bottom-up evaluation by span length.
Span plans
span_grammar reads the span form of a rule presentation, and
span_inside and span_recognize are the executors that
quivers.stochastic.planning.plan selects for it: values by length,
with the split points of each premise pair summed before the rules, and
support by Boolean matrix products over the split points.
Edge
¶
Edge = tuple[int, int, Tensor]
A weighted step between categories over one span: from, to, weight.
LexicalAxiom
¶
Bases: Axiom
Populate length-1 spans from a learnable lexicon.
Creates the chart tensor and fills
chart[b, :, i, i+1] = log_softmax(lexicon[tokens[b, i]]).
| PARAMETER | DESCRIPTION |
|---|---|
n_terminals
|
Vocabulary size.
TYPE:
|
n_categories
|
Number of category types.
TYPE:
|
Source code in src/quivers/stochastic/span.py
log_lexicon
property
¶
log_lexicon: Tensor
The log-probability lexicon.
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Shape |
forward
¶
forward(tokens: Tensor, semiring: ChartSemiring) -> SpanChart
Fill the length-1 spans from the lexicon.
| PARAMETER | DESCRIPTION |
|---|---|
tokens
|
Integer terminal indices of shape
TYPE:
|
semiring
|
The scoring semiring, recorded on the chart.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SpanChart
|
A chart whose cells |
Source code in src/quivers/stochastic/span.py
SpanChart
¶
SpanChart(cells: dict[tuple[int, int], Tensor], batch: int, seq_len: int, n_categories: int, device: device, semiring: ChartSemiring)
A span-indexed chart held as functional (non-in-place) cells.
This wraps a dict of (i, j) -> (batch, C) tensors. The
schedule fills cells bottom-up, and to_tensor() assembles
them into a dense (batch, C, seq_len, seq_len+1) tensor.
| PARAMETER | DESCRIPTION |
|---|---|
cells
|
The filled cells, keyed by span
TYPE:
|
batch
|
The batch size.
TYPE:
|
seq_len
|
The sentence length.
TYPE:
|
n_categories
|
The number of categories.
TYPE:
|
device
|
The device the dense chart is built on.
TYPE:
|
semiring
|
The scoring semiring; its
TYPE:
|
Source code in src/quivers/stochastic/span.py
to_tensor
¶
to_tensor() -> Tensor
Assemble cells into a dense chart tensor.
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Shape |
Source code in src/quivers/stochastic/span.py
BinarySpanDeduction
¶
BinarySpanDeduction(rule_system: RuleSystem, learnable: bool = True)
Bases: Deduction
Binary rule application over span items.
For each split point k in [i+1, j), combines
chart[i, k, lefts] and chart[k, j, rights]
to produce chart[i, j, results].
| PARAMETER | DESCRIPTION |
|---|---|
rule_system
|
The structural rules.
TYPE:
|
learnable
|
Whether rule weights are learnable.
TYPE:
|
Source code in src/quivers/stochastic/span.py
forward
¶
forward(chart: Tensor | None, semiring: ChartSemiring, **context) -> Tensor
Apply binary rules for one span cell (i, j).
| PARAMETER | DESCRIPTION |
|---|---|
chart
|
Unused; the cells are read from
TYPE:
|
semiring
|
The scoring semiring.
TYPE:
|
**context
|
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
The |
Source code in src/quivers/stochastic/span.py
UnarySpanDeduction
¶
UnarySpanDeduction(rule_system: RuleSystem, learnable: bool = True)
Bases: Deduction
Unary rules over one span, closed under their Kleene star.
A unary rule (a, b) with weight w derives category a
over a span from category b over the same span. Chains of such
rules never consume input and may cycle, so a cell is closed once by
the closure U* = I ⊕ U ⊕ U² ⊕ ... of the rule matrix
U[b, a] = ⊕ w, which sums every chain exactly once
Stolcke (1995), section
4.5.2, generalized to a semiring as in
Goodman (1999).
| PARAMETER | DESCRIPTION |
|---|---|
rule_system
|
The structural rules.
TYPE:
|
learnable
|
Whether rule weights are learnable.
TYPE:
|
Source code in src/quivers/stochastic/span.py
has_rules
property
¶
Whether this deduction has any unary rules.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when it has one. |
rule_matrix
¶
rule_matrix(n_categories: int, semiring: ChartSemiring) -> Tensor
The unary rules as a matrix over the semiring.
| PARAMETER | DESCRIPTION |
|---|---|
n_categories
|
The number of categories
TYPE:
|
semiring
|
The scoring semiring.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
|
Source code in src/quivers/stochastic/span.py
closure
¶
closure(n_categories: int, semiring: ChartSemiring) -> Tensor
The Kleene star U* of the unary-rule matrix.
| PARAMETER | DESCRIPTION |
|---|---|
n_categories
|
The number of categories
TYPE:
|
semiring
|
The scoring semiring.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
|
| RAISES | DESCRIPTION |
|---|---|
DivergentClosureError
|
If the closure's series diverges in the semiring. |
Source code in src/quivers/stochastic/span.py
forward
¶
forward(chart: Tensor, semiring: ChartSemiring, **context) -> Tensor
Close a cell under the unary rules.
| PARAMETER | DESCRIPTION |
|---|---|
chart
|
A
TYPE:
|
semiring
|
The scoring semiring.
TYPE:
|
**context
|
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
The |
| RAISES | DESCRIPTION |
|---|---|
DivergentClosureError
|
If the closure's series diverges in the semiring. |
Source code in src/quivers/stochastic/span.py
SpanGoal
¶
Bases: Goal
Extract chart[start_cat, 0, seq_len].
| PARAMETER | DESCRIPTION |
|---|---|
start_idx
|
Index of the start category.
TYPE:
|
Source code in src/quivers/stochastic/span.py
forward
¶
Read the start category's score over the whole sentence.
| PARAMETER | DESCRIPTION |
|---|---|
chart
|
The dense chart of shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
The |
Source code in src/quivers/stochastic/span.py
CKYSchedule
¶
Bases: Schedule
Bottom-up CKY: process spans in increasing length order.
For each span length 2..n: 1. Apply binary deductions for each cell (i, i+span_len). 2. Apply unary deductions to the resulting cell.
run
¶
run(chart: SpanChart, deductions: ModuleList, semiring: ChartSemiring) -> Tensor
Fill the chart bottom-up and return it as a dense tensor.
| PARAMETER | DESCRIPTION |
|---|---|
chart
|
The chart
TYPE:
|
deductions
|
The
TYPE:
|
semiring
|
The scoring semiring.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
The dense chart of shape |
Source code in src/quivers/stochastic/span.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
SpanRefused
¶
Bases: ValueError
A presentation is not in span form, or a run does not fit its plan.
| PARAMETER | DESCRIPTION |
|---|---|
reason
|
Why.
TYPE:
|
code
|
TYPE:
|
Source code in src/quivers/stochastic/span.py
SpanRule
didactic-model
¶
SpanRule(*, rule: Rule = field(opaque=True, extras=OPAQUE_BY_VALUE), binding: dict[str, Ground] = field(opaque=True, extras=OPAQUE_BY_VALUE), result: int, left: int = -1, right: int = -1, reads: Literal['none', 'span', 'split'] = 'none', positions: tuple[str, ...] = ())
Bases: ValueModel
One instance of a rule over categories, as the span kernel reads it.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
The rule.
TYPE:
|
binding
|
The values of its category variables.
TYPE:
|
result
|
The conclusion's category.
TYPE:
|
left
|
The first premise's category;
TYPE:
|
right
|
The second premise's category;
TYPE:
|
reads
|
What positions the side condition reads:
TYPE:
|
positions
|
The rule's position variables: start and end, with the split point between them for a binary rule.
TYPE:
|
SpanGrammar
didactic-model
¶
SpanGrammar(*, presentation: RulePresentation = field(opaque=True, extras=OPAQUE_BY_VALUE), family: FamilyId = field(opaque=True, extras=OPAQUE_BY_VALUE), category_slots: tuple[int, ...] = (), start: int = 0, end: int = 1, categories: tuple[tuple[str, ...], ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), binary: tuple[SpanRule, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), unary: tuple[SpanRule, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), constants: tuple[SpanRule, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), unary_cyclic: bool = False)
Bases: ValueModel
A presentation in span form: categories over spans of positions.
Every judgment is of one family whose indices are some indices of
closed sorts of nullary constructors, the category, and two natural
numbers, the start and end of a span. Every rule is binary,
A(i, j) <- B(i, k), C(k, j), unary, A(i, j) <- B(i, j), or
has no premises and a ground conclusion; its position arguments are
variables, its category arguments literals or variables of their
sorts (a variable stands for each constructor in turn), and its side
condition may read any of them. The length j - i grows strictly
along a binary rule, so the spans of each length are final once the
shorter ones are; that is the schedule.
| PARAMETER | DESCRIPTION |
|---|---|
presentation
|
The presentation.
TYPE:
|
family
|
The family.
TYPE:
|
category_slots
|
The argument positions of the category.
TYPE:
|
start
|
The argument position of the start.
TYPE:
|
end
|
The argument position of the end.
TYPE:
|
categories
|
Every category, its constructors at the category slots in order.
TYPE:
|
binary
|
The binary rule instances.
TYPE:
|
unary
|
The unary rule instances.
TYPE:
|
constants
|
The rules without premises.
TYPE:
|
unary_cyclic
|
Whether the unary rules' graph of categories has a cycle.
TYPE:
|
pairs
property
¶
The distinct premise pairs of the binary rules.
A rule whose side condition reads the split point is a pair of its own, since its sum over split points is its own.
| RETURNS | DESCRIPTION |
|---|---|
tuple of tuple of int
|
|
category
¶
category(item: Item) -> int
The category of an item of the family.
| PARAMETER | DESCRIPTION |
|---|---|
item
|
The item.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Its category's position in |
Source code in src/quivers/stochastic/span.py
positions
¶
positions(item: Item) -> tuple[int, int]
The start and end of an item of the family.
| PARAMETER | DESCRIPTION |
|---|---|
item
|
The item.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of int
|
|
Source code in src/quivers/stochastic/span.py
item
¶
item(category: int, start: int, end: int) -> Item
The item of a category over a span.
| PARAMETER | DESCRIPTION |
|---|---|
category
|
The category's position.
TYPE:
|
start
|
The start.
TYPE:
|
end
|
The end.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Item
|
The item. |
Source code in src/quivers/stochastic/span.py
SpanWork
didactic-model
¶
SpanWork(*, products: int = 0, sums: int = 0, pivots: int = 0, exact: int = 0, conditions: int = 0, allocated: int = 0, peak: int = 0)
Bases: ValueModel
The work of a span run, in elements of the algebra.
| PARAMETER | DESCRIPTION |
|---|---|
products
|
Binary products.
TYPE:
|
sums
|
Binary sums.
TYPE:
|
pivots
|
Closures of one element inside the unary closures.
TYPE:
|
exact
|
Operations of the closures' exact decisions.
TYPE:
|
conditions
|
Side conditions evaluated.
TYPE:
|
allocated
|
Elements of the tensors formed.
TYPE:
|
peak
|
Elements formed and held at once: the chart so far and one length's temporaries.
TYPE:
|
span_grammar
¶
span_grammar(presentation: RulePresentation) -> SpanGrammar
The span form of a presentation.
| PARAMETER | DESCRIPTION |
|---|---|
presentation
|
The presentation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SpanGrammar
|
Its span form. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If it is not a rule presentation. |
SpanRefused
|
If the presentation is not in span form, with the first reason. |
Source code in src/quivers/stochastic/span.py
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 | |
span_inside
¶
span_inside(grammar: SpanGrammar, algebra: OrderPreservingSemiring, seeds: Mapping[int, Tensor], length: int, binary: list[Tensor], unary: list[Tensor], *, like: Tensor, empty: Sequence[set[int]] = (), cyclic: bool = False) -> tuple[dict[int, Tensor], SpanWork]
The inside values of every span, by span length.
For each length l from one to the input's, the cells of length
l are computed at once: for each distinct premise pair (B, C)
the products x(B, i, k) ⊗ x(C, k, i + l) are summed over the split
points k first, then each binary rule multiplies its pair's sum by
its weight, the rules are summed into their conclusion's category,
the inputs of the length are added, and the cells are closed under the
unary rules. Summing the split points before the rules is right
distributivity, so the products keep the premises' order and the
rule weight last, and no product over categories, rules and split
points together is formed.
Inputs over empty spans make categories nullable. Their weights over
each empty span are solved first (_nullable), and a binary rule with
an empty premise becomes a step of its cell over one span, closed with
the unary rules: the standard treatment of empty spans, exact.
| PARAMETER | DESCRIPTION |
|---|---|
grammar
|
The grammar.
TYPE:
|
algebra
|
The algebra.
TYPE:
|
seeds
|
For each length,
TYPE:
|
length
|
TYPE:
|
binary
|
The weight of each instance of
TYPE:
|
unary
|
The weight of each instance of
TYPE:
|
like
|
The dtype and device.
TYPE:
|
empty
|
The categories of the inputs over each empty span, by position;
none by default. Their weights are
TYPE:
|
cyclic
|
Whether the contract admits a cycle over one span.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of dict and SpanWork
|
For each length |
| RAISES | DESCRIPTION |
|---|---|
SpanRefused
|
If the steps over one span have a cycle the contract does not admit or the algebra cannot sum, nullable categories form a nonlinear cycle, or an empty first premise needs a commutative product the algebra does not establish. |
Source code in src/quivers/stochastic/span.py
1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 | |
span_recognize
¶
span_recognize(grammar: SpanGrammar, seeds: Mapping[int, Tensor], length: int, binary: list[bool], unary: list[bool], *, device: device, empty: Sequence[set[int]] = ()) -> tuple[dict[int, Tensor], SpanWork]
Which category is derivable over which span, by Boolean matrix products.
For each length the pair matrix M[i][B, C] = OR_k x(B, i, k) AND
x(C, k, i + l) is the product of two 0-1 matrices over the split
points, computed as one batched matrix product and read as > 0;
each present binary rule reads its pair, and the cells are closed
under the present unary rules by one product with their closure.
The products are of counts below 2^53, so float64 holds them
exactly.
| PARAMETER | DESCRIPTION |
|---|---|
grammar
|
The grammar.
TYPE:
|
seeds
|
For each length,
TYPE:
|
length
|
TYPE:
|
binary
|
Whether each binary instance is present.
TYPE:
|
unary
|
Whether each unary instance is present.
TYPE:
|
device
|
The device.
TYPE:
|
empty
|
The categories of the inputs present over each empty span.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of dict and SpanWork
|
For each length, |
Source code in src/quivers/stochastic/span.py
2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 | |
Cited sources¶
Stuart M. Shieber, Yves Schabes, and Fernando C. N. Pereira. Principles and Implementation of Deductive Parsing. The Journal of Logic Programming, 24(1–2):3–36, 1995. URL: https://www.sciencedirect.com/science/article/pii/074310669500035I, doi:10.1016/0743-1066(95)00035-I.
Joshua Goodman. Semiring Parsing. Computational Linguistics, 25(4):573–606, 1999. URL: https://aclanthology.org/J99-4004/.
Joachim Lambek. The Mathematics of Sentence Structure. The American Mathematical Monthly, 65(3):154–170, 1958. URL: https://www.tandfonline.com/doi/abs/10.1080/00029890.1958.11989160, doi:10.1080/00029890.1958.11989160.