Class: Hilbert::World::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/hilbert/world.rb

Constant Summary collapse

@@propositions =
[]

Class Method Summary collapse

Class Method Details

.<<(logic_form) ⇒ Object



13
14
15
# File 'lib/hilbert/world.rb', line 13

def <<(logic_form)
  @@propositions << logic_form
end

.atom(sym) ⇒ Object



31
32
33
34
35
36
# File 'lib/hilbert/world.rb', line 31

def atom(sym)
  unless sym.to_s == sym.to_s.upcase && sym.to_s.length == 1
    raise 'Proposltionla variable should be capital character'
  end
  eval "$#{sym} ||= PropositionalLogic::Atom.new(:#{sym})"
end

.clear!Object



38
39
40
# File 'lib/hilbert/world.rb', line 38

def clear!
  @@propositions = []
end

.impl(logic_form, logic_str) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hilbert/world.rb', line 17

def impl(logic_form, logic_str)
  # HOTFIX:
  return %|"Evaluate: #{logic_str} is UNDEFINED"| if @@propositions.empty?
  str = (!!!!!!!(@@propositions.inject(:*) >= logic_form)).to_s
  case str
  when 'TRUE'
    %|"Evaluate: #{logic_str} is TRUE"|
  when 'FALSE'
    %|"Evaluate: #{logic_str} is FALSE"|
  else
    %|"Evaluate: #{logic_str} is UNDEFINED"|
  end
end

.tautologyObject



9
10
11
# File 'lib/hilbert/world.rb', line 9

def tautology
  @@propositions
end