dtwasat.hh 6.24 KB
Newer Older
1
// -*- coding: utf-8 -*-
2
3
// Copyright (C) 2013, 2014, 2015 Laboratoire de Recherche et
// Développement de l'Epita.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//
// 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/>.

20
#pragma once
21

22
#include <spot/twa/twagraph.hh>
23
24
25

namespace spot
{
26
  /// \brief Attempt to synthetize an equivalent deterministic TωA
27
  /// with a SAT solver.
28
  ///
29
  /// \param a the input TωA.  It should be a deterministic TωA.
30
  ///
31
32
33
  /// \param target_acc_number is the number of acceptance sets wanted
  /// in the result.
  ///
34
35
  /// \param target_acc the target acceptance condition
  ///
36
37
38
  /// \param target_state_number is the desired number of states in
  /// the result.  The output may have less than \a
  /// target_state_number reachable states.
39
  ///
40
  /// \param state_based set to true to force all outgoing transitions
41
  /// of a state to share the same acceptance conditions.
42
  ///
43
44
45
  /// \param colored if true, force all transitions to belong to
  /// exactly one acceptance set.
  ///
46
  /// This functions attempts to find a TωA with \a target_acc_number
47
  /// acceptance sets and target_state_number states that is
48
  /// equivalent to \a a.  If no such TωA is found, a null pointer is
49
  /// returned.
50
  SPOT_API twa_graph_ptr
51
  dtwa_sat_synthetize(const const_twa_graph_ptr& a,
52
53
54
55
56
                      unsigned target_acc_number,
                      const acc_cond::acc_code& target_acc,
                      int target_state_number,
                      bool state_based = false,
                      bool colored = false);
57

58
  /// \brief Attempt to minimize a deterministic TωA with a SAT solver.
59
  ///
60
  /// This calls dtwa_sat_synthetize() in a loop, with a decreasing
61
62
  /// number of states, and returns the last successfully built TGBA.
  ///
63
  /// If no smaller TGBA exists, this returns a null pointer.
64
  SPOT_API twa_graph_ptr
65
  dtwa_sat_minimize(const const_twa_graph_ptr& a,
66
67
68
69
70
                    unsigned target_acc_number,
                    const acc_cond::acc_code& target_acc,
                    bool state_based = false,
                    int max_states = -1,
                    bool colored = false);
71

72
  /// \brief Attempt to minimize a deterministic TωA with a SAT solver.
73
  ///
74
  /// This calls dtwa_sat_synthetize() in a loop, but attempting to
75
76
77
  /// find the minimum number of states using a binary search.
  //
  /// If no smaller TBA exist, this returns a null pointer.
78
  SPOT_API twa_graph_ptr
79
  dtwa_sat_minimize_dichotomy(const const_twa_graph_ptr& a,
80
81
82
                              unsigned target_acc_number,
                              const acc_cond::acc_code& target_acc,
                              bool state_based = false,
83
                              bool langmap = false,
84
85
                              int max_states = -1,
                              bool colored = false);
86

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  /// \brief Attempt to minimize a deterministic TωA with a SAT solver.
  ///
  /// It acts like dtwa_sat_synthetisze() and obtains a first minimized
  /// automaton. Then, incrementally, it encodes and solves the deletion of one
  /// state as many time as param value.
  /// If param >= 0, this process is fully repeated until the minimal automaton
  /// is found. Otherwise, it continues to delete states one by one
  /// incrementally until the minimal automaton is found.
  ///
  /// If no smaller TGBA exists, this returns a null pointer.
  SPOT_API twa_graph_ptr
  dtwa_sat_minimize_incr(const const_twa_graph_ptr& a,
                         unsigned target_acc_number,
                         const acc_cond::acc_code& target_acc,
                         bool state_based = false,
                         int max_states = -1,
                         bool colored = false,
                         int param = 2);

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
  /// \brief Attempt to minimize a deterministic TωA with a SAT solver.
  ///
  /// This acts like dtba_sat_synthetize() and obtains a first minimized
  /// automaton. Then, it adds <param> assumptions, such that each assumption
  /// removes a new state and implies the previous assumptions. A first
  /// resolution is attempted assuming the last assumption (thus involving all
  /// the previous ones). If the problem is SAT several stages have just been
  /// won and all this process is restarted. Otherwise, it is known that the
  /// minimal automaton can be obtained with fewer assumption. This
  /// automaton is found dichotomously.
  ///
  /// If no smaller TGBA exists, this returns a null pointer.
  SPOT_API twa_graph_ptr
  dtwa_sat_minimize_assume(const const_twa_graph_ptr& a,
                           unsigned target_acc_number,
                           const acc_cond::acc_code& target_acc,
                           bool state_based = false,
                           int max_states = -1,
                           bool colored = false,
                           int param = 6);

127
128
129
  /// \brief High-level interface to SAT-based minimization
  ///
  /// Minimize the automaton \a aut, using options \a opt.
130
  /// These options are given as a comma-separated list of
131
132
  /// assignments of the form:
  ///
133
134
135
136
137
  ///   states = 10      // synthetize automaton with fixed number of states
  ///   max-states = 20  // minimize starting from this upper bound
  ///   acc = "generalized-Buchi 2"
  ///   acc = "Rabin 3"
  ///   acc = "same" /* default */
138
139
140
141
  ///   dichotomy = 1    // use dichotomy
  ///   incr = 1         // use satsolver incrementally to attempt to delete a
  ///                       fixed number of states before starting from scratch
  ///   incr < 0         // use satsolver incrementally, never restart
142
  ///   colored = 1      // build a colored TωA
143
144
  ///
  SPOT_API twa_graph_ptr
145
  sat_minimize(twa_graph_ptr aut, const char* opt, bool state_based = false);
146
}