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 Th28:
 for X be non empty finite Subset of BinFinTrees IndexedREAL,
 s,t,w be finite binary DecoratedTree of IndexedREAL st
 ( for T be finite binary DecoratedTree of IndexedREAL st T in X holds
 for p be Element of (dom T), r be Element of NAT st r = (T.p) `1
 holds r <= MaxVl(X) ) &
 ( for p,q be finite binary DecoratedTree of IndexedREAL
 st p in X & q in X & p <> q holds rng p /\ rng q = {} ) &
 s in X & t in X & s <> t & w in X \{s,t}
holds
 rng (MakeTree (t,s,(MaxVl(X) + 1)) ) /\ rng w = {}
proof
let X be non empty finite Subset of BinFinTrees IndexedREAL,
 s,t,w be finite binary DecoratedTree of IndexedREAL;
assume A1:
 ( for T be finite binary DecoratedTree of IndexedREAL st T in X holds
 for p be Element of (dom T), r be Element of NAT st r = (T.p) `1
 holds r <= MaxVl(X) ) &
 ( for p,q be finite binary DecoratedTree of IndexedREAL
 st p in X & q in X & p <> q holds rng p /\ rng q = {} ) &
 s in X & t in X & s <> t & w in X \{s,t};
set d= MakeTree (t,s,MaxVl(X) + 1);
 A2: d.{} = [(MaxVl(X) + 1),(Vrootr t) +(Vrootr s)] by TREES_4:def 4;
 set bx = [MaxVl(X) + 1,(Vrootr t) +(Vrootr s)];
 set q = <*dom t, dom s*>;
 A3: len q = 2 by FINSEQ_1:44;
 A6: dom (bx -tree (t,s)) = tree ((dom t),(dom s)) by TREES_4:14;
A7: for a be object st a in dom d holds a = {} or
 (ex f be Element of dom t st a = <* 0 *> ^ f ) or
 (ex f be Element of dom s st a = <* 1 *> ^ f )
 proof
 let a be object;
 assume A8: a in dom d;
 per cases by A8,A6,TREES_3:def 15;
 suppose a = {};
 hence thesis;
 end;
 suppose ex n being Nat, f being FinSequence st
 ( n < len q & f in q . (n + 1) & a = <*n*> ^ f );
 then consider n being Nat, f being FinSequence such that
 A9: n < len q & f in q . (n + 1) & a = <*n*> ^ f;
 per cases by NAT_1:23,A3,A9;
 suppose n = 0;
   hence thesis by A9;
 end;
 suppose n = 1;
   hence thesis by A9;
 end;
 end;
end;
assume rng (MakeTree (t,s,(MaxVl(X) + 1)) ) /\ rng w <> {}; then
 consider nx be object such that
 A10: nx in (rng d ) /\ (rng w ) by XBOOLE_0:def 1;
 A11: nx in (rng d ) & nx in (rng w) by XBOOLE_0:def 4,A10;
 then consider a0 be object such that
 A12: a0 in dom d & nx = d.a0 by FUNCT_1:def 3;
 consider b0 be object such that
 A13: b0 in dom w & nx = w.b0 by FUNCT_1:def 3,A11;
reconsider a=a0 as Element of (dom d) by A12;
reconsider b=b0 as Element of (dom w) by A13;
 A14: w in X & w <> s & w <> t
 proof
 w in X & not w in {s,t} by A1,XBOOLE_0:def 5;
 hence w in X & w <> s & w <> t by TARSKI:def 2;
 end; then
 A15: rng s /\ rng w = {} by A1;
 A16: rng t /\ rng w = {} by A1,A14;
ex x,y be object st x in NAT & y in REAL & w.b = [x,y] by ZFMISC_1:def 2;
then reconsider r = (w.b) `1 as Element of NAT;
 per cases by A7;
 suppose a = {}; then
 (d.a)`1 = MaxVl(X) + 1 by A2;
 hence contradiction by NAT_1:16,A1,A14,A12,A13;
 end;
 suppose ex f be Element of dom t st a = <* 0 *> ^ f; then
 consider f be Element of dom t such that
 A17: a = <* 0 *> ^ f;
 d.a = t.f by A17,Th11; then
 d.a in rng t by FUNCT_1:3;
 hence contradiction by A16,A12,A11,XBOOLE_0:def 4;
 end;
 suppose ex f be Element of dom s st a = <* 1 *> ^ f; then
 consider f be Element of dom s such that
 A18: a = <* 1 *> ^ f;
 d.a = s.f by A18,Th12; then
 nx in rng s by A12,FUNCT_1:3;
 hence contradiction by A15,A11,XBOOLE_0:def 4;
 end;
end;
