Skip to content

Automatically generated goal names #20809

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 8 commits into
base: master
Choose a base branch
from

Conversation

dhalilov
Copy link
Contributor

@dhalilov dhalilov commented Jun 25, 2025

This PR adds the possibility to have automatically generated goal names through the Accessible Goal Names option. This also includes qualified goal names and showing the difference between accessible and non-accessible printing names in Show Existentials.

Requires #20813 to be merged first.

  • Added / updated test-suite.
  • Added changelog.
  • Added / updated documentation.
    • Updated documented syntax by running make doc_gram_rsts.
  • Opened overlay pull requests.

@dhalilov dhalilov requested review from a team as code owners June 25, 2025 16:09
@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Jun 25, 2025
@dhalilov dhalilov force-pushed the autonaming-goals branch 3 times, most recently from 1a989d3 to ca1c5f5 Compare June 26, 2025 09:30
@ppedrot
Copy link
Member

ppedrot commented Jun 26, 2025

@coqbot run full ci

@coqbot-app coqbot-app bot removed the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Jun 26, 2025
Copy link
Contributor

coqbot-app bot commented Jun 26, 2025

🔴 CI failure at commit ca1c5f5 without any failure in the test-suite

✔️ Corresponding job for the base commit 90e3b7e succeeded

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

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

@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Jun 26, 2025
@ppedrot ppedrot added needs: merge of dependency This PR depends on another PR being merged first. labels Jun 26, 2025
@ppedrot ppedrot marked this pull request as draft June 26, 2025 14:48
@ppedrot ppedrot marked this pull request as draft June 26, 2025 14:48
Copy link
Member

@jfehrle jfehrle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some details to consider.

It seems incomplete not to handle all tactics that introduce new goals, eg split.

Probably more comments later. Only so much I'm willing to do on my phone. I won't be near my computer until next week.

| WITH OPT ( [ natural | "[" ident "]" ] ":" ) "{"
| MOVETO simple_tactic OPT ( [ natural | "[" ident "]" ] ":" ) "{"
| WITH OPT ( [ natural | "[" fullyqualid "]" ] ":" ) "{"
| MOVETO simple_tactic OPT ( [ natural | "[" fullyqualid "]" ] ":" ) "{"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "fullyqualid"? Are you prohibiting use of the shortest unique suffix? If so, that behavior is inconsistent with all other qualids--and give your rationale.

Also I didn't see a description of this nonterminal in the doc---IMO that's a requirement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualified goal names behave differently from other qualids, since there is only one name for them which is the shortest one by construction. That means they are also always fully qualified, so I think fullyqualid makes the distinction clear.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualified goal names behave differently from other quali

That's precisely the problem. While the syntax is the same as qualids, their behavior/use is entirely different. Just call them goal names and explain that they may have multiple dotted components.

@dhalilov
Copy link
Contributor Author

It seems incomplete not to handle all tactics that introduce new goals, eg split.

split does not work at the moment because conj (constructor of and) does not have named hypotheses, so no names cannot be generated. Could be changed in another patch.

@dhalilov dhalilov force-pushed the autonaming-goals branch 2 times, most recently from e086bfc to ff080d7 Compare June 27, 2025 21:04
@dhalilov
Copy link
Contributor Author

dhalilov commented Jun 27, 2025

(Cleaned the history. The PR needs #20813 to be merged first and then will be rebased on master)

@jfehrle
Copy link
Member

jfehrle commented Jun 27, 2025

The PR needs #20813 to be merged first and then will be rebased on master)

Best to put this in the PR description--reviewers are likely to miss this if it's only in the conversation.

Copy link
Member

@jfehrle jfehrle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how this feature is really helpful for users. Maybe you can give a better example or (maybe easier) explain in words when/why it's helpful. If you can't make a convincing case, I would not approve this PR. It also seems quite limited since names are generated only for 3 tactics.

If you can make that convincing case, there are details of the behavior and documentation that we'd need to further consider/revise.

Comment on lines 19 to 23
(** If true, this option enables automatic generation of goal names. *)
let { Goptions.get = accessible_goal_names } =
Goptions.declare_bool_option_and_ref
~key:["Accessible";"Goal";"Names"]
~value:true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Accessible" seems vague, "Generate" may be better.
I would make the default false; I think most users won't enable this option.

@mattam82
Copy link
Member

mattam82 commented Jul 2, 2025

I don't see how this feature is really helpful for users. Maybe you can give a better example or (maybe easier) explain in words when/why it's helpful. If you can't make a convincing case, I would not approve this PR. It also seems quite limited since names are generated only for 3 tactics.

If you can make that convincing case, there are details of the behavior and documentation that we'd need to further consider/revise.

This feature / work was presented and discussed at Rocq'n'share last week and got positive feedback, giving a convincing case that this can definitely be useful to users to organize their proofs, and choose to focus on specific subgoals, rather than relying on fragile comments. I guess you were not aware of that @jfehrle.

@dhalilov
Copy link
Contributor Author

dhalilov commented Jul 2, 2025

I don't see how this feature is really helpful for users. Maybe you can give a better example or (maybe easier) explain in words when/why it's helpful.

The idea behind generating goal names is to provide a more robust alternatives to bullets and numbers. If you are doing case analysis on an inductive with two constructors (say A and B), then your proof usually looks like this:

destruct x.
- (* case A *) ...
- (* case B *) ...

This proof is bound to break in various ways if you changed the order of the constructors, or added a new one. It is likely that the proof would break in a random bullet, which would be tricky to understand.

With named goals, you get a slightly better proof that allows you to write your cases in any order:

destruct x.
1: refine ?[A].
2: refine ?[B].
[A]: { ... }
[B]: { ... }

but you're still relying on the order of the constructors when you're giving names, and so you have the same problem as before.

If we generated goal names A and B instead, the proof would be totally independent of the order of the constructors, and you could write your cases in any order you'd like.

This improves both readability, maintainability, and error messages at a low cost. (Note that Lean provides a case tactic, which has a similar mechanism.)

It also seems quite limited since names are generated only for 3 tactics.

Since the mechanism is quite general, it should work for any tactic that unifies with hypotheses, so I expect it to work with some e-tactics such as econstructor or etransitivity (I don't have a list of these). Also, we could extend the range of supported tactics in the future (e.g. split is easy to support); for now, this PR acts as a working basis for future extensions.

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jul 2, 2025
@jfehrle
Copy link
Member

jfehrle commented Jul 2, 2025

@mattam82 I guess you were not aware of that

How would I be aware of that if I didn't attend the meeting?

@jfehrle
Copy link
Member

jfehrle commented Jul 2, 2025

@dhalilov That makes some sense. It would be good to explain this briefly where the option is described, maybe something like
"This option makes it possible to write proofs that have multiple subgoals without depending on the order in which the constructors were defined. If you use bullets and goal numbers in a proof, then changing the order of constructors in the definition will break the proof. Currently this works for the following cases: <add bullet-pointed list>" Then a short example of a proof using the names with (for brevity/clarity) no output. Might be nice to define a new inductive in the example with more than 2 constructors.

Also, we could extend the range of supported tactics in the future

For usability, it's best to make the feature as comprehensive as reasonably possible. It can be annoying to have something work in some cases and not work in other similar cases--it requires more thinking by the user. This annoyance may lead to people not using the feature. To get adoption, you want users to have a great experience the first time they try a feature. If the feature is not comprehensive, the doc could say that the feature is experimental.

@dhalilov dhalilov force-pushed the autonaming-goals branch from ff080d7 to ad873cf Compare July 2, 2025 22:21
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jul 2, 2025
@dhalilov dhalilov force-pushed the autonaming-goals branch from ad873cf to 6032b00 Compare July 2, 2025 22:42
@ppedrot ppedrot added kind: feature New user-facing feature request or implementation. and removed needs: merge of dependency This PR depends on another PR being merged first. labels Jul 3, 2025
@ppedrot
Copy link
Member

ppedrot commented Jul 3, 2025

@coqbot run full ci

@coqbot-app coqbot-app bot removed the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Jul 3, 2025
@ppedrot
Copy link
Member

ppedrot commented Jul 3, 2025

@coqbot bench

Copy link
Contributor

coqbot-app bot commented Jul 3, 2025

🏁 Bench results:

┌─────────────────────────────────────┬─────────────────────────┬───────────────────────────────────────┬─────────────────────────┐
│                                     │      user time [s]      │           CPU instructions            │  max resident mem [KB]  │
│                                     │                         │                                       │                         │
│            package_name             │   NEW      OLD    PDIFF │      NEW             OLD        PDIFF │   NEW      OLD    PDIFF │
├─────────────────────────────────────┼─────────────────────────┼───────────────────────────────────────┼─────────────────────────┤
│                            coq-core │    2.88     3.00  -4.00 │    19764229167     19761519591   0.01 │   92888    92984  -0.10 │
│                rocq-metarocq-common │   41.55    42.20  -1.54 │   270777453877    270139471493   0.24 │  908484   924740  -1.76 │
│               coq-mathcomp-analysis │  900.26   910.91  -1.17 │  6834312009633   6837336040175  -0.04 │ 1894040  1908888  -0.78 │
│                        rocq-bignums │   28.39    28.67  -0.98 │   183059438709    182978941403   0.04 │  478716   481644  -0.61 │
│              coq-mathcomp-odd-order │  562.01   566.54  -0.80 │  4069832001255   4071256467437  -0.03 │ 2230688  2231608  -0.04 │
│          rocq-metarocq-translations │   16.55    16.65  -0.60 │   119812612610    119833720623  -0.02 │  770408   775404  -0.64 │
│             rocq-mathcomp-character │   86.85    87.32  -0.54 │   614398140983    617013482157  -0.42 │ 1474664  1471424   0.22 │
│                           rocq-core │    6.32     6.35  -0.47 │    39049009912     38946714985   0.26 │  438428   437536   0.20 │
│                   coq-iris-examples │  358.29   359.93  -0.46 │  2374023010531   2371139714251   0.12 │ 1072432  1090916  -1.69 │
│                 rocq-mathcomp-field │  157.32   158.03  -0.45 │  1202911149271   1203707318859  -0.07 │ 1751780  1745024   0.39 │
│                        coq-coqprime │   51.22    51.45  -0.45 │   353625176786    353705709263  -0.02 │  805652   805780  -0.02 │
│                        rocq-runtime │   74.11    74.42  -0.42 │   537284112631    536418788975   0.16 │  487656   491144  -0.71 │
│              rocq-metarocq-template │   81.66    81.97  -0.38 │   572597077387    570431436703   0.38 │  990340  1000816  -1.05 │
│ coq-neural-net-interp-computed-lite │  232.68   233.54  -0.37 │  2249294531233   2249018760964   0.01 │  899300   901460  -0.24 │
│                           coq-verdi │   44.20    44.36  -0.36 │   296145610734    295332457686   0.28 │  531244   523464   1.49 │
│         coq-rewriter-perf-SuperFast │  469.48   470.96  -0.31 │  3744832842965   3743339348781   0.04 │ 1235092  1230732   0.35 │
│                            coq-corn │  680.75   682.73  -0.29 │  4704822075969   4693610651952   0.24 │  711876   706236   0.80 │
│                           rocq-elpi │   12.76    12.79  -0.23 │    91643913987     91668090197  -0.03 │  480776   480412   0.08 │
│               rocq-metarocq-erasure │  503.55   504.38  -0.16 │  3460979642453   3449470753985   0.33 │ 1772128  1817760  -2.51 │
│                 rocq-metarocq-pcuic │  643.95   644.87  -0.14 │  4168478536771   4152532430570   0.38 │ 2325224  2326444  -0.05 │
│                      coq-coquelicot │   37.65    37.70  -0.13 │   228991298004    228252960106   0.32 │  828812   828320   0.06 │
│                         coq-unimath │ 1761.42  1762.53  -0.06 │ 14656528896660  14656483301695   0.00 │ 1048288  1046064   0.21 │
│           rocq-metarocq-safechecker │  322.11   322.17  -0.02 │  2413300157000   2410352870665   0.12 │ 1776684  1752784   1.36 │
│                 rocq-metarocq-utils │   23.12    23.12   0.00 │   151035327882    150763777836   0.18 │  582264   582268  -0.00 │
│               rocq-mathcomp-algebra │  281.62   281.61   0.00 │  2119660123180   2118880698917   0.04 │ 1435576  1358064   5.71 │
│                 coq-category-theory │  613.69   613.56   0.02 │  4522400654949   4517030691718   0.12 │  948568   967436  -1.95 │
│                         rocq-stdlib │  446.16   445.80   0.08 │  1599982832395   1594006660534   0.37 │  620352   615592   0.77 │
│                       coq-fourcolor │ 1326.65  1325.38   0.10 │ 12369066961957  12366714201200   0.02 │  896716   900408  -0.41 │
│               coq-engine-bench-lite │  124.72   124.59   0.10 │   940889944284    936941835646   0.42 │ 1055584  1099388  -3.98 │
│                           coq-color │  249.35   248.96   0.16 │  1573535450904   1568683876800   0.31 │ 1121208  1119952   0.11 │
│          coq-performance-tests-lite │  885.72   884.14   0.18 │  7210151623979   7200239887573   0.14 │ 1939896  1937660   0.12 │
│                        coq-bedrock2 │  350.09   349.30   0.23 │  2903919622608   2902151831176   0.06 │  894680   888912   0.65 │
│                        coq-rewriter │  333.76   332.98   0.23 │  2508229679390   2502127414871   0.24 │ 1308008  1305616   0.18 │
│                      coq-verdi-raft │  532.42   531.17   0.24 │  3686414060241   3682120769476   0.12 │  854616   845156   1.12 │
│                    coq-fiat-parsers │  277.26   276.19   0.39 │  2144078107204   2140725063904   0.16 │ 2351580  2349436   0.09 │
│              rocq-mathcomp-fingroup │   23.73    23.60   0.55 │   152383765466    152459743025  -0.05 │  526368   529256  -0.55 │
│              rocq-mathcomp-solvable │   93.55    93.03   0.56 │   638421378192    639065113854  -0.10 │ 1045976  1051952  -0.57 │
│                       coq-fiat-core │   58.28    57.95   0.57 │   356310750442    355825588176   0.14 │  485164   485504  -0.07 │
│                            coq-hott │  154.74   153.75   0.64 │  1069421743608   1068383338183   0.10 │  470908   470728   0.04 │
│                         coq-coqutil │   45.25    44.94   0.69 │   285637872391    285225942953   0.14 │  564756   566888  -0.38 │
│                        coq-compcert │  313.37   311.16   0.71 │  2062527837396   2035839647916   1.31 │ 1309384  1149756  13.88 │
│                    coq-math-classes │   88.21    87.40   0.93 │   539016477603    532874893850   1.15 │  512616   512912  -0.06 │
│                             coq-vst │  859.29   848.18   1.31 │  6544612915667   6442859626228   1.58 │ 2564576  2231248  14.94 │
│             rocq-mathcomp-ssreflect │    1.29     1.26   2.38 │     9107527780      9111667383  -0.05 │  551436   551612  -0.03 │
│                      rocq-equations │    9.22     8.92   3.36 │    63237488455     63204134956   0.05 │  401148   400020   0.28 │
└─────────────────────────────────────┴─────────────────────────┴───────────────────────────────────────┴─────────────────────────┘

INFO: failed to install
coq-fiat-crypto-with-bedrock (in NEW)

🐢 Top 25 slow downs
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                   TOP 25 SLOW DOWNS                                                    │
│                                                                                                                        │
│  OLD     NEW     DIFF    %DIFF    Ln                  FILE                                                             │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 31.535  33.616  2.0810    6.60%    97  coq-vst/veric/binop_lemmas5.v.html                                              │
│   65.9    67.7  1.7251    2.62%   609  coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html                     │
│ 40.618  42.204  1.5860    3.90%   834  coq-vst/veric/binop_lemmas4.v.html                                              │
│   93.8    94.7  0.8941    0.95%   968  coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │
│ 11.719  12.565  0.8460    7.22%   126  coq-vst/veric/binop_lemmas6.v.html                                              │
│  2.951   3.757  0.8060   27.31%   431  coq-vst/veric/binop_lemmas3.v.html                                              │
│  3.569   4.356  0.7870   22.05%   154  coq-vst/veric/binop_lemmas5.v.html                                              │
│   93.7    94.4  0.7614    0.81%   999  coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │
│  4.599   5.276  0.6770   14.72%    84  coq-vst/veric/binop_lemmas2.v.html                                              │
│  1.448   1.953  0.5050   34.88%    60  coq-vst/veric/binop_lemmas2.v.html                                              │
│   38.7    39.2  0.4935    1.27%   236  coq-rewriter/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap.v.html      │
│  2.347   2.838  0.4910   20.92%   728  coq-vst/veric/expr_lemmas.v.html                                                │
│  1.417   1.879  0.4620   32.60%   153  coq-vst/veric/binop_lemmas6.v.html                                              │
│   45.8    46.2  0.4588    1.00%   115  coq-bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html                      │
│  0.246   0.668  0.4219  171.39%   719  rocq-stdlib/theories/MSets/MSetRBT.v.html                                       │
│   38.0    38.4  0.4039    1.06%   224  coq-performance-tests-lite/PerformanceExperiments/rewrite_lift_lets_map.v.html  │
│   3.88   4.268  0.3880   10.00%   477  coq-vst/veric/expr_lemmas3.v.html                                               │
│  0.995   1.369  0.3740   37.59%   937  coq-vst/veric/binop_lemmas2.v.html                                              │
│   1.23    1.57  0.3343   27.11%  1142  rocq-stdlib/theories/FSets/FMapAVL.v.html                                       │
│   48.1    48.4  0.3175    0.66%   376  coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html     │
│  0.488   0.802  0.3144   64.47%   747  rocq-stdlib/theories/MSets/MSetRBT.v.html                                       │
│   1.43    1.73  0.2966   20.70%   313  rocq-stdlib/theories/Strings/Byte.v.html                                        │
│   36.2    36.5  0.2936    0.81%   139  coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html                    │
│  0.196   0.481  0.2850  145.55%   374  rocq-stdlib/theories/Sorting/SetoidList.v.html                                  │
│  0.299   0.577  0.2776   92.75%  1161  rocq-stdlib/theories/Strings/Byte.v.html                                        │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
🐇 Top 25 speed ups
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                            TOP 25 SPEED UPS                                                             │
│                                                                                                                                         │
│  OLD      NEW      DIFF     %DIFF    Ln                    FILE                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│    200       199  -0.7706   -0.39%     8  coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │
│   1.28     0.726  -0.5510  -43.15%   813  rocq-stdlib/theories/MSets/MSetRBT.v.html                                                     │
│   3.98      3.61  -0.3711   -9.32%   492  rocq-stdlib/theories/Reals/Cauchy/ConstructiveCauchyRealsMult.v.html                          │
│ 34.626    34.278  -0.3480   -1.01%   147  coq-vst/veric/expr_lemmas4.v.html                                                             │
│   2.55      2.23  -0.3134  -12.31%   607  rocq-stdlib/theories/Zmod/ZmodBase.v.html                                                     │
│ 33.535    33.248  -0.2870   -0.86%   194  coq-vst/veric/expr_lemmas4.v.html                                                             │
│  0.614     0.340  -0.2742  -44.68%   597  rocq-stdlib/theories/Strings/Byte.v.html                                                      │
│  0.319    0.0633  -0.2554  -80.15%  1208  coq-unimath/UniMath/CategoryTheory/DisplayedCats/Examples/StrictTwoSidedDispCat.v.html        │
│   1.04     0.788  -0.2475  -23.91%   736  rocq-stdlib/theories/Reals/Cauchy/ConstructiveCauchyReals.v.html                              │
│   8.49      8.24  -0.2454   -2.89%  1331  coq-mathcomp-odd-order/theories/PFsection9.v.html                                             │
│   24.1      23.8  -0.2362   -0.98%   558  coq-bedrock2/bedrock2/src/bedrock2Examples/insertionsort.v.html                               │
│   21.7      21.5  -0.2323   -1.07%   651  rocq-stdlib/theories/Zmod/ZmodBase.v.html                                                     │
│   1.17     0.942  -0.2238  -19.19%  2109  rocq-stdlib/theories/FSets/FMapFacts.v.html                                                   │
│   23.6      23.4  -0.2229   -0.94%    12  coq-fourcolor/theories/proof/job295to298.v.html                                               │
│  0.354     0.138  -0.2165  -61.15%  1187  rocq-stdlib/theories/Strings/Byte.v.html                                                      │
│  0.226    0.0129  -0.2134  -94.30%   323  rocq-metarocq-erasure/erasure/theories/Typed/OptimizeCorrectness.v.html                       │
│   11.6      11.4  -0.2098   -1.81%   410  coq-verdi-raft/theories/RaftProofs/LeaderLogsLogMatchingProof.v.html                          │
│  0.509     0.300  -0.2094  -41.13%   313  rocq-stdlib/theories/Reals/Abstract/ConstructiveLUB.v.html                                    │
│  0.223    0.0141  -0.2090  -93.66%   112  rocq-metarocq-erasure/erasure/theories/EDeps.v.html                                           │
│   17.7      17.5  -0.2074   -1.17%    31  coq-engine-bench-lite/coq/PerformanceDemos/pattern.v.html                                     │
│   9.27      9.07  -0.2068   -2.23%   434  coq-mathcomp-odd-order/theories/PFsection12.v.html                                            │
│  0.485     0.281  -0.2047  -42.16%    12  rocq-stdlib/theories/MSets/MSets.v.html                                                       │
│  0.208   0.00333  -0.2045  -98.40%   763  rocq-metarocq-erasure/erasure/theories/EWcbvEval.v.html                                       │
│  0.195   0.00114  -0.1943  -99.41%    90  rocq-metarocq-erasure/erasure/theories/EEtaExpanded.v.html                                    │
│  0.193  0.000577  -0.1924  -99.70%   121  rocq-metarocq-erasure/erasure/theories/ESubstitution.v.html                                   │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Copy link
Contributor

coqbot-app bot commented Jul 3, 2025

🔴 CI failure at commit 6032b00 without any failure in the test-suite

✔️ Corresponding job for the base commit 7aa1b22 succeeded

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

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

@jfehrle jfehrle self-requested a review July 5, 2025 15:42
Copy link
Member

@jfehrle jfehrle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Further suggestions and questions.

Comment on lines 800 to 808
.. rocqtop:: all abort

Set Generate Goal Names.

Goal forall n m, n + m = m + n.
Proof.
intros. induction m.
[O]: {
simpl. induction n.
Copy link
Member

@jfehrle jfehrle Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 4 line example expands into more than a page in the documentation, long for a simple example. Would be nice to omit some of the output to shorten it.

Where you have multiple tactics on the same line, the output for both confusingly appears below the tactic line like so (above the red line is simpl, below the red line is induction):

image

The simplest thing is to put them on separate lines. In this case, maybe better not to show the output for intros and other uninteresting bits, like this:

Suggested change
.. rocqtop:: all abort
Set Generate Goal Names.
Goal forall n m, n + m = m + n.
Proof.
intros. induction m.
[O]: {
simpl. induction n.
.. rocqtop:: in abort
Set Generate Goal Names.
Goal forall n m, n + m = m + n.
intros.
.. rocqtop:: all
induction m.
.. rocqtop:: in
[O]: {
simpl.
.. rocqtop:: all
induction n.

There seems to be a bug in the rocqtop directive: the output for [O]: { should appear just below that line.

BTW, do you know you can view the formatted documentation by clicking on this link in the PR?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a bug in the rocqtop directive: the output for [O]: { should appear just below that line.

This is also present in other examples, so it might be a parsing issue.

I'll shorten the output a bit 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an bug/limitation in the Python code for the directive.

Comment on lines 800 to 808
.. rocqtop:: all abort

Set Generate Goal Names.

Goal forall n m, n + m = m + n.
Proof.
intros. induction m.
[O]: {
simpl. induction n.
Copy link
Member

@jfehrle jfehrle Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the focus rules remain the same (i.e. switch to S when you're focused in O isn't allowed), it would be nicer if the user could specify only the last component of the goal name--just S below instead of O.S (or O instead of O.O). I don't know how long the qualified names may get in practice, nor whether restructuring a proof might mean changing many qualified names.

image

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the focus rules remain the same (i.e. switch to S when you're focused in O isn't allowed)

You can still apply a tactic to S even where O is focused by doing [S]: tac. What is not allowed is to nest focusing braces, so removing the second focusing brace after [S]: in your example should make it work.

it would be nicer if the user could specify only the last component of the goal name--just S below instead of O.S (or O instead of O.O)

I do agree but goal names are global to the proof and thus only specifying S would be ambiguous, which is precisely why qualified names are required. Relying on the focus state for name resolution would introduce unnecessary complexity in my opinion.

I don't know how long the qualified names may get in practice, nor whether restructuring a proof might mean changing many qualified names.

Since we are only working with shortest names, the qualification depth is equal to the number of consecutive destruct/induction that the proof made on the same inductive type, so you can expect names to not be very long (unless you are doing a repeat destruct, but in that case I don't think you would use named goals anyway since you are generating too many cases to handle by hand).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nicer if the user could specify only the last component of the goal name

I do agree but goal names are global to the proof and thus only specifying S would be ambiguous, which is precisely why qualified names are required.

Just check at run time whether there are multiple goal names that match S and, if so, generate an error. If your trie stores the qualified name in reverse order, that should be easy to do. (Similar to qualids for modules: the user generally only needs to provide a suffix that uniquely identifies the module.)


.. rocqtop:: all reset

Set Generate Goal Names.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you keep the default "true", maybe not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know yet what will be the default value of the option yet, so I keep it in the examples for now

Comment on lines 758 to 760
This option makes it possible to write proofs with multiple subgoals that do
not depend on the order in which constructors were defined. If you use
bullets or numbers instead, reordering constructors will break the proof.
Copy link
Member

@jfehrle jfehrle Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW: this drops the dependency on the order in which constructors were defined, replacing it with a dependency on the constructor name. If you change a constructor name, a text search will usually make it easy to update the constructor names--unlike depending on the order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed, might be worth adding to the documentation

Comment on lines +444 to +445
:token:`qualid` (see :ref:`existential-variables`). This works even when
the goal is not in focus.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This works even when the goal is not in focus." - this isn't true for my example above using S instead of O.S. Maybe the sentence only covers shelved goals?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this sentence meant that you could focus on shelved goals, yes


This option makes it possible to write proofs with multiple subgoals that do
not depend on the order in which constructors were defined. If you use
bullets or numbers instead, reordering constructors will break the proof.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add a sentence mentioning qualified names here with an in-line example like O.S and a hyperlink to the longer example. It's a key point that should be in the text description, not only in the examples a couple pages below.

Copy link
Member

@jfehrle jfehrle Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other thing: it would be nice to show here how to structure the proof when using the feature. Maybe like this, but just quoted text, keep the ellipses, not a rocqtop example. And maybe a sentence of explanation.

induction n.
[O]: { ... }
[S]: { ... }

FWIW, a user could write weird and much less readable things like:

[A]: tac1.
[B]: tac2.
[A]: tac3.
[A]: tac4.

Comment on lines +795 to +798
If several goals generate the same name (e.g. when doing nested case
analysis or induction), *qualified names* are used to disambiguate them,
using the qualified name of the parent as the basis for the fully
qualified name.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have induction on a bool inside induction on a nat, will the bool cases have names like true or O.true?
I suspect that qualified names are always used for nested cases, but I didn't try an example.

Seems like you should have an example that actually selects a qualified goal name, e.g. [S.O]: {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They will have names true and false since there's no point in prefixing them with O or S. (This is a consequence of the trie data structure we use to insert new names.)

@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Jul 6, 2025
dhalilov added a commit to dhalilov/stdlib that referenced this pull request Jul 6, 2025
@jfehrle
Copy link
Member

jfehrle commented Jul 7, 2025

The doc part is coming along. Let me know when you have the "final" version and I'll take another look. That would be a good time to move the PR from draft status. I'll leave the review of the code to others who are more knowledgeable.

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: feature New user-facing feature request or implementation. needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants