Skip to content

feat: add @[mvcgen_witness_type] attribute for extensible witness classification#12882

Merged
sgraf812 merged 2 commits intomasterfrom
mvcgen-witness-type
Mar 11, 2026
Merged

feat: add @[mvcgen_witness_type] attribute for extensible witness classification#12882
sgraf812 merged 2 commits intomasterfrom
mvcgen-witness-type

Conversation

@sgraf812
Copy link
Copy Markdown
Contributor

This PR adds an @[mvcgen_witness_type] tag attribute, analogous to @[mvcgen_invariant_type], that allows users to mark types as witness types. Goals whose type is an application of a tagged type are classified as witnesses rather than verification conditions, and appear in a new witnesses section in the mvcgen tactic syntax (before invariants).

Witnesses are concrete values the prover supplies (inspired by zero-knowledge proofs), as opposed to invariants (predicates maintained across iterations) or verification conditions (propositions to prove). The test uses a ZK-inspired example where a SquareRootWitness value must be provided by the prover, with the resulting constraint auto-discharged.

Changes:

  • src/Lean/Elab/Tactic/Do/Attr.lean: register @[mvcgen_witness_type] tag attribute and isMVCGenWitnessType helper
  • src/Lean/Elab/Tactic/Do/VCGen/Basic.lean: add witnesses field to State, three-way classification in addSubGoalAsVC
  • src/Std/Tactic/Do/Syntax.lean: add witnesses section syntax (before invariants), extract shared goalDotAlt/goalCaseAlt syntax kinds
  • src/Lean/Elab/Tactic/Do/VCGen.lean: extract shared elabGoalSection, add elabWitnesses, wire up witness labeling and elaboration
  • tests/elab/mvcgenWitnessType.lean: end-to-end tests for witness-only, witness with -leave, and combined witness+invariant scenarios

🤖 Generated with Claude Code

…lassification

This PR adds an `@[mvcgen_witness_type]` tag attribute, analogous to
`@[mvcgen_invariant_type]`, that allows users to mark types as witness
types. Goals whose type is an application of a tagged type are classified
as witnesses rather than verification conditions, and appear in a new
`witnesses` section in the `mvcgen` tactic syntax.

Witnesses are concrete values the prover supplies (inspired by
zero-knowledge proofs), as opposed to invariants (predicates maintained
across iterations) or verification conditions (propositions to prove).

Also extracts shared `elabGoalSection` logic to reduce duplication
between witness and invariant elaboration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sgraf812 sgraf812 added the changelog-tactics User facing tactics label Mar 11, 2026
@sgraf812 sgraf812 enabled auto-merge March 11, 2026 11:20
@sgraf812 sgraf812 added this pull request to the merge queue Mar 11, 2026
…cgen` docstring

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sgraf812 sgraf812 removed this pull request from the merge queue due to a manual request Mar 11, 2026
@sgraf812 sgraf812 enabled auto-merge March 11, 2026 11:29
@sgraf812 sgraf812 added this pull request to the merge queue Mar 11, 2026
Merged via the queue into master with commit a32be44 Mar 11, 2026
15 checks passed
@sgraf812 sgraf812 deleted the mvcgen-witness-type branch March 11, 2026 12:08
sgraf812 added a commit that referenced this pull request Mar 24, 2026
This reverts commit a32be44.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sgraf812 added a commit that referenced this pull request Mar 25, 2026
This PR removes the witness classification semantics from `mvcgen` introduced
in #12882: the `@[mvcgen_witness_type]` attribute, `witnesses` field in
`VCGen.State`, three-way goal classification, `elabWitnesses`, and
`elabGoalSection`.

The `witnesses` syntax section is kept temporarily for stage0 compatibility
and will be removed in a follow-up PR after the stage0 update.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
github-merge-queue bot pushed a commit that referenced this pull request Mar 25, 2026
This PR reverts #12882 which added the `@[mvcgen_witness_type]` tag
attribute and `witnesses` section to `mvcgen`. Théophile Wallez
confirmed he doesn't need this feature and can get by with `invariants`,
so there is no use in having it.

The actual `mvcgen` syntax needs to be adjusted after a stage0 update in
order for `elabMVCGen` to cope with both old and new syntax.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
sgraf812 added a commit that referenced this pull request Mar 25, 2026
This PR reverts the `mvcgen witnesses` syntax addition and undoes the
back compat hack in `elabMVCGen`.
github-merge-queue bot pushed a commit that referenced this pull request Mar 25, 2026
This PR reverts the `mvcgen witnesses` syntax addition and undoes the
back compat hack in `elabMVCGen`.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-tactics User facing tactics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant