Class: PropLogic::Variable
- Inherits:
-
Term
- Object
- Term
- PropLogic::Variable
show all
- Defined in:
- lib/prop_logic/variable.rb
Instance Attribute Summary
Attributes inherited from Term
#terms
Instance Method Summary
collapse
Methods inherited from Term
#and, #assign_false, #assign_true, #each_sat, #equiv?, generate_cache, get, #initialize_copy, #or, #reduce, #sat?, #then, #to_nnf, #to_s_in_term, #unsat?
Methods included from Functions
all_and, all_or, new_variable, sat_loop
Constructor Details
#initialize(name = nil) ⇒ Variable
Returns a new instance of Variable.
3
4
5
6
7
|
# File 'lib/prop_logic/variable.rb', line 3
def initialize(name = nil)
@name = name || "v_#{object_id}"
@terms = [].freeze
freeze
end
|
Instance Method Details
#assign(trues, falses, variables = nil) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/prop_logic/variable.rb', line 39
def assign(trues, falses, variables = nil)
if trues.include? self
True
elsif falses.include? self
False
else
self
end
end
|
#cnf? ⇒ Boolean
31
32
33
|
# File 'lib/prop_logic/variable.rb', line 31
def cnf?
true
end
|
#nnf? ⇒ Boolean
15
16
17
|
# File 'lib/prop_logic/variable.rb', line 15
def nnf?
true
end
|
#not ⇒ NotTerm
Also known as:
~, -@
51
52
53
|
# File 'lib/prop_logic/variable.rb', line 51
def not
Term.__send__ :cached, NotTerm, self
end
|
#reduced? ⇒ Boolean
19
20
21
|
# File 'lib/prop_logic/variable.rb', line 19
def reduced?
true
end
|
#to_cnf ⇒ Object
23
24
25
|
# File 'lib/prop_logic/variable.rb', line 23
def to_cnf
self
end
|
#to_s ⇒ Object
11
12
13
|
# File 'lib/prop_logic/variable.rb', line 11
def to_s(*)
@name
end
|
#tseitin(pool) ⇒ Object
27
28
29
|
# File 'lib/prop_logic/variable.rb', line 27
def tseitin(pool)
self
end
|
#variables ⇒ Object
35
36
37
|
# File 'lib/prop_logic/variable.rb', line 35
def variables
[self]
end
|