Skip to content

Instantly share code, notes, and snippets.

@palmskog
Created September 21, 2018 18:35
Show Gist options
  • Save palmskog/6ca495b89d5f3bb9fb60b6403eff7544 to your computer and use it in GitHub Desktop.
Save palmskog/6ca495b89d5f3bb9fb60b6403eff7544 to your computer and use it in GitHub Desktop.
Require Import List.
Import ListNotations.
Section dedup.
Variable A : Type.
Hypothesis A_eq_dec : forall x y : A, {x = y} + {x <> y}.
Fixpoint dedup (xs : list A) : list A :=
match xs with
| [] => []
| x :: xs => let tail := dedup xs in
if in_dec A_eq_dec x xs then
tail
else
x :: tail
end.
Lemma dedup_In : forall (x : A) xs,
In x xs ->
In x (dedup xs).
Proof using.
induction xs; intros; simpl in *.
- intuition.
- case in_dec; intuition; subst; simpl; auto.
Qed.
End dedup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment