Skip to content

feat: add Meta.synthInstance.apply trace class#12699

Merged
kim-em merged 2 commits intoleanprover:masterfrom
kim-em:kim/synthInstance-apply-trace-class
Mar 1, 2026
Merged

feat: add Meta.synthInstance.apply trace class#12699
kim-em merged 2 commits intoleanprover:masterfrom
kim-em:kim/synthInstance-apply-trace-class

Conversation

@kim-em
Copy link
Collaborator

@kim-em kim-em commented Feb 26, 2026

This PR gives the generate function's "apply @foo to Goal" trace nodes their own trace sub-class Meta.synthInstance.apply instead of sharing the parent Meta.synthInstance class.

This allows metaprograms that walk synthesis traces to distinguish instance application attempts from other synthesis nodes by checking td.cls rather than string-matching on the header text.

The new class is registered with inherited := true, so set_option trace.Meta.synthInstance true continues to show these nodes.

Motivated by mathlib's #defeq_abuse diagnostic tactic (leanprover-community/mathlib4#35750) which currently checks headerStr.contains "apply" to identify these nodes. See https://leanprover.zulipchat.com/#narrow/channel/113488-general/topic/backward.2EisDefEq.2ErespectTransparency

🤖 Prepared with Claude Code

Gives the `generate` function's "apply @foo to Goal" trace nodes their own
trace sub-class `Meta.synthInstance.apply` instead of sharing the parent
`Meta.synthInstance` class. This allows metaprograms that walk synthesis
traces to distinguish instance application attempts from other synthesis
nodes without string-matching on the header text.

The new class is registered with `inherited := true`, so
`set_option trace.Meta.synthInstance true` continues to show these nodes.

Motivated by mathlib's `#defeq_abuse` diagnostic tactic which currently
has to check `headerStr.contains "apply"` to identify these nodes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Feb 26, 2026
@mathlib-lean-pr-testing
Copy link

mathlib-lean-pr-testing bot commented Feb 26, 2026

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase d4b560ec4ac4431e5439565f91e73eec1ce12c37 --onto c595413fccaa47ebdc399d9b817c17425687fc26. You can force Mathlib CI using the force-mathlib-ci label. (2026-02-26 02:13:08)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase d4b560ec4ac4431e5439565f91e73eec1ce12c37 --onto 87ec768a509c45987a7d73258da0cc1ef047925c. You can force Mathlib CI using the force-mathlib-ci label. (2026-02-27 03:35:18)

@leanprover-bot
Copy link
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase d4b560ec4ac4431e5439565f91e73eec1ce12c37 --onto 8038a8b8904f89ad9542c8eda11379f8f006eab1. You can force reference manual CI using the force-manual-ci label. (2026-02-26 02:13:09)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mathlib-bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Mar 1, 2026
This PR adds `#defeq_abuse in`, a tactic/command combinator for diagnosing `backward.isDefEq.respectTransparency` failures. It runs the given tactic or command with the option both `true` and `false`, and when the strict setting fails, walks the trace tree to identify the specific `isDefEq` checks that are root causes.

Reusable trace-tree analysis utilities are extracted into `Mathlib.Lean.MessageData.Trace`:
- `TraceResult` / `traceResultOf` — structured access to the ✅/❌/💥 status encoding
- `foldTraceNodes` — generic fold over `MessageData` trace trees
- `stripTraceResultPrefix` / `dedupByString` — helpers for trace content comparison

Companion lean4 PRs that will simplify this further:
- leanprover/lean4#12698 — structured `TraceResult` field on `TraceData`
- leanprover/lean4#12699 — `Meta.synthInstance.apply` trace class

See https://leanprover.zulipchat.com/#narrow/channel/113488-general/topic/backward.2EisDefEq.2ErespectTransparency

🤖 Prepared with Claude Code

Co-authored-by: Thomas R. Murrills <68410468+thorimur@users.noreply.github.com>
@kim-em kim-em marked this pull request as ready for review March 1, 2026 06:49
@kim-em kim-em added the changelog-language Language features and metaprograms label Mar 1, 2026
@kim-em kim-em added this pull request to the merge queue Mar 1, 2026
Merged via the queue into leanprover:master with commit 235b0eb Mar 1, 2026
23 of 24 checks passed
pfaffelh pushed a commit to pfaffelh/mathlib4 that referenced this pull request Mar 2, 2026
…ity#35750)

This PR adds `#defeq_abuse in`, a tactic/command combinator for diagnosing `backward.isDefEq.respectTransparency` failures. It runs the given tactic or command with the option both `true` and `false`, and when the strict setting fails, walks the trace tree to identify the specific `isDefEq` checks that are root causes.

Reusable trace-tree analysis utilities are extracted into `Mathlib.Lean.MessageData.Trace`:
- `TraceResult` / `traceResultOf` — structured access to the ✅/❌/💥 status encoding
- `foldTraceNodes` — generic fold over `MessageData` trace trees
- `stripTraceResultPrefix` / `dedupByString` — helpers for trace content comparison

Companion lean4 PRs that will simplify this further:
- leanprover/lean4#12698 — structured `TraceResult` field on `TraceData`
- leanprover/lean4#12699 — `Meta.synthInstance.apply` trace class

See https://leanprover.zulipchat.com/#narrow/channel/113488-general/topic/backward.2EisDefEq.2ErespectTransparency

🤖 Prepared with Claude Code

Co-authored-by: Thomas R. Murrills <68410468+thorimur@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants