Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
7facbc3c
Commit
7facbc3c
authored
Dec 23, 2011
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transforming the solver to use different clause representation.
parent
94174d0f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
90 deletions
+44
-90
src/sat/bsat/satProof.c
+20
-82
src/sat/bsat/satSolver2.c
+2
-2
src/sat/bsat/vecRec.h
+22
-6
No files found.
src/sat/bsat/satProof.c
View file @
7facbc3c
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "vec.h"
#include "vec.h"
#include "aig.h"
#include "aig.h"
#include "satTruth.h"
#include "satTruth.h"
#include "vecRec.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -36,67 +37,6 @@ ABC_NAMESPACE_IMPL_START
...
@@ -36,67 +37,6 @@ ABC_NAMESPACE_IMPL_START
They are marked by bitshifting by 2 bits up and setting the LSB to 1
They are marked by bitshifting by 2 bits up and setting the LSB to 1
*/
*/
// data-structure to record resolvents of the proof
typedef
struct
Rec_Int_t_
Rec_Int_t
;
struct
Rec_Int_t_
{
int
nShift
;
// log number of entries on a page
int
Mask
;
// mask for entry number on a page
int
nSize
;
// the total number of entries
int
nLast
;
// the total number of entries before last append
Vec_Ptr_t
*
vPages
;
// memory pages
};
static
inline
Rec_Int_t
*
Rec_IntAlloc
(
int
nShift
)
{
Rec_Int_t
*
p
;
p
=
ABC_CALLOC
(
Rec_Int_t
,
1
);
p
->
nShift
=
nShift
;
p
->
Mask
=
(
1
<<
nShift
)
-
1
;
p
->
vPages
=
Vec_PtrAlloc
(
50
);
return
p
;
}
static
inline
int
Rec_IntSize
(
Rec_Int_t
*
p
)
{
return
p
->
nSize
;
}
static
inline
int
Rec_IntSizeLast
(
Rec_Int_t
*
p
)
{
return
p
->
nLast
;
}
static
inline
void
Rec_IntPush
(
Rec_Int_t
*
p
,
int
Entry
)
{
if
(
(
p
->
nSize
>>
p
->
nShift
)
==
Vec_PtrSize
(
p
->
vPages
)
)
Vec_PtrPush
(
p
->
vPages
,
ABC_ALLOC
(
int
,
p
->
Mask
+
1
)
);
((
int
*
)
Vec_PtrEntry
(
p
->
vPages
,
p
->
nSize
>>
p
->
nShift
))[
p
->
nSize
++
&
p
->
Mask
]
=
Entry
;
}
static
inline
void
Rec_IntAppend
(
Rec_Int_t
*
p
,
int
*
pArray
,
int
nSize
)
{
assert
(
nSize
<=
p
->
Mask
);
if
(
(
p
->
nSize
&
p
->
Mask
)
+
nSize
>=
p
->
Mask
)
{
Rec_IntPush
(
p
,
0
);
p
->
nSize
=
((
p
->
nSize
>>
p
->
nShift
)
+
1
)
*
(
p
->
Mask
+
1
);
}
if
(
(
p
->
nSize
>>
p
->
nShift
)
==
Vec_PtrSize
(
p
->
vPages
)
)
Vec_PtrPush
(
p
->
vPages
,
ABC_ALLOC
(
int
,
p
->
Mask
+
1
)
);
// assert( (p->nSize >> p->nShift) + 1 == Vec_PtrSize(p->vPages) );
memmove
(
(
int
*
)
Vec_PtrEntry
(
p
->
vPages
,
p
->
nSize
>>
p
->
nShift
)
+
(
p
->
nSize
&
p
->
Mask
),
pArray
,
sizeof
(
int
)
*
nSize
);
p
->
nLast
=
p
->
nSize
;
p
->
nSize
+=
nSize
;
}
static
inline
int
Rec_IntEntry
(
Rec_Int_t
*
p
,
int
i
)
{
return
((
int
*
)
p
->
vPages
->
pArray
[
i
>>
p
->
nShift
])[
i
&
p
->
Mask
];
}
static
inline
int
*
Rec_IntEntryP
(
Rec_Int_t
*
p
,
int
i
)
{
return
(
int
*
)
p
->
vPages
->
pArray
[
i
>>
p
->
nShift
]
+
(
i
&
p
->
Mask
);
}
static
inline
void
Rec_IntFree
(
Rec_Int_t
*
p
)
{
Vec_PtrFreeFree
(
p
->
vPages
);
ABC_FREE
(
p
);
}
/*
/*
typedef struct satset_t satset;
typedef struct satset_t satset;
...
@@ -118,12 +58,12 @@ struct satset_t
...
@@ -118,12 +58,12 @@ struct satset_t
/// DECLARATIONS ///
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
static
inline
satset
*
Proof_NodeRead
(
Vec_Int_t
*
p
,
cla
h
)
{
return
satset_read
(
(
veci
*
)
p
,
h
);
}
static
inline
satset
*
Proof_NodeRead
(
Vec_Int_t
*
p
,
cla
h
)
{
return
satset_read
(
(
veci
*
)
p
,
h
);
}
static
inline
cla
Proof_NodeHandle
(
Vec_Int_t
*
p
,
satset
*
c
)
{
return
satset_handle
(
(
veci
*
)
p
,
c
);
}
static
inline
cla
Proof_NodeHandle
(
Vec_Int_t
*
p
,
satset
*
c
)
{
return
satset_handle
(
(
veci
*
)
p
,
c
);
}
static
inline
int
Proof_NodeCheck
(
Vec_Int_t
*
p
,
satset
*
c
)
{
return
satset_check
(
(
veci
*
)
p
,
c
);
}
static
inline
int
Proof_NodeCheck
(
Vec_Int_t
*
p
,
satset
*
c
)
{
return
satset_check
(
(
veci
*
)
p
,
c
);
}
static
inline
int
Proof_NodeSize
(
int
nEnts
)
{
return
sizeof
(
satset
)
/
4
+
nEnts
;
}
static
inline
int
Proof_NodeSize
(
int
nEnts
)
{
return
sizeof
(
satset
)
/
4
+
nEnts
;
}
static
inline
satset
*
Proof_ResolveRead
(
Rec_Int_t
*
p
,
cla
h
)
{
return
(
satset
*
)
Rec_Int
EntryP
(
p
,
h
);
}
static
inline
satset
*
Proof_ResolveRead
(
Vec_Rec_t
*
p
,
cla
h
)
{
return
(
satset
*
)
Vec_Rec
EntryP
(
p
,
h
);
}
// iterating through nodes in the proof
// iterating through nodes in the proof
#define Proof_ForeachNode( p, pNode, h ) \
#define Proof_ForeachNode( p, pNode, h ) \
...
@@ -418,9 +358,6 @@ void Sat_ProofReduce( sat_solver2 * s )
...
@@ -418,9 +358,6 @@ void Sat_ProofReduce( sat_solver2 * s )
}
}
/**Function*************************************************************
/**Function*************************************************************
Synopsis [Performs one resultion step.]
Synopsis [Performs one resultion step.]
...
@@ -432,10 +369,10 @@ void Sat_ProofReduce( sat_solver2 * s )
...
@@ -432,10 +369,10 @@ void Sat_ProofReduce( sat_solver2 * s )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
satset
*
Sat_ProofCheckResolveOne
(
Rec_Int
_t
*
p
,
satset
*
c1
,
satset
*
c2
,
Vec_Int_t
*
vTemp
)
int
Sat_ProofCheckResolveOne
(
Vec_Rec
_t
*
p
,
satset
*
c1
,
satset
*
c2
,
Vec_Int_t
*
vTemp
)
{
{
satset
*
c
;
satset
*
c
;
int
i
,
k
,
Var
=
-
1
,
Count
=
0
;
int
h
,
i
,
k
,
Var
=
-
1
,
Count
=
0
;
// find resolution variable
// find resolution variable
for
(
i
=
0
;
i
<
(
int
)
c1
->
nEnts
;
i
++
)
for
(
i
=
0
;
i
<
(
int
)
c1
->
nEnts
;
i
++
)
for
(
k
=
0
;
k
<
(
int
)
c2
->
nEnts
;
k
++
)
for
(
k
=
0
;
k
<
(
int
)
c2
->
nEnts
;
k
++
)
...
@@ -447,12 +384,12 @@ satset * Sat_ProofCheckResolveOne( Rec_Int_t * p, satset * c1, satset * c2, Vec_
...
@@ -447,12 +384,12 @@ satset * Sat_ProofCheckResolveOne( Rec_Int_t * p, satset * c1, satset * c2, Vec_
if
(
Count
==
0
)
if
(
Count
==
0
)
{
{
printf
(
"Cannot find resolution variable
\n
"
);
printf
(
"Cannot find resolution variable
\n
"
);
return
NULL
;
return
0
;
}
}
if
(
Count
>
1
)
if
(
Count
>
1
)
{
{
printf
(
"Found more than 1 resolution variables
\n
"
);
printf
(
"Found more than 1 resolution variables
\n
"
);
return
NULL
;
return
0
;
}
}
// perform resolution
// perform resolution
Vec_IntClear
(
vTemp
);
Vec_IntClear
(
vTemp
);
...
@@ -465,11 +402,11 @@ satset * Sat_ProofCheckResolveOne( Rec_Int_t * p, satset * c1, satset * c2, Vec_
...
@@ -465,11 +402,11 @@ satset * Sat_ProofCheckResolveOne( Rec_Int_t * p, satset * c1, satset * c2, Vec_
if
(
(
c2
->
pEnts
[
i
]
>>
1
)
!=
Var
)
if
(
(
c2
->
pEnts
[
i
]
>>
1
)
!=
Var
)
Vec_IntPushUnique
(
vTemp
,
c2
->
pEnts
[
i
]
);
Vec_IntPushUnique
(
vTemp
,
c2
->
pEnts
[
i
]
);
// create new resolution entry
// create new resolution entry
Rec_IntAppend
(
p
,
Vec_IntArray
(
vTemp
),
Vec_IntSize
(
vTemp
)
);
h
=
Vec_RecPush
(
p
,
Vec_IntArray
(
vTemp
),
Vec_IntSize
(
vTemp
)
);
// return the new entry
// return the new entry
c
=
Proof_ResolveRead
(
p
,
Rec_IntSizeLast
(
p
)
);
c
=
Proof_ResolveRead
(
p
,
h
);
c
->
nEnts
=
Vec_IntSize
(
vTemp
)
-
2
;
c
->
nEnts
=
Vec_IntSize
(
vTemp
)
-
2
;
return
c
;
return
h
;
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -483,7 +420,7 @@ satset * Sat_ProofCheckResolveOne( Rec_Int_t * p, satset * c1, satset * c2, Vec_
...
@@ -483,7 +420,7 @@ satset * Sat_ProofCheckResolveOne( Rec_Int_t * p, satset * c1, satset * c2, Vec_
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
satset
*
Sat_ProofCheckReadOne
(
Vec_Int_t
*
vClauses
,
Vec_Int_t
*
vProof
,
Rec_Int
_t
*
vResolves
,
int
iAnt
)
satset
*
Sat_ProofCheckReadOne
(
Vec_Int_t
*
vClauses
,
Vec_Int_t
*
vProof
,
Vec_Rec
_t
*
vResolves
,
int
iAnt
)
{
{
satset
*
pAnt
;
satset
*
pAnt
;
if
(
iAnt
&
1
)
if
(
iAnt
&
1
)
...
@@ -511,26 +448,26 @@ void Sat_ProofCheck( sat_solver2 * s )
...
@@ -511,26 +448,26 @@ void Sat_ProofCheck( sat_solver2 * s )
Vec_Int_t
*
vProof
=
(
Vec_Int_t
*
)
&
s
->
proofs
;
Vec_Int_t
*
vProof
=
(
Vec_Int_t
*
)
&
s
->
proofs
;
int
hRoot
=
veci_begin
(
&
s
->
claProofs
)[
satset_read
(
&
s
->
learnts
,
s
->
hLearntLast
>>
1
)
->
Id
];
int
hRoot
=
veci_begin
(
&
s
->
claProofs
)[
satset_read
(
&
s
->
learnts
,
s
->
hLearntLast
>>
1
)
->
Id
];
Rec_Int
_t
*
vResolves
;
Vec_Rec
_t
*
vResolves
;
Vec_Int_t
*
vUsed
,
*
vTemp
;
Vec_Int_t
*
vUsed
,
*
vTemp
;
satset
*
pSet
,
*
pSet0
,
*
pSet1
;
satset
*
pSet
,
*
pSet0
,
*
pSet1
;
int
i
,
k
,
Counter
=
0
,
clk
=
clock
();
int
i
,
k
,
Handle
,
Counter
=
0
,
clk
=
clock
();
// collect visited clauses
// collect visited clauses
vUsed
=
Proof_CollectUsedIter
(
vProof
,
NULL
,
hRoot
);
vUsed
=
Proof_CollectUsedIter
(
vProof
,
NULL
,
hRoot
);
Proof_CleanCollected
(
vProof
,
vUsed
);
Proof_CleanCollected
(
vProof
,
vUsed
);
// perform resolution steps
// perform resolution steps
vTemp
=
Vec_IntAlloc
(
1000
);
vTemp
=
Vec_IntAlloc
(
1000
);
vResolves
=
Rec_IntAlloc
(
20
);
vResolves
=
Vec_RecAlloc
();
Rec_IntPush
(
vResolves
,
-
1
);
Proof_ForeachNodeVec
(
vUsed
,
vProof
,
pSet
,
i
)
Proof_ForeachNodeVec
(
vUsed
,
vProof
,
pSet
,
i
)
{
{
pSet0
=
Sat_ProofCheckReadOne
(
vClauses
,
vProof
,
vResolves
,
pSet
->
pEnts
[
0
]
);
pSet0
=
Sat_ProofCheckReadOne
(
vClauses
,
vProof
,
vResolves
,
pSet
->
pEnts
[
0
]
);
for
(
k
=
1
;
k
<
(
int
)
pSet
->
nEnts
;
k
++
)
for
(
k
=
1
;
k
<
(
int
)
pSet
->
nEnts
;
k
++
)
{
{
pSet1
=
Sat_ProofCheckReadOne
(
vClauses
,
vProof
,
vResolves
,
pSet
->
pEnts
[
k
]
);
pSet1
=
Sat_ProofCheckReadOne
(
vClauses
,
vProof
,
vResolves
,
pSet
->
pEnts
[
k
]
);
pSet0
=
Sat_ProofCheckResolveOne
(
vResolves
,
pSet0
,
pSet1
,
vTemp
);
Handle
=
Sat_ProofCheckResolveOne
(
vResolves
,
pSet0
,
pSet1
,
vTemp
);
pSet0
=
Proof_ResolveRead
(
vResolves
,
Handle
);
}
}
pSet
->
Id
=
Rec_IntSizeLast
(
vResolves
)
;
pSet
->
Id
=
Handle
;
//printf( "Clause for proof %d: ", Vec_IntEntry(vUsed, i) );
//printf( "Clause for proof %d: ", Vec_IntEntry(vUsed, i) );
//satset_print( pSet0 );
//satset_print( pSet0 );
Counter
++
;
Counter
++
;
...
@@ -539,17 +476,18 @@ void Sat_ProofCheck( sat_solver2 * s )
...
@@ -539,17 +476,18 @@ void Sat_ProofCheck( sat_solver2 * s )
// clean the proof
// clean the proof
Proof_CleanCollected
(
vProof
,
vUsed
);
Proof_CleanCollected
(
vProof
,
vUsed
);
// compare the final clause
// compare the final clause
printf
(
"Used %6.2f Mb for resolvents.
\n
"
,
4
.
0
*
Rec_Int
Size
(
vResolves
)
/
(
1
<<
20
)
);
printf
(
"Used %6.2f Mb for resolvents.
\n
"
,
4
.
0
*
Vec_Rec
Size
(
vResolves
)
/
(
1
<<
20
)
);
if
(
pSet0
->
nEnts
>
0
)
if
(
pSet0
->
nEnts
>
0
)
printf
(
"Derived clause with %d lits instead of the empty clause. "
,
pSet0
->
nEnts
);
printf
(
"Derived clause with %d lits instead of the empty clause. "
,
pSet0
->
nEnts
);
else
else
printf
(
"Proof verification successful. "
);
printf
(
"Proof verification successful. "
);
Abc_PrintTime
(
1
,
"Time"
,
clock
()
-
clk
);
Abc_PrintTime
(
1
,
"Time"
,
clock
()
-
clk
);
// cleanup
// cleanup
Rec_Int
Free
(
vResolves
);
Vec_Rec
Free
(
vResolves
);
Vec_IntFree
(
vUsed
);
Vec_IntFree
(
vUsed
);
}
}
/**Function*************************************************************
/**Function*************************************************************
Synopsis [Collects nodes belonging to the UNSAT core.]
Synopsis [Collects nodes belonging to the UNSAT core.]
...
...
src/sat/bsat/satSolver2.c
View file @
7facbc3c
...
@@ -1317,8 +1317,8 @@ void sat_solver2_delete(sat_solver2* s)
...
@@ -1317,8 +1317,8 @@ void sat_solver2_delete(sat_solver2* s)
veci_delete( pCore );
veci_delete( pCore );
ABC_FREE( pCore );
ABC_FREE( pCore );
*/
*/
//
if ( s->fProofLogging )
if
(
s
->
fProofLogging
)
//
Sat_ProofCheck( s );
Sat_ProofCheck
(
s
);
// delete vectors
// delete vectors
veci_delete
(
&
s
->
order
);
veci_delete
(
&
s
->
order
);
...
...
src/sat/bsat/vecRec.h
View file @
7facbc3c
...
@@ -128,9 +128,9 @@ static inline void Vec_RecAlloc_( Vec_Rec_t * p )
...
@@ -128,9 +128,9 @@ static inline void Vec_RecAlloc_( Vec_Rec_t * p )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
static
inline
int
Vec_Rec
EntryNum
(
Vec_Rec_t
*
p
)
static
inline
int
Vec_Rec
Chunk
(
int
i
)
{
{
return
p
->
nEntries
;
return
i
>>
16
;
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -144,9 +144,9 @@ static inline int Vec_RecEntryNum( Vec_Rec_t * p )
...
@@ -144,9 +144,9 @@ static inline int Vec_RecEntryNum( Vec_Rec_t * p )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
static
inline
int
Vec_Rec
Chunk
(
int
i
)
static
inline
int
Vec_Rec
Shift
(
int
i
)
{
{
return
i
>>
16
;
return
i
&
0xFFFF
;
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -160,9 +160,25 @@ static inline int Vec_RecChunk( int i )
...
@@ -160,9 +160,25 @@ static inline int Vec_RecChunk( int i )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
static
inline
int
Vec_RecS
hift
(
int
i
)
static
inline
int
Vec_RecS
ize
(
Vec_Rec_t
*
p
)
{
{
return
i
&
0xFFFF
;
return
Vec_RecChunk
(
p
->
hCurrent
)
*
(
1
<<
p
->
LogSize
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
int
Vec_RecEntryNum
(
Vec_Rec_t
*
p
)
{
return
p
->
nEntries
;
}
}
/**Function*************************************************************
/**Function*************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment