ravensat 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +18 -0
  3. data/README.md +90 -13
  4. data/docs/Arcteryx/CNF.html +827 -0
  5. data/docs/Arcteryx.html +309 -0
  6. data/docs/Ravensat/AndNode.html +159 -0
  7. data/docs/Ravensat/Claw.html +338 -0
  8. data/docs/Ravensat/DimacsDecoder.html +224 -0
  9. data/docs/Ravensat/DimacsEncoder.html +425 -0
  10. data/docs/Ravensat/Extension/BooleanVariable.html +229 -0
  11. data/docs/Ravensat/Extension/Domain.html +319 -0
  12. data/docs/Ravensat/Extension/IntegerVariable.html +589 -0
  13. data/docs/Ravensat/Extension/UndefinedVariable.html +236 -0
  14. data/docs/Ravensat/Extension/Variable.html +443 -0
  15. data/docs/Ravensat/Extension.html +141 -0
  16. data/docs/Ravensat/InitialNode.html +267 -0
  17. data/docs/Ravensat/Node.html +780 -0
  18. data/docs/Ravensat/NotNode.html +159 -0
  19. data/docs/Ravensat/OprNode.html +226 -0
  20. data/docs/Ravensat/OrNode.html +252 -0
  21. data/docs/Ravensat/Solver.html +373 -0
  22. data/docs/Ravensat/VarNode.html +488 -0
  23. data/docs/Ravensat.html +135 -0
  24. data/docs/_index.html +329 -0
  25. data/docs/class_list.html +51 -0
  26. data/docs/css/common.css +1 -0
  27. data/docs/css/full_list.css +58 -0
  28. data/docs/css/style.css +497 -0
  29. data/docs/file.README.html +233 -0
  30. data/docs/file_list.html +56 -0
  31. data/docs/frames.html +17 -0
  32. data/docs/index.html +233 -0
  33. data/docs/js/app.js +314 -0
  34. data/docs/js/full_list.js +216 -0
  35. data/docs/js/jquery.js +4 -0
  36. data/docs/method_list.html +523 -0
  37. data/docs/top-level-namespace.html +110 -0
  38. data/exe/ravensat +1 -5
  39. data/lib/ravensat/ast/and_node.rb +8 -0
  40. data/lib/ravensat/ast/node.rb +84 -20
  41. data/lib/ravensat/ast/not_node.rb +7 -0
  42. data/lib/ravensat/ast/or_node.rb +9 -0
  43. data/lib/ravensat/ast/var_node.rb +10 -1
  44. data/lib/ravensat/claw.rb +44 -0
  45. data/lib/ravensat/dimacs/dimacs_decoder.rb +9 -6
  46. data/lib/ravensat/dimacs/dimacs_encoder.rb +10 -13
  47. data/lib/ravensat/extension/domain.rb +0 -1
  48. data/lib/ravensat/extension/variable/integer_variable.rb +3 -3
  49. data/lib/ravensat/solver.rb +1 -8
  50. data/lib/ravensat/version.rb +1 -1
  51. data/lib/ravensat.rb +1 -1
  52. metadata +38 -3
  53. data/lib/ravensat/ravenclaw.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d0f5a2e88e6b17130dc2101a9c2e85d0e401fba9bcba081299cf14ded1c683b
4
- data.tar.gz: ee09cdeb7da7fd0cd04a80a5017ae351b836cf9a6d63ab92fddaa9181f36dff2
3
+ metadata.gz: bd6bb73a8f6668c36675461d24272ae8e02632c5b2d3f768b5a81347ad29956a
4
+ data.tar.gz: 48e4f44fa76bd1716b32ed98ddaa82d198cb83064e944269ecfd57ab21645860
5
5
  SHA512:
6
- metadata.gz: d763bab0b969a710ef42cae2e1aed39161e4b49488c1d898f8665b14a4763df09a881508875576f6505fc25c75daed694b805cb82ca081c95ac61d31bb49c12d
7
- data.tar.gz: d5ff19dd7503194401664bba22b12bbe16a7ce8b6f1ff8cb54d19d1fcfde0d8912ad25d9762549d19f50dcc0d9d82161f020fae1c1207bd015ce530178eb8b62
6
+ metadata.gz: 5365bfdf37eeb55b5a7ccab53f0ecca8cf8c73ecdfcac2eb9c92ce843aa6fa2e77f711f14a9b00f37cb9a37bfade19c65ea38cbd3f7478398b0d1ef8a5cf416a
7
+ data.tar.gz: abf648c3097425241ae106e7ed42876f9c9a33e55bf4615cefc16c77943aedf62b0bd99fc6b9c2062147dbaf6c9b690b13f5a28204771e03934e4c59bdf98a9e
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.0
14
+ - name: Run the default task
15
+ run: |
16
+ gem install bundler -v 2.2.3
17
+ bundle install
18
+ bundle exec rake
data/README.md CHANGED
@@ -1,8 +1,54 @@
1
1
  # Ravensat
2
2
 
