-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBool_lemma.lp
162 lines (151 loc) · 4.83 KB
/
Bool_lemma.lp
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
require open AL_library.Discriminate
require open AL_library.Bool
require open AL_library.Constructive_logic
require open AL_library.Notation
// Check True. (* True : Prop *)
type true // (* true : B *)
// Check True -> False. (* True -> False : Prop *)
type (⊤ ⊃ ⊥) // imp ⊤ ⊥ : Prop
type _ → _ // ?201 → ?199 : TYPE
// Lemma bool_trivial : forall (P : bool -> Prop) b, P b -> P b.
// Admitted.
theorem bool_trivial : Πp:𝔹→Prop,Πb, π (p b) → π (p b)
//π (imp (P b) (P b))
proof
assume P b H
apply H
qed
//Lemma bool_ext : forall (P : bool -> Prop), P true /\ P false ->
// forall b, P b.
//Admitted.
theorem bool_ext :
Πp, π (p true ∧ p false) → Πb, π(p b)
proof
assume P Hp b
refine bool_ind (λz, P z) _ _ _
apply conj_elim_left _ (P false)
refine Hp
apply conj_elim_right (P true) _
apply Hp
qed
//Lemma bool_ext2 : forall (P : bool -> Prop), P true -> P false ->
// forall b, P b.
//Admitted.
theorem bool_ext2 :
Πp, π (p true) → π (p false) → Πb, π (p b)
proof
assume P HPT HPF b
refine bool_ind (λz, P z) _ _ _
apply HPT
apply HPF
qed
//Lemma andb_prop : forall b1 b2,
// andb b1 b2 = true -> b1 = true /\ b2 = true.
//Proof.
// intros b1 b2 H.
// (* introduit les hypothèses *)
// split. (* sépare le but en deux sous-buts *)
// - destruct b1. (* raisonnement par cas *)
// + reflexivity. (* true = true *)
// + simpl in H. discriminate H. (* false <> true *)
// - destruct b2. (* raisonnement par cas *)
// + reflexivity. (* true = true *)
// + destruct b1 . (* raisonnement par cas *)
// * simpl in H. discriminate H. (* false <> true *)
// * simpl in H. discriminate H. (* false <> true *)
//Qed.
//theorem andb_prop : // Il me manque un outil pour y arriver avec cet énoncé
//Πb1 b2, π (eq {bool} (andb b1 b2) true) →
// π ((eq {bool} b1 true) ∧ (eq {bool} b2 true))
symbol bool_case :
Πp b, π((b = true) ⊃ (p b)) → π((b = false) ⊃ (p b)) → π(p b)
theorem andb_prop b1 b2
: π (imp (andb b1 b2 = true) ((b1 = true) ∧ (b2 = true)))
proof
assume b1 b2 H1
apply conj_intro
// 0. π (b1 = true)
refine bool_case (λz, z = true) b1 _ _ // destruct b1
// 0. π (b1 = true) → π (b1 = true)
assume H2 apply H2
// 1. π (b1 = false) → π (b1 = true)
assume H2
apply eq_ind true (andb b1 b2) _ (λz, b1 = z)
// 0. π (true = andb b1 b2)
rewrite H1 reflexivity
// 1. π (b1 = andb b1 b2)
rewrite H2 reflexivity
// 1. π (b2 = true)
refine bool_case (λz, z = true) b2 _ _ // destruct b2
// 0. π (b2 = true) → π (b2 = true)
assume H2 apply H2
// 1. π (b2 = false) → π (b2 = true)
assume H2
apply eq_ind true (andb b1 b2) _ (λz, b2 = z)
// 0. π (true = andb b1 b2)
rewrite H1 reflexivity
// 1. π (b2 = andb b1 b2)
rewrite H2 reflexivity
qed
theorem andb_prop2 b1 b2
: π (imp (andb b1 b2 = true) ((b1 = true) ∧ (b2 = true)))
proof
assume b1 b2
refine bool_ind (λz, imp (andb z b2 = true) ((z = true) ∧ (b2 = true))) _ _ _
// Case b1 = true
simpl
assume H
apply conj_intro
reflexivity
apply H
// Case b1 = false
simpl
assume H
apply false_elim (false = true ∧ b2 = true)
apply discr_f_t apply H
qed
//[andb_true_iff : forall b1 b2,andb b1 b2 = true <-> b1 = true /\ b2 = true]
// Montrer [or_true_iff], un résultat similaire sur [or].
theorem andb_true_iff b1 b2
: π ((andb b1 b2 = true) ⇔ ((b1 = true) ∧ (b2 = true)))
proof
assume b1 b2
refine bool_ind (λz, imp ((andb z b2) = true)
(z = true ∧ b2 = true) ∧
imp (z = true ∧ b2 = true)
((andb z b2) = true)) _ _ _
// Case b1 = true
simpl
apply conj_intro
assume H apply conj_intro
reflexivity
apply H
assume H apply conj_elim_right (true = true) apply H
// Case b1 = false
simpl
apply conj_intro
assume H
apply false_elim (false = true ∧ b2 = true)
apply discr_f_t apply H
assume H apply conj_elim_left _ (b2 = true) apply H
qed
theorem or_true_iff b1 b2 : π (((orb b1 b2) = true) ⇔ (b1 = true ∨ b2 = true))
proof
assume b1 b2
refine bool_ind (λz, imp ((orb z b2) = true)
(z = true ∨ b2 = true) ∧
imp (z = true ∨ b2 = true)
((orb z b2) = true)) _ _ _
// Case b1 = true
simpl
apply conj_intro
assume H apply disj_intro_left apply H
assume H reflexivity
// Case b1 = false
simpl
apply conj_intro
assume H apply disj_intro_right apply H
assume H apply disj_elim (false = true) (b2 = true) (b2 = true) apply H
assume Hfalse apply false_elim (b2 = true) apply discr_f_t apply Hfalse
assume H2 apply H2
qed