21
21
22
22
(** We start by some general notions for expressing the bijection *)
23
23
24
- Definition identity (A:Type) := fun a:A=> a.
25
- Definition compose (A B C:Type) (g:B->C) (f:A->B) := fun a:A=> g(f a).
24
+ Definition identity (A:Type) := fun ( a:A) => a.
25
+ Definition compose (A B C:Type) (g:B->C) (f:A->B) := fun ( a:A) => g(f a).
26
26
27
27
Section Denumerability.
28
28
29
29
(** What it means to have the same cardinality *)
30
30
Definition same_cardinality (A:Type ) (B:Type ) :=
31
31
{f:A->B & { g:B->A |
32
- (forall b,(compose _ _ _ f g) b= (identity B) b) /\
32
+ (forall b,(compose _ _ _ f g) b = (identity B) b) /\
33
33
forall a,(compose _ _ _ g f) a = (identity A) a}}.
34
34
35
35
(** What it means to be a denumerable *)
@@ -58,10 +58,8 @@ Defined.
58
58
59
59
End Denumerability.
60
60
61
-
62
61
(** We first prove that [Z] is denumerable *)
63
62
64
- From Coq Require Div2.
65
63
From Coq Require Import ZArith.
66
64
From Coq Require Import Lia.
67
65
@@ -73,11 +71,12 @@ Definition Z_to_nat_i (z:Z) :nat :=
73
71
| Zneg p => pred (Nat.double (nat_of_P p))
74
72
end .
75
73
76
- (** Some lemmas about parity. They could be added to [Arith.Div2] *)
77
- Lemma odd_pred2n: forall n : nat, Even.odd n -> {p : nat | n = pred (Nat.double p)}.
74
+ (** Some lemmas about parity. *)
75
+ Lemma odd_pred2n: forall n : nat, Nat.Odd_alt n -> {p : nat | n = pred (Nat.double p)}.
78
76
Proof .
79
77
intros n H_odd;
80
- rewrite (Div2.odd_double _ H_odd);
78
+ apply Nat.Odd_alt_Odd in H_odd;
79
+ rewrite (Nat.Odd_double _ H_odd);
81
80
exists (S (Nat.div2 n));
82
81
generalize (Nat.div2 n);
83
82
clear n H_odd; intros n;
@@ -86,12 +85,19 @@ Proof.
86
85
reflexivity.
87
86
Defined .
88
87
88
+ Lemma even_2n : forall n : nat, Nat.Even_alt n -> {p : nat | n = Nat.double p}.
89
+ Proof .
90
+ intros n H_even; exists (Nat.div2 n).
91
+ apply Nat.Even_alt_Even in H_even.
92
+ apply Nat.Even_double; assumption.
93
+ Defined .
94
+
89
95
Lemma even_odd_exists_dec : forall n, {p : nat | n = Nat.double p} + {p : nat | n = pred (Nat.double p)}.
90
96
Proof .
91
97
intro n;
92
- destruct (Even.even_odd_dec n) as [H_parity|H_parity];
93
- [ left; apply (Div2. even_2n _ H_parity)
94
- | right; apply (odd_pred2n _ H_parity)].
98
+ destruct (Nat.Even_Odd_dec n) as [H_parity|H_parity];
99
+ [ left; apply Nat.Even_alt_Even in H_parity; apply ( even_2n _ H_parity)
100
+ | right; apply Nat.Odd_alt_Odd in H_parity; apply (odd_pred2n _ H_parity)].
95
101
Defined .
96
102
97
103
(** An injection from [nat] to [Z] *)
@@ -106,17 +112,20 @@ Proof.
106
112
unfold Nat.double; intros m n; lia.
107
113
Defined .
108
114
109
- Lemma parity_mismatch_not_eq:forall m n, Even.even m -> Even.odd n -> ~m= n.
115
+ Lemma parity_mismatch_not_eq:forall m n, Nat.Even_alt m -> Nat.Odd_alt n -> m <> n.
110
116
Proof .
111
- intros m n H_even H_odd H_eq; subst m;
112
- apply (Even.not_even_and_odd n); trivial.
117
+ intros m n H_even H_odd H_eq; subst m.
118
+ apply Nat.Even_alt_Even in H_even.
119
+ apply Nat.Odd_alt_Odd in H_odd.
120
+ apply (Nat.Even_Odd_False n); trivial.
113
121
Defined .
114
122
115
- Lemma even_double: forall n, Even.even (Nat.double n).
123
+ Lemma even_double : forall n, Nat.Even_alt (Nat.double n).
116
124
Proof .
117
125
intro n;
118
126
unfold Nat.double;
119
- replace (n + n) with (2*n); auto with arith; lia.
127
+ replace (n + n) with (2*n);
128
+ [apply Nat.Even_alt_Even; exists n; reflexivity | lia].
120
129
Defined .
121
130
122
131
Lemma double_S_neq_pred:forall m n, ~Nat.double (S m) = pred (Nat.double n).
0 commit comments