-
Notifications
You must be signed in to change notification settings - Fork 246
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
Add inverse to Data.Fin.quotRem
and properties
#1422
Comments
Without looking at much, @uzytkownik opened a recent PR (#1402) with some results about |
In fact I think they implemented exactly the results you're looking for! |
Ah! I hadn't seen that. The types match roughly what I had in mind, but the proofs seem very complicated... I'm going to hunt around for a simper proof |
Finding a simpler proof turned out to be way easier than expected. I'll make a PR this evening |
Can we please make |
I have no objections to this. I was going with consistency with |
I have a horrible proof in I would suggest adding |
Before doing anything with reversing multiplications, here's my proof of the other side of the inverse: combine-quotRem : ∀ {n} k (i : Fin (n ℕ.* k)) → uncurry combine (quotRem {n} k i) ≡ i
combine-quotRem {suc n} k i with splitAt k i | P.inspect (splitAt k) i
... | inj₁ j | P.[ eq ] = begin
join k (n ℕ.* k) (inj₁ j) ≡˘⟨ cong (join k (n ℕ.* k)) eq ⟩
join k (n ℕ.* k) (splitAt k i) ≡⟨ join-splitAt k (n ℕ.* k) i ⟩
i ∎
where open ≡-Reasoning
... | inj₂ j | P.[ eq ] = begin
raise {n ℕ.* k} k (uncurry combine (quotRem {n} k j)) ≡⟨ cong (raise k) (combine-quotRem {n} k j) ⟩
join k (n ℕ.* k) (inj₂ j) ≡˘⟨ cong (join k (n ℕ.* k)) eq ⟩
join k (n ℕ.* k) (splitAt k i) ≡⟨ join-splitAt k (n ℕ.* k) i ⟩
i ∎
where open ≡-Reasoning |
It would be nice to be able to demonstrate that
Fin (x * y)
is isomorphic toFin x × Fin y
. This would be useful for proving, for example, inagda-categories
thatFinSetoids
is cartesian, or in something that I'm working on, that you can combine two finite state machines in various wayThe inverse function can be implemented as:
With one direction of inverse proof as:
But I haven't been able to prove the other direction
The text was updated successfully, but these errors were encountered: