Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(frontends/lean/elaborator): don't block on metavariables that dep…
…end on an `out_param` (#657) We noticed in [mathlib#11128](leanprover-community/mathlib#11128) some cases where parameters weren't being inferred, even though they were `out_param`s to an instance: it turned out the instances themselves also weren't being inferred by the elaborator. This PR tweaks the logic in `elaborator::ready_to_synthesize` to match the `out_param` handling in `type_context_old::preprocess_class`. I created a new function that determines the list of parameters that are either an `out_param` themselves, or depend on an `out_param`. The code is a bit different since `preprocess_class` updates the expression during the check. I left the previous check of `preprocess_class` in an `assert` so we can be sure the results are the same. Zulip thread: https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Instance.20parameters.20depending.20on.20.60out_params.60 Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
- Loading branch information
1 parent
477f17f
commit b89028d
Showing
5 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
prelude | ||
import init.core | ||
|
||
class semiring (G : Type*) := (one : G) | ||
|
||
instance : semiring nat := ⟨1⟩ | ||
|
||
class add_monoid_hom_class (F : Type*) (H : out_param Type*) [semiring H] := | ||
(coe : F → nat → H) | ||
(ext_nat : ∀ (f g : F), coe f 1 = coe g 1 → f = g) | ||
|
||
open add_monoid_hom_class | ||
|
||
class semiring_hom_class (F : Type*) (H : out_param Type*) [semiring H] | ||
extends add_monoid_hom_class F H := | ||
(map_one : ∀ (f : F), coe f 1 = semiring.one) | ||
|
||
-- Ensure `H` can be inferred through the `out_param` of `semiring_hom_class`, | ||
-- even though `semiring H` is a non-out_param depending on it. | ||
lemma semiring_hom_class.ext_nat {F : Type*} {H : Type*} [semiring H] | ||
[semiring_hom_class F H] (f g : F) : f = g := | ||
add_monoid_hom_class.ext_nat f g $ | ||
(semiring_hom_class.map_one f).trans (semiring_hom_class.map_one g).symm |