コード例 #1
0
def revFibonnacci(n):
    a = DFA()
    a.setSigma(["a", "b"]),
    for i in range(n):
        a.addState(i)
    a.setInitial(0)
    for i in range(n):
        if i % 2 != 0:
            if i < n - 1:
                a.addTransition(i, 'b', i + 1)
            if i < n - 2:
                a.addTransition(i, 'a', i + 2)
        else:
            if i < n - 2:
                a.addTransition(i, 'b', i + 2)
            if i < n - 1:
                a.addTransition(i, 'a', i + 1)
    a.addFinal(n - 1)
    return a
コード例 #2
0
def emptyDFA(sigma=None):
    """
    Returns the minimal DFA for emptyset (incomplete)

    :param sigma:
    :return:
    """
    d = DFA()
    if sigma is not None:
        d.setSigma(sigma)
    i = d.addState()
    d.setInitial(i)
    return d
コード例 #3
0
ファイル: fio.py プロジェクト: mebusy/codeLib
    def startDFASemRule(self, lst, context=None):
        """


        :param context:
        :param lst:
        :param context:"""
        new = DFA()
        while self.states:
            x = self.states.pop()
            new.addState(x)
        new.Sigma = self.alphabet
        x = self.initials.pop()
        new.setInitial(new.stateIndex(x))
        while self.finals:
            x = self.finals.pop()
            new.addFinal(new.stateIndex(x))
        while self.transitions:
            (x1, x2, x3) = self.transitions.pop()
            new.addTransition(new.stateIndex(x1), x2, new.stateIndex(x3))
        self.theList.append(new)
        self.initLocal()
コード例 #4
0
ファイル: fio.py プロジェクト: FakerKimg/regexor
    def startDFASemRule(self, lst, context=None):
        """


        :param context:
        :param lst:
        :param context:"""
        new = DFA()
        while self.states:
            x = self.states.pop()
            new.addState(x)
        new.Sigma = self.alphabet
        x = self.initials.pop()
        new.setInitial(new.stateIndex(x))
        while self.finals:
            x = self.finals.pop()
            new.addFinal(new.stateIndex(x))
        while self.transitions:
            (x1, x2, x3) = self.transitions.pop()
            new.addTransition(new.stateIndex(x1), x2, new.stateIndex(x3))
        self.theList.append(new)
        self.initLocal()
コード例 #5
0
def epsilonDFA(sigma=None):
    """
    Returns the minimal DFA for {epsilon} (incomplete)

    :param sigma:
    :return:
    """
    d = DFA()
    if sigma is not None:
        d.setSigma(sigma)
    i = d.addState()
    d.setInitial(i)
    d.addFinal(i)
    return d