Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

chore(data/mv_polynomial): adding decidable_eq assumptions#18791

Closed
joelriou wants to merge 7 commits intomasterfrom
polynomial-decidable-eq
Closed

chore(data/mv_polynomial): adding decidable_eq assumptions#18791
joelriou wants to merge 7 commits intomasterfrom
polynomial-decidable-eq

Conversation

@joelriou
Copy link
Copy Markdown
Collaborator


Open in Gitpod

@joelriou joelriou added the WIP Work in progress label Apr 11, 2023
@github-actions github-actions bot added the modifies-synchronized-file This PR touches a files that has already been ported to mathlib4, and may need a synchronization PR. label Apr 11, 2023
@joelriou joelriou changed the title chore(data/mv_polynomial): adding decidable_eq assumtions chore(data/mv_polynomial): adding decidable_eq assumptions Apr 11, 2023
Copy link
Copy Markdown
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.

I think this PR has grown out of control(already!).

Can you split off a PR that edits only the mv_polynomial directory, and doesn't attempt to remove any other classicals?

Comment on lines +150 to 151
def frange [decidable_eq R] (p : R[X]) : finset R :=
finset.image (λ n, p.coeff n) p.support
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's probably best to make this noncomputable for now.

Comment on lines 489 to 490
noncomputable def roots [decidable_eq R] (p : R[X]) : multiset R :=
if h : p = 0 then ∅ else classical.some (exists_multiset_roots h)
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser Apr 11, 2023

Choose a reason for hiding this comment

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

This change is unhelpful; the definition is already very non-computable, so there's no point adding this argument,

Suggested change
noncomputable def roots [decidable_eq R] (p : R[X]) : multiset R :=
if h : p = 0 thenelse classical.some (exists_multiset_roots h)
noncomputable def roots (p : R[X]) : multiset R :=
by haveI := classical.dec_eq R; exact
if h : p = 0 thenelse classical.some (exists_multiset_roots h)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've pushed a fix to that effect

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. I think that all the definitions on polynomials which require a decidable_eq instance should be obtained from classical.dec_eq as above, including for example mv_polynomial.vars in data/mv_polynomial/variables.lean. Otherwise, it escalates quickly... If you agree, I may restart this PR from scratch. (And eventually, the same could be done on the mathlib4 side.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure I agree that they should be, but at any rate they are already define that way. So the minimal fix is to add classical.dec_eq to all the relevant existing defs, and only add decidable_eq when need by theorem statements.

@kim-em
Copy link
Copy Markdown
Collaborator

kim-em commented Apr 21, 2023

Please don't merge this without careful discussion on zulip! Several years ago we went to great effort to remove decidability instances from the polynomial library, and intentionally made everything noncomputable and classical. I don't think these sort of changes are going to be viable.

@eric-wieser
Copy link
Copy Markdown
Member

@semorrison, the idea here is to add the missing instances to lemmas, which I think is widely agreed as sensible. You're right though that in it's current form it also adds them to defs which we don't want to do (at least not mid-port)

@eric-wieser
Copy link
Copy Markdown
Member

I think this PR has grown out of control(already!).

Can you split off a PR that edits only the mv_polynomial directory, and doesn't attempt to remove any other classicals?

I've done this in #18848

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

modifies-synchronized-file This PR touches a files that has already been ported to mathlib4, and may need a synchronization PR. WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants