Skip to content

Add inverse to Data.Fin.quotRem and properties #1422

Closed
@Taneb

Description

@Taneb

It would be nice to be able to demonstrate that Fin (x * y) is isomorphic to Fin x × Fin y. This would be useful for proving, for example, in agda-categories that FinSetoids is cartesian, or in something that I'm working on, that you can combine two finite state machines in various way

The inverse function can be implemented as:

combine :  {n k}  Fin k  Fin n  Fin (n ℕ.* k)
combine x zero = inject+ _ x
combine x (suc y) = raise _ (combine x y)

With one direction of inverse proof as:

 :  {n k} x (y : Fin n)  quotRem k (combine x y) ≡ (x , y)
quotRem-combine {suc n} {k} x 0F rewrite splitAt-inject+ k (n ℕ.* k) x = refl
quotRem-combine {suc n} {k} x (suc y) rewrite splitAt-raise k (n ℕ.* k) (combine x y) = cong (Data.Product.map₂ suc) (quotRem-combine x y)

But I haven't been able to prove the other direction

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions