Skip to content

Guard against parser modification in interp phase #20674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SkySkimmer
Copy link
Contributor

@SkySkimmer SkySkimmer added the request: full CI Use this label when you want your next push to trigger a full CI. label May 23, 2025
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label May 23, 2025
@SkySkimmer
Copy link
Contributor Author

@coqbot bench

@SkySkimmer SkySkimmer added the request: full CI Use this label when you want your next push to trigger a full CI. label May 23, 2025
@SkySkimmer SkySkimmer force-pushed the stronger-synterp-flag branch from 8829df4 to 3b084a5 Compare May 23, 2025 14:14
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label May 23, 2025
@SkySkimmer
Copy link
Contributor Author

@coqbot bench

@rocq-prover rocq-prover deleted a comment from coqbot-app bot May 23, 2025
@rocq-prover rocq-prover deleted a comment from coqbot-app bot May 23, 2025
@SkySkimmer
Copy link
Contributor Author

SkySkimmer commented May 23, 2025

@gares I get this error in elpi tests which does seem like a bug in elpi:

File "./tests/test_tactic.v", line 321, characters 0-113:
Error: Anomaly "The grammar cannot be modified during the interp phase."
Please report at http://rocq-prover.org/bugs/.
Raised at Exninfo.iraise in file "clib/exninfo.ml", line 79, characters 4-11
Called from Procq.modify_state_unsync in file "parsing/procq.ml", line 86, characters 2-19
Called from Lib.add_leaf in file "library/lib.ml", line 516, characters 2-39
Called from Elpi_plugin__Rocq_elpi_builtins.coq_rest_builtins.(fun) in file "src/rocq_elpi_builtins.ml", line 3467, characters 6-86

full backtrace

File "./tests/test_tactic.v", line 321, characters 0-113:
Error: Anomaly "The grammar cannot be modified during the interp phase."
Please report at http://rocq-prover.org/bugs/.
Raised at Exninfo.iraise in file "clib/exninfo.ml", line 79, characters 4-11
Called from Procq.modify_state_unsync in file "parsing/procq.ml", line 86, characters 2-19
Called from Lib.add_leaf in file "library/lib.ml", line 516, characters 2-39
Called from Elpi_plugin__Rocq_elpi_builtins.coq_rest_builtins.(fun) in file "src/rocq_elpi_builtins.ml", line 3467, characters 6-86
Called from Elpi_plugin__Rocq_elpi_builtins.grab_global_env.(fun) in file "src/rocq_elpi_builtins.ml", line 141, characters 33-44
Called from Elpi_runtime__Runtime_trace_off.FFI.wrap_type_err in file "src/runtime/runtime_trace_off.ml", line 2125, characters 6-9
Called from Elpi_runtime__Runtime_trace_off.FFI.call.aux in file "src/runtime/runtime_trace_off.ml", line 2207, characters 32-92
Called from Elpi_runtime__Runtime_trace_off.FFI.call in file "src/runtime/runtime_trace_off.ml", line 2299, characters 21-70
Called from Elpi_runtime__Runtime_trace_off.Constraints.exect_builtin_predicate in file "src/runtime/runtime_trace_off.ml", line 3565, characters 20-83
Called from Elpi_runtime__Runtime_trace_off.Mainloop.make_runtime.run in file "src/runtime/runtime_trace_off.ml", line 3983, characters 19-90
Called from Elpi_util__Util.Fork.fork.ensure_runtime in file "src/utils/util.ml", line 523, characters 16-19
Re-raised at Elpi_util__Util.Fork.fork.ensure_runtime in file "src/utils/util.ml", line 532, characters 7-14
Called from Elpi_runtime__Runtime_trace_off.mk_outcome in file "src/runtime/runtime_trace_off.ml", line 4265, characters 14-23
Called from Elpi_runtime__Runtime_trace_off.execute_once in file "src/runtime/runtime_trace_off.ml", line 4282, characters 20-242
Re-raised at Elpi_runtime__Runtime_trace_off.execute_once in file "src/runtime/runtime_trace_off.ml", line 4287, characters 2-9
Called from Elpi__API.Execute.once in file "src/API.ml", line 235, characters 40-91
Called from Elpi_plugin__Rocq_elpi_vernacular.Compiler.run in file "src/rocq_elpi_vernacular.ml", line 145, characters 13-55
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Elpi_plugin__Rocq_elpi_vernacular.Compiler.run_and_print in file "src/rocq_elpi_vernacular.ml", line 166, characters 8-38
Called from Option.map in file "clib/option.ml", line 102, characters 19-24
Called from Elpi_plugin__Rocq_elpi_vernacular.Interp.run_in_program in file "src/rocq_elpi_vernacular.ml", line 583, characters 18-62
Called from Vernactypes.vtdefault.(fun) in file "vernac/vernactypes.ml", line 173, characters 34-38
Called from Vernactypes.typed_vernac.(fun) in file "vernac/vernactypes.ml", line 170, characters 65-71
Called from Vernactypes.run.(fun) in file "vernac/vernactypes.ml", line 164, characters 15-32
Called from Vernactypes.combine_runners.(fun) in file "vernac/vernactypes.ml", line 126, characters 16-23
Called from Vernactypes.OpaqueAccess.runner.(fun) in file "vernac/vernactypes.ml", line 114, characters 30-34
Called from Vernactypes.combine_runners.(fun) in file "vernac/vernactypes.ml", line 125, characters 14-100
Called from Vernactypes.combine_runners.(fun) in file "vernac/vernactypes.ml", line 126, characters 16-23
Called from Vernactypes.Proof.runner.(fun) in file "vernac/vernactypes.ml", line 69, characters 30-34
Called from Vernactypes.combine_runners.(fun) in file "vernac/vernactypes.ml", line 125, characters 14-100
Called from Vernactypes.Prog.runner.(fun) in file "vernac/vernactypes.ml", line 27, characters 30-34
Called from Vernactypes.combine_runners.(fun) in file "vernac/vernactypes.ml", line 124, characters 12-173
Called from Vernactypes.combine_runners.(fun) in file "vernac/vernactypes.ml", line 124, characters 12-173
Called from Vernactypes.run in file "vernac/vernactypes.ml", line 163, characters 14-96
Called from Vernacinterp.interp_expr_core in file "vernac/vernacinterp.ml", line 80, characters 60-157
Called from Vernacinterp.interp_expr in file "vernac/vernacinterp.ml", line 49, characters 19-121
Called from Flags.with_modified_ref in file "lib/flags.ml", line 17, characters 14-17
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from VernacControl.under_control in file "vernac/vernacControl.ml", line 203, characters 14-18
Called from Vernacinterp.interp_control_gen in file "vernac/vernacinterp.ml", line 36, characters 4-208
Called from Util.try_finally in file "lib/util.ml", line 133, characters 16-19
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Util.try_finally in file "lib/util.ml", line 137, characters 6-32
Called from Flags.with_modified_ref in file "lib/flags.ml", line 17, characters 14-17
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Vernacinterp.interp_gen in file "vernac/vernacinterp.ml", line 151, characters 16-41
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Vernacinterp.interp in file "vernac/vernacinterp.ml", line 165, characters 15-115
Called from Stm.Reach.known_state.reach.(fun) in file "stm/stm.ml", line 2034, characters 16-43
Called from Stm.State.define in file "stm/stm.ml", line 963, characters 6-10
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Stm.Reach.known_state.reach in file "stm/stm.ml", line 2203, characters 4-105
Called from Stm.observe in file "stm/stm.ml", line 2295, characters 4-60
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Stm.process_transaction in file "stm/stm.ml", line 2540, characters 25-92
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Stm.add in file "stm/stm.ml", line 2639, characters 8-50
Called from Vernac.interp_vernac in file "toplevel/vernac.ml", line 76, characters 28-90
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Flags.with_modified_ref in file "lib/flags.ml", line 17, characters 14-17
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Util.try_finally in file "lib/util.ml", line 133, characters 16-19
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Util.try_finally in file "lib/util.ml", line 137, characters 6-32
Called from Vernac.load_vernac_core.loop in file "toplevel/vernac.ml", line 127, characters 8-774
Called from Vernac.load_vernac_core in file "toplevel/vernac.ml", line 150, characters 6-19
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Vernac.load_vernac in file "toplevel/vernac.ml", line 227, characters 30-83
Called from Ccompile.compile in file "toplevel/ccompile.ml", line 68, characters 18-78
Called from Ccompile.compile in file "toplevel/ccompile.ml", line 107, characters 2-59
Called from Coqc.coqc_main in file "toplevel/coqc.ml", line 38, characters 2-100
Called from Coqc.coqc_run in file "toplevel/coqc.ml", line 54, characters 4-36

The object https://github.com/LPCIC/coq-elpi/blob/fa88643771a2a37eb351f714b04289b73f277b4d/src/rocq_elpi_builtins.ml#L1016-L1018 changes the grammar but is declared Interp and I guess is called from Interp code.

Failure in hb_test goes through the same code

Copy link
Contributor

coqbot-app bot commented May 24, 2025

🏁 Bench results:

┌─────────────────────────────────────┬─────────────────────────┬───────────────────────────────────────┬─────────────────────────┐
│                                     │      user time [s]      │           CPU instructions            │  max resident mem [KB]  │
│                                     │                         │                                       │                         │
│            package_name             │   NEW      OLD    PDIFF │      NEW             OLD        PDIFF │   NEW      OLD    PDIFF │
├─────────────────────────────────────┼─────────────────────────┼───────────────────────────────────────┼─────────────────────────┤
│                      rocq-equations │    8.89     9.05  -1.77 │    63257074003     63209791505   0.07 │  400416   399328   0.27 │
│                      coq-verdi-raft │  532.59   538.89  -1.17 │  3730722742499   3728467105084   0.06 │  853668   847584   0.72 │
│                        coq-coqprime │   51.67    52.12  -0.86 │   357311892673    356767166421   0.15 │  797536   799620  -0.26 │
│             rocq-mathcomp-character │   87.73    88.46  -0.83 │   627108983167    625002510223   0.34 │ 1469600  1471660  -0.14 │
│ coq-neural-net-interp-computed-lite │  233.17   234.76  -0.68 │  2250707085658   2250461365960   0.01 │  875104   875612  -0.06 │
│          rocq-metarocq-translations │   16.23    16.34  -0.67 │   117776320148    117454842928   0.27 │  761612   761888  -0.04 │
│               rocq-mathcomp-algebra │  284.28   286.19  -0.67 │  2151560024964   2148815111186   0.13 │ 1424556  1424256   0.02 │
│                           coq-verdi │   44.14    44.42  -0.63 │   297626882941    297362146644   0.09 │  535164   534652   0.10 │
│               coq-engine-bench-lite │  123.19   123.95  -0.61 │   936765891444    941891220760  -0.54 │ 1097496  1094664   0.26 │
│                        coq-compcert │  308.81   310.05  -0.40 │  2038562224370   2035843281835   0.13 │ 1150844  1152444  -0.14 │
│                         rocq-stdlib │  215.54   216.39  -0.39 │  1372485005344   1369374380270   0.23 │  579932   580508  -0.10 │
│               coq-mathcomp-analysis │  853.28   856.41  -0.37 │  6450539732008   6433452573322   0.27 │ 1861796  1862144  -0.02 │
│                        coq-bedrock2 │  345.84   346.99  -0.33 │  2899879446291   2898274955423   0.06 │  895188   895628  -0.05 │
│              rocq-mathcomp-fingroup │   23.44    23.50  -0.26 │   152418737976    152304538136   0.07 │  531056   530728   0.06 │
│                      coq-coquelicot │   37.87    37.96  -0.24 │   230882364076    230545348119   0.15 │  828432   829760  -0.16 │
│              rocq-mathcomp-solvable │   93.30    93.51  -0.22 │   644192617677    643790703991   0.06 │ 1046312  1046156   0.01 │
│                 rocq-metarocq-pcuic │  654.08   655.32  -0.19 │  4250232488332   4245119879406   0.12 │ 2327288  2327200   0.00 │
│              rocq-metarocq-template │   82.82    82.97  -0.18 │   577583631857    576680129482   0.16 │  995776   997068  -0.13 │
│        coq-fiat-crypto-with-bedrock │ 6144.28  6148.87  -0.07 │ 50124534983125  50102449967416   0.04 │ 3205560  3155232   1.60 │
│                        rocq-runtime │   73.96    74.01  -0.07 │   534593273770    534819462591  -0.04 │  490424   490084   0.07 │
│                        coq-rewriter │  334.76   334.97  -0.06 │  2526650843235   2525434844382   0.05 │ 1306344  1305924   0.03 │
│                         coq-unimath │ 1777.37  1778.20  -0.05 │ 14783625439600  14780607600207   0.02 │ 1037268  1097104  -5.45 │
│             rocq-mathcomp-ssreflect │    1.28     1.28   0.00 │     9270811409      9263285724   0.08 │  551820   551824  -0.00 │
│                rocq-metarocq-common │   42.01    42.00   0.02 │   273485053271    273030223883   0.17 │  916580   914984   0.17 │
│          coq-performance-tests-lite │  893.74   893.41   0.04 │  7271767130419   7267724666931   0.06 │ 1939256  1940292  -0.05 │
│                       coq-fourcolor │ 1326.47  1325.98   0.04 │ 12380450226597  12376645490475   0.03 │  894460   894536  -0.01 │
│                   coq-iris-examples │  362.27   362.12   0.04 │  2400424473822   2397427758228   0.12 │ 1058040  1057068   0.09 │
│                             coq-vst │  871.30   870.76   0.06 │  6595596829197   6591237313870   0.07 │ 2217684  2219128  -0.07 │
│                    coq-fiat-parsers │  278.82   278.63   0.07 │  2156386899071   2153904884738   0.12 │ 2289544  2290524  -0.04 │
│                            coq-hott │  155.30   155.07   0.15 │  1076133985089   1074638721149   0.14 │  486876   485000   0.39 │
│                 coq-category-theory │  613.81   612.72   0.18 │  4539128411199   4536694376734   0.05 │  933132   932832   0.03 │
│                         coq-coqutil │   45.04    44.93   0.24 │   285135836677    284469643738   0.23 │  562236   562640  -0.07 │
│                           coq-color │  253.03   252.37   0.26 │  1592733992887   1589874630315   0.18 │ 1101020  1101548  -0.05 │
│               rocq-metarocq-erasure │  517.05   515.51   0.30 │  3587196407453   3583721918444   0.10 │ 1805588  1804296   0.07 │
│                        rocq-bignums │   30.02    29.93   0.30 │   194080285396    193842614691   0.12 │  484788   484496   0.06 │
│                 rocq-metarocq-utils │   23.19    23.12   0.30 │   152691237322    152410737259   0.18 │  574992   575152  -0.03 │
│                            coq-corn │  682.97   680.51   0.36 │  4691311142914   4686613910187   0.10 │  708600   708748  -0.02 │
│              coq-mathcomp-odd-order │  592.27   589.95   0.39 │  4266493749217   4249784179579   0.39 │ 2239152  2242520  -0.15 │
│         coq-rewriter-perf-SuperFast │  468.95   467.01   0.42 │  3742420428302   3741163572477   0.03 │ 1227720  1267448  -3.13 │
│           rocq-metarocq-safechecker │  346.59   345.04   0.45 │  2615634897025   2613940968031   0.06 │ 1792784  1794812  -0.11 │
│                    coq-math-classes │   87.62    87.21   0.47 │   535736283189    534911241874   0.15 │  513276   513608  -0.06 │
│                           rocq-elpi │   12.76    12.70   0.47 │    91689216057     91680096046   0.01 │  485552   485308   0.05 │
│                       coq-fiat-core │   59.20    58.87   0.56 │   360462274668    359378882192   0.30 │  484924   485004  -0.02 │
│                 rocq-mathcomp-field │  160.71   159.50   0.76 │  1234671694861   1219317458831   1.26 │ 1913404  1912508   0.05 │
│                            coq-core │    2.87     2.84   1.06 │    19834449626     19832227734   0.01 │   96416    96428  -0.01 │
│                           rocq-core │    6.31     6.21   1.61 │    38875464458     38799620792   0.20 │  441740   440124   0.37 │
└─────────────────────────────────────┴─────────────────────────┴───────────────────────────────────────┴─────────────────────────┘

