GithubHelp home page GithubHelp logo

go-air / gini Goto Github PK

View Code? Open in Web Editor NEW
147.0 12.0 16.0 597 KB

A fast SAT solver

License: MIT License

Go 100.00%
sat-solver concurrent logic-programming logic-circuit resolution boolean-formulas artificial-intelligence verification testing fuzzing

gini's Introduction

⊧ Gini: A fast SAT solver.

The Gini sat solver is a fast, clean SAT solver written in Go. It is to our knowledge the first ever performant pure-Go SAT solver made available.

GoDoc

Google Group

This solver is fully open source, originally developped at IRI France.

Build/Install

For the impatient:

go install github.com/go-air/gini/...@latest

I recommend however building the package github.com/go-air/gini/internal/xo with bounds checking turned off. This package is all about anything-goes performance and is the workhorse behind most of the gini sat solver. It is also extensively tested and well benchmarked, so it should not pose any safety threat to client code. This makes a signficant speed difference (maybe 10%) on long running problems.

The SAT problem in 5 minutes

The SAT Problem

Usage

Our user guide shows how to solve SAT problems, circuits, do Boolean optimisation, use concurrency, using our distributed CRISP protocol, and more.

Citing Gini

Zenodo DOI based citations and download: DOI

BibText:

@misc{scott_cotton_2019_2553490,
  author       = {Scott  Cotton},
  title        = {go-air/gini: Sapeur},
  month        = jan,
  year         = 2019,
  doi          = {10.5281/zenodo.2553490},
  url          = {https://doi.org/10.5281/zenodo.2553490}
}

gini's People

Contributors

scott-cotton avatar wsc1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gini's Issues

bench tool active runs

The benchmarking tool needs to be able to manage active runs better. Currently, it assumes all runs are complete when doing comparisons.

Make the project go-getable

This can be done by simply moving the content of the /src folder to /. There is really nothing more to it.

[bug] Fails to parse cnf file

cmd used is:

 ./org.alloytools.pardinus.native/native/darwin/arm64/gini -model tmp.cnf 
 c [gini] 2023/06/23 17:22:45 tmp.cnf
 c [gini] 2023/06/23 17:22:45 error: error reading dimacs: error reading dimacs: bad character for int: p

The file starts with:

 p cnf 126 217               

That said, there are lots of spaces after the 217. But it seems to balk at the p already.

The tmp.cnf file:

p cnf 126 217
10 -16 0
11 -16 0
-10 -11 16 0
12 -18 0
13 -18 0
-12 -13 18 0
-16 -18 23 0
-23 25 0
-10 11 15 0
10 -11 15 0
11 -11 15 0
-12 13 17 0
12 -13 17 0
13 -13 17 0
-15 -17 20 0
-16 18 21 0
16 -18 21 0
18 -18 21 0
-20 -21 24 0
-24 25 0
-25 -33 0
-6 -2 -28 0
6 2 -28 0
-2 2 -28 0
28 -32 0
-7 -3 -29 0
7 3 -29 0
-3 3 -29 0
29 -32 0
-8 -4 -30 0
8 4 -30 0
-4 4 -30 0
30 -32 0
-9 -5 -31 0
9 5 -31 0
-5 5 -31 0
31 -32 0
32 -33 0
33 -117 0
-10 6 -34 0
34 -38 0
-11 7 -35 0
35 -38 0
-12 8 -36 0
36 -38 0
-13 9 -37 0
37 -38 0
38 -51 0
1 -40 0
7 -40 0
-1 -7 40 0
1 -41 0
8 -41 0
-1 -8 41 0
-40 -41 47 0
1 -42 0
9 -42 0
-1 -9 42 0
1 -39 0
6 -39 0
-1 -6 39 0
42 39 48 0
-47 -48 49 0
-49 -50 0
-40 -42 43 0
41 39 44 0
-43 -44 45 0
-45 -46 0
10 -46 0
46 -50 0
50 -51 0
51 -67 0
-10 -52 0
6 -52 0
10 -6 52 0
-39 52 -56 0
56 -60 0
-11 -53 0
7 -53 0
11 -7 53 0
-40 53 -57 0
57 -60 0
-12 -54 0
8 -54 0
12 -8 54 0
-41 54 -58 0
58 -60 0
-13 -55 0
9 -55 0
13 -9 55 0
-42 55 -59 0
59 -60 0
60 -66 0
-52 39 -61 0
61 -65 0
-53 40 -62 0
62 -65 0
-54 41 -63 0
63 -65 0
-55 42 -64 0
64 -65 0
65 -66 0
66 -67 0
-10 2 -68 0
68 -72 0
-11 3 -69 0
69 -72 0
-12 4 -70 0
70 -72 0
-13 5 -71 0
71 -72 0
72 -85 0
1 -74 0
3 -74 0
-1 -3 74 0
1 -75 0
4 -75 0
-1 -4 75 0
-74 -75 81 0
1 -76 0
5 -76 0
-1 -5 76 0
1 -73 0
2 -73 0
-1 -2 73 0
76 73 82 0
-81 -82 83 0
-83 -84 0
-74 -76 77 0
75 73 78 0
-77 -78 79 0
-79 -80 0
10 -80 0
80 -84 0
84 -85 0
85 -101 0
-10 -86 0
2 -86 0
10 -2 86 0
-73 86 -90 0
90 -94 0
-11 -87 0
3 -87 0
11 -3 87 0
-74 87 -91 0
91 -94 0
-12 -88 0
4 -88 0
12 -4 88 0
-75 88 -92 0
92 -94 0
-13 -89 0
5 -89 0
13 -5 89 0
-76 89 -93 0
93 -94 0
94 -100 0
-86 73 -95 0
95 -99 0
-87 74 -96 0
96 -99 0
-88 75 -97 0
97 -99 0
-89 76 -98 0
98 -99 0
99 -100 0
100 -101 0
67 101 -102 0
-10 114 0
-11 114 0
-12 114 0
-13 114 0
-114 -115 0
-6 39 -103 0
103 -107 0
-7 40 -104 0
104 -107 0
-8 41 -105 0
105 -107 0
-9 42 -106 0
106 -107 0
107 -113 0
-2 73 -108 0
108 -112 0
-3 74 -109 0
109 -112 0
-4 75 -110 0
110 -112 0
-5 76 -111 0
111 -112 0
112 -113 0
113 -115 0
102 115 -116 0
116 -117 0
117 -125 0
6 -118 0
7 -118 0
8 -118 0
9 -118 0
118 -125 0
14 -124 0
2 -119 0
14 -119 0
119 -123 0
3 -120 0
14 -120 0
120 -123 0
4 -121 0
14 -121 0
121 -123 0
5 -122 0
14 -122 0
122 -123 0
123 -124 0
124 -125 0
1 0
125 0
p cnf 117 196
10 -15 0
11 -15 0
-10 -11 15 0
12 -17 0
13 -17 0
-12 -13 17 0
-15 -17 22 0
-22 24 0
-10 11 14 0
10 -11 14 0
11 -11 14 0
-12 13 16 0
12 -13 16 0
13 -13 16 0
-14 -16 19 0
-15 17 20 0
15 -17 20 0
17 -17 20 0
-19 -20 23 0
-23 24 0
-24 -32 0
-6 -2 -27 0
6 2 -27 0
-2 2 -27 0
27 -31 0
-7 -3 -28 0
7 3 -28 0
-3 3 -28 0
28 -31 0
-8 -4 -29 0
8 4 -29 0
-4 4 -29 0
29 -31 0
-9 -5 -30 0
9 5 -30 0
-5 5 -30 0
30 -31 0
31 -32 0
32 -116 0
-10 6 -33 0
33 -37 0
-11 7 -34 0
34 -37 0
-12 8 -35 0
35 -37 0
-13 9 -36 0
36 -37 0
37 -50 0
1 -39 0
7 -39 0
-1 -7 39 0
1 -40 0
8 -40 0
-1 -8 40 0
-39 -40 46 0
1 -41 0
9 -41 0
-1 -9 41 0
1 -38 0
6 -38 0
-1 -6 38 0
41 38 47 0
-46 -47 48 0
-48 -49 0
-39 -41 42 0
40 38 43 0
-42 -43 44 0
-44 -45 0
10 -45 0
45 -49 0
49 -50 0
50 -66 0
-10 -51 0
6 -51 0
10 -6 51 0
-38 51 -55 0
55 -59 0
-11 -52 0
7 -52 0
11 -7 52 0
-39 52 -56 0
56 -59 0
-12 -53 0
8 -53 0
12 -8 53 0
-40 53 -57 0
57 -59 0
-13 -54 0
9 -54 0
13 -9 54 0
-41 54 -58 0
58 -59 0
59 -65 0
-51 38 -60 0
60 -64 0
-52 39 -61 0
61 -64 0
-53 40 -62 0
62 -64 0
-54 41 -63 0
63 -64 0
64 -65 0
65 -66 0
-10 2 -67 0
67 -71 0
-11 3 -68 0
68 -71 0
-12 4 -69 0
69 -71 0
-13 5 -70 0
70 -71 0
71 -84 0
1 -73 0
3 -73 0
-1 -3 73 0
1 -74 0
4 -74 0
-1 -4 74 0
-73 -74 80 0
1 -75 0
5 -75 0
-1 -5 75 0
1 -72 0
2 -72 0
-1 -2 72 0
75 72 81 0
-80 -81 82 0
-82 -83 0
-73 -75 76 0
74 72 77 0
-76 -77 78 0
-78 -79 0
10 -79 0
79 -83 0
83 -84 0
84 -100 0
-10 -85 0
2 -85 0
10 -2 85 0
-72 85 -89 0
89 -93 0
-11 -86 0
3 -86 0
11 -3 86 0
-73 86 -90 0
90 -93 0
-12 -87 0
4 -87 0
12 -4 87 0
-74 87 -91 0
91 -93 0
-13 -88 0
5 -88 0
13 -5 88 0
-75 88 -92 0
92 -93 0
93 -99 0
-85 72 -94 0
94 -98 0
-86 73 -95 0
95 -98 0
-87 74 -96 0
96 -98 0
-88 75 -97 0
97 -98 0
98 -99 0
99 -100 0
66 100 -101 0
-10 113 0
-11 113 0
-12 113 0
-13 113 0
-113 -114 0
-6 38 -102 0
102 -106 0
-7 39 -103 0
103 -106 0
-8 40 -104 0
104 -106 0
-9 41 -105 0
105 -106 0
106 -112 0
-2 72 -107 0
107 -111 0
-3 73 -108 0
108 -111 0
-4 74 -109 0
109 -111 0
-5 75 -110 0
110 -111 0
111 -112 0
112 -114 0
101 114 -115 0
115 -116 0
1 0
116 0
<

go vet

Here are 12 warnings when I run vet, some would be worth fixing:

$go vet gini...
cmd/gini/sigs.go:25: Println call ends with newline
crisp/client.go:206: unreachable code
crisp/server_test.go:113: arg model for printf verb %s of wrong type: []bool
dimacs/cnf.go:121: unreachable code
dimacs/cnf.go:157: unreachable code
dimacs/cnf.go:162: unreachable code
gen/color_test.go:21: missing argument for Errorf("%d"): format reads arg 1, have only 0 args
internal/xo/cdb_test.go:66: arg p for printf verb %p of wrong type: xo.CLoc
internal/xo/chd_test.go:21: arg h.Learnt() for printf verb %s of wrong type: bool
internal/xo/s_test.go:340: arg s.Solve() for printf verb %s of wrong type: int
internal/xo/watch_test.go:31: arg w.IsBinary() for printf verb %s of wrong type: bool
internal/xo/watch_test.go:43: arg w0.IsBinary() for printf verb %s of wrong type: bool

bench tool focus sets

focus subsets of benchmark suites would allow easier use of the tool with less computational cost, for faster development turn around.

The idea is you have a suite and a set of solvers and a difficulty measure. Filter out or sample from a difficulty level and focus on a small subset for rapid prototyping. If the prototype works well on a focus set, you can promote it to a full run for comparison.

Simplification fixes from https://github.com/dominikh/go-simple

<dgryski@kamek[gini] ʕ╯◔ϖ◔ʔ╯ > gosimple ./...
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/gini_test.go:30:2: should use for range instead of for { select {} }
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/gini_test.go:48:10: should use time.Since instead of time.Now().Sub
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/ax/ax.go:332:8: should use time.Since instead of time.Now().Sub
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/bench/suite.go:157:2: should replace loop with s.Map = append(s.Map, insts...)
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/cmd/gini/main.go:283:12: should use time.Since instead of time.Now().Sub
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/internal/xo/cgc.go:73:2: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>'
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/internal/xo/stats.go:122:10: should use time.Since instead of time.Now().Sub
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/logic/c_test.go:91:5: should omit comparison to bool constant, can be simplified to !vs[4]

The time.Since changes can be done automatically with gofmt: gofmt -w -r 'time.Now().Sub(a) -> time.Since(a)' .

You should also run gofmt -w -s . for some additional simplification fixes that gofmt will handle.

Issues found by https://github.com/gordonklaus/ineffassign

<dgryski@kamek[src] \ʕ◔ϖ◔ʔ/ > ineffassign .
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/bench/cmp.go:201:3: unitDur assigned and not used
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/cmd/gini/main.go:176:8: e assigned and not used
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/crisp/server_test.go:134:10: e assigned and not used
/home/dgryski/work/src/cvs/gocode/src/github.com/IRIFrance/gini/src/gini/gen/rands.go:203:2: dst assigned and not used

The unitDur code is dead code and can be removed.
The dst code is definitely a bug.
The e issue in main.go is also a scoping bug.
The e issue in server_test.go is an unchecked error.

(I ran https://github.com/alecthomas/gometalinter over the code base. Many of the issues are style fixes which give better code, but are not bugs. Gosimple and unconvert both flagged some issues, but I didn't open an issue for them. The rest are very minor.)

Question

I'm trying to model the example cited in the documentation: (1 -2) (2 -3) (3 -4) (4 -1)

        g := gini.New()

	g.Add(z.Lit(1))
	g.Add(z.Lit(2).Not())
	g.Add(0)
	g.Add(z.Lit(2))
	g.Add(z.Lit(3).Not())
	g.Add(0)
	g.Add(z.Lit(3))
	g.Add(z.Lit(4).Not())
	g.Add(0)
	g.Add(z.Lit(4))
	g.Add(z.Lit(1).Not())
	g.Add(0)

g.Solve() is returning -1, though. Am I doing this wrong?

add drat tracing/checking

to participate in the SAT competition, we need to support proof tracing

also, maybe an in-memory proof xo solver will be useful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.