reserve A,B,a,b,c,d,e,f,g,h for set;

theorem Th37:
  for G being non empty symmetric RelStr, x being Element of G, R1
  ,R2 being non empty RelStr st the carrier of R1 misses the carrier of R2 &
subrelstr ([#]G \ {x}) = union_of(R1,R2) & G is path-connected holds ex b being
  Element of R1 st [b,x] in the InternalRel of G
proof
  let G be non empty symmetric RelStr;
  let x be Element of G;
  let R1,R2 be non empty RelStr;
  assume that
A1: the carrier of R1 misses the carrier of R2 and
A2: subrelstr ([#]G \ {x}) = union_of(R1,R2) and
A3: G is path-connected;
  set R = subrelstr ([#]G \ {x}), A = the carrier of R;
  the carrier of R1 c= (the carrier of R1) \/ the carrier of R2 by XBOOLE_1:7;
  then
A4: the carrier of R1 c= the carrier of R by A2,NECKLA_2:def 2;
  set a = the Element of R1;
A5: A = [#]G \ {x} by YELLOW_0:def 15;
A6: x <> a
  proof
    assume not thesis;
    then x in (the carrier of R1) \/ the carrier of R2 by XBOOLE_0:def 3;
    then x in (the carrier of G) \ {x} by A2,A5,NECKLA_2:def 2;
    then not x in {x} by XBOOLE_0:def 5;
    hence thesis by TARSKI:def 1;
  end;
  reconsider A as Subset of G by YELLOW_0:def 15;
A7: the carrier of R = A;
  then the carrier of R1 c= the carrier of G by A4,XBOOLE_1:1;
  then a in the carrier of G;
  then (the InternalRel of G) reduces x,a by A3,A6;
  then consider p being FinSequence such that
A8: len p > 0 and
A9: p.1 = x and
A10: p.len p = a and
A11: for i being Nat st i in dom p & i+1 in dom p holds [p.i,
  p.(i+1)] in (the InternalRel of G) by REWRITE1:11;
  defpred P[Nat] means p.$1 in the carrier of R1 & $1 in dom p & for k being
  Nat st k > $1 holds k in dom p implies p.k in the carrier of R1;
  P[len p] by A8,A10,CARD_1:27,FINSEQ_3:25,FINSEQ_5:6;
  then
A12: ex k being Nat st P[k];
  ex n0 being Nat st P[n0] & for n being Nat st P[n] holds n >= n0 from
  NAT_1:sch 5(A12);
  then consider n0 being Element of NAT such that
A13: P[n0] and
A14: for n being Nat st P[n] holds n >= n0;
  n0 <> 0
  proof
    assume not thesis;
    then 0 in Seg (len p) by A13,FINSEQ_1:def 3;
    hence contradiction by FINSEQ_1:1;
  end;
  then consider k0 being Nat such that
A15: n0 = k0 + 1 by NAT_1:6;
A16: n0 <> 1
  proof
    assume not thesis;
    then not x in {x} by A5,A4,A9,A13,XBOOLE_0:def 5;
    hence contradiction by TARSKI:def 1;
  end;
A17: k0 >= 1
  proof
    assume not thesis;
    then k0 = 0 by NAT_1:25;
    hence contradiction by A15,A16;
  end;
  n0 in Seg (len p) by A13,FINSEQ_1:def 3;
  then
A18: n0 <= len p by FINSEQ_1:1;
A19: k0 < n0 by A15,NAT_1:13;
A20: for k being Nat st k > k0 holds k in dom p implies p.k in the carrier
  of R1
  proof
    assume not thesis;
    then consider k being Nat such that
A21: k > k0 and
A22: k in dom p and
A23: not p.k in the carrier of R1;
    k > n0
    proof
      per cases by XXREAL_0:1;
      suppose
        k < n0;
        hence thesis by A15,A21,NAT_1:13;
      end;
      suppose
        n0 < k;
        hence thesis;
      end;
      suppose
        n0 = k;
        hence thesis by A13,A23;
      end;
    end;
    hence contradiction by A13,A22,A23;
  end;
A24: the carrier of G = (the carrier of R) \/ {x}
  proof
    thus the carrier of G c= (the carrier of R) \/ {x}
    proof
      let a be object;
      assume
A25:  a in the carrier of G;
      per cases;
      suppose
        a = x;
        then a in {x} by TARSKI:def 1;
        hence thesis by XBOOLE_0:def 3;
      end;
      suppose
        a <> x;
        then not a in {x} by TARSKI:def 1;
        then a in A by A5,A25,XBOOLE_0:def 5;
        hence thesis by XBOOLE_0:def 3;
      end;
    end;
    let a be object;
    assume
A26: a in (the carrier of R) \/ {x};
    per cases by A26,XBOOLE_0:def 3;
    suppose
      a in the carrier of R;
      hence thesis by A5;
    end;
    suppose
      a in {x};
      hence thesis;
    end;
  end;
  k0 <= n0 by A15,XREAL_1:29;
  then k0 <= len p by A18,XXREAL_0:2;
  then
A27: k0 in dom p by A17,FINSEQ_3:25;
  then
A28: [p.k0,p.(k0+1)] in the InternalRel of G by A11,A13,A15;
  then
A29: p.k0 in the carrier of G by ZFMISC_1:87;
  thus thesis
  proof
    per cases by A29,A24,XBOOLE_0:def 3;
    suppose
A30:  p.k0 in the carrier of R;
      set u = p.k0, v = p.n0;
      [u,v] in [:the carrier of R,the carrier of R:] by A4,A13,A30,ZFMISC_1:87;
      then
A31:  [u,v] in (the InternalRel of G)|_2 the carrier of R by A15,A28,
XBOOLE_0:def 4;
      p.k0 in (the carrier of R1) \/ the carrier of R2 by A2,A30,NECKLA_2:def 2
;
      then p.k0 in the carrier of R1 or p.k0 in the carrier of R2 by
XBOOLE_0:def 3;
      then reconsider u as Element of R2 by A14,A27,A19,A20;
      reconsider v as Element of R1 by A13;
      not [u,v] in the InternalRel of R
      proof
        u in (the carrier of R1) \/ the carrier of R2 by XBOOLE_0:def 3;
        then
A32:    u in the carrier of R by A2,NECKLA_2:def 2;
A33:    v in the carrier of R1 & the InternalRel of R is_symmetric_in the
        carrier of R by NECKLACE:def 3;
        assume not thesis;
        then [v,u] in the InternalRel of R by A4,A32,A33;
        hence thesis by A1,A2,Th35;
      end;
      hence thesis by A31,YELLOW_0:def 14;
    end;
    suppose
A34:  p.k0 in {x};
      set b = p.n0;
      reconsider b as Element of R1 by A13;
A35:  b in the carrier of R & (the InternalRel of G) is_symmetric_in the
      carrier of G by A4,NECKLACE:def 3;
      p.k0 = x by A34,TARSKI:def 1;
      then [b,x] in (the InternalRel of G) by A7,A15,A28,A35;
      hence thesis;
    end;
  end;
end;
