Skip to main content

omnibias.core.proof.condition

0.5.0rc1Release candidatePython >=3.10Apache-2.0

Coefficient recurrences, activation contracts, jet algebra, and verified arithmetic shared by the numerical backends.

import omnibias.core.proof.condition
Module contract & mathematical conventions

Hypothesis language whose points are conditions, not colourings or maps.

A ConditionHypothesis is a typed expression in a finite GrammarSpec. Proposers emit hypotheses. Typed constructors grow the grammar. The accept gate is an exact Q / finite checker in the owning package — this module never imports holonomic / symbolic / combinatorics / pinn.

An incomplete grammar miss is search_incomplete. It is never “no condition exists” and never a parent theorem. GrammarSpec.complete defaults False.

Shared formulas do not imply universal floating-point identity. Verify dtype, shape, derivative-order support, and the stated numerical assumptions for the path you use.

CONSTANT

ALL_CONDITION_SORTS​

omnibias.core.proof.ALL_CONDITION_SORTSSource ↗
ALL_CONDITION_SORTS: tuple[ConditionSort, ...] = ('conservation', 'dfinite', 'edge_colouring', 'extremal_template', 'forbidden_minor', 'fractional_order', 'jet_monomial', 'ore', 'pde_operator', 'piecewise_hybrid', 'residual_sign', 'sos_onset', 'sos_template')

This exported constant is defined by the expression above. Its exact value and annotation come from the pinned source; use it with the module contract.

Read the implementation
ALL_CONDITION_SORTS: tuple[ConditionSort, ...] = (
    "conservation",
    "dfinite",
    "edge_colouring",
    "extremal_template",
    "forbidden_minor",
    "fractional_order",
    "jet_monomial",
    "ore",
    "pde_operator",
    "piecewise_hybrid",
    "residual_sign",
    "sos_onset",
    "sos_template",
)
Other public import paths
  • omnibias.core.proof.ALL_CONDITION_SORTS
  • omnibias.core.proof.condition.ALL_CONDITION_SORTS
CLASS

ConditionHypothesis​

omnibias.core.proof.ConditionHypothesisSource ↗
class ConditionHypothesis

Dataclass constructor fields; inherited fields, if any, are declared by the base class. A field(...) expression describes a default factory or field options, not a literal argument default.

A proposed condition. Hashable ~omnibias.core.proof.discovery.Candidate.

Parameters

NameType & defaultContract
sortdataclass fieldConditionSortRequiredSee the operation contract and implementation below.
tokensdataclass fieldtuple[ConditionToken, ...]RequiredSee the operation contract and implementation below.
constructorsdataclass fieldtuple[str, ...]Default: ()See the operation contract and implementation below.
coefficientsdataclass fieldtuple[str, ...]Default: ()See the operation contract and implementation below.
grammar_iddataclass fieldstrDefault: 'v1'See the operation contract and implementation below.
Executed regression · hypothesis hash and dict

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_hypothesis_hash_and_dict() -> None:
    left = _jet("y", "yp")
    right = _jet("y", "yp")
    assert left == right
    assert hash(left) == hash(right)
    payload = left.as_dict()
    assert payload["sort"] == "jet_monomial"
    assert payload["pretty"] == "jet_monomial[y, yp]"
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_hypothesis_hash_and_dict" -q

Fields & methods

sortfield
sort: ConditionSort

Declared ConditionSort field on ConditionHypothesis. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
tokensfield
tokens: tuple[ConditionToken, ...]

Declared tuple[ConditionToken, ...] field on ConditionHypothesis. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
constructorsfield
constructors: tuple[str, ...] = ()

Declared tuple[str, ...] field on ConditionHypothesis. Default expression: ().

View source ↗
coefficientsfield
coefficients: tuple[str, ...] = ()

Declared tuple[str, ...] field on ConditionHypothesis. Default expression: ().

View source ↗
grammar_idfield
grammar_id: str = 'v1'

Declared str field on ConditionHypothesis. Default expression: 'v1'.

View source ↗
prettymethod
pretty(self) -> str

See the class contract above and the exact method implementation below.

Returns: str

Executed regression · hypothesis hash and dict

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_hypothesis_hash_and_dict() -> None:
    left = _jet("y", "yp")
    right = _jet("y", "yp")
    assert left == right
    assert hash(left) == hash(right)
    payload = left.as_dict()
    assert payload["sort"] == "jet_monomial"
    assert payload["pretty"] == "jet_monomial[y, yp]"
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_hypothesis_hash_and_dict" -q
Method implementation
    def pretty(self) -> str:
        names = ", ".join(token.name for token in self.tokens)
        return f"{self.sort}[{names}]"
View source ↗
as_dictmethod
as_dict(self) -> dict[str, Any]

See the class contract above and the exact method implementation below.

Returns: dict[str, Any]

Executed regression · hypothesis hash and dict

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_hypothesis_hash_and_dict() -> None:
    left = _jet("y", "yp")
    right = _jet("y", "yp")
    assert left == right
    assert hash(left) == hash(right)
    payload = left.as_dict()
    assert payload["sort"] == "jet_monomial"
    assert payload["pretty"] == "jet_monomial[y, yp]"
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_hypothesis_hash_and_dict" -q
Method implementation
    def as_dict(self) -> dict[str, Any]:
        return {
            "sort": self.sort,
            "tokens": [token.as_dict() for token in self.tokens],
            "constructors": list(self.constructors),
            "coefficients": list(self.coefficients),
            "grammar_id": self.grammar_id,
            "pretty": self.pretty(),
        }
View source ↗
token_namesmethod
token_names(self) -> tuple[str, ...]

See the class contract above and the exact method implementation below.

Returns: tuple[str, ...]

Executed regression · constructor depth cap

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_constructor_depth_cap() -> None:
    grammar = GrammarSpec(
        sorts=("jet_monomial",),
        tokens_by_sort={"jet_monomial": ("y", "yp")},
        constructors=("compose_jets",),
        max_growth_depth=1,
    )
    seed = _jet("y", "yp")
    grown = apply_constructor(seed, "compose_jets", grammar, left="y", right="yp")
    assert grown is not None
    assert "y*yp" in grown.token_names()
    assert apply_constructor(grown, "compose_jets", grammar, left="y", right="y") is None
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_constructor_depth_cap" -q
Method implementation
    def token_names(self) -> tuple[str, ...]:
        return tuple(token.name for token in self.tokens)
View source ↗
Read the implementation
class ConditionHypothesis:
    """A proposed condition. Hashable :class:`~omnibias.core.proof.discovery.Candidate`."""

    sort: ConditionSort
    tokens: tuple[ConditionToken, ...]
    constructors: tuple[str, ...] = ()
    coefficients: tuple[str, ...] = ()
    grammar_id: str = "v1"

    def pretty(self) -> str:
        names = ", ".join(token.name for token in self.tokens)
        return f"{self.sort}[{names}]"

    def as_dict(self) -> dict[str, Any]:
        return {
            "sort": self.sort,
            "tokens": [token.as_dict() for token in self.tokens],
            "constructors": list(self.constructors),
            "coefficients": list(self.coefficients),
            "grammar_id": self.grammar_id,
            "pretty": self.pretty(),
        }

    def token_names(self) -> tuple[str, ...]:
        return tuple(token.name for token in self.tokens)
Other public import paths
  • omnibias.core.proof.ConditionHypothesis
  • omnibias.core.proof.condition.ConditionHypothesis
CONSTANT

ConditionSort​

omnibias.core.proof.ConditionSortSource ↗
ConditionSort = Literal['conservation', 'dfinite', 'edge_colouring', 'extremal_template', 'forbidden_minor', 'fractional_order', 'jet_monomial', 'ore', 'pde_operator', 'piecewise_hybrid', 'residual_sign', 'sos_onset', 'sos_template']

This exported constant is defined by the expression above. Its exact value and annotation come from the pinned source; use it with the module contract.

Read the implementation
ConditionSort = Literal[
    "conservation",
    "dfinite",
    "edge_colouring",
    "extremal_template",
    "forbidden_minor",
    "fractional_order",
    "jet_monomial",
    "ore",
    "pde_operator",
    "piecewise_hybrid",
    "residual_sign",
    "sos_onset",
    "sos_template",
]
Other public import paths
  • omnibias.core.proof.ConditionSort
  • omnibias.core.proof.condition.ConditionSort
CONSTANT

ConditionSortFactory​

omnibias.core.proof.condition.ConditionSortFactorySource ↗
ConditionSortFactory = Callable[..., FiniteFamily | None]

This exported constant is defined by the expression above. Its exact value and annotation come from the pinned source; use it with the module contract.

Read the implementation
ConditionSortFactory = Callable[..., FiniteFamily | None]
CLASS

ConditionToken​

omnibias.core.proof.ConditionTokenSource ↗
class ConditionToken

Dataclass constructor fields; inherited fields, if any, are declared by the base class. A field(...) expression describes a default factory or field options, not a literal argument default.

One typed atom of a condition (a jet monomial, Ore generator, …).

Parameters

NameType & defaultContract
sortdataclass fieldConditionSortRequiredSee the operation contract and implementation below.
namedataclass fieldstrRequiredSee the operation contract and implementation below.
Executed regression · hypothesis hash and dict

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_hypothesis_hash_and_dict() -> None:
    left = _jet("y", "yp")
    right = _jet("y", "yp")
    assert left == right
    assert hash(left) == hash(right)
    payload = left.as_dict()
    assert payload["sort"] == "jet_monomial"
    assert payload["pretty"] == "jet_monomial[y, yp]"
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_hypothesis_hash_and_dict" -q

Fields & methods

sortfield
sort: ConditionSort

Declared ConditionSort field on ConditionToken. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
namefield
name: str

Declared str field on ConditionToken. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
as_dictmethod
as_dict(self) -> dict[str, str]

See the class contract above and the exact method implementation below.

Returns: dict[str, str]

Executed regression · hypothesis hash and dict

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_hypothesis_hash_and_dict() -> None:
    left = _jet("y", "yp")
    right = _jet("y", "yp")
    assert left == right
    assert hash(left) == hash(right)
    payload = left.as_dict()
    assert payload["sort"] == "jet_monomial"
    assert payload["pretty"] == "jet_monomial[y, yp]"
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_hypothesis_hash_and_dict" -q
Method implementation
    def as_dict(self) -> dict[str, str]:
        return {"sort": self.sort, "name": self.name}
View source ↗
Read the implementation
class ConditionToken:
    """One typed atom of a condition (a jet monomial, Ore generator, …)."""

    sort: ConditionSort
    name: str

    def as_dict(self) -> dict[str, str]:
        return {"sort": self.sort, "name": self.name}
Other public import paths
  • omnibias.core.proof.ConditionToken
  • omnibias.core.proof.condition.ConditionToken
CLASS

GrammarGrowthFamily​

omnibias.core.proof.GrammarGrowthFamilySource ↗
class GrammarGrowthFamily

Dataclass constructor fields; inherited fields, if any, are declared by the base class. A field(...) expression describes a default factory or field options, not a literal argument default.

Walk constructor-grown hypotheses. checker is the exact accept gate.

Parameters

NameType & defaultContract
grammardataclass fieldGrammarSpecRequiredSee the operation contract and implementation below.
seeddataclass fieldConditionHypothesisRequiredSee the operation contract and implementation below.
checkerdataclass fieldCallable[[ConditionHypothesis], ExactCheck | None]RequiredSee the operation contract and implementation below.
namedataclass fieldstrDefault: 'condition_grammar_growth'See the operation contract and implementation below.
empty_miss_detaildataclass fieldstrDefault: 'no witness in enumerated grammar'See the operation contract and implementation below.
statementdataclass fieldStatementDefault: field(default_factory=lambda: Statement(name='condition_grammar_growth', obligation='a grown hypothesis in this grammar has an exact witness', parent='condition language', parent_status='open'))See the operation contract and implementation below.

Fields & methods

grammarfield
grammar: GrammarSpec

Declared GrammarSpec field on GrammarGrowthFamily. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
seedfield
seed: ConditionHypothesis

Declared ConditionHypothesis field on GrammarGrowthFamily. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
checkerfield
checker: Callable[[ConditionHypothesis], ExactCheck | None]

Declared Callable[[ConditionHypothesis], ExactCheck | None] field on GrammarGrowthFamily. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
namefield
name: str = 'condition_grammar_growth'

Declared str field on GrammarGrowthFamily. Default expression: 'condition_grammar_growth'.

View source ↗
empty_miss_detailfield
empty_miss_detail: str = 'no witness in enumerated grammar'

Declared str field on GrammarGrowthFamily. Default expression: 'no witness in enumerated grammar'.

View source ↗
statementfield
statement: Statement = field(default_factory=lambda: Statement(name='condition_grammar_growth', obligation='a grown hypothesis in this grammar has an exact witness', parent='condition language', parent_status='open'))

Declared Statement field on GrammarGrowthFamily. Default expression: field(default_factory=lambda: Statement(name='condition_grammar_growth', obligation='a grown hypothesis in this grammar has an exact witness', parent='condition language', parent_status='open')).

View source ↗
completeproperty
complete(self) -> bool

See the class contract above and the exact method implementation below.

Returns: bool

Method implementation
    def complete(self) -> bool:
        return self.grammar.complete
View source ↗
cardinalitymethod
cardinality(self) -> int | None

See the class contract above and the exact method implementation below.

Returns: int | None

Method implementation
    def cardinality(self) -> int | None:
        return None
View source ↗
originmethod
origin(self) -> ConditionHypothesis

See the class contract above and the exact method implementation below.

Returns: ConditionHypothesis

Method implementation
    def origin(self) -> ConditionHypothesis:
        return self.seed
View source ↗
neighborsmethod
neighbors(self, candidate: Candidate) -> Sequence[ConditionHypothesis]

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
candidatepositional-or-keywordCandidateRequiredSee the operation contract and implementation below.

Returns: Sequence[ConditionHypothesis]

Method implementation
    def neighbors(self, candidate: Candidate) -> Sequence[ConditionHypothesis]:
        if not isinstance(candidate, ConditionHypothesis):
            return ()
        return grow_neighbors(candidate, self.grammar)
View source ↗
scoremethod
score(self, candidate: Candidate) -> int

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
candidatepositional-or-keywordCandidateRequiredSee the operation contract and implementation below.

Returns: int

Method implementation
    def score(self, candidate: Candidate) -> int:
        if not isinstance(candidate, ConditionHypothesis):
            return 0
        return -len(candidate.tokens)
View source ↗
checkmethod
check(self, candidate: Candidate) -> ExactCheck | None

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
candidatepositional-or-keywordCandidateRequiredSee the operation contract and implementation below.

Returns: ExactCheck | None

Method implementation
    def check(self, candidate: Candidate) -> ExactCheck | None:
        if not isinstance(candidate, ConditionHypothesis):
            return None
        return self.checker(candidate)
View source ↗
Read the implementation
class GrammarGrowthFamily:
    """Walk constructor-grown hypotheses. ``checker`` is the exact accept gate."""

    grammar: GrammarSpec
    seed: ConditionHypothesis
    checker: Callable[[ConditionHypothesis], ExactCheck | None]
    name: str = "condition_grammar_growth"
    empty_miss_detail: str = "no witness in enumerated grammar"
    statement: Statement = field(
        default_factory=lambda: Statement(
            name="condition_grammar_growth",
            obligation="a grown hypothesis in this grammar has an exact witness",
            parent="condition language",
            parent_status="open",
        )
    )

    @property
    def complete(self) -> bool:
        return self.grammar.complete

    def cardinality(self) -> int | None:
        return None

    def origin(self) -> ConditionHypothesis:
        return self.seed

    def neighbors(self, candidate: Candidate) -> Sequence[ConditionHypothesis]:
        if not isinstance(candidate, ConditionHypothesis):
            return ()
        return grow_neighbors(candidate, self.grammar)

    def score(self, candidate: Candidate) -> int:
        if not isinstance(candidate, ConditionHypothesis):
            return 0
        return -len(candidate.tokens)

    def check(self, candidate: Candidate) -> ExactCheck | None:
        if not isinstance(candidate, ConditionHypothesis):
            return None
        return self.checker(candidate)
Other public import paths
  • omnibias.core.proof.GrammarGrowthFamily
  • omnibias.core.proof.condition.GrammarGrowthFamily
CLASS

GrammarSpec​

omnibias.core.proof.GrammarSpecSource ↗
class GrammarSpec

Dataclass constructor fields; inherited fields, if any, are declared by the base class. A field(...) expression describes a default factory or field options, not a literal argument default.

Finite hypothesis class. complete defaults False (incomplete grammar).

Parameters

NameType & defaultContract
sortsdataclass fieldtuple[ConditionSort, ...]RequiredSee the operation contract and implementation below.
tokens_by_sortdataclass fieldMapping[ConditionSort, tuple[str, ...]]RequiredSee the operation contract and implementation below.
constructorsdataclass fieldtuple[str, ...]Default: ()See the operation contract and implementation below.
max_growth_depthdataclass fieldintDefault: 1See the operation contract and implementation below.
completedataclass fieldboolDefault: FalseSee the operation contract and implementation below.
grammar_iddataclass fieldstrDefault: 'v1'See the operation contract and implementation below.
Regression example · untyped constructor rejected

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_untyped_constructor_rejected() -> None:
    grammar = GrammarSpec(
        sorts=("jet_monomial",),
        tokens_by_sort={"jet_monomial": ("y",)},
        constructors=("compose_jets",),
    )
    assert apply_constructor(_jet("y"), "llm_emit_checker", grammar) is None
python -m pytest packages/omnibias-core/tests/test_condition.py -k test_untyped_constructor_rejected -q
Regression example · constructor depth cap

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_constructor_depth_cap() -> None:
    grammar = GrammarSpec(
        sorts=("jet_monomial",),
        tokens_by_sort={"jet_monomial": ("y", "yp")},
        constructors=("compose_jets",),
        max_growth_depth=1,
    )
    seed = _jet("y", "yp")
    grown = apply_constructor(seed, "compose_jets", grammar, left="y", right="yp")
    assert grown is not None
    assert "y*yp" in grown.token_names()
    assert apply_constructor(grown, "compose_jets", grammar, left="y", right="y") is None
python -m pytest packages/omnibias-core/tests/test_condition.py -k test_constructor_depth_cap -q

Fields & methods

sortsfield
sorts: tuple[ConditionSort, ...]

Declared tuple[ConditionSort, ...] field on GrammarSpec. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
tokens_by_sortfield
tokens_by_sort: Mapping[ConditionSort, tuple[str, ...]]

Declared Mapping[ConditionSort, tuple[str, ...]] field on GrammarSpec. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
constructorsfield
constructors: tuple[str, ...] = ()

Declared tuple[str, ...] field on GrammarSpec. Default expression: ().

View source ↗
max_growth_depthfield
max_growth_depth: int = 1

Declared int field on GrammarSpec. Default expression: 1.

View source ↗
completefield
complete: bool = False

Declared bool field on GrammarSpec. Default expression: False.

View source ↗
grammar_idfield
grammar_id: str = 'v1'

Declared str field on GrammarSpec. Default expression: 'v1'.

View source ↗
tokens_formethod
tokens_for(self, sort: ConditionSort) -> tuple[str, ...]

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
sortpositional-or-keywordConditionSortRequiredSee the operation contract and implementation below.

Returns: tuple[str, ...]

Method implementation
    def tokens_for(self, sort: ConditionSort) -> tuple[str, ...]:
        return tuple(self.tokens_by_sort.get(sort, ()))
View source ↗
Read the implementation
class GrammarSpec:
    """Finite hypothesis class. ``complete`` defaults False (incomplete grammar)."""

    sorts: tuple[ConditionSort, ...]
    tokens_by_sort: Mapping[ConditionSort, tuple[str, ...]]
    constructors: tuple[str, ...] = ()
    max_growth_depth: int = 1
    complete: bool = False
    grammar_id: str = "v1"

    def tokens_for(self, sort: ConditionSort) -> tuple[str, ...]:
        return tuple(self.tokens_by_sort.get(sort, ()))
Other public import paths
  • omnibias.core.proof.GrammarSpec
  • omnibias.core.proof.condition.GrammarSpec
CLASS

KindMetaFamily​

omnibias.core.proof.KindMetaFamilySource ↗
class KindMetaFamily

Dataclass constructor fields; inherited fields, if any, are declared by the base class. A field(...) expression describes a default factory or field options, not a literal argument default.

Candidates are ConditionSort tags. Missing sorts force incomplete grammar.

Parameters

NameType & defaultContract
sortsdataclass fieldtuple[ConditionSort, ...]RequiredSee the operation contract and implementation below.
familiesdataclass fieldMapping[ConditionSort, FiniteFamily] | NoneDefault: NoneSee the operation contract and implementation below.
observationdataclass fieldObservation | NoneDefault: NoneSee the operation contract and implementation below.
sort_scoresdataclass fieldMapping[str, int] | NoneDefault: NoneSee the operation contract and implementation below.
grammar_completedataclass fieldboolDefault: FalseSee the operation contract and implementation below.
budgetdataclass fieldintDefault: 8See the operation contract and implementation below.
namedataclass fieldstrDefault: 'condition_kind_meta'See the operation contract and implementation below.
empty_miss_detaildataclass fieldstrDefault: 'no witness in enumerated grammar'See the operation contract and implementation below.
statementdataclass fieldStatementDefault: field(default_factory=lambda: Statement(name='condition_kind_meta', obligation='some registered condition sort has an exact witness in its box', parent='condition language', parent_status='open'))See the operation contract and implementation below.
Executed regression · zero budget meta is search incomplete

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_zero_budget_meta_is_search_incomplete() -> None:
    saved = _isolated_sorts()
    try:
        meta = KindMetaFamily(
            sorts=("jet_monomial",),
            families={"jet_monomial": _AlwaysHit()},
            grammar_complete=True,
        )
        result = run_discovery(meta.statement, meta, "score_guided", budget=0)
        assert result.status == "BLOCKED"
        assert result.search_incomplete is True
        assert result.evaluated == 0
    finally:
        _restore_sorts(saved)
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_zero_budget_meta_is_search_incomplete" -q
Regression example · kind meta does not prefer jet score

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_kind_meta_does_not_prefer_jet_score() -> None:
    saved = _isolated()
    try:
        meta = KindMetaFamily(
            sorts=("sos_template", "jet_monomial"),
            families={"sos_template": _AlwaysHit(), "jet_monomial": _AlwaysHit()},
            grammar_complete=True,
            budget=2,
        )
        assert meta.score("jet_monomial") == 0
        assert meta.score("sos_template") == 0
        result = run_discovery(meta.statement, meta, "score_guided", budget=4)
        assert result.candidate == "sos_template"
    finally:
        _restore(saved)
python -m pytest packages/omnibias-core/tests/test_observe.py -k test_kind_meta_does_not_prefer_jet_score -q

Fields & methods

sortsfield
sorts: tuple[ConditionSort, ...]

Declared tuple[ConditionSort, ...] field on KindMetaFamily. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.

View source ↗
familiesfield
families: Mapping[ConditionSort, FiniteFamily] | None = None

Declared Mapping[ConditionSort, FiniteFamily] | None field on KindMetaFamily. Default expression: None.

View source ↗
observationfield
observation: Observation | None = None

Declared Observation | None field on KindMetaFamily. Default expression: None.

View source ↗
sort_scoresfield
sort_scores: Mapping[str, int] | None = None

Declared Mapping[str, int] | None field on KindMetaFamily. Default expression: None.

View source ↗
grammar_completefield
grammar_complete: bool = False

Declared bool field on KindMetaFamily. Default expression: False.

Regression example · meta missing sort forces incomplete

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_meta_missing_sort_forces_incomplete() -> None:
    saved = _isolated_sorts()
    try:
        meta = KindMetaFamily(
            sorts=("jet_monomial", "ore"),
            families={"jet_monomial": _AlwaysMiss()},
            grammar_complete=True,
        )
        assert meta.complete is False
        assert meta.grammar_complete is False
        result = run_discovery(meta.statement, meta, "score_guided", budget=4)
        assert result.status == "BLOCKED"
        assert result.search_incomplete is True
        assert result.detail == "search_incomplete"
    finally:
        _restore_sorts(saved)
python -m pytest packages/omnibias-core/tests/test_condition.py -k test_meta_missing_sort_forces_incomplete -q
View source ↗
budgetfield
budget: int = 8

Declared int field on KindMetaFamily. Default expression: 8.

View source ↗
namefield
name: str = 'condition_kind_meta'

Declared str field on KindMetaFamily. Default expression: 'condition_kind_meta'.

View source ↗
empty_miss_detailfield
empty_miss_detail: str = 'no witness in enumerated grammar'

Declared str field on KindMetaFamily. Default expression: 'no witness in enumerated grammar'.

View source ↗
statementfield
statement: Statement = field(default_factory=lambda: Statement(name='condition_kind_meta', obligation='some registered condition sort has an exact witness in its box', parent='condition language', parent_status='open'))

Declared Statement field on KindMetaFamily. Default expression: field(default_factory=lambda: Statement(name='condition_kind_meta', obligation='some registered condition sort has an exact witness in its box', parent='condition language', parent_status='open')).

Regression example · zero budget meta is search incomplete

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_zero_budget_meta_is_search_incomplete() -> None:
    saved = _isolated_sorts()
    try:
        meta = KindMetaFamily(
            sorts=("jet_monomial",),
            families={"jet_monomial": _AlwaysHit()},
            grammar_complete=True,
        )
        result = run_discovery(meta.statement, meta, "score_guided", budget=0)
        assert result.status == "BLOCKED"
        assert result.search_incomplete is True
        assert result.evaluated == 0
    finally:
        _restore_sorts(saved)
python -m pytest packages/omnibias-core/tests/test_condition.py -k test_zero_budget_meta_is_search_incomplete -q
View source ↗
completefield
complete: bool = field(init=False)

Declared bool field on KindMetaFamily. Default expression: field(init=False).

Regression example · meta missing sort forces incomplete

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_meta_missing_sort_forces_incomplete() -> None:
    saved = _isolated_sorts()
    try:
        meta = KindMetaFamily(
            sorts=("jet_monomial", "ore"),
            families={"jet_monomial": _AlwaysMiss()},
            grammar_complete=True,
        )
        assert meta.complete is False
        assert meta.grammar_complete is False
        result = run_discovery(meta.statement, meta, "score_guided", budget=4)
        assert result.status == "BLOCKED"
        assert result.search_incomplete is True
        assert result.detail == "search_incomplete"
    finally:
        _restore_sorts(saved)
python -m pytest packages/omnibias-core/tests/test_condition.py -k test_meta_missing_sort_forces_incomplete -q
View source ↗
__post_init__method
__post_init__(self) -> None

See the class contract above and the exact method implementation below.

Returns: None

Executed regression · zero budget meta is search incomplete

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_zero_budget_meta_is_search_incomplete() -> None:
    saved = _isolated_sorts()
    try:
        meta = KindMetaFamily(
            sorts=("jet_monomial",),
            families={"jet_monomial": _AlwaysHit()},
            grammar_complete=True,
        )
        result = run_discovery(meta.statement, meta, "score_guided", budget=0)
        assert result.status == "BLOCKED"
        assert result.search_incomplete is True
        assert result.evaluated == 0
    finally:
        _restore_sorts(saved)
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_zero_budget_meta_is_search_incomplete" -q
Method implementation
    def __post_init__(self) -> None:
        resolved: dict[ConditionSort, FiniteFamily] = {}
        if self.families is not None:
            for sort, family in self.families.items():
                resolved[sort] = family
        else:
            resolved.update(bind_sorts(self.observation, self.sorts))
        missing = tuple(sort for sort in self.sorts if sort not in resolved)
        grammar_complete = bool(self.grammar_complete) and not missing and bool(self.sorts)
        object.__setattr__(self, "grammar_complete", grammar_complete)
        object.__setattr__(self, "complete", grammar_complete)
        object.__setattr__(self, "_resolved", resolved)
View source ↗
cardinalitymethod
cardinality(self) -> int

See the class contract above and the exact method implementation below.

Returns: int

Executed regression · zero budget meta is search incomplete

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_zero_budget_meta_is_search_incomplete() -> None:
    saved = _isolated_sorts()
    try:
        meta = KindMetaFamily(
            sorts=("jet_monomial",),
            families={"jet_monomial": _AlwaysHit()},
            grammar_complete=True,
        )
        result = run_discovery(meta.statement, meta, "score_guided", budget=0)
        assert result.status == "BLOCKED"
        assert result.search_incomplete is True
        assert result.evaluated == 0
    finally:
        _restore_sorts(saved)
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_zero_budget_meta_is_search_incomplete" -q
Method implementation
    def cardinality(self) -> int:
        return len(self.sorts)
View source ↗
originmethod
origin(self) -> ConditionSort

See the class contract above and the exact method implementation below.

Returns: ConditionSort

Validation & failure cases
  • When not self.sorts, raises ValueError('KindMetaFamily needs at least one sort').
Executed regression · kind meta does not prefer jet score

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_kind_meta_does_not_prefer_jet_score() -> None:
    saved = _isolated()
    try:
        meta = KindMetaFamily(
            sorts=("sos_template", "jet_monomial"),
            families={"sos_template": _AlwaysHit(), "jet_monomial": _AlwaysHit()},
            grammar_complete=True,
            budget=2,
        )
        assert meta.score("jet_monomial") == 0
        assert meta.score("sos_template") == 0
        result = run_discovery(meta.statement, meta, "score_guided", budget=4)
        assert result.candidate == "sos_template"
    finally:
        _restore(saved)
python -m pytest "packages/omnibias-core/tests/test_observe.py::test_kind_meta_does_not_prefer_jet_score" -q
Method implementation
    def origin(self) -> ConditionSort:
        if not self.sorts:
            raise ValueError("KindMetaFamily needs at least one sort")
        return self.sorts[0]
View source ↗
neighborsmethod
neighbors(self, candidate: Candidate) -> Sequence[ConditionSort]

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
candidatepositional-or-keywordCandidateRequiredSee the operation contract and implementation below.

Returns: Sequence[ConditionSort]

Executed regression · meta missing sort forces incomplete

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_meta_missing_sort_forces_incomplete() -> None:
    saved = _isolated_sorts()
    try:
        meta = KindMetaFamily(
            sorts=("jet_monomial", "ore"),
            families={"jet_monomial": _AlwaysMiss()},
            grammar_complete=True,
        )
        assert meta.complete is False
        assert meta.grammar_complete is False
        result = run_discovery(meta.statement, meta, "score_guided", budget=4)
        assert result.status == "BLOCKED"
        assert result.search_incomplete is True
        assert result.detail == "search_incomplete"
    finally:
        _restore_sorts(saved)
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_meta_missing_sort_forces_incomplete" -q
Method implementation
    def neighbors(self, candidate: Candidate) -> Sequence[ConditionSort]:
        if not isinstance(candidate, str) or candidate not in self.sorts:
            return ()
        index = self.sorts.index(candidate)
        out: list[ConditionSort] = []
        if index > 0:
            out.append(self.sorts[index - 1])
        if index + 1 < len(self.sorts):
            out.append(self.sorts[index + 1])
        return out
View source ↗
scoremethod
score(self, candidate: Candidate) -> int

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
candidatepositional-or-keywordCandidateRequiredSee the operation contract and implementation below.

Returns: int

Executed regression · kind meta does not prefer jet score

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_kind_meta_does_not_prefer_jet_score() -> None:
    saved = _isolated()
    try:
        meta = KindMetaFamily(
            sorts=("sos_template", "jet_monomial"),
            families={"sos_template": _AlwaysHit(), "jet_monomial": _AlwaysHit()},
            grammar_complete=True,
            budget=2,
        )
        assert meta.score("jet_monomial") == 0
        assert meta.score("sos_template") == 0
        result = run_discovery(meta.statement, meta, "score_guided", budget=4)
        assert result.candidate == "sos_template"
    finally:
        _restore(saved)
python -m pytest "packages/omnibias-core/tests/test_observe.py::test_kind_meta_does_not_prefer_jet_score" -q
Method implementation
    def score(self, candidate: Candidate) -> int:
        if self.sort_scores is None:
            return 0
        return int(self.sort_scores.get(str(candidate), 0))
View source ↗
checkmethod
check(self, candidate: Candidate) -> ExactCheck | None

See the class contract above and the exact method implementation below.

Parameters

NameType & defaultContract
candidatepositional-or-keywordCandidateRequiredSee the operation contract and implementation below.

Returns: ExactCheck | None

Executed regression · kind meta does not prefer jet score

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_kind_meta_does_not_prefer_jet_score() -> None:
    saved = _isolated()
    try:
        meta = KindMetaFamily(
            sorts=("sos_template", "jet_monomial"),
            families={"sos_template": _AlwaysHit(), "jet_monomial": _AlwaysHit()},
            grammar_complete=True,
            budget=2,
        )
        assert meta.score("jet_monomial") == 0
        assert meta.score("sos_template") == 0
        result = run_discovery(meta.statement, meta, "score_guided", budget=4)
        assert result.candidate == "sos_template"
    finally:
        _restore(saved)
python -m pytest "packages/omnibias-core/tests/test_observe.py::test_kind_meta_does_not_prefer_jet_score" -q
Method implementation
    def check(self, candidate: Candidate) -> ExactCheck | None:
        if not isinstance(candidate, str) or candidate not in self.sorts:
            return None
        sort = candidate
        family = self._resolved.get(sort)
        if family is None:
            return ExactCheck(
                ok=False,
                payload={
                    "sort": candidate,
                    "missing": True,
                    "honesty": condition_honesty(discovered=False),
                    "grammar_complete": self.grammar_complete,
                },
            )
        result = run_discovery(
            family.statement,
            family,
            "score_guided",
            budget=self.budget,
        )
        ok = result.status == "PROVED"
        return ExactCheck(
            ok=ok,
            payload={
                "sort": candidate,
                "sub": result.as_dict(),
                "grammar_complete": self.grammar_complete,
                "honesty": condition_honesty(discovered=ok),
                "no_condition_exists_claim": False,
            },
        )
View source ↗
Read the implementation
class KindMetaFamily:
    """Candidates are :data:`ConditionSort` tags. Missing sorts force incomplete grammar."""

    sorts: tuple[ConditionSort, ...]
    families: Mapping[ConditionSort, FiniteFamily] | None = None
    observation: Observation | None = None
    sort_scores: Mapping[str, int] | None = None
    grammar_complete: bool = False
    budget: int = 8
    name: str = "condition_kind_meta"
    empty_miss_detail: str = "no witness in enumerated grammar"
    statement: Statement = field(
        default_factory=lambda: Statement(
            name="condition_kind_meta",
            obligation="some registered condition sort has an exact witness in its box",
            parent="condition language",
            parent_status="open",
        )
    )
    complete: bool = field(init=False)
    _resolved: dict[ConditionSort, FiniteFamily] = field(init=False, repr=False)

    def __post_init__(self) -> None:
        resolved: dict[ConditionSort, FiniteFamily] = {}
        if self.families is not None:
            for sort, family in self.families.items():
                resolved[sort] = family
        else:
            resolved.update(bind_sorts(self.observation, self.sorts))
        missing = tuple(sort for sort in self.sorts if sort not in resolved)
        grammar_complete = bool(self.grammar_complete) and not missing and bool(self.sorts)
        object.__setattr__(self, "grammar_complete", grammar_complete)
        object.__setattr__(self, "complete", grammar_complete)
        object.__setattr__(self, "_resolved", resolved)

    def cardinality(self) -> int:
        return len(self.sorts)

    def origin(self) -> ConditionSort:
        if not self.sorts:
            raise ValueError("KindMetaFamily needs at least one sort")
        return self.sorts[0]

    def neighbors(self, candidate: Candidate) -> Sequence[ConditionSort]:
        if not isinstance(candidate, str) or candidate not in self.sorts:
            return ()
        index = self.sorts.index(candidate)
        out: list[ConditionSort] = []
        if index > 0:
            out.append(self.sorts[index - 1])
        if index + 1 < len(self.sorts):
            out.append(self.sorts[index + 1])
        return out

    def score(self, candidate: Candidate) -> int:
        if self.sort_scores is None:
            return 0
        return int(self.sort_scores.get(str(candidate), 0))

    def check(self, candidate: Candidate) -> ExactCheck | None:
        if not isinstance(candidate, str) or candidate not in self.sorts:
            return None
        sort = candidate
        family = self._resolved.get(sort)
        if family is None:
            return ExactCheck(
                ok=False,
                payload={
                    "sort": candidate,
                    "missing": True,
                    "honesty": condition_honesty(discovered=False),
                    "grammar_complete": self.grammar_complete,
                },
            )
        result = run_discovery(
            family.statement,
            family,
            "score_guided",
            budget=self.budget,
        )
        ok = result.status == "PROVED"
        return ExactCheck(
            ok=ok,
            payload={
                "sort": candidate,
                "sub": result.as_dict(),
                "grammar_complete": self.grammar_complete,
                "honesty": condition_honesty(discovered=ok),
                "no_condition_exists_claim": False,
            },
        )
Other public import paths
  • omnibias.core.proof.KindMetaFamily
  • omnibias.core.proof.condition.KindMetaFamily
CONSTANT

TYPED_CONSTRUCTORS​

omnibias.core.proof.condition.TYPED_CONSTRUCTORSSource ↗
TYPED_CONSTRUCTORS: frozenset[str] = frozenset({'add_minor_edge', 'compose_jets', 'multiply_columns', 'raise_ore_degree', 'split_partition'})

This exported constant is defined by the expression above. Its exact value and annotation come from the pinned source; use it with the module contract.

Read the implementation
TYPED_CONSTRUCTORS: frozenset[str] = frozenset(
    {
        "add_minor_edge",
        "compose_jets",
        "multiply_columns",
        "raise_ore_degree",
        "split_partition",
    }
)
FUNCTION

apply_constructor​

omnibias.core.proof.apply_constructorSource ↗
apply_constructor(hypothesis: ConditionHypothesis, constructor: str, grammar: GrammarSpec, *, left: str | None=None, right: str | None=None) -> ConditionHypothesis | None

Rewrite hypothesis. Returns None if the constructor is illegal.

Parameters

