Composable deductions and rule schemata¶
This page states what a deduction assembled from signatures, lexicon modules, and rule schemata means. The surface is described in the composable deductions reference; the monolithic deductions it denotes are those of weighted deduction.
A reindexed interpretation pulls back a target carrier along a checked map on category indices. Rule operations form an algebra on that carrier, and the fold of an input derivation evaluates the operations at its mapped indices. Proof search and weights continue to use the source presentation. Thus two source categories with an equal image still have their own source judgments.
1. Deductions as presentations¶
A deduction's rules present a polynomial functor over its judgments: a rule with premises \(p_1, \dots, p_k\) and conclusion \(c\) contributes the term \(c \leftarrow p_1 \times \dots \times p_k\), and the rules together are the sum of their terms. The chart is the least weighted fixed point of that functor, the initial algebra of the presentation over the semiring the deduction declares. Two consequences shape everything below. Adding rules adds terms, so a deduction with the rules of \(S\) and the rules of \(T\) is the sum \(P_S + P_T\) of their presentations. And an algebra of a sum on a carrier is exactly a pair of algebras on that carrier, one for each summand, which is what makes the copaired folds of section 6 well defined.
2. Composition by origin¶
Each declaration contributes atoms, binder constructors, and rules, each tagged by its origin, the declaration that introduces it: a deduction signature, a lexicon module, or the deduction itself. A deduction \(G\) that extends signatures \(S_1, \dots, S_n\) and takes lexicon modules \(L_1, \dots, L_m\) denotes the colimit of the diagram of inclusions among its parts, where \(S_i\) includes every signature it extends. Because every inclusion maps a tagged element to the same tagged element, the colimit is the union of the parts in which two elements are identified exactly when they have one origin. A signature reached along two paths is therefore contributed once.
Names play no part in this identification. Two elements of different origins that share a spelling are two atoms of the colimit, and the item family of \(G\) names its constructors by spelling, so the colimit has no faithful item family; composition refuses it rather than renaming one of them. The refusal names both declarations. Rules are treated alike.
A lexicon module \(L\) is typed against a signature \(S\): every atom of every category of an entry of \(L\) is an atom whose origin is \(S\) or a signature \(S\) includes. A deduction takes \(L\) only if it includes \(S\). The entries of \(L\) are then axioms over \(S\)'s language, and the atoms \(L\) declares are logical-form constants of origin \(L\).
The composed deduction keeps \(G\)'s header. Its atoms are listed signatures first (bases before extensions, each in declaration order), then lexicon modules in the order named, then \(G\)'s own; its rules likewise; its lexicon is the entries of the lexicon modules in order, then \(G\)'s inline entries. Every engine runs this deduction, so a composed deduction and the monolithic deduction with the same atoms, rules, and entries have the same charts and weights.
3. Rule schemata¶
A schema \(r\) with parameters \(x_1 : D_1, \dots, x_k : D_k\) is a family of rules indexed by the
assignments \(D = D_1 \times \dots \times D_k\), where \(\mathrm{Bool} = \{\mathit{false},
\mathit{true}\}\), an index sort with nullary constructors is the set of its constructors, and
\(\mathrm{Nat}\) is cut down to \(\{0, \dots, b\}\) by a bound the instantiation states. A
rules r[c] where w line denotes the subset \(D_{c,w} \subseteq D\) of assignments satisfying the
constraints, and contributes the sum of the instances,
so each instance takes part in the chart exactly as a hand-written rule would. The instance \(r[a]\) substitutes \(a\) into the patterns: a value of an index sort is the atom of the same spelling, and the slash spine is defined by recursion on its length,
with \(Z_1, \dots, Z_n\) fresh variables shared by every spine over \(Z\) in the rule. For CCG, the forward schema at \(n = 0\) is application, at \(n = 1\) harmonic or crossed composition according to \(e\), and at \(n = 2\) generalized composition of degree two (Steedman, 2000).
A sum is not idempotent: \(P + P\) counts every derivation by \(P\) twice. Two instances of one schema that are the same rule up to the names of their variables, such as the forward schema at \(n = 0\) for either slash, are therefore refused, and the instantiation must exclude one.
4. Shared weights¶
A learnable rule reads a weight \(\theta_r(\beta)\) for its non-position bindings \(\beta\). A shared
weight family \(F\) is instead a map \(\theta_F : I \to K\) from the family's index set to the
semiring's carrier, and an instance \(i\) of a schema naming shared = F(x_{j_1}, \dots) reads
\(\theta_F(\pi(i))\), where \(\pi\) projects the instance's assignment onto the indexing parameters.
Weight sharing is the reindexing of the rule weight family along \(\pi\). By the chain rule the
gradient of a chart weight \(Z\) with respect to one index is the sum over the instances it serves,
so every instance that fires trains the shared weight.
5. Items of an extension¶
The item family of a deduction has one constructor per atom, typed by the slots the rules give
it: a chart position is Int, anything else an item. For a signature \(S\) extended by \(G\), the
constructors of \(G.\mathrm{Item}\) are those of \(S.\mathrm{Item}\), renamed into \(G\), together with
a row \(\rho\) of the constructors the other parts add: \(G.\mathrm{Item} = \mathrm{Item}[S \mid
\rho]\) in the sense of extensible variants (Morris and McKinna, 2019). The inclusion
\(\iota_G : S.\mathrm{Item} \to G.\mathrm{Item}\) sends each core constructor to its image.
The sorts of the core's slots are those \(S\)'s own rules fix. A slot a numeral fills is a
position, a slot an atom, an application, or a bound variable fills is an item, and the relation
"a rule fills both with one variable" generates classes of slots that share a sort in every
extension, because in each extension one variable fills them all. A class with a fixed slot has
that slot's sort; every other class is open, and its sort is a parameter of the signature that
each extension instantiates: span's positions are \(\mathrm{Int}\) in a lexicalized extension and
items in one that takes its axioms as input. An atom \(S\)'s rules never apply has its arity and
each of its slots open in the same way.
Generic code over \(S\) is typed against Deduction extends S. Its body is checked once, at an item
family with \(S\)'s constructors, an abstract type for each open class, and one constructor \(\star\)
that no code can name, standing for \(\rho\). A case analysis must therefore cover \(\star\), with a wildcard, and so it cannot assume that
\(S\)'s constructors are all there are; a constructor of \(\rho\) cannot be named at all. Each call is
specialized at the deduction passed, where \(\star\) is replaced by the actual row. A deduction
matches the signature when it includes \(S\) and gives \(S\)'s constructors the slots \(S\) gives them.
6. Folds and naturality¶
A class derived through a signature morphism, such as Quote[T via q], is the fold
\(\mathrm{fold}_q : \mathrm{Item} \to T\) the morphism's clauses induce, the unique algebra
morphism out of the item term algebra (Swierstra, 2008; Hubers and Morris, 2023). For an extension,
section 1 gives the algebra on \(T\) as a copair: the core's algebra \(q_S\) on the constructors of
\(S\) and the extension's algebra \(q_\rho\) on those of \(\rho\), with the extension's own clause for a
core constructor, if it gives one, taking precedence. A clause names its constructor through a
part, and since the composite identifies a constructor by its origin (section 2), every part
reaching it, whether the part declaring it or a signature extending that part, names the same
constructor: the algebras are keyed by origin, never by the signature that derives the fold. A constructor that no part's algebra covers
leaves the copair undefined and is refused.
The core's fold is natural along the inclusion when
which holds when \(q_G\) restricted to \(S\)'s constructors is \(q_S\). The core's item family is
parameterized by the sorts of its open slot classes (section 5), and a fold reads each slot at
one type, so \(S.\mathrm{Item}\) is instantiated at each sort assignment \(\sigma\) its extensions
give, \(S.\mathrm{Item}_\sigma\), with the core's algebra and \(\iota_G : S.\mathrm{Item}_{\sigma(G)}
\to G.\mathrm{Item}\) for each extension at its own assignment. Binding items are no
exception: a bound variable is the item \(\mathrm{bound}(k)\) with \(k\) its
de Bruijn index, the number of binders between
an occurrence and its own, so the item term algebra is first-order, alpha-equivalent terms are equal items,
\(\iota_G\) keeps every number and hence every binding, and a binder's clause receives the
abstraction as its bound-variable item and its body. Each extension's law is
generated as a property over \(S.\mathrm{Item}\) and checked by qvr test; it fails exactly when
the extension's own clause for a core constructor disagrees with the core's.
7. Conservativity of an extension¶
A rule of \(G\) may derive an item of \(S\)'s language that \(S\)'s rules do not derive from the same
axioms (composition derives S/NP from Mary saw), so a result about \(S\) need not survive the
extension. Following the classification of theory inclusions (theories), the
inclusion of \(S\)'s rules into \(G\)'s is
- definitional when \(G\) adds no rules and no symbols;
- conservative when for every set \(A\) of axioms over \(S\)'s language, every item over \(S\)'s language derivable from \(A\) by \(G\)'s rules is derivable from \(A\) by \(S\)'s;
- neither otherwise.
The checker establishes conservativity by a sufficient condition. If \(G\) adds no rules, its rules
are \(S\)'s and the condition holds trivially. Otherwise it requires that every added rule's
conclusion apply a symbol outside \(S\), so no added rule concludes an item of \(S\)'s language, and
that every rule keep each non-position premise variable in its conclusion, so no rule turns an
item mentioning such a symbol into one of \(S\)'s language; by induction on derivations, every
derivation of an item of \(S\)'s language then uses \(S\)'s rules only. It refutes conservativity
with a witness: a sentence over the lexical entries whose categories are in \(S\)'s language, on
which \(G\)'s chart holds an item of \(S\)'s language that the chart of \(S\)'s rules lacks. Anything
else is undetermined; the checker never classifies by trust, and qvr check reports every
extension that is not established conservative.
Cited sources¶
Mark Steedman. The Syntactic Process. MIT Press, 2000. URL: https://direct.mit.edu/books/book/4283/The-Syntactic-Process, doi:10.7551/mitpress/6591.001.0001.
J. Garrett Morris and James McKinna. Abstracting Extensible Data Types: Or, Rows by Any Other Name. Proceedings of the ACM on Programming Languages, 3(POPL):1–28, 2019. doi:10.1145/3290325.
Wouter Swierstra. Data Types à la Carte. Journal of Functional Programming, 18(4):423–436, 2008. doi:10.1017/S0956796808006758.
Alex Hubers and J. Garrett Morris. Generic Programming with Extensible Data Types: Or, Making Ad Hoc Extensible Data Types Less Ad Hoc. Proceedings of the ACM on Programming Languages, 7(ICFP):356–384, 2023. doi:10.1145/3607843.