Skip to content

Instantly share code, notes, and snippets.

@palmskog
Created May 27, 2016 02:49
Show Gist options
  • Save palmskog/e92f49ffc862f2ed0e001245b5581b11 to your computer and use it in GitHub Desktop.
Save palmskog/e92f49ffc862f2ed0e001245b5581b11 to your computer and use it in GitHub Desktop.
Require Import Arith.
Fixpoint fin_of_nat (m n : nat) : fin n + {m >= n} :=
match n with
| 0 => inright (Nat.le_0_l _)
| S n' =>
match m with
| 0 => inleft None
| S m' =>
match fin_of_nat m' n' with
| inleft f => inleft (Some f)
| inright pf => inright (gt_le_S _ _ (le_lt_n_Sm _ _ pf))
end
end
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment