
theorem
  for n being Nat for x,y being nonpair-yielding FinSeqLen of n
  for s being State of n-BitGFA0Circ(x,y) holds Following(s,1+2*n) is stable
proof
  let n be Nat, f,g be nonpair-yielding FinSeqLen of n;
  deffunc S(set,Nat) = BitGFA0Str(f.($2+1), g.($2+1), $1);
  deffunc A(set,Nat) = BitGFA0Circ(f.($2+1), g.($2+1), $1);
  deffunc o(set,Nat) = GFA0CarryOutput(f.($2+1), g.($2+1), $1);
  set S0 = 1GateCircStr(<*>, (0-tuples_on BOOLEAN)-->FALSE);
  set A0 = 1GateCircuit(<*>, (0-tuples_on BOOLEAN)-->FALSE);
  set h0 = [<*>, (0-tuples_on BOOLEAN)-->FALSE];
  set N = (1,2) followed_by In(n,NAT);
A1: N.0 = 1 by FUNCT_7:122;
A2: N.1 = 2 by FUNCT_7:123;
A3: N.2 = n  by FUNCT_7:124;
  deffunc n(Nat) = N.$1;
A4: for x being set, n being Nat holds
  A(x,n) is Boolean gate`2=den strict Circuit of S(x,n);
A5: now
    let s be State of A0;
    Following(s, 1) = Following s by FACIRC_1:14;
    hence Following(s, n(0)) is stable by A1,CIRCCMB2:2;
  end;
  deffunc F(Nat) = $1-BitGFA0CarryOutput(f,g);
  consider h being ManySortedSet of NAT such that
A6: for n being Element of NAT holds h.n = F(n) from PBOOLE:sch 5;
A7: for n being Nat, x being set
  for A being non-empty Circuit of S(x,n) st x = h.(n) & A = A(x,n)
  for s being State of A holds Following(s, n(1)) is stable
  proof
    set f1 = and2, f0 = xor2;
    let n be Nat, x be set, A be non-empty Circuit of S(x,n);
    assume
A8: x = h.n;
    n in NAT by ORDINAL1:def 12;
    then
A9: x = F(n) by A6,A8;
    then
A10: x <> [<*f.(n+1),g.(n+1)*>,f1] by Lm2;
    x <> [<*f.(n+1),g.(n+1)*>,f0] by A9,Lm2;
    hence thesis by A2,A10,GFACIRC1:40;
  end;
  set Sn = n-BitGFA0Str(f,g);
  set An = n-BitGFA0Circ(f,g);
  set o0 = 0-BitGFA0CarryOutput(f,g);
  consider f1,g1,h1 being ManySortedSet of NAT such that
A11: Sn = f1.n and
A12: An = g1.n and
A13: f1.0 = S0 and
A14: g1.0 = A0 and
A15: h1.0 = h0 and
A16: for n being Nat, S being non empty ManySortedSign, A being
  non-empty MSAlgebra over S for z being set st S = f1.n & A = g1.n & z = h1.n
  holds f1.(n+1) = S +* S(z,n) & g1.(n+1) = A +* A(z,n) & h1.(n+1) = o(z,n)
  by Def2;
  now
    let i be object;
    assume
A17: i in NAT;
    then reconsider j = i as Nat;
    thus h1.i = F(j) by A13,A14,A15,A16,Th1
      .= h.i by A6,A17;
  end;
  then
A18: h1 = h by PBOOLE:3;
A19: ex u,v being ManySortedSet of NAT st Sn = u.(n(2)) & An = v.(n(2)) &
  u.0 = S0 & v.0 = A0 & h.0 = o0 &
  for n being Nat, S being non empty ManySortedSign,
  A1 being non-empty MSAlgebra over S
  for x being set, A2 being non-empty MSAlgebra over S(x,n)
  st S = u.n & A1 = v.n & x = h.n & A2 = A(x,n)
  holds u.(n+1) = S +* S(x,n) & v.(n+1) = A1 +* A2 & h.(n+1) = o(x, n)
  proof
    take f1, g1;
    thus thesis by A3,A6,A11,A12,A13,A14,A16,A18;
  end;
A20: InnerVertices S0 is Relation & InputVertices S0 is without_pairs
  by FACIRC_1:38,39;
A21: o0 = h0 by Th2;
  InnerVertices S0 = {h0} by CIRCCOMB:42;
  then
A22: h.0 = o0 & o0 in InnerVertices S0 by A6,A21,TARSKI:def 1;
A23: for n being Nat, x being set holds
  InnerVertices S(x,n) is Relation by GFACIRC1:32;
A24: for n being Nat, x being set st x = h.n holds
  (InputVertices S(x, n)) \ {x} is without_pairs
  proof
    set f1 = and2, f0 = xor2;
    let n be Nat, x be set such that
A25: x = h.n;
    n in NAT by ORDINAL1:def 12;
    then
A26: x = F(n) by A6,A25;
    then
A27: x <> [<*f.(n+1),g.(n+1)*>,f1] by Lm2;
    x <> [<*f.(n+1),g.(n+1)*>,f0] by A26,Lm2;
    then
A28: InputVertices S(x, n) = {f.(n+1),g.(n+1),x} by A27,GFACIRC1:33;
    let a be pair object;
    assume
A29: a in (InputVertices S(x, n)) \ {x};
    then
A30: a in {f.(n+1),g.(n+1),x} by A28,XBOOLE_0:def 5;
A31: not a in {x} by A29,XBOOLE_0:def 5;
    a = f.(n+1) or a = g.(n+1) or a = x by A30,ENUMSET1:def 1;
    hence thesis by A31,TARSKI:def 1;
  end;
A32: for n being Nat, x being set st x = h.n holds h.(n+1) = o(x, n) &
  x in InputVertices S(x,n) & o(x, n) in InnerVertices S(x, n)
  proof
    set f1 = and2, f2 = and2, f3 = and2, f0 = xor2;
    let n be Nat, x be set such that
A33: x = h.n;
    n in NAT by ORDINAL1:def 12;
    then
A34: x = F(n) by A6,A33;
    h.(n+1) = F(n+1) by A6;
    hence h.(n+1) = o(x, n) by A34,Th7;
A35: x <> [<*f.(n+1),g.(n+1)*>,f1] by A34,Lm2;
    x <> [<*f.(n+1),g.(n+1)*>,f0] by A34,Lm2;
    then InputVertices S(x, n) = {f.(n+1),g.(n+1),x} by A35,GFACIRC1:33;
    hence x in InputVertices S(x, n) by ENUMSET1:def 1;
A36: InnerVertices S(x, n) = {[<*f.(n+1),g.(n+1)*>,f0]} \/
    {GFA0AdderOutput(f.(n+1),g.(n+1),x)} \/ {[<*f.(n+1),g.(n+1)*>,f1],
    [<*g.(n+1),x*>,f2], [<*x,f.(n+1)*>,f3]} \/
    {GFA0CarryOutput(f.(n+1),g.(n+1),x)} by GFACIRC1:31;
    o(x, n) in {o(x, n)} by TARSKI:def 1;
    hence thesis by A36,XBOOLE_0:def 3;
  end;
  for s being State of An holds Following(s,n(0)+n(2)*n(1)) is stable
  from CIRCCMB2:sch 22(A4,A5,A7,A19,A20,A22,A23,A24,A32);
  hence thesis by A1,A2,A3;
end;
