reserve X for set, R,R1,R2 for Relation;
reserve x,y,z for set;
reserve n,m,k for Nat;

theorem
  for S1,S2 being finite Subset of X
  for R being connected Order of X holds
  order(S1 \/ S2,R) = order(S1,R)^order(S2,R) iff
  for x,y st x in S1 & y in S2 holds x <> y & x,y in R
  proof
    let S1,S2 be finite Subset of X;
    let R be connected Order of X;
A1: rng order(S1\/S2,R) = S1\/S2 & rng order(S1,R) = S1 & rng order(S2,R) = S2
    by Def11;
A2: dom (order(S1,R)^order(S2,R)) = dom order(S1,R)+^dom order(S2,R)
    by ORDINAL4:def 1;
A3: order(S1\/S2,R) is one-to-one & order(S1,R) is one-to-one &
    order(S2,R) is one-to-one by Def11;
    hereby
      assume
A4:   order(S1 \/ S2,R) = order(S1,R)^order(S2,R);
      let x,y; assume
A5:   x in S1 & y in S2; then
      consider z be object such that
A6:   z in dom order(S1,R) & x = order(S1,R).z by A1,FUNCT_1:def 3;
      consider s being object such that
A7:   s in dom order(S2,R) & y = order(S2,R).s by A1,A5,FUNCT_1:def 3;
      reconsider z,s as Element of NAT by A6,A7;
A8:   order(S1\/S2,R).z = x & order(S1\/S2,R).(dom order(S1,R)+^s) = y
      by A4,A6,A7,ORDINAL4:def 1;
A9:   z in dom order(S1\/S2,R) & dom order(S1,R)+^s in dom order(S1\/S2,R)
      by A2,A6,A7,A4,ORDINAL3:17,25;
A10:   dom order(S1,R)+^s = Segm (dom order(S1,R)+s) by CARD_2:36;
      z in dom order(S1,R)+^s by A6,ORDINAL3:25; then
      z < dom order(S1,R)+s by A10,NAT_1:44;
      hence x <> y & x,y in R by A3,A8,A9,A10,Def11;
    end;
    assume
A11: for x,y st x in S1 & y in S2 holds x <> y & x,y in R;
A12: rng(order(S1,R)^order(S2,R)) = S1 \/ S2 by A1,Th7;
    set o1 = order(S1,R), o2 = order(S2,R);
A13: order(S1,R)^order(S2,R) is one-to-one
    proof
      let x,y be object; assume
A14:  x in dom (o1^o2) & y in dom (o1^o2) & (o1^o2).x = (o1^o2).y;
      per cases by A14,A2,ORDINAL3:38;
      suppose
A15:    x in dom o1 & y in dom o1; then
        (o1^o2).x = o1.x & (o1^o2).y = o1.y by ORDINAL4:def 1;
        hence x = y by A3,A14,A15;
      end;
      suppose
A16:    x in dom o1 & ex a being Ordinal st a in dom o2 & y = dom o1+^a; then
        consider a being Ordinal such that
A17:    a in dom o2 & y = dom o1+^a;
        (o1^o2).x = o1.x & (o1^o2).y = o2.a by A16,A17,ORDINAL4:def 1; then
        (o1^o2).x in S1 & (o1^o2).y in S2 by A1,A16,A17,FUNCT_1:def 3;
        hence thesis by A11,A14;
      end;
      suppose
A18:     y in dom o1 & ex a being Ordinal st a in dom o2 & x = dom o1+^a; then
        consider a being Ordinal such that
A19:     a in dom o2 & x = dom o1+^a;
        (o1^o2).y = o1.y & (o1^o2).x = o2.a by A18,A19,ORDINAL4:def 1; then
        (o1^o2).x in S2 & (o1^o2).y in S1 by A1,A18,A19,FUNCT_1:def 3;
        hence thesis by A11,A14;
      end;
      suppose
A20:    (ex a being Ordinal st a in dom o2 & x = dom o1+^a) &
        ex a being Ordinal st a in dom o2 & y = dom o1+^a; then
        consider a being Ordinal such that
A21:    a in dom o2 & x = dom o1+^a;
        consider b being Ordinal such that
A22:    b in dom o2 & y = dom o1+^b by A20;
        (o1^o2).x = o2.a & (o1^o2).y = o2.b by A21,A22,ORDINAL4:def 1;
        hence thesis by A21,A22,A3,A14;
      end;
    end;
    now let x,y be Nat;
      assume
A23:   x in dom(o1^o2) & y in dom(o1^o2);
      per cases by A23,A2,ORDINAL3:38;
      suppose
A24:    x in dom o1 & y in dom o1; then
        (o1^o2).x = o1.x & (o1^o2).y = o1.y by ORDINAL4:def 1;
        hence x <= y iff (o1^o2).x, (o1^o2).y in R by A24,Def11;
      end;
      suppose
A25:    x in dom o1 & ex a being Ordinal st a in dom o2 & y = dom o1+^a; then
        consider a being Ordinal such that
A26:    a in dom o2 & y = dom o1+^a;
        (o1^o2).x = o1.x & (o1^o2).y = o2.a & x in Segm y
        by A25,A26,ORDINAL3:25,ORDINAL4:def 1; then
        (o1^o2).x in S1 & (o1^o2).y in S2 & x < y
        by A1,A25,A26,FUNCT_1:def 3,NAT_1:44;
        hence x <= y iff (o1^o2).x, (o1^o2).y in R by A11;
      end;
      suppose
A27:    y in dom o1 & ex a being Ordinal st a in dom o2 & x = dom o1+^a; then
        consider a being Ordinal such that
A28:     a in dom o2 & x = dom o1+^a;
A29:     (o1^o2).y = o1.y & (o1^o2).x = o2.a & y in Segm x
        by A27,A28,ORDINAL3:25,ORDINAL4:def 1; then
A30:     (o1^o2).x in S2 & (o1^o2).y in S1 & y < x
        by A1,A27,A28,FUNCT_1:def 3,NAT_1:44;
        thus x <= y implies (o1^o2).x, (o1^o2).y in R by A29,NAT_1:44;
        assume
A31:     (o1^o2).x, (o1^o2).y in R;
        (o1^o2).y, (o1^o2).x in R by A30,A11;
        hence x <= y by A23,A13,A31,Def2;
      end;
      suppose
A32:     (ex a being Ordinal st a in dom o2 & x = dom o1+^a) &
        ex a being Ordinal st a in dom o2 & y = dom o1+^a; then
        consider a being Ordinal such that
A33:     a in dom o2 & x = dom o1+^a;
        consider b being Ordinal such that
A34:     b in dom o2 & y = dom o1+^b by A32;
        reconsider a,b as Element of NAT by A33,A34;
        x <= y iff Segm x c= Segm y by NAT_1:39; then
     x <= y iff Segm a c= Segm b by A33,A34,ORDINAL3:23,18;
        then
A35:     (x <= y iff a <= b) by NAT_1:39;
         (o1^o2).x = o2.a & (o1^o2).y = o2.b
        by A33,A34,ORDINAL4:def 1;
        hence x <= y iff (o1^o2).x, (o1^o2).y in R by A33,A34,Def11,A35;
      end;
    end;
    hence thesis by A12,A13,Def11;
  end;
