Beispiel #1
0
    def startTRANSSemRule(self, lst, context=None):
        """

            :param lst:
            :param context:"""
        if self.TRtype is None:
            new = SFT()
        elif self.TRtype == "GFT":
            new = GFT()
        else:
            raise common.TRError
        new.Sigma = self.alphabet
        new.Output = self.alphabetOut
        while self.states:
            x = self.states.pop()
            new.addState(x)
        while self.initials:
            x = self.initials.pop()
            new.addInitial(new.stateIndex(x))
        while self.finals:
            x = self.finals.pop()
            new.addFinal(new.stateIndex(x))
        while self.transitions:
            (x1, x2, x3, x4) = self.transitions.pop()
            new.addTransition(new.stateIndex(x1), x2, x3, new.stateIndex(x4))
        self.theList.append(new)
        self.initLocal()
Beispiel #2
0
    def startTRANSSemRule(self, lst, context=None):
            """

            :param lst:
            :param context:"""
            if self.TRtype is None:
                new = SFT()
            elif self.TRtype == "GFT":
                new = GFT()
            else: raise common.TRError
            new.Sigma = self.alphabet
            new.Output = self.alphabetOut
            while self.states:
                x = self.states.pop()
                new.addState(x)
            while self.initials:
                x = self.initials.pop()
                new.addInitial(new.stateIndex(x))
            while self.finals:
                x = self.finals.pop()
                new.addFinal(new.stateIndex(x))
            while self.transitions:
                (x1, x2, x3, x4) = self.transitions.pop()
                new.addTransition(new.stateIndex(x1), x2, x3, new.stateIndex(x4))
            self.theList.append(new)
            self.initLocal()
Beispiel #3
0
def symmAndRefl(t, ipt=False):
    """ Return the  transducer      t | t.inverse,  if ipt is True;
        return the transducer  t | t.inverse | id,  otherwise

    :type t: SFT
    :type ipt: bool
    :rtype: SFT"""
    t1 = t | t.inverse()
    if ipt is True:
        return t1
    t2 = SFT()
    s0 = t2.addState()
    t2.addInitial(s0)
    t2.addFinal(s0)
    for sym in t.Sigma:
        t2.addTransition(s0, sym, sym, s0)
    return t1 | t2