(* ratInverse only works correctly when the number is positive *)
Definition ratInverse (r : Rat) :=
  match r with
    | RatIntro n d =>
      match n with
        | O => RatIntro d (pos (S O))
        | S n' => RatIntro d (pos (S n'))
      end
  end.Fixpoint expRat r n :=
  match n with
    | O => rat1 
    | S n' => r * (expRat r n')
  end.

(* Specifications: *)
Lemma expRat_le_1 : forall n x, x <= 1 -> expRat x n <= 1.
Lemma expRat_le : forall n1 n2 x, x <= 1 -> n2 >= n1 -> expRat x n2 <= expRat x n1.
Lemma expRat_leRat_compat : forall n r1 r2, r1 <= r2 -> expRat r1 n <= expRat r2 n.
Lemma expRat_le' : forall n1 n2 r v, expRat r n1 <= v -> ~ (1 <= r) -> n2 >= n1 -> expRat r n2 <= v.
Lemma rat_ge_1 : forall n (d : posnat), n >= d -> 1 <= RatIntro n d.
Lemma leRat_ratAdd_same_r : forall r1 r2 r3, r2 + r1 <= r3 + r1 -> r2 <= r3.
Lemma half_distance_1_le : forall r, ~ 1 <= r -> ~ 1 <= r + (1 / 2) * (ratSubtract 1 r).
Lemma leRat_terms : forall n1 n2 (d1 d2 : posnat), (n1 <= n2)%nat -> (d2 <= d1)%nat -> RatIntro n1 d1 <= RatIntro n2 d2.
Lemma posnatMult_eq : forall p1 p2, posnatToNat (posnatMult p1 p2) = (p1 * p2)%nat.
Theorem mult_gt_zero_if : forall (a b : nat), a * b > 0 -> (a > 0 /\ b > 0).
Lemma expRat_le_half_exists : forall r, ~ 1 <= r -> exists n, expRat r n <= (1/2).