NameType & defaultContract
hypothesispositional-or-keywordConditionHypothesisRequiredSee the operation contract and implementation below.
constructorpositional-or-keywordstrRequiredSee the operation contract and implementation below.
grammarpositional-or-keywordGrammarSpecRequiredSee the operation contract and implementation below.
leftkeyword-onlystr | NoneDefault: NoneSee the operation contract and implementation below.
rightkeyword-onlystr | NoneDefault: NoneSee the operation contract and implementation below.
ReturnsConditionHypothesis | None
Executed regression · untyped constructor rejected

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_untyped_constructor_rejected() -> None:
    grammar = GrammarSpec(
        sorts=("jet_monomial",),
        tokens_by_sort={"jet_monomial": ("y",)},
        constructors=("compose_jets",),
    )
    assert apply_constructor(_jet("y"), "llm_emit_checker", grammar) is None
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_untyped_constructor_rejected" -q
Regression example · constructor depth cap

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_constructor_depth_cap() -> None:
    grammar = GrammarSpec(
        sorts=("jet_monomial",),
        tokens_by_sort={"jet_monomial": ("y", "yp")},
        constructors=("compose_jets",),
        max_growth_depth=1,
    )
    seed = _jet("y", "yp")
    grown = apply_constructor(seed, "compose_jets", grammar, left="y", right="yp")
    assert grown is not None
    assert "y*yp" in grown.token_names()
    assert apply_constructor(grown, "compose_jets", grammar, left="y", right="y") is None
python -m pytest packages/omnibias-core/tests/test_condition.py -k test_constructor_depth_cap -q
Read the implementation
def apply_constructor(
    hypothesis: ConditionHypothesis,
    constructor: str,
    grammar: GrammarSpec,
    *,
    left: str | None = None,
    right: str | None = None,
) -> ConditionHypothesis | None:
    """Rewrite ``hypothesis``. Returns ``None`` if the constructor is illegal."""

    if constructor not in TYPED_CONSTRUCTORS:
        return None
    if constructor not in grammar.constructors:
        return None
    if len(hypothesis.constructors) >= grammar.max_growth_depth:
        return None
    names = hypothesis.token_names()
    if constructor in {"compose_jets", "multiply_columns"}:
        if left is None or right is None:
            return None
        if left not in names or right not in names:
            return None
        product = f"{left}*{right}"
        if product in names:
            return None
        token = ConditionToken(hypothesis.sort, product)
        return ConditionHypothesis(
            sort=hypothesis.sort,
            tokens=hypothesis.tokens + (token,),
            constructors=hypothesis.constructors + (constructor,),
            coefficients=hypothesis.coefficients,
            grammar_id=hypothesis.grammar_id,
        )
    if constructor == "raise_ore_degree":
        if hypothesis.sort != "ore" or not hypothesis.coefficients:
            return None
        order = int(hypothesis.coefficients[0]) + 1
        rest = hypothesis.coefficients[1:]
        return ConditionHypothesis(
            sort="ore",
            tokens=hypothesis.tokens,
            constructors=hypothesis.constructors + ("raise_ore_degree",),
            coefficients=(str(order),) + rest,
            grammar_id=hypothesis.grammar_id,
        )
    if constructor == "split_partition":
        if any("@" in token.name for token in hypothesis.tokens):
            return None
        grown: list[ConditionToken] = []
        for token in hypothesis.tokens:
            grown.append(ConditionToken(token.sort, f"{token.name}@0"))
            grown.append(ConditionToken(token.sort, f"{token.name}@1"))
        return ConditionHypothesis(
            sort=hypothesis.sort,
            tokens=tuple(grown),
            constructors=hypothesis.constructors + ("split_partition",),
            coefficients=hypothesis.coefficients,
            grammar_id=hypothesis.grammar_id,
        )
    if constructor == "add_minor_edge":
        if left is None or right is None or left == right:
            return None
        lo, hi = (left, right) if left < right else (right, left)
        if not _vertex_ok(lo) or not _vertex_ok(hi):
            return None
        edge = f"e:{lo}-{hi}"
        if edge in names:
            return None
        token = ConditionToken("forbidden_minor", edge)
        return ConditionHypothesis(
            sort="forbidden_minor",
            tokens=hypothesis.tokens + (token,),
            constructors=hypothesis.constructors + ("add_minor_edge",),
            coefficients=hypothesis.coefficients,
            grammar_id=hypothesis.grammar_id,
        )
    return None
Other public import paths
  • omnibias.core.proof.apply_constructor
  • omnibias.core.proof.condition.apply_constructor
FUNCTION

bind_sorts​

omnibias.core.proof.bind_sortsSource ↗
bind_sorts(observation: Observation | None, sorts: Sequence[ConditionSort] | None=None) -> dict[ConditionSort, FiniteFamily]

Apply registered factories. None means the sort does not apply.

Parameters

NameType & defaultContract
observationpositional-or-keywordObservation | NoneRequiredSee the operation contract and implementation below.
sortspositional-or-keywordSequence[ConditionSort] | NoneDefault: NoneSee the operation contract and implementation below.
Returnsdict[ConditionSort, FiniteFamily]
Regression example · poly only observation binds only sos

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_poly_only_observation_binds_only_sos() -> None:
    obs = observation_planted_sos()
    bound = bind_sorts(obs)
    assert set(bound) == {"sos_template"}
    family = bind_sos_template(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert bind_sos_template(Observation(tag="tanh")) is None
    assert bind_sos_onset(obs) is None
python -m pytest packages/omnibias-sos/tests/test_conditions.py -k test_poly_only_observation_binds_only_sos -q
Regression example · binder none drops sort and forces incomplete

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_binder_none_drops_sort_and_forces_incomplete() -> None:
    saved = _isolated()
    try:
        def _bind_ore(obs: Observation | None) -> object | None:
            if obs is None:
                return _AlwaysHit()
            return None

        from omnibias.core.proof.condition import register_condition_sort

        register_condition_sort("ore", _bind_ore)
        obs = Observation(tag="tanh", jet_names=("y",), jet_rows=(("1",),))
        assert bind_sorts(obs, ("ore",)) == {}
        meta = KindMetaFamily(
            sorts=("ore",),
            observation=obs,
            grammar_complete=True,
        )
        assert meta.complete is False
        result = run_discovery(meta.statement, meta, "score_guided", budget=4)
        assert result.status == "BLOCKED"
        assert result.search_incomplete is True
    finally:
        _restore(saved)
python -m pytest packages/omnibias-core/tests/test_observe.py -k test_binder_none_drops_sort_and_forces_incomplete -q
Read the implementation
def bind_sorts(
    observation: Observation | None,
    sorts: Sequence[ConditionSort] | None = None,
) -> dict[ConditionSort, FiniteFamily]:
    """Apply registered factories. ``None`` means the sort does not apply."""

    wanted: tuple[ConditionSort, ...]
    if sorts is not None:
        wanted = tuple(sorts)
    else:
        registered = list_condition_sorts()
        wanted = registered if registered else ALL_CONDITION_SORTS
    out: dict[ConditionSort, FiniteFamily] = {}
    for sort in wanted:
        factory = _SORT_FACTORIES.get(sort)
        if factory is None:
            continue
        family = _invoke_factory(factory, observation)
        if family is not None:
            out[sort] = family
    return out
Other public import paths
  • omnibias.core.proof.bind_sorts
  • omnibias.core.proof.condition.bind_sorts
FUNCTION

condition_honesty​

omnibias.core.proof.condition_honestySource ↗
condition_honesty(*, discovered: bool) -> dict[str, bool]

Honesty keys for a condition-language check. Forbidden claims stay False.

Parameters

NameType & defaultContract
discoveredkeyword-onlyboolRequiredSee the operation contract and implementation below.
Returnsdict[str, bool]
Executed regression · honesty keys never claim no condition

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_honesty_keys_never_claim_no_condition() -> None:
    honesty = condition_honesty(discovered=True)
    assert honesty["discovered_by_omnibias"] is True
    assert honesty["no_condition_exists_claim"] is False
    assert honesty["unnamed_condition_complete_claim"] is False
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_honesty_keys_never_claim_no_condition" -q
Read the implementation
def condition_honesty(*, discovered: bool) -> dict[str, bool]:
    """Honesty keys for a condition-language check. Forbidden claims stay False."""

    return {
        "discovered_by_omnibias": discovered,
        "dgg_congestion_theorem_refuted": False,
        "erdos_146_claim": False,
        "erdos_180_claim": False,
        "erdos_183_claim": False,
        "jacobian_n2_claim": False,
        "no_condition_exists_claim": False,
        "ten_proofs_formalization_claim": False,
        "unnamed_condition_complete_claim": False,
    }
Other public import paths
  • omnibias.core.proof.condition_honesty
  • omnibias.core.proof.condition.condition_honesty
FUNCTION

condition_sort_factory​

omnibias.core.proof.condition.condition_sort_factorySource ↗
condition_sort_factory(sort: ConditionSort) -> ConditionSortFactory | None

The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.

Parameters

NameType & defaultContract
sortpositional-or-keywordConditionSortRequiredSee the operation contract and implementation below.
ReturnsConditionSortFactory | None
Read the implementation
def condition_sort_factory(sort: ConditionSort) -> ConditionSortFactory | None:
    return _SORT_FACTORIES.get(sort)
FUNCTION

emit_condition​

omnibias.core.proof.emit_conditionSource ↗
emit_condition(hypothesis: ConditionHypothesis, *, parent: str, parent_status: Literal['already_false', 'already_true', 'open']='open', existential: bool=True, obligation: str | None=None) -> Statement

Turn a proposed condition into a Statement the engine can adjudicate.

Parameters

NameType & defaultContract
hypothesispositional-or-keywordConditionHypothesisRequiredSee the operation contract and implementation below.
parentkeyword-onlystrRequiredSee the operation contract and implementation below.
parent_statuskeyword-onlyLiteral['already_false', 'already_true', 'open']Default: 'open'See the operation contract and implementation below.
existentialkeyword-onlyboolDefault: TrueSee the operation contract and implementation below.
obligationkeyword-onlystr | NoneDefault: NoneSee the operation contract and implementation below.
ReturnsStatement
Executed regression · emit condition statement

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_emit_condition_statement() -> None:
    statement = emit_condition(_jet("yp"), parent="Riccati identities", parent_status="already_true")
    assert statement.name == "condition_jet_monomial"
    assert "yp" in statement.obligation
    assert statement.parent_status == "already_true"
python -m pytest "packages/omnibias-core/tests/test_condition.py::test_emit_condition_statement" -q
Read the implementation
def emit_condition(
    hypothesis: ConditionHypothesis,
    *,
    parent: str,
    parent_status: Literal["already_false", "already_true", "open"] = "open",
    existential: bool = True,
    obligation: str | None = None,
) -> Statement:
    """Turn a proposed condition into a :class:`Statement` the engine can adjudicate."""

    return Statement(
        name=f"condition_{hypothesis.sort}",
        obligation=obligation or f"the hypothesis {hypothesis.pretty()} holds in its grammar",
        parent=parent,
        parent_status=parent_status,
        existential=existential,
    )
Other public import paths
  • omnibias.core.proof.emit_condition
  • omnibias.core.proof.condition.emit_condition
FUNCTION

grow_neighbors​

omnibias.core.proof.grow_neighborsSource ↗
grow_neighbors(hypothesis: ConditionHypothesis, grammar: GrammarSpec) -> tuple[ConditionHypothesis, ...]

All one-step typed growths of hypothesis inside grammar.

Parameters

NameType & defaultContract
hypothesispositional-or-keywordConditionHypothesisRequiredSee the operation contract and implementation below.
grammarpositional-or-keywordGrammarSpecRequiredSee the operation contract and implementation below.
Returnstuple[ConditionHypothesis, ...]
Read the implementation
def grow_neighbors(
    hypothesis: ConditionHypothesis,
    grammar: GrammarSpec,
) -> tuple[ConditionHypothesis, ...]:
    """All one-step typed growths of ``hypothesis`` inside ``grammar``."""

    seen: set[ConditionHypothesis] = set()
    out: list[ConditionHypothesis] = []
    names = hypothesis.token_names()
    product_ctor = (
        "compose_jets"
        if "compose_jets" in grammar.constructors
        else "multiply_columns"
        if "multiply_columns" in grammar.constructors
        else None
    )
    if product_ctor is not None:
        for i, left in enumerate(names):
            for right in names[i:]:
                grown = apply_constructor(
                    hypothesis, product_ctor, grammar, left=left, right=right
                )
                if grown is not None and grown not in seen:
                    seen.add(grown)
                    out.append(grown)
    if "raise_ore_degree" in grammar.constructors:
        grown = apply_constructor(hypothesis, "raise_ore_degree", grammar)
        if grown is not None and grown not in seen:
            seen.add(grown)
            out.append(grown)
    if "split_partition" in grammar.constructors:
        grown = apply_constructor(hypothesis, "split_partition", grammar)
        if grown is not None and grown not in seen:
            seen.add(grown)
            out.append(grown)
    if "add_minor_edge" in grammar.constructors:
        verts = [str(i) for i in range(5)]
        for i, left in enumerate(verts):
            for right in verts[i + 1 :]:
                grown = apply_constructor(
                    hypothesis, "add_minor_edge", grammar, left=left, right=right
                )
                if grown is not None and grown not in seen:
                    seen.add(grown)
                    out.append(grown)
    return tuple(out)
Other public import paths
  • omnibias.core.proof.grow_neighbors
  • omnibias.core.proof.condition.grow_neighbors
FUNCTION

list_condition_sorts​

omnibias.core.proof.list_condition_sortsSource ↗
list_condition_sorts() -> tuple[ConditionSort, ...]

The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.

Returnstuple[ConditionSort, ...]
Executed regression · poly only observation binds only sos

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_poly_only_observation_binds_only_sos() -> None:
    obs = observation_planted_sos()
    bound = bind_sorts(obs)
    assert set(bound) == {"sos_template"}
    family = bind_sos_template(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert bind_sos_template(Observation(tag="tanh")) is None
    assert bind_sos_onset(obs) is None
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_poly_only_observation_binds_only_sos" -q
Read the implementation
def list_condition_sorts() -> tuple[ConditionSort, ...]:
    return tuple(sorted(_SORT_FACTORIES, key=str))
Other public import paths
  • omnibias.core.proof.list_condition_sorts
  • omnibias.core.proof.condition.list_condition_sorts
FUNCTION

register_condition_sort​

omnibias.core.proof.register_condition_sortSource ↗
register_condition_sort(sort: ConditionSort, factory: ConditionSortFactory) -> None

Register a package factory that builds a FiniteFamily for sort.

Parameters

NameType & defaultContract
sortpositional-or-keywordConditionSortRequiredSee the operation contract and implementation below.
factorypositional-or-keywordConditionSortFactoryRequiredSee the operation contract and implementation below.
ReturnsNone
Explicit validation & failure cases
  • When existing is not None and existing is not factory, raises ValueError(f'condition sort collision: {sort!r} already registered').

These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.

Executed regression · zero budget select class is incomplete

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_zero_budget_select_class_is_incomplete() -> None:
    saved = _isolated()
    try:
        from omnibias.core.proof.condition import register_condition_sort

        register_condition_sort("jet_monomial", lambda obs: _AlwaysHit())
        obs = Observation(tag="tanh", jet_names=("y",), jet_rows=(("1",),))
        selection = select_class(obs, sorts=("jet_monomial",), budget=0)
        assert selection.result is not None
        assert selection.result.status == "BLOCKED"
        assert selection.result.search_incomplete is True
        assert selection.result.evaluated == 0
        assert selection.honesty["no_condition_exists_claim"] is False
    finally:
        _restore(saved)
python -m pytest "packages/omnibias-core/tests/test_observe.py::test_zero_budget_select_class_is_incomplete" -q
Regression example · select class miss is search incomplete

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_select_class_miss_is_search_incomplete() -> None:
    saved = _isolated()
    try:
        from omnibias.core.proof.condition import register_condition_sort

        register_condition_sort("jet_monomial", lambda obs: _AlwaysMiss())
        obs = Observation(tag="tanh", jet_names=("y",), jet_rows=(("1",),))
        selection = select_class(obs, sorts=("jet_monomial",))
        assert selection.best is None
        assert selection.search_incomplete is True
        assert selection.grammar_complete is False
        assert selection.honesty["no_condition_exists_claim"] is False
        assert selection.honesty["unnamed_condition_complete_claim"] is False
        assert selection.result is not None
        assert selection.result.detail == "search_incomplete"
    finally:
        _restore(saved)
python -m pytest packages/omnibias-core/tests/test_observe.py -k test_select_class_miss_is_search_incomplete -q
Read the implementation
def register_condition_sort(sort: ConditionSort, factory: ConditionSortFactory) -> None:
    """Register a package factory that builds a :class:`FiniteFamily` for ``sort``."""

    existing = _SORT_FACTORIES.get(sort)
    if existing is not None and existing is not factory:
        raise ValueError(f"condition sort collision: {sort!r} already registered")
    _SORT_FACTORIES[sort] = factory
Other public import paths
  • omnibias.core.proof.register_condition_sort
  • omnibias.core.proof.condition.register_condition_sort
FUNCTION

select_class​

omnibias.core.proof.select_classSource ↗
select_class(observation: Observation, *, collect: bool=True, memory: ClassMemory | None=None, gate: Any | None=None, grammar_complete: bool=False, sorts: Sequence[ConditionSort] | None=None, budget: int | None=None, inner_budget: int | None=None, grow: bool=True, max_growth_depth: int=1) -> ClassSelection

Bind, optionally reorder, collect certified hits, and rank.

grammar_complete is accepted and ignored — this driver never marks a grammar complete. Soft RMSE never writes ExactCheck. On an exact miss, grow=True applies one legal constructor step (still incomplete).

Parameters

NameType & defaultContract
observationpositional-or-keywordObservationRequiredSee the operation contract and implementation below.
collectkeyword-onlyboolDefault: TrueSee the operation contract and implementation below.
memorykeyword-onlyClassMemory | NoneDefault: NoneSee the operation contract and implementation below.
gatekeyword-onlyAny | NoneDefault: NoneSee the operation contract and implementation below.
grammar_completekeyword-onlyboolDefault: FalseSee the operation contract and implementation below.
sortskeyword-onlySequence[ConditionSort] | NoneDefault: NoneSee the operation contract and implementation below.
budgetkeyword-onlyint | NoneDefault: NoneSee the operation contract and implementation below.
inner_budgetkeyword-onlyint | NoneDefault: NoneSee the operation contract and implementation below.
growkeyword-onlyboolDefault: TrueSee the operation contract and implementation below.
max_growth_depthkeyword-onlyintDefault: 1See the operation contract and implementation below.
ReturnsClassSelection
Executed regression · zero budget select class is incomplete

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_zero_budget_select_class_is_incomplete() -> None:
    saved = _isolated()
    try:
        from omnibias.core.proof.condition import register_condition_sort

        register_condition_sort("jet_monomial", lambda obs: _AlwaysHit())
        obs = Observation(tag="tanh", jet_names=("y",), jet_rows=(("1",),))
        selection = select_class(obs, sorts=("jet_monomial",), budget=0)
        assert selection.result is not None
        assert selection.result.status == "BLOCKED"
        assert selection.result.search_incomplete is True
        assert selection.result.evaluated == 0
        assert selection.honesty["no_condition_exists_claim"] is False
    finally:
        _restore(saved)
python -m pytest "packages/omnibias-core/tests/test_observe.py::test_zero_budget_select_class_is_incomplete" -q
Regression example · select class miss is search incomplete

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_select_class_miss_is_search_incomplete() -> None:
    saved = _isolated()
    try:
        from omnibias.core.proof.condition import register_condition_sort

        register_condition_sort("jet_monomial", lambda obs: _AlwaysMiss())
        obs = Observation(tag="tanh", jet_names=("y",), jet_rows=(("1",),))
        selection = select_class(obs, sorts=("jet_monomial",))
        assert selection.best is None
        assert selection.search_incomplete is True
        assert selection.grammar_complete is False
        assert selection.honesty["no_condition_exists_claim"] is False
        assert selection.honesty["unnamed_condition_complete_claim"] is False
        assert selection.result is not None
        assert selection.result.detail == "search_incomplete"
    finally:
        _restore(saved)
python -m pytest packages/omnibias-core/tests/test_observe.py -k test_select_class_miss_is_search_incomplete -q
Read the implementation
def select_class(
    observation: Observation,
    *,
    collect: bool = True,
    memory: ClassMemory | None = None,
    gate: Any | None = None,
    grammar_complete: bool = False,
    sorts: Sequence[ConditionSort] | None = None,
    budget: int | None = None,
    inner_budget: int | None = None,
    grow: bool = True,
    max_growth_depth: int = 1,
) -> ClassSelection:
    """Bind, optionally reorder, collect certified hits, and rank.

    ``grammar_complete`` is accepted and ignored — this driver never marks a
    grammar complete. Soft RMSE never writes :class:`ExactCheck`. On an exact
    miss, ``grow=True`` applies one legal constructor step (still incomplete).
    """

    _ = grammar_complete
    if sorts is not None:
        requested = tuple(sorts)
    else:
        registered = list_condition_sorts()
        requested = registered if registered else ALL_CONDITION_SORTS
    if gate is not None:
        proposed = tuple(str(item) for item in gate.propose(observation))
        order = [sort for sort in proposed if sort in requested]
        for sort in requested:
            if sort not in order:
                order.append(sort)
        ordered = cast(tuple[ConditionSort, ...], tuple(order))
        sort_scores = {str(sort): len(ordered) - index for index, sort in enumerate(ordered)}
    else:
        ordered = requested
        sort_scores = None
    n_sorts = len(ordered)
    if budget is None:
        outer = n_sorts
    else:
        outer = budget
    inner = 32 if inner_budget is None else inner_budget
    meta = KindMetaFamily(
        sorts=ordered,
        observation=observation,
        sort_scores=sort_scores,
        grammar_complete=False,
        budget=inner,
    )
    result = run_discovery(
        meta.statement,
        meta,
        "score_guided",
        budget=outer,
        collect=collect,
    )
    hits: list[ClassHit] = []
    for candidate in result.solutions:
        checked: ExactCheck | None
        if candidate == result.candidate and result.check is not None:
            checked = result.check
        else:
            checked = meta.check(candidate)
        if checked is None or not checked.ok:
            continue
        unique = False
        if result.characterization is not None and len(result.solutions) == 1:
            unique = result.characterization.unique_in_family
        hits.append(class_hit_from_check(str(candidate), checked, unique_in_family=unique))
    if grow and outer > 0 and not any(hit.tier == "exact" for hit in hits):
        hits.extend(
            _grow_miss_hits(meta._resolved, max_growth_depth=max_growth_depth)
        )
    ranked = rank_class_hits(hits)
    best = ranked[0] if ranked else None
    if memory is not None and best is not None and best.tier == "exact":
        memory.record(observation, best.sort)
    discovered = best is not None and best.tier in {"exact", "enclosure"}
    return ClassSelection(
        observation=observation,
        hits=tuple(ranked),
        best=best,
        honesty=condition_honesty(discovered=discovered),
        search_incomplete=result.search_incomplete or not meta.complete,
        grammar_complete=False,
        result=result,
    )
Other public import paths
  • omnibias.core.proof.select_class
  • omnibias.core.proof.condition.select_class