示例#1
0
def equivalent(a, phi):
    negphi = spot.formula.Not(phi)
    nega = spot.dualize(spot.tgba_determinize(a))
    a2 = spot.ltl_to_tgba_fm(phi, dict)
    nega2 = spot.ltl_to_tgba_fm(negphi, dict)
    return spot.product(a, nega2).is_empty()\
           and spot.product(nega, a2).is_empty()
示例#2
0
def equivalent(a, phi):
  negphi = spot.formula.Not(phi)
  nega   = spot.dualize(spot.tgba_determinize(a))
  a2     = spot.ltl_to_tgba_fm(phi, dict)
  nega2  = spot.ltl_to_tgba_fm(negphi, dict)
  return spot.product(a, nega2).is_empty()\
         and spot.product(nega, a2).is_empty()
示例#3
0
def equivalent(a, phi):
  negphi = spot.formula.Not(phi)
  nega   = spot.dualize(spot.tgba_determinize(a))
  a2     = spot.ltl_to_tgba_fm(phi, dict)
  nega2  = spot.ltl_to_tgba_fm(negphi, dict)
  return spot.product(a, nega2).is_empty()\
         and spot.product(nega, a2).is_empty()

phi1 = produce_phi(rg, 1000)
phi2 = produce_phi(rg, 1000)
inputres = []
aut = []
for p in zip(phi1, phi2):
  inputres.append(spot.formula.Or(p))
  a1 = spot.ltl_to_tgba_fm(p[0], dict)  
  a2 = spot.ltl_to_tgba_fm(p[1], dict)  
  aut.append(spot.to_generalized_buchi( \
      spot.remove_alternation(spot.sum(a1, a2), True)))

for p in zip(aut, inputres):
  assert equivalent(p[0], p[1])

aut = []
inputres = []

for p in zip(phi1, phi2):
  inputres.append(spot.formula.And(p))
  a1 = spot.ltl_to_tgba_fm(p[0], dict)  
  a2 = spot.ltl_to_tgba_fm(p[1], dict)  
  aut.append(spot.to_generalized_buchi( \
示例#4
0
"map[5]==1") && (F "map[6]==1") && (F "map[7]==1") && (F "map[8]==1")
&& (F "map[9]==1") && (F "map[0]==2") && (F "map[1]==2") && (F
"map[2]==2") && (F "map[3]==2") && (F "map[4]==2") && (F "map[5]==2")
&& (F "map[6]==2") && (F "map[7]==2") && (F "map[8]==2") && (F
"map[9]==2") && (F "map[0]==3") && (F "map[1]==3") && (F "map[2]==3")
&& (F "map[3]==3") && (F "map[4]==3") && (F "map[5]==3") && (F
"map[6]==3") && (F "map[7]==3") && (F "map[8]==3") && (F
"map[9]==3")))"""

e = spot.default_environment.instance()
pf = spot.parse_infix_psl(f, e)
d = spot.make_bdd_dict()

spot.unblock_signal(signal.SIGALRM)
spot.unblock_signal(signal.SIGTERM)
os.setpgrp()
child = os.fork()
if child != 0:
    signal.signal(signal.SIGALRM, alarm_handler)
    signal.alarm(2)
    os.waitpid(child, 0)
    # If the child returns, before we get the alarm it's a bug.
    exit(1)

# This is expected to take WAY more than 2s.
print("Before")
spot.ltl_to_tgba_fm(pf.f, d, True)
print("After")

exit(1)
示例#5
0
cout = spot.get_cout()
cerr = spot.get_cerr()

e = spot.default_environment.instance()
p = spot.empty_parse_error_list()

f = spot.parse(args[0], p, e, debug_opt)
if spot.format_parse_errors(cerr, args[0], p):
    exit_code = 1

dict = spot.bdd_dict()

if f:
    if fm_opt:
        a = spot.ltl_to_tgba_fm(f, dict)
        concrete = 0
    else:
        a = concrete = spot.ltl_to_tgba_lacim(f, dict)
    f.destroy()
    del f

    degeneralized = None
    if degeneralize_opt:
        a = degeneralized = spot.tgba_tba_proxy(a)

    if output == 0:
        spot.dotty_reachable(cout, a)
    elif output == 1:
        if concrete:
            spot.bdd_print_dot(cout, concrete.get_dict(),
示例#6
0
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Make sure that interdependencies between the spot and buddy wrappers
# are not problematic.
import buddy
import spot
import sys

simp = spot.tl_simplifier()

e = spot.default_environment.instance()
pf = spot.parse_infix_psl('GFa', e)
d = simp.get_dict()
a = spot.ltl_to_tgba_fm(pf.f, d)
g = spot.parse_infix_boolean('b&c', e)
b = simp.as_bdd(g.f)
buddy.bdd_printset(b)
spot.nl_cout()
del g

s0 = a.get_init_state()
it = a.succ_iter(s0)
it.first()
while not it.done():
    c = it.cond()
    sys.stdout.write("%s\n" % c)
    b &= c  # `&=' is defined only in buddy.  So if this statement works
    # it means buddy can grok spot's objects.
    buddy.bdd_printset(c)
示例#7
0
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Make sure that interdependencies between the spot and buddy wrappers
# are not problematic.
import buddy
import spot
import sys

simp = spot.tl_simplifier()

e = spot.default_environment.instance()
pf = spot.parse_infix_psl('GFa', e)
d = simp.get_dict()
a = spot.ltl_to_tgba_fm(pf.f, d)
g = spot.parse_infix_boolean('b&c', e)
b = simp.as_bdd(g.f)
buddy.bdd_printset(b); spot.nl_cout()
del g

s0 = a.get_init_state()
it = a.succ_iter(s0)
it.first()
while not it.done():
    c = it.cond()
    sys.stdout.write("%s\n" % c)
    b &= c # `&=' is defined only in buddy.  So if this statement works
           # it means buddy can grok spot's objects.
    buddy.bdd_printset(c); spot.nl_cout()
    it.next()
示例#8
0
def equivalent(a, phi):
    negphi = spot.formula.Not(phi)
    nega = spot.dualize(spot.tgba_determinize(a))
    a2 = spot.ltl_to_tgba_fm(phi, dict)
    nega2 = spot.ltl_to_tgba_fm(negphi, dict)
    return spot.product(a, nega2).is_empty()\
           and spot.product(nega, a2).is_empty()


phi1 = produce_phi(rg, 1000)
phi2 = produce_phi(rg, 1000)
inputres = []
aut = []
for p in zip(phi1, phi2):
    inputres.append(spot.formula.Or(p))
    a1 = spot.ltl_to_tgba_fm(p[0], dict)
    a2 = spot.ltl_to_tgba_fm(p[1], dict)
    aut.append(spot.to_generalized_buchi( \
        spot.remove_alternation(spot.sum(a1, a2), True)))

for p in zip(aut, inputres):
    assert equivalent(p[0], p[1])

aut = []
inputres = []

for p in zip(phi1, phi2):
    inputres.append(spot.formula.And(p))
    a1 = spot.ltl_to_tgba_fm(p[0], dict)
    a2 = spot.ltl_to_tgba_fm(p[1], dict)
    aut.append(spot.to_generalized_buchi( \
示例#9
0
 def __init__(self, ltl_string, print_dot=True):
     opt=None
     #build hoa dfa string representation
     cout = spot.get_cout()
     e = spot.default_environment.instance()
     p = spot.empty_parse_error_list()
     debug_opt = False
     f = spot.parse_infix_psl(ltl_string, p, e, debug_opt)
     dict = spot.make_bdd_dict()
     print("GENERATE")
     a = spot.ltl_to_tgba_fm(f, dict)
     print("ENSURE")
     a = spot.ensure_digraph(a)
     print("MINIMIZE")
     a = spot.minimize_obligation(a, f)
     #a = degeneralized = spot.degeneralize(a)
     if print_dot:
         spot.print_dot(cout, a)
     
     hoa_string=a.to_str('hoa', opt)
     
     self.n_states=0
     self.initial_state=0
     self.accepting_states=[]
     self.transitions=[]
     self.atomic_propositions=[]
     
     hoa_string=hoa_string.split('\n')
     
     current_state=0
     i=0;
     line=None
     while line != '--END--':
         line=hoa_string[i]
         line=line.split(': ')
         if line[0]=='States':
             self.n_states=int(line[1])
             self.transitions=[[] for i in range(0,self.n_states)]
         elif line[0]=='Start':
             self.initial_state=int(line[1])
         elif line[0]=='AP':
             self.atomic_propositions=[i.strip('"') for i in line[1].split(' ')[1:]]
         elif line[0]=='State':
             line=line[1].split(' ')
             if current_state != int(line[0]):
                 print("ERROR")
             if '{' in line[-1]:
                 self.accepting_states.append(current_state)
             i+=1
             line=hoa_string[i]
             while 'State:' not in line:
                 if line == '--END--':
                     break
                 line=line.split(' ')
                 
                 transition=DnfTransitionDef(source=current_state,
                                             target=int(line[-1]),
                                             atomic_propositions=set(),
                                             vector_dnf_label=[]
                                             )
                 for conj_clause_string in line[:-1]:
                     conj_clause_rep={}
                     conj_clause_string=conj_clause_string.strip('[')
                     conj_clause_string=conj_clause_string.strip(']')
                     if conj_clause_string=='t':
                         transition.atomic_propositions=None
                         transition.vector_dnf_label=True
                         continue
                     if conj_clause_string == '|':
                         continue
                     conj_clause_string=conj_clause_string.split('&')
                     for literal_id in conj_clause_string:
                         if '!' in literal_id:
                             literal=self.atomic_propositions[int(literal_id[1:])]
                             transition.atomic_propositions.add(literal)
                             conj_clause_rep[literal]=False
                         else:
                             literal=self.atomic_propositions[int(literal_id)]
                             transition.atomic_propositions.add(literal)
                             conj_clause_rep[literal]=True
                     transition.vector_dnf_label.append(conj_clause_rep)                                                   
                 self.transitions[current_state].append(transition)
                 i+=1
                 line=hoa_string[i]
             current_state+=1
             continue
                 
         i+=1
示例#10
0
cout = spot.get_cout()
cerr = spot.get_cerr()

e = spot.default_environment.instance()

pf = spot.parse_infix_psl(args[0], e, debug_opt)
if pf.format_errors(cerr):
    exit_code = 1
f = pf.f

dict = spot.make_bdd_dict()

if f:
    if fm_opt:
        a = spot.ltl_to_tgba_fm(f, dict)
        concrete = 0
    elif taa_opt:
        a = concrete = spot.ltl_to_taa(f, dict)
    else:
        assert "unspecified translator"

    if wdba:
        a = spot.ensure_digraph(a)
        a = spot.minimize_obligation(a, f)

    del f

    degeneralized = None
    if degeneralize_opt:
        a = degeneralized = spot.degeneralize(a)
示例#11
0
"map[5]==1") && (F "map[6]==1") && (F "map[7]==1") && (F "map[8]==1")
&& (F "map[9]==1") && (F "map[0]==2") && (F "map[1]==2") && (F
"map[2]==2") && (F "map[3]==2") && (F "map[4]==2") && (F "map[5]==2")
&& (F "map[6]==2") && (F "map[7]==2") && (F "map[8]==2") && (F
"map[9]==2") && (F "map[0]==3") && (F "map[1]==3") && (F "map[2]==3")
&& (F "map[3]==3") && (F "map[4]==3") && (F "map[5]==3") && (F
"map[6]==3") && (F "map[7]==3") && (F "map[8]==3") && (F
"map[9]==3")))"""

e = spot.default_environment.instance()
pf = spot.parse_infix_psl(f, e)
d = spot.make_bdd_dict()

spot.unblock_signal(signal.SIGALRM)
spot.unblock_signal(signal.SIGTERM)
os.setpgrp()
child = os.fork()
if child != 0:
    signal.signal(signal.SIGALRM, alarm_handler)
    signal.alarm(2)
    os.waitpid(child, 0)
    # If the child returns, before we get the alarm it's a bug.
    exit(1)

# This is expected to take WAY more than 2s.
print("Before")
spot.ltl_to_tgba_fm(pf.f, d, True)
print("After")

exit(1)