ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
tracer.hpp
Go to the documentation of this file.
1#ifndef _tracer_hpp_INCLUDED
2#define _tracer_hpp_INCLUDED
3
4#include "global.h"
5
6#include <cstdint>
7#include <vector>
8
10
11namespace CaDiCaL {
12
13struct Internal;
14
16
17// Proof tracer class to observer all possible proof events,
18// such as added or deleted clauses.
19// An implementation can decide on which events to act.
20//
21class Tracer {
22
23public:
24 Tracer () {}
25 virtual ~Tracer () {}
26
27 /*------------------------------------------------------------------------*/
28 /* */
29 /* Basic Events */
30 /* */
31 /*------------------------------------------------------------------------*/
32
33 // Notify the tracer that a original clause has been added.
34 // Includes ID and whether the clause is redundant or irredundant
35 // Arguments: ID, redundant, clause, restored
36 //
37 virtual void add_original_clause (int64_t, bool, const std::vector<int> &,
38 bool = false) {}
39
40 // Notify the observer that a new clause has been derived.
41 // Includes ID and whether the clause is redundant or irredundant
42 // If antecedents are derived they will be included here.
43 // Arguments: ID, redundant, clause, antecedents
44 //
45 virtual void add_derived_clause (int64_t, bool, const std::vector<int> &,
46 const std::vector<int64_t> &) {}
47
48 // Notify the observer that a clause is deleted.
49 // Includes ID and redundant/irredundant
50 // Arguments: ID, redundant, clause
51 //
52 virtual void delete_clause (int64_t, bool, const std::vector<int> &) {}
53
54 // Notify the observer that a clause is deleted.
55 // Includes ID and redundant/irredundant
56 // Arguments: ID, redundant, clause
57 //
58 virtual void demote_clause (uint64_t, const std::vector<int> &) {}
59
60 // Notify the observer to remember that the clause might be restored later
61 // Arguments: ID, clause
62 //
63 virtual void weaken_minus (int64_t, const std::vector<int> &) {}
64
65 // Notify the observer that a clause is strengthened
66 // Arguments: ID
67 //
68 virtual void strengthen (int64_t) {}
69
70 // Notify the observer that the solve call ends with status StatusType
71 // If the status is UNSAT and an empty clause has been derived, the second
72 // argument will contain its id.
73 // Note that the empty clause is already added through add_derived_clause
74 // and finalized with finalize_clause
75 // Arguments: int, ID
76 //
77 virtual void report_status (int, int64_t) {}
78
79 /*------------------------------------------------------------------------*/
80 /* */
81 /* Specifically non-incremental */
82 /* */
83 /*------------------------------------------------------------------------*/
84
85 // Notify the observer that a clause is finalized.
86 // Arguments: ID, clause
87 //
88 virtual void finalize_clause (int64_t, const std::vector<int> &) {}
89
90 // Notify the observer that the proof begins with a set of reserved ids
91 // for original clauses. Given ID is the first derived clause ID.
92 // Arguments: ID
93 //
94 virtual void begin_proof (int64_t) {}
95
96 /*------------------------------------------------------------------------*/
97 /* */
98 /* Specifically incremental */
99 /* */
100 /*------------------------------------------------------------------------*/
101
102 // Notify the observer that an assumption has been added
103 // Arguments: assumption_literal
104 //
105 virtual void solve_query () {}
106
107 // Notify the observer that an assumption has been added
108 // Arguments: assumption_literal
109 //
110 virtual void add_assumption (int) {}
111
112 // Notify the observer that a constraint has been added
113 // Arguments: constraint_clause
114 //
115 virtual void add_constraint (const std::vector<int> &) {}
116
117 // Notify the observer that assumptions and constraints are reset
118 //
119 virtual void reset_assumptions () {}
120
121 // Notify the observer that this clause could be derived, which
122 // is the negation of a core of failing assumptions/constraints.
123 // If antecedents are derived they will be included here.
124 // Arguments: ID, clause, antecedents
125 //
126 virtual void add_assumption_clause (int64_t, const std::vector<int> &,
127 const std::vector<int64_t> &) {}
128
129 // Notify the observer that conclude unsat was requested.
130 // will give either the id of the empty clause, the id of a failing
131 // assumption clause or the ids of the failing constrain clauses
132 // Arguments: conclusion_type, clause_ids
133 //
135 const std::vector<int64_t> &) {}
136
137 // Notify the observer that conclude sat was requested.
138 // will give the complete model as a vector.
139 //
140 virtual void conclude_sat (const std::vector<int> &) {}
141
142 // Notify the observer that conclude unknown was requested.
143 // will give the current trail as a vector.
144 //
145 virtual void conclude_unknown (const std::vector<int> &) {}
146};
147
148/*--------------------------------------------------------------------------*/
149
150// Following tracers for internal use.
151
152struct InternalTracer : public Tracer {
153public:
155 virtual ~InternalTracer () {}
156
157 virtual void connect_internal (Internal *) {}
158};
159
161public:
163 virtual ~StatTracer () {}
164
165 virtual void print_stats () {}
166};
167
169
170public:
172 virtual ~FileTracer () {}
173
174 virtual bool closed () = 0;
175 virtual void close (bool print = false) = 0;
176 virtual void flush (bool print = false) = 0;
177};
178
179} // namespace CaDiCaL
180
182
183#endif
#define ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_END
virtual bool closed()=0
virtual void flush(bool print=false)=0
virtual void close(bool print=false)=0
virtual ~FileTracer()
Definition tracer.hpp:172
virtual void print_stats()
Definition tracer.hpp:165
virtual ~StatTracer()
Definition tracer.hpp:163
virtual void add_constraint(const std::vector< int > &)
Definition tracer.hpp:115
virtual void add_derived_clause(int64_t, bool, const std::vector< int > &, const std::vector< int64_t > &)
Definition tracer.hpp:45
virtual void begin_proof(int64_t)
Definition tracer.hpp:94
virtual void conclude_unsat(ConclusionType, const std::vector< int64_t > &)
Definition tracer.hpp:134
virtual void add_assumption_clause(int64_t, const std::vector< int > &, const std::vector< int64_t > &)
Definition tracer.hpp:126
virtual void solve_query()
Definition tracer.hpp:105
virtual void delete_clause(int64_t, bool, const std::vector< int > &)
Definition tracer.hpp:52
virtual void reset_assumptions()
Definition tracer.hpp:119
virtual void weaken_minus(int64_t, const std::vector< int > &)
Definition tracer.hpp:63
virtual void conclude_sat(const std::vector< int > &)
Definition tracer.hpp:140
virtual void report_status(int, int64_t)
Definition tracer.hpp:77
virtual void finalize_clause(int64_t, const std::vector< int > &)
Definition tracer.hpp:88
virtual void demote_clause(uint64_t, const std::vector< int > &)
Definition tracer.hpp:58
virtual void add_original_clause(int64_t, bool, const std::vector< int > &, bool=false)
Definition tracer.hpp:37
virtual void strengthen(int64_t)
Definition tracer.hpp:68
virtual void conclude_unknown(const std::vector< int > &)
Definition tracer.hpp:145
virtual void add_assumption(int)
Definition tracer.hpp:110
virtual ~Tracer()
Definition tracer.hpp:25
ConclusionType
Definition tracer.hpp:15
@ CONFLICT
Definition tracer.hpp:15
@ ASSUMPTIONS
Definition tracer.hpp:15
@ CONSTRAINT
Definition tracer.hpp:15
virtual ~InternalTracer()
Definition tracer.hpp:155
virtual void connect_internal(Internal *)
Definition tracer.hpp:157