qed.
theorem eq_minus_gcd_aux: \forall p,m,n.O < n \to n \le m \to n \le p \to
-ex nat (\lambda a. ex nat (\lambda b.
-a*n - b*m = (gcd_aux p m n) \lor b*m - a*n = (gcd_aux p m n))).
+\exists a,b. a*n - b*m = gcd_aux p m n \lor b*m - a*n = gcd_aux p m n.
intro.
elim p.
absurd O < n.assumption.apply le_to_not_lt.assumption.
cut O < m.
cut (divides n1 m) \lor \not (divides n1 m).
change with
-ex nat (\lambda a. ex nat (\lambda b.
+\exists a,b.
a*n1 - b*m = match divides_b n1 m with
[ true \Rightarrow n1
| false \Rightarrow gcd_aux n n1 (mod m n1)]
\lor
b*m - a*n1 = match divides_b n1 m with
[ true \Rightarrow n1
-| false \Rightarrow gcd_aux n n1 (mod m n1)])).
+| false \Rightarrow gcd_aux n n1 (mod m n1)].
elim Hcut1.
rewrite > divides_to_divides_b_true.
simplify.
assumption.assumption.
rewrite > not_divides_to_divides_b_false.
change with
-ex nat (\lambda a. ex nat (\lambda b.
+\exists a,b.
a*n1 - b*m = gcd_aux n n1 (mod m n1)
\lor
-b*m - a*n1 = gcd_aux n n1 (mod m n1))).
+b*m - a*n1 = gcd_aux n n1 (mod m n1).
cut
-ex nat (\lambda a. ex nat (\lambda b.
+\exists a,b.
a*(mod m n1) - b*n1= gcd_aux n n1 (mod m n1)
\lor
-b*n1 - a*(mod m n1) = gcd_aux n n1 (mod m n1))).
+b*n1 - a*(mod m n1) = gcd_aux n n1 (mod m n1).
elim Hcut2.elim H5.elim H6.
(* first case *)
rewrite < H7.
apply lt_to_le_to_lt ? n1.assumption.assumption.
qed.
-theorem eq_minus_gcd: \forall m,n.
-ex nat (\lambda a. ex nat (\lambda b.
-a*n - b*m = (gcd n m) \lor b*m - a*n = (gcd n m))).
+theorem eq_minus_gcd:
+ \forall m,n.\exists a,b.a*n - b*m = (gcd n m) \lor b*m - a*n = (gcd n m).
intros.
change with
-ex nat (\lambda a. ex nat (\lambda b.
+\exists a,b.
a*n - b*m =
match leb n m with
[ true \Rightarrow
| false \Rightarrow
match m with
[ O \Rightarrow n
- | (S p) \Rightarrow gcd_aux (S p) n (S p) ]]
-)).
+ | (S p) \Rightarrow gcd_aux (S p) n (S p) ]].
apply leb_elim n m.
apply nat_case1 n.
simplify.intros.
apply sym_eq.apply minus_n_O.
intros.
change with
-ex nat (\lambda a. ex nat (\lambda b.
+\exists a,b.
a*(S m1) - b*m = (gcd_aux (S m1) m (S m1))
-\lor b*m - a*(S m1) = (gcd_aux (S m1) m (S m1)))).
+\lor b*m - a*(S m1) = (gcd_aux (S m1) m (S m1)).
apply eq_minus_gcd_aux.
simplify. apply le_S_S.apply le_O_n.
assumption.apply le_n.
apply sym_eq.apply minus_n_O.
intros.
change with
-ex nat (\lambda a. ex nat (\lambda b.
+\exists a,b.
a*n - b*(S m1) = (gcd_aux (S m1) n (S m1))
-\lor b*(S m1) - a*n = (gcd_aux (S m1) n (S m1)))).
+\lor b*(S m1) - a*n = (gcd_aux (S m1) n (S m1)).
cut
-ex nat (\lambda a. ex nat (\lambda b.
+\exists a,b.
a*(S m1) - b*n = (gcd_aux (S m1) n (S m1))
\lor
-b*n - a*(S m1) = (gcd_aux (S m1) n (S m1)))).
+b*n - a*(S m1) = (gcd_aux (S m1) n (S m1)).
elim Hcut.elim H2.elim H3.
apply ex_intro ? ? a1.
apply ex_intro ? ? a.
cut divides n p \lor \not (divides n p).
elim Hcut.left.assumption.
right.
-cut ex nat (\lambda a. ex nat (\lambda b.
-a*n - b*p = (S O) \lor b*p - a*n = (S O))).
+cut \exists a,b. a*n - b*p = (S O) \lor b*p - a*n = (S O).
elim Hcut1.elim H3.*)
theorem divides_times_to_divides: \forall n,p,q:nat.prime n \to divides n (p*q) \to
elim Hcut.
left.assumption.
right.
-cut ex nat (\lambda a. ex nat (\lambda b.
-a*n - b*p = (S O) \lor b*p - a*n = (S O))).
+cut \exists a,b. a*n - b*p = (S O) \lor b*p - a*n = (S O).
elim Hcut1.elim H3.elim H4.
(* first case *)
rewrite > times_n_SO q.rewrite < H5.
rewrite > H2.simplify.apply le_n.
qed.
+
definition max_spec \def \lambda f:nat \to bool.\lambda n: nat.
-ex nat (\lambda i:nat. (le i n) \land (f i = true)) \to
+\exists i. (le i n) \land (f i = true) \to
(f n) = true \land (\forall i. i < n \to (f i = false)).
theorem f_max_true : \forall f:nat \to bool. \forall n:nat.
-ex nat (\lambda i:nat. (le i n) \land (f i = true)) \to f (max n f) = true.
+(\exists i:nat. le i n \land f i = true) \to f (max n f) = true.
intros 2.
elim n.elim H.elim H1.generalize in match H3.
apply le_n_O_elim a H2.intro.simplify.rewrite > H4.
cut O < m.apply lt_O_n_elim m Hcut.exact not_le_Sn_O.
rewrite < max_O_f f.assumption.
generalize in match H1.
-(* ?? non posso generalizzare su un goal implicativo ?? *)
elim max_S_max f n1.
elim H3.
absurd m \le S n1.assumption.
qed.
theorem f_min_aux_true: \forall f:nat \to bool. \forall off,m:nat.
-ex nat (\lambda i:nat. (le (m-off) i) \land (le i m) \land (f i = true)) \to
+(\exists i. le (m-off) i \land le i m \land f i = true) \to
f (min_aux off m f) = true.
intros 2.
elim off.elim H.elim H1.elim H2.
simplify.apply le_S_S.apply le_O_n.
qed.
-(* mi sembra che il problem sia ex *)
-theorem ex_prime: \forall n. (S O) \le n \to ex nat (\lambda m.
-n < m \land m \le (S (fact n)) \land (prime m)).
+theorem ex_prime: \forall n. (S O) \le n \to \exists m.
+n < m \land m \le (S (fact n)) \land (prime m).
intros.
elim H.
apply ex_intro nat ? (S(S O)).
theorem ex_m_le_n_nth_prime_m:
\forall n: nat. nth_prime O \le n \to
-ex nat (\lambda m. nth_prime m \le n \land n < nth_prime (S m)).
+\exists m. nth_prime m \le n \land n < nth_prime (S m).
intros.
apply increasing_to_le2.
exact lt_nth_prime_n_nth_prime_Sn.assumption.
(* nth_prime enumerates all primes *)
theorem prime_to_nth_prime : \forall p:nat. prime p \to
-ex nat (\lambda i:nat. nth_prime i = p).
+\exists i. nth_prime i = p.
intros.
-cut ex nat (\lambda m. nth_prime m \le p \land p < nth_prime (S m)).
+cut \exists m. nth_prime m \le p \land p < nth_prime (S m).
elim Hcut.elim H1.
cut nth_prime a < p \lor nth_prime a = p.
elim Hcut1.