Theories¶
The theory layer of a module: theory, view, and model declarations elaborated over panproto's
theory engine through quivers.gat. TheoryLayer
is what the compiler builds and what Program.theory_layer holds. The
theories reference describes the surface, and
the semantics states the constructions and guarantees.
theories
¶
Theories, views, and models of QVR modules, elaborated over panproto.
A theory is a presentation: sorts, operations, equations, and rules,
and the theories it includes. A view is a theory morphism whose
domain's equations become obligations in its codomain. A model is a
finite set-theoretic model, interpreted by QIEC types and computations or
constructed along a view. Every composition is a
colimit computed by panproto's
theory engine through quivers.gat, over shared theories
identified by origin and never by name; see the theories page of the
semantics documentation.
TheoryLayer is what the compiler
builds for a module and what Program.theory_layer exposes.
MAX_ASSIGNMENTS
module-attribute
¶
The most variable assignments a law is checked at in one model.
MODEL_FUEL
module-attribute
¶
The machine steps one operation of a model may take on one argument tuple.
MAX_SEARCHED_MODELS
module-attribute
¶
The most complete models of the included theory one search examines.
HostValue
¶
HostValue = bool | tuple[HostValue, ...] | RuntimeConstructor
A value of a finite type as the reference machine holds it.
ResultValue
¶
ResultValue = Tensor | bool | int | str | RuntimeConstructor | tuple[ResultValue, ...]
A value the reference machine returns from a model's operation.
TheoryStatement
¶
TheoryStatement = TheoryDecl | ViewDecl | ModelDecl
A declaration of the theory layer.
Classification
¶
What an extension of a theory is known to be.
LawStatus
¶
How a law is known to hold: proved by the checker, or assumed.
A law that is assumed may still be checked in finite models; the models it was checked in are recorded beside its status.
MemberKind
¶
The kinds of symbol and law a presentation has.
CarrierError
¶
Bases: ValueError
A type whose values the checker cannot list, with the reason.
Verdict
didactic-model
¶
Verdict(*, classification: Classification, reason: str, witness: ExtensionWitness | None = None, search: SearchResult | None = None)
Bases: Model
The classification of one inclusion and the argument for it.
| PARAMETER | DESCRIPTION |
|---|---|
classification
|
What the checker established.
TYPE:
|
reason
|
Why.
TYPE:
|
witness
|
The model with no expansion, for
TYPE:
|
search
|
The bounded model search, when the inclusion asked for one and the classification was not settled without it.
TYPE:
|
TheoryLayer
¶
The theories, views, and models of a module and what is known of them.
| ATTRIBUTE | DESCRIPTION |
|---|---|
theories |
Every theory by origin: the declared ones by name, and every theory expression by its text.
TYPE:
|
views |
Every view by name.
TYPE:
|
models |
Every model by name.
TYPE:
|
extensions |
The classification of every inclusion and hiding.
TYPE:
|
Source code in src/quivers/dsl/theories/layer.py
declarations
property
¶
declarations: tuple[TheoryStatement, ...]
The queued declarations, in source order.
| RETURNS | DESCRIPTION |
|---|---|
tuple
|
The declarations. |
add
¶
add(statement: TheoryStatement) -> None
Queue a declaration, in source order.
| PARAMETER | DESCRIPTION |
|---|---|
statement
|
The declaration.
TYPE:
|
Source code in src/quivers/dsl/theories/layer.py
theory
¶
theory(name: str) -> TheoryValue
A declared theory.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Its name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TheoryValue
|
The theory. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If no theory of that name is declared. |
Source code in src/quivers/dsl/theories/layer.py
add_theory
¶
add_theory(value: TheoryValue) -> TheoryValue
Record a theory built outside a theory declaration.
A module signature that carries equations is a theory
(quivers.dsl.theories.instances.signature_theory); recording it
here lets views and models refer to it by its origin.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The theory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TheoryValue
|
The theory. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a theory, view, or model of the same name is declared. |
Source code in src/quivers/dsl/theories/layer.py
check_view
¶
check_view(decl: ViewDecl) -> CheckedView
Elaborate one view and settle its obligations with the known models.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
The view.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CheckedView
|
The view, each obligation established or assumed. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If the view is refused, an obligation is refuted by a model of its codomain, or an obligation is neither established nor assumed. |
Source code in src/quivers/dsl/theories/layer.py
check
¶
check(module: QiecModule | None) -> None
Elaborate and check every queued declaration.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The module's checked QIEC core, whose types and computations
interpret models, or
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
At the first declaration, view obligation, or inclusion the checker refuses. |
Source code in src/quivers/dsl/theories/layer.py
models_of
¶
models_of(origin: str) -> tuple[CheckedModel, ...]
The checked models of one theory.
| PARAMETER | DESCRIPTION |
|---|---|
origin
|
The theory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of CheckedModel
|
Its models, in declaration order. |
Source code in src/quivers/dsl/theories/layer.py
LocalLaw
didactic-model
¶
Bases: Model
A checked equation or rule a theory declares itself.
| PARAMETER | DESCRIPTION |
|---|---|
local
|
Its name as declared.
TYPE:
|
sides
|
Its two sides, as panproto serializes terms, in one JSON list.
TYPE:
|
oriented
|
Whether it is a rule
TYPE:
|
line
|
Where it is declared.
TYPE:
|
col
|
Where it is declared.
TYPE:
|
LocalOperation
didactic-model
¶
Bases: Model
An operation a theory declares itself.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The operation.
TYPE:
|
serialized
|
The operation in panproto's serialized shape: its inputs, each with a name, a sort expression, and whether it is implicit, and its output sort expression.
TYPE:
|
line
|
Where it is declared.
TYPE:
|
col
|
Where it is declared.
TYPE:
|
LocalPart
didactic-model
¶
LocalPart(*, sorts: tuple[LocalSort, ...] = (), operations: tuple[LocalOperation, ...] = (), laws: tuple[LocalLaw, ...] = (), assume_terminating: bool = False)
Bases: Model
The declarations of a theory that are not included from another.
| PARAMETER | DESCRIPTION |
|---|---|
sorts
|
Its sorts.
TYPE:
|
operations
|
Its operations.
TYPE:
|
laws
|
Its equations and rules.
TYPE:
|
assume_terminating
|
Whether termination of the rules it can reach is assumed.
TYPE:
|
is_empty
¶
Whether it declares nothing.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether there are no sorts, operations, or laws. |
LocalSort
didactic-model
¶
Bases: Model
A sort a theory declares itself.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The sort.
TYPE:
|
serialized
|
The sort in panproto's serialized shape, with its parameters.
TYPE:
|
line
|
Where it is declared.
TYPE:
|
col
|
Where it is declared.
TYPE:
|
SearchResult
didactic-model
¶
SearchResult(*, bound: int, models: int = 0, exhausted: bool = True, witness: ExtensionWitness | None = None)
Bases: Model
What a bounded search found.
| PARAMETER | DESCRIPTION |
|---|---|
bound
|
The most elements a carrier had.
TYPE:
|
models
|
The models of the included theory examined.
TYPE:
|
exhausted
|
Whether every model within the bound was examined, rather than
the search stopping at
TYPE:
|
witness
|
A model with no expansion, if one was found.
TYPE:
|
CheckedModel
didactic-model
¶
CheckedModel(*, name: str, theory: str, model: FiniteModel, interpretations: tuple[SymbolInterpretation, ...] = (), construction: Literal['', 'reduct', 'free'] = '', source: str = '', view: str = '', unit: tuple[UnitPair, ...] = (), line: int = 0, col: int = 0)
Bases: Model
A finite model of a theory, checked against its laws.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The model's name.
TYPE:
|
theory
|
The origin of the theory it is a model of.
TYPE:
|
model
|
Its carriers and operation tables.
TYPE:
|
interpretations
|
The QIEC type of each sort and computation of each operation, for a model given by them.
TYPE:
|
construction
|
TYPE:
|
source
|
The model a constructed model starts from.
TYPE:
|
view
|
The view it is constructed along.
TYPE:
|
unit
|
The unit of a free extension.
TYPE:
|
line
|
Where it is declared.
TYPE:
|
col
|
Where it is declared.
TYPE:
|
CheckedView
didactic-model
¶
CheckedView(*, name: str, domain: str, codomain: str, morphism: MorphismRecord, obligations: tuple[ObligationRecord, ...] = (), line: int = 0, col: int = 0)
Bases: Model
A theory morphism and the status of every obligation it incurs.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The view's name.
TYPE:
|
domain
|
The origin of its domain.
TYPE:
|
codomain
|
The origin of its codomain.
TYPE:
|
morphism
|
The morphism panproto checked.
TYPE:
|
obligations
|
One per equation of the domain, in declaration order.
TYPE:
|
line
|
Where it is declared.
TYPE:
|
col
|
Where it is declared.
TYPE:
|
ExtensionRecord
didactic-model
¶
ExtensionRecord(*, theory: str, included: str, classification: Classification, declared: Classification | None = None, status: LawStatus = 'established', reason: str = '', witness: ExtensionWitness | None = None, search_bound: int | None = None, searched_models: int = 0, line: int = 0, col: int = 0)
Bases: Model
The classification of one inclusion of a theory into another.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The extension.
TYPE:
|
included
|
The included theory.
TYPE:
|
classification
|
What the checker found:
TYPE:
|
declared
|
The classification the declaration states, if any.
TYPE:
|
status
|
TYPE:
|
reason
|
The argument for the classification.
TYPE:
|
witness
|
The model with no expansion, for
TYPE:
|
search_bound
|
The most elements per sort the model search tried, when the
inclusion asked for one; an
TYPE:
|
searched_models
|
The models of the included theory the search examined.
TYPE:
|
line
|
Where the inclusion is written.
TYPE:
|
col
|
Where the inclusion is written.
TYPE:
|
ExtensionWitness
didactic-model
¶
Bases: Model
A model of the included theory with no expansion to the extension.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
The model.
TYPE:
|
sort
|
A sort of the included theory.
TYPE:
|
left
|
Two distinct elements of the sort the extension identifies.
TYPE:
|
right
|
Two distinct elements of the sort the extension identifies.
TYPE:
|
Member
didactic-model
¶
Member(*, kind: MemberKind, name: str, origin: str, local: str, line: int = 0, col: int = 0)
Bases: Model
A sort, operation, equation, or rule of a presentation and its origin.
| PARAMETER | DESCRIPTION |
|---|---|
kind
|
What it is.
TYPE:
|
name
|
Its name in the flat theory. A sort or operation keeps the name it
was declared with; a law is qualified by its origin, as
TYPE:
|
origin
|
The theory that declares it.
TYPE:
|
local
|
Its name as declared.
TYPE:
|
line
|
Where it is declared.
TYPE:
|
col
|
Where it is declared.
TYPE:
|
ObligationRecord
didactic-model
¶
ObligationRecord(*, equation: Member, lhs: str, rhs: str, image_lhs: str, image_rhs: str, status: LawStatus, witness: Witness | None = None, reason: str = '', checked_in: tuple[str, ...] = ())
Bases: Model
One equation of a view's domain and what is known of its image.
| PARAMETER | DESCRIPTION |
|---|---|
equation
|
The equation in the domain.
TYPE:
|
lhs
|
Its two sides.
TYPE:
|
rhs
|
Its two sides.
TYPE:
|
image_lhs
|
Their images in the codomain.
TYPE:
|
image_rhs
|
Their images in the codomain.
TYPE:
|
status
|
TYPE:
|
witness
|
The derivation, for an established obligation.
TYPE:
|
reason
|
Why the checker did not establish it, for an assumed obligation.
TYPE:
|
checked_in
|
The models of the codomain the image was checked in.
TYPE:
|
RuleCheck
didactic-model
¶
Bases: Model
What the checker found about a theory's rules.
| PARAMETER | DESCRIPTION |
|---|---|
termination
|
TYPE:
|
confluence
|
TYPE:
|
SymbolInterpretation
didactic-model
¶
Bases: Model
What interprets one sort or operation in a model.
| PARAMETER | DESCRIPTION |
|---|---|
symbol
|
The sort or operation.
TYPE:
|
value
|
The QIEC type or computation that interprets it.
TYPE:
|
TheoryError
¶
Bases: ValueError
A theory, view, or model declaration the checker refuses.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
What is wrong, naming the symbols, laws, and theories involved.
TYPE:
|
line
|
The source position of the offending declaration or entry.
TYPE:
|
col
|
The source position of the offending declaration or entry.
TYPE:
|
Source code in src/quivers/dsl/theories/values.py
TheoryParameter
didactic-model
¶
Bases: Model
A parameter of a generic theory.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The parameter's name.
TYPE:
|
theory
|
The origin of the theory it ranges over.
TYPE:
|
TheoryValue
didactic-model
¶
TheoryValue(*, name: str, theory: Theory = field(opaque=True, extras=OPAQUE_BY_IDENTITY), own: Theory = field(opaque=True, extras=OPAQUE_BY_IDENTITY), signature: Theory = field(opaque=True, extras=OPAQUE_BY_IDENTITY), members: tuple[Member, ...] = (), includes: tuple[str, ...] = (), closure: tuple[str, ...] = (), parameters: tuple[TheoryParameter, ...] = (), composition: ComposedTheory | None = None, rules: RuleCheck = field(default_factory=RuleCheck), line: int = 0, col: int = 0)
Bases: ValueModel
A presentation with its identity of origin.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The origin: the declaration's name, or the text of the theory expression that built it. Two values with one origin are the same theory.
TYPE:
|
theory
|
The flat presentation.
TYPE:
|
own
|
The flat signature with only the laws this origin declares.
TYPE:
|
signature
|
The flat signature without laws.
TYPE:
|
members
|
Every sort, operation, equation, and rule, with its origin.
TYPE:
|
includes
|
The origins it includes directly.
TYPE:
|
closure
|
Every origin it includes, directly or not, each after the origins it includes.
TYPE:
|
parameters
|
The parameters of a generic theory.
TYPE:
|
composition
|
The colimit panproto computed, with its provenance and report.
TYPE:
|
rules
|
What is known of its rules. |
line
|
Where it is declared.
TYPE:
|
col
|
Where it is declared.
TYPE:
|
member
¶
member(kind: MemberKind, name: str) -> Member | None
The member of one kind with one flat name.
| PARAMETER | DESCRIPTION |
|---|---|
kind
|
The kind.
TYPE:
|
name
|
The flat name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Member or None
|
The member, or |
Source code in src/quivers/dsl/theories/values.py
names
¶
names(*kinds: MemberKind) -> tuple[str, ...]
The flat names of every member of the given kinds.
| PARAMETER | DESCRIPTION |
|---|---|
*kinds
|
The kinds.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of str
|
The names, in member order. |
Source code in src/quivers/dsl/theories/values.py
own_members
¶
own_members() -> tuple[Member, ...]
The members whose origin is this theory.
| RETURNS | DESCRIPTION |
|---|---|
tuple of Member
|
The members it declares itself. |
Source code in src/quivers/dsl/theories/values.py
reaches
¶
Whether this theory is origin or includes it.
| PARAMETER | DESCRIPTION |
|---|---|
origin
|
An origin.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether |
Source code in src/quivers/dsl/theories/values.py
hide
¶
hide(value: TheoryValue, names: Sequence[tuple[str, int, int]], registry: Mapping[str, TheoryValue], *, name: str, line: int, col: int) -> TheoryValue
A theory without some sorts and operations, and the laws that use them.
Hiding a sort hides every operation whose signature mentions it.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The theory.
TYPE:
|
names
|
The hidden sorts and operations.
TYPE:
|
registry
|
Every theory by origin.
TYPE:
|
name
|
The result's origin.
TYPE:
|
line
|
Where the hiding is written.
TYPE:
|
col
|
Where the hiding is written.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TheoryValue
|
The visible part. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a hidden name is not a sort or operation of the theory. |
Source code in src/quivers/dsl/theories/algebra.py
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 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
instantiate
¶
instantiate(generic: TheoryValue, parameter: str, actual: TheoryValue, fitting: CheckedView | None, registry: Mapping[str, TheoryValue], *, name: str, line: int, col: int) -> TheoryValue
A generic theory instantiated at one parameter, by pushout.
| PARAMETER | DESCRIPTION |
|---|---|
generic
|
The generic theory.
TYPE:
|
parameter
|
The parameter instantiated.
TYPE:
|
actual
|
The theory it is instantiated with.
TYPE:
|
fitting
|
The fitting view from the parameter's theory to
TYPE:
|
registry
|
Every theory by origin.
TYPE:
|
name
|
The result's origin.
TYPE:
|
line
|
Where the instantiation is written.
TYPE:
|
col
|
Where the instantiation is written.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TheoryValue
|
The pushout of |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If the theory has no such parameter, the fitting view does not go
from the parameter's theory to |
Source code in src/quivers/dsl/theories/algebra.py
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 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
law_terms
¶
law_terms(value: TheoryValue, flat: str) -> tuple[Json, Json]
The serialized sides of a law of a theory.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The theory.
TYPE:
|
flat
|
The law's flat name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Json
|
Its left and right sides. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If the theory has no law of that name. |
Source code in src/quivers/dsl/theories/algebra.py
maximal
¶
maximal(origins: Sequence[str], registry: Mapping[str, TheoryValue]) -> list[str]
The origins not included by another of the given origins.
| PARAMETER | DESCRIPTION |
|---|---|
origins
|
Origins, closed under inclusion.
TYPE:
|
registry
|
Every theory by origin.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of str
|
The maximal ones, in the given order. |
Source code in src/quivers/dsl/theories/algebra.py
rename
¶
rename(value: TheoryValue, renames: Sequence[tuple[str, str, int, int]], registry: Mapping[str, TheoryValue], *, name: str, line: int, col: int) -> TheoryValue
A copy of a theory with some sorts and operations renamed.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The theory.
TYPE:
|
renames
|
The renamed symbols and their new names.
TYPE:
|
registry
|
Every theory by origin.
TYPE:
|
name
|
The copy's origin.
TYPE:
|
line
|
Where the renaming is written.
TYPE:
|
col
|
Where the renaming is written.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TheoryValue
|
The copy. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a renamed name is not a sort or operation of the theory, two symbols get one name, or a new name is already taken. |
Source code in src/quivers/dsl/theories/algebra.py
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 357 358 | |
summed
¶
summed(summands: Sequence[TheoryValue], shared: Sequence[tuple[TheoryValue, int, int]], registry: Mapping[str, TheoryValue], *, name: str, line: int, col: int) -> TheoryValue
The colimit of theories over the theories they share.
| PARAMETER | DESCRIPTION |
|---|---|
summands
|
The theories composed.
TYPE:
|
shared
|
The theories declared shared.
TYPE:
|
registry
|
Every theory by origin.
TYPE:
|
name
|
The result's origin.
TYPE:
|
line
|
Where the sum is written.
TYPE:
|
col
|
Where the sum is written.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TheoryValue
|
The colimit. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a declared shared theory is not included by two summands, two
summands share a theory |
Source code in src/quivers/dsl/theories/algebra.py
term_operations
¶
term_operations(term: Json) -> set[str]
The operations applied in a serialized term.
| PARAMETER | DESCRIPTION |
|---|---|
term
|
A term in panproto's serialized shape.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
set of str
|
Every operation it applies. |
Source code in src/quivers/dsl/theories/algebra.py
finite_values
¶
finite_values(type_: TypeExpr, module: QiecModule, enclosing: tuple[TypeExpr, ...] = ()) -> tuple[HostValue, ...]
Every value of a finite type, constructors in declaration order.
| PARAMETER | DESCRIPTION |
|---|---|
type_
|
The type.
TYPE:
|
module
|
The checked module declaring its families.
TYPE:
|
enclosing
|
The families whose values are being built around this one.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of HostValue
|
The values. |
| RAISES | DESCRIPTION |
|---|---|
CarrierError
|
If the type is not finite: an opaque or indexed family, a constructor with static binders, a recursive family, or a type with infinitely many values. |
Source code in src/quivers/dsl/theories/carriers.py
named_type
¶
named_type(name: str, module: QiecModule) -> TypeExpr
The QIEC type a model's sort interpretation names.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
TYPE:
|
module
|
The checked module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TypeExpr
|
The type. |
| RAISES | DESCRIPTION |
|---|---|
CarrierError
|
If the name is neither a builtin finite type nor a family of the module, or the family takes parameters or indices. |
Source code in src/quivers/dsl/theories/carriers.py
render_value
¶
render_value(value: Value) -> str
Render a value record as QVR writes it.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The value.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
| RAISES | DESCRIPTION |
|---|---|
CarrierError
|
If the record is not a value variant. |
Source code in src/quivers/dsl/theories/carriers.py
value_record
¶
value_record(value: ResultValue, module: QiecModule) -> Value
A machine value as panproto's value record.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
A value of a finite type, or a result of an operation.
TYPE:
|
module
|
The checked module, for constructor names.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Value
|
A constructor value tagged by the constructor's source name, a boolean (a truth tensor included), an integer, a string, or a list for a tuple. |
| RAISES | DESCRIPTION |
|---|---|
CarrierError
|
If the value is of none of these forms. |
Source code in src/quivers/dsl/theories/carriers.py
classify
¶
classify(base: TheoryValue, extension: TheoryValue, models: Sequence[CheckedModel], search_bound: int | None = None) -> Verdict
Classify the inclusion of one theory into another that includes it.
| PARAMETER | DESCRIPTION |
|---|---|
base
|
The included theory.
TYPE:
|
extension
|
A theory that includes it.
TYPE:
|
models
|
Checked models of
TYPE:
|
search_bound
|
When given, and neither the syntactic conditions nor
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Verdict
|
The classification and its argument. A search that finds nothing leaves it undetermined within its bound, never conservative. |
Source code in src/quivers/dsl/theories/classification.py
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 357 358 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 477 478 479 480 481 482 483 | |
check_instance
¶
check_instance(theory: TheoryValue, instance: str, interpretations: Mapping[str, str], module: QiecModule, *, line: int = 0, col: int = 0) -> CheckedModel
Check an instance of a signature as a finite model of its theory.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The signature's theory.
TYPE:
|
instance
|
The instance's name, for refusals.
TYPE:
|
interpretations
|
Each sort's QIEC type and each operation's computation.
TYPE:
|
module
|
The checked module the types and computations belong to.
TYPE:
|
line
|
Where the instance is declared.
TYPE:
|
col
|
Where the instance is declared.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CheckedModel
|
The model, every law of the theory checked at every assignment. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a symbol is not interpreted, a carrier is not finite, a computation does not fit its operation, or a law fails, with the assignment. |
Source code in src/quivers/dsl/theories/instances.py
check_instance_view
¶
check_instance_view(theory: TheoryValue, instance: TheoryValue, mapping: Mapping[str, str], layer: TheoryLayer, *, name: str, assumed: Sequence[str] = (), line: int = 0, col: int = 0) -> CheckedView
Check an instance that is a theory as a view from the signature's theory.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The signature's theory, the view's domain.
TYPE:
|
instance
|
The instance, the view's codomain.
TYPE:
|
mapping
|
Each sort and operation of
TYPE:
|
layer
|
The layer holding both theories and the models of
TYPE:
|
name
|
The view's name.
TYPE:
|
assumed
|
The equations the instance assumes.
TYPE:
|
line
|
Where the instance is declared.
TYPE:
|
col
|
Where the instance is declared.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CheckedView
|
The view, each obligation established or assumed. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If the mapping is not a theory morphism, or an obligation is refuted by a model or neither established nor assumed. |
Source code in src/quivers/dsl/theories/instances.py
signature_theory
¶
signature_theory(name: str, sorts: Sequence[str], operations: Sequence[tuple[str, Sequence[str], str]], equations: Sequence[EquationDecl], registry: Mapping[str, TheoryValue], *, includes: Sequence[TheoryValue] = (), line: int = 0, col: int = 0) -> TheoryValue
The theory of a signature's sorts, operations, and equations.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The theory's origin, the signature's name.
TYPE:
|
sorts
|
The signature's own sorts.
TYPE:
|
operations
|
Its own operations.
TYPE:
|
equations
|
Its equations and rules, as the parser reads them.
TYPE:
|
registry
|
Every theory by origin, for
TYPE:
|
includes
|
Theories the signature includes.
TYPE:
|
line
|
Where the signature is declared.
TYPE:
|
col
|
Where the signature is declared.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TheoryValue
|
The theory. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a law is ill-sorted, or panproto refuses the composition. |
Source code in src/quivers/dsl/theories/instances.py
law_theory
¶
law_theory(value: TheoryValue, name: str, lhs: str, rhs: str) -> Theory
A theory's signature with one equation.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The theory whose sorts and operations it has.
TYPE:
|
name
|
The equation's name.
TYPE:
|
lhs
|
Its sides, in panproto's term syntax.
TYPE:
|
rhs
|
Its sides, in panproto's term syntax.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Theory
|
The theory. |
Source code in src/quivers/dsl/theories/layer.py
check_laws_hold
¶
check_laws_hold(where: str, model: FiniteModel, value: TheoryValue, line: int, col: int) -> ModelVerification
Require every law of a theory to hold in a finite model.
| PARAMETER | DESCRIPTION |
|---|---|
where
|
The model, for refusals.
TYPE:
|
model
|
The model.
TYPE:
|
value
|
Its theory.
TYPE:
|
line
|
Where the model is declared.
TYPE:
|
col
|
Where the model is declared.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ModelVerification
|
panproto's verdict, |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a law fails, with the assignment and the values of both sides,
or the check is not exhaustive within |
Source code in src/quivers/dsl/theories/models.py
constructed_model
¶
constructed_model(decl: ModelDecl, source: CheckedModel, view: CheckedView, registry: Mapping[str, TheoryValue]) -> CheckedModel
The reduct or free extension of a model along a view.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
The declaration,
TYPE:
|
source
|
The model it starts from.
TYPE:
|
view
|
The view.
TYPE:
|
registry
|
Every theory by origin.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CheckedModel
|
A model of the view's domain (reduct) or codomain (free extension), checked against its theory. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If the source is not a model of the theory the construction starts from, or panproto refuses the construction. |
Source code in src/quivers/dsl/theories/models.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 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 | |
interpreted_model
¶
interpreted_model(decl: ModelDecl, value: TheoryValue, module: QiecModule | None) -> CheckedModel
Build and check a model given by QIEC types and computations.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
The declaration, with its interpretations.
TYPE:
|
value
|
The theory it interprets.
TYPE:
|
module
|
The checked module whose types and computations interpret it, or
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CheckedModel
|
The model. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a symbol is interpreted twice, not at all, or by something that does not fit its signature; a carrier is not finite; a computation is effectful, fails, or returns a value outside its carrier; or a law of the theory fails in the model, with the assignment. |
Source code in src/quivers/dsl/theories/models.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 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 312 313 314 315 316 | |
laws_as_equations
¶
A theory whose rules are also stated as equations.
A model satisfies a rule l ~> r when it satisfies l = r, so a
model is checked against this theory.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The theory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Theory
|
The theory with every rule added as an equation of the same name. |
Source code in src/quivers/dsl/theories/models.py
refuse_dependent
¶
refuse_dependent(where: str, value: TheoryValue, line: int, col: int) -> None
Refuse a model of a theory with dependent sorts or implicit inputs.
| PARAMETER | DESCRIPTION |
|---|---|
where
|
The model, for the refusal.
TYPE:
|
value
|
Its theory.
TYPE:
|
line
|
Where the model is declared.
TYPE:
|
col
|
Where the model is declared.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a sort of the theory takes parameters or an operation has an implicit input: checking a finite model of such a theory needs equations with variable contexts and models whose elements carry their sort arguments, which panproto does not provide yet. |
Source code in src/quivers/dsl/theories/models.py
assemble
¶
assemble(name: str, includes: Sequence[TheoryValue], local: LocalPart, registry: Mapping[str, TheoryValue], *, parameters: tuple[TheoryParameter, ...] = (), line: int = 0, col: int = 0) -> TheoryValue
Compose a presentation from what it includes and what it declares.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The presentation's origin.
TYPE:
|
includes
|
The theories it includes directly.
TYPE:
|
local
|
Its own checked declarations.
TYPE:
|
registry
|
Every theory elaborated so far, by origin.
TYPE:
|
parameters
|
Its parameters, for a generic theory.
TYPE:
|
line
|
Where it is declared.
TYPE:
|
col
|
Where it is declared.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TheoryValue
|
The presentation. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If panproto refuses the colimit, naming both sources of a clash, or a rule system is not confluent or not shown terminating. |
Source code in src/quivers/dsl/theories/presentation.py
1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 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 | |
build_local
¶
build_local(name: str, base: Theory | None, local: LocalPart, origin: str, mentioned: tuple[set[str], set[str]]) -> Theory
The theory of a presentation's own declarations.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The theory's name.
TYPE:
|
base
|
The colimit of the included theories, whose mentioned sorts and operations are declared first.
TYPE:
|
local
|
The own declarations.
TYPE:
|
origin
|
The origin the own laws are qualified by.
TYPE:
|
mentioned
|
The included sorts and operations the own declarations mention, closed under what their signatures mention.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Theory
|
The mentioned included symbols, the own symbols, and the own laws. |
Source code in src/quivers/dsl/theories/presentation.py
check_laws
¶
check_laws(owner: str, equations: Sequence[EquationDecl], signature: Signature) -> tuple[LocalLaw, ...]
Check a theory's equations and rules over its signature.
Each side is resolved and sort-checked by the equation checker of
binding signatures (quivers.structural.rewriting.make_equation): a
bare name is an operation when the signature declares one and a
variable otherwise, both sides have one sort, and every variable of a
rule's right side occurs on its left. For a theory with dependent
sorts the check is of the sorts' heads; panproto typechecks the
arguments when the theory is composed.
| PARAMETER | DESCRIPTION |
|---|---|
owner
|
The theory, for refusals.
TYPE:
|
equations
|
The declared equations and rules.
TYPE:
|
signature
|
The theory's signature, included symbols and own together.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of LocalLaw
|
The checked laws, serialized. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If two laws share a name, or a law is ill-sorted or not first order, located at the law. |
Source code in src/quivers/dsl/theories/presentation.py
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 | |
check_rules
¶
check_rules(value: TheoryValue, assume_terminating: bool) -> RuleCheck
Check the confluence and termination of a theory's rules.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The theory.
TYPE:
|
assume_terminating
|
Whether the theory assumes its rules terminate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuleCheck
|
Confluence is established when every critical pair joins; termination is established by the lexicographic path ordering or recorded as assumed. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a critical pair does not join, or a rule is not oriented by the path ordering and termination is not assumed, located at the rule. |
Source code in src/quivers/dsl/theories/presentation.py
first_order_signature
¶
first_order_signature(name: str, sorts: Sequence[str], ops: Mapping[str, tuple[tuple[str, ...], str]]) -> Signature
The binding signature of a presentation's erasure.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The signature's name.
TYPE:
|
sorts
|
Its sorts, by name.
TYPE:
|
ops
|
Each operation's explicit inputs' sorts and output sort, by their heads.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Signature
|
A signature whose sorts are object sorts and whose constructors bind nothing, so that the equation checker of binding signatures checks the presentation's equations up to the arguments of dependent sorts, which panproto's typechecker then checks. |
Source code in src/quivers/dsl/theories/presentation.py
input_names
¶
The names panproto gives an operation's unnamed inputs.
| PARAMETER | DESCRIPTION |
|---|---|
arity
|
The number of inputs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of str
|
|
Source code in src/quivers/dsl/theories/presentation.py
is_dependent
¶
Whether a theory has a sort with parameters or an implicit input.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The theory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether some sort takes parameters or some operation has an implicit input. |
Source code in src/quivers/dsl/theories/presentation.py
law_entries
¶
The serialized equations and rules of a theory with given names.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The theory.
TYPE:
|
names
|
The laws kept.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of two lists
|
The equations and the rules, in declaration order. |
Source code in src/quivers/dsl/theories/presentation.py
law_name
¶
The flat name of a law: its local name qualified by its origin.
| PARAMETER | DESCRIPTION |
|---|---|
origin
|
The theory that declares it.
TYPE:
|
local
|
Its name as declared.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/dsl/theories/presentation.py
operation_entries
¶
operation_entries(theory: Theory) -> dict[str, Json]
The serialized operations of a theory, by name.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The theory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict of str to Json
|
Each operation as panproto serializes it. |
Source code in src/quivers/dsl/theories/presentation.py
operation_entry
¶
An operation in panproto's serialized shape.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The operation.
TYPE:
|
inputs
|
Each input's name, sort expression, and whether it is implicit.
TYPE:
|
output
|
The output sort expression.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Json
|
The serialized operation. |
Source code in src/quivers/dsl/theories/presentation.py
operation_inputs
¶
Every input of a serialized operation.
| PARAMETER | DESCRIPTION |
|---|---|
entry
|
The operation in panproto's serialized shape.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of (str, Json, bool)
|
Each input's name, sort expression, and whether it is implicit. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the entry is not an operation. |
Source code in src/quivers/dsl/theories/presentation.py
operation_signature
¶
operation_signature(entry: Json) -> tuple[str, tuple[str, ...], tuple[str, ...], str]
Read a serialized operation's explicit signature.
| PARAMETER | DESCRIPTION |
|---|---|
entry
|
An operation in panproto's serialized shape.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple
|
Its name, the names and sorts (by their head) of its explicit inputs, which its applications take as arguments, and its output sort's head. Implicit inputs are inferred where it is applied. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the entry is not an operation. |
Source code in src/quivers/dsl/theories/presentation.py
operations_of
¶
The explicit signatures of a theory's operations.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The theory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
Each operation's explicit input names, their sorts' heads, and its output sort's head, by name. |
Source code in src/quivers/dsl/theories/presentation.py
rename_operation_entry
¶
A serialized operation with sorts and operations renamed.
| PARAMETER | DESCRIPTION |
|---|---|
entry
|
The operation.
TYPE:
|
sorts
|
New names of sorts.
TYPE:
|
ops
|
New names of operations.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Json
|
The renamed operation. |
Source code in src/quivers/dsl/theories/presentation.py
rename_sort_entry
¶
A serialized sort with sorts and operations renamed.
| PARAMETER | DESCRIPTION |
|---|---|
entry
|
The sort.
TYPE:
|
sorts
|
New names of sorts.
TYPE:
|
ops
|
New names of operations.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Json
|
The renamed sort. |
Source code in src/quivers/dsl/theories/presentation.py
rename_sort_expression
¶
A serialized sort expression with sorts and operations renamed.
| PARAMETER | DESCRIPTION |
|---|---|
expression
|
The sort expression.
TYPE:
|
sorts
|
New names of sorts.
TYPE:
|
ops
|
New names of operations.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Json
|
The renamed expression. |
Source code in src/quivers/dsl/theories/presentation.py
rename_term
¶
A serialized term with operations renamed.
| PARAMETER | DESCRIPTION |
|---|---|
term
|
The term.
TYPE:
|
ops
|
New names of operations; others keep theirs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Json
|
The renamed term. |
Source code in src/quivers/dsl/theories/presentation.py
restricted
¶
A law-free theory of some of a theory's sorts and operations.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The theory.
TYPE:
|
name
|
The restriction's name.
TYPE:
|
sorts
|
The sorts kept, with every sort and operation they mention.
TYPE:
|
ops
|
The operations kept, with every sort and operation they mention.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Theory
|
The restriction, in the theory's declaration order. |
Source code in src/quivers/dsl/theories/presentation.py
signature_of
¶
signature_of(value: TheoryValue, extra: LocalPart | None = None) -> Signature
The first-order binding signature of a theory, with extra declarations.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The theory whose sorts and operations it holds.
TYPE:
|
extra
|
Further sorts and operations.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Signature
|
The signature the equation checker resolves terms against. |
Source code in src/quivers/dsl/theories/presentation.py
sort_arguments
¶
The argument terms of a sort expression.
| PARAMETER | DESCRIPTION |
|---|---|
expression
|
A serialized sort expression.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of Json
|
Its argument terms, empty for a plain sort. |
Source code in src/quivers/dsl/theories/presentation.py
sort_entries
¶
sort_entries(theory: Theory) -> dict[str, Json]
The serialized sorts of a theory, by name.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The theory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict of str to Json
|
Each sort as panproto serializes it. |
Source code in src/quivers/dsl/theories/presentation.py
sort_entry
¶
A sort in panproto's serialized shape.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The sort.
TYPE:
|
parameters
|
Its parameters and their sort expressions, for a dependent sort.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Json
|
The serialized sort. |
Source code in src/quivers/dsl/theories/presentation.py
sort_head
¶
sort_head(expression: Json) -> str
The sort a sort expression applies.
| PARAMETER | DESCRIPTION |
|---|---|
expression
|
A serialized sort expression: a name, or
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The sort's name. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the value is not a sort expression. |
Source code in src/quivers/dsl/theories/presentation.py
sort_parameters
¶
sort_parameters(theory: Theory) -> dict[str, tuple[tuple[str, Json], ...]]
The parameters of each sort of a theory.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The theory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
Each sort's parameters as (name, serialized sort) pairs, empty for a sort without parameters. |
Source code in src/quivers/dsl/theories/presentation.py
sort_parameters_of
¶
The parameters of one serialized sort.
| PARAMETER | DESCRIPTION |
|---|---|
entry
|
The sort.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of (str, Json)
|
Each parameter's name and sort expression. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the parameters are not serialized as panproto writes them. |
Source code in src/quivers/dsl/theories/presentation.py
sorts_of
¶
The sorts of a theory.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The theory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of str
|
Its sorts, in declaration order. |
Source code in src/quivers/dsl/theories/presentation.py
with_laws
¶
A theory's signature with given laws in place of its own.
| PARAMETER | DESCRIPTION |
|---|---|
theory
|
The theory whose sorts and operations are kept.
TYPE:
|
name
|
The new theory's name.
TYPE:
|
eqs
|
Its equations, serialized.
TYPE:
|
directed
|
Its rules, serialized.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Theory
|
The theory. |
Source code in src/quivers/dsl/theories/presentation.py
search_refutation
¶
search_refutation(base: TheoryValue, extension: TheoryValue, bound: int) -> SearchResult
Search the models of an included theory, up to a size bound, for one with no expansion to the extension.
| PARAMETER | DESCRIPTION |
|---|---|
base
|
The included theory, every sort without parameters.
TYPE:
|
extension
|
A theory that includes it.
TYPE:
|
bound
|
The most elements a carrier may have; every size vector from one
element per sort up to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SearchResult
|
The first model found whose free extension identifies two of its elements, or the number of models examined without one. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/dsl/theories/search.py
own_signature
¶
own_signature(decl: TheoryDecl, base: TheoryValue) -> LocalPart
The sorts and operations a theory declaration declares itself.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
The declaration.
TYPE:
|
base
|
The colimit of the theories it includes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LocalPart
|
Its own sorts and operations, without laws. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a sort or operation is declared twice, or a signature is ill-formed, located at the declaration. |
Source code in src/quivers/dsl/theories/signatures.py
elaborate_view
¶
elaborate_view(decl: ViewDecl, domain: TheoryValue, codomain: TheoryValue) -> CheckedView
Check a view's signature and record what panproto finds of each equation.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
The declaration.
TYPE:
|
domain
|
Its domain.
TYPE:
|
codomain
|
Its codomain.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CheckedView
|
The view. An obligation panproto discharges is |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If a mapping names no symbol of the domain, maps a symbol twice, or has an ill-sorted image; a symbol is left unmapped with no identity of origin into the codomain; or panproto refuses the signature, located at the declaration. |
Source code in src/quivers/dsl/theories/views.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 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 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 357 358 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 | |
inclusion_view
¶
inclusion_view(name: str, included: TheoryValue, value: TheoryValue) -> MorphismRecord
The inclusion of a theory into one that includes it, as a morphism.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The morphism's name.
TYPE:
|
included
|
The included theory.
TYPE:
|
value
|
A theory that includes it, so that every symbol of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MorphismRecord
|
The identity-on-names morphism. |
Source code in src/quivers/dsl/theories/views.py
resolve_equation
¶
resolve_equation(value: TheoryValue, name: str, line: int, col: int, what: str) -> Member
The equation of a theory a source name refers to.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The theory.
TYPE:
|
name
|
The equation's local name, or its name qualified by its origin.
TYPE:
|
line
|
Where the name is written.
TYPE:
|
col
|
Where the name is written.
TYPE:
|
what
|
What refers to it, for refusals.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Member
|
The equation. |
| RAISES | DESCRIPTION |
|---|---|
TheoryError
|
If no equation, or more than one, has that name. |