Created
April 8, 2015 18:12
-
-
Save wilcoxjay/7793370578da8154472b to your computer and use it in GitHub Desktop.
Nonempty list safe head
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Require Import List. | |
Import ListNotations. | |
Section nelist. | |
Variable (A : Type). | |
Definition nelist : Type := {l : list A | l <> nil}. | |
Definition safe_head (l : nelist) : A. | |
refine (match proj1_sig l as y' return y' <> [] -> _ with | |
| [] => fun H => _ | |
| x :: l' => fun _ => x | |
end _). | |
- congruence. | |
- exact (proj2_sig l). | |
Defined. | |
End nelist. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment