omnibias.sos.families
Sum-of-squares constructions, polynomial positivity checks, and rigorous validation of proposed Gram matrices.
import omnibias.sos.familiesModule contract & mathematical conventions
SOS degree box: positivity in a Gram span, not “only equations.”
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.
SosDegreeFamily
omnibias.sos.families.SosDegreeFamilySource ↗class SosDegreeFamilyDataclass 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.
Candidate = half-degree; check = existing certify_sos on a planted poly.
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: 'sos_degree_search' | See the operation contract and implementation below. |
completedataclass field | boolDefault: True | See the operation contract and implementation below. |
statementdataclass field | StatementDefault: field(default_factory=lambda: Statement(name='sos_degree_search', obligation='the planted polynomial is SOS at some half-degree in the box', parent='global nonnegativity', parent_status='already_true')) | 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" -qFields & methods
polynomialfield
polynomial: Polynomial = field(default_factory=planted_sum_of_squares)Declared Polynomial field on SosDegreeFamily. Default expression: field(default_factory=planted_sum_of_squares).
max_half_degreefield
max_half_degree: int = 2Declared int field on SosDegreeFamily. Default expression: 2.
namefield
name: str = 'sos_degree_search'Declared str field on SosDegreeFamily. Default expression: 'sos_degree_search'.
completefield
complete: bool = TrueDeclared bool field on SosDegreeFamily. Default expression: True.
statementfield
statement: Statement = field(default_factory=lambda: Statement(name='sos_degree_search', obligation='the planted polynomial is SOS at some half-degree in the box', parent='global nonnegativity', parent_status='already_true'))Declared Statement field on SosDegreeFamily. Default expression: field(default_factory=lambda: Statement(name='sos_degree_search', obligation='the planted polynomial is SOS at some half-degree in the box', parent='global nonnegativity', parent_status='already_true')).
cardinalitymethod
cardinality(self) -> intSee the class contract above and the exact method implementation below.
Returns: int
Method implementation
def cardinality(self) -> int:
return self.max_half_degreeoriginmethod
origin(self) -> intSee the class contract above and the exact method implementation below.
Returns: int
Method implementation
def origin(self) -> int:
return 1neighborsmethod
neighbors(self, candidate: Candidate) -> Sequence[int]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[int]
Method implementation
def neighbors(self, candidate: Candidate) -> Sequence[int]:
value = int(candidate) # type: ignore[arg-type]
out: list[int] = []
if value > 1:
out.append(value - 1)
if value < self.max_half_degree:
out.append(value + 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
Method implementation
def score(self, candidate: Candidate) -> int:
return -int(candidate) # type: ignore[arg-type]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:
half = int(candidate) # type: ignore[arg-type]
if not 1 <= half <= self.max_half_degree:
return None
cert = certify_sos(self.polynomial, half_degree=half)
ok = cert.status == "proved"
return ExactCheck(
ok=ok,
payload={
"half_degree": half,
"status": cert.status,
"honesty": {
"discovered_by_omnibias": ok,
"unproven_claim": False,
},
},
)Read the implementation
class SosDegreeFamily:
"""Candidate = half-degree; check = existing ``certify_sos`` on a planted poly."""
polynomial: Polynomial = field(default_factory=planted_sum_of_squares)
max_half_degree: int = 2
name: str = "sos_degree_search"
complete: bool = True
statement: Statement = field(
default_factory=lambda: Statement(
name="sos_degree_search",
obligation="the planted polynomial is SOS at some half-degree in the box",
parent="global nonnegativity",
parent_status="already_true",
)
)
def cardinality(self) -> int:
return self.max_half_degree
def origin(self) -> int:
return 1
def neighbors(self, candidate: Candidate) -> Sequence[int]:
value = int(candidate) # type: ignore[arg-type]
out: list[int] = []
if value > 1:
out.append(value - 1)
if value < self.max_half_degree:
out.append(value + 1)
return out
def score(self, candidate: Candidate) -> int:
return -int(candidate) # type: ignore[arg-type]
def check(self, candidate: Candidate) -> ExactCheck | None:
half = int(candidate) # type: ignore[arg-type]
if not 1 <= half <= self.max_half_degree:
return None
cert = certify_sos(self.polynomial, half_degree=half)
ok = cert.status == "proved"
return ExactCheck(
ok=ok,
payload={
"half_degree": half,
"status": cert.status,
"honesty": {
"discovered_by_omnibias": ok,
"unproven_claim": False,
},
},
)planted_sum_of_squares
omnibias.sos.families.planted_sum_of_squaresSource ↗planted_sum_of_squares() -> PolynomialThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
PolynomialExecuted 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" -qRead the implementation
def planted_sum_of_squares() -> Polynomial:
x = Polynomial.variable(0, 2)
y = Polynomial.variable(1, 2)
one = Polynomial.constant(1.0, 2)
return x * x + y * y + one