Deduction composition¶
Deduction signatures, lexicon modules, and rule schemata, composed into ordinary deductions; the item families of signatures, their inclusions and copaired folds; and the classification of an extension. The reference describes the surface, and the semantics states the rules.
deduction_composition
¶
Compose deductions from signatures, lexicon modules, and rule schemata.
A deduction may extend deduction signatures and take lexicon modules:
deduction signature CCGCore
atoms S, NP, N, Fwd, Bwd, span
rule fwd_app : span(I, K, Fwd(X, Y)), span(K, J, Y) |- span(I, J, X)
lexicon Nouns for CCGCore
atoms dog
"dog" : N = dog
deduction Grammar : Word -> Word [start=S]
extends CCGCore, Composition[n <= 1]
lexicon Nouns
compose_deductions interprets every such deduction statically as one
monolithic deduction whose atoms, rules, and lexicon are the union of
its parts, so every engine (the checked elaboration, the compiled agenda,
each transpile target) sees exactly the deduction a user could have
written by hand. The union is a colimit over the shared parts, by origin:
- an atom (and every rule) belongs to the declaration that introduces it.
A signature reached along two paths (
GrammarextendsAandB, both extendingBase) contributes its atoms once; two different declarations introducing one name are two atoms and are refused, never merged because their spellings coincide; - a lexicon module is typed against a signature: every atom its entries' categories use is an atom of that signature or of a signature it extends, and the deduction taking it must extend that signature;
- a signature's rules apply only atoms it declares or includes, and a
rule's identifiers are resolved where the rule is written: an atom
declared downstream, by an extension or a lexicon, never captures one
of its pattern variables or bound names, which are renamed apart from
every atom of the composed deduction (
_hygienic).
Rule schemata (quivers.dsl.deduction_schemata) are instantiated over the
composed rule set: a rules line in a signature or in the deduction
names any schema in scope, and extends S[c] keeps, of the instances of
the schemata declared in S (and the signatures S extends), those
whose parameters satisfy c.
The composed deduction records where each symbol was declared
(origins) and the signatures it extends (cores), whose atoms are
the constructors of the signature's own item family S.Item: the core a
generic reader of any extension observes, and the domain of the inclusion
S.Item -> Grammar.Item along which reification is natural.
CompositionError
¶
Bases: ValueError
A deduction whose parts do not compose.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
What is wrong.
TYPE:
|
line
|
Where.
TYPE:
|
col
|
Where.
TYPE:
|
Source code in src/quivers/dsl/deduction_composition.py
compose_deductions
¶
Interpret every composed deduction as one monolithic deduction.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
A flat module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The module itself when no statement is composed; otherwise the module with every deduction composed, and its deduction signatures, lexicon modules, and exports of them removed (they denote no code of their own). |
| RAISES | DESCRIPTION |
|---|---|
CompositionError
|
If a part is unknown, atoms or rules of different origins share a name, a lexicon entry's category uses an atom its signature lacks, a signature rule applies an atom the signature lacks, or a schema or its instantiation is ill-formed. |
Source code in src/quivers/dsl/deduction_composition.py
deduction_schemata
¶
Rule schemata: families of deduction rules indexed by static parameters.
A rule with a static telescope, rule r[n : Nat, e : Dir] : ..., is a
schema: one rule for every assignment of its parameters. A rules
line instantiates it at the assignments its constraints admit,
rules r[n <= 2, e in Dir] where not (n == 0 && e == Bwd)
and each instance is an ordinary rule, so it takes part in the chart
exactly as a hand-written rule would. A parameter ranges over its sort:
Bool over false and true, a declared index sort over its
constructors (each must be nullary), and Nat over the numerals a
bracketed bound (n <= 2, n < 3, n == 1) admits. Membership
constraints (e in {Fwd}) narrow a domain; every other constraint, and
the where condition, is a Boolean condition on the assignment.
Instantiation substitutes an assignment into the schema's patterns. A
parameter standing for an index value is the deduction atom of the same
spelling, in argument position or as the head of an application
(e(X, Y) is Fwd(X, Y) at e = Fwd); a numeral parameter is a
numeral. A slash spine Y |e Z ... n is the category Y taking the
n arguments Z_1 ... Z_n through the slash e, that is
e(...e(e(Y, Z_1), Z_2)..., Z_n); every spine over the same sequence
variable in one rule has the same length, so a premise and the
conclusion share the arguments. A name sequence z ... n, the first of
an application's two arguments, folds the application to the right:
e(z ... n, B) is B at n = 0 and e(z_1, e(z_2, ... e(z_n,
B))) otherwise, so Lam(z ... n, App(F, G |App z ... n)) binds the
names the spine applies G to, the composition combinator of degree
n. A sequence shares its variable's length with the rule's spines.
Each instance is named r_v1_..._vk (the parameters' values in
telescope order). The #[shared = F(p, ...)] pragma makes the rule's
weight the learnable weight family F at the index the parameters
take, so instances that agree on that index read one weight; its key is
shared_weight_key.
SHARED_OPTION
module-attribute
¶
The option key naming a rule's shared weight family.
SchemaValue
¶
A value of a schema parameter: a numeral, a Boolean, or an index value.
SchemaError
¶
Bases: ValueError
A rule schema or instantiation that does not denote a finite rule set.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
What is wrong.
TYPE:
|
line
|
Where.
TYPE:
|
col
|
Where.
TYPE:
|
Source code in src/quivers/dsl/deduction_schemata.py
render_value
¶
render_value(value: SchemaValue) -> str
The spelling of a parameter value in names and patterns.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The value.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/dsl/deduction_schemata.py
schema_parameters
¶
schema_parameters(rule: SequentRule) -> tuple[QiecIndexBinder, ...]
A schema's parameters, refusing a binder that is not over an index sort.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
A rule; a rule with no telescope has no parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[QiecIndexBinder, ...]
|
Its parameters, in telescope order. |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If the telescope binds a type, an effect, or a row: a schema's parameters range over finite static domains. |
Source code in src/quivers/dsl/deduction_schemata.py
constraint_location
¶
constraint_location(constraint: SchemaConstraint, line: int, col: int) -> tuple[int, int]
Where a constraint is written, or the given location if unknown.
| PARAMETER | DESCRIPTION |
|---|---|
constraint
|
The constraint.
TYPE:
|
line
|
The location to report when the constraint carries none.
TYPE:
|
col
|
The location to report when the constraint carries none.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, int]
|
The line and the column. |
Source code in src/quivers/dsl/deduction_schemata.py
evaluate_condition
¶
evaluate_condition(node: LetExprNode, environment: Mapping[str, SchemaValue], values: frozenset[str], where: tuple[str, int, int]) -> SchemaValue
Evaluate a constraint over one assignment.
| PARAMETER | DESCRIPTION |
|---|---|
node
|
The expression.
TYPE:
|
environment
|
The parameters' values.
TYPE:
|
values
|
The index values in scope, which a name may spell.
TYPE:
|
where
|
The schema's name and the instantiation's location, for refusals.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SchemaValue
|
The expression's value. |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If the expression uses a name that is neither a parameter nor an index value, an operator outside comparisons, arithmetic, and the Boolean connectives, or operands of the wrong kind. |
Source code in src/quivers/dsl/deduction_schemata.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
assignments
¶
assignments(rule: SequentRule, instantiation: RuleInstantiation, sorts: Mapping[str, QiecIndexDecl], restrictions: tuple[SchemaConstraint, ...] = ()) -> Iterator[tuple[SchemaValue, ...]]
Every assignment of a schema's parameters an instantiation admits.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
The schema.
TYPE:
|
instantiation
|
The
TYPE:
|
sorts
|
The module's index sorts.
TYPE:
|
restrictions
|
Further constraints from an
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
tuple[SchemaValue, ...]
|
One value per parameter, in telescope order, in the order of the domains (numerals ascending, index values in declaration order). |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If a constraint names no parameter, a domain is infinite or unknown, or a condition is ill-formed. |
Source code in src/quivers/dsl/deduction_schemata.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | |
index_values
¶
index_values(sorts: Mapping[str, QiecIndexDecl]) -> frozenset[str]
Every nullary index constructor of the module.
| PARAMETER | DESCRIPTION |
|---|---|
sorts
|
The module's index sorts.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
frozenset[str]
|
The names a constraint may use as values. |
Source code in src/quivers/dsl/deduction_schemata.py
constraint_names
¶
constraint_names(constraint: SchemaConstraint) -> set[str]
The names a constraint mentions.
| PARAMETER | DESCRIPTION |
|---|---|
constraint
|
A constraint.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
set[str]
|
The parameter of a membership; every variable of a condition. |
Source code in src/quivers/dsl/deduction_schemata.py
instantiate
¶
instantiate(rule: SequentRule, assignment: tuple[SchemaValue, ...]) -> SequentRule
The instance of a schema at one assignment.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
The schema.
TYPE:
|
assignment
|
One value per parameter, in telescope order.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SequentRule
|
The rule, with no parameters, named |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If a numeral or a Boolean heads an application or stands for a slash, a spine's or a name sequence's length is no numeral, two of them over one sequence variable differ in length, a name sequence is not the first of an application's two arguments, or a sequence variable's names would capture a name the rule already uses. |
Source code in src/quivers/dsl/deduction_schemata.py
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 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 | |
shared_weight_key
¶
shared_weight_key(rule: SequentRule) -> str | None
The weight-family index a rule's shared pragma reads, if any.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
A rule with no parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
|
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If the pragma's value is not a family name or a family applied to numerals and names, or still names a parameter. |
family_parameter_key
¶
The agenda engine's parameter key of a shared weight family's index.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
An injective spelling without dots: |
Source code in src/quivers/dsl/deduction_schemata.py
canonical_rule
¶
canonical_rule(rule: SequentRule, atoms: frozenset[str]) -> str
A rule's premises and conclusion up to the names of its variables.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
A rule.
TYPE:
|
atoms
|
The deduction's atoms; every other identifier (not a numeral) of a pattern is a variable.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The patterns with every variable renamed by first occurrence; two rules with equal renderings derive the same items. |
Source code in src/quivers/dsl/deduction_schemata.py
deduction_reification
¶
Item families of deduction signatures, inclusions, and copaired folds.
A deduction signature S that derives classes (deduction signature S
deriving (Quote[Term via q])) has an item family of its own, S.Item,
whose constructors are its atoms: the term algebra of the core. Every
composed deduction G extending S then gets
- the inclusion
G.include.S : S.Item -> G.Item, the unique fold sending each core constructor to the constructor ofGit is (its item family isItem[S | rho]: the core's constructors and the extension's); - every class
Sderives, derived forG.Itemtoo. A class derived through morphisms (a fold, asQuoteis) is copaired:G's ownviamorphisms, then the core's, each clause renamed from the constructor's declaring origin (S.Fwd,Lexicon.dog) toG's constructor (G.Fwd). The first clause for a constructor wins, so an extension may give a core constructor an algebra of its own; a constructor with no clause in any part is refused, naming the declaration that introduces it. There is no default clause. - the naturality law of each such fold along the inclusion, generated as a
property: for every core itemx, the core's fold ofxequals the extension's fold ofG.include.S(x), compared by the target'seq. The law fails exactly when an extension's own clause for a core constructor disagrees with the core's. It is a test of the module declaring the extension, so a flat program holds the laws of its root module's deductions only, titled with the names people write:quote of std.grammar.ccg.Categorial.Item is natural along its inclusion into G.Item, the extension identifying the instantiation.
Every generated declaration and refusal is located at the declaration it concerns: a core's fold where the signature derives it, and an extension's inclusion, copaired fold, and law where the deduction is declared, so a diagnostic names that declaration's file and line through the module graph's source map.
Binders take part like other constructors: a term's bound variables are
items bound(k) numbered canonically in binding order, so the item term
algebra is first-order, alpha-equivalent terms are equal items, and the
inclusion, which keeps every number, preserves binding.
The slots S's rules leave open (slot_classes), and the slots of an
atom its rules never apply, take the sorts each extension gives them, and
a fold's clauses read each slot at one type, so the item family is
instantiated once per sort assignment: S.Item when S leaves
nothing open, else S.at_<sorts>.Item (CCGCore.at_int.Item for
lexicalized extensions, CCGCore.at_item.Item for those taking axioms
as input), each with its own constructors S.at_<sorts>.<atom> and its
own derived classes. Each extension includes, and states the law along,
its own instantiation; extensions with one assignment share one.
Composition identifies a constructor by its origin, so a clause may name
it through any part reaching it, whatever the instantiation: its
declaring signature (Categorial.S), any included signature extending
that one (Reified.S for Reified extends Categorial), or the
signature or deduction whose fold the clause is for. Every spelling is
the one constructor, in the core's fold and in each extension's copair.
A core whose every constructor holds an item (Fwd, Bwd, and span
with no atom) has no finite item, so its naturality law holds vacuously and
is not generated.
Everything here is surface QVR generated from the composed deduction, so it elaborates and checks like hand-written code.
ReificationError
¶
Bases: ValueError
A signature whose item family or folds cannot be generated.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
What is wrong.
TYPE:
|
line
|
Where.
TYPE:
|
col
|
Where.
TYPE:
|
Source code in src/quivers/dsl/deduction_reification.py
open_atoms
¶
open_atoms(decl: DeductionDecl) -> frozenset[str]
The atoms a deduction signature's rules never mention.
Nothing in the signature fixes such an atom's arity or the sorts of
its slots: each extension fixes them (_instantiation), and generic
code over the signature requires what its own uses fix.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
A deduction signature's atoms, binders, and rules, as a deduction with no lexicon.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
frozenset[str]
|
The atoms no rule writes, applied or bare. |
Source code in src/quivers/dsl/deduction_reification.py
slot_sorts
¶
slot_sorts(decl: DeductionDecl) -> dict[str, tuple[str, ...]]
Each symbol of a deduction and the sorts of its slots.
A slot is Int where it holds a chart position (position_slots)
or a bound variable's number, and an item otherwise. This is the item
family the deduction's elaboration declares.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
A composed deduction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, tuple[str, ...]]
|
|
Source code in src/quivers/dsl/deduction_reification.py
slot_classes
¶
slot_classes(decl: DeductionDecl) -> dict[str, tuple[str, ...]]
The slot sorts a deduction signature fixes, and those it leaves open.
A signature has no lexicon of its own, so whether a slot holds a chart
position may be decided only by the deduction extending it: span's
first two slots are positions in a deduction that reads a sentence
through a lexicon and items in one that takes its axioms as input. A
slot is
"int"when the signature's rules make it a position (a numeral fills it, or a variable shared with such a slot);"item"when they fill it with an atom or an application (which no position slot holds), when it is a binder's bound variable, or when a variable connects it with such a slot;"slot<k>"otherwise: one of the open classes, numbered in order of appearance, of slots the rules connect by shared variables. Every slot of a class has one sort in any deduction extending the signature, since a shared variable fills them all, and that sort is the extension's to fix.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
A deduction signature's atoms, binders, and rules (schema instances included), as a deduction with no lexicon.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, tuple[str, ...]]
|
The sort or class of each slot, by symbol, ordered as |
Source code in src/quivers/dsl/deduction_reification.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
reify_cores
¶
Generate the core families, inclusions, folds, and laws of a module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
A module whose deductions are composed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The module itself when no extended signature derives a class; otherwise the module with each such signature's item family and its classes, each extension's inclusion and copaired classes, and the naturality law of each fold. |
| RAISES | DESCRIPTION |
|---|---|
ReificationError
|
If two extensions type a core constructor differently, or a fold names more than one target type. |
Source code in src/quivers/dsl/deduction_reification.py
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 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | |
deduction_conservativity
¶
Classify the extension of a deduction signature by a deduction.
A deduction G extending a signature S may derive items that are
already items of S's language (adding composition to an application
core derives new S categories), so a result about the core need not
survive the extension. In the vocabulary of theory inclusions
(quivers.dsl.theories), the inclusion of S's rules into G's is
- definitional when
Gadds no rules and no symbols toS; - conservative when, for every set of axioms in
S's language, every item inS's languageGderives from themSderives too; - neither when some axioms in
S's language letGderive anSitemSdoes not.
The checker establishes conservativity by a sufficient syntactic condition and refutes it with a witness, never by trust:
- every rule
Gadds concludes an item whose pattern applies a symbolSlacks, so its conclusions are neverSitems, and every rule ofGkeeps every premise variable in its conclusion, so no rule turns an item mentioning such a symbol back into anSitem: conservative; - a sentence over the entries of
G's lexicon whose categories are inS's language, of at mostMAX_LENGTHwords, on whichG's chart holds anSitem that the chart ofS's rules alone lacks: neither, with the sentence and the item as the witness; - anything else is undetermined.
Results of generic code typed against Deduction extends S hold for an
extension exactly when its inclusion is conservative or definitional;
extension_notes reports every other verdict so a reader knows a result
about the core does not carry over.
ExtensionVerdict
didactic-model
¶
ExtensionVerdict(*, deduction: str, signature: str, classification: Classification, reason: str, sentence: tuple[str, ...] = (), item: str = '', line: int = 0, col: int = 0)
Bases: Model
The classification of one deduction's extension of one signature.
| PARAMETER | DESCRIPTION |
|---|---|
deduction
|
The extending deduction.
TYPE:
|
signature
|
The extended signature.
TYPE:
|
classification
|
What the checker established.
TYPE:
|
reason
|
Why.
TYPE:
|
sentence
|
For
TYPE:
|
item
|
For
TYPE:
|
line
|
The deduction's location.
TYPE:
|
col
|
The deduction's location.
TYPE:
|
classify_extension
¶
classify_extension(module: Module, deduction: DeductionDecl, signature: str) -> ExtensionVerdict
Classify a composed deduction's extension of one of its signatures.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The composed module holding the deduction.
TYPE:
|
deduction
|
A composed deduction.
TYPE:
|
signature
|
A signature it extends.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ExtensionVerdict
|
The classification, with the reason or the witness. |
Source code in src/quivers/dsl/deduction_conservativity.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
classify_extensions
¶
classify_extensions(module: Module) -> tuple[ExtensionVerdict, ...]
Classify every extension of a signature by a deduction of a module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
A module; its deductions are composed first.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ExtensionVerdict, ...]
|
One verdict per deduction and signature it extends, in order. |
Source code in src/quivers/dsl/deduction_conservativity.py
extension_notes
¶
extension_notes(module: Module) -> tuple[ExtensionVerdict, ...]
The extensions whose generic results do not carry over from the core.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
A module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ExtensionVerdict, ...]
|
Every verdict that is neither definitional nor conservative: for
those deductions, a result of generic code typed against
|
Source code in src/quivers/dsl/deduction_conservativity.py
deduction_modules
¶
Walk deduction bodies, deduction signatures, and lexicon modules.
A deduction and a deduction signature share one body language (atoms,
binders, rules and rule schemata, rules instantiations, extends
lines, lexicon blocks and lexicon references), so one walker reads it
into a DeductionBody; each declaration then keeps the parts it admits.
Rule patterns are walked by walk_rule_pattern, which is the only place
a slash spine (Y |e Z ... n) is read: a spine anywhere else is not a
pattern of a rule schema and quivers.dsl.parser.expressions refuses it.
PragmaWalker
¶
PragmaWalker = Callable[[_Tree, str | None], tuple[OptionEntry, ...]]
Walks a lexicon_pragma vertex (or its absence) into options.
DeductionBody
didactic-model
¶
DeductionBody(*, atoms: tuple[str, ...] = (), binders: tuple[str, ...] = (), rules: tuple[SequentRule, ...] = (), lexicon: tuple[LexiconEntry, ...] = (), lexicon_from_file: str | None = None, lexicon_from_file_options: tuple[OptionEntry, ...] = (), extends: tuple[DeductionExtension, ...] = (), lexicons: tuple[LexiconReference, ...] = (), instantiations: tuple[RuleInstantiation, ...] = (), lexicon_line: int = 0, lexicon_col: int = 0)
Bases: Model
The parts of one deduction or deduction-signature body.
| PARAMETER | DESCRIPTION |
|---|---|
atoms
|
The declared atoms.
TYPE:
|
binders
|
The declared binder constructors.
TYPE:
|
rules
|
The rules and rule schemata.
TYPE:
|
lexicon
|
The entries of inline lexicon blocks.
TYPE:
|
lexicon_from_file
|
The path of a
TYPE:
|
lexicon_from_file_options
|
That line's options.
TYPE:
|
extends
|
The
TYPE:
|
lexicons
|
The lexicon modules named on
TYPE:
|
instantiations
|
The
TYPE:
|
lexicon_line
|
Where the first inline lexicon block or
TYPE:
|
lexicon_col
|
Where the first inline lexicon block or
TYPE:
|
walk_rule_pattern
¶
walk_rule_pattern(t: _Tree, vid: str) -> ObjectExpr
Walk a premise or conclusion of a rule, reading slash spines.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
An object-expression vertex.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ObjectExpr
|
The pattern; a spine becomes an |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a spine is malformed. |
Source code in src/quivers/dsl/parser/deduction_modules.py
walk_deduction_body
¶
walk_deduction_body(t: _Tree, vid: str, *, entry: EntryWalker, pragma: PragmaWalker) -> DeductionBody
Walk the body entries of a deduction or a deduction signature.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
entry
|
Walks a lexicon entry.
TYPE:
|
pragma
|
Walks a rule's pragma.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DeductionBody
|
Its parts, in source order. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If an entry is malformed. |
Source code in src/quivers/dsl/parser/deduction_modules.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
walk_deduction_signature_decl
¶
walk_deduction_signature_decl(t: _Tree, vid: str, *, docs: tuple[str, ...], entry: EntryWalker, pragma: PragmaWalker) -> DeductionSignatureDecl
Walk a deduction signature declaration.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
docs
|
Its doc comment.
TYPE:
|
entry
|
Walks a lexicon entry.
TYPE:
|
pragma
|
Walks a rule's pragma.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DeductionSignatureDecl
|
The signature. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the body holds a lexicon block or a |
Source code in src/quivers/dsl/parser/deduction_modules.py
walk_lexicon_decl
¶
walk_lexicon_decl(t: _Tree, vid: str, *, docs: tuple[str, ...], entry: EntryWalker) -> LexiconDecl
Walk a lexicon NAME for S declaration.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
docs
|
Its doc comment.
TYPE:
|
entry
|
Walks a lexicon entry.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LexiconDecl
|
The lexicon module. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If its name or signature is missing. |