(****************************************************************************** Markov's inequality.  Based on Wikipedia proof Copyright 2008 Robert Kam  This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.  You should have received a copy of the GNU Lesser General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>. ******************************************************************************)
(* sigalg = sigma algebra preimg = preimage cntabl = countable msur = measure function msurable = measurable simple = simple function lebint = Lebesgue integral lebint_s = Lebesgue integral for simple function borl = Borel set unoin = union *)
(****************************************************************************** Note: chicli_pottier_simpson, classic, Extensionality_Ensembles, NNPP are used frequently Also lemmas from Rtopology which use classic as well as R_total_order ******************************************************************************)
Require Export Powerset.
Require Export Rtopology.
Require Export Raxioms.
Require Export Rfunctions.
Require Export Image.
Require Export RIneq.
Require Export PartSum.
intros EM. pose(select:=fun b:bool=>if b then P else ~P). assert{b:bool|
select b}as([|],HP). apply constructive_definite_description. rewrite<-
unique_existence;split. destruct EM. exists true;trivial. exists false;trivial.
intros[|][|]H1 H2;simpl in *;reflexivity||contradiction. left;trivial. right;
trivial. Qed.
Definition cntabl(U:Type)(C:Ensemble(Ensemble U)):=
exists f:nat->Ensemble U,forall c,C c->exists i:nat,f i=c.
(**)
intros sIH n. induction n. intros n' Hn'. apply sIH. intros. elimtype False;
intuition. intuition. Qed.
(**)
intros k. apply aaron_stump_cse545 with(Q:=fun z=>Q z->exists m,Q m/\forall n
,Q n->m<=n)(n:=k). 2:auto. intros n H H1. elim(classic(forall i,i<n->~Q i)).
intro H2. exists n. split. auto. intros j H3. apply NNPP. red;intro H4. apply(
H2 j). intuition. auto.
(**)
intro H2. assert(H3:exists i:nat,i<n/\Q i). apply NNPP. red;intro H3. apply H2.
intros i H4. red;intro H5. apply H3. exists i. auto. elim H3. intros ii H4.
elim(H ii). intros m H5. exists m. auto. tauto. tauto. Qed.

(****************************************************************************** You can actually prove this without using constructive_definite_description, you can use Yevgeniy Marakov's constructive_indefinite_description_nat from Coq.Logic.ConstructiveEpsilon, which is purely constructive -- probably don't even need classic really to do this proof. ******************************************************************************)
Lemma cntabl_P0(U:Type)(C:Ensemble(Ensemble U))
:cntabl _ C->
exists g:forall c,C c->nat,
(forall c c' c'',g c c'=g c c'')
/\forall c cc c' cc',g c c'=g cc cc'->c=cc.