// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2011, 2012, 2013 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// 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 .
#ifndef SPOT_TGBA_TAATGBA_HH
# define SPOT_TGBA_TAATGBA_HH
#include
#include
#include
#include "misc/hash.hh"
#include "ltlast/formula.hh"
#include "bdddict.hh"
#include "tgba.hh"
namespace spot
{
/// \brief A self-loop Transition-based Alternating Automaton (TAA)
/// which is seen as a TGBA (abstract class, see below).
class SPOT_API taa_tgba : public tgba
{
public:
taa_tgba(bdd_dict* dict);
struct transition;
typedef std::list state;
typedef std::set state_set;
/// Explicit transitions.
struct transition
{
bdd condition;
bdd acceptance_conditions;
const state_set* dst;
};
void add_condition(transition* t, const ltl::formula* f);
/// TGBA interface.
virtual ~taa_tgba();
virtual spot::state* get_init_state() const;
virtual tgba_succ_iterator*
succ_iter(const spot::state* local_state,
const spot::state* global_state = 0,
const tgba* global_automaton = 0) const;
virtual bdd_dict* get_dict() const;
virtual std::string format_state(const spot::state* state) const = 0;
virtual bdd all_acceptance_conditions() const;
virtual bdd neg_acceptance_conditions() const;
protected:
virtual bdd compute_support_conditions(const spot::state* state) const;
virtual bdd compute_support_variables(const spot::state* state) const;
typedef std::vector ss_vec;
bdd_dict* dict_;
mutable bdd all_acceptance_conditions_;
mutable bool all_acceptance_conditions_computed_;
bdd neg_acceptance_conditions_;
taa_tgba::state_set* init_;
ss_vec state_set_vec_;
private:
// Disallow copy.
taa_tgba(const taa_tgba& other) = delete;
taa_tgba& operator=(const taa_tgba& other) = delete;
};
/// Set of states deriving from spot::state.
class SPOT_API set_state : public spot::state
{
public:
set_state(const taa_tgba::state_set* s, bool delete_me = false)
: s_(s), delete_me_(delete_me)
{
}
virtual int compare(const spot::state*) const;
virtual size_t hash() const;
virtual set_state* clone() const;
virtual ~set_state()
{
if (delete_me_)
delete s_;
}
const taa_tgba::state_set* get_state() const;
private:
const taa_tgba::state_set* s_;
bool delete_me_;
};
class SPOT_API taa_succ_iterator : public tgba_succ_iterator
{
public:
taa_succ_iterator(const taa_tgba::state_set* s, bdd all_acc);
virtual ~taa_succ_iterator();
virtual void first();
virtual void next();
virtual bool done() const;
virtual set_state* current_state() const;
virtual bdd current_condition() const;
virtual bdd current_acceptance_conditions() const;
private:
/// Those typedefs are used to generate all possible successors in
/// the constructor using a cartesian product.
typedef taa_tgba::state::const_iterator iterator;
typedef std::pair iterator_pair;
typedef std::vector bounds_t;
typedef std::unordered_map,
state_ptr_hash, state_ptr_equal> seen_map;
struct distance_sort :
public std::binary_function
{
bool
operator()(const iterator_pair& lhs, const iterator_pair& rhs) const
{
return std::distance(lhs.first, lhs.second) <
std::distance(rhs.first, rhs.second);
}
};
std::vector::const_iterator i_;
std::vector succ_;
bdd all_acceptance_conditions_;
seen_map seen_;
};
/// A taa_tgba instance with states labeled by a given type.
/// Still an abstract class, see below.
template
class SPOT_API taa_tgba_labelled : public taa_tgba
{
public:
taa_tgba_labelled(bdd_dict* dict) : taa_tgba(dict) {};
void set_init_state(const label& s)
{
std::vector