catlogic 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/catlogic/distribution.rb +14 -12
- data/lib/catlogic/figure.rb +37 -34
- data/lib/catlogic/form.rb +94 -93
- data/lib/catlogic/integer.rb +5 -0
- data/lib/catlogic/mood.rb +24 -12
- data/lib/catlogic/premise_collection.rb +92 -29
- data/lib/catlogic/premise_pair.rb +52 -50
- data/lib/catlogic/proposition.rb +145 -143
- data/lib/catlogic/proposition_type.rb +44 -40
- data/lib/catlogic/quality.rb +17 -11
- data/lib/catlogic/quantity.rb +16 -11
- data/lib/catlogic/string.rb +20 -0
- data/lib/catlogic/syllogism.rb +129 -133
- data/lib/catlogic/term.rb +29 -25
- data/lib/catlogic/version.rb +1 -1
- data/lib/catlogic.rb +3 -3
- data/scripts/displayInferredTruths.rb +59 -237
- data/scripts/getAllValidPropositions.rb +2 -2
- data/scripts/testCombineSets.rb +16 -16
- data/scripts/testIfUnique.rb +4 -4
- data/scripts/testPremisePair.rb +3 -3
- data/scripts/testProposition.rb +1 -1
- data/scripts/testPropositionType.rb +1 -1
- data/scripts/testQuantity.rb +1 -1
- data/scripts/testReduceToUniqueSet.rb +6 -6
- data/scripts/testSyllogism.rb +5 -5
- data/scripts/testSyllogismForm.rb +3 -3
- data/spec/distribution_spec.rb +3 -3
- data/spec/figure_spec.rb +1 -1
- data/spec/form_spec.rb +3 -3
- data/spec/mood_spec.rb +1 -1
- data/spec/premise_collection_spec.rb +72 -13
- data/spec/premise_pair_spec.rb +14 -9
- data/spec/proposition_spec.rb +24 -24
- data/spec/proposition_type_spec.rb +4 -4
- data/spec/quality_spec.rb +2 -2
- data/spec/quantity_spec.rb +2 -2
- data/spec/syllogism_spec.rb +13 -13
- data/spec/term_spec.rb +6 -6
- metadata +4 -2
@@ -3,12 +3,22 @@ require 'catlogic'
|
|
3
3
|
|
4
4
|
describe "premise collection object" do
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
$collection2 = Catlogic::PremiseCollection.new([Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Mammals"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mortal Things"), true),
|
8
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("People"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mammals"), true)])
|
8
9
|
|
9
|
-
$collection3 = PremiseCollection.new([Proposition.new(Quantity.new("universal"), Term.new("Mammals"), Quality.new("affirmative"), Term.new("Mortal Things"), true),
|
10
|
-
Proposition.new(Quantity.new("universal"), Term.new("People"), Quality.new("affirmative"), Term.new("Mammals"), true),
|
11
|
-
Proposition.new(Quantity.new("universal"), Term.new("Ants"), Quality.new("
|
10
|
+
$collection3 = Catlogic::PremiseCollection.new([Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Mammals"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mortal Things"), true),
|
11
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("People"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mammals"), true),
|
12
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Ants"), Catlogic::Quality.new("negative"), Catlogic::Term.new("People"), true)])
|
13
|
+
|
14
|
+
$collection3repeat = Catlogic::PremiseCollection.new([Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Mammals"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mortal Things"), true),
|
15
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("People"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mammals"), true),
|
16
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("People"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mammals"), true)])
|
17
|
+
|
18
|
+
$collection4 = Catlogic::PremiseCollection.new([Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Dogs"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mortal Things"), true),
|
19
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("People"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mammals"), true),
|
20
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Ants"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Cats"), true),
|
21
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Zebras"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Whales"), true)])
|
12
22
|
|
13
23
|
it "should confirm that there are two or more premises in the collection" do
|
14
24
|
result = $collection2.at_least_two?
|
@@ -20,22 +30,71 @@ describe "premise collection object" do
|
|
20
30
|
result.should == 3
|
21
31
|
end
|
22
32
|
|
23
|
-
it 'should reduce
|
24
|
-
result = $
|
33
|
+
it 'should reduce collection3repeat to unique propositions only and return count of 2' do
|
34
|
+
result = $collection3repeat.unique_set
|
35
|
+
result.count.should == 2
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should be able to provide actual size of initual set even with a repeat premise' do
|
39
|
+
result = $collection3repeat.initial_propositions
|
25
40
|
result.count.should == 3
|
26
41
|
end
|
42
|
+
it 'should be able to provide actual size of unique set when set with a repeat premise is given' do
|
43
|
+
result = $collection3repeat.unique_propositions
|
44
|
+
result.count.should == 2
|
45
|
+
end
|
27
46
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
Proposition.new(Quantity.new("universal"), Term.new("
|
47
|
+
## testing unique set method
|
48
|
+
it 'should reduce non-unique collection to a new collection with unique propositions only and should have a count of 2' do
|
49
|
+
collection = Catlogic::PremiseCollection.new([Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Mammals"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mortal Things"), true),
|
50
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Mammals"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mortal Things"), true),
|
51
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Ants"), Catlogic::Quality.new("Negative"), Catlogic::Term.new("Mammals"), true)])
|
32
52
|
result = collection.unique_set
|
33
|
-
result.
|
53
|
+
result.size.should == 2
|
34
54
|
|
35
55
|
end
|
36
|
-
|
56
|
+
## Testing factorial on collections2-4; answers calculated based on permutations formula P(n,r) = n! / (n - r)! where n=total set and r=lenght of the subset.
|
57
|
+
## aka "The number of ways of obtaining an ordered subset of r elements from a set of n elements."
|
37
58
|
it 'should return a premise pair collection for two propositions whose set count is 2' do
|
38
59
|
result = $collection2.premise_pairs
|
39
60
|
result.count.should == 2
|
40
61
|
end
|
62
|
+
|
63
|
+
it 'should return a premise pair collection for three propositions whose set count is 3' do
|
64
|
+
result = $collection3.premise_pairs
|
65
|
+
result.count.should == 6
|
66
|
+
end
|
67
|
+
it 'should return a premise pair collection for three propositions whose set count is 4' do
|
68
|
+
result = $collection4.premise_pairs
|
69
|
+
result.count.should == 12
|
70
|
+
end
|
71
|
+
|
72
|
+
##Testing possible three-term pairs on collections 2-4
|
73
|
+
it 'should return answer of 2 for total number of three term paris in $collection2' do
|
74
|
+
result = $collection2.three_term_premise_pairs
|
75
|
+
result.count.should == 2
|
76
|
+
end
|
77
|
+
it 'should return answer of 4 for total number of three term paris in $collection3' do
|
78
|
+
result = $collection3.three_term_premise_pairs
|
79
|
+
result.count.should == 4
|
80
|
+
end
|
81
|
+
it 'should return answer of 0 for total number of three term paris in $collection4' do
|
82
|
+
result = $collection4.three_term_premise_pairs
|
83
|
+
result.count.should == 0
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should return valid syllogisms for two premise AA (1) premise pair in $collection 2 (should return an AAA1, AAI1 and an AAI4' do
|
87
|
+
result = $collection2.valid_syllogisms
|
88
|
+
result.count.should == 3
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should return all valid inferred truths for AA (1) premise pair -- the conclusions for an AAA1, AAI1 and AAI4 syllogisms' do
|
92
|
+
result = $collection2.inferred_truths_all
|
93
|
+
result.count.should == 3
|
94
|
+
end
|
95
|
+
## this test isn't very good since collection2 does not generate any repeat inferred truths.
|
96
|
+
it 'should return unique valid inferred truths for AA (1) premise pair' do
|
97
|
+
result = $collection2.inferred_truths_new
|
98
|
+
result.count.should == 3
|
99
|
+
end
|
41
100
|
end
|
data/spec/premise_pair_spec.rb
CHANGED
@@ -3,9 +3,9 @@ require 'catlogic'
|
|
3
3
|
|
4
4
|
describe "premise pair object" do
|
5
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)
|
6
|
+
$major = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Mammals"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Dogs"), true)
|
7
|
+
$minor = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Mammals"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mortal Things"), true)
|
8
|
+
$pair = Catlogic::PremisePair.new($major, $minor)
|
9
9
|
|
10
10
|
it 'can return the major proposition' do
|
11
11
|
result = $pair.major
|
@@ -23,18 +23,18 @@ describe "premise pair object" do
|
|
23
23
|
end
|
24
24
|
|
25
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)
|
26
|
+
major = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Mammals"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Dogs"), true)
|
27
|
+
minor = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Dogs"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mammals"), true)
|
28
|
+
pair = Catlogic::PremisePair.new(major, minor)
|
29
29
|
|
30
30
|
result = pair.three_term_pair?
|
31
31
|
result.should == false
|
32
32
|
end
|
33
33
|
|
34
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)
|
35
|
+
major = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Mammals"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Dogs"), true)
|
36
|
+
minor = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Cats"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Wicked"), true)
|
37
|
+
pair = Catlogic::PremisePair.new(major, minor)
|
38
38
|
|
39
39
|
result = pair.three_term_pair?
|
40
40
|
result.should == false
|
@@ -45,6 +45,11 @@ describe "premise pair object" do
|
|
45
45
|
result.label.should == "Mammals"
|
46
46
|
end
|
47
47
|
|
48
|
+
it 'can retrieve possible conclusions for a premise pair' do
|
49
|
+
result = $pair.possible_conclusions
|
50
|
+
result.count.should == 4
|
51
|
+
end
|
52
|
+
|
48
53
|
|
49
54
|
|
50
55
|
|
data/spec/proposition_spec.rb
CHANGED
@@ -2,9 +2,9 @@ require 'spec_helper'
|
|
2
2
|
require 'catlogic'
|
3
3
|
|
4
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)
|
5
|
+
$propositionAtrue = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new('dogs'), Catlogic::Quality.new("affirmative"), Catlogic::Term.new('mortal things'), true)
|
6
|
+
$propositionIfalse = Catlogic::Proposition.new(Catlogic::Quantity.new("particular"), Catlogic::Term.new('dogs'), Catlogic::Quality.new("affirmative"), Catlogic::Term.new('mortal things'), false)
|
7
|
+
$propositionItrue = Catlogic::Proposition.new(Catlogic::Quantity.new("particular"), Catlogic::Term.new('dogs'), Catlogic::Quality.new("affirmative"), Catlogic::Term.new('mortal things'), true)
|
8
8
|
it 'can return the quantity' do
|
9
9
|
result = $propositionAtrue.quantity
|
10
10
|
result.label.should == 'universal'
|
@@ -136,7 +136,7 @@ describe 'proposition object' do
|
|
136
136
|
truthvalue.should == true
|
137
137
|
end
|
138
138
|
it 'can return the correct position of a designated middle term -- in this case dogs' do
|
139
|
-
middleterm = Term.new('dogs')
|
139
|
+
middleterm = Catlogic::Term.new('dogs')
|
140
140
|
position = $propositionAtrue.position_of_term(middleterm)
|
141
141
|
position.should == 'subject'
|
142
142
|
end
|
@@ -161,12 +161,12 @@ describe 'proposition object' do
|
|
161
161
|
|
162
162
|
it 'can identify that a given proposition is repeated one time in given array' do
|
163
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)
|
164
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Events"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Caused Happenings"), true),
|
165
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Caused Happenings"), true),
|
166
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Fun"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Events"), true)
|
167
167
|
]
|
168
168
|
|
169
|
-
proposition = Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true)
|
169
|
+
proposition = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Caused Happenings"), true)
|
170
170
|
|
171
171
|
result = proposition.number_of_occurences(premisesArray)
|
172
172
|
result.should == 1
|
@@ -174,12 +174,12 @@ describe 'proposition object' do
|
|
174
174
|
|
175
175
|
it 'can identify that a given proposition is repeated zero times in given array' do
|
176
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)
|
177
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Events"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Caused Happenings"), true),
|
178
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Caused Happenings"), true),
|
179
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Fun"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Events"), true)
|
180
180
|
]
|
181
181
|
|
182
|
-
proposition = Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("affirmative"), Term.new("Caused Happenings"), true)
|
182
|
+
proposition = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Caused Happenings"), true)
|
183
183
|
|
184
184
|
result = proposition.number_of_occurences(premisesArray)
|
185
185
|
result.should == 0
|
@@ -187,12 +187,12 @@ describe 'proposition object' do
|
|
187
187
|
it 'can return answer true when proposition is unique (not included) in a given set' do
|
188
188
|
|
189
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)
|
190
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Events"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Caused Happenings"), true),
|
191
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Caused Happenings"), true),
|
192
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Fun"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Events"), true)
|
193
193
|
]
|
194
194
|
|
195
|
-
proposition = Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("affirmative"), Term.new("Caused Happenings"), true)
|
195
|
+
proposition = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Caused Happenings"), true)
|
196
196
|
|
197
197
|
result = proposition.unique?(premisesArray)
|
198
198
|
|
@@ -201,12 +201,12 @@ describe 'proposition object' do
|
|
201
201
|
it 'can return answer false when proposition is not unique (i.e. is included) in a given set' do
|
202
202
|
|
203
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)
|
204
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Events"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Caused Happenings"), true),
|
205
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Caused Happenings"), true),
|
206
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Fun"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Events"), true)
|
207
207
|
]
|
208
208
|
|
209
|
-
proposition = Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true)
|
209
|
+
proposition = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Caused Happenings"), true)
|
210
210
|
|
211
211
|
result = proposition.unique?(premisesArray)
|
212
212
|
|
@@ -214,14 +214,14 @@ describe 'proposition object' do
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'can return answer false for two propositions that are not identical' do
|
217
|
-
prop1 = Proposition.new(Quantity.new("universal"), Term.new("Events"), Quality.new("affirmative"), Term.new("Caused Happenings"), true)
|
218
|
-
prop2 = Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true)
|
217
|
+
prop1 = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Events"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Caused Happenings"), true)
|
218
|
+
prop2 = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Caused Happenings"), true)
|
219
219
|
result = prop1.same_as?(prop2)
|
220
220
|
result.should == false
|
221
221
|
end
|
222
222
|
it 'can return answer true for two propositions that are identical' do
|
223
|
-
prop1 = Proposition.new(Quantity.new("universal"), Term.new("Events"), Quality.new("affirmative"), Term.new("Caused Happenings"), true)
|
224
|
-
prop2 = Proposition.new(Quantity.new("universal"), Term.new("Events"), Quality.new("affirmative"), Term.new("Caused Happenings"), true)
|
223
|
+
prop1 = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Events"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Caused Happenings"), true)
|
224
|
+
prop2 = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Events"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Caused Happenings"), true)
|
225
225
|
result = prop1.same_as?(prop2)
|
226
226
|
result.should == true
|
227
227
|
end
|
@@ -2,10 +2,10 @@ require 'spec_helper'
|
|
2
2
|
require 'catlogic'
|
3
3
|
|
4
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")
|
5
|
+
$typeA = Catlogic::PropositionType.new("A")
|
6
|
+
$typeE = Catlogic::PropositionType.new("E")
|
7
|
+
$typeI = Catlogic::PropositionType.new("I")
|
8
|
+
$typeO = Catlogic::PropositionType.new("O")
|
9
9
|
|
10
10
|
it 'can return the correct label for a proposition type A' do
|
11
11
|
result = $typeA.label
|
data/spec/quality_spec.rb
CHANGED
@@ -3,13 +3,13 @@ require 'catlogic'
|
|
3
3
|
|
4
4
|
describe 'quality object' do
|
5
5
|
it 'can return quality as string' do
|
6
|
-
quality = Quality.new('affirmative')
|
6
|
+
quality = Catlogic::Quality.new('affirmative')
|
7
7
|
result = quality.label
|
8
8
|
result.should == 'affirmative'
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'can return term opposite as string' do
|
12
|
-
quality = Quality.new('affirmative')
|
12
|
+
quality = Catlogic::Quality.new('affirmative')
|
13
13
|
opposite = quality.opposite
|
14
14
|
result = opposite.label
|
15
15
|
result.should == 'negative'
|
data/spec/quantity_spec.rb
CHANGED
@@ -4,13 +4,13 @@ require 'pry'
|
|
4
4
|
|
5
5
|
describe 'quantity object' do
|
6
6
|
it 'can return quantity as string' do
|
7
|
-
quantity = Quantity.new('universal')
|
7
|
+
quantity = Catlogic::Quantity.new('universal')
|
8
8
|
result = quantity.label
|
9
9
|
result.should == 'universal'
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'can return term opposite as string' do
|
13
|
-
quantity = Quantity.new('particular')
|
13
|
+
quantity = Catlogic::Quantity.new('particular')
|
14
14
|
opposite = quantity.opposite
|
15
15
|
result = opposite.label
|
16
16
|
|
data/spec/syllogism_spec.rb
CHANGED
@@ -3,16 +3,16 @@ require "catlogic"
|
|
3
3
|
|
4
4
|
describe "syllogism object" do
|
5
5
|
|
6
|
-
$majorproposition = Proposition.new(Quantity.new('universal'), Term.new('mortal things'), Quality.new('affirmative'), Term.new('dogs'), true)
|
7
|
-
$minorproposition = Proposition.new(Quantity.new('universal'), Term.new('living things'), Quality.new('affirmative'), Term.new('mortal things'), true)
|
8
|
-
$conclusionproposition = Proposition.new(Quantity.new('universal'), Term.new('living things'), Quality.new('affirmative'), Term.new('dogs'), true)
|
9
|
-
$syllogism_aaa1 = Syllogism.new($majorproposition, $minorproposition, $conclusionproposition)
|
10
|
-
$syllogism_aaa4 = Syllogism.new($minorproposition, $majorproposition, $conclusionproposition)
|
6
|
+
$majorproposition = Catlogic::Proposition.new(Catlogic::Quantity.new('universal'), Catlogic::Term.new('mortal things'), Catlogic::Quality.new('affirmative'), Catlogic::Term.new('dogs'), true)
|
7
|
+
$minorproposition = Catlogic::Proposition.new(Catlogic::Quantity.new('universal'), Catlogic::Term.new('living things'), Catlogic::Quality.new('affirmative'), Catlogic::Term.new('mortal things'), true)
|
8
|
+
$conclusionproposition = Catlogic::Proposition.new(Catlogic::Quantity.new('universal'), Catlogic::Term.new('living things'), Catlogic::Quality.new('affirmative'), Catlogic::Term.new('dogs'), true)
|
9
|
+
$syllogism_aaa1 = Catlogic::Syllogism.new($majorproposition, $minorproposition, $conclusionproposition)
|
10
|
+
$syllogism_aaa4 = Catlogic::Syllogism.new($minorproposition, $majorproposition, $conclusionproposition)
|
11
11
|
|
12
|
-
$majorproposition2 = Proposition.new(Quantity.new('universal'), Term.new('dogs'), Quality.new('affirmative'), Term.new('mortal things'), true)
|
13
|
-
$minorproposition2 = Proposition.new(Quantity.new('universal'), Term.new('living things'), Quality.new('affirmative'), Term.new('mortal things'), true)
|
14
|
-
$conclusionproposition2 = Proposition.new(Quantity.new('universal'), Term.new('living things'), Quality.new('affirmative'), Term.new('dogs'), true)
|
15
|
-
$syllogism_aaa2 = Syllogism.new($majorproposition2, $minorproposition2, $conclusionproposition2)
|
12
|
+
$majorproposition2 = Catlogic::Proposition.new(Catlogic::Quantity.new('universal'), Catlogic::Term.new('dogs'), Catlogic::Quality.new('affirmative'), Catlogic::Term.new('mortal things'), true)
|
13
|
+
$minorproposition2 = Catlogic::Proposition.new(Catlogic::Quantity.new('universal'), Catlogic::Term.new('living things'), Catlogic::Quality.new('affirmative'), Catlogic::Term.new('mortal things'), true)
|
14
|
+
$conclusionproposition2 = Catlogic::Proposition.new(Catlogic::Quantity.new('universal'), Catlogic::Term.new('living things'), Catlogic::Quality.new('affirmative'), Catlogic::Term.new('dogs'), true)
|
15
|
+
$syllogism_aaa2 = Catlogic::Syllogism.new($majorproposition2, $minorproposition2, $conclusionproposition2)
|
16
16
|
|
17
17
|
it 'can retrieve the middle term' do
|
18
18
|
|
@@ -21,10 +21,10 @@ describe "syllogism object" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'can return error if not trying to get middle on non three-term syllogism' do
|
24
|
-
majorproposition = Proposition.new(Quantity.new('universal'), Term.new('mortal things'), Quality.new('affirmative'), Term.new('living things'), true)
|
25
|
-
minorproposition = Proposition.new(Quantity.new('universal'), Term.new('living things'), Quality.new('affirmative'), Term.new('mortal things'), true)
|
26
|
-
conclusionproposition = Proposition.new(Quantity.new('universal'), Term.new('living things'), Quality.new('affirmative'), Term.new('dogs'), true)
|
27
|
-
syllogism_test = Syllogism.new(majorproposition, minorproposition, conclusionproposition)
|
24
|
+
majorproposition = Catlogic::Proposition.new(Catlogic::Quantity.new('universal'), Catlogic::Term.new('mortal things'), Catlogic::Quality.new('affirmative'), Catlogic::Term.new('living things'), true)
|
25
|
+
minorproposition = Catlogic::Proposition.new(Catlogic::Quantity.new('universal'), Catlogic::Term.new('living things'), Catlogic::Quality.new('affirmative'), Catlogic::Term.new('mortal things'), true)
|
26
|
+
conclusionproposition = Catlogic::Proposition.new(Catlogic::Quantity.new('universal'), Catlogic::Term.new('living things'), Catlogic::Quality.new('affirmative'), Catlogic::Term.new('dogs'), true)
|
27
|
+
syllogism_test = Catlogic::Syllogism.new(majorproposition, minorproposition, conclusionproposition)
|
28
28
|
|
29
29
|
middleterm = syllogism_test.middle
|
30
30
|
middleterm.should == 'Error: this is not a three term syllogism'
|
data/spec/term_spec.rb
CHANGED
@@ -4,28 +4,28 @@ require 'pry'
|
|
4
4
|
|
5
5
|
describe 'term object' do
|
6
6
|
it 'can return term as string' do
|
7
|
-
term = Term.new('dogs')
|
7
|
+
term = Catlogic::Term.new('dogs')
|
8
8
|
result = term.label
|
9
9
|
result.should == 'dogs'
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'can return term opposite as string' do
|
13
|
-
term = Term.new('dogs')
|
13
|
+
term = Catlogic::Term.new('dogs')
|
14
14
|
opposite = term.opposite
|
15
15
|
result = opposite.label
|
16
16
|
result.should == 'non-dogs'
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'can return correct distribution for subject term' do
|
20
|
-
term = Term.new('dogs')
|
21
|
-
quantity = Quantity.new('universal')
|
20
|
+
term = Catlogic::Term.new('dogs')
|
21
|
+
quantity = Catlogic::Quantity.new('universal')
|
22
22
|
result = term.distribution_subject(quantity)
|
23
23
|
result.label.should == 'distributed'
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'can return correct distribution for predicate term' do
|
27
|
-
term = Term.new('dogs')
|
28
|
-
quality = Quality.new('affirmative')
|
27
|
+
term = Catlogic::Term.new('dogs')
|
28
|
+
quality = Catlogic::Quality.new('affirmative')
|
29
29
|
result = term.distribution_predicate(quality)
|
30
30
|
result.label.should == 'undistributed'
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: catlogic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey C. Witt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/catlogic/distribution.rb
|
87
87
|
- lib/catlogic/figure.rb
|
88
88
|
- lib/catlogic/form.rb
|
89
|
+
- lib/catlogic/integer.rb
|
89
90
|
- lib/catlogic/mood.rb
|
90
91
|
- lib/catlogic/premise_collection.rb
|
91
92
|
- lib/catlogic/premise_pair.rb
|
@@ -93,6 +94,7 @@ files:
|
|
93
94
|
- lib/catlogic/proposition_type.rb
|
94
95
|
- lib/catlogic/quality.rb
|
95
96
|
- lib/catlogic/quantity.rb
|
97
|
+
- lib/catlogic/string.rb
|
96
98
|
- lib/catlogic/syllogism.rb
|
97
99
|
- lib/catlogic/term.rb
|
98
100
|
- lib/catlogic/version.rb
|