reserve x,y,c for set;

theorem Th18:
  for x,y,c being non pair set for s being State of BorrowCirc(x,y
  ,c) holds Following(s,2) is stable
proof
  let x,y,c be non pair set;
  set S = BorrowStr(x,y,c);
  reconsider xx = x, yy = y, cc = c as Vertex of S by Th6;
  let s be State of BorrowCirc(x,y,c);
  set a1 = s.xx, a2 = s.yy, a3 = s.cc;
  set ffs = Following(s,2), fffs = Following ffs;
A1: ffs = Following Following s by FACIRC_1:15;
A2: y in InputVertices S by Th8;
  then (Following s).y = a2 by CIRCUIT2:def 5;
  then
A3: ffs.y = a2 by A1,A2,CIRCUIT2:def 5;
  a2 = s.y;
  then
A4: ffs.[<*x,c*>,and2a] = 'not' a1 '&' a3 by Lm2;
A5: x in InputVertices S by Th8;
  then (Following s).x = a1 by CIRCUIT2:def 5;
  then
A6: ffs.x = a1 by A1,A5,CIRCUIT2:def 5;
  a1 = s.x;
  then
A7: ffs.[<*y,c*>,and2 ] = a2 '&' a3 by Lm2;
A8: c in InputVertices S by Th8;
  then (Following s).c = a3 by CIRCUIT2:def 5;
  then
A9: ffs.c = a3 by A1,A8,CIRCUIT2:def 5;
  a3 = s.c;
  then
A10: ffs.[<*x,y*>,and2a] = 'not' a1 '&' a2 by Lm2;
A11: ffs.BorrowOutput(x,y,c) = 'not' a1 '&' a2 'or' a2 '&' a3 'or' 'not' a1
  '&' a3 by Lm2;
A12: now
    let a be object;
    assume
A13: a in the carrier of S;
    then reconsider v = a as Vertex of S;
A14: v in InputVertices S \/ InnerVertices S by A13,XBOOLE_1:45;
    thus ffs.a = (fffs).a
    proof
      per cases by A14,XBOOLE_0:def 3;
      suppose
        v in InputVertices S;
        hence thesis by CIRCUIT2:def 5;
      end;
      suppose
        v in InnerVertices S;
        then v in {[<*x,y*>,and2a], [<*y,c*>,and2], [<*x,c*>,and2a]} \/ {
        BorrowOutput(x,y,c)} by Th9;
        then
        v in {[<*x,y*>,and2a], [<*y,c*>,and2], [<*x,c*>,and2a]} or v in {
        BorrowOutput(x,y,c)} by XBOOLE_0:def 3;
        then v = [<*x,y*>,and2a] or v = [<*y,c*>,and2] or v = [<*x,c*>,and2a]
        or v = BorrowOutput(x,y,c) by ENUMSET1:def 1,TARSKI:def 1;
        hence thesis by A11,A10,A7,A4,A6,A3,A9,Lm1,Th13;
      end;
    end;
  end;
  dom Following Following(s,2) = the carrier of S & dom Following(s,2) =
  the carrier of S by CIRCUIT1:3;
  hence ffs = fffs by A12,FUNCT_1:2;
end;
