Commit graph

306 commits

Author SHA1 Message Date
Alexandre Duret-Lutz
b03935a4cf Simplify {r1;b1}&&{r2;b2} or {b1:r1}&&{b2:r2}, or similar.
* src/ltlvisit/simplify.cc: Add four rules.
* doc/tl/tl.tex: Document these rules.
* src/ltltest/reduccmp.test: Add tests.
2012-04-28 09:34:44 +02:00
Alexandre Duret-Lutz
ec9a3f96cb * src/ltlvisit/postfix.cc: Fix recursion on bunop formulae. 2012-04-28 09:34:44 +02:00
Alexandre Duret-Lutz
614810c0db Simplify {b && {r1;...;rn}}.
* doc/tl/tl.tex: Document the rules.
* src/ltlvisit/simplify.cc (simplify_visitor): Implement them.
* src/ltltest/reduccmp.test: Test them.
2012-04-28 09:34:44 +02:00
Alexandre Duret-Lutz
d0cfd44ba6 Simplify {b && {r1:...:rn}} as {b && r1 && ... && rn}.
* src/ltlvisit/simplify.cc (simplify_visitor): Do it.
* src/ltltest/reduccmp.test: Add a test.
* doc/tl/tl.tex: Document it.
* src/ltlast/multop.cc: Fix the computation of is.accepting_eword
for Fusion.  The Fusion operator never accepts [*0].
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
77084747b9 Simplify {b && r[*]} as {b && r}; likewise for [->] and [=].
* src/ltlvisit/simplify.cc (simplify_visitor): Do it.
* src/ltltest/reduccmp.test: Add more tests.
* doc/tl/tl.tex: Document it.
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
0f11e5fe0e Speedup mark_concat_ops() and simplify_mark() with a cache.
* src/ltlvisit/mark.hh, src/ltlvisit/mark.cc (mark_concat_ops,
simplify_mark): Rewrite these two functions as methods of
(mark_tools): this new class.
* src/ltlast/binop.cc, src/ltlast/unop.cc: Adjust computation
of not_marked to ignore marked operators that are not at
the top-level.  I.e., something like X(!{a}) is not marked.
* src/tgbaalgos/ltl2tgba_fm.cc (translate_dict::mt): New
instance of mark_tools.
(formula_canonizer::translate) Adjust calls to
mark_concat_ops() and simplify_mark().
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
2f03649324 Generalize syntactic implication for event. and univ. formulae.
* src/ltlvisit/simplify.cc (syntactic_implication_aux): Refine
rules to deal with pure eventualities and purely universal
properties.
* src/ltltest/reduccmp.test: Add tests.
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
07e40e706a Translate Boolean formulae as BDD using the ltl_simplifier cache.
* src/ltlvisit/simplify.hh, src/ltlvisit/simplify.cc
(ltl_simplifier::ltl_simplifier, ltl_simplifier::get_dict): Make
it possible to supply and retrieve the dictionary used.
(ltl_simplifier::as_bdd): New function, exported from the cache.
* src/tgbaalgos/ltl2tgba_fm.cc (translate_dict): Store the
ltl_simplifier object.
(translate_dict::boolean_to_bdd): Call ltl_simplifier::as_bdd.
(translate_ratexp): New wrapper around the ratexp_trad_visitor,
calling boolean_to_bdd whenever possible.
(ratexp_trad_visitor): Do not deal with negated formulae, there
are necessarily Boolean and handled by translate_ratexp().
(ltl_visitor): Adjust to call translate_ratexp.
(ltl_to_tgba_fm): Adjust passing of the ltl_simplifier to the
translate_dict, and make sure everybody is using the same
dictionary.
* src/tgbatest/ltl2tgba.cc: Pass the dictionary to the
ltl_simplifier.
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
369ad87e50 Rewrite syntactic implication using a single function.
* src/ltlvisit/simplify.cc (inf_left_recurse_visitor,
inf_right_recurse_visitor): Remove.
(syntactic_implication, syntactic_implication_aux): Rewrite all
rules for syntactic implication.
(syntactic_implication_neg): Simplify.
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
7514cc15ee Decrease the maximum bound used in random BUnOps.
* src/ltlvisit/randomltl.cc (bunop_bounded_builder,
bunop_bool_bounded_builder): Set the maximum value
to 3 instead of 4, to speed up the test suite.
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
c54627bebd Avoid containment checks on equal formulae.
* src/ltlvisit/contain.cc
(language_containment_checker::contained,
language_containment_checker::neg_contained,
language_containment_checker::contained_neg): Detect
cases where both formulae are equal.
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
7f7627bf22 Check that reductions are legitimates with containment.
* src/ltlvisit/simplify.cc, src/ltlvisit/simplify.hh
(are_equivalent): Export this function from the cache.
* src/ltltest/reduc.cc, src/ltltest/equals.cc: Use
are_equivalent() to check that the reductions are legitimate.
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
c9a659c8d4 Compare Boolean LTL formulae using BDDs.
* src/ltlvisit/simplify.cc (syntactic_implication): Here.
2012-04-28 09:34:43 +02:00
Alexandre Duret-Lutz
fea49630f6 Merge the syntactic implication code with ltl_simplifier.
So that we can latter use some combined optimizations.

* src/ltlvisit/simplify.hh, src/ltlvisit/simplify.cc: Integrate
the code from syntimpl.cc
* src/ltlvisit/syntimpl.hh, src/ltlvisit/syntimpl.cc: Delete.  All
code has been moved above.
* src/ltlvisit/Makefile.am: Adjust.
* src/ltltest/syntimpl.cc: Adjust code.
2012-04-28 09:34:42 +02:00
Alexandre Duret-Lutz
3db13a6f97 * src/ltlvisit/simplify.cc: More comments. 2012-04-28 09:34:42 +02:00
Alexandre Duret-Lutz
03fd46a13b Rewrite xor, =>, and <=> in negative_normal_form().
* src/ltlvisit/simplify.hh, src/ltlvisit/simplify.cc
(ltl_simplify::negative_normal_form): Remove the third
parameter and always rewrite XOR, =>, and <=>.  This avoid
problems with the cache, that could have been populated with
a different value for this third parameter.
* src/ltltest/reduc.cc, src/tgbaalgos/ltl2tgba_fm.cc: Adjust
calls to negative_normal_form().
* src/ltltest/nenoform.test: Adjust tests.
2012-04-28 09:34:42 +02:00
Alexandre Duret-Lutz
b89f86edcf Mark reduce_tau03() as deprecated.
* src/ltlvisit/contain.hh (reduce_tau03): Mark as deprecated.
* src/tgbaalgos/ltl2tgba_fm.cc, src/tgbatest/ltl2tgba.cc,
src/ltltest/equals.cc: Do not include ltlvisit/contain.hh, since
it's not used.
2012-04-28 09:34:42 +02:00
Alexandre Duret-Lutz
5c1729d6e4 Remove basicreduce files. ltl_simplifier does all the work.
* src/ltlvisit/basicreduce.cc, src/ltlvisit/basicreduce.hh: Delete.
* src/ltlvisit/Makefile.am: Remove them.
2012-04-28 09:34:42 +02:00
Alexandre Duret-Lutz
67f4e8b5ce Deprecate reduce() in favor of ltl_simplifier.
* src/ltlvisit/reduce.hh: Mark the file as obsolete.
(reduce): Declare this function as obsolete.
* src/ltlvisit/reduce.cc: Define SKIP_DEPRECATED_WARNING
so we can include reduce.hh.
* src/sanity/includes.test: Also use SKIP_DEPRECATED_WARNING
when compiling headers.
* iface/dve2/dve2check.cc,
src/ltltest/equals.cc, src/ltltest/randltl.cc,
src/ltltest/reduc.cc, src/tgbaalgos/ltl2tgba_fm.hh,
src/tgbaalgos/ltl2tgba_fm.cc, src/tgbatest/randtgba.cc,
wrap/python/ajax/spot.in, wrap/python/spot.i: Adjust
to use ltl_simplifier.
* src/tgbatest/ltl2tgba.cc: Adjust to use ltl_simplifier,
and replace -fr1...-fr7 options by a single -fr option.
* src/tgbatest/spotlbtt.test: Adjust -fr flags accordingly.
* src/tgbatest/reductgba.cc: Do not include reduce.hh.
2012-04-28 09:34:42 +02:00
Alexandre Duret-Lutz
c0085a8f30 Move the remaining reduce() logic into ltl_simplifier.
* src/ltlvisit/simplify.hh
(ltl_simplifier::negative_normal_form): Allow logical
unabbreviations during the NNF pass.
* src/ltlvisit/simplify.cc
(ltl_simplifier::negative_normal_form)
(negative_normal_form_visitor): Adjust.
(ltl_simplifier::simplify): Request unabbreviations.
* src/ltlvisit/reduce.cc (reduce): Remove most
of the code, leaving only a call ltl_simplifier
and some wrapper code to convert options.
* src/ltltest/reduccmp.test: Add more test cases.
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
d4d4c0e7d3 Typo in the code rewriting "a M 1 = Fa".
* src/ltlvisit/simplify.cc (simplify_visitor): Fix it,
and leave the trace code.
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
c2335edb57 Remove the negative_normal_form call from reduce().
* src/ltlvisit/simplify.cc (ltl_simplifier::simplify):
Convert in negative normal form if needed.
* src/ltlvisit/reduce.cc (reduce): Do not call
negative_normal_form().
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
1087c62356 Move language containment into ltl_simplifier.
* src/ltlvisit/simplify.cc: Integrate the tau03
containment rules.
* src/ltlvisit/simplify.hh: Add options to select simplifications.
* src/ltlvisit/reduce.cc (reduce): Do not call reduce_tau03().
* src/ltlvisit/contain.cc (reduce_tau03_visitor): Remove.
(reduce_tau03): Implement it using ltl_simplifier.
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
82b42494db Generalize G,&,| rewritings to deal with event. and univ. terms.
* src/ltlvisit/simplify.cc (ltl_simplifier): Adjust
code.
* src/ltltest/reduccmp.test: Add some test cases.
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
ab7a1c7aa9 More rewritings or multop::And and multop::Or.
* src/ltlvisit/simplify.cc (ltl_simplifier): Add more rewritings
for formulae that are both universal and eventual.
* src/ltltest/reduccmp.test: Add six more cases.
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
47fb449198 * src/ltlvisit/reduce.hh: 80 columns. 2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
ca686cb07e Fix a case caught by the random formula generator.
* src/ltlvisit/simplify.cc (ltl_simplifier): Since we are processing
the formula bottom-up, don't assume all trivial simplification have
been done.
* src/ltltest/reduccmp.test: More tests.
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
ca2fe4f3f8 Reimplement basic_reduce()'s rules in ltl_simplifier.
So far I have only checked these rewritings with reduccmp.test.
There are probably a few kinks to iron out.

* src/ltlvisit/simplify.cc: Reimplement most of the basic
rewriting rules, leaving some FIXME comments for dubious ones.
* src/ltlast/multop.cc, src/ltlast/multop.hh: Ignore NULL
pointers in the vector.
* src/ltlvisit/reduce.cc (reduce): Do not call basic_reduce().
* src/ltltest/reduccmp.test: Adjust tests.
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
e3e0f913b6 * src/ltlvisit/simplify.hh (ltl_simplifier): Disallow copy. 2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
dd1cd89a73 event./univ. and syntactic implications rewriting in ltl_simplifier.
* src/ltlvisit/reduce.cc (reduce_visitor): Move ...
* src/ltlvisit/simplify.cc (simplify_visitor): ... here, and
adjust to use the new ltl_simplifier_options.
* src/ltlvisit/reduce.cc (reduce): Use ltl_simplifier
to perform the work of reduce_visitor.  Eventually we want to
get rid of reduce.cc.
* src/ltlvisit/reduce.hh (reduce): Remove the
syntactic_implication_cache used as third argument.
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
aa5c2f606b Take trivial identities into account to simplify basicreduce.
* src/ltlvisit/basicreduce.cc: Do not test
for things like X(true), F(false), or `a U 1`.
These are all trivial identities.
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
9f7ef5d0c3 Introduce ltl_simplifier.
It is limited to negative_normal_form_visitor for now.

* src/ltlvisit/simplify.cc, src/ltlvisit/simplify.hh: New files.
* src/ltlvisit/Makefile.am: Add them.
* src/ltlvisit/nenoform.cc, src/ltlvisit/nenoform.hh: Rewrite
using ltl_simplifier.
2012-04-28 09:30:37 +02:00
Alexandre Duret-Lutz
0e4e2a79b2 Cosmetic change to please sanity checks.
* src/ltlvisit/randomltl.cc (random_formula::update_sums): Remove
duplicate semicolon.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
6e6b6b1e01 Disable LTL reductions on SERE formulae.
* src/ltlvisit/contain.cc (recurse, reduce_tau03): Do not
run on non-PSL formulae.
* src/ltlvisit/reduce.cc (reduce_visitor::visit): Skip
multop::Fusion operators, and do not run syntactic_implication_neg
on SERE formulae.
* src/ltlvisit/syntimpl.cc (inf_right_recurse_visitor::visit):
Skip [*0].
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
fdd73d5123 Add support for the {SERE}! PSL operator.
* src/ltlparse/ltlscan.ll: Recognize }!.  Also remove
five duplicate rules.
* src/ltlparse/ltlparse.yy: Build {r}<>->1 when parsing {r}!.
* src/ltlvisit/tostring.cc: Print {r}! instead of {r}<>->1.
* src/ltltest/tostring.test, src/ltltest/equals.test:
Add more tests.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
c8801935bf Fix handling of PSL operators in reductions rules.
We still don't have any PSL-specific reductions, but at least
the LTL reduction now appear to work on PSL formulas.

* src/ltlvisit/basicreduce.cc (basic_reduce_visitor): Fix the
call to std::copy to handle Concat, Fusion, and AndNLM.
* src/ltlvisit/reduce.cc (reduce_visitor): Fix handling
of UConcat, EConcat, and EConcatMarked.
* src/tgbatest/randpsl.test: Activate reductions.
* src/ltltest/reducpsl.test: New file.
* src/ltltest/Makefile.am (TESTS): Add it.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
b8b4aa72c5 Plug a memory leak in randltl.
* src/ltlvisit/randomltl.hh (random_formula::~random_formula):
Declare as virtual.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
cce6dd34f8 Add random generators of Boolean, SERE, and PSL formula.
* src/ltlvisit/randomltl.cc, src/ltlvisit/randomltl.hh:
(random_boolean, random_sere, random_psl): Add new classes.
* src/ltltest/randltl.cc: Add options to support the above.
Nore: the -p option was renamed to -pL for consistency, but
it is still understood.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
cc889a7f66 Make it possible to format SERE.
* src/ltlvisit/tostring.hh, src/ltlvisit/tostring.cc (to_string):
Add third option to enable formating suitable for SERE.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
fe7d7473ed * src/ltlvisit/tostring.cc: Fix parentheses for [*] operator. 2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
7c7704f92e Prepare the introduction of random_sere() and random_psl().
* src/ltlvisit/randomltl.hh (random_ltl): Split this class into...
(random_formula, random_ltl): ... these.
* src/ltlvisit/randomltl.cc: New
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
4ef7805e73 Speedup syntactic_implication() by using a cache.
* src/ltlvisit/syntimpl.hh (syntactic_implication,
syntactic_implication_neg): Move as member of ...
(syntactic_implication_cache): ... this new class, that holds
a cache of results to speedup these functions.
* src/ltlvisit/syntimpl.cc: Adjust to use (lookup, populate,
and cleanup) the cache.
* src/ltltest/syntimpl.cc: Likewise.
* src/ltlvisit/reduce.hh (reduce): Take an optional
syntactic_implication_cache parameter.
* src/ltlvisit/reduce.cc: Adjust to use a
syntactic_implication_cache.
* src/ltltest/equals.cc: Call dump_instances() to help debugging.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
20c088a45a Speedup some rewriting by detecting cases where they do nothing.
* src/ltlvisit/nenoform.cc, src/ltlvisit/lunabbrev.cc,
src/ltlvisit/simpfg.cc, src/ltlvisit/tunabbrev.cc: Do not recurse
if the formula properties indicate that it is already in the right
form.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
6380968f32 Remove the has_mark() function in favor of the is_marked() method.
* src/ltlast/unop.cc (NegClosure): Reset is.not_marked.
* src/ltlvisit/mark.hh,
src/ltlvisit/mark.cc (has_mark_visitor, has_mark): Remove.
* src/tgbaalgos/ltl2tgba_fm.cc: Use f->is_marked() instead
of has_mark(f).
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
957ba664b7 Get rid of all dynamic_cast<>s while working on LTL formulae.
They are too slow.

* src/ltlast/formula.hh (opkind, kind, kind_): Use an enum
to indicate the actual kind of the formula.  This way we can
check the kind of a formula without relying on dynamic_cast.
* src/ltlast/atomic_prop.cc, src/ltlast/automatop.cc,
src/ltlast/binop.cc, src/ltlast/bunop.cc, src/ltlast/constant.cc,
src/ltlast/multop.cc, src/ltlast/refformula.cc,
src/ltlast/refformula.hh, src/ltlast/unop.cc: Adjust constructors.
* src/ltlvisit/basicreduce.cc, src/ltlvisit/mark.cc,
src/ltlvisit/reduce.cc, src/ltlvisit/syntimpl.cc,
src/ltlvisit/tostring.cc: Replace all dynamic_cast by a
call to kind() followed by a static_cast.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
48cde88b9b Replace the constant_term visitor by a flag in the formulae.
* src/ltlast/formula.hh (formula::accepts_eword): New method.
(formula::is.accepting_eword): New flag.
* src/ltlast/formula.cc (print_formula_props): Display the new
property.
* src/ltlast/atomic_prop.cc, src/ltlast/automatop.cc,
src/ltlast/binop.cc, src/ltlast/bunop.cc, src/ltlast/constant.cc,
src/ltlast/multop.cc, src/ltlast/unop.cc: Update
is.accepting_eword as appropriate.
* src/ltltest/consterm.cc, src/tgbaalgos/ltl2tgba_fm.cc: Adjust to
use accepts_eword().
* src/ltlvisit/consterm.cc, src/ltlvisit/consterm.hh: Delete.
* src/ltlvisit/Makefile.am: Remove these files.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
546260e7a0 Maintain basic LTL properties using a bitfield inside formula objects.
This bitfield is easily updated as the formulae are constructed.
Doing so avoids many AST recursions to compute these properties
individually.  This patch removes the eventual_universal_visitor,
as well as the kind_of() function.

* src/ltlast/formula.hh (is_boolean, is_sugar_free_boolean,
is_in_nenoform, is_X_free, is_sugar_free_ltl,
is_ltl_formula, is_eltl_formula, is_psl_formula, is_eventual,
is_universal, is_marked): New methods to query formula
properties in constant time.
(get_props, ltl_prop): A method and structure for
implementation as a field bit in an unsigned, for fast
computation.
(print_formula_props): New function.
* src/ltlast/formula.cc (print_formula_props): Implement it.
* src/ltlast/atomic_prop.cc, src/ltlast/binop.cc,
src/ltlast/bunop.cc, src/ltlast/constant.cc, src/ltlast/multop.cc,
src/ltlast/unop.cc, src/ltlast/automatop.cc: Compute the
properties as instances are constructed.
* src/ltlparse/ltlparse.yy: Update to use is_boolean() instead
of kind_of().
* src/ltltest/kind.cc: Update to use print_formula_props().
* src/ltltest/kind.test: Adjust to test eventual and universal
properties.
* src/ltlvisit/kind.cc, src/ltlvisit/kind.hh: Delete these files.
* src/ltlvisit/Makefile.am: Remove kind.hh and kind.cc.
* src/ltlvisit/reduce.cc (recurse_eu, eventual_universal_visitor):
Remove, no longer needed.
(reduce_visitor, is_eventual, is_universal): Adjust to
use formula::is_eventual(), and formula::is_universal().
* src/ltlvisit/reduce.hh (is_eventual, is_universal): Declare as
deprecated.
2012-04-28 09:30:36 +02:00
Alexandre Duret-Lutz
c6a751b9d4 Speed up computation of constant term on [->] and [=] operators.
* src/ltlvisit/consterm.cc: Stop the recursion on [->] and [=].
2012-04-28 09:30:35 +02:00
Alexandre Duret-Lutz
437128b55b Add functions to compute the kind of a formula (LTL, PSL, Boolean...)
* src/ltlvisit/kind.hh, src/ltlvisit/kind.cc: New files.
* src/ltlvisit/Makefile.am: Add them.
* src/ltltest/kind.test, src/ltltest/kind.cc: New files.
* src/ltltest/Makefile.am: Add them.
2012-04-28 09:30:35 +02:00
Alexandre Duret-Lutz
567b460738 Add support for [+].
* src/ltlast/bunop.cc (bunop::format): Output [*1..] as [+].
* src/ltlvisit/tostring.cc: Output "a*" as "a[*]" for consistency.
* src/ltlparse/ltlparse.yy, src/ltlparse/ltlscan.ll: Recognize [+].
* src/ltltest/tostring.test, src/ltltest/equals.test,
src/tgbatest/ltl2tgba.test: More tests.
2012-04-28 09:30:35 +02:00