Class: Catlogic::Syllogism

Inherits:
Object
  • Object
show all
Defined in:
lib/catlogic/syllogism.rb

Overview

Class for any syllogism object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(major, minor, conclusion = nil) ⇒ Syllogism

Syllogism object initiation takes three Proposition objects



8
9
10
11
12
13
14
15
16
# File 'lib/catlogic/syllogism.rb', line 8

def initialize(major, minor, conclusion=nil)
  @major = major
  @minor = minor
  if conclusion == nil
    @conclusion = self.getComputedConclusion
  else
    @conclusion = conclusion
  end
end

Instance Attribute Details

#conclusionObject (readonly)

Returns the value of attribute conclusion.



4
5
6
# File 'lib/catlogic/syllogism.rb', line 4

def conclusion
  @conclusion
end

#majorObject (readonly)

Returns the value of attribute major.



4
5
6
# File 'lib/catlogic/syllogism.rb', line 4

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



4
5
6
# File 'lib/catlogic/syllogism.rb', line 4

def minor
  @minor
end

Instance Method Details

#affirm_from_neg_testObject



131
132
133
134
135
136
137
# File 'lib/catlogic/syllogism.rb', line 131

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

#displayPropositionalFormObject



162
163
164
165
# File 'lib/catlogic/syllogism.rb', line 162

def displayPropositionalForm
  form = Form.new(self.mood, self.figure)
  form.displayPropositionalForm
end

#exclusive_premises_testObject

exclusive premises



123
124
125
126
127
128
129
# File 'lib/catlogic/syllogism.rb', line 123

def exclusive_premises_test
  if @major.quality.label == 'negative' && @minor.quality.label == 'negative'
    validity = false
  else
    validity = true
  end
end

#figureObject

gets the Figure of Syllogism (e.g. 1, 2, 3, 4)



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/catlogic/syllogism.rb', line 74

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

#formObject

Retrieve Form object of the Syllogism (i.e. AAAI, EAI4)



91
92
93
94
# File 'lib/catlogic/syllogism.rb', line 91

def form
  form = Form.new(self.mood, self.figure)
  return form
end

#illicit_major_testObject



106
107
108
109
110
111
112
113
# File 'lib/catlogic/syllogism.rb', line 106

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_testObject



114
115
116
117
118
119
120
121
# File 'lib/catlogic/syllogism.rb', line 114

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

#labelObject



158
159
160
# File 'lib/catlogic/syllogism.rb', line 158

def label
  return "#{@major.label}\n#{@minor.label}\n#{@conclusion.label}"
end

#majortermObject

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



48
49
50
51
52
53
54
55
# File 'lib/catlogic/syllogism.rb', line 48

def majorterm
  if @major.subject.label == self.middle.label
    majorterm = @major.predicate
  else
    majorterm = @major.subject
  end
  majorterm
end

#middleObject

This method gets the middle term by looking for the term in the major and minor terms that are used twice.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/catlogic/syllogism.rb', line 19

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

#minortermObject



56
57
58
59
60
61
62
63
# File 'lib/catlogic/syllogism.rb', line 56

def minorterm
  if @minor.subject.label == self.middle.label
    minorterm = @minor.predicate
  else
    minorterm = @minor.subject
  end
  minorterm
end

#moodObject

returns the Mood object of Syllogism (e.g. AAA, EEE)



67
68
69
70
# File 'lib/catlogic/syllogism.rb', line 67

def mood
  mood = Mood.new(@major.type, @minor.type, @conclusion.type)
  return mood
end

#neg_from_affirms_testObject



139
140
141
142
143
144
145
146
147
# File 'lib/catlogic/syllogism.rb', line 139

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

Returns:

  • (Boolean)


34
35
36
37
38
39
40
41
# File 'lib/catlogic/syllogism.rb', line 34

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_testObject



96
97
98
99
100
101
102
103
104
# File 'lib/catlogic/syllogism.rb', line 96

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

#validityObject



150
151
152
153
154
155
156
# File 'lib/catlogic/syllogism.rb', line 150

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