(* Copyright (C) 2005-2008 Sebastien Briais *)
(* http://lamp.epfl.ch/~sbriais/ *)
(* This library is free software; you can redistribute it and/or modify *)
(* it under the terms of the GNU Lesser General Public License as *)
(* published by the Free Software Foundation; either version 2.1 of the *)
(* License, or (at your option) any later version. *)
(* This library is distributed in the hope that it will be useful, but *)
(* WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *)
(* Lesser General Public License for more details. *)
(* You should have received a copy of the GNU Lesser General Public *)
(* License along with this library; if not, write to the Free Software *)
(* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *)
(* 02110-1301 USA *)
Unset Standard Proposition Elimination Names.
(** definition of square *)
Definition square (x:nat) := x*x.
unfold square.
intros.
ring.
Qed.
(** we now generalize the theorem to the nth-root *)
Fixpoint power (x n:nat) {struct n} : nat :=
match n with
O => 1
| (S n) => (x*(power x n))
end.
induction n;simpl;trivial.
intros;rewrite (IHn x y);ring.
Qed.
induction n;simpl;intros.
auto with arith.
rewrite IHn;ring.
Qed.
induction n;simpl;intros.
inversion H.
exists (power x n);trivial.
Qed.
induction n;simpl;intros.
induction m;simpl;auto with arith.
rewrite IHm;ring.
rewrite power_mult_lemma1;rewrite IHn;rewrite <- power_plus_lemma1;trivial.
Qed.
induction n;simpl;intros.
discriminate.
case (mult_lemma2 x (power x n) H);auto.
Qed.
induction m;simpl;try omega;intros.
destruct m;simpl;try omega.
simpl in IHm.
assert (1 < p*(power p m)).
apply IHm;auto with arith.
rewrite mult_comm.
apply lt_trans with (1*p);try omega.
apply mult_lt_compat_r;try omega.
Qed.

(** 1^n = 1 *)
Lemma power_one : forall (n:nat),(power 1 n)=1.