catlogic 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +36 -0
  9. data/Rakefile +7 -0
  10. data/bin2/.idea/.name +1 -0
  11. data/bin2/.idea/bin.iml +9 -0
  12. data/bin2/.idea/encodings.xml +5 -0
  13. data/bin2/.idea/misc.xml +5 -0
  14. data/bin2/.idea/modules.xml +9 -0
  15. data/bin2/.idea/scopes/scope_settings.xml +5 -0
  16. data/bin2/.idea/vcs.xml +7 -0
  17. data/bin2/.idea/workspace.xml +129 -0
  18. data/bin2/displayInferredTruths.rb +43 -0
  19. data/bin2/getAllValidPropositions.rb +24 -0
  20. data/bin2/testCombineSets.rb +27 -0
  21. data/bin2/testIfUnique.rb +14 -0
  22. data/bin2/testPremisePair.rb +10 -0
  23. data/bin2/testProposition.rb +47 -0
  24. data/bin2/testPropositionType.rb +40 -0
  25. data/bin2/testQuantity.rb +12 -0
  26. data/bin2/testReduceToUniqueSet.rb +18 -0
  27. data/bin2/testSyllogism.rb +45 -0
  28. data/bin2/testSyllogismForm.rb +51 -0
  29. data/catlogic.gemspec +25 -0
  30. data/lib/catlogic/distribution.rb +16 -0
  31. data/lib/catlogic/figure.rb +45 -0
  32. data/lib/catlogic/form.rb +22 -0
  33. data/lib/catlogic/mood.rb +14 -0
  34. data/lib/catlogic/premise_collection.rb +211 -0
  35. data/lib/catlogic/premise_pair.rb +61 -0
  36. data/lib/catlogic/proposition.rb +181 -0
  37. data/lib/catlogic/proposition_type.rb +47 -0
  38. data/lib/catlogic/quality.rb +16 -0
  39. data/lib/catlogic/quantity.rb +16 -0
  40. data/lib/catlogic/syllogism.rb +171 -0
  41. data/lib/catlogic/term.rb +32 -0
  42. data/lib/catlogic/version.rb +3 -0
  43. data/lib/catlogic.rb +17 -0
  44. data/spec/distribution_spec.rb +26 -0
  45. data/spec/figure_spec.rb +27 -0
  46. data/spec/form_spec.rb +22 -0
  47. data/spec/mood_spec.rb +17 -0
  48. data/spec/premise_pair_spec.rb +51 -0
  49. data/spec/proposition_spec.rb +215 -0
  50. data/spec/proposition_type_spec.rb +37 -0
  51. data/spec/quality_spec.rb +17 -0
  52. data/spec/quantity_spec.rb +19 -0
  53. data/spec/spec_helper.rb +89 -0
  54. data/spec/syllogism_spec.rb +121 -0
  55. data/spec/term_spec.rb +35 -0
  56. metadata +166 -0
@@ -0,0 +1,171 @@
1
+ # Class for any syllogism object.
2
+ class Syllogism
3
+ attr_reader :major, :minor, :conclusion
4
+
5
+ # Syllogism object initiation takes three Proposition objects
6
+
7
+ def initialize(major, minor, conclusion=nil)
8
+ @major = major
9
+ @minor = minor
10
+ if conclusion == nil
11
+ @conclusion = self.getComputedConclusion
12
+ else
13
+ @conclusion = conclusion
14
+ end
15
+ end
16
+
17
+ # This method gets the middle term by looking for the term in the major and minor terms that are used twice.
18
+ def middle
19
+ termarray = [@major.subject.label, @major.predicate.label, @minor.subject.label, @minor.predicate.label]
20
+ middle = nil
21
+ if self.three_term?
22
+ termarray.detect do |term|
23
+ if termarray.count(term) == 2
24
+ middle = Term.new(term)
25
+ end
26
+ end
27
+ else
28
+ middle = "Error: this is not a three term syllogism"
29
+ end
30
+ middle
31
+ end
32
+
33
+ def three_term?
34
+ termarray = [@major.subject.label, @major.predicate.label, @minor.subject.label, @minor.predicate.label]
35
+ if termarray.uniq.size == 3
36
+ answer = true
37
+ else
38
+ answer = false
39
+ end
40
+ end
41
+
42
+
43
+
44
+ # gets the major term as a String from the major premise by identifying the middle term
45
+ # and then identifying the term in the premise that is not the middle
46
+
47
+ def majorterm
48
+ if @major.subject.label == self.middle.label
49
+ majorterm = @major.predicate
50
+ else
51
+ majorterm = @major.subject
52
+ end
53
+ majorterm
54
+ end
55
+ def minorterm
56
+ if @minor.subject.label == self.middle.label
57
+ minorterm = @minor.predicate
58
+ else
59
+ minorterm = @minor.subject
60
+ end
61
+ minorterm
62
+ end
63
+
64
+ # returns the Mood object of Syllogism (e.g. AAA, EEE)
65
+
66
+ def mood
67
+ mood = Mood.new(@major.type, @minor.type, @conclusion.type)
68
+ return mood
69
+ end
70
+
71
+ # gets the Figure of Syllogism (e.g. 1, 2, 3, 4)
72
+
73
+ def figure
74
+ mjmp = @major.position_of_term(self.middle)
75
+ mnmp = @minor.position_of_term(self.middle)
76
+
77
+ if mjmp == 'subject' && mnmp == 'predicate'
78
+ figure = Figure.new(1)
79
+ elsif mjmp == 'predicate' && mnmp == 'predicate'
80
+ figure = Figure.new(2)
81
+ elsif mjmp == 'subject' && mnmp == 'subject'
82
+ figure = Figure.new(3)
83
+ elsif mjmp == 'predicate' && mnmp == 'subject'
84
+ figure = Figure.new(4)
85
+ end
86
+ return figure
87
+ end
88
+
89
+ # Retrieve Form object of the Syllogism (i.e. AAAI, EAI4)
90
+ def form
91
+ form = Form.new(self.mood, self.figure)
92
+ return form
93
+ end
94
+
95
+ def undistributed_middle_test
96
+ ## Rule Number 1 - middle distributed
97
+ if @major.distribution(@major.position_of_term(self.middle)).label == 'undistributed' && @minor.distribution(@minor.position_of_term(self.middle)).label == 'undistributed'
98
+ validity = false
99
+ else
100
+ validity = true
101
+ end
102
+ return validity
103
+ end
104
+
105
+ def illicit_major_test
106
+ ##Rule Number 2a distribution of major term
107
+ if @conclusion.distribution('predicate').label == 'distributed' && @major.distribution(@major.position_of_term(self.majorterm)).label != 'distributed'
108
+ validity = false
109
+ else
110
+ validity = true
111
+ end
112
+ end
113
+ def illicit_minor_test
114
+ ##Rule Number 2b distribution of minor term - check fallacy of illicit minor
115
+ if @conclusion.distribution('subject').label == 'distributed' && @minor.distribution(@minor.position_of_term(self.minorterm)).label != 'distributed'
116
+ validity = false
117
+ else
118
+ validty = true
119
+ end
120
+ end
121
+ # exclusive premises
122
+ def exclusive_premises_test
123
+ if @major.quality.label == 'negative' && @minor.quality.label == 'negative'
124
+ validity = false
125
+ else
126
+ validity = true
127
+ end
128
+ end
129
+
130
+ def affirm_from_neg_test
131
+ if (@major.quality.label == 'negative' || @minor.quality.label == 'negative') && @conclusion.quality.label != 'negative'
132
+ validity = false
133
+ else
134
+ validity = true
135
+ end
136
+ end
137
+
138
+ def neg_from_affirms_test
139
+ if (@conclusion.quality.label == 'negative' && (@major.quality.label != 'negative' && @minor.quality.label != 'negative'))
140
+
141
+ validity = false
142
+ #validity = "pass"
143
+ else
144
+ validity = true
145
+ end
146
+ end
147
+
148
+
149
+ def validity
150
+ 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)
151
+ validity = false
152
+ else
153
+ validity = true
154
+ end
155
+ end
156
+
157
+ def label
158
+ return "#{@major.label}\n#{@minor.label}\n#{@conclusion.label}"
159
+ end
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+ def displayPropositionalForm
168
+ form = Form.new(self.mood, self.figure)
169
+ form.displayPropositionalForm
170
+ end
171
+ end
@@ -0,0 +1,32 @@
1
+ class Term
2
+ attr_reader :label
3
+
4
+ def initialize(termname)
5
+ @label = termname
6
+ end
7
+
8
+ def opposite
9
+ opposite = Term.new("non-#{@label}")
10
+ return opposite
11
+ end
12
+
13
+ def distribution_subject(quantity)
14
+ if quantity.label == 'universal'
15
+ @distribution = Distribution.new('distributed')
16
+ elsif quantity.label == 'particular'
17
+ @distribution = Distribution.new('undistributed')
18
+ end
19
+ return @distribution
20
+
21
+ end
22
+
23
+ def distribution_predicate(quality)
24
+ if quality.label == 'affirmative'
25
+ @distribution = Distribution.new('undistributed')
26
+ elsif quality.label == 'negative'
27
+ @distribution = Distribution.new('distributed')
28
+ end
29
+ return @distribution
30
+ end
31
+
32
+ end
@@ -0,0 +1,3 @@
1
+ module Catlogic
2
+ VERSION = "0.0.1"
3
+ end
data/lib/catlogic.rb ADDED
@@ -0,0 +1,17 @@
1
+ require "catlogic/version"
2
+
3
+ #module Catlogic
4
+ # Your code goes here...
5
+ require "catlogic/distribution"
6
+ require "catlogic/quality"
7
+ require "catlogic/quantity"
8
+ require "catlogic/term"
9
+ require "catlogic/proposition"
10
+ require "catlogic/proposition_type"
11
+ require "catlogic/syllogism"
12
+ require "catlogic/figure"
13
+ require "catlogic/mood"
14
+ require "catlogic/form"
15
+ require "catlogic/premise_pair"
16
+ require "catlogic/premise_collection"
17
+ #end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'catlogic'
3
+ require 'pry'
4
+
5
+ describe 'distribution object' do
6
+ it 'can return distribution label as string' do
7
+ term = Distribution.new('distributed')
8
+ result = term.label
9
+ result.should == 'distributed'
10
+ end
11
+
12
+ it 'can return distribution opposite label as string' do
13
+ term = Distribution.new('distributed')
14
+ opposite = term.opposite
15
+ result = opposite.label
16
+ result.should == 'undistributed'
17
+ end
18
+
19
+ it 'can return undistributed opposite label as string' do
20
+ term = Distribution.new('undistributed')
21
+ opposite = term.opposite
22
+ result = opposite.label
23
+ result.should == 'distributed'
24
+ end
25
+
26
+ end
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+ require "catlogic"
3
+
4
+ describe "figure object" do
5
+ $figure_1 = Figure.new(1)
6
+
7
+ it "should return the label of the figure type object" do
8
+ label = $figure_1.label
9
+ label.should == 1
10
+ end
11
+ it "should return the major type subject term object" do
12
+ subject = $figure_1.major_subject
13
+ subject.label.should == "M"
14
+ end
15
+ it "should return the major type predicate term object" do
16
+ subject = $figure_1.major_predicate
17
+ subject.label.should == "P"
18
+ end
19
+ it "should return the minor type subject term object" do
20
+ subject = $figure_1.minor_subject
21
+ subject.label.should == "S"
22
+ end
23
+ it "should return the minor type predicate term object" do
24
+ subject = $figure_1.minor_predicate
25
+ subject.label.should == "M"
26
+ end
27
+ end
data/spec/form_spec.rb ADDED
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+ require "catlogic"
3
+
4
+ describe "form object" do
5
+ mood_aaa = Mood.new(PropositionType.new('A'), PropositionType.new('A'), PropositionType.new('A'))
6
+ figure_1 = Figure.new(1)
7
+ $form = Form.new(mood_aaa, figure_1)
8
+
9
+ it "should return form label" do
10
+ label = $form.label
11
+ label.should == "AAA1"
12
+ end
13
+
14
+ it "should return a syllogism object for the given form" do
15
+ syllogism = $form.syllogism
16
+ major = syllogism.major
17
+ minor = syllogism.minor
18
+ conclusion = syllogism.conclusion
19
+
20
+ major.label == "All M are P" && minor.label == "All S are M" && conclusion.label == "All S are P"
21
+ end
22
+ end
data/spec/mood_spec.rb ADDED
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+ require "catlogic"
3
+
4
+ describe "mood object" do
5
+
6
+ $moodobject_aaa = Mood.new(PropositionType.new('A'), PropositionType.new('A'), PropositionType.new('A'))
7
+
8
+ it 'can display the label of the mood object' do
9
+ mood = $moodobject_aaa.label
10
+ mood.should == 'AAA'
11
+ end
12
+
13
+ it 'can get the major type proposition' do
14
+ majortype = $moodobject_aaa.majortype
15
+ majortype.label.should === 'A'
16
+ end
17
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+ require 'catlogic'
3
+
4
+ describe "premise pair object" do
5
+
6
+ $major = Proposition.new(Quantity.new("universal"), Term.new("Mammals"), Quality.new("affirmative"), Term.new("Dogs"), true)
7
+ $minor = Proposition.new(Quantity.new("universal"), Term.new("Mammals"), Quality.new("affirmative"), Term.new("Mortal Things"), true)
8
+ $pair = PremisePair.new($major, $minor)
9
+
10
+ it 'can return the major proposition' do
11
+ result = $pair.major
12
+ result.should == $major
13
+ end
14
+
15
+ it 'can return the minor proposition' do
16
+ result = $pair.minor
17
+ result.should == $minor
18
+ end
19
+
20
+ it 'can provide true result when this pair has three and only three distinct terms' do
21
+ result = $pair.three_term_pair?
22
+ result.should == true
23
+ end
24
+
25
+ it 'can return false result when this pair has only two distinct terms' do
26
+ major = Proposition.new(Quantity.new("universal"), Term.new("Mammals"), Quality.new("affirmative"), Term.new("Dogs"), true)
27
+ minor = Proposition.new(Quantity.new("universal"), Term.new("Dogs"), Quality.new("affirmative"), Term.new("Mammals"), true)
28
+ pair = PremisePair.new(major, minor)
29
+
30
+ result = pair.three_term_pair?
31
+ result.should == false
32
+ end
33
+
34
+ it 'can return false result when this pair has only four distinct terms' do
35
+ major = Proposition.new(Quantity.new("universal"), Term.new("Mammals"), Quality.new("affirmative"), Term.new("Dogs"), true)
36
+ minor = Proposition.new(Quantity.new("universal"), Term.new("Cats"), Quality.new("affirmative"), Term.new("Wicked"), true)
37
+ pair = PremisePair.new(major, minor)
38
+
39
+ result = pair.three_term_pair?
40
+ result.should == false
41
+ end
42
+
43
+ it 'can return middle term of pair' do
44
+ result = $pair.middle
45
+ result.label.should == "Mammals"
46
+ end
47
+
48
+
49
+
50
+
51
+ end
@@ -0,0 +1,215 @@
1
+ require 'spec_helper'
2
+ require 'catlogic'
3
+
4
+ describe 'proposition object' do
5
+ $propositionAtrue = Proposition.new(Quantity.new("universal"), Term.new('dogs'), Quality.new("affirmative"), Term.new('mortal things'), true)
6
+ $propositionIfalse = Proposition.new(Quantity.new("particular"), Term.new('dogs'), Quality.new("affirmative"), Term.new('mortal things'), false)
7
+ $propositionItrue = Proposition.new(Quantity.new("particular"), Term.new('dogs'), Quality.new("affirmative"), Term.new('mortal things'), true)
8
+ it 'can return the quantity' do
9
+ result = $propositionAtrue.quantity
10
+ result.label.should == 'universal'
11
+ end
12
+ it 'can return the quality' do
13
+ result = $propositionAtrue.quality
14
+ result.label.should == 'affirmative'
15
+ end
16
+ it 'can return the subject' do
17
+ result = $propositionAtrue.subject
18
+ result.label.should == 'dogs'
19
+ end
20
+ it 'can return the predicate' do
21
+ result = $propositionAtrue.predicate
22
+ result.label.should == 'mortal things'
23
+ end
24
+ it 'can return the truth value' do
25
+ result = $propositionAtrue.truthvalue
26
+ result.should == true
27
+ end
28
+ it 'can return the type of proposition' do
29
+ type = $propositionAtrue.type
30
+ type.label.should == "A"
31
+ end
32
+ it 'can return the contradictory' do
33
+ quality = $propositionAtrue.contradictory.quality
34
+ quantity = $propositionAtrue.contradictory.quantity
35
+ # need a better test that can test the object rather than just string outputs
36
+ quality.label.should == "negative" && quantity.label.should == "particular"
37
+ end
38
+ it 'can return the correct subaltern of A proposition' do
39
+ # the sub altern of an A type proposition should be True I proposition
40
+ subaltern = $propositionAtrue.subaltern
41
+ quantity = subaltern.quantity
42
+ subject = subaltern.quality
43
+ quality = subaltern.quality
44
+ predicate = subaltern.quality
45
+ truthvalue = subaltern.truthvalue
46
+
47
+ quantity.label.should == "particular" &&
48
+ subject.label == "dogs" &&
49
+ quality.label.should == "affirmative" &&
50
+ predicate.label.should == "mortal things" &&
51
+ truthvalue.should == true
52
+ end
53
+ it 'can return the correct contra of a true A Proposition' do
54
+ contrary = $propositionAtrue.contrary
55
+ quantity = contrary.quantity
56
+ subject = contrary.quality
57
+ quality = contrary.quality
58
+ predicate = contrary.quality
59
+ truthvalue = contrary.truthvalue
60
+
61
+ quantity.label.should == "universal" &&
62
+ subject.label == "dogs" &&
63
+ quality.label.should == "negative" &&
64
+ predicate.label.should == "mortal things" &&
65
+ truthvalue.should == false
66
+ end
67
+ it 'can return the correct subcontrary response of a true I Proposition' do
68
+ subcontrary = $propositionIfalse.subcontrary
69
+ quantity = subcontrary.quantity
70
+ subject = subcontrary.quality
71
+ quality = subcontrary.quality
72
+ predicate = subcontrary.quality
73
+ truthvalue = subcontrary.truthvalue
74
+
75
+ quantity.label.should == "particular" &&
76
+ subject.label == "dogs" &&
77
+ quality.label.should == "negative" &&
78
+ predicate.label.should == "mortal things" &&
79
+ truthvalue.should == true
80
+ end
81
+ it 'can return the correct converse of an true I proposition' do
82
+ converse = $propositionItrue.converse
83
+ quantity = converse.quantity
84
+ subject = converse.quality
85
+ quality = converse.quality
86
+ predicate = converse.quality
87
+ truthvalue = converse.truthvalue
88
+
89
+ quantity.label.should == "particular" &&
90
+ subject.label == "mortal things" &&
91
+ quality.label.should == "negative" &&
92
+ predicate.label.should == "dogs" &&
93
+ truthvalue.should == true
94
+
95
+ end
96
+ it 'can return the obverse of an true A proposition' do
97
+ obverse = $propositionAtrue.converse
98
+ quantity = obverse.quantity
99
+ subject = obverse.quality
100
+ quality = obverse.quality
101
+ predicate = obverse.quality
102
+ truthvalue = obverse.truthvalue
103
+
104
+ quantity.label.should == "universal" &&
105
+ subject.label == "dogs" &&
106
+ quality.label.should == "negative" &&
107
+ predicate.label.should == "non-mortal things" &&
108
+ truthvalue.should == true
109
+ end
110
+ it 'can return the obverse of a true A proposition' do
111
+ obverse = $propositionAtrue.converse
112
+ quantity = obverse.quantity
113
+ subject = obverse.quality
114
+ quality = obverse.quality
115
+ predicate = obverse.quality
116
+ truthvalue = obverse.truthvalue
117
+
118
+ quantity.label.should == "universal" &&
119
+ subject.label == "dogs" &&
120
+ quality.label.should == "negative" &&
121
+ predicate.label.should == "non-mortal things" &&
122
+ truthvalue.should == true
123
+ end
124
+ it 'can return the correct contrapolated proposition of a true A proposition' do
125
+ contrapolated = $propositionAtrue.converse
126
+ quantity = contrapolated.quantity
127
+ subject = contrapolated.quality
128
+ quality = contrapolated.quality
129
+ predicate = contrapolated.quality
130
+ truthvalue = contrapolated.truthvalue
131
+
132
+ quantity.label.should == "universal" &&
133
+ subject.label == "non-mortal things" &&
134
+ quality.label.should == "affirmative" &&
135
+ predicate.label.should == "non-dogs" &&
136
+ truthvalue.should == true
137
+ end
138
+ it 'can return the correct position of a designated middle term -- in this case dogs' do
139
+ middleterm = Term.new('dogs')
140
+ position = $propositionAtrue.position_of_term(middleterm)
141
+ position.should == 'subject'
142
+ end
143
+ it 'can return a human readable version of an A proposition' do
144
+ label = $propositionAtrue.label
145
+ label.should == 'All dogs are mortal things'
146
+ end
147
+ it 'can return a human readable version of an I proposition' do
148
+ label = $propositionItrue.label
149
+ label.should == 'Some dogs are mortal things'
150
+ end
151
+
152
+ it 'can return distribution for a designated subject term position' do
153
+ distribution = $propositionAtrue.distribution('subject')
154
+ distribution.label.should == "distributed"
155
+ end
156
+
157
+ it 'can return distribution for a designated predicate term position' do
158
+ distribution = $propositionItrue.distribution('predicate')
159
+ distribution.label.should == "undistributed"
160
+ end
161
+
162
+ it 'can identify that a given proposition is repeated one time in given array' do
163
+ premisesArray = [
164
+ Proposition.new(Quantity.new("universal"), Term.new("Events"), Quality.new("affirmative"), Term.new("Caused Happenings"), true),
165
+ Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true),
166
+ Proposition.new(Quantity.new("universal"), Term.new("Fun"), Quality.new("affirmative"), Term.new("Events"), true)
167
+ ]
168
+
169
+ proposition = Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true)
170
+
171
+ result = proposition.number_of_occurences(premisesArray)
172
+ result.should == 1
173
+ end
174
+
175
+ it 'can identify that a given proposition is repeated zero times in given array' do
176
+ premisesArray = [
177
+ Proposition.new(Quantity.new("universal"), Term.new("Events"), Quality.new("affirmative"), Term.new("Caused Happenings"), true),
178
+ Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true),
179
+ Proposition.new(Quantity.new("universal"), Term.new("Fun"), Quality.new("affirmative"), Term.new("Events"), true)
180
+ ]
181
+
182
+ proposition = Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("affirmative"), Term.new("Caused Happenings"), true)
183
+
184
+ result = proposition.number_of_occurences(premisesArray)
185
+ result.should == 0
186
+ end
187
+ it 'can return answer true when proposition is unique (not included) in a given set' do
188
+
189
+ premisesArray = [
190
+ Proposition.new(Quantity.new("universal"), Term.new("Events"), Quality.new("affirmative"), Term.new("Caused Happenings"), true),
191
+ Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true),
192
+ Proposition.new(Quantity.new("universal"), Term.new("Fun"), Quality.new("affirmative"), Term.new("Events"), true)
193
+ ]
194
+
195
+ proposition = Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("affirmative"), Term.new("Caused Happenings"), true)
196
+
197
+ result = proposition.unique?(premisesArray)
198
+
199
+ result.should == true
200
+ end
201
+ it 'can return answer false when proposition is not unique (i.e. is included) in a given set' do
202
+
203
+ premisesArray = [
204
+ Proposition.new(Quantity.new("universal"), Term.new("Events"), Quality.new("affirmative"), Term.new("Caused Happenings"), true),
205
+ Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true),
206
+ Proposition.new(Quantity.new("universal"), Term.new("Fun"), Quality.new("affirmative"), Term.new("Events"), true)
207
+ ]
208
+
209
+ proposition = Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true)
210
+
211
+ result = proposition.unique?(premisesArray)
212
+
213
+ result.should == false
214
+ end
215
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'catlogic'
3
+
4
+ describe 'proposition_type object' do
5
+ $typeA = PropositionType.new("A")
6
+ $typeE = PropositionType.new("E")
7
+ $typeI = PropositionType.new("I")
8
+ $typeO = PropositionType.new("O")
9
+
10
+ it 'can return the correct label for a proposition type A' do
11
+ result = $typeA.label
12
+ result.should == "A"
13
+ end
14
+
15
+ it 'can return the correct label for a proposition type O' do
16
+ result = $typeO.label
17
+ result.should == "O"
18
+ end
19
+
20
+ it 'can return the correct quantity for proposition type E' do
21
+ result = $typeE.quantity.label
22
+ result.should == "universal"
23
+ end
24
+
25
+ it 'can return the correct proposition for proposition type I' do
26
+ proposition = $typeI.proposition
27
+
28
+ # prefer a test on the object construction but I don't know how to do that
29
+ quantity = proposition.quantity.label
30
+ subject = proposition.subject.label
31
+ quality = proposition.quality.label
32
+ predicate = proposition.predicate.label
33
+ quantity.should == "particular" && subject.should == "S" && quality.should == "affirmative" && predicate.should == "P"
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'catlogic'
3
+
4
+ describe 'quality object' do
5
+ it 'can return quality as string' do
6
+ quality = Quality.new('affirmative')
7
+ result = quality.label
8
+ result.should == 'affirmative'
9
+ end
10
+
11
+ it 'can return term opposite as string' do
12
+ quality = Quality.new('affirmative')
13
+ opposite = quality.opposite
14
+ result = opposite.label
15
+ result.should == 'negative'
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'catlogic'
3
+ require 'pry'
4
+
5
+ describe 'quantity object' do
6
+ it 'can return quantity as string' do
7
+ quantity = Quantity.new('universal')
8
+ result = quantity.label
9
+ result.should == 'universal'
10
+ end
11
+
12
+ it 'can return term opposite as string' do
13
+ quantity = Quantity.new('particular')
14
+ opposite = quantity.opposite
15
+ result = opposite.label
16
+
17
+ result.should == 'universal'
18
+ end
19
+ end