(* This program 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 program 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 General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
Require Export Qhomographic_Qpositive_to_Q_properties.
Definition spec_fraction_encoding (a b : Z) : Q := Qmult a (Qinv b).
Definition spec_positive_fraction_encoding (a b : Z)
(Ha : (0 < a)%Z) (Hb : (0 < b)%Z) :=
Qpositive_mult (Z_to_Qpositive a Ha) (Qpositive_inv (Z_to_Qpositive b Hb)).
Definition spec_positive_fraction_encoding1 (a b : Z) :=
Q_tail (Qmult a (Qinv b)).
Definition spec_positive_fraction_encoding2 (a b : Z) :=
Qpositive_mult (Q_tail a) (Qpositive_inv (Q_tail b)).

Lemma spec_coding :
forall m n : nat,
Qpositive_c (S m) (S n) (S m + S n) =
spec_positive_fraction_encoding1 (m + 1) (n + 1).