-
Notifications
You must be signed in to change notification settings - Fork 0
/
Solution.v
54 lines (51 loc) · 1.21 KB
/
Solution.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Require Import Problem PeanoNat Omega.
Lemma lemma (n : nat) (l : list nat)
: list_in l n = false -> List.count_occ Nat.eq_dec l n = 0.
Proof.
induction l; simpl; [auto|].
destruct (Nat.eq_dec a n).
- subst a.
rewrite Nat.eqb_refl.
discriminate.
- apply Nat.neq_sym in n0.
apply Nat.eqb_neq in n0.
rewrite n0.
auto.
Qed.
Lemma lemma2 (l : list nat) (n : nat)
: list_in l n = false -> list_in (unique l) n = false.
Proof.
induction l; simpl; [auto|].
destruct (Nat.eq_dec n a).
- subst n.
rewrite Nat.eqb_refl.
discriminate.
- apply Nat.eqb_neq in n0.
rewrite n0.
destruct (list_in l a); [auto|].
simpl.
rewrite n0.
auto.
Qed.
Theorem solution : task.
Proof.
unfold Problem.task.
intros.
induction l; simpl; [discriminate|].
destruct (Nat.eq_dec n a).
- subst n.
clear H.
remember (list_in l a) as b.
destruct b; [auto|].
clear IHl.
simpl.
destruct (Nat.eq_dec a a); [|contradiction].
rewrite lemma; [auto|].
apply lemma2; auto.
- simpl in H.
rewrite (proj2 (Nat.eqb_neq _ _) n0) in H.
specialize (IHl H).
destruct (list_in l a); [auto|].
simpl.
destruct (Nat.eq_dec a n); [contradict n0|]; auto.
Qed.