Class: PropLogic::ThenTerm
- Inherits:
-
Term
- Object
- Term
- PropLogic::ThenTerm
show all
- Defined in:
- lib/prop_logic/then_term.rb
Instance Attribute Summary
Attributes inherited from Term
#terms
Instance Method Summary
collapse
Methods inherited from Term
#and, #assign, #assign_false, #assign_true, #cnf?, #each_sat, #equiv?, generate_cache, get, #initialize_copy, #not, #or, #reduced?, #sat?, #then, #to_cnf, #to_s_in_term, #unsat?, #variables
Methods included from Functions
all_and, all_or, new_variable, sat_loop
Constructor Details
#initialize(term1, term2) ⇒ ThenTerm
Returns a new instance of ThenTerm.
3
4
5
|
# File 'lib/prop_logic/then_term.rb', line 3
def initialize(term1, term2)
@terms = [term1, term2].freeze
end
|
Instance Method Details
#nnf? ⇒ Boolean
12
13
14
|
# File 'lib/prop_logic/then_term.rb', line 12
def nnf?
false
end
|
#reduce ⇒ Object
20
21
22
|
# File 'lib/prop_logic/then_term.rb', line 20
def reduce
to_nnf.reduce
end
|
#to_nnf ⇒ Object
16
17
18
|
# File 'lib/prop_logic/then_term.rb', line 16
def to_nnf
(~@terms[0]).to_nnf | @terms[1].to_nnf
end
|
#to_s(in_term = false) ⇒ Object
7
8
9
10
|
# File 'lib/prop_logic/then_term.rb', line 7
def to_s(in_term = false)
str = "#{@terms[0].to_s(true)} => #{@terms[1].to_s(true)}"
in_term ? "( #{str} )" : str
end
|