Commit 8b4ec5de authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

formula: rename the constants for consistency

False/True are problematic in Python, and I don't like that the
enum is op::False but the constructor formula::ff().  So let's
just use ff and tt everywhere, and also eword instead of EmptyWord.

* src/ltlast/formula.hh (False, True, EmptyWord, AP, is_false, is_true):
Rename to...
(ff, tt, eword, ap, is_ff, is_tt): ... these.
* iface/ltsmin/ltsmin.cc, src/ltlast/formula.cc,
src/ltlvisit/apcollect.cc, src/ltlvisit/dot.cc, src/ltlvisit/mark.cc,
src/ltlvisit/mutation.cc, src/ltlvisit/print.cc,
src/ltlvisit/relabel.cc, src/ltlvisit/simpfg.cc,
src/ltlvisit/simplify.cc, src/ltlvisit/snf.cc, src/ltlvisit/unabbrev.cc,
src/twa/acc.cc, src/twa/acc.hh, src/twa/formula2bdd.cc,
src/twaalgos/gtec/gtec.cc, src/twaalgos/hoa.cc, src/twaalgos/ltl2taa.cc,
src/twaalgos/ltl2tgba_fm.cc, src/twaalgos/neverclaim.cc,
src/twaalgos/product.cc, src/twaalgos/remfin.cc, src/twaalgos/safety.cc,
src/tests/parseerr.test, src/tests/utf8.test, wrap/python/spot.py:
Adjust.
parent fad05632
......@@ -647,12 +647,12 @@ namespace spot
// appropriately. ALIVE_PROP is the bdd that should be ANDed
// to all transitions leaving a live state, while DEAD_PROP should
// be ANDed to all transitions leaving a dead state.
if (dead.is_false())
if (dead.is_ff())
{
alive_prop = bddtrue;
dead_prop = bddfalse;
}
else if (dead.is_true())
else if (dead.is_tt())
{
alive_prop = bddtrue;
dead_prop = bddtrue;
......
......@@ -138,7 +138,7 @@ namespace spot
void
fnode::destroy_aux() const
{
if (SPOT_UNLIKELY(is(op::AP)))
if (SPOT_UNLIKELY(is(op::ap)))
{
auto i = m.ap2name.find(id());
auto n = m.name2ap.erase(i->second);
......@@ -165,10 +165,10 @@ namespace spot
case op::x: \
return #x; \
break
C(False);
C(True);
C(EmptyWord);
C(AP);
C(ff);
C(tt);
C(eword);
C(ap);
C(Not);
C(X);
C(F);
......@@ -618,7 +618,7 @@ namespace spot
// - 0[*min..max] = 0 if min > 0
// - b[:*0..max] = 1
// - b[:*min..max] = 0 if min > 0
if (child->is_false()
if (child->is_ff()
|| (o == op::FStar && child->is_boolean()))
{
if (min == 0)
......@@ -709,7 +709,7 @@ namespace spot
// F(0) = G(0) = 0
// F(1) = G(1) = 1
if (f->is_false() || f->is_true())
if (f->is_ff() || f->is_tt())
return f;
assert(!f->is_eword());
......@@ -719,10 +719,10 @@ namespace spot
case op::Not:
{
// !1 = 0
if (f->is_true())
if (f->is_tt())
return ff();
// !0 = 1
if (f->is_false())
if (f->is_ff())
return tt();
// ![*0] = 1[+]
if (f->is_eword())
......@@ -754,7 +754,7 @@ namespace spot
}
case op::X:
// X(1) = 1, X(0) = 0
if (f->is_true() || f->is_false())
if (f->is_tt() || f->is_ff())
return f;
assert(!f->is_eword());
break;
......@@ -771,10 +771,10 @@ namespace spot
case op::NegClosure:
case op::NegClosureMarked:
// {1} = 0
if (f->is_true())
if (f->is_tt())
return ff();
// {0} = 1, {[*0]} = 1
if (f->is_false() || f->is_eword())
if (f->is_ff() || f->is_eword())
return tt();
// {b} = !b
if (f->is_boolean())
......@@ -806,9 +806,9 @@ namespace spot
}
// - (1 ^ Exp) = !Exp
// - (0 ^ Exp) = Exp
if (first->is_true())
if (first->is_tt())
return unop(op::Not, second);
if (first->is_false())
if (first->is_ff())
return second;
if (first == second)
{
......@@ -830,9 +830,9 @@ namespace spot
// - (0 <=> Exp) = !Exp
// - (1 <=> Exp) = Exp
// - (Exp <=> Exp) = 1
if (first->is_false())
if (first->is_ff())
return unop(op::Not, second);
if (first->is_true())
if (first->is_tt())
return second;
if (first == second)
{
......@@ -850,19 +850,19 @@ namespace spot
// - (Exp => 1) = 1
// - (Exp => 0) = !Exp
// - (Exp => Exp) = 1
if (first->is_true())
if (first->is_tt())
return second;
if (first->is_false())
if (first->is_ff())
{
second->destroy();
return tt();
}
if (second->is_true())
if (second->is_tt())
{
first->destroy();
return second;
}
if (second->is_false())
if (second->is_ff())
return unop(op::Not, first);
if (first == second)
{
......@@ -876,9 +876,9 @@ namespace spot
// - (Exp U 0) = 0
// - (0 U Exp) = Exp
// - (Exp U Exp) = Exp
if (second->is_true()
|| second->is_false()
|| first->is_false()
if (second->is_tt()
|| second->is_ff()
|| first->is_ff()
|| first == second)
{
first->destroy();
......@@ -890,14 +890,14 @@ namespace spot
// - (0 W Exp) = Exp
// - (1 W Exp) = 1
// - (Exp W Exp) = Exp
if (second->is_true()
|| first->is_false()
if (second->is_tt()
|| first->is_ff()
|| first == second)
{
first->destroy();
return second;
}
if (first->is_true())
if (first->is_tt())
{
second->destroy();
return first;
......@@ -908,9 +908,9 @@ namespace spot
// - (Exp R 0) = 0
// - (1 R Exp) = Exp
// - (Exp R Exp) = Exp
if (second->is_true()
|| second->is_false()
|| first->is_true()
if (second->is_tt()
|| second->is_ff()
|| first->is_tt()
|| first == second)
{
first->destroy();
......@@ -922,14 +922,14 @@ namespace spot
// - (1 M Exp) = Exp
// - (0 M Exp) = 0
// - (Exp M Exp) = Exp
if (second->is_false()
|| first->is_true()
if (second->is_ff()
|| first->is_tt()
|| first == second)
{
first->destroy();
return second;
}
if (first->is_false())
if (first->is_ff())
{
second->destroy();
return first;
......@@ -942,15 +942,15 @@ namespace spot
// - [*0] <>-> Exp = 0
// - Exp <>-> 0 = 0
// - boolExp <>-> Exp = boolExp & Exp
if (first->is_true())
if (first->is_tt())
return second;
if (first->is_false()
if (first->is_ff()
|| first->is_eword())
{
second->destroy();
return ff();
}
if (second->is_false())
if (second->is_ff())
{
first->destroy();
return second;
......@@ -964,15 +964,15 @@ namespace spot
// - [*0] []-> Exp = 1
// - Exp []-> 1 = 1
// - boolExp []-> Exp = !boolExp | Exp
if (first->is_true())
if (first->is_tt())
return second;
if (first->is_false()
if (first->is_ff()
|| first->is_eword())
{
second->destroy();
return tt();
}
if (second->is_true())
if (second->is_tt())
{
first->destroy();
return second;
......@@ -1000,13 +1000,13 @@ namespace spot
m.ap2name.emplace(next_id_, name);
// next_id_ is incremented by setup_props(), called by the
// constructor of fnode
return ires.first->second = new fnode(op::AP, {});
return ires.first->second = new fnode(op::ap, {});
}
const std::string&
fnode::ap_name() const
{
if (op_ != op::AP)
if (op_ != op::ap)
throw std::runtime_error("ap_name() called on non-AP formula");
auto i = m.ap2name.find(id());
assert(i != m.ap2name.end());
......@@ -1014,9 +1014,9 @@ namespace spot
}
size_t fnode::next_id_ = 0U;
const fnode* fnode::ff_ = new fnode(op::False, {});
const fnode* fnode::tt_ = new fnode(op::True, {});
const fnode* fnode::ew_ = new fnode(op::EmptyWord, {});
const fnode* fnode::ff_ = new fnode(op::ff, {});
const fnode* fnode::tt_ = new fnode(op::tt, {});
const fnode* fnode::ew_ = new fnode(op::eword, {});
const fnode* fnode::one_star_ = nullptr; // Only built when necessary.
void fnode::setup_props(op o)
......@@ -1032,8 +1032,8 @@ namespace spot
switch (op_)
{
case op::False:
case op::True:
case op::ff:
case op::tt:
is_.boolean = true;
is_.sugar_free_boolean = true;
is_.in_nenoform = true;
......@@ -1055,7 +1055,7 @@ namespace spot
is_.lbt_atomic_props = true;
is_.spin_atomic_props = true;
break;
case op::EmptyWord:
case op::eword:
is_.boolean = false;
is_.sugar_free_boolean = false;
is_.in_nenoform = true;
......@@ -1077,7 +1077,7 @@ namespace spot
is_.lbt_atomic_props = true;
is_.spin_atomic_props = true;
break;
case op::AP:
case op::ap:
is_.boolean = true;
is_.sugar_free_boolean = true;
is_.in_nenoform = true;
......@@ -1119,7 +1119,7 @@ namespace spot
is_.not_marked = true;
is_.eventual = children[0]->is_universal();
is_.universal = children[0]->is_eventual();
is_.in_nenoform = (children[0]->is(op::AP));
is_.in_nenoform = (children[0]->is(op::ap));
is_.sere_formula = is_.boolean;
is_.syntactic_safety = children[0]->is_syntactic_guarantee();
......@@ -1336,7 +1336,7 @@ namespace spot
is_.not_marked = true;
// f U g is universal if g is eventual, or if f == 1.
is_.eventual = children[1]->is_eventual();
is_.eventual |= children[0]->is_true();
is_.eventual |= children[0]->is_tt();
is_.boolean = false;
is_.sere_formula = false;
is_.finite = false;
......@@ -1357,7 +1357,7 @@ namespace spot
props = children[0]->props & children[1]->props;
is_.not_marked = true;
// f W g is universal if f and g are, or if g == 0.
is_.universal |= children[1]->is_false();
is_.universal |= children[1]->is_ff();
is_.boolean = false;
is_.sere_formula = false;
is_.finite = false;
......@@ -1380,7 +1380,7 @@ namespace spot
is_.not_marked = true;
// g R f is universal if f is universal, or if g == 0.
is_.universal = children[1]->is_universal();
is_.universal |= children[0]->is_false();
is_.universal |= children[0]->is_ff();
is_.boolean = false;
is_.sere_formula = false;
is_.finite = false;
......@@ -1402,7 +1402,7 @@ namespace spot
props = children[0]->props & children[1]->props;
is_.not_marked = true;
// g M f is eventual if both g and f are eventual, or if f == 1.
is_.eventual |= children[1]->is_true();
is_.eventual |= children[1]->is_tt();
is_.boolean = false;
is_.sere_formula = false;
is_.finite = false;
......@@ -1585,7 +1585,7 @@ namespace spot
if (m != unbounded())
os << +m;
}
if (op_ == op::AP)
if (op_ == op::ap)
os << " \"" << ap_name() << '"';
if (auto s = size())
{
......
......@@ -41,10 +41,10 @@ namespace spot
{
enum class op: uint8_t
{
False,
True,
EmptyWord,
AP,
ff,
tt,
eword,
ap,
// unary operators
Not,
X,
......@@ -210,9 +210,9 @@ namespace spot
return ff_;
}
bool is_false() const
bool is_ff() const
{
return op_ == op::False;
return op_ == op::ff;
}
static const fnode* tt()
......@@ -220,9 +220,9 @@ namespace spot
return tt_;
}
bool is_true() const
bool is_tt() const
{
return op_ == op::True;
return op_ == op::tt;
}
static const fnode* eword()
......@@ -232,12 +232,12 @@ namespace spot
bool is_eword() const
{
return op_ == op::EmptyWord;
return op_ == op::eword;
}
bool is_constant() const
{
return op_ == op::False || op_ == op::True || op_ == op::EmptyWord;
return op_ == op::ff || op_ == op::tt || op_ == op::eword;
}
bool is_Kleene_star() const
......@@ -579,7 +579,7 @@ namespace spot
{
if (f->is(op::Not))
f = f->nth(0);
if (f->is(op::AP))
if (f->is(op::ap))
return f;
return nullptr;
};
......@@ -1088,9 +1088,9 @@ namespace spot
return formula(fnode::ff());
}
bool is_false() const
bool is_ff() const
{
return ptr_->is_false();
return ptr_->is_ff();
}
static formula tt()
......@@ -1098,9 +1098,9 @@ namespace spot
return formula(fnode::tt());
}
bool is_true() const
bool is_tt() const
{
return ptr_->is_true();
return ptr_->is_tt();
}
static formula eword()
......@@ -1130,7 +1130,7 @@ namespace spot
bool is_literal()
{
return (is(op::AP) ||
return (is(op::ap) ||
// If f is in nenoform, Not can only occur in front of
// an atomic proposition. So this way we do not have
// to check the type of the child.
......@@ -1194,10 +1194,10 @@ namespace spot
{
switch (op o = kind())
{
case op::False:
case op::True:
case op::EmptyWord:
case op::AP:
case op::ff:
case op::tt:
case op::eword:
case op::ap:
return *this;
case op::Not:
case op::X:
......
......@@ -47,7 +47,7 @@ namespace spot
s = new atomic_prop_set;
f.traverse([&](const formula& f)
{
if (f.is(op::AP))
if (f.is(op::ap))
s->insert(f);
return false;
});
......
......@@ -60,9 +60,9 @@ namespace spot
return src;
op o = f.kind();
std::string str = (o == op::AP) ? f.ap_name() : f.kindstr();
std::string str = (o == op::ap) ? f.ap_name() : f.kindstr();
if (o == op::AP || f.is_constant())
if (o == op::ap || f.is_constant())
*sinks_ << " " << src << " [label=\""
<< str << "\", shape=box];\n";
else
......@@ -71,10 +71,10 @@ namespace spot
int childnum = 0;
switch (o)
{
case op::False:
case op::True:
case op::EmptyWord:
case op::AP:
case op::ff:
case op::tt:
case op::eword:
case op::ap:
case op::Not:
case op::X:
case op::F:
......
......@@ -37,10 +37,10 @@ namespace spot
ltl::formula res;
switch (f.kind())
{
case op::False:
case op::True:
case op::EmptyWord:
case op::AP:
case op::ff:
case op::tt:
case op::eword:
case op::ap:
case op::Not:
case op::X:
case op::F:
......@@ -103,10 +103,10 @@ namespace spot
ltl::formula res;
switch (f.kind())
{
case op::False:
case op::True:
case op::EmptyWord:
case op::AP:
case op::ff:
case op::tt:
case op::eword:
case op::ap:
case op::Not:
case op::X:
case op::F:
......
......@@ -67,11 +67,11 @@ namespace spot
switch (f.kind())
{
case op::False:
case op::True:
case op::EmptyWord:
case op::ff:
case op::tt:
case op::eword:
return f;
case op::AP:
case op::ap:
if (opts_ & Mut_Ap2Const)
{
if (mutation_counter_-- == 0)
......
......@@ -423,16 +423,16 @@ namespace spot
op o = f.kind();
switch (o)
{
case op::False:
case op::ff:
emit(KFalse);
break;
case op::True:
case op::tt:
emit(KTrue);
break;
case op::EmptyWord:
case op::eword:
emit(KEmptyWord);
break;
case op::AP:
case op::ap:
{
const std::string& str = f.ap_name();
if (!is_bare_word(str.c_str()))
......@@ -483,7 +483,7 @@ namespace spot
case op::Not:
{
formula c = f[0];
if (c.is(op::AP))
if (c.is(op::ap))
{
// If we negate a single letter in UTF-8, use a
// combining overline.
......@@ -585,7 +585,7 @@ namespace spot
formula right = f[1];
unsigned last = left.size() - 1;
bool onelast = false;
if (left.is(op::Concat) && left[last].is_true())
if (left.is(op::Concat) && left[last].is_tt())
{
visit(left.all_but(last));
onelast = true;
......@@ -609,7 +609,7 @@ namespace spot
}
else if (o == op::EConcat)
{
if (f[1].is(op::True))
if (f[1].is_tt())
{
os_ << '!';
// No recursion on right.
......@@ -743,7 +743,7 @@ namespace spot
unsigned default_max = formula::unbounded();
// Abbreviate "1[*]" as "[*]".
if (!c.is(op::True) || o != op::Star)
if (!c.is_tt() || o != op::Star)
{
if (o == op::Star)
{
......@@ -1042,13 +1042,13 @@ namespace spot
op o = f.kind();
switch (o)
{
case op::False:
case op::ff:
os_ << 'f';
break;
case op::True:
case op::tt:
os_ << 't';
break;
case op::AP:
case op::ap:
{
const std::string& str = f.ap_name();
if (!is_pnum(str.c_str()))
......@@ -1100,7 +1100,7 @@ namespace spot
os_ << "& ";
first_ = true;
break;
case op::EmptyWord:
case op::eword:
case op::Closure:
case op::NegClosure:
case op::NegClosureMarked:
......
......@@ -121,7 +121,7 @@ namespace spot
formula
visit(formula f)
{
if (f.is(op::AP))
if (f.is(op::ap))
return rename(f);
else
return f.map([this](formula f)
......@@ -420,7 +420,7 @@ namespace spot
formula
visit(formula f)
{