Advertisement
Guest User

Untitled

a guest
Jul 10th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.39 KB | None | 0 0
  1. Require Import Setoid.
  2. Axiom PNP : forall p : Prop, p \/ ~p.
  3. Lemma L0 : forall (x y : Prop), x->y->x.
  4. Proof.
  5. intros x y.
  6. intros H1 H2.
  7. assumption.
  8. Qed.
  9.  
  10. Lemma L1: forall (x y : Prop), x -> (x \/ y).
  11. Proof.
  12. intros x y.
  13. intros H1.
  14. left.
  15. exact H1.
  16. Qed.
  17.  
  18. Lemma L2: forall (x y : Prop), x->y->(x/\y).
  19. Proof.
  20. intros x y.
  21. intros H1 H2.
  22. split.
  23. exact H1.
  24. exact H2.
  25. Qed.
  26.  
  27.  
  28. Lemma L3: forall (x y : Prop), (x->y)->(~y->~x).
  29. Proof.
  30. intros x y.
  31. intros H1 H2.
  32. intro H3.
  33. apply (H2 (H1 H3)).
  34. Qed.
  35.  
  36. Theorem T2: forall (e f g h : Prop), (e->(f/\~g))->((f\/g)->h)->e->h.
  37. Proof.
  38. intros e f g h.
  39. intros H1.
  40. intros H2.
  41. intros H3.
  42. apply H1 in H3.
  43. destruct H3 as [H3a H3b].
  44. assert (H4 : f->(f\/g)).
  45. apply L1.
  46. apply (H2 (H4 H3a)).
  47. Qed.
  48.  
  49. Theorem T3: forall x : Prop, x<->~~x.
  50. Proof.
  51. intro x.
  52. split.
  53. intro H1.
  54. intro H2.
  55. apply (H2 H1).
  56. intro H3.
  57. destruct (PNP x) as [H9a | H9b].
  58. exact H9a.
  59. apply H3 in H9b.
  60. contradict H9b.
  61. Qed.
  62.  
  63. Theorem DM1: forall (p q : Prop), ~(p\/q)<->(~p/\~q).
  64. Proof.
  65. intros p q.
  66. split.
  67. intro H1.
  68. split.
  69. intro H2.
  70. destruct H1.
  71. left.
  72. exact H2.
  73. intro H3.
  74. destruct H1.
  75. right.
  76. exact H3.
  77. intro H4.
  78. intro H5.
  79. destruct H4.
  80. destruct H5.
  81. apply (H H1).
  82. apply (H0 H1).
  83. Qed.
  84.  
  85.  
  86. Theorem DM2: forall (p q :Prop), ~(p/\q) <-> (~p\/~q).
  87. Proof.
  88. intros p q.
  89. split.
  90. intro H1.
  91. destruct (PNP p).
  92. destruct (PNP q).
  93. destruct H1.
  94. split.
  95. exact H.
  96. exact H0.
  97. right.
  98. exact H0.
  99. left.
  100. exact H.
  101. intro H1.
  102. destruct H1.
  103. intro H2.
  104. destruct H2.
  105. apply (H H0).
  106. intro H3.
  107. destruct H3.
  108. apply (H H1).
  109. Qed.
  110.  
  111. Theorem T10 {T: Type} : forall (p : T -> Prop), ~(exists x, p x) <-> (forall x, ~p x).
  112. Proof.
  113. intros p.
  114. split.
  115. intro H1.
  116. intro x.
  117. intro H2.
  118. destruct H1.
  119. exists x.
  120. assumption.
  121. intro H1.
  122. intro H2.
  123. destruct H2.
  124. apply (H1 x).
  125. exact H.
  126. Qed.
  127.  
  128. Theorem T11 {T: Type} : forall (p : T -> Prop), ~(forall x, p x) <-> (exists x, ~p x).
  129. Proof.
  130. intro p.
  131. split.
  132. intro H1.
  133. destruct (PNP (exists x , ~p x)).
  134. assumption.
  135. destruct H1.
  136. rewrite T10 in H.
  137. intro x.
  138. apply T3.
  139. apply (H x).
  140. intro H1.
  141. intro H2.
  142. admit.
  143. Qed.
  144.  
  145. Theorem T12 {T:Type}:
  146. forall (p q r : Prop),
  147. p\/(q/\r) <-> (p\/q)/\(p\/r).
  148. Proof.
  149. intros p q r.
  150. split.
  151. intro H1.
  152. split.
  153. destruct H1.
  154. left.
  155. assumption.
  156. destruct H as [H1a H1b].
  157. right.
  158. assumption.
  159. destruct H1.
  160. left.
  161. assumption.
  162. destruct H as [H1a H1b].
  163. right.
  164. assumption.
  165.  
  166. intro H1.
  167. destruct H1 as [H1a H1b].
  168. destruct H1a as [H1aa | H1ab].
  169. left.
  170. assumption.
  171. destruct H1b as [H1ba | H1bb].
  172. left.
  173. assumption.
  174. right.
  175. split.
  176. assumption.
  177. assumption.
  178.  
  179. Qed.
  180.  
  181. Theorem T13 {T:Type}:
  182. forall (p q r : Prop),
  183. p/\(q\/r) <-> (p/\q)\/(p/\r).
  184. Proof.
  185. intros p q r.
  186. split.
  187. intro H1.
  188. destruct H1 as [H1a H1b].
  189. destruct H1b as [H1ba | H1bb].
  190. left.
  191. split.
  192. assumption.
  193. assumption.
  194. right.
  195. split.
  196. assumption.
  197. assumption.
  198. intro H1.
  199. destruct H1 as [H1a | H1b].
  200. destruct H1a as [H1ba H1bb].
  201. split.
  202. assumption.
  203. left.
  204. assumption.
  205. destruct H1b as [H1ba H1bb].
  206. split.
  207. assumption.
  208. right.
  209. assumption.
  210.  
  211.  
  212. Qed.
  213.  
  214. Theorem T100 {T1 T2: Type} {w: T1} : forall (A: T1 ->Prop) (B: T2->Prop), (forall x ,(exists y, A x /\ B y)) -> (exists y ,(forall x, A x /\ B y)).
  215. Proof.
  216. intros A B.
  217. intro H1.
  218. destruct (PNP (exists y, B y)) as [H2a | H2b].
  219. destruct H2a as [y H2a].
  220. exists y.
  221. intro x.
  222. split.
  223. specialize (H1 x).
  224. destruct H1 as [z [H1a _]].
  225. assumption.
  226. assumption.
  227. destruct H2b.
  228. destruct (H1 w) as [y [_ H1b]].
  229. exists y.
  230. assumption.
  231. Qed.
  232.  
  233.  
  234. Theorem T101 {T1 T2: Prop} {w: T1} : forall (A: T1 ->Prop) (B: T2->Prop), (forall x ,(exists y, A x /\ B y)) -> ((forall x, A x) /\ (exists y, B y)).
  235. Proof.
  236. intros A B.
  237. intro H1.
  238. split.
  239. intro x.
  240. specialize (H1 x).
  241. destruct H1 as [y [H1a H1b]].
  242. assumption.
  243. specialize (H1 w).
  244. destruct H1 as [y [_ H1b]].
  245. exists y.
  246. assumption.
  247. Qed.
  248.  
  249. Theorem T102 {w : Type} : forall (A B : Type->Prop), ((exists x, A x) -> (exists y, B y)) -> (exists x, A x -> (exists y, B y)).
  250. Proof.
  251. intros A B.
  252. intro H1.
  253. exists w.
  254. intro H2.
  255. destruct H1.
  256. exists w.
  257. assumption.
  258. exists x.
  259. assumption.
  260. Qed.
  261.  
  262. Theorem T103 {w:Type}:
  263. forall (X Y Z A:Type->Prop),
  264. (forall x, (X x \/ Y x -> Z x))->
  265. (forall x, (Z x \/ A x -> X x/\ Y x))->
  266. (forall x, X x <-> Z x).
  267. Proof.
  268. intros X Y Z A.
  269. intro H1.
  270. intro H2.
  271. intro x.
  272. split.
  273. intro H3.
  274. specialize (H1 x).
  275. assert (X x \/ Y x).
  276. left.
  277. assumption.
  278. apply (H1 H).
  279. admit.
  280. Qed.
  281.  
  282. Require Import Arith.
  283. Require Import Setoid.
  284.  
  285. Eval cbv in (S 5).
  286.  
  287. Theorem out_plus_0_l : forall a , 0+a = a.
  288. Proof.
  289. intro a.
  290. rewrite -> plus_0_l.
  291. reflexivity.
  292. Qed.
  293.  
  294. Theorem out_plus_0_r : forall a , a+0 = a.
  295. Proof.
  296. intro a.
  297. induction a.
  298. reflexivity.
  299. unfold plus.
  300. fold plus.
  301. rewrite -> IHa.
  302. reflexivity.
  303. Qed.
  304.  
  305. Lemma L4 : forall a b : nat, S a + b = S(a+b).
  306. Proof.
  307. intros a b.
  308. unfold plus.
  309. fold plus.
  310. reflexivity.
  311. Qed.
  312.  
  313. Lemma L5: forall a b : nat, a + S b = S(a+b).
  314. Proof.
  315. intros a b.
  316. induction a.
  317. reflexivity.
  318. unfold plus.
  319. fold plus.
  320. rewrite -> IHa.
  321. reflexivity.
  322. Qed.
  323.  
  324. Theorem our_plus_comm: forall a b :nat, a+b = b+a.
  325. Proof.
  326. intros a b.
  327. induction a.
  328. rewrite -> out_plus_0_r.
  329. rewrite -> out_plus_0_l.
  330. reflexivity.
  331. unfold plus.
  332. fold plus.
  333. rewrite -> IHa.
  334. rewrite -> L5.
  335. reflexivity.
  336. Qed.
  337.  
  338.  
  339. Theorem our_plus_assoc: forall a b c:nat, a+(b+c) = a+b+c.
  340. Proof.
  341. intros a b c.
  342. induction a.
  343. unfold plus.
  344. fold plus.
  345. reflexivity.
  346. unfold plus.
  347. fold plus.
  348. rewrite -> IHa.
  349. reflexivity.
  350. Qed.
  351.  
  352. Theorem our_mult_0_l: forall a:nat, 0*a = 0.
  353. Proof.
  354. intros a.
  355. reflexivity.
  356. Qed.
  357.  
  358. Theorem our_mult_0_r: forall a:nat, a*0 = 0.
  359. Proof.
  360. intros a.
  361. induction a.
  362. reflexivity.
  363. unfold mult.
  364. fold mult.
  365. rewrite -> IHa.
  366. reflexivity.
  367. Qed.
  368.  
  369. Theorem our_mult_1_l: forall a:nat, 1*a = a.
  370. Proof.
  371. intros a.
  372. unfold mult.
  373. rewrite -> out_plus_0_r.
  374. reflexivity.
  375. Qed.
  376.  
  377. Theorem our_mult_1_r: forall a:nat, a*1 = a.
  378. Proof.
  379. intros a.
  380. induction a.
  381. reflexivity.
  382. unfold mult.
  383. fold mult.
  384. rewrite -> IHa.
  385. unfold plus.
  386. reflexivity.
  387. Qed.
  388.  
  389.  
  390. Lemma L6: forall a b : nat, S a * b = b + a*b.
  391. Proof.
  392. intros a b.
  393. unfold mult.
  394. fold mult.
  395. reflexivity.
  396. Qed.
  397.  
  398. Lemma L7: forall a b : nat, a * S b = a + a * b.
  399. Proof.
  400. intros a b.
  401. induction a.
  402. unfold mult.
  403. reflexivity.
  404. unfold mult.
  405. fold mult.
  406. rewrite IHa.
  407. unfold plus.
  408. fold plus.
  409. rewrite -> our_plus_assoc.
  410. rewrite -> our_plus_assoc.
  411. rewrite -> (our_plus_comm b a).
  412. reflexivity.
  413. Qed.
  414.  
  415. Theorem our_mult_comm: forall a b :nat, a*b = b*a.
  416. Proof.
  417. intros a b.
  418. induction a.
  419. unfold mult.
  420. fold mult.
  421. rewrite -> our_mult_0_r.
  422. reflexivity.
  423. unfold mult.
  424. fold mult.
  425. rewrite -> IHa.
  426. rewrite -> L7.
  427. reflexivity.
  428. Qed.
  429.  
  430. Theorem our_mult_distr_r : forall a b c : nat, (a+b)*c = a*c + b*c.
  431. Proof.
  432. intros a b c.
  433. induction a.
  434. reflexivity.
  435. rewrite -> L4.
  436. unfold mult.
  437. fold mult.
  438. rewrite -> IHa.
  439. rewrite -> our_plus_assoc.
  440. reflexivity.
  441. Qed.
  442.  
  443.  
  444. Theorem our_mult_distr_l : forall a b c :nat , a*(b+c) = a * b + a * c.
  445. Proof.
  446. intros a b c.
  447. rewrite -> (our_mult_comm _ (b+c)).
  448. rewrite -> our_mult_distr_r.
  449. rewrite -> (our_mult_comm b a).
  450. rewrite -> (our_mult_comm c a).
  451. reflexivity.
  452. Qed.
  453.  
  454.  
  455.  
  456. Theorem our_mult_assoc: forall a b c:nat, a*(b*c) = a*b*c.
  457. Proof.
  458. intros a b c.
  459. induction a.
  460. unfold mult.
  461. reflexivity.
  462. unfold mult.
  463. fold mult.
  464. rewrite -> IHa.
  465. rewrite -> our_mult_distr_r.
  466. reflexivity.
  467. Qed.
  468.  
  469. Inductive day : Type :=
  470. | sunday : day
  471. | monday : day
  472. | tuesday : day
  473. | wednsday : day
  474. | thursday : day
  475. | friday : day
  476. | saturday : day.
  477.  
  478. Inductive nat' : Type :=
  479. | z : nat'
  480. | S : nat' -> nat'.
  481.  
  482. Inductive bin : Type :=
  483. | E : bin
  484. | B0 : bin -> bin
  485. | B1 : bin -> bin.
  486.  
  487. Definition next_day (d : day) : day :=
  488. match d with
  489. | sunday => monday
  490. | monday => tuesday
  491. | tuesday => wednsday
  492. | wednsday => thursday
  493. | thursday => friday
  494. | friday => saturday
  495. | saturday => sunday
  496. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement