
theorem Th107:
  for a, b, c being Ordinal st b in c holds a (+) b in a (+) c
proof
  let a, b, c be Ordinal;
  assume A1: b in c;
  per cases;
  suppose a = 0;
    then a (+) b = b & a (+) c = c by Th82;
    hence thesis by A1;
  end;
  suppose A2: a <> 0;
    :: the basic idea is to grab the first summands of the CNF of b and c
    :: that are equal, put them to a and use the lemma on the rest
    defpred P[Nat] means (CantorNF b).$1 <> (CantorNF c).$1;
    A3: ex i being Nat st P[i]
    proof
      assume A4: for i being Nat holds not P[i];
      A5: dom CantorNF b = dom CantorNF c
      proof
        assume dom CantorNF b <> dom CantorNF c;
        then per cases by XBOOLE_0:def 10;
        suppose not dom CantorNF b c= dom CantorNF c;
          then A6: (CantorNF b).(dom CantorNF c) <> {}
            by ORDINAL1:16, FUNCT_1:def 9;
          not dom CantorNF c in dom CantorNF c;
          then (CantorNF c).(dom CantorNF c) = {} by FUNCT_1:def 2;
          hence contradiction by A4, A6;
        end;
        suppose not dom CantorNF c c= dom CantorNF b;
          then A7: (CantorNF c).(dom CantorNF b) <> {}
            by ORDINAL1:16, FUNCT_1:def 9;
          not dom CantorNF b in dom CantorNF b;
          then (CantorNF b).(dom CantorNF b) = {} by FUNCT_1:def 2;
          hence contradiction by A4, A7;
        end;
      end;
      for x being object st x in dom CantorNF b
        holds (CantorNF b).x = (CantorNF c).x by A4;
      then Sum^ CantorNF b = Sum^ CantorNF c by A5, FUNCT_1:2;
      hence contradiction by A1;
    end;
    consider i being Nat such that
      A8: P[i] & for j being Nat st P[j] holds i <= j from NAT_1:sch 5(A3);
    set A1 = (CantorNF b)|i, A2 = (CantorNF c)|i;
    set B1 = (CantorNF b)/^i, B2 = (CantorNF c)/^i;
    A9: i c= dom CantorNF b & i c= dom CantorNF c
    proof
      assume not (i c= dom CantorNF b & i c= dom CantorNF c);
      then per cases;
      suppose A10: not i c= dom CantorNF b;
        then consider x being object such that
          A11: x in i & not x in dom CantorNF b by TARSKI:def 3;
        i in omega by ORDINAL1:def 12;
        then x in omega by A11, ORDINAL1:10;
        then reconsider x as Nat;
        A12: (CantorNF b).x = {} by A11, FUNCT_1:def 2;
        x in Segm i by A11;
        then (CantorNF b).x = (CantorNF c).x by A8, NAT_1:44;
        then dom CantorNF c c= x by A12, FUNCT_1:def 9, ORDINAL1:16;
        then dom CantorNF c in i by A11, ORDINAL1:12;
        then A13: (CantorNF c).i = {} by FUNCT_1:def 2;
        dom CantorNF b in i by A10, ORDINAL1:16;
        hence contradiction by A8, A13, FUNCT_1:def 2;
      end;
      suppose A14: not i c= dom CantorNF c;
        then consider x being object such that
          A15: x in i & not x in dom CantorNF c by TARSKI:def 3;
        i in omega by ORDINAL1:def 12;
        then x in omega by A15, ORDINAL1:10;
        then reconsider x as Nat;
        A16: (CantorNF c).x = {} by A15, FUNCT_1:def 2;
        x in Segm i by A15;
        then (CantorNF b).x = (CantorNF c).x by A8, NAT_1:44;
        then dom CantorNF b c= x by A16, FUNCT_1:def 9, ORDINAL1:16;
        then dom CantorNF b in i by A15, ORDINAL1:12;
        then A17: (CantorNF b).i = {} by FUNCT_1:def 2;
        dom CantorNF c in i by A14, ORDINAL1:16;
        hence contradiction by A8, A17, FUNCT_1:def 2;
      end;
    end;
    A18: dom A1 = dom(CantorNF b) /\ i by RELAT_1:61
      .= i by A9, XBOOLE_1:28
      .= dom(CantorNF c) /\ i by A9, XBOOLE_1:28
      .= dom A2 by RELAT_1:61;
    for x being object st x in dom A1 holds A1.x = A2.x
    proof
      let x be object;
      assume x in dom A1;
      then A19: x in i by RELAT_1:57;
      i in omega by ORDINAL1:def 12;
      then x in omega by A19, ORDINAL1:10;
      then reconsider m = x as Nat;
      m in Segm i by A19;
      then A20: m < i by NAT_1:44;
      thus A1.x = (CantorNF b).m by A19, FUNCT_1:49
        .= (CantorNF c).m by A8, A20
        .= A2.x by A19, FUNCT_1:49;
    end;
    then A21: A1 = A2 by A18, FUNCT_1:2;
    A22: Sum^ B1 in Sum^ B2
    proof
      Sum^ CantorNF b in Sum^ (A2 ^ B2) by A1;
      then Sum^ (A1 ^ B1) in Sum^ A2 +^ Sum^ B2 by Th24;
      then Sum^ A1 +^ Sum^ B1 in Sum^ A2 +^ Sum^ B2 by Th24;
      hence thesis by A21, ORDINAL3:22;
    end;
    A23: A1^B1 is Cantor-normal-form;
    A24: A2^B2 is Cantor-normal-form;
    A25: b = Sum^ (A1 ^ B1)
      .= Sum^ A1 +^ Sum^ B1 by Th24
      .= Sum^ A1 (+) Sum^ B1 by A23, Th84;
    A26: c = Sum^ (A2 ^ B2)
      .= Sum^ A2 +^ Sum^ B2 by Th24
      .= Sum^ A2 (+) Sum^ B2 by A24, Th84;
    A27: a(+)Sum^ A1 is non empty by A2;
    B1.0 <> B2.0
    proof
      0 in dom B1 or 0 in dom B2
      proof
        assume not 0 in dom B1 & not 0 in dom B2;
        then dom B1 c= {} & dom B2 c= {} by ORDINAL1:16;
        then B1 = {} & B2 = {};
        then A1^B1 = A1 & A2^B2 = A2;
        then A28: CantorNF b = A1 & CantorNF c = A2;
        not i in i;
        then not i in dom(CantorNF b)/\ i & not i in dom(CantorNF c)/\ i
          by XBOOLE_0:def 4;
        then A29: not i in dom A1 & not i in dom A2 by RELAT_1:61;
        then (CantorNF b).i = {} by A28, FUNCT_1:def 2
          .= (CantorNF c).i by A28, A29, FUNCT_1:def 2;
        hence contradiction by A8;
      end;
      then per cases;
      suppose 0 in dom B1 & 0 in dom B2;
        then B1.0 = (CantorNF b).(0+i) & B2.0 = (CantorNF c).(0+i)
          by AFINSQ_2:def 2;
        hence thesis by A8;
      end;
      suppose 0 in dom B1 & not 0 in dom B2;
        then B1.0 <> {} & B2.0 = {} by FUNCT_1:def 9, FUNCT_1:def 2;
        hence thesis;
      end;
      suppose not 0 in dom B1 & 0 in dom B2;
        then B1.0 = {} & B2.0 <> {} by FUNCT_1:def 9, FUNCT_1:def 2;
        hence thesis;
      end;
    end;
    then (CantorNF Sum^ B1).0 <> (CantorNF Sum^ B2).0;
    then (a(+)Sum^ A1)(+)Sum^ B1 in (a(+)Sum^ A2)(+)Sum^ B2
      by A21, A22, A27, Lm11;
    then a(+)b in (a(+)Sum^ A2)(+)Sum^ B2 by A25, Th81;
    hence thesis by A26, Th81;
  end;
end;
