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

Refactor coproduct equivalences #1137

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions src/foundation/functoriality-coproduct-types.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,36 +194,48 @@ module _
where

abstract
is-equiv-map-coproduct :
{f : A → A'} {g : B → B'} →
is-equiv f → is-equiv g → is-equiv (map-coproduct f g)
pr1
( pr1
( is-equiv-map-coproduct
( (sf , Sf) , (rf , Rf))
( (sg , Sg) , (rg , Rg)))) = map-coproduct sf sg
pr2
( pr1
( is-equiv-map-coproduct {f} {g}
( (sf , Sf) , (rf , Rf))
( (sg , Sg) , (rg , Rg)))) =
( ( inv-htpy (preserves-comp-map-coproduct sf f sg g)) ∙h
( htpy-map-coproduct Sf Sg)) ∙h
is-section-map-inv-equiv-coproduct :
(f : A ≃ A') (g : B ≃ B') →
( map-coproduct (map-equiv f) (map-equiv g)) ∘
( map-coproduct (map-inv-equiv f) (map-inv-equiv g)) ~ id
Comment on lines +199 to +200
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks to me like you should define

map-equiv-coproduct = map-coproduct (map-equiv f) (map-equiv g)

and

map-inv-equiv-coproduct = map-coproduct (map-inv-equiv f) (map-inv-equiv g)

And then this should be

is-section map-equiv-coproduct map-inv-equiv-coproduct

is-section-map-inv-equiv-coproduct f g =
( inv-htpy
( preserves-comp-map-coproduct
( map-inv-equiv f)
( map-equiv f)
( map-inv-equiv g)
( map-equiv g))) ∙h
( htpy-map-coproduct
( is-section-map-inv-equiv f)
( is-section-map-inv-equiv g)) ∙h
( id-map-coproduct A' B')
pr1
( pr2
( is-equiv-map-coproduct
( (sf , Sf) , (rf , Rf))
( (sg , Sg) , (rg , Rg)))) = map-coproduct rf rg
pr2
( pr2
( is-equiv-map-coproduct {f} {g}
( (sf , Sf) , (rf , Rf))
( (sg , Sg) , (rg , Rg)))) =
( ( inv-htpy (preserves-comp-map-coproduct f rf g rg)) ∙h
( htpy-map-coproduct Rf Rg)) ∙h

abstract
is-retraction-map-inv-equiv-coproduct :
(f : A ≃ A') (g : B ≃ B') →
( map-coproduct (map-inv-equiv f) (map-inv-equiv g)) ∘
( map-coproduct (map-equiv f) (map-equiv g)) ~ id
Comment on lines +216 to +217
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above

is-retraction map-equiv-coproduct map-inv-equiv-coproduct

is-retraction-map-inv-equiv-coproduct f g =
( inv-htpy
( preserves-comp-map-coproduct
( map-equiv f)
( map-inv-equiv f)
( map-equiv g)
( map-inv-equiv g))) ∙h
( htpy-map-coproduct
( is-retraction-map-inv-equiv f)
( is-retraction-map-inv-equiv g)) ∙h
( id-map-coproduct A B)

is-equiv-map-coproduct :
{f : A → A'} {g : B → B'} →
is-equiv f → is-equiv g → is-equiv (map-coproduct f g)
is-equiv-map-coproduct {f} {g} H K =
is-equiv-is-invertible
( map-coproduct (map-inv-is-equiv H) (map-inv-is-equiv K))
( is-section-map-inv-equiv-coproduct (f , H) (g , K))
( is-retraction-map-inv-equiv-coproduct (f , H) (g , K))

map-equiv-coproduct : A ≃ A' → B ≃ B' → A + B → A' + B'
map-equiv-coproduct e e' = map-coproduct (map-equiv e) (map-equiv e')

Expand Down
26 changes: 26 additions & 0 deletions src/univalent-combinatorics/coproduct-types.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ open import elementary-number-theory.natural-numbers
open import foundation.action-on-identifications-functions
open import foundation.coproduct-types
open import foundation.dependent-pair-types
open import foundation.equivalence-extensionality
open import foundation.equivalences
open import foundation.function-extensionality
open import foundation.function-types
open import foundation.functoriality-coproduct-types
open import foundation.functoriality-propositional-truncation
open import foundation.homotopies
open import foundation.identity-types
open import foundation.injective-maps
open import foundation.mere-equivalences
open import foundation.propositional-truncations
open import foundation.type-arithmetic-coproduct-types
Expand Down Expand Up @@ -69,6 +72,29 @@ inr-coproduct-Fin k l = map-coproduct-Fin k l ∘ inr
compute-inl-coproduct-Fin :
(k : ℕ) → inl-coproduct-Fin k 0 ~ id
compute-inl-coproduct-Fin k x = refl

map-Fin-add-ℕ :
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see that the original name Fin-add-ℕ is not your fault, but having a capitalized word (Fin) before an uncapitalized one (add) is a sure sign that the naming should be improved.

I think better names for the entries in this file would be, in order,

  • coproduct-Fin -> compute-coproduct-Fin
  • map-coproduct-Fin -> map-compute-coproduct-Fin
  • Fin-add-ℕ -> inv-compute-coproduct-Fin, and then please add a definition for map-inv-compute-coproduct-Fin
  • inl-coproduct-Fin is fine
  • inr-coproduct-Fin is fine
  • map-Fin-add-ℕ -> map-compute-map-inv-compute-coproduct-Fin (since the maps are not definitionally the same)
  • compute-map-Fin-add-ℕ -> compute-map-inv-compute-coproduct-Fin

Could you please make these renamings as part of this pull request?

(k l : ℕ) → Fin (k +ℕ l) → Fin k + Fin l
map-Fin-add-ℕ k zero-ℕ = inl
map-Fin-add-ℕ k (succ-ℕ l) =
( map-equiv (associative-coproduct {A = Fin k} {B = Fin l})) ∘
( map-coproduct (map-Fin-add-ℕ k l) id)

compute-map-Fin-add-ℕ :
(k l : ℕ) → map-equiv (Fin-add-ℕ k l) ~ map-Fin-add-ℕ k l
Copy link
Collaborator

Choose a reason for hiding this comment

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

After my above suggested renamings

Suggested change
(k l : ℕ) → map-equiv (Fin-add-ℕ k l) ~ map-Fin-add-ℕ k l
(k l : ℕ) →
map-inv-compute-coproduct-Fin k l ~
map-compute-map-inv-compute-coproduct-Fin k l

compute-map-Fin-add-ℕ k zero-ℕ x = refl
compute-map-Fin-add-ℕ k (succ-ℕ l) x =
( htpy-eq
( distributive-map-inv-comp-equiv
( inv-associative-coproduct)
( equiv-coproduct (coproduct-Fin k l) id-equiv))
( x)) ∙
( htpy-eq-equiv
( inv-inv-equiv associative-coproduct)
( map-inv-equiv (equiv-coproduct (coproduct-Fin k l) id-equiv) x)) ∙
( ap
( map-associative-coproduct)
( htpy-map-coproduct (compute-map-Fin-add-ℕ k l) refl-htpy x))
```

### Inclusion of `coproduct-Fin` into the natural numbers
Expand Down
Loading