(* -*- coding: utf-8 -*- *)
(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
Require Export BinNums.
Equalities Orders OrdersFacts GenericMinMax PeanoNat.
Require Export BinPosDef.
(**********************************************************************)
(** * Binary positive numbers, operations and properties *)
(**********************************************************************)
(** Initial development by Pierre Crégut, CNET, Lannion, France *)
(** The type [positive] and its constructors [xI] and [xO] and [xH] are now defined in [BinNums.v] *)
Local Open Scope positive_scope.
(** Every definitions and early properties about positive numbers are placed in a module [Pos] for qualification purpose. *)
Module Pos
<: UsualOrderedTypeFull
<: UsualDecidableTypeFull
<: TotalOrder.
(** * Definitions of operations, now in a separate file *)
Include BinPosDef.Pos.
(** In functor applications that follow, we only inline t and eq *)
Set Inline Level 30.
(** * Logical Predicates *)
Definition eq := @Logic.eq positive.
Definition eq_equiv := @eq_equivalence positive.
Include BackportEq.
Definition lt x y := (x ?= y) = Lt.
Definition gt x y := (x ?= y) = Gt.
Definition le x y := (x ?= y) <> Gt.
Definition ge x y := (x ?= y) <> Lt.
Infix "<=" := le : positive_scope.
Infix "<" := lt : positive_scope.
Infix ">=" := ge : positive_scope.
Infix ">" := gt : positive_scope.
Notation "x <= y <= z" := (x <= y /\ y <= z) : positive_scope.
Notation "x <= y < z" := (x <= y /\ y < z) : positive_scope.
Notation "x < y < z" := (x < y /\ y < z) : positive_scope.
Notation "x < y <= z" := (x < y /\ y <= z) : positive_scope.
(**********************************************************************)
(** * Properties of operations over positive numbers *)
(** ** Decidability of equality on binary positive numbers *)

Lemma add_reg_r p q r : p + r = q + r -> p = q.