Skip to content

feat(theories): make FinType.card abstract, specified by card_spec - #1224

Open
mattc-try wants to merge 1 commit into
EasyCrypt:mainfrom
mattc-try:feat/fintype-abstract-card
Open

mattc-try wants to merge 1 commit into
EasyCrypt:mainfrom
mattc-try:feat/fintype-abstract-card

Conversation

@mattc-try

Copy link
Copy Markdown

Closes #1223.

What: FinType.card is now an abstract operator with axiom card_spec : card = size enum (order_spec in CyclicGroup). This allows CyclicGroup clones with an abstract order, e.g. two groups sharing one order and one ZModE for a pairing (tests/fintype-shared-card.ec, which hits anomaly: CoreIncompatible on main).

Stdlib adaptations (12 files): proofs that unfolded or folded card/order use card_spec/order_spec; proof * clones that fixed enum also fix card; clones that already set card discharge card_spec. The commit message lists the affected theories.

Testing: make unit, make stdlib and make examples pass on this branch and on main (e704d26) with the provers pinned in easycrypt.project (CVC5 1.1.2, Z3 4.16.0, Alt-Ergo 2.6.4). The new test passes here and fails on main.

Breaking change / external projects (run locally against each project's current default branch):

  • jasmin eclib, sha3: unaffected.
  • cryptobox: one failure (Cryptobox.ec:1248) that also occurs with main, so unrelated.
  • xsalsa (2 files), formosa-xmss (2 files), formosa-slh-dsa (6 files): break, and pass with small patches. Almost all are FinType clones under proof * that set enum but not card; the fix is op card <= size (<same list>) plus realize card_spec. Two slh-dsa proofs also need card_spec passed to smt.

The patches are ready; we can send them to the maintainers or provide them as merge-feat/fintype-abstract-card branches, whichever you prefer.

`FinType.card` was defined as `size enum`. A clone can only override a
defined operator by a convertible term, so a `CyclicGroup` could not be
given an abstract order: two cyclic groups of the same order `p`
sharing one exponent ring, as needed for a pairing, could not be
stated. On `main`, `clone CyclicGroup with op order <= p` fails with
the anomaly `EcTheoryReplay.CoreIncompatible`.

`card` is now an abstract operator specified by
`axiom card_spec : card = size enum`. This is a conservative extension:
interpreting `card` as `size enum` recovers the previous theory. In
`CyclicGroup` the axiom is `order_spec`.

Proofs that unfolded or folded `card` (or `order`), explicitly or by
conversion, now rewrite with `card_spec` (FinType, Group, Distr,
Tuple). Clones under `proof *` that fixed `enum` now also fix `card`
and realize `card_spec` (FinProdType, ZModPCyclic, DZmodP,
FiniteEager in ROM, the three clones in Word, and the ChaChaPoly and
MEE-CBC examples). Clones that already set `card` discharge
`card_spec` instead of leaving it as an axiom (Bool, DBool, DWord,
BitWord).

Downstream developments need the same adaptations: rewrite with
`card_spec` (or pass it to `smt`) where `card` was unfolded, and
define `card` in `FinType` clones under `proof *`.

Test: tests/fintype-shared-card.ec.

Co-authored-by: Thomas Haines <907287+gerlion@users.noreply.github.com>
@oskgo

oskgo commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

You can already get this behaviour by introducing an abstract enum, axiomatizing it's order to be p and then instantiating the theory with enum.

I think that leaving both p and enum abstract is worse than what we have currently, but an alternative design where enum is made concrete using the choice operator could be considered.

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.

Cannot clone CyclicGroup with an abstract order (needed for pairings): anomaly CoreIncompatible

2 participants