reserve SOURCE for non empty finite set,
 p for Probability of Trivial-SigmaField SOURCE,
 Tseq for FinSequence of BoolBinFinTrees IndexedREAL,
 q for FinSequence of NAT;
reserve T for BinHuffmanTree of p;

theorem Th24:
 Tseq,q,p is_constructingBinHuffmanTree implies
 for i be Nat st 1 <=i & i < len Tseq
 for X,Y be non empty finite Subset of BinFinTrees IndexedREAL
 st X=Tseq.i & Y = Tseq.(i+1) holds
 MaxVl(Y)=MaxVl(X) + 1
proof
assume A1:Tseq,q,p is_constructingBinHuffmanTree;
let i be Nat;
 assume 1 <=i & i < len Tseq; then
 consider X,Y be non empty finite Subset of BinFinTrees IndexedREAL,
    s being MinValueTree of X,
    t being MinValueTree of Y,
    v being finite binary DecoratedTree of IndexedREAL such that
A2: Tseq.i = X & Y = X \ {s} &
 v in {MakeTree (t,s,MaxVl(X) + 1),MakeTree (s,t,MaxVl(X) + 1) } &
 Tseq.(i+1) = (X \ {t,s} ) \/ {v} by A1;
 let X0,Y0 be non empty finite Subset of BinFinTrees IndexedREAL;
assume A3: X0=Tseq.i & Y0 = Tseq.(i+1);
 consider LX0 be non empty finite Subset of NAT such that
 A4: LX0 = {Vrootl p where p
 is Element of BinFinTrees IndexedREAL: p in X0 }
 & MaxVl(X0) = max LX0 by Def9;
consider LY0 be non empty finite Subset of NAT such that
 A5: LY0 = {Vrootl p where p
 is Element of BinFinTrees IndexedREAL: p in Y0 }
 & MaxVl(Y0) = max LY0 by Def9;
v= [(MaxVl(X0) + 1),(Vrootr t) +(Vrootr s)] -tree (t,s) or
 v= [(MaxVl(X0) + 1),(Vrootr s) +(Vrootr t)] -tree (s,t)
by TARSKI:def 2, A2,A3; then
A6: v.{} = [(MaxVl(X0) + 1),(Vrootr t) +(Vrootr s)] or
 v.{} = [(MaxVl(X0) + 1),(Vrootr s) +(Vrootr t)] by TREES_4:def 4;
 dom v is finite & dom v is binary by BINTREE1:def 3; then
 reconsider pv=v as Element of BinFinTrees IndexedREAL by Def2;
 v in {v} by TARSKI:def 1; then
 v in Tseq.(i+1) by A2,XBOOLE_0:def 3; then
 A7: Vrootl pv in LY0 by A5,A3;
 for x be ExtReal st x in LY0 holds x <= Vrootl pv
 proof
 let x be ExtReal;
 assume x in LY0; then
 consider p be Element of BinFinTrees IndexedREAL such that
 A8: x=Vrootl p & p in Y0 by A5;
 A9: p in (X \ {t,s} ) or p in {v} by XBOOLE_0:def 3,A8,A3,A2;
 per cases by A9,TARSKI:def 1,A3,A2,XBOOLE_0:def 5;
 suppose p in X0; then
 Vrootl p in LX0 by A4; then
 Vrootl p <= MaxVl(X0) by A4,XXREAL_2:def 8;
 hence x <= Vrootl pv by A6,A8,NAT_1:16,XXREAL_0:2;
 end;
 suppose p = v;
 hence x <= Vrootl pv by A8;
 end;
 end;
hence MaxVl(Y0) = MaxVl(X0) + 1 by A5,A6,A7,XXREAL_2:def 8;
end;
