equals.cc 4.2 KB
Newer Older
1
2
// Copyright (C) 2008, 2009, 2010, 2011 Laboratoire de Recherche et
// Dveloppement de l'Epita (LRDE).
Guillaume Sadegh's avatar
Guillaume Sadegh committed
3
// Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de
4
5
// Paris 6 (LIP6), dpartement Systmes Rpartis Coopratifs (SRC),
// Universit Pierre et Marie Curie.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz 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 <iostream>
25
#include <cassert>
26
27
#include <cstdlib>
#include <cstring>
28
#include "ltlparse/public.hh"
29
#include "ltlvisit/lunabbrev.hh"
30
#include "ltlvisit/tunabbrev.hh"
31
#include "ltlvisit/dump.hh"
32
#include "ltlvisit/nenoform.hh"
33
#include "ltlvisit/contain.hh"
34
#include "ltlast/allnodes.hh"
35
#include "ltlvisit/simplify.hh"
36
#include "ltlvisit/tostring.hh"
37
38

void
39
syntax(char* prog)
40
{
41
  std::cerr << prog << " [-E] formula1 formula2" << std::endl;
42
43
44
45
  exit(2);
}

int
46
main(int argc, char** argv)
47
{
48
49
50
51
52
53
54
55
56
  bool check_first = true;

  if (argc > 1 && !strcmp(argv[1], "-E"))
    {
      check_first = false;
      argv[1] = argv[0];
      ++argv;
      --argc;
    }
57
58
59
60
  if (argc != 3)
    syntax(argv[0]);

  spot::ltl::parse_error_list p1;
61
  spot::ltl::formula* f1 = spot::ltl::parse(argv[1], p1);
62

63
  if (check_first && spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
64
65
66
    return 2;

  spot::ltl::parse_error_list p2;
67
  spot::ltl::formula* f2 = spot::ltl::parse(argv[2], p2);
68

69
  if (spot::ltl::format_parse_errors(std::cerr, argv[2], p2))
70
71
    return 2;

72
73
74
#if (defined LUNABBREV) || (defined TUNABBREV) || (defined NENOFORM)
  spot::ltl::formula* tmp;
#endif
75
#ifdef LUNABBREV
76
  tmp = f1;
77
  f1 = spot::ltl::unabbreviate_logic(f1);
78
  tmp->destroy();
79
  spot::ltl::dump(std::cout, f1);
80
  std::cout << std::endl;
81
#endif
82
#ifdef TUNABBREV
83
  tmp = f1;
84
  f1 = spot::ltl::unabbreviate_ltl(f1);
85
  tmp->destroy();
86
  spot::ltl::dump(std::cout, f1);
87
88
89
  std::cout << std::endl;
#endif
#ifdef NENOFORM
90
  tmp = f1;
91
  f1 = spot::ltl::negative_normal_form(f1);
92
  tmp->destroy();
93
  spot::ltl::dump(std::cout, f1);
94
  std::cout << std::endl;
95
#endif
96
#ifdef REDUC
97
98
99
100
101
102
103
104
  {
    spot::ltl::ltl_simplifier_options opt(true, true, true, false, false);
    spot::ltl::ltl_simplifier simp(opt);
    spot::ltl::formula* tmp;
    tmp = f1;
    f1 = simp.simplify(f1);
    tmp->destroy();
  }
105
  spot::ltl::dump(std::cout, f1);
106
  std::cout << std::endl;
107
#endif
108
#ifdef REDUC_TAU
109
110
111
112
113
114
115
116
  {
    spot::ltl::ltl_simplifier_options opt(false, false, false, true, false);
    spot::ltl::ltl_simplifier simp(opt);
    spot::ltl::formula* tmp;
    tmp = f1;
    f1 = simp.simplify(f1);
    tmp->destroy();
  }
117
  spot::ltl::dump(std::cout, f1);
118
  std::cout << std::endl;
119
120
#endif
#ifdef REDUC_TAUSTR
121
122
123
124
125
126
127
128
  {
    spot::ltl::ltl_simplifier_options opt(false, false, false, true, true);
    spot::ltl::ltl_simplifier simp(opt);
    spot::ltl::formula* tmp;
    tmp = f1;
    f1 = simp.simplify(f1);
    tmp->destroy();
  }
129
  spot::ltl::dump(std::cout, f1);
130
  std::cout << std::endl;
131
#endif
132

133
  int exit_code = f1 != f2;
134

135
136
137
138
139
140
  if (exit_code)
    {
      spot::ltl::dump(std::cerr, f1) << std::endl;
      spot::ltl::dump(std::cerr, f2) << std::endl;
    }

141
142
  f1->destroy();
  f2->destroy();
143
144
145
146
147
148

  spot::ltl::atomic_prop::dump_instances(std::cerr);
  spot::ltl::unop::dump_instances(std::cerr);
  spot::ltl::binop::dump_instances(std::cerr);
  spot::ltl::multop::dump_instances(std::cerr);
  spot::ltl::automatop::dump_instances(std::cerr);
149
150
151
152
  assert(spot::ltl::atomic_prop::instance_count() == 0);
  assert(spot::ltl::unop::instance_count() == 0);
  assert(spot::ltl::binop::instance_count() == 0);
  assert(spot::ltl::multop::instance_count() == 0);
153
  assert(spot::ltl::automatop::instance_count() == 0);
154
  return exit_code;
155
}