lean4-htt/tests/lean/run/3313.lean
Kyle Miller 675d2d5a11
feat: only direct parents of classes create projections (#5920)
This PR changes the rule for which projections become instances. Before,
all parents along with all indirect ancestors that were represented as
subobject fields would have their projections become instances. Now only
projections for direct parents become instances.

Features:
- Only parents that are not ancestors of other parents get instances.
This allows "discretionary" indirect parents to be inserted for the
purpose of computing strict resolution orders when
`structure.strictResolutionOrder` is enabled, without having an impact
on typeclass synthesis.
- Non-subobject projections are now theorems if the parent is a
proposition. These are also no longer `@[reducible]`.

Closes #2905
2024-11-12 01:55:17 +00:00

40 lines
1.3 KiB
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.

class AddCommGroup (α : Type) extends Zero α where
class Ring (α : Type) extends Zero α, AddCommGroup α
class Module (R : Type) (M : Type) [Zero R] [Zero M] where
instance (R : Type) [Zero R] : Module R R := ⟨⟩
structure Submodule (R : Type) (M : Type) [Zero R] [Zero M] [Module R M] : Type where
class HasQuotient (A : outParam <| Type) (B : Type) where
quotient' : B → Type
instance Submodule.hasQuotient {R : Type} {M : Type} [Ring R] [AddCommGroup M]
[Module R M]: HasQuotient M (Submodule R M) := ⟨fun _ => M⟩
def Synonym (M : Type) [Zero M] := M
instance Synonym.zero {G : Type} [Zero G] : Zero (Synonym G) := ⟨(Zero.zero : G)⟩
instance Synonym.addCommGroup {G : Type} [AddCommGroup G] : AddCommGroup (Synonym G) :=
{ Synonym.zero with }
instance Synonym.module (M : Type) {R : Type} [Zero R] [Zero M] [Module R M] :
Module R (Synonym M) := { }
variable (R : Type) [Ring R]
set_option maxSynthPendingDepth 2 in
/-- info: Submodule.hasQuotient -/
#guard_msgs in
#synth HasQuotient (Synonym (Synonym R)) (Submodule R (Synonym (Synonym R))) -- works
/-!
After https://github.com/leanprover/lean4/pull/5920 works without changing maxSynthPendingDepth.
-/
/-- info: Submodule.hasQuotient -/
#guard_msgs in
#synth HasQuotient (Synonym (Synonym R)) (Submodule R (Synonym (Synonym R)))