Class: Logica::Predicates::Compounds::Disjunction

Inherits:
Base
  • Object
show all
Defined in:
lib/logica/predicates/compounds/disjunction.rb

Constant Summary

Constants inherited from Base

Base::ACCEPTOR_TYPE_ID

Instance Attribute Summary

Attributes inherited from Base

#predicates

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#arity, #initialize, #name_and_attributes, new_from_list, new_from_pair, #with_extra_predicate_last, #with_extra_predicates, #without

Methods inherited from Base

#and, #and_not, #arity, #disjoint_with?, #exhaustive_with?, #generalization_of?, #generalization_of_negation_of?, #iff, #implies, #method_missing, #name_and_attributes, #negated, #or_not, #partially_applied_with, predicate_factory, #respond_to_missing?, #to_method, #to_proc, #to_s, #unsatisfied_by?, #xor

Methods included from ComparableByState

#==, #hash, #state

Constructor Details

This class inherits a constructor from Logica::Predicates::Compounds::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Logica::Predicates::Base

Class Method Details

.absorbing_elementObject



14
15
16
# File 'lib/logica/predicates/compounds/disjunction.rb', line 14

def absorbing_element
  predicate_factory.tautology
end

.internal_binary_operationObject



6
7
8
# File 'lib/logica/predicates/compounds/disjunction.rb', line 6

def internal_binary_operation
  :or
end

.neutral_elementObject



10
11
12
# File 'lib/logica/predicates/compounds/disjunction.rb', line 10

def neutral_element
  predicate_factory.contradiction
end

Instance Method Details

#generalization_of_other?(other) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/logica/predicates/compounds/disjunction.rb', line 35

def generalization_of_other?(other)
  super || predicates.any? { |pred| pred.generalization_of?(other) }
end

#or(other) ⇒ Object



23
24
25
# File 'lib/logica/predicates/compounds/disjunction.rb', line 23

def or(other)
  other.or_with_disjunction(self)
end

#or_with_other(other) ⇒ Object



27
28
29
# File 'lib/logica/predicates/compounds/disjunction.rb', line 27

def or_with_other(other)
  with_extra_predicate_first(other)
end

#portion_satisfied_by(*arguments) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/logica/predicates/compounds/disjunction.rb', line 39

def portion_satisfied_by(*arguments)
  if satisfied_by?(*arguments)
    self
  else
    portions = predicates.map { |predicate| predicate.portion_satisfied_by(*arguments) }
    predicate_factory.conjunction(portions)
  end
end

#remainder_unsatisfied_by(*arguments) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/logica/predicates/compounds/disjunction.rb', line 48

def remainder_unsatisfied_by(*arguments)
  if satisfied_by?(*arguments)
    predicate_factory.contradiction
  else
    remainders = predicates.map { |predicate| predicate.remainder_unsatisfied_by(*arguments) }
    predicate_factory.disjunction(remainders)
  end
end

#satisfied_by?(*arguments) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/logica/predicates/compounds/disjunction.rb', line 19

def satisfied_by?(*arguments)
  predicates.any? { |predicate| predicate.satisfied_by?(*arguments) }
end

#specialization_of?(other) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/logica/predicates/compounds/disjunction.rb', line 31

def specialization_of?(other)
  other.generalization_of_disjunction?(self)
end