Skip to content

[Merged by Bors] - refactor(Mathlib/Data/DFinsupp/Basic): remove Decidable instances from some DFinsupp functions#13235

Closed
Komyyy wants to merge 5 commits intomasterfrom
Komyyy/DFinsupp.sigmaCurryEquiv
Closed

[Merged by Bors] - refactor(Mathlib/Data/DFinsupp/Basic): remove Decidable instances from some DFinsupp functions#13235
Komyyy wants to merge 5 commits intomasterfrom
Komyyy/DFinsupp.sigmaCurryEquiv

Conversation

@Komyyy
Copy link
Copy Markdown
Contributor

@Komyyy Komyyy commented May 26, 2024

This PR removes Decidable instances from these DFinsupp functions:
1.

def DFinsupp.sigmaUncurry
    {ι : Type u} {α : ι → Type u_2} {δ : (i : ι) → α i → Type v} [(i : ι) → (j : α i) → Zero (δ i j)]
    [(i : ι) → DecidableEq (α i)] [(i : ι) → (j : α i) → Decidable (x ≠ 0)]
    (f : Π₀ (i : ι) (j : α i), δ i j) : Π₀ (i : (i : ι) × α i), δ i.fst i.snd

def DFinsupp.sigmaCurryEquiv
    {ι : Type u} [DecidableEq ι] {α : ι → Type u_2} {δ : (i : ι) → α i → Type v} [(i : ι) → (j : α i) → Zero (δ i j)]
    [(i : ι) → DecidableEq (α i)] [(i : ι) → (j : α i) → Decidable (x ≠ 0)] :
  Π₀ (i : (i : ι) × α i), δ i.fst i.snd ≃ Π₀ (i : ι) (j : α i), δ i j

to

def DFinsupp.sigmaUncurry
    {ι : Type u} {α : ι → Type u_2} {δ : (i : ι) → α i → Type v} [(i : ι) → (j : α i) → Zero (δ i j)] [DecidableEq ι]
    (f : Π₀ (i : ι) (j : α i), δ i j) : Π₀ (i : (i : ι) × α i), δ i.fst i.snd

def DFinsupp.sigmaCurryEquiv
    {ι : Type u} {α : ι → Type u_2} {δ : (i : ι) → α i → Type v} [(i : ι) → (j : α i) → Zero (δ i j)] [DecidableEq ι] :
  Π₀ (i : (i : ι) × α i), δ i.fst i.snd ≃ Π₀ (i : ι) (j : α i), δ i j

We use Trunc.finChoice from #13025 to compute support with the only DecidableEq ι instance.

instance DFinsupp.decidableZero
    {ι : Type u} {β : ι → Type v} [DecidableEq ι] [(i : ι) → Zero (β i)] [(i : ι) → (x : β i) → Decidable (x ≠ 0)] (f : Π₀ (i : ι), β i) :
  Decidable (0 = f)

to

instance DFinsupp.decidableZero
    {ι : Type u} {β : ι → Type v} [(i : ι) → Zero (β i)] [(i : ι) → (x : β i) → Decidable (x = 0)] (f : Π₀ (i : ι), β i) :
  Decidable (f = 0)

We remove the redundant DecidableEq ι instance. Additionally, We replace the (i : ι) → (x : β i) → Decidable (x ≠ 0) instance with (i : ι) → (x : β i) → Decidable (x = 0) because it's more principal, and swaps f and 0.

noncomputable def DFinsupp.comapDomain
    {ι : Type u} {β : ι → Type v} [DecidableEq ι] {κ : Type u_1} [(i : ι) → Zero (β i)] (h : κ → ι) (hh : Function.Injective h) (f : Π₀ (i : ι), β i) :
  Π₀ (k : κ), β (h k)

to

noncomputable def DFinsupp.comapDomain
    {ι : Type u} {β : ι → Type v} {κ : Type u_1} [(i : ι) → Zero (β i)] (h : κ → ι) (hh : Function.Injective h) (f : Π₀ (i : ι), β i) :
  Π₀ (k : κ), β (h k)

DecidableEq ι is required to compute unconstructive support so this is redundant.


Open in Gitpod

@Komyyy Komyyy added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. t-algebra Algebra (groups, rings, fields, etc) labels May 26, 2024
@Komyyy Komyyy requested a review from eric-wieser May 26, 2024 07:59
@Komyyy Komyyy added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label May 26, 2024
@Komyyy Komyyy removed the request for review from eric-wieser May 26, 2024 08:00
@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label May 26, 2024
@Komyyy Komyyy removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label May 26, 2024
@ghost
Copy link
Copy Markdown

ghost commented May 26, 2024

@Komyyy Komyyy added the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label May 26, 2024
@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label May 26, 2024
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jun 6, 2024
@Komyyy Komyyy added awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. and removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) labels Jun 7, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 7, 2024

Import summary

Dependency changes
File Base Count Head Count Change
Mathlib.Data.DFinsupp.Basic 609 610 +1 (+0.16%)
Mathlib.Algebra.DirectSum.Basic 610 611 +1 (+0.16%)
Mathlib.Algebra.DirectSum.Module 853 854 +1 (+0.12%)
Mathlib.Algebra.Module.PID 1456 1457 +1 (+0.07%)

@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Jun 7, 2024
@kim-em
Copy link
Copy Markdown
Contributor

kim-em commented Jul 14, 2024

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Jul 14, 2024
mathlib-bors bot pushed a commit that referenced this pull request Jul 14, 2024
…rom some `DFinsupp` functions (#13235)

This PR removes `Decidable` instances from these `DFinsupp` functions:
1.
```lean
def DFinsupp.sigmaUncurry
    {ι : Type u} {α : ι → Type u_2} {δ : (i : ι) → α i → Type v} [(i : ι) → (j : α i) → Zero (δ i j)]
    [(i : ι) → DecidableEq (α i)] [(i : ι) → (j : α i) → Decidable (x ≠ 0)]
    (f : Π₀ (i : ι) (j : α i), δ i j) : Π₀ (i : (i : ι) × α i), δ i.fst i.snd

def DFinsupp.sigmaCurryEquiv
    {ι : Type u} [DecidableEq ι] {α : ι → Type u_2} {δ : (i : ι) → α i → Type v} [(i : ι) → (j : α i) → Zero (δ i j)]
    [(i : ι) → DecidableEq (α i)] [(i : ι) → (j : α i) → Decidable (x ≠ 0)] :
  Π₀ (i : (i : ι) × α i), δ i.fst i.snd ≃ Π₀ (i : ι) (j : α i), δ i j
```
to
```lean
def DFinsupp.sigmaUncurry
    {ι : Type u} {α : ι → Type u_2} {δ : (i : ι) → α i → Type v} [(i : ι) → (j : α i) → Zero (δ i j)] [DecidableEq ι]
    (f : Π₀ (i : ι) (j : α i), δ i j) : Π₀ (i : (i : ι) × α i), δ i.fst i.snd

def DFinsupp.sigmaCurryEquiv
    {ι : Type u} {α : ι → Type u_2} {δ : (i : ι) → α i → Type v} [(i : ι) → (j : α i) → Zero (δ i j)] [DecidableEq ι] :
  Π₀ (i : (i : ι) × α i), δ i.fst i.snd ≃ Π₀ (i : ι) (j : α i), δ i j
```

We use `Trunc.finChoice` from #13025 to compute support with the only `DecidableEq ι` instance.

2.
```lean
instance DFinsupp.decidableZero
    {ι : Type u} {β : ι → Type v} [DecidableEq ι] [(i : ι) → Zero (β i)] [(i : ι) → (x : β i) → Decidable (x ≠ 0)] (f : Π₀ (i : ι), β i) :
  Decidable (0 = f)
```
to
```lean
instance DFinsupp.decidableZero
    {ι : Type u} {β : ι → Type v} [(i : ι) → Zero (β i)] [(i : ι) → (x : β i) → Decidable (x = 0)] (f : Π₀ (i : ι), β i) :
  Decidable (f = 0)
```

We remove the redundant `DecidableEq ι` instance. Additionally, We replace the `(i : ι) → (x : β i) → Decidable (x ≠ 0)` instance with `(i : ι) → (x : β i) → Decidable (x = 0)` because it's more principal, and swaps `f` and `0`.

3.
```lean
noncomputable def DFinsupp.comapDomain
    {ι : Type u} {β : ι → Type v} [DecidableEq ι] {κ : Type u_1} [(i : ι) → Zero (β i)] (h : κ → ι) (hh : Function.Injective h) (f : Π₀ (i : ι), β i) :
  Π₀ (k : κ), β (h k)
```
to
```lean
noncomputable def DFinsupp.comapDomain
    {ι : Type u} {β : ι → Type v} {κ : Type u_1} [(i : ι) → Zero (β i)] (h : κ → ι) (hh : Function.Injective h) (f : Π₀ (i : ι), β i) :
  Π₀ (k : κ), β (h k)
```

`DecidableEq ι` is required to compute unconstructive support so this is redundant.



Co-authored-by: Pol'tta / Miyahara Kō <52843868+Komyyy@users.noreply.github.com>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jul 14, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title refactor(Mathlib/Data/DFinsupp/Basic): remove Decidable instances from some DFinsupp functions [Merged by Bors] - refactor(Mathlib/Data/DFinsupp/Basic): remove Decidable instances from some DFinsupp functions Jul 14, 2024
@mathlib-bors mathlib-bors bot closed this Jul 14, 2024
@mathlib-bors mathlib-bors bot deleted the Komyyy/DFinsupp.sigmaCurryEquiv branch July 14, 2024 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors. t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants