Skip to content

Missing cast properties #1443

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

Closed
gallais opened this issue Mar 1, 2021 · 4 comments · Fixed by #1839
Closed

Missing cast properties #1443

gallais opened this issue Mar 1, 2021 · 4 comments · Fixed by #1839
Assignees
Milestone

Comments

@gallais
Copy link
Member

gallais commented Mar 1, 2021

Realised tonight we don't have these (and their equivalents for Vec)

cast-is-id :  {m} (eq : m ≡ m) (k : Fin m)  cast eq k ≡ k
cast-is-id eq Fin.zero    = refl
cast-is-id eq (Fin.suc k) = cong Fin.suc (cast-is-id (suc-injective eq) k)

cast-is-subst :  {m n} (eq : m ≡ n) (k : Fin m)  subst Fin eq k ≡ cast eq k
cast-is-subst refl k = sym (cast-is-id refl k)

Note that it would also be nice to prove commutation lemmas for subst &
constructors for the various inductive types we have.

@JacquesCarette
Copy link
Contributor

I also ended up needing

  cast-cast-is-id :  {m n} (eq₁ : m ≡ n) (eq₂ : n ≡ m) (k : Fin n)  cast eq₁ (cast eq₂ k) ≡ k
  cast-cast-is-id {ℕ.suc m} {.(ℕ.suc _)} eq₁ eq₂ F.zero = refl
  cast-cast-is-id {ℕ.suc m} {.(ℕ.suc _)} eq₁ eq₂ (F.suc k) = cong Fin.suc (cast-cast-is-id (suc-injective eq₁) (suc-injective eq₂) k)

  cast-trans :  {m n o} (eq₁ : m ≡ n) (eq₂ : n ≡ o) (k : Fin m)  cast (trans eq₁ eq₂) k ≡ cast eq₂ (cast eq₁ k)
  cast-trans {ℕ.suc m} {ℕ.suc n} {ℕ.suc o} eq₁ eq₂ F.zero = refl
  cast-trans {ℕ.suc m} {ℕ.suc n} {ℕ.suc o} eq₁ eq₂ (F.suc k) = cong Fin.suc (cast-trans (suc-injective eq₁) (suc-injective eq₂) k)

where I did need to expand out those implicits to get the casts to fire.

@gallais
Copy link
Member Author

gallais commented Mar 2, 2021

cast-cast-is-id seems to be a direct corollary of cast-is-id and cast-trans.

@JacquesCarette
Copy link
Contributor

That could be - I proved cast-cast-is-id first, and then cast-trans was needed later...

@jamesmckinna
Copy link
Contributor

Can/Should we (try to) do this for milestone 2.0?

@gallais gallais self-assigned this Sep 21, 2022
@MatthewDaggitt MatthewDaggitt added this to the v2.0 milestone Sep 23, 2022
gallais added a commit to gallais/agda-stdlib that referenced this issue Sep 30, 2022
gallais added a commit to gallais/agda-stdlib that referenced this issue Sep 30, 2022
@MatthewDaggitt MatthewDaggitt linked a pull request Oct 4, 2022 that will close this issue
@andreasabel andreasabel mentioned this issue Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants