Class: Proposition
- Inherits:
-
Object
- Object
- Proposition
- Defined in:
- lib/catlogic/proposition.rb
Instance Attribute Summary collapse
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
-
#quality ⇒ Object
readonly
Returns the value of attribute quality.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#truthvalue ⇒ Object
readonly
Returns the value of attribute truthvalue.
Instance Method Summary collapse
- #contradictory ⇒ Object
- #contrapolated ⇒ Object
- #contrary ⇒ Object
- #converse ⇒ Object
- #distribution(position) ⇒ Object
-
#initialize(quantity, subject, quality, predicate, truthvalue) ⇒ Proposition
constructor
A new instance of Proposition.
- #label ⇒ Object
- #number_of_occurences(set) ⇒ Object
- #obverse ⇒ Object
- #position_of_term(term) ⇒ Object
- #same_as?(proposition) ⇒ Boolean
- #subaltern ⇒ Object
- #subcontrary ⇒ Object
- #type ⇒ Object
- #unique?(set) ⇒ Boolean
Constructor Details
#initialize(quantity, subject, quality, predicate, truthvalue) ⇒ Proposition
Returns a new instance of Proposition.
5 6 7 8 9 10 11 |
# File 'lib/catlogic/proposition.rb', line 5 def initialize(quantity, subject, quality, predicate, truthvalue) @quantity=quantity @subject=subject @quality=quality @predicate=predicate @truthvalue=truthvalue end |
Instance Attribute Details
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
3 4 5 |
# File 'lib/catlogic/proposition.rb', line 3 def predicate @predicate end |
#quality ⇒ Object (readonly)
Returns the value of attribute quality.
3 4 5 |
# File 'lib/catlogic/proposition.rb', line 3 def quality @quality end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
3 4 5 |
# File 'lib/catlogic/proposition.rb', line 3 def quantity @quantity end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
3 4 5 |
# File 'lib/catlogic/proposition.rb', line 3 def subject @subject end |
#truthvalue ⇒ Object (readonly)
Returns the value of attribute truthvalue.
3 4 5 |
# File 'lib/catlogic/proposition.rb', line 3 def truthvalue @truthvalue end |
Instance Method Details
#contradictory ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/catlogic/proposition.rb', line 26 def contradictory quantity = @quantity.opposite quality = @quality.opposite @contradictory = Proposition.new(quantity, @subject, quality, @predicate, !@truthvalue) return @contradictory end |
#contrapolated ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/catlogic/proposition.rb', line 106 def contrapolated if self.type.label == "E" || self.type.label == "I" truthvalue = "unknown" else truthvalue = @truthvalue end subject = @subject.opposite predicate = @predicate.opposite @contrapolated = Proposition.new(@quantity, predicate, @quality, subject, truthvalue) end |
#contrary ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/catlogic/proposition.rb', line 57 def contrary if @quantity.label == "particular" abort("There is no contrary for this type of propostion. Try subcontrary") end quality = @quality.opposite if @truthvalue truthvalue = !@truthvalue elsif !@truthvalue truthvalue = "unknown" end contrary = Proposition.new(@quantity, @subject, quality, @predicate, truthvalue) return contrary end |
#converse ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/catlogic/proposition.rb', line 90 def converse if self.type.label == "A" || self.type.label == "O" truthvalue = "unknown" else truthvalue = @truthvalue end @converse = Proposition.new(@quantity, @predicate, @quality, @subject, truthvalue) end |
#distribution(position) ⇒ Object
149 150 151 152 153 154 155 156 |
# File 'lib/catlogic/proposition.rb', line 149 def distribution(position) if position == 'subject' distribution = @subject.distribution_subject(@quantity) elsif position == 'predicate' distribution = @predicate.distribution_predicate(@quality) end return distribution end |
#label ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/catlogic/proposition.rb', line 128 def label if @quantity.label == "universal" if @quality.label == "affirmative" display_quantity = "All" display_quality = "are" elsif @quality.label == "negative" display_quantity = "No" display_quality = "are" end elsif @quantity.label == "particular" if @quality.label == "affirmative" display_quantity = "Some" display_quality = "are" elsif @quality.label == "negative" display_quantity = "Some" display_quality = "are not" end end "#{display_quantity} #{@subject.label} #{display_quality} #{@predicate.label}" end |
#number_of_occurences(set) ⇒ Object
179 180 181 182 183 184 185 186 187 |
# File 'lib/catlogic/proposition.rb', line 179 def number_of_occurences(set) @occurences = 0 set.each do |proposition| if self.same_as?(proposition) @occurences += 1 end end @occurences end |
#obverse ⇒ Object
99 100 101 102 103 104 |
# File 'lib/catlogic/proposition.rb', line 99 def obverse quality = @quality.opposite predicate = @predicate.opposite @obverse = Proposition.new(@quantity, @subject, quality, predicate, @truthvalue) end |
#position_of_term(term) ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'lib/catlogic/proposition.rb', line 119 def position_of_term(term) if self.subject.label == term.label @positionofmiddle = 'subject' elsif self.predicate.label == term.label @positionofmiddle = 'predicate' end return @positionofmiddle end |
#same_as?(proposition) ⇒ Boolean
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/catlogic/proposition.rb', line 158 def same_as?(proposition) if (proposition.quantity.label == self.quantity.label && proposition.subject.label == self.subject.label && proposition.quality.label == self.quality.label && proposition.predicate.label == self.predicate.label && proposition.truthvalue == self.truthvalue) true else false end end |
#subaltern ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/catlogic/proposition.rb', line 35 def subaltern quantity = @quantity.opposite if @quantity.label == "universal" if @truthvalue truthvalue = @truthvalue elsif !@truthvalue truthvalue = "unknown" end elsif @quantity.label == "particular" if !@truthvalue truthvalue = !@truthvalue elsif @truthvalue truthvalue = "unknown" end end @subaltern = Proposition.new(quantity, @subject, @quality, @predicate, truthvalue) return @subaltern end |
#subcontrary ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/catlogic/proposition.rb', line 73 def subcontrary if @quantity.label == "universal" abort("There is no subcontrary for this type of propostion. Try contrary.") end quality = @quality.opposite if !@truthvalue truthvalue = !@truthvalue elsif @truthvalue truthvalue = "unknown" end subcontrary = Proposition.new(@quantity, @subject, quality, @predicate, truthvalue) return subcontrary end |
#type ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/catlogic/proposition.rb', line 13 def type if @quantity.label == 'universal' && @quality.label == 'affirmative' @type=PropositionType.new("A") elsif @quantity.label == 'universal' && @quality.label == 'negative' @type=PropositionType.new("E") elsif @quantity.label == 'particular' && @quality.label == 'affirmative' @type=PropositionType.new("I") elsif @quantity.label == 'particular' && @quality.label == 'negative' @type=PropositionType.new("O") end return @type end |
#unique?(set) ⇒ Boolean
170 171 172 173 174 175 176 177 |
# File 'lib/catlogic/proposition.rb', line 170 def unique?(set) numerofoccurences = self.number_of_occurences(set) if numerofoccurences == 0 true else false end end |