(** * Definition of [Q] and basic properties *)

(** Rationals are pairs of [Z] and [positive] numbers. *)

Record Q : Set := Qmake {Qnum : Z; Qden : positive}.(** * Definition of [Q] and basic properties *)

(** Rationals are pairs of [Z] and [positive] numbers. *)

Record Q : Set := Qmake {Qnum : Z; Qden : positive}.(** * Definition of [Q] and basic properties *)

(** Rationals are pairs of [Z] and [positive] numbers. *)

Record Q : Set := Qmake {Qnum : Z; Qden : positive}.(** * Definition of [Q] and basic properties *)

(** Rationals are pairs of [Z] and [positive] numbers. *)

Record Q : Set := Qmake {Qnum : Z; Qden : positive}.Ltac simpl_mult := rewrite ?Pos2Z.inj_mul.(** [a#b] denotes the fraction [a] over [b]. *)

Notation "a # b" := (Qmake a b) (at level 55, no associativity) : Q_scope.Definition inject_Z (x : Z) := Qmake x 1.Notation QDen p := (Zpos (Qden p)).Definition Qeq (p q : Q) := (Qnum p * QDen q)%Z = (Qnum q * QDen p)%Z.Definition Qle (x y : Q) := (Qnum x * QDen y <= Qnum y * QDen x)%Z.Definition Qlt (x y : Q) := (Qnum x * QDen y < Qnum y * QDen x)%Z.Notation Qgt a b := (Qlt b a) (only parsing).Notation Qge a b := (Qle b a) (only parsing).Infix "==" := Qeq (at level 70, no associativity) : Q_scope.Infix "<" := Qlt : Q_scope.Infix "<=" := Qle : Q_scope.Notation "x > y" := (Qlt y x)(only parsing) : Q_scope.Notation "x >= y" := (Qle y x)(only parsing) : Q_scope.Notation "x <= y <= z" := (x<=y/\y<=z) : Q_scope.Notation "x <= y < z" := (x<=y/\y<z) : Q_scope.Notation "x < y <= z" := (x<y/\y<=z) : Q_scope.Notation "x < y < z" := (x<y/\y<z) : Q_scope.

Lemma inject_Z_injective (a b: Z): inject_Z a == inject_Z b <-> a = b.