omnibias.sos.conditions
Sum-of-squares constructions, polynomial positivity checks, and rigorous validation of proposed Gram matrices.
import omnibias.sos.conditionsModule 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.
SosOnsetFamily
omnibias.sos.conditions.SosOnsetFamilySource ↗class SosOnsetFamilyDataclass 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
| Name | Type & default | Contract |
|---|---|---|
polynomialdataclass field | PolynomialDefault: field(default_factory=planted_sum_of_squares) | See the operation contract and implementation below. |
constraintsdataclass field | tuple[Polynomial, ...]Default: () | See the operation contract and implementation below. |
max_half_degreedataclass field | intDefault: 2 | See the operation contract and implementation below. |
namedataclass field | strDefault: 'condition_sos_onset' | See the operation contract and implementation below. |
grammardataclass field | GrammarSpecDefault: 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" -qFields & 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).
constraintsfield
constraints: tuple[Polynomial, ...] = ()Declared tuple[Polynomial, ...] field on SosOnsetFamily. Default expression: ().
max_half_degreefield
max_half_degree: int = 2Declared int field on SosOnsetFamily. Default expression: 2.
namefield
name: str = 'condition_sos_onset'Declared str field on SosOnsetFamily. Default expression: 'condition_sos_onset'.
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)).
__post_init__method
__post_init__(self) -> NoneSee 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" -qMethod 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"completeproperty
complete(self) -> boolSee 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" -qMethod implementation
def complete(self) -> bool:
return self.grammar.completecardinalitymethod
cardinality(self) -> intSee 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" -qMethod implementation
def cardinality(self) -> int:
return self.max_half_degreeoriginmethod
origin(self) -> ConditionHypothesisSee 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" -qMethod implementation
def origin(self) -> ConditionHypothesis:
return _onset_hypothesis(1)neighborsmethod
neighbors(self, candidate: Candidate) -> Sequence[ConditionHypothesis]See the class contract above and the exact method implementation below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
candidatepositional-or-keyword | CandidateRequired | See 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 outscoremethod
score(self, candidate: Candidate) -> intSee the class contract above and the exact method implementation below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
candidatepositional-or-keyword | CandidateRequired | See 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" -qMethod implementation
def score(self, candidate: Candidate) -> int:
if not isinstance(candidate, ConditionHypothesis) or not candidate.coefficients:
return 0
return -int(candidate.coefficients[0])checkmethod
check(self, candidate: Candidate) -> ExactCheck | NoneSee the class contract above and the exact method implementation below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
candidatepositional-or-keyword | CandidateRequired | See 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" -qMethod 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),
},
)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 -qempty_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.
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),
},
)SosTemplateFamily
omnibias.sos.conditions.SosTemplateFamilySource ↗class SosTemplateFamilyDataclass 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
| Name | Type & default | Contract |
|---|---|---|
polynomialdataclass field | PolynomialDefault: field(default_factory=planted_sum_of_squares) | See the operation contract and implementation below. |
max_half_degreedataclass field | intDefault: 2 | See the operation contract and implementation below. |
namedataclass field | strDefault: 'condition_sos_template' | See the operation contract and implementation below. |
grammardataclass field | GrammarSpecDefault: 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 Truepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -qRegression 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 Falsepython -m pytest packages/omnibias-sos/tests/test_conditions.py -k test_sos_template_vanishing_poly_misses -qFields & 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).
max_half_degreefield
max_half_degree: int = 2Declared int field on SosTemplateFamily. Default expression: 2.
namefield
name: str = 'condition_sos_template'Declared str field on SosTemplateFamily. Default expression: 'condition_sos_template'.
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)).
__post_init__method
__post_init__(self) -> NoneSee 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 Truepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -qMethod 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"completeproperty
complete(self) -> boolSee 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 Truepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -qMethod implementation
def complete(self) -> bool:
return self.grammar.completecardinalitymethod
cardinality(self) -> intSee 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 Truepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -qMethod implementation
def cardinality(self) -> int:
return self.max_half_degreeoriginmethod
origin(self) -> ConditionHypothesisSee 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 Truepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -qMethod implementation
def origin(self) -> ConditionHypothesis:
return _sos_hypothesis(1)neighborsmethod
neighbors(self, candidate: Candidate) -> Sequence[ConditionHypothesis]See the class contract above and the exact method implementation below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
candidatepositional-or-keyword | CandidateRequired | See 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 Falsepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_vanishing_poly_misses" -qMethod 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 outscoremethod
score(self, candidate: Candidate) -> intSee the class contract above and the exact method implementation below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
candidatepositional-or-keyword | CandidateRequired | See 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 Truepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -qMethod implementation
def score(self, candidate: Candidate) -> int:
if not isinstance(candidate, ConditionHypothesis) or not candidate.coefficients:
return 0
return -int(candidate.coefficients[0])checkmethod
check(self, candidate: Candidate) -> ExactCheck | NoneSee the class contract above and the exact method implementation below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
candidatepositional-or-keyword | CandidateRequired | See 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 Truepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_sos_template_planted_hits" -qMethod 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)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 Truepython -m pytest packages/omnibias-sos/tests/test_conditions.py -k test_sos_template_planted_hits -qempty_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.
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)bind_sos_onset
omnibias.sos.conditions.bind_sos_onsetSource ↗bind_sos_onset(observation: Observation | None=None) -> SosOnsetFamily | NoneThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
observationpositional-or-keyword | Observation | NoneDefault: None | See the operation contract and implementation below. |
SosOnsetFamily | NoneExecuted 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 Nonepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_poly_only_observation_binds_only_sos" -qRegression 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 -qRead 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,
)bind_sos_template
omnibias.sos.conditions.bind_sos_templateSource ↗bind_sos_template(observation: Observation | None=None) -> SosTemplateFamily | NoneThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
observationpositional-or-keyword | Observation | NoneDefault: None | See the operation contract and implementation below. |
SosTemplateFamily | NoneExecuted 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 Nonepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_poly_only_observation_binds_only_sos" -qRead 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)
)observation_planted_onset
omnibias.sos.conditions.observation_planted_onsetSource ↗observation_planted_onset() -> ObservationThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
ObservationExecuted 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" -qRegression 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 Nonepython -m pytest packages/omnibias-sos/tests/test_conditions.py -k test_poly_only_observation_binds_only_sos -qRead 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,),
)observation_planted_sos
omnibias.sos.conditions.observation_planted_sosSource ↗observation_planted_sos() -> ObservationThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
ObservationExecuted 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 Nonepython -m pytest "packages/omnibias-sos/tests/test_conditions.py::test_poly_only_observation_binds_only_sos" -qRead 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)