blob: 1868f557df3e66292dbe0e6ddbdae06f930fc14e (
plain)
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
|
/********************* */
/*! \file predicate.cpp
** \verbatim
** Original author: mdeters
** Major contributors: none
** Minor contributors (to current version): none
** This file is part of the CVC4 prototype.
** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
** Courant Institute of Mathematical Sciences
** New York University
** See the file COPYING in the top-level source directory for licensing
** information.\endverbatim
**
** \brief Representation of predicates for predicate subtyping
**
** Simple class to represent predicates for predicate subtyping.
** Instances of this class are carried as the payload of
** the CONSTANT-metakinded SUBTYPE_TYPE types.
**/
#include "expr/expr.h"
#include "util/predicate.h"
#include "util/Assert.h"
using namespace std;
namespace CVC4 {
Predicate::Predicate(Expr e, Expr w) throw(IllegalArgumentException) : d_predicate(e), d_witness(w) {
CheckArgument(! e.isNull(), e, "Predicate cannot be null");
CheckArgument(e.getType().isPredicate(), e, "Expression given is not predicate");
CheckArgument(FunctionType(e.getType()).getArgTypes().size() == 1, e, "Expression given is not predicate of a single argument");
}
Predicate::operator Expr() const {
return d_predicate;
}
bool Predicate::operator==(const Predicate& p) const {
return d_predicate == p.d_predicate && d_witness == p.d_witness;
}
std::ostream&
operator<<(std::ostream& out, const Predicate& p) {
out << p.d_predicate;
if(! p.d_witness.isNull()) {
out << " : " << p.d_witness;
}
return out;
}
size_t PredicateHashStrategy::hash(const Predicate& p) {
ExprHashFunction h;
return h(p.d_witness) * 5039 + h(p.d_predicate);
}
}/* CVC4 namespace */
|