Skip to content

Sync with upstream: unconditional Pasta group orders (daira/CompElliptic#6) - #2

Merged
martyall merged 6 commits into
mainfrom
sync-upstream-unconditional-order
Jul 16, 2026
Merged

martyall merged 6 commits into
mainfrom
sync-upstream-unconditional-order

Conversation

@martyall

Copy link
Copy Markdown
Member

Merges daira/CompElliptic main (through daira/CompElliptic#6) into this fork, on top of our absolute-field-names line.

Upstream deletes the HasseBound hypothesis entirely: card_eq is now unconditional, via the elementary fibre bound #E ≤ 2·#F + 1 plus the native_decide prime-order witness (Vesta's leftover #E = 2p case is excluded because −5 is not a cube — new Fields/Residue.lean). Gpt/Gpt_ne_zero now discharge by kernel decide.

Conflict resolution (PastaOrder, Encodings, plus alias fixes in Curves/Pasta): take upstream's proofs with this fork's absolute field names (Fp/Fq) substituted for the old role aliases. Our SWPoint ↔ Affine.Point equivalence + card bridge and the v4.30.0 toolchain are preserved.

Downstream (l-adic/snarky formal/pasta) this deletes the two Hasse axioms — the workspace's last declared curve axioms.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RhavGeUhGukSRQTRH6JEaD

martyall and others added 6 commits July 7, 2026 00:36
The role names stated the Pasta cycle as a pun (VestaBaseField =
PallasScalarField and vice versa) — four names for two fields. The fields
now carry their standard absolute names: Fp (the Pallas base field, also
the Vesta scalar field) and Fq (the Pallas scalar field, also the Vesta
base field), matching proof-systems' own convention. Role information
belongs to consumers' relative projections, not to which alias was picked.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Several facts were being re-derived ad hoc at each use site. Pull them
out to a single home so that callers, existing and future, can consume
them instead of restating them.

* `SWPoint.equivSubtype` — the `SWPoint E ≃ { pr : F × F // Valid .. }`
  injection was hand-rolled separately for decidable equality and for
  finiteness. Both now derive from the equiv, as does anything that
  wants to count points as a subtype of `F × F`.
* `Decidable (Valid a b p)` — sits beside the `OnCurve` instance it
  builds on. This removes the need to write `Or.inl (by decide)` to
  exhibit a representable point, and with it the comment in
  `Encodings/Pasta` explaining why `Valid` could not be decided
  directly.
* `SWPoint.neg_x` / `SWPoint.neg_y` — `(-P).y = -P.y` is `rfl`, but was
  inlined with a "there is no named lemma for it" apology at each use.
  Now there is one.
* `dvd_natCard_of_prime_witness` — the prime-witness half of
  `card_eq_of_prime_witness`, split off so other order-pinning routes
  can share it. Its body also stops hand-rolling Mathlib's
  `addOrderOf_eq_prime`, which is exactly the three lines it spelled out.

No new mathematical results and no statement changes: every existing
theorem keeps its signature, and only proofs and locations move.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fix the Pallas and Vesta group orders to their known primes with no assumption.
A prime-order witness ([order]·G = 𝒪) gives r ∣ #E; it then remains to bound #E.
Mathlib has no Hasse bound for WeierstrassCurve, so use the elementary fibre bound

looser than Hasse (a factor of ~2 rather than 2√q) but unconditional, and enough when
r ≈ #F: Pallas closes directly (#F < r ⇒ #E < 2r), and Vesta additionally rules out

CurveOrder holds the reusable core: Layer 1 pins the order from the witness plus an
upper bound (< 2r, or < 3r without 2-torsion); Layer 2 is the fibre bound. Curves.PastaOrder
instantiates it at the two curves. Every remaining obligation is a closed comparison of

Co-authored-by: Gregor Mitscha-Baude <gregor.mitscha-baude@gmx.at>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
Pin the Pasta group orders without assuming Hasse
Upstream deletes the HasseBound hypothesis entirely: card_eq is now
unconditional via the elementary fibre bound #E <= 2#F + 1 + the prime-order
witness (Vesta's #E = 2p case excluded by -5 not being a cube). Conflicts
resolved by taking upstream's proofs with this fork's absolute field names
(Fp/Fq) substituted for the old role aliases.
The absolute-field-names commit renamed the four role aliases to Fp/Fq in
the generated CompElliptic/Fields/Pasta.lean but never updated
scripts/gen_pasta.py, so the generator-reproducibility CI gate failed once
it ran on a PR. field_block gains an optional fielddoc parameter (the
committed file carries docstrings on the field abbrevs; gen_jubjub.py is
unaffected by the default), and gen_pasta.py emits Fp/Fq throughout.

Verified: both gen_pasta.py and gen_jubjub.py reproduce the committed files
byte-identically under PARI/GP.
@martyall
martyall merged commit c47ad4d into main Jul 16, 2026
2 checks passed
@martyall
martyall deleted the sync-upstream-unconditional-order branch July 17, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants