reduce.cc 2.26 KB
Newer Older
1
// Copyright (C) 2008, 2009, 2010, 2011 Laboratoire de Recherche et
2
// Dveloppement de l'Epita (LRDE).
Guillaume Sadegh's avatar
Guillaume Sadegh committed
3
// Copyright (C) 2004, 2006, 2007 Laboratoire d'Informatique de
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
4
// Paris 6 (LIP6), dpartement Systmes Rpartis Coopratifs (SRC),
5
// Universit Pierre et Marie Curie.
martinez's avatar
martinez committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//
// 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 2 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 Spot; see the file COPYING.  If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.

24
#include "reduce.hh"
25
#include "ltlast/allnodes.hh"
martinez's avatar
martinez committed
26
27
28
#include <cassert>

#include "lunabbrev.hh"
29
#include "simpfg.hh"
30
#include "simplify.hh"
martinez's avatar
martinez committed
31
32
33
34
35
36
37

namespace spot
{
  namespace ltl
  {

    formula*
38
    reduce(const formula* f, int opt)
39
    {
40
41
      formula* f1;
      formula* f2;
42
      formula* prev = 0;
43

44
45
46
47
48
49
50
      ltl_simplifier_options o;
      o.reduce_basics = opt & Reduce_Basics;
      o.synt_impl = opt & Reduce_Syntactic_Implications;
      o.event_univ = opt & Reduce_Eventuality_And_Universality;
      o.containment_checks = opt & Reduce_Containment_Checks;
      o.containment_checks_stronger = opt & Reduce_Containment_Checks_Stronger;
      ltl_simplifier simplifier(o);
51

52
      int n = 0;
53

54
      while (f != prev)
55
	{
56
57
58
59
	  ++n;
	  assert(n < 100);
	  if (prev)
	    {
60
	      prev->destroy();
61
62
63
64
	      prev = const_cast<formula*>(f);
	    }
	  else
	    {
65
	      prev = f->clone();
66
67
68
	    }
	  f1 = unabbreviate_logic(f);
	  f2 = simplify_f_g(f1);
69
	  f1->destroy();
70
	  f = simplifier.simplify(f2);
71
	  f2->destroy();
72
	}
73
      prev->destroy();
74

75
      return const_cast<formula*>(f);
martinez's avatar
martinez committed
76
    }
77
78
79
80

    bool
    is_eventual(const formula* f)
    {
81
      return f->is_eventual();
82
83
84
85
86
    }

    bool
    is_universal(const formula* f)
    {
87
      return f->is_universal();
88
    }
martinez's avatar
martinez committed
89
90
  }
}