-
Notifications
You must be signed in to change notification settings - Fork 8
/
ProofObjects.v
162 lines (130 loc) · 3.91 KB
/
ProofObjects.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
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
Require Export MoreLogic.
Check b_sum.
Theorem eight_is_beautiful : beautiful 8.
Proof.
apply b_sum with ( n := 3 ) ( m := 5 ).
apply b_3. apply b_5.
Show Proof.
Qed.
Definition eight_is_beautiful''' : beautiful 8 :=
b_sum 3 5 b_3 b_5.
Theorem n2beautiful : forall n, beautiful n -> beautiful ( 2 * n ).
Proof.
intros n H.
simpl. apply b_sum with ( n := n ) ( m := ( n + 0 ) ).
assumption. SearchAbout ( _ + O = _ ).
rewrite -> Plus.plus_0_r. assumption.
Qed.
Definition nine_is_beautiful' : beautiful 9 :=
b_sum 3 6 b_3 ( b_sum 3 3 b_3 b_3 ).
Definition b_plus3' : forall n, beautiful n -> beautiful (3+n) :=
fun ( n : nat ) => fun ( H : beautiful n ) => b_sum 3 n b_3 H.
Definition b_times2': forall n, beautiful n -> beautiful (2 * n) :=
fun ( n : nat ) => fun ( H : beautiful n ) =>
b_times2 n H.
Definition gorgeous_plus13_po: forall n, gorgeous n -> gorgeous (13+n) :=
fun ( n : nat ) => fun ( H : gorgeous n ) =>
gorgeous_plus13 n H.
Print conj.
Theorem and_commutes : forall P Q, P /\ Q -> Q /\ P.
Proof.
intros P Q H. inversion H as [ HP HQ ].
split. assumption. assumption.
Qed.
Print and_commutes.
Definition and_commutes' : forall P Q, P /\ Q -> Q /\ P :=
fun ( P Q : Prop ) ( H : P /\ Q ) =>
match H with
| conj HP HQ => conj Q P HQ HP
end.
Definition conj_fact : forall P Q R, P /\ Q -> Q /\ R -> P /\ R :=
fun ( P Q R : Prop )
=> fun ( HPQ : P /\ Q ) => fun ( HQR : Q /\ R )
=>
match HPQ, HQR with
| conj HP _, conj _ HR => conj P R HP HR
end.
Theorem beautiful_iff_gorgeous :
forall n, beautiful n <-> gorgeous n.
Proof.
intros n. split.
apply beautiful__gorgeous.
apply gorgeous__beautiful.
Show Proof.
Qed.
Definition beautiful_iff_gorgeous' :
forall n, beautiful n <-> gorgeous n :=
fun ( n : nat ) =>
conj ( beautiful n -> gorgeous n ) ( gorgeous n -> beautiful n )
( beautiful__gorgeous n ) ( gorgeous__beautiful n ).
Theorem or_commute : forall P Q, P \/ Q -> Q \/ P.
Proof.
intros P Q H. inversion H as [ HP | HQ ].
right. assumption.
left. assumption.
Show Proof.
Qed.
Definition or_commute' : forall P Q, P \/ Q -> Q \/ P :=
fun ( P Q : Prop ) ( H : P \/ Q ) =>
match H with
| or_introl HP => or_intror Q P HP
| or_intror HQ => or_introl Q P HQ
end.
Check ex.
Definition some_nat_is_even : Prop :=
ex _ ev.
Check ev.
Check ex.
Definition snie : some_nat_is_even :=
ex_intro _ ev 4 ( ev_SS 2 ( ev_SS O ev_O )).
Theorem p : ex _ (fun n => beautiful (S n)).
Proof.
exists 2. apply b_3.
Show Proof.
Qed.
Definition p' : ex _ (fun n => beautiful (S n)) :=
ex_intro nat ( fun n : nat => beautiful ( S n ) ) 2 b_3.
Check plus_comm.
Lemma plus_comm_r : forall a b c, c + ( b + a ) = c + ( a + b ).
Proof.
intros a b c.
rewrite plus_comm with ( m := c ) ( n := b + a ).
rewrite plus_comm with ( m := c ).
rewrite plus_comm with ( m := a ).
reflexivity.
Qed.
Example trans_eq_example' : forall (a b c d e f : nat),
[a;b] = [c;d] ->
[c;d] = [e;f] ->
[a;b] = [e;f].
Proof.
intros a b c d e f H1 H2. inversion H1. inversion H2.
reflexivity.
Qed.
Example trans_eq_example'' : forall (a b c d e f : nat),
[a;b] = [c;d] ->
[c;d] = [e;f] ->
[a;b] = [e;f].
Proof.
Print trans_eq.
intros a b c d e f H1 H2.
apply trans_eq with ( m := [ c; d ] ). assumption.
assumption.
Qed.
(* trans_eq =
fun (X : Type) (n m o : X) (H1 : n = m) (H2 : m = o) =>
eq_ind_r (fun n0 : X => n0 = o) H2 H1
: forall (X : Type) (n m o : X), n = m -> m = o -> n = o *)
Example trans_eq_example''' : forall (a b c d e f : nat),
[a;b] = [c;d] ->
[c;d] = [e;f] ->
[a;b] = [e;f].
Proof.
intros a b c d e f H1 H2.
apply ( trans_eq ( list nat ) [ a ; b ] [ c ; d ] [ e ; f ] H1 H2 ).
Show Proof.
Qed.
Definition addOne : nat -> nat.
intros n. Show Proof. apply S. Show Proof.
apply n. Show Proof.
Defined.