def run_bench(automata): for aut in automata: # Make sure all our implementations behave identically res5 = is_empty2(aut) res4 = is_empty1(aut) spot.generic_emptiness_check_select_version("spot28") res3a = spot.generic_emptiness_check(aut) spot.generic_emptiness_check_select_version("atva19") res3b = spot.generic_emptiness_check(aut) spot.generic_emptiness_check_select_version("spot29") res3c = spot.generic_emptiness_check(aut) res2 = spot.remove_fin(aut).is_empty() res1 = generic_emptiness2(aut) res = (str(res1)[0] + str(res2)[0] + str(res3a)[0] + str(res3b)[0] + str(res3c)[0] + str(res4)[0] + str(res5)[0]) print(res) assert res in ('TTTTTTT', 'FFFFFFF') if res == 'FFFFFFF': run3 = spot.generic_accepting_run(aut) assert run3.replay(spot.get_cout()) is True
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
elif o == '-t': output = 6 elif o == '-T': taa_opt = 1 elif o == '-v': output = 5 elif o == '-W': wdba = 1 else: usage(prog) if len(args) != 1: usage(prog) 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
# You should have received a copy of the GNU General Public License # along with Spot; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. import sys import spot e = spot.default_environment.instance() p = spot.empty_parse_error_list() l = ['GFa', 'a U (((b)) xor c)', '!(FFx <=> Fx)', 'a \/ a \/ b \/ a \/ a']; for str1 in l: f = spot.parse(str1, p, e, 0) if spot.format_parse_errors(spot.get_cout(), str1, p): sys.exit(1) str2 = str(f) f.destroy() print str2 # Try to reparse the stringified formula f = spot.parse(str2, p, e) if spot.format_parse_errors(spot.get_cout(), str2, p): sys.exit(1) print f f.destroy() assert spot.atomic_prop.instance_count() == 0 assert spot.binop.instance_count() == 0 assert spot.unop.instance_count() == 0 assert spot.multop.instance_count() == 0
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public # License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os import spot contents = ''' HOA: v1 name: "a U b" States: 2 Start: 1 AP: 2 "a" "b" acc-name: Buchi Acceptance: 1 Inf(0) properties: trans-labels explicit-labels state-acc deterministic --BODY-- State: 0 {0} [t] 0 State: 1 [1] 0 [0&!1] 1 --END-- ''' filename = 'parsetgba.hoa' out = open(filename, 'w+') out.write(contents) out.close() a = spot.parse_aut(filename, spot.make_bdd_dict()) assert not a.errors spot.print_dot(spot.get_cout(), a.aut) del a os.unlink(filename)