Skip to content

Commit 5e5c0ba

Browse files
authored
Merge branch 'master' into bugfix/issue-366
2 parents 53040e2 + d2afb85 commit 5e5c0ba

File tree

13 files changed

+701
-79
lines changed

13 files changed

+701
-79
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ jobs:
2222
mode: gcov
2323
config-opt: --enable-mcsat
2424
env: CC=gcc-13 CXX=g++-13
25+
- os: ubuntu-latest
26+
mode: debug
27+
config-opt: --enable-thread-safety --enable-mcsat
28+
env: CC=gcc CXX=g++
29+
- os: ubuntu-latest
30+
mode: release
31+
config-opt: --enable-thread-safety --enable-mcsat
32+
env: CC=gcc CXX=g++
33+
- os: ubuntu-latest
34+
mode: gcov
35+
config-opt: --enable-thread-safety --enable-mcsat
36+
env: CC=gcc-13 CXX=g++-13
2537
name: ${{ matrix.os }}|${{ matrix.mode }}|${{ matrix.config-opt }}|${{ matrix.env }} (push)
2638
runs-on: ${{ matrix.os }}
2739
steps:
@@ -36,13 +48,16 @@ jobs:
3648
env: ${{ matrix.env }}
3749
- name: Test
3850
uses: ./.github/actions/test
51+
env:
52+
TIME_LIMIT: ${{ matrix.mode == 'gcov' && contains(matrix.config-opt, '--enable-thread-safety') && contains(matrix.config-opt, '--enable-mcsat') && '120' || '60' }}
53+
REGRESS_EXCLUDE_FILTER: ${{ matrix.mode == 'gcov' && contains(matrix.config-opt, '--enable-thread-safety') && contains(matrix.config-opt, '--enable-mcsat') && 'iss517.smt2$' || '' }}
3954
with:
4055
mode: ${{ matrix.mode }}
4156
- name: Coverage
42-
if: matrix.mode == 'gcov'
57+
if: matrix.mode == 'gcov' && matrix.config-opt == '--enable-mcsat'
4358
uses: ./.github/actions/coverage
4459
- name: Coveralls
45-
if: matrix.mode == 'gcov'
60+
if: matrix.mode == 'gcov' && matrix.config-opt == '--enable-mcsat'
4661
uses: coverallsapp/github-action@master
4762
with:
4863
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -68,6 +83,22 @@ jobs:
6883
mode: debug
6984
config-opt: --enable-thread-safety --enable-mcsat
7085
env: CC=gcc CXX=g++
86+
- os: ubuntu-latest
87+
mode: release
88+
config-opt: --enable-thread-safety --enable-mcsat
89+
env: CC=gcc CXX=g++
90+
- os: ubuntu-latest
91+
mode: gcov
92+
config-opt: --enable-thread-safety --enable-mcsat
93+
env: CC=gcc-13 CXX=g++-13
94+
- os: macos-latest
95+
mode: debug
96+
config-opt: --enable-thread-safety --enable-mcsat
97+
env: CC=clang CXX=clang++
98+
- os: macos-latest
99+
mode: release
100+
config-opt: --enable-thread-safety --enable-mcsat
101+
env: CC=clang CXX=clang++
71102
name: ${{ matrix.os }}|${{ matrix.mode }}|${{ matrix.config-opt }}|${{ matrix.env }} (pr)
72103
runs-on: ${{ matrix.os }}
73104
steps:
@@ -82,13 +113,16 @@ jobs:
82113
env: ${{ matrix.env }}
83114
- name: Test
84115
uses: ./.github/actions/test
116+
env:
117+
TIME_LIMIT: ${{ matrix.mode == 'gcov' && contains(matrix.config-opt, '--enable-thread-safety') && contains(matrix.config-opt, '--enable-mcsat') && '120' || '60' }}
118+
REGRESS_EXCLUDE_FILTER: ${{ matrix.mode == 'gcov' && contains(matrix.config-opt, '--enable-thread-safety') && contains(matrix.config-opt, '--enable-mcsat') && 'iss517.smt2$' || '' }}
85119
with:
86120
mode: ${{ matrix.mode }}
87121
- name: Coverage
88-
if: matrix.mode == 'gcov'
122+
if: matrix.mode == 'gcov' && matrix.config-opt == '--enable-mcsat'
89123
uses: ./.github/actions/coverage
90124
- name: Coveralls
91-
if: matrix.mode == 'gcov'
125+
if: matrix.mode == 'gcov' && matrix.config-opt == '--enable-mcsat'
92126
uses: coverallsapp/github-action@master
93127
with:
94128
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/windows_ci.yml

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
matrix:
1010
os: [windows-latest]
1111
mode: [debug, release]
12-
config-opt: [' ', --enable-thread-safety]
12+
config-opt: [' ', --enable-thread-safety, --enable-thread-safety --enable-mcsat]
1313

1414
name: ${{ matrix.os }}|${{ matrix.mode }}|${{ matrix.config-opt}}
1515
runs-on: ${{ matrix.os }}
1616

1717
steps:
18-
- run: git config --global core.autocrlf input
18+
- run: git config --global core.autocrlf false && git config --global core.eol lf
1919

2020
- uses: actions/checkout@v4
2121

@@ -25,44 +25,79 @@ jobs:
2525
# Packages to install
2626
packages: |
2727
autoconf,
28+
automake,
29+
cmake,
2830
coreutils,
31+
curl,
2932
gperf,
33+
libtool,
3034
m4,
3135
make,
3236
mingw64-x86_64-gcc-core,
37+
mingw64-x86_64-gcc-g++,
3338
moreutils,
3439
wget
3540
3641
- name: Building GMP
3742
shell: bash
3843
env:
39-
CYGWIN: winsymlinks:native
44+
CYGWIN: winsymlinks:native binmode
45+
run: pushd . && mkdir -p /tools && cd /tools && mkdir -p dynamic_gmp static_gmp && gmp_archive=gmp-6.3.0.tar.xz && (curl -fL --retry 5 --retry-delay 2 --connect-timeout 20 --max-time 600 https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz -o "$gmp_archive" || wget --tries=5 --timeout=20 -O "$gmp_archive" https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz || curl -fL --retry 5 --retry-delay 2 --connect-timeout 20 --max-time 600 https://mirrors.kernel.org/gnu/gmp/gmp-6.3.0.tar.xz -o "$gmp_archive" || wget --tries=5 --timeout=20 -O "$gmp_archive" https://mirrors.kernel.org/gnu/gmp/gmp-6.3.0.tar.xz || curl -fL --retry 5 --retry-delay 2 --connect-timeout 20 --max-time 600 https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz -o "$gmp_archive" || wget --tries=5 --timeout=20 -O "$gmp_archive" https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz) && tar xf "$gmp_archive" && cd gmp-6.3.0 && ./configure --host=x86_64-w64-mingw32 --build=i686-pc-cygwin --enable-cxx --enable-shared --disable-static --prefix=/tools/dynamic_gmp && make && make install && make clean && ./configure --host=x86_64-w64-mingw32 --build=i686-pc-cygwin --enable-cxx --enable-static --disable-shared --prefix=/tools/static_gmp && make && make install && popd
46+
47+
- name: Building MCSAT Dependencies
48+
if: contains(matrix.config-opt, '--enable-mcsat')
49+
shell: bash
50+
env:
51+
CYGWIN: winsymlinks:native binmode
52+
run: >-
53+
mkdir -p /tools/mcsat_deps &&
54+
git -c core.autocrlf=false clone https://github.com/SRI-CSL/libpoly.git &&
55+
sed -i 's/tracef("f\\[%zu\\] = ", i);/tracef("f[%u] = ", (unsigned) i);/g' libpoly/src/number/algebraic_number.c &&
56+
mkdir -p libpoly/build-mingw &&
57+
cd libpoly/build-mingw &&
58+
cmake .. -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_INSTALL_PREFIX=/tools/mcsat_deps -DBUILD_SHARED_LIBS=OFF -DGMP_LIBRARY=/tools/static_gmp/lib/libgmp.a -DGMP_INCLUDE_DIR=/tools/static_gmp/include -DGMPXX_LIBRARY=/tools/static_gmp/lib/libgmpxx.a -DGMPXX_INCLUDE_DIR=/tools/static_gmp/include -DCMAKE_C_FLAGS='-D__USE_MINGW_ANSI_STDIO -Wno-error=format -Wno-error=format-extra-args' -DCMAKE_CXX_FLAGS='-D__USE_MINGW_ANSI_STDIO -Wno-error=format -Wno-error=format-extra-args' &&
59+
make &&
60+
make install &&
61+
cd ../.. &&
62+
git -c core.autocrlf=false clone https://github.com/ivmai/cudd.git &&
63+
cd cudd &&
64+
git checkout tags/cudd-3.0.0 &&
65+
sed -i 's/\r$//' configure &&
66+
find build-aux -type f -exec sed -i 's/\r$//' {} + &&
67+
chmod +x configure build-aux/* &&
68+
./configure --host=x86_64-w64-mingw32 --build=i686-pc-cygwin --disable-shared --enable-static --disable-dependency-tracking --disable-maintainer-mode --prefix=/tools/mcsat_deps &&
69+
make config.h &&
70+
test -f config.status && sed -i 's/\r$//' config.status || true &&
71+
test -f libtool && sed -i 's/\r$//' libtool || true &&
72+
make &&
73+
make install
74+
75+
- name: Building Yices (non-MCSAT)
76+
if: "!contains(matrix.config-opt, '--enable-mcsat')"
77+
shell: bash
78+
env:
79+
CYGWIN: winsymlinks:native binmode
4080
run: >-
41-
pushd . &&
42-
mkdir -p /tools && cd /tools && mkdir -p dynamic_gmp && mkdir -p static_gmp &&
43-
wget https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz &&
44-
tar xf gmp-6.3.0.tar.xz &&
45-
cd gmp-6.3.0 &&
46-
./configure --host=x86_64-w64-mingw32 --build=i686-pc-cygwin --enable-shared --disable-static --prefix=/tools/dynamic_gmp &&
47-
make && make install && make clean &&
48-
./configure --host=x86_64-w64-mingw32 --build=i686-pc-cygwin --enable-static --disable-shared --prefix=/tools/static_gmp &&
49-
make && make install &&
50-
popd
81+
autoconf &&
82+
./configure ${{ matrix.config-opt }} --host=x86_64-w64-mingw32 CPPFLAGS="-I/tools/dynamic_gmp/include" LDFLAGS="-L/tools/dynamic_gmp/lib" --with-static-gmp=/tools/static_gmp/lib/libgmp.a --with-static-gmp-include-dir=/tools/static_gmp/include &&
83+
export LD_LIBRARY_PATH=/usr/local/lib/:${LD_LIBRARY_PATH} &&
84+
make OPTION=mingw64 MODE=${{ matrix.mode }}
5185
52-
- name: Building Yices
86+
- name: Building Yices (MCSAT)
87+
if: contains(matrix.config-opt, '--enable-mcsat')
5388
shell: bash
5489
env:
55-
CYGWIN: winsymlinks:native
90+
CYGWIN: winsymlinks:native binmode
5691
run: >-
57-
autoconf &&
58-
./configure ${{ matrix.config-opt }} --host=x86_64-w64-mingw32 CPPFLAGS=-I/tools/dynamic_gmp/include LDFLAGS=-L/tools/dynamic_gmp/lib --with-static-gmp=/tools/static_gmp/lib/libgmp.a --with-static-gmp-include-dir=/tools/static_gmp/include &&
59-
export LD_LIBRARY_PATH=/usr/local/lib/:${LD_LIBRARY_PATH} &&
92+
autoconf &&
93+
./configure ${{ matrix.config-opt }} --host=x86_64-w64-mingw32 CPPFLAGS="-I/tools/dynamic_gmp/include -I/tools/mcsat_deps/include" LDFLAGS="-L/tools/dynamic_gmp/lib -L/tools/mcsat_deps/lib" --with-static-gmp=/tools/static_gmp/lib/libgmp.a --with-static-gmp-include-dir=/tools/static_gmp/include --with-static-libpoly=/tools/mcsat_deps/lib/libpoly.a --with-static-libpoly-include-dir=/tools/mcsat_deps/include &&
94+
export LD_LIBRARY_PATH=/usr/local/lib/:${LD_LIBRARY_PATH} &&
6095
make OPTION=mingw64 MODE=${{ matrix.mode }}
6196
6297
- name: Run Yices API Tests
6398
shell: bash
6499
env:
65-
CYGWIN: winsymlinks:native
100+
CYGWIN: winsymlinks:native binmode
66101
run: >-
67102
export PATH=/tools/dynamic_gmp/bin:/tools/static_gmp/bin:$PATH &&
68103
make OPTION=mingw64 MODE=${{ matrix.mode }} check-api &&

src/api/yices_api.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9216,7 +9216,7 @@ smt_status_t _o_yices_check_context_with_assumptions(context_t *ctx, const param
92169216
}
92179217

92189218
EXPORTED smt_status_t yices_check_context_with_assumptions(context_t *ctx, const param_t *params, uint32_t n, const term_t a[]) {
9219-
MT_PROTECT(smt_status_t, __yices_globals.lock, _o_yices_check_context_with_assumptions(ctx, params, n, a));
9219+
return _o_yices_check_context_with_assumptions(ctx, params, n, a);
92209220
}
92219221

92229222
/*
@@ -9243,7 +9243,7 @@ static bool good_terms_for_check_with_model(uint32_t n, const term_t t[]) {
92439243
*
92449244
* This checks ctx /\ t[0] = val(mdl, t[0]) /\ .... /\ t[n-1] = val(mdl, t[n-1])
92459245
*/
9246-
EXPORTED smt_status_t yices_check_context_with_model(context_t *ctx, const param_t *params, model_t* mdl, uint32_t n, const term_t t[]) {
9246+
static smt_status_t _o_yices_check_context_with_model(context_t *ctx, const param_t *params, model_t* mdl, uint32_t n, const term_t t[]) {
92479247
param_t default_params;
92489248
smt_status_t stat;
92499249

@@ -9252,7 +9252,7 @@ EXPORTED smt_status_t yices_check_context_with_model(context_t *ctx, const param
92529252
return YICES_STATUS_ERROR;
92539253
}
92549254

9255-
if (! good_terms_for_check_with_model(n, t)) {
9255+
if (! _o_good_terms_for_check_with_model(n, t)) {
92569256
// this sets the error code already (to VARIABLE_REQUIRED)
92579257
// but Dejan created another error code that means the same thing here.
92589258
set_error_code(MCSAT_ERROR_ASSUMPTION_TERM_NOT_SUPPORTED);
@@ -9308,6 +9308,10 @@ EXPORTED smt_status_t yices_check_context_with_model(context_t *ctx, const param
93089308
return stat;
93099309
}
93109310

9311+
EXPORTED smt_status_t yices_check_context_with_model(context_t *ctx, const param_t *params, model_t* mdl, uint32_t n, const term_t t[]) {
9312+
MT_PROTECT(smt_status_t, __yices_globals.lock, _o_yices_check_context_with_model(ctx, params, mdl, n, t));
9313+
}
9314+
93119315

93129316
/*
93139317
* Check context with model and hint
@@ -9319,7 +9323,7 @@ EXPORTED smt_status_t yices_check_context_with_model(context_t *ctx, const param
93199323
*
93209324
* This checks ctx /\ t[0] = val(mdl, t[0]) /\ .... /\ t[m-1] = val(mdl, t[m-1])
93219325
*/
9322-
EXPORTED smt_status_t yices_check_context_with_model_and_hint(context_t *ctx, const param_t *params, model_t* mdl, uint32_t n, const term_t t[], uint32_t m) {
9326+
static smt_status_t _o_yices_check_context_with_model_and_hint(context_t *ctx, const param_t *params, model_t* mdl, uint32_t n, const term_t t[], uint32_t m) {
93239327

93249328
param_t default_params;
93259329
smt_status_t stat;
@@ -9329,7 +9333,7 @@ EXPORTED smt_status_t yices_check_context_with_model_and_hint(context_t *ctx, co
93299333
return YICES_STATUS_ERROR;
93309334
}
93319335

9332-
if (! good_terms_for_check_with_model(n, t)) {
9336+
if (! _o_good_terms_for_check_with_model(n, t)) {
93339337
// this sets the error code already (to VARIABLE_REQUIRED)
93349338
// but Dejan created another error code that means the same thing here.
93359339
set_error_code(MCSAT_ERROR_ASSUMPTION_TERM_NOT_SUPPORTED);
@@ -9387,6 +9391,10 @@ EXPORTED smt_status_t yices_check_context_with_model_and_hint(context_t *ctx, co
93879391
return stat;
93889392
}
93899393

9394+
EXPORTED smt_status_t yices_check_context_with_model_and_hint(context_t *ctx, const param_t *params, model_t* mdl, uint32_t n, const term_t t[], uint32_t m) {
9395+
MT_PROTECT(smt_status_t, __yices_globals.lock, _o_yices_check_context_with_model_and_hint(ctx, params, mdl, n, t, m));
9396+
}
9397+
93909398
/*
93919399
* Set a fixed variable ordering for making mcsat decisions.
93929400
*

src/context/context.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ extern bool context_has_simplex_solver(context_t *ctx);
143143
*/
144144
extern int32_t assert_formula(context_t *ctx, term_t f);
145145

146-
147146
/*
148147
* Assert all formulas f[0] ... f[n-1]
149148
* same return code as above.

src/context/context_solver.c

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "utils/int_hash_sets.h"
4545

4646
#include "api/yices_globals.h"
47+
#include "api/yices_api_lock_free.h"
4748
#include "mt/thread_macros.h"
4849

4950

@@ -716,45 +717,14 @@ static void cache_unsat_core(context_t *ctx, const ivector_t *core) {
716717
}
717718

718719
/*
719-
* Check under assumptions given as terms.
720-
* - if MCSAT is enabled, this uses temporary labels + model interpolation.
721-
* - otherwise terms are converted to literals and handled by the CDCL(T) path.
722-
*
723-
* Preconditions:
724-
* - context status must be IDLE.
720+
* MCSAT variant of check_context_with_term_assumptions.
721+
* Caller must hold __yices_globals.lock.
725722
*/
726-
smt_status_t check_context_with_term_assumptions(context_t *ctx, const param_t *params, uint32_t n, const term_t *a, int32_t *error) {
723+
static smt_status_t _o_check_context_with_term_assumptions_mcsat(context_t *ctx, const param_t *params, uint32_t n, const term_t *a, int32_t *error) {
727724
smt_status_t stat;
728725
ivector_t assumptions;
729726
uint32_t i;
730727

731-
if (error != NULL) {
732-
*error = CTX_NO_ERROR;
733-
}
734-
735-
context_invalidate_unsat_core_cache(ctx);
736-
737-
if (ctx->mcsat == NULL) {
738-
literal_t l;
739-
740-
init_ivector(&assumptions, n);
741-
for (i=0; i<n; i++) {
742-
l = context_add_assumption(ctx, a[i]);
743-
if (l < 0) {
744-
if (error != NULL) {
745-
*error = l;
746-
}
747-
delete_ivector(&assumptions);
748-
return YICES_STATUS_ERROR;
749-
}
750-
ivector_push(&assumptions, l);
751-
}
752-
753-
stat = check_context_with_assumptions(ctx, params, n, assumptions.data);
754-
delete_ivector(&assumptions);
755-
return stat;
756-
}
757-
758728
/*
759729
* MCSAT: create fresh labels b_i, assert (b_i => a_i), then solve with model b_i=true.
760730
* We extract interpolant/core before cleanup, then restore sticky UNSAT artifacts.
@@ -793,7 +763,7 @@ smt_status_t check_context_with_term_assumptions(context_t *ctx, const param_t *
793763
term_t implication = mk_implies(&tm, b, a[i]);
794764

795765
int_hmap_add(&label_map, b, a[i]);
796-
code = assert_formula(ctx, implication);
766+
code = _o_assert_formula(ctx, implication);
797767
if (code < 0) {
798768
if (error != NULL) {
799769
*error = code;
@@ -839,6 +809,52 @@ smt_status_t check_context_with_term_assumptions(context_t *ctx, const param_t *
839809
}
840810
}
841811

812+
static smt_status_t check_context_with_term_assumptions_mcsat(context_t *ctx, const param_t *params, uint32_t n, const term_t *a, int32_t *error) {
813+
MT_PROTECT(smt_status_t, __yices_globals.lock, _o_check_context_with_term_assumptions_mcsat(ctx, params, n, a, error));
814+
}
815+
816+
/*
817+
* Check under assumptions given as terms.
818+
* - if MCSAT is enabled, this uses temporary labels + model interpolation.
819+
* - otherwise terms are converted to literals and handled by the CDCL(T) path.
820+
*
821+
* Preconditions:
822+
* - context status must be IDLE.
823+
*/
824+
smt_status_t check_context_with_term_assumptions(context_t *ctx, const param_t *params, uint32_t n, const term_t *a, int32_t *error) {
825+
if (error != NULL) {
826+
*error = CTX_NO_ERROR;
827+
}
828+
829+
context_invalidate_unsat_core_cache(ctx);
830+
831+
if (ctx->mcsat == NULL) {
832+
smt_status_t stat;
833+
ivector_t assumptions;
834+
uint32_t i;
835+
literal_t l;
836+
837+
init_ivector(&assumptions, n);
838+
for (i=0; i<n; i++) {
839+
l = context_add_assumption(ctx, a[i]);
840+
if (l < 0) {
841+
if (error != NULL) {
842+
*error = l;
843+
}
844+
delete_ivector(&assumptions);
845+
return YICES_STATUS_ERROR;
846+
}
847+
ivector_push(&assumptions, l);
848+
}
849+
850+
stat = check_context_with_assumptions(ctx, params, n, assumptions.data);
851+
delete_ivector(&assumptions);
852+
return stat;
853+
}
854+
855+
return check_context_with_term_assumptions_mcsat(ctx, params, n, a, error);
856+
}
857+
842858
/*
843859
* Check with given model
844860
* - if mcsat status is not IDLE, return the status

0 commit comments

Comments
 (0)