(****************************************************************************  IEEE754  :  Paux  Laurent Thery  ******************************************************************************)
Require Export Digit.
Require Export Option.
Require Export Inverse_Image.
Require Export Wf_nat.
Fixpoint exp (n m : nat) {struct m} : nat :=
match m with
| O => 1
| S m' => n * exp n m'
end.
intros n p; elim p; simpl in |- *; auto with arith.
intros n0 H' q; rewrite mult_assoc_reverse; rewrite <- H'; auto.
Qed.
Fixpoint positive_exp (p n : positive) {struct n} : positive :=
match n with
| xH => p
| xO n1 =>
match positive_exp p n1 with
| r =>
(fun (x : positive) (_ : positive -> positive)
(y : positive) => (x * y)%positive) r (
fun x => x) r
end
| xI n1 =>
match positive_exp p n1 with
| r =>
(fun (x : positive) (_ : positive -> positive)
(y : positive) => (x * y)%positive) p (
fun x => x)
((fun (x : positive)
(_ : positive -> positive)
(y : positive) => (x * y)%positive) r (
fun x => x) r)
end
end.

Theorem positive_exp_correct :
forall p n : positive,
nat_of_P (positive_exp p n) =
exp (nat_of_P p) (nat_of_P n).