Class: TruthTable
- Inherits:
-
Object
- Object
- TruthTable
- Defined in:
- lib/logical/algorithms/truth_table.rb
Instance Attribute Summary collapse
-
#evaluations ⇒ Object
readonly
Returns the value of attribute evaluations.
Instance Method Summary collapse
-
#initialize(formula) ⇒ TruthTable
constructor
A new instance of TruthTable.
- #invalid? ⇒ Boolean
- #satisfied? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(formula) ⇒ TruthTable
Returns a new instance of TruthTable.
6 7 8 9 10 |
# File 'lib/logical/algorithms/truth_table.rb', line 6 def initialize(formula) @formula = formula letters = formula.literals.map(&:letter) @evaluations = Interpretation.all(letters).map { |i| Evaluation.new(i, formula) } end |
Instance Attribute Details
#evaluations ⇒ Object (readonly)
Returns the value of attribute evaluations.
4 5 6 |
# File 'lib/logical/algorithms/truth_table.rb', line 4 def evaluations @evaluations end |
Instance Method Details
#invalid? ⇒ Boolean
20 21 22 |
# File 'lib/logical/algorithms/truth_table.rb', line 20 def invalid? !satisfied? end |
#satisfied? ⇒ Boolean
16 17 18 |
# File 'lib/logical/algorithms/truth_table.rb', line 16 def satisfied? @evaluations.map(&:value).any? end |
#valid? ⇒ Boolean
12 13 14 |
# File 'lib/logical/algorithms/truth_table.rb', line 12 def valid? @evaluations.map(&:value).all? end |