module MagicLogic::Utils
Constants
- ATOM_PREFIX
Public Instance Methods
dpll()
click to toggle source
# File lib/magic_logic/utils.rb, line 46 def dpll case self when *[Taut, UTaut, Atom] self else #TODO: refactor count = $atoms.count rslt = (1 .. 2 ** count).map do |i| s = evl count.times { |j| s.sbst!(j, (i >> j) & 1 == 1) } eval(s) end case rslt.uniq when [true] then $tout when [false] then $utout else self end end end
evl()
click to toggle source
# File lib/magic_logic/utils.rb, line 30 def evl case self when Taut then "(true)" when UTaut then "(false)" when Atom then "(#{ATOM_PREFIX}#{$atoms.index(self)})" when FORM then "(#{vars.map(&:evl).join(_ ope, '||', '&&')})" when NEG then "(!#{p.evl})" end end
include?(p)
click to toggle source
# File lib/magic_logic/utils.rb, line 26 def include?(p) false end
is_and?()
click to toggle source
# File lib/magic_logic/utils.rb, line 22 def is_and? is_form?(:*) end
is_form?(ope=nil)
click to toggle source
# File lib/magic_logic/utils.rb, line 13 def is_form?(ope=nil) return is_a?(FORM) && self.ope == ope if ope is_a?(FORM) end
is_neg?()
click to toggle source
# File lib/magic_logic/utils.rb, line 9 def is_neg? is_a?(NEG) end
is_or?()
click to toggle source
# File lib/magic_logic/utils.rb, line 18 def is_or? is_form?(:+) end
neg?(p)
click to toggle source
# File lib/magic_logic/utils.rb, line 5 def neg?(p) (is_neg? && self.p == p) || (p.is_neg? && p.p == self) end