catlogic 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -7,253 +7,75 @@ rescue LoadError
|
|
7
7
|
require 'catlogic'
|
8
8
|
end
|
9
9
|
|
10
|
-
premises2 = [Proposition.new("universal", "Mammals", "affirmative", "Mortal Things", true),
|
11
|
-
Proposition.new("universal", "People", "affirmative", "Mammals", true)]
|
10
|
+
premises2 = [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
12
|
|
13
|
-
premises3 = [Proposition.new("universal", "Mammals", "affirmative", "Mortal Things", true),
|
14
|
-
Proposition.new("universal", "People", "affirmative", "Mammals", true),
|
15
|
-
Proposition.new("universal", "Ants", "negative", "Mammals", true)]
|
13
|
+
premises3 = [Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Mammals"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mortal Things"), true),
|
14
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("People"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Mammals"), true),
|
15
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Ants"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Mammals"), true)]
|
16
16
|
|
17
17
|
|
18
|
-
premises4 = [Proposition.new("universal", "planes", "affirmative", "things with wings", true),
|
19
|
-
Proposition.new("particular", "planes", "affirmative", "things with propellors", true),
|
20
|
-
Proposition.new("universal", "pilots", "affirmative", "things that fly planes", true),
|
21
|
-
Proposition.new("universal", "things that fly planes", "affirmative", "tall things", true)]
|
18
|
+
premises4 = [Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("planes"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("things with wings"), true),
|
19
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("particular"), Catlogic::Term.new("planes"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("things with propellors"), true),
|
20
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("pilots"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("things that fly planes"), true),
|
21
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("things that fly planes"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("tall things"), true)]
|
22
22
|
|
23
|
-
premises5 = [Proposition.new("universal", "dogs", "affirmative", "animals", true),
|
24
|
-
Proposition.new("universal", "cats", "affirmative", "animals", true),
|
25
|
-
Proposition.new("universal", "animals", "affirmative", "mortals", true),
|
26
|
-
Proposition.new("universal", "mortals", "affirmative", "things that disintegrate", true),
|
27
|
-
Proposition.new("particular", "dogs", "affirmative", "brown", true)]
|
23
|
+
premises5 = [Catlogic::Proposition.new("universal", "dogs", "affirmative", "animals", true),
|
24
|
+
Catlogic::Proposition.new("universal", "cats", "affirmative", "animals", true),
|
25
|
+
Catlogic::Proposition.new("universal", "animals", "affirmative", "mortals", true),
|
26
|
+
Catlogic::Proposition.new("universal", "mortals", "affirmative", "things that disintegrate", true),
|
27
|
+
Catlogic::Proposition.new("particular", "dogs", "affirmative", "brown", true)]
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
puts "
|
39
|
-
|
40
|
-
puts
|
41
|
-
puts
|
42
|
-
premises4.each do |proposition|
|
43
|
-
proposition.displayProposition
|
44
|
-
end
|
45
|
-
puts "==============="
|
46
|
-
|
47
|
-
collection.displayLoopedInferredTruths
|
48
|
-
#puts "#{collection.getNumberOfInferredTruths} / #{collection.getNumberOfInputTruths}: #{collection.getRatioInputToInferred}/1"
|
49
|
-
|
50
|
-
=begin
|
51
|
-
def getAllValidSyllogisms
|
52
|
-
|
53
|
-
if @collection.count < 2
|
54
|
-
puts "collection must include two or more propositions"
|
55
|
-
else
|
56
|
-
#inputconclusions = @collection
|
57
|
-
validsyllogisms = []
|
58
|
-
pairs = []
|
59
|
-
|
60
|
-
@collection.each do |proposition|
|
61
|
-
|
62
|
-
@collection.each do |secondproposition|
|
63
|
-
unless proposition.equal? secondproposition
|
64
|
-
pairs << PremisePair.new(proposition, secondproposition)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
pairs.each do |pair|
|
69
|
-
if pair.isThreeTermPair?
|
70
|
-
conclusions = pair.getPossibleConclusions
|
71
|
-
conclusions.each do |conclusion|
|
72
|
-
syllogism = Syllogism.new(pair.getMajor, pair.getMinor, conclusion)
|
73
|
-
if syllogism.validity == "valid"
|
74
|
-
validsyllogisms << syllogism
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
return validsyllogisms
|
81
|
-
end
|
82
|
-
|
83
|
-
def getUniqueValidSyllogisms
|
84
|
-
inputconclusions = @collection
|
85
|
-
validsyllogisms = self.getAllValidSyllogisms
|
86
|
-
uniquevalidsyllogisms = []
|
87
|
-
|
88
|
-
validsyllogisms.each do |syllogism|
|
89
|
-
validconclusion = syllogism.getConclusion
|
90
|
-
if (validconclusion.isUnique?(inputconclusions))
|
91
|
-
uniquevalidsyllogisms << syllogism
|
92
|
-
end
|
93
|
-
end
|
94
|
-
return uniquevalidsyllogisms
|
95
|
-
end
|
96
|
-
=end
|
97
|
-
|
98
|
-
=begin
|
99
|
-
def getUniqueInferredTruths
|
100
|
-
|
101
|
-
uniquevalidsyllogisms = self.getUniqueValidSyllogisms
|
102
|
-
uniqueinferredtruths = []
|
103
|
-
|
104
|
-
uniquevalidsyllogisms.each do |syllogism|
|
105
|
-
uniqueinferredtruths << syllogism.getConclusion
|
106
|
-
end
|
107
|
-
|
108
|
-
return uniqueinferredtruths
|
109
|
-
end
|
110
|
-
=end
|
111
|
-
|
112
|
-
=begin
|
113
|
-
def getAllInferredTruths
|
114
|
-
inputconclusions = @collection
|
115
|
-
inferredconclusions = []
|
116
|
-
|
117
|
-
validsyllogisms = self.getAllValidSyllogisms
|
118
|
-
validsyllogisms.each do |syllogism|
|
119
|
-
validconclusion = syllogism.getConclusion
|
120
|
-
|
121
|
-
if (validconclusion.isUnique?(inputconclusions))
|
122
|
-
inferredconclusions << validconclusion
|
123
|
-
end
|
29
|
+
def display_inferences(collection, iteration)
|
30
|
+
puts "==============="
|
31
|
+
puts "inference set number #{iteration}"
|
32
|
+
puts "---------------"
|
33
|
+
puts "Number of initial propositions: #{collection.unique_propositions.count}"
|
34
|
+
puts "---------------"
|
35
|
+
puts "Number of new inference #{collection.inferred_truths_new.count}"
|
36
|
+
puts "----------------"
|
37
|
+
puts "inferred propositions for iteration #{iteration}:"
|
38
|
+
puts "----------------"
|
39
|
+
collection.inferred_truths_new.each do |proposition|
|
40
|
+
puts proposition.label
|
124
41
|
end
|
125
|
-
|
42
|
+
puts "==============="
|
43
|
+
puts ""
|
126
44
|
end
|
127
45
|
|
128
|
-
|
129
|
-
def
|
130
|
-
|
131
|
-
|
132
|
-
|
46
|
+
# create first combined set or propositions
|
47
|
+
def combine_sets(oldarray, newarray)
|
48
|
+
combinedset = []
|
49
|
+
combinedset << oldarray
|
50
|
+
combinedset << newarray
|
51
|
+
return combinedset.flatten
|
133
52
|
end
|
134
53
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
puts
|
147
|
-
puts "======================="
|
148
|
-
|
149
|
-
|
150
|
-
self.displayAllValidSyllogisms
|
151
|
-
self.displayUniqueSyllogisms
|
152
|
-
self.displayInferredTruths
|
153
|
-
|
154
|
-
|
155
|
-
while (inferredtruths.count != 0)
|
156
|
-
|
157
|
-
## create new collection object
|
158
|
-
newcollection = PremiseCollection.new(combinedset)
|
159
|
-
|
160
|
-
## get next set of inferences
|
161
|
-
|
162
|
-
#reset inferred truths
|
163
|
-
inferredtruths = newcollection.getUniqueInferredTruths
|
164
|
-
#rest combined set
|
165
|
-
combinedset = newcollection.combineSets(inferredtruths)
|
166
|
-
|
167
|
-
puts "======================="
|
168
|
-
puts "next set of inferences"
|
169
|
-
puts inferredtruths.count
|
170
|
-
puts "======================="
|
171
|
-
|
172
|
-
#display inferred set
|
173
|
-
newcollection.displayAllValidSyllogisms
|
174
|
-
newcollection.displayUniqueSyllogisms
|
175
|
-
newcollection.displayInferredTruths
|
176
|
-
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
|
181
|
-
def combineSets(newset)
|
182
|
-
newcollection = []
|
183
|
-
|
184
|
-
newcollection << @collection
|
185
|
-
newcollection << newset
|
186
|
-
|
187
|
-
|
188
|
-
return newcollection.flatten
|
189
|
-
end
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
def reduceToUniqueSet
|
194
|
-
unique_knownconclusions = []
|
195
|
-
|
196
|
-
@collection.each do |conclusion|
|
197
|
-
if unique_knownconclusions.count == 0
|
198
|
-
unique_knownconclusions << conclusion
|
199
|
-
elsif conclusion.isUnique?(unique_knownconclusions)
|
200
|
-
unique_knownconclusions << conclusion
|
201
|
-
end
|
202
|
-
|
203
|
-
|
204
|
-
end
|
205
|
-
return unique_knownconclusions
|
206
|
-
end
|
207
|
-
|
208
|
-
def displayInferredTruths
|
209
|
-
truths = self.getUniqueInferredTruths
|
210
|
-
puts
|
211
|
-
puts "==== Begin Display All Unique Inferred Truths ==="
|
212
|
-
truths.each do |truth|
|
213
|
-
truth.displayProposition
|
214
|
-
end
|
215
|
-
puts "==== End Display All Unique Inferred Truths ==="
|
216
|
-
puts
|
217
|
-
|
218
|
-
end
|
219
|
-
|
220
|
-
def displayAllValidSyllogisms
|
221
|
-
puts
|
222
|
-
puts "====== Begin Display All Valid Syllogisms==="
|
223
|
-
allvalidsyllogisms = self.getAllValidSyllogisms
|
224
|
-
allvalidsyllogisms.each do |syllogism|
|
225
|
-
syllogism.displayForm
|
226
|
-
syllogism.displaySyllogism
|
227
|
-
puts
|
228
|
-
end
|
229
|
-
puts "======End All Vallid Syllogisms==="
|
230
|
-
puts
|
231
|
-
end
|
232
|
-
|
233
|
-
def displayUniqueSyllogisms
|
234
|
-
|
235
|
-
puts
|
236
|
-
puts "======Begin Display All Syllogism Producing new truths==="
|
237
|
-
uniquevalidsyllogisms = self.getUniqueValidSyllogisms
|
238
|
-
uniquevalidsyllogisms.each do |syllogism|
|
239
|
-
syllogism.displayForm
|
240
|
-
syllogism.displaySyllogism
|
241
|
-
puts
|
242
|
-
end
|
243
|
-
puts "======End Display All Syllogism Producing new truths==="
|
244
|
-
puts
|
245
|
-
|
246
|
-
end
|
247
|
-
|
248
|
-
|
249
|
-
def getNumberOfInferredTruths
|
250
|
-
self.getUniqueInferredTruths.count
|
251
|
-
end
|
252
|
-
def getNumberOfInputTruths
|
253
|
-
@collection.count
|
54
|
+
#Set up
|
55
|
+
collection = Catlogic::PremiseCollection.new(premises4)
|
56
|
+
puts ""
|
57
|
+
puts "==============="
|
58
|
+
puts "Initial Set"
|
59
|
+
puts "---------------"
|
60
|
+
puts "intial set size: #{collection.size}"
|
61
|
+
puts "---------------"
|
62
|
+
puts "input propositions"
|
63
|
+
puts "----------------"
|
64
|
+
collection.unique_propositions.each do |proposition|
|
65
|
+
puts proposition.label
|
254
66
|
end
|
255
|
-
|
256
|
-
|
67
|
+
puts "==============="
|
68
|
+
puts ""
|
69
|
+
|
70
|
+
|
71
|
+
iteration = 1
|
72
|
+
## basic idea of loop is simply to keep combing input propositions and inferred propositions until there are no more new inferred propositions
|
73
|
+
while (collection.inferred_truths_new.count != 0)
|
74
|
+
display_inferences(collection, iteration)
|
75
|
+
iteration += 1
|
76
|
+
|
77
|
+
combinedset = combine_sets(collection.unique_propositions, collection.inferred_truths_new)
|
78
|
+
collection = Catlogic::PremiseCollection.new(combinedset)
|
79
|
+
|
257
80
|
end
|
258
81
|
|
259
|
-
=end
|
@@ -17,8 +17,8 @@ numberArray.each do |i|
|
|
17
17
|
|
18
18
|
typeArray.each do |secondtype|
|
19
19
|
typeArray.each do |thirdtype|
|
20
|
-
mood = Mood.new(PropositionType.new(type), PropositionType.new(secondtype), PropositionType.new(thirdtype))
|
21
|
-
form = Form.new(mood, Figure.new(i))
|
20
|
+
mood = Catlogic::Mood.new(Catlogic::PropositionType.new(type), Catlogic::PropositionType.new(secondtype), Catlogic::PropositionType.new(thirdtype))
|
21
|
+
form = Catlogic::Form.new(mood, Catlogic::Figure.new(i))
|
22
22
|
|
23
23
|
if form.validity == true
|
24
24
|
puts form.label + " " + form.name
|
data/scripts/testCombineSets.rb
CHANGED
@@ -7,22 +7,22 @@ rescue LoadError
|
|
7
7
|
require 'catlogic'
|
8
8
|
end
|
9
9
|
|
10
|
-
premises1 = [Proposition.new("universal", "dogs", "affirmative", "animals", true),
|
11
|
-
Proposition.new("universal", "cats", "affirmative", "animals", true),
|
12
|
-
Proposition.new("universal", "animals", "affirmative", "mortals", true),
|
13
|
-
Proposition.new("universal", "mortals", "affirmative", "things that disintegrate", true),
|
14
|
-
Proposition.new("particular", "dogs", "affirmative", "brown", true),
|
15
|
-
Proposition.new("particular", "cats", "negative", "mean things", true),
|
16
|
-
Proposition.new("particular", "cats", "negative", "mean things", true),
|
17
|
-
Proposition.new("universal", "animals", "negative", "divine things", true),
|
18
|
-
Proposition.new("particular", "animals", "affirmative", "carnivores", true)]
|
19
|
-
|
20
|
-
|
21
|
-
premises2 = [Proposition.new("universal", "Events", "affirmative", "Caused Happenings", true),
|
22
|
-
Proposition.new("universal", "Free Decisions", "negative", "Caused Happenings", true),
|
23
|
-
Proposition.new("universal", "Caused Happenings", "affirmative", "Physical", true)]
|
24
|
-
|
25
|
-
collection = PremiseCollection.new(premises1)
|
10
|
+
premises1 = [Catlogic::Proposition.new("universal", "dogs", "affirmative", "animals", true),
|
11
|
+
Catlogic::Proposition.new("universal", "cats", "affirmative", "animals", true),
|
12
|
+
Catlogic::Proposition.new("universal", "animals", "affirmative", "mortals", true),
|
13
|
+
Catlogic::Proposition.new("universal", "mortals", "affirmative", "things that disintegrate", true),
|
14
|
+
Catlogic::Proposition.new("particular", "dogs", "affirmative", "brown", true),
|
15
|
+
Catlogic::Proposition.new("particular", "cats", "negative", "mean things", true),
|
16
|
+
Catlogic::Proposition.new("particular", "cats", "negative", "mean things", true),
|
17
|
+
Catlogic::Proposition.new("universal", "animals", "negative", "divine things", true),
|
18
|
+
Catlogic::Proposition.new("particular", "animals", "affirmative", "carnivores", true)]
|
19
|
+
|
20
|
+
|
21
|
+
premises2 = [Catlogic::Proposition.new("universal", "Events", "affirmative", "Caused Happenings", true),
|
22
|
+
Catlogic::Proposition.new("universal", "Free Decisions", "negative", "Caused Happenings", true),
|
23
|
+
Catlogic::Proposition.new("universal", "Caused Happenings", "affirmative", "Physical", true)]
|
24
|
+
|
25
|
+
collection = Catlogic::PremiseCollection.new(premises1)
|
26
26
|
|
27
27
|
newcollection = collection.combineSets(premises2)
|
28
28
|
|
data/scripts/testIfUnique.rb
CHANGED
@@ -7,13 +7,13 @@ rescue LoadError
|
|
7
7
|
require 'catlogic'
|
8
8
|
end
|
9
9
|
|
10
|
-
premisesArray = [Proposition.new(Quantity.new("universal"), Term.new("Events"), Quality.new("affirmative"), Term.new("Caused Happenings"), true),
|
11
|
-
Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true),
|
12
|
-
Proposition.new(Quantity.new("universal"), Term.new("Fun"), Quality.new("affirmative"), Term.new("Events"), true)]
|
10
|
+
premisesArray = [Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Events"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Caused Happenings"), true),
|
11
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Caused Happenings"), true),
|
12
|
+
Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Fun"), Catlogic::Quality.new("affirmative"), Catlogic::Term.new("Events"), true)]
|
13
13
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
proposition = Proposition.new(Quantity.new("universal"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), true)
|
17
|
+
proposition = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Caused Happenings"), true)
|
18
18
|
|
19
19
|
puts proposition.number_of_occurences(premisesArray)
|
data/scripts/testPremisePair.rb
CHANGED
@@ -7,9 +7,9 @@ rescue LoadError
|
|
7
7
|
require 'catlogic'
|
8
8
|
end
|
9
9
|
|
10
|
-
premise1 = Proposition.new("universal", "Mammals", "affirmative", "Dogs", true)
|
11
|
-
premise2 = Proposition.new("universal", "Mammals", "affirmative", "Mortal Things", true)
|
10
|
+
premise1 = Catlogic::Proposition.new("universal", "Mammals", "affirmative", "Dogs", true)
|
11
|
+
premise2 = Catlogic::Proposition.new("universal", "Mammals", "affirmative", "Mortal Things", true)
|
12
12
|
|
13
13
|
|
14
|
-
pair = PremisePair.new(premise1, premise2)
|
14
|
+
pair = Catlogic::PremisePair.new(premise1, premise2)
|
15
15
|
puts pair.isThreeTermPair?;
|
data/scripts/testProposition.rb
CHANGED
@@ -7,7 +7,7 @@ rescue LoadError
|
|
7
7
|
require 'catlogic'
|
8
8
|
end
|
9
9
|
|
10
|
-
proposition = Proposition.new(Quantity.new("particular"), Term.new("Free Decisions"), Quality.new("negative"), Term.new("Caused Happenings"), false)
|
10
|
+
proposition = Catlogic::Proposition.new(Catlogic::Quantity.new("particular"), Catlogic::Term.new("Free Decisions"), Catlogic::Quality.new("negative"), Catlogic::Term.new("Caused Happenings"), false)
|
11
11
|
|
12
12
|
#converse = proposition.getContrapolated
|
13
13
|
#converse.displayProposition
|
data/scripts/testQuantity.rb
CHANGED
@@ -7,14 +7,14 @@ rescue LoadError
|
|
7
7
|
require 'catlogic'
|
8
8
|
end
|
9
9
|
|
10
|
-
premisesArray = [Proposition.new("universal", "Events", "affirmative", "Caused Happenings", true),
|
11
|
-
Proposition.new("universal", "Free Decisions", "negative", "Caused Happenings", true),
|
12
|
-
Proposition.new("universal", "Fun", "affirmative", "Events", true),
|
13
|
-
Proposition.new("universal", "Fun", "affirmative", "Events", true),
|
14
|
-
Proposition.new("universal", "Fun", "affirmative", "Events", true)]
|
10
|
+
premisesArray = [Catlogic::Proposition.new("universal", "Events", "affirmative", "Caused Happenings", true),
|
11
|
+
Catlogic::Proposition.new("universal", "Free Decisions", "negative", "Caused Happenings", true),
|
12
|
+
Catlogic::Proposition.new("universal", "Fun", "affirmative", "Events", true),
|
13
|
+
Catlogic::Proposition.new("universal", "Fun", "affirmative", "Events", true),
|
14
|
+
Catlogic::Proposition.new("universal", "Fun", "affirmative", "Events", true)]
|
15
15
|
|
16
16
|
|
17
|
-
collection = PremiseCollection.new(premisesArray)
|
17
|
+
collection = Catlogic::PremiseCollection.new(premisesArray)
|
18
18
|
|
19
19
|
reducedcollection = collection.reduceToUniqueSet
|
20
20
|
|
data/scripts/testSyllogism.rb
CHANGED
@@ -7,17 +7,17 @@ rescue LoadError
|
|
7
7
|
require 'catlogic'
|
8
8
|
end
|
9
9
|
|
10
|
-
major = Proposition.new(Quantity.new("universal"), Term.new("pollution free"), Quality.new("negative"), Term.new("completely efficient"), true)
|
11
|
-
minor = Proposition.new(Quantity.new("universal"), Term.new("automobile"), Quality.new("negative"), Term.new("completely efficient"), true)
|
12
|
-
conclusion = Proposition.new(Quantity.new("universal"), Term.new("automobile"), Quality.new("negative"), Term.new("pollution free"), true)
|
13
|
-
syllogism = Syllogism.new(major, minor, conclusion)
|
10
|
+
major = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("pollution free"), Catlogic::Quality.new("negative"), Catlogic::Term.new("completely efficient"), true)
|
11
|
+
minor = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("automobile"), Catlogic::Quality.new("negative"), Catlogic::Term.new("completely efficient"), true)
|
12
|
+
conclusion = Catlogic::Proposition.new(Catlogic::Quantity.new("universal"), Catlogic::Term.new("automobile"), Catlogic::Quality.new("negative"), Catlogic::Term.new("pollution free"), true)
|
13
|
+
syllogism = Catlogic::Syllogism.new(major, minor, conclusion)
|
14
14
|
|
15
15
|
puts "=========="
|
16
16
|
puts "Testing syllogism (#{syllogism.form.label}):"
|
17
17
|
puts "====Syllogism======"
|
18
18
|
puts syllogism.label
|
19
19
|
puts "====Propositional Form===="
|
20
|
-
puts Form.new(syllogism.mood, syllogism.figure).syllogism.label
|
20
|
+
puts Catlogic::Form.new(syllogism.mood, syllogism.figure).syllogism.label
|
21
21
|
puts "=====Validity===="
|
22
22
|
puts "Validity: #{syllogism.validity}"
|
23
23
|
puts "=========="
|
@@ -7,9 +7,9 @@ rescue LoadError
|
|
7
7
|
require 'catlogic'
|
8
8
|
end
|
9
9
|
|
10
|
-
mood = Mood.new(PropositionType.new("A"), PropositionType.new("A"), PropositionType.new("A"))
|
11
|
-
figure = Figure.new(3)
|
12
|
-
form = Form.new(mood, figure)
|
10
|
+
mood = Catlogic::Mood.new(Catlogic::PropositionType.new("A"), Catlogic::PropositionType.new("A"), Catlogic::PropositionType.new("A"))
|
11
|
+
figure = Catlogic::Figure.new(3)
|
12
|
+
form = Catlogic::Form.new(mood, figure)
|
13
13
|
puts "====================="
|
14
14
|
puts "Testing: #{form.label}"
|
15
15
|
|
data/spec/distribution_spec.rb
CHANGED
@@ -4,20 +4,20 @@ require 'pry'
|
|
4
4
|
|
5
5
|
describe 'distribution object' do
|
6
6
|
it 'can return distribution label as string' do
|
7
|
-
term = Distribution.new('distributed')
|
7
|
+
term = Catlogic::Distribution.new('distributed')
|
8
8
|
result = term.label
|
9
9
|
result.should == 'distributed'
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'can return distribution opposite label as string' do
|
13
|
-
term = Distribution.new('distributed')
|
13
|
+
term = Catlogic::Distribution.new('distributed')
|
14
14
|
opposite = term.opposite
|
15
15
|
result = opposite.label
|
16
16
|
result.should == 'undistributed'
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'can return undistributed opposite label as string' do
|
20
|
-
term = Distribution.new('undistributed')
|
20
|
+
term = Catlogic::Distribution.new('undistributed')
|
21
21
|
opposite = term.opposite
|
22
22
|
result = opposite.label
|
23
23
|
result.should == 'distributed'
|
data/spec/figure_spec.rb
CHANGED
data/spec/form_spec.rb
CHANGED
@@ -2,9 +2,9 @@ require "spec_helper"
|
|
2
2
|
require "catlogic"
|
3
3
|
|
4
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)
|
5
|
+
mood_aaa = Catlogic::Mood.new(Catlogic::PropositionType.new('A'), Catlogic::PropositionType.new('A'), Catlogic::PropositionType.new('A'))
|
6
|
+
figure_1 = Catlogic::Figure.new(1)
|
7
|
+
$form = Catlogic::Form.new(mood_aaa, figure_1)
|
8
8
|
|
9
9
|
it "should return form label" do
|
10
10
|
label = $form.label
|
data/spec/mood_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require "catlogic"
|
|
3
3
|
|
4
4
|
describe "mood object" do
|
5
5
|
|
6
|
-
$moodobject_aaa = Mood.new(PropositionType.new('A'), PropositionType.new('A'), PropositionType.new('A'))
|
6
|
+
$moodobject_aaa = Catlogic::Mood.new(Catlogic::PropositionType.new('A'), Catlogic::PropositionType.new('A'), Catlogic::PropositionType.new('A'))
|
7
7
|
|
8
8
|
it 'can display the label of the mood object' do
|
9
9
|
mood = $moodobject_aaa.label
|