Skip to content

Discreteness and H-Levels of W-types #498

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

TOTBWF
Copy link
Collaborator

@TOTBWF TOTBWF commented May 17, 2025

Description

This PR proves that a W-type W A B is discrete when A is discrete and B x is Listable for every x. I've also added
a characterisation of equality types of W-types. These should make arguments about decidable equality a bit easier to make for inductive types: instead of doing a giant $O(n^2)$ case bash, we can construct an equivalence with a W-type instead. Some automation on this front would be useful, but I've spent enough time shaving this yak already :)

Checklist

Before submitting a merge request, please check the items below:

  • I've read the contributing guidelines.
  • The imports of new modules have been sorted with support/sort-imports.hs (or nix run --experimental-features nix-command -f . sort-imports).
  • All new code blocks have "agda" as their language.

If your change affects many files without adding substantial content, and
you don't want your name to appear on those pages (for example, treewide
refactorings or reformattings), start the commit message and PR title with chore:.

@TOTBWF TOTBWF requested review from ncfavier and plt-amy May 17, 2025 21:58
@Lavenza
Copy link
Member

Lavenza commented May 17, 2025

Pull request preview

Changed pages

Comment on lines +591 to +602
sup x f ≡ sup y g
≃⟨ ap-equiv W-fixpoint ⟩
(x , f) ≡ (y , g)
≃˘⟨ Iso→Equiv Σ-pathp-iso ⟩
Σ[ p ∈ (x ≡ y) ] PathP (λ i → B (p i) → W A B) f g
≃˘⟨ Σ-ap-snd (λ p → funext-dep≃) ⟩
Σ[ p ∈ (x ≡ y) ] (∀ {bw bv} → PathP (λ i → B (p i)) bw bv → f bw ≡ g bv)
≃⟨ Σ-ap-snd (λ p → Π-impl-cod≃ λ bw → Π-impl-cod≃ λ bv → Π-cod≃ (λ q → Path≃Code (f bw) (g bv))) ⟩
Σ[ p ∈ (x ≡ y) ] (∀ {bw bv} → PathP (λ i → B (p i)) bw bv → Code (f bw) (g bv))
≃⟨⟩
Code (sup x f) (sup y g)
≃∎
Copy link
Member

Choose a reason for hiding this comment

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

Cool!

@plt-amy
Copy link
Member

plt-amy commented May 18, 2025

I have this much simpler identity system construction sitting around:

W-is-hlevel {ℓ} {ℓ'} {A = A} {B = B} n ahl = identity-system→hlevel n W-ids W-tr where
  W-code : W A B  W A B  Type (ℓ ⊔ ℓ')
  W-code (sup x f) (sup y g) = Σ[ p ∈ x ≡ᵢ y ] ( i  W-code (f i) (g (substᵢ B p i)))

  W-code-refl :  x  W-code x x
  W-code-refl (sup x f) = reflᵢ , λ a  W-code-refl (f a)

  W-decode :  x y  W-code x y  x ≡ y
  W-decode (sup x f) (sup y g) (reflᵢ , p) = ap (sup x) (funext λ a  W-decode _ _ (p a))

  W-coh :  x y (p : W-code x y)  PathP (λ i  W-code x (W-decode x y p i)) (W-code-refl x) p
  W-coh (sup x f) (sup y g) (reflᵢ , p) = Σ-pathp refl (funextP λ x  W-coh (f x) (g x) (p x))

  W-ids : is-identity-system W-code W-code-refl
  W-ids .to-path = W-decode _ _
  W-ids .to-path-over = W-coh _ _

  W-tr :  x y  is-hlevel (W-code x y) n
  W-tr (sup x f) (sup y g) = Σ-is-hlevel n (≡ᵢ-is-hlevel' ahl x y) λ x  Π-is-hlevel n λ i  W-tr _ _

@TOTBWF
Copy link
Collaborator Author

TOTBWF commented May 18, 2025

I think there is value in having both, but mostly because I think the proof of Path≃Code is cute 🙂

We should probably provide a version of your identity system as an extensionality transformer though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants