
theorem Th13f:
for F being Field,
    m,n being Ordinal
for b being bag of n st support b = {m} holds
len(divisors b) = b.m + 1 &
for k being Nat, S being finite Subset of n st S = {m} &
     k in dom(divisors b) holds (divisors b).k = (S,k-'1)-bag
proof
let F being Field, m,n be Ordinal; let b be bag of n;
assume AS: support b = {m};
per cases;
suppose A: not(m in n);
   now let o be object;
     assume o in n;
     then not o in support b by A,AS,TARSKI:def 1;
     hence b.o = {} by PRE_POLY:def 7 .= (EmptyBag n).o by PBOOLE:5;
     end; then
B: b = EmptyBag n by PBOOLE:def 10; then
C: b.m = 0 by PBOOLE:5;
D: divisors b = <* EmptyBag n *> by B,PRE_POLY:67; then
E: dom(divisors b) = { 1 } by FINSEQ_1:2,FINSEQ_1:38;
   thus len(divisors b) = b.m + 1 by C,D,FINSEQ_1:40;
   now let k be Nat, S be finite Subset of n;
     assume H: S = {m} & k in dom(divisors b);
     then I: k = 1 by E,TARSKI:def 1; then
F:   (divisors b).k = EmptyBag n by D;
     k -' 1 = k - 1 by H,E,XREAL_0:def 2;
     hence (divisors b).k = (S,k-'1)-bag by F,I,UPROOTS:9;
     end;
  hence thesis;
  end;
suppose m in n; then
   for o being object st o in {m} holds o in n by TARSKI:def 1; then
   reconsider S = {m} as finite Subset of n by TARSKI:def 3;
   deffunc g(Nat) = (S,$1-'1)-bag;
   consider F being FinSequence such that
A: len F = b.m + 1 &
   for k being Nat st k in dom F holds F.k = g(k) from FINSEQ_1:sch 2;
   set B = { (S,i)-bag where i is Element of NAT : i <= b.m };
F: B is finite
     proof
     defpred P[set] means 1 = 1;
     set G = { g(i) where i is Nat: i <= b.m+1 & P[i] };
     H: G is finite from FINSEQ_1:sch 6;
     B c= G
       proof
       now let o be object;
         assume o in B; then
         consider i being Element of NAT such that
         H1: o = (S,i)-bag & i <= b.m;
         H2: i + 1 <= b.m + 1 by H1,XREAL_1:6;
         i + 1 -' 1 = i + 1 - 1 by XREAL_0:def 2;
         hence o in G by H1,H2;
         end;
       hence thesis;
       end;
     hence thesis by H;
     end;
G: B c= Bags n
     proof
     now let o be object;
       assume o in B; then
       consider i being Element of NAT such that
       H1: o = (S,i)-bag & i <= b.m;
       thus o in Bags n by H1;
       end;
     hence thesis;
     end;
   (S,0)-bag in B; then
   reconsider B as non empty finite Subset of Bags n by F,G;
D: rng F = B
     proof
     D0: now let o be object;
         assume o in rng F; then
         consider i being Nat such that
         D1: i in dom F & F.i = o by FINSEQ_2:10;
         D2: o = (S,i-'1)-bag by D1,A;
         dom F = Seg(len F) by FINSEQ_1:def 3; then
         D3: 1 <= i & i <= b.m + 1 by D1,A,FINSEQ_1:1; then
         D4: i - 1 <= b.m + 1 - 1 by XREAL_1:9;
         i - 1 = i -' 1 by D3,XREAL_0:def 2;
         hence o in B by D2,D4;
         end;
     now let o be object;
       assume o in B; then
       consider i being Element of NAT such that
       D1: o = (S,i)-bag & i <= b.m;
       D2: i + 1 -' 1 = i + 1 - 1 by XREAL_0:def 2;
       1 <= i + 1 & i + 1 <= b.m + 1 by D1,XREAL_1:6,NAT_1:11; then
       i + 1 in Seg(len F) by A; then
       D3: i + 1 in dom F by FINSEQ_1:def 3; then
       F.(i+1) = o by A,D2,D1;
       hence o in rng F by D3,FUNCT_1:def 3;
       end;
     hence thesis by D0,TARSKI:2;
     end; then
   reconsider F as FinSequence of Bags n by FINSEQ_1:def 4;
   field(BagOrder n) = Bags n by ORDERS_1:12; then
C: BagOrder n linearly_orders B by ORDERS_1:37,ORDERS_1:38;
   for x,y being Nat st x in dom F & y in dom F & x < y
   holds F/.x <> F/.y & [F/.x,F/.y] in BagOrder n
     proof
     let x,y being Nat;
     assume C1: x in dom F & y in dom F & x < y; then
     C2: F/.x = F.x & F/.y = F.y by PARTFUN1:def 6;
     dom F = Seg(len F) by FINSEQ_1:def 3; then
     1 <= x & 1 <= y by C1,FINSEQ_1:1; then
     C4: x -' 1 = x - 1 & y -' 1 = y - 1 by XREAL_0:def 2; then
     C7: x -' 1 < y -' 1 by C1,XREAL_1:9;
     C5: F.x = (S,x-'1)-bag & F.y = (S,y-'1)-bag by C1,A;
     C6: m in {m} by TARSKI:def 1;
     thus F/.x <> F/.y
       proof
       (F.x).m = x -' 1 & (F.y).m = y -' 1 by C5,C6,UPROOTS:7;
       hence thesis by C4,C2,C1;
       end;
     thus [F/.x,F/.y] in BagOrder n
       proof
       (S,x-'1)-bag <=' (S,y-'1)-bag
         proof
         per cases;
         suppose x -' 1 = 0; then
           (S,x-'1)-bag = EmptyBag n by UPROOTS:9;
           hence thesis by PRE_POLY:60;
           end;
         suppose x -' 1 <> 0; then
           D2: support (S,x-'1)-bag = {m} by UPROOTS:8;
           D3: (S,x-'1)-bag.m = x -' 1 by C6,UPROOTS:7;
           D4: support (S,y-'1)-bag = {m} by C7,UPROOTS:8;
           (S,y-'1)-bag.m = y -' 1 by C6,UPROOTS:7;
           hence thesis by C7,D2,D3,D4,Th13e;
           end;
         end;
       hence thesis by C2,C5,PRE_POLY:def 14;
       end;
     end; then
B: F = SgmX(BagOrder n, B) by C,D,PRE_POLY:def 2;
H: for p being bag of n holds p in B iff p divides b
     proof
     let p be bag of n;
     B1: now assume p in B; then
         consider i being Element of NAT such that
         B2: p = (S,i)-bag & i <= b.m;
         per cases;
         suppose i = 0; then
           (S,i)-bag = EmptyBag n by UPROOTS:9;
           hence p divides b by B2,PRE_POLY:59;
           end;
         suppose i <> 0; then
           B3: support (S,i)-bag = {m} by UPROOTS:8;
           now let k be object;
             per cases;
             suppose B4: k = m;
               m in {m} by TARSKI:def 1;
               hence p.k <= b.k by B2,B4,UPROOTS:7;
               end;
             suppose k <> m;
               then not k in support p by B2,B3,TARSKI:def 1;
               hence p.k <= b.k by PRE_POLY:def 7;
               end;
             end;
           hence p divides b by PRE_POLY:def 11;
           end;
         end;
     now assume p divides b; then
        per cases by AS,Th13h;
        suppose p = EmptyBag n;
          then p = (S,0)-bag by UPROOTS:9;
          hence p in B;
          end;
        suppose B2: support p = {m} & p.m <= b.m;
          p = (S,p.m)-bag
            proof
            now let o be object;
              assume o in n;
              per cases;
              suppose o in support p;
                then B3: o = m by B2,TARSKI:def 1;
                m in {m} by TARSKI:def 1;
                hence p.o = (S,p.m)-bag.o by B3,UPROOTS:7;
                end;
              suppose B3: not o in support p;
                hence p.o = 0 by PRE_POLY:def 7
                         .= (S,p.m)-bag.o by B3,B2,UPROOTS:6;
                end;
              end;
            hence thesis by PBOOLE:3;
            end;
          hence p in B by B2;
          end;
        end;
     hence thesis by B1;
     end; then
E: F = divisors b by B,PRE_POLY:def 16;
   thus len(divisors b) = b.m + 1 by A,B,H,PRE_POLY:def 16;
   thus for k being Nat, S being finite Subset of n st S = {m} &
        k in dom(divisors b) holds (divisors b).k = (S,k-'1)-bag by A,E;
   end;
end;
