Repository navigation
Canonical structures and unification: treat all forms of primitive projections alike - #22789
Conversation
bb70f5b to
3f98cdc
Compare
|
@coqbot bench |
3f98cdc to
d0618c4
Compare
|
@coqbot run full ci |
|
🏁 Bench results: INFO: failed to install 🐢 Top 25 slow downs┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 41.2 44.6 3.3609 8.15% 370 coq-fiat-crypto-with-bedrock/src/Stringification/Zig.v.html │ │ 0.232 2.84 2.6087 1123.06% 619 coq-mathcomp-odd-order/theories/PFsection3.v.html │ │ 8.72 10.5 1.7930 20.56% 1332 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 30.0 31.3 1.2590 4.20% 809 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 2.23 3.38 1.1514 51.59% 987 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 2.28 3.40 1.1146 48.79% 1199 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 0.201 1.27 1.0646 530.54% 1156 rocq-mathcomp-group-representation/group_representation/inertia.v.html │ │ 29.0 29.9 0.9300 3.21% 803 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 27.3 28.2 0.9082 3.33% 797 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 0.270 1.10 0.8312 308.09% 2105 coq-mathcomp-odd-order/theories/PFsection13.v.html │ │ 77.8 78.5 0.7713 0.99% 48 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html │ │ 20.1 20.9 0.7660 3.81% 777 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 25.6 26.3 0.7593 2.97% 791 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 78.5 79.3 0.7544 0.96% 22 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html │ │ 1.11 1.69 0.5854 52.79% 1390 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 220 220 0.5693 0.26% 8 coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │ │ 289 290 0.5405 0.19% 3 coq-rewriter-perf-SuperFast/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap/_10_SuperFast.v.html │ │ 19.6 20.1 0.5367 2.74% 669 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 15.8 16.2 0.4489 2.84% 272 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html │ │ 10.5 10.9 0.4376 4.17% 757 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 25.4 25.8 0.4284 1.69% 49 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html │ │ 22.8 23.2 0.3956 1.73% 68 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/VerifyDecode.v.html │ │ 8.38 8.78 0.3955 4.72% 3 coq-performance-tests-lite/PerformanceExperiments/Reify/LtacVariants/_4_SuperFast.v.html │ │ 0.741 1.13 0.3899 52.60% 88 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Platform.v.html │ │ 10.2 10.5 0.3536 3.48% 2325 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlatToRiscvFunctions.v.html │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 7.48 0.0434 -7.4381 -99.42% 127 coq-mathcomp-odd-order/theories/BGappendixAB.v.html │ │ 8.46 5.46 -3.0043 -35.51% 708 rocq-mathcomp-field/field/algebraics_fundamentals.v.html │ │ 2.35 0.0725 -2.2781 -96.92% 405 coq-mathcomp-odd-order/theories/BGappendixC.v.html │ │ 1.67 0.197 -1.4746 -88.24% 423 rocq-mathcomp-group-representation/group_representation/mxabelem.v.html │ │ 6.71 5.25 -1.4642 -21.81% 606 rocq-mathcomp-field/field/algebraics_fundamentals.v.html │ │ 18.1 16.7 -1.3694 -7.57% 572 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 67.2 65.9 -1.2743 -1.90% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 1.29 0.0179 -1.2694 -98.61% 919 coq-mathcomp-odd-order/theories/PFsection12.v.html │ │ 67.1 65.9 -1.2672 -1.89% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 19.4 18.2 -1.1962 -6.16% 560 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 2.62 1.43 -1.1893 -45.45% 67 rocq-mathcomp-group-representation/group_representation/integral_char.v.html │ │ 1.24 0.116 -1.1286 -90.71% 397 coq-mathcomp-odd-order/theories/BGappendixC.v.html │ │ 1.19 0.0732 -1.1195 -93.86% 396 coq-mathcomp-odd-order/theories/BGappendixC.v.html │ │ 1.14 0.0391 -1.0976 -96.56% 151 coq-mathcomp-odd-order/theories/BGappendixAB.v.html │ │ 4.97 3.89 -1.0770 -21.68% 677 rocq-mathcomp-field/field/algebraics_fundamentals.v.html │ │ 1.06 0.168 -0.8960 -84.24% 152 coq-mathcomp-odd-order/theories/BGappendixAB.v.html │ │ 30.1 29.2 -0.8853 -2.94% 150 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 14.5 13.6 -0.8778 -6.06% 383 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html │ │ 1.95 1.10 -0.8506 -43.64% 767 rocq-mathcomp-field/field/algebraics_fundamentals.v.html │ │ 30.3 29.5 -0.8390 -2.77% 159 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 30.0 29.1 -0.8096 -2.70% 200 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 30.1 29.4 -0.7926 -2.63% 168 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 30.0 29.2 -0.7800 -2.60% 182 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 30.1 29.4 -0.7616 -2.53% 141 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 0.850 0.107 -0.7431 -87.45% 315 rocq-mathcomp-field/field/finfield.v.html │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
mattam82
left a comment
There was a problem hiding this comment.
The last commit repairs incompatibilities found in the CI.
|
🏁 Bench results: INFO: failed to install 🐢 Top 25 slow downs┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 0.373 61.3 60.9206 16338.56% 72 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.173 30.7 30.5460 17683.13% 82 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.124 4.53 4.4086 3555.04% 125 coq-iris-examples/theories/logrel/F_mu_ref_conc/unary/logrel.v.html │ │ 0.126 4.47 4.3441 3439.53% 161 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.102 4.32 4.2168 4128.42% 124 coq-iris-examples/theories/logrel/F_mu_ref_conc/unary/logrel.v.html │ │ 0.103 4.22 4.1181 3982.47% 160 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.159 3.54 3.3813 2125.38% 163 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.101 3.05 2.9533 2924.18% 144 coq-iris-examples/theories/logrel/F_mu_ref_conc/unary/logrel.v.html │ │ 0.0896 2.99 2.8957 3232.78% 181 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.0701 2.88 2.8089 4009.78% 143 coq-iris-examples/theories/logrel/F_mu_ref_conc/unary/logrel.v.html │ │ 0.0653 2.80 2.7397 4198.16% 180 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.0733 2.68 2.6106 3561.55% 126 coq-iris-examples/theories/logrel/F_mu_ref_conc/unary/logrel.v.html │ │ 0.240 2.85 2.6098 1087.06% 619 coq-mathcomp-odd-order/theories/PFsection3.v.html │ │ 41.8 44.0 2.2142 5.30% 370 coq-fiat-crypto-with-bedrock/src/Stringification/Zig.v.html │ │ 0.123 2.30 2.1750 1773.18% 183 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 8.36 10.3 1.9657 23.52% 1332 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 30.1 31.7 1.5834 5.25% 809 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 0.0411 1.56 1.5193 3696.53% 145 coq-iris-examples/theories/logrel/F_mu_ref_conc/unary/logrel.v.html │ │ 0.0482 1.42 1.3731 2847.16% 165 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.0467 1.42 1.3701 2934.02% 129 coq-iris-examples/theories/logrel/F_mu_ref_conc/unary/logrel.v.html │ │ 0.0414 1.22 1.1801 2851.38% 134 coq-iris-examples/theories/logrel/F_mu_ref_conc/unary/logrel.v.html │ │ 0.0389 1.21 1.1745 3018.80% 171 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.0880 1.18 1.0878 1235.55% 172 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 29.0 30.1 1.0740 3.70% 803 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 0.0468 1.10 1.0522 2250.30% 148 coq-iris-examples/theories/logrel/F_mu_ref_conc/unary/logrel.v.html │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 7.59 0.0437 -7.5487 -99.42% 127 coq-mathcomp-odd-order/theories/BGappendixAB.v.html │ │ 218 214 -4.2765 -1.96% 8 coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │ │ 8.73 5.58 -3.1504 -36.09% 708 rocq-mathcomp-field/field/algebraics_fundamentals.v.html │ │ 2.36 0.0718 -2.2856 -96.96% 405 coq-mathcomp-odd-order/theories/BGappendixC.v.html │ │ 18.3 16.7 -1.6009 -8.73% 572 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 6.94 5.35 -1.5804 -22.79% 606 rocq-mathcomp-field/field/algebraics_fundamentals.v.html │ │ 19.6 18.1 -1.5557 -7.92% 560 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 1.68 0.193 -1.4885 -88.53% 423 rocq-mathcomp-group-representation/group_representation/mxabelem.v.html │ │ 45.5 44.2 -1.3836 -3.04% 2 coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/fiat_crypto.v.html │ │ 68.5 67.2 -1.3582 -1.98% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 48.0 46.7 -1.3319 -2.77% 3 coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/WithBedrock/fiat_crypto.v.html │ │ 68.6 67.3 -1.2948 -1.89% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 2.70 1.42 -1.2802 -47.44% 67 rocq-mathcomp-group-representation/group_representation/integral_char.v.html │ │ 1.29 0.0197 -1.2657 -98.47% 919 coq-mathcomp-odd-order/theories/PFsection12.v.html │ │ 22.5 21.3 -1.2479 -5.53% 229 coq-unimath/UniMath/CategoryTheory/Presheaves/Sheafification.v.html │ │ 293 292 -1.2422 -0.42% 3 coq-rewriter-perf-SuperFast/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap/_10_SuperFast.v.html │ │ 47.7 46.5 -1.1783 -2.47% 3 coq-performance-tests-lite/PerformanceExperiments/typeclass_reification_let_in_HOAS/_0_SuperFast.v.html │ │ 1.24 0.113 -1.1295 -90.92% 397 coq-mathcomp-odd-order/theories/BGappendixC.v.html │ │ 1.19 0.0720 -1.1142 -93.93% 396 coq-mathcomp-odd-order/theories/BGappendixC.v.html │ │ 1.15 0.0394 -1.1080 -96.57% 151 coq-mathcomp-odd-order/theories/BGappendixAB.v.html │ │ 5.11 4.03 -1.0805 -21.15% 677 rocq-mathcomp-field/field/algebraics_fundamentals.v.html │ │ 47.9 46.8 -1.0056 -2.10% 3 coq-fiat-crypto-with-bedrock/src/ExtractionOCaml/bedrock2_fiat_crypto.v.html │ │ 45.5 44.5 -0.9710 -2.13% 376 coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html │ │ 40.9 39.9 -0.9704 -2.37% 467 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoor.v.html │ │ 30.7 29.7 -0.9520 -3.10% 159 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
6ef91b9 to
6193463
Compare
|
@coqbot run full ci |
|
@coqbot bench |
With rocq-prover/rocq#22789, canonical structure inference and unification treat all forms of a primitive projection alike, so that the records declared with #[primitive] can be used as the other ones: - the terms HB declares use folded primitive projections, as the ones elaborated by Rocq (fold-projections, applied in log.coq.env.add-const*); - clean-op-ty also rewrites operations used as primitive projections; - parametrized mixin-src clauses typecheck the mixin argument; - mixin-for, the non-forgetful inheritance check and HB.pack recognize a sort projection in its primitive form. Records are still non-primitive unless #[primitive] is given. Assisted by GenAI tools
Records are now primitive unless #[primitive=no] is given. tests/hnf: the parameter of the primitive projection f.y is printed as "_". Requires rocq-prover/rocq#22789. Assisted by GenAI tools
|
@coqbot bench |
|
@coqbot run full ci |
A primitive projection appears as a [Proj] node (folded or unfolded), as the application of its compatibility constant, or pending on a reduction stack. Canonical structure inference and coercion classes distinguished them, so that an instance or a coercion declared with one form was not found with another. - Structures: the key of a value headed by the applied compatibility constant of a primitive projection is [Proj_cs], and the stored value is folded. A value which is the projection as a function is eta-contracted to its compatibility constant. - Coercionops: the class of the applied compatibility constant of a primitive projection is [CL_PROJ]. - Evarconv: [decompose_proj] refolds a projection pending on the stack; [check_conv_record] folds the value it looks up, and falls back to the key of the compatibility constant for partial applications; the keys cache records [Proj] heads. Two different forms of the same projection are compared as such, after unifying the types of their records, which stand for the parameters the primitive form does not carry. - Evarconv: canonical structure inference is tried for a projection stuck on an evar before the other side is unfolded. The steps which relate two forms of a projection through their records are only taken when canonical structure inference may have to solve a problem on the record: the projection has canonical instances, or its record is itself headed by such a projection ([Structures.CSTable.has_canonical_instances]; the projections which have instances are kept in the summary, next to the table of instances). Developments using primitive records without canonical structures (HoTT, UniMath, category-theory) rely on the other projections being reduced at once. When both sides have the same projection pending on their stacks and the stacks fail to unify, the failure is remembered: stacks ending with them are not unified again while the records are unfolded, as a projection constant is unified first-order once before being unfolded. Assisted by GenAI tools
Typeclass resolution, apply and rewrite use the unification of tactics, which finds the instance of a meta by unfolding both sides of a problem step by step. Unfolding a projection constant leaves a [match] without a key, so the other side is unfolded next; a primitive projection always had a key and its expansion reduced it completely, so one side was unfolded to the end, metas got unfolded instances and canonical structure inference no longer saw the record. For a primitive projection which has canonical instances (see [Structures.CSTable.has_canonical_instances]), and only for those: - Expanding a folded projection only unfolds it. The unfolded projection is still a key, expanded by reducing it, but it comes after any other key, as the [match] of a projection constant does. - As in Evarconv, the term a side was before being reduced or unfolded is remembered when it is headed by such a projection. When the other side becomes flexible (a meta or an evar, possibly applied), it is unified with that term first, and with its reduct only if this fails. - Failing problems are not explored again: unfolding the projection changes neither the first-order problem, nor canonical structure inference, nor the reduction of the other side, so only the reduction of the unfolded projection is tried. While that reduction is pending, an unfolding of the other side only matters when it exposes the same projection (tried first-order and with canonical structures), a projection canonical structure inference applies to, or a meta or an evar ([unify_pending_projection]). Otherwise two chains of definitions going through such projections, e.g. the ones of ofe and bi in Iris, were explored in every interleaving. Besides: - The instances the arguments of a canonical instance get while the canonical solution is unified are compared at once, instead of when the whole unification is over, so that the other steps are tried when they are inconsistent. - [whd_betaiota_deltazeta_for_iota_state] knows the values of metas: the kernel machine is resumed on the value of a meta when it is stuck on one. Assisted by GenAI tools
- Count the arguments of canonical projection patterns and of instance values in both forms of a primitive projection. - Folded and unfolded projections are the same head; a structure projection head asks for canonical structure inference or reduction as a projection constant does. - Unify the terms before their types when a projection is involved: the type of a primitive projection does not determine its parameters. Assisted by GenAI tools
The bench builds rocq-mathcomp-analysis, with rocq-mathcomp-classical and rocq-mathcomp-reals as dependencies from the same repository: map the analysis CI project to them so that a PR overlay is used. Assisted by GenAI tools
Overlay, for Hierarchy Builder structures declared as primitive records: - hierarchy-builder: math-comp/hierarchy-builder#610 The changes elpi, math-comp and mathcomp-analysis need were merged (LPCIC/coq-elpi#1143, math-comp/math-comp#1691, math-comp/analysis#2181). Assisted by GenAI tools
|
@coqbot run full ci |
|
@coqbot bench |
|
🏁 Bench results: 🐢 Top 25 slow downs┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 24.4 26.0 1.6261 6.66% 359 rocq-iris/iris/algebra/view.v.html │ │ 49.8 50.9 1.1270 2.26% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 50.2 51.0 0.8400 1.67% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 65.7 66.4 0.6547 1.00% 302 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/Addchain.v.html │ │ 31.1 31.7 0.6382 2.05% 197 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html │ │ 37.4 38.0 0.6052 1.62% 116 coq-bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html │ │ 35.2 35.7 0.4752 1.35% 27 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html │ │ 0.471 0.925 0.4536 96.28% 1732 rocq-mathcomp-analysis/theories/realfun.v.html │ │ 0.478 0.926 0.4471 93.44% 1727 rocq-mathcomp-analysis/theories/realfun.v.html │ │ 6.70 7.15 0.4451 6.64% 820 coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/NNORecursiveMap.v.html │ │ 30.0 30.4 0.4262 1.42% 96 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/VerifyDecode.v.html │ │ 17.4 17.8 0.4063 2.33% 708 coq-fiat-crypto-with-bedrock/src/Rewriter/RulesProofs.v.html │ │ 18.9 19.3 0.4016 2.12% 1073 rocq-metarocq-safechecker/_build/default/theories/SafeChecker/PCUICSafeReduce.v.html │ │ 0.0904 0.461 0.3704 409.83% 886 coq-mathcomp-odd-order/theories/PFsection4.v.html │ │ 43.6 43.9 0.3609 0.83% 52 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 37.7 38.1 0.3580 0.95% 116 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html │ │ 25.7 26.1 0.3450 1.34% 310 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/Addchain.v.html │ │ 17.7 18.1 0.3209 1.81% 978 coq-category-theory/Instance/Grp/Colimit/Presentation.v.html │ │ 0.305 0.616 0.3112 102.01% 1570 rocq-mathcomp-analysis/theories/realfun.v.html │ │ 8.75 9.06 0.3100 3.54% 3 coq-performance-tests-lite/PerformanceExperiments/Reify/Ltac2/_5_SuperFast.v.html │ │ 25.8 26.2 0.3080 1.19% 334 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord.v.html │ │ 43.3 43.6 0.3075 0.71% 52 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 0.312 0.612 0.2998 96.16% 1577 rocq-mathcomp-analysis/theories/realfun.v.html │ │ 25.6 25.9 0.2951 1.15% 258 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord.v.html │ │ 11.2 11.5 0.2831 2.52% 3 coq-performance-tests-lite/PerformanceExperiments/Reify/Ltac2/_4_SuperFast.v.html │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 10.6 0.297 -10.2980 -97.20% 2108 rocq-mathcomp-analysis/theories/ftc.v.html │ │ 8.80 0.301 -8.4976 -96.58% 245 rocq-mathcomp-analysis/theories/gauss_integral.v.html │ │ 7.48 0.0425 -7.4398 -99.43% 127 coq-mathcomp-odd-order/theories/BGappendixAB.v.html │ │ 4.96 0.191 -4.7655 -96.14% 2061 rocq-mathcomp-analysis/theories/ftc.v.html │ │ 8.24 5.37 -2.8697 -34.84% 708 rocq-mathcomp-field/field/algebraics_fundamentals.v.html │ │ 2.89 0.565 -2.3256 -80.45% 1324 rocq-mathcomp-analysis/theories/realfun.v.html │ │ 3.50 1.18 -2.3204 -66.25% 184 rocq-mathcomp-analysis/theories/topology_theory/function_spaces.v.html │ │ 2.88 0.564 -2.3190 -80.43% 1327 rocq-mathcomp-analysis/theories/realfun.v.html │ │ 2.32 0.0688 -2.2560 -97.04% 405 coq-mathcomp-odd-order/theories/BGappendixC.v.html │ │ 19.7 17.9 -1.7328 -8.81% 560 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 8.91 7.19 -1.7171 -19.28% 1332 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 2.61 0.926 -1.6815 -64.48% 393 rocq-mathcomp-analysis/theories/elementary_functions/trigonometry_functions.v.html │ │ 1.99 0.329 -1.6592 -83.45% 1386 rocq-mathcomp-analysis/theories/ftc.v.html │ │ 18.0 16.4 -1.6403 -9.11% 572 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 4.18 2.56 -1.6193 -38.76% 260 coq-unimath/UniMath/CategoryTheory/Monoidal/RezkCompletion/LiftedMonoidal.v.html │ │ 1.98 0.403 -1.5762 -79.63% 2847 rocq-mathcomp-analysis/theories/realfun.v.html │ │ 1.98 0.403 -1.5735 -79.61% 2856 rocq-mathcomp-analysis/theories/realfun.v.html │ │ 1.70 0.193 -1.5049 -88.61% 423 rocq-mathcomp-group-representation/group_representation/mxabelem.v.html │ │ 2.27 0.852 -1.4145 -62.40% 1222 rocq-mathcomp-analysis/theories/normedtype_theory/tvs.v.html │ │ 6.60 5.30 -1.2961 -19.65% 606 rocq-mathcomp-field/field/algebraics_fundamentals.v.html │ │ 1.77 0.478 -1.2944 -73.02% 2888 rocq-mathcomp-analysis/theories/realfun.v.html │ │ 1.26 0.0169 -1.2474 -98.66% 919 coq-mathcomp-odd-order/theories/PFsection12.v.html │ │ 2.65 1.44 -1.2159 -45.80% 67 rocq-mathcomp-group-representation/group_representation/integral_char.v.html │ │ 1.46 0.263 -1.1988 -82.00% 2331 rocq-mathcomp-analysis/theories/realfun.v.html │ │ 1.44 0.250 -1.1873 -82.60% 2309 rocq-mathcomp-analysis/theories/realfun.v.html │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
|
Note that the iris slowdown is likely due to the fact that it is very sensitive to TC resolution of classes with primitive projections. I suspect that #22934 will help tremendously here, at the very least it will hide the slowdown in the big speedup and may even cancel it completely as most TC resolutions of primitive records are just skipped. |
|
Yes, indeed. It's unification through typeclass resolution going through the new paths, which I tried to cut as much as possible while staying correct/return the same unifiers as evar_conv did. |
| (* The primitive projections which have an entry in [object_table], through | ||
| their compatibility constant: this is asked at each step of unification *) | ||
| let prim_projections_table = | ||
| Summary.ref (ProjReprMap.empty : unit ProjReprMap.t) |
There was a problem hiding this comment.
a map to unit is better done with a set
There was a problem hiding this comment.
but we don't have set in the quotiented apis
|
@coqbot merge now |
|
@SkySkimmer: Please take care of the following overlays:
|
With rocq-prover/rocq#22789, canonical structure inference and unification treat all forms of a primitive projection alike, so that the records declared with #[primitive] can be used as the other ones: - the terms HB declares use folded primitive projections, as the ones elaborated by Rocq (fold-projections, applied in log.coq.env.add-const*); - clean-op-ty also rewrites operations used as primitive projections; - parametrized mixin-src clauses typecheck the mixin argument; - mixin-for, the non-forgetful inheritance check and HB.pack recognize a sort projection in its primitive form. Records are still non-primitive unless #[primitive] is given. Assisted by GenAI tools
With rocq-prover/rocq#22789, canonical structure inference and unification treat all forms of a primitive projection alike, so that the records declared with #[primitive] can be used as the other ones: - the terms HB declares use folded primitive projections, as the ones elaborated by Rocq (fold-projections, applied in log.coq.env.add-const*); - clean-op-ty also rewrites operations used as primitive projections; - parametrized mixin-src clauses typecheck the mixin argument; - mixin-for, the non-forgetful inheritance check and HB.pack recognize a sort projection in its primitive form. Records are still non-primitive unless #[primitive] is given. Assisted by GenAI tools
This change was originally part of my universes-and-variances branch (initial evarconv refolding code by me), as using primitive projections for structures is necessary to get the right cumulativity constraints on packed classes but it's also a general purpose improvement: CS + primproj work better together, unification and evarconv have closer strategies for finding a solution to a CS problem (without disturbing the previous unification.ml behaviour too much) and ssrmatching can really match primproj-headed patterns up-to CS resolution. The speedup for math-comp is significant: around 10% overall.
A primitive projection appears in three forms: a
Projnode (folded or unfolded), the application of its compatibility constant, and a projection pending on a reduction stack. Canonical structure inference, coercion classes, the unification of tactics and the ssreflect matcher treated these forms differently, so that an instance, a coercion or a pattern given in one form was not found in another. This PR makes them agree, with the aim of letting Hierarchy Builder declare its structures, mixins and factories as primitive records.With the overlays below, math-comp, odd-order, finmap, bigenough and mathcomp-analysis build with primitive HB records.
Commits
Structureskeys and folds values headed by the compatibility constant asProj_cs;Coercionopsgives them the classCL_PROJ;Evarconvrefolds projections pending on the stack, tries canonical structure inference for a projection stuck on an evar before unfolding the other side, and compares two forms of the same projection through their records.The new steps of commits 1 and 2 only apply to projections of structures which have canonical instances (
Structures.CSTable.has_canonical_instances). Other primitive projections are unified as on master: HoTT, UniMath and category-theory rely on that.Which primitive projections have canonical instances is asked at each step of unification, so it is precomputed: a summary table next to the table of instances, filled where instances are registered. It is a
unit Environ.QProjection.Repr.Map.trather than aNames.PRset.tbecause the environment-aware name modules only provide maps, and the table of instances is itself looked up throughEnviron.QGlobRef.Map. The two are equivalent as long as these modules are implemented over user names.Overlays
#[primitive=no]is given. The second commit needs this PR.Timings
Bench with the overlays (job 8411410, user time and instructions against master): mathcomp-analysis −15.7% (−22.2%), odd-order −12.2% (−15.5%), group-representation −11.0% (−14.9%), field −10.4% (−13.6%), finite-group −6.2%, solvable −5.6%, algebra −2.3%, order and boot unchanged; iris_examples +4.6% (+4.4%).
The gains come from the primitive HB records: without the overlays, the math-comp packages are within +1.2% in instructions (local run), and this PR builds math-comp master with non-primitive records.
Known limitations
logrel/F_mu_ref_conc/{binary,unary}/logrel.v(about +12% each): failingPropercandidates are unified through two chains of projections (ofe_equiv,bi_equiv, ...), and the slowest sentence takes 45k unification steps against 28k on master.lebesgue_integral_fubini.vin mathcomp-analysis take 0.34 s against 0.15 s on master (local measurement).