| Total Complexity | 3 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| 1 | module PropLogic |
||
| 6 | # |
||
| 7 | class DefaultIncrementalSolver |
||
| 8 | # @param [Term] initial term |
||
| 9 | def initialize(term) |
||
| 10 | @term = term |
||
| 11 | end |
||
| 12 | |||
| 13 | # Current term |
||
| 14 | attr_reader :term |
||
| 15 | |||
| 16 | # Adding new terms to this solver. |
||
| 17 | # @param [Term] terms to add. |
||
| 18 | # @return [DefaultIncrementalSolver] self |
||
| 19 | def add(*terms) |
||
| 20 | @term = @term.and(*terms) |
||
| 21 | self |
||
| 22 | end |
||
| 23 | |||
| 24 | alias_method :<<, :add |
||
| 25 | |||
| 26 | # Check satisfiability of terms. |
||
| 27 | # @return [Term] if satisfied |
||
| 28 | # @return [false] if unsatisfied |
||
| 29 | def sat? |
||
| 30 | @term.sat? |
||
| 31 | end |
||
| 32 | end |
||
| 34 |