Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - chore(algebra/punit_instances): add comm_cancel_monoid_with_zero, normalized_gcd_monoid, and scalar action instances #10312

Closed
wants to merge 2 commits into from

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Nov 13, 2021

Motivated by this Zulip thread.

This also moves the simp lemmas closer to the instances they refer to.


Open in Gitpod

@eric-wieser eric-wieser added the awaiting-review The author would like community review of the PR label Nov 13, 2021
@eric-wieser eric-wieser changed the title chore(algebra/punit_instances): add comm_cancel_monoid_with_zero and normalized_gcd_monoid instances chore(algebra/punit_instances): add comm_cancel_monoid_with_zero, normalized_gcd_monoid, and scalar action instances Nov 13, 2021
Comment on lines +137 to +138
/-! TODO: provide `mul_semiring_action R punit` -/
-- importing it here currently causes timeouts elsewhere due to the import order changing
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing horrible timeouts in files I don't care about, so in the interest of getting all the other instances merged I'm going to skip this one.

@robertylewis
Copy link
Member

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Dec 8, 2021
bors bot pushed a commit that referenced this pull request Dec 8, 2021
…normalized_gcd_monoid`, and scalar action instances (#10312)

Motivated by [this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Is.200.20not.20equal.20to.201.3F/near/261366868). 

This also moves the simp lemmas closer to the instances they refer to.
@bors
Copy link

bors bot commented Dec 8, 2021

Build failed (retrying...):

bors bot pushed a commit that referenced this pull request Dec 8, 2021
…normalized_gcd_monoid`, and scalar action instances (#10312)

Motivated by [this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Is.200.20not.20equal.20to.201.3F/near/261366868). 

This also moves the simp lemmas closer to the instances they refer to.
@bors
Copy link

bors bot commented Dec 8, 2021

Build failed (retrying...):

bors bot pushed a commit that referenced this pull request Dec 9, 2021
…normalized_gcd_monoid`, and scalar action instances (#10312)

Motivated by [this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Is.200.20not.20equal.20to.201.3F/near/261366868). 

This also moves the simp lemmas closer to the instances they refer to.
@bors
Copy link

bors bot commented Dec 9, 2021

Build failed (retrying...):

bors bot pushed a commit that referenced this pull request Dec 9, 2021
…normalized_gcd_monoid`, and scalar action instances (#10312)

Motivated by [this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Is.200.20not.20equal.20to.201.3F/near/261366868). 

This also moves the simp lemmas closer to the instances they refer to.
@bors
Copy link

bors bot commented Dec 9, 2021

Build failed (retrying...):

…normalized_gcd_monoid`, and scalar action instances (#10312)

Motivated by [this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Is.200.20not.20equal.20to.201.3F/near/261366868). 

This also moves the simp lemmas closer to the instances they refer to.
@bors
Copy link

bors bot commented Dec 9, 2021

Build failed:

@Vierkantor
Copy link
Collaborator

The direct cause of the error seems to be that the _inst provided by letI fails the defeq check:

@normed_space 𝕜
  (@continuous_multilinear_map 𝕜 (fin m) (λ (i : fin m), E) (Π (i : ι), F' i)
     (λ (a b : fin m),
        (λ (a b : fin m), @subtype.decidable_eq ℕ (λ (x : ℕ), x < m) (λ (a b : ℕ), nat.decidable_eq a b) a b) a
          b)
     (@ring.to_semiring 𝕜
        (@normed_ring.to_ring 𝕜
           (@normed_comm_ring.to_normed_ring 𝕜
              (@normed_field.to_normed_comm_ring 𝕜 (@nondiscrete_normed_field.to_normed_field 𝕜 _inst_12)))))
     (λ (i : fin m),
        @add_comm_group.to_add_comm_monoid ((λ (i : fin m), E) i)
          (@normed_group.to_add_comm_group ((λ (i : fin m), E) i) ((λ (i : fin m), _inst_11) i)))
     (@add_comm_group.to_add_comm_monoid (Π (i : ι), F' i)
        (@normed_group.to_add_comm_group (Π (i : ι), F' i)
           (@pi.normed_group ι (λ (i : ι), F' i) _inst_14 (λ (i : ι), _inst_15 i))))
     (λ (i : fin m),
        @normed_space.to_module 𝕜 ((λ (i : fin m), E) i) (@nondiscrete_normed_field.to_normed_field 𝕜 _inst_12)
          ((λ (i : fin m), _inst_11) i)
          ((λ (i : fin m), _inst_13) i))
     (@normed_space.to_module 𝕜 (Π (i : ι), F' i) (@nondiscrete_normed_field.to_normed_field 𝕜 _inst_12)
        (@pi.normed_group ι (λ (i : ι), F' i) _inst_14 (λ (i : ι), _inst_15 i))
        (@pi.normed_space 𝕜 ι (@nondiscrete_normed_field.to_normed_field 𝕜 _inst_12) (λ (i : ι), F' i) _inst_14
           (λ (i : ι), _inst_15 i)
           (λ (i : ι), _inst_16 i)))
     (λ (i : fin m),
        @uniform_space.to_topological_space ((λ (i : fin m), E) i)
          (@metric_space.to_uniform_space' ((λ (i : fin m), E) i)
             (@semi_normed_group.to_pseudo_metric_space ((λ (i : fin m), E) i)
                (@normed_group.to_semi_normed_group ((λ (i : fin m), E) i) ((λ (i : fin m), _inst_11) i)))))
     (@uniform_space.to_topological_space (Π (i : ι), F' i)
        (@metric_space.to_uniform_space' (Π (i : ι), F' i)
           (@semi_normed_group.to_pseudo_metric_space (Π (i : ι), F' i)
              (@normed_group.to_semi_normed_group (Π (i : ι), F' i)
                 (@pi.normed_group ι (λ (i : ι), F' i) _inst_14 (λ (i : ι), _inst_15 i)))))))
  (@nondiscrete_normed_field.to_normed_field 𝕜 _inst_12)
  (@continuous_multilinear_map.to_normed_group 𝕜 (fin m) (λ (i : fin m), E) (Π (i : ι), F' i)
     (λ (a b : fin m),
        (λ (a b : fin m), @subtype.decidable_eq ℕ (λ (x : ℕ), x < m) (λ (a b : ℕ), nat.decidable_eq a b) a b) a
          b)
     (fin.fintype m)
     _inst_12
     (λ (i : fin m), (λ (i : fin m), _inst_11) i)
     (λ (i : fin m), (λ (i : fin m), _inst_13) i)
     (@pi.normed_group ι (λ (i : ι), F' i) _inst_14 (λ (i : ι), _inst_15 i))
     (@pi.normed_space 𝕜 ι (@nondiscrete_normed_field.to_normed_field 𝕜 _inst_12) (λ (i : ι), F' i) _inst_14
        (λ (i : ι), _inst_15 i)
        (λ (i : ι), _inst_16 i)))
 := _inst_1 ?x_1 ?x_2
failed is_def_eq

@Vierkantor
Copy link
Collaborator

In addition, local attribute [-instance] punit.mul_action fixes the error.

@eric-wieser
Copy link
Member Author

Does punit appear anywhere in the goal?

@Vierkantor
Copy link
Collaborator

Nope, although punit.mul_action does appear at a few points in the instance search log. I have no idea why that would break anything (out_params sneakily being unified wrongly?)

@Vierkantor
Copy link
Collaborator

Another way to fix it is to remind the elaborator that the instance exists:

  { intros m hm x hx,
    have := has_fderiv_within_at_pi.2 (λ i, (h i).fderiv_within m hm x hx),
    letI : normed_space 𝕜
      (continuous_multilinear_map 𝕜 (λ (i : fin m), E) (Π (i : ι), F' i)) := infer_instance,
    convert (L m).has_fderiv_at.comp_has_fderiv_within_at x this }, -- works?!

@Vierkantor
Copy link
Collaborator

Another thought, is this the instance-under-binder issue popping up again? (lean4 #509) That one has similar symptoms of inexplicable failure to find instances that goes away if you put the failing instance on its own and infer_instance it.

@eric-wieser
Copy link
Member Author

I went for the letI solution because it's a bit more explanatory and the comment can go closer to the problem.

Weirly, by apply_instance fails where infer_instance succeeds...

@eric-wieser
Copy link
Member Author

bors merge

bors bot pushed a commit that referenced this pull request Dec 10, 2021
…normalized_gcd_monoid`, and scalar action instances (#10312)

Motivated by [this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Is.200.20not.20equal.20to.201.3F/near/261366868). 

This also moves the simp lemmas closer to the instances they refer to.



Co-authored-by: Anne Baanen <vierkantor@vierkantor.com>
@bors
Copy link

bors bot commented Dec 10, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title chore(algebra/punit_instances): add comm_cancel_monoid_with_zero, normalized_gcd_monoid, and scalar action instances [Merged by Bors] - chore(algebra/punit_instances): add comm_cancel_monoid_with_zero, normalized_gcd_monoid, and scalar action instances Dec 10, 2021
@bors bors bot closed this Dec 10, 2021
@bors bors bot deleted the eric-wieser/punit-instances branch December 10, 2021 02:07
Comment on lines +1903 to +1905
-- TODO: lean can't find the instance without this: If we remove this `letI`, we have to add
-- `local attribute [-instance] punit.mul_action` instead!
letI : normed_space 𝕜 (E [×m]→L[𝕜] (Π i, F' i)) := infer_instance,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#11972 (accidentally) makes this unecessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants