-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathersatz.cabal
348 lines (331 loc) · 9.8 KB
/
ersatz.cabal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
name: ersatz
version: 0.5
license: BSD3
license-file: LICENSE
author: Edward A. Kmett, Eric Mertens, Johan Kiviniemi
maintainer: Edward A. Kmett <ekmett@gmail.com>
copyright: © 2010-2015 Edward A. Kmett, © 2014-2015 Eric Mertens, © 2013 Johan Kiviniemi
stability: experimental
homepage: http://github.com/ekmett/ersatz
bug-reports: http://github.com/ekmett/ersatz/issues
category: Logic, Algorithms
synopsis: A monad for expressing SAT or QSAT problems using observable sharing.
description: A monad for expressing SAT or QSAT problems using observable sharing.
.
For example, we can express a full-adder with:
.
> full_adder :: Bit -> Bit -> Bit -> (Bit, Bit)
> full_adder a b cin = (s2, c1 || c2)
> where (s1,c1) = half_adder a b
> (s2,c2) = half_adder s1 cin
.
> half_adder :: Bit -> Bit -> (Bit, Bit)
> half_adder a b = (a `xor` b, a && b)
.
/Longer Examples/
.
Included are a couple of examples included with the distribution.
Neither are as fast as a dedicated solver for their respective
domains, but they showcase how you can solve real world problems
involving 10s or 100s of thousands of variables and constraints
with `ersatz`.
.
@ersatz-sudoku@
.
> % time ersatz-sudoku
> Problem:
> ┌───────┬───────┬───────┐
> │ 5 3 │ 7 │ │
> │ 6 │ 1 9 5 │ │
> │ 9 8 │ │ 6 │
> ├───────┼───────┼───────┤
> │ 8 │ 6 │ 3 │
> │ 4 │ 8 3 │ 1 │
> │ 7 │ 2 │ 6 │
> ├───────┼───────┼───────┤
> │ 6 │ │ 2 8 │
> │ │ 4 1 9 │ 5 │
> │ │ 8 │ 7 9 │
> └───────┴───────┴───────┘
> Solution:
> ┌───────┬───────┬───────┐
> │ 5 3 4 │ 6 7 8 │ 9 1 2 │
> │ 6 7 2 │ 1 9 5 │ 3 4 8 │
> │ 1 9 8 │ 3 4 2 │ 5 6 7 │
> ├───────┼───────┼───────┤
> │ 8 5 9 │ 7 6 1 │ 4 2 3 │
> │ 4 2 6 │ 8 5 3 │ 7 9 1 │
> │ 7 1 3 │ 9 2 4 │ 8 5 6 │
> ├───────┼───────┼───────┤
> │ 9 6 1 │ 5 3 7 │ 2 8 4 │
> │ 2 8 7 │ 4 1 9 │ 6 3 5 │
> │ 3 4 5 │ 2 8 6 │ 1 7 9 │
> └───────┴───────┴───────┘
> ersatz-sudoku 1,13s user 0,04s system 99% cpu 1,179 total
.
@ersatz-regexp-grid@
.
This solves the \"regular crossword puzzle\" (<https://github.com/ekmett/ersatz/raw/master/notes/grid.pdf grid.pdf>) from the 2013 MIT mystery hunt.
.
> % time ersatz-regexp-grid
.
"SPOILER"
.
> ersatz-regexp-grid 2,45s user 0,05s system 99% cpu 2,502 total
build-type: Simple
cabal-version: >= 1.10
tested-with: GHC == 8.0.2
, GHC == 8.2.2
, GHC == 8.4.4
, GHC == 8.6.5
, GHC == 8.8.4
, GHC == 8.10.7
, GHC == 9.0.2
, GHC == 9.2.8
, GHC == 9.4.8
, GHC == 9.6.6
, GHC == 9.8.4
, GHC == 9.10.1
, GHC == 9.12.1
extra-source-files:
.gitignore
.hlint.yaml
AUTHORS.md
CHANGELOG.md
README.md
notes/SPOILER.html
notes/grid.pdf
notes/papers.md
data-files:
data/dimacs/bf/bf0432-007.cnf
data/dimacs/bf/bf1355-075.cnf
data/dimacs/bf/bf1355-638.cnf
data/dimacs/bf/bf2670-001.cnf
data/dimacs/bf/descr.html
data/dimacs/bf/ssa0432-003.cnf
data/dimacs/bf/ssa2670-130.cnf
data/dimacs/bf/ssa2670-141.cnf
data/dimacs/bf/ssa6288-047.cnf
data/dimacs/bf/ssa7552-038.cnf
data/dimacs/bf/ssa7552-158.cnf
data/dimacs/bf/ssa7552-159.cnf
data/dimacs/bf/ssa7552-160.cnf
data/dimacs/blocksworld/anomaly.cnf
data/dimacs/blocksworld/bw_large.a.cnf
data/dimacs/blocksworld/bw_large.b.cnf
data/dimacs/blocksworld/bw_large.c.cnf
data/dimacs/blocksworld/descr.html
data/dimacs/blocksworld/huge.cnf
data/dimacs/blocksworld/medium.cnf
data/dimacs/bmc/bmc-ibm-1.cnf
data/dimacs/bmc/bmc-ibm-2.cnf
data/dimacs/bmc/bmc-ibm-3.cnf
data/dimacs/bmc/bmc-ibm-4.cnf
data/dimacs/bmc/bmc-ibm-5.cnf
data/dimacs/bmc/bmc-ibm-7.cnf
data/dimacs/logistics/descr.html
data/dimacs/logistics/logistics.a.cnf
data/dimacs/logistics/logistics.b.cnf
data/dimacs/logistics/logistics.c.cnf
data/dimacs/logistics/logistics.d.cnf
data/dimacs/parity/descr
data/dimacs/parity/par16-1-c.cnf
data/dimacs/parity/par16-1.cnf
data/dimacs/parity/par16-2-c.cnf
data/dimacs/parity/par16-2.cnf
data/dimacs/parity/par16-3-c.cnf
data/dimacs/parity/par16-3.cnf
data/dimacs/parity/par16-4-c.cnf
data/dimacs/parity/par16-4.cnf
data/dimacs/parity/par16-5-c.cnf
data/dimacs/parity/par16-5.cnf
data/dimacs/parity/par8-1-c.cnf
data/dimacs/parity/par8-1.cnf
data/dimacs/parity/par8-2-c.cnf
data/dimacs/parity/par8-2.cnf
data/dimacs/parity/par8-3-c.cnf
data/dimacs/parity/par8-3.cnf
data/dimacs/parity/par8-4-c.cnf
data/dimacs/parity/par8-4.cnf
data/dimacs/parity/par8-5-c.cnf
data/dimacs/parity/par8-5.cnf
data/dimacs/phole/descr.html
data/dimacs/phole/hole6.cnf
data/dimacs/phole/hole7.cnf
data/dimacs/phole/hole8.cnf
source-repository head
type: git
location: https://github.com/ekmett/ersatz.git
flag examples
description: Build examples
default: True
manual: True
library
ghc-options: -Wall
hs-source-dirs: src
default-language: Haskell2010
build-depends:
array >= 0.2 && < 0.6,
base >= 4.9 && < 5,
bytestring >= 0.10.4.0 && < 0.13,
containers >= 0.2.0.1 && < 0.9,
data-default >= 0.5 && < 0.9,
lens >= 4 && < 6,
mtl >= 1.1 && < 2.4,
process >= 1.1 && < 1.7,
semigroups >= 0.16 && < 1,
streams >= 3.3 && < 4,
temporary >= 1.1 && < 1.4,
transformers >= 0.3 && < 0.7,
unordered-containers == 0.2.*,
attoparsec
exposed-modules:
Ersatz
Ersatz.Bit
Ersatz.Bits
Ersatz.BitChar
Ersatz.Codec
Ersatz.Equatable
Ersatz.Internal.Formula
Ersatz.Internal.Literal
Ersatz.Orderable
Ersatz.Problem
Ersatz.Solution
Ersatz.Solver
Ersatz.Solver.DepQBF
Ersatz.Solver.Kissat
Ersatz.Solver.Lingeling
Ersatz.Solver.Minisat
Ersatz.Solver.Z3
Ersatz.Variable
Ersatz.Counting
Ersatz.Relation
other-modules:
Ersatz.Internal.Parser
Ersatz.Internal.StableName
Ersatz.Solver.Common
Ersatz.Relation.Data
Ersatz.Relation.Prop
Ersatz.Relation.Op
Ersatz.Relation.ARS
executable ersatz-regexp-grid
-- description: An example program that solves the regular expression crossword problem <http://www.coinheist.com/rubik/a_regular_crossword/> using Ersatz.
if flag(examples)
build-depends:
base < 5,
containers,
ersatz,
fail,
lens,
mtl,
parsec >= 3.1 && < 3.2,
semigroups
else
buildable: False
main-is: Main.hs
other-modules:
RegexpGrid.Problem
RegexpGrid.Regexp
RegexpGrid.Types
default-language: Haskell2010
ghc-options: -Wall
hs-source-dirs: examples/regexp-grid
executable ersatz-sudoku
-- description: An example program that solves a sudoku problem using Ersatz.
if flag(examples)
build-depends:
array,
base < 5,
ersatz,
mtl
else
buildable: False
default-language: Haskell2010
main-is: Main.hs
other-modules:
Sudoku.Cell
Sudoku.Problem
ghc-options: -Wall
hs-source-dirs: examples/sudoku
executable ersatz-graph-coloring
-- description: An example program that solves a graph coloring problem using Ersatz.
if flag(examples)
build-depends:
array,
base < 5,
bytestring,
ersatz,
mtl,
optparse-applicative
else
buildable: False
default-language: Haskell2010
main-is: Coloring.hs
ghc-options: -Wall
hs-source-dirs: examples/qbf
executable ersatz-circuit-synthesis
-- description: An example program that solves a circuit synthesis problem using Ersatz.
if flag(examples)
build-depends:
array,
base < 5,
bytestring,
ersatz,
mtl
else
buildable: False
default-language: Haskell2010
main-is: Synthesis.hs
ghc-options: -Wall -Wno-type-defaults
hs-source-dirs: examples/qbf
-- test-suite properties
-- type: exitcode-stdio-1.0
-- ghc-options: -Wall
-- default-language: Haskell2010
-- build-depends:
-- array,
-- base < 5,
-- containers,
-- data-reify >= 0.5 && < 0.7,
-- ersatz,
-- mtl,
-- transformers,
-- test-framework >= 0.2.4 && < 0.9,
-- test-framework-quickcheck >= 0.2.4 && < 0.4,
-- test-framework-hunit >= 0.2.4 && < 0.4,
-- QuickCheck >= 1.2.0.0 && < 2.6,
-- HUnit >= 1.2.2.1 && < 1.3
--
-- hs-source-dirs: tests
-- Main-is: properties.hs
test-suite hunit
type: exitcode-stdio-1.0
main-is: HUnit.hs
hs-source-dirs: tests
build-depends:
base,
containers,
data-default,
ersatz,
tasty >= 1.4 && < 1.6,
tasty-hunit >= 0.10 && < 0.11
default-language: Haskell2010
ghc-options: -Wall
test-suite speed
type: exitcode-stdio-1.0
main-is: Speed.hs
hs-source-dirs: tests
build-depends: base, ersatz
default-language: Haskell2010
test-suite moore
type: exitcode-stdio-1.0
main-is: Moore.hs
hs-source-dirs: tests
build-depends: base, array, ersatz
default-language: Haskell2010
test-suite z001
type: exitcode-stdio-1.0
main-is: Z001.hs
hs-source-dirs: tests
build-depends: base, ersatz
default-language: Haskell2010