-
Notifications
You must be signed in to change notification settings - Fork 1
/
TLFormulaAND.cpp
126 lines (97 loc) · 2.64 KB
/
TLFormulaAND.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: TLFormulaAND.cc
* Project: QUEST
* Author: Marc Diefenbruch, Axel M. Hirche
* Date: (C) 1997, 1998 University of Essen, Germany
*/
#include "SCL/SCStream.h"
#include "TLFormulaAND.h"
#include "TLFormulaOR.h"
#include "TLFormulaNOT.h"
#include "TLFormulaFALSE.h"
#if _SC_DMALLOC
#include <dmalloc.h>
#endif
#if _TL_INLINING_ == 0
#include "TLFormulaAND.inl.h"
#endif
TLFormulaAND::~TLFormulaAND (void)
{
/* void */
}
TLFormula* TLFormulaAND::GetCopy (void) const
{
return new TLFormulaAND (this);
}
TLFormula* TLFormulaAND::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 TLFormulaFALSE(); // a && ~a <-> FALSE
}
}
return new TLFormulaAND (leftOperand->Rewrite(),
rightOperand->Rewrite());
}
TLFormula* TLFormulaAND::PushNegations (SCBoolean doIt) const
{
if (doIt)
return new TLFormulaOR (leftOperand->PushNegations(doIt),
rightOperand->PushNegations(doIt));
else
return new TLFormulaAND (leftOperand->PushNegations(doIt),
rightOperand->PushNegations(doIt));
}
SCNatural TLFormulaAND::GetPrecedenceLevel (void) const
{
return PREC_LEVEL_0;
}
SCBoolean TLFormulaAND::operator== (const TLFormula& phi) const
{
TLFormulaAND* tmpPhi = (TLFormulaAND*) φ
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 TLFormulaAND::operator== (const TLFormula* phi) const
{
return *this == *phi;
}
SCBoolean TLFormulaAND::operator!= (const TLFormula& pPhi) const
{
return !(*this == pPhi);
}
SCBoolean TLFormulaAND::operator!= (const TLFormula* pPhi) const
{
return !(*this == *pPhi);
}