You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reduced the issue to a self-contained, reproducible test case.
Description
Typeclass inference fails to discover an instance which I can create manually using instances known to Lean, and there does not seem to be a type class diamond or loop involved.
class has_note (M : Type) where
note : M
notation "♩" => has_note.note
class has_note2 (M : Type) extends has_note M
variable {ι : Type} (β : ι → Type)
structure foo [∀ i, has_note (β i)] : Type where
to_fun : ∀ i, β i
instance foo.has_note [∀ i, has_note (β i)] : has_note (foo (λ i => β i)) where
note := { to_fun := λ _ => ♩ }
instance foo.has_note2 [∀ i, has_note2 (β i)] : has_note2 (foo (λ i => β i)) where
note := ♩
variable (α : Type) (M : Type)
structure bar [has_note M] where
to_fun : α → M
instance bar.has_note [has_note M] : has_note (bar α M) where
note := { to_fun := λ _ => ♩ }
instance bar.has_note2 [has_note2 M] : has_note2 (bar α M) where
note := ♩
example [has_note2 M] : has_note2 (foo (λ (i : ι) => bar (β i) M)) :=
inferInstance -- fails
example [has_note2 M] : has_note2 (foo (λ (i : ι) => bar (β i) M)) :=
foo.has_note2 _ -- works
The trace for the failing inferInstance is
[Meta.synthInstance.generate] instance foo.has_note2
[Meta.synthInstance.tryResolve]
[Meta.synthInstance.tryResolve] has_note2
(foo fun (i : ι) => bar (β i) M) =?= has_note2 (foo fun (i : ?m.1321) => ?m.1322 i)
[Meta.synthInstance.tryResolve] failure
[Meta.synthInstance] failed
This also fails in Lean 3. [This shows up when building algebraic instances for finsupp and dfinsupp (finitely supported functions, i.e. functions which take the note value (0 or 1) for all but finitely many inputs)].
Expected behavior: [What you expect to happen]
I am expecting type class inference to succeed but my understanding of Lean 4's type class system is poor.
Versions
Lean (version 4.0.0-nightly-2021-06-03, commit c47fff1, Release)
Linux bob 5.4.0-74-generic #83-Ubuntu SMP Sat May 8 02:35:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
The text was updated successfully, but these errors were encountered:
This is a quick and dirty port of `abel1`, just a direct translation of what is in Lean 3, with minimal modifications to use the new `norm_num`. (This PR depends on leanprover#507, integer operations for norm_num.)
Recall `abel1` is the tactic that solves equations; I haven't done the normalizer tactic `abel` yet, but hopefully it's straightforward from here.
- [x] depends on: leanprover#507
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Prerequisites
Description
Typeclass inference fails to discover an instance which I can create manually using instances known to Lean, and there does not seem to be a type class diamond or loop involved.
The trace for the failing
inferInstance
isThis also fails in Lean 3. [This shows up when building algebraic instances for
finsupp
anddfinsupp
(finitely supported functions, i.e. functions which take the note value (0 or 1) for all but finitely many inputs)].Expected behavior: [What you expect to happen]
I am expecting type class inference to succeed but my understanding of Lean 4's type class system is poor.
Versions
Lean (version 4.0.0-nightly-2021-06-03, commit c47fff1, Release)
Linux bob 5.4.0-74-generic #83-Ubuntu SMP Sat May 8 02:35:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
The text was updated successfully, but these errors were encountered: