jacopy.PropertyRegistry

class jacopy.PropertyRegistry(*, strict_axioms_only=False)

Bases: object

Stores properties keyed by expression, class, or predicate.

Lookup order in get():

  1. Exact expression match.

  2. Class-based: walks type.__mro__ from most specific to Expr.

  3. Predicate-based: first registered predicate whose property type matches wins.

An expression or class may hold multiple distinct property types, but at most one of any given property-type from the same source (exact / class / predicate). Duplicate declarations at the same source raise ValueError, the intended fix is an explicit retract().

Parameters:

strict_axioms_only (bool)

__init__(*, strict_axioms_only=False)
Parameters:

strict_axioms_only (bool)

Return type:

None

Methods

__init__(*[, strict_axioms_only])

all_for(expr)

Yield every property visible for expr (after filters).

axioms(allowed)

Narrow the visible property types to allowed during the block.

declare(expr, prop)

Attach prop to the exact expression expr.

declare_for_class(cls, prop)

Attach prop to every instance of cls (subclasses inherit).

declare_for_predicate(predicate, prop)

Attach prop to every expression satisfying predicate.

get(expr, prop_cls)

Return the property of type prop_cls on expr, or None.

has(expr, prop_cls)

lookup(expr, prop_cls, *[, record])

The Declaration (prop, level, rank) of the RAW declaration (no visibility filter, no shadowing) that answers prop_cls for expr: level is "exact", "class" or "predicate", rank the comparable specificity tuple (smaller = more specific; class level carries the MRO depth), or (None, None, None).

peek(expr, prop_cls)

get()'s answer WITHOUT recording a read: a pre-filter for a caller whose result depends only on a POSITIVE answer, which it then re-queries with get() so the answer becomes the step's hypothesis (negative answers do not pile up).

retract(expr, prop_cls)

Remove the exact-expression property of type prop_cls.

retract_for_class(cls, prop_cls)

scope()

Roll back every registry mutation made inside the block.

set_strict(strict)

untracked()

Suspend read recording on this thread for the block (the model oracle restates registry data without minting hypotheses; peek()).

Attributes

axiom_whitelist

everything visible) — public read access for independent restatements of the visibility rule (the model oracle).

strict_axioms_only

property axiom_whitelist: Set[type] | None

everything visible) — public read access for independent restatements of the visibility rule (the model oracle).

Type:

The active axioms() whitelist (None

declare(expr, prop)

Attach prop to the exact expression expr.

Parameters:
  • expr (Expr)

  • prop (Property)

Return type:

None

lookup(expr, prop_cls, *, record=False)

The Declaration (prop, level, rank) of the RAW declaration (no visibility filter, no shadowing) that answers prop_cls for expr: level is "exact", "class" or "predicate", rank the comparable specificity tuple (smaller = more specific; class level carries the MRO depth), or (None, None, None). Public read access to the declaration data for consumers that must restate the Scalar contract independently (the model oracle) or decide it on the raw answers (the predicate’s clash check: a visibility filter never turns a declared graded element into a constant). With record=True the raw answer is appended to the open read log as a RAW fact — a hypothesis checked against the raw declarations of the citing registry.

Parameters:
retract(expr, prop_cls)

Remove the exact-expression property of type prop_cls. A retract that would EXPOSE a Scalar contradiction (the removed declaration was shadowing one, or was the Graded(0) hiding a class-level Graded(k)) is refused and leaves the registry unchanged.

Parameters:
Return type:

Property | None

declare_for_class(cls, prop)

Attach prop to every instance of cls (subclasses inherit).

Exact-expression declarations still take priority over class-based ones. An explicit retract() on a particular expression does NOT remove the class-based fallback, it only clears an exact binding.

Parameters:
Return type:

None

declare_for_predicate(predicate, prop)

Attach prop to every expression satisfying predicate.

Predicates are matched in registration order; the first matching entry whose property type is being queried wins. Use sparingly, a badly-written predicate is the usual way to silently poison a registry.

Parameters:
Return type:

None

get(expr, prop_cls)

Return the property of type prop_cls on expr, or None.

Lookup cascades: exact → class (MRO) → predicate. The first hit, after applying visibility filters, is returned — except that a class/predicate-level Scalar shadowed by a strictly more specific Graded / NonCommuting / AntiCommuting declaration answers None (the Scalar contract’s specificity rule).

Parameters:
Return type:

P | None

peek(expr, prop_cls)

get()’s answer WITHOUT recording a read: a pre-filter for a caller whose result depends only on a POSITIVE answer, which it then re-queries with get() so the answer becomes the step’s hypothesis (negative answers do not pile up).

Parameters:
Return type:

P | None

untracked()

Suspend read recording on this thread for the block (the model oracle restates registry data without minting hypotheses; peek()).

all_for(expr)

Yield every property visible for expr (after filters).

Collects candidate property types across all three sources and resolves each via get() so priority and filters apply uniformly.

Parameters:

expr (Expr)

Return type:

Iterator[Property]

scope()

Roll back every registry mutation made inside the block.

Designed for hypothetical edits: declare a property, run a proof, and have the declaration vanish afterwards even if the proof raised. Safe to nest.

axioms(allowed)

Narrow the visible property types to allowed during the block.

Within the block, get() returns None for any property whose type is not in allowed, as if it had not been declared. Complements strict_axioms_only, which filters by provenance rather than type.

Nests correctly: an inner axioms() overrides the outer whitelist for its scope and restores on exit.

Parameters:

allowed (Iterable[Type[Property]])