🐢 Top 25 slow downs
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                         TOP 25 SLOW DOWNS                                                         │
│                                                                                                                                   │
│  OLD    NEW    DIFF   %DIFF   Ln                     FILE                                                                         │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│  12.9   13.7  0.8213   6.38%  571  coq-mathcomp-odd-order/theories/PFsection9.v.html                                              │
│  10.3   10.9  0.5898   5.75%  559  coq-mathcomp-odd-order/theories/PFsection9.v.html                                              │
│  44.6   45.1  0.5248   1.18%    3  coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/WithBedrock/fiat_crypto.v.html            │
│  1.53   2.03  0.5035  32.90%   42  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html                       │
│  43.0   43.4  0.4507   1.05%    2  coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/fiat_crypto.v.html                        │
│  78.4   78.8  0.4295   0.55%   48  coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html                        │
│  9.11   9.44  0.3285   3.60%  434  coq-mathcomp-odd-order/theories/PFsection12.v.html                                             │
│  5.30   5.62  0.3248   6.13%  705  rocq-mathcomp-field/field/algebraics_fundamentals.v.html                                       │
│  15.2   15.5  0.2880   1.89%  620  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlattenExpr.v.html        │
│  5.90   6.18  0.2811   4.76%    5  coq-fiat-crypto-with-bedrock/src/Assembly/Parse/Examples/fiat_p256_mul_optimised_seed12.v.html │
│  8.54   8.80  0.2636   3.09%  199  coq-mathcomp-odd-order/theories/PFsection12.v.html                                             │
│  21.0   21.3  0.2600   1.24%  479  rocq-metarocq-erasure/erasure/theories/EWcbvEvalCstrsAsBlocksFixLambdaInd.v.html               │
│  15.4   15.7  0.2465   1.60%  618  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlattenExpr.v.html        │
│  4.33   4.58  0.2438   5.63%  603  rocq-mathcomp-field/field/algebraics_fundamentals.v.html                                       │
│  7.73   7.97  0.2411   3.12%  602  coq-unimath/UniMath/CategoryTheory/EnrichedCats/Limits/Examples/StructureEnrichedLimits.v.html │
│  28.6   28.8  0.2366   0.83%  146  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoorTop.v.html                   │
│  58.3   58.5  0.2330   0.40%   27  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html                       │
│  17.8   18.0  0.2234   1.26%   32  coq-performance-tests-lite/src/pattern.v.html                                                  │
│  26.7   27.0  0.2231   0.83%  149  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoorTop.v.html                   │
│ 0.468  0.690  0.2223  47.55%  340  coq-mathcomp-analysis/theories/lebesgue_measure.v.html                                         │
│  23.1   23.3  0.2022   0.88%   12  coq-fourcolor/theories/proof/job554to562.v.html                                                │
│  3.13   3.33  0.2008   6.41%  674  rocq-mathcomp-field/field/algebraics_fundamentals.v.html                                       │
│ 0.486  0.683  0.1978  40.74%   10  rocq-mathcomp-character/character/vcharacter.v.html                                            │
│  17.1   17.3  0.1817   1.06%   12  coq-fourcolor/theories/proof/job623to633.v.html                                                │
│  9.84   10.0  0.1794   1.82%  279  coq-category-theory/Theory/Metacategory.v.html                                                 │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
🐇 Top 25 speed ups
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                               TOP 25 SPEED UPS                                                                │
│                                                                                                                                               │
│  OLD      NEW      DIFF     %DIFF    Ln                      FILE                                                                             │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│    201       199  -2.0299   -1.01%      8  coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html      │
│   22.1      21.4  -0.7556   -3.41%     49  coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html                            │
│   17.9      17.4  -0.5267   -2.94%     31  coq-engine-bench-lite/coq/PerformanceDemos/pattern.v.html                                          │
│    236       236  -0.5159   -0.22%    141  coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html                         │
│   92.2      91.8  -0.3793   -0.41%     20  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/NBE.v.html                                        │
│   19.3      18.9  -0.3767   -1.95%    481  coq-verdi-raft/theories/RaftProofs/EndToEndLinearizability.v.html                                  │
│    117       117  -0.3607   -0.31%     22  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html                             │
│   21.0      20.6  -0.3570   -1.70%     40  coq-fiat-crypto-with-bedrock/src/PushButtonSynthesis/SolinasReductionReificationCache.v.html       │
│   19.0      18.7  -0.3092   -1.63%    708  coq-fiat-crypto-with-bedrock/src/Rewriter/RulesProofs.v.html                                       │
│   54.0      53.7  -0.3042   -0.56%    424  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/EdwardsXYZT.v.html                         │
│   65.2      64.9  -0.2821   -0.43%    609  coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html                                        │
│   21.6      21.3  -0.2784   -1.29%     24  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/MultiRetSplit.v.html                              │
│   11.8      11.6  -0.2635   -2.23%    388  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/Logic/Existential.v.html           │
│   24.0      23.7  -0.2617   -1.09%    558  coq-bedrock2/bedrock2/src/bedrock2Examples/insertionsort.v.html                                    │
│   15.4      15.1  -0.2576   -1.68%    417  coq-fiat-crypto-with-bedrock/src/Bedrock/Group/ScalarMult/MontgomeryLadder.v.html                  │
│   11.9      11.7  -0.2468   -2.07%    324  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/Logic/Existential.v.html           │
│   6.70      6.46  -0.2340   -3.49%   1288  coq-mathcomp-analysis/theories/derive.v.html                                                       │
│   26.7      26.5  -0.2243   -0.84%     68  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/VerifyDecode.v.html │
│    133       133  -0.2213   -0.17%    155  coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html                         │
│ 43.423    43.205  -0.2180   -0.50%    834  coq-vst/veric/binop_lemmas4.v.html                                                                 │
│   41.9      41.7  -0.2173   -0.52%     50  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html               │
│   22.4      22.2  -0.2089   -0.93%     85  coq-fiat-crypto-with-bedrock/src/Curves/Montgomery/AffineProofs.v.html                             │
│   3.55      3.34  -0.2065   -5.82%    957  coq-unimath/UniMath/CategoryTheory/Monoidal/Examples/DisplayedCartesianMonoidal.v.html             │
│  0.199  0.000175  -0.1984  -99.91%  16808  coq-coqprime/src/Coqprime/examples/BasePrimes.v.html                                               │
│   98.8      98.6  -0.1978   -0.20%    968  coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html                    │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Copy link
Contributor

coqbot-app bot commented May 24, 2025

🔴 CI failures at commit 3b084a5 without any failure in the test-suite

✔️ Corresponding jobs for the base commit 4043e70 succeeded

❔ Ask me to try to extract minimal test cases that can be added to the test-suite

🏃 @coqbot ci minimize will minimize the following targets: ci-elpi_test, ci-hb_test
  • You can also pass me a specific list of targets to minimize as arguments.

@gares
Copy link
Member

gares commented May 25, 2025

@SkySkimmer this is a call to add-abbreviation-for-tactic. My hope was that it had no synterp action, a bit like abbreviations for regular terms. Eg Foo.Bar arg becomes ltac:(elpi "Foo.Bar" args).

  MLCode(Pred("coq.notation.add-abbreviation-for-tactic",
    In(B.string,"Name",
    In(B.string,"TacticName",
    CIn(CConv.(!>>) B.list tactic_arg,"FixedArgs",
    Full(proof_context, {|Declares a parsing rule similar to
  Notation Name X1..Xn := ltac:(elpi TacticName FixedArgs (X1)..(Xn))
so that Name can be used in the middle of a term to invoke an
elpi tactic. While FixedArgs can contain str, int, and trm all
other arguments will necessarily be terms, and their number is
not fixed (the user can pass as many as he likes).
The tactic receives as the elpi.loc attribute the precise location
at which the term is written (unlike if a regular abbreviation was
declared by hand).
A call to coq.notation.add-abbreviation-for-tactic TacName TacName []
is equivalent to Elpi Export TacName.|})))),
    (fun name tacname more_args ~depth { options} _ -> grab_global_env "coq.notation.add-abbreviation-for-tactic" (fun state ->
      ...

I think I could make it also available in the synterp phase to that one cann announce it, but it is really necessary? This is the code that triggers it

let cache_abbrev_for_tac { abbrev_name; tac_name = tacname; tac_fixed_args = more_args } =
  let action args loc =
  let open Ltac_plugin in
  let tac =
    let open Tacexpr in
    let elpi_tac = {
      mltac_plugin = "rocq-elpi.elpi";
      mltac_tactic = "elpi_tac"; } in
    let elpi_tac_entry = {
      mltac_name = elpi_tac;
      mltac_index = 0; } in
    let more_args = more_args |> List.map (function
      | Rocq_elpi_arg_HOAS.Tac.Int _ as t -> t
      | Rocq_elpi_arg_HOAS.Tac.String _ as t -> t
      | Rocq_elpi_arg_HOAS.Tac.Term (t,_) ->
        let expr = Constrextern.extern_glob_constr Constrextern.empty_extern_env t in
        let rec aux () ({ CAst.v } as orig) = match v with
        | Constrexpr.CEvar _ -> CAst.make @@ Constrexpr.CHole(None)
        | _ -> Constrexpr_ops.map_constr_expr_with_binders (fun _ () -> ()) aux () orig in
        Rocq_elpi_arg_HOAS.Tac.Term (aux () expr)
      | _ -> assert false)  in
    let tacname = loc, tacname in
    let tacname = Genarg.in_gen (Genarg.rawwit Rocq_elpi_arg_syntax.wit_qualified_name) tacname in
    let args = args |> List.map (fun (arg,_) -> Rocq_elpi_arg_HOAS.Tac.Term(arg)) in
    let args = Genarg.in_gen (Genarg.rawwit (Genarg.wit_list Rocq_elpi_arg_syntax.wit_elpi_tactic_arg)) (more_args @ args) in
    (TacML (elpi_tac_entry, [TacGeneric(None, tacname); TacGeneric(None, args)])) in
  CAst.make @@ Constrexpr.CGenarg (Genarg.in_gen (Genarg.rawwit wit_ltac_in_term) (CAst.make tac)) in
  let Gbpmp (rule, action) = gbpmp action (List.rev abbrev_name) in
  Pcoq.grammar_extend Pcoq.Constr.term (Pcoq.Fresh
    (Gramlib.Gramext.Before "10",
     [ (None, None, [ Pcoq.Production.make
      (Pcoq.Rule.next rule (Pcoq.Symbol.list0 (Pcoq.Symbol.nterm Pcoq.Constr.arg)))
      action
    ])]))

let subst_abbrev_for_tac (subst, { abbrev_name; tac_name; tac_fixed_args }) = {
  abbrev_name;
  tac_name;
  tac_fixed_args = List.map (Rocq_elpi_arg_HOAS.Tac.subst subst) tac_fixed_args
}

let inAbbreviationForTactic : tac_abbrev -> Libobject.obj =
  Libobject.declare_object @@ Libobject.global_object_nodischarge "ELPI-EXPORTED-TAC-ABBREV"
      ~cache:cache_abbrev_for_tac ~subst:(Some subst_abbrev_for_tac)

Indeed it changes the grammar. My question is: can I achieve the same without changing the grammare?

@SkySkimmer
Copy link
Contributor Author

SkySkimmer commented May 25, 2025

I think the

their number is not fixed (the user can pass as many as he likes).

part is currently not possible without changing the grammar.

Maybe we could extend the abbreviation system to support it but I'm not sure of the details.

EDIT: supporting a non-ident abbrev_name is also not possible with current abbreviations

@SkySkimmer SkySkimmer added the needs: independent fix The PR reveals an independent bug. label Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: independent fix The PR reveals an independent bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants