elf13.v 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. Set Implicit Arguments.
  2. Unset Strict Implicit.
  3. Unset Printing Implicit Defensive.
  4. From mathcomp Require Import all_ssreflect.
  5. From mathcomp Require Import algebra.rat.
  6. From mathcomp Require Import ring.
  7. From mathcomp Require Import ssrint.
  8. From mathcomp Require Import ssralg.
  9. From mathcomp Require Import prime.
  10. Open Scope ring_scope.
  11. Inductive Pochodzi : rat -> Prop :=
  12. | Pochodzi0 : Pochodzi 0
  13. | Pochodzi1 : Pochodzi 1
  14. | PochodziC : forall a b : rat, Pochodzi a -> Pochodzi b -> Pochodzi ((a+b) / 2%:Q).
  15. Section PrzerzucanieLiczb.
  16. Variable F : fieldType.
  17. Implicit Types a b c d e: F.
  18. Lemma _rozdzielne a b c d e (nzero : [&& e != 0, d != 0 & b != 0]):
  19. ((a / b) + (c / d)) / e = (a * d + c * b) / (b * d * e).
  20. Proof.
  21. field; assumption.
  22. Qed.
  23. Lemma _rozdzielne' a b c d e q w (nzero : [&& e != 0, d != 0 & b != 0]) :
  24. q = (a *d +c*b) -> w = (b*d*e) ->
  25. ((a / b) + (c / d)) / e = q / w.
  26. Proof.
  27. move => -> ->.
  28. apply _rozdzielne.
  29. assumption.
  30. Qed.
  31. End PrzerzucanieLiczb.
  32. Open Scope nat_scope.
  33. Lemma expNe0 (a b : nat): a != 0 -> a^b != 0.
  34. Proof.
  35. move => H.
  36. rewrite -ssrnat.lt0n.
  37. rewrite ssrnat.expn_gt0.
  38. apply/orP; left.
  39. rewrite ssrnat.lt0n.
  40. assumption.
  41. Qed.
  42. Close Scope nat_scope.
  43. Lemma pochodzi_w_postaci_a_2b p : Pochodzi p -> exists a b : nat, p = (a%:Q)/((2^b)%N%:Q).
  44. Proof.
  45. elim.
  46. exists 0%N; exists 0%N; reflexivity.
  47. exists 1%N; exists 0%N; reflexivity.
  48. move => a b Pa Ha Pb Hb.
  49. case: Ha => q1. case => q2 ->.
  50. case: Hb => w1. case => w2 ->.
  51. exists (q1 * (2 ^ w2) + w1 * (2 ^ q2))%N.
  52. exists (q2 + w2 + 1)%N.
  53. apply _rozdzielne'.
  54. apply/andP.
  55. split. by simpl.
  56. apply/andP.
  57. split.
  58. rewrite ssrnum.Num.Theory.pnatr_eq0.
  59. apply expNe0.
  60. by simpl.
  61. rewrite ssrnum.Num.Theory.pnatr_eq0.
  62. apply expNe0.
  63. by simpl.
  64. by field.
  65. move => {Pa Pb a b p}.
  66. rewrite !expnD.
  67. by field.
  68. Qed.
  69. Lemma primes2 b : 13%N \in (primes (2^ b.+1))%N -> False.
  70. Proof.
  71. elim: b.
  72. by simpl.
  73. move => b H.
  74. rewrite expnSr.
  75. rewrite primesM.
  76. move => /orP; case.
  77. assumption.
  78. by simpl.
  79. rewrite lt0n.
  80. apply: expNe0.
  81. by simpl.
  82. by simpl.
  83. Qed.
  84. Lemma False_false (P : bool) (H : (P -> False)) : (P = false).
  85. Proof. apply/idP. exact H. Qed.
  86. Lemma primes13 a : 13%N \in (primes (a.+1 * 13 ))%N.
  87. Proof.
  88. rewrite primesM; [apply/orP; right | |]; by simpl.
  89. Qed.
  90. Lemma dwa_b_a13: forall a b , ((2 ^ b) %N == (a * 13%N)%N) -> False.
  91. Proof.
  92. elim.
  93. move => b.
  94. rewrite mul0n.
  95. move => /eqP.
  96. elim: b.
  97. by cbn.
  98. move => n H.
  99. rewrite expnSr.
  100. move => /eqP.
  101. rewrite muln_eq0.
  102. move => /orP; case.
  103. move => /eqP; assumption.
  104. by cbn.
  105. move => a Ha.
  106. elim.
  107. by cbn.
  108. move => b Hb H.
  109. move: (f_equal (fun x => 13 \in (primes x))%N (eqP H)).
  110. rewrite (False_false (@primes2 b)).
  111. rewrite (@introTF _ _ true idP (primes13 a)).
  112. done.
  113. Qed.
  114. Lemma nie_mozna_byc_elfem_w_1_13: ~ Pochodzi (1%N%:Q / 13%N%:Q) .
  115. Proof.
  116. move => /pochodzi_w_postaci_a_2b [a] [b] /eqP .
  117. rewrite (@GRing.eqr_div _ 1%N%:Q 13%N%:Q a%:Q (2^b)%N%:Q ).
  118. rewrite GRing.mul1r.
  119. move => /eqP H.
  120. apply (@dwa_b_a13 a b).
  121. rewrite -(@ssrnum.Num.Theory.eqr_nat rat_numDomainType).
  122. rewrite /intmul in H.
  123. rewrite H.
  124. apply/eqP. move => {H}.
  125. ring.
  126. by simpl.
  127. apply /eqP.
  128. move => /eqP.
  129. rewrite /intmul.
  130. rewrite -[0]/(0%:R).
  131. rewrite (@ssrnum.Num.Theory.eqr_nat).
  132. elim: b.
  133. by simpl. move => b H.
  134. rewrite expnSr.
  135. rewrite muln_eq0.
  136. move => /orP. case.
  137. exact H.
  138. move => /eqP.
  139. discriminate. (* Dowód kończy się dyskryminowaniem elfów xD *)
  140. Qed.