jacopy.Definition

class jacopy.Definition

Bases: ABC

A single rewrite rule keyed to a local pattern.

Subclasses provide matches() (does expr fit the left-hand side?) and rewrite() (produce the right-hand side). The name is used verbatim in the ProofStep rule field.

A definition is classified as an axiom by default, the engine tags its ProofStep with provenance_tag="axiom". A subclass that represents a theorem overrides theorem_proof_builder() to return a callable producing the sub-proof; in foundational mode the engine then attaches that sub-proof under the step as children. Efficient mode still tags the step "theorem" but skips sub-proof construction, so the same definition serves both proof modes.

__init__()

Methods

__init__()

matches(expr)

True when expr is an instance of this definition's LHS.

rewrite(expr)

Return the RHS.

theorem_proof_builder()

Return a callable producing this definition's sub-proof, or None.

Attributes

anchor

the Expr class (or tuple of classes) this definition's LHS is rooted at.

identity

Structural IDENTITY of the rule: None by default — the rule is never deduplicated by identity and its key falls back to (class name, display name).

is_theorem

True when this definition carries a sub-proof builder.

key

identity when given, else (class name, display name).

name

owner

the algebroid of a declared axiom, the theorem's owner for a cited theorem, … None for structure-free rules.

role

"definition" — a definitional unfolding or a structural law (no assumption); "assumption" — a DECLARED axiom of a structure (the *Declaration rules), i.e. a hypothesis the proof depends on; "theorem" — a cited proven result.

source

a jacopy.bibliography.Citation — or a tuple of them — built with jacopy.bibliography.cite(), e.g. cite("Uchino2002", "Section 1, axiom [C5]").

unverified

Explicitly-unverified citation (a TheoremBook record marked unverified): its steps are classified as legacy assumptions.

anchor = None

the Expr class (or tuple of classes) this definition’s LHS is rooted at. When set, the engine only consults the rule on nodes of that type (via an MRO-indexed lookup) instead of trying every rule at every node. None keeps the rule in the always-consulted fallback list.

Type:

Optional dispatch anchor

owner = None

the algebroid of a declared axiom, the theorem’s owner for a cited theorem, … None for structure-free rules. The engine refuses two rules whose owners share a tree-visible name but differ (jacopy.proof.ownership).

Type:

The structure this rule was built for

role = 'definition'

"definition" — a definitional unfolding or a structural law (no assumption); "assumption" — a DECLARED axiom of a structure (the *Declaration rules), i.e. a hypothesis the proof depends on; "theorem" — a cited proven result. ProofResult.from_chain reads it from the fired steps; a step whose rule recorded no role is kept as a LEGACY assumption, never dropped.

Type:

What the rule IS, logically

unverified = False

Explicitly-unverified citation (a TheoremBook record marked unverified): its steps are classified as legacy assumptions.

identity = None

Structural IDENTITY of the rule: None by default — the rule is never deduplicated by identity and its key falls back to (class name, display name). A rule that gives one returns (class, structure identity, mathematical parameters): two rules with equal identity are the same rule (an explicit assumption instance, a declared axiom of a structure with its parameters …).

source = None

a jacopy.bibliography.Citation — or a tuple of them — built with jacopy.bibliography.cite(), e.g. cite("Uchino2002", "Section 1, axiom [C5]"). The engine copies it onto every ProofStep the rule produces and the display layer prints it; no matching, rewriting or classification reads it. None: the rule names no source.

Type:

Literature source of the rule (metadata only)

property key

identity when given, else (class name, display name). Recorded on every fired ProofStep and on the resulting requirement records, so a citation can check that the SAME licensing rule is registered in the citing engine.

Type:

The rule’s structural key

abstractmethod matches(expr)

True when expr is an instance of this definition’s LHS.

Parameters:

expr (Expr)

Return type:

bool

abstractmethod rewrite(expr)

Return the RHS. Caller guarantees matches(expr) is True.

Parameters:

expr (Expr)

Return type:

Expr

theorem_proof_builder()

Return a callable producing this definition’s sub-proof, or None.

The returned callable has signature (matched_expr: Expr) -> ProofChain and is only invoked by the engine when mode="foundational". None (the default) marks the definition as a pure axiom.

property is_theorem: bool

True when this definition carries a sub-proof builder.