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;
reserve Rtfsm1, Rtfsm2 for reduced non empty Mealy-FSM over IAlph, OAlph;
reserve CRtfsm1, CRtfsm2 for connected reduced non empty Mealy-FSM over IAlph
  , OAlph,
  q1u, q2u for State of tfsm;
reserve CRtfsm1, CRtfsm2 for connected reduced finite non empty Mealy-FSM
  over IAlph, OAlph;

theorem Th65:
  Ctfsm1, Ctfsm2-are_equivalent implies the_reduction_of Ctfsm1,
  the_reduction_of Ctfsm2-are_isomorphic
proof
  assume
A1: Ctfsm1, Ctfsm2-are_equivalent;
  set rtfsm2 = the_reduction_of Ctfsm2;
  set rtfsm1 = the_reduction_of Ctfsm1;
  consider fsm1, fsm2 being finite non empty Mealy-FSM over IAlph, OAlph such
  that
A2: (the carrier of fsm1) misses (the carrier of fsm2) and
A3: fsm1,rtfsm1-are_isomorphic and
A4: fsm2,rtfsm2-are_isomorphic by Th62;
A5: rtfsm1,Ctfsm1-are_equivalent by Th41;
  set Srtfsm1 = the carrier of rtfsm1, Srtfsm2 = the carrier of rtfsm2;
  set ISrtfsm1= the InitS of rtfsm1, ISrtfsm2= the InitS of rtfsm2;
  set Sfsm1 = the carrier of fsm1, Sfsm2 = the carrier of fsm2;
  set ISfsm1= the InitS of fsm1, ISfsm2= the InitS of fsm2;
A6: rtfsm2,Ctfsm2-are_equivalent by Th41;
  fsm2,rtfsm2-are_equivalent by A4,Th63;
  then
A7: fsm2,Ctfsm2-are_equivalent by A6,Th15;
A8: fsm1 is connected
  proof
    assume not fsm1 is connected;
    then consider q1 being Element of Sfsm1 such that
A9: not q1 is accessible;
    consider Tf being Function of the carrier of fsm1, Srtfsm1 such that
A10: Tf is bijective and
A11: Tf.the InitS of fsm1 = ISrtfsm1 & for q being State of fsm1, s
    being Element of IAlph holds Tf.((the Tran of fsm1).(q, s)) = (the Tran of
rtfsm1).(Tf.q, s) & (the OFun of fsm1).(q, s) = (the OFun of rtfsm1).(Tf.q, s)
    by A3;
A12: dom Tf = Sfsm1 by FUNCT_2:def 1;
    set q = Tf.q1;
    q is accessible by Def22;
    then consider w being FinSequence of IAlph such that
A13: ISrtfsm1,w-leads_to q;
A14: 1 <= len w + 1 by NAT_1:11;
    then
    Tf.((ISfsm1,w)-admissible.(len w + 1)) = (ISrtfsm1,w)-admissible.(len
    w + 1) by A11,Th43;
    then
A15: Tf".(Tf.((ISfsm1,w)-admissible.(len w + 1))) = Tf".q by A13;
    len (ISfsm1,w)-admissible = len w + 1 by Def2;
    then len w + 1 in Seg (len (ISfsm1,w)-admissible) by A14,FINSEQ_1:1;
    then len w + 1 in dom (ISfsm1,w)-admissible by FINSEQ_1:def 3;
    then (the InitS of fsm1,w)-admissible.(len w + 1) in dom Tf by A12,
FINSEQ_2:11;
    then (ISfsm1,w)-admissible.(len w + 1) = Tf".(Tf.q1) by A10,A15,FUNCT_1:34
      .= q1 by A10,A12,FUNCT_1:34;
    then ISfsm1,w-leads_to q1;
    hence contradiction by A9;
  end;
A16: fsm2 is connected
  proof
    assume not fsm2 is connected;
    then consider q1 being Element of Sfsm2 such that
A17: not q1 is accessible;
    consider Tf being Function of Sfsm2, Srtfsm2 such that
A18: Tf is bijective and
A19: Tf.ISfsm2 = ISrtfsm2 & for q being State of fsm2, s being Element
of IAlph holds Tf.((the Tran of fsm2).(q, s)) = (the Tran of rtfsm2).(Tf.q, s)
    & (the OFun of fsm2).(q, s) = (the OFun of rtfsm2).(Tf.q, s) by A4;
A20: dom Tf = Sfsm2 by FUNCT_2:def 1;
    set q = Tf.q1;
    q is accessible by Def22;
    then consider w being FinSequence of IAlph such that
A21: ISrtfsm2,w-leads_to q;
A22: 1 <= len w + 1 by NAT_1:11;
    then
    Tf.((ISfsm2,w)-admissible.(len w + 1)) = (ISrtfsm2,w)-admissible.(len
    w + 1) by A19,Th43;
    then
A23: Tf".(Tf.((ISfsm2,w)-admissible.(len w + 1))) = Tf".q by A21;
    len (ISfsm2,w)-admissible = len w + 1 by Def2;
    then len w + 1 in Seg (len (ISfsm2,w)-admissible) by A22,FINSEQ_1:1;
    then len w + 1 in dom (ISfsm2,w)-admissible by FINSEQ_1:def 3;
    then (ISfsm2,w)-admissible.(len w + 1) in dom Tf by A20,FINSEQ_2:11;
    then (ISfsm2,w)-admissible.(len w + 1) = Tf".(Tf.q1) by A18,A23,FUNCT_1:34
      .= q1 by A18,A20,FUNCT_1:34;
    then ISfsm2,w-leads_to q1;
    hence contradiction by A17;
  end;
  fsm1,rtfsm1-are_equivalent by A3,Th63;
  then fsm1,Ctfsm1-are_equivalent by A5,Th15;
  then
A24: fsm1,Ctfsm2-are_equivalent by A1,Th15;
  reconsider fsm1, fsm2 as reduced finite non empty Mealy-FSM over IAlph,
  OAlph by A3,A4,Th47;
  fsm1, fsm2-are_isomorphic by A2,A8,A16,A7,A24,Th15,Th64;
  then fsm1,rtfsm2-are_isomorphic by A4,Th42;
  hence thesis by A3,Th42;
end;
