chore: use private proof elaborator to remove set_option backward.privateInPublic - #42755
chore: use private proof elaborator to remove set_option backward.privateInPublic#42755thorimur wants to merge 30 commits into
private proof elaborator to remove set_option backward.privateInPublic#42755Conversation
…via `by as_aux_lemma` Delegating to `by as_aux_lemma => exact @$t` had three problems: * `by` only leaves the exporting context when `backward.proofsInPublic` is `false` (`Lean.Elab.Term.runTactic`), so under that option `private` silently became a no-op and failed to resolve private declarations at all. This contradicted the existing comment stating we deliberately do not check that option. * `@$t` only means "no implicit lambda" for non-identifiers; for an identifier it takes the `elabAtom` branch and makes implicit arguments *explicit*, so `private` broke any lemma with leading implicit arguments. * `by` already abstracts proofs into an auxiliary theorem itself, so `as_aux_lemma` emitted a redundant second one. Elaborate the term outside the exporting context and call `mkAuxTheorem` ourselves instead. This matches what `by exact` does (`exact` is `elabTermEnsuringType` against the goal type, and `runTactic` wraps using the expected type rather than re-inferring), minus the three problems above. `withSynthesize` is required so that synthetic metavariables created while elaborating the term are solved before abstracting; otherwise `mkValueTypeClosure` abstracts them into parameters of the auxiliary theorem and the proof is hoisted back out into the exporting context. Also skip the wrapper for a local hypothesis, pass `cache := !e.hasSorry`, and make the module docstring an actual docstring (`/-!`), which silences a `linter.style.header` warning on every build. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
PR summary 8ae65fe1da
|
| Files | Import difference |
|---|---|
| ../mathlib-ci/scripts/pr_summary/import_trans_difference.sh all | |
| There are 8267 files with changed transitive imports taking up over 360930 characters: this is too many to display! | |
You can run this locally from your mathlib4 directory: |
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
Declarations diff (regex)
+ F
+ FEq
+ aPriv
+ aPrivBothErrors
+ aPrivSilenced
+ bPriv
+ bPrivSilenced
+ f
+ f'
+ fImplicit
+ fImplicit'
+ fLocal
+ fLocalSilenced
+ fNestedBy
+ fProofsInPublic
+ foo
+ fooPub
+ fooThm
+ fα
+ fα'
+ fα''
+ fαPub'
+ fαPub''
+ gImplicit
+ implicitThm
+ sup_aux
+ truncatedSup
+ usePriv
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)
✅ Lean-aware diff — post-build, computed from the Lean environment (commit
8ae65fe).
- +2 new declarations
- −2 removed declarations
+Mathlib.Tactic.PrivateProof.linter.privateProof.warnIfUnnecessary
+Mathlib.Tactic.PrivateProof.privateElab
-Matroid.diff_subset_ground
-Matroid.ground_diff_subset_groundIncrease in strong tech debt: (relative, absolute) = (0.65, 0.66)
| Current number | Change | Type (strong) |
|---|---|---|
| 5130 | 1 | backward.isDefEq.respectTransparency |
| 2677 | 1 | backward.isDefEq.respectTransparency.types |
| 622 | -62 | backward.privateInPublic |
| 267 | -65 | backward.privateInPublic.warn |
| 1 | 1 | backward.proofsInPublic |
Current commit 8ae65fe1da
Reference commit 4d476f6d44
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.sh pr_summary
- The
relativevalue is the weighted sum of the differences with weight given by the inverse of the current value of the statistic. - The
absolutevalue is therelativevalue divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
…f dot notation (data is being constructed classically)
…hen we want to use it in definitions that are not fully ready to remove `backward.privateInPublic`. Note: we also insist on wrapping the proof anyway now (unless it's a free variable), since the user probably wants to see if that'll work.
19e4706 to
bdd3888
Compare
This reverts commit bdd3888.
WIP