3
- Ravensat is an interface to SAT Solver .
4
- In order to use Ravensat, you need to install SAT Solver and specify the name of the Solver .
5
- (If you do not specify SAT Solver, it will use the one bundled in the gem .)
3
+ [![GitHub Actions](https://github.com/matsuda0528/ravensat/actions/workflows/main.yml/badge.svg)](https://github.com/matsuda0528/ravensat/actions/workflows/main.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/ravensat.svg)](https://badge.fury.io/rb/ravensat)
5
+ [![LICENSE](https://img.shields.io/github/license/matsuda0528/ravensat)](https://opensource.org/licenses/MIT)
6
+
7
+ [![GitHub Pages](https://img.shields.io/badge/GitHub%20Pages--brightgreen.svg?logo=github&style=social)](https://matsuda0528.github.io/ravensat/)
8
+
9
+ Ravensat is an interface to SAT solver in Ruby.
10
+
11
+ In order to use Ravensat, you need to install SAT solver.
12
+ If you do not install SAT solver, it will use the one bundled in the gem.
13
+
14
+ About [SAT](https://en.wikipedia.org/wiki/Boolean_satisfiability_problem), [SAT solver](https://en.wikipedia.org/wiki/SAT_solver)
15
+
16
+ ## Description
17
+ To solve SAT, we usually use SAT solver.
18
+ Now, let's solve the following SAT with SAT solver.
19
+
20
+ $$(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})$$
21
+
22
+ Most SAT solvers are input in [DIMACS Format](https://www.cs.utexas.edu/users/moore/acl2/manuals/current/manual/index-seo.php/SATLINK____DIMACS).
23
+ Converting the example SAT to DIMACS Format yields the following.
24
+
25
+ ```DIMACS Format
26
+ p cnf 5 3
27
+ 1 -5 4 0
28
+ -1 5 3 4 0
29
+ -3 -4 0
30
+ ```
31
+
32
+ DIMACS Format is widely distributed as an I/O format for SAT solver.
33
+ However, when solving a large SAT, the following problems occur.
34
+ - Need to create a file with thousands of lines.
35
+ - Confusion arises because of the inability to name variables meaningfully.
36
+
37
+ To solve these problems, Ravensat can be used.
38
+ Using Ravensat, propositional variables can be defined as local variables in Ruby.
39
+
40
+ ```ruby
41
+ fuji_is_the_highest_mountain_in_japan = Ravensat::VarNode.new
42
+ ```
43
+
44
+ In addition, you can write logical expressions intuitively.
45
+
46
+ ```ruby
47
+ x = Ravensat::VarNode.new
48
+ y = Ravensat::VarNode.new
49
+
50
+ (x | y) & (~x | y) # (x or y) and (not x or y)
51
+ ```
6
52
 
7
53
 
8
54
  ## Installation
@@ -22,26 +68,45 @@ Or install it yourself as:
22
68
  $ gem install ravensat
23
69
 
24
70
  ## Usage
25
- ### General Usage
71
+ ### Basic Usage
72
+ This is a basic usage example of the library.
73
+
26
74
  ```ruby
27
75
  require 'ravensat'
28
76
 
29
77
  a = Ravensat::VarNode.new
30
78
  b = Ravensat::VarNode.new
31
79
 
32
- a.value #=> nil
33
- b.value #=> nil
80
+ a.result #=> nil
81
+ b.result #=> nil
34
82
 
35
83
  logic = (a | b) & (~a | b) & (a | ~b)
36
84
 
37
85
  solver = Ravensat::Solver.new
38
86
  solver.solve logic #=> true(SAT)
39
87
 
40
- a.value #=> true
41
- b.value #=> true
88
+ a.result #=> true
89
+ b.result #=> true
90
+ ```
91
+
92
+ If you have SAT solver installed, you can write:
93
+
94
+ ```ruby
95
+ solver = Ravensat::Solver.new("<solver_name>")
96
+ solver.solve logic
42
97
  ```
43
98
 
44
- ### Extension Usage(SAT)
99
+ The available solvers are assumed to be those that can be I/O in the DIMACS Format.
100
+ At least, we have confirmed that it works properly with [MiniSat](https://github.com/niklasso/minisat).
101
+
102
+ If you do not use an external SAT solver, create a SAT solver object without any constructor arguments.
103
+ In that case, **Arcteryx**(the very simple SAT solver built into Ravensat) will launch.
104
+
105
+ ### Extension Usage
106
+ In Ravensat::Extension, C-like variable definitions are available.
107
+
108
+ *Note: In Ravensat::Extension, all undefined variables and methods are caught by method_missing method.*
109
+
45
110
  ```ruby
46
111
  require 'ravensat'
47
112
 
@@ -53,13 +118,15 @@ module Ravensat
53
118
  solver = Ravensat::Solver.new
54
119
  solver.solve logic #=> true
55
120
 
56
- a.value #=> true
57
- b.value #=> true
121
+ a.result #=> true
122
+ b.result #=> true
58
123
  end
59
124
  end
60
125
  ```
61
126
 
62
127
  ### Extension Usage(CSP; Constraint Satisfaction Problem)
128
+ It is possible to define integer variables and to describe some integer constraints.
129
+
63
130
  ```ruby
64
131
  require 'ravensat'
65
132
 
@@ -83,10 +150,20 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
83
150
 
84
151
  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).
85
152
 
153
+ ## License
154
+
155
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
156
+
86
157
  ## Contributing
87
158
 
88
159
  Bug reports and pull requests are welcome on GitHub at https://github.com/matsuda0528/ravensat.
89
160
 
90
- ## License
161
+ ```
162
+ ____ _
163
+ | _ \ __ ___ _____ _ __ ___ __ _| |_
164
+ | |_) / _` \ \ / / _ \ '_ \/ __|/ _` | __|
165
+ | _ < (_| |\ V / __/ | | \__ \ (_| | |_
166
+ |_| \_\__,_| \_/ \___|_| |_|___/\__,_|\__|
167
+
168
+ ```
91
169
 
92
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).