lean4-htt/tests/lean/run/auxParentProj.lean
Leonardo de Moura 70aa6bc81d
fix: detect stuck mvars through auxiliary parent projections (#12564)
This PR fixes `getStuckMVar?` to detect stuck metavariables through
auxiliary parent projections created for diamond inheritance. These
coercions (e.g., `AddMonoid'.toAddZero'`) are not registered as regular
projections because they construct the parent value from individual
fields rather than extracting a single field. Previously,
`getStuckMVar?` would give up when encountering them, preventing TC
synthesis from being triggered.

- Add `AuxParentProjectionInfo` environment extension to `ProjFns.lean`
recording `numParams` and `fromClass` for these coercions
- Register the info during structure elaboration in
`mkCoercionToCopiedParent`
- Consult the new extension in `getStuckMVar?` as a fallback when
`getProjectionFnInfo?` returns `none`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Kim Morrison <kim@tqft.net>
2026-02-23 03:46:06 +00:00

21 lines
865 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-!
# Test for auxiliary parent projections (diamond inheritance)
`getStuckMVar?` should detect stuck metavariables through auxiliary parent projections
created for diamond inheritance. Previously, these coercions were not registered as projections,
so `getStuckMVar?` would give up and TC synthesis was never triggered.
-/
class AddZero' (M : Type u_2) extends Zero M, Add M where
class AddMonoid' (M : Type u) extends Add M, AddZero' M where
instance : AddZero' Int where
instance : AddMonoid' Int where
theorem sub_nonneg' {α : Type u} [AddMonoid' α] [Sub α] [LE α] {a b : α} :
0 ≤ a - b ↔ b ≤ a := sorry
-- This used to fail because `getStuckMVar?` could not find the stuck mvar
-- through `AddMonoid'.toAddZero'` (an auxiliary parent projection from diamond inheritance).
example (a b : Int) : 0 ≤ a - b ↔ b ≤ a := by rw [sub_nonneg']