Skip to content

Instantly share code, notes, and snippets.

@wilcoxjay
Created September 14, 2023 20:04
Show Gist options
  • Save wilcoxjay/0eff5a2c4f2f07981e87fa321bdaff99 to your computer and use it in GitHub Desktop.
Save wilcoxjay/0eff5a2c4f2f07981e87fa321bdaff99 to your computer and use it in GitHub Desktop.
Induction by hand in Coq
Require Import List.
Import ListNotations.
Definition map_length {A B} (f : A -> B) :
forall l, length (map f l) = length l.
refine (fix loop l := _).
refine (match l with
| [] => _
| x :: xs => _
end).
refine eq_refl.
change (S (length (map f xs)) = S (length xs)). (* optional: cleaner simplifying by hand *)
refine (f_equal S _).
refine (loop xs).
Defined.
Print map_length.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment