Skip to content

Update syntax in auto.rst chapter#13343

Merged
coqbot-app[bot] merged 2 commits intorocq-prover:masterfrom
jfehrle:prodn_auto
Nov 25, 2020
Merged

Update syntax in auto.rst chapter#13343
coqbot-app[bot] merged 2 commits intorocq-prover:masterfrom
jfehrle:prodn_auto

Conversation

@jfehrle
Copy link
Copy Markdown
Member

@jfehrle jfehrle commented Nov 10, 2020

Convert and refine the chapter.

Fixes #5201

@jfehrle jfehrle added kind: documentation Additions or improvement to documentation. needs: merge of dependency This PR depends on another PR being merged first. labels Nov 10, 2020
@jfehrle jfehrle added this to the 8.13+beta1 milestone Nov 10, 2020
@jfehrle jfehrle requested a review from Zimmi48 November 10, 2020 19:15
@jfehrle jfehrle requested review from a team as code owners November 10, 2020 19:15
@jfehrle jfehrle force-pushed the prodn_auto branch 2 times, most recently from 70ef971 to ddcbc27 Compare November 10, 2020 21:26
Comment thread doc/sphinx/proofs/automatic-tactics/logic.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
@Zimmi48 Zimmi48 removed the request for review from a team November 11, 2020 13:50
@Zimmi48 Zimmi48 removed the needs: merge of dependency This PR depends on another PR being merged first. label Nov 11, 2020
@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 11, 2020

Updated.

@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 12, 2020

I'm wondering what to do about clause_dft_concl. It looks like rewrite would use all the options, but autounfold only a few. It should have a single writeup in one place. Your thoughts?

@Zimmi48 Zimmi48 self-assigned this Nov 12, 2020
@Zimmi48
Copy link
Copy Markdown
Member

Zimmi48 commented Nov 12, 2020

It belongs here IMHO. If we could keep the nonterminal names as close to what is currently presented as possible, this would be nice BTW (occurrence_clause is a nicer name than clause_dft_concl).

Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment on lines +150 to +155
:n:`with *`
Use the unfolding hints in all existing hint databases.

Uses the unfold hints declared in all the hint databases.
:n:`with {+ @ident }`
Use the unfolding hints in :n:`{+ @ident }` in addition to the database ``core``.
Use the fake database `nocore` to omit `core`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is basically the same explanation as the previous one of hintbases, so I don't think it is actually worth repeating.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, we should hyperlink to a common description for commonly used bits of grammar rather than repeating the same text over and over. That may be easier to do as a cleanup once the syntax has been updated everywhere.

Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst
Unfolds constants that were declared through a :cmd:`Hint Unfold`
in the given databases.

.. tacn:: autorewrite {? * } with {+ @ident } {? @clause_dft_concl } {? using @ltac_expr }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mattam82 (or @JasonGross): can you tell us what this optional * does?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can you guess from this? The * passes a ~conds:AllMatches to the lower level code. Naive is the default for ~conds.

The options are defined as:

type conditions =
  | Naive (* Only try the first occurrence of the lemma (default) *)
  | FirstSolved (* Use the first match whose side-conditions are solved *)
  | AllMatches (* Rewrite all matches whose side-conditions are solved *)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From this, I would conclude approximately that * means autorewrite will rewrite in all occurrences that match a single rewrite lemma instead of rewriting in only one place at once, and that it may do more progress in some cases because of this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This seems to be a bit of a mess. Only some parts of the occurrences clause are accepted. I guess the * is a workaround for not supporting the at 1 form. Would you mind turning my last example into something that works and verifying that the occurrence numbers are applied in H?

