reserve m, n, i, k for Nat;
reserve IAlph, OAlph for non empty set,
  fsm for non empty FSM over IAlph,
  s for Element of IAlph,
  w, w1, w2 for FinSequence of IAlph,
  q, q9, q1, q2 for State of fsm;
reserve tfsm, tfsm1, tfsm2, tfsm3 for non empty Mealy-FSM over IAlph, OAlph,
  sfsm for non empty Moore-FSM over IAlph, OAlph,
  qs for State of sfsm,
  q, q1, q2 , q3, qa, qb, qc, qa9, qt, q1t, q2t for State of tfsm,
  q11, q12 for State of tfsm1,
  q21, q22 for State of tfsm2;
reserve OAlphf for finite non empty set,
  tfsmf for finite non empty Mealy-FSM over IAlph, OAlphf,
  sfsmf for finite non empty Moore-FSM over IAlph, OAlphf;
reserve tfsm, rtfsm for finite non empty Mealy-FSM over IAlph, OAlph,
  q for State of tfsm;
reserve qr1, qr2 for State of rtfsm,
  Tf for Function of the carrier of tfsm1, the carrier of tfsm2;
reserve Rtfsm for reduced finite non empty Mealy-FSM over IAlph, OAlph;
reserve Ctfsm, Ctfsm1, Ctfsm2 for connected finite non empty Mealy-FSM over
  IAlph, OAlph;

theorem
  for cTran being Function of [:accessibleStates tfsm, IAlph:],
accessibleStates tfsm, cOFun being Function of [:accessibleStates tfsm, IAlph:]
, OAlph, cInitS being Element of accessibleStates tfsm st cTran = (the Tran of
  tfsm) | [:accessibleStates tfsm, IAlph:] & cOFun = (the OFun of tfsm) | [:
  accessibleStates tfsm, IAlph:] & cInitS = the InitS of tfsm holds tfsm,
  Mealy-FSM(#accessibleStates tfsm, cTran, cOFun, cInitS#) -are_equivalent
proof
  set M = tfsm;
  let cTran be Function of [:accessibleStates M, IAlph:], accessibleStates M,
cOFun be Function of [:accessibleStates M, IAlph:], OAlph, cInitS be Element of
  accessibleStates M such that
A1: cTran = (the Tran of M) | [:accessibleStates M, IAlph:] and
A2: cOFun = (the OFun of M) | [:accessibleStates M, IAlph:] and
A3: cInitS = the InitS of M;
  let w be FinSequence of IAlph;
  set cm = Mealy-FSM(#accessibleStates M, cTran, cOFun, cInitS#);
  set ma= (the InitS of M,w)-admissible;
  set cma= (the InitS of cm, w)-admissible;
  set mr = (the InitS of M, w)-response;
  set cmr = (the InitS of cm, w)-response;
A4: now
    defpred P[Nat] means $1 in dom ma implies ma.$1 = cma.$1;
    thus len ma = len w + 1 & len cma = len w + 1 by Def2;
    then
A5: dom ma = Seg(len w + 1) by FINSEQ_1:def 3;
A6: for k being Nat st P[k] holds P[k + 1]
    proof
      let j be Nat such that
A7:   j in dom ma implies ma.j = cma.j;
A8:   0=j or 0<j & 0+1=1;
      assume j+1 in dom ma;
      then
A9:   j+1<=len w + 1 by A5,FINSEQ_1:1;
      then
A10:  j<=len w by XREAL_1:6;
A11:  j<len w +1 by A9,NAT_1:13;
      per cases by A8,NAT_1:13;
      suppose
A12:    0 = j;
        hence ma.(j+1) = the InitS of M by Def2
          .= cma.(j+1) by A3,A12,Def2;
      end;
      suppose
A13:    1 <= j;
        then (ex mwj being Element of IAlph, mqj,mqj1 being State of M st mwj
= w.j & mqj = ma.j & mqj1 = ma.(j+1) & mwj-succ_of mqj = mqj1 )& ex cmwj being
Element of IAlph,cmqj,cmqj1 being State of cm st cmwj = w.j & cmqj = cma.j &
        cmqj1 = cma.(j+1) & cmwj-succ_of cmqj=cmqj1 by A10,Def2;
        hence thesis by A1,A5,A7,A11,A13,FINSEQ_1:1,FUNCT_1:49;
      end;
    end;
A14: P[0] by A5,FINSEQ_1:1;
    thus for j be Nat holds P[j] from NAT_1:sch 2(A14, A6);
  end;
  then
A15: ma = cma by FINSEQ_2:9;
  now
    thus len mr = len w & len cmr = len w by Def6;
    then
A16: dom mr = Seg len w by FINSEQ_1:def 3;
    let j be Nat;
    assume
A17: j in dom mr;
    then
A18: j in dom w by A16,FINSEQ_1:def 3;
    j in Seg (len w + 1) by A16,A17,FINSEQ_2:8;
    then j in dom cma by A4,FINSEQ_1:def 3;
    then
A19: cma.j in accessibleStates M by FINSEQ_2:11;
    w.j in IAlph by A18,FINSEQ_2:11;
    then
A20: [cma.j, w.j] in [:accessibleStates M, IAlph:] by A19,ZFMISC_1:87;
    thus mr.j = (the OFun of M).[ma.j, w.j] by A18,Def6
      .= cOFun.[cma.j, w.j] by A2,A15,A20,FUNCT_1:49
      .= cmr.j by A18,Def6;
  end;
  hence thesis by FINSEQ_2:9;
end;
