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 Th20:
  M is calculating_type & s leads_to_final_state_of M
  implies ex t st t is_result_of s, M
proof
  assume that
A1: M is calculating_type and
A2: s leads_to_final_state_of M;
  consider q such that
A3: q is_accessible_via s and
A4: q in the FinalS of M by A2;
  consider w such that
A5: the InitS of M,<*s*>^w-leads_to q by A3;
A6: GEN(<*s*>^w, the InitS of M).(len(<*s*>^w)+1) = q by A5;
  consider m being non zero Element of NAT such that
A7: for w st len w+1 >= m & w.1 = s holds GEN(w, the InitS of M).m in the
  FinalS of M and
A8: for w,j st j <= len w +1 & w.1 = s & j < m holds not GEN(w, the
  InitS of M).j in the FinalS of M
  by A1,A2,Th18;
A9: (<*s*>^w).1 = s by FINSEQ_1:41;
  then
A10: len(<*s*>^w)+1 >= m by A4,A6,A8;
  then GEN(<*s*>^w, the InitS of M).m in the FinalS of M by A7,A9;
  then reconsider t = (the OFun of M).(GEN(<*s*>^w, the InitS of M).m)
  as Element of O by FUNCT_2:5;
  take t, m;
  let w1 such that
A11: w1.1=s;
  (<*s*>^w).1 = s by FINSEQ_1:41;
  hence m <= len w1+1 implies t = (the OFun of M).(GEN(w1, the InitS of M).m) &
  GEN(w1, the InitS of M).m in the FinalS of M by A1,A7,A10,A11;
  thus thesis by A8,A11;
end;
