Skip to main content

omnibias.sos.conditions

0.1.0a2AlphaPython >=3.10AGPL / commercial

Sum-of-squares constructions, polynomial positivity checks, and rigorous validation of proposed Gram matrices.

import omnibias.sos.conditions
Module contract & mathematical conventions

SOS-template condition family: half-degree as a hypothesis.

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.

CLASS

SosOnsetFamily​

omnibias.sos.conditions.SosOnsetFamilySource ↗
class SosOnsetFamily

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.

Putinar on-set nonnegativity. Enclosure, never a forged exact residual.

Parameters

NameType & defaultContract
polynomialdataclass fieldPolynomialDefault: field(default_factory=planted_sum_of_squares)See the operation contract and implementation below.
constraintsdataclass fieldtuple[Polynomial, ...]Default: ()See the operation contract and implementation below.
max_half_degreedataclass fieldintDefault: 2See the operation contract and implementation below.
namedataclass fieldstrDefault: 'condition_sos_onset'See the operation contract and implementation below.
grammardataclass fieldGrammarSpecDefault: field(default_factory=lambda: GrammarSpec(sorts=('sos_onset',), tokens_by_sort={'sos_onset': ('half_degree',)}, complete=False))See the operation contract and implementation below.
Executed regression · sos onset planted enclosure

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_sos_onset_planted_enclosure() -> None:
    obs = observation_planted_onset()
    family = bind_sos_onset(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload.get("tier") == "enclosure"
    catalog = SosOnsetFamily()
    replay = run_discovery(catalog.statement, catalog, "score_guided", budget=4)
    assert replay.status in {"PROVED", "BLOCKED"}
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_onset_planted_enclosure" -q

Fields & methods

polynomialfield
polynomial: Polynomial = field(default_factory=planted_sum_of_squares)

Declared Polynomial field on SosOnsetFamily. Default expression: field(default_factory=planted_sum_of_squares).

View source ↗
constraintsfield
constraints: tuple[Polynomial, ...] = ()

Declared tuple[Polynomial, ...] field on SosOnsetFamily. Default expression: ().

View source ↗
max_half_degreefield
max_half_degree: int = 2

Declared int field on SosOnsetFamily. Default expression: 2.

View source ↗
namefield
name: str = 'condition_sos_onset'

Declared str field on SosOnsetFamily. Default expression: 'condition_sos_onset'.

View source ↗
grammarfield
grammar: GrammarSpec = field(default_factory=lambda: GrammarSpec(sorts=('sos_onset',), tokens_by_sort={'sos_onset': ('half_degree',)}, complete=False))

Declared GrammarSpec field on SosOnsetFamily. Default expression: field(default_factory=lambda: GrammarSpec(sorts=('sos_onset',), tokens_by_sort={'sos_onset': ('half_degree',)}, complete=False)).

View source ↗
__post_init__method
__post_init__(self) -> None

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

Returns: None

Executed regression · sos onset planted enclosure

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_sos_onset_planted_enclosure() -> None:
    obs = observation_planted_onset()
    family = bind_sos_onset(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload.get("tier") == "enclosure"
    catalog = SosOnsetFamily()
    replay = run_discovery(catalog.statement, catalog, "score_guided", budget=4)
    assert replay.status in {"PROVED", "BLOCKED"}
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_onset_planted_enclosure" -q
Method implementation
    def __post_init__(self) -> None:
        self.statement = emit_condition(
            _onset_hypothesis(1),
            parent="on-set nonnegativity",
            parent_status="already_true",
            obligation="the observed polynomial is nonnegative on the packed constraint set",
        )
        self.empty_miss_detail = "no witness in enumerated grammar"
View source ↗
completeproperty
complete(self) -> bool

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

Returns: bool

Executed regression · sos onset planted enclosure

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_sos_onset_planted_enclosure() -> None:
    obs = observation_planted_onset()
    family = bind_sos_onset(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload.get("tier") == "enclosure"
    catalog = SosOnsetFamily()
    replay = run_discovery(catalog.statement, catalog, "score_guided", budget=4)
    assert replay.status in {"PROVED", "BLOCKED"}
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_onset_planted_enclosure" -q
Method implementation
    def complete(self) -> bool:
        return self.grammar.complete
View source ↗
cardinalitymethod
cardinality(self) -> int

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

Returns: int

Executed regression · sos onset planted enclosure

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_sos_onset_planted_enclosure() -> None:
    obs = observation_planted_onset()
    family = bind_sos_onset(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload.get("tier") == "enclosure"
    catalog = SosOnsetFamily()
    replay = run_discovery(catalog.statement, catalog, "score_guided", budget=4)
    assert replay.status in {"PROVED", "BLOCKED"}
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_onset_planted_enclosure" -q
Method implementation
    def cardinality(self) -> int:
        return self.max_half_degree
View source ↗
originmethod
origin(self) -> ConditionHypothesis

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

Returns: ConditionHypothesis

Executed regression · sos onset planted enclosure

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_sos_onset_planted_enclosure() -> None:
    obs = observation_planted_onset()
    family = bind_sos_onset(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload.get("tier") == "enclosure"
    catalog = SosOnsetFamily()
    replay = run_discovery(catalog.statement, catalog, "score_guided", budget=4)
    assert replay.status in {"PROVED", "BLOCKED"}
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_onset_planted_enclosure" -q
Method implementation
    def origin(self) -> ConditionHypothesis:
        return _onset_hypothesis(1)
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) or not candidate.coefficients:
            return ()
        half = int(candidate.coefficients[0])
        out: list[ConditionHypothesis] = []
        if half > 1:
            out.append(_onset_hypothesis(half - 1))
        if half < self.max_half_degree:
            out.append(_onset_hypothesis(half + 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 · sos onset planted enclosure

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_sos_onset_planted_enclosure() -> None:
    obs = observation_planted_onset()
    family = bind_sos_onset(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload.get("tier") == "enclosure"
    catalog = SosOnsetFamily()
    replay = run_discovery(catalog.statement, catalog, "score_guided", budget=4)
    assert replay.status in {"PROVED", "BLOCKED"}
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_onset_planted_enclosure" -q
Method implementation
    def score(self, candidate: Candidate) -> int:
        if not isinstance(candidate, ConditionHypothesis) or not candidate.coefficients:
            return 0
        return -int(candidate.coefficients[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 · sos onset planted enclosure

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_sos_onset_planted_enclosure() -> None:
    obs = observation_planted_onset()
    family = bind_sos_onset(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload.get("tier") == "enclosure"
    catalog = SosOnsetFamily()
    replay = run_discovery(catalog.statement, catalog, "score_guided", budget=4)
    assert replay.status in {"PROVED", "BLOCKED"}
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_onset_planted_enclosure" -q
Method implementation
    def check(self, candidate: Candidate) -> ExactCheck | None:
        if not isinstance(candidate, ConditionHypothesis) or candidate.sort != "sos_onset":
            return None
        if not candidate.coefficients:
            return None
        half = int(candidate.coefficients[0])
        cert = certify_nonneg_on_set(
            self.polynomial,
            self.constraints,
            half_degree=half,
        )
        ok = cert.status == "proved"
        return ExactCheck(
            ok=ok,
            payload={
                "tier": "enclosure",
                "status": cert.status,
                "half_degree": half,
                "hypothesis": candidate.as_dict(),
                "honesty": condition_honesty(discovered=ok),
            },
        )
View source ↗
statementattribute
statement = emit_condition(_onset_hypothesis(1), parent='on-set nonnegativity', parent_status='already_true', obligation='the observed polynomial is nonnegative on the packed constraint set')

Public instance attribute assigned by __post_init__. The source assignment is statement = emit_condition(_onset_hypothesis(1), parent='on-set nonnegativity', parent_status='already_true', obligation='the observed polynomial is nonnegative on the packed constraint set'); it describes instance state, not a literal constructor default.

Regression example · sos onset planted enclosure

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_sos_onset_planted_enclosure() -> None:
    obs = observation_planted_onset()
    family = bind_sos_onset(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload.get("tier") == "enclosure"
    catalog = SosOnsetFamily()
    replay = run_discovery(catalog.statement, catalog, "score_guided", budget=4)
    assert replay.status in {"PROVED", "BLOCKED"}
python -m pytest packages/omnibias-sos/tests/test_conditions.py -k test_sos_onset_planted_enclosure -q
View source ↗
empty_miss_detailattribute
empty_miss_detail = 'no witness in enumerated grammar'

Public instance attribute assigned by __post_init__. The source assignment is empty_miss_detail = 'no witness in enumerated grammar'; it describes instance state, not a literal constructor default.

View source ↗
Read the implementation
class SosOnsetFamily:
    """Putinar on-set nonnegativity. Enclosure, never a forged exact residual."""

    polynomial: Polynomial = field(default_factory=planted_sum_of_squares)
    constraints: tuple[Polynomial, ...] = ()
    max_half_degree: int = 2
    name: str = "condition_sos_onset"
    grammar: GrammarSpec = field(
        default_factory=lambda: GrammarSpec(
            sorts=("sos_onset",),
            tokens_by_sort={"sos_onset": ("half_degree",)},
            complete=False,
        )
    )

    def __post_init__(self) -> None:
        self.statement = emit_condition(
            _onset_hypothesis(1),
            parent="on-set nonnegativity",
            parent_status="already_true",
            obligation="the observed polynomial is nonnegative on the packed constraint set",
        )
        self.empty_miss_detail = "no witness in enumerated grammar"

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

    def cardinality(self) -> int:
        return self.max_half_degree

    def origin(self) -> ConditionHypothesis:
        return _onset_hypothesis(1)

    def neighbors(self, candidate: Candidate) -> Sequence[ConditionHypothesis]:
        if not isinstance(candidate, ConditionHypothesis) or not candidate.coefficients:
            return ()
        half = int(candidate.coefficients[0])
        out: list[ConditionHypothesis] = []
        if half > 1:
            out.append(_onset_hypothesis(half - 1))
        if half < self.max_half_degree:
            out.append(_onset_hypothesis(half + 1))
        return out

    def score(self, candidate: Candidate) -> int:
        if not isinstance(candidate, ConditionHypothesis) or not candidate.coefficients:
            return 0
        return -int(candidate.coefficients[0])

    def check(self, candidate: Candidate) -> ExactCheck | None:
        if not isinstance(candidate, ConditionHypothesis) or candidate.sort != "sos_onset":
            return None
        if not candidate.coefficients:
            return None
        half = int(candidate.coefficients[0])
        cert = certify_nonneg_on_set(
            self.polynomial,
            self.constraints,
            half_degree=half,
        )
        ok = cert.status == "proved"
        return ExactCheck(
            ok=ok,
            payload={
                "tier": "enclosure",
                "status": cert.status,
                "half_degree": half,
                "hypothesis": candidate.as_dict(),
                "honesty": condition_honesty(discovered=ok),
            },
        )
CLASS

SosTemplateFamily​

omnibias.sos.conditions.SosTemplateFamilySource ↗
class SosTemplateFamily

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.

Wrap SosDegreeFamily as an SOS-template hypothesis.

Parameters

NameType & defaultContract
polynomialdataclass fieldPolynomialDefault: field(default_factory=planted_sum_of_squares)See the operation contract and implementation below.
max_half_degreedataclass fieldintDefault: 2See the operation contract and implementation below.
namedataclass fieldstrDefault: 'condition_sos_template'See the operation contract and implementation below.
grammardataclass fieldGrammarSpecDefault: field(default_factory=lambda: GrammarSpec(sorts=('sos_template',), tokens_by_sort={'sos_template': ('half_degree',)}, complete=False))See the operation contract and implementation below.
Executed regression · sos template planted hits

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_sos_template_planted_hits() -> None:
    family = SosTemplateFamily()
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload["honesty"]["no_condition_exists_claim"] is False
    assert result.check.payload["honesty"]["discovered_by_omnibias"] is True
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -q
Regression example · sos template vanishing poly misses

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_sos_template_vanishing_poly_misses() -> None:
    x = Polynomial.variable(0, 2)
    y = Polynomial.variable(1, 2)
    family = SosTemplateFamily(polynomial=x * x + y * y)
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "BLOCKED"
    assert result.search_incomplete is True
    assert result.check is None or result.check.ok is False
python -m pytest packages/omnibias-sos/tests/test_conditions.py -k test_sos_template_vanishing_poly_misses -q

Fields & methods

polynomialfield
polynomial: Polynomial = field(default_factory=planted_sum_of_squares)

Declared Polynomial field on SosTemplateFamily. Default expression: field(default_factory=planted_sum_of_squares).

View source ↗
max_half_degreefield
max_half_degree: int = 2

Declared int field on SosTemplateFamily. Default expression: 2.

View source ↗
namefield
name: str = 'condition_sos_template'

Declared str field on SosTemplateFamily. Default expression: 'condition_sos_template'.

View source ↗
grammarfield
grammar: GrammarSpec = field(default_factory=lambda: GrammarSpec(sorts=('sos_template',), tokens_by_sort={'sos_template': ('half_degree',)}, complete=False))

Declared GrammarSpec field on SosTemplateFamily. Default expression: field(default_factory=lambda: GrammarSpec(sorts=('sos_template',), tokens_by_sort={'sos_template': ('half_degree',)}, complete=False)).

View source ↗
__post_init__method
__post_init__(self) -> None

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

Returns: None

Executed regression · sos template planted hits

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_sos_template_planted_hits() -> None:
    family = SosTemplateFamily()
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload["honesty"]["no_condition_exists_claim"] is False
    assert result.check.payload["honesty"]["discovered_by_omnibias"] is True
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -q
Method implementation
    def __post_init__(self) -> None:
        self._inner = SosDegreeFamily(
            polynomial=self.polynomial,
            max_half_degree=self.max_half_degree,
        )
        self.statement = emit_condition(
            _sos_hypothesis(1),
            parent="global nonnegativity",
            parent_status="already_true",
            obligation="the planted polynomial is SOS at some half-degree in this grammar",
        )
        self.empty_miss_detail = "no witness in enumerated grammar"
View source ↗
completeproperty
complete(self) -> bool

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

Returns: bool

Executed regression · sos template planted hits

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_sos_template_planted_hits() -> None:
    family = SosTemplateFamily()
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload["honesty"]["no_condition_exists_claim"] is False
    assert result.check.payload["honesty"]["discovered_by_omnibias"] is True
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -q
Method implementation
    def complete(self) -> bool:
        return self.grammar.complete
View source ↗
cardinalitymethod
cardinality(self) -> int

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

Returns: int

Executed regression · sos template planted hits

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_sos_template_planted_hits() -> None:
    family = SosTemplateFamily()
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload["honesty"]["no_condition_exists_claim"] is False
    assert result.check.payload["honesty"]["discovered_by_omnibias"] is True
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -q
Method implementation
    def cardinality(self) -> int:
        return self.max_half_degree
View source ↗
originmethod
origin(self) -> ConditionHypothesis

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

Returns: ConditionHypothesis

Executed regression · sos template planted hits

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_sos_template_planted_hits() -> None:
    family = SosTemplateFamily()
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload["honesty"]["no_condition_exists_claim"] is False
    assert result.check.payload["honesty"]["discovered_by_omnibias"] is True
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -q
Method implementation
    def origin(self) -> ConditionHypothesis:
        return _sos_hypothesis(1)
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]

Executed regression · sos template vanishing poly misses

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_sos_template_vanishing_poly_misses() -> None:
    x = Polynomial.variable(0, 2)
    y = Polynomial.variable(1, 2)
    family = SosTemplateFamily(polynomial=x * x + y * y)
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "BLOCKED"
    assert result.search_incomplete is True
    assert result.check is None or result.check.ok is False
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_vanishing_poly_misses" -q
Method implementation
    def neighbors(self, candidate: Candidate) -> Sequence[ConditionHypothesis]:
        if not isinstance(candidate, ConditionHypothesis) or not candidate.coefficients:
            return ()
        half = int(candidate.coefficients[0])
        out: list[ConditionHypothesis] = []
        if half > 1:
            out.append(_sos_hypothesis(half - 1))
        if half < self.max_half_degree:
            out.append(_sos_hypothesis(half + 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 · sos template planted hits

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_sos_template_planted_hits() -> None:
    family = SosTemplateFamily()
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload["honesty"]["no_condition_exists_claim"] is False
    assert result.check.payload["honesty"]["discovered_by_omnibias"] is True
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -q
Method implementation
    def score(self, candidate: Candidate) -> int:
        if not isinstance(candidate, ConditionHypothesis) or not candidate.coefficients:
            return 0
        return -int(candidate.coefficients[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 · sos template planted hits

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_sos_template_planted_hits() -> None:
    family = SosTemplateFamily()
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload["honesty"]["no_condition_exists_claim"] is False
    assert result.check.payload["honesty"]["discovered_by_omnibias"] is True
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -q
Method implementation
    def check(self, candidate: Candidate) -> ExactCheck | None:
        if not isinstance(candidate, ConditionHypothesis) or candidate.sort != "sos_template":
            return None
        if not candidate.coefficients:
            return None
        half = int(candidate.coefficients[0])
        inner = self._inner.check(half)
        if inner is None:
            return None
        payload = dict(inner.payload)
        payload["hypothesis"] = candidate.as_dict()
        honesty = dict(payload.get("honesty", {})) if isinstance(payload.get("honesty"), dict) else {}
        honesty.update(condition_honesty(discovered=inner.ok))
        payload["honesty"] = honesty
        return ExactCheck(ok=inner.ok, payload=payload)
View source ↗
statementattribute
statement = emit_condition(_sos_hypothesis(1), parent='global nonnegativity', parent_status='already_true', obligation='the planted polynomial is SOS at some half-degree in this grammar')

Public instance attribute assigned by __post_init__. The source assignment is statement = emit_condition(_sos_hypothesis(1), parent='global nonnegativity', parent_status='already_true', obligation='the planted polynomial is SOS at some half-degree in this grammar'); it describes instance state, not a literal constructor default.

Regression example · sos template planted hits

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_sos_template_planted_hits() -> None:
    family = SosTemplateFamily()
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload["honesty"]["no_condition_exists_claim"] is False
    assert result.check.payload["honesty"]["discovered_by_omnibias"] is True
python -m pytest packages/omnibias-sos/tests/test_conditions.py -k test_sos_template_planted_hits -q
View source ↗
empty_miss_detailattribute
empty_miss_detail = 'no witness in enumerated grammar'

Public instance attribute assigned by __post_init__. The source assignment is empty_miss_detail = 'no witness in enumerated grammar'; it describes instance state, not a literal constructor default.

View source ↗
Read the implementation
class SosTemplateFamily:
    """Wrap :class:`SosDegreeFamily` as an SOS-template hypothesis."""

    polynomial: Polynomial = field(default_factory=planted_sum_of_squares)
    max_half_degree: int = 2
    name: str = "condition_sos_template"
    grammar: GrammarSpec = field(
        default_factory=lambda: GrammarSpec(
            sorts=("sos_template",),
            tokens_by_sort={"sos_template": ("half_degree",)},
            complete=False,
        )
    )

    def __post_init__(self) -> None:
        self._inner = SosDegreeFamily(
            polynomial=self.polynomial,
            max_half_degree=self.max_half_degree,
        )
        self.statement = emit_condition(
            _sos_hypothesis(1),
            parent="global nonnegativity",
            parent_status="already_true",
            obligation="the planted polynomial is SOS at some half-degree in this grammar",
        )
        self.empty_miss_detail = "no witness in enumerated grammar"

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

    def cardinality(self) -> int:
        return self.max_half_degree

    def origin(self) -> ConditionHypothesis:
        return _sos_hypothesis(1)

    def neighbors(self, candidate: Candidate) -> Sequence[ConditionHypothesis]:
        if not isinstance(candidate, ConditionHypothesis) or not candidate.coefficients:
            return ()
        half = int(candidate.coefficients[0])
        out: list[ConditionHypothesis] = []
        if half > 1:
            out.append(_sos_hypothesis(half - 1))
        if half < self.max_half_degree:
            out.append(_sos_hypothesis(half + 1))
        return out

    def score(self, candidate: Candidate) -> int:
        if not isinstance(candidate, ConditionHypothesis) or not candidate.coefficients:
            return 0
        return -int(candidate.coefficients[0])

    def check(self, candidate: Candidate) -> ExactCheck | None:
        if not isinstance(candidate, ConditionHypothesis) or candidate.sort != "sos_template":
            return None
        if not candidate.coefficients:
            return None
        half = int(candidate.coefficients[0])
        inner = self._inner.check(half)
        if inner is None:
            return None
        payload = dict(inner.payload)
        payload["hypothesis"] = candidate.as_dict()
        honesty = dict(payload.get("honesty", {})) if isinstance(payload.get("honesty"), dict) else {}
        honesty.update(condition_honesty(discovered=inner.ok))
        payload["honesty"] = honesty
        return ExactCheck(ok=inner.ok, payload=payload)
FUNCTION

bind_sos_onset​

omnibias.sos.conditions.bind_sos_onsetSource ↗
bind_sos_onset(observation: Observation | None=None) -> SosOnsetFamily | None

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

Parameters

NameType & defaultContract
observationpositional-or-keywordObservation | NoneDefault: NoneSee the operation contract and implementation below.
ReturnsSosOnsetFamily | None
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
Regression example · sos onset planted enclosure

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_sos_onset_planted_enclosure() -> None:
    obs = observation_planted_onset()
    family = bind_sos_onset(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload.get("tier") == "enclosure"
    catalog = SosOnsetFamily()
    replay = run_discovery(catalog.statement, catalog, "score_guided", budget=4)
    assert replay.status in {"PROVED", "BLOCKED"}
python -m pytest packages/omnibias-sos/tests/test_conditions.py -k test_sos_onset_planted_enclosure -q
Read the implementation
def bind_sos_onset(observation: Observation | None = None) -> SosOnsetFamily | None:
    if observation is None:
        return SosOnsetFamily()
    if not observation.poly_terms or not observation.poly_constraints:
        return None
    constraints = tuple(
        _poly_from_terms(observation.poly_n_vars, terms)
        for terms in observation.poly_constraints
    )
    return SosOnsetFamily(
        polynomial=_poly_from_terms(observation.poly_n_vars, observation.poly_terms),
        constraints=constraints,
    )
FUNCTION

bind_sos_template​

omnibias.sos.conditions.bind_sos_templateSource ↗
bind_sos_template(observation: Observation | None=None) -> SosTemplateFamily | None

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

Parameters

NameType & defaultContract
observationpositional-or-keywordObservation | NoneDefault: NoneSee the operation contract and implementation below.
ReturnsSosTemplateFamily | None
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 bind_sos_template(observation: Observation | None = None) -> SosTemplateFamily | None:
    if observation is None:
        return SosTemplateFamily()
    if not observation.poly_terms or observation.poly_constraints:
        return None
    return SosTemplateFamily(
        polynomial=_poly_from_terms(observation.poly_n_vars, observation.poly_terms)
    )
FUNCTION

observation_planted_onset​

omnibias.sos.conditions.observation_planted_onsetSource ↗
observation_planted_onset() -> Observation

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

ReturnsObservation
Executed regression · sos onset planted enclosure

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_sos_onset_planted_enclosure() -> None:
    obs = observation_planted_onset()
    family = bind_sos_onset(obs)
    assert family is not None
    result = run_discovery(family.statement, family, "score_guided", budget=4)
    assert result.status == "PROVED"
    assert result.check is not None
    assert result.check.payload.get("tier") == "enclosure"
    catalog = SosOnsetFamily()
    replay = run_discovery(catalog.statement, catalog, "score_guided", budget=4)
    assert replay.status in {"PROVED", "BLOCKED"}
python -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_onset_planted_enclosure" -q
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
Read the implementation
def observation_planted_onset() -> Observation:
    poly = planted_sum_of_squares()
    terms = tuple(
        (exponent, str(Fraction(coeff).limit_denominator()))
        for exponent, coeff in poly.coeffs.items()
    )
    one = (((0, 0), "1"),)
    return Observation(
        poly_n_vars=poly.n_vars,
        poly_terms=terms,
        poly_constraints=(one,),
    )
FUNCTION

observation_planted_sos​

omnibias.sos.conditions.observation_planted_sosSource ↗
observation_planted_sos() -> Observation

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

ReturnsObservation
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 observation_planted_sos() -> Observation:
    poly = planted_sum_of_squares()
    terms = tuple(
        (exponent, str(Fraction(coeff).limit_denominator()))
        for exponent, coeff in poly.coeffs.items()
    )
    return Observation(tag="sos", poly_n_vars=poly.n_vars, poly_terms=terms)