Skip to content

coq-community/qarith-stern-brocot

Repository files navigation

Binary Rational Numbers

Docker CI Nix CI Contributing Code of Conduct Zulip DOI

Development of rational numbers in Coq as finite binary lists and defining field operations on them in two different ways: strict and lazy.

Meta

Building and installation instructions

The easiest way to install the latest released version of Binary Rational Numbers is via OPAM:

opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq-qarith-stern-brocot

To instead build and install manually, do:

git clone https://github.com/coq-community/qarith-stern-brocot.git
cd qarith-stern-brocot
make   # or make -j <number-of-cores-on-your-machine> 
make install

Documentation

This project contains a rational arithmetic library for Coq. This includes:

  • A binary representation for positive rational numbers Qpositive and its extension to Q by adding a sign bit (also known as Stern-Brocot tree encoding).
  • Arithmetic operations on Qpositive and Q defined in an strict way.
  • More efficient arithmetic operations on Q defined lazily using homographic and quadratic algorithms for this binary representation (exact rational arithmetic).
  • Proof of the correctness of the homographic and quadratic algorithms using the strict operations.
  • The files enable the user to use Coq field tactic on Q with two different field structures (using strict or lazy operations).
  • The Haskell extraction of the lazy algorithms (quadratic.hs).
  • A syntax for using the rational numbers as pair of integers, and writing simple arithmetic operations on them.
  • A proof of irrationality of the square root of 2.
  • A proof that Q is Archimedean.
  • A proof that Q is countable.