src/main/java/de/dfki/lt/loot/fsa/FiniteAutomaton.java
public boolean isEquivalent(FiniteAutomaton<EdgeInfo> aut) {

    // get the complement of this automaton
    FiniteAutomaton<EdgeInfo> complement = this.complement();
    // change the complement so that it has only ONE final state
    int newFinalState = complement.newVertex();
    int currentFinalState = -1;
    while ((currentFinalState = complement._finalStates.nextSetBit(currentFinalState + 1)) != -1) {
      complement.newEdge(EPSILON, currentFinalState, newFinalState);
    }
    complement._finalStates.clear();
    complement.setFinalState(newFinalState);
    // get the corresponding sub automaton
    SubAutomaton subComplement =
      new SubAutomaton(complement.getInitialState(), newFinalState);

    // add the other automaton
    SubAutomaton subAut = complement.addAutomaton(aut);

    // create union
    complement.alternative(subComplement, subAut);

    // determinize and finalize automaton
    complement.setInitialState(subComplement.getInitialState());
    complement._finalStates.clear();
    complement.setFinalState(subComplement.getFinalState());

    FiniteAutomaton<EdgeInfo> detAut = new FiniteAutomaton<EdgeInfo>();
    detAut._comp = this._comp;
    Determinization.determinize(complement, this._comp, detAut);
    // TODO activate again when minimization is working correctly
    //Minimization.minimize(detAut, this._comp);

    // automaton are equivalent if resulting automaton accepts everything
    return detAut.acceptsAll();
  }
/**
   * Checks if this automaton accepts the same language as the given automaton.
   *
   * @param aut
   *          a finite automaton
   * @return a flag indicating equivalence
   */
Checks if this automaton accepts the same language as the given automaton.
@param aut
a finite automaton
@return a flag indicating equivalence
Checks if this automaton accepts the same language as the given automaton . @param aut a finite automaton @return a flag indicating equivalence
public boolean isEquivalent(FiniteAutomaton<EdgeInfo> aut) {
    FiniteAutomaton<EdgeInfo> complement = this.complement();
    int newFinalState = complement.newVertex();
    int currentFinalState = -1;
    while ((currentFinalState = complement._finalStates.nextSetBit(currentFinalState + 1)) != -1) {
      complement.newEdge(EPSILON, currentFinalState, newFinalState);
    }
    complement._finalStates.clear();
    complement.setFinalState(newFinalState);
    SubAutomaton subComplement =
      new SubAutomaton(complement.getInitialState(), newFinalState);
    SubAutomaton subAut = complement.addAutomaton(aut);
    complement.alternative(subComplement, subAut);
    complement.setInitialState(subComplement.getInitialState());
    complement._finalStates.clear();
    complement.setFinalState(subComplement.getFinalState());
    FiniteAutomaton<EdgeInfo> detAut = new FiniteAutomaton<EdgeInfo>();
    detAut._comp = this._comp;
    Determinization.determinize(complement, this._comp, detAut);
    return detAut.acceptsAll();
  }
public boolean isEquivalent ( FiniteAutomaton < EdgeInfo > aut ) { FiniteAutomaton < EdgeInfo > complement = this . complement ( ) ; int newFinalState = complement . newVertex ( ) ; int currentFinalState = - 1 ; while ( ( currentFinalState = complement . _finalStates . nextSetBit ( currentFinalState + 1 ) ) != - 1 ) { complement . newEdge ( EPSILON , currentFinalState , newFinalState ) ; } complement . _finalStates . clear ( ) ; complement . setFinalState ( newFinalState ) ; SubAutomaton subComplement = new SubAutomaton ( complement . getInitialState ( ) , newFinalState ) ; SubAutomaton subAut = complement . addAutomaton ( aut ) ; complement . alternative ( subComplement , subAut ) ; complement . setInitialState ( subComplement . getInitialState ( ) ) ; complement . _finalStates . clear ( ) ; complement . setFinalState ( subComplement . getFinalState ( ) ) ; FiniteAutomaton < EdgeInfo > detAut = new FiniteAutomaton < EdgeInfo > ( ) ; detAut . _comp = this . _comp ; Determinization . determinize ( complement , this . _comp , detAut ) ; return detAut . acceptsAll ( ) ; }
Checks if this automaton accepts the same language as the given automaton.
Checks if this automaton accepts the same language as the given automaton .
// get the complement of this automaton // change the complement so that it has only ONE final state // get the corresponding sub automaton // add the other automaton // create union // determinize and finalize automaton // TODO activate again when minimization is working correctly //Minimization.minimize(detAut, this._comp); // automaton are equivalent if resulting automaton accepts everything