%This file is automatically generated. Do not touch it.
\documentclass[10pt]{article}
\usepackage{a4wide,amstext,amssymb}
\makeindex

% Some special symbols
\def\RR{\mathbb{R}}
\def\QQ{\mathbb{Q}}
\def\NN{\mathbb{N}}
\def\ZZ{\mathbb{Z}}
\def\noto{\mathrel{\#}}
\newcommand{\ac}{^{\prime}}
\def\eqqe{\leftrightarrow}
\newcommand{\maxx}{\mbox{max}}

% environments that are not numbered
\newcommand{\newenvs}[1]{\begin{list}{}{\setlength{\leftmargin}{0pt}
                         \setlength{\rightmargin}{0pt}}\item {#1}}
\newcommand{\newenve}[1]{{#1}\end{list}}
\newcommand{\newenv}[3]{\newenvironment{#1}{\newenvs{#2}}{\newenve{#3}}}

\newenv{convention}{\bf Convention:}{}
\newenv{nameconvention}{\bf Name convention:}{}
\newenv{shortcoming}{\bf Coq shortcoming:}{}
\newenv{notation}{\bf Notation:}{}
\newtheorem{numnotation}{Notation}
\newtheorem{numconvention}[numnotation]{Convention}
\newtheorem{definition}{Definition}[section]
\newtheorem{lemma}[definition]{Lemma}
\newtheorem{conjecture}[definition]{Conjecture}
\newtheorem{proposition}[definition]{Proposition}
\newtheorem{theorem}[definition]{Theorem}
\newtheorem{corollary}[definition]{Corollary}
\newtheorem{remark}[definition]{Remark}
\newtheorem{fact}[definition]{Fact}
\newtheorem{example}[definition]{Example}
\newtheorem{examples}[definition]{Examples}
\newtheorem{claim}[definition]{Claim}

\sloppy
\begin{document}
\title{Theory development leading to the Fundamental
Theorem of Algebra} 
\author{Herman Geuvers, Randy Pollack, Freek Wiedijk, Jan Zwanenburg}
\maketitle
\tableofcontents
\newpage
\section{About this document}
\subsection{Why this document}
To have an actual overview of the concrete Coq proof-development of
FTA, we need to have a document in which all lemmas and definition can
be found, with the actual names (in Coq), together with (syntactic)
conventions, design decisions and explanations. We produce this
document in \LaTeX, to be able to use ordinary mathematical notation
for explanation.

This document should always reflect the actual state of affairs of the
Coq development. Therefore it is best to extract this \LaTeX\ code
form the Coq code. Coq already provides one way of doing so, by the so
called `gallina' files. These remove from a Coq file all proofs,
yielding a \verb!.g! file. However, we want more: notably we want to
add {\em mathematical\/} comments. Hence we introduce a different
set-up, where we add comments to the Coq files. A small compiler
script then translates the Coq files to \LaTeX\ source code (taking
the comments into account, comaparable with compiler-directives in
programs). Note that there are two other possibilities: (1) Use
\LaTeX\ files with comments that facilitate the extraction of Coq
code; (2) Define a new file format from which both the Coq code and
the \LaTeX\ code can be extracted. As we are working with Coq most of
the time, these two options seem less convenient.  So, taking the
option of using the Coq files as basic, the comments will have to be
written as Coq-comments to be able to use the files as valid Coq proof
scripts.

\subsection{How to make this document}
In the \verb!algebra! main directory, type \verb!maketex!  (or
\verb!bin/maketex! if you get the reply
\verb!maketex: command not found!).  This command concatenates the
file \verb!body/body_pre.tex!, the tex comments in the Coq script
files (see below), and the file \verb!body/body_post.tex!  into the
file \verb!body/body.tex!. The file \verb!body/body.tex! should not be
edited manually!  Go to the \verb!body! subdirectory, and latex the
file \verb!body.tex!.

\subsection{Tex comments in script files}
\begin{itemize}
\item To put some piece of the script file verbatim in the tex file (e.g.\ for
lemmas and definitions), insert
\[\verb!(* Begin_Tex_Verb *)!\]
before this piece, and
\[\verb!(* End_Tex_Verb *)!\]
just after this piece.
\item In order to put some prose in the tex file, insert a line
\[\verb!(* Tex_Prose!\]
then insert the text, and then insert a line
\[\verb!*)!\]
\end{itemize}
\subsection{Guidelines for producing this document}
We have made the following \LaTeX\ environments:
\begin{itemize}
\item The {\sf convention}, {\sf numconvention} environments for unnumbered
      and numbered conventions, respectively.
\item The {\sf nameconvention} environment.
\item The {\sf notation}, {\sf numnotation} environments.
\item The {\sf shortcoming} environment.
\end{itemize}
What {\em should\/} be included and how:
\begin{itemize}
\item Lemmas: verbatim.
\item Definitions: verbatim. (It is not clear how interactively constructed
definitions should be included; see below.)
\item Variable declarations: typically with the \LaTeX\ convention environment.
\item Syntactic definitions: with the \LaTeX\ notation environment.
\item Sections: Since every script file corresponds with one section
in the \LaTeX\ document, a Coq-section should usually be included as a
\LaTeX-subsection, and a nested Coq-section should be included as a
\LaTeX-subsubsection.  However, the end of one Coq-section does not
always coincide with the start of a next Coq-section (in contrast to
\LaTeX). In these cases, additional \LaTeX\ ((sub)sub)sections are
introduced to avoid confusion (e.g.\ see \verb!CSetoids.v!).

If a Coq-section is introduced only for a few definitions/lemmas, it is
sometimes simpler not to include this structure in the \LaTeX\ file.

\item Coercions: as conventions.
\item Comments: usually as \LaTeX\ prose.
\end{itemize}
What {\em should not\/} be included:
\begin{itemize}
\item Proofs.
\item Tactic definitions.
\item Import lists ({\tt Require}).
\item Commands for setting implicit arguments on/off.
\item Hints.
\end{itemize}
\section{General notes}
\subsection{Notes about the development}
\begin{itemize}
\item We would like to avoid giving explicit proof terms in
definitions and lemmas as much as possible. (In mathematics, the
existence (or construction) of an object may depend on the {\em
truth\/} (or {\em provability}) of a statement, but not on its actual
proof.  In Coq, we cannot always avoid this, in particular, when
making definitions.  
\item In Coq, a definition can be given in two
ways. Either it must be completely written out, or it is completely
constructed interactively; there is no in-between.  The latter option
has as disadvantage that we cannot really see how something is defined. 
(We do not display the proof script, but even a proof script says little 
about the actual constructed object). The
former has as disadvantage that the subterms corresponding with proofs
may be hard to write. Currently, we don't have any guideline which of
the two options to choose.  (One would like to pack all proof
information in lemmas, so that each proof occurring in a definition
could be denoted by just a variable.) What soemtimes works well for 
objects that are hard to define is to define the object interactively, then
to print it (using the \verb!Print! command) and then to redefine the 
printed thing (possibly after some editing).

\item The word \verb!Axiom! occurring in proof scripts usually means we 
      just did not prove the property yet.
\item Many operations \verb!op! have a syntactically sugared version, e.g.
      for which some arguments are implicit (e.g. defined by the ``Syntactic
      Definition'' construction in combination with ``?'').
      This sugared version is always denoted by capitalizing the first letter
      of \verb!op!.
\item In Coq, there are two ways to provide implicit arguments.
First the {\tt Implicit Arguments} mechanism. Second, the {\tt Syntactic
Definition} mechanism in combination with {\tt ?}. We need a guideline when
to use which one.
\end{itemize}
\subsection{Notes about Coq (shortcomings)}
\begin{enumerate}
\item
   The Coq syntax is not particularly perfect.  All kinds of
   operators can not be written down in the way one would want to.  A
   mature parser with overloading (where the  $+$ in $x+y$
   depends on the types of $x$ and $y$) would help.
\item
   Proof obligations can be very cumbersome.  If you write down
    something like \verb!3^(1-k)!, you have to think about whether it
    is {\em allowed\/} to user a power to the $1-k$th.  That's ok to a
    certain extent (it's in the mathematics), {\em but} you will have
    to add the {\em reason\/} why you're allowed to do it as an
    argument. This makes expressions very heavy.
\item
   Continuing forward and then `backwards' constructing what you need
   can be inefficient, because what you are going to {\em use\/} are
   the things that are already there, instead of {\em extending\/} the
   things that are already there. So, you will take detours, do things
   in an unnecesarily ugly way and do things in a too restricted way
   (where you could prove a more general result), just to prevent you
   from having to add a whole list of elementary lemmas. (You have the
   feeling that `that level of generality is not the issue right
   now'.) Moreover, re-coqing the whole development, taking into
   account all the new `basic generalities' will take a lot of time,
   which discourages you even stronger to prove the add the
   generalities.

   On the other hand, starting from the basics only works (and even
   then only to a certain extent) if you know what the basic results
   are that you will be needing. This is the case for established
   theories, like groups (but even then you will notice that when
   you're in Coq, you will need a lot more then you had imagined), but
   it does not work if you want to set up, say, a small library for
   dealing with finite sequences: you will reamin working on the
   basics for a long time, to find out later that you needed different
   definitions and properties about them.
\item
   `Efficiency' makes that you will write down the development less
   clearly then possible and desirable. For example Freek uses
   \verb!Half! instead of \verb!One[/]Two! and then chooses a
   derivation that uses only multiplication, because division is so
   complicated. That is not what you want, because the development
   gets less perspicuous.
\end{enumerate}
General namegiving conventions:
\begin{itemize}
\item \verb!imp! stands for implies.
\item ``left'' and ``right'' are abbreviated to \verb!lft! and \verb!rht!,
      respectively.
\item 
\begin{tabular}[t]{lll}
preserve & $\mapsto$ & {\tt pres}\\
predicate & $\mapsto$ & {\tt pred}\\
relation & $\mapsto$ & {\tt rel}\\
respects & $\mapsto$ & {\tt resp}\\
\end{tabular}
\end{itemize}
\newpage
\section{Formalization of the algebraic hierarchy in Coq}

We extend 
structures according to the following abstract
pattern (the reader might find it easier to consider a specific example,
e.g. see Section~\ref{section:monoids}).

\newcommand{\mvar}[1]{{\it #1}}
\newcommand{\mvarSub}[2]{$\text{\it#1}_#2$}
Let us say we extend structure $A$ (with name \mvar{AName}) to structure $B$
(with name \mvar{BName}, abbreviated to \mvar{b}), with operations
\mvarSub{opName}{1} : $\sigma_1$, \ldots,
\mvarSub{opName}{n} : $\sigma_n$, and with properties
\mvarSub{propName}{1} : $P_1$, \ldots,
\mvarSub{propName}{m} : $P_m$.
We do this as follows.

First we define a record \verb!is_!\mvar{Bname} in which all properties are
grouped:
\begin{tabbing}
\tt Record \verb!is_!\mvar{BName} 
    [A:\mvar{AName}; \mvarSub{opName}{1} : $\sigma_1$; {\ldots} ; 
                     \mvarSub{opName}{n} : $\sigma_n$] : Prop := \\
\tt \verb!  {ax_!\mvarSub{propName}{1} : $P_1$; \\
\tt \verb!   !\vdots \\
\tt \verb!   ax_!\mvarSub{propName}{m} : $P_m$\\
\tt \verb!  }.!
\end{tabbing}
Then we define the actual structure $B$:
\begin{tabbing}
\tt Record \mvar{BName} : Type :=\\
\tt  \verb!  {!\mvar{b}\verb!_crr :> !\mvar{AName};\\
\tt  \verb!   !\mvar{b}\verb!_!\mvarSub{opName}{1} : $\sigma_1$; \\
\tt  \verb!   !\vdots \\
\tt  \verb!   !\mvar{b}\verb!_!\mvarSub{opName}{n} : $\sigma_n$; \\
\tt  \verb!   !\mvar{b}\verb!_proof : (is_!\mvar{BName} \mvar{b}\verb!_crr!
                                  \mvar{b}\verb!_!\mvarSub{opName}{1} \ldots
                                  \mvar{b}\verb!_!\mvarSub{opName}{n}\verb!)!\\
\tt  \verb!  }.!
\end{tabbing}
And then we prove the basic lemmas directly corresponding to the properties
(maybe after introducing some notational conveniences).
\begin{tabbing}
\tt Section \mvar{BName}\verb!_axioms.!\\
\tt Variable B : \mvar{BName}.\\
\tt Lemma \mvar{BName}\verb!_is_!\mvar{BName} : \verb!is_!\mvar{BName} B 
\mvar{b}\verb!_!\mvarSub{opName}{1}\ldots\mvar{b}\verb!_!\mvarSub{opName}{n}.\\
\tt Lemma \mvarSub{propName}{1} : $P_1$.\\
\tt \vdots\\
\tt Lemma \mvarSub{propName}{m} : $P_m$.\\
\tt End \mvar{BName}\verb!_axioms.!\\
\end{tabbing}
The reason for introducing
the basic lemmas is stated in note~\ref{item:basic-lemmas}
below.

Notes.
\begin{enumerate}
\item The properties $P_1$ through $P_m$ are always written using auxiliary
definitions, often defined directly before \verb!is_!\mvar{Bname}.
E.g.\ in the definition of monoids (Section~\ref{section:monoids}) $P_1$ is
\verb!is_rht_unit G Csg_op Zero!, and \verb!is_rht_unit! is defined 
directly before \verb!is_Monoid!.
\item If there is just one property (i.e.\ $m=1$), then we do not use the
record mechanism to define \verb!is_!\mvar{Bname}, but use an ordinary
definition instead.
\item\label{item:basic-lemmas}
Each field in the record \verb!is_!\mvar{Bname} has an associated
function \verb!ax_!\mvarSub{propName}{i}, with the following type:
\begin{tabbing}\tt
(A:\mvar{AName}; \mvarSub{opName}{1} : $\sigma_1$; {\ldots} ; 
                 \mvarSub{opName}{n} : $\sigma_n$)
 \verb!is_!\mvar{BName} \verb!->! $P_i$.
\end{tabbing}
This type is very cumbersome to use. Therefore we introduced the basic lemmas.
The natural names \mvarSub{propName}{1}\ldots \mvarSub{propName}{m}
are reserved for these basic lemmas, and to avoid name clashes
the field names are prefixed with ``\verb!ax_!''.
\item The operations may be either functions that deliver a mathematical
object (e.g.\ addition), or predicates (e.g.\ less than).
\end{enumerate}
\subsection*{Alternatives and design decisions}
\begin{itemize}
\item Alternative: more structuring, with \verb!sig_!\mvar{bName}.
\item Alternative: less structuring, without \verb!is_!\mvar{bName}.
\end{itemize}

\section{New tactics}
There are two groups of new tactics, each treated in a separate subsection.
To understand their description the reader
should have basic knowledge of our implementation of the algebraic hierarchy.

\subsection{Proving equalities}
There are two new tactics that prove \verb!CSetoid! equalities, i.e.\ goals of
the form $a$ \verb![=]! $b$.
First, we have the \verb!Algebra! tactic, which is implemented with Coq's Auto
mechanism.
It can be used to prove simple equalities, typically only those that are
just one application of a lemma.

Second, we have the \verb!Rational! tactic.
This tactic works only from \verb!CRings! onwards, so for \verb!CRings!,
\verb!CFields!, \verb!COrdFields! and so on, but not for \verb!CGroups!,
\verb!CMonoids!, etc.
The tactic \verb!Rational! is much more clever than \verb!Algebra!: it rewrites
both sides of the equality to some canonical form and compares these.
It automatically uses commutativity, associativity and so on.

\subsection{Using equalities}
Consider the following situation:
the goal is of the form $a$ \verb![#]! $b$ and the user wants to prove this
by showing $a'$ \verb![#]! $b$, since $a$ \verb![=]! $a'$.
In this situation, the user can type \verb!Step_ap_lft! $a'$.
This generates the goal $a'$ \verb![#]! $b$, and a goal $a$ \verb![=]! $a'$,
which the \verb!Algebra! tactic tries to solve.

Similarly, the right hand side $b$ of an apartness can be replaced by an equal
$b'$ by typing \verb!Step_ap_rht! $b'$.
Similar to \verb!Step_ap_lft! and \verb!Step_ap_rht! are the
\verb!Step_Rat_ap_lft! and \verb!Step_Rat_ap_rht! tactics, which use 
\verb!Rational! instead of \verb!Algebra! to prove the equality.

These four tactic are for the apartness relation. Similar tactics exist for
\verb![=]!, \verb![:<]!, \verb![:<=]!, and \verb!AbsSmall!, as shown below.

\begin{tabular}{l|l|l}
Relation & equality proved with \verb!Algebra!
         & equality proved with \verb!Rational! \\\hline
\verb![#]! & \verb!Step_ap_lft! & \verb!Step_Rat_ap_lft! \\
           & \verb!Step_ap_rht! & \verb!Step_Rat_ap_rht! \\\hline
\verb![=]! & \verb!Step_lft! (or \verb!Step!)&  \verb!Step_Rat_lft! \\
           & \verb!Step_rht! (or \verb!Stepr!) & \verb!Step_Rat_rht! \\\hline
\verb![:<]! & \verb!Step_less_lft! & \verb!Step_Rat_less_lft! \\
           & \verb!Step_less_rht! & \verb!Step_Rat_less_rht! \\\hline
\verb![:<=]! & \verb!Step_leEq_lft! & \verb!Step_Rat_leEq_lft! \\
             & \verb!Step_leEq_rht! & \verb!Step_Rat_leEq_rht! \\\hline
\verb!AbsSmall! & \verb!Step_AbsSmall_lft!&\verb!Step_Rat_AbsSmall_lft! \\
                & \verb!Step_AbsSmall_rht!&\verb!Step_Rat_AbsSmall_rht!\\\hline
\end{tabular}

Finally, the \verb!Step_final! $c$ tactic tries to prove the equality
$a$ \verb![=]! $b$ by applying \verb!Algebra! to 
$a$ \verb![=]! $c$ and $c$ \verb![=]! $b$.
% $Id:$ 

% file "Basics.v", line 6-7 *)
\section{Basics}
This is random stuff that should be in the Coq basic library.
% file "Basics.v", line 11-12 *)
This is the axiom of choice.  It currently is the one `real'
axiom.  We need it because we write our logic in Prop.
% file "Basics.v", line 15 *)
\index{ex_informative@\verb/ex_informative/, (\emph{lemma})}
\begin{verbatim}
Axiom ex_informative : (A:Set;P:A->Prop)(Ex [x:A](P x))->{x:A|(P x)}.
\end{verbatim}
% file "Basics.v", line 19-20 *)
The next is needed to define the Max function. We have to be able
to go from a `non-informative' disjunction to an `informative' one
% file "Basics.v", line 23 *)
\index{or_informative@\verb/or_informative/, \emph{lemma}}
\begin{verbatim}
Lemma or_informative : (A,B:Prop)A\/B->{A}+{B}.
\end{verbatim}
% file "Basics.v", line 32 *)
\index{lt_z_two@\verb/lt_z_two/, \emph{lemma}}
\begin{verbatim}
Lemma lt_z_two: (lt O (2)).
\end{verbatim}
% file "Basics.v", line 38 *)
\index{le_pred@\verb/le_pred/, \emph{lemma}}
\begin{verbatim}
Lemma le_pred : (n,m:nat)(le n m)->(le (pred n)(pred m)).
\end{verbatim}
% file "Basics.v", line 48-49 *)
\index{lt_mult_right@\verb/lt_mult_right/, \emph{lemma}}
\begin{verbatim}
Lemma lt_mult_right :
  (x,y,z:nat) (lt x y) -> (lt (0) z) -> (lt (mult x z) (mult y z)).
\end{verbatim}
% file "Basics.v", line 60-61 *)
\index{le_mult_left@\verb/le_mult_left/, \emph{lemma}}
\begin{verbatim}
Lemma le_mult_left :
  (x,y,z:nat) (le x y) -> (le (mult z x) (mult z y)).
\end{verbatim}
% file "Basics.v", line 74-75 *)
Faculty function. Does not exist in Arith. (?)
Needed for special operations on polynomials.
% file "Basics.v", line 78-83 *)
\index{fac@\verb/fac/, \emph{fixpoint}}
\begin{verbatim}

Fixpoint fac [n:nat] :nat :=
	Cases n of
	   O 		=> (S O)
	   | (S m)	=> (mult (S m)(fac m))
	end.
\end{verbatim}
% file "Basics.v", line 87 *)
\index{nat_fac_gtzero@\verb/nat_fac_gtzero/, \emph{lemma}}
\begin{verbatim}
Lemma nat_fac_gtzero:(n:nat)(lt O (fac n)).
\end{verbatim}
% file "Basics.v", line 124 *)
\index{not_eq_sym@\verb/not_eq_sym/, \emph{lemma}}
\begin{verbatim}
Lemma not_eq_sym: (A:Set; a,b:A) ~a=b -> ~b=a.
\end{verbatim}
% file "Basics.v", line 130 *)
\index{contrapos@\verb/contrapos/, \emph{lemma}}
\begin{verbatim}
Lemma contrapos: (A,B:Prop)(A->B)->(X:Prop)(B->X)->A->X.
\end{verbatim}
% file "Basics.v", line 136 *)
\index{deMorgan_or_and@\verb/deMorgan_or_and/, \emph{lemma}}
\begin{verbatim}
Lemma deMorgan_or_and: (A,B,X:Prop)((A\/B)->X) -> (A->X)/\(B->X).
\end{verbatim}
% file "Basics.v", line 142 *)
\index{deMorgan_and_or@\verb/deMorgan_and_or/, \emph{lemma}}
\begin{verbatim}
Lemma deMorgan_and_or: (A,B,X:Prop)(A->X)/\(B->X) -> (A\/B->X).
\end{verbatim}
% file "Basics.v", line 148-149 *)
\index{deMorgan_ex_all@\verb/deMorgan_ex_all/, \emph{lemma}}
\begin{verbatim}
Lemma deMorgan_ex_all:
  (A:Set)(P:A->Prop)(X:Prop)((Ex P)->X) -> (a:A)(P a)->X.
\end{verbatim}
% file "Basics.v", line 155-156 *)
\index{deMorgan_all_ex@\verb/deMorgan_all_ex/, \emph{lemma}}
\begin{verbatim}
Lemma deMorgan_all_ex:
  (A:Set)(P:A->Prop)(X:Prop)((a:A)(P a)->X) -> (Ex P)->X.
\end{verbatim}
% file "Basics.v", line 162-163 *)
\begin{verbatim}
Inductive Ex2 [A,B:Set; P:A->B->Prop] : Prop :=
   Ex2_intro: (a:A;b:B)(P a b) -> (Ex2 P).
\end{verbatim}
% file "Basics.v", line 169-170 *)
Three lemmas for proving properties about definitions made with case
distinction to a sumbool, i.e. \verb!{A} + {B}!.
% file "Basics.v", line 173-175 *)
\index{sumbool_rec_or@\verb/sumbool_rec_or/, \emph{lemma}}
\begin{verbatim}
Lemma sumbool_rec_or : (A,B:Prop)(S:Set)(l,r:S)(s:{A}+{B})
                  (sumbool_rec A B [_:{A}+{B}]S [x:A]l [x:B]r s) = l \/
                  (sumbool_rec A B [_:{A}+{B}]S [x:A]l [x:B]r s) = r.
\end{verbatim}
% file "Basics.v", line 183-184 *)
\index{not_r_sumbool_rec@\verb/not_r_sumbool_rec/, \emph{lemma}}
\begin{verbatim}
Lemma not_r_sumbool_rec : (A,B:Prop)(S:Set)(l,r:S)~B->(H:{A}+{B})
                  (sumbool_rec A B [_:{A}+{B}]S [x:A]l [x:B]r H) = l.
\end{verbatim}
% file "Basics.v", line 192-193 *)
\index{not_l_sumbool_rec@\verb/not_l_sumbool_rec/, \emph{lemma}}
\begin{verbatim}
Lemma not_l_sumbool_rec : (A,B:Prop)(S:Set)(l,r:S)~A->(H:{A}+{B})
                          (sumbool_rec A B [_:{A}+{B}]S [x:A]l [x:B]r H) = r.
\end{verbatim}
% file "Basics.v", line 201 *)
\index{max@\verb/max/, \emph{definition}}
\begin{verbatim}
Definition max : nat->nat->nat.
\end{verbatim}
% file "Basics.v", line 210 *)
\index{le_max1@\verb/le_max1/, \emph{lemma}}
\begin{verbatim}
Lemma le_max1 : (m,n:nat)(le m (max m n)).
\end{verbatim}
% file "Basics.v", line 222 *)
\index{le_max2@\verb/le_max2/, \emph{lemma}}
\begin{verbatim}
Lemma le_max2 : (m,n:nat)(le n (max m n)).
\end{verbatim}
% file "Basics.v", line 235 *)
\subsection{Some results about Z}
% file "Basics.v", line 239-240 *)
We consider the injection \verb!inject_nat! from \verb!nat! to !Z! as a
coercion.
% file "Basics.v", line 245-253 *)
\index{POS_anti_convert@\verb/POS_anti_convert/, \emph{lemma}}
\begin{verbatim}
Lemma POS_anti_convert :
              (n:nat)`(S n) = (POS (anti_convert n))`.
Induction n.
Simpl.
Reflexivity.
Intros.
Simpl.
Reflexivity.
Qed.
\end{verbatim}
% file "Basics.v", line 257-258 *)
\index{NEG_anti_convert@\verb/NEG_anti_convert/, \emph{lemma}}
\begin{verbatim}
Lemma NEG_anti_convert :
              (n:nat)`-(S n) = (NEG (anti_convert n))`.
\end{verbatim}
% file "Basics.v", line 269-270 *)
\index{lt_O_positive_to_nat@\verb/lt_O_positive_to_nat/, \emph{lemma}}
\begin{verbatim}
Lemma lt_O_positive_to_nat :
                     (p:positive)(m:nat)(lt O m)->(lt O (positive_to_nat p m)).
\end{verbatim}
% file "Basics.v", line 287-288 *)
\index{anti_convert_pred_convert@\verb/anti_convert_pred_convert/, \emph{lemma}}
\begin{verbatim}
Lemma anti_convert_pred_convert :
                          (p:positive)(p = (anti_convert (pred (convert p)))).
\end{verbatim}
% file "Basics.v", line 312 *)
\index{p_is_some_anti_convert@\verb/p_is_some_anti_convert/, \emph{lemma}}
\begin{verbatim}
Lemma p_is_some_anti_convert : (p:positive)(EX n:nat | p = (anti_convert n)).
\end{verbatim}
% file "Basics.v", line 320-321 *)
\index{convert_is_POS@\verb/convert_is_POS/, \emph{lemma}}
\begin{verbatim}
Lemma convert_is_POS :
              (p:positive)`(convert p) = (POS p)`.
\end{verbatim}
% file "Basics.v", line 332-333 *)
\index{min_convert_is_NEG@\verb/min_convert_is_NEG/, \emph{lemma}}
\begin{verbatim}
Lemma min_convert_is_NEG :
              (p:positive)`-(convert p) = (NEG p)`.
\end{verbatim}
% file "Basics.v", line 344 *)
\index{Z_exh@\verb/Z_exh/, \emph{lemma}}
\begin{verbatim}
Lemma Z_exh : (z:Z)(EX n:nat | z=n) \/ (EX n:nat | z=`-n`).
\end{verbatim}
% file "Basics.v", line 364-365 *)
\index{nats_Z_ind@\verb/nats_Z_ind/, \emph{lemma}}
\begin{verbatim}
Lemma nats_Z_ind :
                 (P:Z->Prop)((n:nat)(P n)) -> ((n:nat)(P `-n`)) -> (z:Z)(P z).
\end{verbatim}
% file "Basics.v", line 378-381 *)
\index{pred_succ_Z_ind@\verb/pred_succ_Z_ind/, \emph{lemma}}
\begin{verbatim}
Lemma pred_succ_Z_ind : (P:Z->Prop)(P `0`) ->
                                   ((n:Z)(P n)->(P `n+1`)) ->
                                   ((n:Z)(P n)->(P `n-1`)) ->
                                   (z:Z)(P z).
\end{verbatim}
% file "Basics.v", line 408 *)
\index{Zmult_minus_distr_r@\verb/Zmult_minus_distr_r/, \emph{lemma}}
\begin{verbatim}
Lemma Zmult_minus_distr_r : (n,m,p:Z)`p*(n-m) = p*n-p*m`.
\end{verbatim}
% file "Basics.v", line 420 *)
\index{Zodd_Zeven_min1@\verb/Zodd_Zeven_min1/, \emph{lemma}}
\begin{verbatim}
Lemma Zodd_Zeven_min1 : (x:Z)(Zodd x) -> (Zeven `x-1`).
\end{verbatim}
% file "Basics.v", line 441-446 *)
\index{caseZ_diff@\verb/caseZ_diff/, \emph{definition}}
\begin{verbatim}
Definition caseZ_diff := [A:Set][z:Z][f:nat->nat->A]
  Cases z of
    ZERO => (f O O)
  | (POS m) => (f (convert m) O)
  | (NEG m) => (f O (convert m))
  end.
\end{verbatim}
% file "Basics.v", line 451 *)
\index{caseZ_diff_O@\verb/caseZ_diff_O/, \emph{lemma}}
\begin{verbatim}
Lemma caseZ_diff_O : (A:Set)(f:nat->nat->A)(caseZ_diff `0` f) = (f O O).
\end{verbatim}
% file "Basics.v", line 458-459 *)
\index{caseZ_diff_Pos@\verb/caseZ_diff_Pos/, \emph{lemma}}
\begin{verbatim}
Lemma caseZ_diff_Pos : (A:Set)(f:nat->nat->A)(n:nat)
                       (caseZ_diff `n` f) = (f n O).
\end{verbatim}
% file "Basics.v", line 471-472 *)
\index{caseZ_diff_Neg@\verb/caseZ_diff_Neg/, \emph{lemma}}
\begin{verbatim}
Lemma caseZ_diff_Neg : (A:Set)(f:nat->nat->A)(n:nat)
                       (caseZ_diff `-n` f) = (f O n).
\end{verbatim}
% file "Basics.v", line 484-486 *)
\index{proper_caseZ_diff@\verb/proper_caseZ_diff/, \emph{lemma}}
\begin{verbatim}
Lemma proper_caseZ_diff : (A:Set)(f:nat->nat->A)
              ((m,n,p,q:nat)(plus m q) = (plus n p) -> (f m n) = (f p q)) ->
              (m,n:nat)(caseZ_diff `m-n` f) = (f m n).
\end{verbatim}
% file "Basics.v", line 514 *)
\index{diff_Z_ind@\verb/diff_Z_ind/, \emph{lemma}}
\begin{verbatim}
Lemma diff_Z_ind : (P:Z->Prop)((m,n:nat)(P `m-n`)) -> ((z:Z)(P z)).
\end{verbatim}
% file "CSetoids.v", line 8-10 *)
\section{Setoids}
Definition of a constructive setoid,
i.e. a set with an equivalence relation and an apartness relation.
% file "CSetoids.v", line 28-31 *)
\subsection{Relations necessary for Setoids}
\begin{convention}
Let \verb!A : Set!.
\end{convention}
% file "CSetoids.v", line 37-38 *)
\index{irreflexive@\verb/irreflexive/, \emph{definition}}
\begin{verbatim}
Definition irreflexive [R:(relation A)] : Prop :=
        (x:A)(not(R x x)).
\end{verbatim}
% file "CSetoids.v", line 42-43 *)
\index{cotransitive@\verb/cotransitive/, \emph{definition}}
\begin{verbatim}
Definition cotransitive [R:(relation A)] : Prop :=
        (x,y:A)(R x y) -> (z:A)(R x z) \/ (R z y).
\end{verbatim}
% file "CSetoids.v", line 47-48 *)
\index{tight_apart@\verb/tight_apart/, \emph{definition}}
\begin{verbatim}
Definition tight_apart [eq,R:(relation A)]: Prop :=
        (x,y:A)(not(R x y)) <-> (eq x y).
\end{verbatim}
% file "CSetoids.v", line 52-53 *)
\index{antisymmetric@\verb/antisymmetric/, \emph{definition}}
\begin{verbatim}
Definition antisymmetric [R:(relation A)] : Prop :=
        (x,y: A)(R x y) -> (not(R y x)).
\end{verbatim}
% file "CSetoids.v", line 60 *)
\subsection{Definition of Setoid}
% file "CSetoids.v", line 63-68 *)
\index{is_CSetoid@\verb/is_CSetoid/, \emph{record}}
\begin{verbatim}
Record is_CSetoid [A:Set; eq,ap:(relation A)] : Prop :=
  { ax_ap_irreflexive  : (irreflexive ap);
    ax_ap_symmetric    : (Symmetric ap);
    ax_ap_cotransitive : (cotransitive ap);
    ax_ap_tight        : (tight_apart eq ap)
  }.
\end{verbatim}
% file "CSetoids.v", line 72-77 *)
\index{CSetoid@\verb/CSetoid/, \emph{record}}
\begin{verbatim}
Record CSetoid : Type :=
  { cs_crr   :> Set;
    cs_eq    :  (relation cs_crr);
    cs_ap    :  (relation cs_crr);
    cs_proof :  (is_CSetoid cs_crr cs_eq cs_ap)
  }.
\end{verbatim}
% file "CSetoids.v", line 81-86 *)
\begin{notation}
\begin{itemize}
\item \verb!cs_eq ? x y! is denoted by \verb!x [=] y!.
\item \verb!cs_ap ? x y! is denoted by \verb!x [#] y!.
\end{itemize}
\end{notation}
% file "CSetoids.v", line 99 *)
\index{cs_neq@\verb/cs_neq/, \emph{definition}}
\begin{verbatim}
Definition cs_neq [S: CSetoid] : (relation S) := [x,y:S](not(x [=] y)).
\end{verbatim}
% file "CSetoids.v", line 103-105 *)
\begin{notation}
\verb!cs_neq ? x y! is denoted by \verb!x [~=] y!.
\end{notation}
% file "CSetoids.v", line 124-127 *)
\begin{nameconvention}
In the names of lemmas, we refer to \verb! [=]! by \verb!eq!, \verb![~=]! by
\verb!neq!, and \verb![#]! by \verb!ap!.
\end{nameconvention}
% file "CSetoids.v", line 131-135 *)
\subsection{Setoid axioms}
We want concrete lemmas that state the axiomatic properties of a setoid.
\begin{convention}
Let \verb!S! be a setoid.
\end{convention}
% file "CSetoids.v", line 144 *)
\index{CSetoid_is_CSetoid@\verb/CSetoid_is_CSetoid/, \emph{lemma}}
\begin{verbatim}
Lemma CSetoid_is_CSetoid : (is_CSetoid S (cs_eq S) (cs_ap S)).
\end{verbatim}
% file "CSetoids.v", line 149 *)
\index{ap_irreflexive@\verb/ap_irreflexive/, \emph{lemma}}
\begin{verbatim}
Lemma ap_irreflexive : (irreflexive (cs_ap S)).
\end{verbatim}
% file "CSetoids.v", line 157 *)
\index{ap_symmetric@\verb/ap_symmetric/, \emph{lemma}}
\begin{verbatim}
Lemma ap_symmetric : (Symmetric (cs_ap S)).
\end{verbatim}
% file "CSetoids.v", line 165 *)
\index{ap_cotransitive@\verb/ap_cotransitive/, \emph{lemma}}
\begin{verbatim}
Lemma ap_cotransitive : (cotransitive (cs_ap S)).
\end{verbatim}
% file "CSetoids.v", line 173 *)
\index{ap_tight@\verb/ap_tight/, \emph{lemma}}
\begin{verbatim}
Lemma ap_tight : (tight_apart (cs_eq S) (cs_ap S)).
\end{verbatim}
% file "CSetoids.v", line 185-188 *)
\subsection{Setoid basics}\label{section:setoid-basics}
\begin{convention}
Let \verb!S! be a setoid.
\end{convention}
% file "CSetoids.v", line 199-201 *)
In `there exists a {\em unique\/}
$a:S$ such that \ldots ', we now mean unique with respect to the
setoid equality. We use \verb!ex_unq! to denote unique existence
% file "CSetoids.v", line 205-206 *)
\index{ex_unq@\verb/ex_unq/, \emph{definition}}
\begin{verbatim}
Definition ex_unq := [P:S->Prop]
	(EX x:S | (P x) /\ (y:S)(P y)-> x[=]y).
\end{verbatim}
% file "CSetoids.v", line 210 *)
\index{eq_reflexive@\verb/eq_reflexive/, \emph{lemma}}
\begin{verbatim}
Lemma eq_reflexive: (Reflexive (cs_eq S)).
\end{verbatim}
% file "CSetoids.v", line 218 *)
\index{eq_symmetric@\verb/eq_symmetric/, \emph{lemma}}
\begin{verbatim}
Lemma eq_symmetric: (Symmetric (cs_eq S)).
\end{verbatim}
% file "CSetoids.v", line 227 *)
\index{eq_transitive@\verb/eq_transitive/, \emph{lemma}}
\begin{verbatim}
Lemma eq_transitive: (Transitive (cs_eq S)).
\end{verbatim}
% file "CSetoids.v", line 240-250 *)
\begin{shortcoming}
The lemma \verb!eq_reflexive! above is convertible to
\verb!eq_reflexive_unfolded! below. We need the second version too,
because the first cannot be applied when an instance of reflexivity is needed.
(``I have complained bitterly about this.'' RP)
\end{shortcoming}

\begin{nameconvention}
If lemma $a$ is just an unfolding of lemma $b$, the name of $a$ is the name
$b$ with the suffix ``\verb!_unfolded!''.
\end{nameconvention}
% file "CSetoids.v", line 254 *)
\index{eq_reflexive_unfolded@\verb/eq_reflexive_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma eq_reflexive_unfolded : (x:S)(x [=] x).
\end{verbatim}
% file "CSetoids.v", line 259 *)
\index{eq_symmetric_unfolded@\verb/eq_symmetric_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma eq_symmetric_unfolded : (x,y:S)(x [=] y)->(y [=] x).
\end{verbatim}
% file "CSetoids.v", line 264 *)
\index{eq_transitive_unfolded@\verb/eq_transitive_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma eq_transitive_unfolded : (x,y,z:S)(x [=] y)->(y [=] z)->(x [=] z).
\end{verbatim}
% file "CSetoids.v", line 271 *)
\index{ap_irreflexive_unfolded@\verb/ap_irreflexive_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma ap_irreflexive_unfolded : (x:S)(~(x[#]x)).
\end{verbatim}
% file "CSetoids.v", line 278-279 *)
\index{ap_cotransitive_unfolded@\verb/ap_cotransitive_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma ap_cotransitive_unfolded : (x,y:S)((x[#]y)->
                                         (z:S)((x[#]z) \/ (z[#]y))).
\end{verbatim}
% file "CSetoids.v", line 286 *)
\index{ap_symmetric_unfolded@\verb/ap_symmetric_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma ap_symmetric_unfolded : (x,y:S)((x[#]y) -> (y[#]x)).
\end{verbatim}
% file "CSetoids.v", line 291-297 *)
\begin{shortcoming}
We would like to write
\[\verb!Lemma eq_equiv_not_ap : (x,y:S)(x [=] y) <-> ~(x [#] y).!\]
In Coq, however, this lemma cannot be easily applied.
Therefore we have to split the lemma into the following two lemmas
\verb!eq_imp_not_ap! and \verb!not_ap_imp_eq!.
\end{shortcoming}
% file "CSetoids.v", line 301 *)
\index{eq_imp_not_ap@\verb/eq_imp_not_ap/, \emph{lemma}}
\begin{verbatim}
Lemma eq_imp_not_ap : (x,y:S)(x [=] y) -> ~(x [#] y).
\end{verbatim}
% file "CSetoids.v", line 310 *)
\index{not_ap_imp_eq@\verb/not_ap_imp_eq/, \emph{lemma}}
\begin{verbatim}
Lemma not_ap_imp_eq : (x,y:S)~(x [#] y) -> (x [=] y).
\end{verbatim}
% file "CSetoids.v", line 319 *)
\index{neq_imp_notnot_ap@\verb/neq_imp_notnot_ap/, \emph{lemma}}
\begin{verbatim}
Lemma neq_imp_notnot_ap : (x,y:S)(x [~=] y) -> ~~(x [#] y).
\end{verbatim}
% file "CSetoids.v", line 331 *)
\index{notnot_ap_imp_neq@\verb/notnot_ap_imp_neq/, \emph{lemma}}
\begin{verbatim}
Lemma notnot_ap_imp_neq :  (x,y:S)~~(x [#] y) -> (x [~=] y).
\end{verbatim}
% file "CSetoids.v", line 343 *)
\index{ap_imp_neq@\verb/ap_imp_neq/, \emph{lemma}}
\begin{verbatim}
Lemma ap_imp_neq: (x,y:S)(x [#] y)->(x [~=] y).
\end{verbatim}
% file "CSetoids.v", line 350 *)
\index{not_neq_imp_eq@\verb/not_neq_imp_eq/, \emph{lemma}}
\begin{verbatim}
Lemma not_neq_imp_eq : (x,y:S)~(x[~=]y) -> x [=] y.
\end{verbatim}
% file "CSetoids.v", line 361 *)
\index{eq_imp_not_neq@\verb/eq_imp_not_neq/, \emph{lemma}}
\begin{verbatim}
Lemma eq_imp_not_neq : (x,y:S)(x [=] y) -> ~(x[~=]y).
\end{verbatim}
% file "CSetoids.v", line 374-376 *)
\begin{notation}
\verb!Ex_unq! stands for \verb!ex_unq ?!
\end{notation}
% file "CSetoids.v", line 387-401 *)
\subsection{Relations and predicates}
Here we define the notions of well-definedness and strong extensionality
on predicates and relations.

\begin{convention}
Let \verb!S! be a setoid.
\end{convention}

\begin{nameconvention}
\begin{itemize}
\item ``well-defined'' is abbreviated to \verb!well_def! (or \verb!wd!?).
\item ``strongly extensional'' is abbreviated to \verb!strong_ext!
(or \verb!strext!?).
\end{itemize}
\end{nameconvention}
% file "CSetoids.v", line 409-413 *)
\subsubsection{Predicates}
\begin{convention}
Let \verb!P! be a predicate on (the carrier of) \verb!S!.
\end{convention}

% file "CSetoids.v", line 419-420 *)
\index{pred_strong_ext@\verb/pred_strong_ext/, \emph{definition}}
\index{pred_well_def@\verb/pred_well_def/, \emph{definition}}
\begin{verbatim}
Definition pred_strong_ext: Prop := (x,y: S)(P x) -> (P y) \/ (x [#] y).
Definition pred_well_def: Prop :=   (x,y: S)(P x) -> (x [=] y) -> (P y).
\end{verbatim}
% file "CSetoids.v", line 426 *)
\subsubsection{Definition of a setoid predicate}
% file "CSetoids.v", line 429-433 *)
\index{CSetoid_predicate@\verb/CSetoid_predicate/, \emph{record}}
\begin{verbatim}
Record CSetoid_predicate : Type :=
  { csp_pred   :> S -> Prop;
    csp_wd     :  (pred_well_def csp_pred);
    csp_strext :  (pred_strong_ext csp_pred)
  }.
\end{verbatim}
% file "CSetoids.v", line 440-443 *)
\subsubsection{Relation}
\begin{convention}
Let \verb!R! be a relation on (the carrier of) \verb!S!.
\end{convention}
% file "CSetoids.v", line 449-454 *)
\index{rel_well_def_rht@\verb/rel_well_def_rht/, \emph{definition}}
\index{rel_well_def_lft@\verb/rel_well_def_lft/, \emph{definition}}
\index{rel_strong_ext@\verb/rel_strong_ext/, \emph{definition}}
\begin{verbatim}
Definition rel_well_def_rht: Prop :=
  (x,y,z: S)(R x y) -> (y [=] z) -> (R x z).
Definition rel_well_def_lft: Prop :=
  (x,y,z: S)(R x y) -> (x [=] z) -> (R z y).
Definition rel_strong_ext : Prop :=
  (x1,x2,y1,y2 : S)(R x1 y1) -> (R x2 y2) \/ (x1 [#] x2) \/ (y1 [#] y2).
\end{verbatim}
% file "CSetoids.v", line 460-463 *)
\index{rel_strong_ext_lft@\verb/rel_strong_ext_lft/, \emph{definition}}
\index{rel_strong_ext_rht@\verb/rel_strong_ext_rht/, \emph{definition}}
\begin{verbatim}
Definition rel_strong_ext_lft : Prop :=
  (x1,x2,y : S)(R x1 y) -> (R x2 y) \/ (x1 [#] x2).
Definition rel_strong_ext_rht : Prop :=
  (x,y1,y2 : S)(R x y1) -> (R x y2) \/ (y1 [#] y2).
\end{verbatim}
% file "CSetoids.v", line 467 *)
\index{rel_strext_imp_lftarg@\verb/rel_strext_imp_lftarg/, \emph{lemma}}
\begin{verbatim}
Lemma rel_strext_imp_lftarg: rel_strong_ext -> rel_strong_ext_lft.
\end{verbatim}
% file "CSetoids.v", line 490 *)
\index{rel_strext_imp_rhtarg@\verb/rel_strext_imp_rhtarg/, \emph{lemma}}
\begin{verbatim}
Lemma rel_strext_imp_rhtarg: rel_strong_ext -> rel_strong_ext_rht.
\end{verbatim}
% file "CSetoids.v", line 505-506 *)
\index{rel_strextarg_imp_strext@\verb/rel_strextarg_imp_strext/, \emph{lemma}}
\begin{verbatim}
Lemma rel_strextarg_imp_strext:
   rel_strong_ext_rht -> rel_strong_ext_lft -> rel_strong_ext.
\end{verbatim}
% file "CSetoids.v", line 521 *)
\subsubsection{Definition of a setoid relation}
% file "CSetoids.v", line 525 *)
The type of relations over a setoid.
% file "CSetoids.v", line 528-533 *)
\index{CSetoid_relation@\verb/CSetoid_relation/, \emph{record}}
\begin{verbatim}
Record CSetoid_relation : Type :=
  { csr_rel    :> S -> S -> Prop;
    csr_wdr    : (rel_well_def_rht csr_rel);
    csr_wdl    : (rel_well_def_lft csr_rel);
    csr_strext : (rel_strong_ext csr_rel)
  }.
\end{verbatim}
% file "CSetoids.v", line 539 *)
\index{ap_well_def_rht@\verb/ap_well_def_rht/, \emph{lemma}}
\begin{verbatim}
Lemma ap_well_def_rht: (rel_well_def_rht (cs_ap S)).
\end{verbatim}
% file "CSetoids.v", line 551 *)
\index{ap_well_def_lft@\verb/ap_well_def_lft/, \emph{lemma}}
\begin{verbatim}
Lemma ap_well_def_lft: (rel_well_def_lft (cs_ap S)).
\end{verbatim}
% file "CSetoids.v", line 563-564 *)
\index{ap_well_def_rht_unfolded@\verb/ap_well_def_rht_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma ap_well_def_rht_unfolded:
   (x,y,z:S)(x [#] y) -> (y [=] z) -> (x [#] z).
\end{verbatim}
% file "CSetoids.v", line 569-570 *)
\index{ap_well_def_lft_unfolded@\verb/ap_well_def_lft_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma ap_well_def_lft_unfolded:
   (x,y,z:S)(x [#] y) -> (x [=] z) -> (z [#] y).
\end{verbatim}
% file "CSetoids.v", line 575 *)
\index{ap_strong_ext@\verb/ap_strong_ext/, \emph{lemma}}
\begin{verbatim}
Lemma ap_strong_ext: (rel_strong_ext (cs_ap S)).
\end{verbatim}
% file "CSetoids.v", line 589 *)
\index{predS_well_def@\verb/predS_well_def/, \emph{definition}}
\begin{verbatim}
Definition predS_well_def [P:S->Set]: Set := (x,y:S)(P x) -> (x [=] y) -> (P y).
\end{verbatim}
% file "CSetoids.v", line 612-621 *)
\subsection{Functions between setoids}
Such functions must preserve the setoid equality
and be strongly extensional w.r.t. the apartness, i.e. e.g.
if \verb!f(x,y) apart f(x1,y1)!, then  \verb!x apart x1 \/ y apart y1!.
For every arity this has to be defined separately.
\begin{convention}
Let \verb!S1!, \verb!S2! and \verb!S3! be setoids.
\end{convention}

First we consider unary functions.
% file "CSetoids.v", line 633-635 *)
In the following two definitions,
\verb!f! is a function from (the carrier of) \verb!S1! to
(the carrier of) \verb!S2!.
% file "CSetoids.v", line 640-641 *)
\index{fun_well_def@\verb/fun_well_def/, \emph{definition}}
\index{fun_strong_ext@\verb/fun_strong_ext/, \emph{definition}}
\begin{verbatim}
Definition fun_well_def : Prop := (x, y: S1)(x [=] y) -> (f x) [=] (f y).
Definition fun_strong_ext : Prop := (x, y: S1)((f x) [#] (f y)) -> x [#] y.
\end{verbatim}
% file "CSetoids.v", line 647 *)
\index{fun_strong_ext_imp_well_def@\verb/fun_strong_ext_imp_well_def/, \emph{lemma}}
\begin{verbatim}
Lemma fun_strong_ext_imp_well_def : fun_strong_ext -> fun_well_def.
\end{verbatim}
% file "CSetoids.v", line 664-668 *)
\index{CSetoid_fun@\verb/CSetoid_fun/, \emph{record}}
\begin{verbatim}
Record CSetoid_fun : Set :=
  { csf_fun    :> S1 -> S2;
    csf_wd     :  (fun_well_def csf_fun);
    csf_strext :  (fun_strong_ext csf_fun)
  }.
\end{verbatim}
% file "CSetoids.v", line 674 *)
\index{Const_CSetoid_fun@\verb/Const_CSetoid_fun/, \emph{definition}}
\begin{verbatim}
Definition Const_CSetoid_fun : S2 -> CSetoid_fun.
\end{verbatim}
% file "CSetoids.v", line 688-690 *)
Now we consider binary functions.
In the following two definitions,
\verb!f! is a function from \verb!S1! and \verb!S2! to \verb!S3!.
% file "CSetoids.v", line 695-701 *)
\index{bin_fun_well_def@\verb/bin_fun_well_def/, \emph{definition}}
\index{bin_fun_strong_ext@\verb/bin_fun_strong_ext/, \emph{definition}}
\begin{verbatim}
Definition bin_fun_well_def : Prop :=
  (x1, x2: S1)(y1, y2: S2)
   (x1 [=] x2) -> (y1 [=] y2) -> (f x1 y1) [=] (f x2 y2).

Definition bin_fun_strong_ext : Prop :=
  (x1, x2: S1)(y1, y2: S2)
   ((f x1 y1) [#] (f x2 y2)) -> (x1 [#] x2) \/ (y1 [#] y2).
\end{verbatim}
% file "CSetoids.v", line 707 *)
\index{bin_fun_strong_ext_imp_well_def@\verb/bin_fun_strong_ext_imp_well_def/, \emph{lemma}}
\begin{verbatim}
Lemma bin_fun_strong_ext_imp_well_def : bin_fun_strong_ext -> bin_fun_well_def.
\end{verbatim}
% file "CSetoids.v", line 727-731 *)
\index{CSetoid_bin_fun@\verb/CSetoid_bin_fun/, \emph{record}}
\begin{verbatim}
Record CSetoid_bin_fun : Set :=
  { csbf_fun    :> S1 -> S2 -> S3;
    csbf_wd     :  (bin_fun_well_def csbf_fun);
    csbf_strext :  (bin_fun_strong_ext csbf_fun)
  }.
\end{verbatim}
% file "CSetoids.v", line 745-747 *)
Let \verb!S1!,  \verb!S2! and \verb!S3! be setoids, \verb!f! a
setoid function from \verb!S1! to \verb!S2!, and \verb!g! from \verb!S2!
to \verb!S3! in the following definition of composition.
% file "CSetoids.v", line 754 *)
\index{compose_CSetoid_fun@\verb/compose_CSetoid_fun/, \emph{definition}}
\begin{verbatim}
Definition compose_CSetoid_fun: (CSetoid_fun S1 S3).
\end{verbatim}
% file "CSetoids.v", line 771-781 *)
\subsection{The unary and binary (inner) operations on a csetoid.}
An operation is a function with domain(s) and co-domain equal.

\begin{nameconvention}
The word ``unary operation'' is abbreviated to \verb!un_op!;
``binary operation'' is abbreviated to \verb!bin_op!.
\end{nameconvention}

\begin{convention}
Let \verb!S! be a setoid.
\end{convention}
% file "CSetoids.v", line 787 *)
Properties of binary operations
% file "CSetoids.v", line 790-792 *)
\index{commutes@\verb/commutes/, \emph{definition}}
\index{associative@\verb/associative/, \emph{definition}}
\begin{verbatim}
Definition commutes [f:S->S->S] : Prop := (x,y: S)(f x y) [=] (f y x).
Definition associative [f:S->S->S]: Prop :=
    (x,y,z:S)(f x (f y z)) [=] (f (f x y) z).
\end{verbatim}
% file "CSetoids.v", line 796 *)
Well-defined unary operations on a setoid.
% file "CSetoids.v", line 799-800 *)
\index{un_op_well_def@\verb/un_op_well_def/, \emph{definition}}
\index{un_op_strong_ext@\verb/un_op_strong_ext/, \emph{definition}}
\begin{verbatim}
Definition un_op_well_def := (fun_well_def S S).
Definition un_op_strong_ext := (fun_strong_ext S S).
\end{verbatim}
% file "CSetoids.v", line 804-805 *)
\index{CSetoid_un_op@\verb/CSetoid_un_op/, \emph{definition}}
\index{Build_CSetoid_un_op@\verb/Build_CSetoid_un_op/, \emph{definition}}
\begin{verbatim}
Definition CSetoid_un_op : Set := (CSetoid_fun S S).
Definition Build_CSetoid_un_op := (Build_CSetoid_fun S S).
\end{verbatim}
% file "CSetoids.v", line 811 *)
\index{id_strext@\verb/id_strext/, \emph{lemma}}
\begin{verbatim}
Lemma id_strext : (un_op_strong_ext [x:S]x).
\end{verbatim}
% file "CSetoids.v", line 820 *)
\index{id_pres_eq@\verb/id_pres_eq/, \emph{lemma}}
\begin{verbatim}
Lemma id_pres_eq : (un_op_well_def [x:S]x).
\end{verbatim}
% file "CSetoids.v", line 829 *)
\index{id_un_op@\verb/id_un_op/, \emph{definition}}
\begin{verbatim}
Definition id_un_op := (Build_CSetoid_un_op [x:S]x id_pres_eq id_strext).
\end{verbatim}
% file "CSetoids.v", line 836 *)
\index{un_op_strext@\verb/un_op_strext/, \emph{definition}}
\begin{verbatim}
Definition un_op_strext := (csf_strext S S).
\end{verbatim}
% file "CSetoids.v", line 842-843 *)
\index{un_op_wd_unfolded@\verb/un_op_wd_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma un_op_wd_unfolded:
  (op:CSetoid_un_op)(x,y:S)(x [=] y) -> (op x) [=] (op y).
\end{verbatim}
% file "CSetoids.v", line 848-849 *)
\index{un_op_strext_unfolded@\verb/un_op_strext_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma un_op_strext_unfolded:
  (op:CSetoid_un_op)(x,y:S)((op x) [#] (op y)) -> x [#] y.
\end{verbatim}
% file "CSetoids.v", line 855 *)
Well-defined binary operations on a setoid.
% file "CSetoids.v", line 858-859 *)
\index{bin_op_well_def@\verb/bin_op_well_def/, \emph{definition}}
\index{bin_op_strong_ext@\verb/bin_op_strong_ext/, \emph{definition}}
\begin{verbatim}
Definition bin_op_well_def := (bin_fun_well_def S S S).
Definition bin_op_strong_ext := (bin_fun_strong_ext S S S).
\end{verbatim}
% file "CSetoids.v", line 865-866 *)
\index{CSetoid_bin_op@\verb/CSetoid_bin_op/, \emph{definition}}
\index{Build_CSetoid_bin_op@\verb/Build_CSetoid_bin_op/, \emph{definition}}
\begin{verbatim}
Definition CSetoid_bin_op : Set := (CSetoid_bin_fun S S S).
Definition Build_CSetoid_bin_op := (Build_CSetoid_bin_fun S S S).
\end{verbatim}
% file "CSetoids.v", line 872-873 *)
\index{bin_op_wd@\verb/bin_op_wd/, \emph{definition}}
\index{bin_op_strext@\verb/bin_op_strext/, \emph{definition}}
\begin{verbatim}
Definition bin_op_wd := (csbf_wd S S S).
Definition bin_op_strext := (csbf_strext S S S).
\end{verbatim}
% file "CSetoids.v", line 883-885 *)
\index{bin_op_wd_unfolded@\verb/bin_op_wd_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma bin_op_wd_unfolded:
    (op:CSetoid_bin_op)(x1, x2, y1, y2: S)
      (x1 [=] x2) -> (y1 [=] y2) -> (op x1 y1) [=] (op x2 y2).
\end{verbatim}
% file "CSetoids.v", line 891-893 *)
\index{bin_op_strext_unfolded@\verb/bin_op_strext_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma bin_op_strext_unfolded:
    (op:CSetoid_bin_op)(x1, x2, y1, y2: S)
      ((op x1 y1) [#] (op x2 y2)) -> (x1 [#] x2) \/ (y1 [#] y2).
\end{verbatim}
% file "CSetoids.v", line 900-901 *)
\index{bin_op_is_wd_un_op_lft@\verb/bin_op_is_wd_un_op_lft/, \emph{lemma}}
\begin{verbatim}
Lemma bin_op_is_wd_un_op_lft:
    (op:CSetoid_bin_op)(c: S)(un_op_well_def [x:S](op x c)).
\end{verbatim}
% file "CSetoids.v", line 909-910 *)
\index{bin_op_is_wd_un_op_rht@\verb/bin_op_is_wd_un_op_rht/, \emph{lemma}}
\begin{verbatim}
Lemma bin_op_is_wd_un_op_rht:
    (op:CSetoid_bin_op)(c: S)(un_op_well_def [x:S](op c x)).
\end{verbatim}
% file "CSetoids.v", line 918-919 *)
\index{bin_op_is_strext_un_op_lft@\verb/bin_op_is_strext_un_op_lft/, \emph{lemma}}
\begin{verbatim}
Lemma bin_op_is_strext_un_op_lft:
    (op:CSetoid_bin_op)(c: S)(un_op_strong_ext [x:S](op x c)).
\end{verbatim}
% file "CSetoids.v", line 929-930 *)
\index{bin_op_is_strext_un_op_rht@\verb/bin_op_is_strext_un_op_rht/, \emph{lemma}}
\begin{verbatim}
Lemma bin_op_is_strext_un_op_rht:
    (op:CSetoid_bin_op)(c: S)(un_op_strong_ext [x:S](op c x)).
\end{verbatim}
% file "CSetoids.v", line 940-943 *)
\index{bin_op2un_op_rht@\verb/bin_op2un_op_rht/, \emph{definition}}
\begin{verbatim}
Definition bin_op2un_op_rht : CSetoid_bin_op->(S)->CSetoid_un_op :=
[op:CSetoid_bin_op; c:(S)]
 (Build_CSetoid_un_op [x:(S)](op c x)
   (bin_op_is_wd_un_op_rht op c) (bin_op_is_strext_un_op_rht op c)).
\end{verbatim}
% file "CSetoids.v", line 947-950 *)
\index{bin_op2un_op_lft@\verb/bin_op2un_op_lft/, \emph{definition}}
\begin{verbatim}
Definition bin_op2un_op_lft : CSetoid_bin_op->(S)->CSetoid_un_op :=
[op:CSetoid_bin_op; c:(S)]
 (Build_CSetoid_un_op [x:(S)](op x c)
   (bin_op_is_wd_un_op_lft op c) (bin_op_is_strext_un_op_lft op c)).
\end{verbatim}
% file "CSetoids.v", line 970-973 *)
\subsection{The binary outer operations on a csetoid.}
\begin{convention}
Let \verb!S1! and \verb!S2! be setoids.
\end{convention}
% file "CSetoids.v", line 980 *)
Well-defined outer operations on a setoid.
% file "CSetoids.v", line 983-989 *)
\index{outer_op_well_def@\verb/outer_op_well_def/, \emph{definition}}
\index{outer_op_strong_ext@\verb/outer_op_strong_ext/, \emph{definition}}
\index{CSetoid_outer_op@\verb/CSetoid_outer_op/, \emph{definition}}
\index{Build_CSetoid_outer_op@\verb/Build_CSetoid_outer_op/, \emph{definition}}
\index{csoo_wd@\verb/csoo_wd/, \emph{definition}}
\index{csoo_strext@\verb/csoo_strext/, \emph{definition}}
\begin{verbatim}
Definition outer_op_well_def := (bin_fun_well_def S1 S2 S2).
Definition outer_op_strong_ext := (bin_fun_strong_ext S1 S2 S2).

Definition CSetoid_outer_op : Set := (CSetoid_bin_fun S1 S2 S2).
Definition Build_CSetoid_outer_op := (Build_CSetoid_bin_fun S1 S2 S2).
Definition csoo_wd := (csbf_wd S1 S2 S2).
Definition csoo_strext := (csbf_strext S1 S2 S2).
\end{verbatim}
% file "CSetoids.v", line 994-996 *)
\index{csoo_wd_unfolded@\verb/csoo_wd_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma csoo_wd_unfolded:
    (op:CSetoid_outer_op)(x1, x2: S1)(y1, y2: S2)
      (x1 [=] x2) -> (y1 [=] y2) -> (op x1 y1) [=] (op x2 y2).
\end{verbatim}
% file "CSetoids.v", line 1006-1009 *)
\subsection{Combining operations}
\begin{convention}
Let \verb!S1!, \verb!S2! and \verb!S3! be setoids.
\end{convention}
% file "CSetoids.v", line 1015-1016 *)
In the following definition, we assume \verb!f! is a setoid function from
\verb!S1! to \verb!S2!, and \verb!op! is an unary operation on \verb!S2!.
% file "CSetoids.v", line 1023 *)
\verb!opOnFun! is the composition \verb!op! after \verb!f!.
% file "CSetoids.v", line 1026 *)
\index{opOnFun@\verb/opOnFun/, \emph{definition}}
\begin{verbatim}
Definition opOnFun: (CSetoid_fun S1 S2).
\end{verbatim}
% file "CSetoids.v", line 1046-1049 *)
\subsection{Subsetoids}
\begin{convention}
Let \verb!S! be a setoid, and \verb!P! a predicate on the carrier of \verb!S!.
\end{convention}
% file "CSetoids.v", line 1056-1059 *)
\index{subcsetoid_crr@\verb/subcsetoid_crr/, \emph{record}}
\begin{verbatim}
Record subcsetoid_crr : Set :=
  { scs_elem :> S;
    scs_prf : (P scs_elem)
  }.
\end{verbatim}
% file "CSetoids.v", line 1063-1067 *)
\index{restrict_relation@\verb/restrict_relation/, \emph{definition}}
\begin{verbatim}
Definition restrict_relation [R:(relation S)]: (relation subcsetoid_crr) :=
  [a, b: subcsetoid_crr]
  Cases a b of
   (Build_subcsetoid_crr x _) (Build_subcsetoid_crr y _) => (R x y)
  end.
\end{verbatim}
% file "CSetoids.v", line 1071-1072 *)
\index{subcsetoid_eq@\verb/subcsetoid_eq/, \emph{definition}}
\begin{verbatim}
Definition subcsetoid_eq: (relation subcsetoid_crr) :=
  (restrict_relation (cs_eq S)).
\end{verbatim}
% file "CSetoids.v", line 1076-1077 *)
\index{subcsetoid_ap@\verb/subcsetoid_ap/, \emph{definition}}
\begin{verbatim}
Definition subcsetoid_ap: (relation subcsetoid_crr) :=
  (restrict_relation (cs_ap S)).
\end{verbatim}
% file "CSetoids.v", line 1083 *)
\index{subcsetoid_equiv@\verb/subcsetoid_equiv/, \emph{remark}}
\begin{verbatim}
Remark subcsetoid_equiv : (equiv ? subcsetoid_eq).
\end{verbatim}
% file "CSetoids.v", line 1108 *)
\index{subcsetoid_is_CSetoid@\verb/subcsetoid_is_CSetoid/, \emph{lemma}}
\begin{verbatim}
Lemma subcsetoid_is_CSetoid : (is_CSetoid ? subcsetoid_eq subcsetoid_ap).
\end{verbatim}
% file "CSetoids.v", line 1126-1128 *)
\index{Build_SubCSetoid@\verb/Build_SubCSetoid/, \emph{definition}}
\begin{verbatim}
Definition Build_SubCSetoid : CSetoid :=
  (Build_CSetoid subcsetoid_crr subcsetoid_eq subcsetoid_ap
            subcsetoid_is_CSetoid).
\end{verbatim}
% file "CSetoids.v", line 1134-1137 *)
\subsubsection{Subsetoid unary operations}
\begin{convention}
Let \verb!f! be a unary setoid operation on \verb!S!.
\end{convention}
% file "CSetoids.v", line 1142 *)
\index{un_op_pres_pred@\verb/un_op_pres_pred/, \emph{definition}}
\begin{verbatim}
Definition un_op_pres_pred : Prop := (x:S)(P x) -> (P (f x)).
\end{verbatim}
% file "CSetoids.v", line 1145-1147 *)
\begin{convention}
Assume \verb!pr : un_op_pres_pred!.
\end{convention}
% file "CSetoids.v", line 1152-1156 *)
\index{restr_un_op@\verb/restr_un_op/, \emph{definition}}
\begin{verbatim}
Definition restr_un_op : subcsetoid_crr -> subcsetoid_crr :=
  [a: subcsetoid_crr]
  Cases a of (Build_subcsetoid_crr x p) =>
              (Build_subcsetoid_crr (f x) (pr x p))
  end.
\end{verbatim}
% file "CSetoids.v", line 1160 *)
\index{restr_un_op_well_def@\verb/restr_un_op_well_def/, \emph{lemma}}
\begin{verbatim}
Lemma restr_un_op_well_def: (un_op_well_def Build_SubCSetoid restr_un_op).
\end{verbatim}
% file "CSetoids.v", line 1167 *)
\index{restr_un_op_strong_ext@\verb/restr_un_op_strong_ext/, \emph{lemma}}
\begin{verbatim}
Lemma restr_un_op_strong_ext: (un_op_strong_ext Build_SubCSetoid restr_un_op).
\end{verbatim}
% file "CSetoids.v", line 1174-1176 *)
\index{Build_SubCSetoid_un_op@\verb/Build_SubCSetoid_un_op/, \emph{definition}}
\begin{verbatim}
Definition Build_SubCSetoid_un_op: (CSetoid_un_op Build_SubCSetoid) :=
  (Build_CSetoid_un_op Build_SubCSetoid restr_un_op restr_un_op_well_def
                                                       restr_un_op_strong_ext).
\end{verbatim}
% file "CSetoids.v", line 1183-1186 *)
\subsubsection{Subsetoid binary operations}
\begin{convention}
Let \verb!f! be a binary setoid operation on \verb!S!.
\end{convention}
% file "CSetoids.v", line 1191 *)
\index{bin_op_pres_pred@\verb/bin_op_pres_pred/, \emph{definition}}
\begin{verbatim}
Definition bin_op_pres_pred : Prop := (x,y:S)(P x) -> (P y) -> (P (f x y)).
\end{verbatim}
% file "CSetoids.v", line 1194-1196 *)
\begin{convention}
Assume \verb!un_op_pres_pred!.
\end{convention}
% file "CSetoids.v", line 1201-1204 *)
\index{restr_bin_op@\verb/restr_bin_op/, \emph{definition}}
\begin{verbatim}
Definition restr_bin_op [a,b:subcsetoid_crr]: subcsetoid_crr :=
  Cases a b of (Build_subcsetoid_crr x p) (Build_subcsetoid_crr y q) =>
                   (Build_subcsetoid_crr (f x y) (pr x y p q))
  end.
\end{verbatim}
% file "CSetoids.v", line 1208 *)
\index{restr_bin_op_well_def@\verb/restr_bin_op_well_def/, \emph{lemma}}
\begin{verbatim}
Lemma restr_bin_op_well_def: (bin_op_well_def Build_SubCSetoid restr_bin_op).
\end{verbatim}
% file "CSetoids.v", line 1215-1216 *)
\index{restr_bin_op_strong_ext@\verb/restr_bin_op_strong_ext/, \emph{lemma}}
\begin{verbatim}
Lemma restr_bin_op_strong_ext:
                         (bin_op_strong_ext Build_SubCSetoid restr_bin_op).
\end{verbatim}
% file "CSetoids.v", line 1223-1225 *)
\index{Build_SubCSetoid_bin_op@\verb/Build_SubCSetoid_bin_op/, \emph{definition}}
\begin{verbatim}
Definition Build_SubCSetoid_bin_op : (CSetoid_bin_op Build_SubCSetoid) :=
  (Build_CSetoid_bin_op Build_SubCSetoid restr_bin_op restr_bin_op_well_def
                                                    restr_bin_op_strong_ext).
\end{verbatim}
% file "CSetoids.v", line 1230-1231 *)
\index{restr_f_assoc@\verb/restr_f_assoc/, \emph{lemma}}
\begin{verbatim}
Lemma restr_f_assoc: (Associative f) ->
                     (Associative (Build_SubCSetoid_bin_op)).
\end{verbatim}
% file "CSetoids.v", line 1249 *)
\subsubsection{Miscalleneous}
% file "CSetoids.v", line 1254-1256 *)
\index{proper_caseZ_diff_CS@\verb/proper_caseZ_diff_CS/, \emph{lemma}}
\begin{verbatim}
Lemma proper_caseZ_diff_CS : (S:CSetoid)(f:nat->nat->S)
              ((m,n,p,q:nat)(plus m q) = (plus n p) -> (f m n) [=] (f p q)) ->
              (m,n:nat)(caseZ_diff `m-n` f) [=] (f m n).
\end{verbatim}
% file "vectors.v", line 11-15 *)
\section{Vector Basics}
\subsection{Some List Basics}
\begin{convention}
Let \verb!A! be a Set and \verb!X! be a Setoid.
\end{convention}
% file "vectors.v", line 23-26 *)
\index{NotIn@\verb/NotIn/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint NotIn  [x:X;l:(list X)] : Prop :=
      Cases l of
	nil => True
	| (cons y k) => (x[#]y)/\(NotIn x k) end.
\end{verbatim}
% file "vectors.v", line 30-33 *)
\index{distinct@\verb/distinct/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint distinct [l:(list X)] : Prop :=
Cases l of nil => True
	| (cons x k) => (NotIn x k)/\(distinct k)
end.
\end{verbatim}
% file "vectors.v", line 41-48 *)
\index{take@\verb/take/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint take [i:nat;l:(list A)] : (list A) :=
	Cases l of
	  nil 	=> (nil A)
	  | (cons x k) => (Cases i of
				O => (nil A)
				| (S j) => (cons x (take j k))
			   end)
	end.
\end{verbatim}
% file "vectors.v", line 56-63 *)
\index{drop@\verb/drop/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint drop [i:nat;l:(list A)] : (list A) :=
	Cases l of
	  nil 	=> (nil A)
	  | (cons x k) => (Cases i of
				O => l
				| (S j) =>  (drop j k)
			   end)
	end.
\end{verbatim}
% file "vectors.v", line 67-70 *)
Some preminiaries about list insertion. We insert an element at the end
if the index is too high, so
$\verb!ins_list! r i (l_0,\ldots, l_{n-1}) = (l_0,\ldots, l_{i-1} r l_i,
\ldots,l_{n-1})$
% file "vectors.v", line 74-81 *)
\index{ins_list@\verb/ins_list/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint ins_list [r:A;i:nat;l:(list A)] : (list A) :=
	Cases l of
	  nil 	=> (cons r (nil A))
	  | (cons x k) => (Cases i of
				O => (cons r (cons x k))
				| (S j) => (cons x (ins_list r j k))
			   end)
	end.
\end{verbatim}
% file "vectors.v", line 85-89 *)
\index{ins_end@\verb/ins_end/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint ins_end [r:A;l:(list A)] : (list A) :=
	Cases l of
	  nil 	=> (cons r (nil A))
	  | (cons x k) => (cons x (ins_end r k))
	end.
\end{verbatim}
% file "vectors.v", line 93-94 *)
\index{ins_lth@\verb/ins_lth/, \emph{lemma}}
\begin{verbatim}
Lemma ins_lth: (r:A; i:nat; l: (list A))
			((length (ins_list r i l)) = (S(length l))).
\end{verbatim}
% file "vectors.v", line 107-108 *)
\index{nthd_inslist_comm@\verb/nthd_inslist_comm/, \emph{lemma}}
\begin{verbatim}
Lemma nthd_inslist_comm : (i:nat; l:(list A);r:A)
			((nth i (ins_list r i l)r) = r).
\end{verbatim}
% file "vectors.v", line 118-119 *)
Taking the $i$th element of a list $l$, given that $l$ has length $n$
and $i< n$.
% file "vectors.v", line 122-138 *)
\index{nth_list@\verb/nth_list/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint nth_list [l:(list A);n:nat] :
                              (i:nat)(lt i n)->(length l)=n ->A :=
<[n:nat;l:(list A)](i:nat)(lt i n)->((length l)=n)->A>
Cases n l of
   O   _           => [i:nat;H:(lt i O);Hl :(length _)=O]
                                        (False_rec A (lt_n_O i H))
|(S n0) nil        => [i:nat;H:(lt i (S n0));Hl :(length (nil A))=(S n0)]
                                        (False_rec A (O_S n0 Hl))
|(S n0)(cons a l0) => [i:nat;H:(lt i (S n0));Hl :(length  (cons a l0))=(S n0)]
(* Distiguish (lt (S i) (S n0)) \/ ((S i)=(S n0)) *)
     (Cases (le_lt_eq_dec (S i) (S n0) H) of
(* x: (lt (S i) (S n0)) *)
     (left x) => (nth_list (lt_S_n i n0 x) (eq_add_S (length l0) n0 Hl))
(* x : ((S i)=(S n0)) *)
     | (right x) => a
     end)
end.
\end{verbatim}
% file "CSemiGroups.v", line 30 *)
\section{Semi Groups}
% file "CSemiGroups.v", line 34 *)
\subsection{Definition of the notion semi group}
% file "CSemiGroups.v", line 38-39 *)
\index{is_CSemi_grp@\verb/is_CSemi_grp/, \emph{definition}}
\begin{verbatim}
Definition is_CSemi_grp [A:CSetoid; unit: A; op:(CSetoid_bin_op A)] :=
  (Associative op).
\end{verbatim}
% file "CSemiGroups.v", line 43-48 *)
\index{CSemi_grp@\verb/CSemi_grp/, \emph{record}}
\begin{verbatim}
Record CSemi_grp : Type :=
  { csg_crr   :> CSetoid;
    csg_unit  :  csg_crr;                      (* non-empty *)
    csg_op    :  (CSetoid_bin_op csg_crr);
    csg_proof :  (is_CSemi_grp csg_crr csg_unit csg_op)
  }.
\end{verbatim}
% file "CSemiGroups.v", line 52-54 *)
\begin{notation}
\verb!csg_unit ?! is denoted with \verb!Zero!.
\end{notation}
% file "CSemiGroups.v", line 61-70 *)
\begin{notation}
\verb!csg_op ? x y! is denoted with \verb!x [+] y!.
\end{notation}

\begin{nameconvention}
In the {\em names} of lemmas, we will denote \verb!Zero! with \verb!zero!,
and \verb![+]! with \verb!plus!.
We denote \verb![#] Zero! in the names of lemmas by \verb!ap_zero!
(and not, e.g.\ \verb!nonzero!).
\end{nameconvention}
% file "CSemiGroups.v", line 81-85 *)
\subsection{Semi group axioms}
The axiomatic properties of a semi group.
\begin{convention}
Let \verb!G! be a semi-group.
\end{convention}
% file "CSemiGroups.v", line 91 *)
\index{CSemi_grp_is_CSemi_grp@\verb/CSemi_grp_is_CSemi_grp/, \emph{lemma}}
\begin{verbatim}
Lemma CSemi_grp_is_CSemi_grp : (is_CSemi_grp G Zero Csg_op).
\end{verbatim}
% file "CSemiGroups.v", line 98 *)
\index{plus_assoc@\verb/plus_assoc/, \emph{lemma}}
\begin{verbatim}
Lemma plus_assoc : (Associative (csg_op G)).
\end{verbatim}
% file "CSemiGroups.v", line 108-111 *)
\subsection{Semi group basics}
\begin{convention}
Let \verb!G! be a semi-group.
\end{convention}
% file "CSemiGroups.v", line 119-120 *)
\index{plus_assoc_unfolded@\verb/plus_assoc_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma plus_assoc_unfolded : (G:CSemi_grp)(x,y,z:G)
                            (x [+] (y [+] z)) [=] ((x [+] y) [+] z).
\end{verbatim}
% file "CSemiGroups.v", line 128-131 *)
The predicate "non-zero" is defined as follows.
In lemmas we will continue to write \verb!x [#] Zero!, rather than
\verb!nonZeroP x!, but the predicate is useful for some high-level definitions,
e.g. for the setoid of non-zeros.
% file "CSemiGroups.v", line 134 *)
\index{nonZeroP@\verb/nonZeroP/, \emph{definition}}
\begin{verbatim}
Definition nonZeroP [x:G] : Prop := (x [#] Zero).
\end{verbatim}
% file "CSemiGroups.v", line 146-150 *)
\subsection{Sub-semi-groups}
\begin{convention}
Let \verb!csg! a semi-group and \verb!P! a predicate on the semi-group with
\verb!P Zero! and which is preserved by \verb![+]!.
\end{convention}
% file "CSemiGroups.v", line 159-164 *)
\index{subcrr@\verb/subcrr/, \emph{local}}
\index{Build_SubCSemi_grp@\verb/Build_SubCSemi_grp/, \emph{definition}}
\begin{verbatim}
Local subcrr : CSetoid := (Build_SubCSetoid ? P).
Definition Build_SubCSemi_grp : CSemi_grp :=
  (Build_CSemi_grp subcrr
                   (Build_subcsetoid_crr ??? Punit)
                   (Build_SubCSetoid_bin_op ??? op_pres_P)
                   (restr_f_assoc ??? op_pres_P (plus_assoc csg))).
\end{verbatim}
% file "CMonoids.v", line 8-9 *)
\section{Monoids}\label{section:monoids}
We deal only with commutative algebraic structures.
% file "CMonoids.v", line 13 *)
\subsection{Definition of monoids}
% file "CMonoids.v", line 17-19 *)
\index{is_rht_unit@\verb/is_rht_unit/, \emph{definition}}
\begin{verbatim}
Definition is_rht_unit
 [S: CSetoid; op: (CSetoid_bin_op S); one: S] : Prop :=
    (x: S)((op x one) [=] x).
\end{verbatim}
% file "CMonoids.v", line 27-29 *)
\index{is_lft_unit@\verb/is_lft_unit/, \emph{definition}}
\begin{verbatim}
Definition is_lft_unit
 [S: CSetoid; op: (CSetoid_bin_op S); one: S] : Prop :=
    (x: S)((op one x) [=] x).
\end{verbatim}
% file "CMonoids.v", line 36-39 *)
\index{is_CMonoid@\verb/is_CMonoid/, \emph{record}}
\begin{verbatim}
Record is_CMonoid [G: CSemi_grp]: Prop :=
  { runit : (is_rht_unit G Csg_op Zero);
    commut: (commutes G Csg_op)
  }.
\end{verbatim}
% file "CMonoids.v", line 43-46 *)
\index{CMonoid@\verb/CMonoid/, \emph{record}}
\begin{verbatim}
Record CMonoid : Type :=
  { cm_crr   :> CSemi_grp;
    cm_proof :  (is_CMonoid cm_crr)
  }.
\end{verbatim}
% file "CMonoids.v", line 51-54 *)
\subsection{Monoid axioms}
\begin{convention}
Let \verb!M! be a monoid.
\end{convention}
% file "CMonoids.v", line 60 *)
\index{CMonoid_is_CMonoid@\verb/CMonoid_is_CMonoid/, \emph{lemma}}
\begin{verbatim}
Lemma CMonoid_is_CMonoid : (is_CMonoid M).
\end{verbatim}
% file "CMonoids.v", line 68 *)
\index{cm_rht_unit@\verb/cm_rht_unit/, \emph{lemma}}
\begin{verbatim}
Lemma cm_rht_unit: (Is_rht_unit Csg_op Zero::M).
\end{verbatim}
% file "CMonoids.v", line 76 *)
\index{cm_commutes@\verb/cm_commutes/, \emph{lemma}}
\begin{verbatim}
Lemma cm_commutes: (Commutes (csg_op M)).
\end{verbatim}
% file "CMonoids.v", line 86-89 *)
\subsection{Monoid basics}
\begin{convention}
Let \verb!G! be a monoid.
\end{convention}
% file "CMonoids.v", line 95 *)
\index{cm_commutes_unfolded@\verb/cm_commutes_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma cm_commutes_unfolded: (x, y: M)((x [+] y) [=] (y [+] x)).
\end{verbatim}
% file "CMonoids.v", line 101 *)
\index{cm_rht_unit_unfolded@\verb/cm_rht_unit_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma cm_rht_unit_unfolded : (x:M)((x [+] Zero) [=] x).
\end{verbatim}
% file "CMonoids.v", line 108-109 *)
\index{lftUnit_iff_rhtUnit@\verb/lftUnit_iff_rhtUnit/, \emph{lemma}}
\begin{verbatim}
Lemma lftUnit_iff_rhtUnit:
  (x:M)(Is_lft_unit Csg_op x) <-> (Is_rht_unit Csg_op x).
\end{verbatim}
% file "CMonoids.v", line 118 *)
\index{cm_lft_unit@\verb/cm_lft_unit/, \emph{lemma}}
\begin{verbatim}
Lemma cm_lft_unit: (Is_lft_unit Csg_op Zero::M).
\end{verbatim}
% file "CMonoids.v", line 127 *)
\index{cm_lft_unit_unfolded@\verb/cm_lft_unit_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma cm_lft_unit_unfolded: (x:M)((Zero [+] x) [=] x).
\end{verbatim}
% file "CMonoids.v", line 134-135 *)
\index{cm_unit_unique_lft@\verb/cm_unit_unique_lft/, \emph{lemma}}
\begin{verbatim}
Lemma cm_unit_unique_lft:
    (x:M)(Is_lft_unit Csg_op x)->(x [=] Zero).
\end{verbatim}
% file "CMonoids.v", line 142-143 *)
\index{cm_unit_unique_rht@\verb/cm_unit_unique_rht/, \emph{lemma}}
\begin{verbatim}
Lemma cm_unit_unique_rht:
    (x:M)(Is_rht_unit Csg_op x)->(x [=] Zero).
\end{verbatim}
% file "CMonoids.v", line 152 *)
TO DO: Say something about the reason for the following lemma.
% file "CMonoids.v", line 155-158 *)
\index{is_CMonoid_proof_irr@\verb/is_CMonoid_proof_irr/, \emph{lemma}}
\begin{verbatim}
Lemma is_CMonoid_proof_irr :
  (S:CSetoid)(one:S)(mult:(CSetoid_bin_op S))(p,q:(Associative mult))
                 (is_CMonoid (Build_CSemi_grp S one mult p)) ->
                 (is_CMonoid (Build_CSemi_grp S one mult q)).
\end{verbatim}
% file "CMonoids.v", line 170-174 *)
\subsection{Submonoids}
\begin{convention}
Let \verb!P! a predicate on \verb!M! with
\verb!P Zero! and which is preserved by \verb![+]!.
\end{convention}
% file "CMonoids.v", line 183 *)
\index{subcrr@\verb/subcrr/, \emph{local}}
\begin{verbatim}
Local subcrr : CSemi_grp := (Build_SubCSemi_grp ?? Punit op_pres_P).
\end{verbatim}
% file "CMonoids.v", line 187 *)
\index{ismon_scrr@\verb/ismon_scrr/, \emph{lemma}}
\begin{verbatim}
Lemma ismon_scrr: (is_CMonoid subcrr).
\end{verbatim}
% file "CMonoids.v", line 199 *)
\index{Build_SubCMonoid@\verb/Build_SubCMonoid/, \emph{definition}}
\begin{verbatim}
Definition Build_SubCMonoid : CMonoid := (Build_CMonoid subcrr ismon_scrr).
\end{verbatim}
% file "CGroups.v", line 8 *)
\section{Groups}
% file "CGroups.v", line 12 *)
\subsection{Definition of the notion of Group}
% file "CGroups.v", line 15-17 *)
\index{is_inverse@\verb/is_inverse/, \emph{definition}}
\begin{verbatim}
Definition is_inverse
 [S:CSetoid; op:(CSetoid_bin_op S); one:S; x:S; x_inv:S] : Prop :=
  ((op x x_inv) [=] one).
\end{verbatim}
% file "CGroups.v", line 22-23 *)
\index{is_CGroup@\verb/is_CGroup/, \emph{definition}}
\begin{verbatim}
Definition is_CGroup [G: CMonoid; inv: (CSetoid_un_op G)] :=
     (x: G)(Is_inverse Csg_op Zero x (inv x)).
\end{verbatim}
% file "CGroups.v", line 27-31 *)
\index{CGroup@\verb/CGroup/, \emph{record}}
\begin{verbatim}
Record CGroup : Type :=
  { cg_crr   :> CMonoid;
    cg_inv   :  (CSetoid_un_op cg_crr);
    cg_proof :  (is_CGroup cg_crr cg_inv)
  }.
\end{verbatim}
% file "CGroups.v", line 39-41 *)
\begin{notation}
\verb!cg_inv ? a! is denoted by \verb![--]a!.
\end{notation}
% file "CGroups.v", line 51 *)
\index{cg_minus@\verb/cg_minus/, \emph{definition}}
\begin{verbatim}
Definition cg_minus := [G: CGroup][x, y: G](x [+] [--]y).
\end{verbatim}
% file "CGroups.v", line 55-62 *)
\begin{notation}
\verb!cg_minus ? a b! is denoted by \verb!a[-]b!.
\end{notation}

\begin{nameconvention}
In the {\em names} of lemmas, we will denote \verb![--]! with \verb!min!,
and \verb![-]! with \verb!minus!.
\end{nameconvention}
% file "CGroups.v", line 73-76 *)
\subsection{Group axioms}
\begin{convention}
Let \verb!G! be a group.
\end{convention}
% file "CGroups.v", line 82 *)
\index{cg_rht_inv@\verb/cg_rht_inv/, \emph{lemma}}
\begin{verbatim}
Lemma cg_rht_inv: (x: G)(Is_inverse Csg_op Zero x (Cg_inv x)).
\end{verbatim}
% file "CGroups.v", line 89-93 *)
\subsection{Group basics}
General properties of groups.
\begin{convention}
Let \verb!G! be a group.
\end{convention}
% file "CGroups.v", line 99 *)
\index{cg_rht_inv_unfolded@\verb/cg_rht_inv_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma cg_rht_inv_unfolded: (x:G)((x [+] [--]x) [=] Zero).
\end{verbatim}
% file "CGroups.v", line 105 *)
\index{cg_minus_correct@\verb/cg_minus_correct/, \emph{lemma}}
\begin{verbatim}
Lemma cg_minus_correct: (x: G)(x [-] x) [=] Zero.
\end{verbatim}
% file "CGroups.v", line 114 *)
\index{cg_lft_inv@\verb/cg_lft_inv/, \emph{lemma}}
\begin{verbatim}
Lemma cg_lft_inv: (x: G)(Is_inverse Csg_op Zero ([--]x) x).
\end{verbatim}
% file "CGroups.v", line 122 *)
\index{cg_lft_inv_unfolded@\verb/cg_lft_inv_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma cg_lft_inv_unfolded: (x:G) ([--]x [+] x) [=] Zero.
\end{verbatim}
% file "CGroups.v", line 129 *)
\index{cg_minus_unfolded@\verb/cg_minus_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma cg_minus_unfolded: (x,y:G) (x [-] y) [=] (x [+] [--]y).
\end{verbatim}
% file "CGroups.v", line 136-137 *)
\index{cg_minus_wd@\verb/cg_minus_wd/, \emph{lemma}}
\begin{verbatim}
Lemma cg_minus_wd: (x,x',y,y':G)
  (x [=] x')->(y [=] y')->(x[-]y [=] x'[-]y').
\end{verbatim}
% file "CGroups.v", line 146-147 *)
\index{cg_minus_strext@\verb/cg_minus_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cg_minus_strext: (x,x',y,y':G)
  (x[-]y [#] x'[-]y') -> (x [#] x')\/(y [#] y').
\end{verbatim}
% file "CGroups.v", line 157-159 *)
\index{cg_minus_is_csetoid_bin_op@\verb/cg_minus_is_csetoid_bin_op/, \emph{definition}}
\begin{verbatim}
Definition cg_minus_is_csetoid_bin_op : (CSetoid_bin_op G):=
(Build_CSetoid_bin_op G (cg_minus G)
   (cg_minus_wd) (cg_minus_strext)).
\end{verbatim}
% file "CGroups.v", line 164 *)
\index{grp_inv_assoc@\verb/grp_inv_assoc/, \emph{lemma}}
\begin{verbatim}
Lemma grp_inv_assoc: (x,y:G) (x[+]y)[-]y [=] x.
\end{verbatim}
% file "CGroups.v", line 173 *)
\index{cg_inv_unique@\verb/cg_inv_unique/, \emph{lemma}}
\begin{verbatim}
Lemma cg_inv_unique: (x,y:G) ((x [+] y) [=] Zero) -> y [=] [--]x.
\end{verbatim}
% file "CGroups.v", line 184 *)
\index{cg_inv_inv@\verb/cg_inv_inv/, \emph{lemma}}
\begin{verbatim}
Lemma cg_inv_inv: (x:G)[--][--]x [=] x.
\end{verbatim}
% file "CGroups.v", line 196 *)
\index{cg_cancel_lft@\verb/cg_cancel_lft/, \emph{lemma}}
\begin{verbatim}
Lemma cg_cancel_lft: (a, b, c:G)((a [+] b) [=] (a [+] c)) -> b [=] c.
\end{verbatim}
% file "CGroups.v", line 209 *)
\index{cg_cancel_rht@\verb/cg_cancel_rht/, \emph{lemma}}
\begin{verbatim}
Lemma cg_cancel_rht: (a, b, c: G)((b [+] a) [=] (c [+] a)) -> b [=] c.
\end{verbatim}
% file "CGroups.v", line 219 *)
\index{cg_inv_unique'@\verb/cg_inv_unique'/, \emph{lemma}}
\begin{verbatim}
Lemma cg_inv_unique': (x,y:G) ((x [+] y) [=] Zero) -> x [=] [--]y.
\end{verbatim}
% file "CGroups.v", line 230 *)
\index{cg_inv_unique_2@\verb/cg_inv_unique_2/, \emph{lemma}}
\begin{verbatim}
Lemma cg_inv_unique_2 : (x,y:G)(x[-]y [=] Zero)->(x [=] y).
\end{verbatim}
% file "CGroups.v", line 239 *)
\index{cg_zero_inv@\verb/cg_zero_inv/, \emph{lemma}}
\begin{verbatim}
Lemma cg_zero_inv: [--]Zero::G [=] Zero.
\end{verbatim}
% file "CGroups.v", line 247 *)
\index{cg_inv_zero@\verb/cg_inv_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cg_inv_zero : (x:G)x[-]Zero [=] x.
\end{verbatim}
% file "CGroups.v", line 256 *)
\index{cg_inv_op@\verb/cg_inv_op/, \emph{lemma}}
\begin{verbatim}
Lemma cg_inv_op: (x,y:G) [--](x[+]y) [=] [--]y [+] [--]x.
\end{verbatim}
% file "CGroups.v", line 268 *)
\index{csg_op_inv@\verb/csg_op_inv/, \emph{lemma}}
\begin{verbatim}
Lemma csg_op_inv: (x,y:G) [--](x[+]y) [=] [--]x [+] [--]y.
\end{verbatim}
% file "CGroups.v", line 278-282 *)
\subsection{Sub-groups}
\begin{convention}
Let \verb!P! a predicate on \verb!G! with
\verb!P Zero! and which is preserved by \verb![+]! and \verb![--]!.
\end{convention}
% file "CGroups.v", line 291-293 *)
\index{subcrr@\verb/subcrr/, \emph{local}}
\index{subinv@\verb/subinv/, \emph{local}}
\begin{verbatim}
Local subcrr : CMonoid := (Build_SubCMonoid ?? Punit op_pres_P).
Local subinv : (CSetoid_un_op subcrr) :=
  (Build_SubCSetoid_un_op ??? inv_pres_P).
\end{verbatim}
% file "CGroups.v", line 297 *)
\index{isgrp_scrr@\verb/isgrp_scrr/, \emph{lemma}}
\begin{verbatim}
Lemma isgrp_scrr: (is_CGroup subcrr subinv).
\end{verbatim}
% file "CGroups.v", line 303 *)
\index{Build_SubCGroup@\verb/Build_SubCGroup/, \emph{definition}}
\begin{verbatim}
Definition Build_SubCGroup : CGroup := (Build_CGroup subcrr ? isgrp_scrr).
\end{verbatim}
% file "CGroups.v", line 316-319 *)
\subsection{Associative properties of groups}
\begin{convention}
Let \verb!G! be a group.
\end{convention}
% file "CGroups.v", line 325 *)
\index{assoc_1@\verb/assoc_1/, \emph{lemma}}
\begin{verbatim}
Lemma assoc_1 : (x,y,z:G)(x[-](y[-]z) [=] (x[-]y)[+]z).
\end{verbatim}
% file "CGroups.v", line 334 *)
\index{assoc_2@\verb/assoc_2/, \emph{lemma}}
\begin{verbatim}
Lemma assoc_2 : (x,y,z:G)(x[+](y[-]z) [=] (x[+]y)[-]z).
\end{verbatim}
% file "CGroups.v", line 340 *)
\index{minus_plus@\verb/minus_plus/, \emph{lemma}}
\begin{verbatim}
Lemma minus_plus : (x,y,z:G)((x[-](y[+]z)) [=] ((x[-]y)[-]z)).
\end{verbatim}
% file "CGroups.v", line 348 *)
\index{zero_minus@\verb/zero_minus/, \emph{lemma}}
\begin{verbatim}
Lemma zero_minus : (x:G)((Zero [-] x) [=] ([--] x)).
\end{verbatim}
% file "CGroups.v", line 356 *)
\index{cg_cancel_mixed@\verb/cg_cancel_mixed/, \emph{lemma}}
\begin{verbatim}
Lemma cg_cancel_mixed:(x,y:G)(x[=]x[-]y[+]y).
\end{verbatim}
% file "CGroups.v", line 366 *)
\index{plus_resp_eq@\verb/plus_resp_eq/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_eq:(a,b,c:G)(b[=]c)->(a[+]b[=]a[+]c).
\end{verbatim}
% file "CGroups.v", line 380-384 *)
\subsection{Apartness in Constructive Groups}
Specific properties of {\em constructive} groups.
\begin{convention}
Let \verb!G! be a group.
\end{convention}
% file "CGroups.v", line 390-391 *)
\index{cg_add_ap_zero@\verb/cg_add_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cg_add_ap_zero:
  (x,y:G)((x [+] y) [#] Zero) -> (x [#] Zero) \/ (y [#] Zero).
\end{verbatim}
% file "CGroups.v", line 400 *)
\index{op_rht_resp_ap@\verb/op_rht_resp_ap/, \emph{lemma}}
\begin{verbatim}
Lemma op_rht_resp_ap: (x,y,z:G)(x [#] y) -> (x [+] z) [#] (y [+] z).
\end{verbatim}
% file "CGroups.v", line 413 *)
\index{op_lft_resp_ap@\verb/op_lft_resp_ap/, \emph{lemma}}
\begin{verbatim}
Lemma op_lft_resp_ap: (x,y,z:G)(y [#] z) -> (x [+] y) [#] (x [+] z).
\end{verbatim}
% file "CGroups.v", line 423 *)
\index{cg_ap_cancel_rht@\verb/cg_ap_cancel_rht/, \emph{lemma}}
\begin{verbatim}
Lemma cg_ap_cancel_rht: (x,y,z:G) ((x [+] z) [#] (y [+] z)) -> x [#] y.
\end{verbatim}
% file "CGroups.v", line 436 *)
\index{plus_cancel_ap_rht@\verb/plus_cancel_ap_rht/, \emph{lemma}}
\begin{verbatim}
Lemma plus_cancel_ap_rht : (x,y,z:G)((x[+]z) [#] (y[+]z)) -> x[#]y.
\end{verbatim}
% file "CGroups.v", line 441 *)
\index{cg_ap_cancel_lft@\verb/cg_ap_cancel_lft/, \emph{lemma}}
\begin{verbatim}
Lemma cg_ap_cancel_lft: (x,y,z:G) ((x [+] y) [#] (x [+] z)) -> y [#] z.
\end{verbatim}
% file "CGroups.v", line 453 *)
\index{plus_cancel_ap_lft@\verb/plus_cancel_ap_lft/, \emph{lemma}}
\begin{verbatim}
Lemma plus_cancel_ap_lft : (x,y,z:G)((z[+]x) [#] (z[+]y)) -> x[#]y.
\end{verbatim}
% file "CGroups.v", line 461 *)
\index{minus_ap_zero@\verb/minus_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma minus_ap_zero: (x,y:G)(x [#] y) -> (x[-]y) [#] Zero.
\end{verbatim}
% file "CGroups.v", line 470 *)
\index{zero_minus_apart@\verb/zero_minus_apart/, \emph{lemma}}
\begin{verbatim}
Lemma zero_minus_apart: (x,y:G)((x[-]y) [#] Zero) -> x [#] y.
\end{verbatim}
% file "CGroups.v", line 479 *)
\index{min_resp_ap_zero@\verb/min_resp_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma min_resp_ap_zero: (x:G)(x [#] Zero) -> [--]x [#] Zero.
\end{verbatim}
% file "CGroups.v", line 490 *)
\index{min_resp_ap@\verb/min_resp_ap/, \emph{lemma}}
\begin{verbatim}
Lemma min_resp_ap : (x,y:G)(x[#]y) -> ([--]x) [#] ([--]y).
\end{verbatim}
% file "CGroups.v", line 506 *)
\index{minus_resp_ap_lft@\verb/minus_resp_ap_lft/, \emph{lemma}}
\begin{verbatim}
Lemma minus_resp_ap_lft : (x,y,z:G)(x[#]y) -> (z[-]x) [#] (z[-]y).
\end{verbatim}
% file "CGroups.v", line 516 *)
\index{minus_resp_ap_rht@\verb/minus_resp_ap_rht/, \emph{lemma}}
\begin{verbatim}
Lemma minus_resp_ap_rht : (x,y,z:G)(x[#]y) -> (x[-]z) [#] (y[-]z).
\end{verbatim}
% file "CGroups.v", line 525 *)
\index{minus_cancel_ap_rht@\verb/minus_cancel_ap_rht/, \emph{lemma}}
\begin{verbatim}
Lemma minus_cancel_ap_rht : (x,y,z:G)((x[-]z) [#] (y[-]z)) -> x[#]y.
\end{verbatim}
% file "CSums.v", line 8-12 *)
\section{Sums}

\begin{convention}
Let \verb!G! be a group.
\end{convention}
% file "CSums.v", line 20-24 *)
\index{sumlist@\verb/sumlist/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint sumlist [l:(list G)] : G :=
  Cases l of
    nil => Zero::G
  | (cons x k) => x[+](sumlist k)
  end.
\end{verbatim}
% file "CSums.v", line 28-35 *)
\index{sumx@\verb/sumx/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint sumx [n:nat] : ((i:nat)(lt i n)->G)->G :=
  <[n:nat](((i:nat)(lt i n)->G)->G)>
  Cases n of
    O => [_:(i:nat)(lt i O)->G]Zero::G
  | (S m) => [f:(i:nat)(lt i (S m))->G]
      (sumx m [i:nat][l:(lt i m)](f i (lt_S ?? l)))
        [+](f m (lt_n_Sn m))
  end.
\end{verbatim}
% file "CSums.v", line 39-44 *)
\index{sum0@\verb/sum0/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint sum0 [n:nat] : (nat->G)->G := [f:nat->G]
(* sum i=0..(n-1) *)
  Cases n of
    O => Zero::G
  | (S m) => (sum0 m f)[+](f m)
  end.
\end{verbatim}
% file "CSums.v", line 48-50 *)
\index{sum1@\verb/sum1/, \emph{definition}}
\begin{verbatim}
Definition sum1 : nat->nat->(nat->G)->G :=
(* sum i=m..(n-1) *)
  [m,n:nat][f:nat->G]((sum0 n f)[-](sum0 m f)).
\end{verbatim}
% file "CSums.v", line 54-56 *)
\index{sum@\verb/sum/, \emph{definition}}
\begin{verbatim}
Definition sum : nat->nat->(nat->G)->G :=
(* sum i=m..n *)
  [m,n:nat](sum1 m (S n)).
\end{verbatim}
% file "CSums.v", line 60 *)
\index{sum_one@\verb/sum_one/, \emph{lemma}}
\begin{verbatim}
Lemma sum_one : (n:nat)(f:nat->G)(sum n n f)[=](f n).
\end{verbatim}
% file "CSums.v", line 72-73 *)
\index{sum_sum@\verb/sum_sum/, \emph{lemma}}
\begin{verbatim}
Lemma sum_sum : (l,m,n:nat)(f:nat->G)
  (sum l m f)[+](sum (S m) n f)[=](sum l n f).
\end{verbatim}
% file "CSums.v", line 94-95 *)
\index{sum_first@\verb/sum_first/, \emph{lemma}}
\begin{verbatim}
Lemma sum_first : (m,n:nat)(f:nat->G)
  (sum m n f) [=] (f m)[+](sum (S m) n f).
\end{verbatim}
% file "CSums.v", line 115-116 *)
\index{sum_last@\verb/sum_last/, \emph{lemma}}
\begin{verbatim}
Lemma sum_last : (m,n:nat)(f:nat->G)
  (sum m (S n) f) [=] (sum m n f)[+](f (S n)).
\end{verbatim}
% file "CSums.v", line 129-130 *)
\index{sum_last'@\verb/sum_last'/, \emph{lemma}}
\begin{verbatim}
Lemma sum_last' : (m,n:nat)(f:nat->G)(lt O n) ->
  (sum m n f) [=] (sum m (pred n) f)[+](f n).
\end{verbatim}
% file "CSums.v", line 138-139 *)
\index{sum0_wd@\verb/sum0_wd/, \emph{lemma}}
\begin{verbatim}
Lemma sum0_wd : (m:nat)(f,f':nat->G)((i:nat)(f i)[=](f' i)) ->
                (sum0 m f)[=](sum0 m f').
\end{verbatim}
% file "CSums.v", line 152-153 *)
\index{sum_wd@\verb/sum_wd/, \emph{lemma}}
\begin{verbatim}
Lemma sum_wd : (m,n:nat)(f,f':nat->G)((i:nat)(f i)[=](f' i)) ->
               (sum m n f)[=](sum m n f').
\end{verbatim}
% file "CSums.v", line 168-170 *)
\index{sum0_plus_sum0@\verb/sum0_plus_sum0/, \emph{lemma}}
\begin{verbatim}
Lemma sum0_plus_sum0 : (f,g:nat->G)(m:nat)
                     (sum0 m [i:nat]((f i)[+](g i))) [=]
                     ((sum0 m f) [+] (sum0 m g)).
\end{verbatim}
% file "CSums.v", line 189-191 *)
\index{sum_plus_sum@\verb/sum_plus_sum/, \emph{lemma}}
\begin{verbatim}
Lemma sum_plus_sum : (f,g:nat->G)(a,b:nat)
                     (sum a b [i:nat]((f i)[+](g i))) [=]
                     ((sum a b f) [+] (sum a b g)).
\end{verbatim}
% file "CSums.v", line 209-211 *)
\index{sum_apzero@\verb/sum_apzero/, \emph{lemma}}
\begin{verbatim}
Lemma sum_apzero : (a:nat->G)(k,l:nat)(le k l) ->
  ((sum k l a) [#] Zero) ->
    (EX i | (le k i) /\ (le i l) /\ ((a i) [#] Zero)).
\end{verbatim}
% file "CSums.v", line 233-235 *)
\index{sum_zero@\verb/sum_zero/, \emph{lemma}}
\begin{verbatim}
Lemma sum_zero : (a:nat->G)(k,l:nat)(le k (S l)) ->
  ((i:nat)(le k i) -> (le i l) -> (a i) [=] Zero) ->
    (sum k l a) [=] Zero.
\end{verbatim}
% file "CSums.v", line 256-259 *)
\index{sum_wd'@\verb/sum_wd'/, \emph{lemma}}
\begin{verbatim}
Lemma sum_wd' :
  (k,l:nat)(le k (S l)) -> (a,a':nat->G)
    ((i:nat)(le k i) -> (le i l) -> ((a i)[=](a' i))) ->
      (sum k l a)[=](sum k l a').
\end{verbatim}
% file "CSums.v", line 282-284 *)
\index{sum_term@\verb/sum_term/, \emph{lemma}}
\begin{verbatim}
Lemma sum_term : (a:nat->G)(k,i0,l:nat)(le k i0) -> (le i0 l) ->
  ((i:nat)(le k i) -> (~i=i0) -> (le i l) -> (a i) [=] Zero) ->
    (sum k l a) [=] (a i0).
\end{verbatim}
% file "CSums.v", line 306-308 *)
\index{sum0_shift@\verb/sum0_shift/, \emph{lemma}}
\begin{verbatim}
Lemma sum0_shift : (a,b:nat->G)(l:nat)
  ((i:nat)((a i) [=] (b (S i)))) ->
    (b (0))[+](sum0 l a) [=] (sum0 (S l) b).
\end{verbatim}
% file "CSums.v", line 320-322 *)
\index{sum_shift@\verb/sum_shift/, \emph{lemma}}
\begin{verbatim}
Lemma sum_shift : (a,b:nat->G)(k,l:nat)
  ((i:nat)((a i) [=] (b (S i)))) ->
    (sum k l a) [=] (sum (S k) (S l) b).
\end{verbatim}
% file "CRings.v", line 15-16 *)
\section{Rings}
We actually define commutative rings with 1.
% file "CRings.v", line 20 *)
\subsection{Definition of the notion of Ring}
% file "CRings.v", line 23-25 *)
\index{distributive@\verb/distributive/, \emph{definition}}
\begin{verbatim}
Definition distributive :=
  [S:CSetoid; mult,plus:(CSetoid_bin_op S)]
  (x,y,z:S) (mult x (plus y z)) [=] (plus (mult x y) (mult x z)).
\end{verbatim}
% file "CRings.v", line 30-35 *)
\index{is_CRing@\verb/is_CRing/, \emph{record}}
\begin{verbatim}
Record is_CRing [G : CGroup; one : G; mult : (CSetoid_bin_op G)] : Prop :=
  { ax_mult_assoc : (Associative mult);
    ax_mult_mon : (is_CMonoid (Build_CSemi_grp G one mult ax_mult_assoc));
    ax_dist : (Distributive mult (csg_op G));
    ax_non_triv : (one [#] Zero)
  }.
\end{verbatim}
% file "CRings.v", line 39-44 *)
\index{CRing@\verb/CRing/, \emph{record}}
\begin{verbatim}
Record CRing : Type :=
  { cr_crr   :> CGroup;
    cr_one   :  cr_crr;
    cr_mult  :  (CSetoid_bin_op cr_crr);
    cr_proof :  (is_CRing cr_crr cr_one cr_mult)
  }.
\end{verbatim}
% file "CRings.v", line 48-50 *)
\index{cr_plus@\verb/cr_plus/, \emph{definition}}
\index{cr_inv@\verb/cr_inv/, \emph{definition}}
\index{cr_minus@\verb/cr_minus/, \emph{definition}}
\begin{verbatim}
Definition cr_plus  :=  csg_op.
Definition cr_inv   :=  cg_inv.
Definition cr_minus :=  cg_minus.
\end{verbatim}
% file "CRings.v", line 56-59 *)
\begin{notation}
The term \verb!cr_one! with its first argument left implicit is denoted by
\verb!One!.
\end{notation}
% file "CRings.v", line 72-79 *)
\begin{notation}
The multiplication \verb!cr_mult x y! is denoted by \verb!x [*] y!.
\end{notation}

\begin{nameconvention}
In the {\em names} of lemmas, we will denote \verb!One! with \verb!one!,
and \verb![*]! with \verb!mult!.
\end{nameconvention}
% file "CRings.v", line 88-91 *)
\subsection{Ring axioms}
\begin{convention}
Let \verb!R! be a ring.
\end{convention}
% file "CRings.v", line 96 *)
\index{CRing_is_CRing@\verb/CRing_is_CRing/, \emph{lemma}}
\begin{verbatim}
Lemma CRing_is_CRing : (is_CRing R One Cr_mult).
\end{verbatim}
% file "CRings.v", line 103 *)
\index{mult_assoc@\verb/mult_assoc/, \emph{lemma}}
\begin{verbatim}
Lemma mult_assoc : (Associative (cr_mult R)).
\end{verbatim}
% file "CRings.v", line 110 *)
\index{mult_mon@\verb/mult_mon/, \emph{lemma}}
\begin{verbatim}
Lemma mult_mon : (is_CMonoid (Build_CSemi_grp R One Cr_mult mult_assoc)).
\end{verbatim}
% file "CRings.v", line 121 *)
\index{dist@\verb/dist/, \emph{lemma}}
\begin{verbatim}
Lemma dist : (Distributive Cr_mult (cr_plus R)).
\end{verbatim}
% file "CRings.v", line 129 *)
\index{ring_non_triv@\verb/ring_non_triv/, \emph{lemma}}
\begin{verbatim}
Lemma ring_non_triv : (One::R [#] Zero).
\end{verbatim}
% file "CRings.v", line 137 *)
\index{mult_wd@\verb/mult_wd/, \emph{lemma}}
\begin{verbatim}
Lemma mult_wd : (x1,x2,y1,y2:R)(x1[=]x2)-> (y1[=]y2)-> (x1[*]y1) [=] (x2[*]y2).
\end{verbatim}
% file "CRings.v", line 144 *)
\index{mult_wd_lft@\verb/mult_wd_lft/, \emph{lemma}}
\begin{verbatim}
Lemma mult_wd_lft : (x1,x2,y:R)(x1[=]x2)-> (x1[*]y) [=] (x2[*]y).
\end{verbatim}
% file "CRings.v", line 153 *)
\index{mult_wd_rht@\verb/mult_wd_rht/, \emph{lemma}}
\begin{verbatim}
Lemma mult_wd_rht : (x,y1,y2:R)(y1[=]y2)-> (x[*]y1) [=] (x[*]y2).
\end{verbatim}
% file "CRings.v", line 167-170 *)
\subsection{Ring constructions}
\begin{convention}
Let \verb!R! be a ring.
\end{convention}
% file "CRings.v", line 175 *)
The multiplicative monoid of a ring is defined as follows.
% file "CRings.v", line 178 *)
\index{Build_multCMonoid@\verb/Build_multCMonoid/, \emph{definition}}
\begin{verbatim}
Definition Build_multCMonoid : CMonoid := (Build_CMonoid ? (mult_mon R)).
\end{verbatim}
% file "CRings.v", line 182 *)
The csetoid of non-zeros of a ring is defined as follows.
% file "CRings.v", line 185-186 *)
\index{NonZeros@\verb/NonZeros/, \emph{definition}}
\index{nzinj@\verb/nzinj/, \emph{definition}}
\begin{verbatim}
Definition NonZeros : CSetoid := (Build_SubCSetoid R NonZeroP).
Definition nzinj : NonZeros -> R := (scs_elem R NonZeroP).
\end{verbatim}
% file "CRings.v", line 192-193 *)
\index{nzpro@\verb/nzpro/, \emph{definition}}
\begin{verbatim}
Definition nzpro : (x:R)(x [#] Zero)->NonZeros :=
                             (Build_subcsetoid_crr R NonZeroP).
\end{verbatim}
% file "CRings.v", line 197 *)
\index{inj_pro@\verb/inj_pro/, \emph{lemma}}
\begin{verbatim}
Lemma inj_pro: (x:R; nz:(x[#]Zero)) (nzinj (nzpro x nz)) [=] x.
\end{verbatim}
% file "CRings.v", line 203 *)
\index{pro_inj@\verb/pro_inj/, \emph{lemma}}
\begin{verbatim}
Lemma pro_inj: (x:NonZeros) (nzpro (nzinj x) (scs_prf ?? x)) [=] x.
\end{verbatim}
% file "CRings.v", line 209 *)
\index{nonz_eq@\verb/nonz_eq/, \emph{lemma}}
\begin{verbatim}
Lemma nonz_eq:(x,y:NonZeros)(((nzinj x)[=](nzinj y))-> (x[=]y)).
\end{verbatim}
% file "CRings.v", line 219 *)
\index{nzinj_strong_ext@\verb/nzinj_strong_ext/, \emph{lemma}}
\begin{verbatim}
Lemma nzinj_strong_ext : (x,y:NonZeros)((nzinj x) [#] (nzinj y)) -> (x[#]y).
\end{verbatim}
% file "CRings.v", line 237 *)
\index{nzinj_wd@\verb/nzinj_wd/, \emph{lemma}}
\begin{verbatim}
Lemma nzinj_wd : (x,y:NonZeros)(x[=]y) -> (nzinj x) [=] (nzinj y).
\end{verbatim}
% file "CRings.v", line 255-256 *)
\index{nzpro_strong_ext@\verb/nzpro_strong_ext/, \emph{lemma}}
\begin{verbatim}
Lemma nzpro_strong_ext : (x,y:R)(Hx:x[#]Zero)(Hy:y[#]Zero)
                         (((nzpro x Hx) [#] (nzpro y Hy)) -> (x[#]y)).
\end{verbatim}
% file "CRings.v", line 264-265 *)
\index{nzpro_wd@\verb/nzpro_wd/, \emph{lemma}}
\begin{verbatim}
Lemma nzpro_wd : (x,y:R)(Hx:x[#]Zero)(Hy:y[#]Zero) (x [=] y) ->
                  (nzpro x Hx) [=] (nzpro y Hy).
\end{verbatim}
% file "CRings.v", line 287-289 *)
\begin{numnotation}\label{notation:nzpro}
We will write \verb!nzpro ? x p! as \verb!x [//] p!.
\end{numnotation}
% file "CRings.v", line 301-304 *)
\subsection{Ring unfolded}
\begin{convention}
Let \verb!R! be a ring.
\end{convention}
% file "CRings.v", line 310-311 *)
\index{mult_assoc_unfolded@\verb/mult_assoc_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma mult_assoc_unfolded : (x,y,z:R)
                            (x [*] (y [*] z)) [=] ((x [*] y) [*] z).
\end{verbatim}
% file "CRings.v", line 317 *)
\index{mult_commutes@\verb/mult_commutes/, \emph{lemma}}
\begin{verbatim}
Lemma mult_commutes: (x,y:R) (x[*]y) [=] (y[*]x).
\end{verbatim}
% file "CRings.v", line 323 *)
\index{mult_one@\verb/mult_one/, \emph{lemma}}
\begin{verbatim}
Lemma mult_one: (x:R)(x [*] One) [=] x.
\end{verbatim}
% file "CRings.v", line 328 *)
\index{one_mult@\verb/one_mult/, \emph{lemma}}
\begin{verbatim}
Lemma one_mult: (x:R)(One [*] x) [=] x.
\end{verbatim}
% file "CRings.v", line 333-334 *)
\index{ring_dist_unfolded@\verb/ring_dist_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma ring_dist_unfolded:
  (x,y,z:R) x [*] (y [+] z) [=] (x [*] y) [+] (x [*] z).
\end{verbatim}
% file "CRings.v", line 340-341 *)
\index{ring_distl_unfolded@\verb/ring_distl_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma ring_distl_unfolded:
  (x,y,z:R) (y [+] z) [*] x [=] (y [*] x) [+] (z [*] x).
\end{verbatim}
% file "CRings.v", line 358-361 *)
\subsection{Ring basics}
\begin{convention}
Let \verb!R! be a ring.
\end{convention}
% file "CRings.v", line 366 *)
\index{one_ap_zero@\verb/one_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma one_ap_zero : (One::R [#] Zero).
\end{verbatim}
% file "CRings.v", line 371 *)
NonZeroP is well-defined and strongly-extensional, but we don't use this.
% file "CRings.v", line 389-390 *)
\index{is_zero_rht@\verb/is_zero_rht/, \emph{definition}}
\begin{verbatim}
Definition is_zero_rht [S:CSetoid; op:(CSetoid_bin_op S); zero:S]: Prop :=
    (x:S)((op x zero) [=] zero).
\end{verbatim}
% file "CRings.v", line 394-395 *)
\index{is_zero_lft@\verb/is_zero_lft/, \emph{definition}}
\begin{verbatim}
Definition is_zero_lft [S:CSetoid; op:(CSetoid_bin_op S); zero:S]: Prop :=
    (x:S)((op zero x) [=] zero).
\end{verbatim}
% file "CRings.v", line 401 *)
\index{cring_mult_zero@\verb/cring_mult_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cring_mult_zero: (x:R) (x [*] Zero) [=] Zero.
\end{verbatim}
% file "CRings.v", line 411 *)
\index{cring_mult_zero_op@\verb/cring_mult_zero_op/, \emph{lemma}}
\begin{verbatim}
Lemma cring_mult_zero_op: (x:R) Zero[*]x [=] Zero.
\end{verbatim}
% file "CRings.v", line 418 *)
\index{cring_minus_mult_lft@\verb/cring_minus_mult_lft/, \emph{lemma}}
\begin{verbatim}
Lemma cring_minus_mult_lft: (x,y:R) x [*] ([--]y) [=] [--](x [*] y).
\end{verbatim}
% file "CRings.v", line 428 *)
\index{cring_minus_mult_rht@\verb/cring_minus_mult_rht/, \emph{lemma}}
\begin{verbatim}
Lemma cring_minus_mult_rht: (x,y:R) ([--]x) [*] y [=] [--](x [*] y).
\end{verbatim}
% file "CRings.v", line 437 *)
\index{cring_mult_ap_zero@\verb/cring_mult_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cring_mult_ap_zero: (x,y:R)((x [*] y) [#] Zero) -> (x [#] Zero).
\end{verbatim}
% file "CRings.v", line 447 *)
\index{cring_mult_ap_zero_op@\verb/cring_mult_ap_zero_op/, \emph{lemma}}
\begin{verbatim}
Lemma cring_mult_ap_zero_op: (x,y:R)((x [*] y) [#] Zero) -> (y [#] Zero).
\end{verbatim}
% file "CRings.v", line 455 *)
\index{inv_mult_invol@\verb/inv_mult_invol/, \emph{lemma}}
\begin{verbatim}
Lemma inv_mult_invol: (x,y:R)([--]x[*][--]y [=] x[*]y).
\end{verbatim}
% file "CRings.v", line 463-464 *)
\index{ring_dist_minus@\verb/ring_dist_minus/, \emph{lemma}}
\begin{verbatim}
Lemma ring_dist_minus :
  (x,y,z:R) x [*] (y [-] z) [=] (x [*] y) [-] (x [*] z).
\end{verbatim}
% file "CRings.v", line 475-476 *)
\index{ring_distl_minus@\verb/ring_distl_minus/, \emph{lemma}}
\begin{verbatim}
Lemma ring_distl_minus:
  (x,y,z:R) (y [-] z) [*] x [=] (y [*] x) [-] (z [*] x).
\end{verbatim}
% file "CRings.v", line 497-499 *)
\subsection{Ring Auxiliary}
Some auxiliary functions and operations over a ring;
especially geared towards CReals.
% file "CRings.v", line 504-507 *)
\subsubsection{Exponentiation}
\begin{convention}
Let \verb!R! be a ring.
\end{convention}
% file "CRings.v", line 514-516 *)
\index{nexp@\verb/nexp/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint nexp [x:R;m:nat]: R :=
  Cases m of O => One | (S n) => ((nexp x n) [*] x)
  end.
\end{verbatim}
% file "CRings.v", line 520 *)
\index{nexp_well_def@\verb/nexp_well_def/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_well_def: (n:nat)(Fun_well_def [x:R](nexp x n)).
\end{verbatim}
% file "CRings.v", line 528 *)
\index{nexp_strong_ext@\verb/nexp_strong_ext/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_strong_ext: (n:nat)(Fun_strong_ext [x:R](nexp x n)).
\end{verbatim}
% file "CRings.v", line 538-540 *)
\index{nexp_op@\verb/nexp_op/, \emph{definition}}
\begin{verbatim}
Definition nexp_op :=
  [n:nat](Build_CSetoid_un_op R [x:R](nexp x n)
    (nexp_well_def n) (nexp_strong_ext n)).
\end{verbatim}
% file "CRings.v", line 550-552 *)
\begin{notation}
\verb!a [^] b! stands for \verb!nexp_op ? a b!.
\end{notation}
% file "CRings.v", line 567-570 *)
\subsubsection{The injection of natural numbers into a ring}
\begin{convention}
Let \verb!R! be a ring.
\end{convention}
% file "CRings.v", line 575 *)
The injection of Coq natural numbers into a ring is called \verb!nring!.
% file "CRings.v", line 578-580 *)
\index{nring@\verb/nring/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint nring [m:nat]: R :=
  Cases m of O => Zero | (S n) => ((nring n) [+] One)
  end.
\end{verbatim}
% file "CRings.v", line 586-587 *)
\index{nring_comm_plus@\verb/nring_comm_plus/, \emph{lemma}}
\begin{verbatim}
Lemma nring_comm_plus:
  (n,m:nat)(nring (plus n m)) [=] ((nring n) [+] (nring m)).
\end{verbatim}
% file "CRings.v", line 598-599 *)
\index{nring_comm_mult@\verb/nring_comm_mult/, \emph{lemma}}
\begin{verbatim}
Lemma nring_comm_mult :
  (n,m:nat)(nring (mult n m)) [=] ((nring n) [*] (nring m)).
\end{verbatim}
% file "CRings.v", line 619-623 *)
\begin{notation}
\verb!Two! denotes \verb!Nring (S (S O))!,
\verb!Three! denotes \verb!Nring (S (S (S O)))! and
\verb!Four! denotes \verb!Nring (S (S (S (S O))))!.
\end{notation}
% file "CRings.v", line 645 *)
\index{one_plus_one@\verb/one_plus_one/, \emph{lemma}}
\begin{verbatim}
Lemma one_plus_one : (R:CRing)((One::R) [+] One) [=] Two.
\end{verbatim}
% file "CRings.v", line 653 *)
\index{x_plus_x@\verb/x_plus_x/, \emph{lemma}}
\begin{verbatim}
Lemma x_plus_x : (R:CRing)(x:R)(x[+]x) [=] Two[*]x.
\end{verbatim}
% file "CRings.v", line 669-672 *)
\subsubsection{The injection of integers into a ring}
\begin{convention}
Let \verb!R! be a ring.
\end{convention}
% file "CRings.v", line 678 *)
The injection of Coq integers into a ring is called \verb!zring!.
% file "CRings.v", line 681 *)
\index{zring@\verb/zring/, \emph{definition}}
\begin{verbatim}
Definition zring [k:Z] : R := (caseZ_diff k [m,n:nat](Nring m) [-] (Nring n)).
\end{verbatim}
% file "CRings.v", line 685 *)
\index{zring_zero@\verb/zring_zero/, \emph{lemma}}
\begin{verbatim}
Lemma zring_zero : (zring `0`) [=] Zero.
\end{verbatim}
% file "CRings.v", line 693 *)
\index{zring_diff@\verb/zring_diff/, \emph{lemma}}
\begin{verbatim}
Lemma zring_diff : (m,n:nat)(zring `m-n`) [=] (Nring m) [-] (Nring n).
\end{verbatim}
% file "CRings.v", line 720 *)
\index{zring_plus_nat@\verb/zring_plus_nat/, \emph{lemma}}
\begin{verbatim}
Lemma zring_plus_nat : (n:nat)(zring `n`) [=] (Nring n).
\end{verbatim}
% file "CRings.v", line 734 *)
\index{zring_min_nat@\verb/zring_min_nat/, \emph{lemma}}
\begin{verbatim}
Lemma zring_min_nat : (n:nat)(zring `-n`) [=] [--](Nring n).
\end{verbatim}
% file "CRings.v", line 748 *)
\index{zring_plus@\verb/zring_plus/, \emph{lemma}}
\begin{verbatim}
Lemma zring_plus : (i,j:Z)(zring `i+j`) [=] (zring i)[+](zring j).
\end{verbatim}
% file "CRings.v", line 781 *)
\index{zring_min@\verb/zring_min/, \emph{lemma}}
\begin{verbatim}
Lemma zring_min : (i:Z)(zring `-i`) [=] [--](zring i).
\end{verbatim}
% file "CRings.v", line 800 *)
\index{zring_minus@\verb/zring_minus/, \emph{lemma}}
\begin{verbatim}
Lemma zring_minus : (i,j:Z)(zring `i-j`) [=] (zring i)[-](zring j).
\end{verbatim}
% file "CRings.v", line 811 *)
\index{zring_mult@\verb/zring_mult/, \emph{lemma}}
\begin{verbatim}
Lemma zring_mult : (i,j:Z)(zring `i*j`) [=] (zring i)[*](zring j).
\end{verbatim}
% file "CRings.v", line 876 *)
\index{zring_one@\verb/zring_one/, \emph{lemma}}
\begin{verbatim}
Lemma zring_one : (zring `1`) [=] One.
\end{verbatim}
% file "CRings.v", line 886 *)
\index{zring_inv@\verb/zring_inv/, \emph{lemma}}
\begin{verbatim}
Lemma zring_inv : (x:R)((zring `-1`)[*]x [=] [--]x).
\end{verbatim}
% file "CRings.v", line 908-911 *)
\subsection{Ring sums}
\begin{convention}
Let \verb!R! be a ring.
\end{convention}
% file "CRings.v", line 916 *)
\subsubsection{Infinite Ring sums}
% file "CRings.v", line 921-924 *)
\index{Sum_upto@\verb/Sum_upto/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint Sum_upto [r:nat->R; n:nat] : R :=
  Cases n of O     => Zero
	   | (S x) => (r x) [+] (Sum_upto r x)
  end.
\end{verbatim}
% file "CRings.v", line 928 *)
\index{sum_upto_O@\verb/sum_upto_O/, \emph{lemma}}
\begin{verbatim}
Lemma sum_upto_O : (r:nat->R)(Sum_upto r O) [=] Zero.
\end{verbatim}
% file "CRings.v", line 936-937 *)
\index{Sum_from_upto@\verb/Sum_from_upto/, \emph{definition}}
\begin{verbatim}
Definition Sum_from_upto [r:nat->R; p,n:nat] : R :=
  (Sum_upto r n) [-] (Sum_upto r p).
\end{verbatim}
% file "CRings.v", line 941-942 *)
Here's an alternative def of \verb!Sum_from_upto!, with lemma that
it's equivalent to the original.
% file "CRings.v", line 945 *)
\index{seq_from@\verb/seq_from/, \emph{definition}}
\begin{verbatim}
Definition seq_from [r:nat->R; p:nat] : nat->R := [i:nat](r (plus p i)).
\end{verbatim}
% file "CRings.v", line 949-950 *)
\index{Sum_from_upto_alt@\verb/Sum_from_upto_alt/, \emph{definition}}
\begin{verbatim}
Definition Sum_from_upto_alt [r:nat->R; p,n:nat] : R :=
  (Sum_upto (seq_from r p) (minus n p)).
\end{verbatim}
% file "CRings.v", line 955-957 *)
\index{sum_from_upto_eq@\verb/sum_from_upto_eq/, (\emph{commented out})}
\begin{verbatim}
Ax_iom sum_from_upto_eq:
  (r:nat->R)(n,p:nat)(le p n) ->
    (Sum_from_upto_alt r p n) [=] (Sum_from_upto r p n).
\end{verbatim}
% file "CRings.v", line 965 *)
\subsection{Ring Sums over Lists}
% file "CRings.v", line 969-973 *)
\index{RList_Mem@\verb/RList_Mem/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint RList_Mem [l:(list R); n:nat] : R :=
  Cases l n of nil _       => Zero
             | (cons a _) O => a
             | (cons _ k) (S y) => (RList_Mem k y)
  end.
\end{verbatim}
% file "CRings.v", line 977-980 *)
\index{List_Sum_upto@\verb/List_Sum_upto/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint List_Sum_upto [l:(list R); n:nat] : R :=
  Cases n of O     => Zero
	   | (S x) => (RList_Mem l x) [+] (List_Sum_upto l x)
  end.
\end{verbatim}
% file "CRings.v", line 984 *)
\index{list_sum_upto_O@\verb/list_sum_upto_O/, \emph{lemma}}
\begin{verbatim}
Lemma list_sum_upto_O : (l:(list R))(List_Sum_upto l O) [=] Zero.
\end{verbatim}
% file "CRings.v", line 992-993 *)
\index{List_Sum_from_upto@\verb/List_Sum_from_upto/, \emph{definition}}
\begin{verbatim}
Definition List_Sum_from_upto [l:(list R); p,n:nat] : R :=
   (List_Sum_upto l n) [-] (List_Sum_upto l p).
\end{verbatim}
% file "CRings.v", line 997-998 *)
Here's an alternative def of \verb!List_Sum_from_upto!, with lemma
 that it's equivalent to the original.
% file "CRings.v", line 1001-1004 *)
\index{List_End@\verb/List_End/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint List_End [l:(list R); p:nat] : (list R) :=
   Cases p of O     => l
            | (S x) => (List_End (tail l) x)
   end.
\end{verbatim}
% file "CRings.v", line 1008-1009 *)
\index{List_Sum_from_upto_alt@\verb/List_Sum_from_upto_alt/, \emph{definition}}
\begin{verbatim}
Definition List_Sum_from_upto_alt [l:(list R); p,n:nat] : R :=
   (List_Sum_upto (List_End l p) (minus n p)).
\end{verbatim}
% file "CRings.v", line 1014-1016 *)
\index{list_sum_from_upto_eq@\verb/list_sum_from_upto_eq/, (\emph{commented out})}
\begin{verbatim}
Ax_iom list_sum_from_upto_eq :
  (l:(list R))(n,p:nat)(le p n) ->
      (List_Sum_from_upto_alt l p n) [=] (List_Sum_from_upto l p n).
\end{verbatim}
% file "CRings.v", line 1024-1027 *)
\subsection{Distribution properties}
\begin{convention}
Let \verb!R! be a ring.
\end{convention}
% file "CRings.v", line 1033 *)
\index{dist_1b@\verb/dist_1b/, \emph{lemma}}
\begin{verbatim}
Lemma dist_1b : (x,y,z:R)((x[+]y)[*]z [=] x[*]z[+]y[*]z).
\end{verbatim}
% file "CRings.v", line 1042 *)
\index{dist_2a@\verb/dist_2a/, \emph{lemma}}
\begin{verbatim}
Lemma dist_2a : (x,y,z:R)(z[*](x[-]y) [=] z[*]x[-]z[*]y).
\end{verbatim}
% file "CRings.v", line 1052 *)
\index{dist_2b@\verb/dist_2b/, \emph{lemma}}
\begin{verbatim}
Lemma dist_2b : (x,y,z:R)((x[-]y)[*]z [=] x[*]z[-]y[*]z).
\end{verbatim}
% file "CRings.v", line 1061-1063 *)
\index{mult_distr_sum0_lft@\verb/mult_distr_sum0_lft/, \emph{lemma}}
\begin{verbatim}
Lemma mult_distr_sum0_lft : (f:nat->R)(x:R)(a:nat)
                            (Sum0 a [i:nat](x [*] (f i))) [=]
                            (x [*] (Sum0 a f)).
\end{verbatim}
% file "CRings.v", line 1077-1079 *)
\index{mult_distr_sum_lft@\verb/mult_distr_sum_lft/, \emph{lemma}}
\begin{verbatim}
Lemma mult_distr_sum_lft : (f:nat->R)(x:R)(a,b:nat)
                           (Sum a b [i:nat](x [*] (f i))) [=]
                           (x [*] (Sum a b f)).
\end{verbatim}
% file "CRings.v", line 1090-1092 *)
\index{mult_distr_sum_rht@\verb/mult_distr_sum_rht/, \emph{lemma}}
\begin{verbatim}
Lemma mult_distr_sum_rht : (f:nat->R)(x:R)(a,b:nat)
                           (Sum a b [i:nat]((f i) [*] x)) [=]
                           ((Sum a b f) [*] x).
\end{verbatim}
% file "CRings.v", line 1107-1110 *)
\subsection{Properties of exponenation over N}
\begin{convention}
Let \verb!R! be a ring.
\end{convention}
% file "CRings.v", line 1116 *)
\index{nexp_wd@\verb/nexp_wd/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_wd :(x,y:R)(n:nat)(x[=]y)->(x[^]n [=] y[^]n).
\end{verbatim}
% file "CRings.v", line 1123 *)
\index{nexp_Sn@\verb/nexp_Sn/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_Sn : (x:R)(n:nat)(x[*]x[^]n [=] x[^](S n)).
\end{verbatim}
% file "CRings.v", line 1131 *)
\index{nexp_plus@\verb/nexp_plus/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_plus : (x:R)(m,n:nat)(x[^]m[*]x[^]n [=] x[^](plus m n)).
\end{verbatim}
% file "CRings.v", line 1152 *)
\index{one_nexp@\verb/one_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma one_nexp : (n:nat)((One::R)[^]n [=] One).
\end{verbatim}
% file "CRings.v", line 1166 *)
\index{mult_nexp@\verb/mult_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma mult_nexp : (x,y:R)(n:nat)((x[*]y)[^]n [=] x[^]n[*]y[^]n).
\end{verbatim}
% file "CRings.v", line 1187 *)
\index{nexp_mult@\verb/nexp_mult/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_mult : (x:R)(m,n:nat)((x[^]m)[^]n [=] x[^](mult m n)).
\end{verbatim}
% file "CRings.v", line 1207 *)
\index{zero_nexp@\verb/zero_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma zero_nexp : (x:R)(n:nat)(lt O n)->((Zero::R)[^]n [=] Zero).
\end{verbatim}
% file "CRings.v", line 1217 *)
\index{min_nexp_even@\verb/min_nexp_even/, \emph{lemma}}
\begin{verbatim}
Lemma min_nexp_even : (x:R)(n:nat)(even n)->(([--]x)[^]n [=] x[^]n).
\end{verbatim}
% file "CRings.v", line 1231 *)
\index{min_nexp_two@\verb/min_nexp_two/, \emph{lemma}}
\begin{verbatim}
Lemma min_nexp_two : (x:R)(([--]x)[^](2) [=] x[^](2)).
\end{verbatim}
% file "CRings.v", line 1240 *)
\index{min_nexp_odd@\verb/min_nexp_odd/, \emph{lemma}}
\begin{verbatim}
Lemma min_nexp_odd : (x:R)(n:nat)(odd n)->(([--]x)[^]n [=] [--](x[^]n)).
\end{verbatim}
% file "CRings.v", line 1252 *)
\index{nexp_one@\verb/nexp_one/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_one : (x:R)(x[^](1) [=] x).
\end{verbatim}
% file "CRings.v", line 1260 *)
\index{nexp_two@\verb/nexp_two/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_two : (x:R)(x[^](2) [=] x[*]x).
\end{verbatim}
% file "CRings.v", line 1270 *)
\index{nexp_funny@\verb/nexp_funny/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_funny : (x,y:R)((x[+]y)[*](x[-]y) [=] x[^](2)[-]y[^](2)).
\end{verbatim}
% file "CRings.v", line 1286 *)
\index{nexp_funny'@\verb/nexp_funny'/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_funny' : (x,y:R)((x[-]y)[*](x[+]y) [=] x[^](2)[-]y[^](2)).
\end{verbatim}
% file "Step2.v", line 7-8 *)
\section{The {\tt Step2} tactic}
Some definition and lemmas used by a tactic for equational reasoning.
% file "Step2.v", line 19 *)
\index{implies@\verb/implies/, \emph{definition}}
\begin{verbatim}
Definition implies := [p,q:Prop]p->q : Prop->Prop->Prop.
\end{verbatim}
% file "Step2.v", line 23 *)
\index{fold_implies@\verb/fold_implies/, \emph{lemma}}
\begin{verbatim}
Lemma fold_implies : (p,q:Prop)(p->q)==(implies p q).
\end{verbatim}
% file "Step2.v", line 30-31 *)
\index{eq_wd_implies@\verb/eq_wd_implies/, \emph{lemma}}
\begin{verbatim}
Lemma eq_wd_implies :
  (S:CSetoid)(x,y,x',y':S)(x[=]x')->(y[=]y')->(implies x'[=]y' x[=]y).
\end{verbatim}
% file "Step2.v", line 44-45 *)
\index{ap_wd_implies@\verb/ap_wd_implies/, \emph{lemma}}
\begin{verbatim}
Lemma ap_wd_implies :
  (S:CSetoid)(x,y,x',y':S)(x[=]x')->(y[=]y')->(implies x'[#]y' x[#]y).
\end{verbatim}
% file "CPolynomials.v", line 6-12 *)
\section{Polynomials}
The first section only proves the polynomials form a ring, and nothing more
interesting.
Section~\ref{section:poly-equality} gives some basic properties of
equality and induction of polynomials.
\subsection{Definition of polynomials; they form a ring}
\label{section:poly-ring}
% file "CPolynomials.v", line 17-19 *)
\begin{convention}
Let \verb!CR! be a ring.
\end{convention}
% file "CPolynomials.v", line 25-27 *)
\verb!(cpoly CR)! is $R[X]$;
\verb!cpoly_zero! is the `empty' polynomial with no coefficients;
\verb!(cpoly_linear c p)! is $c + X * p$
% file "CPolynomials.v", line 31-36 *)
\index{cpoly_constant@\verb/cpoly_constant/, \emph{definition}}
\index{cpoly_one@\verb/cpoly_one/, \emph{definition}}
\begin{verbatim}
Inductive cpoly : Set :=
    cpoly_zero : cpoly
  | cpoly_linear : (s:CR)(c:cpoly)cpoly.

Definition cpoly_constant [c:CR]: cpoly := (cpoly_linear c cpoly_zero).
Definition cpoly_one: cpoly := (cpoly_constant One).
\end{verbatim}
% file "CPolynomials.v", line 40 *)
Some useful induction lemmas for doubly quantified propositions.
% file "CPolynomials.v", line 43-47 *)
\index{cpoly_double_ind0@\verb/cpoly_double_ind0/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_double_ind0 : (P:cpoly->cpoly->Prop)
   ((p:cpoly)(P p cpoly_zero)) ->
   ((p:cpoly)(P cpoly_zero p)) ->
   ((p,q:cpoly)(c,d:CR)(P p q)->(P (cpoly_linear c p) (cpoly_linear d q))) ->
   (p,q:cpoly)(P p q).
\end{verbatim}
% file "CPolynomials.v", line 54-58 *)
\index{cpoly_double_sym_ind0@\verb/cpoly_double_sym_ind0/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_double_sym_ind0 : (P:cpoly->cpoly->Prop)
   (Symmetric P) ->
   ((p:cpoly)(P p cpoly_zero)) ->
   ((p,q:cpoly)(c,d:CR)(P p q)->(P (cpoly_linear c p) (cpoly_linear d q))) ->
   (p,q:cpoly)(P p q).
\end{verbatim}
% file "CPolynomials.v", line 65-69 *)
\index{cpoly_double_ind0'@\verb/cpoly_double_ind0'/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_double_ind0' : (P:cpoly->cpoly->Prop)
   ((p:cpoly)(P cpoly_zero p)) ->
   ((p:cpoly)(c:CR)(P (cpoly_linear c p) cpoly_zero)) ->
   ((p,q:cpoly)(c,d:CR)(P p q)->(P (cpoly_linear c p) (cpoly_linear d q))) ->
   (p,q:cpoly)(P p q).
\end{verbatim}
% file "CPolynomials.v", line 76 *)
\subsubsection{The polynomials form a setoid}
% file "CPolynomials.v", line 79-83 *)
\index{cpoly_eq_zero@\verb/cpoly_eq_zero/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint cpoly_eq_zero [p:cpoly] : Prop :=
  Cases p of
    cpoly_zero => True
  | (cpoly_linear c p1) => (c [=] Zero) /\ (cpoly_eq_zero p1)
  end.
\end{verbatim}
% file "CPolynomials.v", line 87-95 *)
\index{cpoly_eq@\verb/cpoly_eq/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint cpoly_eq [p:cpoly] : cpoly->Prop := [q:cpoly]
  Cases p of
    cpoly_zero => (cpoly_eq_zero q)
  | (cpoly_linear c p1) =>
      Cases q of
        cpoly_zero => (cpoly_eq_zero p)
      | (cpoly_linear d q1) => (c [=] d) /\ (cpoly_eq p1 q1)
      end
  end.
\end{verbatim}
% file "CPolynomials.v", line 99-101 *)
\index{cpoly_eq_p_zero@\verb/cpoly_eq_p_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_eq_p_zero : (p:cpoly)(cpoly_eq p cpoly_zero) == (cpoly_eq_zero p).
Induction p; Auto.
Qed.
\end{verbatim}
% file "CPolynomials.v", line 105-109 *)
\index{cpoly_ap_zero@\verb/cpoly_ap_zero/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint cpoly_ap_zero [p:cpoly] : Prop :=
  Cases p of
    cpoly_zero => False
  | (cpoly_linear c p1) => (c [#] Zero) \/ (cpoly_ap_zero p1)
  end.
\end{verbatim}
% file "CPolynomials.v", line 113-121 *)
\index{cpoly_ap@\verb/cpoly_ap/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint cpoly_ap [p:cpoly] : cpoly->Prop := [q:cpoly]
  Cases p of
    cpoly_zero => (cpoly_ap_zero q)
  | (cpoly_linear c p1) =>
      Cases q of
        cpoly_zero => (cpoly_ap_zero p)
      | (cpoly_linear d q1) => (c [#] d) \/ (cpoly_ap p1 q1)
      end
  end.
\end{verbatim}
% file "CPolynomials.v", line 125 *)
\index{cpoly_ap_p_zero@\verb/cpoly_ap_p_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_ap_p_zero : (p:cpoly)(cpoly_ap_zero p) == (cpoly_ap p cpoly_zero).
\end{verbatim}
% file "CPolynomials.v", line 131 *)
\index{irreflexive_cpoly_ap@\verb/irreflexive_cpoly_ap/, \emph{lemma}}
\begin{verbatim}
Lemma irreflexive_cpoly_ap : (irreflexive cpoly_ap).
\end{verbatim}
% file "CPolynomials.v", line 147 *)
\index{symmetric_cpoly_ap@\verb/symmetric_cpoly_ap/, \emph{lemma}}
\begin{verbatim}
Lemma symmetric_cpoly_ap : (symmetric ? cpoly_ap).
\end{verbatim}
% file "CPolynomials.v", line 170 *)
\index{cotransitive_cpoly_ap@\verb/cotransitive_cpoly_ap/, \emph{lemma}}
\begin{verbatim}
Lemma cotransitive_cpoly_ap : (cotransitive cpoly_ap).
\end{verbatim}
% file "CPolynomials.v", line 254 *)
\index{tight_apart_cpoly_ap@\verb/tight_apart_cpoly_ap/, \emph{lemma}}
\begin{verbatim}
Lemma tight_apart_cpoly_ap : (tight_apart cpoly_eq cpoly_ap).
\end{verbatim}
% file "CPolynomials.v", line 287 *)
\index{cpoly_is_CSetoid@\verb/cpoly_is_CSetoid/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_is_CSetoid : (is_CSetoid ? cpoly_eq cpoly_ap).
\end{verbatim}
% file "CPolynomials.v", line 297-298 *)
\index{cpoly_csetoid@\verb/cpoly_csetoid/, \emph{definition}}
\begin{verbatim}
Definition cpoly_csetoid :=
                    (Build_CSetoid cpoly cpoly_eq cpoly_ap cpoly_is_CSetoid).
\end{verbatim}
% file "CPolynomials.v", line 302-308 *)
Now that we know that the polynomials form a setoid, we can use the
notation with \verb![#]! and \verb![=]!. In order to use this notation,
we introduce \verb!cpoly_zero_cs! and \verb!cpoly_linear_cs!, so that Coq
recognizes we are talking about a setoid.
We formulate the induction properties and
the most basic properties of equality and apartness
in terms of these generators.
% file "CPolynomials.v", line 312-315 *)
\index{cpoly_zero_cs@\verb/cpoly_zero_cs/, \emph{local}}
\index{cpoly_linear_cs@\verb/cpoly_linear_cs/, \emph{local}}
\begin{verbatim}
Local cpoly_zero_cs := cpoly_zero : cpoly_csetoid.

Local cpoly_linear_cs [c:CR; p:cpoly_csetoid] : cpoly_csetoid :=
                      (cpoly_linear c p).
\end{verbatim}
% file "CPolynomials.v", line 319-322 *)
\index{cpoly_ind_cs@\verb/cpoly_ind_cs/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_ind_cs : (P:cpoly_csetoid->Prop)
   (P cpoly_zero_cs) ->
   ((p:cpoly_csetoid)(c:CR)(P p)->(P (cpoly_linear_cs c p))) ->
   (p:cpoly_csetoid)(P p).
\end{verbatim}
% file "CPolynomials.v", line 330-335 *)
\index{cpoly_double_ind0_cs@\verb/cpoly_double_ind0_cs/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_double_ind0_cs : (P:cpoly_csetoid->cpoly_csetoid->Prop)
   ((p:cpoly_csetoid)(P p cpoly_zero_cs)) ->
   ((p:cpoly_csetoid)(P cpoly_zero_cs p)) ->
   ((p,q:cpoly_csetoid)(c,d:CR)
                 (P p q)->(P (cpoly_linear_cs c p) (cpoly_linear_cs d q))) ->
   (p,q:cpoly_csetoid)(P p q).
\end{verbatim}
% file "CPolynomials.v", line 347-352 *)
\index{cpoly_double_sym_ind0_cs@\verb/cpoly_double_sym_ind0_cs/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_double_sym_ind0_cs : (P:cpoly_csetoid->cpoly_csetoid->Prop)
   (Symmetric P) ->
   ((p:cpoly_csetoid)(P p cpoly_zero_cs)) ->
   ((p,q:cpoly_csetoid)(c,d:CR)(P p q)->
                       (P (cpoly_linear_cs c p) (cpoly_linear_cs d q))) ->
   (p,q:cpoly_csetoid)(P p q).
\end{verbatim}
% file "CPolynomials.v", line 359-361 *)
\index{cpoly_lin_eq_zero@\verb/cpoly_lin_eq_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_lin_eq_zero : (p:cpoly_csetoid)(c:CR)
     ((cpoly_linear_cs c p) [=] cpoly_zero_cs) ==
     ((c [=] Zero) /\ (p [=] (cpoly_zero_cs))).
\end{verbatim}
% file "CPolynomials.v", line 371-373 *)
\index{cpoly_zero_eq_lin@\verb/cpoly_zero_eq_lin/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_zero_eq_lin : (p:cpoly_csetoid)(c:CR)
     (cpoly_zero_cs [=] (cpoly_linear_cs c p)) ==
     ((c [=] Zero) /\ ((cpoly_zero_cs) [=] p)).
\end{verbatim}
% file "CPolynomials.v", line 381-383 *)
\index{cpoly_lin_eq_lin@\verb/cpoly_lin_eq_lin/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_lin_eq_lin : (p,q:cpoly_csetoid)(c,d:CR)
     ((cpoly_linear_cs c p) [=] (cpoly_linear_cs d q)) ==
     ((c [=] d) /\ (p [=] q)).
\end{verbatim}
% file "CPolynomials.v", line 392-394 *)
\index{cpoly_lin_ap_zero@\verb/cpoly_lin_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_lin_ap_zero : (p:cpoly_csetoid)(c:CR)
     ((cpoly_linear_cs c p) [#] cpoly_zero_cs) ==
     ((c [#] Zero) \/ (p [#] (cpoly_zero_cs))).
\end{verbatim}
% file "CPolynomials.v", line 404-406 *)
\index{cpoly_zero_ap_lin@\verb/cpoly_zero_ap_lin/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_zero_ap_lin : (p:cpoly_csetoid)(c:CR)
     (cpoly_zero_cs [#] (cpoly_linear_cs c p)) ==
     ((c [#] Zero) \/ ((cpoly_zero_cs) [#] p)).
\end{verbatim}
% file "CPolynomials.v", line 414-416 *)
\index{cpoly_lin_ap_lin@\verb/cpoly_lin_ap_lin/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_lin_ap_lin : (p,q:cpoly_csetoid)(c,d:CR)
     ((cpoly_linear_cs c p) [#] (cpoly_linear_cs d q)) ==
     ((c [#] d) \/ (p [#] q)).
\end{verbatim}
% file "CPolynomials.v", line 424 *)
\index{cpoly_linear_strext@\verb/cpoly_linear_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_linear_strext : (bin_fun_strong_ext ??? cpoly_linear_cs).
\end{verbatim}
% file "CPolynomials.v", line 433 *)
\index{cpoly_linear_wd@\verb/cpoly_linear_wd/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_linear_wd : (bin_fun_well_def ??? cpoly_linear_cs).
\end{verbatim}
% file "CPolynomials.v", line 440-441 *)
\index{cpoly_linear_fun@\verb/cpoly_linear_fun/, \emph{definition}}
\begin{verbatim}
Definition cpoly_linear_fun :=
  (Build_CSetoid_bin_fun ???? cpoly_linear_wd cpoly_linear_strext).
\end{verbatim}
% file "CPolynomials.v", line 445-450 *)
\index{cpoly_double_comp_ind@\verb/cpoly_double_comp_ind/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_double_comp_ind : (P : cpoly_csetoid -> cpoly_csetoid -> Prop)
 ((p1,p2,q1,q2:cpoly_csetoid)((p1[=]p2)->(q1[=]q2)->(P p1 q1)->(P p2 q2))) ->
 (P cpoly_zero_cs cpoly_zero_cs) ->
 ((p,q:cpoly_csetoid)(c,d:CR)(P p q)->
                           (P (cpoly_linear_cs c p) (cpoly_linear_cs d q))) ->
 (p,q:cpoly_csetoid)(P p q).
\end{verbatim}
% file "CPolynomials.v", line 479-486 *)
\index{cpoly_triple_comp_ind@\verb/cpoly_triple_comp_ind/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_triple_comp_ind :
 (P : cpoly_csetoid -> cpoly_csetoid -> cpoly_csetoid -> Prop)
 ((p1,p2,q1,q2,r1,r2:cpoly_csetoid)((p1[=]p2)->(q1[=]q2)->(r1[=]r2)->
                    (P p1 q1 r1)->(P p2 q2 r2))) ->
 (P cpoly_zero_cs cpoly_zero_cs cpoly_zero_cs) ->
 ((p,q,r:cpoly_csetoid)(c,d,e:CR)(P p q r)->
     (P (cpoly_linear_cs c p) (cpoly_linear_cs d q) (cpoly_linear_cs e r))) ->
 (p,q,r:cpoly_csetoid)(P p q r).
\end{verbatim}
% file "CPolynomials.v", line 526 *)
\subsubsection{The polynomials form a semi-group and a monoid}
% file "CPolynomials.v", line 529-537 *)
\index{cpoly_plus@\verb/cpoly_plus/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint cpoly_plus [p:cpoly] : cpoly -> cpoly := [q:cpoly]
  Cases p of
    cpoly_zero => q
  | (cpoly_linear c p1) =>
      Cases q of
        cpoly_zero => p
      | (cpoly_linear d q1) => (cpoly_linear c[+]d (cpoly_plus p1 q1))
      end
  end.
\end{verbatim}
% file "CPolynomials.v", line 541-542 *)
\index{cpoly_plus_cs@\verb/cpoly_plus_cs/, \emph{definition}}
\begin{verbatim}
Definition cpoly_plus_cs [p,q:cpoly_csetoid] : cpoly_csetoid
                                             := (cpoly_plus p q).
\end{verbatim}
% file "CPolynomials.v", line 546 *)
\index{cpoly_zero_plus@\verb/cpoly_zero_plus/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_zero_plus : (p:cpoly_csetoid)(cpoly_plus_cs cpoly_zero_cs p) = p.
\end{verbatim}
% file "CPolynomials.v", line 552 *)
\index{cpoly_plus_zero@\verb/cpoly_plus_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_plus_zero : (p:cpoly_csetoid)(cpoly_plus_cs p cpoly_zero_cs) = p.
\end{verbatim}
% file "CPolynomials.v", line 560-562 *)
\index{cpoly_lin_plus_lin@\verb/cpoly_lin_plus_lin/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_lin_plus_lin : (p,q:cpoly_csetoid)(c,d:CR)
             (cpoly_plus_cs (cpoly_linear_cs c p) (cpoly_linear_cs d q)) =
             (cpoly_linear_cs (c[+]d) (cpoly_plus_cs p q)).
\end{verbatim}
% file "CPolynomials.v", line 568-569 *)
\index{cpoly_plus_commutative@\verb/cpoly_plus_commutative/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_plus_commutative :
               (p,q:cpoly_csetoid)(cpoly_plus_cs p q) [=] (cpoly_plus_cs q p).
\end{verbatim}
% file "CPolynomials.v", line 590-592 *)
\index{cpoly_plus_q_ap_q@\verb/cpoly_plus_q_ap_q/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_plus_q_ap_q : (p,q:cpoly_csetoid)
              ((cpoly_plus_cs p q) [#] q) ->
              (p [#] cpoly_zero_cs).
\end{verbatim}
% file "CPolynomials.v", line 619-620 *)
\index{cpoly_p_plus_ap_p@\verb/cpoly_p_plus_ap_p/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_p_plus_ap_p : (p,q:cpoly_csetoid)
              ((cpoly_plus_cs p q) [#] p) -> (q [#] cpoly_zero).
\end{verbatim}
% file "CPolynomials.v", line 630-632 *)
\index{cpoly_ap_zero_plus@\verb/cpoly_ap_zero_plus/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_ap_zero_plus : (p,q:cpoly_csetoid)
              ((cpoly_plus_cs p q) [#] cpoly_zero_cs) ->
              (p [#] cpoly_zero_cs) \/ (q [#] cpoly_zero_cs).
\end{verbatim}
% file "CPolynomials.v", line 674 *)
\index{cpoly_plus_op_strext@\verb/cpoly_plus_op_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_plus_op_strext : (bin_op_strong_ext cpoly_csetoid cpoly_plus_cs).
\end{verbatim}
% file "CPolynomials.v", line 776 *)
\index{cpoly_plus_op_proof@\verb/cpoly_plus_op_proof/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_plus_op_proof : (bin_op_well_def cpoly_csetoid cpoly_plus_cs).
\end{verbatim}
% file "CPolynomials.v", line 784-785 *)
\index{cpoly_plus_op@\verb/cpoly_plus_op/, \emph{definition}}
\begin{verbatim}
Definition cpoly_plus_op :=
  (Build_CSetoid_bin_op ?? cpoly_plus_op_proof cpoly_plus_op_strext).
\end{verbatim}
% file "CPolynomials.v", line 789 *)
\index{cpoly_plus_associative@\verb/cpoly_plus_associative/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_plus_associative : (Associative cpoly_plus_op).
\end{verbatim}
% file "CPolynomials.v", line 821-823 *)
\index{cpoly_csemi_grp@\verb/cpoly_csemi_grp/, \emph{definition}}
\begin{verbatim}
Definition cpoly_csemi_grp :=
       (Build_CSemi_grp cpoly_csetoid cpoly_zero cpoly_plus_op
                        cpoly_plus_associative).
\end{verbatim}
% file "CPolynomials.v", line 827 *)
\index{cpoly_cm_proof@\verb/cpoly_cm_proof/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_cm_proof : (is_CMonoid cpoly_csemi_grp).
\end{verbatim}
% file "CPolynomials.v", line 840 *)
\index{cpoly_cmonoid@\verb/cpoly_cmonoid/, \emph{definition}}
\begin{verbatim}
Definition cpoly_cmonoid := (Build_CMonoid ? cpoly_cm_proof).
\end{verbatim}
% file "CPolynomials.v", line 844 *)
\subsubsection{The polynomials form a group}
% file "CPolynomials.v", line 847-851 *)
\index{cpoly_min@\verb/cpoly_min/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint cpoly_min [p:cpoly] : cpoly :=
  Cases p of
    cpoly_zero => cpoly_zero
  | (cpoly_linear c p1) => (cpoly_linear [--]c (cpoly_min p1))
  end.
\end{verbatim}
% file "CPolynomials.v", line 855 *)
\index{cpoly_min_cs@\verb/cpoly_min_cs/, \emph{definition}}
\begin{verbatim}
Definition cpoly_min_cs [p:cpoly_csetoid] : cpoly_csetoid := (cpoly_min p).
\end{verbatim}
% file "CPolynomials.v", line 859 *)
\index{cpoly_min_zero@\verb/cpoly_min_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_min_zero : (cpoly_min_cs cpoly_zero_cs) = cpoly_zero_cs.
\end{verbatim}
% file "CPolynomials.v", line 865-867 *)
\index{cpoly_min_lin@\verb/cpoly_min_lin/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_min_lin : (p:cpoly_csetoid)(c:CR)
    (cpoly_min_cs (cpoly_linear_cs c p)) =
    (cpoly_linear_cs ([--]c) (cpoly_min_cs p)).
\end{verbatim}
% file "CPolynomials.v", line 875 *)
\index{cpoly_min_op_strext@\verb/cpoly_min_op_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_min_op_strext : (un_op_strong_ext cpoly_csetoid cpoly_min_cs).
\end{verbatim}
% file "CPolynomials.v", line 917 *)
\index{cpoly_min_op_proof@\verb/cpoly_min_op_proof/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_min_op_proof : (un_op_well_def cpoly_csetoid cpoly_min_cs).
\end{verbatim}
% file "CPolynomials.v", line 925-926 *)
\index{cpoly_min_op@\verb/cpoly_min_op/, \emph{definition}}
\begin{verbatim}
Definition cpoly_min_op :=
  (Build_CSetoid_un_op ?? cpoly_min_op_proof cpoly_min_op_strext).
\end{verbatim}
% file "CPolynomials.v", line 930 *)
\index{cpoly_cg_proof@\verb/cpoly_cg_proof/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_cg_proof : (is_CGroup cpoly_cmonoid cpoly_min_op).
\end{verbatim}
% file "CPolynomials.v", line 951 *)
\index{cpoly_cgroup@\verb/cpoly_cgroup/, \emph{definition}}
\begin{verbatim}
Definition cpoly_cgroup := (Build_CGroup ?? cpoly_cg_proof).
\end{verbatim}
% file "CPolynomials.v", line 955 *)
\subsubsection{The polynomials form a ring}
% file "CPolynomials.v", line 958-962 *)
\index{cpoly_mult_cr@\verb/cpoly_mult_cr/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint cpoly_mult_cr [q:cpoly] : CR -> cpoly := [c:CR]
  Cases q of
    cpoly_zero => cpoly_zero
  | (cpoly_linear d q1) => (cpoly_linear c[*]d (cpoly_mult_cr q1 c))
  end.
\end{verbatim}
% file "CPolynomials.v", line 966-972 *)
\index{cpoly_mult@\verb/cpoly_mult/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint cpoly_mult [p:cpoly] : cpoly -> cpoly := [q:cpoly]
  Cases p of
    cpoly_zero => cpoly_zero
  | (cpoly_linear c p1) =>
      (cpoly_plus (cpoly_mult_cr q c)
                  (cpoly_linear Zero (cpoly_mult p1 q)))
  end.
\end{verbatim}
% file "CPolynomials.v", line 976-977 *)
\index{cpoly_mult_cr_cs@\verb/cpoly_mult_cr_cs/, \emph{definition}}
\begin{verbatim}
Definition cpoly_mult_cr_cs [p:cpoly_csetoid; c:CR] : cpoly_csetoid
                                                    := (cpoly_mult_cr p c).
\end{verbatim}
% file "CPolynomials.v", line 981-982 *)
\index{cpoly_zero_mult_cr@\verb/cpoly_zero_mult_cr/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_zero_mult_cr : (c:CR)
                            (cpoly_mult_cr_cs cpoly_zero_cs c)=cpoly_zero_cs.
\end{verbatim}
% file "CPolynomials.v", line 988-990 *)
\index{cpoly_lin_mult_cr@\verb/cpoly_lin_mult_cr/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_lin_mult_cr : (c,d:CR)(q:cpoly_csetoid)
                              (cpoly_mult_cr_cs (cpoly_linear_cs d q) c) =
                              (cpoly_linear_cs c[*]d (cpoly_mult_cr_cs q c)).
\end{verbatim}
% file "CPolynomials.v", line 996-997 *)
\index{cpoly_mult_cr_zero@\verb/cpoly_mult_cr_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_cr_zero : (p:cpoly_csetoid)
                           (cpoly_mult_cr_cs p Zero) [=] cpoly_zero_cs.
\end{verbatim}
% file "CPolynomials.v", line 1011-1012 *)
\index{cpoly_mult_cr_strext@\verb/cpoly_mult_cr_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_cr_strext :
          (bin_fun_strong_ext cpoly_cgroup CR cpoly_cgroup cpoly_mult_cr_cs).
\end{verbatim}
% file "CPolynomials.v", line 1065-1066 *)
\index{cpoly_mult_cr_wd@\verb/cpoly_mult_cr_wd/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_cr_wd :
           (bin_fun_well_def cpoly_cgroup CR cpoly_cgroup cpoly_mult_cr_cs).
\end{verbatim}
% file "CPolynomials.v", line 1073-1074 *)
\index{cpoly_mult_cs@\verb/cpoly_mult_cs/, \emph{definition}}
\begin{verbatim}
Definition cpoly_mult_cs [p,q:cpoly_csetoid] : cpoly_csetoid
                                             := (cpoly_mult p q).
\end{verbatim}
% file "CPolynomials.v", line 1078-1079 *)
\index{cpoly_zero_mult@\verb/cpoly_zero_mult/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_zero_mult : (q:cpoly_csetoid)
                        (cpoly_mult_cs cpoly_zero_cs q)=cpoly_zero_cs.
\end{verbatim}
% file "CPolynomials.v", line 1085-1088 *)
\index{cpoly_lin_mult@\verb/cpoly_lin_mult/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_lin_mult : (c:CR)(p,q:cpoly_csetoid)
                         (cpoly_mult_cs (cpoly_linear_cs c p) q) =
                         (cpoly_plus_cs (cpoly_mult_cr_cs q c)
                             (cpoly_linear_cs Zero (cpoly_mult_cs p q))).
\end{verbatim}
% file "CPolynomials.v", line 1094 *)
\index{cpoly_mult_op_strext@\verb/cpoly_mult_op_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_op_strext : (bin_op_strong_ext cpoly_csetoid cpoly_mult_cs).
\end{verbatim}
% file "CPolynomials.v", line 1180 *)
\index{cpoly_mult_op_proof@\verb/cpoly_mult_op_proof/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_op_proof : (bin_op_well_def cpoly_csetoid cpoly_mult).
\end{verbatim}
% file "CPolynomials.v", line 1188-1189 *)
\index{cpoly_mult_op@\verb/cpoly_mult_op/, \emph{definition}}
\begin{verbatim}
Definition cpoly_mult_op :=
  (Build_CSetoid_bin_op ?? cpoly_mult_op_proof cpoly_mult_op_strext).
\end{verbatim}
% file "CPolynomials.v", line 1193-1195 *)
\index{cpoly_mult_cr_dist@\verb/cpoly_mult_cr_dist/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_cr_dist : (p,q:cpoly_csetoid)(c:CR)
               (cpoly_mult_cr_cs (cpoly_plus_cs p q) c) [=]
               (cpoly_plus_cs (cpoly_mult_cr_cs p c) (cpoly_mult_cr_cs q c)).
\end{verbatim}
% file "CPolynomials.v", line 1225 *)
\index{cpoly_cr_dist@\verb/cpoly_cr_dist/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_cr_dist : (Distributive cpoly_mult_op cpoly_plus_op).
\end{verbatim}
% file "CPolynomials.v", line 1284-1286 *)
\index{cpoly_mult_cr_assoc_mult_cr@\verb/cpoly_mult_cr_assoc_mult_cr/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_cr_assoc_mult_cr : (p:cpoly_csetoid)(c,d:CR)
   (cpoly_mult_cr_cs (cpoly_mult_cr_cs p c) d)
      [=] (cpoly_mult_cr_cs p d[*]c).
\end{verbatim}
% file "CPolynomials.v", line 1301-1303 *)
\index{cpoly_mult_cr_assoc_mult@\verb/cpoly_mult_cr_assoc_mult/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_cr_assoc_mult : (p,q:cpoly_csetoid)(c:CR)
          (cpoly_mult_cr_cs (cpoly_mult_cs p q) c)
      [=] (cpoly_mult_cs (cpoly_mult_cr_cs p c) q).
\end{verbatim}
% file "CPolynomials.v", line 1329-1330 *)
\index{cpoly_mult_zero@\verb/cpoly_mult_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_zero :
   (p:cpoly_csetoid)(cpoly_mult_cs p cpoly_zero_cs) [=] (cpoly_zero_cs).
\end{verbatim}
% file "CPolynomials.v", line 1346-1349 *)
\index{cpoly_mult_lin@\verb/cpoly_mult_lin/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_lin : (c:CR)(p,q:cpoly_csetoid)
                         (cpoly_mult_cs p (cpoly_linear_cs c q)) [=]
                         (cpoly_plus_cs (cpoly_mult_cr_cs p c)
                             (cpoly_linear_cs Zero (cpoly_mult_cs p q))).
\end{verbatim}
% file "CPolynomials.v", line 1388-1389 *)
\index{cpoly_mult_commutative@\verb/cpoly_mult_commutative/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_commutative :
   (p,q:cpoly_csetoid)(cpoly_mult_cs p q) [=] (cpoly_mult_cs q p).
\end{verbatim}
% file "CPolynomials.v", line 1411-1414 *)
\index{cpoly_mult_dist_rht@\verb/cpoly_mult_dist_rht/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_dist_rht :
   (p,q,r:cpoly_csetoid)
   (cpoly_mult_cs (cpoly_plus_cs p q) r) [=]
   (cpoly_plus_cs (cpoly_mult_cs p r) (cpoly_mult_cs q r)).
\end{verbatim}
% file "CPolynomials.v", line 1434 *)
\index{cpoly_mult_assoc@\verb/cpoly_mult_assoc/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_assoc : (Associative cpoly_mult_op).
\end{verbatim}
% file "CPolynomials.v", line 1472 *)
\index{cpoly_mult_cr_one@\verb/cpoly_mult_cr_one/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_cr_one : (p:cpoly_csetoid)(cpoly_mult_cr_cs p One)[=]p.
\end{verbatim}
% file "CPolynomials.v", line 1484 *)
\index{cpoly_one_mult@\verb/cpoly_one_mult/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_one_mult : (p:cpoly_csetoid)(cpoly_mult_cs cpoly_one p)[=]p.
\end{verbatim}
% file "CPolynomials.v", line 1501 *)
\index{cpoly_mult_one@\verb/cpoly_mult_one/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_one : (p:cpoly_csetoid)(cpoly_mult_cs p cpoly_one)[=]p.
\end{verbatim}
% file "CPolynomials.v", line 1510-1511 *)
\index{cpoly_mult_monoid@\verb/cpoly_mult_monoid/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_mult_monoid: (is_CMonoid
   (Build_CSemi_grp cpoly_csetoid cpoly_one cpoly_mult_op cpoly_mult_assoc)).
\end{verbatim}
% file "CPolynomials.v", line 1519 *)
\index{cpoly_cr_non_triv@\verb/cpoly_cr_non_triv/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_cr_non_triv : (cpoly_ap cpoly_one cpoly_zero).
\end{verbatim}
% file "CPolynomials.v", line 1528 *)
\index{cpoly_is_CRing@\verb/cpoly_is_CRing/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_is_CRing : (is_CRing cpoly_cgroup cpoly_one cpoly_mult_op).
\end{verbatim}
% file "CPolynomials.v", line 1537-1538 *)
\index{cpoly_cring@\verb/cpoly_cring/, \emph{definition}}
\begin{verbatim}
Definition cpoly_cring :=
  (Build_CRing cpoly_cgroup cpoly_one cpoly_mult_op cpoly_is_CRing) : CRing.
\end{verbatim}
% file "CPolynomials.v", line 1542 *)
\index{cpoly_constant_strext@\verb/cpoly_constant_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_constant_strext : (fun_strong_ext CR cpoly_cring  cpoly_constant).
\end{verbatim}
% file "CPolynomials.v", line 1551 *)
\index{cpoly_constant_wd@\verb/cpoly_constant_wd/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_constant_wd : (fun_well_def CR cpoly_cring cpoly_constant).
\end{verbatim}
% file "CPolynomials.v", line 1558-1560 *)
\index{_c_@\verb/_c_/, \emph{definition}}
\begin{verbatim}
Definition _c_ :=
  (Build_CSetoid_fun CR cpoly_cring cpoly_constant
                        cpoly_constant_wd cpoly_constant_strext).
\end{verbatim}
% file "CPolynomials.v", line 1564 *)
\index{_x_@\verb/_x_/, \emph{definition}}
\begin{verbatim}
Definition _x_ : cpoly_cring := (cpoly_linear_cs Zero One::cpoly_cring).
\end{verbatim}
% file "CPolynomials.v", line 1568-1569 *)
\index{cpoly_x_minus_c@\verb/cpoly_x_minus_c/, \emph{definition}}
\begin{verbatim}
Definition cpoly_x_minus_c : CR -> cpoly_cring
                           := [c:CR](cpoly_linear_cs ([--]c) One::cpoly_cring).
\end{verbatim}
% file "CPolynomials.v", line 1573 *)
\index{cpoly_x_minus_c_strext@\verb/cpoly_x_minus_c_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_x_minus_c_strext : (fun_strong_ext CR cpoly_cring cpoly_x_minus_c).
\end{verbatim}
% file "CPolynomials.v", line 1587 *)
\index{cpoly_x_minus_c_wd@\verb/cpoly_x_minus_c_wd/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_x_minus_c_wd : (fun_well_def CR cpoly_cring cpoly_x_minus_c).
\end{verbatim}
% file "CPolynomials.v", line 1599-1601 *)
\begin{notation}
\verb!cpoly_linear_fun ? c p! is denoted with \verb!c [+X*] p!.
\end{notation}
% file "CPolynomials.v", line 1615-1616 *)
\subsection{Apartness, equality, and induction}
\label{section:poly-equality}
% file "CPolynomials.v", line 1626-1627 *)
\index{linear_eq_zero@\verb/linear_eq_zero/, \emph{lemma}}
\begin{verbatim}
Lemma linear_eq_zero : (p:Cpoly_cring)(c:CR)
     ((c [+X*] p) [=] Zero) == ((c [=] Zero) /\ (p [=] Zero)).
\end{verbatim}
% file "CPolynomials.v", line 1633-1634 *)
\index{zero_eq_linear@\verb/zero_eq_linear/, \emph{lemma}}
\begin{verbatim}
Lemma zero_eq_linear : (p:Cpoly_cring)(c:CR)
     (Zero [=] c [+X*] p) == ((c [=] Zero) /\ (Zero [=] p)).
\end{verbatim}
% file "CPolynomials.v", line 1640-1641 *)
\index{linear_eq_linear@\verb/linear_eq_linear/, \emph{lemma}}
\begin{verbatim}
Lemma linear_eq_linear : (p,q:Cpoly_cring)(c,d:CR)
     (c [+X*] p [=] d [+X*] q) == ((c [=] d) /\ (p [=] q)).
\end{verbatim}
% file "CPolynomials.v", line 1647-1648 *)
\index{linear_ap_zero@\verb/linear_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma linear_ap_zero : (p:Cpoly_cring)(c:CR)
     (c [+X*] p [#] Zero) == ((c [#] Zero) \/ (p [#] Zero)).
\end{verbatim}
% file "CPolynomials.v", line 1654-1655 *)
\index{zero_ap_linear@\verb/zero_ap_linear/, \emph{lemma}}
\begin{verbatim}
Lemma zero_ap_linear : (p:Cpoly_cring)(c:CR)
     (Zero [#] c [+X*] p) == ((c [#] Zero) \/ (Zero [#] p)).
\end{verbatim}
% file "CPolynomials.v", line 1661-1662 *)
\index{linear_ap_linear@\verb/linear_ap_linear/, \emph{lemma}}
\begin{verbatim}
Lemma linear_ap_linear : (p,q:Cpoly_cring)(c,d:CR)
     (c [+X*] p [#] d [+X*] q) == ((c [#] d) \/ (p [#] q)).
\end{verbatim}
% file "CPolynomials.v", line 1668-1671 *)
\index{cpoly_induc@\verb/cpoly_induc/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_induc : (P:Cpoly_cring->Prop)
   (P Zero) ->
   ((p:Cpoly_cring)(c:CR)(P p)->(P (c [+X*] p))) ->
   (p:Cpoly_cring)(P p).
\end{verbatim}
% file "CPolynomials.v", line 1677-1681 *)
\index{cpoly_double_ind@\verb/cpoly_double_ind/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_double_ind : (P:Cpoly_cring->Cpoly_cring->Prop)
   ((p:Cpoly_cring)(P p Zero)) ->
   ((p:Cpoly_cring)(P Zero p)) ->
   ((p,q:Cpoly_cring)(c,d:CR)(P p q)->(P (c [+X*] p) (d [+X*] q))) ->
   (p,q:Cpoly_cring)(P p q).
\end{verbatim}
% file "CPolynomials.v", line 1687-1691 *)
\index{cpoly_double_sym_ind@\verb/cpoly_double_sym_ind/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_double_sym_ind : (P:Cpoly_cring->Cpoly_cring->Prop)
   (Symmetric P) ->
   ((p:Cpoly_cring)(P p Zero)) ->
   ((p,q:Cpoly_cring)(c,d:CR)(P p q)->(P (c [+X*] p) (d [+X*] q))) ->
   (p,q:Cpoly_cring)(P p q).
\end{verbatim}
% file "CPolynomials.v", line 1697-1701 *)
\index{poly_double_comp_ind@\verb/poly_double_comp_ind/, \emph{lemma}}
\begin{verbatim}
Lemma poly_double_comp_ind : (P : Cpoly_cring -> Cpoly_cring -> Prop)
 ((p1,p2,q1,q2:Cpoly_cring)((p1[=]p2)->(q1[=]q2)->(P p1 q1)->(P p2 q2))) ->
 (P Zero Zero) ->
 ((p,q:Cpoly_cring)(c,d:CR)(P p q)->(P (c [+X*] p) (d [+X*] q))) ->
 (p,q:Cpoly_cring)(P p q).
\end{verbatim}
% file "CPolynomials.v", line 1707-1714 *)
\index{poly_triple_comp_ind@\verb/poly_triple_comp_ind/, \emph{lemma}}
\begin{verbatim}
Lemma poly_triple_comp_ind :
 (P : Cpoly_cring -> Cpoly_cring -> Cpoly_cring -> Prop)
 ((p1,p2,q1,q2,r1,r2:Cpoly_cring)((p1[=]p2)->(q1[=]q2)->(r1[=]r2)->
                    (P p1 q1 r1)->(P p2 q2 r2))) ->
 (P Zero Zero Zero) ->
 ((p,q,r:Cpoly_cring)(c,d,e:CR)(P p q r)->
         (P (c [+X*] p) (d [+X*] q) (e [+X*] r))) ->
 (p,q,r:Cpoly_cring)(P p q r).
\end{verbatim}
% file "CPolynomials.v", line 1729-1734 *)
\index{cpoly_apply@\verb/cpoly_apply/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint cpoly_apply [p:Cpoly_cring] : CR -> CR := [x:CR]
  Cases p of
    cpoly_zero => Zero
  | (cpoly_linear c p1) =>
      (c [+](x [*] (cpoly_apply p1 x)))
  end.
\end{verbatim}
% file "CPolynomials.v", line 1738 *)
\index{cpoly_apply_strext@\verb/cpoly_apply_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_apply_strext : (bin_fun_strong_ext ??? cpoly_apply).
\end{verbatim}
% file "CPolynomials.v", line 1790 *)
\index{cpoly_apply_wd@\verb/cpoly_apply_wd/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_apply_wd : (bin_fun_well_def ??? cpoly_apply).
\end{verbatim}
% file "CPolynomials.v", line 1797-1798 *)
\index{cpoly_apply_fun@\verb/cpoly_apply_fun/, \emph{definition}}
\begin{verbatim}
Definition cpoly_apply_fun :=
  (Build_CSetoid_bin_fun ???? cpoly_apply_wd cpoly_apply_strext).
\end{verbatim}
% file "CPolynomials.v", line 1805-1809 *)
\begin{notation}
\verb!cpoly_apply_fun! is denoted infix by {\tt !}.
The first argument is left implicit.
In the names of lemmas, we write \verb!apply!.
\end{notation}
% file "CPolynomials.v", line 1819-1823 *)
\subsection{Basic properties of polynomials}
\begin{convention}
Let \verb!R! be a ring and write \verb!RX! for the ring of polynomials
over \verb!R!.
\end{convention}
% file "CPolynomials.v", line 1832 *)
\subsubsection{Constant and identity}
% file "CPolynomials.v", line 1836-1838 *)
\index{csetoid_fun_wd_unfolded@\verb/csetoid_fun_wd_unfolded/, \emph{lemma}}
\begin{verbatim}
(* BELONGS IN CSETOIDS ! *)
Lemma csetoid_fun_wd_unfolded : (S1,S2:CSetoid)(f:(CSetoid_fun S1 S2))
                           (x,x':S1)(x[=]x')->(f x)[=](f x').
\end{verbatim}
% file "CPolynomials.v", line 1846-1849 *)
\index{csetoid_bin_fun_wd_unfolded@\verb/csetoid_bin_fun_wd_unfolded/, \emph{lemma}}
\begin{verbatim}
(* BELONGS IN CSETOIDS ! *)
Lemma csetoid_bin_fun_wd_unfolded :
       (S1,S2,S3:CSetoid)(f:(CSetoid_bin_fun S1 S2 S3))
               (x,x':S1;y,y':S2)(x[=]x')->(y[=]y')->(f x y)[=](f x' y').
\end{verbatim}
% file "CPolynomials.v", line 1858 *)
\index{cpoly_X_@\verb/cpoly_X_/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_X_ : (_X_ [=] ((Zero::RX) [+X*] One)).
\end{verbatim}
% file "CPolynomials.v", line 1864 *)
\index{cpoly_C_@\verb/cpoly_C_/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_C_ : (c:RX)((_C_ c) [=] (c [+X*] Zero)).
\end{verbatim}
% file "CPolynomials.v", line 1872 *)
\index{cpoly_const_eq@\verb/cpoly_const_eq/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_const_eq : (c,d:R)(c[=]d)->(_C_ c)[=](_C_ d).
\end{verbatim}
% file "CPolynomials.v", line 1879 *)
\index{_c_zero@\verb/_c_zero/, \emph{lemma}}
\begin{verbatim}
Lemma _c_zero : Zero [=] (_C_ Zero::R).
\end{verbatim}
% file "CPolynomials.v", line 1886 *)
\index{_c_one@\verb/_c_one/, \emph{lemma}}
\begin{verbatim}
Lemma _c_one : One [=] (_C_ One::R).
\end{verbatim}
% file "CPolynomials.v", line 1892 *)
\index{_c_mult@\verb/_c_mult/, \emph{lemma}}
\begin{verbatim}
Lemma _c_mult : (a,b:R)((_C_ a[*]b) [=] (_C_ a)[*](_C_ b)).
\end{verbatim}
% file "CPolynomials.v", line 1898-1899 *)
\index{cpoly_lin@\verb/cpoly_lin/, \emph{lemma}}
\begin{verbatim}
Lemma cpoly_lin : (p:RX)(c:R)
                  (c [+X*] p) [=] ((_C_ c) [+] (_X_ [*] p)).
\end{verbatim}
% file "CPolynomials.v", line 1936-1938 *)
\index{poly_linear@\verb/poly_linear/, \emph{lemma}}
\begin{verbatim}
(* SUPERFLUOUS *)
Lemma poly_linear : (c:R)(f:RX)
  ((cpoly_linear ? c f) [=] _X_[*]f[+](_C_ c)).
\end{verbatim}
% file "CPolynomials.v", line 1946 *)
\index{poly_c_apzero@\verb/poly_c_apzero/, \emph{lemma}}
\begin{verbatim}
Lemma poly_c_apzero : (a:R)((_C_ a) [#] Zero) -> (a [#] Zero).
\end{verbatim}
% file "CPolynomials.v", line 1957-1958 *)
\index{_c_mult_lin@\verb/_c_mult_lin/, \emph{lemma}}
\begin{verbatim}
Lemma _c_mult_lin : (p:RX)(c,d:R)
                      (_C_ c) [*] (d [+X*] p) [=] c[*]d [+X*] ((_C_ c) [*] p).
\end{verbatim}
% file "CPolynomials.v", line 1972-1974 *)
\index{lin_mult@\verb/lin_mult/, \emph{lemma}}
\begin{verbatim}
(* SUPERFLUOUS ? *)
Lemma lin_mult : (p,q:RX)(c:R)
 ((c [+X*] p) [*] q) [=] (_C_ c) [*] q [+] _X_ [*] (p [*] q).
\end{verbatim}
% file "CPolynomials.v", line 1985 *)
\subsubsection{Application}
% file "CPolynomials.v", line 1989-1990 *)
\index{poly_eq_zero@\verb/poly_eq_zero/, \emph{lemma}}
\begin{verbatim}
(* !!! SUPERFLUOUS *)
Lemma poly_eq_zero :(p:RX)(p[=](cpoly_zero R)) -> (x:R)(p!x [=] Zero).
\end{verbatim}
% file "CPolynomials.v", line 1999 *)
\index{apply_wd@\verb/apply_wd/, \emph{lemma}}
\begin{verbatim}
Lemma apply_wd : (p,p':RX)(x,x':R)(p [=] p')->(x [=] x')->(p!x [=] p'!x').
\end{verbatim}
% file "CPolynomials.v", line 2006 *)
\index{cpolyap_pres_eq@\verb/cpolyap_pres_eq/, \emph{lemma}}
\begin{verbatim}
Lemma cpolyap_pres_eq :(f:RX;x,y:R)(x[=]y)->(f!x)[=](f!y).
\end{verbatim}
% file "CPolynomials.v", line 2013 *)
\index{cpolyap_strext@\verb/cpolyap_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cpolyap_strext :(f:RX;x,y:R)((f!x)[#](f!y))->(x[#]y).
\end{verbatim}
% file "CPolynomials.v", line 2022-2023 *)
\index{cpoly_csetoid_op@\verb/cpoly_csetoid_op/, \emph{definition}}
\begin{verbatim}
Definition cpoly_csetoid_op : RX -> (CSetoid_un_op R) :=
[f:RX](Build_CSetoid_fun ??[x:R](f!x) (cpolyap_pres_eq f)(cpolyap_strext f)).
\end{verbatim}
% file "CPolynomials.v", line 2027 *)
\index{_c_apply@\verb/_c_apply/, \emph{lemma}}
\begin{verbatim}
Lemma _c_apply : (c,x:R)((_C_ c)!x [=] c).
\end{verbatim}
% file "CPolynomials.v", line 2036 *)
\index{_x_apply@\verb/_x_apply/, \emph{lemma}}
\begin{verbatim}
Lemma _x_apply : (x:R)(_X_!x [=] x).
\end{verbatim}
% file "CPolynomials.v", line 2047 *)
\index{plus_apply@\verb/plus_apply/, \emph{lemma}}
\begin{verbatim}
Lemma plus_apply : (p,q:RX)(x:R)((p [+] q)!x [=] p!x [+] q!x).
\end{verbatim}
% file "CPolynomials.v", line 2072 *)
\index{min_apply@\verb/min_apply/, \emph{lemma}}
\begin{verbatim}
Lemma min_apply : (p:RX)(x:R)(([--]p)!x [=] [--](p!x)).
\end{verbatim}
% file "CPolynomials.v", line 2091 *)
\index{minus_apply@\verb/minus_apply/, \emph{lemma}}
\begin{verbatim}
Lemma minus_apply : (p,q:RX)(x:R)((p [-] q)!x [=] p!x [-] q!x).
\end{verbatim}
% file "CPolynomials.v", line 2101 *)
\index{_c_mult_apply@\verb/_c_mult_apply/, \emph{lemma}}
\begin{verbatim}
Lemma _c_mult_apply : (q:RX)(c,x:R)(((_C_ c) [*] q)!x [=] c [*] q!x).
\end{verbatim}
% file "CPolynomials.v", line 2131 *)
\index{mult_apply@\verb/mult_apply/, \emph{lemma}}
\begin{verbatim}
Lemma mult_apply : (p,q:RX)(x:R)((p [*] q)!x [=] p!x [*] q!x).
\end{verbatim}
% file "CPolynomials.v", line 2155 *)
\index{one_apply@\verb/one_apply/, \emph{lemma}}
\begin{verbatim}
Lemma one_apply : (x:R)(One!x [=] One).
\end{verbatim}
% file "CPolynomials.v", line 2165 *)
\index{nexp_apply@\verb/nexp_apply/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_apply : (p:RX)(n:nat)(x:R)((p[^]n)!x [=] (p!x)[^]n).
\end{verbatim}
% file "CPolynomials.v", line 2179-2181 *)
\index{poly_min_apply@\verb/poly_min_apply/, \emph{lemma}}
\begin{verbatim}
(* SUPERFLUOUS *)
Lemma poly_min_apply :
  (p:RX)(x:R)((cpoly_min ? p)!x [=] [--](p!x)).
\end{verbatim}
% file "CPolynomials.v", line 2187-2188 *)
\index{sum0_cpoly_ap@\verb/sum0_cpoly_ap/, \emph{lemma}}
\begin{verbatim}
Lemma sum0_cpoly_ap : (f:nat->RX)(a:R)(k:nat)
  ((Sum0 k f)!a [=] (Sum0 k [i:nat](f i)!a)).
\end{verbatim}
% file "CPolynomials.v", line 2202-2203 *)
\index{sum_cpoly_ap@\verb/sum_cpoly_ap/, \emph{lemma}}
\begin{verbatim}
Lemma sum_cpoly_ap : (f:nat->RX)(a:R)(k,l:nat)
  ((Sum k l f)!a [=] (Sum k l [i:nat](f i)!a)).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 6-10 *)
\section{Polynomials: NthCoeff}
\begin{convention}
Let \verb!R! be a ring and write \verb!RX! for the ring of polynomials
over \verb!R!.
\end{convention}
% file "CPoly_NthCoeff.v", line 20-23 *)
The $n$-th coefficient of a polynomial. The default value is \verb!Zero::CR!
e.g.\ if the $n$ is higher than the length. For the polynomial
$a_0 +a_1 X +a_2 X^2 + \cdots + a_n X^n$, the $0$-th coefficient is $a_0$,
the $1$-th is $a_1$ etcetera.
% file "CPoly_NthCoeff.v", line 26-34 *)
\index{nth_coeff@\verb/nth_coeff/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint nth_coeff [n:nat; p:RX] : R :=
  Cases p of
    cpoly_zero => Zero
  | (cpoly_linear c q) =>
      Cases n of
        O => c
      | (S m) => (nth_coeff m q)
      end
  end.
\end{verbatim}
% file "CPoly_NthCoeff.v", line 38-39 *)
\index{Nth_coeff_strext@\verb/Nth_coeff_strext/, \emph{lemma}}
\begin{verbatim}
Lemma Nth_coeff_strext : (n:nat)(p,p':RX)
               ((nth_coeff n p)[#](nth_coeff n p')) -> p[#]p'.
\end{verbatim}
% file "CPoly_NthCoeff.v", line 79-80 *)
\index{Nth_coeff_wd@\verb/Nth_coeff_wd/, \emph{lemma}}
\begin{verbatim}
Lemma Nth_coeff_wd : (n:nat)(p,p':RX)
  (p [=] p') -> ((nth_coeff n p) [=] (nth_coeff n p')).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 94-95 *)
\index{nth_coeff_fun@\verb/nth_coeff_fun/, \emph{definition}}
\begin{verbatim}
Definition nth_coeff_fun[n:nat] :=
  (Build_CSetoid_fun ??? (Nth_coeff_wd n) (Nth_coeff_strext n)).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 99-109 *)
\begin{shortcoming}
We would like to use \verb!nth_coeff_fun n! all the time.
However, Coq's coercion mechanism doesn't support this properly:
the term
\verb!(nth_coeff_fun n p)! won't get parsed, and has to be written as
\verb!((nth_coeff_fun n) p)! instead.

So, in the names of lemmas, we write \verb!(nth_coeff n p)!,
which always (e.g.\ in proofs) can be converted
to \verb!((nth_coeff_fun n) p)!.
\end{shortcoming}
% file "CPoly_NthCoeff.v", line 113-114 *)
\index{nonConst@\verb/nonConst/, \emph{definition}}
\begin{verbatim}
Definition nonConst [p:RX]: Prop :=
   (EX n | (lt O n)/\((nth_coeff n p) [#] Zero)).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 118-143 *)
\index{nth_coeff_ok@\verb/nth_coeff_ok/, \emph{fixpoint}}
\index{in_coeff@\verb/in_coeff/, \emph{fixpoint}}
\index{nth_coeff_S@\verb/nth_coeff_S/, \emph{lemma}}
\begin{verbatim}
(* Following probably NOT needed *)
(* These functions are NOT extensional, that is *)
(* they are not SETOID functions *)

Fixpoint nth_coeff_ok [n:nat; p:RX] : bool :=
  Cases n p of
     O cpoly_zero => false
  |  O (cpoly_linear c q) => true
  | (S m) cpoly_zero => false
  | (S m) (cpoly_linear c q) => (nth_coeff_ok m q)
  end.

(* The in_coeff predicate*)
Fixpoint in_coeff  [c:R;p:RX] : Prop :=
      Cases p of
	  cpoly_zero => False
	| (cpoly_linear d q) => (c [=] d) \/ (in_coeff c q)
      end.
(* cpoly_zero case should be (c [=] Zero) to be extensional *)


Lemma nth_coeff_S :
 (m:nat)(p:RX)(c:R)(in_coeff (nth_coeff m p) p)
   ->(in_coeff (nth_coeff (S m) (c [+X*] p)) (c [+X*] p)).
Simpl; Auto.
Qed.
\end{verbatim}
% file "CPoly_NthCoeff.v", line 160 *)
\index{Nth_coeff_zero@\verb/Nth_coeff_zero/, \emph{lemma}}
\begin{verbatim}
Lemma Nth_coeff_zero : (n:nat)(Nth_coeff n Zero::RX)[=]Zero.
\end{verbatim}
% file "CPoly_NthCoeff.v", line 168 *)
\index{coeff_O_lin@\verb/coeff_O_lin/, \emph{lemma}}
\begin{verbatim}
Lemma coeff_O_lin : (p:RX)(c:R)(Nth_coeff (0) (c[+X*]p)) [=]c.
\end{verbatim}
% file "CPoly_NthCoeff.v", line 176-177 *)
\index{coeff_Sm_lin@\verb/coeff_Sm_lin/, \emph{lemma}}
\begin{verbatim}
Lemma coeff_Sm_lin : (p:RX)(c:R)(m:nat)
                     (Nth_coeff (S m) (c[+X*]p)) [=] (Nth_coeff m p).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 185 *)
\index{coeff_O_c_@\verb/coeff_O_c_/, \emph{lemma}}
\begin{verbatim}
Lemma coeff_O_c_ : (c:R)(Nth_coeff (0) (_C_ c))[=]c.
\end{verbatim}
% file "CPoly_NthCoeff.v", line 193 *)
\index{coeff_O_x_mult@\verb/coeff_O_x_mult/, \emph{lemma}}
\begin{verbatim}
Lemma coeff_O_x_mult : (p:RX)(Nth_coeff (0) (_X_ [*] p)) [=] Zero.
\end{verbatim}
% file "CPoly_NthCoeff.v", line 204-205 *)
\index{coeff_Sm_x_mult@\verb/coeff_Sm_x_mult/, \emph{lemma}}
\begin{verbatim}
Lemma coeff_Sm_x_mult : (p:RX)(m:nat)
             (Nth_coeff (S m) (_X_ [*] p)) [=] (Nth_coeff m p).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 216-217 *)
\index{coeff_Sm_mult_x_@\verb/coeff_Sm_mult_x_/, \emph{lemma}}
\begin{verbatim}
Lemma coeff_Sm_mult_x_ : (p:RX)(m:nat)
             (Nth_coeff (S m) (p [*] _X_)) [=] (Nth_coeff m p).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 228-229 *)
\index{Nth_coeff_ap_zero_imp@\verb/Nth_coeff_ap_zero_imp/, \emph{lemma}}
\begin{verbatim}
Lemma Nth_coeff_ap_zero_imp : (p:RX)(n:nat)
                             ((Nth_coeff n p) [#] Zero) -> (p [#] Zero).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 239-240 *)
\index{Nth_coeff_plus@\verb/Nth_coeff_plus/, \emph{lemma}}
\begin{verbatim}
Lemma Nth_coeff_plus : (p,q:RX)(n:nat)
  (Nth_coeff n (p[+]q)) [=] (Nth_coeff n p)[+](Nth_coeff n q).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 264-265 *)
\index{Nth_coeff_min@\verb/Nth_coeff_min/, \emph{lemma}}
\begin{verbatim}
Lemma Nth_coeff_min : (p:RX)(n:nat)
  (Nth_coeff n ([--]p)) [=] [--](Nth_coeff n p).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 284-285 *)
\index{Nth_coeff_c_mult_p@\verb/Nth_coeff_c_mult_p/, \emph{lemma}}
\begin{verbatim}
Lemma Nth_coeff_c_mult_p : (p:RX)(c:R)(n:nat)
  ((Nth_coeff n (_C_ c)[*]p) [=] c[*](Nth_coeff n p)).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 307-308 *)
\index{Nth_coeff_p_mult_c_@\verb/Nth_coeff_p_mult_c_/, \emph{lemma}}
\begin{verbatim}
Lemma Nth_coeff_p_mult_c_ : (p:RX)(c:R)(n:nat)
  ((Nth_coeff n p[*](_C_ c)) [=] (Nth_coeff n p)[*]c).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 319-321 *)
\index{Nth_coeff_complicated@\verb/Nth_coeff_complicated/, \emph{lemma}}
\begin{verbatim}
Lemma Nth_coeff_complicated : (a,b:R)(p:RX)(n:nat)
  (Nth_coeff (S n) ((_C_ a)[*]_X_[+](_C_ b))[*]p) [=]
    a[*](Nth_coeff n p)[+]b[*](Nth_coeff (S n) p).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 335-336 *)
\index{all_Nth_coeff_eq_imp@\verb/all_Nth_coeff_eq_imp/, \emph{lemma}}
\begin{verbatim}
Lemma all_Nth_coeff_eq_imp : (p,p':RX)
  ((i:nat)((Nth_coeff i p) [=] (Nth_coeff i p'))) -> (p [=] p').
\end{verbatim}
% file "CPoly_NthCoeff.v", line 353 *)
\index{poly_at_zero@\verb/poly_at_zero/, \emph{lemma}}
\begin{verbatim}
Lemma poly_at_zero : (p:RX)(p!Zero [=] (Nth_coeff O p)).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 361-362 *)
\index{nth_coeff_min'@\verb/nth_coeff_min'/, \emph{lemma}}
\begin{verbatim}
Lemma nth_coeff_min' :
  (p:(cpoly R))(i:nat)(Nth_coeff i (cpoly_min ? p)) [=] [--](Nth_coeff i p).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 368-369 *)
\index{nth_coeff_minus@\verb/nth_coeff_minus/, \emph{lemma}}
\begin{verbatim}
Lemma nth_coeff_minus :
  (p,q:RX)(i:nat)(Nth_coeff i p[-]q) [=] (Nth_coeff i p)[-](Nth_coeff i q).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 380-382 *)
\index{nth_coeff_sum0@\verb/nth_coeff_sum0/, \emph{lemma}}
\begin{verbatim}
Lemma nth_coeff_sum0 :
  (p_:nat->RX)(k,n:nat)
    (Nth_coeff k (Sum0 n p_)) [=] (Sum0 n [i:nat](Nth_coeff k (p_ i))).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 392-394 *)
\index{nth_coeff_sum@\verb/nth_coeff_sum/, \emph{lemma}}
\begin{verbatim}
Lemma nth_coeff_sum :
  (p_:nat->RX)(k,m,n:nat)
    (Nth_coeff k (Sum m n p_)) [=] (Sum m n [i:nat](Nth_coeff k (p_ i))).
\end{verbatim}
% file "CPoly_NthCoeff.v", line 402-403 *)
\index{nth_coeff_nexp_eq@\verb/nth_coeff_nexp_eq/, \emph{lemma}}
\begin{verbatim}
Lemma nth_coeff_nexp_eq :
   (i:nat)(Nth_coeff i (_X_ [^]i)) [=] One::R.
\end{verbatim}
% file "CPoly_NthCoeff.v", line 412-413 *)
\index{nth_coeff_nexp_neq@\verb/nth_coeff_nexp_neq/, \emph{lemma}}
\begin{verbatim}
Lemma nth_coeff_nexp_neq :
   (i,j:nat)~(i=j)->(Nth_coeff i (_X_[^]j)) [=] Zero::R.
\end{verbatim}
% file "CPoly_NthCoeff.v", line 425-427 *)
\index{nth_coeff_mult@\verb/nth_coeff_mult/, \emph{lemma}}
\begin{verbatim}
Lemma nth_coeff_mult :
  (p,q:RX)(n:nat)(Nth_coeff n p[*]q) [=]
    (Sum (0) n [i:nat](Nth_coeff i p)[*](Nth_coeff (minus n i) q)).
\end{verbatim}
% file "CFields.v", line 52-53 *)
\section{Fields}\label{section:fields}
\subsection{Definition of the notion Field}
% file "CFields.v", line 57-66 *)
\index{is_CField@\verb/is_CField/, \emph{definition}}
\index{CField@\verb/CField/, \emph{record}}
\begin{verbatim}
Definition is_CField
  [R: CRing; cf_rcpcl: (CSetoid_un_op (NonZeros R))] : Prop :=
  (x: (NonZeros R))(Is_inverse (cr_mult R) One
                               (NZinj x) (NZinj (cf_rcpcl x))).

Record CField : Type :=
  { cf_crr   :> CRing;
    cf_rcpcl :  (CSetoid_un_op (NonZeros cf_crr));
    cf_proof :  (is_CField cf_crr cf_rcpcl)
  }.
\end{verbatim}
% file "CFields.v", line 71 *)
\index{f_rcpcl@\verb/f_rcpcl/, \emph{definition}}
\begin{verbatim}
Definition f_rcpcl [F:CField; x:(NonZeros F)] : F := (NZinj ((cf_rcpcl ?) x)).
\end{verbatim}
% file "CFields.v", line 78 *)
\verb!cf_div! is the division in a field.
% file "CFields.v", line 81 *)
\index{cf_div@\verb/cf_div/, \emph{definition}}
\begin{verbatim}
Definition cf_div [F:CField; x: F; y: (NonZeros F)]: F := (x [*] (F_rcpcl y)).
\end{verbatim}
% file "CFields.v", line 86-90 *)
\begin{notation}
The division \verb!cf_div x y! is denoted infix by \verb!x [/] y!.
\end{notation}
Recall that \verb!x [//] p! is of type \verb!NonZeros F! if \verb!x : F!
and \verb!p : x [#] Zero! (see Notation~\ref{notation:nzpro}).
% file "CFields.v", line 98-130 *)
\begin{numconvention}\label{convention:div-form}
\begin{enumerate}
\item
 We do not use \verb!NonZeros!,
 but write the condition \verb![#]Zero! separately.
\item
 In each lemma, we use only variables for proof objects, and these variables
 are universally quantified.

 E.g. the informal lemma
\begin{verbatim}
(1/x).(1/y) = 1/(x.y) for all x and y
\end{verbatim}
   is formalized as
\begin{verbatim}
(x,y:F)(H1:x#0)(H2:y#0)(H3:(x.y)#0) (1/x//H1).(1/y//H2) = 1/(x.y)//H3
\end{verbatim}
and {\em not} as
\begin{verbatim}
(x,y:F)(H1:x#0)(H2:y#0)(1/x//H1).(1/y//H2) = 1/(x.y)//(prod_nz x y H1 H2)
\end{verbatim}

   We have made this choice to make it easier to apply lemmas; this can be
   quite awkward if we would use the last formulation.

\item
   So every division occurring in the formulation of a lemma is of the form
   \verb!e[/]e'[//]H! where \verb!H! is a variable.
   Only exceptions: we may write \verb!e[/](Snring n)! and
   \verb!e[/]TwoNZ!,  \verb!e[/]ThreeNZ! and so on.
   (Constants like \verb!TwoNZ! will be defined later on.)
\end{enumerate}
\end{numconvention}
% file "CFields.v", line 134-137 *)
\subsection{Field axioms}
\begin{convention}
Let \verb!F! be a field.
\end{convention}
% file "CFields.v", line 143 *)
\index{CField_is_CField@\verb/CField_is_CField/, \emph{lemma}}
\begin{verbatim}
Lemma CField_is_CField : (is_CField F (cf_rcpcl F)).
\end{verbatim}
% file "CFields.v", line 150-152 *)
\index{rcpcl_is_inverse@\verb/rcpcl_is_inverse/, \emph{lemma}}
\begin{verbatim}
Lemma rcpcl_is_inverse :
 (x: (NonZeros F))(Is_inverse (cr_mult F) One
                               (NZinj x) (NZinj ((cf_rcpcl F) x))).
\end{verbatim}
% file "CFields.v", line 163-166 *)
\subsection{Field basics}
\begin{convention}
Let \verb!F! be a field.
\end{convention}
% file "CFields.v", line 172-173 *)
\index{rcpcl_is_inverse_unfolded@\verb/rcpcl_is_inverse_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma rcpcl_is_inverse_unfolded :
              (x: (NonZeros F))(NZinj x) [*] (NZinj ((cf_rcpcl F) x)) [=] One.
\end{verbatim}
% file "CFields.v", line 179 *)
\index{field_mult_inv@\verb/field_mult_inv/, \emph{lemma}}
\begin{verbatim}
Lemma field_mult_inv: (x:F)(H:x[#]Zero)(x [*] (F_rcpcl (x[//]H))) [=] One.
\end{verbatim}
% file "CFields.v", line 191 *)
\index{field_mult_inv_op@\verb/field_mult_inv_op/, \emph{lemma}}
\begin{verbatim}
Lemma field_mult_inv_op : (x:F)(H:x[#]Zero)((F_rcpcl (x[//]H)) [*] x) [=] One.
\end{verbatim}
% file "CFields.v", line 204-207 *)
\subsection{Properties of multiplication}
\begin{convention}
Let \verb!F! be a field.
\end{convention}
% file "CFields.v", line 212-213 *)
\index{mult_resp_ap_zero@\verb/mult_resp_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma mult_resp_ap_zero:
  (x,y:F)(x [#] Zero) -> (y [#] Zero) -> (x[*]y [#] Zero).
\end{verbatim}
% file "CFields.v", line 228-229 *)
\index{mult_lft_resp_ap@\verb/mult_lft_resp_ap/, \emph{lemma}}
\begin{verbatim}
Lemma mult_lft_resp_ap :
   (x,y,z:F)(x [#] y) -> (z [#] Zero) -> (z [*] x) [#] (z [*] y).
\end{verbatim}
% file "CFields.v", line 241-242 *)
\index{mult_rht_resp_ap@\verb/mult_rht_resp_ap/, \emph{lemma}}
\begin{verbatim}
Lemma mult_rht_resp_ap :
   (x,y,z:F)(x [#] y) -> (z [#] Zero) -> (x [*] z) [#] (y [*] z).
\end{verbatim}
% file "CFields.v", line 252-253 *)
\index{mult_resp_neq_zero@\verb/mult_resp_neq_zero/, \emph{lemma}}
\begin{verbatim}
Lemma mult_resp_neq_zero :
   (x,y:F)(x [~=] Zero)->(y [~=] Zero)->((x [*] y) [~=] Zero).
\end{verbatim}
% file "CFields.v", line 281-282 *)
\index{mult_resp_neq@\verb/mult_resp_neq/, \emph{lemma}}
\begin{verbatim}
Lemma mult_resp_neq :
   (x,y,z:F)(x [~=] y)->(z [~=] Zero)->((x [*] z) [~=] (y [*] z)).
\end{verbatim}
% file "CFields.v", line 295-296 *)
\index{mult_eq_zero@\verb/mult_eq_zero/, \emph{lemma}}
\begin{verbatim}
Lemma mult_eq_zero :
   (x,y:F)(x [~=] Zero)->((x [*] y) [=] Zero)->(y [=] Zero).
\end{verbatim}
% file "CFields.v", line 316 *)
\index{mult_cancel_lft@\verb/mult_cancel_lft/, \emph{lemma}}
\begin{verbatim}
Lemma mult_cancel_lft : (x,y,z:F)(z [#] Zero)->(z[*]x [=] z[*]y)->(x [=] y).
\end{verbatim}
% file "CFields.v", line 330 *)
\index{mult_cancel_rht@\verb/mult_cancel_rht/, \emph{lemma}}
\begin{verbatim}
Lemma mult_cancel_rht : (x,y,z:F)(z [#] Zero)->(x[*]z [=] y[*]z)->(x [=] y).
\end{verbatim}
% file "CFields.v", line 343 *)
The multiplicative group of nonzeros of a field.
% file "CFields.v", line 346 *)
The multiplicative monoid of NonZeros.
% file "CFields.v", line 349-351 *)
\index{NonZeroMonoid@\verb/NonZeroMonoid/, \emph{definition}}
\begin{verbatim}
Definition NonZeroMonoid : CMonoid :=
  (Build_SubCMonoid (Build_multCMonoid F)
                    (nonZeroP F) (one_ap_zero F) mult_resp_ap_zero).
\end{verbatim}
% file "CFields.v", line 355 *)
\index{fmg_cs_inv@\verb/fmg_cs_inv/, \emph{lemma}}
\begin{verbatim}
Lemma fmg_cs_inv: (CSetoid_un_op NonZeroMonoid).
\end{verbatim}
% file "CFields.v", line 361-362 *)
\index{plus_nonzeros_eq_mult_dom@\verb/plus_nonzeros_eq_mult_dom/, \emph{lemma}}
\begin{verbatim}
Lemma plus_nonzeros_eq_mult_dom : (x,y:NonZeroMonoid)
            (NZinj (x [+] y)) [=] ((NZinj x) [*] (NZinj y)).
\end{verbatim}
% file "CFields.v", line 374 *)
\index{cfield_to_mult_cgroup@\verb/cfield_to_mult_cgroup/, \emph{lemma}}
\begin{verbatim}
Lemma cfield_to_mult_cgroup : CGroup.
\end{verbatim}
% file "CFields.v", line 387-388 *)
\index{square_eq_aux@\verb/square_eq_aux/, \emph{lemma}}
\begin{verbatim}
Lemma square_eq_aux :
      (x,a:F)(x[^](2) [=] a[^](2))-> (x[+]a)[*](x[-]a) [=] Zero.
\end{verbatim}
% file "CFields.v", line 397-398 *)
\index{square_eq_weak@\verb/square_eq_weak/, \emph{lemma}}
\begin{verbatim}
Lemma square_eq_weak :
      (x,a:F)(x[^](2) [=] a[^](2))-> ~((x [#] a) /\ (x [#] [--]a)).
\end{verbatim}
% file "CFields.v", line 414-416 *)
\index{conditional_square_eq@\verb/conditional_square_eq/, \emph{lemma}}
\begin{verbatim}
Lemma conditional_square_eq :
   (x,a:F)(Two::F [#] Zero)->(a [#] Zero)->
   (x[^](2) [=] a[^](2))->((x [=] a) \/ (x [=] [--]a)).
\end{verbatim}
% file "CFields.v", line 453-456 *)
\subsection{Properties of reciprocal}
\begin{convention}
Let \verb!F! be a field.
\end{convention}
% file "CFields.v", line 461 *)
\index{inv_one@\verb/inv_one/, \emph{lemma}}
\begin{verbatim}
Lemma inv_one : (F_rcpcl (One[//](ring_non_triv F))) [=] One.
\end{verbatim}
% file "CFields.v", line 469-470 *)
\index{cf_rcpcl_wd@\verb/cf_rcpcl_wd/, \emph{lemma}}
\begin{verbatim}
Lemma cf_rcpcl_wd : (F:CField)(x,y:(NonZeros F)) (x [=] y) ->
                                        ((cf_rcpcl F) x) [=] ((cf_rcpcl F) y).
\end{verbatim}
% file "CFields.v", line 478-479 *)
\index{F_rcpcl_wd@\verb/F_rcpcl_wd/, \emph{lemma}}
\begin{verbatim}
Lemma F_rcpcl_wd : (F:CField)(x,y:(NonZeros F)) (x [=] y) ->
                                                (F_rcpcl x) [=] (F_rcpcl y).
\end{verbatim}
% file "CFields.v", line 489-490 *)
\index{F_rcpcl_mult@\verb/F_rcpcl_mult/, \emph{lemma}}
\begin{verbatim}
Lemma F_rcpcl_mult : (y,z:F)(nzy:y [#] Zero)(nzz:z[#]Zero)(nzyz:y[*]z[#]Zero)
 (F_rcpcl ((y[*]z) [//]nzyz)) [=] (F_rcpcl y [//] nzy) [*](F_rcpcl z [//] nzz).
\end{verbatim}
% file "CFields.v", line 505-506 *)
\index{F_rcpcl_resp_ap_zero@\verb/F_rcpcl_resp_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma F_rcpcl_resp_ap_zero : (y:F)(nzy:(y [#] Zero))
                                  ((F_rcpcl (y [//]nzy)) [#] Zero).
\end{verbatim}
% file "CFields.v", line 514-515 *)
\index{F_rcpcl_F_rcpcl@\verb/F_rcpcl_F_rcpcl/, \emph{lemma}}
\begin{verbatim}
Lemma F_rcpcl_F_rcpcl : (x:F)(nzx:x [#] Zero)(nzr:(F_rcpcl x [//] nzx)[#]Zero)
                        (F_rcpcl (F_rcpcl x [//] nzx) [//] nzr) [=] x.
\end{verbatim}
% file "CFields.v", line 529-537 *)
\subsection{Properties of division}
\begin{convention}
Let \verb!F! be a field.
\end{convention}

\begin{nameconvention}
In the names of lemmas, we denote \verb![/]! by \verb!div!, and
\verb!One[/]! by \verb!recip!.
\end{nameconvention}
% file "CFields.v", line 542 *)
\index{div_prop@\verb/div_prop/, \emph{lemma}}
\begin{verbatim}
Lemma div_prop : (F:CField)(x:F)(H:x[#]Zero)(Zero[/]x[//]H [=] Zero).
\end{verbatim}
% file "CFields.v", line 550 *)
\index{div_1@\verb/div_1/, \emph{lemma}}
\begin{verbatim}
Lemma div_1 : (x,y:F)(y_:y [#] Zero)((x[/](y[//]y_))[*]y [=] x).
\end{verbatim}
% file "CFields.v", line 559 *)
\index{div_1'@\verb/div_1'/, \emph{lemma}}
\begin{verbatim}
Lemma div_1' : (x,y:F)(y_:y [#] Zero)(y[*](x[/](y[//]y_)) [=] x).
\end{verbatim}
% file "CFields.v", line 567 *)
\index{div_1''@\verb/div_1''/, \emph{lemma}}
\begin{verbatim}
Lemma div_1'' : (x,y:F)(y_:y [#] Zero)((x[*]y)[/](y[//]y_) [=] x).
\end{verbatim}
% file "CFields.v", line 580 *)
\index{x_div_x@\verb/x_div_x/, \emph{lemma}}
\begin{verbatim}
Lemma x_div_x : (x:F)(x_: x [#] Zero)((x[/](x[//]x_)) [=] One).
\end{verbatim}
% file "CFields.v", line 590 *)
\index{x_div_one@\verb/x_div_one/, \emph{lemma}}
\begin{verbatim}
Lemma x_div_one : (x:F)((x[/](One[//](ring_non_triv (F)))) [=] x).
\end{verbatim}
% file "CFields.v", line 600 *)
The next lemma says \verb!x.(y/z) = (x.y)/z!.
% file "CFields.v", line 603-604 *)
\index{x_mult_y_div_z@\verb/x_mult_y_div_z/, \emph{lemma}}
\begin{verbatim}
Lemma x_mult_y_div_z : (x,y,z:F)(z_: z [#] Zero)
                       ((x[*](y[/](z[//]z_))) [=] ((x[*]y)[/](z[//]z_))).
\end{verbatim}
% file "CFields.v", line 615-616 *)
\index{div_wd@\verb/div_wd/, \emph{lemma}}
\begin{verbatim}
Lemma div_wd : (x0,x1,y0,y1:F)(nzy0:y0 [#] Zero)(nzy1:y1[#]Zero)
  (x0 [=] x1)->(y0 [=] y1)->(x0[/]y0[//]nzy0 [=] x1[/]y1[//]nzy1).
\end{verbatim}
% file "CFields.v", line 631 *)
The next lemma says \verb!(x/y)/z = x/(y.z)!
% file "CFields.v", line 634-636 *)
\index{div_div@\verb/div_div/, \emph{lemma}}
\begin{verbatim}
Lemma div_div : (x,y,z:F)(nzy:y [#] Zero)(nzz:z[#]Zero)
  (nzyz:y[*]z[#]Zero)
    (((x[/]y[//]nzy)[/]z[//]nzz) [=] (x[/](y[*]z)[//]nzyz)).
\end{verbatim}
% file "CFields.v", line 648-649 *)
\index{div_resp_ap_zero_rev@\verb/div_resp_ap_zero_rev/, \emph{lemma}}
\begin{verbatim}
Lemma div_resp_ap_zero_rev : (x,y:F)(nzy:(y [#] Zero))(x[#]Zero) ->
                                  (x [/] y [//]nzy [#] Zero).
\end{verbatim}
% file "CFields.v", line 660-661 *)
\index{div_resp_ap_zero@\verb/div_resp_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma div_resp_ap_zero:
(x,y:F)(nzy:(y [#] Zero))(x [/] y [//]nzy [#] Zero) -> (x[#]Zero).
\end{verbatim}
% file "CFields.v", line 668 *)
The next lemma says \verb!x/(y/z) = (x.z)/y!
% file "CFields.v", line 671-673 *)
\index{div_div2@\verb/div_div2/, \emph{lemma}}
\begin{verbatim}
Lemma div_div2 : (x,y,z:F)
  (nzy:y [#] Zero)(nzz:z[#]Zero)(nzyz:(y[/]z[//]nzz)[#]Zero)
  ((x[/](y[/](z[//]nzz)) [//]nzyz) [=] ((x[*]z)[/](y[//]nzy))).
\end{verbatim}
% file "CFields.v", line 690 *)
The next lemma says \verb!(x.p)/(y.q) = (x/y).(p/q)!
% file "CFields.v", line 693-695 *)
\index{mult_of_divs@\verb/mult_of_divs/, \emph{lemma}}
\begin{verbatim}
Lemma mult_of_divs : (x,y,p,q:F)
  (nzy:(y[#]Zero))(nzq:(q[#]Zero))(nzyq:y[*]q[#]Zero)
    ((x[*]p)[/](y[*]q)[//]nzyq [=] (x[/]y[//]nzy)[*](p[/]q[//]nzq)).
\end{verbatim}
% file "CFields.v", line 710-711 *)
\index{div_dist@\verb/div_dist/, \emph{lemma}}
\begin{verbatim}
Lemma div_dist : (x,y,z:F)(nzz:z[#]Zero)
  (x[+]y)[/]z[//]nzz [=] x[/]z[//]nzz[+]y[/]z[//]nzz.
\end{verbatim}
% file "CFields.v", line 719-720 *)
\index{div_semi_sym@\verb/div_semi_sym/, \emph{lemma}}
\begin{verbatim}
Lemma div_semi_sym : (x,y,z:F)(Hy:y[#]Zero)(Hz:z[#]Zero)
                     (x[/]y[//]Hy)[/]z[//]Hz [=] (x[/]z[//]Hz)[/]y[//]Hy.
\end{verbatim}
% file "CFields.v", line 730-731 *)
\index{eq_div@\verb/eq_div/, \emph{lemma}}
\begin{verbatim}
Lemma eq_div : (x,y,u,v:F)(Hy:y[#]Zero)(Hv:v[#]Zero)
               (x[*]v [=] u[*]y) -> (x[/]y[//]Hy [=] u[/]v[//]Hv).
\end{verbatim}
% file "CFields.v", line 745-747 *)
\index{div_strong_ext@\verb/div_strong_ext/, \emph{lemma}}
\begin{verbatim}
Lemma div_strong_ext : (x0,x1,y0,y1:F)(Hy0:y0[#]Zero)(Hy1:y1[#]Zero)
                       (x0[/]y0[//]Hy0 [#] x1[/]y1[//]Hy1) ->
                       (x0[#]x1) \/ (y0[#]y1).
\end{verbatim}
% file "CFields.v", line 776-777 *)
\index{mult_cancel_ap_zero_lft@\verb/mult_cancel_ap_zero_lft/, \emph{lemma}}
\begin{verbatim}
Lemma mult_cancel_ap_zero_lft :
 (x,y:R)(x [*] y [#] Zero) -> x [#] Zero.
\end{verbatim}
% file "CFields.v", line 791-792 *)
\index{mult_cancel_ap_zero_rht@\verb/mult_cancel_ap_zero_rht/, \emph{lemma}}
\begin{verbatim}
Lemma mult_cancel_ap_zero_rht :
 (x,y:R)(x [*] y [#] Zero) -> y [#] Zero.
\end{verbatim}
% file "Reflection.v", line 6 *)
\section{Reflection}
% file "CPoly_Degree.v", line 7-11 *)
\section{Polynomials: Degree}
\begin{convention}
Let \verb!R! be a ring and write \verb!RX! for the ring of polynomials
over \verb!R!.
\end{convention}
% file "CPoly_Degree.v", line 21-25 *)
The length of a polynomial is the number of its coefficients. This is a
syntactical property, as the highest coefficient may be $0$. Note that the
`zero' polynomial \verb!cpoly_zero! has length $0$, a constant
polynomial has length $1$ and so forth. So the length is always $1$ higher
than the `degree' (assuming that the highest coefficient is $\noto 0$)!
% file "CPoly_Degree.v", line 28-32 *)
\index{lth_of_poly@\verb/lth_of_poly/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint lth_of_poly [p: RX] : nat :=
  Cases p of
     	cpoly_zero => O
	| (cpoly_linear d q) => (S(lth_of_poly q))
  end.
\end{verbatim}
% file "CPoly_Degree.v", line 36-48 *)
   When dealing with constructive polynomials, notably
   over the reals or complex numbers, the degree may be unknown, as we can not
   decide whether the highest coeffiecient is $\noto 0$.
   Hence, degree is a {\em relation\/} between polynomials and natural numbers;
   if the degree is unknown for polynomial $p$, degree$(n,p)$ doesn't hold for
   any $n$.
   If we don't know the degree of $p$, we may still know it to be below or
   above a certain number. E.g.\ for the polynomial
   $p_0 +p_1 X +\cdots + p_{n-1} X^{n-1}$,
   if $p_i \noto 0$, we can say that the `degree is
   at least $i$' and if $p_{j+1} = \ldots =p_n =0$ (with $n$ the length of the
   polynomial), we can say that the `degree is
   at most $j$'.
% file "CPoly_Degree.v", line 52-68 *)
\index{degree_le@\verb/degree_le/, \emph{definition}}
\index{degree@\verb/degree/, \emph{definition}}
\index{monic@\verb/monic/, \emph{definition}}
\index{odd_cpoly@\verb/odd_cpoly/, \emph{definition}}
\index{even_cpoly@\verb/even_cpoly/, \emph{definition}}
\index{regular@\verb/regular/, \emph{definition}}
\begin{verbatim}
Definition degree_le : nat -> RX -> Prop :=
[n:nat][p:RX] (m:nat)((lt n m)-> ((Nth_coeff m p) [=] Zero)).

Definition degree : nat -> RX -> Prop :=
[n:nat][p:RX] ((Nth_coeff n p) [#] Zero) /\ (degree_le n p).

Definition monic : nat -> RX -> Prop :=
[n:nat][p:RX] ((Nth_coeff n p) [=] One) /\ (degree_le n p).

Definition odd_cpoly : RX -> Prop :=
[p:RX](EX n | (odd n)/\(degree n p)).

Definition even_cpoly : RX -> Prop :=
[p:RX](EX n | (even n)/\(degree n p)).

Definition regular :RX-> Prop :=
[p:RX](EX n |(degree n p)).
\end{verbatim}
% file "CPoly_Degree.v", line 86-87 *)
\index{Degree_le_wd@\verb/Degree_le_wd/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_le_wd : (p,p':RX)(n:nat)
  (p [=] p')->(Degree_le n p)->(Degree_le n p').
\end{verbatim}
% file "CPoly_Degree.v", line 94-95 *)
\index{Degree_wd@\verb/Degree_wd/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_wd : (p,p':RX)(n:nat)
  (p [=] p')->(Degree n p)->(Degree n p').
\end{verbatim}
% file "CPoly_Degree.v", line 104-105 *)
\index{Monic_wd@\verb/Monic_wd/, \emph{lemma}}
\begin{verbatim}
Lemma Monic_wd : (p,p':RX)(n:nat)
  (p [=] p')->(Monic n p)->(Monic n p').
\end{verbatim}
% file "CPoly_Degree.v", line 114 *)
\index{Degree_imp_Degree_le@\verb/Degree_imp_Degree_le/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_imp_Degree_le : (p:RX)(n:nat)(Degree n p)->(Degree_le n p).
\end{verbatim}
% file "CPoly_Degree.v", line 120 *)
\index{Degree_le_c_@\verb/Degree_le_c_/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_le_c_ : (c:R)(Degree_le O (_C_ c)).
\end{verbatim}
% file "CPoly_Degree.v", line 128 *)
\index{Degree_c_@\verb/Degree_c_/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_c_ : (c:R)(c [#] Zero)->(Degree O (_C_ c)).
\end{verbatim}
% file "CPoly_Degree.v", line 134 *)
\index{Monic_c_one@\verb/Monic_c_one/, \emph{lemma}}
\begin{verbatim}
Lemma Monic_c_one : (Monic O (_C_ One::R)).
\end{verbatim}
% file "CPoly_Degree.v", line 140 *)
\index{Degree_le_x_@\verb/Degree_le_x_/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_le_x_ : (Degree_le (1) _X_::RX).
\end{verbatim}
% file "CPoly_Degree.v", line 149 *)
\index{Degree_x_@\verb/Degree_x_/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_x_ : (Degree (1) _X_::RX).
\end{verbatim}
% file "CPoly_Degree.v", line 155 *)
\index{Monic_x_@\verb/Monic_x_/, \emph{lemma}}
\begin{verbatim}
Lemma Monic_x_ : (Monic (1) _X_::RX).
\end{verbatim}
% file "CPoly_Degree.v", line 161-162 *)
\index{degree_le_mon@\verb/degree_le_mon/, \emph{lemma}}
\begin{verbatim}
Lemma degree_le_mon : (p:RX)(m,n:nat)
  (le m n) -> (Degree_le m p) -> (Degree_le n p).
\end{verbatim}
% file "CPoly_Degree.v", line 168 *)
\index{Degree_le_min@\verb/Degree_le_min/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_le_min : (p:RX)(n:nat)(Degree_le n p)->(Degree_le n [--]p).
\end{verbatim}
% file "CPoly_Degree.v", line 176-177 *)
\index{Degree_le_plus@\verb/Degree_le_plus/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_le_plus : (p,q:RX)(n:nat)
  (Degree_le n p) -> (Degree_le n q) -> (Degree_le n p[+]q).
\end{verbatim}
% file "CPoly_Degree.v", line 185-186 *)
\index{Degree_le_minus@\verb/Degree_le_minus/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_le_minus : (p,q:RX)(n:nat)
  (Degree_le n p) -> (Degree_le n q) -> (Degree_le n p[-]q).
\end{verbatim}
% file "CPoly_Degree.v", line 194-196 *)
\index{sum_degree_le@\verb/sum_degree_le/, \emph{lemma}}
\begin{verbatim}
Lemma sum_degree_le : (f:nat->RX)(n,k,l:nat)(le k (S l)) ->
  ((i:nat)(le k i) -> (le i l) -> (Degree_le n (f i))) ->
    (Degree_le n (Sum k l f)).
\end{verbatim}
% file "CPoly_Degree.v", line 220 *)
\index{Degree_min@\verb/Degree_min/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_min : (p:RX)(n:nat)(Degree n p)->(Degree n [--]p).
\end{verbatim}
% file "CPoly_Degree.v", line 229-230 *)
\index{Degree_plus_rht@\verb/Degree_plus_rht/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_plus_rht : (p,q:RX)(m,n:nat)
             (Degree_le m p)->(Degree n q)->(lt m n)->(Degree n (p [+] q)).
\end{verbatim}
% file "CPoly_Degree.v", line 246-247 *)
\index{Degree_minus_lft@\verb/Degree_minus_lft/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_minus_lft : (p,q:RX)(m,n:nat)
             (Degree_le m p)->(Degree n q)->(lt m n)->(Degree n (q [-] p)).
\end{verbatim}
% file "CPoly_Degree.v", line 257-258 *)
\index{Monic_plus@\verb/Monic_plus/, \emph{lemma}}
\begin{verbatim}
Lemma Monic_plus : (p,q:RX)(m,n:nat)
  (Degree_le m p) -> (Monic n q) -> (lt m n) -> (Monic n p[+]q).
\end{verbatim}
% file "CPoly_Degree.v", line 274-275 *)
\index{Monic_minus@\verb/Monic_minus/, \emph{lemma}}
\begin{verbatim}
Lemma Monic_minus : (p,q:RX)(m,n:nat)
  (Degree_le m p) -> (Monic n q) -> (lt m n) -> (Monic n q[-]p).
\end{verbatim}
% file "CPoly_Degree.v", line 285-286 *)
\index{Degree_le_mult@\verb/Degree_le_mult/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_le_mult : (p,q:RX)(m,n:nat)
             (Degree_le m p)->(Degree_le n q)->(Degree_le (plus m n) p[*]q).
\end{verbatim}
% file "CPoly_Degree.v", line 300-303 *)
\index{Degree_mult_aux@\verb/Degree_mult_aux/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_mult_aux : (p,q:RX)(m,n:nat)
 (Degree_le m p)->(Degree_le n q)->
             (Nth_coeff (plus m n) p[*]q) [=]
               (Nth_coeff m p)[*](Nth_coeff n q).
\end{verbatim}
% file "CPoly_Degree.v", line 341-342 *)
\index{Monic_mult@\verb/Monic_mult/, \emph{lemma}}
\begin{verbatim}
Lemma Monic_mult : (p,q:RX)(m,n:nat)
             (Monic m p)->(Monic n q)->(Monic (plus m n) p[*]q).
\end{verbatim}
% file "CPoly_Degree.v", line 352-353 *)
\index{Degree_le_nexp@\verb/Degree_le_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_le_nexp : (p:RX)(m,n:nat)
             (Degree_le m p)->(Degree_le (mult m n) p[^]n).
\end{verbatim}
% file "CPoly_Degree.v", line 367 *)
\index{Monic_nexp@\verb/Monic_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma Monic_nexp : (p:RX)(m,n:nat)(Monic m p)->(Monic (mult m n) p[^]n).
\end{verbatim}
% file "CPoly_Degree.v", line 381-382 *)
\index{lt_i_Lth_of_poly@\verb/lt_i_Lth_of_poly/, \emph{lemma}}
\begin{verbatim}
Lemma lt_i_Lth_of_poly : (i:nat)(p:RX)
  ((Nth_coeff i p) [#] Zero) -> (lt i (Lth_of_poly p)).
\end{verbatim}
% file "CPoly_Degree.v", line 394-395 *)
\index{poly_degree_lth@\verb/poly_degree_lth/, \emph{lemma}}
\begin{verbatim}
Lemma poly_degree_lth : (p:RX)
  (Degree_le (Lth_of_poly p) p).
\end{verbatim}
% file "CPoly_Degree.v", line 403 *)
\index{poly_ex_degree@\verb/poly_ex_degree/, \emph{lemma}}
\begin{verbatim}
Lemma poly_ex_degree : (p:RX)(EX n | (Degree_le n p)).
\end{verbatim}
% file "CPoly_Degree.v", line 409-410 *)
\index{poly_as_sum''@\verb/poly_as_sum''/, \emph{lemma}}
\begin{verbatim}
Lemma poly_as_sum'' : (p:RX)(n:nat)(Degree_le n p)->
  p [=] (Sum (0) n [i:nat](_C_ (Nth_coeff i p))[*]_X_[^]i).
\end{verbatim}
% file "CPoly_Degree.v", line 438-439 *)
\index{poly_as_sum'@\verb/poly_as_sum'/, \emph{lemma}}
\begin{verbatim}
Lemma poly_as_sum' : (p:RX)
  p [=] (Sum (0) (Lth_of_poly p) [i:nat](_C_ (Nth_coeff i p))[*]_X_[^]i).
\end{verbatim}
% file "CPoly_Degree.v", line 445-446 *)
\index{poly_as_sum@\verb/poly_as_sum/, \emph{lemma}}
\begin{verbatim}
Lemma poly_as_sum : (p:RX)(n:nat)(Degree_le n p)->
  (x:R)(p!x [=] (Sum (0) n [i:nat](Nth_coeff i p)[*]x[^]i)).
\end{verbatim}
% file "CPoly_Degree.v", line 459-460 *)
\index{degree_le_zero@\verb/degree_le_zero/, \emph{lemma}}
\begin{verbatim}
Lemma degree_le_zero : (p:RX)
  (Degree_le (0) p) -> (EX a | p [=] (_C_ a)).
\end{verbatim}
% file "CPoly_Degree.v", line 472-473 *)
\index{Degree_le_1_imp@\verb/Degree_le_1_imp/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_le_1_imp : (p:RX)
  (Degree_le (1) p) -> (EX a | (EX b | p [=] (_C_ a)[*]_X_[+](_C_ b))).
\end{verbatim}
% file "CPoly_Degree.v", line 486-488 *)
\index{degree_le_cpoly_linear@\verb/degree_le_cpoly_linear/, \emph{lemma}}
\begin{verbatim}
Lemma degree_le_cpoly_linear :
  (p:(cpoly R))(c:R)(n:nat)
    (Degree_le (S n) (cpoly_linear ? c p)) -> (Degree_le n p).
\end{verbatim}
% file "CPoly_Degree.v", line 496-498 *)
\index{monic_cpoly_linear@\verb/monic_cpoly_linear/, \emph{lemma}}
\begin{verbatim}
Lemma monic_cpoly_linear :
  (p:(cpoly R))(c:R)(n:nat)
    (Monic (S n) (cpoly_linear ? c p)) -> (Monic n p).
\end{verbatim}
% file "CPoly_Degree.v", line 505-507 *)
\index{monic_one@\verb/monic_one/, \emph{lemma}}
\begin{verbatim}
Lemma monic_one :
  (p:(cpoly R))(c:R)
    (Monic (1) (cpoly_linear ? c p)) -> (x:R)(p!x [=] One).
\end{verbatim}
% file "CPoly_Degree.v", line 519-520 *)
\index{monic_apzero@\verb/monic_apzero/, \emph{lemma}}
\begin{verbatim}
Lemma monic_apzero :
  (p:RX)(n:nat)(Monic n p) -> (p [#] Zero).
\end{verbatim}
% file "CPoly_Degree.v", line 541-542 *)
\index{Degree_mult@\verb/Degree_mult/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_mult : (p,q:FX)(m,n:nat)
             (Degree m p)->(Degree n q)->(Degree (plus m n) p[*]q).
\end{verbatim}
% file "CPoly_Degree.v", line 551 *)
\index{Degree_nexp@\verb/Degree_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_nexp : (p:FX)(m,n:nat)(Degree m p)->(Degree (mult m n) p[^]n).
\end{verbatim}
% file "CPoly_Degree.v", line 565-566 *)
\index{Degree_le_mult_imp@\verb/Degree_le_mult_imp/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_le_mult_imp : (m,n:nat)(p,q:FX)
  (Degree m p) -> (Degree_le (plus m n) p[*]q) -> (Degree_le n q).
\end{verbatim}
% file "CPoly_Degree.v", line 600-601 *)
\index{Degree_mult_imp@\verb/Degree_mult_imp/, \emph{lemma}}
\begin{verbatim}
Lemma Degree_mult_imp : (p,q:FX)(m,n:nat)
  (Degree m p) -> (Degree (plus m n) p[*]q) -> (Degree n q).
\end{verbatim}
% file "COrdFields.v", line 11-12 *)
\section{Ordered Fields}
\subsection{Definition of the notion of ordered field}
% file "COrdFields.v", line 20-23 *)
\index{strictorder@\verb/strictorder/, \emph{record}}
\begin{verbatim}
Record strictorder [A:Set; R: A->A->Prop] : Prop :=
  { so_trans : (Transitive R);
    so_asym  : (antisymmetric R)
  }.
\end{verbatim}
% file "COrdFields.v", line 29-34 *)
\index{is_COrdField@\verb/is_COrdField/, \emph{record}}
\begin{verbatim}
Record is_COrdField [F: CField; less : (CSetoid_relation F)] : Prop :=
 {ax_less_strorder : (strictorder less);
  ax_plus_resp_less: (x,y:F)(less x y) -> (z:F)(less (x[+]z) (y[+]z));
  ax_mult_resp_pos : (x,y:F)(less Zero x)->(less Zero y)->(less Zero (x[*]y));
  ax_less_conf_ap  : (x,y:F)(x [#] y) <-> ((less x y) \/ (less y x))
 }.
\end{verbatim}
% file "COrdFields.v", line 38-42 *)
\index{COrdField@\verb/COrdField/, \emph{record}}
\begin{verbatim}
Record COrdField : Type :=
  {cof_crr   :> CField;
   cof_less  :  (CSetoid_relation cof_crr);
   cof_proof :  (is_COrdField cof_crr cof_less)
  }.
\end{verbatim}
% file "COrdFields.v", line 46-51 *)
\begin{notation}
\verb!cof_less! is denoted infix by {\tt [:<]}.
The first argument is left implicit.
In the names of lemmas, {\tt [:<]} is written as \verb!less! and
 {\tt Zero [:<]} is written as \verb!pos!.
\end{notation}
% file "COrdFields.v", line 60 *)
\index{greater@\verb/greater/, \emph{definition}}
\begin{verbatim}
Definition greater := [F:COrdField; x,y : F] y[:<]x.
\end{verbatim}
% file "COrdFields.v", line 64-66 *)
\begin{notation}
\verb!a [:>] b! denotes \verb!greater ? a b!.
\end{notation}
% file "COrdFields.v", line 77 *)
Less or equal is defined as ``not greater than''.
% file "COrdFields.v", line 81 *)
\index{leEq@\verb/leEq/, \emph{definition}}
\begin{verbatim}
Definition leEq [F:COrdField; x,y:F]: Prop := ~(y[:<]x).
\end{verbatim}
% file "COrdFields.v", line 87-91 *)
\begin{notation}
{\tt LeEq} is denoted infix by {\tt [:<=]}.
In lemmas, {\tt [:<=]} is written as {\tt leEq}, and
{\tt Zero [:<=]} is written as \verb!nonneg!.
\end{notation}
% file "COrdFields.v", line 100-103 *)
\subsection{COrdField axioms}
\begin{convention}
Let \verb!F! be a field.
\end{convention}
% file "COrdFields.v", line 109 *)
\index{COrdField_is_COrdField@\verb/COrdField_is_COrdField/, \emph{lemma}}
\begin{verbatim}
Lemma COrdField_is_COrdField : (is_COrdField F (cof_less F)).
\end{verbatim}
% file "COrdFields.v", line 116 *)
\index{less_strorder@\verb/less_strorder/, \emph{lemma}}
\begin{verbatim}
Lemma less_strorder : (strictorder (cof_less F)).
\end{verbatim}
% file "COrdFields.v", line 123 *)
\index{less_transitive_unfolded@\verb/less_transitive_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma less_transitive_unfolded : (x,y,z:F)(x[:<]y) -> (y[:<]z) -> (x[:<]z).
\end{verbatim}
% file "COrdFields.v", line 131 *)
\index{less_antisymmetric_unfolded@\verb/less_antisymmetric_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma less_antisymmetric_unfolded : (x,y:F)((x[:<]y) -> ~(y[:<]x)).
\end{verbatim}
% file "COrdFields.v", line 139 *)
\index{less_irreflexive@\verb/less_irreflexive/, \emph{lemma}}
\begin{verbatim}
Lemma less_irreflexive : (irreflexive (cof_less F)).
\end{verbatim}
% file "COrdFields.v", line 148 *)
\index{less_irreflexive_unfolded@\verb/less_irreflexive_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma less_irreflexive_unfolded : (x:F)(~(x[:<]x)).
\end{verbatim}
% file "COrdFields.v", line 154 *)
\index{plus_resp_less_rht@\verb/plus_resp_less_rht/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_less_rht : (x,y,z:F)(x [:<] y) -> (x[+]z [:<] y[+]z).
\end{verbatim}
% file "COrdFields.v", line 162-163 *)
\index{mult_resp_pos@\verb/mult_resp_pos/, \emph{lemma}}
\begin{verbatim}
Lemma mult_resp_pos :
                (x,y:F)(Zero [:<] x)->(Zero [:<] y)->(Zero [:<] (x[*]y)).
\end{verbatim}
% file "COrdFields.v", line 170 *)
\index{less_conf_ap@\verb/less_conf_ap/, \emph{lemma}}
\begin{verbatim}
Lemma less_conf_ap : (x,y:F)(x [#] y) <-> ((x [:<] y) \/ (y [:<] x)).
\end{verbatim}
% file "COrdFields.v", line 177 *)
\index{less_wdr@\verb/less_wdr/, \emph{lemma}}
\begin{verbatim}
Lemma less_wdr : (x,y,z:F)(x[:<]y) -> (y [=] z) -> (x[:<]z).
\end{verbatim}
% file "COrdFields.v", line 183 *)
\index{less_wdl@\verb/less_wdl/, \emph{lemma}}
\begin{verbatim}
Lemma less_wdl : (x,y,z:F)(x[:<]y) -> (x [=] z) -> (z[:<]y).
\end{verbatim}
% file "COrdFields.v", line 189-190 *)
\index{less_wd_implies@\verb/less_wd_implies/, \emph{lemma}}
\begin{verbatim}
Lemma less_wd_implies :
  (x,y,x',y':F)(x[=]x')->(y[=]y')->(implies x'[:<]y' x[:<]y).
\end{verbatim}
% file "COrdFields.v", line 224 *)
\subsection{Basics}
% file "COrdFields.v", line 228-229 *)
\begin{convention} Let {\tt R} be a {\tt COrdField}.
\end{convention}
% file "COrdFields.v", line 235 *)
\index{less_imp_ap@\verb/less_imp_ap/, \emph{lemma}}
\begin{verbatim}
Lemma less_imp_ap : (x,y:R)((x [:<] y) -> (x [#] y)).
\end{verbatim}
% file "COrdFields.v", line 242 *)
\index{Greater_imp_ap@\verb/Greater_imp_ap/, \emph{lemma}}
\begin{verbatim}
Lemma Greater_imp_ap : (x,y:R)((y [:<] x) -> (x [#] y)).
\end{verbatim}
% file "COrdFields.v", line 249 *)
\index{ap_imp_less@\verb/ap_imp_less/, \emph{lemma}}
\begin{verbatim}
Lemma ap_imp_less : (x,y:R)((x [#] y) -> ((x [:<] y)\/(y [:<] x))).
\end{verbatim}
% file "COrdFields.v", line 257 *)
   Now properties which can be derived.
% file "COrdFields.v", line 261 *)
\index{cotrans_less@\verb/cotrans_less/, \emph{lemma}}
\begin{verbatim}
Lemma cotrans_less : (cotransitive (cof_less R)).
\end{verbatim}
% file "COrdFields.v", line 288 *)
\index{cotrans_less_unfolded@\verb/cotrans_less_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma cotrans_less_unfolded : (x,y:R)(x [:<] y)->(z:R)(x[:<]z)\/(z[:<]y).
\end{verbatim}
% file "COrdFields.v", line 294 *)
\index{pos_ap_zero@\verb/pos_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma pos_ap_zero : (x:R)(Zero [:<] x)-> x [#] Zero.
\end{verbatim}
% file "COrdFields.v", line 309-315 *)
\subsection{Infinity of ordered fields}

In an ordered field we have that \verb!One [+] One! and
\verb!One [+] One [+] One! and so on are all apart from zero.
We first show this, so that we can define \verb!TwoNZ!, \verb!ThreeNZ!
and so on. These are elements of \verb!NonZeros!, so that we can write
e.g.\ \verb!x[/]TwoNZ!.
% file "COrdFields.v", line 319-321 *)
\begin{convention}
Let \verb!R! be a field.
\end{convention}
% file "COrdFields.v", line 327 *)
\index{pos_one@\verb/pos_one/, \emph{lemma}}
\begin{verbatim}
Lemma pos_one : (Zero::R [:<] One).
\end{verbatim}
% file "COrdFields.v", line 345 *)
\index{nring_less_succ@\verb/nring_less_succ/, \emph{lemma}}
\begin{verbatim}
Lemma nring_less_succ : (m:nat)((Nring m)::R) [:<] (Nring (S m)).
\end{verbatim}
% file "COrdFields.v", line 356 *)
\index{nring_less@\verb/nring_less/, \emph{lemma}}
\begin{verbatim}
Lemma nring_less : (m,n:nat)(lt m n) -> (((Nring m)::R) [:<] (Nring n)).
\end{verbatim}
% file "COrdFields.v", line 368 *)
\index{nring_leEq@\verb/nring_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma nring_leEq : (m,n:nat)(le m n) -> (((Nring m)::R) [:<=] (Nring n)).
\end{verbatim}
% file "COrdFields.v", line 379 *)
\index{nring_apart@\verb/nring_apart/, \emph{lemma}}
\begin{verbatim}
Lemma nring_apart : (m,n:nat)(~(m=n) -> ((Nring m)::R [#] (Nring n))).
\end{verbatim}
% file "COrdFields.v", line 392 *)
\index{nring_ap_zero@\verb/nring_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma nring_ap_zero :(n:nat)(~(n=O) ->((nring R n)[#]Zero)).
\end{verbatim}
% file "COrdFields.v", line 400 *)
\index{nringS_ap_zero@\verb/nringS_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma nringS_ap_zero:(m:nat)((nring R (S m))[#]Zero).
\end{verbatim}
% file "COrdFields.v", line 408 *)
\index{nring_ap_zero_imp@\verb/nring_ap_zero_imp/, \emph{lemma}}
\begin{verbatim}
Lemma nring_ap_zero_imp:(n:nat)((nring R n)[#]Zero)->(~(O=n)).
\end{verbatim}
% file "COrdFields.v", line 423 *)
\index{Snring@\verb/Snring/, \emph{definition}}
\begin{verbatim}
Definition Snring : nat->(NonZeros R).
\end{verbatim}
% file "COrdFields.v", line 435 *)
\index{pos_Snring@\verb/pos_Snring/, \emph{lemma}}
\begin{verbatim}
Lemma pos_Snring : (n:nat)((Zero::R) [:<] (NZinj (Snring n))).
\end{verbatim}
% file "COrdFields.v", line 444 *)
\index{nring_fac_ap_zero@\verb/nring_fac_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma nring_fac_ap_zero:(n:nat)((nring R (fac n))[#]Zero).
\end{verbatim}
% file "COrdFields.v", line 457-461 *)
\subsubsection{Properties of one up to four}
\begin{nameconvention}
In the names of lemmas, we denote the numbers 0,1,2,3,4 and so on, by
\verb!zero!, \verb!one!, \verb!two! etc.
\end{nameconvention}
% file "COrdFields.v", line 465 *)
\index{less_plusOne@\verb/less_plusOne/, \emph{lemma}}
\begin{verbatim}
Lemma less_plusOne: (x:R) x [:<] x[+]One.
\end{verbatim}
% file "COrdFields.v", line 475 *)
\index{plus_one_ext_less@\verb/plus_one_ext_less/, \emph{lemma}}
\begin{verbatim}
Lemma plus_one_ext_less: (x,y:R)(x [:<] y) -> x [:<] y[+]One.
\end{verbatim}
% file "COrdFields.v", line 485 *)
\index{one_less_two@\verb/one_less_two/, \emph{lemma}}
\begin{verbatim}
Lemma one_less_two : (One::R [:<] Two).
\end{verbatim}
% file "COrdFields.v", line 493 *)
\index{two_less_three@\verb/two_less_three/, \emph{lemma}}
\begin{verbatim}
Lemma two_less_three : (Two::R [:<] Three).
\end{verbatim}
% file "COrdFields.v", line 500 *)
\index{three_less_four@\verb/three_less_four/, \emph{lemma}}
\begin{verbatim}
Lemma three_less_four : (Three::R [:<] Four).
\end{verbatim}
% file "COrdFields.v", line 507 *)
\index{pos_two@\verb/pos_two/, \emph{lemma}}
\begin{verbatim}
Lemma pos_two : (Zero::R [:<] Two).
\end{verbatim}
% file "COrdFields.v", line 515 *)
\index{one_less_three@\verb/one_less_three/, \emph{lemma}}
\begin{verbatim}
Lemma one_less_three : (One::R [:<] Three).
\end{verbatim}
% file "COrdFields.v", line 523 *)
\index{two_less_four@\verb/two_less_four/, \emph{lemma}}
\begin{verbatim}
Lemma two_less_four : (Two::R [:<] Four).
\end{verbatim}
% file "COrdFields.v", line 531 *)
\index{pos_three@\verb/pos_three/, \emph{lemma}}
\begin{verbatim}
Lemma pos_three : (Zero::R [:<] Three).
\end{verbatim}
% file "COrdFields.v", line 540 *)
\index{one_less_four@\verb/one_less_four/, \emph{lemma}}
\begin{verbatim}
Lemma one_less_four : (One::R [:<] Four).
\end{verbatim}
% file "COrdFields.v", line 548 *)
\index{pos_four@\verb/pos_four/, \emph{lemma}}
\begin{verbatim}
Lemma pos_four : (Zero::R [:<] Four).
\end{verbatim}
% file "COrdFields.v", line 556 *)
\index{two_ap_zero@\verb/two_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma two_ap_zero : Two [#] Zero::R.
\end{verbatim}
% file "COrdFields.v", line 563 *)
\index{three_ap_zero@\verb/three_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma three_ap_zero : Three [#] Zero::R.
\end{verbatim}
% file "COrdFields.v", line 570 *)
\index{four_ap_zero@\verb/four_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma four_ap_zero : Four [#] Zero::R.
\end{verbatim}
% file "COrdFields.v", line 581-584 *)
\begin{convention}
\verb!OneNZ!, \verb!TwoNZ!, \verb!ThreeNZ! and \verb!FourNZ! are 1,
2, 3 and 4 as elements of \verb!NonZeros!.
\end{convention}
% file "COrdFields.v", line 606 *)
\subsubsection{Consequences of infinity}
% file "COrdFields.v", line 610-612 *)
\index{square_eq@\verb/square_eq/, \emph{lemma}}
\begin{verbatim}
Lemma square_eq :
   (F:COrdField)(x,a:F)(a [#] Zero)->
   (x[^](2) [=] a[^](2))->((x [=] a) \/ (x [=] [--]a)).
\end{verbatim}
% file "COrdFields.v", line 627 *)
\subsection{Properties of $\leq$ ({\tt leEq})}
% file "COrdFields.v", line 631-632 *)
\begin{convention} Let {\tt R} be a {\tt COrdField}.
\end{convention}
% file "COrdFields.v", line 637 *)
\index{leEq_wdr@\verb/leEq_wdr/, \emph{lemma}}
\begin{verbatim}
Lemma leEq_wdr : (x,y,z:R)(x[:<=]y) -> (y [=] z) -> (x[:<=]z).
\end{verbatim}
% file "COrdFields.v", line 649 *)
\index{leEq_wdl@\verb/leEq_wdl/, \emph{lemma}}
\begin{verbatim}
Lemma leEq_wdl : (x,y,z:R)(x[:<=]y) -> (x [=] z) -> (z[:<=]y).
\end{verbatim}
% file "COrdFields.v", line 661 *)
\index{leEq_reflexive@\verb/leEq_reflexive/, \emph{lemma}}
\begin{verbatim}
Lemma leEq_reflexive : (x:R)(x[:<=]x).
\end{verbatim}
% file "COrdFields.v", line 669 *)
\index{eq_imp_leEq@\verb/eq_imp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma eq_imp_leEq : (x,y:R)(x[=]y)->(x[:<=]y).
\end{verbatim}
% file "COrdFields.v", line 678 *)
\index{leEq_imp_eq@\verb/leEq_imp_eq/, \emph{lemma}}
\begin{verbatim}
Lemma leEq_imp_eq : (x,y:R)(x [:<=] y) -> (y [:<=] x) -> (x [=] y).
\end{verbatim}
% file "COrdFields.v", line 689-692 *)
\index{lt_equiv_imp_eq@\verb/lt_equiv_imp_eq/, \emph{lemma}}
\begin{verbatim}
Lemma lt_equiv_imp_eq : (x,x':R)
  ((y:R)(x [:<] y) -> (x' [:<] y)) ->
  ((y:R)(x' [:<] y) -> (x [:<] y)) ->
    x [=] x'.
\end{verbatim}
% file "COrdFields.v", line 703 *)
\index{less_leEq_trans@\verb/less_leEq_trans/, \emph{lemma}}
\begin{verbatim}
Lemma less_leEq_trans : (x,y,z:R)(x [:<] y) -> (y [:<=] z) -> (x [:<] z).
\end{verbatim}
% file "COrdFields.v", line 715 *)
\index{leEq_less_trans@\verb/leEq_less_trans/, \emph{lemma}}
\begin{verbatim}
Lemma leEq_less_trans : (x,y,z:R)(x [:<=] y) -> (y [:<] z) -> (x [:<] z).
\end{verbatim}
% file "COrdFields.v", line 728 *)
\index{leEq_transitive@\verb/leEq_transitive/, \emph{lemma}}
\begin{verbatim}
Lemma leEq_transitive:(x,y,z:R)(x[:<=]y)->(y[:<=]z)->(x[:<=]z).
\end{verbatim}
% file "COrdFields.v", line 740 *)
\index{less_leEq@\verb/less_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma less_leEq : (x,y:R)(x [:<] y) -> (x [:<=] y).
\end{verbatim}
% file "COrdFields.v", line 770 *)
\subsection{Properties of $<$ ({\tt less})}
% file "COrdFields.v", line 774-775 *)
\begin{convention} Let {\tt R} be a {\tt COrdField}.
\end{convention}
% file "COrdFields.v", line 781-786 *)
\begin{convention}
We do not use a special predicate for positivity,
(e.g. {\tt PosP}), but just write {\tt Zero [:<] x}.
Reasons: it is more natural; in ordinary mathematics we also write $0<x$
(or $x>0$).
\end{convention}
% file "COrdFields.v", line 791-792 *)
\subsubsection{Addition and subtraction}\label{section:less_plus_minus}
\subsubsection*{$+$ and $-$ respect $<$}
% file "COrdFields.v", line 796 *)
\index{plus_resp_less_lft@\verb/plus_resp_less_lft/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_less_lft : (x,y,z:R)(x [:<] y) -> (z[+]x) [:<] (z[+]y).
\end{verbatim}
% file "COrdFields.v", line 806 *)
\index{min_resp_less@\verb/min_resp_less/, \emph{lemma}}
\begin{verbatim}
Lemma min_resp_less : (x,y:R)(x [:<] y) -> ([--]y) [:<] ([--]x).
\end{verbatim}
% file "COrdFields.v", line 816 *)
\index{minus_resp_less@\verb/minus_resp_less/, \emph{lemma}}
\begin{verbatim}
Lemma minus_resp_less : (x,y,z:R)(x [:<] y) -> ((x[-]z) [:<] (y[-]z)).
\end{verbatim}
% file "COrdFields.v", line 826 *)
\index{minus_resp_less_rht@\verb/minus_resp_less_rht/, \emph{lemma}}
\begin{verbatim}
Lemma minus_resp_less_rht :(x,y,z:R)(y [:<] x) -> ((z[-]x) [:<] (z[-]y)).
\end{verbatim}
% file "COrdFields.v", line 837-838 *)
\index{plus_resp_less_both@\verb/plus_resp_less_both/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_less_both : (a,b,c,d:R)(a [:<] b) -> (c [:<] d) ->
                                       ((a[+]c) [:<] (b[+]d)).
\end{verbatim}
% file "COrdFields.v", line 849-851 *)
For versions of \verb!plus_resp_less_both! where one \verb![:<]! in the
assumption is replaced by \verb![:<=]! see
Section~\ref{section:leEq-plus-minus}.
% file "COrdFields.v", line 855 *)
\subsubsection*{Cancellation laws}
% file "COrdFields.v", line 859 *)
\index{plus_cancel_less@\verb/plus_cancel_less/, \emph{lemma}}
\begin{verbatim}
Lemma plus_cancel_less : (x,y,z:R)((x[+]z) [:<] (y[+]z)) -> (x [:<] y).
\end{verbatim}
% file "COrdFields.v", line 873 *)
\index{min_cancel_less@\verb/min_cancel_less/, \emph{lemma}}
\begin{verbatim}
Lemma min_cancel_less : (x,y:R)(([--]x) [:<] ([--]y)) -> (y [:<] x).
\end{verbatim}
% file "COrdFields.v", line 883-896 *)
\subsubsection*{Laws for shifting}
Lemmas where an operation is transformed into the inverse operation on
the other side of an inequality are called laws for shifting.
\begin{nameconvention}
The names of laws for shifting start with ``\verb!shift_!'', and then come
the operation and the inequality, in the order in which they occur in the
conclusion.
If the shifted operand changes sides w.r.t. the operation and its inverse,
the name gets a prime.
\end{nameconvention}

It would be nicer to write the laws for shifting as bi-implications,
However, it is impractical to use these in Coq
(see the Coq shortcoming in Section~\ref{section:setoid-basics}).
% file "COrdFields.v", line 900 *)
\index{shift_less_plus@\verb/shift_less_plus/, \emph{lemma}}
\begin{verbatim}
Lemma shift_less_plus :   (a,b,c:R)(a[-]c [:<] b) -> a [:<] b[+]c.
\end{verbatim}
% file "COrdFields.v", line 909 *)
\index{shift_less_plus'@\verb/shift_less_plus'/, \emph{lemma}}
\begin{verbatim}
Lemma shift_less_plus' :  (a,b,c:R)(a[-]b [:<] c) -> a [:<] b[+]c.
\end{verbatim}
% file "COrdFields.v", line 918 *)
\index{shift_less_minus@\verb/shift_less_minus/, \emph{lemma}}
\begin{verbatim}
Lemma shift_less_minus :  (a,b,c:R)(a[+]c [:<] b)-> (a [:<] b [-] c).
\end{verbatim}
% file "COrdFields.v", line 927 *)
\index{shift_less_minus'@\verb/shift_less_minus'/, \emph{lemma}}
\begin{verbatim}
Lemma shift_less_minus' : (a,b,c:R)(c[+]a [:<] b)-> (a [:<] b [-] c).
\end{verbatim}
% file "COrdFields.v", line 936 *)
\index{shift_plus_less@\verb/shift_plus_less/, \emph{lemma}}
\begin{verbatim}
Lemma shift_plus_less :   (a,b,c:R)(a [:<] c [-] b) -> (a[+]b [:<] c).
\end{verbatim}
% file "COrdFields.v", line 945 *)
\index{shift_plus_less'@\verb/shift_plus_less'/, \emph{lemma}}
\begin{verbatim}
Lemma shift_plus_less' :  (a,b,c:R)(b [:<] c [-] a) -> (a[+]b [:<] c).
\end{verbatim}
% file "COrdFields.v", line 954 *)
\index{shift_minus_less@\verb/shift_minus_less/, \emph{lemma}}
\begin{verbatim}
Lemma shift_minus_less :  (a,b,c:R)(a [:<] c[+]b) -> (a[-]b [:<] c).
\end{verbatim}
% file "COrdFields.v", line 963 *)
\index{shift_minus_less'@\verb/shift_minus_less'/, \emph{lemma}}
\begin{verbatim}
Lemma shift_minus_less' : (a,b,c:R)(a [:<] b[+]c) -> (a[-]b [:<] c).
\end{verbatim}
% file "COrdFields.v", line 972 *)
Some special cases of laws for shifting.
% file "COrdFields.v", line 976 *)
\index{shift_zero_less_minus@\verb/shift_zero_less_minus/, \emph{lemma}}
\begin{verbatim}
Lemma shift_zero_less_minus : (x,y:R)(x[:<]y) -> (Zero[:<](y[-]x)).
\end{verbatim}
% file "COrdFields.v", line 985 *)
\index{qltone@\verb/qltone/, \emph{lemma}}
\begin{verbatim}
Lemma qltone: (q:R) (q [:<] One) ->(q[-]One [#]Zero).
\end{verbatim}
% file "COrdFields.v", line 998 *)
\subsubsection{Multiplication and division}
% file "COrdFields.v", line 1002-1015 *)
   By convention~\ref{convention:div-form}
   in CFields (Section~\ref{section:fields}), we often have redundant premises
   in lemmas. E.g. the informal statement
     \[\text{for all }x, y \text{ in } R \text{ with } 0<x \text{ and } 0<y
       \text{ we have } 0 < y / x
     \]
   is formalized as follows.
\begin{verbatim}
        (x,y:R)(H: (x [#] Zero))(Zero [:<] x) -> (Zero [:<] y)->
        (Zero [:<] y[/]x[//]H)
\end{verbatim}
   We do this to keep it easy to use such lemmas.

\subsubsection*{Multiplication and division respect $<$}
% file "COrdFields.v", line 1019-1020 *)
\index{mult_resp_less@\verb/mult_resp_less/, \emph{lemma}}
\begin{verbatim}
Lemma mult_resp_less :
 (x,y,z:R)(x [:<] y) -> (Zero [:<] z) -> ((x [*] z) [:<] (y [*] z)).
\end{verbatim}
% file "COrdFields.v", line 1037-1038 *)
\index{recip_resp_pos@\verb/recip_resp_pos/, \emph{lemma}}
\begin{verbatim}
Lemma recip_resp_pos :
 (y:R)(Hy:y[#]Zero)(Zero [:<] y) -> Zero [:<] (One [/] y[//]Hy).
\end{verbatim}
% file "COrdFields.v", line 1059-1061 *)
\index{div_resp_less_rht@\verb/div_resp_less_rht/, \emph{lemma}}
\begin{verbatim}
Lemma div_resp_less_rht :
 (x,y,z:R)(H1:z[#]Zero)(x [:<] y) -> (Zero [:<] z) ->
         ((x [/] z[//]H1) [:<] (y [/] z[//]H1)).
\end{verbatim}
% file "COrdFields.v", line 1073-1075 *)
\index{div_resp_pos@\verb/div_resp_pos/, \emph{lemma}}
\begin{verbatim}
Lemma div_resp_pos :
        (x,y:R)(H: (x [#] Zero))(Zero [:<] x) -> (Zero [:<] y)->
        (Zero [:<] y[/]x[//]H).
\end{verbatim}
% file "COrdFields.v", line 1084-1085 *)
\index{mult_resp_less_lft@\verb/mult_resp_less_lft/, \emph{lemma}}
\begin{verbatim}
Lemma mult_resp_less_lft :
 (x,y,z:R)(x [:<] y) -> (Zero [:<] z) -> ((z [*] x) [:<] (z [*] y)).
\end{verbatim}
% file "COrdFields.v", line 1097-1099 *)
\index{mult_resp_less_both@\verb/mult_resp_less_both/, \emph{lemma}}
\begin{verbatim}
Lemma mult_resp_less_both :
 (x,y,u,v:R)(Zero [:<=] x) -> (x [:<] y) -> (Zero [:<=] u) -> (u [:<] v) ->
 x[*]u [:<] y[*]v.
\end{verbatim}
% file "COrdFields.v", line 1180-1182 *)
\index{recip_resp_less@\verb/recip_resp_less/, \emph{lemma}}
\begin{verbatim}
Lemma recip_resp_less :
 (x,y:R)(Hx:x[#]Zero)(Hy:y[#]Zero)(Zero [:<] x) -> (x [:<] y) ->
            (One [/] y[//]Hy) [:<] (One [/] x[//]Hx).
\end{verbatim}
% file "COrdFields.v", line 1198 *)
\subsubsection*{Cancellation laws}
% file "COrdFields.v", line 1201-1202 *)
\index{mult_cancel_less@\verb/mult_cancel_less/, \emph{lemma}}
\begin{verbatim}
Lemma mult_cancel_less : (x,y,z:R)(Zero [:<] z) ->
                         ((x[*]z) [:<] (y[*]z)) -> (x [:<] y).
\end{verbatim}
% file "COrdFields.v", line 1217-1219 *)
\subsubsection*{Laws for shifting}
For namegiving, see the Section~\ref{section:less_plus_minus}
on plus and minus.
% file "COrdFields.v", line 1222-1223 *)
\index{shift_div_less@\verb/shift_div_less/, \emph{lemma}}
\begin{verbatim}
Lemma shift_div_less : (x,y,z:R)(H:y[#]Zero)(Zero [:<] y) ->
                       (x [:<] (z[*]y)) -> ((x[/]y[//]H) [:<] z).
\end{verbatim}
% file "COrdFields.v", line 1231-1232 *)
\index{shift_div_less'@\verb/shift_div_less'/, \emph{lemma}}
\begin{verbatim}
Lemma shift_div_less' : (x,y,z:R)(H:y[#]Zero)(Zero [:<] y) ->
                        (x [:<] (y [*]z)) -> ((x[/]y[//]H) [:<] z).
\end{verbatim}
% file "COrdFields.v", line 1240-1241 *)
\index{shift_less_div@\verb/shift_less_div/, \emph{lemma}}
\begin{verbatim}
Lemma shift_less_div : (x,y,z:R)(H:y[#]Zero)(Zero [:<] y) ->
                    ((x[*]y) [:<] z) -> (x [:<] z[/]y[//]H).
\end{verbatim}
% file "COrdFields.v", line 1249-1250 *)
\index{shift_less_mult'@\verb/shift_less_mult'/, \emph{lemma}}
\begin{verbatim}
Lemma shift_less_mult' : (x,y,z:R)(H:y[#]Zero)(Zero [:<] y) ->
                         ((x[/]y[//]H) [:<] z) -> (x [:<] (y [*]z)).
\end{verbatim}
% file "COrdFields.v", line 1258-1259 *)
\index{shift_mult_less@\verb/shift_mult_less/, \emph{lemma}}
\begin{verbatim}
Lemma shift_mult_less : (x,y,z:R)(H:y[#]Zero)(Zero [:<] y) ->
                        (x [:<] z[/]y[//]H) -> ((x[*]y) [:<] z).
\end{verbatim}
% file "COrdFields.v", line 1267 *)
\subsubsection*{Other properties of multiplication and division}
% file "COrdFields.v", line 1270-1272 *)
\index{swap_div@\verb/swap_div/, \emph{lemma}}
\begin{verbatim}
Lemma swap_div : (x,y,z:R)(Hy:y[#]Zero)(Hz:z[#]Zero)
                 (Zero [:<] y) -> (Zero [:<] z) ->
                 ((x[/]z[//]Hz)[:<] y) -> ((x[/]y[//]Hy) [:<] z).
\end{verbatim}
% file "COrdFields.v", line 1282-1284 *)
\index{eps_div_less_eps@\verb/eps_div_less_eps/, \emph{lemma}}
\begin{verbatim}
Lemma eps_div_less_eps : (eps,d:R)(d_:d [#] Zero)
                         (Zero[:<]eps) -> (One [:<] d) ->
                         ((eps[/](d[//]d_))[:<]eps).
\end{verbatim}
% file "COrdFields.v", line 1301 *)
\index{pos_div_two@\verb/pos_div_two/, \emph{lemma}}
\begin{verbatim}
Lemma pos_div_two : (eps:R)(Zero [:<] eps) -> (Zero [:<] (eps[/]TwoNZ)).
\end{verbatim}
% file "COrdFields.v", line 1317 *)
\subsubsection{Miscellaneous}
% file "COrdFields.v", line 1321 *)
\index{nring_pos@\verb/nring_pos/, \emph{lemma}}
\begin{verbatim}
Lemma nring_pos : (m:nat)((lt O m) -> (Zero [:<] (nring R m))).
\end{verbatim}
% file "COrdFields.v", line 1335 *)
\index{Smallest_less_Average@\verb/Smallest_less_Average/, \emph{lemma}}
\begin{verbatim}
Lemma Smallest_less_Average : (a,b:R)(a[:<]b)->(a[:<]((a[+]b) [/] TwoNZ)).
\end{verbatim}
% file "COrdFields.v", line 1346 *)
\index{Average_less_Greatest@\verb/Average_less_Greatest/, \emph{lemma}}
\begin{verbatim}
Lemma Average_less_Greatest : (a,b:R)(a[:<]b)->((a[+]b) [/] TwoNZ) [:<] b.
\end{verbatim}
% file "COrdFields.v", line 1357-1359 *)
\index{sum_resp_less@\verb/sum_resp_less/, \emph{lemma}}
\begin{verbatim}
Lemma sum_resp_less : (f,g:nat->R)(a,b:nat)(le a b)->
                      ((i:nat)(le a i) -> (le i b) -> (f i) [:<] (g i)) ->
                      (Sum a b f) [:<] (Sum a b g).
\end{verbatim}
% file "COrdFields.v", line 1392 *)
\subsection{Properties of $\leq$ ({\tt leEq})}
% file "COrdFields.v", line 1396-1397 *)
\begin{convention} Let {\tt R} be a {\tt COrdField}.
\end{convention}
% file "COrdFields.v", line 1404-1405 *)
\subsubsection{Addition and subtraction}\label{section:leEq-plus-minus}
\subsubsection*{+ and - respect $\leq$}
% file "COrdFields.v", line 1409 *)
\index{plus_resp_leEq@\verb/plus_resp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_leEq : (x,y,z:R)(x [:<=] y) -> (x[+]z) [:<=] (y[+]z).
\end{verbatim}
% file "COrdFields.v", line 1419 *)
\index{plus_resp_leEq_lft@\verb/plus_resp_leEq_lft/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_leEq_lft : (x,y,z:R)(x [:<=] y) -> (z[+]x) [:<=] (z[+]y).
\end{verbatim}
% file "COrdFields.v", line 1428 *)
\index{minus_resp_leEq@\verb/minus_resp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma minus_resp_leEq : (x,y,z:R)(x [:<=] y) -> (x[-]z) [:<=] (y[-]z).
\end{verbatim}
% file "COrdFields.v", line 1437 *)
\index{min_resp_leEq@\verb/min_resp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma min_resp_leEq :  (x,y:R)(x [:<=] y) -> ([--]y) [:<=] ([--]x).
\end{verbatim}
% file "COrdFields.v", line 1450-1451 *)
\index{plus_resp_leEq_both@\verb/plus_resp_leEq_both/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_leEq_both : (x,y,a,b:R)(x [:<=] y)->(a [:<=] b)
	->(x [+] a [:<=] y [+] b).
\end{verbatim}
% file "COrdFields.v", line 1464-1465 *)
\index{plus_resp_less_leEq@\verb/plus_resp_less_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_less_leEq : (a,b,c,d:R)(a [:<] b) -> (c [:<=] d) ->
                                       ((a[+]c) [:<] (b[+]d)).
\end{verbatim}
% file "COrdFields.v", line 1474-1475 *)
\index{plus_resp_leEq_less@\verb/plus_resp_leEq_less/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_leEq_less : (a,b,c,d:R)(a [:<=] b) -> (c [:<] d) ->
                                       ((a[+]c) [:<] (b[+]d)).
\end{verbatim}
% file "COrdFields.v", line 1484-1485 *)
\index{minus_resp_less_leEq@\verb/minus_resp_less_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma minus_resp_less_leEq :
  (x,y,x',y':R)(x [:<=] y) -> (y' [:<] x') -> (x[-]x' [:<] y[-]y').
\end{verbatim}
% file "COrdFields.v", line 1496-1497 *)
\index{minus_resp_leEq_both@\verb/minus_resp_leEq_both/, \emph{lemma}}
\begin{verbatim}
Lemma minus_resp_leEq_both :
  (x,y,x',y':R)(x [:<=] y) -> (y' [:<=] x') -> (x[-]x' [:<=] y[-]y').
\end{verbatim}
% file "COrdFields.v", line 1507 *)
\subsubsection*{Cancellation properties}
% file "COrdFields.v", line 1510-1511 *)
\index{plus_cancel_leEq_rht@\verb/plus_cancel_leEq_rht/, \emph{lemma}}
\begin{verbatim}
Lemma plus_cancel_leEq_rht: (x,y,z:R)( (x[+]z) [:<=] (y[+]z) )->
	(x[:<=]y).
\end{verbatim}
% file "COrdFields.v", line 1521 *)
\index{min_cancel_leEq@\verb/min_cancel_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma min_cancel_leEq:(x,y:R)([--]y[:<=][--]x)->(x[:<=]y).
\end{verbatim}
% file "COrdFields.v", line 1531 *)
\subsubsection*{Laws for shifting}
% file "COrdFields.v", line 1535 *)
\index{shift_leEq_plus'@\verb/shift_leEq_plus'/, \emph{lemma}}
\begin{verbatim}
Lemma shift_leEq_plus' : (a,b,c:R)(a[-]b [:<=] c) -> (a[:<=] b[+]c).
\end{verbatim}
% file "COrdFields.v", line 1543 *)
\index{shift_leEq_rht@\verb/shift_leEq_rht/, \emph{lemma}}
\begin{verbatim}
Lemma shift_leEq_rht: (a,b:R)(Zero [:<=] b[-]a) -> (a [:<=] b).
\end{verbatim}
% file "COrdFields.v", line 1552 *)
\index{shift_leEq_lft@\verb/shift_leEq_lft/, \emph{lemma}}
\begin{verbatim}
Lemma shift_leEq_lft : (a,b:R)(a [:<=] b) -> (Zero [:<=] b[-]a).
\end{verbatim}
% file "COrdFields.v", line 1563 *)
\subsubsection{Multiplication and division}
% file "COrdFields.v", line 1567 *)
\subsubsection*{Multiplication and division respect $\leq$}
% file "COrdFields.v", line 1571-1572 *)
\index{mult_resp_leEq_rht@\verb/mult_resp_leEq_rht/, \emph{lemma}}
\begin{verbatim}
Lemma mult_resp_leEq_rht:
            (x,y,z:R)(x [:<=] y) -> (Zero [:<=] z) -> (x[*]z) [:<=] (y[*]z).
\end{verbatim}
% file "COrdFields.v", line 1638-1639 *)
\index{mult_resp_leEq_lft@\verb/mult_resp_leEq_lft/, \emph{lemma}}
\begin{verbatim}
Lemma mult_resp_leEq_lft:
            (x,y,z:R)(x[:<=]y)->(Zero[:<=]z)-> (z[*]x[:<=]z[*]y).
\end{verbatim}
% file "COrdFields.v", line 1650-1652 *)
\index{recip_resp_leEq@\verb/recip_resp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma recip_resp_leEq : (x,y:R)(Hx:x[#]Zero)(Hy:y[#]Zero)
                        (Zero[:<]y) -> (y[:<=]x) ->
                        (One[/]x[//]Hx [:<=] One[/]y[//]Hy).
\end{verbatim}
% file "COrdFields.v", line 1670 *)
\subsubsection*{Cancellation properties}
% file "COrdFields.v", line 1674-1675 *)
\index{mult_cancel_leEq@\verb/mult_cancel_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma mult_cancel_leEq : (x,y,z:R)(Zero [:<] z) ->
                         ((x[*]z) [:<=] (y[*]z)) -> (x [:<=] y).
\end{verbatim}
% file "COrdFields.v", line 1687 *)
\subsubsection*{Laws for shifting}
% file "COrdFields.v", line 1691-1693 *)
\index{shift_leEq_mult'@\verb/shift_leEq_mult'/, \emph{lemma}}
\begin{verbatim}
Lemma shift_leEq_mult' :
                 (x,y,z:R)(H:y[#]Zero)(Zero[:<]y) ->
                 (x[/]y[//]H [:<=] z) -> (x [:<=] y[*]z).
\end{verbatim}
% file "COrdFields.v", line 1701-1703 *)
\index{shift_leEq_div@\verb/shift_leEq_div/, \emph{lemma}}
\begin{verbatim}
Lemma shift_leEq_div :
                 (x,y,z:R)(H:y[#]Zero)(Zero[:<]y) ->
                 (x[*]y [:<=] z) -> (x [:<=] z[/]y[//]H).
\end{verbatim}
% file "COrdFields.v", line 1716 *)
\subsubsection{Miscellaneous}
% file "COrdFields.v", line 1720 *)
\index{sqr_nonneg@\verb/sqr_nonneg/, \emph{lemma}}
\begin{verbatim}
Lemma sqr_nonneg: (x:R) Zero [:<=] (x[^](2)).
\end{verbatim}
% file "COrdFields.v", line 1739 *)
\index{cc_abs_aid@\verb/cc_abs_aid/, \emph{lemma}}
\begin{verbatim}
Lemma cc_abs_aid: (x,y:R)(Zero [:<=] ((x[^](2)) [+] (y[^](2)))).
\end{verbatim}
% file "COrdFields.v", line 1749 *)
\index{nexp_resp_pos@\verb/nexp_resp_pos/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_resp_pos : (x:R)(k:nat)(Zero [:<] x)->(Zero [:<] x[^]k).
\end{verbatim}
% file "COrdFields.v", line 1763-1764 *)
\index{power_resp_leEq@\verb/power_resp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma power_resp_leEq : (x,y:R)(k:nat)
  (Zero [:<] x)->(x [:<=] y)->(x[^]k [:<=] y[^]k).
\end{verbatim}
% file "COrdFields.v", line 1783-1784 *)
\index{mult_resp_nonneg@\verb/mult_resp_nonneg/, \emph{lemma}}
\begin{verbatim}
Lemma mult_resp_nonneg : (x,y:R)(Zero[:<=]x) -> (Zero[:<=]y) ->
                                (Zero[:<=] x[*]y).
\end{verbatim}
% file "COrdFields.v", line 1801 *)
\index{nexp_resp_nonneg@\verb/nexp_resp_nonneg/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_resp_nonneg : (x:R)(k:nat)(Zero [:<=] x)->(Zero [:<=] x[^]k).
\end{verbatim}
% file "COrdFields.v", line 1810-1811 *)
\index{nexp_resp_less@\verb/nexp_resp_less/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_resp_less : (x,y:R)(n:nat)(le (1) n) -> (Zero [:<=] x) ->
                             (x [:<] y) -> x[^]n [:<] y[^]n.
\end{verbatim}
% file "COrdFields.v", line 1833-1834 *)
\index{power_cancel_leEq@\verb/power_cancel_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma power_cancel_leEq : (x,y:R)(k:nat)(lt O k) ->
  (Zero [:<=] y)->(x[^]k [:<=] y[^]k)->(x [:<=] y).
\end{verbatim}
% file "COrdFields.v", line 1841-1842 *)
\index{power_cancel_less@\verb/power_cancel_less/, \emph{lemma}}
\begin{verbatim}
Lemma power_cancel_less : (x,y:R)(k:nat)
  (Zero [:<=] y)->(x[^]k [:<] y[^]k)->(x [:<] y).
\end{verbatim}
% file "COrdFields.v", line 1860-1862 *)
\index{sum_resp_leEq@\verb/sum_resp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma sum_resp_leEq : (f,g:nat->R)(a,b:nat)(le a (S b)) ->
                      ((i:nat)(le a i) -> (le i b) -> (f i) [:<=] (g i)) ->
                      (Sum a b f) [:<=] (Sum a b g).
\end{verbatim}
% file "COrdFields.v", line 1892-1893 *)
\index{approach_zero@\verb/approach_zero/, \emph{lemma}}
\begin{verbatim}
Lemma approach_zero:(x:R)((e:R)(Zero[:<]e)->(x[:<]e))->
			~(Zero[:<]x).
\end{verbatim}
% file "COrdFields.v", line 1912-1913 *)
\index{approach_zero_weak@\verb/approach_zero_weak/, \emph{lemma}}
\begin{verbatim}
Lemma approach_zero_weak:(x:R)((e:R)(Zero [:<] e)-> x [:<=] e)->
                              ~(Zero [:<] x).
\end{verbatim}
% file "COrdFields.v", line 1940 *)
\subsection{Properties of positive numbers}
% file "COrdFields.v", line 1944-1945 *)
\begin{convention} Let {\tt R} be a {\tt COrdField}.
\end{convention}
% file "COrdFields.v", line 1950-1951 *)
\begin{verbatim}
Syntactic Definition ZeroR := (Zero::R).
Syntactic Definition OneR := (One::R).
\end{verbatim}
% file "COrdFields.v", line 1955 *)
\index{pos_ap_zeros@\verb/pos_ap_zeros/, \emph{definition}}
\begin{verbatim}
Definition pos_ap_zeros: (x:R)(Zero [:<] x)-> (NonZeros R).
\end{verbatim}
% file "COrdFields.v", line 1964-1965 *)
\index{mult_pos_imp@\verb/mult_pos_imp/, \emph{lemma}}
\begin{verbatim}
Lemma mult_pos_imp : (a,b:R)(Zero [:<] a[*] b) ->
    ((Zero [:<] a) /\ (Zero [:<] b)) \/ ((a [:<] Zero) /\ (b [:<] Zero)).
\end{verbatim}
% file "COrdFields.v", line 2014-2015 *)
\index{plus_resp_pos_nonneg@\verb/plus_resp_pos_nonneg/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_pos_nonneg :
       (x,y:R)(Zero [:<] x) -> (Zero [:<=] y) -> (Zero [:<] x[+]y).
\end{verbatim}
% file "COrdFields.v", line 2024-2025 *)
\index{plus_resp_nonneg_pos@\verb/plus_resp_nonneg_pos/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_nonneg_pos :
       (x,y:R)(Zero [:<=] x) -> (Zero [:<] y) -> (Zero [:<] x[+]y).
\end{verbatim}
% file "COrdFields.v", line 2033 *)
\index{pos_square@\verb/pos_square/, \emph{lemma}}
\begin{verbatim}
Lemma pos_square : (x:R)(x [#] Zero)->(Zero [:<] x[^](2)).
\end{verbatim}
% file "COrdFields.v", line 2048 *)
\index{mult_cancel_pos_rht@\verb/mult_cancel_pos_rht/, \emph{lemma}}
\begin{verbatim}
Lemma mult_cancel_pos_rht : (x,y:R)(Zero [:<] x[*]y)->(Zero [:<] x)->(Zero [:<] y).
\end{verbatim}
% file "COrdFields.v", line 2059 *)
\index{mult_cancel_pos_lft@\verb/mult_cancel_pos_lft/, \emph{lemma}}
\begin{verbatim}
Lemma mult_cancel_pos_lft : (x,y:R)(Zero [:<] x[*]y)->(Zero [:<] y)->(Zero [:<] x).
\end{verbatim}
% file "COrdFields.v", line 2068 *)
\index{pos_wd@\verb/pos_wd/, \emph{lemma}}
\begin{verbatim}
Lemma pos_wd : (x,y:R)(x [=] y)->(Zero [:<] y)->(Zero [:<] x).
\end{verbatim}
% file "COrdFields.v", line 2076 *)
\index{even_power_pos@\verb/even_power_pos/, \emph{lemma}}
\begin{verbatim}
Lemma even_power_pos : (n:nat)(even n) -> (x:R)(x [#] Zero) -> (Zero [:<] x[^]n).
\end{verbatim}
% file "COrdFields.v", line 2088 *)
\index{odd_power_cancel_pos@\verb/odd_power_cancel_pos/, \emph{lemma}}
\begin{verbatim}
Lemma odd_power_cancel_pos : (n:nat)(odd n)->(x:R)(Zero [:<] x[^]n)->(Zero [:<] x).
\end{verbatim}
% file "COrdFields.v", line 2105 *)
\index{plus_resp_pos@\verb/plus_resp_pos/, \emph{lemma}}
\begin{verbatim}
Lemma plus_resp_pos : (x,y:R)(Zero [:<] x)->(Zero [:<] y)->(Zero [:<] x[+]y).
\end{verbatim}
% file "COrdFields.v", line 2114 *)
\index{pos_nring_S@\verb/pos_nring_S/, \emph{lemma}}
\begin{verbatim}
Lemma pos_nring_S: (n:nat)((Zero::R) [:<] (Nring (S n))).
\end{verbatim}
% file "COrdFields.v", line 2132 *)
\subsection{Properties of non-negative numbers}
% file "COrdFields.v", line 2136-2137 *)
\begin{convention} Let {\tt R} be a {\tt COrdField}.
\end{convention}
% file "COrdFields.v", line 2142-2143 *)
\begin{verbatim}
Syntactic Definition ZeroR := (Zero::R).
Syntactic Definition OneR := (One::R).
\end{verbatim}
% file "COrdFields.v", line 2152 *)
\subsection{Properties of {\tt AbsSmall}.}
% file "COrdFields.v", line 2158 *)
\index{absSmall@\verb/absSmall/, \emph{definition}}
\begin{verbatim}
Definition absSmall [R:COrdField;e,x:R]: Prop := ([--]e [:<] x) /\ (x [:<] e).
\end{verbatim}
% file "COrdFields.v", line 2170-2171 *)
\begin{convention} Let {\tt R} be a {\tt COrdField}.
\end{convention}
% file "COrdFields.v", line 2176 *)
\index{AbsSmall_wd_rht@\verb/AbsSmall_wd_rht/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_wd_rht : (rel_well_def_rht R AbsSmall).
\end{verbatim}
% file "COrdFields.v", line 2191-2192 *)
\index{AbsSmall_wd_rht_unfolded@\verb/AbsSmall_wd_rht_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_wd_rht_unfolded : (x,y,z:R)(AbsSmall x y)->(y[=]z)->
                                 (AbsSmall x z).
\end{verbatim}
% file "COrdFields.v", line 2197 *)
\index{AbsSmall_wd_lft@\verb/AbsSmall_wd_lft/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_wd_lft : (rel_well_def_lft R AbsSmall).
\end{verbatim}
% file "COrdFields.v", line 2212-2213 *)
\index{AbsSmall_wd_lft_unfolded@\verb/AbsSmall_wd_lft_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_wd_lft_unfolded : (x,y,z:R)(AbsSmall x y)->(x[=]z)->
                                 (AbsSmall z y).
\end{verbatim}
% file "COrdFields.v", line 2243 *)
\begin{verbatim}
Syntactic Definition ZeroR := (Zero::R).
\end{verbatim}
% file "COrdFields.v", line 2249-2250 *)
\index{AbsSmall_leEq_trans@\verb/AbsSmall_leEq_trans/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_leEq_trans :  (e1,e2,d:R)(e1 [:<=] e2) ->
                             (AbsSmall e1 d) -> (AbsSmall e2 d).
\end{verbatim}
% file "COrdFields.v", line 2269-2270 *)
\index{AbsSmall_trans@\verb/AbsSmall_trans/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_trans :  (e1,e2,d:R)(e1 [:<] e2) ->
                        (AbsSmall e1 d) -> (AbsSmall e2 d).
\end{verbatim}
% file "COrdFields.v", line 2280-2281 *)
\index{less_imp_AbsSmall@\verb/less_imp_AbsSmall/, \emph{lemma}}
\begin{verbatim}
Lemma less_imp_AbsSmall : (e,d:R)(Zero [:<=] e) -> (e [:<] d) ->
                           (AbsSmall d e).
\end{verbatim}
% file "COrdFields.v", line 2293 *)
\index{min_resp_AbsSmall@\verb/min_resp_AbsSmall/, \emph{lemma}}
\begin{verbatim}
Lemma min_resp_AbsSmall: (x,y:R)(AbsSmall x y) -> (AbsSmall x [--]y).
\end{verbatim}
% file "COrdFields.v", line 2307-2308 *)
\index{AbsSmall_minus@\verb/AbsSmall_minus/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_minus : (e,x1,x2:R)
                       (AbsSmall e (x1[-]x2)) -> (AbsSmall e (x2[-]x1)).
\end{verbatim}
% file "COrdFields.v", line 2317-2319 *)
\index{AbsSmall_plus@\verb/AbsSmall_plus/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_plus : (e1,e2,x1,x2:R)
                      (AbsSmall e1 x1) -> (AbsSmall e2 x2) ->
                      (AbsSmall (e1[+]e2) (x1[+]x2)).
\end{verbatim}
% file "COrdFields.v", line 2332-2335 *)
\index{AbsSmall_eps_div_two@\verb/AbsSmall_eps_div_two/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_eps_div_two : (e,x1,x2:R)
                             (AbsSmall (e[/]TwoNZ) x1) ->
                             (AbsSmall (e[/]TwoNZ) x2) ->
                             (AbsSmall e (x1[+]x2)).
\end{verbatim}
% file "COrdFields.v", line 2345-2347 *)
\index{AbsSmall_x_plus_delta@\verb/AbsSmall_x_plus_delta/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_x_plus_delta : (x,eps,delta:R)
               (Zero [:<] eps) -> (Zero [:<] delta) -> (delta[:<]eps) ->
               (AbsSmall eps (x[-](x[+]delta))).
\end{verbatim}
% file "COrdFields.v", line 2361-2363 *)
\index{AbsSmall_x_minus_delta@\verb/AbsSmall_x_minus_delta/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_x_minus_delta : (x,eps,delta:R)
                  (Zero [:<] eps) -> (Zero[:<] delta) -> (delta[:<]eps) ->
                  (AbsSmall eps (x[-](x[-]delta))).
\end{verbatim}
% file "COrdFields.v", line 2380-2381 *)
\index{AbsSmall_x_plus_eps_div2@\verb/AbsSmall_x_plus_eps_div2/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_x_plus_eps_div2 : (x,eps:R)(Zero [:<] eps)->
                    (AbsSmall eps (x[-](x[+]eps[/]TwoNZ))).
\end{verbatim}
% file "COrdFields.v", line 2398-2399 *)
\index{AbsSmall_x_minus_eps_div2@\verb/AbsSmall_x_minus_eps_div2/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_x_minus_eps_div2 : (x,eps:R)(Zero [:<] eps)->
                     (AbsSmall eps (x[-](x[-]eps[/]TwoNZ))).
\end{verbatim}
% file "COrdFields.v", line 2416-2417 *)
\index{AbsSmall_intermediate@\verb/AbsSmall_intermediate/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_intermediate : (x,y,z,eps:R)(x [:<] y)->(y[:<]z)->
                              (AbsSmall eps (z[-]x)) -> (AbsSmall eps (z[-]y)).
\end{verbatim}
% file "COrdFields.v", line 2432-2433 *)
\index{AbsSmall_eps_div2@\verb/AbsSmall_eps_div2/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_eps_div2 : (eps:R)(Zero [:<] eps)->
                          (AbsSmall eps (eps[/]TwoNZ)).
\end{verbatim}
% file "COrdFields.v", line 2448 *)
\index{AbsSmall_pos@\verb/AbsSmall_pos/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_pos: (e,x:R)(AbsSmall e x)->(Zero[:<]e).
\end{verbatim}
% file "COrdFields.v", line 2469-2470 *)
\index{AbsSmall_mult@\verb/AbsSmall_mult/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_mult :(e1,e2,x1,x2: R)(AbsSmall e1 x1)->
	(AbsSmall e2 x2)->(AbsSmall Three[*](e1[*]e2) x1[*]x2).
\end{verbatim}
% file "COrdFields.v", line 2553-2554 *)
\index{AbsSmall_cancel_mult@\verb/AbsSmall_cancel_mult/, \emph{lemma}}
\begin{verbatim}
Lemma AbsSmall_cancel_mult:(e,x,z:R)(Zero[:<]z)->
			(AbsSmall e[*]z x[*]z)->(AbsSmall e x).
\end{verbatim}
% file "COrdFields.v", line 2574-2577 *)
\subsection{Properties of one over successor}
\begin{convention}
Let \verb!R! be an ordered field.
\end{convention}
% file "COrdFields.v", line 2581-2582 *)
\index{one_div_succ@\verb/one_div_succ/, \emph{definition}}
\begin{verbatim}
Definition one_div_succ := [R:COrdField][i:nat](One [/] (Snring R i))
                        :  (R:COrdField)(nat->R).
\end{verbatim}
% file "COrdFields.v", line 2592-2593 *)
\index{one_div_succ_resp_leEq@\verb/one_div_succ_resp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma one_div_succ_resp_leEq :
      (m,n:nat)(le m n)->((one_div_succ R n) [:<=] (one_div_succ R m)).
\end{verbatim}
% file "COrdFields.v", line 2603 *)
\index{one_div_succ_pos@\verb/one_div_succ_pos/, \emph{lemma}}
\begin{verbatim}
Lemma one_div_succ_pos : (i:nat)((Zero::R) [:<] (One_div_succ i)).
\end{verbatim}
% file "COrdFields.v", line 2614-2615 *)
\index{One_div_succ_resp_less@\verb/One_div_succ_resp_less/, \emph{lemma}}
\begin{verbatim}
Lemma One_div_succ_resp_less : (i,j:nat)(lt i j)->
                              ((cof_less R) (One_div_succ j) (One_div_succ i)).
\end{verbatim}
% file "COrdFields.v", line 2626-2627 *)
\index{One_div_succ_resp_leEq@\verb/One_div_succ_resp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma One_div_succ_resp_leEq : (i,j:nat)(le i j)->
                              ((leEq R) (One_div_succ j) (One_div_succ i)).
\end{verbatim}
% file "COrdFields.v", line 2636 *)
\subsection{Properties of Half}
% file "COrdFields.v", line 2644 *)
\index{half@\verb/half/, \emph{definition}}
\begin{verbatim}
Definition half := [R:COrdField]One::R[/]TwoNZ.
\end{verbatim}
% file "COrdFields.v", line 2655-2656 *)
\begin{convention} Let {\tt R} be a {\tt COrdField}
\end{convention}
% file "COrdFields.v", line 2662 *)
\index{half_1@\verb/half_1/, \emph{lemma}}
\begin{verbatim}
Lemma half_1 : (Half::R)[*]Two [=] One.
\end{verbatim}
% file "COrdFields.v", line 2670 *)
\index{pos_half@\verb/pos_half/, \emph{lemma}}
\begin{verbatim}
Lemma pos_half : ((Zero::R) [:<] Half).
\end{verbatim}
% file "COrdFields.v", line 2680 *)
\index{half_1'@\verb/half_1'/, \emph{lemma}}
\begin{verbatim}
Lemma half_1' : (x:R)((x[*]Half)[*]Two [=] x).
\end{verbatim}
% file "COrdFields.v", line 2688 *)
\index{half_2@\verb/half_2/, \emph{lemma}}
\begin{verbatim}
Lemma half_2 : (Half::R)[+]Half [=] One.
\end{verbatim}
% file "COrdFields.v", line 2695 *)
\index{half_lt1@\verb/half_lt1/, \emph{lemma}}
\begin{verbatim}
Lemma half_lt1 : (Half::R)[:<] One.
\end{verbatim}
% file "COrdFields.v", line 2705 *)
\index{half_3@\verb/half_3/, \emph{lemma}}
\begin{verbatim}
Lemma half_3 : (x:R)(Zero [:<] x) -> (Half[*]x [:<] x).
\end{verbatim}
% file "COrdFields.v", line 2722 *)
\subsection{Cauchy}
% file "COrdFields.v", line 2726-2727 *)
\begin{convention} Let {\tt R} be a {\tt COrdField}.
\end{convention}
% file "COrdFields.v", line 2733-2735 *)
\index{Cauchy_prop@\verb/Cauchy_prop/, \emph{definition}}
\begin{verbatim}
Definition Cauchy_prop [g:nat -> R]: Prop :=
   (e:R)(Zero [:<] e) -> (Ex [N:nat](m:nat)(le N m)
			   -> (AbsSmall e ((g m)[-](g N)))).
\end{verbatim}
% file "COrdFields.v", line 2740-2747 *)
\index{CauchySeq@\verb/CauchySeq/, \emph{record}}
\begin{verbatim}
(* Def. CauchyP, Build_CauchyP *)
(* Should be defined in terms of CauchyP *)
(* Implicit arguments turned off, because Coq makes a mess of it in combination
   with the coercions *)
Record CauchySeq : Set :=
  {CS_seq  :> nat -> R;
   CS_proof: (Cauchy_prop CS_seq)
  }.
\end{verbatim}
% file "COrdFields.v", line 2751-2753 *)
\index{seqLimit@\verb/seqLimit/, \emph{definition}}
\begin{verbatim}
Definition seqLimit [seq:nat->R; lim:R]: Prop :=
   (e:R)(Zero [:<] e) -> (Ex [N:nat](m:nat)(le N m)
			   -> (AbsSmall e ((seq m)[-]lim))).
\end{verbatim}
% file "COrdFields.v", line 2831-2833 *)
\index{estimate_sqrt@\verb/estimate_sqrt/, \emph{lemma}}
\begin{verbatim}
Lemma estimate_sqrt :
  (a:R)(Zero [:<] a) ->
    (EX e | (Zero [:<] e) /\ (e[^](2) [:<] a)).
\end{verbatim}
% file "COrdFields.v", line 2858-2860 *)
\index{estimate_sqrt'@\verb/estimate_sqrt'/, \emph{lemma}}
\begin{verbatim}
Lemma estimate_sqrt' :
  (a,b:R)(Zero [:<] a) -> (Zero [:<] b) ->
    (EX e | (Zero [:<] e) /\ (a[*]e[^](2) [:<] b)).
\end{verbatim}
% file "COrdFields.v", line 2877-2880 *)
\index{mult_abssmall'_rht@\verb/mult_abssmall'_rht/, \emph{lemma}}
\begin{verbatim}
Lemma mult_abssmall'_rht :
  (x,y,C:R)(Zero [:<] C) ->
  ([--]C [:<] x) -> (x [:<] C) -> ([--]C [:<] y) -> (y [:<] C) ->
    (x[*]y [:<] Three[*]C[^](2)).
\end{verbatim}
% file "COrdFields.v", line 2899-2902 *)
\index{mult_abssmall_rht@\verb/mult_abssmall_rht/, \emph{lemma}}
\begin{verbatim}
Lemma mult_abssmall_rht :
  (x,y,X,Y:R)(Zero [:<] X) -> (Zero [:<] Y) ->
  ([--]X [:<] x) -> (x [:<] X) -> ([--]Y [:<] y) -> (y [:<] Y) ->
    (x[*]y [:<] X[*]Y).
\end{verbatim}
% file "COrdFields.v", line 2939-2942 *)
\index{mult_abssmall_lft@\verb/mult_abssmall_lft/, \emph{lemma}}
\begin{verbatim}
Lemma mult_abssmall_lft :
  (x,y,X,Y:R)(Zero [:<] X) -> (Zero [:<] Y) ->
  ([--]X [:<] x) -> (x [:<] X) -> ([--]Y [:<] y) -> (y [:<] Y) ->
    ([--](X[*]Y) [:<] x[*]y).
\end{verbatim}
% file "COrdFields.v", line 2954-2955 *)
\index{mult_abssmall@\verb/mult_abssmall/, \emph{lemma}}
\begin{verbatim}
Lemma mult_abssmall :
  (x,y,X,Y:R)(AbsSmall X x) -> (AbsSmall Y y) -> (AbsSmall X[*]Y x[*]y).
\end{verbatim}
% file "Expon.v", line 9-13 *)
\section{Exponentiation}
\subsection{More properties about {\tt nexp}}
\begin{convention}
Let \verb!R! be an ordered field.
\end{convention}
% file "Expon.v", line 20 *)
\index{nexp_resp_ap_zero@\verb/nexp_resp_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_resp_ap_zero : (x:R)(n:nat)(x[#]Zero)->(x[^]n [#] Zero).
\end{verbatim}
% file "Expon.v", line 36-37 *)
\index{nexp_distr_div@\verb/nexp_distr_div/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_distr_div : (x,y:R)(n:nat)(H:y[#]Zero)(H1:y[^]n[#]Zero)
                       (x[/]y[//]H) [^] n [=] (x[^]n) [/] (y[^]n) [//] H1.
\end{verbatim}
% file "Expon.v", line 52-53 *)
\index{nexp_distr_div'@\verb/nexp_distr_div'/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_distr_div' : (x,y:R)(n:nat)(H:y[#]Zero)
        (x[/]y[//]H) [^] n [=] (x[^]n) [/] (y[^]n) [//] (nexp_resp_ap_zero y n H).
\end{verbatim}
% file "Expon.v", line 60-61 *)
\index{small_nexp_resp_lt@\verb/small_nexp_resp_lt/, \emph{lemma}}
\begin{verbatim}
Lemma small_nexp_resp_lt : (x:R)(m,n:nat)
            (Zero [:<] x) -> (x [:<] One) -> (lt m n) -> x[^]n [:<] x[^]m.
\end{verbatim}
% file "Expon.v", line 97-98 *)
\index{great_nexp_resp_lt@\verb/great_nexp_resp_lt/, \emph{lemma}}
\begin{verbatim}
Lemma great_nexp_resp_lt : (x:R)(m,n:nat)
            (One [:<] x) -> (lt m n) -> x[^]m [:<] x[^]n.
\end{verbatim}
% file "Expon.v", line 116-117 *)
\index{small_nexp_resp_le@\verb/small_nexp_resp_le/, \emph{lemma}}
\begin{verbatim}
Lemma small_nexp_resp_le : (x:R)(m,n:nat)
            (Zero [:<] x) -> (x [:<] One) -> (le m n) -> x[^]n [:<=] x[^]m.
\end{verbatim}
% file "Expon.v", line 128-129 *)
\index{great_nexp_resp_le@\verb/great_nexp_resp_le/, \emph{lemma}}
\begin{verbatim}
Lemma great_nexp_resp_le : (x:R)(m,n:nat)
            (One [:<] x) -> (le m n) -> x[^]m [:<=] x[^]n.
\end{verbatim}
% file "Expon.v", line 138-139 *)
\index{nexp_resp_leEq@\verb/nexp_resp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_resp_leEq :
                (x,y:R)(k:nat)(Zero [:<=] x)->(x [:<=] y)->(x[^]k [:<=] y[^]k).
\end{verbatim}
% file "Expon.v", line 146-147 *)
\index{nexp_distr_recip@\verb/nexp_distr_recip/, \emph{lemma}}
\begin{verbatim}
Lemma nexp_distr_recip : (x:R)(n:nat)(H:x[#]Zero)(H1:x[^]n[#]Zero)
                         (One[/]x[//]H)[^]n [=] One[/](x[^]n)[//]H1.
\end{verbatim}
% file "Expon.v", line 170-173 *)
\subsection{Definition of {\tt zexp} : integer exponentiation}
\begin{convention}
Let \verb!R! be an ordered field.
\end{convention}
% file "Expon.v", line 181-182 *)
It would be nicer to define \verb!zexp! using \verb!caseZdiff!, but we already
have most properties now.
% file "Expon.v", line 186-191 *)
\index{zexp@\verb/zexp/, \emph{definition}}
\begin{verbatim}
Definition zexp[n:Z; x:(NonZeros R)] : R :=
         Cases n of
           ZERO => (One::R)
         | (POS p) => (NZinj x) [^] (convert p)
         | (NEG p) => (One[/]x) [^] (convert p)
         end.
\end{verbatim}
% file "Expon.v", line 197-199 *)
\begin{notation}
\verb!a [^^] b! stands for \verb!zexp ? a b!.
\end{notation}
% file "Expon.v", line 211-214 *)
\subsection{Properties of {\tt zexp}}
\begin{convention}
Let \verb!R! be an ordered field.
\end{convention}
% file "Expon.v", line 222 *)
\index{zexp_zero@\verb/zexp_zero/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_zero : (x:R)(H:x[#]Zero) ((x[//]H) [^^] `0`) [=] One.
\end{verbatim}
% file "Expon.v", line 232-233 *)
\index{zexp_nexp@\verb/zexp_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_nexp : (x:R)(H:x[#]Zero)(n:nat)
                  ((x[//]H) [^^] n) [=] (x [^] n).
\end{verbatim}
% file "Expon.v", line 251-252 *)
\index{zexp_min_nexp@\verb/zexp_min_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_min_nexp : (x:R)(H:x[#]Zero)(n:nat)
                      ((x[//]H) [^^] `-n`) [=] ((One[/]x[//]H) [^] n).
\end{verbatim}
% file "Expon.v", line 270-271 *)
\index{zexp_min_nexp'@\verb/zexp_min_nexp'/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_min_nexp' : (x:R)(n:nat)(H:x[#]Zero)(H1:x[^]n[#]Zero)
                       ((x[//]H) [^^] `-n`) [=] (One[/](x [^] n)[//]H1).
\end{verbatim}
% file "Expon.v", line 282-284 *)
\index{zexp_strong_ext@\verb/zexp_strong_ext/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_strong_ext : (x,y:R)(m:Z)(Hx:x[#]Zero)(Hy:y[#]Zero)
                       ((x[//]Hx)[^^]m [#] (y[//]Hy)[^^] m) ->
                       x [#] y.
\end{verbatim}
% file "Expon.v", line 309-310 *)
\index{zexp_well_def@\verb/zexp_well_def/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_well_def : (x,y:R)(m:Z)(Hx:x[#]Zero)(Hy:y[#]Zero)(x [=] y) ->
                       ((x[//]Hx)[^^]m [=] (y[//]Hy)[^^] m).
\end{verbatim}
% file "Expon.v", line 323-324 *)
\index{zexp_plus1@\verb/zexp_plus1/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_plus1 : (x:R)(H:x[#]Zero)(m:Z)
                   ((x[//]H) [^^] `m+1`) [=] ((x[//]H) [^^] m) [*] x.
\end{verbatim}
% file "Expon.v", line 359 *)
\index{zexp_resp_ap_zero@\verb/zexp_resp_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_resp_ap_zero : (x:R)(m:Z)(H:x[#]Zero)((x[//]H) [^^] m) [#] Zero.
\end{verbatim}
% file "Expon.v", line 378-379 *)
\index{zexp_min@\verb/zexp_min/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_min : (x:R)(H:x[#]Zero)(m:Z)(Hexp: (x[//]H) [^^] m [#] Zero)
   ((x[//]H) [^^] `-m`) [=] One[/] ((x[//]H) [^^] m) [//] Hexp.
\end{verbatim}
% file "Expon.v", line 407-408 *)
\index{zexp_min1@\verb/zexp_min1/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_min1 : (x:R)(H:x[#]Zero)(m:Z)
                   ((x[//]H) [^^] `m-1`) [=] ((x[//]H) [^^] m) [/] x [//] H.
\end{verbatim}
% file "Expon.v", line 426-427 *)
\index{zexp_plus@\verb/zexp_plus/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_plus : (x:R)(H:x[#]Zero)(m,n:Z)
              ((x[//]H) [^^] `m+n`) [=] ((x[//]H) [^^] m [*] (x[//]H) [^^]n).
\end{verbatim}
% file "Expon.v", line 456-458 *)
\index{zexp_minus@\verb/zexp_minus/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_minus : (x:R)(H:x[#]Zero)(m,n:Z)(Hexp : (x[//]H) [^^] n [#] Zero)
   ((x[//]H) [^^] `m-n`) [=]
   (((x[//]H) [^^] m) [/] ((x[//]H) [^^] n) [//] Hexp).
\end{verbatim}
% file "Expon.v", line 472 *)
\index{one_zexp@\verb/one_zexp/, \emph{lemma}}
\begin{verbatim}
Lemma one_zexp : (z:Z)(OneNZ [^^] z [=] (One::R)).
\end{verbatim}
% file "Expon.v", line 493-495 *)
\index{mult_zexp@\verb/mult_zexp/, \emph{lemma}}
\begin{verbatim}
Lemma mult_zexp : (x,y:R)(z:Z)(Hx:x[#]Zero)(Hy:y[#]Zero)(Hp:x[*]y[#]Zero)
                  ((x[*]y) [//] Hp) [^^] z [=]
                  (x [//] Hx) [^^] z [*] (y [//] Hy) [^^] z.
\end{verbatim}
% file "Expon.v", line 520-522 *)
\index{zexp_mult@\verb/zexp_mult/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_mult :  (x:R)(m,n:Z)(Hx:x[#]Zero)(He:(x[//]Hx)[^^]m [#] Zero)
                  (x [//] Hx) [^^] `m*n` [=]
                  ((x [//] Hx) [^^] m [//] He) [^^] n.
\end{verbatim}
% file "Expon.v", line 547 *)
\index{zexp_two@\verb/zexp_two/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_two : (x:R)(Hx:x[#]Zero)(x[//]Hx) [^^] `2` [=] x[*]x.
\end{verbatim}
% file "Expon.v", line 557-558 *)
\index{min_zexp_even@\verb/min_zexp_even/, \emph{lemma}}
\begin{verbatim}
Lemma min_zexp_even : (x:R)(m:Z)(Zeven m)->(Hx:x[#]Zero)(Hneg:[--]x[#]Zero)
                  ([--]x[//]Hneg) [^^] m [=] (x[//]Hx) [^^] m.
\end{verbatim}
% file "Expon.v", line 576-577 *)
\index{min_zexp_two@\verb/min_zexp_two/, \emph{lemma}}
\begin{verbatim}
Lemma min_zexp_two : (x:R)(Hx:x[#]Zero)(Hneg:[--]x[#]Zero)
                     ([--]x[//]Hneg) [^^] `2` [=] (x[//]Hx) [^^] `2`.
\end{verbatim}
% file "Expon.v", line 588-589 *)
\index{min_zexp_odd@\verb/min_zexp_odd/, \emph{lemma}}
\begin{verbatim}
Lemma min_zexp_odd : (x:R)(m:Z)(Zodd m)->(Hx:x[#]Zero)(Hneg:[--]x[#]Zero)
                  ([--]x[//]Hneg) [^^] m [=] [--]((x[//]Hx) [^^] m).
\end{verbatim}
% file "Expon.v", line 611 *)
\index{zexp_one@\verb/zexp_one/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_one : (x:R)(H:x[#]Zero)(x[//]H)[^^]`1` [=] x.
\end{verbatim}
% file "Expon.v", line 621-623 *)
\index{zexp_funny@\verb/zexp_funny/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_funny : (x,y:R)(Hx:x[#]Zero)(Hy:y[#]Zero)
                   (x[+]y) [*] (x[-]y) [=]
                   (x[//]Hx)[^^]`2` [-] (y[//]Hy)[^^]`2`.
\end{verbatim}
% file "Expon.v", line 633-635 *)
\index{zexp_funny'@\verb/zexp_funny'/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_funny' : (x,y:R)(Hx:x[#]Zero)(Hy:y[#]Zero)
                    (x[-]y) [*] (x[+]y) [=]
                    (x[//]Hx)[^^]`2` [-] (y[//]Hy)[^^]`2`.
\end{verbatim}
% file "Expon.v", line 645-646 *)
\index{zexp_pos@\verb/zexp_pos/, \emph{lemma}}
\begin{verbatim}
Lemma zexp_pos : (x:R)(H:x[#]Zero)(z:Z)(Zero [:<] x) ->
                 (Zero [:<] (x[//]H) [^^] z).
\end{verbatim}
% file "Expon.v", line 677-679 *)
\index{root_unique@\verb/root_unique/, \emph{lemma}}
\begin{verbatim}
Lemma root_unique :
  (x,y:R)(Zero [:<=] x) -> (Zero [:<=] y) -> (n:nat)(lt (0) n) ->
    (x[^]n [=] y[^]n) -> (x [=] y).
\end{verbatim}
% file "Expon.v", line 692-693 *)
\index{root_one@\verb/root_one/, \emph{lemma}}
\begin{verbatim}
Lemma root_one :
  (x:R)(Zero [:<=] x) -> (n:nat)(lt (0) n) -> (x[^]n [=] One) -> (x [=] One).
\end{verbatim}
% file "CReals.v", line 6-7 *)
\section{Reals}
\subsection{Definition of the notion of reals}
% file "CReals.v", line 13-16 *)
\index{is_CReals@\verb/is_CReals/, \emph{record}}
\begin{verbatim}
Record is_CReals [R: COrdField; lim : (CauchySeq R) -> R] : Prop :=
  {ax_Lim  : (s:(CauchySeq R))(SeqLimit s (lim s));
   ax_Arch : (x:R)(Ex [n:nat](x [:<] (Nring n)))
  }.
\end{verbatim}
% file "CReals.v", line 20-24 *)
\index{CReals@\verb/CReals/, \emph{record}}
\begin{verbatim}
Record CReals : Type :=
  {crl_crr   :> COrdField;
   crl_lim   :  (CauchySeq crl_crr) -> crl_crr;
   crl_proof :  (is_CReals crl_crr crl_lim)
  }.
\end{verbatim}
% file "CReals.v", line 30 *)
\index{lim@\verb/lim/, \emph{definition}}
\begin{verbatim}
Definition lim := crl_lim : (IR:CReals)(CauchySeq IR) -> IR.
\end{verbatim}
% file "CReals1.v", line 6-8 *)
\begin{convention}
Let \verb!IR! be a structure for real numbers.
\end{convention}
% file "CReals1.v", line 22-24 *)
\begin{convention}
With \verb!ZeroR! and \verb!OneR! we denote the zero and one of this structure.
\end{convention}
% file "CReals1.v", line 32 *)
\subsection{CReals axioms}
% file "CReals1.v", line 36 *)
\index{CReals_is_CReals@\verb/CReals_is_CReals/, \emph{lemma}}
\begin{verbatim}
Lemma CReals_is_CReals : (is_CReals IR Lim).
\end{verbatim}
% file "CReals1.v", line 45 *)
\index{Lim_Cauchy@\verb/Lim_Cauchy/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_Cauchy : (s:(CauchySeq IR))(SeqLimit s (Lim s)).
\end{verbatim}
% file "CReals1.v", line 53 *)
\index{Archimedes@\verb/Archimedes/, \emph{lemma}}
\begin{verbatim}
Lemma Archimedes : (x:IR)(Ex [n:nat](x [:<] (Nring n))).
\end{verbatim}
% file "CReals1.v", line 61 *)
\index{CauchySeqR@\verb/CauchySeqR/, \emph{definition}}
\begin{verbatim}
Definition CauchySeqR := (CauchySeq IR).
\end{verbatim}
% file "CReals1.v", line 68-116 *)
\subsection{Cauchy definitions}
This section gives several definitions of Cauchy sequences. There
are no lemmas in this section.

\begin{enumerate}
\item
The current definition of Cauchy (\verb!Cauchy_prop!) is:
\[\forall \epsilon>0. \exists N. \forall m\geq N. |seq_m - seq_N| < \epsilon\]
\item
Variant 1 of Cauchy (\verb!Cauchy_prop1!) is:\\
\[\forall k. \exists N. \forall m \geq N. |seq_m - seq_N| < 1/(k+1) \]

\item
 In all of the following variants the limit occurs in the definition.
 Therefore it is useful to define an auxiliary
 predicate \verb!Cauchy_lim_prop?!,
 in terms of which \verb!Cauchy_prop?! is defined.

Variant 2 of Cauchy (\verb!Cauchy_prop2!):
\[\begin{array}{l}
\exists y. \verb!Cauchy_lim_prop2!~seq~y \text{ where }\\
\verb!Cauchy_lim_prop2!~seq~y :=
\forall \epsilon>0. \exists N. \forall m \geq N. |seq_m - y| < \epsilon
\end{array}\]

Note that \verb!Cauchy_lim_prop2! equals \verb!seqLimit!.
\item
Variant 3 of Cauchy (\verb!Cauchy_prop3!):
\[\begin{array}{l}
\exists y. \verb!Cauchy_lim_prop3!~seq~y \text{ where }\\
\verb!Cauchy_lim_prop3!~seq~y :=
\forall k. \exists N. \forall m\geq N. |seq_m - y| < 1/(k+1)
\end{array}\]
\item
 The following variant is more restricted.\\
Variant 4 of Cauchy (\verb!Cauchy_prop4!):
\[\begin{array}{l}
\exists y. \verb!Cauchy_lim_prop4!~seq~y \text{ where }\\
\verb!Cauchy_lim_prop4!~seq~y := \forall k. |seq_k - y| < 1/(k+1)
\end{array}\]
\end{enumerate}
 So
\[ \verb!Cauchy_prop4! \Rightarrow
   \verb!Cauchy_prop3! \Leftrightarrow
   \verb!Cauchy_prop2! \Leftrightarrow
   \verb!Cauchy_prop1! \Leftrightarrow
   \verb!Cauchy_prop!\]

 Note: I don't know which formulations are useful.
% file "CReals1.v", line 120-122 *)
\index{Cauchy_prop1@\verb/Cauchy_prop1/, \emph{definition}}
\begin{verbatim}
Definition Cauchy_prop1 := [seq:(nat->IR)]
                           (k:nat)(Ex [N:nat](m:nat)((le N m) ->
                           (AbsSmall (One_div_succ k) ((seq m) [-] (seq N))))).
\end{verbatim}
% file "CReals1.v", line 127-130 *)
\index{Cauchy_lim_prop2@\verb/Cauchy_lim_prop2/, \emph{definition}}
\begin{verbatim}
Definition Cauchy_lim_prop2 := [seq:(nat->IR)][y:IR]
                               (eps:IR)(Zero [:<] eps) ->
                               (Ex [N:nat](m:nat)((le N m) ->
                               (AbsSmall eps ((seq m) [-] y)))).
\end{verbatim}
% file "CReals1.v", line 134-135 *)
\index{Cauchy_prop2@\verb/Cauchy_prop2/, \emph{definition}}
\begin{verbatim}
Definition Cauchy_prop2 := [seq:(nat->IR)]
                           (Ex [y:IR](Cauchy_lim_prop2 seq y)).
\end{verbatim}
% file "CReals1.v", line 140-143 *)
\index{Cauchy_lim_prop3@\verb/Cauchy_lim_prop3/, \emph{definition}}
\begin{verbatim}
Definition Cauchy_lim_prop3 := [seq:(nat->IR)][y:IR]
                               (k:nat)
                               (Ex [N:nat](m:nat)((le N m) ->
                               (AbsSmall (One_div_succ k) ((seq m) [-] y)))).
\end{verbatim}
% file "CReals1.v", line 147-148 *)
\index{Cauchy_prop3@\verb/Cauchy_prop3/, \emph{definition}}
\begin{verbatim}
Definition Cauchy_prop3 := [seq:(nat->IR)]
                           (Ex [y:IR](Cauchy_lim_prop3 seq y)).
\end{verbatim}
% file "CReals1.v", line 153-154 *)
\index{Cauchy_lim_prop4@\verb/Cauchy_lim_prop4/, \emph{definition}}
\begin{verbatim}
Definition Cauchy_lim_prop4 := [seq:(nat->IR)][y:IR]
                         (((m:nat)(AbsSmall (One_div_succ m) ((seq m)[-]y)))).
\end{verbatim}
% file "CReals1.v", line 158-159 *)
\index{Cauchy_prop4@\verb/Cauchy_prop4/, \emph{definition}}
\begin{verbatim}
Definition Cauchy_prop4 := [seq:(nat->IR)]
                           (Ex [y:IR](Cauchy_lim_prop4 seq y)).
\end{verbatim}
% file "CReals1.v", line 166 *)
\subsection{Inequalities of limits}
% file "CReals1.v", line 170 *)
The next lemma is equal to lemma \verb!Lim_Cauchy!.
% file "CReals1.v", line 173-174 *)
\index{Cauchy_complete@\verb/Cauchy_complete/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_complete : (seq:(CauchySeq IR))
                        (Cauchy_lim_prop2 seq (Lim seq)).
\end{verbatim}
% file "CReals1.v", line 180-181 *)
\index{less_Lim_so_less_seq@\verb/less_Lim_so_less_seq/, \emph{lemma}}
\begin{verbatim}
Lemma less_Lim_so_less_seq : (seq:(CauchySeq IR))(y:IR)(y [:<] (Lim seq)) ->
             (Ex [N:nat](m:nat)(le N m)->(y [:<] (seq m))).
\end{verbatim}
% file "CReals1.v", line 206-207 *)
\index{Lim_less_so_seq_less@\verb/Lim_less_so_seq_less/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_less_so_seq_less : (seq:(CauchySeq IR))(y:IR)((Lim seq) [:<] y) ->
                            (Ex [N:nat](m:nat)(le N m)->((seq m) [:<] y)).
\end{verbatim}
% file "CReals1.v", line 230-232 *)
\index{Lim_less_Lim_so_seq_less_seq@\verb/Lim_less_Lim_so_seq_less_seq/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_less_Lim_so_seq_less_seq :
               (seq1,seq2:(CauchySeq IR))((Lim seq1) [:<] (Lim seq2)) ->
               (Ex [N:nat](m:nat)(le N m)->((seq1 m) [:<] (seq2 m))).
\end{verbatim}
% file "CReals1.v", line 262-263 *)
The next lemma
follows from \verb!less_Lim_so_less_seq! with $y := (y+(\verb!Lim!~seq))/2$.
% file "CReals1.v", line 266-268 *)
\index{less_Lim_so@\verb/less_Lim_so/, \emph{lemma}}
\begin{verbatim}
Lemma less_Lim_so : (seq:(CauchySeq IR))(y:IR)(y [:<] (Lim seq)) ->
             (Ex [eps:IR](Zero [:<] eps) /\
                (Ex [N:nat](m:nat)(le N m)->((y[+]eps) [:<] (seq m)))).
\end{verbatim}
% file "CReals1.v", line 290-292 *)
\index{Lim_less_so@\verb/Lim_less_so/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_less_so : (seq:(CauchySeq IR))(y:IR)((Lim seq) [:<] y) ->
             (Ex [eps:IR](Zero [:<] eps) /\
               (Ex [N:nat](m:nat)(le N m)->(((seq m)[+]eps) [:<] y))).
\end{verbatim}
% file "CReals1.v", line 312-313 *)
\index{leEq_seq_so_leEq_lim@\verb/leEq_seq_so_leEq_lim/, \emph{lemma}}
\begin{verbatim}
Lemma leEq_seq_so_leEq_lim : (seq:CauchySeqR)(y:IR)((i:nat)y[:<=](seq i)) ->
                                             (y[:<=](Lim seq)).
\end{verbatim}
% file "CReals1.v", line 326-327 *)
\index{Lim_leEq_Lim@\verb/Lim_leEq_Lim/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_leEq_Lim : (seq1,seq2:CauchySeqR)((i:nat)(seq1 i)[:<=](seq2 i)) ->
                                           ((Lim seq1)[:<=](Lim seq2)).
\end{verbatim}
% file "CReals1.v", line 340-341 *)
\index{seq_leEq_so_lim_leEq@\verb/seq_leEq_so_lim_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma seq_leEq_so_lim_leEq : (seq:CauchySeqR)(y:IR)((i:nat)(seq i)[:<=]y) ->
                                    ((Lim seq)[:<=] y).
\end{verbatim}
% file "CReals1.v", line 355-356 *)
\index{limits_unique@\verb/limits_unique/, \emph{lemma}}
\begin{verbatim}
Lemma limits_unique : (seq:(CauchySeq IR))(y:IR)
                      (Cauchy_lim_prop2 seq y) -> (y [=] (Lim seq)).
\end{verbatim}
% file "CReals1.v", line 402 *)
\subsection{Equivalence of formulations of Cauchy}
% file "CReals1.v", line 406-407 *)
\index{Cauchy_prop1_prop@\verb/Cauchy_prop1_prop/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_prop1_prop : (seq:(nat->IR))
                          (Cauchy_prop1 seq) -> (Cauchy_prop seq).
\end{verbatim}
% file "CReals1.v", line 451-452 *)
\index{Cauchy_prop2_prop@\verb/Cauchy_prop2_prop/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_prop2_prop : (seq:(nat->IR))
                          (Cauchy_prop2 seq) -> (Cauchy_prop seq).
\end{verbatim}
% file "CReals1.v", line 479-480 *)
\index{Cauchy_lim_prop3_prop2@\verb/Cauchy_lim_prop3_prop2/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_lim_prop3_prop2 : (seq:(nat->IR))(y:IR)
                         (Cauchy_lim_prop3 seq y) -> (Cauchy_lim_prop2 seq y).
\end{verbatim}
% file "CReals1.v", line 511-512 *)
\index{Cauchy_prop3_prop2@\verb/Cauchy_prop3_prop2/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_prop3_prop2 : (seq:(nat->IR))
                          (Cauchy_prop3 seq) -> (Cauchy_prop2 seq).
\end{verbatim}
% file "CReals1.v", line 524-525 *)
\index{Cauchy_prop3_prop@\verb/Cauchy_prop3_prop/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_prop3_prop : (seq:(nat->IR))
                          (Cauchy_prop3 seq) -> (Cauchy_prop seq).
\end{verbatim}
% file "CReals1.v", line 536-537 *)
\index{Build_CauchySeq1@\verb/Build_CauchySeq1/, \emph{definition}}
\begin{verbatim}
Definition Build_CauchySeq1 : (seq:(nat->IR))
                         (Cauchy_prop1 seq) -> CauchySeqR.
\end{verbatim}
% file "CReals1.v", line 548-549 *)
\index{Cauchy_lim_prop4_prop3@\verb/Cauchy_lim_prop4_prop3/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_lim_prop4_prop3 : (seq:(nat->IR))(y:IR)
                        (Cauchy_lim_prop4 seq y) -> (Cauchy_lim_prop3 seq y).
\end{verbatim}
% file "CReals1.v", line 564-565 *)
\index{Cauchy_lim_prop4_prop2@\verb/Cauchy_lim_prop4_prop2/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_lim_prop4_prop2 : (seq:(nat->IR))(y:IR)
                        (Cauchy_lim_prop4 seq y) -> (Cauchy_lim_prop2 seq y).
\end{verbatim}
% file "CReals1.v", line 575-576 *)
\index{Cauchy_prop4_prop3@\verb/Cauchy_prop4_prop3/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_prop4_prop3 : (seq:(nat->IR))
                        (Cauchy_prop4 seq) -> (Cauchy_prop3 seq).
\end{verbatim}
% file "CReals1.v", line 589-590 *)
\index{Cauchy_prop4_prop@\verb/Cauchy_prop4_prop/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_prop4_prop : (seq:(nat->IR))
                             (Cauchy_prop4 seq) -> (Cauchy_prop seq).
\end{verbatim}
% file "CReals1.v", line 600-601 *)
\index{Build_CauchySeq4@\verb/Build_CauchySeq4/, \emph{definition}}
\begin{verbatim}
Definition Build_CauchySeq4 : (seq:(nat->IR))
                         (Cauchy_prop4 seq) -> CauchySeqR.
\end{verbatim}
% file "CReals1.v", line 611-612 *)
\index{Build_CauchySeq4_y@\verb/Build_CauchySeq4_y/, \emph{definition}}
\begin{verbatim}
Definition Build_CauchySeq4_y : (seq:(nat->IR))(y:IR)
                           (Cauchy_lim_prop4 seq y) -> CauchySeqR.
\end{verbatim}
% file "CReals1.v", line 622-624 *)
\index{Lim_CauchySeq4@\verb/Lim_CauchySeq4/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_CauchySeq4 : (seq:(nat->IR))(y:IR)
                       (H:(Cauchy_lim_prop4 seq y))
                       ((Lim (Build_CauchySeq4_y seq y H)) [=] y).
\end{verbatim}
% file "CReals1.v", line 638-639 *)
\index{Build_CauchySeq2@\verb/Build_CauchySeq2/, \emph{definition}}
\begin{verbatim}
Definition Build_CauchySeq2 : (seq:(nat->IR))
                         (Cauchy_prop2 seq) -> CauchySeqR.
\end{verbatim}
% file "CReals1.v", line 649-650 *)
\index{Build_CauchySeq2_y@\verb/Build_CauchySeq2_y/, \emph{definition}}
\begin{verbatim}
Definition Build_CauchySeq2_y : (seq:(nat->IR))(y:IR)
                           (Cauchy_lim_prop2 seq y) -> CauchySeqR.
\end{verbatim}
% file "CReals1.v", line 661-663 *)
\index{Lim_CauchySeq2@\verb/Lim_CauchySeq2/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_CauchySeq2 : (seq:(nat->IR))(y:IR)
                       (H:(Cauchy_lim_prop2 seq y))
                       ((Lim (Build_CauchySeq2_y seq y H)) [=] y).
\end{verbatim}
% file "CReals1.v", line 680 *)
\subsection{Properties of Cauchy sequences}
% file "CReals1.v", line 684-686 *)
\index{Cauchy_lim_sum@\verb/Cauchy_lim_sum/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_lim_sum : (seq1,seq2:(nat->IR))(y1,y2:IR)
                (Cauchy_lim_prop2 seq1 y1) -> (Cauchy_lim_prop2 seq2 y2) ->
                (Cauchy_lim_prop2 ([n:nat]((seq1 n) [+] (seq2 n))) (y1[+]y2)).
\end{verbatim}
% file "CReals1.v", line 714-715 *)
\index{Cauchy_sum@\verb/Cauchy_sum/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_sum : (seq1,seq2:CauchySeqR)
                   (Cauchy_prop ([n:nat]((seq1 n) [+] (seq2 n)))).
\end{verbatim}
% file "CReals1.v", line 727-730 *)
\index{Lim_sum@\verb/Lim_sum/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_sum : (seq1,seq2:CauchySeqR)
(Lim (Build_CauchySeq IR ([n:nat]((seq1 n) [+] (seq2 n)))
                         (Cauchy_sum seq1 seq2)))
[=] ((Lim seq1) [+] (Lim seq2)).
\end{verbatim}
% file "CReals1.v", line 742-744 *)
\index{Cauchy_lim_minus@\verb/Cauchy_lim_minus/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_lim_minus : (seq:(nat->IR))(y:IR)
                (Cauchy_lim_prop2 seq y) ->
                (Cauchy_lim_prop2 ([n:nat]([--](seq n))) ([--]y)).
\end{verbatim}
% file "CReals1.v", line 759-760 *)
\index{Cauchy_minus@\verb/Cauchy_minus/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_minus : (seq:CauchySeqR)
                     (Cauchy_prop ([n:nat]([--](seq n)))).
\end{verbatim}
% file "CReals1.v", line 771-774 *)
\index{Lim_minus@\verb/Lim_minus/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_minus : (seq:CauchySeqR)
(Lim (Build_CauchySeq IR ([n:nat]([--] (seq n)))
                         (Cauchy_minus seq)))
[=] ([--](Lim seq)).
\end{verbatim}
% file "CReals1.v", line 786-788 *)
\index{Cauchy_lim_min@\verb/Cauchy_lim_min/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_lim_min : (seq1,seq2:(nat->IR))(y1,y2:IR)
                (Cauchy_lim_prop2 seq1 y1) -> (Cauchy_lim_prop2 seq2 y2) ->
                (Cauchy_lim_prop2 ([n:nat]((seq1 n) [-] (seq2 n))) (y1[-]y2)).
\end{verbatim}
% file "CReals1.v", line 800-801 *)
\index{Cauchy_min@\verb/Cauchy_min/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_min : (seq1,seq2:CauchySeqR)
                   (Cauchy_prop ([n:nat]((seq1 n) [-] (seq2 n)))).
\end{verbatim}
% file "CReals1.v", line 813-816 *)
\index{Lim_min@\verb/Lim_min/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_min : (seq1,seq2:CauchySeqR)
(Lim (Build_CauchySeq IR ([n:nat]((seq1 n) [-] (seq2 n)))
                         (Cauchy_min seq1 seq2)))
[=] ((Lim seq1) [-] (Lim seq2)).
\end{verbatim}
% file "CReals1.v", line 829-831 *)
\index{Cauchy_lim_mult@\verb/Cauchy_lim_mult/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_lim_mult : (seq1,seq2:(nat->IR))(y1,y2:IR)
                (Cauchy_lim_prop2 seq1 y1) -> (Cauchy_lim_prop2 seq2 y2) ->
                (Cauchy_lim_prop2 ([n:nat]((seq1 n) [*] (seq2 n))) (y1[*]y2)).
\end{verbatim}
% file "CReals1.v", line 861-862 *)
\index{Cauchy_mult@\verb/Cauchy_mult/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_mult : (seq1,seq2:CauchySeqR)
                   (Cauchy_prop ([n:nat]((seq1 n) [*] (seq2 n)))).
\end{verbatim}
% file "CReals1.v", line 874-877 *)
\index{Lim_mult@\verb/Lim_mult/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_mult : (seq1,seq2:CauchySeqR)
(Lim (Build_CauchySeq IR ([n:nat]((seq1 n) [*] (seq2 n)))
                         (Cauchy_mult seq1 seq2)))
[=] ((Lim seq1) [*] (Lim seq2)).
\end{verbatim}
% file "CReals1.v", line 894-914 *)
\subsection{Maximum}
Let us first consider the informal definition of maximum.

\begin{definition}\label{defmax}
Given $x,y\in\RR$, we define the maximum of $x$ and $y$. First
construct a sequence $(y'_i)_{i\in\NN}$ such that
$$\forall i\in \NN[-\frac{1}{i}< y-y'_i <\frac{1}{i} \wedge y'_i \noto
x].$$ This is is possible (Lemma \verb!exis_AFS! below). Note that
$(y'_i)_{i\in\NN}$ is a Cauchy sequence and $y=\lim_{i\rightarrow \infty}
y'_i$. Now define the sequence $(s_i)_{i\in\NN}$ by
$$s_i :=
\left\{ \begin{array}{rcl}
        x &\mbox{if}& x>y'_i,\\
        y'_i &\mbox{if}& x<y'_i,\\
       \end{array}\right.$$
Now $(s_i)_{i\in\NN}$ is a Cauchy sequence and we define
$$\maxx (x ,y) := \lim_{i\rightarrow \infty} s_i.$$
\end{definition}

First we will consider the ``apart from'' sequence $y'_i$, then we define
the maximum function, and then prove its properties.
% file "CReals1.v", line 919-926 *)
\subsubsection{The ``apart from'' sequence}
Given an $x$ and $y$, the ``apart from''
sequence is a Cauchy sequence $y'_i$ with limit $y$
and with $y'_i$ apart from $x$ for all $i$.
Below, this ``apart from sequence'' $y'$ is called \verb!AFS!.
\begin{convention}
Let \verb!x! and \verb!y! be reals.
\end{convention}
% file "CReals1.v", line 932-934 *)
\index{Inform_cotrans_less_unfolded@\verb/Inform_cotrans_less_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma Inform_cotrans_less_unfolded
     : (R:COrdField; a,b:R)
        (a [:<] b)->(c:R){a [:<] c}+{c [:<] b}.
\end{verbatim}
% file "CReals1.v", line 943-944 *)
\index{exis_AFS@\verb/exis_AFS/, \emph{lemma}}
\begin{verbatim}
Lemma exis_AFS : (eps:IR)(Zero [:<] eps) ->
                    (sig IR [y':IR]((AbsSmall eps (y' [-] y)) /\ (y' [#] x))).
\end{verbatim}
% file "CReals1.v", line 989 *)
Now we construct the sequence $y'_i$, with name \verb!AFS!.
% file "CReals1.v", line 992-994 *)
\index{AFS@\verb/AFS/, \emph{definition}}
\begin{verbatim}
Definition AFS := [i:nat](proj1_sig ? ? (exis_AFS (One_div_succ i)
                         (one_div_succ_pos ? i)))
               :  nat->IR.
\end{verbatim}
% file "CReals1.v", line 998-999 *)
\index{AFS_prop@\verb/AFS_prop/, \emph{lemma}}
\begin{verbatim}
Lemma AFS_prop :
     (i:nat)((AbsSmall (One_div_succ i) ((AFS i)[-]y)) /\ ((AFS i) [#] x)).
\end{verbatim}
% file "CReals1.v", line 1006 *)
\index{AFS_ap@\verb/AFS_ap/, \emph{lemma}}
\begin{verbatim}
Lemma AFS_ap : (i:nat)((AFS i) [#] x).
\end{verbatim}
% file "CReals1.v", line 1014 *)
\verb!AFS x y! is a Cauchy-sequence, and has limit \verb!y!.
% file "CReals1.v", line 1017 *)
\index{AFS_Cauchy_lim@\verb/AFS_Cauchy_lim/, \emph{lemma}}
\begin{verbatim}
Lemma AFS_Cauchy_lim : (Cauchy_lim_prop4 AFS y).
\end{verbatim}
% file "CReals1.v", line 1027 *)
\index{Cauchy_prop_AFS@\verb/Cauchy_prop_AFS/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_prop_AFS : (Cauchy_prop AFS).
\end{verbatim}
% file "CReals1.v", line 1037 *)
Now we make \verb!AFCS! which is a {\em Cauchy} sequence.
% file "CReals1.v", line 1040 *)
\index{AFCS@\verb/AFCS/, \emph{definition}}
\begin{verbatim}
Definition AFCS : (CauchySeq IR).
\end{verbatim}
% file "CReals1.v", line 1049 *)
\index{Lim_AFCS@\verb/Lim_AFCS/, \emph{lemma}}
\begin{verbatim}
Lemma Lim_AFCS : (Lim AFCS) [=] y.
\end{verbatim}
% file "CReals1.v", line 1057 *)
\index{AFCS_ap@\verb/AFCS_ap/, \emph{lemma}}
\begin{verbatim}
Lemma AFCS_ap : (i:nat)((AFCS i) [#] x).
\end{verbatim}
% file "CReals1.v", line 1069-1074 *)
\subsubsection{The actual max function}

\begin{convention}
Let \verb!x! and \verb!y! be reals
(we will define the maximum of \verb!x! and \verb!y!).
\end{convention}
% file "CReals1.v", line 1080 *)
\index{Inform_ap_imp_less@\verb/Inform_ap_imp_less/, \emph{lemma}}
\begin{verbatim}
Lemma Inform_ap_imp_less : (a,b:IR)((a [#] b) -> {a[:<]b} + {b[:<]a}).
\end{verbatim}
% file "CReals1.v", line 1089 *)
\verb!Max_seq i! corresponds with $s_i$ in informal Definition~\ref{defmax}.
% file "CReals1.v", line 1092 *)
\index{Max_seq@\verb/Max_seq/, \emph{definition}}
\begin{verbatim}
Definition Max_seq : nat->IR.
\end{verbatim}
% file "CReals1.v", line 1106 *)
\index{Max_is_x@\verb/Max_is_x/, \emph{lemma}}
\begin{verbatim}
Lemma Max_is_x : (i:nat)((AFS x y i) [:<]x) -> (Max_seq i) = x.
\end{verbatim}
% file "CReals1.v", line 1117 *)
\index{Max_is_AFS_i@\verb/Max_is_AFS_i/, \emph{lemma}}
\begin{verbatim}
Lemma Max_is_AFS_i : (i:nat)(x[:<](AFS x y i)) -> (Max_seq i) = (AFS x y i).
\end{verbatim}
% file "CReals1.v", line 1129 *)
\index{Cauchy_Max_seq@\verb/Cauchy_Max_seq/, \emph{lemma}}
\begin{verbatim}
Lemma Cauchy_Max_seq : (Cauchy_prop Max_seq).
\end{verbatim}
% file "CReals1.v", line 1164 *)
\index{Max_CauchySeq@\verb/Max_CauchySeq/, \emph{definition}}
\begin{verbatim}
Definition Max_CauchySeq : CauchySeqR.
\end{verbatim}
% file "CReals1.v", line 1172 *)
\index{MAX@\verb/MAX/, \emph{definition}}
\begin{verbatim}
Definition MAX : IR.
\end{verbatim}
% file "CReals1.v", line 1179-1190 *)
Constructively, the elementary properties of the maximum function are:
\begin{itemize}
\item $x\leq \maxx (x,y)$,
\item $x\leq \maxx (x,y)$,
\item $z<\maxx(x,y) \Rightarrow z<x \vee z<y$.
\end{itemize}
(This can be more concisely expressed as
 $z<\maxx(x,y) \Leftrightarrow z<x \vee z<y$).
From these elementary properties we can prove all other properties, including
strong extensionality.
With strong extensionality, we can make the binary {\em operation} \verb!Max!.
(So \verb!Max! is \verb!MAX! coupled with some proofs.)
% file "CReals1.v", line 1196 *)
\index{lft_leEq_MAX@\verb/lft_leEq_MAX/, \emph{lemma}}
\begin{verbatim}
Lemma lft_leEq_MAX : x[:<=]MAX.
\end{verbatim}
% file "CReals1.v", line 1220 *)
\index{rht_leEq_MAX@\verb/rht_leEq_MAX/, \emph{lemma}}
\begin{verbatim}
Lemma rht_leEq_MAX : y[:<=]MAX.
\end{verbatim}
% file "CReals1.v", line 1241 *)
\index{less_MAX_imp@\verb/less_MAX_imp/, \emph{lemma}}
\begin{verbatim}
Lemma less_MAX_imp : (z:IR)(z[:<]MAX) -> (z[:<]x) \/ (z[:<]y).
\end{verbatim}
% file "CReals1.v", line 1293 *)
\index{MAX_strong_ext@\verb/MAX_strong_ext/, \emph{lemma}}
\begin{verbatim}
Lemma MAX_strong_ext : (bin_op_strong_ext ? MAX).
\end{verbatim}
% file "CReals1.v", line 1328 *)
\index{MAX_well_def@\verb/MAX_well_def/, \emph{lemma}}
\begin{verbatim}
Lemma MAX_well_def : (bin_op_well_def IR MAX).
\end{verbatim}
% file "CReals1.v", line 1338 *)
\subsubsection{Properties of Max}
% file "CReals1.v", line 1342 *)
\index{Max@\verb/Max/, \emph{definition}}
\begin{verbatim}
Definition Max := (Build_CSetoid_bin_op ? MAX MAX_well_def MAX_strong_ext).
\end{verbatim}
% file "CReals1.v", line 1346 *)
\index{lft_leEq_Max@\verb/lft_leEq_Max/, \emph{lemma}}
\begin{verbatim}
Lemma lft_leEq_Max : (x,y:IR)x [:<=] (Max x y).
\end{verbatim}
% file "CReals1.v", line 1354 *)
\index{rht_leEq_Max@\verb/rht_leEq_Max/, \emph{lemma}}
\begin{verbatim}
Lemma rht_leEq_Max : (x,y:IR)y [:<=] (Max x y).
\end{verbatim}
% file "CReals1.v", line 1362 *)
\index{less_Max_imp@\verb/less_Max_imp/, \emph{lemma}}
\begin{verbatim}
Lemma less_Max_imp : (x,y,z:IR)(z[:<](Max x y)) -> (z[:<]x) \/ (z[:<]y).
\end{verbatim}
% file "CReals1.v", line 1370 *)
\index{Max_leEq@\verb/Max_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma Max_leEq : (x,y,z:IR)(x[:<=]z) -> (y[:<=]z) -> (Max x y)[:<=]z.
\end{verbatim}
% file "CReals1.v", line 1386 *)
\index{Max_less@\verb/Max_less/, \emph{lemma}}
\begin{verbatim}
Lemma Max_less : (x,y,z:IR)(x [:<] z) -> (y [:<] z) -> (Max x y) [:<] z.
\end{verbatim}
% file "CReals1.v", line 1408-1412 *)
\index{equiv_imp_eq_max@\verb/equiv_imp_eq_max/, \emph{lemma}}
\begin{verbatim}
Lemma equiv_imp_eq_max : (x,x',m:IR)
  ((y:IR)(x [:<] y) -> (x' [:<] y) -> (m [:<] y)) ->
  ((y:IR)(m [:<] y) -> (x [:<] y)) ->
  ((y:IR)(m [:<] y) -> (x' [:<] y)) ->
    (Max x x') [=] m.
\end{verbatim}
% file "CReals1.v", line 1425 *)
\index{Max_id@\verb/Max_id/, \emph{lemma}}
\begin{verbatim}
Lemma Max_id : (x:IR)(Max x x) [=] x.
\end{verbatim}
% file "CReals1.v", line 1432 *)
\index{Max_comm@\verb/Max_comm/, \emph{lemma}}
\begin{verbatim}
Lemma Max_comm : (x,y:IR)(Max x y)[=](Max y x).
\end{verbatim}
% file "CReals1.v", line 1446-1448 *)
\begin{lemma} \label{lemmaxgeq}
$\forall x,y\in\RR[ x\leq y \leftrightarrow \maxx(x,y) = y]$.
\end{lemma}
% file "CReals1.v", line 1452 *)
\index{leEq_imp_Max_is_rht@\verb/leEq_imp_Max_is_rht/, \emph{lemma}}
\begin{verbatim}
Lemma leEq_imp_Max_is_rht : (x,y:IR)(x [:<=] y) -> (Max x y) [=] y.
\end{verbatim}
% file "CReals1.v", line 1463 *)
\index{Max_is_rht_imp_leEq@\verb/Max_is_rht_imp_leEq/, \emph{lemma}}
\begin{verbatim}
Lemma Max_is_rht_imp_leEq : (x,y:IR)((Max x y) [=] y) -> (x [:<=] y).
\end{verbatim}
% file "CReals1.v", line 1492 *)
\subsection{Absolute value}
% file "CReals1.v", line 1496-1497 *)
\index{ABSIR@\verb/ABSIR/, \emph{definition}}
\begin{verbatim}
Definition ABSIR := [x:IR](Max x ([--]x))
                 :  IR -> IR.
\end{verbatim}
% file "CReals1.v", line 1502 *)
\index{ABSIR_strong_ext@\verb/ABSIR_strong_ext/, \emph{lemma}}
\begin{verbatim}
Lemma ABSIR_strong_ext : (un_op_strong_ext ? ABSIR).
\end{verbatim}
% file "CReals1.v", line 1525 *)
\index{ABSIR_well_def@\verb/ABSIR_well_def/, \emph{lemma}}
\begin{verbatim}
Lemma ABSIR_well_def : (un_op_well_def ? ABSIR).
\end{verbatim}
% file "CReals1.v", line 1533-1534 *)
\index{AbsIR@\verb/AbsIR/, \emph{definition}}
\begin{verbatim}
Definition AbsIR := (Build_CSetoid_un_op ? ABSIR ABSIR_well_def ABSIR_strong_ext)
                 :  (CSetoid_un_op IR).
\end{verbatim}
% file "CReals1.v", line 1538 *)
\index{abs_wdIR@\verb/abs_wdIR/, \emph{lemma}}
\begin{verbatim}
Lemma abs_wdIR: (x,y:IR) (x[=]y)->(AbsIR x) [=] (AbsIR y).
\end{verbatim}
% file "CReals1.v", line 1544-1545 *)
\index{Abs_wd_lft_unfolded@\verb/Abs_wd_lft_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma Abs_wd_lft_unfolded : (x,y,e:IR)(x[=]y) -> ((AbsIR x)[:<]e) ->
((AbsIR y)[:<]e).
\end{verbatim}
% file "CReals1.v", line 1555-1556 *)
\index{Abs_wd_rht_unfolded@\verb/Abs_wd_rht_unfolded/, \emph{lemma}}
\begin{verbatim}
Lemma Abs_wd_rht_unfolded : (x,y,e:IR)(x[=]y) -> (e[:<](AbsIR x)) ->
(e[:<](AbsIR y)).
\end{verbatim}
% file "CReals1.v", line 1566 *)
\index{AbsIRz_isz@\verb/AbsIRz_isz/, \emph{lemma}}
\begin{verbatim}
Lemma AbsIRz_isz :(AbsIR Zero)[=]Zero.
\end{verbatim}
% file "CReals1.v", line 1591-1592 *)
\index{abs_eq_abssmall@\verb/abs_eq_abssmall/, \emph{lemma}}
\begin{verbatim}
Lemma abs_eq_abssmall :(x,e:IR)([--]e [:<] x) -> (x [:<] e) ->
	(AbsSmall e x).
\end{verbatim}
% file "CReals1.v", line 1600-1601 *)
\index{abs_eq_abssmall2@\verb/abs_eq_abssmall2/, \emph{lemma}}
\begin{verbatim}
Lemma abs_eq_abssmall2 :(x,e:IR)(Zero[:<]e) -> ((AbsIR x) [:<] e) ->
	(AbsSmall e x).
\end{verbatim}
% file "RealFuncts.v", line 6 *)
\section{Functions on Reals}
% file "RealFuncts.v", line 15-27 *)
\subsection{Continuity}
Let \verb!f! be a unary setoid operation on \verb!IR! and
let \verb!f2! be a binary setoid operation on \verb!IR!.

We use the following notations for intervals. \verb!Intclr a b! for the
closed interval $[a,b]$, \verb!Intolr a b! for the
open interval ${<}a,b{>}$, \verb!Intcl a! for the
left-closed interval $[a,\infty{>}$, \verb!Intol a! for the
left-open interval ${<}a,\infty{>}$, \verb!Intcr b! for the
right-closed interval ${<}-\infty,b]$.

Intervals like $[a,b]$ are defined for arbitrary reals $a,b$ (being
$\emptyset$ for $a>b$).
% file "RealFuncts.v", line 31-40 *)
\index{Intclr@\verb/Intclr/, \emph{definition}}
\index{Intolr@\verb/Intolr/, \emph{definition}}
\index{Intol@\verb/Intol/, \emph{definition}}
\index{Intcl@\verb/Intcl/, \emph{definition}}
\index{Intcr@\verb/Intcr/, \emph{definition}}
\begin{verbatim}
Definition Intclr [a,b:IR; x:IR] : Prop :=
  (a [:<=] x) /\ (x [:<=] b).
Definition Intolr [a,b:IR; x:IR] : Prop :=
  (a [:<] x) /\ (x [:<] b).
Definition Intol [a:IR; x:IR] : Prop :=
  (a [:<] x).
Definition Intcl [a:IR; x:IR] : Prop :=
  (a [:<=] x).
Definition Intcr [b:IR; x:IR] : Prop :=
   (x [:<=] b).
\end{verbatim}
% file "RealFuncts.v", line 44-48 *)
The limit of $f(x)$ as $x$ goes to $p = l$, for both unary and binary
functions:\\
The limit of $f$ in $p$ is $l$ if $\forall e\in\RR (0< e) \rightarrow
\exists d\in\RR (0< d) /\
 \forall x\in\RR(-d<p-x < d<) \rightarrow(AbsSmall -e <l-f(x) <e)$
% file "RealFuncts.v", line 51-54 *)
\index{funLim@\verb/funLim/, \emph{definition}}
\begin{verbatim}
Definition funLim [p,l:IR] : Prop :=
  (e:IR)(Zero [:<] e)->
    (Ex [d:IR] (Zero [:<] d) /\
               (x:IR)(AbsSmall d (p[-]x)) -> (AbsSmall e (l[-](f x)))).
\end{verbatim}
% file "RealFuncts.v", line 57-56 *)
% file "RealFuncts.v", line 59-62 *)
\index{funLim_Cauchy@\verb/funLim_Cauchy/, \emph{definition}}
\begin{verbatim}
Definition funLim_Cauchy [p,l:IR] : Prop :=
  (s:CauchySeqR)((Lim s)[=] p) ->
    	(e:IR)(Zero [:<] e) -> (Ex [N:nat](m:nat)(le N m)
			   -> (AbsSmall e ((f(s m))[-]l))).
\end{verbatim}
% file "RealFuncts.v", line 65-64 *)
% file "RealFuncts.v", line 86-88 *)
The limit of $f$ in $(p,p')$ is $l$ if $\forall e\in\RR (0< e) \rightarrow
\exists d\in\RR (0< d) /\ \forall x\in\RR(-d<p-x < d<) \rightarrow
(-d<p'-y < d<) \rightarrow(AbsSmall -e <l-f(x,y) <e)$
% file "RealFuncts.v", line 91-95 *)
\index{funLim2@\verb/funLim2/, \emph{definition}}
\begin{verbatim}
Definition funLim2 [p,p',l:IR] : Prop :=
  (e:IR)(Zero [:<] e)->
    (Ex [d:IR] (Zero [:<] d) /\
               (x,y:IR)(AbsSmall d (p[-]x)) -> (AbsSmall d (p'[-]y))
                        ->(AbsSmall e (l[-](f2 x y)))).
\end{verbatim}
% file "RealFuncts.v", line 99-101 *)
The function $f$ is continuous at $p$ if the limit of $f(x)$ as $x$ goes to $p$
is $f(p)$.  This is the $\epsilon/\delta$ definition.
We also give the defintion with limits of Cauchy sequences.
% file "RealFuncts.v", line 104-106 *)
\index{continAt@\verb/continAt/, \emph{definition}}
\index{continAtCauchy@\verb/continAtCauchy/, \emph{definition}}
\index{continAt2@\verb/continAt2/, \emph{definition}}
\begin{verbatim}
Definition continAt [p:IR]: Prop := (funLim p (f p)).
Definition continAtCauchy [p:IR]: Prop := (funLim_Cauchy p (f p)).
Definition continAt2 [p,q:IR]: Prop := (funLim2 p q (f2 p q)).
\end{verbatim}
% file "RealFuncts.v", line 111 *)
\index{continAt_prop1@\verb/continAt_prop1/, (\emph{commented out})}
\begin{verbatim}
Ax_iom continAt_prop1 :(p:IR)(continAt p)->(continAtCauchy p).
\end{verbatim}
% file "RealFuncts.v", line 116-121 *)
\index{contin@\verb/contin/, \emph{definition}}
\index{continCauchy@\verb/continCauchy/, \emph{definition}}
\index{contin2@\verb/contin2/, \emph{definition}}
\begin{verbatim}
Definition contin :Prop :=
  (x:IR)(continAt x).
Definition continCauchy :Prop :=
  (x:IR)(continAtCauchy x).
Definition contin2 :Prop :=
  (x,y:IR)(continAt2 x y).
\end{verbatim}
% file "RealFuncts.v", line 125-126 *)
Continuous on a closed, resp.\ open, resp.\ left open, resp.\ left closed
interval
% file "RealFuncts.v", line 129-136 *)
\index{continOnc@\verb/continOnc/, \emph{definition}}
\index{continOno@\verb/continOno/, \emph{definition}}
\index{continOnol@\verb/continOnol/, \emph{definition}}
\index{continOncl@\verb/continOncl/, \emph{definition}}
\begin{verbatim}
Definition continOnc [a,b:IR]: Prop :=
  (x:IR)(Intclr a b x) -> (continAt x).
Definition continOno [a,b:IR]: Prop :=
  (x:IR)(Intolr a b x) -> (continAt x).
Definition continOnol [a:IR]: Prop :=
  (x:IR)(Intol a x) -> (continAt x).
Definition continOncl [a:IR]: Prop :=
  (x:IR)(Intcl a x) -> (continAt x).
\end{verbatim}
% file "RealFuncts.v", line 143-144 *)
If $\lim_{x->p} (f x) = l$, then for every sequence $p_n$ whose
limit is $p$, $\lim_{n->\infty} f (p_n) =l$.
% file "RealFuncts.v", line 147-149 *)
\index{funLim_SeqLimit@\verb/funLim_SeqLimit/, \emph{lemma}}
\begin{verbatim}
Lemma funLim_SeqLimit:
  (p,l:IR)(fl:(funLim p l))
    (pn:nat->IR)(sl:(SeqLimit pn p)) (SeqLimit ([n:nat](f (pn n))) l).
\end{verbatim}
% file "RealFuncts.v", line 170-172 *)
Now the same Lemma in terms of Cauchy sequences: if $\lim_{x->p} (f x) = l$,
then for every Cauchy sequence $s_n$ whose
limit is $p$, $\lim_{n->\infty} f (s_n) =l$.
% file "RealFuncts.v", line 175-178 *)
\index{funLim_isCauchy@\verb/funLim_isCauchy/, (\emph{commented out})}
\begin{verbatim}
Ax_iom funLim_isCauchy:
  (p,l:IR)(funLim p l)->(s:CauchySeqR)((Lim s)[=] p) ->
	(e:IR)(Zero [:<] e) -> (Ex [N:nat](m:nat)(le N m)
			   -> (AbsSmall e ((s m)[-](s N)))).
\end{verbatim}
% file "RealFuncts.v", line 186-198 *)
\index{str_monot@\verb/str_monot/, \emph{definition}}
\index{str_monotOnc@\verb/str_monotOnc/, \emph{definition}}
\index{str_monotOncl@\verb/str_monotOncl/, \emph{definition}}
\index{str_monotOnol@\verb/str_monotOnol/, \emph{definition}}
\begin{verbatim}
Definition str_monot  := (x,y:IR)(x[:<]y)->((f x)[:<](f y)).

Definition str_monotOnc  := [a,b:IR]
         (x,y:IR)(Intclr a b x)->(Intclr a b y)
                  ->(x[:<]y)->((f x)[:<](f y)).

Definition str_monotOncl  := [a:IR]
         (x,y:IR)(Intcl a x)->(Intcl a y)
                  ->(x[:<]y)->((f x)[:<](f y)).

Definition str_monotOnol  := [a:IR]
         (x,y:IR)(Intol a x)->(Intol a y)
                  ->(x[:<]y)->((f x)[:<](f y)).
\end{verbatim}
% file "RealFuncts.v", line 211-216 *)
$\forall c\in\RR (f\mbox{ strongly monotonic on }[c,\infty>)
\rightarrow \forall a,b\in\RR(c <a)\rightarrow( c< b)\rightarrow\ (f (a)<0)
\rightarrow\ (0:<f(b))
         \rightarrow \forall x,y\in\RR (a\leq x\leq b)\rightarrow
	(a\leq y\leq b)\rightarrow (x<y)
                \rightarrow \exists z\in\RR(x\leq z\leq y)\wedge(f(z)\noto 0))$
% file "RealFuncts.v", line 219-222 *)
\index{strmon_ivt_prem@\verb/strmon_ivt_prem/, (\emph{commented out})}
\begin{verbatim}
Ax_iom strmon_ivt_prem : (c:IR)(str_monotOncl c) ->
  (a,b:IR)(Intcl c a)->(Intcl c b)-> ((f a)[:<] Zero) -> (Zero [:<](f b))
         -> (x,y:IR)(Intclr a b x)->(Intclr a b y) -> (x[:<]y)
                ->(EX z:IR | (Intclr x y z)/\((f z)[#]Zero)).
\end{verbatim}
% file "RealFuncts.v", line 227-230 *)
$\forall c\in\RR (f\mbox{ strongly monotonic on }[c,\infty>)
\rightarrow \forall a,b\in\RR(a<b) \rightarrow(c <a)\rightarrow( c< b)
\rightarrow(f (a)<0)\rightarrow (0:<f(b))
         \rightarrow \exists z\in\RR(a\leq z\leq b)\wedge(f(z)= 0))$
% file "RealFuncts.v", line 233-236 *)
\index{strmoncl_imp_ivt@\verb/strmoncl_imp_ivt/, (\emph{commented out})}
\begin{verbatim}
Ax_iom strmoncl_imp_ivt : (c:IR)(str_monotOncl c)
             -> (a,b:IR)(a[:<]b)->(Intcl c a)->(Intcl c b)
                 -> ((f a)[:<]Zero) -> (Zero [:<] (f b))
                     -> (EX z:IR | (Intclr a b z)/\ ((f z)[=]Zero)).
\end{verbatim}
% file "CMetricFields.v", line 9-13 *)
\index{is_CMetricField@\verb/is_CMetricField/, \emph{record}}
\begin{verbatim}
Record is_CMetricField [F: CField; abs : (CSetoid_fun F IR)] : Prop :=
 {ax_abs_gt_zero   : (x:F)(Zero[:<=] (abs x));
  ax_abs_resp_mult : (x,y:F)(abs(x[*]y)) [=](abs x)[*](abs y);
  ax_abs_triangle  : (x,y:F)(abs(x[+]y)) [:<=] (abs x)[+](abs y)
 }.
\end{verbatim}
% file "CMetricFields.v", line 17-21 *)
\index{CMetricField@\verb/CMetricField/, \emph{record}}
\begin{verbatim}
Record CMetricField : Type :=
  {cmf_crr   :> CField;
   cmf_abs   :  (CSetoid_fun cmf_crr IR);
   cmf_proof :  (is_CMetricField cmf_crr cmf_abs)
  }.
\end{verbatim}
% file "CMetricFields.v", line 31-33 *)
\index{MCauchy_prop@\verb/MCauchy_prop/, \emph{definition}}
\begin{verbatim}
Definition MCauchy_prop [g:nat -> F]: Prop :=
   (e:IR)(Zero [:<] e) -> (Ex [N:nat](m:nat)(le N m)
			   -> (MAbs((g m)[-](g N)))[:<]e ).
\end{verbatim}
% file "CMetricFields.v", line 37-40 *)
\index{MCauchySeq@\verb/MCauchySeq/, \emph{record}}
\begin{verbatim}
Record MCauchySeq : Set :=
  {MCS_seq  :> nat -> F;
   MCS_proof: (MCauchy_prop MCS_seq)
  }.
\end{verbatim}
% file "CMetricFields.v", line 44-46 *)
\index{MseqLimit@\verb/MseqLimit/, \emph{definition}}
\begin{verbatim}
Definition MseqLimit [seq:nat->F; lim:F]: Prop :=
   (e:IR)(Zero [:<] e) -> (Ex [N:nat](m:nat)(le N m)
				-> (MAbs((seq m)[-]lim))[:<]e ).
\end{verbatim}
% file "CMetricFields.v", line 50-51 *)
\index{is_MCauchyCompl@\verb/is_MCauchyCompl/, \emph{definition}}
\begin{verbatim}
Definition is_MCauchyCompl  [lim : MCauchySeq -> F] : Prop :=
  (s:MCauchySeq)(MseqLimit s (lim s)).
\end{verbatim}
% file "CSumsReals.v", line 6-13 *)
\section{Sums over Reals}

\begin{convention}
Let \verb!c! be a real.
\end{convention}

Here we prove that
\[\Sigma_{m\leq i \leq n}~c^k = \frac{c^{n+1}-c^m}{c-1}.\]
% file "CSumsReals.v", line 21-22 *)
\index{sum0_c_exp@\verb/sum0_c_exp/, \emph{lemma}}
\begin{verbatim}
Lemma sum0_c_exp : (H:c[-]One[#]Zero)(m:nat)
        ((sum0 IR m [i:nat](c[^]i)) [=] ((c[^]m [-] One)[/](c [-] One)[//]H)).
\end{verbatim}
% file "CSumsReals.v", line 37-39 *)
\index{sum_c_exp@\verb/sum_c_exp/, \emph{lemma}}
\begin{verbatim}
Lemma sum_c_exp : (H:c[-]One[#]Zero)
                      (m,n:nat)((Sum m n [i:nat](c[^]i))
                      [=]((c[^](S n) [-] c[^]m)[/](c [-] One)[//]H)).
\end{verbatim}
% file "CSumsReals.v", line 51 *)
The following formulation is often more useful if $c<1$.
% file "CSumsReals.v", line 54-56 *)
\index{sum_c_exp'@\verb/sum_c_exp'/, \emph{lemma}}
\begin{verbatim}
Lemma sum_c_exp' : (H:One[-]c[#]Zero)
                       (m,n:nat)((Sum m n [i:nat](c[^]i))
		        [=]((c[^]m [-] c[^](S n))[/](One [-] c)[//]H)).
\end{verbatim}
% file "NRootIR.v", line 6 *)
\section{Roots of Real Numbers}
% file "NRootIR.v", line 10 *)
\subsection{roots exist}
% file "NRootIR.v", line 23 *)
\index{nrootIR@\verb/nrootIR/, \emph{lemma}}
\begin{verbatim}
Lemma nrootIR : (EX x | (Zero [:<=] x) /\ (x[^]n [=] c)).
\end{verbatim}
% file "NRootIR.v", line 65-67 *)
\index{nroot'@\verb/nroot'/, \emph{lemma}}
\begin{verbatim}
(* nth roots exist *)
Lemma nroot': (x:IR)(k:nat)(Zero [:<=] x)->(lt O k)->
  (sig IR [y:IR]((Zero [:<=] y) /\ (y[^]k [=] x))).
\end{verbatim}
% file "NRootIR.v", line 76-77 *)
\index{nroot@\verb/nroot/, \emph{lemma}}
\begin{verbatim}
Lemma nroot: (x:IR)(k:nat)(Zero [:<] x)->(lt O k)->
  (sig IR [y:IR]((Zero [:<=] y) /\ (y[^]k [=] x))).
\end{verbatim}
% file "NRootIR.v", line 85-86 *)
\index{nroot_fun@\verb/nroot_fun/, \emph{definition}}
\begin{verbatim}
Definition nroot_fun [x:IR; k:nat; posx:(Zero [:<] x); posk:(lt O k)] : IR :=
  (proj1_sig ?? (nroot x k posx posk)).
\end{verbatim}
% file "NRootIR.v", line 90-91 *)
\index{nroot_power@\verb/nroot_power/, \emph{lemma}}
\begin{verbatim}
Lemma nroot_power : (x:IR; k:nat; posx:(Zero [:<] x); posk:(lt O k))
  (nroot_fun x k posx posk)[^]k [=] x.
\end{verbatim}
% file "NRootIR.v", line 101-102 *)
\index{nroot_pos@\verb/nroot_pos/, \emph{lemma}}
\begin{verbatim}
Lemma nroot_pos : (x:IR; k:nat; posx:(Zero [:<] x); posk:(lt O k))
  Zero [:<] (nroot_fun x k posx posk).
\end{verbatim}
% file "NRootIR.v", line 120-121 *)
\index{nroot_power'@\verb/nroot_power'/, \emph{lemma}}
\begin{verbatim}
Lemma nroot_power' : (x:IR; k:nat; posxk:(Zero [:<] x[^]k); posk:(lt O k))
  (Zero [:<=] x) -> (nroot_fun (x[^]k) k posxk posk) [=] x.
\end{verbatim}
% file "NRootIR.v", line 131-133 *)
\index{nroot_pres_lt@\verb/nroot_pres_lt/, \emph{lemma}}
\begin{verbatim}
Lemma nroot_pres_lt :
	(x,y:IR;k:nat;zltx:(Zero[:<]x);zlty:(Zero[:<]y);lt0k:(lt (0) k))
	(x[:<]y)->((nroot_fun x k zltx lt0k) [:<] (nroot_fun y k zlty lt0k)).
\end{verbatim}
% file "NRootIR.v", line 142-143 *)
\index{nroot_pres_lt1@\verb/nroot_pres_lt1/, \emph{lemma}}
\begin{verbatim}
Lemma nroot_pres_lt1 : (x:IR;k:nat;zltx:(Zero[:<]x);lt0k:(lt (0) k))
	(x[:<]One)->((nroot_fun x k zltx lt0k) [:<] One).
\end{verbatim}
% file "NRootIR.v", line 158 *)
\subsection{square root}
% file "NRootIR.v", line 162-163 *)
\index{sqrt@\verb/sqrt/, \emph{definition}}
\begin{verbatim}
Definition sqrt [x:IR; xpos:(Zero [:<=] x)] : IR :=
  (proj1_sig ?? (nroot' x (2) xpos (lt_O_Sn (1)))).
\end{verbatim}
% file "NRootIR.v", line 167 *)
\index{sqrt_sqr@\verb/sqrt_sqr/, \emph{lemma}}
\begin{verbatim}
Lemma sqrt_sqr : (x:IR)(xpos:(Zero [:<=] x))((sqrt x xpos)[^](2) [=] x).
\end{verbatim}
% file "NRootIR.v", line 177 *)
\index{sqrt_nonneg@\verb/sqrt_nonneg/, \emph{lemma}}
\begin{verbatim}
Lemma sqrt_nonneg : (x:IR)(xpos:(Zero [:<=] x))(Zero [:<=] (sqrt x xpos)).
\end{verbatim}
% file "NRootIR.v", line 185-186 *)
\index{sqrt_wd@\verb/sqrt_wd/, \emph{lemma}}
\begin{verbatim}
Lemma sqrt_wd : (x,y:IR)(xpos:(Zero [:<=] x))(ypos:(Zero [:<=] y))
  (x [=] y)->((sqrt x xpos) [=] (sqrt y ypos)).
\end{verbatim}
% file "NRootIR.v", line 198-199 *)
\index{sqrt_to_nonneg@\verb/sqrt_to_nonneg/, \emph{lemma}}
\begin{verbatim}
Lemma sqrt_to_nonneg : (x:IR)(Zero [:<=] x)->(x2pos:(Zero [:<=] x[^](2)))
  ((sqrt x[^](2) x2pos) [=] x).
\end{verbatim}
% file "NRootIR.v", line 208-209 *)
\index{sqrt_to_nonpos@\verb/sqrt_to_nonpos/, \emph{lemma}}
\begin{verbatim}
Lemma sqrt_to_nonpos : (x:IR)(x [:<=] Zero)->(x2pos:(Zero [:<=] x[^](2)))
  ((sqrt x[^](2) x2pos) [=] [--]x).
\end{verbatim}
% file "NRootIR.v", line 220-222 *)
\index{sqrt_mult@\verb/sqrt_mult/, \emph{lemma}}
\begin{verbatim}
Lemma sqrt_mult : (x,y:IR)
  (xpos:(Zero [:<=] x))(ypos:(Zero [:<=] y))(xypos:(Zero [:<=] x[*]y))
    ((sqrt x[*]y xypos) [=] (sqrt x xpos)[*](sqrt y ypos)).
\end{verbatim}
% file "NRootIR.v", line 237-239 *)
\index{sqrt_mult_wd@\verb/sqrt_mult_wd/, \emph{lemma}}
\begin{verbatim}
Lemma sqrt_mult_wd :
  (x,y,z:IR)(xpos:(Zero [:<=] x))(ypos:(Zero [:<=] y))(zpos:(Zero [:<=] z))
    (z [=] x[*]y) -> (sqrt z zpos) [=] (sqrt x xpos)[*](sqrt y ypos).
\end{verbatim}
% file "NRootIR.v", line 248-249 *)
\index{sqrt_less@\verb/sqrt_less/, \emph{lemma}}
\begin{verbatim}
Lemma sqrt_less : (x,y:IR)(ypos:(Zero [:<=] y))
  (x[^](2) [:<] y)->(x [:<] (sqrt y ypos)).
\end{verbatim}
% file "NRootIR.v", line 258-259 *)
\index{sqrt_less'@\verb/sqrt_less'/, \emph{lemma}}
\begin{verbatim}
Lemma sqrt_less' : (x,y:IR)(ypos:(Zero [:<=] y))
  (x[^](2) [:<] y)->([--]x [:<] (sqrt y ypos)).
\end{verbatim}
% file "NRootIR.v", line 279-280 *)
\index{AbsIR_sqrt_sqr@\verb/AbsIR_sqrt_sqr/, \emph{lemma}}
\begin{verbatim}
Lemma AbsIR_sqrt_sqr : (x:IR; xxpos:(Zero [:<=] x[^](2)))
  (AbsIR x) [=] (sqrt x[^](2) xxpos).
\end{verbatim}
% file "NRootIR.v", line 315 *)
\index{abs_pres_multIR@\verb/abs_pres_multIR/, \emph{lemma}}
\begin{verbatim}
Lemma abs_pres_multIR : (x,y:IR) (AbsIR (x[*]y)) [=] ((AbsIR x)[*](AbsIR y)).
\end{verbatim}
% file "NRootIR.v", line 326-327 *)
\index{triangle_IR@\verb/triangle_IR/, \emph{lemma}}
\begin{verbatim}
(* Cauchy-Schwartz for IR *)
Lemma triangle_IR: (x,y:IR) (AbsIR (x[+]y)) [:<=] ((AbsIR x)[+](AbsIR y)).
\end{verbatim}
% file "NRootIR.v", line 353-354 *)
\index{triangle_sumIR@\verb/triangle_sumIR/, \emph{lemma}}
\begin{verbatim}
Lemma triangle_sumIR : (k,l:nat)(s:nat->IR)(le k (S l)) ->
  (AbsIR (Sum k l s)) [:<=] (Sum k l [i:nat](AbsIR (s i))).
\end{verbatim}
% file "CComplex.v", line 6 *)
\section{Complex Numbers}
% file "CComplex.v", line 11-20 *)
\index{CC_set@\verb/CC_set/, \emph{record}}
\index{cc_ap@\verb/cc_ap/, \emph{definition}}
\index{cc_eq@\verb/cc_eq/, \emph{definition}}
\index{cc_is_CSetoid@\verb/cc_is_CSetoid/, \emph{lemma}}
\begin{verbatim}
Record CC_set : Set :=
      {Re : IR;
       Im : IR}.

Definition cc_ap [x,y:CC_set]: Prop :=
  ((Re x) [#] (Re y)) \/ ((Im x) [#] (Im y)).
Definition cc_eq [x,y:CC_set]: Prop :=
  ((Re x) [=] (Re y)) /\ ((Im x) [=] (Im y)).

Lemma cc_is_CSetoid : (is_CSetoid ? cc_eq cc_ap).
\end{verbatim}
% file "CComplex.v", line 55-70 *)
\index{cc_csetoid@\verb/cc_csetoid/, \emph{definition}}
\index{cc_plus@\verb/cc_plus/, \emph{definition}}
\index{cc_mult@\verb/cc_mult/, \emph{definition}}
\index{cc_zero@\verb/cc_zero/, \emph{definition}}
\index{cc_one@\verb/cc_one/, \emph{definition}}
\index{cc_i@\verb/cc_i/, \emph{definition}}
\index{cc_min@\verb/cc_min/, \emph{definition}}
\index{cc_plus_op_proof@\verb/cc_plus_op_proof/, \emph{lemma}}
\begin{verbatim}
Definition cc_csetoid := (Build_CSetoid CC_set cc_eq cc_ap cc_is_CSetoid).

Definition cc_plus : CC_set -> CC_set -> CC_set :=
  [x,y:CC_set](Build_CC_set ((Re x)[+](Re y)) ((Im x)[+](Im y))).

Definition cc_mult : CC_set -> CC_set -> CC_set :=
  [x,y:CC_set]
  (Build_CC_set ((Re x)[*](Re y)) [-] ((Im x)[*](Im y))
	  ((Re x)[*](Im y)) [+] ((Im x)[*](Re y))).

Definition cc_zero := (Build_CC_set Zero::IR Zero::IR).
Definition cc_one := (Build_CC_set One::IR Zero::IR).
Definition cc_i := (Build_CC_set Zero::IR One::IR).
Definition cc_min [x:CC_set]: CC_set := (Build_CC_set ([--](Re x)) ([--](Im x))).

Lemma cc_plus_op_proof : (bin_op_well_def cc_csetoid cc_plus).
\end{verbatim}
% file "CComplex.v", line 80 *)
\index{cc_mult_op_proof@\verb/cc_mult_op_proof/, \emph{lemma}}
\begin{verbatim}
Lemma cc_mult_op_proof : (bin_op_well_def cc_csetoid cc_mult).
\end{verbatim}
% file "CComplex.v", line 90 *)
\index{cc_min_op_proof@\verb/cc_min_op_proof/, \emph{lemma}}
\begin{verbatim}
Lemma cc_min_op_proof : (un_op_well_def cc_csetoid cc_min).
\end{verbatim}
% file "CComplex.v", line 100 *)
\index{cc_min_strext@\verb/cc_min_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cc_min_strext : (un_op_strong_ext cc_csetoid cc_min).
\end{verbatim}
% file "CComplex.v", line 111 *)
\index{cc_plus_strext@\verb/cc_plus_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cc_plus_strext : (bin_op_strong_ext cc_csetoid cc_plus).
\end{verbatim}
% file "CComplex.v", line 124 *)
\index{cc_mult_strext@\verb/cc_mult_strext/, \emph{lemma}}
\begin{verbatim}
Lemma cc_mult_strext : (bin_op_strong_ext cc_csetoid cc_mult).
\end{verbatim}
% file "CComplex.v", line 145-152 *)
\index{cc_min_op@\verb/cc_min_op/, \emph{definition}}
\index{cc_plus_op@\verb/cc_plus_op/, \emph{definition}}
\index{cc_mult_op@\verb/cc_mult_op/, \emph{definition}}
\index{cc_csg_associative@\verb/cc_csg_associative/, \emph{lemma}}
\begin{verbatim}
Definition cc_min_op :=
(Build_CSetoid_un_op cc_csetoid cc_min cc_min_op_proof cc_min_strext).
Definition cc_plus_op :=
(Build_CSetoid_bin_op cc_csetoid cc_plus cc_plus_op_proof cc_plus_strext).
Definition cc_mult_op :=
(Build_CSetoid_bin_op cc_csetoid cc_mult cc_mult_op_proof cc_mult_strext).

Lemma cc_csg_associative : (Associative cc_plus_op).
\end{verbatim}
% file "CComplex.v", line 159 *)
\index{cc_cr_mult_associative@\verb/cc_cr_mult_associative/, \emph{lemma}}
\begin{verbatim}
Lemma cc_cr_mult_associative : (Associative cc_mult_op).
\end{verbatim}
% file "CComplex.v", line 166-169 *)
\index{cc_csemi_grp@\verb/cc_csemi_grp/, \emph{definition}}
\index{cc_cm_proof@\verb/cc_cm_proof/, \emph{lemma}}
\begin{verbatim}
Definition cc_csemi_grp :=
(Build_CSemi_grp cc_csetoid cc_zero cc_plus_op cc_csg_associative).

Lemma cc_cm_proof : (is_CMonoid cc_csemi_grp).
\end{verbatim}
% file "CComplex.v", line 179-182 *)
\index{cc_cmonoid@\verb/cc_cmonoid/, \emph{definition}}
\index{cc_cg_proof@\verb/cc_cg_proof/, \emph{lemma}}
\begin{verbatim}
Definition cc_cmonoid :=
(Build_CMonoid ? cc_cm_proof).

Lemma cc_cg_proof : (is_CGroup cc_cmonoid cc_min_op).
\end{verbatim}
% file "CComplex.v", line 189 *)
\index{cc_cr_dist@\verb/cc_cr_dist/, \emph{lemma}}
\begin{verbatim}
Lemma cc_cr_dist : (Distributive cc_mult_op cc_plus_op).
\end{verbatim}
% file "CComplex.v", line 196 *)
\index{cc_cr_non_triv@\verb/cc_cr_non_triv/, \emph{lemma}}
\begin{verbatim}
Lemma cc_cr_non_triv : (cc_ap cc_one cc_zero).
\end{verbatim}
% file "CComplex.v", line 202-207 *)
\index{cc_cgroup@\verb/cc_cgroup/, \emph{definition}}
\index{cc_cr_mult_mon@\verb/cc_cr_mult_mon/, \emph{lemma}}
\begin{verbatim}
Definition cc_cgroup :=
(Build_CGroup cc_cmonoid cc_min_op cc_cg_proof).

Lemma cc_cr_mult_mon :
(is_CMonoid (Build_CSemi_grp
       (csg_crr cc_cgroup) cc_one cc_mult_op cc_cr_mult_associative)).
\end{verbatim}
% file "CComplex.v", line 219 *)
\index{cc_mult_commutes@\verb/cc_mult_commutes/, \emph{lemma}}
\begin{verbatim}
Lemma cc_mult_commutes: (Commutes cc_mult_op).
\end{verbatim}
% file "CComplex.v", line 227 *)
\index{cc_isCRing@\verb/cc_isCRing/, \emph{lemma}}
\begin{verbatim}
Lemma cc_isCRing : (is_CRing  cc_cgroup cc_one cc_mult_op).
\end{verbatim}
% file "CComplex.v", line 236-237 *)
\index{cc_cring@\verb/cc_cring/, \emph{definition}}
\begin{verbatim}
Definition cc_cring :=
(Build_CRing cc_cgroup cc_one cc_mult_op cc_isCRing) : CRing.
\end{verbatim}
% file "CComplex.v", line 241 *)
If $x\noto 0$ or $y\noto 0$, then  $x^2 + y^2 \noto 0$.
% file "CComplex.v", line 244-246 *)
\index{cc_inv_aid@\verb/cc_inv_aid/, \emph{lemma}}
\begin{verbatim}
Lemma cc_inv_aid:
(x,y:IR)((x [#] Zero) \/ (y [#] Zero)) ->
	(((x[^](2)) [+] (y[^] (2))) [#] Zero).
\end{verbatim}
% file "CComplex.v", line 255-256 *)
If $x\noto 0$ or $y\noto 0$, then  $\frac{x}{x^2 + y^2} \noto 0$ or
$\frac{-y}{x^2 + y^2} \noto 0$.
% file "CComplex.v", line 259-262 *)
\index{cc_inv_aid2@\verb/cc_inv_aid2/, \emph{lemma}}
\begin{verbatim}
Lemma cc_inv_aid2:
(x,y:IR)(h:(x [#] Zero) \/ (y [#] Zero))
  ((x [/] (NZpro (cc_inv_aid ?? h))) [#] Zero) \/
  (([--]y [/] (NZpro (cc_inv_aid ?? h))) [#] Zero).
\end{verbatim}
% file "CComplex.v", line 278 *)
\index{cc_inv@\verb/cc_inv/, \emph{definition}}
\begin{verbatim}
Definition cc_inv : (NonZeros cc_cring) -> (NonZeros cc_cring).
\end{verbatim}
% file "CComplex.v", line 294 *)
\index{cc_Inv@\verb/cc_Inv/, \emph{lemma}}
\begin{verbatim}
Lemma cc_Inv : (CSetoid_un_op (NonZeros cc_cring)).
\end{verbatim}
% file "CComplex.v", line 335 *)
\index{cc_cfield_proof@\verb/cc_cfield_proof/, \emph{lemma}}
\begin{verbatim}
Lemma cc_cfield_proof : (is_CField cc_cring cc_Inv).
\end{verbatim}
% file "CComplex.v", line 347-359 *)
\index{cc_cfield@\verb/cc_cfield/, \emph{definition}}
\index{CC@\verb/CC/, \emph{definition}}
\index{cc_set_CC@\verb/cc_set_CC/, \emph{definition}}
\index{cc_IR@\verb/cc_IR/, \emph{definition}}
\index{conj@\verb/conj/, \emph{definition}}
\index{AbsCC@\verb/AbsCC/, \emph{definition}}
\begin{verbatim}
Definition cc_cfield := (Build_CField cc_cring cc_Inv cc_cfield_proof).
Definition CC := cc_cfield.

Definition cc_set_CC : IR -> IR -> CC := Build_CC_set.
Definition cc_IR [x:IR]: CC := (cc_set_CC x Zero).

Definition conj : CC -> CC  :=
[z:CC_set](CC_set_rec [_:CC_set]CC_set
	[Re0,Im0:IR](Build_CC_set Re0 [--]Im0) z).

Definition AbsCC [z:CC]: IR :=
(sqrt (((Re z)[^](2)) [+] ((Im z)[^](2)))
	     (cc_abs_aid ? (Re z) (Im z))).
\end{verbatim}
% file "CComplex.v", line 363 *)
\index{TwoCC_ap_zero@\verb/TwoCC_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma TwoCC_ap_zero : (Two::CC [#] Zero).
\end{verbatim}
% file "CComplex.v", line 384 *)
\index{I_square@\verb/I_square/, \emph{lemma}}
\begin{verbatim}
Lemma I_square : I[*]I [=] [--]One.
\end{verbatim}
% file "CComplex.v", line 393 *)
\index{I_square'@\verb/I_square'/, \emph{lemma}}
\begin{verbatim}
Lemma I_square' : I[^](2) [=] [--]One.
\end{verbatim}
% file "CComplex.v", line 399 *)
\index{I_inv_lft@\verb/I_inv_lft/, \emph{lemma}}
\begin{verbatim}
Lemma I_inv_lft : ([--]I)[*]I [=] One.
\end{verbatim}
% file "CComplex.v", line 406 *)
\index{I_inv_rht@\verb/I_inv_rht/, \emph{lemma}}
\begin{verbatim}
Lemma I_inv_rht : I[*]([--]I) [=] One.
\end{verbatim}
% file "CComplex.v", line 413 *)
\index{mult_I@\verb/mult_I/, \emph{lemma}}
\begin{verbatim}
Lemma mult_I : (x,y:IR)((x[+I*]y)[*]I [=] ([--]y)[+I*]x).
\end{verbatim}
% file "CComplex.v", line 419-420 *)
\index{I_wd@\verb/I_wd/, \emph{lemma}}
\begin{verbatim}
Lemma I_wd : (x,x',y,y':IR)
  (x [=] x')->(y [=] y')->(x[+I*]y [=] x'[+I*]y').
\end{verbatim}
% file "CComplex.v", line 426-427 *)
\index{calculate_norm@\verb/calculate_norm/, \emph{lemma}}
\begin{verbatim}
Lemma calculate_norm : (x,y:IR)
  ((x[+I*]y)[*](conj x[+I*]y) [=] (cc_IR x[^](2)[+]y[^](2))).
\end{verbatim}
% file "CComplex.v", line 433 *)
\index{calculate_Re@\verb/calculate_Re/, \emph{lemma}}
\begin{verbatim}
Lemma calculate_Re: (c:CC)((cc_IR (Re c))[*]Two [=] c[+](conj c)).
\end{verbatim}
% file "CComplex.v", line 440 *)
\index{calculate_Im@\verb/calculate_Im/, \emph{lemma}}
\begin{verbatim}
Lemma calculate_Im: (c:CC)((cc_IR (Im c))[*](Two[*]I) [=] c[-](conj c)).
\end{verbatim}
% file "CComplex.v", line 447 *)
\index{Re_wd@\verb/Re_wd/, \emph{lemma}}
\begin{verbatim}
Lemma Re_wd : (c,c':CC)(c [=] c')->((Re c) [=] (Re c')).
\end{verbatim}
% file "CComplex.v", line 454 *)
\index{Im_wd@\verb/Im_wd/, \emph{lemma}}
\begin{verbatim}
Lemma Im_wd : (c,c':CC)(c [=] c')->((Im c) [=] (Im c')).
\end{verbatim}
% file "CComplex.v", line 461 *)
\index{Re_resp_plus@\verb/Re_resp_plus/, \emph{lemma}}
\begin{verbatim}
Lemma Re_resp_plus :(x,y:CC)(Re (x[+]y)) [=] (Re x)[+](Re y).
\end{verbatim}
% file "CComplex.v", line 468 *)
\index{Re_resp_min@\verb/Re_resp_min/, \emph{lemma}}
\begin{verbatim}
Lemma Re_resp_min :(x,y:CC)(Re (x[-]y)) [=] (Re x)[-](Re y).
\end{verbatim}
% file "CComplex.v", line 475 *)
\index{Im_resp_plus@\verb/Im_resp_plus/, \emph{lemma}}
\begin{verbatim}
Lemma Im_resp_plus :(x,y:CC)(Im (x[+]y)) [=] (Im x)[+](Im y).
\end{verbatim}
% file "CComplex.v", line 482 *)
\index{Im_resp_min@\verb/Im_resp_min/, \emph{lemma}}
\begin{verbatim}
Lemma Im_resp_min :(x,y:CC)(Im (x[-]y)) [=] (Im x)[-](Im y).
\end{verbatim}
% file "CComplex.v", line 489-490 *)
\index{cc_calculate_square@\verb/cc_calculate_square/, \emph{lemma}}
\begin{verbatim}
Lemma cc_calculate_square : (x,y:IR)
  ((x[+I*]y)[^](2) [=] (x[^](2)[-]y[^](2))[+I*]((x[*]y)[*]Two)).
\end{verbatim}
% file "CComplex.v", line 505 *)
\index{conj_1@\verb/conj_1/, \emph{lemma}}
\begin{verbatim}
Lemma conj_1 : (c,c':CC)((conj c[+]c') [=] (conj c)[+](conj c')).
\end{verbatim}
% file "CComplex.v", line 512 *)
\index{conj_2@\verb/conj_2/, \emph{lemma}}
\begin{verbatim}
Lemma conj_2 : (c,c':CC)((conj c[*]c') [=] (conj c)[*](conj c')).
\end{verbatim}
% file "CComplex.v", line 521 *)
\index{conj_4@\verb/conj_4/, \emph{lemma}}
\begin{verbatim}
Lemma conj_4 : (c,c':CC)((conj c) [#] (conj c'))->(c [#] c').
\end{verbatim}
% file "CComplex.v", line 531 *)
\index{conj_5@\verb/conj_5/, \emph{lemma}}
\begin{verbatim}
Lemma conj_5 : (c:CC)((conj (conj c)) [=] c).
\end{verbatim}
% file "CComplex.v", line 537 *)
\index{conj_6@\verb/conj_6/, \emph{lemma}}
\begin{verbatim}
Lemma conj_6 : (conj Zero) [=] Zero.
\end{verbatim}
% file "CComplex.v", line 543 *)
\index{conj_7@\verb/conj_7/, \emph{lemma}}
\begin{verbatim}
Lemma conj_7 : (conj One) [=] One.
\end{verbatim}
% file "CComplex.v", line 551 *)
\index{conj_3@\verb/conj_3/, \emph{lemma}}
\begin{verbatim}
Lemma conj_3 : (c:CC)(n:nat)((conj c[^]n) [=] (conj c)[^]n).
\end{verbatim}
% file "CComplex.v", line 569 *)
\index{cc_IR_1@\verb/cc_IR_1/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_1 : (x,y:IR) (x [=] y) -> (cc_IR x) [=] (cc_IR y).
\end{verbatim}
% file "CComplex.v", line 577 *)
\index{cc_IR_1a@\verb/cc_IR_1a/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_1a : (x,y:IR) (x [#] y) -> (cc_IR x) [#] (cc_IR y).
\end{verbatim}
% file "CComplex.v", line 583 *)
\index{cc_IR_2@\verb/cc_IR_2/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_2 : (x,y:IR) (cc_IR x)[*](cc_IR y) [=] (cc_IR x[*]y).
\end{verbatim}
% file "CComplex.v", line 591 *)
\index{cc_IR_4a@\verb/cc_IR_4a/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_4a : (x,y,z:IR) x[+I*]y[*](cc_IR z) [=] (x[*]z)[+I*](y[*]z).
\end{verbatim}
% file "CComplex.v", line 597 *)
\index{cc_IR_4b@\verb/cc_IR_4b/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_4b : (x,y,z:IR) (cc_IR z)[*]x[+I*]y [=] (z[*]x)[+I*](z[*]y).
\end{verbatim}
% file "CComplex.v", line 603 *)
\index{cc_IR_5a@\verb/cc_IR_5a/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_5a : (x,y:IR) (cc_IR x)[+](cc_IR y) [=] (cc_IR x[+]y).
\end{verbatim}
% file "CComplex.v", line 611 *)
\index{cc_IR_5b@\verb/cc_IR_5b/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_5b : (x,y:IR) (cc_IR x)[-](cc_IR y) [=] (cc_IR x[-]y).
\end{verbatim}
% file "CComplex.v", line 617 *)
\index{cc_IR_zero@\verb/cc_IR_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_zero : (cc_IR Zero) [=] Zero.
\end{verbatim}
% file "CComplex.v", line 625 *)
\index{cc_IR_one@\verb/cc_IR_one/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_one : (cc_IR One) [=] One.
\end{verbatim}
% file "CComplex.v", line 633 *)
\index{cc_IR_Nring@\verb/cc_IR_Nring/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_Nring : (n:nat)((cc_IR (Nring n)) [=] (Nring n)).
\end{verbatim}
% file "CComplex.v", line 644 *)
\index{cc_IR_3@\verb/cc_IR_3/, \emph{lemma}}
\begin{verbatim}
Lemma cc_IR_3 : (x:IR)(n:nat) (cc_IR x)[^]n [=] (cc_IR x[^]n).
\end{verbatim}
% file "CComplex.v", line 664 *)
\index{AbsCC_wd@\verb/AbsCC_wd/, \emph{lemma}}
\begin{verbatim}
Lemma AbsCC_wd : (x,y:CC)(x [=] y) -> ((AbsCC x) [=] (AbsCC y)).
\end{verbatim}
% file "CComplex.v", line 677-678 *)
\index{cc_minus_abs@\verb/cc_minus_abs/, \emph{lemma}}
\begin{verbatim}
Lemma cc_minus_abs :
(x:CC)(AbsCC ([--]x)) [=] (AbsCC x).
\end{verbatim}
% file "CComplex.v", line 691-692 *)
\index{cc_min_abs@\verb/cc_min_abs/, \emph{lemma}}
\begin{verbatim}
Lemma cc_min_abs :
(x,y:CC)(AbsCC (x[-]y)) [=] (AbsCC(y[-]x)).
\end{verbatim}
% file "CComplex.v", line 701-702 *)
\index{cc_mult_abs@\verb/cc_mult_abs/, \emph{lemma}}
\begin{verbatim}
Lemma cc_mult_abs :
(x,y:CC)(AbsCC (x[*]y)) [=] ((AbsCC x)[*](AbsCC y)).
\end{verbatim}
% file "CComplex.v", line 714 *)
\index{AbsCC_minzero@\verb/AbsCC_minzero/, \emph{lemma}}
\begin{verbatim}
Lemma AbsCC_minzero : (x:CC)(AbsCC(x[-]Zero))[=] (AbsCC x).
\end{verbatim}
% file "CComplex.v", line 722 *)
\index{AbsCC_IR@\verb/AbsCC_IR/, \emph{lemma}}
\begin{verbatim}
Lemma AbsCC_IR : (x:IR)(Zero [:<=] x) -> (AbsCC (cc_IR x)) [=] x.
\end{verbatim}
% file "CComplex.v", line 734-736 *)
\index{cc_div_abs@\verb/cc_div_abs/, \emph{lemma}}
\begin{verbatim}
Lemma cc_div_abs :
(x,y:CC)(nz:y[#]Zero)(anz:(AbsCC y)[#]Zero)
  (AbsCC (x[/]y[//]nz)) [=] (AbsCC x)[/](AbsCC y)[//]anz.
\end{verbatim}
% file "CComplex.v", line 746-748 *)
\index{cc_div_abs'@\verb/cc_div_abs'/, \emph{lemma}}
\begin{verbatim}
Lemma cc_div_abs' :
(x:CC)(y:IR)(nz:y[#]Zero)(cnz:(cc_IR y)[#]Zero)(Zero [:<=] y) ->
  (AbsCC (x[/](cc_IR y)[//]cnz)) [=] (AbsCC x)[/]y[//]nz.
\end{verbatim}
% file "CComplex.v", line 760 *)
\index{AbsCC_zero@\verb/AbsCC_zero/, \emph{lemma}}
\begin{verbatim}
Lemma AbsCC_zero : (AbsCC Zero) [=] Zero.
\end{verbatim}
% file "CComplex.v", line 770 *)
\index{AbsCC_one@\verb/AbsCC_one/, \emph{lemma}}
\begin{verbatim}
Lemma AbsCC_one : (AbsCC One) [=] One.
\end{verbatim}
% file "CComplex.v", line 778-779 *)
\index{cc_pow_abs@\verb/cc_pow_abs/, \emph{lemma}}
\begin{verbatim}
Lemma cc_pow_abs :
(x:CC; n:nat)(AbsCC (x[^]n)) [=] ((AbsCC x)[^]n).
\end{verbatim}
% file "CComplex.v", line 787 *)
\index{AbsCC_pos@\verb/AbsCC_pos/, \emph{lemma}}
\begin{verbatim}
Lemma AbsCC_pos : (x:CC)(x [#] Zero) -> (Zero [:<] (AbsCC x)).
\end{verbatim}
% file "CComplex.v", line 803 *)
\index{AbsCC_ap_zero@\verb/AbsCC_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma AbsCC_ap_zero : (x:CC)(Zero [#] (AbsCC x)) -> (x [#] Zero).
\end{verbatim}
% file "CComplex.v", line 824 *)
\index{AbsCC_nonneg@\verb/AbsCC_nonneg/, \emph{lemma}}
\begin{verbatim}
Lemma AbsCC_nonneg : (x:CC)(Zero [:<=] (AbsCC x)).
\end{verbatim}
% file "CComplex.v", line 831-832 *)
\index{AbsCC_small_imp_eq@\verb/AbsCC_small_imp_eq/, \emph{lemma}}
\begin{verbatim}
Lemma AbsCC_small_imp_eq :
  (x:CC)((e:IR)(Zero [:<] e) -> (AbsCC x) [:<] e) -> x [=] Zero.
\end{verbatim}
% file "Triangle.v", line 6 *)
\index{triangle@\verb/triangle/, \emph{lemma}}
\begin{verbatim}
Lemma triangle : (x,y:CC)(AbsCC (x[+]y)) [:<=] (AbsCC x)[+](AbsCC y).
\end{verbatim}
% file "Triangle.v", line 46-47 *)
\index{triangle_sum@\verb/triangle_sum/, \emph{lemma}}
\begin{verbatim}
Lemma triangle_sum : (m,n:nat)(z:nat->CC)(le m (S n)) ->
  (AbsCC (Sum m n z)) [:<=] (Sum m n [i:nat](AbsCC (z i))).
\end{verbatim}
% file "KeyLemma.v", line 9 *)
\section{Key Lemma}
% file "KeyLemma.v", line 13 *)
TO DO: Put next lemma in more appropriate place.
% file "KeyLemma.v", line 16-19 *)
\index{maj_upto_eps@\verb/maj_upto_eps/, \emph{lemma}}
\begin{verbatim}
Lemma maj_upto_eps : (a:nat->IR; n:nat; eps:IR)
        (lt (0) n) -> (Zero [:<] eps)
        -> (EX k | (le (1) k) /\ (le k n) /\
                (i:nat)(le (1) i) -> (le i n) -> (a i)[-]eps [:<] (a k)).
\end{verbatim}
% file "KeyLemma.v", line 82-86 *)
\begin{convention}
Let \verb!a : nat->IR!, \verb!n : nat!, \verb!(lt (0) n)!,
\verb!eps : IR!, \verb!(Zero [:<] eps)!, \verb!(k:nat)(Zero [:<=] (a k))!,
\verb!(a n) [=] One!, \verb!a_0 : IR!, \verb!(eps [:<] a_0)!.
\end{convention}
% file "KeyLemma.v", line 99 *)
\index{a_0_eps_pos@\verb/a_0_eps_pos/, \emph{lemma}}
\begin{verbatim}
Lemma a_0_eps_pos : Zero [:<] a_0 [-] eps.
\end{verbatim}
% file "KeyLemma.v", line 106 *)
\index{a_0_eps_fuzz@\verb/a_0_eps_fuzz/, \emph{lemma}}
\begin{verbatim}
Lemma a_0_eps_fuzz : a_0 [-] eps [:<] a_0.
\end{verbatim}
% file "KeyLemma.v", line 116 *)
\index{lem_1a@\verb/lem_1a/, \emph{lemma}}
\begin{verbatim}
Lemma lem_1a : (minus n (minus n (1))) = (1).
\end{verbatim}
% file "KeyLemma.v", line 124 *)
\index{lem_1b@\verb/lem_1b/, \emph{lemma}}
\begin{verbatim}
Lemma lem_1b : (n,j:nat)(le (minus n (S j)) (minus n j)).
\end{verbatim}
% file "KeyLemma.v", line 131 *)
\index{lem_1c@\verb/lem_1c/, \emph{lemma}}
\begin{verbatim}
Lemma lem_1c : (n,j:nat)(le (minus n j) n).
\end{verbatim}
% file "KeyLemma.v", line 138-141 *)
\index{lem_1@\verb/lem_1/, \emph{lemma}}
\begin{verbatim}
Lemma lem_1:
  (EX t | (Zero [:<] t) /\ (EX k | (le (1) k) /\ (le k n) /\
        ((a k)[*]t[^]k [=] a_0[-]eps) /\
        (i:nat)(le (1) i) -> (le i n) -> ((a i)[*]t[^]i [:<] a_0))).
\end{verbatim}
% file "KeyLemma.v", line 290 *)
\index{p3m@\verb/p3m/, \emph{definition}}
\begin{verbatim}
Definition p3m := [i:nat](One[/]ThreeNZ)[^]i ::IR.
\end{verbatim}
% file "KeyLemma.v", line 294 *)
\index{p3m_pos@\verb/p3m_pos/, \emph{lemma}}
\begin{verbatim}
Lemma p3m_pos : (i:nat)(Zero [:<] (p3m i)).
\end{verbatim}
% file "KeyLemma.v", line 305 *)
\index{p3m_S@\verb/p3m_S/, \emph{lemma}}
\begin{verbatim}
Lemma p3m_S : (i:nat)((p3m (S i)) [=] (p3m i)[/]ThreeNZ).
\end{verbatim}
% file "KeyLemma.v", line 316 *)
\index{p3m_P@\verb/p3m_P/, \emph{lemma}}
\begin{verbatim}
Lemma p3m_P : (i:nat)((p3m i) [=] (p3m (S i))[*]Three).
\end{verbatim}
% file "KeyLemma.v", line 323 *)
\index{p3m_aux@\verb/p3m_aux/, \emph{lemma}}
\begin{verbatim}
Lemma p3m_aux : (i,j:nat)((p3m (S i))[^]j [=] (p3m j)[*](p3m i)[^]j).
\end{verbatim}
% file "KeyLemma.v", line 334 *)
\index{p3m_pow@\verb/p3m_pow/, \emph{lemma}}
\begin{verbatim}
Lemma p3m_pow : (i,j:nat)((p3m i)[^]j [=] (p3m (mult i j))).
\end{verbatim}
% file "KeyLemma.v", line 344 *)
\index{p3m_0@\verb/p3m_0/, \emph{lemma}}
\begin{verbatim}
Lemma p3m_0 : (p3m (0)) [=] One.
\end{verbatim}
% file "KeyLemma.v", line 354 *)
\index{third_pos@\verb/third_pos/, \emph{lemma}}
\begin{verbatim}
Lemma third_pos : Zero::IR [:<] One[/]ThreeNZ.
\end{verbatim}
% file "KeyLemma.v", line 363 *)
\index{third_less_one@\verb/third_less_one/, \emph{lemma}}
\begin{verbatim}
Lemma third_less_one : One[/]ThreeNZ [:<] One::IR.
\end{verbatim}
% file "KeyLemma.v", line 374 *)
\index{p3m_mon@\verb/p3m_mon/, \emph{lemma}}
\begin{verbatim}
Lemma p3m_mon : (i,j:nat)(lt i j) -> ((p3m j) [:<] (p3m i)).
\end{verbatim}
% file "KeyLemma.v", line 382 *)
\index{p3m_mon'@\verb/p3m_mon'/, \emph{lemma}}
\begin{verbatim}
Lemma p3m_mon' : (i,j:nat)(le i j) -> ((p3m j) [:<=] (p3m i)).
\end{verbatim}
% file "KeyLemma.v", line 390 *)
\index{p3m_small@\verb/p3m_small/, \emph{lemma}}
\begin{verbatim}
Lemma p3m_small : (i:nat)((p3m i) [:<=] One).
\end{verbatim}
% file "KeyLemma.v", line 399 *)
\index{p3m_smaller@\verb/p3m_smaller/, \emph{lemma}}
\begin{verbatim}
Lemma p3m_smaller : (i:nat)(lt (0) i)->((p3m i) [:<] Half).
\end{verbatim}
% file "KeyLemma.v", line 414-418 *)
\index{chfun@\verb/chfun/, \emph{definition}}
\begin{verbatim}
Definition chfun [k:nat->nat; a,j:nat] : nat->nat := [i:nat]
  Cases (le_gt_dec i j) of
    (left _)  => (k i)
  | (right _) => a
  end.
\end{verbatim}
% file "KeyLemma.v", line 422-423 *)
\index{chfun_1@\verb/chfun_1/, \emph{lemma}}
\begin{verbatim}
Lemma chfun_1 :
  (k:nat->nat; a,j:nat)(i:nat)(le i j) -> (k i) = ((chfun k a j) i).
\end{verbatim}
% file "KeyLemma.v", line 434-435 *)
\index{chfun_2@\verb/chfun_2/, \emph{lemma}}
\begin{verbatim}
Lemma chfun_2 :
  (k:nat->nat; j:nat; a:nat)(i:nat)(lt j i) -> a = ((chfun k a j) i).
\end{verbatim}
% file "KeyLemma.v", line 446-449 *)
\index{chfun_3@\verb/chfun_3/, \emph{lemma}}
\begin{verbatim}
Lemma chfun_3 : (k:nat->nat; j:nat; a:nat)
        ((i:nat)(le (1) (k i)) /\ (le (k i) n)) ->
        (le (1) a) -> (le a n) ->
          (i:nat)(le (1) ((chfun k a j) i)) /\ (le ((chfun k a j) i) n).
\end{verbatim}
% file "KeyLemma.v", line 459-462 *)
\index{chfun_4@\verb/chfun_4/, \emph{lemma}}
\begin{verbatim}
Lemma chfun_4 : (k:nat->nat; j:nat; a:nat)
        ((i:nat)(le (k (S i)) (k i))) ->
        (le a (k j)) ->
          (i:nat)(le ((chfun k a j) (S i)) ((chfun k a j) i)).
\end{verbatim}
% file "KeyLemma.v", line 476 *)
\index{halfeps@\verb/halfeps/, \emph{definition}}
\begin{verbatim}
Definition halfeps := Half[*]eps.
\end{verbatim}
% file "KeyLemma.v", line 480 *)
\index{halfeps_pos@\verb/halfeps_pos/, \emph{lemma}}
\begin{verbatim}
Lemma halfeps_pos : Zero [:<] halfeps.
\end{verbatim}
% file "KeyLemma.v", line 489 *)
\index{halfeps_halfeps@\verb/halfeps_halfeps/, \emph{lemma}}
\begin{verbatim}
Lemma halfeps_halfeps : (x:IR)((x[-]halfeps)[-]halfeps [=] x[-]eps).
\end{verbatim}
% file "KeyLemma.v", line 500 *)
\index{halfeps_eps@\verb/halfeps_eps/, \emph{lemma}}
\begin{verbatim}
Lemma halfeps_eps : (x,y:IR)(x[-]halfeps [:<] y) -> (x[-]eps [:<] y).
\end{verbatim}
% file "KeyLemma.v", line 513-514 *)
\index{halfeps_trans@\verb/halfeps_trans/, \emph{lemma}}
\begin{verbatim}
Lemma halfeps_trans :
  (x,y,z:IR)(x[-]halfeps [:<] y) -> (y[-]halfeps [:<] z) -> (x[-]eps [:<] z).
\end{verbatim}
% file "KeyLemma.v", line 526-528 *)
\index{Key_1a@\verb/Key_1a/, \emph{lemma}}
\begin{verbatim}
Lemma Key_1a :
(i,j:nat; a,t:IR)
  a[*](t[*](p3m (S j)))[^]i [=] (p3m i)[*](a[*](t[*](p3m j))[^]i).
\end{verbatim}
% file "KeyLemma.v", line 540 *)
\index{Key_1b@\verb/Key_1b/, \emph{lemma}}
\begin{verbatim}
Lemma Key_1b : (k:nat)(le (1) k) -> ((p3m k)[*]eps [:<] halfeps).
\end{verbatim}
% file "KeyLemma.v", line 551-555 *)
\index{Key_1@\verb/Key_1/, \emph{lemma}}
\begin{verbatim}
Lemma Key_1 :
(i,k,j:nat; ai,ak,t:IR)
  (le (1) k) -> (lt k i) -> (Zero [:<=] ai) -> (Zero [:<] t) ->
  (ai[*](t[*](p3m j))[^]i[-]eps [:<] ak[*](t[*](p3m j))[^]k) ->
    (ai[*](t[*](p3m (S j)))[^]i[-]halfeps [:<] ak[*](t[*](p3m (S j)))[^]k).
\end{verbatim}
% file "KeyLemma.v", line 584-589 *)
\index{Key_2@\verb/Key_2/, \emph{lemma}}
\begin{verbatim}
Lemma Key_2 :
(i,k,k',j:nat; ai,ak,ak',t:IR)
  (le (1) k) -> (lt k i) -> (Zero [:<=] ai) -> (Zero [:<] t) ->
  (ak[*](t[*](p3m (S j)))[^]k[-]halfeps [:<] ak'[*](t[*](p3m (S j)))[^]k') ->
  (ai[*](t[*](p3m j))[^]i[-]eps [:<] ak[*](t[*](p3m j))[^]k) ->
        (ai[*](t[*](p3m (S j)))[^]i[-]eps [:<] ak'[*](t[*](p3m (S j)))[^]k').
\end{verbatim}
% file "KeyLemma.v", line 598-610 *)
\index{Key@\verb/Key/, \emph{lemma}}
\begin{verbatim}
Lemma Key :
(EX t | (Zero [:<] t) /\
  (J : nat)
  (EX k : nat -> nat |
        ((i:nat)(le (1) (k i)) /\ (le (k i) n)) /\
        ((i:nat)(le (k (S i)) (k i))) /\
        (let k_0 = (k (0)) in
                (a k_0)[*]t[^]k_0 [=] a_0[-]eps) /\
        ((j:nat)(le j J) ->
          let k_j = (k j) in
          let r = t[*](p3m j) in
                (i:nat)(le (1) i) -> (le i n) ->
                        (a i)[*]r[^]i[-]eps [:<] (a k_j)[*]r[^]k_j))).
\end{verbatim}
% file "MainLemma.v", line 6 *)
\section{Main Lemma}
% file "MainLemma.v", line 10 *)
TO DO: Put next lemma in more appropriate place.
% file "MainLemma.v", line 13-18 *)
\index{kseq_prop@\verb/kseq_prop/, \emph{lemma}}
\begin{verbatim}
Lemma kseq_prop :
(k:nat->nat; n:nat)
        ((i:nat)(le (1) (k i)) /\ (le (k i) n)) ->
        ((i:nat)(le (k (S i))(k i))) ->
          (EX j | (lt (S j) (mult (2) n)) /\ (k j) = (k (S j)) /\
                                                (k (S j)) = (k (S (S j)))).
\end{verbatim}
% file "MainLemma.v", line 76-80 *)
\begin{convention}
Let \verb!a : nat->IR!, \verb!n : nat!, \verb!(lt (0) n)!,
\verb!eps : IR!, \verb!(Zero [:<] eps)!, \verb!(k:nat)(Zero [:<=] (a k))!,
\verb!(a n) [=] One!, \verb!a_0 : IR!, \verb!(eps [:<] a_0)!.
\end{convention}
% file "MainLemma.v", line 93 *)
\index{a_0_pos@\verb/a_0_pos/, \emph{lemma}}
\begin{verbatim}
Lemma a_0_pos : Zero [:<] a_0.
\end{verbatim}
% file "MainLemma.v", line 100-102 *)
\index{two_n@\verb/two_n/, \emph{local}}
\index{Small@\verb/Small/, \emph{local}}
\index{Smaller@\verb/Smaller/, \emph{local}}
\begin{verbatim}
Local two_n := (mult (2) n).
Local Small := (p3m n).
Local Smaller := (p3m (mult two_n n)).
\end{verbatim}
% file "MainLemma.v", line 107-114 *)
\index{Main_1a'@\verb/Main_1a'/, \emph{lemma}}
\begin{verbatim}
Lemma Main_1a' :
(t:IR; j,k:nat)
  let r' = t[*](p3m (S (S j))) in
  let r = t[*](p3m (S j)) in
    ((i:nat)(le (1) i) -> (le i n) ->
      ((a i)[*]r'[^]i[-]eps [:<] (a k)[*]r'[^]k)) ->
    (i:nat)(le (1) i) -> (le i n) ->
      (a i)[*](r[/]ThreeNZ)[^]i[-]eps [:<] (a k)[*](r[/]ThreeNZ)[^]k.
\end{verbatim}
% file "MainLemma.v", line 125-132 *)
\index{Main_1b'@\verb/Main_1b'/, \emph{lemma}}
\begin{verbatim}
Lemma Main_1b' :
(t:IR; j,k:nat)
  let r' = t[*](p3m j) in
  let r = t[*](p3m (S j)) in
    ((i:nat)(le (1) i) -> (le i n) ->
      ((a i)[*]r'[^]i[-]eps [:<] (a k)[*]r'[^]k)) ->
    (i:nat)(le (1) i) -> (le i n) ->
      (a i)[*](r[*]Three)[^]i[-]eps [:<] (a k)[*](r[*]Three)[^]k.
\end{verbatim}
% file "MainLemma.v", line 143-151 *)
\index{Main_1a@\verb/Main_1a/, \emph{lemma}}
\begin{verbatim}
Lemma Main_1a :
(r:IR; k:nat)
  (Zero [:<] r) -> (le (1) k) -> (le k n) ->
  ((i:nat)(le (1) i) -> (le i n) ->
    ((a i)[*](r[/]ThreeNZ)[^]i[-]eps [:<] (a k)[*](r[/]ThreeNZ)[^]k)) ->
        let p_ = [i:nat](a i)[*]r[^]i in
        let p_k = (a k)[*]r[^]k in
          ((Sum (1) (pred k) p_)
                [:<] Half[*](One[-]Small)[*]p_k[+]Half[*]Three[^]n[*]eps).
\end{verbatim}
% file "MainLemma.v", line 261-269 *)
\index{Main_1b@\verb/Main_1b/, \emph{lemma}}
\begin{verbatim}
Lemma Main_1b :
(r:IR; k:nat)
  (Zero [:<] r) -> (le (1) k) -> (le k n) ->
  ((i:nat)(le (1) i) -> (le i n) ->
    ((a i)[*](r[*]Three)[^]i[-]eps [:<] (a k)[*](r[*]Three)[^]k)) ->
        let p_ = [i:nat](a i)[*]r[^]i in
        let p_k = (a k)[*]r[^]k in
          ((Sum (S k) n p_)
                [:<] Half[*](One[-]Small)[*]p_k[+]Half[*]Three[^]n[*]eps).
\end{verbatim}
% file "MainLemma.v", line 415-425 *)
\index{Main_1@\verb/Main_1/, \emph{lemma}}
\begin{verbatim}
Lemma Main_1 :
(r:IR; k:nat)
  (Zero [:<] r) -> (le (1) k) -> (le k n) ->
  ((i:nat)(le (1) i) -> (le i n) ->
    ((a i)[*](r[/]ThreeNZ)[^]i[-]eps [:<] (a k)[*](r[/]ThreeNZ)[^]k)) ->
  ((i:nat)(le (1) i) -> (le i n) ->
    ((a i)[*](r[*]Three)[^]i[-]eps [:<] (a k)[*](r[*]Three)[^]k)) ->
        let p_ = [i:nat](a i)[*]r[^]i in
        let p_k = (a k)[*]r[^]k in
          ((Sum (1) (pred k) p_) [+] (Sum (S k) n p_)
                [:<] (One[-]Small)[*]p_k[+]Three[^]n[*]eps).
\end{verbatim}
% file "MainLemma.v", line 441-444 *)
\index{Main_2'@\verb/Main_2'/, \emph{lemma}}
\begin{verbatim}
Lemma Main_2' :
(t:IR; i,k:nat)
  ((a i)[*](t[*](p3m (0)))[^]i[-]eps [:<] (a k)[*](t[*](p3m (0)))[^]k) ->
    (a i)[*]t[^]i[-]eps [:<] (a k)[*]t[^]k.
\end{verbatim}
% file "MainLemma.v", line 455-462 *)
\index{Main_2@\verb/Main_2/, \emph{lemma}}
\begin{verbatim}
Lemma Main_2 :
(t:IR; j,k:nat)
  let r = t[*](p3m j) in
        (Zero [:<] t) ->
        ((a k)[*]t[^]k [=] a_0[-]eps) ->
        ((i:nat)(le (1) i) -> (le i n) ->
          (a i)[*]t[^]i[-]eps [:<] (a k)[*]t[^]k) ->
        (i:nat)(le (1) i) -> (le i n) -> (a i)[*]r[^]i [:<] a_0.
\end{verbatim}
% file "MainLemma.v", line 492-498 *)
\index{Main_3a@\verb/Main_3a/, \emph{lemma}}
\begin{verbatim}
Lemma Main_3a :
(t:IR; j,k,k_0:nat)
  let r = t[*](p3m j) in
        (le k_0 n) ->
        ((a k_0)[*]t[^]k_0 [=] a_0[-]eps) ->
        ((a k_0)[*]r[^]k_0[-]eps [:<] (a k)[*]r[^]k) ->
        (p3m (mult j n))[*]a_0[-]Two[*]eps [:<] (a k)[*]r[^]k.
\end{verbatim}
% file "MainLemma.v", line 527-534 *)
\index{Main_3@\verb/Main_3/, \emph{lemma}}
\begin{verbatim}
Lemma Main_3 :
(t:IR; j,k,k_0:nat)
  let r = t[*](p3m j) in
        (lt j two_n) ->
        (le k_0 n) ->
        ((a k_0)[*]t[^]k_0 [=] a_0[-]eps) ->
        ((a k_0)[*]r[^]k_0[-]eps [:<] (a k)[*]r[^]k) ->
          (Smaller[*]a_0[-]Two[*]eps [:<] (a k)[*]r[^]k).
\end{verbatim}
% file "MainLemma.v", line 551-558 *)
\index{Main@\verb/Main/, \emph{lemma}}
\begin{verbatim}
Lemma Main :
(EX r | (Zero [:<] r) /\ (EX k | (le (1) k) /\ (le k n) /\
      let p_ = [i:nat](a i)[*]r[^]i in
      let p_k = (a k)[*]r[^]k in
        ((Sum (1) (pred k) p_) [+] (Sum (S k) n p_)
                [:<] (One[-]Small)[*]p_k[+]Three[^]n[*]eps) /\
        (r[^]n [:<] a_0) /\
        (Smaller[*]a_0[-]Two[*]eps [:<] p_k) /\ (p_k [:<] a_0))).
\end{verbatim}
% file "NRootCC.v", line 8 *)
\section{Roots of Complex Numbers}
% file "NRootCC.v", line 12 *)
\subsection{CC ap Zero}
% file "NRootCC.v", line 18-21 *)
\index{cc_ap_zero@\verb/cc_ap_zero/, \emph{lemma}}
\begin{verbatim}
Lemma cc_ap_zero : (P:CC->Prop)
  ((a,b:IR)(a [#] Zero)->(P a[+I*]b))->
  ((a,b:IR)(b [#] Zero)->(P a[+I*]b))->
    (c:CC)(c [#] Zero)->(P c).
\end{verbatim}
% file "NRootCC.v", line 37 *)
\subsection{Imag to Real}
% file "NRootCC.v", line 43-44 *)
\index{imag_to_real@\verb/imag_to_real/, \emph{lemma}}
\begin{verbatim}
Lemma imag_to_real : (a,b,a',b':IR)(a'[+I*]b' [=] (a[+I*]b)[*]I)->
  (a [#] Zero)->(b' [#] Zero).
\end{verbatim}
% file "NRootCC.v", line 67 *)
\subsection{NRoot I}
% file "NRootCC.v", line 73-74 *)
\index{sqrt_Half@\verb/sqrt_Half/, \emph{definition}}
\index{sqrt_I@\verb/sqrt_I/, \emph{definition}}
\begin{verbatim}
Definition sqrt_Half := (sqrt Half (less_leEq ??? (pos_half IR))).
Definition sqrt_I := sqrt_Half[+I*]sqrt_Half.
\end{verbatim}
% file "NRootCC.v", line 78 *)
\index{sqrt_I_nexp@\verb/sqrt_I_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma sqrt_I_nexp : (sqrt_I[^](2) [=] I).
\end{verbatim}
% file "NRootCC.v", line 107-108 *)
\index{nroot_I_nexp_aux@\verb/nroot_I_nexp_aux/, \emph{lemma}}
\begin{verbatim}
Lemma nroot_I_nexp_aux : (n:nat)(on:(odd n))
  (Ex [m:nat] (mult n n) = (plus (mult (4) m) (1))).
\end{verbatim}
% file "NRootCC.v", line 121 *)
\index{nroot_I@\verb/nroot_I/, \emph{definition}}
\begin{verbatim}
Definition nroot_I [n:nat; on:(odd n)] : CC := I[^]n.
\end{verbatim}
% file "NRootCC.v", line 125 *)
\index{nroot_I_nexp@\verb/nroot_I_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma nroot_I_nexp : (n:nat; on:(odd n))((nroot_I ? on)[^]n [=] I).
\end{verbatim}
% file "NRootCC.v", line 167 *)
\index{nroot_minus_I@\verb/nroot_minus_I/, \emph{definition}}
\begin{verbatim}
Definition nroot_minus_I [n:nat; on:(odd n)] : CC := [--](nroot_I n on).
\end{verbatim}
% file "NRootCC.v", line 171-172 *)
\index{nroot_minus_I_nexp@\verb/nroot_minus_I_nexp/, \emph{lemma}}
\begin{verbatim}
Lemma nroot_minus_I_nexp : (n:nat)(on:(odd n))
  ((nroot_minus_I n on)[^]n [=] [--]I).
\end{verbatim}
% file "NRootCC.v", line 185 *)
\subsection{NRootCC 1}
% file "NRootCC.v", line 191 *)
\subsubsection{NRootCC 1 ap real}
% file "NRootCC.v", line 197-199 *)
\begin{convention}
Let \verb!a, b : IR! and \verb!bnz : b [#] Zero!.
\end{convention}
% file "NRootCC.v", line 205 *)
\index{c2@\verb/c2/, \emph{local}}
\begin{verbatim}
Local c2 := a[^](2)[+]b[^](2).
\end{verbatim}
% file "NRootCC.v", line 209 *)
\index{nrCC1_c2pos@\verb/nrCC1_c2pos/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC1_c2pos : (Zero [:<] c2).
\end{verbatim}
% file "NRootCC.v", line 219 *)
\index{c@\verb/c/, \emph{local}}
\begin{verbatim}
Local c := (sqrt c2 (less_leEq ??? nrCC1_c2pos)).
\end{verbatim}
% file "NRootCC.v", line 223 *)
\index{a'2@\verb/a'2/, \emph{local}}
\begin{verbatim}
Local a'2 := (c[+]a)[*]Half.
\end{verbatim}
% file "NRootCC.v", line 227 *)
\index{nrCC1_a'2pos@\verb/nrCC1_a'2pos/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC1_a'2pos : (Zero [:<] a'2).
\end{verbatim}
% file "NRootCC.v", line 246 *)
\index{a'@\verb/a'/, \emph{local}}
\begin{verbatim}
Local a' := (sqrt a'2 (less_leEq ??? nrCC1_a'2pos)).
\end{verbatim}
% file "NRootCC.v", line 250 *)
\index{b'2@\verb/b'2/, \emph{local}}
\begin{verbatim}
Local b'2 := (c[-]a)[*]Half.
\end{verbatim}
% file "NRootCC.v", line 254 *)
\index{nrCC1_b'2pos@\verb/nrCC1_b'2pos/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC1_b'2pos : (Zero [:<] b'2).
\end{verbatim}
% file "NRootCC.v", line 270 *)
\index{b'@\verb/b'/, \emph{local}}
\begin{verbatim}
Local b' := (sqrt b'2 (less_leEq ??? nrCC1_b'2pos)).
\end{verbatim}
% file "NRootCC.v", line 274 *)
\index{nrCC1_a3@\verb/nrCC1_a3/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC1_a3 : a'[^](2)[-]b'[^](2) [=] a.
\end{verbatim}
% file "NRootCC.v", line 286 *)
\index{nrCC1_a4@\verb/nrCC1_a4/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC1_a4 : (c[+]a)[*](c[-]a) [=] b[^](2).
\end{verbatim}
% file "NRootCC.v", line 315 *)
\index{nrCC1_a5@\verb/nrCC1_a5/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC1_a5 : a'2[*]b'2 [=] (b[*]Half)[^](2).
\end{verbatim}
% file "NRootCC.v", line 354 *)
\index{nrCC1_a6@\verb/nrCC1_a6/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC1_a6 : (Zero [:<] a'2[*]b'2).
\end{verbatim}
% file "NRootCC.v", line 362 *)
\index{nrCC1_a6'@\verb/nrCC1_a6'/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC1_a6' : (Zero [:<] (b[*]Half)[^](2)).
\end{verbatim}
% file "NRootCC.v", line 375 *)
\index{nrCC1_a7_upper@\verb/nrCC1_a7_upper/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC1_a7_upper : (Zero [:<] b)->(a'[*]b' [=] b[*]Half).
\end{verbatim}
% file "NRootCC.v", line 393 *)
\index{nrCC1_a7_lower@\verb/nrCC1_a7_lower/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC1_a7_lower : (b [:<] Zero)->(a'[*][--]b' [=] b[*]Half).
\end{verbatim}
% file "NRootCC.v", line 420 *)
\index{nrootCC_1_upper@\verb/nrootCC_1_upper/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_1_upper : (Zero [:<] b)->((a'[+I*]b')[^](2) [=] a[+I*]b).
\end{verbatim}
% file "NRootCC.v", line 440 *)
\index{nrootCC_1_lower@\verb/nrootCC_1_lower/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_1_lower : (b [:<] Zero)->((a'[+I*][--]b')[^](2) [=] a[+I*]b).
\end{verbatim}
% file "NRootCC.v", line 463 *)
\index{nrootCC_1_ap_real@\verb/nrootCC_1_ap_real/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_1_ap_real : (Ex [z:CC](z[^](2) [=] a[+I*]b)).
\end{verbatim}
% file "NRootCC.v", line 477 *)
\subsubsection{NRootCC 1 ap imag}
% file "NRootCC.v", line 483-485 *)
\begin{convention}
Let \verb!a, b : IR! and \verb!anz : a [#] Zero!.
\end{convention}
% file "NRootCC.v", line 491-493 *)
\index{c'@\verb/c'/, \emph{local}}
\index{a'@\verb/a'/, \emph{local}}
\index{b'@\verb/b'/, \emph{local}}
\begin{verbatim}
Local c' := (a[+I*]b)[*][--]I.
Local a' := (Re c').
Local b' := (Im c').
\end{verbatim}
% file "NRootCC.v", line 497 *)
\index{nrootCC_1_ap_imag@\verb/nrootCC_1_ap_imag/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_1_ap_imag : (Ex [z:CC](z[^](2) [=] a[+I*]b)).
\end{verbatim}
% file "NRootCC.v", line 550 *)
\index{nrootCC_1@\verb/nrootCC_1/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_1 : (c:CC)(c [#] Zero)->(Ex [z:CC](z[^](2) [=] c)).
\end{verbatim}
% file "NRootCC.v", line 562 *)
\subsection{NRootCC 2}
% file "NRootCC.v", line 568-570 *)
\begin{convention}
Let \verb!n : nat! and \verb!c, z : CC! and \verb!cnz : c [#] Zero!.
\end{convention}
% file "NRootCC.v", line 577-580 *)
\index{nrootCC_2'@\verb/nrootCC_2'/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_2' :
  ((z[*](conj z))[^]n [=] c[*](conj c))->
    (z[^]n[*](conj c)[-](conj z)[^]n[*]c [=] Zero)->
      ((z[^]n)[^](2) [=] c[^](2)).
\end{verbatim}
% file "NRootCC.v", line 639-642 *)
\index{nrootCC_2@\verb/nrootCC_2/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_2 :
  ((z[*](conj z))[^]n [=] c[*](conj c))->
    (z[^]n[*](conj c)[-](conj z)[^]n[*]c [=] Zero)->
      ((z[^]n [=] c) \/ (z[^]n [=] [--]c)).
\end{verbatim}
% file "NRootCC.v", line 653 *)
\subsection{NRootCC 3}
% file "NRootCC.v", line 659-663 *)
\index{Im_poly@\verb/Im_poly/, \emph{fixpoint}}
\begin{verbatim}
Fixpoint Im_poly [p:(cpoly CC)] : (cpoly IR) :=
  Cases p of
    cpoly_zero => (cpoly_zero IR)
  | (cpoly_linear c p1) => (cpoly_linear IR (Im c) (Im_poly p1))
  end.
\end{verbatim}
% file "NRootCC.v", line 667 *)
\index{nrCC3_a1@\verb/nrCC3_a1/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC3_a1 : (p:(cpoly CC))(r:IR)((Im_poly p)!r [=] (Im p!(cc_IR r))).
\end{verbatim}
% file "NRootCC.v", line 712-713 *)
\index{nrCC3_a2@\verb/nrCC3_a2/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC3_a2 : (p:(cpoly CC))(n:nat)
  ((Nth_coeff n (Im_poly p)) [=] (Im (Nth_coeff n p))).
\end{verbatim}
% file "NRootCC.v", line 740-742 *)
\begin{convention}
Let \verb!a, b : IR! and \verb!bnz : b [#] Zero! and \verb!n : nat!.
\end{convention}
% file "NRootCC.v", line 749 *)
\index{nrCC3_poly''@\verb/nrCC3_poly''/, \emph{definition}}
\begin{verbatim}
Definition nrCC3_poly'' := (_X_[+](_C_ I))[^]n.
\end{verbatim}
% file "NRootCC.v", line 753 *)
\index{nrCC3_a3@\verb/nrCC3_a3/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC3_a3 : (r:IR)((nrCC3_poly''!(cc_IR r)) [=] (r[+I*]One)[^]n).
\end{verbatim}
% file "NRootCC.v", line 780 *)
\index{nrCC3_a4@\verb/nrCC3_a4/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC3_a4 : (Degree_le (1) _X_[+](_C_ I)).
\end{verbatim}
% file "NRootCC.v", line 796 *)
\index{nrCC3_a5@\verb/nrCC3_a5/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC3_a5 : (Degree_le n nrCC3_poly'').
\end{verbatim}
% file "NRootCC.v", line 807 *)
\index{nrCC3_a6@\verb/nrCC3_a6/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC3_a6 : (Nth_coeff n nrCC3_poly'') [=] One.
\end{verbatim}
% file "NRootCC.v", line 824 *)
\index{nrCC3_poly'@\verb/nrCC3_poly'/, \emph{definition}}
\begin{verbatim}
Definition nrCC3_poly' := nrCC3_poly''[*](_C_ a[+I*][--]b).
\end{verbatim}
% file "NRootCC.v", line 828-829 *)
\index{nrCC3_a7@\verb/nrCC3_a7/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC3_a7 : (r:IR)
  ((nrCC3_poly'!(cc_IR r)) [=] (r[+I*]One)[^]n[*](a[+I*][--]b)).
\end{verbatim}
% file "NRootCC.v", line 845 *)
\index{nrCC3_a8@\verb/nrCC3_a8/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC3_a8 : (Degree_le n nrCC3_poly').
\end{verbatim}
% file "NRootCC.v", line 856 *)
\index{nrCC3_a9@\verb/nrCC3_a9/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC3_a9 : (Nth_coeff n nrCC3_poly') [=] a[+I*][--]b.
\end{verbatim}
% file "NRootCC.v", line 871 *)
\index{nrootCC_3_poly@\verb/nrootCC_3_poly/, \emph{definition}}
\begin{verbatim}
Definition nrootCC_3_poly := (Im_poly nrCC3_poly').
\end{verbatim}
% file "NRootCC.v", line 875-876 *)
\index{nrootCC_3_@\verb/nrootCC_3_/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_3_ : (r:IR)
  ((nrootCC_3_poly!r) [=] (Im (r[+I*]One)[^]n[*](a[+I*][--]b))).
\end{verbatim}
% file "NRootCC.v", line 888-890 *)
\index{nrootCC_3@\verb/nrootCC_3/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_3 : (r:IR)
  ((cc_IR (nrootCC_3_poly!r))[*](Two[*]I) [=]
    ((r[+I*]One)[^]n[*](a[+I*][--]b)[-](r[+I*][--]One)[^]n[*](a[+I*]b))).
\end{verbatim}
% file "NRootCC.v", line 920 *)
\index{nrootCC_3_degree@\verb/nrootCC_3_degree/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_3_degree : (Degree n nrootCC_3_poly).
\end{verbatim}
% file "NRootCC.v", line 959 *)
\subsection{NRootCC 3'}
% file "NRootCC.v", line 965-967 *)
\begin{convention}
Let \verb!c : IR! and \verb!n : nat! and \verb!nnz : (lt O n)!.
\end{convention}
% file "NRootCC.v", line 974 *)
\index{nrootCC_3'_poly@\verb/nrootCC_3'_poly/, \emph{definition}}
\begin{verbatim}
Definition nrootCC_3'_poly := _X_[^]n[-](_C_ c).
\end{verbatim}
% file "NRootCC.v", line 978 *)
\index{nrootCC_3'@\verb/nrootCC_3'/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_3' : (x:IR)(nrootCC_3'_poly!x [=] x[^]n[-]c).
\end{verbatim}
% file "NRootCC.v", line 994 *)
\index{nrootCC_3'_degree@\verb/nrootCC_3'_degree/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_3'_degree : (Degree n nrootCC_3'_poly).
\end{verbatim}
% file "NRootCC.v", line 1011 *)
\subsection{NRootCC 4}
% file "NRootCC.v", line 1017 *)
\subsubsection{NRootCC 4 ap real}
% file "NRootCC.v", line 1023-1026 *)
\begin{convention}
Let \verb!a, b : IR! and \verb!bnz : b [#] Zero! and \verb!n:nat! and
\verb!on : (odd n)!.
\end{convention}
% file "NRootCC.v", line 1034 *)
\index{c@\verb/c/, \emph{local}}
\begin{verbatim}
Local c := a[+I*]b.
\end{verbatim}
% file "NRootCC.v", line 1040-1041 *)
\index{nrCC4_a1@\verb/nrCC4_a1/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a1 :
  (Ex [r:IR]((r[+I*]One)[^]n[*](conj c)[-](r[+I*][--]One)[^]n[*]c [=] Zero)).
\end{verbatim}
% file "NRootCC.v", line 1069-1071 *)
\begin{convention}
Let \verb!r2', c2 : IR! and \verb!r2'nz : r2' [#] Zero!.
\end{convention}
% file "NRootCC.v", line 1077 *)
\index{nrCC4_a1'@\verb/nrCC4_a1'/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a1' : (Ex [y2:IR]((y2[*]r2')[^]n [=] c2)).
\end{verbatim}
% file "NRootCC.v", line 1120-1125 *)
\begin{convention}
Let \verb!r,y2 : IR! with
\verb!(r[+I*]One)[^]n[*](conj c)[-](r[+I*][--]One)[^]n[*]c [=] Zero!
and
\verb!(y2[*](r[^](2)[+]One))[^]n [=] a[^](2)[+]b[^](2)!.
\end{convention}
% file "NRootCC.v", line 1135 *)
\index{nrCC4_a2@\verb/nrCC4_a2/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a2 : (Zero [:<] a[^](2)[+]b[^](2)).
\end{verbatim}
% file "NRootCC.v", line 1144 *)
\index{nrCC4_a3@\verb/nrCC4_a3/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a3 : (Zero [:<] r[^](2)[+]One).
\end{verbatim}
% file "NRootCC.v", line 1152 *)
\index{nrCC4_a4@\verb/nrCC4_a4/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a4 : (Zero [:<] y2).
\end{verbatim}
% file "NRootCC.v", line 1163-1164 *)
\index{nrCC4_y@\verb/nrCC4_y/, \emph{definition}}
\index{y@\verb/y/, \emph{local}}
\begin{verbatim}
Definition nrCC4_y := (sqrt y2 (less_leEq ??? nrCC4_a4)).
Local y := nrCC4_y.
\end{verbatim}
% file "NRootCC.v", line 1168-1169 *)
\index{nrCC4_x@\verb/nrCC4_x/, \emph{definition}}
\index{x@\verb/x/, \emph{local}}
\begin{verbatim}
Definition nrCC4_x := y[*]r.
Local x := nrCC4_x.
\end{verbatim}
% file "NRootCC.v", line 1173 *)
\index{nrCC4_a5@\verb/nrCC4_a5/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a5 : x [=] y[*]r.
\end{verbatim}
% file "NRootCC.v", line 1181 *)
\index{nrCC4_a6@\verb/nrCC4_a6/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a6 : (x[^](2)[+]y[^](2))[^]n [=] a[^](2)[+]b[^](2).
\end{verbatim}
% file "NRootCC.v", line 1204-1205 *)
\index{nrCC4_z@\verb/nrCC4_z/, \emph{definition}}
\index{z@\verb/z/, \emph{local}}
\begin{verbatim}
Definition nrCC4_z := x[+I*]y.
Local z := nrCC4_z.
\end{verbatim}
% file "NRootCC.v", line 1209 *)
\index{nrCC4_a7@\verb/nrCC4_a7/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a7 : (z[^]n[*](conj c)[-](conj z)[^]n[*]c) [=] Zero.
\end{verbatim}
% file "NRootCC.v", line 1274 *)
\index{nrCC4_a8@\verb/nrCC4_a8/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a8 : (z[*](conj z))[^]n [=] c[*](conj c).
\end{verbatim}
% file "NRootCC.v", line 1293 *)
\index{nrCC4_a9@\verb/nrCC4_a9/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a9 : (z[^]n [=] c) \/ (z[^]n [=] [--]c).
\end{verbatim}
% file "NRootCC.v", line 1308-1310 *)
\index{nrCC4_a10@\verb/nrCC4_a10/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC4_a10 : (c:CC)
  (Ex [z:CC]((z[^]n [=] c) \/ (z[^]n [=] [--]c)))->
    (Ex [z:CC](z[^]n [=] c)).
\end{verbatim}
% file "NRootCC.v", line 1327 *)
\index{nrootCC_4_ap_real@\verb/nrootCC_4_ap_real/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_4_ap_real : (Ex [z:CC](z[^]n [=] c)).
\end{verbatim}
% file "NRootCC.v", line 1342 *)
\subsubsection{NRootCC 4 ap imag}
% file "NRootCC.v", line 1348-1352 *)
\begin{convention}
Let \verb!a, b : IR! and \verb!n : nat!
with
\verb!a [#] Zero! and \verb!(odd n)!.
\end{convention}
% file "NRootCC.v", line 1360-1362 *)
\index{c'@\verb/c'/, \emph{local}}
\index{a'@\verb/a'/, \emph{local}}
\index{b'@\verb/b'/, \emph{local}}
\begin{verbatim}
Local c' := (a[+I*]b)[*]I.
Local a' := (Re c').
Local b' := (Im c').
\end{verbatim}
% file "NRootCC.v", line 1366 *)
\index{nrootCC_4_ap_real'@\verb/nrootCC_4_ap_real'/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_4_ap_real' : (Ex [z':CC](z'[^]n [=] a'[+I*]b')).
\end{verbatim}
% file "NRootCC.v", line 1377 *)
\index{nrootCC_4_ap_imag@\verb/nrootCC_4_ap_imag/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_4_ap_imag : (Ex [z:CC](z[^]n [=] a[+I*]b)).
\end{verbatim}
% file "NRootCC.v", line 1405-1406 *)
\index{nrootCC_4@\verb/nrootCC_4/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_4 : (c:CC)(c [#] Zero)->(n:nat)(odd n)->
  (Ex [z:CC](z[^]n [=] c)).
\end{verbatim}
% file "NRootCC.v", line 1419 *)
\subsection{NRootCC}
% file "NRootCC.v", line 1426-1429 *)
\index{nrCC_5a1@\verb/nrCC_5a1/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC_5a1 :
  (P:nat->Prop)
  ((n:nat)(odd n)->(P n))-> ((n:nat)(lt O n)->(P n)->(P (double n)))->
    (n:nat)(lt O n)->(P n).
\end{verbatim}
% file "NRootCC.v", line 1463 *)
\index{nrCC_5a2@\verb/nrCC_5a2/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC_5a2 : (n:nat)(double n) = (mult (2) n).
\end{verbatim}
% file "NRootCC.v", line 1472 *)
\index{nrCC_5a3@\verb/nrCC_5a3/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC_5a3 : (n:nat)(z:CC)((z[^](2))[^]n [=] z[^](double n)).
\end{verbatim}
% file "NRootCC.v", line 1485-1489 *)
\begin{convention}
Let \verb!c : CC!
with
\verb!c [#] Zero!.
\end{convention}
% file "NRootCC.v", line 1495-1496 *)
\index{nrCC_5a4@\verb/nrCC_5a4/, \emph{lemma}}
\begin{verbatim}
Lemma nrCC_5a4 : (n:nat)(lt O n)->
  (Ex [z:CC](z[^]n [=] c))->(Ex [z:CC](z[^](double n) [=] c)).
\end{verbatim}
% file "NRootCC.v", line 1520 *)
\index{nrootCC_5@\verb/nrootCC_5/, \emph{lemma}}
\begin{verbatim}
Lemma nrootCC_5 : (n:nat)(lt O n)->(Ex [z:CC](z[^]n [=] c)).
\end{verbatim}
% file "NRootCC.v", line 1533 *)
\subsection{Final def}
% file "NRootCC.v", line 1537-1539 *)
\index{nrootCC@\verb/nrootCC/, \emph{definition}}
\begin{verbatim}
Definition nrootCC :
  (c:CC)(c [#] Zero)->(n:nat)(lt O n)->(Ex [z:CC](z[^]n [=] c))
    := nrootCC_5.
\end{verbatim}
% file "KneserLemma.v", line 8 *)
\section{Kneser Lemma}
% file "KneserLemma.v", line 14-17 *)
\begin{convention}
Let \verb!b : nat->CC!, \verb!n : nat!, \verb!(lt (0) n)!,
\verb!(b n) [=] One!, \verb!c : IR!, \verb!(AbsCC b_0) [:<] c!.
\end{convention}
% file "KneserLemma.v", line 23-24 *)
\index{b_0@\verb/b_0/, \emph{local}}
\index{b_n@\verb/b_n/, \emph{local}}
\begin{verbatim}
Local b_0 := (b O).
Local b_n := (b n).
\end{verbatim}
% file "KneserLemma.v", line 31-35 *)
\index{two_n@\verb/two_n/, \emph{local}}
\index{Small@\verb/Small/, \emph{local}}
\index{Smaller@\verb/Smaller/, \emph{local}}
\index{Smallest@\verb/Smallest/, \emph{local}}
\index{q@\verb/q/, \emph{local}}
\begin{verbatim}
Local two_n := (mult (2) n).
Local Small := (p3m n).
Local Smaller := (p3m (mult two_n n)).
Local Smallest := Small[*]Smaller.
Local q := One[-]Smallest.
\end{verbatim}
% file "KneserLemma.v", line 39-41 *)
\index{b_0'_exists@\verb/b_0'_exists/, \emph{lemma}}
\begin{verbatim}
Lemma b_0'_exists :
(eta:IR)(Zero [:<] eta) ->
        (EX b_0' | ((AbsCC (b_0'[-]b_0)) [:<] eta) /\ (b_0' [#] Zero)).
\end{verbatim}
% file "KneserLemma.v", line 53 *)
\index{eta_0@\verb/eta_0/, \emph{local}}
\begin{verbatim}
Local eta_0 := (c[-](AbsCC b_0))[/]FourNZ.
\end{verbatim}
% file "KneserLemma.v", line 57 *)
\index{eta_0_pos@\verb/eta_0_pos/, \emph{lemma}}
\begin{verbatim}
Lemma eta_0_pos : (Zero[:<] eta_0).
\end{verbatim}
% file "KneserLemma.v", line 68-73 *)
\index{eta_exists@\verb/eta_exists/, \emph{lemma}}
\begin{verbatim}
Lemma eta_exists :
        (EX eta | (Zero [:<] eta) /\
          (EX b_0' |
            ((AbsCC (b_0'[-]b_0)) [:<] eta) /\
            (b_0' [#] Zero) /\
            ((AbsCC b_0')[+]Three[*]eta [:<] c))).
\end{verbatim}
% file "KneserLemma.v", line 105-107 *)
\index{eps_exists_1@\verb/eps_exists_1/, \emph{lemma}}
\begin{verbatim}
Lemma eps_exists_1 :
  (eps,x,y:IR)(Zero [:<] eps) -> (Zero [:<] x) -> (Zero [:<] y) ->
    (EX eps' | (Zero [:<] eps') /\ (eps' [:<] eps) /\ (x[*]eps' [:<] y)).
\end{verbatim}
% file "KneserLemma.v", line 153-159 *)
\index{eps_exists_2@\verb/eps_exists_2/, \emph{lemma}}
\begin{verbatim}
Lemma eps_exists_2 :
  (x1,y1,x2,y2,z:IR)
    (Zero [:<] x1) -> (Zero [:<] y1) ->
    (Zero [:<] x2) -> (Zero [:<] y2) ->
    (Zero [:<] z) ->
      (EX eps | (Zero [:<] eps) /\
        (x1[*]eps [:<] y1) /\ (x2[*]eps [:<] y2) /\ (eps [:<] z)).
\end{verbatim}
% file "KneserLemma.v", line 189-194 *)
\index{eps_exists@\verb/eps_exists/, \emph{lemma}}
\begin{verbatim}
Lemma eps_exists :
(eta,a_0:IR)(Zero [:<] eta) -> (Zero [:<] a_0) ->
        (EX eps | (Zero [:<] eps) /\
          (Two[*](Three[^]n[+]One)[*]eps [:<] eta) /\
          (Two[*]eps [:<] Smaller[*]a_0) /\
          (eps [:<] a_0)).
\end{verbatim}
% file "KneserLemma.v", line 214 *)
\index{a@\verb/a/, \emph{local}}
\begin{verbatim}
Local a : nat->IR := [i:nat](AbsCC (b i)).
\end{verbatim}
% file "KneserLemma.v", line 218-228 *)
\index{z_exists@\verb/z_exists/, \emph{lemma}}
\begin{verbatim}
Lemma z_exists :
(b_0':CC; k:nat; r,eta:IR)
  let a_0 = (AbsCC b_0') in
        (Zero [:<] a_0) -> (Zero [:<] (a k)) ->
        (le (1) k) -> (le k n) ->
        (Zero [:<] r) -> (Zero [:<] eta) ->
        ((AbsCC (b_0'[-]b_0)) [:<] eta) ->
        ((a k)[*]r[^]k [:<] a_0) ->
          (EX z |
            ((AbsCC z) [=] r) /\
            ((AbsCC (b_0[+](b k)[*]z[^]k)) [:<] a_0[-](a k)[*]r[^]k[+]eta)).
\end{verbatim}
% file "KneserLemma.v", line 339 *)
\index{Kneser_1'@\verb/Kneser_1'/, \emph{lemma}}
\begin{verbatim}
Lemma Kneser_1' : Half [:<] q.
\end{verbatim}
% file "KneserLemma.v", line 373 *)
\index{Kneser_1''@\verb/Kneser_1''/, \emph{lemma}}
\begin{verbatim}
Lemma Kneser_1'' : q [:<] One.
\end{verbatim}
% file "KneserLemma.v", line 390-394 *)
\index{Kneser_1@\verb/Kneser_1/, \emph{lemma}}
\begin{verbatim}
Lemma Kneser_1 :
(a_0,eta,eps:IR)(Zero [:<] eta) -> (Zero [:<] eps) ->
        (a_0[+]Three[*]eta [:<] c) ->
        (Two[*](Three[^]n[+]One)[*]eps [:<] eta) ->
          (q[*]a_0[+]Three[^]n[*]eps[+]eps[+]eta [:<] q[*]c).
\end{verbatim}
% file "KneserLemma.v", line 444-447 *)
\index{Kneser_2a@\verb/Kneser_2a/, \emph{lemma}}
\begin{verbatim}
Lemma Kneser_2a :
(R:CRing)(m,n,i:nat)(f:nat->R)
  (le (1) i) ->
    (Sum m n f) [=] (f m)[+](f i)[+]((Sum (S m) (pred i) f)[+](Sum (S i) n f)).
\end{verbatim}
% file "KneserLemma.v", line 457-462 *)
\index{Kneser_2b@\verb/Kneser_2b/, \emph{lemma}}
\begin{verbatim}
Lemma Kneser_2b :
(k:nat; z:CC)(le (1) k) ->
  let p_ = [i:nat](b i)[*]z[^]i in
        (Sum (0) n [i:nat](b i)[*]z[^]i) [=]
          (b_0[+](b k)[*]z[^]k)[+]
            ((Sum (1) (pred k) p_)[+](Sum (S k) n p_)).
\end{verbatim}
% file "KneserLemma.v", line 476-480 *)
\index{Kneser_2c@\verb/Kneser_2c/, \emph{lemma}}
\begin{verbatim}
Lemma Kneser_2c :
(m,n:nat; z:CC)(le m (S n)) ->
  let r = (AbsCC z) in
        (AbsCC (Sum m n [i:nat](b i)[*]z[^]i)) [:<=]
          (Sum m n [i:nat](a i)[*]r[^]i).
\end{verbatim}
% file "KneserLemma.v", line 492-498 *)
\index{Kneser_2@\verb/Kneser_2/, \emph{lemma}}
\begin{verbatim}
Lemma Kneser_2 :
(k:nat; z:CC)(le (1) k) -> (le k n) ->
  let r = (AbsCC z) in
  let p_ = [i:nat](a i)[*]r[^]i in
        (AbsCC (Sum (0) n [i:nat](b i)[*]z[^]i)) [:<=]
          (AbsCC (b_0[+](b k)[*]z[^]k))[+]
             ((Sum (1) (pred k) p_)[+](Sum (S k) n p_)).
\end{verbatim}
% file "KneserLemma.v", line 524-527 *)
\index{Kneser_3@\verb/Kneser_3/, \emph{lemma}}
\begin{verbatim}
Lemma Kneser_3 :
        (EX z |
          ((AbsCC z)[^]n [:<] c) /\
          ((AbsCC (Sum (0) n [i:nat](b i)[*]z[^]i)) [:<] q[*]c)).
\end{verbatim}
% file "KneserLemma.v", line 644-651 *)
\index{Kneser@\verb/Kneser/, \emph{lemma}}
\begin{verbatim}
Lemma Kneser :
(n:nat)(lt (0) n) ->
  (EX q | (Zero [:<] q) /\ (q [:<] One) /\
    (p:(cpoly CC))(Monic n p) ->
      (c:IR)((AbsCC (p!Zero)) [:<] c) ->
        (EX z |
          ((AbsCC z)[^]n [:<] c) /\
          ((AbsCC (p!z)) [:<] q[*]c))).
\end{verbatim}
% file "FTAreg.v", line 564-566 *)
\index{fta_monic@\verb/fta_monic/, \emph{lemma}}
\begin{verbatim}
Lemma fta_monic : (p: (cpoly CC);n:nat)(lt (0) n) ->
 (Monic n p)->
 (EX c | ( p ! c) [=] Zero).
\end{verbatim}
% file "FTAreg.v", line 606-608 *)
\index{fta_reg@\verb/fta_reg/, \emph{lemma}}
\begin{verbatim}
Lemma fta_reg : (p: (cpoly CC);n:nat)(lt (0) n) ->
 (Degree n p)->
 (EX c | ( p ! c) [=] Zero).
\end{verbatim}
% file "FTA.v", line 7 *)
\section{Fundamental Theorem of Algebra}
% file "FTA.v", line 13-18 *)
\index{fta_reg'@\verb/fta_reg'/, \emph{lemma}}
\begin{verbatim}
Variable f : (cpoly_cring CC).
Variable n : nat.
Hypothesis f_degree : (Degree (S n) f).

Lemma fta_reg' :
  (EX f1 | (Degree (1) f1) /\ (EX f2 | (Degree n f2) /\ (f [=] f1[*]f2))).
\end{verbatim}
% file "FTA.v", line 39-43 *)
\begin{verbatim}
Variable f : (cpoly_cring CC).
Variable n : nat.
Hypothesis f_degree : (Degree_le (S n) f).
Variable c : CC.
Hypothesis f_c : f!c [#] Zero.
\end{verbatim}
% file "FTA.v", line 61-63 *)
\index{fta_1@\verb/fta_1/, \emph{lemma}}
\begin{verbatim}
Lemma fta_1 :
  (EX f1 | (Degree_le (1) f1) /\ (EX f2 | (Degree_le n f2) /\
    (f [=] f1[*]f2))).
\end{verbatim}
% file "FTA.v", line 95-97 *)
\index{fta_1'@\verb/fta_1'/, \emph{lemma}}
\begin{verbatim}
Lemma fta_1' :
  (EX a | (EX b | (EX g | (Degree_le n g) /\
    (f [=] ((_C_ a)[*]_X_[+](_C_ b))[*]g)))).
\end{verbatim}
% file "FTA.v", line 115-117 *)
\index{fta'@\verb/fta'/, \emph{lemma}}
\begin{verbatim}
Lemma fta' :
  (n:nat)(f:(cpoly_cring CC))
    (Degree_le n f) -> (nonConst ? f) -> (EX z | f!z [=] Zero).
\end{verbatim}
% file "FTA.v", line 159 *)
\index{fta@\verb/fta/, \emph{lemma}}
\begin{verbatim}
Lemma fta : (f:(cpoly_cring CC))(nonConst ? f) -> (EX z | f!z [=] Zero).
\end{verbatim}
\input body.ind
\end{document}
