Ejemplo n.º 1
0
# t3 : Transition 
t3 = Transition(s1,"a",s2)
# t4 : Transition
t4 = Transition(s1,"b",s2)
# t5 : Transition
t5 = Transition(s2,"a",s0)
# t6 : Transition
t6 = Transition(s2,"b",s1)

## création de l'automate
# auto,auto1 : Automate
auto = Automate([t1,t2,t3,t4,t5,t6])
auto1 = Automate([t1,t2,t3,t4,t5,t6],[s0,s1,s2])

print(auto)
auto.show("A_ListeTrans")
print(auto1)
auto1.show("A1_ListeTrans")
## auto est bien indentique à auto1

# auto2 : Automate
auto2 = Automate.creationAutomate("auto2.txt")
print(auto2)
auto2.show("A2_listeTrans")

# t : Transition
t = Transition(s0,"a",s1)
auto.removeTransition(t)
print(auto)
auto.removeTransition(t1)
print(auto)
Ejemplo n.º 2
0
from transition import Transition
from parser import *
#from essai import Essai

#import projet

print("DEBUT PROGRAMME\n")

s = State(1, False, False)
s2 = State(1, True, False)
t = Transition(s, "a", s)
t2 = Transition(s, "a", s2)
s.insertPrefix(2)
a = Automate([t, t2])
a.prefixStates(3)
a.show("justep")
"""
print "etat s " + s.id
print "s "+ str(s)
print "t "+ str(t)
print "a "+ str(a)
"""

print("s=s2? " + str(s == s2))
print("t=t2? " + str(t == t2))

s1 = State(1, True, False)
s2 = State(2, False, True)
t1 = Transition(s1, "a", s1)
t2 = Transition(s1, "a", s2)
t3 = Transition(s1, "b", s2)
Ejemplo n.º 3
0
s2_5 = State(2, False, True)
t1_5 = Transition(s0_5, "a", s0_5)
t2_5 = Transition(s0_5, "b", s0_5)
t3_5 = Transition(s0_5, "a", s1_5)
t4_5 = Transition(s1_5, "b", s2_5)
t5_5 = Transition(s2_5, "a", s2_5)
t6_5 = Transition(s2_5, "b", s2_5)
trans5 = [t1_5, t2_5, t3_5, t4_5, t5_5, t6_5]
auto5 = Automate(trans5, label="auto5")

# cmplt = Automate.completeAutomate(auto1,"ab")
# deter = Automate.determinisation(auto3)
# cmplm = Automate.complementaire(auto1, auto1.getAlphabetFromTransitions())
# inter = Automate.intersection(auto4, auto5)
# union = Automate.union(auto1, auto2)
# conca = Automate.concatenation(auto1, auto2)
etoil = Automate.etoile(auto3)

# auto1.show("auto1")
# auto2.show("auto2")
auto3.show("auto3")
# auto4.show("auto4")
# auto5.show("auto5")
# deter.show("determinisation")
# cmplm.show("complementaire")
# inter.show("intersection")
# union.show("union")
# conca.show("concatenation")
etoil.show("etoile")

print("\n/!\ Automates prets extermination humains /!\\\n")
Ejemplo n.º 4
0
# liste_etats : list[State]
liste_etats = [s0,s1,s2]

## creation de l’automate
# auto : Automate
auto = Automate(liste_trans)

# auto1 : Automate
auto1 = Automate(liste_trans, liste_etats)

# auto2 : Automate
auto2 = Automate.creationAutomate("auto.txt")


print(auto)
auto.show("exo1")

#print(auto1)
#auto1.show("exo1_2")

#print(auto2)
#auto2.show("exo1_3")

##----------------------------------MANIPULATION--------------------------------------

auto.removeTransition(t)

#print(auto)
#auto.show("exo2rem")

auto.addTransition(t)
Ejemplo n.º 5
0
# ND/C

s04 = State(0,True,False)
s14 = State(1,False,True)
auto4 = Automate([Transition(s04,'a',s04),Transition(s04,'b',s04),Transition(s04,'a',s14),Transition(s14,'a',s14),Transition(s14,'b',s14)])

# auto5 reconnait les mots commençant par un b (avec deux états initiaux)
# ND/C

s05 = State(0,True,False)
s15 = State(1,True,False)
s25 = State(2,False,True)
s35 = State(3,False,False)
auto5 = Automate([Transition(s05,'a',s35),Transition(s15,'a',s35),Transition(s05,'b',s25),Transition(s15,'b',s35),Transition(s25,'a',s25),Transition(s25,'b',s25),Transition(s35,'a',s35),Transition(s35,'b',s35)])

"""
auto1.show("auto1")
auto2.show("auto2")
auto3.show("auto3")
auto4.show("auto4")
auto5.show("auto5")
"""

#####
# Tests des fonctions
#####

print("Début des tests :")

# Fonction succ
Ejemplo n.º 6
0
list = [s1,s2]
print (a.succ(list,"c"))
print (a.succ(list,"b"))
list2 = [s1,s6]
print (d.succ(list2,"c"))
print (d.succ(list2,"b"))
print ("Etats accessibles")

print (Automate.accepte(a, "abc"))
print (Automate.accepte(a, "aaabbcb"))
print (Automate.accepte(a, "abs"))
print (Automate.accepte(c, "abc"))
print (Automate.accepte(c, "aaabbcb"))
print (Automate.accepte(c, "abcs"))
a.show("hey.pdf")
a.show("salut")



print (Automate.estComplet(a,["a","b","c"]))
print (Automate.estComplet(a, ["0","1"]))
print (Automate.estComplet(a, ["a","b"]))
print (Automate.estComplet(c,["a","b","c"]))

print ("\nDeterministe\n")
print (Automate.estDeterministe(a))
print (Automate.estDeterministe(b))
print (Automate.estDeterministe(c))
print (Automate.estDeterministe(d))
Ejemplo n.º 7
0
s0 = State(0, True, False)
# s1 state
s1 = State(1, False, True)
# s2 state
s2 = State(2, False, True)
#Création de transitions
t1 = Transition(s0, "a", s0)
t2 = Transition(s0, "b", s1)
t3 = Transition(s1, "a", s2)
t4 = Transition(s1, "b", s2)
t5 = Transition(s2, "a", s0)
t6 = Transition(s2, "b", s1)
# affichage de l'automate
auto = Automate([t1, t2, t3, t4, t5, t6])
print(auto)
auto.show("A_ListeTrans")

# Créations de l'automate à l'aide de ses transitions et états :
auto1 = Automate([t1, t2, t3, t4, t5, t6], [s0, s1, s2])
print(auto1)
auto1.show("A_ListeEtats")
# Création de l'aitomate à partir d'un fichier texte :
auto2 = Automate.creationAutomate("auto.txt")
print(auto2)
auto2.show("A_texte")
"""
# Premières manipulations
t = Transition(s0,"a",s0)
auto.removeTransition(t)
print(auto)
auto.removeTransition(t1)