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] - feat(field_theory/intermediate_field): generalize algebra instances #8761

Closed
wants to merge 4 commits into from

Conversation

Vierkantor
Copy link
Collaborator

The algebra and is_scalar_tower instances for intermediate_field are (again) as general as those for subalgebra.


Open in Gitpod

@Vierkantor Vierkantor added easy < 20s of review time. See the lifecycle page for guidelines. awaiting-review The author would like community review of the PR labels Aug 19, 2021
@bors
Copy link

bors bot commented Aug 19, 2021

✌️ Vierkantor can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

Copy link
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

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

bors d+

@github-actions github-actions bot added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels Aug 19, 2021
@Vierkantor
Copy link
Collaborator Author

Looks like the timeout is due to a bad, but terminating, interaction with the instance [h : fact (p.splits (algebra_map F E))] : algebra p.splitting_field E. Giving that instance a lower priority makes the failing lemma a lot faster again.

@Vierkantor
Copy link
Collaborator Author

Vierkantor commented Aug 19, 2021

I don't really understand what is going on. The issue is that typeclass search gets stuck when it makes a wrong turn at gal.is_scalar_tower. But there should be nothing that can cause a loop there, since there are no is_scalar_tower in its (transitive) assumptions. Instead it keeps on starting a search for a fact (p.splits (algebra_map F E)) instance.

Here's some test code. Above two examples that should, and do, fail fast. Then the problem where Lean gets stuck.

def should_fail_fast1 (α : p.splitting_field) : is_scalar_tower F p.splitting_field p.splitting_field :=
@gal.is_scalar_tower _ _ p p.splitting_field _ _ _  -- failed to synthesize class instance

def should_fail_fast2 : fact
  (@splits F p.splitting_field _inst_1 (@splitting_field.field F _inst_1 p)
    (@algebra_map F p.splitting_field
      (@comm_ring.to_comm_semiring F (@euclidean_domain.to_comm_ring F (@field.to_euclidean_domain F _inst_1)))
      (@ring.to_semiring p.splitting_field
        (@division_ring.to_ring p.splitting_field
          (@field.to_division_ring p.splitting_field (@splitting_field.field F _inst_1 p))))
      (@splitting_field.algebra F _inst_1 p))
p) := infer_instance -- failed to synthesize class instance

def should_work_but_loops (α : p.splitting_field) : is_scalar_tower F F⟮α⟯ p.splitting_field :=
@@intermediate_field.is_scalar_tower_mid _ _ _ _ _ _ _ (@gal.is_scalar_tower _ _ p p.splitting_field _ _ _)
-- timeout, keeps trying to find the above instance

@Vierkantor Vierkantor added awaiting-author A reviewer has asked the author a question or requested changes help-wanted The author needs attention to resolve issues awaiting-review The author would like community review of the PR and removed easy < 20s of review time. See the lifecycle page for guidelines. delegated The PR author may merge after reviewing final suggestions. help-wanted The author needs attention to resolve issues awaiting-author A reviewer has asked the author a question or requested changes labels Aug 23, 2021
The `algebra` and `is_scalar_tower` instances for `intermediate_field` are (again) as general as those for `subalgebra`.
@Vierkantor
Copy link
Collaborator Author

Ah nevermind, there's another similar failure, this case for @is_scalar_tower F ↥(solvable_by_rad F E ) ↥(solvable_by_rad F E)...

@Vierkantor
Copy link
Collaborator Author

Ah this is bad, even the following times out:

example (S : intermediate_field K L) (T : intermediate_field K S) : is_scalar_tower K T S := infer_instance

Use a specialized instance for the common case `is_scalar_tower K S L`, which
was the only instance in the old situation.
@jcommelin
Copy link
Member

Sorry, I was away for a couple of days. Is there some zulip discussion about this problem?

@Vierkantor
Copy link
Collaborator Author

Yes: https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Forever.20inferring.20the.20same.20instance

The issue seems to have been resolved by providing a shortcut, which @eric-wieser seems to agree with.

@jcommelin
Copy link
Member

Thanks 🎉

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 Aug 26, 2021
bors bot pushed a commit that referenced this pull request Aug 26, 2021
…#8761)

The `algebra` and `is_scalar_tower` instances for `intermediate_field` are (again) as general as those for `subalgebra`.
@bors
Copy link

bors bot commented Aug 26, 2021

Build failed (retrying...):

bors bot pushed a commit that referenced this pull request Aug 26, 2021
…#8761)

The `algebra` and `is_scalar_tower` instances for `intermediate_field` are (again) as general as those for `subalgebra`.
@bors
Copy link

bors bot commented Aug 26, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(field_theory/intermediate_field): generalize algebra instances [Merged by Bors] - feat(field_theory/intermediate_field): generalize algebra instances Aug 26, 2021
@bors bors bot closed this Aug 26, 2021
@bors bors bot deleted the generalize-algebra-instance branch August 26, 2021 13:06
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