
theorem Th10:
  for A being set, S being finite Subset of A, b being bag of A
  holds S = support b & degree b = card S iff b = (S, 1)-bag
proof
  let A be set, S be finite Subset of A, b be bag of A;
  set cS = canFS(S);
  set f = b*cS;
A1: dom b = A by PARTFUN1:def 2;
  set g = (card S) |-> 1;
A2: len cS = card S by FINSEQ_1:93;
A3: rng cS = S by FUNCT_2:def 3;
  then
A4: dom f = dom cS by A1,RELAT_1:27;
  then dom f = Seg len cS by FINSEQ_1:def 3;
  then reconsider f as FinSequence by FINSEQ_1:def 2;
A5: len cS = len f by A4,FINSEQ_3:29;
  hereby
    set sb = (S, 1)-bag;
    assume that
A6: S = support b and
A7: degree b = card S;
    consider F being FinSequence of NAT such that
A8: degree b = Sum F and
A9: F = b*cS by A6,Def3;
    now
      let i be Element of NAT;
      assume i in dom F;
      then F.i = b.(cS.i) & cS.i in rng cS by A4,A9,FUNCT_1:3,12;
      hence F.i <> 0 by A6,PRE_POLY:def 7;
    end;
    then
A10: F = len F |-> 1 by A2,A5,A7,A8,A9,Th1;
A11: support b = support sb by A6,Th5;
    now
      thus dom b = dom sb by A1,PARTFUN1:def 2;
      let x be object;
      assume x in dom b;
      per cases;
      suppose
A12:    x in support b;
        then
A13:    cS".x in dom cS by A3,A6,FUNCT_1:32;
        then
A14:    cS".x in Seg len F by A4,A9,FINSEQ_1:def 3;
        rng cS = support b by A6,FUNCT_2:def 3;
        hence b.x = b.(cS.(cS".x)) by A12,FUNCT_1:35
          .= F.(cS".x) by A9,A13,FUNCT_1:13
          .= 1 by A10,A14,FUNCOP_1:7
          .= sb.x by A6,A12,Th4;
      end;
      suppose
A15:    not x in support b;
        hence b.x = 0 by PRE_POLY:def 7
          .= sb.x by A11,A15,PRE_POLY:def 7;
      end;
    end;
    hence b = (S, 1)-bag;
  end;
  rng f c= NAT
  proof
    let y be object;
    assume y in rng f;
    then consider x being object such that
A16: x in dom f and
A17: y = f.x by FUNCT_1:def 3;
    f.x = b.(cS.x) by A16,FUNCT_1:12;
    hence thesis by A17;
  end;
  then reconsider f as FinSequence of NAT by FINSEQ_1:def 4;
  assume
A18: b = (S, 1)-bag;
A19: rng cS = S by FUNCT_2:def 3;
  now
    thus len f = card S by A4,A2,FINSEQ_3:29;
    thus len g = card S by CARD_1:def 7;
    let i be Nat;
A20: dom f = Seg card S by A4,A2,FINSEQ_1:def 3;
    assume
A21: i in dom f;
    hence f.i = b.(cS.i) by FUNCT_1:12
      .= 1 by A4,A19,A18,A21,Th4,FUNCT_1:3
      .= g.i by A20,A21,FUNCOP_1:7;
  end;
  then
A22: f = g by FINSEQ_2:9;
  thus S = support b by A18,Th5;
  then degree b = Sum f by Def3;
  hence degree b = (card S)*1 by A22,RVSUM_1:80
    .= card S;
end;
