reserve o1,o2 for Ordinal;

theorem Th11:
  for a1,b1 being Element of Bags o1, a2,b2 being Element of Bags
  o2 holds a1 +^ a2 < b1 +^ b2 iff a1 < b1 or a1 = b1 & a2 < b2
proof
  let a1,b1 be Element of Bags o1, a2,b2 be Element of Bags o2;
  thus a1 +^ a2 < b1 +^ b2 implies a1 < b1 or a1 = b1 & a2 < b2
  proof
    assume a1 +^ a2 < b1 +^ b2;
    then consider k be Ordinal such that
A1: (a1 +^ a2).k < (b1 +^ b2).k and
A2: for l being Ordinal st l in k holds (a1 +^ a2).l = (b1 +^ b2).l by
PRE_POLY:def 9;
    now
      assume not k in dom(b1+^b2);
      then (b1+^b2).k = 0 by FUNCT_1:def 2;
      hence contradiction by A1,NAT_1:2;
    end;
    then
A3: k in o1+^o2 by PARTFUN1:def 2;
    now
      per cases by A3,XBOOLE_0:def 5;
      case
A4:     k in o1;
        reconsider a19=a1,b19=b1 as bag of o1;
A5:     for l being Ordinal st l in k holds a19.l = b19.l
        proof
          let l be Ordinal;
          assume
A6:       l in k;
          then
A7:       (a1 +^ a2).l = (b1 +^ b2).l by A2;
A8:       l in o1 by A4,A6,ORDINAL1:10;
          then (a1 +^ a2).l = a1.l by Def1;
          hence thesis by A7,A8,Def1;
        end;
        (a1 +^ a2).k = a1.k by A4,Def1;
        then a1.k < b1.k by A1,A4,Def1;
        hence a1 < b1 by A5,PRE_POLY:def 9;
      end;
      case
A9:     k in (o1+^ o2)\o1;
        set k1 = k -^ o1;
        not k in o1 by A9,XBOOLE_0:def 5;
        then o1 c= k by ORDINAL1:16;
        then
A10:    k = o1+^(k-^o1) by ORDINAL3:def 5;
A11:    for l being Ordinal st l in k1 holds a2.l = b2.l
        proof
          let l be Ordinal;
          o1 c= o1 +^l by ORDINAL3:24;
          then
A12:      not o1 +^l in o1 by ORDINAL1:5;
          assume
A13:      l in k1;
          then o1 +^ l in o1 +^ k1 by ORDINAL2:32;
          then o1 +^ l in o1 +^o2 by A9,A10,ORDINAL1:10;
          then
A14:      o1 +^ l in (o1+^ o2)\o1 by A12,XBOOLE_0:def 5;
          then
A15:      (b1 +^ b2).(o1 +^ l) = b2.(o1+^l-^o1) by Def1
            .= b2.l by ORDINAL3:52;
          (a1 +^ a2).(o1 +^ l) = a2.(o1+^l-^o1) by A14,Def1
            .= a2.l by ORDINAL3:52;
          hence thesis by A2,A10,A13,A15,ORDINAL2:32;
        end;
        for i be object st i in o1 holds a1.i = b1.i
        proof
          not k in o1 by A9,XBOOLE_0:def 5;
          then
A16:      o1 c= k by ORDINAL1:16;
          let i be object;
          assume
A17:      i in o1;
          then reconsider i9=i as Ordinal;
          (a1 +^ a2).i9 = a1.i9 & (b1 +^ b2).i9 = b1.i9 by A17,Def1;
          hence thesis by A2,A17,A16;
        end;
        hence a1 = b1 by PBOOLE:3;
        (a1+^a2).k = a2.(k-^o1) by A9,Def1;
        then a2.k1 < b2.k1 by A1,A9,Def1;
        hence a2 < b2 by A11,PRE_POLY:def 9;
      end;
    end;
    hence thesis;
  end;
  thus a1 < b1 or a1 = b1 & a2 < b2 implies a1 +^ a2 < b1 +^ b2
  proof
    assume
A18: a1 < b1 or a1 = b1 & a2 < b2;
    now
      per cases;
      case
        a1 < b1;
        then consider k be Ordinal such that
A19:    k in o1 and
A20:    a1.k < b1.k and
A21:    for l being Ordinal st l in k holds a1.l = b1.l by Th2;
A22:    for l being Ordinal st l in k holds (a1 +^ a2).l = (b1 +^ b2).l
        proof
          let l be Ordinal;
          assume
A23:      l in k;
          then l in o1 by A19,ORDINAL1:10;
          then (a1 +^ a2).l = a1.l & (b1 +^ b2).l = b1.l by Def1;
          hence thesis by A21,A23;
        end;
        (a1 +^ a2).k = a1.k & (b1 +^ b2).k = b1.k by A19,Def1;
        hence thesis by A20,A22,PRE_POLY:def 9;
      end;
      case
A24:    not a1 < b1;
        then consider k be Ordinal such that
A25:    k in o2 and
A26:    a2.k < b2.k and
A27:    for l being Ordinal st l in k holds a2.l = b2.l by A18,Th2;
        set x = o1+^k;
A28:    for l being Ordinal st l in x holds (a1 +^ a2).l = (b1 +^ b2).l
        proof
          let l be Ordinal;
          assume
A29:      l in x;
          per cases;
          suppose
A30:        l in o1;
            hence (a1 +^ a2).l = b1.l by A18,A24,Def1
              .= (b1 +^ b2).l by A30,Def1;
          end;
          suppose
A31:        not l in o1;
            then o1 c= l by ORDINAL1:16;
            then l-^o1 in o1+^k-^o1 by A29,ORDINAL3:53;
            then
A32:        l-^o1 in k by ORDINAL3:52;
            o1 +^ k in o1+^o2 by A25,ORDINAL2:32;
            then l in o1+^o2 by A29,ORDINAL1:10;
            then
A33:        l in (o1+^o2) \ o1 by A31,XBOOLE_0:def 5;
            hence (a1 +^ a2).l = a2.(l -^ o1) by Def1
              .= b2.(l -^ o1) by A27,A32
              .= (b1 +^ b2).l by A33,Def1;
          end;
        end;
        o1 c= o1+^k by ORDINAL3:24;
        then
A34:    not o1+^k in o1 by ORDINAL1:5;
A35:    k= o1+^k-^o1 by ORDINAL3:52;
        o1+^k in o1+^o2 by A25,ORDINAL2:32;
        then
A36:    o1+^k in (o1+^o2) \ o1 by A34,XBOOLE_0:def 5;
        then (b1+^b2).(o1+^k) = b2.(o1+^k-^o1) by Def1;
        then (a1 +^ a2).x < (b1 +^ b2).x by A26,A36,A35,Def1;
        hence thesis by A28,PRE_POLY:def 9;
      end;
    end;
    hence thesis;
  end;
end;
