Built with
Alectryon , running Coq+SerAPI v8.13.0+0.13.0. Bubbles (
) indicate interactive fragments: hover for details, tap to reveal contents. Use
Ctrl+↑ Ctrl+↓ to navigate,
Ctrl+🖱️ to focus. On Mac, use
⌘ instead of
Ctrl .
(******************************************************************************)
(* *)
(* PSI *)
(* psi n = the psi function *)
(* *)
(* *)
(* *)
(******************************************************************************)
From mathcomp Require Import all_ssreflect all_algebra finmap.Notation "[ rel _ _ | _ ]" was already used in scope
fun_scope. [notation-overridden,parsing]Notation "[ rel _ _ : _ | _ ]" was already used in
scope fun_scope. [notation-overridden,parsing]Notation "[ rel _ _ in _ & _ | _ ]" was already used
in scope fun_scope. [notation-overridden,parsing]Notation "[ rel _ _ in _ & _ ]" was already used in
scope fun_scope. [notation-overridden,parsing]Notation "[ rel _ _ in _ | _ ]" was already used in
scope fun_scope. [notation-overridden,parsing]Notation "[ rel _ _ in _ ]" was already used in scope
fun_scope. [notation-overridden,parsing]Notation "_ + _" was already used in scope nat_scope.
[notation-overridden,parsing]Notation "_ - _" was already used in scope nat_scope.
[notation-overridden,parsing]Notation "_ <= _" was already used in scope nat_scope.
[notation-overridden,parsing]Notation "_ < _" was already used in scope nat_scope.
[notation-overridden,parsing]Notation "_ >= _" was already used in scope nat_scope.
[notation-overridden,parsing]Notation "_ > _" was already used in scope nat_scope.
[notation-overridden,parsing]Notation "_ <= _ <= _" was already used in scope
nat_scope. [notation-overridden,parsing]Notation "_ < _ <= _" was already used in scope
nat_scope. [notation-overridden,parsing]Notation "_ <= _ < _" was already used in scope
nat_scope. [notation-overridden,parsing]Notation "_ < _ < _" was already used in scope
nat_scope. [notation-overridden,parsing]Notation "_ * _" was already used in scope nat_scope.
[notation-overridden,parsing]New coercion path [GRing.subring_closedM;
GRing.smulr_closedN] : GRing.subring_closed >-> GRing.oppr_closed is ambiguous with existing
[GRing.subring_closedB; GRing.zmod_closedN] : GRing.subring_closed >-> GRing.oppr_closed.
[ambiguous-paths,typechecker] New coercion path [GRing.subring_closed_semi;
GRing.semiring_closedM] : GRing.subring_closed >-> GRing.mulr_closed is ambiguous with existing
[GRing.subring_closedM; GRing.smulr_closedM] : GRing.subring_closed >-> GRing.mulr_closed.
New coercion path [GRing.subring_closed_semi;
GRing.semiring_closedD] : GRing.subring_closed >-> GRing.addr_closed is ambiguous with existing
[GRing.subring_closedB; GRing.zmod_closedD] : GRing.subring_closed >-> GRing.addr_closed.
[ambiguous-paths,typechecker] New coercion path [GRing.sdivr_closed_div;
GRing.divr_closedM] : GRing.sdivr_closed >-> GRing.mulr_closed is ambiguous with existing
[GRing.sdivr_closedM; GRing.smulr_closedM] : GRing.sdivr_closed >-> GRing.mulr_closed.
[ambiguous-paths,typechecker] New coercion path [GRing.subalg_closedBM;
GRing.subring_closedB] : GRing.subalg_closed >-> GRing.zmod_closed is ambiguous with existing
[GRing.subalg_closedZ; GRing.submod_closedB] : GRing.subalg_closed >-> GRing.zmod_closed.
[ambiguous-paths,typechecker] New coercion path [GRing.divring_closed_div;
GRing.sdivr_closedM] : GRing.divring_closed >-> GRing.smulr_closed is ambiguous with existing
[GRing.divring_closedBM; GRing.subring_closedM] : GRing.divring_closed >-> GRing.smulr_closed.
New coercion path [GRing.divring_closed_div;
GRing.sdivr_closedM;
GRing.smulr_closedN] : GRing.divring_closed >-> GRing.oppr_closed is ambiguous with existing
[GRing.divring_closedBM; GRing.subring_closedB;
GRing.zmod_closedN] : GRing.divring_closed >-> GRing.oppr_closed.
[ambiguous-paths,typechecker] New coercion path [GRing.divalg_closedBdiv;
GRing.divring_closedBM] : GRing.divalg_closed >-> GRing.subring_closed is ambiguous with existing
[GRing.divalg_closedZ; GRing.subalg_closedBM] : GRing.divalg_closed >-> GRing.subring_closed.
New coercion path [GRing.divalg_closedBdiv;
GRing.divring_closedBM;
GRing.subring_closedB] : GRing.divalg_closed >-> GRing.zmod_closed is ambiguous with existing
[GRing.divalg_closedZ; GRing.subalg_closedZ;
GRing.submod_closedB] : GRing.divalg_closed >-> GRing.zmod_closed.
[ambiguous-paths,typechecker] New coercion path [GRing.Pred.subring_smul;
GRing.Pred.smul_mul] : GRing.Pred.subring >-> GRing.Pred.mul is ambiguous with existing
[GRing.Pred.subring_semi; GRing.Pred.semiring_mul] : GRing.Pred.subring >-> GRing.Pred.mul.
[ambiguous-paths,typechecker] New coercion path [GRing.Pred.divring_sdiv;
GRing.Pred.sdiv_smul;
GRing.Pred.smul_mul] : GRing.Pred.divring >-> GRing.Pred.mul is ambiguous with existing
[GRing.Pred.divring_ring; GRing.Pred.subring_semi;
GRing.Pred.semiring_mul] : GRing.Pred.divring >-> GRing.Pred.mul.
[ambiguous-paths,typechecker]
From hanoi Require Import extra triangular phi.
Set Implicit Arguments .
Unset Strict Implicit .
Unset Printing Implicit Defensive .
Open Scope fset_scope.
Open Scope nat_scope.
Section BigFSetAux .
Variable (R : Type ) (idx : R) (op : Monoid.com_law idx).
Variable (I J : choiceType).
Lemma fsum_nat_const (e : {fset I}) a : \sum_(i <- e) a = #|` e| * a.R : Type
idx : R
op : Monoid.com_law idx
I, J : choiceType
e : {fset I}
a : nat
\sum_(i <- e) a = #|` e| * a
Proof .2
by rewrite big_const_seq count_predT iter_addn_0 mulnC. Qed .
Lemma diff_fset0_elem (e : {fset I}) : e != fset0 -> {i : I | i \in e}.5 6 7 8 9
e != fset0 -> {i : I | i \in e}
Proof .e
by case : e => [] [|i l] iH //=; exists i ; rewrite inE eqxx.
Qed .
(* Should be reworked *)
Lemma eq_fbigmax (e : {fset I}) (F : I -> nat) :
0 < #|`e| -> {i0 : I | i0 \in e /\ \max_(i <- e) F i = F i0}.0 < #|` e| ->
{i0 : I | i0 \in e /\ \max_(i <- e) F i = F i0}
Proof .14
have [n cI] := ubnP #|`e|; elim : n => // n IH e cI in e cI *.5 6 7 8 17 n : nat
IH : forall e : {fset I},
#|` e| < n ->
0 < #|` e| ->
{i0 : I | i0 \in e /\ \max_(i <- e) F i = F i0}
9 cI : #|` e| < n.+1
18
rewrite cardfs_gt0 => /diff_fset0_elem[i iH].5 6 7 8 17 1e 1f 9 20 i : I
iH : i \in e
{i0 : I | i0 \in e /\ \max_(i <- e) F i = F i0}
have [|H] := leqP #|`(e `\ i)| 0 .24 #|` e `\ i| <= 0 ->
{i0 : I | i0 \in e /\ \max_(i1 <- e) F i1 = F i0}
rewrite leqn0 cardfs_eq0 => /eqP eZ.5 6 7 8 17 1e 1f 9 20 25 26 eZ : e `\ i = fset0
27 2c
exists i ; split => //.33 \max_(i <- e) F i = F i
2c
rewrite (big_fsetD1 i) //= eZ big1_fset => [|j]; last by rewrite inE.
by apply /maxn_idPl.
case : (IH (e `\ i)) => // [|j [jIe jH]].
by move : cI; rewrite (cardfsD1 i) iH.
have [FiLFj|FjLFi] := leqP (F i) (F j).5 6 7 8 17 1e 1f 9 20 25 26 2f 47 48 49 FiLFj : F i <= F j
27
exists j ; split => //.
by move : jIe; rewrite !inE => /andP[].
rewrite (big_fsetD1 i) //= jH.50 maxn (F i) (F j) = F j
52
by apply /maxn_idPr.
exists i ; split .
by move : jIe; rewrite !inE => /andP[].
rewrite (big_fsetD1 i) //= jH.
by apply /maxn_idPl/ltnW.
Qed .
Lemma big_fsetD1cond (a : I) (A : {fset I}) (P : pred I) (F : I -> R) :
a \in A -> P a ->
\big[op/idx]_(i <- A | P i) F i =
op (F a) (\big[op/idx]_(i <- A `\ a | P i) F i).5 6 7 8 a : I
A : {fset I}
P : pred I
F : I -> R
a \in A ->
P a ->
\big[op/idx]_(i <- A | P i) F i =
op (F a) (\big[op/idx]_(i <- A `\ a | P i) F i)
Proof .75
move => aA aP; rewrite (big_fsetIDcond _ (mem [fset a])).5 6 7 8 78 79 7a 7b aA : a \in A
aP : P a
op
(\big[op/idx]_(i <- [fset x
| x in A
& mem [fset a] x] | P i)
F i)
(\big[op/idx]_(i <- [fset x
| x in A
& ~~ mem [fset a] x] | P i)
F i) =
op (F a) (\big[op/idx]_(i <- A `\ a | P i) F i)
congr (op _ _); last first .81 \big[op/idx]_(i <- [fset x
| x in A
& ~~ mem [fset a] x] | P i)
F i = \big[op/idx]_(i <- A `\ a | P i) F i
by apply : eq_fbigl_cond => i; rewrite !inE /= [_ && (_ != _)]andbC.
rewrite (_ : [fset _ | _ in _ & _] = [fset a]).81 \big[op/idx]_(i <- [fset a] | P i) F i = F a
rewrite big_seq_fsetE /= /index_enum /= -enumT enum_fset1 /=.81 \big[op/idx]_(x <- [:: [` fset11 a]] | P (fsval x))
F (fsval x) = F a
93
by rewrite unlock /= aP Monoid.Theory.mulm1.
by apply /fsetP=> i; rewrite !inE /= andbC; case : eqP => //->.
Qed .
End BigFSetAux .
Section BigFSetAux .
Variable (R : Type ) (idx : R) (op : Monoid.com_law idx).
Variable (I J : choiceType).
Lemma bigfmax_leqP (P : pred I) (m : nat) (e : {fset I}) (F : I -> nat) :
reflect (forall i : I, i \in e -> P i -> F i <= m)
(\max_(i <- e | P i) F i <= m).reflect (forall i : I, i \in e -> P i -> F i <= m)
(\max_(i <- e | P i) F i <= m)
Proof .9e
apply : (iffP idP) => leFm => [i iIe Pi|].5 6 7 8 7a a1 9 17 leFm : \max_(i <- e | P i) F i <= m
25 iIe : i \in e
Pi : P i
F i <= m
move : leFm.5 6 7 8 7a a1 9 17 25 a9 aa
\max_(i <- e | P i) F i <= m -> F i <= m
ac
rewrite (big_fsetD1cond _ _ _ Pi) //= => /(leq_trans _)-> //.b4 F i <= maxn (F i) (\max_(i <- e `\ i | P i) F i)
ac
by apply : leq_maxl.
rewrite big_seq_cond.ae \max_(i <- e | (i \in e) && P i) F i <= m
elim /big_ind: _ => //= [m1 m2 m1Lm m2Ln | i /andP[]].5 6 7 8 7a a1 9 17 af m1, m2 : nat
m1Lm : m1 <= m
m2Ln : m2 <= m
maxn m1 m2 <= m
by rewrite geq_max m1Lm.
by apply : leFm.
Qed .
Lemma leq_bigfmax (e : {fset I}) (F : I -> nat) i :
i \in e -> F i <= \max_(i <- e) F i.5 6 7 8 9 17 25
i \in e -> F i <= \max_(i <- e) F i
Proof .d1
move => iIe.5 6 7 8 9 17 25 a9
F i <= \max_(i <- e) F i
have : i \in enum_fset e by [].
elim : enum_fset => //= a l IH.5 6 7 8 9 17 25 a9 78 l : seq I
IH : i \in l -> F i <= \max_(i <- l) F i
i \in a :: l -> F i <= \max_(i <- (a :: l)) F i
rewrite inE big_cons => /orP[/eqP<-|/IH H]; first by apply : leq_maxl.5 6 7 8 9 17 25 a9 78 e2 e3 H : F i <= \max_(i <- l) F i
F i <= maxn (F a) (\max_(j <- l) F j)
by apply : leq_trans H _; apply : leq_maxr.
Qed .
End BigFSetAux .
Section PsiDef .
Implicit Type e : {fset nat}.
Import Order.TTheory GRing.Theory Num.Theory.
Open Scope fset_scope.
Definition psi_aux l e : int :=
((2 ^ l).-1 + (\sum_(i <- e) 2 ^ (minn (troot i) l)))%:R - (l * 2 ^ l)%:R.
Notation "'ψ'' n" := (psi_aux n) (format "'ψ'' n" , at level 0 ).
Lemma psi_aux_0_ge0 e : (0 <= psi_aux 0 e)%R.
Proof .ec
by rewrite /psi_aux add0n mul0n subr0 (ler_nat _ 0 ). Qed .
Lemma psi_aux_sub l e1 e2 : e1 `<=` e2 -> (psi_aux l e1 <= psi_aux l e2)%R.e1 `<=` e2 -> (ψ'(l) e1 <= ψ'(l) e2)%R
Proof .f3
move => e1Se2.
apply : ler_sub => //.fd (((2 ^ l).-1 + \sum_(i <- e1) 2 ^ minn (∇i) l)%:R <=
((2 ^ l).-1 + \sum_(i <- e2) 2 ^ minn (∇i) l)%:R)%R
rewrite ler_nat.fd (2 ^ l).-1 + \sum_(i <- e1) 2 ^ minn (∇i) l <=
(2 ^ l).-1 + \sum_(i <- e2) 2 ^ minn (∇i) l
rewrite leq_add2l //.fd \sum_(i <- e1) 2 ^ minn (∇i) l <=
\sum_(i <- e2) 2 ^ minn (∇i) l
rewrite [X in _ <= X](bigID (fun i => i \in e1)) /=.fd \sum_(i <- e1) 2 ^ minn (∇i) l <=
\sum_(i <- e2 | i \in e1) 2 ^ minn (∇i) l +
\sum_(i <- e2 | i \notin e1) 2 ^ minn (∇i) l
suff iH : [fset x in e1 | xpredT x] =i [fset i in e2 | i \in e1].f6 f7 fe iH : [fset x | x in e1 & true]
=i [fset i | i in e2 & i \in e1]
10f
by rewrite (eq_fbigl_cond _ _ iH) /= leq_addr.
move => i; rewrite !inE /=.(i \in [eta mem_seq e1]) && true =
(i \in [eta mem_seq e2]) && (i \in e1)
have /fsubsetP/(_ i) := e1Se2.11e (i \in e1 -> i \in e2) ->
(i \in [eta mem_seq e1]) && true =
(i \in [eta mem_seq e2]) && (i \in e1)
by case : (i \in e1) => [->//|]; rewrite andbF.
Qed .
Lemma psi_auxE_le l e :
psi_aux l e =
(((2 ^ l * #|`[fset i in e | (l <= troot i)%nat]|.+1 ).-1
+ (\sum_(i <- e | (troot i < l)%nat) 2 ^ troot i))%:R - (l * 2 ^ l)%:R)%R.f6 ef
ψ'(l) e =
(((2 ^ l * #|` [fset i in e | (l <= ∇i)%N]|.+1 ).-1 +
\sum_(i <- e | (∇i < l)%N) 2 ^ ∇i)%:R -
(l * 2 ^ l)%:R)%R
Proof .126
rewrite /psi_aux.128 (((2 ^ l).-1 + \sum_(i <- e) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R)%R =
(((2 ^ l * #|` [fset i | i in e & (l <= ∇i)%N]|.+1 ).-1 +
\sum_(i <- e | (∇i < l)%N) 2 ^ ∇i)%:R -
(l * 2 ^ l)%:R)%R
congr (_%:R - _%:R)%R.128 ((2 ^ l).-1 + \sum_(i <- e) 2 ^ minn (∇i) l)%N =
((2 ^ l * #|` [fset i | i in e & l <= ∇i]|.+1 ).-1 +
\sum_(i <- e | ∇i < l) 2 ^ ∇i)%N
rewrite (big_fsetID _ [pred i | l <= ∇i]) /=.128 ((2 ^ l).-1 +
(\sum_(i <- [fset x | x in e & l <= ∇x])
2 ^ minn (∇i) l +
\sum_(i <- [fset x | x in e & ~~ (l <= ∇x)])
2 ^ minn (∇i) l))%N =
((2 ^ l * #|` [fset i | i in e & l <= ∇i]|.+1 ).-1 +
\sum_(i <- e | ∇i < l) 2 ^ ∇i)%N
rewrite (@eq_fbigr _ _ _ _ _ _ _ (fun i => 2 ^ l)) /=; last first .128 forall x : nat,
x \in [fset x0 | x0 in e & l <= ∇x0] ->
true -> 2 ^ minn (∇x) l = 2 ^ l
by move => i; rewrite !inE => /andP[_ /minn_idPr->].
rewrite fsum_nat_const.128 ((2 ^ l).-1 +
(#|` [fset x | x in e & l <= ∇x]| * 2 ^ l +
\sum_(i <- [fset x | x in e & ~~ (l <= ∇x)])
2 ^ minn (∇i) l))%N =
((2 ^ l * #|` [fset i | i in e & l <= ∇i]|.+1 ).-1 +
\sum_(i <- e | ∇i < l) 2 ^ ∇i)%N
rewrite (@eq_fbigr _ _ _ _ _ _ _ (fun i => 2 ^ (troot i))) /=; last first .128 forall x : nat,
x \in [fset x0 | x0 in e & ~~ (l <= ∇x0)] ->
true -> 2 ^ minn (∇x) l = 2 ^ ∇x
move => i; rewrite !inE => /andP[_ H] _.2 ^ minn (∇i) l = 2 ^ ∇i
149
suff /minn_idPl-> : troot i <= l by [].
by rewrite ltnW // ltnNge.
rewrite addnA; congr (_ + _)%nat.128 ((2 ^ l).-1 + #|` [fset x | x in e & l <= ∇x]| * 2 ^ l)%N =
(2 ^ l * #|` [fset i | i in e & l <= ∇i]|.+1 ).-1
rewrite mulnS [_ ^ _ * #|`_|]mulnC.128 ((2 ^ l).-1 + #|` [fset x | x in e & l <= ∇x]| * 2 ^ l)%N =
(2 ^ l + #|` [fset i | i in e & l <= ∇i]| * 2 ^ l).-1
15e
by case : (2 ^ l) (expn_gt0 2 l).
by apply : eq_fbigl_cond => i; rewrite !inE ltnNge andbT.
Qed .
Lemma psi_auxE_lt l e :
psi_aux l e =
(((2 ^ l * #|`[fset i in e | (l < troot i)%nat]|.+1 ).-1
+ (\sum_(i <- e | (troot i <= l)%nat) 2 ^ troot i))%:R - (l * 2 ^ l)%:R)%R.128 ψ'(l) e =
(((2 ^ l * #|` [fset i in e | (l < ∇i)%N]|.+1 ).-1 +
\sum_(i <- e | (∇i <= l)%N) 2 ^ ∇i)%:R -
(l * 2 ^ l)%:R)%R
Proof .169
rewrite /psi_aux.128 (((2 ^ l).-1 + \sum_(i <- e) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R)%R =
(((2 ^ l * #|` [fset i | i in e & (l < ∇i)%N]|.+1 ).-1 +
\sum_(i <- e | (∇i <= l)%N) 2 ^ ∇i)%:R -
(l * 2 ^ l)%:R)%R
congr (_%:R - _%:R)%R.128 ((2 ^ l).-1 + \sum_(i <- e) 2 ^ minn (∇i) l)%N =
((2 ^ l * #|` [fset i | i in e & l < ∇i]|.+1 ).-1 +
\sum_(i <- e | ∇i <= l) 2 ^ ∇i)%N
rewrite (big_fsetID _ [pred i | l < troot i]) /=.128 ((2 ^ l).-1 +
(\sum_(i <- [fset x | x in e & l < ∇x])
2 ^ minn (∇i) l +
\sum_(i <- [fset x | x in e & ~~ (l < ∇x)])
2 ^ minn (∇i) l))%N =
((2 ^ l * #|` [fset i | i in e & l < ∇i]|.+1 ).-1 +
\sum_(i <- e | ∇i <= l) 2 ^ ∇i)%N
rewrite (@eq_fbigr _ _ _ _ _ _ _ (fun => 2 ^ l)) /=; last first .128 forall x : nat,
x \in [fset x0 | x0 in e & l < ∇x0] ->
true -> 2 ^ minn (∇x) l = 2 ^ l
by move => i; rewrite !inE => /andP[_ /ltnW/minn_idPr ->].
rewrite fsum_nat_const.128 ((2 ^ l).-1 +
(#|` [fset x | x in e & l < ∇x]| * 2 ^ l +
\sum_(i <- [fset x | x in e & ~~ (l < ∇x)])
2 ^ minn (∇i) l))%N =
((2 ^ l * #|` [fset i | i in e & l < ∇i]|.+1 ).-1 +
\sum_(i <- e | ∇i <= l) 2 ^ ∇i)%N
rewrite (@eq_fbigr _ _ _ _ _ _ _ (fun i => 2 ^ troot i)) /=; last first .128 forall x : nat,
x \in [fset x0 | x0 in e & ~~ (l < ∇x0)] ->
true -> 2 ^ minn (∇x) l = 2 ^ ∇x
move => i; rewrite !inE /= => /andP[_ H] _.
suff /minn_idPl-> : troot i <= l by [].
by rewrite leqNgt.
rewrite addnA; congr (_ + _)%nat.128 ((2 ^ l).-1 + #|` [fset x | x in e & l < ∇x]| * 2 ^ l)%N =
(2 ^ l * #|` [fset i | i in e & l < ∇i]|.+1 ).-1
rewrite mulnS [_ ^ _ * #|`_|]mulnC.128 ((2 ^ l).-1 + #|` [fset x | x in e & l < ∇x]| * 2 ^ l)%N =
(2 ^ l + #|` [fset i | i in e & l < ∇i]| * 2 ^ l).-1
19d
by case : (2 ^ l) (expn_gt0 2 l).
by apply : eq_fbigl_cond => i; rewrite !inE ltnNge andbT negbK.
Qed .
Definition psi_auxb e := (maxn #|`e| (\max_(i <- e) troot i)).+1 .
Notation "'ψ_b' n" := (psi_auxb n) (format "'ψ_b' n" , at level 0 ).
Lemma psi_aux_psib l e : psi_auxb e <= l -> (psi_aux l e <= 0 )%R.128 ψ_b(e) <= l -> (ψ'(l) e <= 0 )%R
Proof .1a8
rewrite /psi_auxb; case : l => // l.ef f6
maxn #|` e| (\max_(i <- e) ∇i) < l.+1 ->
(ψ'(l.+1 ) e <= 0 )%R
rewrite ltnS /psi_aux geq_max => /andP[eLl maxLl].ef f6 eLl : #|` e| <= l
maxLl : \max_(i <- e) ∇i <= l
(((2 ^ l.+1 ).-1 + \sum_(i <- e) 2 ^ minn (∇i) l.+1 )%:R -
(l.+1 * 2 ^ l.+1 )%:R <= 0 )%R
rewrite mulSn -{2 }[_ ^ _]prednK ?expn_gt0 // addSnnS.1b4 (((2 ^ l.+1 ).-1 + \sum_(i <- e) 2 ^ minn (∇i) l.+1 )%:R -
((2 ^ l.+1 ).-1 + (l * 2 ^ l.+1 ).+1 )%:R <= 0 )%R
rewrite !natrD [(_%:R + _)%R]addrC opprD addrA addrK.1b4 ((\sum_(i <- e) 2 ^ minn (∇i) l.+1 )%:R -
(l * 2 ^ l.+1 ).+1 %:R <= 0 )%R
rewrite subr_le0 ler_nat.1b4 \sum_(i <- e) 2 ^ minn (∇i) l.+1 <= (l * 2 ^ l.+1 ).+1
apply : leq_trans (leqnSn _).1b4 \sum_(i <- e) 2 ^ minn (∇i) l.+1 <= l * 2 ^ l.+1
apply : leq_trans (_ : #|`e| * 2 ^ l.+1 <= _); last first .1b4 #|` e| * 2 ^ l.+1 <= l * 2 ^ l.+1
by rewrite leq_mul2r eLl orbT.
rewrite -fsum_nat_const.1b4 \sum_(i <- e) 2 ^ minn (∇i) l.+1 <=
\sum_(i <- e) 2 ^ l.+1
apply : leq_sum => i iIe.2 ^ minn (∇i) l.+1 <= 2 ^ l.+1
apply : leq_pexp2l => //.1d9 minn (∇i) l.+1 <= l.+1
by apply geq_minr.
Qed .
Definition rnz (z : int) := `|Num.max 0 %R z|.
Lemma rnz_ler0 z : (z <= 0 )%R -> rnz z = 0 .
Proof .1e1
by move => zN; rewrite /rnz max_l. Qed .
Lemma rnz_ger0 z : (0 <= z)%R -> (z = (rnz z)%:R)%R.1e3 (0 <= z)%R -> z = ((rnz z)%:R)%R
Proof .1e8
by move => zP; rewrite /rnz max_r // natz gez0_abs. Qed .
Lemma ler_rnz z : (z <= rnz z)%R.
Proof .1ed
by rewrite /rnz; case : ler0P => //= zP; rewrite gtz0_abs. Qed .
Lemma rnz_ler z1 z2 : (z1 <= z2)%R -> rnz z1 <= rnz z2.(z1 <= z2)%R -> rnz z1 <= rnz z2
Proof .1f4
rewrite /rnz; case : ler0P => // z1_gt0 z1Lz2; case : ler0P => //= [|z2_gt0].1f7 z1_gt0 : (0 < z1)%R
z1Lz2 : (z1 <= z2)%R
(z2 <= 0 )%R -> `|z1| <= 0
by rewrite leNgt => /negP[]; apply : lt_le_trans z1Lz2.
by rewrite -lez_nat !gtz0_abs.
Qed .
Definition psi e := \max_(l < psi_auxb e) rnz (psi_aux l e).
Notation "'ψ' n" := (psi n) (format "'ψ' n" , at level 0 ).
Lemma psiE_leq e n :
psi_auxb e <= n -> psi e = \max_(l < n) rnz (psi_aux l e).ef 1e
ψ_b(e) <= n -> ψ(e) = \max_(l < n) rnz (ψ'(l) e)
Proof .20a
move => pLn.ψ(e) = \max_(l < n) rnz (ψ'(l) e)
rewrite /psi.212 \max_(l < ψ_b(e)) rnz (ψ'(l) e) =
\max_(l < n) rnz (ψ'(l) e)
rewrite (big_ord_widen_cond _ xpredT (fun i => rnz (psi_aux i e)) pLn).212 \max_(i < n | true && (i < ψ_b(e))) rnz (ψ'(i) e) =
\max_(l < n) rnz (ψ'(l) e)
rewrite [RHS](bigID (fun i : 'I_n => i < psi_auxb e)) /=.212 \max_(i < n | i < ψ_b(e)) rnz (ψ'(i) e) =
maxn (\max_(i < n | i < ψ_b(e)) rnz (ψ'(i) e))
(\max_(i < n | ~~ (i < ψ_b(e))) rnz (ψ'(i) e))
rewrite [X in _ = maxn _ X]big1 ?maxn0 // => i.~~ (i < ψ_b(e)) -> rnz (ψ'(i) e) = 0
rewrite -leqNgt => /psi_aux_psib.224 (ψ'(i) e <= 0 )%R -> rnz (ψ'(i) e) = 0
exact : rnz_ler0.
Qed .
Lemma psi_max e l : (psi_aux l e <= (psi e)%:R)%R.1af (ψ'(l) e <= ψ(e)%:R)%R
Proof .22c
pose n := maxn (psi_auxb e) l.+1 .ef f6 n := maxn ψ_b(e) l.+1 : nat
22e
have /psiE_leq-> : psi_auxb e <= n by apply : leq_maxl.233 (ψ'(l) e <= (\max_(l < n) rnz (ψ'(l) e))%:R)%R
have O : l < n by apply : leq_maxr.
have [/le_trans->//|/ltW/rnz_ger0->] := lerP (psi_aux l e) 0 .23c (0 <= (\max_(l < n) rnz (ψ'(l) e))%:R)%R
by rewrite (ler_nat _ 0 ).
rewrite ler_nat.23c rnz (ψ'(l) e) <= \max_(l < n) rnz (ψ'(l) e)
by rewrite (bigD1 (Ordinal O)) //= leq_maxl.
Qed .
Lemma psi_ler l e :
(((2 ^ l).-1 + \sum_(i <- e) 2 ^ (minn (troot i) l))%:R - (l * 2 ^ l)%:R
<= ((psi e)%:R : int))%R.128 (((2 ^ l).-1 + \sum_(i <- e) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R <= (ψ(e)%:R : int))%R
Proof .24d
have [/psi_aux_psib/le_trans->//|lLp] := leqP (psi_auxb e) l.
by rewrite (ler_nat _ 0 ).
rewrite [X in (_ <= X%:R)%R](bigD1 (Ordinal lLp)) //=.257 (((2 ^ l).-1 + \sum_(i <- e) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R <=
(maxn (rnz (ψ'(l) e))
(\max_(i < ψ_b(e) | i != Ordinal lLp)
rnz (ψ'(i) e)))%:R)%R
apply : le_trans (ler_rnz _) _.257 (rnz
(((2 ^ l).-1 + \sum_(i <- e) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R) <=
(maxn (rnz (ψ'(l) e))
(\max_(i < ψ_b(e) | i != Ordinal lLp)
rnz (ψ'(i) e)))%:R)%R
rewrite -natz ler_nat.257 rnz
(((2 ^ l).-1 + \sum_(i <- e) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R) <=
maxn (rnz (ψ'(l) e))
(\max_(i < ψ_b(e) | i != Ordinal lLp) rnz (ψ'(i) e))
apply : leq_maxl.
Qed .
Lemma psiE e : {l | ((psi e)%:R = psi_aux l e)%R}.ee {l : nat | (ψ(e)%:R)%R = ψ'(l) e}
Proof .26a
have [l] : {l : 'I_(psi_auxb e) | psi e = rnz (psi_aux l e)}.ee {l : 'I_ψ_b(e) | ψ(e) = rnz (ψ'(l) e)}
apply : eq_bigmax.ee 0 < #|ordinal_finType ψ_b(e)|
272
by rewrite card_ord.
rewrite /rnz; case : ler0P => [pG pE|pP ->]; last first .{l0 : nat | (`|ψ'(l) e|%:R)%R = ψ'(l0) e}
by exists l ; rewrite natz gtz0_abs.
by exists 0 ; apply /eqP; rewrite eq_le {1 }pE psi_aux_0_ge0 psi_max.
Qed .
Lemma psi_sub e1 e2 : e1 `<=` e2 -> psi e1 <= psi e2.f7
e1 `<=` e2 -> ψ(e1) <= ψ(e2)
Proof .28d
move => e1Se2.
rewrite (psiE_leq (leq_maxl (psi_auxb e1) (psi_auxb e2))).295 \max_(l < maxn ψ_b(e1) ψ_b(e2)) rnz (ψ'(l) e1) <=
ψ(e2)
rewrite (psiE_leq (leq_maxl (psi_auxb e2) (psi_auxb e1))).295 \max_(l < maxn ψ_b(e1) ψ_b(e2)) rnz (ψ'(l) e1) <=
\max_(l < maxn ψ_b(e2) ψ_b(e1)) rnz (ψ'(l) e2)
rewrite maxnC.295 \max_(l < maxn ψ_b(e2) ψ_b(e1)) rnz (ψ'(l) e1) <=
\max_(l < maxn ψ_b(e2) ψ_b(e1)) rnz (ψ'(l) e2)
elim /big_ind2: _ => // [x1 x2 y1 y2 x2Lx1 y2Ly1 | i _].f7 fe x1, x2, y1, y2 : nat
x2Lx1 : x2 <= x1
y2Ly1 : y2 <= y1
maxn x2 y2 <= maxn x1 y1
rewrite geq_max (leq_trans x2Lx1 (leq_maxl _ _)).2a6 true && (y2 <= maxn x1 y1)
2ab
by rewrite (leq_trans y2Ly1 (leq_maxr _ _)).
apply : rnz_ler.2ad (ψ'(i) e1 <= ψ'(i) e2)%R
by apply : psi_aux_sub.
Qed .
Lemma psi_aux_le_psi e1 e2 :
(forall l , (psi_aux l e1 <= psi_aux l e2)%R) -> psi e1 <= psi e2.28f (forall l : nat, (ψ'(l) e1 <= ψ'(l) e2)%R) ->
ψ(e1) <= ψ(e2)
Proof .2bc
move => H.f7 H : forall l : nat, (ψ'(l) e1 <= ψ'(l) e2)%R
296
pose e := maxn (psi_auxb e1) (psi_auxb e2).f7 2c4 e := maxn ψ_b(e1) ψ_b(e2) : nat
296
rewrite (psiE_leq (leq_maxl _ _ : _ <= e)).2c8 \max_(l < e) rnz (ψ'(l) e1) <= ψ(e2)
rewrite (psiE_leq (leq_maxr _ _ : _ <= e)).2c8 \max_(l < e) rnz (ψ'(l) e1) <=
\max_(l < e) rnz (ψ'(l) e2)
elim : e => [|e IH]; first by rewrite !big_ord0.f7 2c4 e : nat
IH : \max_(l < e) rnz (ψ'(l) e1) <=
\max_(l < e) rnz (ψ'(l) e2)
\max_(l < e.+1 ) rnz (ψ'(l) e1) <=
\max_(l < e.+1 ) rnz (ψ'(l) e2)
by rewrite !big_ord_recr /= geq_max !leq_max IH /= rnz_ler // orbT.
Qed .
Lemma psi_auxb_sint n : psi_auxb `[n] = n.+1 .
Proof .2da
congr (_.+1 ).2dc maxn #|` `[n]| (\max_(i <- `[n]) ∇i) = n
rewrite /psi_auxb.2e0
rewrite card_sint ?geq_minr // subn0.2dc maxn n (\max_(i <- `[n]) ∇i) = n
apply /eqP.2dc maxn n (\max_(i <- `[n]) ∇i) == n
rewrite eqn_leq leq_maxl andbT geq_max leqnn andTb.2dc \max_(i <- `[n]) ∇i <= n
apply /bigfmax_leqP => i; rewrite mem_sint /= => iLn _.
by apply : leq_trans (leq_rootnn _) (ltnW _).
Qed .
Lemma psi_aux_sintE n l :
psi_aux l `[n] =
(((2 ^ l).-1 + \sum_(0 <= i < n) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R)%R.ψ'(l) `[n] =
(((2 ^ l).-1 + \sum_(0 <= i < n) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R)%R
Proof .2f7
congr ((_ + _)%:R - _%:R)%R.2f9 \sum_(i <- `[n]) 2 ^ minn (∇i) l =
\sum_(0 <= i < n) 2 ^ minn (∇i) l
elim : n => [|n IH]; first by rewrite sint0_set0 /= big_nil.l, n : nat
IH : \sum_(i <- `[n]) 2 ^ minn (∇i) l =
\sum_(0 <= i < n) 2 ^ minn (∇i) l
\sum_(i <- `[n.+1 ]) 2 ^ minn (∇i) l =
\sum_(0 <= i < n.+1 ) 2 ^ minn (∇i) l
rewrite (big_fsetD1 n) /=; last by rewrite mem_sint andTb.304 (2 ^ minn (∇n) l +
\sum_(i <- `[n.+1 ] `\ n) 2 ^ minn (∇i) l)%N =
\sum_(0 <= i < n.+1 ) 2 ^ minn (∇i) l
by rewrite sintSr IH !big_mkord big_ord_recr /= addnC.
Qed .
Lemma psi_auxb_set0 : psi_auxb fset0 = 1 .
Proof .30d
by rewrite /psi_auxb cardfs0 max0n big_seq_cond big1. Qed .
Lemma psi_set0 : psi fset0 = 0 .
Proof .312
rewrite /psi psi_auxb_set0.\max_(l < 1 ) rnz (ψ'(l) fset0) = 0
rewrite !big_ord_recr /= big_ord0 /= max0n.
by rewrite /psi_aux /= big_seq_cond big1.
Qed .
Lemma psi_eq0 e : (psi e == 0 ) = (e == fset0).ee (ψ(e) == 0 ) = (e == fset0)
Proof .31f
have [->|[x]] := fset_0Vmem e; first by rewrite psi_set0 !eqxx.x \in e -> (ψ(e) == 0 ) = (e == fset0)
have [->|_] := e =P fset0; first by rewrite inE.326 x \in e -> (ψ(e) == 0 ) = false
move => xIe.
suff : psi e > 0 by case : psi.
rewrite -(ltr_nat int_numDomainType).
apply : lt_le_trans (psi_max _ 0 ).
by rewrite /psi_aux add0n subr0 ltr_nat (big_fsetD1 x).
Qed .
Lemma psi_sint0 : psi `[0 ] = 0 .
Proof .340
by rewrite sint0_set0 psi_set0. Qed .
Lemma psi_sint1 : psi `[1 ] = 1 .
Proof .345
rewrite /psi psi_auxb_sint.\max_(l < 2 ) rnz (ψ'(l) `[1 ]) = 1
rewrite -(big_mkord xpredT (fun l => rnz (psi_aux l _))).\max_(0 <= i < 2 ) rnz (ψ'(i) `[1 ]) = 1
pose f l :=
rnz (((2 ^ l).-1 + \sum_(0 <= i < 1 ) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R).f := fun l : nat =>
rnz
(((2 ^ l).-1 + \sum_(0 <= i < 1 ) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R): nat -> nat
350
rewrite (eq_bigr f) => [|i _]; last by rewrite psi_aux_sintE.354 \max_(0 <= i < 2 ) f i = 1
by rewrite /f /= unlock .
Qed .
Lemma psi_sint2 : psi `[2 ] = 2 .
Proof .35b
rewrite /psi psi_auxb_sint.\max_(l < 3 ) rnz (ψ'(l) `[2 ]) = 2
rewrite -(big_mkord xpredT (fun l => rnz (psi_aux l _))).\max_(0 <= i < 3 ) rnz (ψ'(i) `[2 ]) = 2
pose f l :=
rnz (((2 ^ l).-1 + \sum_(0 <= i < 2 ) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R).f := fun l : nat =>
rnz
(((2 ^ l).-1 + \sum_(0 <= i < 2 ) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R): nat -> nat
366
rewrite (eq_bigr f) => [|i _]; last by rewrite psi_aux_sintE.36a \max_(0 <= i < 3 ) f i = 2
by rewrite /f /= unlock .
Qed .
Lemma psi_sint3 : psi `[3 ] = 4 .
Proof .371
rewrite /psi psi_auxb_sint.\max_(l < 4 ) rnz (ψ'(l) `[3 ]) = 4
rewrite -(big_mkord xpredT (fun l => rnz (psi_aux l _))).\max_(0 <= i < 4 ) rnz (ψ'(i) `[3 ]) = 4
pose f l :=
rnz (((2 ^ l).-1 + \sum_(0 <= i < 3 ) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R).f := fun l : nat =>
rnz
(((2 ^ l).-1 + \sum_(0 <= i < 3 ) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R): nat -> nat
37c
rewrite (eq_bigr f) => [|i _]; last by rewrite psi_aux_sintE.380 \max_(0 <= i < 4 ) f i = 4
by rewrite /f /= unlock .
Qed .
Lemma psi_aux_incr n l :
l < (troot n).-1 -> (psi_aux l `[n] <= psi_aux l.+1 `[n])%R.2f9 l < (∇n).-1 -> (ψ'(l) `[n] <= ψ'(l.+1 ) `[n])%R
Proof .387
move => lLr.(ψ'(l) `[n] <= ψ'(l.+1 ) `[n])%R
have dlLn : delta l.+2 <= n.
rewrite -root_delta_le -subn_gt0.
by rewrite -[l.+1 ]addn1 addnC subnDA subn_gt0 subn1.
rewrite psi_auxE_lt psi_auxE_le.397 (((2 ^ l * #|` [fset i | i in `[n] & (l < ∇i)%N]|.+1 ).-1 +
\sum_(i <- `[n] | (∇i <= l)%N) 2 ^ ∇i)%:R -
(l * 2 ^ l)%:R <=
((2 ^ l.+1 *
#|` [fset i | i in `[n] & (l < ∇i)%N]|.+1 ).-1 +
\sum_(i <- `[n] | (∇i < l.+1 )%N) 2 ^ ∇i)%:R -
(l.+1 * 2 ^ l.+1 )%:R)%R
set s := \sum_(_ <- _ | _) _.2fa 38f 398 s := \sum_(H <- `[n] | ∇H <= l) 2 ^ ∇H : nat
(((2 ^ l * #|` [fset i | i in `[n] & (l < ∇i)%N]|.+1 ).-1 +
s)%:R - (l * 2 ^ l)%:R <=
((2 ^ l.+1 *
#|` [fset i | i in `[n] & (l < ∇i)%N]|.+1 ).-1 + s)%:R -
(l.+1 * 2 ^ l.+1 )%:R)%R
have -> : [fset i in `[n] | l < troot i] = [fset i in `[n] | delta l.+1 <= i].3a7 [fset i | i in `[n] & l < ∇i] =
[fset i | i in `[n] & Δl.+1 <= i]
by apply /fsetP => i; rewrite !inE root_delta_le.
have /(sint_sub n)-> : 0 <= delta l.+1 by apply : delta_le (_ : 0 <= l.+1 ).3a7 (((2 ^ l * #|` sint (Δl.+1 ) n|.+1 ).-1 + s)%:R -
(l * 2 ^ l)%:R <=
((2 ^ l.+1 * #|` sint (Δl.+1 ) n|.+1 ).-1 + s)%:R -
(l.+1 * 2 ^ l.+1 )%:R)%R
rewrite card_sint //.3a7 (((2 ^ l * (n - Δl.+1 ).+1 ).-1 + s)%:R - (l * 2 ^ l)%:R <=
((2 ^ l.+1 * (n - Δl.+1 ).+1 ).-1 + s)%:R -
(l.+1 * 2 ^ l.+1 )%:R)%R
set c := n - _.2fa 38f 398 3a8 c := n - Δl.+1 : nat
(((2 ^ l * c.+1 ).-1 + s)%:R - (l * 2 ^ l)%:R <=
((2 ^ l.+1 * c.+1 ).-1 + s)%:R - (l.+1 * 2 ^ l.+1 )%:R)%R
rewrite expnS mulnAC [2 * _ * _]mulnC.3bf (((2 ^ l * c.+1 ).-1 + s)%:R - (l * 2 ^ l)%:R <=
((2 ^ l * (2 * c.+1 )).-1 + s)%:R -
(l.+1 * (2 * 2 ^ l))%:R)%R
rewrite mul2n mulnA muln2 -!addnn -[(_ + l.+1 )%nat]addSnnS.3bf (((2 ^ l * c.+1 ).-1 + s)%:R - (l * 2 ^ l)%:R <=
((2 ^ l * (c.+1 + c.+1 )).-1 + s)%:R -
((l.+2 + l) * 2 ^ l)%:R)%R
rewrite mulnDl mulnDr prednDr ?(muln_gt0, expn_gt0) //.3bf (((2 ^ l * c.+1 ).-1 + s)%:R - (l * 2 ^ l)%:R <=
(2 ^ l * c.+1 + (2 ^ l * c.+1 ).-1 + s)%:R -
(l.+2 * 2 ^ l + l * 2 ^ l)%:R)%R
set x := 2 ^ _ * _.2fa 38f 398 3a8 3c0 x := 2 ^ l * c.+1 : nat
((x.-1 + s)%:R - (l * 2 ^ l)%:R <=
(x + x.-1 + s)%:R - (l.+2 * 2 ^ l + l * 2 ^ l)%:R)%R
rewrite -[(_ + _ + s)%nat]addnA [(x + _)%nat]addnC.3d1 ((x.-1 + s)%:R - (l * 2 ^ l)%:R <=
(x.-1 + s + x)%:R - (l.+2 * 2 ^ l + l * 2 ^ l)%:R)%R
rewrite [((_ + _ * _)%:R)%R]natrD opprD addrA ler_sub //.3d1 ((x.-1 + s)%:R <=
(x.-1 + s + x)%:R - (l.+2 * 2 ^ l)%:R)%R
rewrite ler_subr_addr [((_ + x)%:R)%R]natrD ler_add //.3d1 ((l.+2 * 2 ^ l)%:R <= x%:R)%R
rewrite ler_nat.
rewrite mulnC leq_mul2l.3d1 (2 ^ l == 0 ) || (l.+1 < c.+1 )
rewrite -subSn; last first .
apply : leq_trans (_ : delta l.+2 <= _); first by by apply : delta_le.
by apply : leq_trans dlLn _.
by rewrite ltn_subRL -addnS -deltaS (leq_trans dlLn) ?orbT .
Qed .
Lemma psi_aux_decr n l :
(troot n).-1 <= l -> (psi_aux l.+1 `[n] <= psi_aux l `[n])%R.2f9 (∇n).-1 <= l -> (ψ'(l.+1 ) `[n] <= ψ'(l) `[n])%R
Proof .3f6
move => rLl.(ψ'(l.+1 ) `[n] <= ψ'(l) `[n])%R
have dlLn : n < delta l.+2 .
rewrite ltnNge -root_delta_le -subn_gt0.
by rewrite -[l.+1 ]addn1 addnC subnDA subn_gt0 subn1 -ltnNge.
rewrite psi_auxE_le.406 (((2 ^ l.+1 *
#|` [fset i | i in `[n] & (l < ∇i)%N]|.+1 ).-1 +
\sum_(i <- `[n] | (∇i < l.+1 )%N) 2 ^ ∇i)%:R -
(l.+1 * 2 ^ l.+1 )%:R <= ψ'(l) `[n])%R
rewrite psi_auxE_lt.406 (((2 ^ l.+1 *
#|` [fset i | i in `[n] & (l < ∇i)%N]|.+1 ).-1 +
\sum_(i <- `[n] | (∇i < l.+1 )%N) 2 ^ ∇i)%:R -
(l.+1 * 2 ^ l.+1 )%:R <=
((2 ^ l * #|` [fset i | i in `[n] & (l < ∇i)%N]|.+1 ).-1 +
\sum_(i <- `[n] | (∇i <= l)%N) 2 ^ ∇i)%:R -
(l * 2 ^ l)%:R)%R
set s := \sum_(_ <- _ | _) _.2fa 3fe 407 s := \sum_(H <- `[n] | ∇H < l.+1 ) 2 ^ ∇H : nat
(((2 ^ l.+1 *
#|` [fset i | i in `[n] & (l < ∇i)%N]|.+1 ).-1 + s)%:R -
(l.+1 * 2 ^ l.+1 )%:R <=
((2 ^ l * #|` [fset i | i in `[n] & (l < ∇i)%N]|.+1 ).-1 +
s)%:R - (l * 2 ^ l)%:R)%R
have -> : [fset i in `[n] | l < troot i] =
[fset i in `[n] | delta l.+1 <= i].
by apply /fsetP => i; rewrite !inE root_delta_le.
have /(sint_sub n)-> : 0 <= delta l.+1 by apply : delta_le (_ : 0 <= l.+1 ).41a (((2 ^ l.+1 * #|` sint (Δl.+1 ) n|.+1 ).-1 + s)%:R -
(l.+1 * 2 ^ l.+1 )%:R <=
((2 ^ l * #|` sint (Δl.+1 ) n|.+1 ).-1 + s)%:R -
(l * 2 ^ l)%:R)%R
rewrite card_sint //.41a (((2 ^ l.+1 * (n - Δl.+1 ).+1 ).-1 + s)%:R -
(l.+1 * 2 ^ l.+1 )%:R <=
((2 ^ l * (n - Δl.+1 ).+1 ).-1 + s)%:R - (l * 2 ^ l)%:R)%R
set c := n - _.2fa 3fe 407 41b 3c0
(((2 ^ l.+1 * c.+1 ).-1 + s)%:R - (l.+1 * 2 ^ l.+1 )%:R <=
((2 ^ l * c.+1 ).-1 + s)%:R - (l * 2 ^ l)%:R)%R
rewrite expnS mulnAC [2 * _ * _]mulnC.431 (((2 ^ l * (2 * c.+1 )).-1 + s)%:R -
(l.+1 * (2 * 2 ^ l))%:R <=
((2 ^ l * c.+1 ).-1 + s)%:R - (l * 2 ^ l)%:R)%R
rewrite mul2n mulnA muln2 -!addnn -[(_ + l.+1 )%nat]addSnnS.431 (((2 ^ l * (c.+1 + c.+1 )).-1 + s)%:R -
((l.+2 + l) * 2 ^ l)%:R <=
((2 ^ l * c.+1 ).-1 + s)%:R - (l * 2 ^ l)%:R)%R
rewrite mulnDl mulnDr prednDr ?(muln_gt0, expn_gt0) //.431 ((2 ^ l * c.+1 + (2 ^ l * c.+1 ).-1 + s)%:R -
(l.+2 * 2 ^ l + l * 2 ^ l)%:R <=
((2 ^ l * c.+1 ).-1 + s)%:R - (l * 2 ^ l)%:R)%R
set x := 2 ^ _ * _.2fa 3fe 407 41b 3c0 3d2
((x + x.-1 + s)%:R - (l.+2 * 2 ^ l + l * 2 ^ l)%:R <=
(x.-1 + s)%:R - (l * 2 ^ l)%:R)%R
rewrite -[(_ + s)%nat]addnA [(x + _)%nat]addnC.442 ((x.-1 + s + x)%:R - (l.+2 * 2 ^ l + l * 2 ^ l)%:R <=
(x.-1 + s)%:R - (l * 2 ^ l)%:R)%R
rewrite [((_ + _ * _)%:R)%R]natrD opprD addrA ler_sub //.442 ((x.-1 + s + x)%:R - (l.+2 * 2 ^ l)%:R <=
(x.-1 + s)%:R)%R
rewrite ler_subl_addr [((_ + x)%:R)%R]natrD ler_add //.442 (x%:R <= (l.+2 * 2 ^ l)%:R)%R
rewrite ler_nat.
rewrite mulnC leq_mul2l.442 (2 ^ l == 0 ) || (c < l.+2 )
rewrite -[l.+2 ](addnK (delta l.+1 )) addnC -deltaS.442 (2 ^ l == 0 ) || (c < Δl.+2 - Δl.+1 )
rewrite ltn_sub2r ?orbT // [X in _ < X]deltaS //.
by rewrite addnS ltnS leq_addr.
Qed .
Lemma psi_aux_sint n : ((psi `[n])%:R)%R = psi_aux (troot n).-1 `[n].2dc (ψ(`[n])%:R)%R = ψ'((∇n).-1 ) `[n]
Proof .461
apply /eqP.2dc (ψ(`[n])%:R)%R == ψ'((∇n).-1 ) `[n]
rewrite eq_le psi_max andbT.2dc (ψ(`[n])%:R <= ψ'((∇n).-1 ) `[n])%R
case : (psiE `[n]) => l ->.2f9 (ψ'(l) `[n] <= ψ'((∇n).-1 ) `[n])%R
have [E|E] := leqP (troot n).-1 l.
rewrite -(subnK E).474 (ψ'(l - (∇n).-1 + (∇n).-1 ) `[n] <= ψ'((∇n).-1 ) `[n])%R
476
elim : (_ - _) => [|k IH] //.2fa 475 k : nat
IH : (ψ'(k + (∇n).-1 ) `[n] <= ψ'((∇n).-1 ) `[n])%R
(ψ'(k.+1 + (∇n).-1 ) `[n] <= ψ'((∇n).-1 ) `[n])%R
476
apply : le_trans IH.2fa 475 482
(ψ'(k.+1 + (∇n).-1 ) `[n] <= ψ'(k + (∇n).-1 ) `[n])%R
476
rewrite addSn.488 (ψ'((k + (∇n).-1 ).+1 ) `[n] <= ψ'(k + (∇n).-1 ) `[n])%R
476
apply : psi_aux_decr => //.488 (∇n).-1 <= k + (∇n).-1
476
by rewrite leq_addl.
rewrite -(subKn (ltnW E)).478 (ψ'((∇n).-1 - ((∇n).-1 - l)) `[n] <= ψ'((∇n).-1 ) `[n])%R
elim : (_ - l) => [|k IH].478 (ψ'((∇n).-1 - 0 ) `[n] <= ψ'((∇n).-1 ) `[n])%R
by rewrite subn0.
apply : le_trans IH.2fa 479 482
(ψ'((∇n).-1 - k.+1 ) `[n] <= ψ'((∇n).-1 - k) `[n])%R
rewrite subnS.4a8 (ψ'(((∇n).-1 - k).-1 ) `[n] <= ψ'((∇n).-1 - k) `[n])%R
have [|E1] := leqP (troot n).-1 k.4a8 (∇n).-1 <= k ->
(ψ'(((∇n).-1 - k).-1 ) `[n] <= ψ'((∇n).-1 - k) `[n])%R
by rewrite -subn_eq0 => /eqP->.
rewrite -{2 }[_-_]prednK ?subn_gt0 //.4b4 (ψ'(((∇n).-1 - k).-1 ) `[n] <=
ψ'(((∇n).-1 - k).-1 .+1 ) `[n])%R
apply : psi_aux_incr => //.4b4 ((∇n).-1 - k).-1 < (∇n).-1
case : _.-1 E1 => // u _; case : k => // k.
apply : leq_trans (_ : u.+1 .-1 < u.+1 ) => //.4c4 (u.+1 - k.+1 ).-1 < u.+1 .-1 .+1
by rewrite ltnS -!subn1 leq_sub2r // leq_subr.
Qed .
(* This is 2.2 *)
Lemma psi_sint_phi n : (psi `[n]).*2 = (phi n.+1 ).-1 .2dc ψ(`[n]).*2 = ϕ(n.+1 ).-1
Proof .4cc
have [|nP] := leqP n 0 ; first by case : (n)=> //; rewrite psi_sint0.
apply /eqP; rewrite -(eqr_nat int_numDomainType).4d3 (ψ(`[n]).*2 %:R)%R == (ϕ(n.+1 ).-1 %:R)%R
rewrite -muln2 natrM mulr_natr.4d3 (ψ(`[n])%:R *+ 2 )%R == (ϕ(n.+1 ).-1 %:R)%R
rewrite psi_aux_sint // psi_auxE_lt.4d3 ((((2 ^ (∇n).-1 *
#|` [fset i | i in `[n] & ((∇n).-1 < ∇i)%N]|.+1 ).-1 +
\sum_(i <- `[n] | (∇i <= (∇n).-1 )%N) 2 ^ ∇i)%:R -
((∇n).-1 * 2 ^ (∇n).-1 )%:R) *+ 2 )%R ==
(ϕ(n.+1 ).-1 %:R)%R
rewrite (_ : [fset _ in _ | _] = [fset i in `[n] | delta (troot n) <= i]);
last first .4d3 [fset H
| H in mem_fin (fset_finpred `[n])
& (∇n).-1 < ∇H] = [fset i | i in `[n] & Δ(∇n) <= i]
apply /fsetP=> i; rewrite !inE; congr (_ && _).1e 4d4 11f
((∇n).-1 < ∇i) = (Δ(∇n) <= i)
4e5
by rewrite prednK ?troot_gt0 // root_delta_le.
rewrite sint_sub ?delta_gt0 ?troot_gt0 // card_sint //.4d3 ((((2 ^ (∇n).-1 * (n - Δ(∇n)).+1 ).-1 +
\sum_(i <- `[n] | (∇i <= (∇n).-1 )%N) 2 ^ ∇i)%:R -
((∇n).-1 * 2 ^ (∇n).-1 )%:R) *+ 2 )%R ==
(ϕ(n.+1 ).-1 %:R)%R
rewrite (_ : \sum_(i <- _ | _) _ = phi (delta (troot n))); last first .4d3 \sum_(i <- `[n] | ∇i <= (∇n).-1 ) 2 ^ ∇i = ϕ(Δ(∇n))
rewrite phiE.4d3 \sum_(i <- `[n] | ∇i <= (∇n).-1 ) 2 ^ ∇i =
\sum_(i < Δ(∇n)) 2 ^ ∇i
4f8
rewrite [RHS](eq_bigl
(fun i : 'I_ _ => (i : nat) \in (enum_fset `[n]))); last first .4d3 xpredT =1 (fun i : 'I_(Δ(∇n)) => i \in `[n])
move => i.
by rewrite mem_sint leq0n (leq_trans (ltn_ord _)) // delta_root_le.
elim : enum_fset (fset_uniq `[n]) => /= [_|a l IH /andP[aNIl lU]].4d3 \sum_(i <- [::] | ∇i <= (∇n).-1 ) 2 ^ ∇i =
\sum_(i < Δ(∇n) | i \in [::]) 2 ^ ∇i
by rewrite big_nil big1.
rewrite big_cons /= IH //; case : leqP => aLb; last first .1e 4d4 a 516 517 518 519 aLb : (∇n).-1 < ∇a
\sum_(i < Δ(∇n) | i \in l) 2 ^ ∇i =
\sum_(i < Δ(∇n) | i \in a :: l) 2 ^ ∇i
rewrite prednK ?troot_gt0 // in aLb.1e 4d4 a 516 517 518 519 aLb : ∇n <= ∇a
523 524
apply : eq_bigl => i; rewrite inE eqn_leq [a <= i]leqNgt.1e 4d4 a 516 517 518 519 52d 50a
(i \in l) = (i <= a) && ~~ (i < a) || (i \in l)
524
by rewrite (leq_trans (ltn_ord i)) ?andbF // -root_delta_le.
have aLn : a < Δ(∇n).
by rewrite -root_delta_lt -[troot n]prednK // troot_gt0.
rewrite [RHS](bigD1 (Ordinal aLn)) ?(inE, eqxx) //=.53c (2 ^ ∇a + \sum_(i < Δ(∇n) | i \in l) 2 ^ ∇i)%N =
(2 ^ ∇a +
\sum_(i < Δ(∇n) | (i \in a :: l) &&
(i != Ordinal aLn)) 2 ^ ∇i)%N
4f8
congr ((_ + _)%nat).53c \sum_(i < Δ(∇n) | i \in l) 2 ^ ∇i =
\sum_(i < Δ(∇n) | (i \in a :: l) && (i != Ordinal aLn))
2 ^ ∇i
4f8
apply : eq_bigl => i; rewrite inE -val_eqE /=.1e 4d4 a 516 517 518 519 527 53d 50a
(i \in l) = ((i == a) || (i \in l)) && (i != a)
4f8
by case : (_ =P _); rewrite ?andbT // => ->; rewrite (negPf aNIl).
set m := troot n.((((2 ^ m.-1 * (n - Δm).+1 ).-1 + ϕ(Δm))%:R -
(m.-1 * 2 ^ m.-1 )%:R) *+ 2 )%R == (ϕ(n.+1 ).-1 %:R)%R
rewrite -[n - _]/(tmod n).554 ((((2 ^ m.-1 * (tmod n).+1 ).-1 + ϕ(Δm))%:R -
(m.-1 * 2 ^ m.-1 )%:R) *+ 2 )%R == (ϕ(n.+1 ).-1 %:R)%R
set p := tmod n.((((2 ^ m.-1 * p.+1 ).-1 + ϕ(Δm))%:R -
(m.-1 * 2 ^ m.-1 )%:R) *+ 2 )%R == (ϕ(n.+1 ).-1 %:R)%R
rewrite phi_deltaE.55e ((((2 ^ m.-1 * p.+1 ).-1 + (1 + m * 2 ^ m - 2 ^ m))%:R -
(m.-1 * 2 ^ m.-1 )%:R) *+ 2 )%R == (ϕ(n.+1 ).-1 %:R)%R
(* taking care of m * 2 ^ m - 2 ^ m *)
rewrite -{2 }[m]prednK ?troot_gt0 //.55e ((((2 ^ m.-1 * p.+1 ).-1 +
(1 + m.-1 .+1 * 2 ^ m - 2 ^ m))%:R -
(m.-1 * 2 ^ m.-1 )%:R) *+ 2 )%R == (ϕ(n.+1 ).-1 %:R)%R
rewrite mulSn addnCA [(2 ^ _ + _)%nat]addnC addnK add1n.55e ((((2 ^ m.-1 * p.+1 ).-1 + (m.-1 * 2 ^ m).+1 )%:R -
(m.-1 * 2 ^ m.-1 )%:R) *+ 2 )%R == (ϕ(n.+1 ).-1 %:R)%R
rewrite addnS -addSn prednK; last first .
by rewrite muln_gt0 expn_gt0.
(* taking care of m.-1 * 2 ^ m - m.-1 * 2 ^ m.-1 *)
rewrite -{3 }[m]prednK ?troot_gt0 //.55e (((2 ^ m.-1 * p.+1 + m.-1 * 2 ^ m.-1 .+1 )%:R -
(m.-1 * 2 ^ m.-1 )%:R) *+ 2 )%R == (ϕ(n.+1 ).-1 %:R)%R
rewrite expnS mul2n -addnn mulnDr addnA natrD addrK.55e ((2 ^ m.-1 * p.+1 + m.-1 * 2 ^ m.-1 )%:R *+ 2 )%R ==
(ϕ(n.+1 ).-1 %:R)%R
rewrite mulnC -mulnDl addSnnS prednK ?troot_gt0 //.55e (((p + m) * 2 ^ m.-1 )%:R *+ 2 )%R == (ϕ(n.+1 ).-1 %:R)%R
rewrite -mulr_natr -natrM muln2 eqr_nat.55e ((p + m) * 2 ^ m.-1 ).*2 == ϕ(n.+1 ).-1
rewrite phi_modSE -/m -/p.55e ((p + m) * 2 ^ m.-1 ).*2 == (1 + (m + p) * 2 ^ m).-1
rewrite add1n -pred_Sn addnC -{4 }[m]prednK ?troot_gt0 //.55e ((m + p) * 2 ^ m.-1 ).*2 == (m + p) * 2 ^ m.-1 .+1
by rewrite expnS mulnCA mul2n.
Qed .
Lemma psi_sint_leq a b : a <= b -> psi `[a] <= psi `[b].a <= b -> ψ(`[a]) <= ψ(`[b])
Proof .590
move => aLb; apply : psi_sub; apply /fsubsetP=> i.
by rewrite !mem_sint /= => iLa; apply : leq_trans aLb.
Qed .
Lemma psi_sintS n : (psi `[n.+1 ] = psi `[n] + 2 ^ (troot n.+1 ).-1 )%nat.2dc ψ(`[n.+1 ]) = (ψ(`[n]) + 2 ^ (∇n.+1 ).-1 )%N
Proof .59d
have F : 0 < phi n.+1 by apply : phi_le (_ : 1 <= _).
apply : double_inj; rewrite doubleD.5a4 ψ(`[n.+1 ]).*2 = (ψ(`[n]).*2 + (2 ^ (∇n.+1 ).-1 ).*2 )%N
rewrite !psi_sint_phi //.5a4 ϕ(n.+2 ).-1 = (ϕ(n.+1 ).-1 + (2 ^ (∇n.+1 ).-1 ).*2 )%N
rewrite -mul2n -expnS prednK ?troot_gt0 //.5a4 ϕ(n.+2 ).-1 = (ϕ(n.+1 ).-1 + 2 ^ ∇n.+1 )%N
by rewrite phiE big_ord_recr -phiE prednDl.
Qed .
(* This is 2.2 *)
Lemma psi_leD a b : psi `[a + b] <= (psi `[a]).*2 + 2 ^ (b.-1 ).592 ψ(`[a + b]) <= ψ(`[a]).*2 + 2 ^ b.-1
Proof .5b3
case : b => [|b]; first by rewrite addn0 -addnn -addnA leq_addr.592 ψ(`[a + b.+1 ]) <= ψ(`[a]).*2 + 2 ^ b.+1 .-1
rewrite -leq_double doubleD [_.+1 .-1 ]/=.592 ψ(`[a + b.+1 ]).*2 <= (ψ(`[a]).*2 ).*2 + (2 ^ b).*2
rewrite !psi_sint_phi -addSn -ltnS prednK ?phi_gt0 //.592 ϕ(a.+1 + b.+1 ) <= ((ϕ(a.+1 ).-1 ).*2 + (2 ^ b).*2 ).+1
apply : leq_trans (phi_leD _ _) _.592 ϕ(a.+1 ).*2 + (2 ^ b.+1 ).-1 <=
((ϕ(a.+1 ).-1 ).*2 + (2 ^ b).*2 ).+1
rewrite -{1 }[phi (a.+1 )]prednK ?phi_gt0 // doubleS.592 (ϕ(a.+1 ).-1 ).*2 .+2 + (2 ^ b.+1 ).-1 <=
((ϕ(a.+1 ).-1 ).*2 + (2 ^ b).*2 ).+1
by rewrite expnS mul2n -prednDr ?double_gt0 ?expn_gt0 .
Qed .
(* This is 2.3 *)
Lemma psi_SS_le n : psi `[n.+2 ] >= 2 ^(troot n).+1 .2dc 2 ^ (∇n).+1 <= ψ(`[n.+2 ])
Proof .5cc
case : n => [|n]; first by rewrite psi_sint2.2dc 2 ^ (∇n.+1 ).+1 <= ψ(`[n.+3 ])
have /psi_sint_leq/(leq_trans _)->// : (delta (troot n.+1 )).+2 <= n.+3 .
by rewrite !ltnS -root_delta_le.
set s := troot _.2 ^ s.+1 <= ψ(`[(Δs).+2 ])
have [|tLs] := leqP s 1 .5e1 s <= 1 -> 2 ^ s.+1 <= ψ(`[(Δs).+2 ])
case : s => [|[|]] //; first by rewrite psi_sint2 ?(leq_trans _ thLN).2dc 0 < 1 -> 2 ^ 2 <= ψ(`[(Δ1).+2 ])
5e8
by rewrite psi_sint3.
rewrite -leq_double psi_sint_phi phi_modSE.5ea (2 ^ s.+1 ).*2 <=
(1 + (∇(Δs).+2 + tmod (Δs).+2 ) * 2 ^ ∇(Δs).+2 ).-1
have tE : troot (delta s).+2 = s.
by apply /eqP; rewrite trootE deltaS ltnW //= -addn2 addSnnS leq_add2l.
rewrite tE.5fd (2 ^ s.+1 ).*2 <= (1 + (s + tmod (Δs).+2 ) * 2 ^ s).-1
have ->: tmod (delta s).+2 = 2 by rewrite /tmod tE -addn2 addnC addnK.5fd (2 ^ s.+1 ).*2 <= (1 + (s + 2 ) * 2 ^ s).-1
by rewrite -mul2n expnS mulnA /= leq_mul2r (leq_add2r 2 2 ) tLs orbT.
Qed .
Lemma psi_aux0_sint n : psi_aux 0 `[n] = n.
Proof .60b
rewrite /psi_aux add0n subr0.2dc ((\sum_(i <- `[n]) 2 ^ minn (∇i) 0 )%:R)%R = n
apply /eqP; rewrite -natz eqr_nat; apply /eqP.2dc \sum_(i <- `[n]) 2 ^ minn (∇i) 0 = n
rewrite (eq_bigr (fun => 1 )) => [|i _].2dc \sum_(i <- `[n]) 1 = n
by rewrite fsum_nat_const card_sint // subn0 muln1.
by rewrite minn0.
Qed .
(* This is 2.4.1 *)
Lemma psi_sint_min n : n <= psi `[n].
Proof .623
rewrite -(ler_nat int_numDomainType).2dc (n%:R <= ψ(`[n])%:R)%R
rewrite natz -[X in (X <= _)%R]psi_aux0_sint.2dc (ψ'(0 ) `[n] <= ψ(`[n])%:R)%R
by apply : psi_max.
Qed .
Lemma sum_sint (F : nat -> nat) n :
\sum_(i <- `[n]) F i = \sum_(i < n) F i.\sum_(i <- `[n]) F i = \sum_(i < n) F i
Proof .630
rewrite big_seq_cond.632 \sum_(i <- `[n] | (i \in `[n]) && true) F i =
\sum_(i < n) F i
rewrite [LHS](eq_bigl (fun i => (i < n))); last first .632 (fun i : nat => (i \in `[n]) && true) =1
(fun i : nat => i < n)
by move => i; rewrite mem_sint andbT.
rewrite [RHS](eq_bigl
(fun i : 'I_ _ => ((i : nat) \in (enum_fset `[n])))); last first .632 xpredT =1 (fun i : 'I_n => i \in `[n])
by move => i; rewrite mem_sint ltn_ord.
elim : enum_fset (fset_uniq `[n]) => /= [_|a l IH /andP[aNIl lU]].632 \sum_(i <- [::] | i < n) F i =
\sum_(i < n | i \in [::]) F i
by rewrite big_nil big1.
rewrite big_cons /= IH //; case : (boolP (a < n)) => aLn; last first .633 655 516 656 518 519 aLn : ~~ (a < n)
\sum_(i < n | i \in l) F i =
\sum_(i < n | i \in a :: l) F i
apply : eq_bigl => i; move : (ltn_ord i); rewrite inE; case : eqP => [->| //].633 655 516 656 518 519 65f 225
a < n -> (a \in l) = true || (a \in l)
661
by rewrite (negPf aLn).
rewrite [RHS](bigD1 (Ordinal aLn)) ?(inE, eqxx) //=.663 (F a + \sum_(i < n | i \in l) F i)%N =
(F a +
\sum_(i < n | (i \in a :: l) && (i != Ordinal aLn))
F i)%N
congr ((_ + _)%nat).663 \sum_(i < n | i \in l) F i =
\sum_(i < n | (i \in a :: l) && (i != Ordinal aLn))
F i
apply : eq_bigl => i; rewrite inE -val_eqE /=.633 655 516 656 518 519 664 225
54d
by case : (_ =P _); rewrite ?andbT // => ->; rewrite (negPf aNIl).
Qed .
Lemma max_set_nat (e : {fset nat}) : #|`e|.-1 <= \max_(i <- e) i.ee #|` e|.-1 <= \max_(i <- e) i
Proof .67b
have [n cI] := ubnP #|`e|; elim : n => // [] [|n] IH e cI in e cI *.IH : forall e ,
#|` e| < 0 -> #|` e|.-1 <= \max_(i <- e) i
ef cI : #|` e| < 1
67d
by move : cI; rewrite ltnS leqn0 => /eqP->.
move : cI; rewrite leq_eqVlt => /orP[/eqP eC|]; last first .1e 688 ef
#|` e|.+1 < n.+2 -> #|` e|.-1 <= \max_(i <- e) i
by apply : IH.
have /(eq_fbigmax id)[/= i [iIe iM]] : 0 < #|`e| by rewrite -ltnS eC.1e 688 ef 695 150 a9 iM : \max_(i <- e) i = i
67d
have eE : #|` e| = #|` e `\ i|.+1 by rewrite (cardfsD1 i) iIe.1e 688 ef 695 150 a9 69d eE : #|` e| = #|` e `\ i|.+1
67d
have /IH H : #|`e `\ i| < n.+1 by rewrite -eE -ltnS eC.1e 688 ef 695 150 a9 69d 6a2 H : #|` e `\ i|.-1 <= \max_(i <- e `\ i) i
67d
rewrite eE /=.6a6 #|` e `\ i| <= \max_(i <- e) i
case eIE : (#|` e `\ i|) => [//|k].1e 688 ef 695 150 a9 69d 6a2 6a7 482 eIE : #|` e `\ i| = k.+1
k < \max_(i <- e) i
have /(eq_fbigmax id)[j []] : 0 < #|` e `\ i| by rewrite eIE.1e 688 ef 695 150 a9 69d 6a2 6a7 482 6b0 j : nat_choiceType
j \in e `\ i ->
\max_(i <- e `\ i) i = j -> k < \max_(i <- e) i
rewrite !inE => /andP[jDi jIe] jM.1e 688 ef 695 150 a9 69d 6a2 6a7 482 6b0 6b6 jDi : j != i
jIe : j \in e
jM : \max_(i <- e `\ i) i = j
6b1
move : H; rewrite eIE => H.1e 688 ef 695 150 a9 69d 6a2 482 6b0 6b6 6bc 6bd 6be H : k.+1 .-1 <= \max_(i <- e `\ i) i
6b1
apply : leq_ltn_trans H _; rewrite iM jM.1e 688 ef 695 150 a9 69d 6a2 482 6b0 6b6 6bc 6bd 6be
j < i
have : j <= i by rewrite -iM; apply : leq_bigfmax.
by rewrite leq_eqVlt (negPf jDi).
Qed .
Lemma psi_aux_card_le l e : (psi_aux l `[#|`e|] <= psi_aux l e)%R.128 (ψ'(l) `[#|` e|] <= ψ'(l) e)%R
Proof .6ce
rewrite ler_sub // ler_nat leq_add2l.128 \sum_(i <- `[#|` e|]) 2 ^ minn (∇i) l <=
\sum_(i <- e) 2 ^ minn (∇i) l
rewrite (sum_sint (fun i => 2 ^ minn (∇i) l)) //.128 \sum_(i < #|` e|) 2 ^ minn (∇i) l <=
\sum_(i <- e) 2 ^ minn (∇i) l
have [n cI] := ubnP #|`e|; elim : n => // [] [|n] IH e cI in e cI *.f6 IH : forall e ,
#|` e| < 0 ->
\sum_(i < #|` e|) 2 ^ minn (∇i) l <=
\sum_(i <- e) 2 ^ minn (∇i) l
ef 684 6d9
by move : cI; rewrite ltnS leqn0 => /eqP-> ; rewrite big_ord0.
move : cI; rewrite leq_eqVlt => /orP[/eqP [] eC|]; last first .305 6e2 ef
#|` e|.+1 < n.+2 ->
\sum_(i < #|` e|) 2 ^ minn (∇i) l <=
\sum_(i <- e) 2 ^ minn (∇i) l
by apply : IH.
have /(eq_fbigmax id)[/= i [iIe iM]] : 0 < #|`e| by rewrite -ltnS eC.
have eE : #|` e| = #|` e `\ i|.+1 by rewrite (cardfsD1 i) iIe.305 6e2 ef 6ee 150 a9 69d 6a2
6d9
rewrite eE big_ord_recr /= (big_fsetD1 i) //= addnC.6f9 2 ^ minn (∇#|` e `\ i|) l +
\sum_(i0 < #|` e `\ i|) 2 ^ minn (∇i0) l <=
2 ^ minn (∇i) l + \sum_(i <- e `\ i) 2 ^ minn (∇i) l
apply : leq_add; last by apply : IH; rewrite -eC eE.6f9 2 ^ minn (∇#|` e `\ i|) l <= 2 ^ minn (∇i) l
rewrite leq_exp2l // leq_min geq_minr andbT.6f9 minn (∇#|` e `\ i|) l <= ∇i
apply : leq_trans (geq_minl _ _) _.
apply : troot_le.
rewrite -{2 }iM -ltnS -eE -[#|`_|]prednK; last by rewrite eC.6f9 #|` e|.-1 < (\max_(i <- e) i).+1
by apply : max_set_nat.
Qed .
(* This is 2.4.2 *)
Lemma psi_card_le e : psi `[#|`e|] <= psi e.
Proof .713
apply : psi_aux_le_psi => l.
by apply : psi_aux_card_le.
Qed .
(* This is 2.4.3 *)
Lemma psi_exp e : psi e <= (2 ^ #|`e|).-1 .ee ψ(e) <= (2 ^ #|` e|).-1
Proof .71b
rewrite -(ler_nat int_numDomainType).ee (ψ(e)%:R <= (2 ^ #|` e|).-1 %:R)%R
have [l ->] := psiE e.1af (ψ'(l) e <= (2 ^ #|` e|).-1 %:R)%R
apply : le_trans (_ : ((2 ^ l).-1 + \sum_(i <- e) 2 ^ l)%:R -
(l * 2 ^ l)%:R <= _)%R.1af (ψ'(l) e <=
((2 ^ l).-1 + \sum_(i <- e) 2 ^ l)%:R -
(l * 2 ^ l)%:R)%R
apply : ler_sub => //.1af (((2 ^ l).-1 + \sum_(i <- e) 2 ^ minn (∇i) l)%:R <=
((2 ^ l).-1 + \sum_(i <- e) 2 ^ l)%:R)%R
72b
rewrite ler_nat leq_add2l.1af \sum_(i <- e) 2 ^ minn (∇i) l <= \sum_(i <- e) 2 ^ l
72b
apply : leq_sum => i Hi.2 ^ minn (∇i) l <= 2 ^ l
72b
by rewrite leq_exp2l // geq_minr.
rewrite fsum_nat_const ler_subl_addr -natrD ler_nat [X in _ <= X]addnC.1af (2 ^ l).-1 + #|` e| * 2 ^ l <=
l * 2 ^ l + (2 ^ #|` e|).-1
rewrite -prednDl ?expn_gt0 // -prednDr ?expn_gt0 //.1af (2 ^ l + #|` e| * 2 ^ l).-1 <=
(l * 2 ^ l + 2 ^ #|` e|).-1
rewrite -!subn1 leq_sub2r //.1af 2 ^ l + #|` e| * 2 ^ l <= l * 2 ^ l + 2 ^ #|` e|
have [E|E] := leqP #|`e| l.
rewrite -(subnK E).74e 2 ^ (l - #|` e| + #|` e|) +
#|` e| * 2 ^ (l - #|` e| + #|` e|) <=
(l - #|` e| + #|` e|) * 2 ^ (l - #|` e| + #|` e|) +
2 ^ #|` e|
750
set u := _ - _.2 ^ (u + #|` e|) + #|` e| * 2 ^ (u + #|` e|) <=
(u + #|` e|) * 2 ^ (u + #|` e|) + 2 ^ #|` e|
750
rewrite expnD !mulnDl addnAC leq_add2r.75b 2 ^ u * 2 ^ #|` e| <=
u * (2 ^ u * 2 ^ #|` e|) + 2 ^ #|` e|
750
case : u => [|u]; first by rewrite mul1n.2 ^ u.+1 * 2 ^ #|` e| <=
u.+1 * (2 ^ u.+1 * 2 ^ #|` e|) + 2 ^ #|` e|
750
by rewrite mulSn -addnA leq_addr.
rewrite -(subnK (ltnW E)).752 2 ^ l + (#|` e| - l + l) * 2 ^ l <=
l * 2 ^ l + 2 ^ (#|` e| - l + l)
set u := _ - _.2 ^ l + (u + l) * 2 ^ l <= l * 2 ^ l + 2 ^ (u + l)
rewrite expnD !mulnDl addnA addnC leq_add2l.772 2 ^ l + u * 2 ^ l <= 2 ^ u * 2 ^ l
by rewrite -mulSn leq_mul2r ltn_expl // orbT.
Qed .
(* This is 2.5 *)
Lemma psi_diff e1 e2 : psi e1 - psi e2 <= \sum_(i <- e1 `\` e2) 2 ^ troot i.28f ψ(e1) - ψ(e2) <= \sum_(i <- e1 `\` e2) 2 ^ ∇i
Proof .77a
rewrite leq_subLR -(ler_nat int_numDomainType) natrD addrC -ler_subl_addr.28f (ψ(e1)%:R - ψ(e2)%:R <=
(\sum_(i <- e1 `\` e2) 2 ^ ∇i)%:R)%R
have [l ->] := psiE e1.f7 f6
(ψ'(l) e1 - ψ(e2)%:R <=
(\sum_(i <- e1 `\` e2) 2 ^ ∇i)%:R)%R
apply : le_trans (ler_sub (lexx _) (psi_max _ l)) _.785 (ψ'(l) e1 - ψ'(l) e2 <=
(\sum_(i <- e1 `\` e2) 2 ^ ∇i)%:R)%R
rewrite /psi_aux opprB addrA subrK addnC !natrD opprD addrA addrK.785 ((\sum_(i <- e1) 2 ^ minn (∇i) l)%:R -
(\sum_(i <- e2) 2 ^ minn (∇i) l)%:R <=
(\sum_(i <- e1 `\` e2) 2 ^ ∇i)%:R)%R
rewrite ler_subl_addr -natrD ler_nat addnC -leq_subLR.785 \sum_(i <- e1) 2 ^ minn (∇i) l -
\sum_(i <- e2) 2 ^ minn (∇i) l <=
\sum_(i <- e1 `\` e2) 2 ^ ∇i
set s1 := \sum_(_ <- _) _; set s2 := \sum_(_ <- _) _; set s3 := \sum_(_ <- _) _.f7 f6 s1 := \sum_(H <- e1) 2 ^ minn (∇H) l : nat
s2 := \sum_(H <- e2) 2 ^ minn (∇H) l : nat
s3 := \sum_(H <- e1 `\` e2) 2 ^ ∇H : nat
s1 - s2 <= s3
pose f i := 2 ^ minn (troot i) l.f7 f6 797 798 799 f := fun i : nat => 2 ^ minn (∇i) l: nat -> nat
79a
apply : leq_trans (_ : \sum_(i <- e1 `\` e2) f i <= _); last first .79e \sum_(i <- e1 `\` e2) f i <= s3
by apply : leq_sum => i _; rewrite leq_exp2l // geq_minl.
rewrite leq_subLR.79e s1 <= s2 + \sum_(i <- e1 `\` e2) f i
rewrite [s1](big_fsetID _ (fun i => i \in e2)) //=.79e \sum_(i <- [fset x | x in e1 & x \in e2])
2 ^ minn (∇i) l +
\sum_(i <- [fset x | x in e1 & x \notin e2])
2 ^ minn (∇i) l <= s2 + \sum_(i <- e1 `\` e2) f i
apply : leq_add.79e \sum_(i <- [fset x | x in e1 & x \in e2])
2 ^ minn (∇i) l <= s2
rewrite [s2](big_fsetID _ (fun i => i \in e1)) //=.79e \sum_(i <- [fset x | x in e1 & x \in e2])
2 ^ minn (∇i) l <=
\sum_(i <- [fset x | x in e2 & x \in e1])
2 ^ minn (∇i) l +
\sum_(i <- [fset x | x in e2 & x \notin e1])
2 ^ minn (∇i) l
7b6
apply : leq_trans (leq_addr _ _).79e \sum_(i <- [fset x | x in e1 & x \in e2])
2 ^ minn (∇i) l <=
\sum_(i <- [fset x | x in e2 & x \in e1])
2 ^ minn (∇i) l
7b6
rewrite leq_eqVlt; apply /orP; left ; apply /eqP.79e \sum_(i <- [fset x | x in e1 & x \in e2])
2 ^ minn (∇i) l =
\sum_(i <- [fset x | x in e2 & x \in e1])
2 ^ minn (∇i) l
7b6
by apply : eq_fbigl => i; rewrite !inE andbC.
rewrite leq_eqVlt; apply /orP; left ; apply /eqP.79e \sum_(i <- [fset x | x in e1 & x \notin e2])
2 ^ minn (∇i) l = \sum_(i <- e1 `\` e2) f i
by apply : eq_fbigl => i; rewrite !inE andbC.
Qed .
(* This is 2.6 *)
Lemma psi_delta e s a :
#|` e `\` `[delta s]| <= s -> a \in e -> psi e - psi (e `\ a) <= 2 ^ s.-1 .#|` e `\` `[Δs]| <= s ->
a \in e -> ψ(e) - ψ(e `\ a) <= 2 ^ s.-1
Proof .7cd
move => CLs aIe.ef 7d0 7d1 CLs : #|` e `\` `[Δs]| <= s
aIe : a \in e
ψ(e) - ψ(e `\ a) <= 2 ^ s.-1
rewrite leq_subLR -(ler_nat int_numDomainType) natrD addrC -ler_subl_addr.7d7 (ψ(e)%:R - ψ(e `\ a)%:R <= (2 ^ s.-1 )%:R)%R
have [l Hl] := psiE e.ef 7d0 7d1 7d8 7d9 f6 Hl : (ψ(e)%:R)%R = ψ'(l) e
7de
have F l1 : s <= l1.+1 -> (psi_aux l1.+1 e <= psi_aux l1 e)%R.ef 7d0 7d1 7d8 7d9 f6 7e3 l1 : nat
s <= l1.+1 -> (ψ'(l1.+1 ) e <= ψ'(l1) e)%R
move => sLl1.ef 7d0 7d1 7d8 7d9 f6 7e3 7e8 sLl1 : s <= l1.+1
(ψ'(l1.+1 ) e <= ψ'(l1) e)%R
7ea
rewrite psi_auxE_le.7f1 (((2 ^ l1.+1 * #|` [fset i | i in e & (l1 < ∇i)%N]|.+1 ).-1 +
\sum_(i <- e | (∇i < l1.+1 )%N) 2 ^ ∇i)%:R -
(l1.+1 * 2 ^ l1.+1 )%:R <= ψ'(l1) e)%R
7ea
rewrite psi_auxE_lt.7f1 (((2 ^ l1.+1 * #|` [fset i | i in e & (l1 < ∇i)%N]|.+1 ).-1 +
\sum_(i <- e | (∇i < l1.+1 )%N) 2 ^ ∇i)%:R -
(l1.+1 * 2 ^ l1.+1 )%:R <=
((2 ^ l1 * #|` [fset i | i in e & (l1 < ∇i)%N]|.+1 ).-1 +
\sum_(i <- e | (∇i <= l1)%N) 2 ^ ∇i)%:R -
(l1 * 2 ^ l1)%:R)%R
7ea
set s1 := \sum_(_ <- _ | _) _.ef 7d0 7d1 7d8 7d9 f6 7e3 7e8 7f2 s1 := \sum_(H <- e | ∇H < l1.+1 ) 2 ^ ∇H : nat
(((2 ^ l1.+1 * #|` [fset i | i in e & (l1 < ∇i)%N]|.+1 ).-1 +
s1)%:R - (l1.+1 * 2 ^ l1.+1 )%:R <=
((2 ^ l1 * #|` [fset i | i in e & (l1 < ∇i)%N]|.+1 ).-1 +
s1)%:R - (l1 * 2 ^ l1)%:R)%R
7ea
have -> : [fset i in e | l1 < troot i] = [fset i in e | delta l1.+1 <= i].7ff [fset i | i in e & l1 < ∇i] =
[fset i | i in e & Δl1.+1 <= i]
by apply /fsetP => i; rewrite !inE root_delta_le.
set c := #|`_|.ef 7d0 7d1 7d8 7d9 f6 7e3 7e8 7f2 800 c := #|` [fset i | i in e & Δl1.+1 <= i]| : nat
(((2 ^ l1.+1 * c.+1 ).-1 + s1)%:R -
(l1.+1 * 2 ^ l1.+1 )%:R <=
((2 ^ l1 * c.+1 ).-1 + s1)%:R - (l1 * 2 ^ l1)%:R)%R
7ea
have Hc : c <= s.
apply : leq_trans CLs.ef 7d0 7d1 7d9 f6 7e3 7e8 7f2 800 810
c <= #|` e `\` `[Δs]|
816
apply : fsubset_leq_card.81d [fset i | i in e & Δl1.+1 <= i] `<=` e `\` `[Δs]
816
apply /fsubsetP=> i.ef 7d0 7d1 7d9 f6 7e3 7e8 7f2 800 810 11f
i \in [fset i | i in e & Δl1.+1 <= i] ->
i \in e `\` `[Δs]
816
rewrite !inE => /andP[-> H].ef 7d0 7d1 7d9 f6 7e3 7e8 7f2 800 810 11f H : Δl1.+1 <= i
(i \notin `[Δs]) && true
816
rewrite andbT mem_sint -leqNgt (leq_trans _ H) //.
by apply : delta_le.
rewrite expnS mulnAC [2 * _ * _]mulnC.818 (((2 ^ l1 * (2 * c.+1 )).-1 + s1)%:R -
(l1.+1 * (2 * 2 ^ l1))%:R <=
((2 ^ l1 * c.+1 ).-1 + s1)%:R - (l1 * 2 ^ l1)%:R)%R
7ea
rewrite mul2n mulnA muln2 -!addnn -[(_ + l1.+1 )%N]addSnnS.818 (((2 ^ l1 * (c.+1 + c.+1 )).-1 + s1)%:R -
((l1.+2 + l1) * 2 ^ l1)%:R <=
((2 ^ l1 * c.+1 ).-1 + s1)%:R - (l1 * 2 ^ l1)%:R)%R
7ea
rewrite mulnDl mulnDr prednDr ?(muln_gt0, expn_gt0) //.818 ((2 ^ l1 * c.+1 + (2 ^ l1 * c.+1 ).-1 + s1)%:R -
(l1.+2 * 2 ^ l1 + l1 * 2 ^ l1)%:R <=
((2 ^ l1 * c.+1 ).-1 + s1)%:R - (l1 * 2 ^ l1)%:R)%R
7ea
set x := 2 ^ _ * _.ef 7d0 7d1 7d8 7d9 f6 7e3 7e8 7f2 800 810 819 x := 2 ^ l1 * c.+1 : nat
((x + x.-1 + s1)%:R -
(l1.+2 * 2 ^ l1 + l1 * 2 ^ l1)%:R <=
(x.-1 + s1)%:R - (l1 * 2 ^ l1)%:R)%R
7ea
rewrite -[(_ + s1)%N]addnA [(x + _)%N]addnC.844 ((x.-1 + s1 + x)%:R -
(l1.+2 * 2 ^ l1 + l1 * 2 ^ l1)%:R <=
(x.-1 + s1)%:R - (l1 * 2 ^ l1)%:R)%R
7ea
rewrite [X in (_ - X <= _)%R]natrD opprD addrA ler_add //.844 ((x.-1 + s1 + x)%:R - (l1.+2 * 2 ^ l1)%:R <=
(x.-1 + s1)%:R)%R
7ea
rewrite ler_sub_addr natrD ler_add // ler_nat.844 x <= l1.+2 * 2 ^ l1
7ea
by rewrite mulnC leq_mul2l ltnS (leq_trans _ sLl1) ?orbT .
pose l1 := minn l s.-1 .ef 7d0 7d1 7d8 7d9 f6 7e3 7ed l1 := minn l s.-1 : nat
7de
have -> : ((psi e)%:R = psi_aux l1 e)%R.859 (ψ(e)%:R)%R = ψ'(l1) e
have [/minn_idPl U|E] := leqP l s.-1 ; first by rewrite [l1]U.ef 7d0 7d1 7d8 7d9 f6 7e3 7ed 85a E : s.-1 < l
85e 85f
have /ltnW/minn_idPr U := E.ef 7d0 7d1 7d8 7d9 f6 7e3 7ed 85a 866 U : minn l s.-1 = s.-1
85e 85f
rewrite [l1]U.86a (ψ(e)%:R)%R = ψ'(s.-1 ) e
85f
apply /eqP; rewrite eq_le psi_max andbT Hl.86a (ψ'(l) e <= ψ'(s.-1 ) e)%R
85f
rewrite -(subnK (ltnW E)).86a (ψ'(l - s.-1 + s.-1 ) e <= ψ'(s.-1 ) e)%R
85f
elim : (_ - _) => [|k IH] //.ef 7d0 7d1 7d8 7d9 f6 7e3 7ed 85a 866 86b 482 IH : (ψ'(k + s.-1 ) e <= ψ'(s.-1 ) e)%R
(ψ'(k.+1 + s.-1 ) e <= ψ'(s.-1 ) e)%R
85f
apply : le_trans IH.ef 7d0 7d1 7d8 7d9 f6 7e3 7ed 85a 866 86b 482
(ψ'(k.+1 + s.-1 ) e <= ψ'(k + s.-1 ) e)%R
85f
rewrite addSn.881 (ψ'((k + s.-1 ).+1 ) e <= ψ'(k + s.-1 ) e)%R
85f
apply : F => //.ef 7d0 7d1 7d8 7d9 f6 7e3 85a 866 86b 482
s <= (k + s.-1 ).+1
85f
case : (s) => // s1.ef 7d0 7d1 7d8 7d9 f6 7e3 85a 866 86b k, s1 : nat
s1 < (k + s1.+1 .-1 ).+1
85f
by rewrite ltnS /= leq_addl.
apply : le_trans (ler_sub (lexx _) (psi_max _ l1)) _.859 (ψ'(l1) e - ψ'(l1) (e `\ a) <= (2 ^ s.-1 )%:R)%R
rewrite /psi_aux opprB addrA subrK addnC !natrD opprD addrA addrK.859 ((\sum_(i <- e) 2 ^ minn (∇i) l1)%:R -
(\sum_(i <- e `\ a) 2 ^ minn (∇i) l1)%:R <=
(2 ^ s.-1 )%:R)%R
rewrite ler_subl_addr -natrD ler_nat addnC -leq_subLR.859 \sum_(i <- e) 2 ^ minn (∇i) l1 -
\sum_(i <- e `\ a) 2 ^ minn (∇i) l1 <= 2 ^ s.-1
rewrite (big_fsetD1 a) //= addnK leq_exp2l //.
by apply : leq_trans (geq_minr _ _) (geq_minr _ _).
Qed .
(* This is 2.7 *)
Lemma psi_add n s e1 e2 :
e1 `<=` `[n] -> n >= delta (s.-1 ) -> #|`e2| <= s ->
psi (e1 `|` e2) - psi (e1) <= psi `[n + s] - psi `[n].e1 `<=` `[n] ->
Δs.-1 <= n ->
#|` e2| <= s ->
ψ(e1 `|` e2) - ψ(e1) <= ψ(`[n + s]) - ψ(`[n])
Proof .8a6
move => e1Sn.Δs.-1 <= n ->
#|` e2| <= s ->
ψ(e1 `|` e2) - ψ(e1) <= ψ(`[n + s]) - ψ(`[n])
elim : s e2 => [e2 _|s IH e2 dLn Ce2].1e e1 : {fset nat}
8b0 e2 : {fset nat}
#|` e2| <= 0 ->
ψ(e1 `|` e2) - ψ(e1) <= ψ(`[n + 0 ]) - ψ(`[n])
rewrite leqn0 cardfs_eq0 => /eqP->.8b5 ψ(e1 `|` fset0) - ψ(e1) <= ψ(`[n + 0 ]) - ψ(`[n])
8b9
by rewrite fsetU0 subnn.
have [->|[x xIe2]] := fset_0Vmem e2.8bb ψ(e1 `|` fset0) - ψ(e1) <= ψ(`[n + s.+1 ]) - ψ(`[n])
by rewrite fsetU0 subnn.
have dLn1 : delta (s.-1 ) <= n.
apply : leq_trans dLn.1e 8b6 8b0 7d0 8bc 8b7 8be 327 8ce
Δs.-1 <= Δs.+1 .-1
8d6
by apply : delta_le; case : (s) => // s1 /=.
pose e3 := e2 `\ x.1e 8b6 8b0 7d0 8bc 8b7 8bd 8be 327 8ce 8d9 e3 := e2 `\ x : {fset nat_choiceType}
8bf
have Ce3 : #|` e3| <= s.
by move : Ce2; rewrite (cardfsD1 x) xIe2 ltnS.
apply : leq_trans (leq_sub_add (psi (e1 `|` e3)) _ _) _.8ed ψ(e1 `|` e2) - ψ(e1 `|` e3) + (ψ(e1 `|` e3) - ψ(e1)) <=
ψ(`[n + s.+1 ]) - ψ(`[n])
rewrite addnS psi_sintS.8ed ψ(e1 `|` e2) - ψ(e1 `|` e3) + (ψ(e1 `|` e3) - ψ(e1)) <=
ψ(`[n + s]) + 2 ^ (∇(n + s).+1 ).-1 - ψ(`[n])
rewrite [X in _ <= X - _]addnC -addnBA; last first .8ed ψ(`[n]) <= ψ(`[n + s])
by apply : psi_sint_leq; rewrite leq_addr.
apply : leq_add; last by apply : IH.8ed ψ(e1 `|` e2) - ψ(e1 `|` e3) <= 2 ^ (∇(n + s).+1 ).-1
have [xIe1|xNIe1] := boolP (x \in e1).1e 8b6 8b0 7d0 8bc 8b7 8bd 8be 327 8ce 8d9 8e6 8ee xIe1 : x \in e1
907
have -> : e1 `|` e2 = e1 `|` e3.
apply /fsetP=> i; rewrite !inE.1e 8b6 8b0 7d0 8bc 8b7 8bd 8be 327 8ce 8d9 8e6 8ee 90c 11f
(i \in e1) || (i \in e2) =
(i \in e1) || (i != x) && (i \in e2)
915
by case : eqP => // ->; rewrite xIe1.
by rewrite subnn.
have -> : e1 `|` e3 = (e1 `|` e2) `\ x.90f e1 `|` e3 = (e1 `|` e2) `\ x
apply /fsetP=> i; rewrite !inE.1e 8b6 8b0 7d0 8bc 8b7 8bd 8be 327 8ce 8d9 8e6 8ee 910 11f
(i \in e1) || (i != x) && (i \in e2) =
(i != x) && ((i \in e1) || (i \in e2))
927
case : eqP => // ->.92d (x \in e1) || ~~ true && (x \in e2) =
~~ true && ((x \in e1) || (x \in e2))
927
by rewrite (negPf xNIe1).
apply : psi_delta; last first .
by rewrite !inE xIe2 orbT.
rewrite -addnS.90f #|` (e1 `|` e2) `\` `[Δ(∇(n + s.+1 ))]| <= ∇(n + s.+1 )
set t := s.+1 .1e 8b6 8b0 7d0 8bc 8b7 8bd 8be 327 8ce 8d9 8e6 8ee 910 t := s.+1 : nat
#|` (e1 `|` e2) `\` `[Δ(∇(n + t))]| <= ∇(n + t)
set g := troot (n + t).1e 8b6 8b0 7d0 8bc 8b7 8bd 8be 327 8ce 8d9 8e6 8ee 910 948 g := ∇(n + t) : nat
#|` (e1 `|` e2) `\` `[Δg]| <= g
apply : leq_trans (_ : #|` e2 `|` (e1 `\` `[delta g])| <= _).94d #|` (e1 `|` e2) `\` `[Δg]| <= #|` e2 `|` e1 `\` `[Δg]|
apply : fsubset_leq_card.94d (e1 `|` e2) `\` `[Δg] `<=` e2 `|` e1 `\` `[Δg]
954
apply /fsubsetP=> i.1e 8b6 8b0 7d0 8bc 8b7 8bd 8be 327 8ce 8d9 8e6 8ee 910 948 94e 11f
i \in (e1 `|` e2) `\` `[Δg] ->
i \in e2 `|` e1 `\` `[Δg]
954
rewrite !inE.95e (i \notin `[Δg]) && ((i \in e1) || (i \in e2)) ->
(i \in e2) || (i \notin `[Δg]) && (i \in e1)
954
by do 2 case : (_ \in _); rewrite ?(orbT, orbF).
apply : leq_trans (_ : #|` e2| + #|` e1 `\` `[delta g]| <= _).94d #|` e2 `|` e1 `\` `[Δg]| <=
#|` e2| + #|` e1 `\` `[Δg]|
by rewrite -cardfsUI leq_addr.
apply : leq_trans (_ : t + #|` e1 `\` `[delta g]| <= _).94d #|` e2| + #|` e1 `\` `[Δg]| <= t + #|` e1 `\` `[Δg]|
by rewrite leq_add2r.
apply : leq_trans (_ : t + #|` sint (delta g) n| <= _).94d t + #|` e1 `\` `[Δg]| <= t + #|` sint (Δg) n|
rewrite leq_add2l.94d #|` e1 `\` `[Δg]| <= #|` sint (Δg) n|
97f
apply : fsubset_leq_card.94d e1 `\` `[Δg] `<=` sint (Δg) n
97f
apply /fsubsetP=> i.95e i \in e1 `\` `[Δg] -> i \in sint (Δg) n
97f
rewrite !(inE, mem_sint) /= -leqNgt => /andP[-> /(fsubsetP e1Sn)].95e i \in `[n] -> true && (i < n)
97f
by rewrite mem_sint.
rewrite card_sint.
have [|E] := leqP n (delta g); last first .1e 8b6 8b0 7d0 8bc 8b7 8bd 8be 327 8ce 8d9 8e6 8ee 910 948 94e E : Δg < n
998
rewrite addnBA; last by apply : ltnW.
rewrite leq_subLR addnC.
by rewrite -ltnS -!addnS -deltaS addnS -root_delta_lt.
move /eqP->; rewrite addn0.
by rewrite root_delta_le deltaS leq_add2r.
Qed .
(* This is 2.8 *)
Lemma psi_cap_ge e1 e2 : phi (#|` e1 `|` e2|.+3 ) <= (psi e1 + psi e2).*2 .*2 + 5 .28f ϕ(#|` e1 `|` e2|.+3 ) <= ((ψ(e1) + ψ(e2)).*2 ).*2 + 5
Proof .9b1
rewrite -(ler_nat int_numDomainType) natrD.28f (ϕ(#|` e1 `|` e2|.+3 )%:R <=
((ψ(e1) + ψ(e2)).*2 ).*2 %:R + 5 %:R)%R
rewrite -!muln2 !natrM !mulr_natr -mulrnA natrD.28f (ϕ(#|` e1 `|` e2|.+3 )%:R <=
(ψ(e1)%:R + ψ(e2)%:R) *+ (2 * 2 ) + 5 %:R)%R
set n := #|`_|.(ϕ(n.+3 )%:R <= (ψ(e1)%:R + ψ(e2)%:R) *+ (2 * 2 ) + 5 %:R)%R
pose m := troot (n.+3 ).
pose p := tmod (n.+3 ).
pose l := m.-2 .
have mG2 : m >= 2 by rewrite root_delta_le.
have pLm : p <= m.
by rewrite leq_subLR -ltnS -[X in _ < X]addnS -deltaS -root_delta_lt ltnS.
have nG : n >= delta l.
rewrite -[n]/(n.+3 .-2 .-1 ) [n.+3 ]tmodE /l -/m.9dd Δm.-2 <= (Δm + tmod n.+3 ).-1 .-2
9e6
case : (m) mG2 => // [] [|] // m1 _.Δm1.+2 .-2 <= (Δm1.+2 + tmod n.+3 ).-1 .-2
9e6
by rewrite deltaS deltaS /= !(addSn, addnS, subSS, subn0) -!addnA leq_addr.
apply : le_trans (_ : ((psi_aux l `[0 ] + psi_aux l `[n]) *+ 4 + 5 %:R <= _))%R;
last first .9e8 ((ψ'(l) `[0 ] + ψ'(l) `[n]) *+ 4 + 5 %:R <=
(ψ(e1)%:R + ψ(e2)%:R) *+ (2 * 2 ) + 5 %:R)%R
rewrite ler_add2r ler_muln2r orFb.9e8 (ψ'(l) `[0 ] + ψ'(l) `[n] <= ψ(e1)%:R + ψ(e2)%:R)%R
9fb
apply : le_trans (_ : psi_aux l e1 + psi_aux l e2 <= _)%R; last first .9e8 (ψ'(l) e1 + ψ'(l) e2 <= ψ(e1)%:R + ψ(e2)%:R)%R
by apply : ler_add; apply : psi_max.
apply : le_trans (_ : psi_aux l (e1 `&` e2) + psi_aux l (e1 `|` e2) <= _)%R.9e8 (ψ'(l) `[0 ] + ψ'(l) `[n] <=
ψ'(l) (e1 `&` e2) + ψ'(l) (e1 `|` e2))%R
apply : ler_add; last by apply : psi_aux_card_le.9e8 (ψ'(l) `[0 ] <= ψ'(l) (e1 `&` e2))%R
a10
apply : psi_aux_sub; rewrite sint0_set0.9e8 fset0 `<=` e1 `&` e2
a10
by apply /fsubsetP=> i; rewrite inE.
rewrite /psi_aux.9e8 (((2 ^ l).-1 + \sum_(i <- e1 `&` e2) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R +
(((2 ^ l).-1 +
\sum_(i <- (e1 `|` e2)) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R) <=
((2 ^ l).-1 + \sum_(i <- e1) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R +
(((2 ^ l).-1 + \sum_(i <- e2) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R))%R
9fb
rewrite !natrD !addrA ler_add // -!addrA ler_add //.9e8 ((\sum_(i <- e1 `&` e2) 2 ^ minn (∇i) l)%:R +
(1 *- (l * 2 ^ l) +
((2 ^ l).-1 %:R +
(\sum_(i <- (e1 `|` e2)) 2 ^ minn (∇i) l)%:R)) <=
(\sum_(i <- e1) 2 ^ minn (∇i) l)%:R +
(1 *- (l * 2 ^ l) +
((2 ^ l).-1 %:R + (\sum_(i <- e2) 2 ^ minn (∇i) l)%:R)))%R
9fb
rewrite addrCA [X in (_ <= X)%R]addrCA ler_add //.9e8 ((\sum_(i <- e1 `&` e2) 2 ^ minn (∇i) l)%:R +
((2 ^ l).-1 %:R +
(\sum_(i <- (e1 `|` e2)) 2 ^ minn (∇i) l)%:R) <=
(\sum_(i <- e1) 2 ^ minn (∇i) l)%:R +
((2 ^ l).-1 %:R + (\sum_(i <- e2) 2 ^ minn (∇i) l)%:R))%R
9fb
rewrite addrCA [X in (_ <= X)%R]addrCA ler_add //.9e8 ((\sum_(i <- e1 `&` e2) 2 ^ minn (∇i) l)%:R +
(\sum_(i <- (e1 `|` e2)) 2 ^ minn (∇i) l)%:R <=
(\sum_(i <- e1) 2 ^ minn (∇i) l)%:R +
(\sum_(i <- e2) 2 ^ minn (∇i) l)%:R)%R
9fb
rewrite -!natrD ler_nat.9e8 \sum_(i <- e1 `&` e2) 2 ^ minn (∇i) l +
\sum_(i <- (e1 `|` e2)) 2 ^ minn (∇i) l <=
\sum_(i <- e1) 2 ^ minn (∇i) l +
\sum_(i <- e2) 2 ^ minn (∇i) l
9fb
rewrite [X in _ <= X + _](bigID (fun i => i \in e2)) /=.9e8 \sum_(i <- e1 `&` e2) 2 ^ minn (∇i) l +
\sum_(i <- (e1 `|` e2)) 2 ^ minn (∇i) l <=
\sum_(i <- e1 | i \in e2) 2 ^ minn (∇i) l +
\sum_(i <- e1 | i \notin e2) 2 ^ minn (∇i) l +
\sum_(i <- e2) 2 ^ minn (∇i) l
9fb
rewrite -!addnA leq_add //.9e8 \sum_(i <- e1 `&` e2) 2 ^ minn (∇i) l <=
\sum_(i <- e1 | i \in e2) 2 ^ minn (∇i) l
rewrite leq_eqVlt; apply /orP; left ; apply /eqP.9e8 \sum_(i <- e1 `&` e2) 2 ^ minn (∇i) l =
\sum_(i <- e1 | i \in e2) 2 ^ minn (∇i) l
a3a
by apply : eq_fbigl_cond => i; rewrite !inE /= andbT.
rewrite [X in X <= _](bigID (fun i => i \in e2)) /=.9e8 \sum_(i <- (e1 `|` e2) | i \in e2) 2 ^ minn (∇i) l +
\sum_(i <- (e1 `|` e2) | i \notin e2) 2 ^ minn (∇i) l <=
\sum_(i <- e1 | i \notin e2) 2 ^ minn (∇i) l +
\sum_(i <- e2) 2 ^ minn (∇i) l
9fb
rewrite addnC leq_add //.9e8 \sum_(i <- (e1 `|` e2) | i \notin e2) 2 ^ minn (∇i) l <=
\sum_(i <- e1 | i \notin e2) 2 ^ minn (∇i) l
rewrite leq_eqVlt; apply /orP; left ; apply /eqP.9e8 \sum_(i <- (e1 `|` e2) | i \notin e2) 2 ^ minn (∇i) l =
\sum_(i <- e1 | i \notin e2) 2 ^ minn (∇i) l
a4c
apply : eq_fbigl_cond => i; rewrite !inE /=.f7 9c1 9c7 9cc 9d1 9d6 9de 9e9 11f
((i \in e1) || (i \in e2)) && (i \notin e2) =
(i \in [eta mem_seq e1]) && (i \notin e2)
a4c
by case : (_ \in e2); rewrite ?(andbT, orbT, andbF, orbF).
rewrite leq_eqVlt; apply /orP; left ; apply /eqP.9e8 \sum_(i <- (e1 `|` e2) | i \in e2) 2 ^ minn (∇i) l =
\sum_(i <- e2) 2 ^ minn (∇i) l
9fb
apply : eq_fbigl_cond => i; rewrite !inE /=.a56 ((i \in e1) || (i \in e2)) && (i \in e2) =
(i \in [eta mem_seq e2]) && true
9fb
by case : (_ \in e2); rewrite /= ?(andbT, orbT, andbF, orbF).
have pE : phi (n.+3 ) = ((m + p - 1 ) * 2 ^ m).+1 .9e8 ϕ(n.+3 ) = ((m + p - 1 ) * 2 ^ m).+1
rewrite phi_modE -/m -/p -{1 4 }[m]prednK 1 ?ltnW //.9e8 1 + (m.-1 .+1 + p) * 2 ^ m - 2 ^ m =
((m.-1 .+1 + p - 1 ) * 2 ^ m).+1
a6a
rewrite [(_ + p)%N]addSn mulSn [(2 ^ _ + _)%nat]addnC addnA addnK.9e8 (1 + (m.-1 + p) * 2 ^ m)%N =
(((m.-1 + p).+1 - 1 ) * 2 ^ m).+1
a6a
by rewrite -subn1 -[(_ + _).+1 ]addn1 addnK.
have pdE : ((phi (delta l))%:R = 1 + (l%:R - 1 ) * (2 ^ l)%:R :> int)%R.a6c (ϕ(Δl)%:R)%R = (1 + (l%:R - 1 ) * (2 ^ l)%:R)%R
rewrite phi_deltaE natrB; last first .a6c 2 ^ l <= 1 + l * 2 ^ l
by case : (l) => // l1; rewrite mulSn addnCA leq_addr.
by rewrite natrD /= mulrBl mul1r addrA -natrM.
rewrite le_eqVlt; apply /orP; left ; apply /eqP.a7f (ϕ(n.+3 )%:R)%R =
((ψ'(l) `[0 ] + ψ'(l) `[n]) *+ 4 + 5 %:R)%R
(* right part *)
rewrite psi_aux_sintE // psi_auxE_le.a7f (ϕ(n.+3 )%:R)%R =
((((2 ^ l).-1 + \sum_(0 <= i < 0 ) 2 ^ minn (∇i) l)%:R -
(l * 2 ^ l)%:R +
(((2 ^ l *
#|` [fset i | i in `[n] & (l <= ∇i)%N]|.+1 ).-1 +
\sum_(i <- `[n] | (∇i < l)%N) 2 ^ ∇i)%:R -
(l * 2 ^ l)%:R)) *+ 4 + 5 %:R)%R
pose f i := 2 ^ minn (∇i) l.f7 9c1 9c7 9cc 9d1 9d6 9de 9e9 a6d a80 79f
a95
rewrite !(big_mkord _ f) big_ord0 addn0.a99 (ϕ(n.+3 )%:R)%R =
(((2 ^ l).-1 %:R - (l * 2 ^ l)%:R +
(((2 ^ l *
#|` [fset i | i in `[n] & (l <= ∇i)%N]|.+1 ).-1 +
\sum_(i <- `[n] | (∇i < l)%N) 2 ^ ∇i)%:R -
(l * 2 ^ l)%:R)) *+ 4 + 5 %:R)%R
have -> : [fset i in `[n] | l <= troot i] = [fset i in `[n] | delta l <= i].a99 [fset i | i in `[n] & l <= ∇i] =
[fset i | i in `[n] & Δl <= i]
by apply /fsetP=> i; rewrite !inE root_delta_le.
have /(sint_sub n)-> : 0 <= delta l.
by apply : (@delta_le 0 ).
rewrite card_sint //.a99 (ϕ(n.+3 )%:R)%R =
(((2 ^ l).-1 %:R - (l * 2 ^ l)%:R +
(((2 ^ l * (n - Δl).+1 ).-1 +
\sum_(i <- `[n] | (∇i < l)%N) 2 ^ ∇i)%:R -
(l * 2 ^ l)%:R)) *+ 4 + 5 %:R)%R
rewrite (_ : \sum_(_ <- _ | _) _ = phi (delta l)); last first .a99 \sum_(H <- `[n] | ∇H < l) 2 ^ ∇H = ϕ(Δl)
rewrite phiE.a99 \sum_(H <- `[n] | ∇H < l) 2 ^ ∇H =
\sum_(i < Δl) 2 ^ ∇i
aba
rewrite [LHS](eq_bigl (fun i => (i < n) && (∇i < l))); last first .a99 (fun i : nat => ∇i < l) =1
(fun i : nat => (i < n) && (∇i < l))
move => i; case : leqP; rewrite ?(andbT, andbF) // root_delta_lt.f7 9c1 9c7 9cc 9d1 9d6 9de 9e9 a6d a80 79f 150
i < Δl -> true = (i < n)
ac5
by move /(leq_trans)->.
rewrite [RHS](eq_bigl
(fun i : 'I_ _ => ((i : nat) \in (enum_fset `[n])))); last first .a99 xpredT =1 (fun i : 'I_(Δl) => i \in `[n])
by move => i; rewrite mem_sint (leq_trans (ltn_ord _)).
elim : enum_fset (fset_uniq `[n]) => /= [_|a l1 IH /andP[aNIl lU]].a99 \sum_(i <- [::] | (i < n) && (∇i < l)) 2 ^ ∇i =
\sum_(i < Δl | i \in [::]) 2 ^ ∇i
by rewrite big_nil big1.
rewrite big_cons /= IH //; case : (boolP (a < n)) => aLn /=; last first .f7 9c1 9c7 9cc 9d1 9d6 9de 9e9 a6d a80 79f a ae1 ae2 ae3 ae4 65f
\sum_(i < Δl | i \in l1) 2 ^ ∇i =
\sum_(i < Δl | i \in a :: l1) 2 ^ ∇i
apply : eq_bigl => i; move : (ltn_ord i); rewrite inE; case : eqP => [->| //].f7 9c1 9c7 9cc 9d1 9d6 9de 9e9 a6d a80 79f a ae1 ae2 ae3 ae4 65f i : 'I_(Δl)
a < Δl -> (a \in l1) = true || (a \in l1)
aee
by move => /leq_trans/(_ nG); rewrite (negPf aLn).
case : leqP => aLl.f7 9c1 9c7 9cc 9d1 9d6 9de 9e9 a6d a80 79f a ae1 ae2 ae3 ae4 664 aLl : l <= ∇a
aed
apply : eq_bigl => i; move : (ltn_ord i); rewrite inE; case : eqP => [->| //].f7 9c1 9c7 9cc 9d1 9d6 9de 9e9 a6d a80 79f a ae1 ae2 ae3 ae4 664 aff af6
af7 b00
by rewrite -root_delta_lt ltnNge aLl.
rewrite root_delta_lt in aLl.f7 9c1 9c7 9cc 9d1 9d6 9de 9e9 a6d a80 79f a ae1 ae2 ae3 ae4 664 aLl : a < Δl
b04 aba
rewrite [RHS](bigD1 (Ordinal aLl)); apply /eqP; last by rewrite inE eqxx.b0f (2 ^ ∇a + \sum_(i < Δl | i \in l1) 2 ^ ∇i)%N ==
addn_comoid (2 ^ ∇(Ordinal aLl))
(\big[addn_comoid/0 ]_(i | (i \in a :: l1) &&
(i != Ordinal aLl)) 2 ^ ∇i)
aba
rewrite /= eqn_add2l; apply /eqP.b0f \sum_(i < Δl | i \in l1) 2 ^ ∇i =
\sum_(i < Δl | (i \in a :: l1) && (i != Ordinal aLl))
2 ^ ∇i
aba
apply : eq_bigl => i; rewrite !inE /= -val_eqE /=.f7 9c1 9c7 9cc 9d1 9d6 9de 9e9 a6d a80 79f a ae1 ae2 ae3 ae4 664 b10 af6
(i \in l1) = ((i == a) || (i \in l1)) && (i != a)
aba
by case : eqP (ltn_ord i) => [->|]; rewrite ?(andbT, negPf aNIl).
(* right part *)
apply : etrans
(_ : ((2 ^ l)%:R * (m.-1 + p)%:R - 1 %:R) *+4 + 5 %:R = _)%R; last first .a99 (((2 ^ l)%:R * (m.-1 + p)%:R - 1 %:R) *+ 4 + 5 %:R)%R =
(((2 ^ l).-1 %:R - (l * 2 ^ l)%:R +
(((2 ^ l * (n - Δl).+1 ).-1 + ϕ(Δl))%:R -
(l * 2 ^ l)%:R)) *+ 4 + 5 %:R)%R
congr (_ *+ _ + _)%R.a99 ((2 ^ l)%:R * (m.-1 + p)%:R - 1 %:R)%R =
((2 ^ l).-1 %:R - (l * 2 ^ l)%:R +
(((2 ^ l * (n - Δl).+1 ).-1 + ϕ(Δl))%:R -
(l * 2 ^ l)%:R))%R
b25
rewrite -!subn1 ![in RHS](natrD, natrM, natrB) ?muln_gt0 ?expn_gt0 //.a99 ((2 ^ l)%:R * (m - 1 + p)%:R - 1 %:R)%R =
((2 ^ l)%:R - 1 %:R - l%:R * (2 ^ l)%:R +
((2 ^ l)%:R * (n - Δl).+1 %:R - 1 %:R + ϕ(Δl)%:R -
l%:R * (2 ^ l)%:R))%R
b25
rewrite pdE !addrA addrK; set u := (2 ^ l)%:R%R.f7 9c1 9c7 9cc 9d1 9d6 9de 9e9 a6d a80 79f u := ((2 ^ l)%:R)%R : Num.NumDomain.porder_ringType int_numDomainType
(u * (m - 1 + p)%:R - 1 %:R)%R =
(u - 1 %:R - l%:R * u + u * (n - Δl).+1 %:R +
(l%:R - 1 ) * u - l%:R * u)%R
b25
rewrite [(u - 1 )%R]addrC -![in RHS]addrA [RHS]addrC; congr (_ - _)%R.b33 (u * (m - 1 + p)%:R)%R =
(u +
(- (l%:R * u) +
(u * (n - Δl).+1 %:R + ((l%:R - 1 ) * u - l%:R * u))))%R
b25
rewrite -{2 }[u]mul1r ![(u * _)%R]mulrC -![(-(_ * u))%R]mulNr -!mulrDl.b33 ((m - 1 + p)%:R * u)%R =
((1 + (1 *- l + ((n - Δl).+1 %:R + (l%:R - 1 - l%:R)))) *
u)%R
b25
congr (_ * _)%R.b33 ((m - 1 + p)%:R)%R =
(1 + (1 *- l + ((n - Δl).+1 %:R + (l%:R - 1 - l%:R))))%R
b25
rewrite {u}!addrA addrAC addrK.a99 ((m - 1 + p)%:R)%R = (1 - l%:R + (n - Δl).+1 %:R - 1 )%R
b25
rewrite -[(_ - _).+1 ]addn1 [in RHS]natrD !addrA addrK.a99 ((m - 1 + p)%:R)%R = (1 - l%:R + (n - Δl)%:R)%R
b25
rewrite -[n]/(n.+3 .-2 .-1 ) [n.+3 ]tmodE -/m -/p.a99 ((m - 1 + p)%:R)%R =
(1 - l%:R + ((Δm + p).-1 .-2 - Δl)%:R)%R
b25
rewrite -[in RHS](subnK mG2) ![in RHS](addnS, addn0) !deltaS !(subnS, subn0).a99 ((m.-1 + p)%:R)%R =
(1 - l%:R +
((Δm.-2 + m.-2 .+1 + m.-2 .+2 + p).-1 .-2 - Δl)%:R)%R
b25
rewrite ![in RHS](addnS, addSn) -!addnA [(delta _ + _)%nat]addnC addnK -/l.a99 ((m.-1 + p)%:R)%R = (1 - l%:R + (l + (l + p))%:R)%R
b25
by rewrite ![in RHS]natrD !addrA subrK /l -(natrD _ 1 %nat) -natrD.
(* left part *)
rewrite pE /l.a99 (((m + p - 1 ) * 2 ^ m).+1 %:R)%R =
(((2 ^ m.-2 )%:R * (m.-1 + p)%:R - 1 %:R) *+ 4 + 5 %:R)%R
case : (m) mG2 => // [] [|m1] //= _.f7 9c1 9c7 9cc 9d1 9de 9e9 a6d a80 79f 9f2
(((m1.+2 + p - 1 ) * 2 ^ m1.+2 ).+1 %:R)%R =
(((2 ^ m1)%:R * (m1.+1 + p)%:R - 1 %:R) *+ 4 + 5 %:R)%R
rewrite addSn subn1 /=.b60 (((m1.+1 + p) * 2 ^ m1.+2 ).+1 %:R)%R =
(((2 ^ m1)%:R * (m1.+1 + p)%:R - 1 %:R) *+ 4 + 5 %:R)%R
rewrite (_ : 5 %:R = 1 *+ 4 + 1 )%R // addrA -mulrnDl.b60 (((m1.+1 + p) * 2 ^ m1.+2 ).+1 %:R)%R =
(((2 ^ m1)%:R * (m1.+1 + p)%:R - 1 %:R + 1 ) *+ 4 + 1 )%R
rewrite subrK -addn1 natrD; congr (_ + _)%R.b60 (((m1.+1 + p) * 2 ^ m1.+2 )%:R)%R =
((2 ^ m1)%:R * (m1.+1 + p)%:R *+ 4 )%R
rewrite -[in RHS]mulr_natr -!natrM [in RHS]mulnAC mulnC.b60 ((2 ^ m1.+2 * (m1.+1 + p))%:R)%R =
((2 ^ m1 * 4 * (m1.+1 + p))%:R)%R
congr (_ * _)%:R%R.b60 2 ^ m1.+2 = 2 ^ m1 * 4
by rewrite mulnC !expnS !mulnA.
Qed .
Lemma phi_3_5_4_phi n : phi (n.+3 ) = (psi `[n.+2 ]).*2 .+1 .2dc ϕ(n.+3 ) = ψ(`[n.+2 ]).*2 .+1
Proof .b77
by rewrite psi_sint_phi prednK ?phi_gt0 . Qed .
Lemma phi_3_5_4_sum n :
phi (n.+3 ) = (\sum_(1 <= i < n.+3 ) 2 ^ troot i).+1 .2dc ϕ(n.+3 ) = (\sum_(1 <= i < n.+3 ) 2 ^ ∇i).+1
Proof .b7c
rewrite phiE.2dc \sum_(i < n.+3 ) 2 ^ ∇i =
(\sum_(1 <= i < n.+3 ) 2 ^ ∇i).+1
rewrite -(big_mkord xpredT (fun i => 2 ^ troot i)).2dc \sum_(0 <= i < n.+3 ) 2 ^ ∇i =
(\sum_(1 <= i < n.+3 ) 2 ^ ∇i).+1
rewrite (big_cat_nat _ _ _ (_ : 0 <= 1 )) //=.2dc (\sum_(0 <= i < 1 ) 2 ^ ∇i +
\sum_(1 <= i < n.+3 ) 2 ^ ∇i)%N =
(\sum_(1 <= i < n.+3 ) 2 ^ ∇i).+1
by rewrite big_nat_recl //= big_mkord big_ord0 addn0 add1n.
Qed .
End PsiDef .
Lemma ltn_diff_ord_max n (i : 'I_n.+2 ) : i != ord_max -> i < n.+1 .
Proof .b8d
move /eqP/val_eqP.b8f val i != val ord_max -> i < n.+1
by have := ltn_ord i; rewrite ltnS leq_eqVlt => /orP[->|].
Qed .
Lemma lift_diff_ord_max n (i : 'I_n.+2 ) :
i != ord_max -> lift ord_max (inord i) = i.b8f i != ord_max -> lift ord_max (inord i) = i
Proof .b98
move => iDm.lift ord_max (inord i) = i
apply /val_eqP; rewrite [val (lift _ _)]lift_max /= ?inordK //.
by apply : ltn_diff_ord_max.
Qed .
Lemma set_ord_max_lift n (e : {set 'I_n.+2 }) :
e :\ ord_max = [set lift ord_max x | x in [set i | lift ord_max i \in e]].e :\ ord_max =
[set lift ord_max x
| x : ordinal_finType n.+2 .-1
& lift ord_max x \in e]
Proof .ba7
apply /setP => i; rewrite !inE /=.1e baa i : ordinal_finType n.+2
(i != ord_max) && (i \in e) =
(i
\in [set lift ord_max x
| x : 'I_n.+1
& lift ord_max x \in e])
apply /andP/imsetP => [[iH iIe]|[j //]].1e baa bb1 iH : i != ord_max
a9 exists2 x : ordinal_finType n.+1 ,
x \in [set i | lift ord_max i \in e] &
i = lift ord_max x
exists (inord i ).bb6 inord i \in [set i | lift ord_max i \in e]
by rewrite inE lift_diff_ord_max.
by rewrite lift_diff_ord_max.
rewrite inE => kH ->; split => //.1e baa bb1 bbc kH : lift ord_max j \in e
lift ord_max j != ord_max
apply /eqP/val_eqP.bce val (lift ord_max j) != val ord_max
by rewrite [val (lift _ _)]lift_max /= neq_ltn ltn_ord.
Qed .