autorewrite * with True at 1.
(* The "at" syntax isn't available yet for the autorewrite tactic. *)
autorewrite * with True in |- * at 1.
(* The "at" syntax isn't available yet for the autorewrite tactic. *)
autorewrite * with True in H at 1.
(* Rewriting base True does not exist. *)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See #4976 and #7672

Copy link
Copy Markdown
Member

@JasonGross JasonGross Nov 20, 2020

Choose a reason for hiding this comment

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

Also #1933 (comment) where @mattam82 seems to have given an explanation (in French)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@JasonGross Thanks for your help. @mattam82's French comment about rewrite* and autorewrite* aligns well with the piece of code found by Jim but the issue opened by Samuel seems to indicate that autorewrite* does not actually work. We need @mattam82 to comment, so I'll ping him by e-mail.

In any case, the current documentation of * added in this PR is probably a bit too simple ("If present, rewrite all occurrences.")

Copy link
Copy Markdown
Member

@Zimmi48 Zimmi48 left a comment

Choose a reason for hiding this comment

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

Here's the rest of my review.

Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
@Zimmi48
Copy link
Copy Markdown
Member

Zimmi48 commented Nov 13, 2020

@jfehrle My suggestion to introduce a new syntax bfs eauto and deprecate the syntax eauto natural natural would make the PR go beyond a simple documentation PR, and thus introduces the issue of the upcoming feature freeze (on Monday 16th). Thus, if you agree to follow this suggestion, maybe that should go to a separate PR to guarantee that this can be merged before Monday. I can also open the PR myself actually.

@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 14, 2020

If we could keep the nonterminal names as close to what is currently presented as possible, this would be nice BTW (occurrence_clause is a nicer name than clause_dft_concl).

occurrence_clause was not used in the chapter. There was a goal_occurrences, but I didn't know what it corresponded to.

@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 14, 2020

I think this should be changed in the mlgs to OPT "-" LIST1 nat_or_var. Make that a separate PR?

occs_nums: [
| LIST1 nat_or_var
| "-" nat_or_var LIST0 int_or_var
]

@jfehrle jfehrle requested a review from a team as a code owner November 15, 2020 05:36
@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 15, 2020

Updated. This took forever to update. Be sure to look at the changes in tactics.rst and in rewriting.rst.

@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 Nov 15, 2020
@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 Nov 16, 2020
@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 16, 2020

Updated.

@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 Nov 16, 2020
Copy link
Copy Markdown
Member

@Zimmi48 Zimmi48 left a comment

Choose a reason for hiding this comment

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

Great improvement to the occurrence clauses section.

Comment thread doc/sphinx/proof-engine/tactics.rst Outdated
Comment thread doc/sphinx/proof-engine/tactics.rst Outdated
Comment thread doc/sphinx/proof-engine/tactics.rst Outdated
Comment thread doc/sphinx/proof-engine/tactics.rst Outdated
Comment thread doc/sphinx/proof-engine/tactics.rst Outdated
Comment thread doc/sphinx/proof-engine/tactics.rst Outdated
Comment thread doc/sphinx/proof-engine/tactics.rst Outdated
Comment thread doc/sphinx/proof-engine/tactics.rst Outdated
@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 18, 2020

Updated.

@Zimmi48
Copy link
Copy Markdown
Member

Zimmi48 commented Nov 19, 2020

Great improvements to rewriting.rst!

Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 19, 2020

Updated. Are we getting close to done?

@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 Nov 20, 2020
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Copy link
Copy Markdown
Member

@Zimmi48 Zimmi48 left a comment

Choose a reason for hiding this comment

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

Only a non-important suggestion but could we introduce more symmetry in the way and the order that the variants and the flags associated to auto, trivial and eauto are presented?

.. tacv:: autounfold with {+ @ident} in @goal_occurrences
Like :tacn:`eauto`, but does a breadth-first search (i.e. the tactic
checks all the relevant hints to see if one solves the goal before
recurring).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

breadth-first search is more than this (it explores all "paths of length 2" before going to "paths of length 3"). Anyway, what about linking to Wikipedia instead of attempting to explain this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Got it. I had some doubt that this was doing a full bfs. AFAIK, the kernel, monad infrastructure, Ltac, etc. are all designed around dfs and backtracking. For efficiency, you'd want to save the resulting proof state for each successful hint at each level rather than repeating application of the hint (easy to code). I'll have to look at that code sometime.

One thing I'd like to experiment with at some point is guiding the search in part by metrics on the proof such as the length of the goal conclusion(s), keeping only the best N results at any point. That may solve some goals more efficiently and/or make useful progress for the user.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

BTW, there are several implementations of proof search and the plan was to get rid of the legacy auto and eauto backend in favor of the most recently written typeclasses eauto which also has a bfs strategy BTW (while keeping the tactics of course). See #721.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, you worked on that! We'll have to chat about it sometime.

Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Copy link
Copy Markdown
Member

@Zimmi48 Zimmi48 left a comment

Choose a reason for hiding this comment

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

I think we are very close to done.

Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment on lines +1269 to +1280
| REPLACE "Proof" "using" section_var_expr "with" Pltac.tactic
| WITH "Proof" "using" section_subset_expr OPT [ "with" ltac_expr5 ]
| DELETE "Proof" "using" section_var_expr
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of making this change in common.edit_mlg, I suggest following more closely the implementation for once. I.e. only document Proof using (without mentioning the with clause) in the proof mode chapter, and put the two forms with the with clause in the auto.rst file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note that doc_grammar complains if the same command is shown in more than one :cmd:. I'll use :cmdv: but then doc_grammar won't check or update it. And I'll add a reference from Print using to Print with.

A bit of a weird case. We should start using the pattern LIST0 [ opt1 | opt2 | ... | optn ] in the grammar where needed to accept multiple options in any order.

@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 Nov 20, 2020
@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 20, 2020

Updated.

@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 Nov 23, 2020
Copy link
Copy Markdown
Member

@Zimmi48 Zimmi48 left a comment

Choose a reason for hiding this comment

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

Looks very good to me. Only nits remaining, although this will now have to be rebased over #13417 which was just merged.

Comment thread doc/sphinx/proof-engine/tactics.rst Outdated
Comment thread doc/sphinx/proofs/writing-proofs/proof-mode.rst Outdated
Comment thread doc/sphinx/proofs/automatic-tactics/auto.rst Outdated
Comment thread doc/sphinx/language/core/inductive.rst Outdated
Comment thread doc/sphinx/language/core/inductive.rst Outdated
| {? @ident } %{ {*; @record_field } {? ; } %}
constructor ::= @ident {* @binder } {? @of_type }
cumul_ident_decl ::= @ident {? @cumul_univ_decl }
cumul_univ_decl ::= @%{ {* {? {| = | + | * } } @ident } {? + } {| %| {*, @univ_constraint } {? + } %} | {| %} | %|%} } }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's best to leave cumul_univ_decl where it has been put in #12653, i.e. next to univ_decl.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As you wish. That list of productions in the universe chapter is a bit of an anomaly, throwing together several nonterminals that don't all refer to each other.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should improve this, of course, but there is no point in putting productions very far from the place they are currently documented.

