Commit 679df4ee authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Implement dtgba_sat_minimize().

Joint work with Soheib Baarir.

* src/tgbaalgos/dtgbasat.cc, src/tgbaalgos/dtgbasat.hh: New files.
* src/tgbaalgos/Makefile.am: Add them.
* src/tgbaalgos/postproc.cc, src/tgbaalgos/postproc.hh: Add
a dtgba-sat-minimize option.
* src/tgbatest/ltl2tgba.cc: Add option -RG.
* src/tgbatest/satmin.test: Add more tests.
parent 260ab53c
......@@ -38,6 +38,7 @@ tgbaalgos_HEADERS = \
dottydec.hh \
dotty.hh \
dtbasat.hh \
dtgbasat.hh \
dupexp.hh \
eltl2tgba_lacim.hh \
emptiness.hh \
......@@ -86,6 +87,7 @@ libtgbaalgos_la_SOURCES = \
dotty.cc \
dottydec.cc \
dtbasat.cc \
dtgbasat.cc \
dupexp.cc \
eltl2tgba_lacim.cc \
emptiness.cc \
......
This diff is collapsed.
// -*- coding: utf-8 -*-
// Copyright (C) 2013 Laboratoire de Recherche et Développement
// de l'Epita.
//
// 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/>.
#ifndef SPOT_TGBAALGOS_DTGBASAT_HH
# define SPOT_TGBAALGOS_DTGBASAT_HH
#include <iosfwd>
#include "tgba/tgba.hh"
#include "tgba/tgbaexplicit.hh"
namespace spot
{
/// \brief Attempt to reduce a deterministic TGBA with a SAT solver.
///
/// \param a the TGBA to reduce. It should have only one acceptance
/// set and be deterministic. I.e., it should be a deterministic TBA.
///
/// \param cand_nacc is the number of acceptance sets in the result.
///
/// This functions attempts to find the smallest TGBA with \a
/// cand_nacc acceptance sets that is equivalent to \a a. If no
/// smaller TGBA is found, a null pointer is returned.
SPOT_API tgba_explicit_number*
dtgba_sat_minimize(const tgba* a, unsigned cand_nacc);
}
#endif // SPOT_TGBAALGOS_DTGBASAT_HH
......@@ -30,6 +30,7 @@
#include "isdet.hh"
#include "tgba/tgbatba.hh"
#include "dtbasat.hh"
#include "dtgbasat.hh"
#include "complete.hh"
namespace spot
......@@ -51,6 +52,7 @@ namespace spot
ba_simul_ = opt->get("ba-simul", -1);
tba_determinisation_ = opt->get("tba-det", 0);
sat_minimize_ = opt->get("sat-minimize", 0);
dtgba_sat_minimize_ = opt->get("dtgba-sat-minimize", -1);
}
}
......@@ -300,6 +302,24 @@ namespace spot
delete res;
}
}
else if (dtgba_sat_minimize_ >= 0 && dba && !dba_is_wdba)
{
const tgba* cmp = tgba_complete(dba);
const tgba* res =
dtgba_sat_minimize(cmp,
dtgba_sat_minimize_
? dtgba_sat_minimize_
: dba->number_of_acceptance_conditions());
delete cmp;
if (res != 0)
{
delete dba;
dba = scc_filter(res, true);
delete res;
}
}
// Degeneralize the dba resulting from tba-determinization
// or sat-minimization (which is a TBA) if requested.
if (dba && !dba_is_wdba && type_ == BA)
......
......@@ -107,6 +107,7 @@ namespace spot
int ba_simul_;
bool tba_determinisation_;
bool sat_minimize_;
int dtgba_sat_minimize_;
};
/// @}
}
......
......@@ -73,6 +73,7 @@
#include "tgbaalgos/dbacomp.hh"
#include "tgbaalgos/complete.hh"
#include "tgbaalgos/dtbasat.hh"
#include "tgbaalgos/dtgbasat.hh"
#include "taalgos/tgba2ta.hh"
#include "taalgos/dotty.hh"
......@@ -432,6 +433,7 @@ main(int argc, char** argv)
bool cs_oblig = false;
bool opt_complete = false;
int opt_dtbasat = -1;
int opt_dtgbasat = -1;
for (;;)
{
......@@ -798,6 +800,14 @@ main(int argc, char** argv)
redopt.reduce_basics = true;
redopt.reduce_size_strictly = true;
}
else if (!strncmp(argv[formula_index], "-RG", 3))
{
if (argv[formula_index][3] != 0)
opt_dtgbasat = to_int(argv[formula_index] + 3);
else
opt_dtgbasat = 0;
//output = -1;
}
else if (!strcmp(argv[formula_index], "-Rm"))
{
opt_minimize = true;
......@@ -818,7 +828,7 @@ main(int argc, char** argv)
if (argv[formula_index][3] != 0)
opt_dtbasat = to_int(argv[formula_index] + 3);
else
opt_dtbasat = -1;
opt_dtbasat = 0;
//output = -1;
}
else if (!strcmp(argv[formula_index], "-RT"))
......@@ -1523,6 +1533,14 @@ main(int argc, char** argv)
if (satminimized)
a = satminimized;
}
else if (opt_dtgbasat >= 0)
{
tm.start("dtgbasat");
satminimized = dtgba_sat_minimize(a, opt_dtgbasat);
tm.stop("dtgbasat");
if (satminimized)
a = satminimized;
}
spot::tgba* complemented = 0;
if (opt_dbacomp)
......
......@@ -86,8 +86,11 @@ G(G!a | F!c | G!b)
EOF
$ltlcross -F formulas \
--timeout=300 \
--timeout=60 \
"$ltl2tgba --det --lbtt %f >%T" \
"$ltl2tgba --det --lbtt -x tba-det --lbtt %f >%T" \
"$ltl2tgba --det --lbtt -x tba-det,sat-minimize --lbtt %f >%T" \
"$ltl2tgba --det --lbtt -x tba-det %f >%T" \
"$ltl2tgba --det --lbtt -x tba-det,sat-minimize %f >%T" \
"$ltl2tgba --det --lbtt -x tba-det,dtgba-sat-minimize=0 %f >%T" \
"$ltl2tgba --det --lbtt -x dtgba-sat-minimize=0 %f >%T" \
"$ltl2tgba --det --lbtt -x tba-det,dtgba-sat-minimize=3 %f >%T" \
--json=det.json
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment