Skip to content

chore: use private proof elaborator to remove set_option backward.privateInPublic - #42755

Draft
thorimur wants to merge 30 commits into
leanprover-community:masterfrom
thorimur:private-proof-use
Draft

chore: use private proof elaborator to remove set_option backward.privateInPublic#42755
thorimur wants to merge 30 commits into
leanprover-community:masterfrom
thorimur:private-proof-use

Conversation

@thorimur

Copy link
Copy Markdown
Contributor

WIP


Open in Gitpod

thorimur and others added 13 commits August 7, 2026 23:59
…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>
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

PR summary 8ae65fe1da

Import changes for modified files

No significant changes to the import graph

Import changes for all files
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_ground

Increase 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
No changes to weak technical debt.

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 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).

@github-actions github-actions Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 14, 2026
@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant