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 Th30:
 for X be non empty finite Subset of BinFinTrees IndexedREAL,
 s,t be finite binary DecoratedTree of IndexedREAL st
 s is one-to-one & t is one-to-one & t in X & s in X
 & rng s /\ rng t = {}
 & ( for z be finite binary DecoratedTree of IndexedREAL
 st z in X holds
 not [(MaxVl(X) + 1),(Vrootr t) +(Vrootr s)] in rng z ) holds
 MakeTree (t,s,(MaxVl(X) + 1)) is one-to-one
 proof
 let X be non empty finite Subset of BinFinTrees
 IndexedREAL,
 s,t be finite binary DecoratedTree of IndexedREAL;
 assume
A1: s is one-to-one & t is one-to-one & t in X & s in X
 & rng s /\ rng t = {}
 & ( for z be finite binary DecoratedTree of IndexedREAL st z in X holds
 not [(MaxVl(X) + 1),(Vrootr t) +(Vrootr s)] in rng z );
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 A6,TREES_3:def 15,A8;
 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;

A10: for x be object st x in dom d & x <> {} holds d.x <> d.{}
proof
 let x be object;
 assume A11: x in dom d & x <> {};
 per cases by A11,A7;
 suppose ex f be Element of dom t st x = <* 0 *> ^ f;
 then consider f be Element of dom t such that
 A12: x = <* 0 *> ^ f;
 d.x = t.f by A12,Th11;
 hence d.x <> d.{} by FUNCT_1:3,A1,A2;
 end;
 suppose ex f be Element of dom s st x = <* 1 *> ^ f;
 then consider f be Element of dom s such that
 A13: x = <* 1 *> ^ f;
 d.x = s.f by A13,Th12;
 hence d.x <> d.{} by FUNCT_1:3,A1,A2;
 end;
end;

A14: for x1,x2 be object
 st x1 in dom d & x2 in dom d & d.x1 = d.x2 holds
 not ((ex f be Element of dom s st x1 = <* 1 *> ^ f ) &
 (ex f be Element of dom t st x2 = <* 0 *> ^ f ))
 proof
 let x1,x2 be object;
 assume A15: x1 in dom d & x2 in dom d & d.x1 = d.x2;
 assume A16: (ex f be Element of dom s st x1 = <* 1 *> ^ f ) &
 (ex f be Element of dom t st x2 = <* 0 *> ^ f );
 then consider f be Element of dom s such that
 A17: x1 = <* 1 *> ^ f;
 A18: d.x1 = s.f by A17,Th12;
 consider g be Element of dom t such that
 A19: x2 = <* 0 *> ^ g by A16;
 A20: s.f = t.g by A15,A18,A19,Th11;
 s.f in rng s & t.g in rng t by FUNCT_1:3;
 hence contradiction by A1,XBOOLE_0:def 4,A20;
end;

for x1,x2 be object st x1 in dom d & x2 in dom d
 & d.x1 = d.x2 holds x1 = x2
proof
 let x1,x2 be object;
 assume A21: x1 in dom d & x2 in dom d & d.x1 = d.x2;
per cases;
 suppose x1 = {} & x2 = {};
 hence thesis;
 end;
 suppose x1 = {} & x2 <> {};
 hence thesis by A21,A10;
 end;
 suppose x1 <> {} & x2 = {};
 hence thesis by A21,A10;
 end;
 suppose
 A22: x1 <> {} & x2 <> {}; then
 A23: (ex f be Element of dom t st x1 = <* 0 *> ^ f ) or
 (ex f be Element of dom s st x1 = <* 1 *> ^ f ) by A21,A7;
 A24: (ex f be Element of dom t st x2 = <* 0 *> ^ f ) or
 (ex f be Element of dom s st x2 = <* 1 *> ^ f ) by A21,A7,A22;
 per cases by A23,A24,A21,A14;
 suppose A25:
 ( (ex f be Element of dom t st x1 = <* 0 *> ^ f ) &
 (ex f be Element of dom t st x2 = <* 0 *> ^ f ) );
 then consider f be Element of dom t such that
 A26: x1 = <* 0 *> ^ f;
 A27: d.x1 = t.f by A26,Th11;
 consider g be Element of dom t such that
 A28: x2 = <* 0 *> ^ g by A25;
 d.x2 = t.g by A28,Th11;
 hence x1=x2 by A26,A28,A1,FUNCT_1:def 4,A21,A27;
 end;
 suppose A29:
 ( (ex f be Element of dom s st x1 = <* 1 *> ^ f ) &
 (ex f be Element of dom s st x2 = <* 1 *> ^ f ) ); then
 consider f be Element of dom s such that
 A30: x1 = <* 1 *> ^ f;
 A31: d.x1 = s.f by A30,Th12;
 consider g be Element of dom s such that
 A32: x2 = <* 1 *> ^ g by A29;
 d.x2 = s.g by A32,Th12;
 hence x1=x2 by A30,A32,A1,FUNCT_1:def 4,A21,A31;
 end;
 end;
 end;
 hence thesis by FUNCT_1:def 4;
end;
