Skip to content

Instantly share code, notes, and snippets.

@yoshihiro503
Created April 21, 2021 10:35
Show Gist options
  • Save yoshihiro503/7163cfa52557cc0a6be39fdf899e19f6 to your computer and use it in GitHub Desktop.
Save yoshihiro503/7163cfa52557cc0a6be39fdf899e19f6 to your computer and use it in GitHub Desktop.
list mapがリストの長さを変えないことを証明する例です
Require Import List.
Import ListNotations.
Fixpoint list_map {A B:Type} (f : A -> B) (xs : list A) :=
match xs with
| [] => []
| x :: xs => f x :: list_map f xs
end.
Theorem list_map_length : forall (A B: Type) (f: A -> B) xs,
length (list_map f xs) = length xs.
Proof.
induction xs.
- reflexivity.
- simpl. now rewrite IHxs.
Qed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment