equals.cc 3.26 KB
Newer Older
1
// Copyright (C) 2003, 2004, 2006, 2008, 2009 Laboratoire d'Informatique de
2
3
// Paris 6 (LIP6), dpartement Systmes Rpartis Coopratifs (SRC),
// Universit Pierre et Marie Curie.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//
// 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.

22
#include <iostream>
23
#include <cassert>
24
25
#include <cstdlib>
#include <cstring>
26
#include "ltlparse/public.hh"
27
#include "ltlvisit/lunabbrev.hh"
28
#include "ltlvisit/tunabbrev.hh"
29
#include "ltlvisit/dump.hh"
30
#include "ltlvisit/nenoform.hh"
31
#include "ltlvisit/contain.hh"
32
#include "ltlast/allnodes.hh"
33
#include "ltlvisit/reduce.hh"
34
#include "ltlvisit/tostring.hh"
35
36

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

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

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

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

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

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

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

70
71
72
#if (defined LUNABBREV) || (defined TUNABBREV) || (defined NENOFORM)
  spot::ltl::formula* tmp;
#endif
73
#ifdef LUNABBREV
74
  tmp = f1;
75
  f1 = spot::ltl::unabbreviate_logic(f1);
76
  tmp->destroy();
77
  spot::ltl::dump(std::cout, f1);
78
  std::cout << std::endl;
79
#endif
80
#ifdef TUNABBREV
81
  tmp = f1;
82
  f1 = spot::ltl::unabbreviate_ltl(f1);
83
  tmp->destroy();
84
  spot::ltl::dump(std::cout, f1);
85
86
87
  std::cout << std::endl;
#endif
#ifdef NENOFORM
88
  tmp = f1;
89
  f1 = spot::ltl::negative_normal_form(f1);
90
  tmp->destroy();
91
  spot::ltl::dump(std::cout, f1);
92
  std::cout << std::endl;
93
#endif
94
95
96
97
#ifdef REDUC
  spot::ltl::formula* tmp;
  tmp = f1;
  f1 = spot::ltl::reduce(f1);
98
  tmp->destroy();
99
100
  spot::ltl::dump(std::cout, f1);
#endif
101
102
103
104
#ifdef REDUC_TAU
  spot::ltl::formula* tmp;
  tmp = f1;
  f1 = spot::ltl::reduce_tau03(f1, false);
105
  tmp->destroy();
106
107
108
109
110
111
  spot::ltl::dump(std::cout, f1);
#endif
#ifdef REDUC_TAUSTR
  spot::ltl::formula* tmp;
  tmp = f1;
  f1 = spot::ltl::reduce_tau03(f1, true);
112
  tmp->destroy();
113
114
  spot::ltl::dump(std::cout, f1);
#endif
115

116
  int exit_code = f1 != f2;
117

118
119
  f1->destroy();
  f2->destroy();
120
121
122
123
  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);
124

125
  return exit_code;
126
}