-
Notifications
You must be signed in to change notification settings - Fork 1
/
TLFormulaOR.cpp
126 lines (96 loc) · 2.65 KB
/
TLFormulaOR.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* File: TLFormulaOR.cc
* Project: QUEST
* Author: Marc Diefenbruch, Axel M. Hirche
* Date: (C) 1997, 1998 University of Essen, Germany
*/
#include "TLFormulaOR.h"
#include "TLFormulaAND.h"
#include "TLFormulaNOT.h"
#include "TLFormulaTRUE.h"
#if _SC_DMALLOC
#include <dmalloc.h>
#endif
#if _TL_INLINING_ == 0
#include "TLFormulaOR.inl.h"
#endif
TLFormulaOR::~TLFormulaOR (void)
{
/* void */
}
TLFormula* TLFormulaOR::GetCopy (void) const
{
return new TLFormulaOR (this);
}
TLFormula* TLFormulaOR::Rewrite (void) const
{
assert (leftOperand);
assert (rightOperand);
if (simplifyFormulae)
{
if (*leftOperand == *rightOperand)
{
return leftOperand->GetCopy(); // a || a <-> a
}
if ( ( (leftOperand->Operator() == NOT)
&& (*((TLFormulaNOT*)leftOperand)->RightOperand() == *rightOperand))
|| ( (rightOperand->Operator() == NOT)
&& (*((TLFormulaNOT*)rightOperand)->RightOperand() == *leftOperand))
)
{
return new TLFormulaTRUE(); // a || ~a <-> TRUE
}
}
return new TLFormulaOR (leftOperand->Rewrite(),
rightOperand->Rewrite());
}
TLFormula* TLFormulaOR::PushNegations (SCBoolean doIt) const
{
if (doIt)
return new TLFormulaAND (leftOperand->PushNegations(doIt),
rightOperand->PushNegations(doIt));
else
return new TLFormulaOR (leftOperand->PushNegations(doIt),
rightOperand->PushNegations(doIt));
}
SCNatural TLFormulaOR::GetPrecedenceLevel (void) const
{
return PREC_LEVEL_0;
}
SCBoolean TLFormulaOR::operator== (const TLFormula& phi) const
{
TLFormulaOR* tmpPhi = (TLFormulaOR*) φ
if (op != tmpPhi->op)
return false;
assert (leftOperand);
assert (rightOperand);
assert (tmpPhi->leftOperand);
assert (tmpPhi->rightOperand);
if (*leftOperand == *(tmpPhi->leftOperand)) // left == left
{
if (*rightOperand == *(tmpPhi->rightOperand)) // right == right
{
return true; // o.k.
}
}
if (*leftOperand == *(tmpPhi->rightOperand)) // try it the other way round
{
if (*rightOperand == *(tmpPhi->leftOperand))
{
return true;
}
}
return false; // Forget it babe...
}
SCBoolean TLFormulaOR::operator== (const TLFormula* phi) const
{
return *this == *phi;
}
SCBoolean TLFormulaOR::operator!= (const TLFormula& pPhi) const
{
return !(*this == pPhi);
}
SCBoolean TLFormulaOR::operator!= (const TLFormula* pPhi) const
{
return !(*this == *pPhi);
}