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 Th61:
  the carrier of CRtfsm1 misses the carrier of CRtfsm2 & CRtfsm1,
CRtfsm2-are_equivalent & tfsm = CRtfsm1-Mealy_union CRtfsm2 implies for Q being
  State of the_reduction_of tfsm ex q1, q2 being Element of Q st q1 in the
  carrier of CRtfsm1 & q2 in the carrier of CRtfsm2 & for q being Element of Q
  holds q = q1 or q = q2
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 and
A3: tfsm = rtfsm1-Mealy_union rtfsm2;
  set ISrtfsm2 = the InitS of rtfsm2;
  set ISrtfsm1 = the InitS of rtfsm1;
A4: (the carrier of rtfsm1) /\ (the carrier of rtfsm2) = {} by A1;
  set Stfsm = the carrier of tfsm;
  set Srtfsm2 = the carrier of rtfsm2;
  set Srtfsm1 = the carrier of rtfsm1;
  set rtfsm = the_reduction_of tfsm;
  set Srtfsm = the carrier of rtfsm;
  assume not thesis;
  then consider Q be Element of the_reduction_of tfsm such that
A5: for q1, q2 being Element of Q holds not q1 in the carrier of rtfsm1
or not q2 in the carrier of rtfsm2 or not for q being Element of Q holds q = q1
  or q = q2;
A6: Srtfsm = final_states_partition tfsm by Def18;
  then reconsider Q as Subset of Stfsm by TARSKI:def 3;
  union final_states_partition tfsm = Stfsm by EQREL_1:def 4
    .= Srtfsm1 \/ Srtfsm2 by A3,Def24;
  then
A7: Q c= Srtfsm1 \/ Srtfsm2 by A6,ZFMISC_1:74;
  Q in Srtfsm;
  then
A8: Q in final_states_partition tfsm by Def18;
  then
A9: Q <> {};
  then consider q being Element of Stfsm such that
A10: q in Q by SUBSET_1:4;
  per cases by A10,A7,XBOOLE_0:def 3;
  suppose
A11: q in Srtfsm1;
    set Q9 = Q \ {q};
A12: now
A13:  Q9 c= Q by XBOOLE_1:36;
      reconsider Q as Subset of Stfsm;
      assume
A14:  Q9 <> {};
      reconsider Q9 as Subset of Stfsm;
      consider x being Element of Stfsm such that
A15:  x in Q9 by A14,SUBSET_1:4;
A16:  Q9 c= Srtfsm1 \/ Srtfsm2 by A7,A13;
      per cases by A15,A16,XBOOLE_0:def 3;
      suppose
A17:    x in Srtfsm1;
        reconsider x as Element of Q by A15,XBOOLE_0:def 5;
        reconsider q as Element of Q by A10;
        not q in Srtfsm1 or not x in Srtfsm1 or q = x by A1,A3,Th59;
        hence contradiction by A11,A15,A17,ZFMISC_1:56;
      end;
      suppose
A18:    x in Srtfsm2;
        set Q99 = Q9 \ {x};
A19:    now
A20:      Q99 c= Q9 by XBOOLE_1:36;
          reconsider Q9 as Subset of Stfsm;
          assume
A21:      Q99 <> {};
          reconsider Q99 as Subset of Stfsm;
          consider y being Element of Stfsm such that
A22:      y in Q99 by A21,SUBSET_1:4;
A23:      Q99 c= Srtfsm1 \/ Srtfsm2 by A16,A20;
          per cases by A22,A23,XBOOLE_0:def 3;
          suppose
A24:        y in Srtfsm1;
            reconsider q as Element of Q by A10;
A25:        y in Q9 by A22,ZFMISC_1:56;
            then reconsider y as Element of Q by ZFMISC_1:56;
            not q in Srtfsm1 or not y in Srtfsm1 or q = y by A1,A3,Th59;
            hence contradiction by A11,A24,A25,ZFMISC_1:56;
          end;
          suppose
A26:        y in Srtfsm2;
            reconsider x as Element of Q by A15,ZFMISC_1:56;
            y in Q9 by A22,ZFMISC_1:56;
            then reconsider y as Element of Q by ZFMISC_1:56;
            not x in Srtfsm2 or not y in Srtfsm2 or x = y by A3,Th60;
            hence contradiction by A18,A22,A26,ZFMISC_1:56;
          end;
        end;
        now
          assume
A27:      Q99 = {};
A28:      for z being Element of Q holds z = q or z = x
          proof
            given z being Element of Q such that
A29:        z <> q and
A30:        z <> x;
            z in Q9 by A9,A29,ZFMISC_1:56;
            hence contradiction by A27,A30,ZFMISC_1:56;
          end;
          reconsider x as Element of Q by A15,ZFMISC_1:56;
          reconsider q as Element of Q by A10;
          not q in Srtfsm1 or not x in Srtfsm2 or ex z being Element of Q
          st z <> q & z <> x by A5;
          hence contradiction by A11,A18,A28;
        end;
        hence contradiction by A19;
      end;
    end;
    now
      reconsider q as Element of Srtfsm1 by A11;
      q is accessible by Def22;
      then consider w be FinSequence of IAlph such that
A31:  ISrtfsm1, w-leads_to q;
      set adl = ISrtfsm2 leads_to_under w;
A32:  now
        reconsider q as Element of Stfsm;
        assume
A33:    not adl in Q;
        reconsider q1 = q as Element of Srtfsm1;
        adl in Srtfsm1 \/ Srtfsm2 by XBOOLE_0:def 3;
        then reconsider adl as Element of Stfsm by A3,Def24;
A34:    not ex Y being Element of Srtfsm st q in Y & adl in Y
        proof
          reconsider Q as Subset of Stfsm;
          assume not thesis;
          then consider Y be Element of Srtfsm such that
A35:      q in Y and
A36:      adl in Y;
          reconsider Y as Subset of Stfsm by A6,TARSKI:def 3;
          Y in Srtfsm;
          then Y in final_states_partition tfsm by Def18;
          then Y misses Q by A8,A33,A36,EQREL_1:def 4;
          hence contradiction by A10,A35,XBOOLE_0:3;
        end;
        reconsider adl2 = adl as Element of Srtfsm2;
        final_states_partition tfsm is final by Def15;
        then not q, adl-are_equivalent by A6,A34;
        then consider dseq being FinSequence of IAlph such that
A37:    (q,dseq)-response <> (adl,dseq)-response;
        (q,dseq)-response = (q1,dseq)-response by A1,A3,Th53;
        then
A38:    (q1,dseq)-response <> (adl2,dseq)-response by A3,A37,Th55;
        ISrtfsm2, w -leads_to adl2 by Def5;
        then (ISrtfsm1,w^dseq)-response <> (ISrtfsm2,w^dseq)-response by A31
,A38,Th12;
        hence contradiction by A2;
      end;
      assume
A39:  Q9 = {};
      now
        assume
A40:    adl in Q;
        adl <> q by A4,XBOOLE_0:def 4;
        hence contradiction by A39,A40,ZFMISC_1:56;
      end;
      hence contradiction by A32;
    end;
    hence contradiction by A12;
  end;
  suppose
A41: q in Srtfsm2;
    set Q9 = Q \ {q};
A42: now
A43:  Q9 c= Q by XBOOLE_1:36;
      reconsider Q as Subset of Stfsm;
      assume
A44:  Q9 <> {};
      reconsider Q9 as Subset of Stfsm;
      consider x being Element of Stfsm such that
A45:  x in Q9 by A44,SUBSET_1:4;
A46:  Q9 c= Srtfsm1 \/ Srtfsm2 by A7,A43;
      per cases by A45,A46,XBOOLE_0:def 3;
      suppose
A47:    x in Srtfsm1;
        set Q99 = Q9 \ {x};
A48:    now
A49:      Q99 c= Q9 by XBOOLE_1:36;
          reconsider Q9 as Subset of Stfsm;
          assume
A50:      Q99 <> {};
          reconsider Q99 as Subset of Stfsm;
          consider y being Element of Stfsm such that
A51:      y in Q99 by A50,SUBSET_1:4;
A52:      Q99 c= Srtfsm1 \/ Srtfsm2 by A46,A49;
          per cases by A51,A52,XBOOLE_0:def 3;
          suppose
A53:        y in Srtfsm1;
            reconsider x as Element of Q by A45,ZFMISC_1:56;
            y in Q9 by A51,ZFMISC_1:56;
            then reconsider y as Element of Q by ZFMISC_1:56;
            not x in Srtfsm1 or not y in Srtfsm1 or x = y by A1,A3,Th59;
            hence contradiction by A47,A51,A53,ZFMISC_1:56;
          end;
          suppose
A54:        y in Srtfsm2;
            reconsider q as Element of Q by A10;
A55:        y in Q9 by A51,ZFMISC_1:56;
            then reconsider y as Element of Q by ZFMISC_1:56;
            not q in Srtfsm2 or not y in Srtfsm2 or q = y by A3,Th60;
            hence contradiction by A41,A54,A55,ZFMISC_1:56;
          end;
        end;
        now
          assume
A56:      Q99 = {};
A57:      for z being Element of Q holds z = q or z = x
          proof
            given z being Element of Q such that
A58:        z <> q and
A59:        z <> x;
            z in Q9 by A9,A58,ZFMISC_1:56;
            hence contradiction by A56,A59,ZFMISC_1:56;
          end;
          reconsider x as Element of Q by A45,ZFMISC_1:56;
          reconsider q as Element of Q by A10;
          not x in Srtfsm1 or not q in Srtfsm2 or ex z being Element of
          Q st z <> x & z <> q by A5;
          hence contradiction by A41,A47,A57;
        end;
        hence contradiction by A48;
      end;
      suppose
A60:    x in Srtfsm2;
        reconsider x as Element of Q by A45,XBOOLE_0:def 5;
        reconsider q as Element of Q by A10;
        not q in Srtfsm2 or not x in Srtfsm2 or q = x by A3,Th60;
        hence contradiction by A41,A45,A60,ZFMISC_1:56;
      end;
    end;
    now
      reconsider q as Element of Srtfsm2 by A41;
      q is accessible by Def22;
      then consider w be FinSequence of IAlph such that
A61:  ISrtfsm2, w-leads_to q;
      set adl = ISrtfsm1 leads_to_under w;
A62:  now
        reconsider q as Element of Stfsm;
        assume
A63:    not adl in Q;
        reconsider q1 = q as Element of Srtfsm2;
        adl in Srtfsm1 \/ Srtfsm2 by XBOOLE_0:def 3;
        then reconsider adl as Element of Stfsm by A3,Def24;
A64:    not ex Y being Element of Srtfsm st q in Y & adl in Y
        proof
          assume not thesis;
          then consider Y be Element of Srtfsm such that
A65:      q in Y and
A66:      adl in Y;
          reconsider Y as Subset of Stfsm by A6,TARSKI:def 3;
          Y in Srtfsm;
          then Y in final_states_partition tfsm by Def18;
          then Y misses Q by A8,A63,A66,EQREL_1:def 4;
          hence contradiction by A10,A65,XBOOLE_0:3;
        end;
        reconsider adl2 = adl as Element of Srtfsm1;
        final_states_partition tfsm is final by Def15;
        then not q, adl-are_equivalent by A6,A64;
        then consider dseq being FinSequence of IAlph such that
A67:    (q,dseq)-response <> (adl,dseq)-response;
        (q,dseq)-response = (q1,dseq)-response by A3,Th55;
        then
A68:    (q1,dseq)-response <> (adl2,dseq)-response by A1,A3,A67,Th53;
        ISrtfsm1, w -leads_to adl2 by Def5;
        then (ISrtfsm2,w^dseq)-response <> (ISrtfsm1,w^dseq)-response by A61
,A68,Th12;
        hence contradiction by A2;
      end;
      assume
A69:  Q9 = {};
      now
        assume
A70:    adl in Q;
        adl <> q by A1,XBOOLE_0:3;
        hence contradiction by A69,A70,ZFMISC_1:56;
      end;
      hence contradiction by A62;
    end;
    hence contradiction by A42;
  end;
end;
