* src/misc/bareword.cc, src/misc/bareword.hh (is_spin_ap): New function. * src/ltlast/formula.cc, src/ltlast/formula.hh (is_spin_atomic_props): New method and boolean. * src/ltlast/atomic_prop.cc, src/ltlast/constant.cc: Update it. * src/ltltest/kind.test: Test it.
130 lines
3.6 KiB
C++
130 lines
3.6 KiB
C++
// -*- coding: utf-8 -*-
|
|
// Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Laboratoire de
|
|
// Recherche et Développement de l'Epita (LRDE).
|
|
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de
|
|
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
|
// Université Pierre et Marie Curie.
|
|
//
|
|
// 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 <http://www.gnu.org/licenses/>.
|
|
|
|
#include "config.h"
|
|
#include "atomic_prop.hh"
|
|
#include "visitor.hh"
|
|
#include "misc/bareword.hh"
|
|
#include <cstddef>
|
|
#include <cassert>
|
|
#include <ostream>
|
|
|
|
namespace spot
|
|
{
|
|
namespace ltl
|
|
{
|
|
|
|
atomic_prop::atomic_prop(const std::string& name, environment& env)
|
|
: formula(AtomicProp), name_(name), env_(&env)
|
|
{
|
|
is.boolean = true;
|
|
is.sugar_free_boolean = true;
|
|
is.in_nenoform = true;
|
|
is.syntactic_si = true; // Assuming LTL (for PSL a Boolean
|
|
// term is not stared will be regarded
|
|
// as not stuttering were this
|
|
// matters.)
|
|
is.sugar_free_ltl = true;
|
|
is.ltl_formula = true;
|
|
is.eltl_formula = true;
|
|
is.psl_formula = true;
|
|
is.sere_formula = true;
|
|
is.finite = true;
|
|
is.eventual = false;
|
|
is.universal = false;
|
|
is.syntactic_safety = true;
|
|
is.syntactic_guarantee = true;
|
|
is.syntactic_obligation = true;
|
|
is.syntactic_recurrence = true;
|
|
is.syntactic_persistence = true;
|
|
is.not_marked = true;
|
|
is.accepting_eword = false;
|
|
// is.lbt_atomic_props should be true if the name has the form
|
|
// pNN where NN is any number of digit.
|
|
std::string::const_iterator pos = name.begin();
|
|
bool lbtap = (pos != name.end() && *pos++ == 'p');
|
|
while (lbtap && pos != name.end())
|
|
{
|
|
char l = *pos++;
|
|
lbtap = (l >= '0' && l <= '9');
|
|
}
|
|
is.lbt_atomic_props = lbtap;
|
|
is.spin_atomic_props = lbtap || is_spin_ap(name.c_str());
|
|
}
|
|
|
|
atomic_prop::~atomic_prop()
|
|
{
|
|
// Get this instance out of the instance map.
|
|
size_t c = instances.erase(key(name(), &env()));
|
|
assert(c == 1);
|
|
(void) c; // For the NDEBUG case.
|
|
}
|
|
|
|
std::string
|
|
atomic_prop::dump() const
|
|
{
|
|
return "AP(" + name() + ")";
|
|
}
|
|
|
|
void
|
|
atomic_prop::accept(visitor& v) const
|
|
{
|
|
v.visit(this);
|
|
}
|
|
|
|
atomic_prop::map atomic_prop::instances;
|
|
|
|
const atomic_prop*
|
|
atomic_prop::instance(const std::string& name, environment& env)
|
|
{
|
|
const atomic_prop* ap;
|
|
auto ires = instances.emplace(key(name, &env), nullptr);
|
|
if (!ires.second)
|
|
{
|
|
ap = ires.first->second;
|
|
ap->clone();
|
|
}
|
|
else
|
|
{
|
|
ap = ires.first->second = new atomic_prop(name, env);
|
|
}
|
|
return ap;
|
|
}
|
|
|
|
unsigned
|
|
atomic_prop::instance_count()
|
|
{
|
|
return instances.size();
|
|
}
|
|
|
|
std::ostream&
|
|
atomic_prop::dump_instances(std::ostream& os)
|
|
{
|
|
for (const auto& i: instances)
|
|
os << i.second << " = " << 1 + i.second->refs_
|
|
<< " * atomic_prop(" << i.first.first << ", "
|
|
<< i.first.second->name() << ")\n";
|
|
return os;
|
|
}
|
|
|
|
}
|
|
}
|