Add a generic mechanism for rewriting with any equality satisfying J#21098
Conversation
5d85858 to
04fdca3
Compare
|
@coqbot run full ci |
04fdca3 to
9e27b8c
Compare
a30387b to
428b37f
Compare
|
@coqbot run full ci |
428b37f to
e8c319f
Compare
|
@coqbot run full ci |
3 similar comments
|
@coqbot run full ci |
|
@coqbot run full ci |
|
@coqbot run full ci |
|
@coqbot bench |
|
🏁 Bench results: INFO: failed to install rocq-mathcomp-boot (dependency rocq-elpi failed) 🐢 Top 25 slow downs┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 199 201 2.1591 1.08% 8 coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │ │ 31.994 34.148 2.1540 6.73% 97 coq-vst/veric/binop_lemmas5.v.html │ │ 63.6 65.5 1.8356 2.88% 608 coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html │ │ 23.3 25.0 1.6496 7.07% 129 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/Projective.v.html │ │ 94.7 95.7 1.0085 1.06% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 38.96 39.582 0.6220 1.60% 834 coq-vst/veric/binop_lemmas4.v.html │ │ 42.6 43.2 0.6118 1.44% 2 coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/fiat_crypto.v.html │ │ 3.26 3.87 0.6035 18.49% 557 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html │ │ 94.8 95.3 0.4873 0.51% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 82.7 83.1 0.4097 0.50% 48 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html │ │ 44.7 45.1 0.4060 0.91% 3 coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/WithBedrock/fiat_crypto.v.html │ │ 8.56 8.96 0.3947 4.61% 1154 coq-fiat-crypto-with-bedrock/src/Assembly/WithBedrock/SymbolicProofs.v.html │ │ 1.79 2.19 0.3946 22.04% 148 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoorTop.v.html │ │ 0.431 0.825 0.3938 91.33% 300 coq-fiat-crypto-with-bedrock/src/Curves/Montgomery/XZProofs.v.html │ │ 0.171 0.517 0.3462 202.18% 374 rocq-stdlib/theories/Sorting/SetoidList.v.html │ │ 0.299 0.644 0.3451 115.58% 719 rocq-stdlib/theories/MSets/MSetRBT.v.html │ │ 21.5 21.9 0.3333 1.55% 49 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html │ │ 36.3 36.6 0.3157 0.87% 139 coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html │ │ 3.847 4.161 0.3140 8.16% 477 coq-vst/veric/expr_lemmas3.v.html │ │ 2.06 2.36 0.2981 14.47% 469 rocq-metarocq-safechecker/safechecker/theories/PCUICEqualityDec.v.html │ │ 6.45 6.75 0.2977 4.62% 476 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/RupicolaCrypto/ChaCha20.v.html │ │ 42.2 42.4 0.2891 0.69% 246 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html │ │ 12.3 12.6 0.2771 2.26% 505 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlatToRiscvCommon.v.html │ │ 10.1 10.3 0.2768 2.75% 417 coq-fiat-crypto-with-bedrock/src/Bedrock/Group/ScalarMult/MontgomeryLadder.v.html │ │ 30.3 30.6 0.2733 0.90% 148 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 180 175 -4.8737 -2.70% 233 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/DecodeByExtension.v.html │ │ 6.59 5.22 -1.3740 -20.84% 130 coq-category-theory/Functor/Strong/Product.v.html │ │ 2.57 1.35 -1.2205 -47.55% 549 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html │ │ 237 236 -0.9321 -0.39% 141 coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html │ │ 35.189 34.349 -0.8400 -2.39% 147 coq-vst/veric/expr_lemmas4.v.html │ │ 34.098 33.37 -0.7280 -2.14% 194 coq-vst/veric/expr_lemmas4.v.html │ │ 64.8 64.3 -0.5370 -0.83% 716 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JacobianCoZ.v.html │ │ 4.55 4.02 -0.5294 -11.64% 492 rocq-stdlib/theories/Reals/Cauchy/ConstructiveCauchyRealsMult.v.html │ │ 94.1 93.5 -0.5173 -0.55% 20 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/NBE.v.html │ │ 30.9 30.4 -0.4708 -1.53% 225 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html │ │ 134 133 -0.4701 -0.35% 155 coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html │ │ 2.76 2.33 -0.4366 -15.80% 240 coq-category-theory/Construction/Comma/Adjunction.v.html │ │ 119 119 -0.4216 -0.35% 22 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html │ │ 15.1 14.7 -0.4171 -2.77% 841 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/Jacobian/CoZ.v.html │ │ 31.3 30.9 -0.4155 -1.33% 334 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord.v.html │ │ 25.3 24.9 -0.3863 -1.53% 226 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html │ │ 1.51 1.13 -0.3741 -24.83% 1142 rocq-stdlib/theories/FSets/FMapAVL.v.html │ │ 2.61 2.24 -0.3715 -14.24% 275 coq-category-theory/Construction/Comma/Adjunction.v.html │ │ 38.6 38.2 -0.3714 -0.96% 1423 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlatToRiscvFunctions.v.html │ │ 63.8 63.4 -0.3671 -0.58% 608 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html │ │ 36.4 36.1 -0.3294 -0.91% 224 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html │ │ 42.2 41.9 -0.3207 -0.76% 223 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html │ │ 38.2 38.0 -0.2818 -0.74% 224 coq-performance-tests-lite/PerformanceExperiments/rewrite_lift_lets_map.v.html │ │ 19.8 19.5 -0.2810 -1.42% 227 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html │ │ 0.604 0.330 -0.2744 -45.41% 1 rocq-stdlib/theories/Reals/Cauchy/ConstructiveExtra.v.html │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
|
@coqbot run full ci |
|
@ppedrot The PR is ready for review. |
|
bedrock2 should be automatically bumped in rupicola and then in fiat-crypto within the next 24h, then the update will show here |
|
@coqbot run full ci |
|
@coqbot bench |
|
🏁 Bench results: INFO: failed to install 🐢 Top 25 slow downs┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 31.976 33.552 1.5760 4.93% 97 coq-vst/veric/binop_lemmas5.v.html │ │ 176 177 1.4110 0.80% 233 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/DecodeByExtension.v.html │ │ 38.878 39.742 0.8640 2.22% 834 coq-vst/veric/binop_lemmas4.v.html │ │ 94.5 95.3 0.7826 0.83% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 236 237 0.7805 0.33% 141 coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html │ │ 94.8 95.5 0.7139 0.75% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 44.2 44.9 0.6290 1.42% 578 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/MMIO.v.html │ │ 82.4 83.1 0.6197 0.75% 48 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html │ │ 0.0167 0.613 0.5962 3569.25% 263 coq-mathcomp-analysis/theories/hoelder.v.html │ │ 32.1 32.7 0.5850 1.82% 121 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 31.1 31.6 0.5682 1.83% 148 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 31.0 31.6 0.5626 1.81% 214 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 30.8 31.4 0.5621 1.82% 139 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 30.9 31.4 0.5550 1.80% 157 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 30.9 31.4 0.5323 1.72% 166 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 31.0 31.5 0.5288 1.71% 180 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 0.000923 0.513 0.5126 55532.94% 219 coq-mathcomp-analysis/theories/ess_sup_inf.v.html │ │ 0.000889 0.492 0.4908 55205.96% 464 coq-mathcomp-analysis/theories/normedtype_theory/ereal_normedtype.v.html │ │ 0.000779 0.486 0.4855 62317.20% 36 coq-mathcomp-analysis/theories/measure_theory/dirac_measure.v.html │ │ 30.8 31.3 0.4819 1.56% 198 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 33.64 34.086 0.4460 1.33% 194 coq-vst/veric/expr_lemmas4.v.html │ │ 34.753 35.168 0.4150 1.19% 147 coq-vst/veric/expr_lemmas4.v.html │ │ 21.6 22.0 0.3843 1.78% 49 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html │ │ 36.9 37.3 0.3779 1.02% 139 coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html │ │ 0.00276 0.369 0.3665 13268.43% 88 rocq-mathcomp-field/field/finfield.v.html │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 202 200 -1.2010 -0.60% 8 coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │ │ 12.1 11.0 -1.0892 -9.03% 194 coq-fiat-crypto-with-bedrock/src/Fancy/Barrett256.v.html │ │ 64.8 63.7 -1.0740 -1.66% 608 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html │ │ 119 119 -0.8236 -0.69% 22 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html │ │ 59.9 59.1 -0.8029 -1.34% 27 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html │ │ 52.5 51.7 -0.7778 -1.48% 526 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/EdwardsXYZT.v.html │ │ 93.9 93.3 -0.6548 -0.70% 20 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/NBE.v.html │ │ 29.8 29.2 -0.6369 -2.14% 715 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 19.0 18.4 -0.6189 -3.26% 31 coq-engine-bench-lite/coq/PerformanceDemos/pattern.v.html │ │ 64.7 64.1 -0.5792 -0.90% 608 coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html │ │ 7.74 7.21 -0.5385 -6.95% 602 coq-unimath/UniMath/CategoryTheory/EnrichedCats/Limits/Examples/StructureEnrichedLimits.v.html │ │ 65.0 64.5 -0.5019 -0.77% 716 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JacobianCoZ.v.html │ │ 13.4 12.9 -0.4942 -3.69% 269 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html │ │ 45.3 44.9 -0.4939 -1.09% 3 coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/WithBedrock/fiat_crypto.v.html │ │ 0.494 0.000483 -0.4930 -99.90% 465 coq-mathcomp-analysis/theories/normedtype_theory/ereal_normedtype.v.html │ │ 1.80 1.35 -0.4435 -24.69% 70 rocq-mathcomp-algebra/algebra/qpoly.v.html │ │ 24.1 23.7 -0.3993 -1.66% 85 coq-fiat-crypto-with-bedrock/src/Curves/Montgomery/AffineProofs.v.html │ │ 1.16 0.775 -0.3856 -33.22% 215 rocq-stdlib/theories/setoid_ring/Ncring_tac.v.html │ │ 36.8 36.4 -0.3779 -1.03% 553 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/EdwardsXYZT.v.html │ │ 0.532 0.156 -0.3758 -70.67% 586 rocq-stdlib/theories/Strings/Byte.v.html │ │ 4.40 4.02 -0.3755 -8.54% 199 coq-fiat-crypto-with-bedrock/src/Fancy/Montgomery256.v.html │ │ 0.750 0.375 -0.3749 -49.97% 14 rocq-stdlib/theories/extraction/ExtrOcamlZBigInt.v.html │ │ 0.369 0.00175 -0.3669 -99.53% 89 rocq-mathcomp-field/field/finfield.v.html │ │ 45.4 45.0 -0.3668 -0.81% 3 coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/bedrock2_fiat_crypto.v.html │ │ 7.45 7.08 -0.3623 -4.87% 604 coq-unimath/UniMath/CategoryTheory/EnrichedCats/Colimits/Examples/StructureEnrichedColimits.v.html │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
|
@coqbot run full ci |
|
@coqbot run full ci |
|
@coqbot run full ci |
|
@coqbot merge now |
|
@ppedrot: Please take care of the following overlays:
|
This PR has a mechanism to make rewrite and discrimante parametrized over any equality satisfying reflexivity and Martin-Löf style J eliminator. The (ad-hoc) parametrization is done using typeclass inference.
This PR is on top of #21161 which provides a way to use the typeclass system on a different DB than
typeclass_instances. For equality, we use the DBrewrite_instances. This avoids being sensitive to the local content of typeclass_instances.Instead of having simply on class for J, we support all the variants used by rewrite (e.g., non-dependent, _r , forward, and so on) for backward compatibility.
Note some for some use cases, supporting those variants is crucial for the guard condition as a rewritten term is a substerm only if the rewriting occurs as a direct pattern-matching (hence for instance the tricky definition of eq_rect_r_dep).
Previously, all those subtleties were handle under the hood by generating internal_rew_... scheme on the fly.
We can now rewrite with an equality where the transport is not based on matching (see for instance Observational.v in the test-suite).
For backward compatibility reason,
eq_rec_ris now a annotation overeq_rect_r.Overlays (to be merged before the current PR)