Created
December 4, 2018 13:59
-
-
Save stackdump/aa97fd20e6fcdba3cd597dfea1706ba3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Set Implicit Arguments. | |
Inductive vector (X : Type) : nat -> Type := | |
| vnul : vector X 0 | |
| vcons {n : nat} (h : X) (v : vector X n) : vector X (S n). | |
Arguments vnul [X]. | |
Definition vhd (X : Type) n (v : vector X (S n)) : X := | |
match v with | |
| vcons _ h _ => h | |
end. | |
Definition vtl (X : Type) n (v : vector X (S n)) : vector X n := | |
match v with | |
| vcons _ _ tl => tl | |
end. | |
Fixpoint vpadd {n : nat} (v1 v2 : vector nat n) : vector nat n := | |
match v1 in vector _ n return vector nat n -> vector nat n with | |
| vnul => fun _ => vnul | |
| vcons _ x1 v1' => fun v2 => vcons (x1 + vhd v2) (vpadd v1' (vtl v2)) | |
end v2. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment