ABC: A System for Sequential Synthesis and Verification
Loading...
Searching...
No Matches
watch.hpp
Go to the documentation of this file.
1
#ifndef _watch_hpp_INCLUDED
2
#define _watch_hpp_INCLUDED
3
4
#include "
global.h
"
5
6
#include <cassert>
7
#include <vector>
8
9
ABC_NAMESPACE_CXX_HEADER_START
10
11
namespace
CaDiCaL
{
12
13
// Watch lists for CDCL search. The blocking literal (see also comments
14
// related to 'propagate') is a must and thus combining that with a 64 bit
15
// pointer will give a 16 byte (8 byte aligned) structure anyhow, which
16
// means the additional 4 bytes for the size come for free. As alternative
17
// one could use a 32-bit reference instead of the pointer which would
18
// however limit the number of clauses to '2^32 - 1'. One would also need
19
// to use at least one more bit (either taken away from the variable space
20
// or the clauses) to denote whether the watch is binary.
21
22
// in fashion of Intel Sat 10.4230/LIPIcs.SAT.2022.8 we try to
23
// guarantee the following invariant:
24
// For both watches:
25
// if the watched literal is negatively assigned
26
// either it will be propagated in the future
27
// or the corresponding blocking literal is positively assigned
28
// and its level is smaller than the level of the watched literal
29
//
30
31
struct
Clause
;
32
33
struct
Watch
{
34
35
Clause
*
clause
;
36
int
blit
;
37
int
size
;
38
39
Watch
(
int
b,
Clause
*c) :
clause
(c),
blit
(b),
size
(c->
size
) {}
40
Watch
() {}
41
42
bool
binary
()
const
{
return
size
== 2; }
43
};
44
45
typedef
vector<Watch>
Watches
;
// of one literal
46
47
typedef
Watches::iterator
watch_iterator
;
48
typedef
Watches::const_iterator
const_watch_iterator
;
49
50
inline
void
remove_watch
(
Watches
&ws,
Clause
*
clause
) {
51
const
auto
end = ws.end ();
52
auto
i = ws.begin ();
53
for
(
auto
j = i; j != end; j++) {
54
const
Watch
&w = *i++ = *j;
55
if
(w.
clause
==
clause
)
56
i--;
57
}
58
CADICAL_assert
(i + 1 == end);
59
ws.resize (i - ws.begin ());
60
}
61
62
// search for the clause and updates the size marked in the watch lists
63
inline
void
update_watch_size
(
Watches
&ws,
int
blit,
Clause
*conflict) {
64
bool
found =
false
;
65
const
int
size = conflict->
size
;
66
for
(
Watch
&w : ws) {
67
if
(w.clause == conflict)
68
w.size = size, w.blit = blit, found =
true
;
69
CADICAL_assert
(w.clause->garbage || w.size == 2 || w.clause->size != 2);
70
}
71
CADICAL_assert
(found), (void) found;
72
}
73
74
}
// namespace CaDiCaL
75
76
ABC_NAMESPACE_CXX_HEADER_END
77
78
#endif
ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_START
Definition
abc_namespaces.h:52
ABC_NAMESPACE_CXX_HEADER_END
#define ABC_NAMESPACE_CXX_HEADER_END
Definition
abc_namespaces.h:53
global.h
CADICAL_assert
#define CADICAL_assert(ignore)
Definition
global.h:14
CaDiCaL
Definition
arena.hpp:8
CaDiCaL::remove_watch
void remove_watch(Watches &ws, Clause *clause)
Definition
watch.hpp:50
CaDiCaL::const_watch_iterator
Watches::const_iterator const_watch_iterator
Definition
watch.hpp:48
CaDiCaL::update_watch_size
void update_watch_size(Watches &ws, int blit, Clause *conflict)
Definition
watch.hpp:63
CaDiCaL::Watches
vector< Watch > Watches
Definition
watch.hpp:45
CaDiCaL::watch_iterator
Watches::iterator watch_iterator
Definition
watch.hpp:47
CaDiCaL::Clause
Definition
clause.hpp:34
CaDiCaL::Clause::size
int size
Definition
clause.hpp:99
CaDiCaL::Watch
Definition
watch.hpp:33
CaDiCaL::Watch::binary
bool binary() const
Definition
watch.hpp:42
CaDiCaL::Watch::size
int size
Definition
watch.hpp:37
CaDiCaL::Watch::Watch
Watch()
Definition
watch.hpp:40
CaDiCaL::Watch::clause
Clause * clause
Definition
watch.hpp:35
CaDiCaL::Watch::blit
int blit
Definition
watch.hpp:36
CaDiCaL::Watch::Watch
Watch(int b, Clause *c)
Definition
watch.hpp:39
clause
Definition
clause.h:22
vector
Definition
vector.h:32
src
sat
cadical
watch.hpp
Generated by Doxygen 1.13.2 © 2025 EPTansuo. All rights reserved.
鲁ICP备2021046540号