@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 Nov 23, 2020
@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 23, 2020

Rebased and updated.

Copy link
Copy Markdown
Member

@Zimmi48 Zimmi48 left a comment

Choose a reason for hiding this comment

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

Looks good to me. Can you squash at the same time as you address my last comments?

Comment on lines 2 to 4
Undocumented :n:`eauto @nat_or_var @nat_or_var` syntax in favor of new ``bfs eauto``.
Also deprecated 2-integer syntax for ``debug eauto`` and ``info_eauto``.
(Use ``bfs eauto`` with the :flag:`Info Eauto` or :flag:`Debug Eauto` flags instead.)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You could put a few :tacn: in this changelog entry (not an important suggestion).

| @qualid
univ_decl ::= @%{ {* @ident } {? + } {? %| {*, @univ_constraint } {? + } } %}
cumul_univ_decl ::= @%{ {* {? {| = | + | * } } @ident } {? + } {? %| {*, @univ_constraint } {? + } } %}
cumul_univ_decl ::= @%{ {* {? {| = | + | * } } @ident } {? + } {| %| {*, @univ_constraint } {? + } %} | {| %} | %|%} } }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The presentation of this production should not change. This is an implementation detail that we need to take care of the special case where you put no space between the | and the final } (case of an empty list of universe constraints).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's a new production that needed the same edit that univ_decl has, which I added. They are very similar. It's tempting to deem it a semantic restriction:

image

@Zimmi48 Zimmi48 added the needs: squashing Some commits should be squashed together. label Nov 24, 2020
@jfehrle jfehrle removed the needs: squashing Some commits should be squashed together. label Nov 24, 2020
@jfehrle
Copy link
Copy Markdown
Member Author

jfehrle commented Nov 24, 2020

Updated and squashed. Thanks for the review!

@Zimmi48
Copy link
Copy Markdown
Member

Zimmi48 commented Nov 25, 2020

@coqbot merge now

@coqbot-app coqbot-app Bot merged commit 6377fbe into rocq-prover:master Nov 25, 2020
gares added a commit to gares/coq that referenced this pull request Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: documentation Additions or improvement to documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remark: auto either solves completely the goal or else leaves it intact. auto and trivial never fail.

4 participants