reserve x,y for Real,
  i, j for non zero Element of NAT,
  I, O for non empty set,
  s,s1,s2,s3 for Element of I,
  w, w1, w2 for FinSequence of I,
  t for Element of O,
  S for non empty FSM over I,
  q, q1 for State of S;
reserve n, m, o, p for non zero Element of NAT,
  M for non empty Moore-SM_Final over I, O,
  q for State of M;

theorem Th22:
  for X being non empty set for f being BinOp of X
  for M being non empty Moore-SM_Final over [:X, X:], succ X
  st M is calculating_type & the carrier of M = succ X & the FinalS of M = X &
  the InitS of M = X & the OFun of M = id the carrier of M &
  for x,y being Element of X holds
  (the Tran of M).[the InitS of M, [x,y]] = f.(x,y) holds M is halting &
  for x,y being Element of X holds f.(x,y) is_result_of [x,y], M
proof
  let X be non empty set, f be BinOp of X;
  let M be non empty Moore-SM_Final over [:X, X:], succ X;
  assume that
A1: M is calculating_type and
A2: the carrier of M = succ X and
A3: the FinalS of M = X and
A4: the InitS of M = X and
A5: the OFun of M = id the carrier of M and
A6: for x,y being Element of X holds (the Tran of M).[the InitS of M, [x
  ,y]] = f.(x,y);
A7: not the InitS of M in the FinalS of M by A3,A4;
  thus
A8: now
    let s be Element of [:X,X:];
    consider x,y being object such that
A9: x in X and
A10: y in X and
A11: s = [x,y] by ZFMISC_1:def 2;
    reconsider x,y as Element of X by A9,A10;
    thus s leads_to_final_state_of M
    proof
      reconsider q = f.(x,y) as State of M by A2,XBOOLE_0:def 3;
      take q;
      thus q is_accessible_via s
      proof
        take w = <*> [:X, X:];
        reconsider W = <*s*>^w as FinSequence of [:X, X:];
A12:    W = <*[x,y]*> by A11,FINSEQ_1:34;
        then len W = 1 by FINSEQ_1:39;
        then
A13:    ex WI being Element of [:X, X:], QI,QI1 being State of M st
( WI = W.1)&( QI = GEN(W, the InitS of M).1)&( QI1 = GEN(W, the InitS of M).(1+
        1))&( WI-succ_of QI = QI1) by FSM_1:def 2;
        GEN(W, the InitS of M).(len W + 1)
        = GEN(W, the InitS of M).(1+1) by A12,FINSEQ_1:39
          .= (the Tran of M).[the InitS of M, W.1] by A13,FSM_1:def 2
          .= (the Tran of M).[the InitS of M, [x,y]] by A11,FINSEQ_1:41
          .= f.(x,y) by A6;
        hence thesis;
      end;
      thus thesis by A3;
    end;
  end;
  let x,y be Element of X;
  consider m being non zero Element of NAT such that
A14: for w being FinSequence of [:X, X:] st len w+1 >= m & w.1 = [x,y] holds
  GEN(w, the InitS of M).m in the FinalS of M and
A15: for w being FinSequence of [:X, X:], i being non zero Element of NAT
  st i <= len w + 1 & w.1 = [x,y] & i < m holds
  not GEN(w, the InitS of M).i in the FinalS of M by A1,A8,Th18;
  take m;
  set s = [x,y], t = f.(x,y);
  let w being FinSequence of [:X, X:] such that
A16: w.1 = s;
  hereby
    assume
A17: m <= len w + 1;
    GEN(w, the InitS of M).1 = X by A4,FSM_1:def 2;
    then
A18: m <> 1 by A4,A7,A14,A16,A17;
    m >= 1 by NAT_1:14;
    then m > 1 by A18,XXREAL_0:1;
    then
A19: m >= 1+1 by NAT_1:13;
    then
A20: 1 + 1 <= len w + 1 by A17,XXREAL_0:2;
    then 1 <= len w by XREAL_1:6;
    then ex WI being Element of [:X, X:], QI, QI1 being State of M
st ( WI = w.1)&( QI = GEN(w, the InitS of M).1)&( QI1 = GEN(w, the InitS of M).
    (1+1))&( WI-succ_of QI = QI1) by FSM_1:def 2;
    then
A21: GEN(w, the InitS of M).2
    = (the Tran of M).[the InitS of M, w.1] by FSM_1:def 2
      .= f.(x,y) by A6,A16;
A22: m = 2 or m > 2 by A19,XXREAL_0:1;
    f.(x,y) in succ X by XBOOLE_0:def 3;
    hence t = (the OFun of M).(GEN(w, the InitS of M).m)
    by A2,A3,A5,A15,A16,A20,A21,A22,FUNCT_1:18;
    thus GEN(w, the InitS of M).m in the FinalS of M by A14,A16,A17;
  end;
  thus thesis by A15,A16;
end;
