
theorem Th64:
  for G being _finite _Graph, H being spanning Subgraph of G
  ex p being non empty _finite Graph-yielding FinSequence
  st p.1 == H & p.len p = G & len p = G.size() - H.size() + 1 &
    for n being Element of dom p st n <= len p - 1 holds
    ex v1,v2 being Vertex of G, e being object
    st p.(n+1) is addEdge of p.n,v1,e,v2 &
      e in the_Edges_of G \ the_Edges_of p.n &
      v1 in the_Vertices_of p.n & v2 in the_Vertices_of p.n
proof
  let G be _finite _Graph;
  defpred P[Nat] means for H being spanning Subgraph of G
    st G.size() - H.size() = $1
    ex p being non empty _finite Graph-yielding FinSequence
    st p.1 == H & p.len p = G & len p = G.size() - H.size() + 1 &
      for n being Element of dom p st n <= len p - 1 holds
      ex v1,v2 being Vertex of G, e being object
      st p.(n+1) is addEdge of p.n,v1,e,v2 &
        e in the_Edges_of G \ the_Edges_of p.n &
        v1 in the_Vertices_of p.n & v2 in the_Vertices_of p.n;
  A1: P[0]
  proof
    let H be spanning Subgraph of G;
    assume A2: G.size() - H.size() = 0;
    then A3: G == H by GLIB_000:119;
    reconsider p = <* G *> as non empty _finite Graph-yielding FinSequence;
    take p;
    thus p.1 == H by A3;
    thus p.len p = p.1 by FINSEQ_1:40
      .= G;
    thus len p = G.size() - H.size() + 1 by A2, FINSEQ_1:40;
    let n be Element of dom p;
    1 <= n & n <= len p by FINSEQ_3:25;
    then 1 <= n & n <= 1 by FINSEQ_1:40;
    then A4: n = 1 by XXREAL_0:1;
    assume n <= len p - 1;
    then n <= 1 - 1 by FINSEQ_1:40;
    hence thesis by A4; :: by contradiction
  end;
  A5: for k being Nat st P[k] holds P[k+1]
  proof
    let k be Nat;
    assume A6: P[k];
    let H be spanning Subgraph of G;
    assume A7: G.size() - H.size() = k+1;
    A8: the_Edges_of G \ the_Edges_of H <> {}
    proof
      assume A9: the_Edges_of G \ the_Edges_of H = {};
      0 = card(the_Edges_of G \ the_Edges_of H) by A9
        .= card the_Edges_of G - card the_Edges_of H by CARD_2:44
        .= G.size() - card the_Edges_of H by GLIB_000:def 25
        .= G.size() - H.size() by GLIB_000:def 25;
      hence contradiction by A7;
    end;
    set e0 = the Element of the_Edges_of G \ the_Edges_of H;
    A10: e0 in the_Edges_of G by A8, TARSKI:def 3;
    then reconsider e0 as Element of the_Edges_of G;
    set u = (the_Source_of G).e0, w = (the_Target_of G).e0;
    reconsider u,w as Vertex of G by A10, FUNCT_2:5;
    A11: the_Vertices_of G = the_Vertices_of H by GLIB_000:def 33;
    set H1 = the addEdge of H, u, e0, w;
    A12: not e0 in the_Edges_of H by A8, XBOOLE_0:def 5;
    A13: k = G.size() - (H.size() + 1) by A7
      .= G.size() - H1.size() by A12, A11, GLIB_006:111;
    A14: the_Vertices_of H1 = the_Vertices_of H by A11, GLIB_006:102;
    H1 is Subgraph of G
    proof
      for e being object holds
        e in the_Edges_of H1 implies e in the_Edges_of G
      proof
        let e be object;
        assume A15: e in the_Edges_of H1;
        the_Edges_of H1 = the_Edges_of H \/ {e0} by A11, A12, GLIB_006:def 11;
        then per cases by A15, XBOOLE_0:def 3;
        suppose e in the_Edges_of H;
          hence thesis;
        end;
        suppose e in {e0};
          hence thesis by A10, TARSKI:def 1;
        end;
      end;
      then A16: the_Edges_of H1 c= the_Edges_of G by TARSKI:def 3;
      now
        let e be set;
        assume e in the_Edges_of H1;
        then A17: e in the_Edges_of H \/ {e0} by A11, A12, GLIB_006:def 11;
        per cases;
        suppose e <> e0;
          then not e in {e0} by TARSKI:def 1;
          then A18: e in the_Edges_of H by A17, XBOOLE_0:def 3;
          thus (the_Source_of H1).e = (the_Source_of H).e by A18
, GLIB_006:def 9
            .= (the_Source_of G).e by A18, GLIB_000:def 32;
          thus (the_Target_of H1).e = (the_Target_of H).e by A18
, GLIB_006:def 9
            .= (the_Target_of G).e by A18, GLIB_000:def 32;
        end;
        suppose A19: e = e0;
          then e DJoins u,w,H1 by A11, A12, GLIB_006:105;
          hence (the_Source_of H1).e = (the_Source_of G).e &
            (the_Target_of H1).e = (the_Target_of G).e by A19, GLIB_000:def 14;
        end;
      end;
      hence thesis by A14, A16, GLIB_000:def 32;
    end;
    then H1 is spanning Subgraph of G by A11, A14, GLIB_000:def 33;
    then consider p being non empty _finite Graph-yielding FinSequence
    such that
      A20: p.1 == H1 & p.len p = G & len p = G.size() - H1.size() + 1 and
      A21: for n being Element of dom p st n <= len p - 1 holds
        ex v1,v2 being Vertex of G, e being object
        st p.(n+1) is addEdge of p.n,v1,e,v2 &
          e in the_Edges_of G \ the_Edges_of p.n &
          v1 in the_Vertices_of p.n & v2 in the_Vertices_of p.n by A6, A13;
    reconsider q = <* H *> ^ p
      as non empty _finite Graph-yielding FinSequence;
    take q;
    A22: q.1 = H by FINSEQ_1:41;
    thus q.1 == H by FINSEQ_1:41;
    A23: len q = len <* H *> + len p by FINSEQ_1:22
      .= len p + 1 by FINSEQ_1:40;
    len p in dom p by FINSEQ_5:6;
    hence q.len q = G by A20, A23, FINSEQ_3:103;
    A24: H.size() + 1 - 1 = H1.size() - 1 by A12, A11, GLIB_006:111;
    thus len q = G.size() - H.size() + 1 by A20, A23, A24;
    let n be Element of dom q;
    assume n <= len q - 1;
    then per cases by Lm13;
    suppose A25: n = 1;
      take u,w,e0;
      1 in dom p by FINSEQ_5:6;
      then A26: p.1 = q.(len <* H *> +1) by FINSEQ_1:def 7
        .= q.(n+1) by A25, FINSEQ_1:40;
      H1 is addEdge of q.n, u, e0, w by A25, FINSEQ_1:41;
      hence q.(n+1) is addEdge of q.n, u, e0, w by A26, A20, GLIB_006:101;
      thus e0 in the_Edges_of G \ the_Edges_of q.n
        by A10, A12, A22, A25, XBOOLE_0:def 5;
      thus u in the_Vertices_of q.n & w in the_Vertices_of q.n
        by A11, A22, A25;
    end;
    suppose A27: n-1 in dom p & n-1 <= len p - 1;
      then reconsider m = n-1 as Element of dom p;
      consider v1,v2 being Vertex of G, e being object such that
        A28: p.(m+1) is addEdge of p.m,v1,e,v2 and
        A29: e in the_Edges_of G \ the_Edges_of p.m &
          v1 in the_Vertices_of p.m & v2 in the_Vertices_of p.m by A21, A27;
      take v1,v2,e;
      A30: 1 <= n by FINSEQ_3:25;
      n <= len p by A27, XREAL_1:9;
      then n in dom p by A30, FINSEQ_3:25;
      then
A31:  p.n = q.(len <* H *> + n) by FINSEQ_1:def 7
        .= q.(n+1) by FINSEQ_1:40;
      p.m = q.(len <* H *> + m) by FINSEQ_1:def 7
        .= q.(m+1) by FINSEQ_1:40
        .= q.n;
      hence thesis by A28, A29, A31;
    end;
  end;
  A32: for k being Nat holds P[k] from NAT_1:sch 2(A1,A5);
  let H be spanning Subgraph of G;
  G.size() - H.size() is Nat by GLIB_000:75, NAT_1:21;
  hence thesis by A32;
end;
