fix broken use of iterator
[satcheck.git] / constraint.h
1 /*      Copyright (c) 2015 Regents of the University of California
2  *
3  *      Author: Brian Demsky <bdemsky@uci.edu>
4  *
5  *      This program is free software; you can redistribute it and/or
6  *      modify it under the terms of the GNU General Public License
7  *      version 2 as published by the Free Software Foundation.
8  */
9
10 #ifndef CONSTRAINT_H
11 #define CONSTRAINT_H
12 #include "classlist.h"
13 #include "stl-model.h"
14
15 enum ConstraintType {
16         TRUE, FALSE, IMPLIES, AND, OR, VAR, NOTVAR, BOGUS
17 };
18
19 typedef enum ConstraintType CType;
20
21 class Constraint {
22  public:
23         Constraint(CType t, Constraint *l, Constraint *r);
24         Constraint(CType t, Constraint *l);
25         Constraint(CType t, uint num, Constraint ** array);
26         Constraint(CType t, uint var);
27         Constraint(CType t);
28         ~Constraint();
29         void print();
30         void printDIMACS(ConstGen *cg);
31         uint getVar() {ASSERT(type==VAR); return numoperandsorvar;}
32         ModelVector<Constraint *> * simplify();
33         CType getType() {return type;}
34         bool isFalse() {return type==FALSE;}
35         bool isTrue() {return type==TRUE;}
36         void free();
37         void freerec();
38         Constraint * clone();
39         void setNeg(Constraint *c) {neg=c;}
40         Constraint *negate();
41
42         MEMALLOC;
43  private:
44         CType type;
45         uint numoperandsorvar;
46         Constraint ** operands;
47         Constraint *neg;
48         friend class ConstGen;
49         friend bool mergeandfree(ModelVector<Constraint *> * to, ModelVector<Constraint *> * from);
50 };
51
52 extern Constraint ctrue;
53 extern Constraint cfalse;
54
55 Constraint * generateConstraint(uint numvars, Constraint ** vars, uint value);
56 Constraint * generateLTConstraint(ConstGen *cg, uint numvars, Constraint ** vars, uint value);
57 Constraint * generateEquivConstraint(uint numvars, Constraint **var1, Constraint **var2);
58 Constraint * generateEquivConstraint(Constraint *var1, Constraint *var2);
59 #endif