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 Th64:
  the carrier of CRtfsm1 misses the carrier of CRtfsm2 & CRtfsm1,
  CRtfsm2-are_equivalent implies CRtfsm1, CRtfsm2-are_isomorphic
proof
  set rtfsm1 = CRtfsm1;
  set rtfsm2 = CRtfsm2;
  assume that
A1: (the carrier of rtfsm1) misses (the carrier of rtfsm2) and
A2: rtfsm1, rtfsm2-are_equivalent;
  set Srtfsm2 = the carrier of rtfsm2;
  set Srtfsm1 = the carrier of rtfsm1;
  set UN = rtfsm1-Mealy_union rtfsm2;
  set RUN = the_reduction_of UN;
  set SRUN = the carrier of RUN;
  defpred P[object, object] means
   ex part being Element of SRUN st $1 in part & $2 in part \ { $1 };
A3: SRUN = final_states_partition UN by Def18;
A4: for x being object st x in Srtfsm1 ex y being object st P[x,y]
  proof
    let x be object;
    set xs = { x };
A5: union SRUN= the carrier of UN by A3,EQREL_1:def 4;
    assume
A6: x in Srtfsm1;
    then x in Srtfsm1 \/ Srtfsm2 by XBOOLE_0:def 3;
    then x in the carrier of UN by Def24;
    then consider part being set such that
A7: x in part and
A8: part in SRUN by A5,TARSKI:def 4;
    reconsider part as Element of SRUN by A8;
    consider p, y be Element of part such that
    p in Srtfsm1 and
A9: y in Srtfsm2 and
    for z being Element of part holds z = p or z = y by A1,A2,Th61;
    set IT = y;
    take IT;
    x <> y by A1,A6,A9,XBOOLE_0:3;
    then y in part \ xs by A7,ZFMISC_1:56;
    hence thesis by A7;
  end;
  consider f being Function such that
A10: dom f = Srtfsm1 & for x being object st x in Srtfsm1 holds P[x,f.x]
  from CLASSES1:sch 1 (A4 );
  now
    assume
A11: not rng f c= Srtfsm2 or not Srtfsm2 c= rng f;
    per cases by A11;
    suppose
      not rng f c= Srtfsm2;
      then consider y1 being object such that
A12:  y1 in rng f and
A13:  not y1 in Srtfsm2;
      consider x1 being object such that
A14:  x1 in Srtfsm1 and
A15:  y1 = f.x1 by A10,A12,FUNCT_1:def 3;
      consider part1 be Element of SRUN such that
A16:  x1 in part1 and
A17:  f.x1 in part1 \ { x1 } by A10,A14;
A18:  now
        assume
A19:    y1 in Srtfsm1;
        y1 <> x1 by A15,A17,ZFMISC_1:56;
        hence contradiction by A1,A14,A15,A16,A17,A19,Th59;
      end;
      part1 is Subset of UN by A3,TARSKI:def 3;
      then
A20:  part1 is Subset of Srtfsm1 \/ Srtfsm2 by Def24;
      y1 in part1 by A15,A17;
      hence contradiction by A13,A20,A18,XBOOLE_0:def 3;
    end;
    suppose
A21:  not Srtfsm2 c= rng f;
A22:  union SRUN = the carrier of UN by A3,EQREL_1:def 4;
      consider y1 being object such that
A23:  y1 in Srtfsm2 and
A24:  not y1 in rng f by A21;
      y1 in Srtfsm1 \/ Srtfsm2 by A23,XBOOLE_0:def 3;
      then y1 in the carrier of UN by Def24;
      then consider Z being set such that
A25:  y1 in Z and
A26:  Z in SRUN by A22,TARSKI:def 4;
      reconsider Z as Element of SRUN by A26;
A27:  Z is Subset of UN by A3,TARSKI:def 3;
      consider q1, q2 being Element of Z such that
A28:  q1 in Srtfsm1 and
      q2 in Srtfsm2 and
      for q being Element of Z holds q = q1 or q = q2 by A1,A2,Th61;
      consider F being Element of SRUN such that
A29:  q1 in F and
A30:  f.q1 in F \ {q1} by A10,A28;
      F is Subset of UN by A3,TARSKI:def 3;
      then
A31:  Z = F or Z misses F by A3,A27,EQREL_1:def 4;
A32:  f.q1 in F by A30;
      now
A33:    now
          assume
A34:      f.q1 in Srtfsm1;
          f.q1 <> q1 by A30,ZFMISC_1:56;
          hence contradiction by A1,A28,A29,A30,A34,Th59;
        end;
        Z is Subset of Srtfsm1 \/ Srtfsm2 by A27,Def24;
        then
A35:    f.q1 in Srtfsm1 or f.q1 in Srtfsm2 by A25,A29,A31,A32,XBOOLE_0:3,def 3;
        assume y1 <> f.q1;
        hence contradiction by A23,A25,A29,A30,A31,A35,A33,Th60,XBOOLE_0:3;
      end;
      hence contradiction by A10,A24,A28,FUNCT_1:def 3;
    end;
  end;
  then
A36: rng f = Srtfsm2;
A37: now
    let x1, x2 be object;
    assume that
A38: x1 in dom f and
A39: x2 in dom f and
A40: f.x1 = f.x2;
    consider part1 be Element of SRUN such that
A41: x1 in part1 & f.x1 in part1 \ { x1 } by A10,A38;
    consider part2 be Element of SRUN such that
A42: x2 in part2 & f.x2 in part2 \ { x2 } by A10,A39;
    assume
A43: x1 <> x2;
    part1 is Subset of UN & part2 is Subset of UN by A3,TARSKI:def 3;
    then part1 = part2 or part1 misses part2 by A3,EQREL_1:def 4;
    hence contradiction by A1,A10,A38,A39,A40,A43,A41,A42,Th59,XBOOLE_0:3;
  end;
  reconsider f as Function of Srtfsm1, Srtfsm2 by A10,A36,FUNCT_2:1;
A44: f.the InitS of rtfsm1 = the InitS of rtfsm2
  proof
    consider part being Element of SRUN such that
A45: the InitS of rtfsm1 in part & f.the InitS of rtfsm1 in part \ {
    the InitS of rtfsm1 } by A10;
    consider Q being Element of SRUN such that
A46: the InitS of rtfsm1 in Q & the InitS of rtfsm2 in Q and
    Q = the InitS of RUN by A1,A2,Th56;
    assume
A47: f.the InitS of rtfsm1 <> the InitS of rtfsm2;
    Q is Subset of UN & part is Subset of UN by A3,TARSKI:def 3;
    then Q = part or Q misses part by A3,EQREL_1:def 4;
    hence contradiction by A47,A46,A45,Th60,XBOOLE_0:3;
  end;
A48: for q being State of rtfsm1, s being Element of IAlph holds f.((the
Tran of rtfsm1).(q, s)) = (the Tran of rtfsm2).(f.q, s) & (the OFun of rtfsm1).
  (q,s) = (the OFun of rtfsm2).(f.q, s)
  proof
    let q be State of rtfsm1, s be Element of IAlph;
    set q1 = (the Tran of rtfsm1).[q,s], fq = f.q;
    set q2 = (the Tran of rtfsm2).[fq,s];
A49: dom (the Tran of rtfsm2) = [: Srtfsm2,IAlph :] by FUNCT_2:def 1;
A50: the carrier of UN = Srtfsm1 \/ Srtfsm2 by Def24;
    then reconsider q9 = q as Element of UN by XBOOLE_0:def 3;
    f.q in rng f by A10,FUNCT_1:def 3;
    then reconsider fq9 = f.q9 as Element of UN by A50,XBOOLE_0:def 3;
    set qu = (the Tran of UN).[q9,s], qfu = (the Tran of UN).[fq9,s];
A51: qfu = ((the Tran of rtfsm1)+*(the Tran of rtfsm2)).[fq9,s] by Def24
      .= q2 by A49,FUNCT_4:13;
    consider XX be Element of SRUN such that
A52: q1 in XX & f.q1 in XX \ { q1 } by A10;
A53: final_states_partition UN is final by Def15;
    ex part be Element of SRUN st q in part & f.q in part \ { q } by A10;
    then
A54: q9, fq9-are_equivalent by A3,A53;
    then qu,qfu-are_equivalent by Th19;
    then consider X being Element of SRUN such that
A55: qu in X & qfu in X by A3,A53;
A56: (the carrier of rtfsm1) /\ (the carrier of rtfsm2) = {} by A1;
A57: dom (the Tran of rtfsm1) = [: Srtfsm1,IAlph :] by FUNCT_2:def 1;
    then dom (the Tran of rtfsm1) /\ dom (the Tran of rtfsm2) = [: Srtfsm1,
    IAlph :] /\ [: Srtfsm2,IAlph :] by FUNCT_2:def 1
      .= [: {} ,IAlph :] by A56,ZFMISC_1:99
      .= {} by ZFMISC_1:90;
    then
A58: dom (the Tran of rtfsm1) misses dom (the Tran of rtfsm2);
A59: qu = ((the Tran of rtfsm1)+*(the Tran of rtfsm2)).[q9,s] by Def24
      .=q1 by A57,A58,FUNCT_4:16;
A60: X is Subset of UN by A3,TARSKI:def 3;
    now
      XX is Subset of UN by A3,TARSKI:def 3;
      then
A61:  X = XX or X misses XX by A3,A60,EQREL_1:def 4;
      assume f.q1 <> q2;
      hence contradiction by A55,A59,A51,A52,A61,Th60,XBOOLE_0:3;
    end;
    hence f.((the Tran of rtfsm1).(q, s)) = (the Tran of rtfsm2).(f.q, s);
A62: dom (the OFun of rtfsm2) = [: Srtfsm2,IAlph :] by FUNCT_2:def 1;
A63: dom (the OFun of rtfsm1) = [: Srtfsm1,IAlph :] by FUNCT_2:def 1;
    then dom (the OFun of rtfsm1) /\ dom (the OFun of rtfsm2) = [: Srtfsm1 /\
    Srtfsm2, IAlph :] by A62,ZFMISC_1:99
      .= {} by A56,ZFMISC_1:90;
    then dom (the OFun of rtfsm1) misses dom (the OFun of rtfsm2);
    hence (the OFun of rtfsm1).(q,s) = ((the OFun of rtfsm1) +* (the OFun of
    rtfsm2)).[q,s] by A63,FUNCT_4:16
      .= (the OFun of UN).[q9,s] by Def24
      .= (the OFun of UN).[fq9,s] by A54,Th19
      .= ((the OFun of rtfsm1) +* (the OFun of rtfsm2)).[f.q,s] by Def24
      .= (the OFun of rtfsm2).(f.q, s) by A62,FUNCT_4:13;
  end;
  f is one-to-one onto by A37,A36,FUNCT_1:def 4,FUNCT_2:def 3;
  hence thesis by A44,A48;
end;
