Skip to content

feat(Util/Notation3): don't try matching tactic blocks - #45042

Open
YaelDillies wants to merge 1 commit into
leanprover-community:masterfrom
YaelDillies:notation3_tactic_blocks
Open

YaelDillies wants to merge 1 commit into
leanprover-community:masterfrom
YaelDillies:notation3_tactic_blocks

Conversation

@YaelDillies

Copy link
Copy Markdown
Contributor

This means that notation3 can e.g. be used to create a delaborator for concrete cycle notation c[...] whereas previously it would fail due to the by decide in the expansion.

This is best effort, in the sense that eluding a proof in pretty-printing is necessarily a loss, unless we somehow run the tactic block while pretty-printing to determine whether the proof could have come from the tactic or had been hand-provided by the user.

Remove the (prettyPrint := false) flag in concrete cycle notation and the application of Cycle.nodup_coe_iff in the default proof term: the decidability instance applies it automatically anyway.

Generated by Claude Opus, hand-edited by myself afterwards.

Assisted-by: Claude Opus 5.5


This means that `notation3` can e.g. be used to create a delaborator for concrete cycle notation `c[...]` whereas previously it would fail due to the `by decide` in the expansion.

This is best effort, in the sense that eluding a proof in pretty-printing is necessarily a loss, unless we somehow run the tactic block while pretty-printing to determine whether the proof could have come from the tactic or had been hand-provided by the user.

Remove the `(prettyPrint := false)` flag in concrete cycle notation and the application of `Cycle.nodup_coe_iff` in the default proof term: the decidability instance applies it automatically anyway.

Generated by Claude Opus, hand-edited by myself afterwards.

Assisted-by: Claude Opus 5.5
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

PR summary 9dcb35b247

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean -- unavailable)

⚠️ No declarations diff yet: there is no built master snapshot at this PR's merge-base (typically a bors-batch intermediate that CI never built). Merge master into this PR and push to refresh.


No changes to strong technical debt.
No changes to weak technical debt.

Current commit 9dcb35b247
Reference commit 3fb40e7781

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@grunweg grunweg added the t-meta Tactics, attributes or user commands label Oct 19, 2026
@YaelDillies YaelDillies added the LLM-generated PRs with substantial input from LLMs - review accordingly label Oct 19, 2026
@JovanGerb

Copy link
Copy Markdown
Contributor

Is this behaviour actually desirable? Since we aren't checking that the tactic actually produces the required proof, this can break round tripping.

@YaelDillies

Copy link
Copy Markdown
Contributor Author

Indeed, but so is eliding proofs. A good parallel here is GetElem notation, which also doesn't print the proof.

@joneugster

Copy link
Copy Markdown
Member

I somewhat share the caution when it comes to notation which doesn't round-trip. Eliding proofs is IMO a different thing because you still actively see ⋯ and you can turn it off with pp.proofs.

Do we have any estimate on which (or how many) notation3 in Mathlib would be prone to this sort of round-tripping error? e.g. the notation in your test seems fine, as I would expect that the default proof by decide almost always works, but I wonder whether there are other notations where failure is very likely?

@joneugster joneugster added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Nov 22, 2026
@YaelDillies

Copy link
Copy Markdown
Contributor Author

Do we have any estimate on which (or how many) notation3 in Mathlib would be prone to this sort of round-tripping error?

Only 3 out of ~200 notation3s in mathlib have a tactic block in their expansion:

  • The two local notation3 "η" => (IsPrimitiveRoot.isUnit hζ.toInteger_isPrimitiveRoot (by decide)).unit in NumberTheory.FLT.Three and NumberTheory.NumberField.Cyclotomic.Three, which just use by decide to discharge the same goal over and over again. Since this notation doesn't have any variable, it can't break round-tripping.
  • c[...] in GroupTheory.Perm.Cycle.Concrete, which is my motivating example.

c[...] fails to round-trip when its parameters aren't closed terms that decide can evaluate. For example, formPerm (ofList [a, b]) h with h derived from hab : a ≠ b would print as c[a, b], which doesn't elaborate. I could not find any such term in mathlib. c[...] seems to be used solely on concrete permutations like c[0, 1, 2] : Perm (Fin 4), where decide always works. Until now those didn't pretty-print at all, because the notation had (prettyPrint := false).

Re pp.proofs: would you be happy if set_option pp.proofs true disabled the pretty-printing I am offering in this PR? Should be very easy to implement.

@YaelDillies YaelDillies removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Nov 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM-generated PRs with substantial input from LLMs - review accordingly t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants