reserve r,lambda for Real,
  i,j,n for Nat;
reserve p,p1,p2,q1,q2 for Point of TOP-REAL 2,
  P, P1 for Subset of TOP-REAL 2;
reserve T for TopSpace;
reserve f,f1,f2,h for FinSequence of TOP-REAL 2;

theorem Th24:
  ex f1,f2 st f1 is being_S-Seq & f2 is being_S-Seq &
R^2-unit_square = L~f1 \/ L~f2 & L~f1 /\ L~f2 = {|[ 0,0 ]|, |[ 1,1 ]|} & f1/.1
  = |[0,0]| & f1/.len f1=|[1,1]| & f2/.1 = |[0,0]| & f2/.len f2 = |[1,1]|
proof
  set p0 = |[ 0,0 ]|, p01 = |[ 0,1 ]|, p10 = |[ 1,0 ]|, p1 = |[ 1,1 ]|;
  set L4 = { p : p`1 = 1 & p`2 <= 1 & p`2 >= 0};
  set L3 = { p : p`1 <= 1 & p`1 >= 0 & p`2 = 0};
  set L2 = { p : p`1 <= 1 & p`1 >= 0 & p`2 = 1};
  set L1 = { p : p`1 = 0 & p`2 <= 1 & p`2 >= 0};
A1: p1`1 = 1 by EUCLID:52;
  reconsider f2 = <* p0,p10,p1 *> as FinSequence of TOP-REAL 2;
  reconsider f1 = <* p0,p01,p1 *> as FinSequence of TOP-REAL 2;
A2: p0`1 = 0 by EUCLID:52;
  take f1,f2;
A3: f1/.2 = p01 by FINSEQ_4:18;
  now
    assume L2 meets L3;
    then consider x being object such that
A4: x in L2 and
A5: x in L3 by XBOOLE_0:3;
A6: ex p2 st p2 = x & p2`1 <= 1 & p2`1 >= 0 & p2`2 = 0 by A5;
    ex p st p = x & p`1 <= 1 & p`1 >= 0 & p`2 = 1 by A4;
    hence contradiction by A6;
  end;
  then
A7: L2 /\ L3 = {};
A8: p10`2 = 0 by EUCLID:52;
A9: p10`1 = 1 by EUCLID:52;
A10: len f2 = 1 + 2 by FINSEQ_1:45;
  then
A11: 1+1 <= len f2;
A12: f1/.3 = p1 by FINSEQ_4:18;
A13: f1/.1 = p0 by FINSEQ_4:18;
A14: {LSeg(f1,i) where i is Nat: 1 <= i & i+1 <= len f1} c= {LSeg
  (p0,p01),LSeg(p01,p1)}
  proof
    let a be object;
    assume a in {LSeg(f1,i) where i is Nat: 1 <= i & i+1 <= len f1};
    then consider i being Nat such that
A15: a = LSeg(f1,i) and
A16: 1<=i and
A17: i+1<=len f1;
    i+1 <= 2 + 1 by A17,FINSEQ_1:45;
    then i <= 1 + 1 by XREAL_1:6;
    then i = 1 or i = 2 by A16,NAT_1:9;
    then a = LSeg(p0,p01) or a = LSeg(p01,p1) by A13,A3,A12,A15,A17,Def3;
    hence thesis by TARSKI:def 2;
  end;
A18: len f1 = 1 + 2 by FINSEQ_1:45;
  then
A19: 1+1 <= len f1;
  1+1 in Seg len f1 by A18,FINSEQ_1:1;
  then LSeg(p0,p01) = LSeg(f1,1) by A18,A13,A3,Def3;
  then
A20: LSeg(p0,p01) in {LSeg(f1,i) where i is Nat: 1 <= i & i+1 <=
  len f1} by A19;
A21: f2/.3 = p1 by FINSEQ_4:18;
A22: p0`2 = 0 by EUCLID:52;
  thus f1 is being_S-Seq
  proof
A23: p01 <> p1 by A1,EUCLID:52;
    p0 <> p01 by A22,EUCLID:52;
    hence f1 is one-to-one by A1,A2,A23,FINSEQ_3:95;
    thus len f1 >= 2 by A18;
    thus f1 is unfolded
    proof
A24:  for x being object holds x in LSeg(p0,p01) /\ LSeg(p01,p1) iff x = p01
      proof
        let x be object;
        thus x in LSeg(p0,p01) /\ LSeg(p01,p1) implies x = p01
        proof
          assume
A25:      x in LSeg(p0,p01) /\ LSeg(p01,p1);
          then x in {p2 : p2`1 <= 1 & p2`1 >= 0 & p2`2 = 1} by Th13,
XBOOLE_0:def 4;
          then
A26:      ex p2 st p2=x & p2`1<=1 & p2`1>=0 & p2`2=1;
          x in {p : p`1 = 0 & p`2 <= 1 & p`2 >= 0} by A25,Th13,XBOOLE_0:def 4;
          then ex p st p = x & p`1 = 0 & p`2 <= 1 & p`2 >= 0;
          hence thesis by A26,EUCLID:53;
        end;
        assume
A27:    x = p01;
        then
A28:    x in LSeg(p01,p1) by RLTOPSP1:68;
        x in LSeg(p0,p01) by A27,RLTOPSP1:68;
        hence thesis by A28,XBOOLE_0:def 4;
      end;
      let i;
      assume that
A29:  1 <= i and
A30:  i + 2 <= len f1;
      i <= 1 by A18,A30,XREAL_1:6;
      then
A31:  i = 1 by A29,XXREAL_0:1;
      1+1 in Seg len f1 by A18,FINSEQ_1:1;
      then
A32:  LSeg(f1,1) = LSeg(p0,p01) by A18,A13,A3,Def3;
      LSeg(f1,1+1) = LSeg(p01,p1) by A18,A3,A12,Def3;
      hence thesis by A3,A31,A32,A24,TARSKI:def 1;
    end;
    thus f1 is s.n.c.
    proof
      let i,j such that
A33:  i+1 < j;
      now
        per cases;
        suppose
          1 <= i;
          then
A34:      1+1 <= i+1 by XREAL_1:6;
          now
            per cases;
            case
              1 <= j & j+1 <= len f1;
              then j <= 2 by A18,XREAL_1:6;
              hence contradiction by A33,A34,XXREAL_0:2;
            end;
            case
              not (1 <= j & j+1 <= len f1);
              then LSeg(f1,j) = {} by Def3;
              hence LSeg(f1,i) /\ LSeg(f1,j) = {};
            end;
          end;
          hence LSeg(f1,i) /\ LSeg(f1,j) = {};
        end;
        suppose
          not (1 <= i & i+1 <= len f1);
          then LSeg(f1,i) = {} by Def3;
          hence LSeg(f1,i) /\ LSeg(f1,j) = {};
        end;
      end;
      hence LSeg(f1,i) /\ LSeg(f1,j) = {};
    end;
    let i;
    assume that
A35: 1 <= i and
A36: i + 1 <= len f1;
A37: i <= 1 + 1 by A18,A36,XREAL_1:6;
    per cases by A35,A37,NAT_1:9;
    suppose
A38:  i = 1;
      then (f1/.i)`1 = p0`1 by FINSEQ_4:18
        .= 0 by EUCLID:52
        .= (f1/.(i+1))`1 by A3,A38,EUCLID:52;
      hence thesis;
    end;
    suppose
A39:  i = 2;
      then (f1/.i)`2 = p01`2 by FINSEQ_4:18
        .= 1 by EUCLID:52
        .= (f1/.(i+1))`2 by A12,A39,EUCLID:52;
      hence thesis;
    end;
  end;
A40: f2/.2 = p10 by FINSEQ_4:18;
A41: f2/.1 = p0 by FINSEQ_4:18;
A42: {LSeg(f2,i) where i is Nat: 1 <= i & i+1 <= len f2} c= {
  LSeg(p0,p10),LSeg(p10,p1)}
  proof
    let a be object;
    assume a in {LSeg(f2,i) where i is Nat: 1 <= i & i+1 <= len f2};
    then consider i being Nat such that
A43: a = LSeg(f2,i) and
A44: 1<=i and
A45: i+1<=len f2;
    i+1 <= 2 + 1 by A45,FINSEQ_1:45;
    then i <= 1 + 1 by XREAL_1:6;
    then i = 1 or i = 2 by A44,NAT_1:9;
    then a = LSeg(p0,p10) or a = LSeg(p10,p1) by A41,A40,A21,A43,A45,Def3;
    hence thesis by TARSKI:def 2;
  end;
  1+1 in Seg len f2 by A10,FINSEQ_1:1;
  then LSeg(p0,p10) = LSeg(f2,1) by A10,A41,A40,Def3;
  then
A46: LSeg(p0,p10) in {LSeg(f2,i) where i is Nat: 1 <= i & i+1 <=
  len f2} by A11;
  LSeg(p10,p1) = LSeg(f2,2) by A10,A40,A21,Def3;
  then LSeg(p10,p1) in {LSeg(f2,i) where i is Nat: 1 <= i & i+1 <=
  len f2} by A10;
  then {LSeg(p0,p10),LSeg(p10,p1)} c= {LSeg(f2,i) where i is Nat:1
  <=i & i+1<=len f2} by A46,ZFMISC_1:32;
  then
A47: L~f2 = union {LSeg(p0,p10),LSeg(p10,p1)} by A42,XBOOLE_0:def 10;
A48: p1`2 = 1 by EUCLID:52;
  thus f2 is being_S-Seq
  proof
    thus f2 is one-to-one by A1,A48,A9,A8,A2,FINSEQ_3:95;
    thus len f2 >= 2 by A10;
    thus f2 is unfolded
    proof
A49:  for x being object holds x in LSeg(p0,p10) /\ LSeg(p10,p1) iff x = p10
      proof
        let x be object;
        thus x in LSeg(p0,p10) /\ LSeg(p10,p1) implies x = p10
        proof
          assume
A50:      x in LSeg(p0,p10) /\ LSeg(p10,p1);
          then x in { p2 : p2`1 = 1 & p2`2 <= 1 & p2`2 >= 0} by Th13,
XBOOLE_0:def 4;
          then
A51:      ex p2 st p2=x & p2`1=1 & p2`2<=1 & p2`2>=0;
          x in { p : p`1 <= 1 & p`1 >= 0 & p`2 = 0} by A50,Th13,XBOOLE_0:def 4;
          then ex p st p = x & p`1 <= 1 & p`1 >= 0 & p`2 = 0;
          hence thesis by A51,EUCLID:53;
        end;
        assume
A52:    x = p10;
        then
A53:    x in LSeg(p10,p1) by RLTOPSP1:68;
        x in LSeg(p0,p10) by A52,RLTOPSP1:68;
        hence thesis by A53,XBOOLE_0:def 4;
      end;
      let i;
      assume that
A54:  1 <= i and
A55:  i + 2 <= len f2;
      i <= 1 by A10,A55,XREAL_1:6;
      then
A56:  i = 1 by A54,XXREAL_0:1;
      1+1 in Seg len f2 by A10,FINSEQ_1:1;
      then
A57:  LSeg(f2,1) = LSeg(p0,p10) by A10,A41,A40,Def3;
      LSeg(f2,1+1) = LSeg(p10,p1) by A10,A40,A21,Def3;
      hence thesis by A40,A56,A57,A49,TARSKI:def 1;
    end;
    thus f2 is s.n.c.
    proof
      let i,j such that
A58:  i+1 < j;
      per cases;
      suppose
        1 <= i;
        then
A59:    1+1 <= i+1 by XREAL_1:6;
        now
          per cases;
          case
            1 <= j & j+1 <= len f2;
            then j <= 2 by A10,XREAL_1:6;
            hence contradiction by A58,A59,XXREAL_0:2;
          end;
          case
            not (1 <= j & j+1 <= len f2);
            then LSeg(f2,j) = {} by Def3;
            hence LSeg(f2,i) /\ LSeg(f2,j) = {};
          end;
        end;
        hence LSeg(f2,i) /\ LSeg(f2,j) = {};
      end;
      suppose
        not (1 <= i & i+1 <= len f2);
        then LSeg(f2,i) = {} by Def3;
        hence LSeg(f2,i) /\ LSeg(f2,j) = {};
      end;
    end;
    let i;
    assume that
A60: 1 <= i and
A61: i + 1 <= len f2;
A62: i <= 1 + 1 by A10,A61,XREAL_1:6;
    per cases by A60,A62,NAT_1:9;
    suppose
A63:  i = 1;
      then (f2/.i)`2 = p0`2 by FINSEQ_4:18
        .= 0 by EUCLID:52
        .= (f2/.(i+1))`2 by A40,A63,EUCLID:52;
      hence thesis;
    end;
    suppose
A64:  i = 2;
      then (f2/.i)`1 = p10`1 by FINSEQ_4:18
        .= 1 by EUCLID:52
        .= (f2/.(i+1))`1 by A21,A64,EUCLID:52;
      hence thesis;
    end;
  end;
A65: LSeg(|[0,0]|,|[0,1]|) /\ LSeg(|[1,0]|,|[1,1]|) = {} by Th20;
  LSeg(p01,p1) = LSeg(f1,2) by A18,A3,A12,Def3;
  then LSeg(p01,p1) in {LSeg(f1,i) where i is Nat: 1 <= i & i+1 <=
  len f1} by A18;
  then {LSeg(p0,p01),LSeg(p01,p1)} c= {LSeg(f1,i) where i is Nat:1
  <=i & i+1<=len f1} by A20,ZFMISC_1:32;
  then
A66: L~f1 = union {LSeg(p0,p01),LSeg(p01,p1)} by A14,XBOOLE_0:def 10;
  then L~f1 = (LSeg(p0,p01) \/ LSeg(p01,p1)) by ZFMISC_1:75;
  hence R^2-unit_square = L~f1 \/ L~f2 by A47,ZFMISC_1:75;
  L~f2 = (LSeg(p0,p10) \/ LSeg(p10,p1)) by A47,ZFMISC_1:75;
  hence L~f1 /\ L~f2 = (L1 \/ L2) /\ (L3 \/ L4) by A66,Th13,ZFMISC_1:75
    .= (L1 \/ L2) /\ L3 \/ (L1 \/ L2) /\ L4 by XBOOLE_1:23
    .= L1 /\ L3 \/ L2 /\ L3 \/ (L1 \/ L2) /\ L4 by XBOOLE_1:23
    .= L1 /\ L3 \/ L2 /\ L3 \/ (L1 /\ L4 \/ L2 /\ L4) by XBOOLE_1:23
    .= {|[ 0,0 ]|, |[ 1,1 ]|} by A7,A65,Th13,Th17,Th18,ENUMSET1:1;
  thus thesis by A18,A10,FINSEQ_4:18;
end;
