Skip to content

Instantly share code, notes, and snippets.

@mbrcknl
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbrcknl/d77537daa9290b361fbd to your computer and use it in GitHub Desktop.
Save mbrcknl/d77537daa9290b361fbd to your computer and use it in GitHub Desktop.
Fixpoint split
{X Y : Type} (l : list (X*Y))
: (list X) * (list Y) :=
match l with
| nil => (nil, nil)
| (x,y) :: t =>
let (r,s) := split t in
(x :: r, y :: s)
end.
Theorem combine_split : forall X Y (l : list (X * Y)) l1 l2,
split l = (l1, l2) ->
combine l1 l2 = l.
Proof.
intros until l1; revert l;
induction l1 as [|x xs]; destruct l2 as [|y ys]; destruct l as [|p ps]; intro S;
try (destruct p; simpl in *; case_eq (split ps); intros xs' ys' H; rewrite H in S);
inversion S;
try rewrite IHxs with (l := ps); subst; auto.
Qed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment