reserve G for Graph,
  v, v1, v2 for Vertex of G,
  c for Chain of G,
  p, p1, p2 for Path of G,
  vs, vs1, vs2 for FinSequence of the carrier of G,
  e, X for set,
  n, m for Nat;

theorem Th18:
  G is connected iff for v1, v2 st v1 <> v2 ex c, vs st c is non
  empty & vs is_vertex_seq_of c & vs.1 = v1 & vs.len vs = v2
proof
  set E = the carrier' of G;
  set S = the Source of G;
  set T = the Target of G;
  thus G is connected implies for v1, v2 being Vertex of G st v1 <> v2 ex c
being Chain of G, vs being FinSequence of the carrier of G st c is non empty &
  vs is_vertex_seq_of c & vs.1 = v1 & vs.len vs = v2
  proof
    reconsider V = the carrier of G as non empty set;
    assume
A1: G is connected;
    let v1, v2 be Vertex of G;
    set V1 = { v where v is Element of V : v = v1 or ex c being Chain of G, vs
being FinSequence of the carrier of G st c is non empty & vs is_vertex_seq_of c
    & vs.1 = v1 & vs.len vs = v };
    set V2 = (V) \ V1;
    v1 in V1;
    then reconsider V1 as non empty set;
    assume
A2: v1 <> v2;
    assume
A3: not thesis;
    now
      assume v2 in V1;
      then
      ex v being Vertex of G st v = v2 &( v = v1 or ex c being Chain of G,
      vs being FinSequence of the carrier of G st c is non empty & vs
      is_vertex_seq_of c & vs.1 = v1 & vs.len vs = v);
      hence contradiction by A2,A3;
    end;
    then reconsider V2 as non empty set by XBOOLE_0:def 5;
    defpred P[set] means $1 = v1 or ex c being Chain of G, vs being
FinSequence of the carrier of G st c is non empty & vs is_vertex_seq_of c & vs.
    1 = v1 & vs.len vs = $1;
A4: { v where v is Element of V : P[v] } is Subset of V from DOMAIN_1:sch
    7;
    defpred P[object] means
(the Source of G).$1 in V1 & (the Target of G).$1 in
    V1;
    consider E1 being set such that
A5: for e being object holds e in E1 iff e in E & P[e] from XBOOLE_0:sch
    1;
A6: dom S = E by FUNCT_2:def 1;
    set E2 = (E) \ E1;
A7: dom (S|E2) = dom S /\ E2 by RELAT_1:61
      .= E2 by A6,XBOOLE_1:28;
A8: rng S c= V by RELAT_1:def 19;
    rng (S|E2) c= V2
    proof
      let v be object;
      assume v in rng (S|E2);
      then consider e being object such that
A9:   e in dom (S|E2) and
A10:  (S|E2).e = v by FUNCT_1:def 3;
      reconsider e as Element of the carrier' of G by A7,A9;
A11:  (S|E2).e = S.e by A9,FUNCT_1:47;
A12:  not e in E1 by A7,A9,XBOOLE_0:def 5;
      per cases by A5,A12;
      suppose
        not e in E;
        hence thesis by A7,A9;
      end;
      suppose
A13:    not (the Source of G).e in V1;
        S.e in V by A7,A9,FUNCT_2:5;
        hence thesis by A10,A11,A13,XBOOLE_0:def 5;
      end;
      suppose
A14:    not (the Target of G).e in V1;
        reconsider Te = T.e as Vertex of G by A7,A9,FUNCT_2:5;
        v in rng (S|E2) & rng (S|E2) c= rng S by A9,A10,FUNCT_1:def 3
,RELAT_1:70;
        then
A15:    v in rng S;
        assume not v in V2;
        then v in V1 by A8,A15,XBOOLE_0:def 5;
        then consider v9 being Vertex of G such that
A16:    v9 = v and
A17:    v9 = v1 or ex c being Chain of G, vs being FinSequence of the
carrier of G st c is non empty & vs is_vertex_seq_of c & vs.1 = v1 & vs.len vs
        = v9;
        thus contradiction
        proof
          per cases by A17;
          suppose
A18:        v9 = v1;
            reconsider ec = <*e*> as Chain of G by A7,A9,MSSCYC_1:5;
            reconsider vs = <*v1, Te*> as FinSequence of the carrier of G;
            len vs = 2 by FINSEQ_1:44;
            then
A19:        vs.1 = v1 & vs.len vs = Te;
            vs is_vertex_seq_of ec by A10,A11,A16,A18,MSSCYC_1:4;
            hence contradiction by A14,A19;
          end;
          suppose
            ex c being Chain of G, vs being FinSequence of the
carrier of G st c is non empty & vs is_vertex_seq_of c & vs.1 = v1 & vs.len vs
            = v9;
            then consider
            c being Chain of G, vs being FinSequence of the carrier
            of G such that
            c is non empty and
A20:        vs is_vertex_seq_of c and
A21:        vs.1 = v1 and
A22:        vs.len vs = v9;
            reconsider c9 = c^<*e*> as Chain of G by A7,A9,A10,A11,A16,A20,A22
,Th12;
            ex vs9 being FinSequence of the carrier of G st vs9 = vs^'<*S
.e,T.e*> & vs9 is_vertex_seq_of c9 & vs9.1 = vs.1 & vs9.len vs9 = Te by A7,A9
,A10,A11,A16,A20,A22,Th12;
            hence contradiction by A14,A21;
          end;
        end;
      end;
    end;
    then reconsider S2 = S|E2 as Function of E2, V2 by A7,FUNCT_2:def 1
,RELSET_1:4;
A23: dom T = E by FUNCT_2:def 1;
A24: dom (T|E2) = dom T /\ E2 by RELAT_1:61
      .= E2 by A23,XBOOLE_1:28;
A25: rng T c= V by RELAT_1:def 19;
    rng (T|E2) c= V2
    proof
      let v be object;
      assume v in rng (T|E2);
      then consider e being object such that
A26:  e in dom (T|E2) and
A27:  (T|E2).e = v by FUNCT_1:def 3;
      reconsider e as Element of the carrier' of G by A24,A26;
A28:  (T|E2).e = T.e by A26,FUNCT_1:47;
A29:  not e in E1 by A24,A26,XBOOLE_0:def 5;
      per cases by A5,A29;
      suppose
        not e in E;
        hence thesis by A24,A26;
      end;
      suppose
A30:    not (the Target of G).e in V1;
        T.e in V by A24,A26,FUNCT_2:5;
        hence thesis by A27,A28,A30,XBOOLE_0:def 5;
      end;
      suppose
A31:    not (the Source of G).e in V1;
        reconsider Se = S.e as Vertex of G by A24,A26,FUNCT_2:5;
        v in rng (T|E2) & rng (T|E2) c= rng T by A26,A27,FUNCT_1:def 3
,RELAT_1:70;
        then
A32:    v in rng T;
        assume not v in V2;
        then v in V1 by A25,A32,XBOOLE_0:def 5;
        then consider v9 being Vertex of G such that
A33:    v9 = v and
A34:    v9 = v1 or ex c being Chain of G, vs being FinSequence of the
carrier of G st c is non empty & vs is_vertex_seq_of c & vs.1 = v1 & vs.len vs
        = v9;
        thus contradiction
        proof
          per cases by A34;
          suppose
A35:        v9 = v1;
            reconsider ec = <*e*> as Chain of G by A24,A26,MSSCYC_1:5;
            reconsider vs = <*v1, Se*> as FinSequence of the carrier of G;
            len vs = 2 by FINSEQ_1:44;
            then
A36:        vs.1 = v1 & vs.len vs = Se;
            vs is_vertex_seq_of ec by A27,A28,A33,A35,Th11;
            hence contradiction by A31,A36;
          end;
          suppose
            ex c being Chain of G, vs being FinSequence of the
carrier of G st c is non empty & vs is_vertex_seq_of c & vs.1 = v1 & vs.len vs
            = v9;
            then consider
            c being Chain of G, vs being FinSequence of the carrier
            of G such that
            c is non empty and
A37:        vs is_vertex_seq_of c and
A38:        vs.1 = v1 and
A39:        vs.len vs = v9;
            reconsider c9 = c^<*e*> as Chain of G by A24,A26,A27,A28,A33,A37
,A39,Th13;
            ex vs9 being FinSequence of the carrier of G st vs9 = vs^'<*T
.e,S.e*> & vs9 is_vertex_seq_of c9 & vs9.1 = vs.1 & vs9.len vs9 = Se by A24,A26
,A27,A28,A33,A37,A39,Th13;
            hence contradiction by A31,A38;
          end;
        end;
      end;
    end;
    then reconsider T2 = T|E2 as Function of E2, V2 by A24,FUNCT_2:def 1
,RELSET_1:4;
A40: E1 c= E
    by A5;
A41: dom (T|E1) = dom T /\ E1 by RELAT_1:61
      .= E /\ E1 by FUNCT_2:def 1
      .= E1 by A40,XBOOLE_1:28;
    rng (T|E1) c= V1
    proof
      let v be object;
      assume v in rng (T|E1);
      then consider e being object such that
A42:  e in dom (T|E1) and
A43:  (T|E1).e = v by FUNCT_1:def 3;
      (T|E1).e = T.e by A42,FUNCT_1:47;
      hence thesis by A5,A41,A42,A43;
    end;
    then reconsider T1 = T|E1 as Function of E1, V1 by A41,FUNCT_2:def 1
,RELSET_1:4;
A44: dom (S|E1) = dom S /\ E1 by RELAT_1:61
      .= E /\ E1 by FUNCT_2:def 1
      .= E1 by A40,XBOOLE_1:28;
    rng (S|E1) c= V1
    proof
      let v be object;
      assume v in rng (S|E1);
      then consider e being object such that
A45:  e in dom (S|E1) and
A46:  (S|E1).e = v by FUNCT_1:def 3;
      (S|E1).e = S.e by A45,FUNCT_1:47;
      hence thesis by A5,A44,A45,A46;
    end;
    then reconsider S1 = S|E1 as Function of E1, V1 by A44,FUNCT_2:def 1
,RELSET_1:4;
    reconsider G1 = MultiGraphStruct (# V1, E1, S1, T1 #), G2 =
    MultiGraphStruct (# V2, E2, S2, T2 #) as Graph;
A47: G is_sum_of G1, G2
    proof
      reconsider MG = the MultiGraphStruct of G as strict Graph;
      thus
A48:  (the Target of G1) tolerates (the Target of G2)
      proof
        let x be object;
        assume
A49:    x in dom (the Target of G1) /\ dom (the Target of G2);
        then x in dom (the Target of G2) by XBOOLE_0:def 4;
        then
A50:    x in E2 by FUNCT_2:def 1;
        x in dom (the Target of G1) by A49,XBOOLE_0:def 4;
        then x in E1 by FUNCT_2:def 1;
        hence thesis by A50,XBOOLE_0:def 5;
      end;
      thus
A51:  (the Source of G1) tolerates (the Source of G2)
      proof
        let x be object;
        assume
A52:    x in dom (the Source of G1) /\ dom (the Source of G2);
        then x in dom (the Source of G2) by XBOOLE_0:def 4;
        then
A53:    x in E2 by FUNCT_2:def 1;
        x in dom (the Source of G1) by A52,XBOOLE_0:def 4;
        then x in E1 by FUNCT_2:def 1;
        hence thesis by A53,XBOOLE_0:def 5;
      end;
A54:  ( for v be set st v in the carrier' of G1 holds (the Source of MG).
v = (the Source of G1).v & (the Target of MG).v = (the Target of G1).v)& for v
be set st v in the carrier' of G2 holds (the Source of MG).v = (the Source of
      G2).v & (the Target of MG).v = (the Target of G2).v by FUNCT_1:49;
      the carrier of MG = (the carrier of G1) \/ (the carrier of G2) &
the carrier' of MG = (the carrier' of G1) \/ (the carrier' of G2) by A4,A40,
XBOOLE_1:45;
      hence thesis by A48,A51,A54,GRAPH_1:def 5;
    end;
    V1 misses V2 by XBOOLE_1:79;
    hence contradiction by A1,A47;
  end;
  assume
A55: for v1, v2 being Vertex of G st v1 <> v2 ex c being Chain of G, vs
being FinSequence of the carrier of G st c is non empty & vs is_vertex_seq_of c
  & vs.1 = v1 & vs.len vs = v2;
  thus G is connected
  proof
    given G1, G2 being Graph such that
A56: (the carrier of G1) misses (the carrier of G2) and
A57: G is_sum_of G1, G2;
    set v2 = the Vertex of G2;
    set v1 = the Vertex of G1;
    set V2 = the carrier of G2;
    set V1 = the carrier of G1;
    set T2 = the Target of G2;
    set T1 = the Target of G1;
    set S2 = the Source of G2;
    set S1 = the Source of G1;
    set E1 = the carrier' of G1;
A58: the MultiGraphStruct of G = G1 \/ G2 by A57;
A59: T1 tolerates T2 & S1 tolerates S2 by A57;
    then
A60: E = E1 \/ the carrier' of G2 by A58,GRAPH_1:def 5;
    the carrier of the MultiGraphStruct of G = V1 \/ V2 by A59,A58,
GRAPH_1:def 5;
    then reconsider v19 = v1, v29 = v2 as Vertex of G by XBOOLE_0:def 3;
A61: (the carrier of G1) /\ (the carrier of G2) = {} by A56;
    then v1 <> v2 by XBOOLE_0:def 4;
    then consider
    c being Chain of G, vs being FinSequence of the carrier of G such
    that
    c is non empty and
A62: vs is_vertex_seq_of c and
A63: vs.1 = v19 and
A64: vs.len vs = v29 by A55;
    defpred P[Nat] means $1 in dom vs & vs.$1 is Vertex of G2;
A65: len vs = len c +1 by A62;
    c is FinSequence of E by MSSCYC_1:def 1;
    then
A66: rng c c= E by FINSEQ_1:def 4;
    1 <= len c+1 by NAT_1:11;
    then len vs in dom vs by A65,FINSEQ_3:25;
    then
A67: ex k being Nat st P[k] by A64;
    consider k being Nat such that
A68: P[k] and
A69: for n being Nat st P[n] holds k <= n from NAT_1:sch 5(A67);
A70: 1 <= k by A68,FINSEQ_3:25;
    k <> 1 by A61,A63,A68,XBOOLE_0:def 4;
    then 1 < k by A70,XXREAL_0:1;
    then 1+1 <= k by NAT_1:13;
    then consider i being Nat such that
A71: 1<=i and
A72: i<k and
A73: k=i+1 by FINSEQ_6:127;
    set e = c.i;
A74: k <= len vs by A68,FINSEQ_3:25;
    then
A75: i <= len c by A65,A73,XREAL_1:6;
    then i in dom c by A71,FINSEQ_3:25;
    then
A76: e in rng c by FUNCT_1:def 3;
    i <= len vs by A72,A74,XXREAL_0:2;
    then
A77: i in dom vs by A71,FINSEQ_3:25;
    per cases by A60,A66,A76,XBOOLE_0:def 3;
    suppose
A78:  e in E1;
      then
A79:  T1.e in V1 by FUNCT_2:5;
A80:  S1.e in V1 by A78,FUNCT_2:5;
      thus contradiction
      proof
        per cases by A62,A71,A75,Lm3;
        suppose
          vs.i = T.e & vs.(i+1) = S.e;
          then vs.k in V1 by A59,A58,A73,A78,A80,GRAPH_1:def 5;
          hence contradiction by A61,A68,XBOOLE_0:def 4;
        end;
        suppose
          vs.i = S.e & vs.(i+1) = T.e;
          then vs.k in V1 by A59,A58,A73,A78,A79,GRAPH_1:def 5;
          hence contradiction by A61,A68,XBOOLE_0:def 4;
        end;
      end;
    end;
    suppose
A81:  e in the carrier' of G2;
      then
A82:  T2.e in V2 by FUNCT_2:5;
A83:  S2.e in V2 by A81,FUNCT_2:5;
      thus contradiction
      proof
        per cases by A62,A71,A75,Lm3;
        suppose
          vs.i = T.e & vs.(i+1) = S.e;
          then vs.i in V2 by A59,A58,A81,A82,GRAPH_1:def 5;
          hence contradiction by A69,A72,A77;
        end;
        suppose
          vs.i = S.e & vs.(i+1) = T.e;
          then vs.i in V2 by A59,A58,A81,A83,GRAPH_1:def 5;
          hence contradiction by A69,A72,A77;
        end;
      end;
    end;
  end;
end;
