-
Notifications
You must be signed in to change notification settings - Fork 0
/
exch.v
79 lines (67 loc) · 1.29 KB
/
exch.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
(** Proof Reflection in Coq ; exch.v ; 050128 ; Dimitri Hendriks; Coq 8.0pl1 *)
Require Export objects.
Set Implicit Arguments.
Section exch_prf.
Variable l1 l2 : list nat.
Let P := prf l1 l2.
(* (exch n n)=(S n), (exch n (S n))=n, otherwise (exch n m)=m, see lemma's below *)
Fixpoint exch (n i : nat) {struct i} : nat :=
match n, i with
| O, O => 1
| O, S O => 0
| O, i' => i' (*i'>1*)
| S n', O => 0
| S n', S i' => S (exch n' i')
end.
Definition exch_hyp : nat -> P -> P := map_prf_hyp exch.
Lemma exch_ok1 : forall n : nat, exch n n = S n.
Proof.
simple induction n; simpl in |- *.
reflexivity.
intros n' IH.
rewrite IH.
reflexivity.
Qed.
Lemma exch_ok2 : forall n : nat, exch n (S n) = n.
simple induction n; simpl in |- *.
reflexivity.
intro n'.
case n'.
reflexivity.
intros n'' IH.
rewrite IH.
reflexivity.
Qed.
Lemma exch_ok3 : forall i n : nat, n <> i -> S n <> i -> exch n i = i.
Proof.
simple induction i.
simple destruct n.
intro H.
apply False_ind.
apply H.
reflexivity.
reflexivity.
intros i' IH n.
case n.
case i'.
intros H H0.
apply False_ind.
apply H0.
reflexivity.
reflexivity.
intros n' H H0.
simpl in |- *.
rewrite (IH n').
reflexivity.
red in |- *.
intro H1.
apply H.
rewrite H1.
reflexivity.
red in |- *.
intro H1.
apply H0.
rewrite H1.
reflexivity.
Qed.
End exch_prf.