Repository navigation
Conversation
`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>
|
You can already get this behaviour by introducing an abstract I think that leaving both |
|
Hello @oskgo, I agree this works for independent groups. I think perhaps the issue/PR did not make clear enough that sharing is the problem In the pairing setting the second group must reuse the first group's exponents ( Variants fail the same way, e.g. building the exponent ring first with Our PR fixes this. I agree it is extra work for every As for your alternative i'm not sure I understand your idea: do you mean Happy to rework the PR in that direction if the maintainers prefer it. |
|
Making both I now understand the use case of having isomorphic, but not equal, groups with a convertible theory of exponents. I agree that we should support this. Maybe it would be better to keep the additional abstract declaration in the theory we want to be convertible? We can stop instantiating |
|
@strub what are your thoughts on this? (Other than "We should really do this with typeclasses.") |
Closes #1223.
What:
FinType.cardis now an abstract operator withaxiom card_spec : card = size enum(order_specinCyclicGroup). This allowsCyclicGroupclones with an abstract order, e.g. two groups sharing one order and oneZModEfor a pairing (tests/fintype-shared-card.ec, which hitsanomaly: CoreIncompatibleonmain).Stdlib adaptations (12 files): proofs that unfolded or folded
card/orderusecard_spec/order_spec;proof *clones that fixedenumalso fixcard; clones that already setcarddischargecard_spec. The commit message lists the affected theories.Testing:
make unit,make stdlibandmake examplespass on this branch and onmain(e704d26) with the provers pinned ineasycrypt.project(CVC5 1.1.2, Z3 4.16.0, Alt-Ergo 2.6.4). The new test passes here and fails onmain.Breaking change / external projects (run locally against each project's current default branch):
Cryptobox.ec:1248) that also occurs withmain, so unrelated.FinTypeclones underproof *that setenumbut notcard; the fix isop card <= size (<same list>)plusrealize card_spec. Two slh-dsa proofs also needcard_specpassed tosmt.The patches are ready; we can send them to the maintainers or provide them as
merge-feat/fintype-abstract-cardbranches, whichever you prefer.