Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ generated files; these are resource knobs, not escape hatches, and are recorded
deliberately.

`scripts/gen_degree.py` is untrusted: Lean re-derives `P n` and checks the Bernstein identity
with `ring`, so a corrupted coefficient fails the build. Its `--check` mode compares against
with `ring`, so a corrupted coefficient fails the build. It writes `Degree{n}.lean` under
`Sendov/FiniteRange/` relative to the repo root, not the shell cwd. Its `--check` mode compares against
numerical quadrature, and that check has already caught a real bug — a dropped `2ˡ` in
`(-2c)ˡ` produced a `P` wrong by sign and scale which nevertheless admitted a Bernstein
representation, with every coefficient negative. **Positivity of a certificate is not
Expand Down
7 changes: 5 additions & 2 deletions scripts/gen_degree.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""
from fractions import Fraction as F
from math import comb, lcm
from pathlib import Path

def mul(p,q):
r=[F(0)]*(len(p)+len(q)-1)
Expand Down Expand Up @@ -222,5 +223,7 @@ def bterm(j):

end Sendov
'''
io.open(f"Degree{n}.lean","w",encoding="utf-8").write(src)
print(f"n={n} deg={d} bytes={len(src)} maxGammaDigits={max(len(str(g)) for g in G)}")
out = Path(__file__).resolve().parents[1] / "Sendov" / "FiniteRange" / f"Degree{n}.lean"
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(src, encoding="utf-8")
print(f"wrote {out} n={n} deg={d} bytes={len(src)} maxGammaDigits={max(len(str(g)) for g in G)}")