Class: Implication

Inherits:
Object
  • Object
show all
Defined in:
lib/logical/formulas/implication.rb

Instance Method Summary collapse

Constructor Details

#initialize(f, g) ⇒ Implication

Returns a new instance of Implication.



4
5
6
7
# File 'lib/logical/formulas/implication.rb', line 4

def initialize(f, g)
  @f = f
  @g = g
end

Instance Method Details

#evaluate(interpretation) ⇒ Object



9
10
11
12
# File 'lib/logical/formulas/implication.rb', line 9

def evaluate(interpretation)
  # Since F → G ≡ ¬F ∨ G 

  !(@f.evaluate(interpretation)) || @g.evaluate(interpretation)
end

#literalsObject



14
15
16
# File 'lib/logical/formulas/implication.rb', line 14

def literals
  @f.literals | @g.literals
end

#to_sObject



18
19
20
# File 'lib/logical/formulas/implication.rb', line 18

def to_s
  "(#{@f.to_s}→#{@g.to_s})"
end