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 ...@@ -647,12 +647,12 @@ namespace spot
// appropriately. ALIVE_PROP is the bdd that should be ANDed // appropriately. ALIVE_PROP is the bdd that should be ANDed
// to all transitions leaving a live state, while DEAD_PROP should // to all transitions leaving a live state, while DEAD_PROP should
// be ANDed to all transitions leaving a dead state. // be ANDed to all transitions leaving a dead state.
if (dead.is_false()) if (dead.is_ff())
{ {
alive_prop = bddtrue; alive_prop = bddtrue;
dead_prop = bddfalse; dead_prop = bddfalse;
} }
else if (dead.is_true()) else if (dead.is_tt())
{ {
alive_prop = bddtrue; alive_prop = bddtrue;
dead_prop = bddtrue; dead_prop = bddtrue;
......
...@@ -138,7 +138,7 @@ namespace spot ...@@ -138,7 +138,7 @@ namespace spot
void void
fnode::destroy_aux() const fnode::destroy_aux() const
{ {
if (SPOT_UNLIKELY(is(op::AP))) if (SPOT_UNLIKELY(is(op::ap)))
{ {
auto i = m.ap2name.find(id()); auto i = m.ap2name.find(id());
auto n = m.name2ap.erase(i->second); auto n = m.name2ap.erase(i->second);
...@@ -165,10 +165,10 @@ namespace spot ...@@ -165,10 +165,10 @@ namespace spot
case op::x: \ case op::x: \
return #x; \ return #x; \
break break
C(False); C(ff);
C(True); C(tt);
C(EmptyWord); C(eword);
C(AP); C(ap);
C(Not); C(Not);
C(X); C(X);
C(F); C(F);
...@@ -618,7 +618,7 @@ namespace spot ...@@ -618,7 +618,7 @@ namespace spot
// - 0[*min..max] = 0 if min > 0 // - 0[*min..max] = 0 if min > 0
// - b[:*0..max] = 1 // - b[:*0..max] = 1
// - b[:*min..max] = 0 if min > 0 // - b[:*min..max] = 0 if min > 0
if (child->is_false() if (child->is_ff()
|| (o == op::FStar && child->is_boolean())) || (o == op::FStar && child->is_boolean()))
{ {
if (min == 0) if (min == 0)
...@@ -709,7 +709,7 @@ namespace spot ...@@ -709,7 +709,7 @@ namespace spot
// F(0) = G(0) = 0 // F(0) = G(0) = 0
// F(1) = G(1) = 1 // F(1) = G(1) = 1
if (f->is_false() || f->is_true()) if (f->is_ff() || f->is_tt())
return f; return f;
assert(!f->is_eword()); assert(!f->is_eword());
...@@ -719,10 +719,10 @@ namespace spot ...@@ -719,10 +719,10 @@ namespace spot
case op::Not: case op::Not:
{ {
// !1 = 0 // !1 = 0
if (f->is_true()) if (f->is_tt())
return ff(); return ff();
// !0 = 1 // !0 = 1
if (f->is_false()) if (f->is_ff())
return tt(); return tt();
// ![*0] = 1[+] // ![*0] = 1[+]
if (f->is_eword()) if (f->is_eword())
...@@ -754,7 +754,7 @@ namespace spot ...@@ -754,7 +754,7 @@ namespace spot
} }
case op::X: case op::X:
// X(1) = 1, X(0) = 0 // X(1) = 1, X(0) = 0
if (f->is_true() || f->is_false()) if (f->is_tt() || f->is_ff())
return f; return f;
assert(!f->is_eword()); assert(!f->is_eword());
break; break;
...@@ -771,10 +771,10 @@ namespace spot ...@@ -771,10 +771,10 @@ namespace spot
case op::NegClosure: case op::NegClosure:
case op::NegClosureMarked: case op::NegClosureMarked:
// {1} = 0 // {1} = 0
if (f->is_true()) if (f->is_tt())
return ff(); return ff();
// {0} = 1, {[*0]} = 1 // {0} = 1, {[*0]} = 1
if (f->is_false() || f->is_eword()) if (f->is_ff() || f->is_eword())
return tt(); return tt();
// {b} = !b // {b} = !b
if (f->is_boolean()) if (f->is_boolean())
...@@ -806,9 +806,9 @@ namespace spot ...@@ -806,9 +806,9 @@ namespace spot
} }
// - (1 ^ Exp) = !Exp // - (1 ^ Exp) = !Exp
// - (0 ^ Exp) = Exp // - (0 ^ Exp) = Exp
if (first->is_true()) if (first->is_tt())
return unop(op::Not, second); return unop(op::Not, second);
if (first->is_false()) if (first->is_ff())
return second; return second;
if (first == second) if (first == second)
{ {
...@@ -830,9 +830,9 @@ namespace spot ...@@ -830,9 +830,9 @@ namespace spot
// - (0 <=> Exp) = !Exp // - (0 <=> Exp) = !Exp
// - (1 <=> Exp) = Exp // - (1 <=> Exp) = Exp
// - (Exp <=> Exp) = 1 // - (Exp <=> Exp) = 1
if (first->is_false()) if (first->is_ff())
return unop(op::Not, second); return unop(op::Not, second);
if (first->is_true()) if (first->is_tt())
return second; return second;
if (first == second) if (first == second)
{ {
...@@ -850,19 +850,19 @@ namespace spot ...@@ -850,19 +850,19 @@ namespace spot
// - (Exp => 1) = 1 // - (Exp => 1) = 1
// - (Exp => 0) = !Exp // - (Exp => 0) = !Exp
// - (Exp => Exp) = 1 // - (Exp => Exp) = 1
if (first->is_true()) if (first->is_tt())
return second; return second;
if (first->is_false()) if (first->is_ff())
{ {
second->destroy(); second->destroy();
return tt(); return tt();
} }
if (second->is_true()) if (second->is_tt())
{ {
first->destroy(); first->destroy();
return second; return second;
} }
if (second->is_false()) if (second->is_ff())
return unop(op::Not, first); return unop(op::Not, first);
if (first == second) if (first == second)
{ {
...@@ -876,9 +876,9 @@ namespace spot ...@@ -876,9 +876,9 @@ namespace spot
// - (Exp U 0) = 0 // - (Exp U 0) = 0
// - (0 U Exp) = Exp // - (0 U Exp) = Exp
// - (Exp U Exp) = Exp // - (Exp U Exp) = Exp
if (second->is_true() if (second->is_tt()
|| second->is_false() || second->is_ff()
|| first->is_false() || first->is_ff()
|| first == second) || first == second)
{ {
first->destroy(); first->destroy();
...@@ -890,14 +890,14 @@ namespace spot ...@@ -890,14 +890,14 @@ namespace spot
// - (0 W Exp) = Exp // - (0 W Exp) = Exp
// - (1 W Exp) = 1 // - (1 W Exp) = 1
// - (Exp W Exp) = Exp // - (Exp W Exp) = Exp
if (second->is_true() if (second->is_tt()
|| first->is_false() || first->is_ff()
|| first == second) || first == second)
{ {
first->destroy(); first->destroy();
return second; return second;
} }
if (first->is_true()) if (first->is_tt())
{ {
second->destroy(); second->destroy();
return first; return first;
...@@ -908,9 +908,9 @@ namespace spot ...@@ -908,9 +908,9 @@ namespace spot
// - (Exp R 0) = 0 // - (Exp R 0) = 0
// - (1 R Exp) = Exp // - (1 R Exp) = Exp
// - (Exp R Exp) = Exp // - (Exp R Exp) = Exp
if (second->is_true() if (second->is_tt()
|| second->is_false() || second->is_ff()
|| first->is_true() || first->is_tt()
|| first == second) || first == second)
{ {
first->destroy(); first->destroy();
...@@ -922,14 +922,14 @@ namespace spot ...@@ -922,14 +922,14 @@ namespace spot
// - (1 M Exp) = Exp // - (1 M Exp) = Exp
// - (0 M Exp) = 0 // - (0 M Exp) = 0
// - (Exp M Exp) = Exp // - (Exp M Exp) = Exp
if (second->is_false() if (second->is_ff()
|| first->is_true() || first->is_tt()
|| first == second) || first == second)
{ {
first->destroy(); first->destroy();
return second; return second;
} }
if (first->is_false()) if (first->is_ff())
{ {
second->destroy(); second->destroy();
return first; return first;
...@@ -942,15 +942,15 @@ namespace spot ...@@ -942,15 +942,15 @@ namespace spot
// - [*0] <>-> Exp = 0 // - [*0] <>-> Exp = 0
// - Exp <>-> 0 = 0 // - Exp <>-> 0 = 0
// - boolExp <>-> Exp = boolExp & Exp // - boolExp <>-> Exp = boolExp & Exp
if (first->is_true()) if (first->is_tt())
return second; return second;
if (first->is_false() if (first->is_ff()
|| first->is_eword()) || first->is_eword())
{ {
second->destroy(); second->destroy();
return ff(); return ff();
} }
if (second->is_false()) if (second->is_ff())
{ {
first->destroy(); first->destroy();
return second; return second;
...@@ -964,15 +964,15 @@ namespace spot ...@@ -964,15 +964,15 @@ namespace spot
// - [*0] []-> Exp = 1 // - [*0] []-> Exp = 1
// - Exp []-> 1 = 1 // - Exp []-> 1 = 1
// - boolExp []-> Exp = !boolExp | Exp // - boolExp []-> Exp = !boolExp | Exp
if (first->is_true()) if (first->is_tt())
return second; return second;
if (first->is_false() if (first->is_ff()
|| first->is_eword()) || first->is_eword())
{ {
second->destroy(); second->destroy();
return tt(); return tt();
} }
if (second->is_true()) if (second->is_tt())
{ {
first->destroy(); first->destroy();
return second; return second;
...@@ -1000,13 +1000,13 @@ namespace spot ...@@ -1000,13 +1000,13 @@ namespace spot
m.ap2name.emplace(next_id_, name); m.ap2name.emplace(next_id_, name);
// next_id_ is incremented by setup_props(), called by the // next_id_ is incremented by setup_props(), called by the
// constructor of fnode // constructor of fnode
return ires.first->second = new fnode(op::AP, {}); return ires.first->second = new fnode(op::ap, {});
} }
const std::string& const std::string&
fnode::ap_name() const fnode::ap_name() const
{ {
if (op_ != op::AP) if (op_ != op::ap)
throw std::runtime_error("ap_name() called on non-AP formula"); throw std::runtime_error("ap_name() called on non-AP formula");
auto i = m.ap2name.find(id()); auto i = m.ap2name.find(id());
assert(i != m.ap2name.end()); assert(i != m.ap2name.end());
...@@ -1014,9 +1014,9 @@ namespace spot ...@@ -1014,9 +1014,9 @@ namespace spot
} }
size_t fnode::next_id_ = 0U; size_t fnode::next_id_ = 0U;
const fnode* fnode::ff_ = new fnode(op::False, {}); const fnode* fnode::ff_ = new fnode(op::ff, {});
const fnode* fnode::tt_ = new fnode(op::True, {}); const fnode* fnode::tt_ = new fnode(op::tt, {});
const fnode* fnode::ew_ = new fnode(op::EmptyWord, {}); const fnode* fnode::ew_ = new fnode(op::eword, {});
const fnode* fnode::one_star_ = nullptr; // Only built when necessary. const fnode* fnode::one_star_ = nullptr; // Only built when necessary.
void fnode::setup_props(op o) void fnode::setup_props(op o)
...@@ -1032,8 +1032,8 @@ namespace spot ...@@ -1032,8 +1032,8 @@ namespace spot
switch (op_) switch (op_)
{ {
case op::False: case op::ff:
case op::True: case op::tt:
is_.boolean = true; is_.boolean = true;
is_.sugar_free_boolean = true; is_.sugar_free_boolean = true;
is_.in_nenoform = true; is_.in_nenoform = true;
...@@ -1055,7 +1055,7 @@ namespace spot ...@@ -1055,7 +1055,7 @@ namespace spot
is_.lbt_atomic_props = true; is_.lbt_atomic_props = true;
is_.spin_atomic_props = true; is_.spin_atomic_props = true;
break; break;
case op::EmptyWord: case op::eword:
is_.boolean = false; is_.boolean = false;
is_.sugar_free_boolean = false; is_.sugar_free_boolean = false;
is_.in_nenoform = true; is_.in_nenoform = true;
...@@ -1077,7 +1077,7 @@ namespace spot ...@@ -1077,7 +1077,7 @@ namespace spot
is_.lbt_atomic_props = true; is_.lbt_atomic_props = true;
is_.spin_atomic_props = true; is_.spin_atomic_props = true;
break; break;
case op::AP: case op::ap:
is_.boolean = true; is_.boolean = true;
is_.sugar_free_boolean = true; is_.sugar_free_boolean = true;
is_.in_nenoform = true; is_.in_nenoform = true;
...@@ -1119,7 +1119,7 @@ namespace spot ...@@ -1119,7 +1119,7 @@ namespace spot
is_.not_marked = true; is_.not_marked = true;
is_.eventual = children[0]->is_universal(); is_.eventual = children[0]->is_universal();
is_.universal = children[0]->is_eventual(); 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_.sere_formula = is_.boolean;
is_.syntactic_safety = children[0]->is_syntactic_guarantee(); is_.syntactic_safety = children[0]->is_syntactic_guarantee();
...@@ -1336,7 +1336,7 @@ namespace spot ...@@ -1336,7 +1336,7 @@ namespace spot
is_.not_marked = true; is_.not_marked = true;
// f U g is universal if g is eventual, or if f == 1. // f U g is universal if g is eventual, or if f == 1.
is_.eventual = children[1]->is_eventual(); is_.eventual = children[1]->is_eventual();
is_.eventual |= children[0]->is_true(); is_.eventual |= children[0]->is_tt();
is_.boolean = false; is_.boolean = false;
is_.sere_formula = false; is_.sere_formula = false;
is_.finite = false; is_.finite = false;
...@@ -1357,7 +1357,7 @@ namespace spot ...@@ -1357,7 +1357,7 @@ namespace spot
props = children[0]->props & children[1]->props; props = children[0]->props & children[1]->props;
is_.not_marked = true; is_.not_marked = true;
// f W g is universal if f and g are, or if g == 0. // 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_.boolean = false;
is_.sere_formula = false; is_.sere_formula = false;
is_.finite = false; is_.finite = false;
...@@ -1380,7 +1380,7 @@ namespace spot ...@@ -1380,7 +1380,7 @@ namespace spot
is_.not_marked = true; is_.not_marked = true;
// g R f is universal if f is universal, or if g == 0. // g R f is universal if f is universal, or if g == 0.
is_.universal = children[1]->is_universal(); is_.universal = children[1]->is_universal();
is_.universal |= children[0]->is_false(); is_.universal |= children[0]->is_ff();
is_.boolean = false; is_.boolean = false;
is_.sere_formula = false; is_.sere_formula = false;
is_.finite = false; is_.finite = false;
...@@ -1402,7 +1402,7 @@ namespace spot ...@@ -1402,7 +1402,7 @@ namespace spot
props = children[0]->props & children[1]->props; props = children[0]->props & children[1]->props;
is_.not_marked = true; is_.not_marked = true;
// g M f is eventual if both g and f are eventual, or if f == 1. // 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_.boolean = false;
is_.sere_formula = false; is_.sere_formula = false;
is_.finite = false; is_.finite = false;
...@@ -1585,7 +1585,7 @@ namespace spot ...@@ -1585,7 +1585,7 @@ namespace spot
if (m != unbounded()) if (m != unbounded())
os << +m; os << +m;
} }
if (op_ == op::AP) if (op_ == op::ap)
os << " \"" << ap_name() << '"'; os << " \"" << ap_name() << '"';
if (auto s = size()) if (auto s = size())
{ {
......
...@@ -41,10 +41,10 @@ namespace spot ...@@ -41,10 +41,10 @@ namespace spot
{ {
enum class op: uint8_t enum class op: uint8_t
{ {
False, ff,
True, tt,
EmptyWord, eword,
AP, ap,
// unary operators // unary operators
Not, Not,
X, X,
...@@ -210,9 +210,9 @@ namespace spot ...@@ -210,9 +210,9 @@ namespace spot
return ff_; return ff_;
} }
bool is_false() const bool is_ff() const
{ {
return op_ == op::False; return op_ == op::ff;
} }
static const fnode* tt() static const fnode* tt()
...@@ -220,9 +220,9 @@ namespace spot ...@@ -220,9 +220,9 @@ namespace spot
return tt_; return tt_;
} }
bool is_true() const bool is_tt() const
{ {
return op_ == op::True; return op_ == op::tt;
} }
static const fnode* eword() static const fnode* eword()
...@@ -232,12 +232,12 @@ namespace spot ...@@ -232,12 +232,12 @@ namespace spot
bool is_eword() const bool is_eword() const
{ {
return op_ == op::EmptyWord; return op_ == op::eword;
} }
bool is_constant() const 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 bool is_Kleene_star() const
...@@ -579,7 +579,7 @@ namespace spot ...@@ -579,7 +579,7 @@ namespace spot
{ {
if (f->is(op::Not)) if (f->is(op::Not))
f = f->nth(0); f = f->nth(0);
if (f->is(op::AP)) if (f->is(op::ap))
return f; return f;
return nullptr; return nullptr;
}; };
...@@ -1088,9 +1088,9 @@ namespace spot ...@@ -1088,9 +1088,9 @@ namespace spot
return formula(fnode::ff()); return formula(fnode::ff());
} }
bool is_false() const bool is_ff() const
{ {
return ptr_->is_false(); return ptr_->is_ff();
} }
static formula tt() static formula tt()
...@@ -1098,9 +1098,9 @@ namespace spot ...@@ -1098,9 +1098,9 @@ namespace spot
return formula(fnode::tt()); return formula(fnode::tt());
} }
bool is_true() const bool is_tt() const
{ {
return ptr_->is_true(); return ptr_->is_tt();
} }