ravensat 0.3.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +44 -21
  3. data/docs/Arcteryx/CNF.html +827 -0
  4. data/docs/Arcteryx.html +309 -0
  5. data/docs/Ravensat/AndNode.html +159 -0
  6. data/docs/Ravensat/Claw.html +338 -0
  7. data/docs/Ravensat/DimacsDecoder.html +224 -0
  8. data/docs/Ravensat/DimacsEncoder.html +425 -0
  9. data/docs/Ravensat/Extension/BooleanVariable.html +229 -0
  10. data/docs/Ravensat/Extension/Domain.html +319 -0
  11. data/docs/Ravensat/Extension/IntegerVariable.html +589 -0
  12. data/docs/Ravensat/Extension/UndefinedVariable.html +236 -0
  13. data/docs/Ravensat/Extension/Variable.html +443 -0
  14. data/docs/Ravensat/Extension.html +141 -0
  15. data/docs/Ravensat/InitialNode.html +267 -0
  16. data/docs/Ravensat/Node.html +780 -0
  17. data/docs/Ravensat/NotNode.html +159 -0
  18. data/docs/Ravensat/OprNode.html +226 -0
  19. data/docs/Ravensat/OrNode.html +252 -0
  20. data/docs/Ravensat/Solver.html +373 -0
  21. data/docs/Ravensat/VarNode.html +488 -0
  22. data/docs/Ravensat.html +135 -0
  23. data/docs/_index.html +329 -0
  24. data/docs/class_list.html +51 -0
  25. data/docs/css/common.css +1 -0
  26. data/docs/css/full_list.css +58 -0
  27. data/docs/css/style.css +497 -0
  28. data/docs/file.README.html +233 -0
  29. data/docs/file_list.html +56 -0
  30. data/docs/frames.html +17 -0
  31. data/docs/index.html +233 -0
  32. data/docs/js/app.js +314 -0
  33. data/docs/js/full_list.js +216 -0
  34. data/docs/js/jquery.js +4 -0
  35. data/docs/method_list.html +523 -0
  36. data/docs/top-level-namespace.html +110 -0
  37. data/lib/ravensat/ast/and_node.rb +8 -0
  38. data/lib/ravensat/ast/node.rb +50 -15
  39. data/lib/ravensat/ast/not_node.rb +7 -0
  40. data/lib/ravensat/ast/or_node.rb +9 -0
  41. data/lib/ravensat/ast/var_node.rb +6 -1
  42. data/lib/ravensat/claw.rb +45 -0
  43. data/lib/ravensat/dimacs/dimacs_decoder.rb +6 -12
  44. data/lib/ravensat/dimacs/dimacs_encoder.rb +10 -13
  45. data/lib/ravensat/extension/variable/integer_variable.rb +3 -3
  46. data/lib/ravensat/solver.rb +1 -1
  47. data/lib/ravensat/version.rb +1 -1
  48. data/lib/ravensat.rb +1 -1
  49. metadata +37 -4
  50. data/Gemfile.lock +0 -45
  51. data/lib/ravensat/ravenclaw.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47afc062227efddad35ed4643e28c4eea8957ecb32c8aa34d3c69a9ff52d3a88
4
- data.tar.gz: a39c4f15fb17321ded803e79b702c55150197b3a613a340ca4a728e0a6a27402
3
+ metadata.gz: 0fe48515db2ce222168fac2854fcab5b2057c84336195e129e6c532ab519082e
4
+ data.tar.gz: bc265a79298a55684d1bb1c83a196e0530b4670515c22d4388f65bdf7b872c67
5
5
  SHA512:
6
- metadata.gz: f29375d0971be0c3a721e9932fec0b69ad9db5b6df089e9d07fad557a82fac176faf7b71eea0ca73b8ee76ba60b413bfc799fd2de798c0b0fc513e39c8c0388d
7
- data.tar.gz: a596fa29bfb55341a016ddde64b2e7d788a4877d4504cd5921cee81e486ee28207fd14027c81c0e113c8485edd0cc9bd5921beac75728da85e3390c1eab4d23f
6
+ metadata.gz: 7d715763470fe222f0ba71c998e27a43f8e40c04ae50cadceae48b324a962eaa75ceef92f02154cc74f9e04edbae47de1f36eb6e3c655019c0f3fedd72aae448
7
+ data.tar.gz: d2178778880fa55127ef5bd0b2b5d76fa5431452d20f06b0672374a99f9a718a881c01c1c055b11579c86e063decc607416c0f3450213f460dac756e28cc201c
data/README.md CHANGED
@@ -1,23 +1,26 @@
1
- # Ravensat
2
-
3
- [![Ruby](https://github.com/matsuda0528/ravensat/actions/workflows/main.yml/badge.svg)](https://github.com/matsuda0528/ravensat/actions/workflows/main.yml)
1
+ [![GitHub Actions](https://github.com/matsuda0528/ravensat/actions/workflows/main.yml/badge.svg)](https://github.com/matsuda0528/ravensat/actions/workflows/main.yml)
4
2
  [![Gem Version](https://badge.fury.io/rb/ravensat.svg)](https://badge.fury.io/rb/ravensat)
5
3
  [![LICENSE](https://img.shields.io/github/license/matsuda0528/ravensat)](https://opensource.org/licenses/MIT)
6
4
 
7
- Ravensat is an interface to SAT solver in Ruby.
5
+ <!-- [![GitHub Pages](https://img.shields.io/badge/GitHub%20Pages--brightgreen.svg?logo=github&style=social)](https://matsuda0528.github.io/ravensat/) -->
6
+
7
+ # Ravensat
8
8
 
9
+ Ravensat provides an intuitive interface for working with SAT solver.
10
+ SAT solver is a useful tool for solving various problems, but it is not user-friendly.
11
+ Ravensat wraps the SAT solver and makes it easier to use.
9
12
  In order to use Ravensat, you need to install SAT solver.
10
13
  If you do not install SAT solver, it will use the one bundled in the gem.
11
14
 
12
15
  About [SAT](https://en.wikipedia.org/wiki/Boolean_satisfiability_problem), [SAT solver](https://en.wikipedia.org/wiki/SAT_solver)
13
16
 
14
17
  ## Description
15
- To solve SAT, we usually use SAT solver.
18
+ To solve SAT(Boolean Satisfiability Problem), we usually use SAT solver.
16
19
  Now, let's solve the following SAT with SAT solver.
17
- <p align="center">
18
- <img src="https://latex.codecogs.com/svg.image?\inline&space;\large&space;\bg{white}(1&space;\lor&space;\lnot&space;5&space;\lor&space;4)&space;\land&space;(\lnot&space;1&space;\lor&space;5&space;\lor&space;3&space;\lor&space;4)&space;\land&space;(\lnot&space;3&space;\lor&space;\lnot&space;4)" style="background-color:white;"/>
19
- </p>
20
20
 
21
+ $$(p_{1} \lor \lnot p_{5} \lor p_{4}) \land (\lnot p_{1} \lor p_{5} \lor p_{3} \lor p_{4}) \land (\lnot p_{3} \lor \lnot p_{4})$$
22
+
23
+ To solve the above SAT, give it to the SAT solver.
21
24
  Most SAT solvers are input in [DIMACS Format](https://www.cs.utexas.edu/users/moore/acl2/manuals/current/manual/index-seo.php/SATLINK____DIMACS).
22
25
  Converting the example SAT to DIMACS Format yields the following.
23
26
 
@@ -27,25 +30,37 @@ p cnf 5 3
27
30
  -1 5 3 4 0
28
31
  -3 -4 0
29
32
  ```
33
+
30
34
  DIMACS Format is widely distributed as an I/O format for SAT solver.
31
35
  However, when solving a large SAT, the following problems occur.
32
36
  - Need to create a file with thousands of lines.
33
37
  - Confusion arises because of the inability to name variables meaningfully.
34
38
 
35
- To solve these problems, Ravensat can be used.
39
+ Therefore, we need an interface that can flexibly determine the names of variables and imperatively write loginal expressions.
40
+ To achieve these requirements, we are developing Ravensat.
36
41
  Using Ravensat, propositional variables can be defined as local variables in Ruby.
42
+
37
43
  ```ruby
38
- fuji_is_the_highest_mountain_in_japan = Ravensat::VarNode.new
44
+ John_is_a_male = Ravensat::VarNode.new
39
45
  ```
40
- In addition, you can write logical expressions intuitively.
46
+
47
+ In addition, you can write logical expressions intuitively and imperatively.
48
+
41
49
  ```ruby
42
50
  x = Ravensat::VarNode.new
43
51
  y = Ravensat::VarNode.new
44
52
 
45
- # (x or y) and (not x or y)
46
53
  (x | y) & (~x | y)
47
54
  ```
48
55
 
56
+ ```ruby
57
+ x = Ravensat::VarNode.new
58
+ y = Ravensat::VarNode.new
59
+ z = Ravensat::VarNode.new
60
+
61
+ # (~x | ~y) & (~x | ~z) & (~y | ~z)
62
+ Ravensat::Claw.pairwise_amo [x,y,z]
63
+ ```
49
64
 
50
65
  ## Installation
51
66
 
@@ -66,41 +81,39 @@ Or install it yourself as:
66
81
  ## Usage
67
82
  ### Basic Usage
68
83
  This is a basic usage example of the library.
84
+
69
85
  ```ruby
70
86
  require 'ravensat'
71
87
 
72
- # Define propositional variables
73
88
  a = Ravensat::VarNode.new
74
89
  b = Ravensat::VarNode.new
75
90
 
76
91
  a.result #=> nil
77
92
  b.result #=> nil
78
93
 
79
- # Generate logical expressions as CNF
80
94
  logic = (a | b) & (~a | b) & (a | ~b)
81
95
 
82
- # Launch SAT solver
83
96
  solver = Ravensat::Solver.new
84
97
  solver.solve logic #=> true(SAT)
85
98
 
86
- # Refer to the satisfiability
87
99
  a.result #=> true
88
100
  b.result #=> true
89
101
  ```
90
102
 
91
103
  If you have SAT solver installed, you can write:
104
+
92
105
  ```ruby
93
- # Launch SAT solver
94
106
  solver = Ravensat::Solver.new("<solver_name>")
95
107
  solver.solve logic
96
108
  ```
109
+
97
110
  The available solvers are assumed to be those that can be I/O in the DIMACS Format.
98
111
  At least, we have confirmed that it works properly with [MiniSat](https://github.com/niklasso/minisat).
99
112
 
100
113
  If you do not use an external SAT solver, create a SAT solver object without any constructor arguments.
101
114
  In that case, **Arcteryx**(the very simple SAT solver built into Ravensat) will launch.
102
115
 
103
- ### Extension Usage
116
+ ### Extension Usage(prototype)
104
117
  In Ravensat::Extension, C-like variable definitions are available.
105
118
 
106
119
  *Note: In Ravensat::Extension, all undefined variables and methods are caught by method_missing method.*
@@ -122,8 +135,8 @@ module Ravensat
122
135
  end
123
136
  ```
124
137
 
125
- ### Extension Usage(CSP; Constraint Satisfaction Problem)
126
138
  It is possible to define integer variables and to describe some integer constraints.
139
+
127
140
  ```ruby
128
141
  require 'ravensat'
129
142
 
@@ -147,10 +160,20 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
147
160
 
148
161
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
149
162
 
163
+ ## License
164
+
165
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
166
+
150
167
  ## Contributing
151
168
 
152
169
  Bug reports and pull requests are welcome on GitHub at https://github.com/matsuda0528/ravensat.
153
170
 
154
- ## License
171
+ ```
172
+ ____ _
173
+ | _ \ __ ___ _____ _ __ ___ __ _| |_
174
+ | |_) / _` \ \ / / _ \ '_ \/ __|/ _` | __|
175
+ | _ < (_| |\ V / __/ | | \__ \ (_| | |_
176
+ |_| \_\__,_| \_/ \___|_| |_|___/\__,_|\__|
177
+
178
+ ```
155
179
 
156
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).