Class: Syllogism
- Inherits:
-
Object
- Object
- Syllogism
- Defined in:
- lib/catlogic/syllogism.rb
Overview
Class for any syllogism object.
Instance Attribute Summary collapse
-
#conclusion ⇒ Object
readonly
Returns the value of attribute conclusion.
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
Instance Method Summary collapse
- #affirm_from_neg_test ⇒ Object
- #displayPropositionalForm ⇒ Object
-
#exclusive_premises_test ⇒ Object
exclusive premises.
-
#figure ⇒ Object
gets the Figure of Syllogism (e.g. 1, 2, 3, 4).
-
#form ⇒ Object
Retrieve Form object of the Syllogism (i.e. AAAI, EAI4).
- #illicit_major_test ⇒ Object
- #illicit_minor_test ⇒ Object
-
#initialize(major, minor, conclusion = nil) ⇒ Syllogism
constructor
Syllogism object initiation takes three Proposition objects.
- #label ⇒ Object
-
#majorterm ⇒ Object
gets the major term as a String from the major premise by identifying the middle term and then identifying the term in the premise that is not the middle.
-
#middle ⇒ Object
This method gets the middle term by looking for the term in the major and minor terms that are used twice.
- #minorterm ⇒ Object
-
#mood ⇒ Object
returns the Mood object of Syllogism (e.g. AAA, EEE).
- #neg_from_affirms_test ⇒ Object
- #three_term? ⇒ Boolean
- #undistributed_middle_test ⇒ Object
- #validity ⇒ Object
Constructor Details
#initialize(major, minor, conclusion = nil) ⇒ Syllogism
Syllogism object initiation takes three Proposition objects
7 8 9 10 11 12 13 14 15 |
# File 'lib/catlogic/syllogism.rb', line 7 def initialize(major, minor, conclusion=nil) @major = major @minor = minor if conclusion == nil @conclusion = self.getComputedConclusion else @conclusion = conclusion end end |
Instance Attribute Details
#conclusion ⇒ Object (readonly)
Returns the value of attribute conclusion.
3 4 5 |
# File 'lib/catlogic/syllogism.rb', line 3 def conclusion @conclusion end |
#major ⇒ Object (readonly)
Returns the value of attribute major.
3 4 5 |
# File 'lib/catlogic/syllogism.rb', line 3 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
3 4 5 |
# File 'lib/catlogic/syllogism.rb', line 3 def minor @minor end |
Instance Method Details
#affirm_from_neg_test ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/catlogic/syllogism.rb', line 130 def affirm_from_neg_test if (@major.quality.label == 'negative' || @minor.quality.label == 'negative') && @conclusion.quality.label != 'negative' validity = false else validity = true end end |
#displayPropositionalForm ⇒ Object
167 168 169 170 |
# File 'lib/catlogic/syllogism.rb', line 167 def displayPropositionalForm form = Form.new(self.mood, self.figure) form.displayPropositionalForm end |
#exclusive_premises_test ⇒ Object
exclusive premises
122 123 124 125 126 127 128 |
# File 'lib/catlogic/syllogism.rb', line 122 def exclusive_premises_test if @major.quality.label == 'negative' && @minor.quality.label == 'negative' validity = false else validity = true end end |
#figure ⇒ Object
gets the Figure of Syllogism (e.g. 1, 2, 3, 4)
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/catlogic/syllogism.rb', line 73 def figure mjmp = @major.position_of_term(self.middle) mnmp = @minor.position_of_term(self.middle) if mjmp == 'subject' && mnmp == 'predicate' figure = Figure.new(1) elsif mjmp == 'predicate' && mnmp == 'predicate' figure = Figure.new(2) elsif mjmp == 'subject' && mnmp == 'subject' figure = Figure.new(3) elsif mjmp == 'predicate' && mnmp == 'subject' figure = Figure.new(4) end return figure end |
#form ⇒ Object
Retrieve Form object of the Syllogism (i.e. AAAI, EAI4)
90 91 92 93 |
# File 'lib/catlogic/syllogism.rb', line 90 def form form = Form.new(self.mood, self.figure) return form end |
#illicit_major_test ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/catlogic/syllogism.rb', line 105 def illicit_major_test ##Rule Number 2a distribution of major term if @conclusion.distribution('predicate').label == 'distributed' && @major.distribution(@major.position_of_term(self.majorterm)).label != 'distributed' validity = false else validity = true end end |
#illicit_minor_test ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/catlogic/syllogism.rb', line 113 def illicit_minor_test ##Rule Number 2b distribution of minor term - check fallacy of illicit minor if @conclusion.distribution('subject').label == 'distributed' && @minor.distribution(@minor.position_of_term(self.minorterm)).label != 'distributed' validity = false else validty = true end end |
#label ⇒ Object
157 158 159 |
# File 'lib/catlogic/syllogism.rb', line 157 def label return "#{@major.label}\n#{@minor.label}\n#{@conclusion.label}" end |
#majorterm ⇒ Object
gets the major term as a String from the major premise by identifying the middle term and then identifying the term in the premise that is not the middle
47 48 49 50 51 52 53 54 |
# File 'lib/catlogic/syllogism.rb', line 47 def majorterm if @major.subject.label == self.middle.label majorterm = @major.predicate else majorterm = @major.subject end majorterm end |
#middle ⇒ Object
This method gets the middle term by looking for the term in the major and minor terms that are used twice.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/catlogic/syllogism.rb', line 18 def middle termarray = [@major.subject.label, @major.predicate.label, @minor.subject.label, @minor.predicate.label] middle = nil if self.three_term? termarray.detect do |term| if termarray.count(term) == 2 middle = Term.new(term) end end else middle = "Error: this is not a three term syllogism" end middle end |
#minorterm ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/catlogic/syllogism.rb', line 55 def minorterm if @minor.subject.label == self.middle.label minorterm = @minor.predicate else minorterm = @minor.subject end minorterm end |
#mood ⇒ Object
returns the Mood object of Syllogism (e.g. AAA, EEE)
66 67 68 69 |
# File 'lib/catlogic/syllogism.rb', line 66 def mood mood = Mood.new(@major.type, @minor.type, @conclusion.type) return mood end |
#neg_from_affirms_test ⇒ Object
138 139 140 141 142 143 144 145 146 |
# File 'lib/catlogic/syllogism.rb', line 138 def neg_from_affirms_test if (@conclusion.quality.label == 'negative' && (@major.quality.label != 'negative' && @minor.quality.label != 'negative')) validity = false #validity = "pass" else validity = true end end |
#three_term? ⇒ Boolean
33 34 35 36 37 38 39 40 |
# File 'lib/catlogic/syllogism.rb', line 33 def three_term? termarray = [@major.subject.label, @major.predicate.label, @minor.subject.label, @minor.predicate.label] if termarray.uniq.size == 3 answer = true else answer = false end end |
#undistributed_middle_test ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/catlogic/syllogism.rb', line 95 def undistributed_middle_test ## Rule Number 1 - middle distributed if @major.distribution(@major.position_of_term(self.middle)).label == 'undistributed' && @minor.distribution(@minor.position_of_term(self.middle)).label == 'undistributed' validity = false else validity = true end return validity end |
#validity ⇒ Object
149 150 151 152 153 154 155 |
# File 'lib/catlogic/syllogism.rb', line 149 def validity if (self.undistributed_middle_test != true || self.illicit_major_test != true || self.illicit_minor_test != true || self.exclusive_premises_test != true || self.affirm_from_neg_test != true || self.neg_from_affirms_test != true) validity = false else validity = true end end |