reserve A for preIfWhileAlgebra;
reserve A for Euclidean preIfWhileAlgebra;
reserve X for non empty countable set;
reserve T for Subset of Funcs(X, INT);
reserve f for Euclidean ExecutionFunction of A, Funcs(X, INT), T;
reserve A for Euclidean preIfWhileAlgebra,
  X for non empty countable set,
   z for (Element of X),
  s,s9 for (Element of Funcs(X, INT)),
  T for Subset of Funcs(X, INT),
  f for Euclidean ExecutionFunction of A, Funcs(X, INT), T,
  v for INT-Variable of A,f,
  t for INT-Expression of A,f;
reserve i for Integer;
reserve b for (Element of X),
  g for Euclidean ExecutionFunction of A, Funcs(X, INT), Funcs(X, INT)\(b,0);

theorem
  for n,x,y,z,i being Variable of g st ex d being Function st d.b = 0 &
d.n = 1 & d.x = 2 & d.y = 3 & d.z = 4 & d.i = 5 holds x:=0\;y:=1\;for-do(i:=1,
  i leq n, i+=1, z:=x\;x:=y\;y+=z) is_terminating_wrt g
proof
  set S = Funcs(X, INT);
  set T = S\(b,0);
  let n,x,y,z,i be Variable of g;
  given d being Function such that
A1: d.b = 0 and
A2: d.n = 1 and
A3: d.x = 2 and
A4: d.y = 3 and
A5: d.z = 4 and
A6: d.i = 5;
A7: i <> y by A4,A6;
A8: n <> z by A2,A5;
A9: n <> y by A2,A4;
A10: n <> x by A2,A3;
A11: i <> z by A5,A6;
  set I = z:=x\;x:=y\;y+=z;
  set I1 = z:=x, I2 = x:=y, I3 = y+=z;
A12: i <> x by A3,A6;
A13: for q be Element of S holds g.(q,I).n = q.n & g.(q,I).i = q.i
  proof
    let q be Element of S;
    thus g.(q,I).n = g.(g.(q,I1\;I2),I3).n by AOFA_000:def 29
      .= g.(q,I1\;I2).n by A9,Th30
      .= g.(g.(q,I1),I2).n by AOFA_000:def 29
      .= g.(q,I1).n by A10,Th27
      .= q.n by A8,Th27;
    thus g.(q,I).i = g.(g.(q,I1\;I2),I3).i by AOFA_000:def 29
      .= g.(q,I1\;I2).i by A7,Th30
      .= g.(g.(q,I1),I2).i by AOFA_000:def 29
      .= g.(q,I1).i by A12,Th27
      .= q.i by A11,Th27;
  end;
  let s;
  set s2 = g.(s, x:=0\;y:=1);
  i <> n by A2,A6;
  then ex d9 being Function st d9.b = 0 & d9.n = 1 & d9.i = 2 by A1,A2,A6,Th1;
  then for-do(i:=1, i leq n, i+=1, z:=x\;x:=y\;y+=z) is_terminating_wrt g by
A13,Th54,AOFA_000:104;
  then
A14: [s2, for-do(i:=1, i leq n, i+=1, z:=x\;x:=y\;y+=z)] in
  TerminatingPrograms(A,S,T,g);
  [s, x:=0\;y:=1] in TerminatingPrograms(A,S,T,g) by AOFA_000:def 36;
  hence thesis by A14,AOFA_000:def 35;
end;
