catlogic 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +7 -0
- data/bin2/.idea/.name +1 -0
- data/bin2/.idea/bin.iml +9 -0
- data/bin2/.idea/encodings.xml +5 -0
- data/bin2/.idea/misc.xml +5 -0
- data/bin2/.idea/modules.xml +9 -0
- data/bin2/.idea/scopes/scope_settings.xml +5 -0
- data/bin2/.idea/vcs.xml +7 -0
- data/bin2/.idea/workspace.xml +129 -0
- data/bin2/displayInferredTruths.rb +43 -0
- data/bin2/getAllValidPropositions.rb +24 -0
- data/bin2/testCombineSets.rb +27 -0
- data/bin2/testIfUnique.rb +14 -0
- data/bin2/testPremisePair.rb +10 -0
- data/bin2/testProposition.rb +47 -0
- data/bin2/testPropositionType.rb +40 -0
- data/bin2/testQuantity.rb +12 -0
- data/bin2/testReduceToUniqueSet.rb +18 -0
- data/bin2/testSyllogism.rb +45 -0
- data/bin2/testSyllogismForm.rb +51 -0
- data/catlogic.gemspec +25 -0
- data/lib/catlogic/distribution.rb +16 -0
- data/lib/catlogic/figure.rb +45 -0
- data/lib/catlogic/form.rb +22 -0
- data/lib/catlogic/mood.rb +14 -0
- data/lib/catlogic/premise_collection.rb +211 -0
- data/lib/catlogic/premise_pair.rb +61 -0
- data/lib/catlogic/proposition.rb +181 -0
- data/lib/catlogic/proposition_type.rb +47 -0
- data/lib/catlogic/quality.rb +16 -0
- data/lib/catlogic/quantity.rb +16 -0
- data/lib/catlogic/syllogism.rb +171 -0
- data/lib/catlogic/term.rb +32 -0
- data/lib/catlogic/version.rb +3 -0
- data/lib/catlogic.rb +17 -0
- data/spec/distribution_spec.rb +26 -0
- data/spec/figure_spec.rb +27 -0
- data/spec/form_spec.rb +22 -0
- data/spec/mood_spec.rb +17 -0
- data/spec/premise_pair_spec.rb +51 -0
- data/spec/proposition_spec.rb +215 -0
- data/spec/proposition_type_spec.rb +37 -0
- data/spec/quality_spec.rb +17 -0
- data/spec/quantity_spec.rb +19 -0
- data/spec/spec_helper.rb +89 -0
- data/spec/syllogism_spec.rb +121 -0
- data/spec/term_spec.rb +35 -0
- metadata +166 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
+
# a separate helper file that requires the additional dependencies and performs
|
11
|
+
# the additional setup, and require it from the spec files that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# rspec-expectations config goes here. You can use an alternate
|
19
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
+
# assertions if you prefer.
|
21
|
+
config.expect_with :rspec do |expectations|
|
22
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
+
# and `failure_message` of custom matchers include text for helper methods
|
24
|
+
# defined using `chain`, e.g.:
|
25
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
+
# # => "be bigger than 2 and smaller than 4"
|
27
|
+
# ...rather than:
|
28
|
+
# # => "be bigger than 2"
|
29
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
+
end
|
31
|
+
|
32
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
+
config.mock_with :rspec do |mocks|
|
35
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
+
# a real object. This is generally recommended, and will default to
|
37
|
+
# `true` in RSpec 4.
|
38
|
+
mocks.verify_partial_doubles = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# The settings below are suggested to provide a good initial experience
|
42
|
+
# with RSpec, but feel free to customize to your heart's content.
|
43
|
+
=begin
|
44
|
+
# These two settings work together to allow you to limit a spec run
|
45
|
+
# to individual examples or groups you care about by tagging them with
|
46
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
47
|
+
# get run.
|
48
|
+
config.filter_run :focus
|
49
|
+
config.run_all_when_everything_filtered = true
|
50
|
+
|
51
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
52
|
+
# For more details, see:
|
53
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
55
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
56
|
+
config.disable_monkey_patching!
|
57
|
+
|
58
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
59
|
+
# be too noisy due to issues in dependencies.
|
60
|
+
config.warnings = true
|
61
|
+
|
62
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
63
|
+
# file, and it's useful to allow more verbose output when running an
|
64
|
+
# individual spec file.
|
65
|
+
if config.files_to_run.one?
|
66
|
+
# Use the documentation formatter for detailed output,
|
67
|
+
# unless a formatter has already been configured
|
68
|
+
# (e.g. via a command-line flag).
|
69
|
+
config.default_formatter = 'doc'
|
70
|
+
end
|
71
|
+
|
72
|
+
# Print the 10 slowest examples and example groups at the
|
73
|
+
# end of the spec run, to help surface which specs are running
|
74
|
+
# particularly slow.
|
75
|
+
config.profile_examples = 10
|
76
|
+
|
77
|
+
# Run specs in random order to surface order dependencies. If you find an
|
78
|
+
# order dependency and want to debug it, you can fix the order by providing
|
79
|
+
# the seed, which is printed after each run.
|
80
|
+
# --seed 1234
|
81
|
+
config.order = :random
|
82
|
+
|
83
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
84
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
85
|
+
# test failures related to randomization by passing the same `--seed` value
|
86
|
+
# as the one that triggered the failure.
|
87
|
+
Kernel.srand config.seed
|
88
|
+
=end
|
89
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "catlogic"
|
3
|
+
|
4
|
+
describe "syllogism object" do
|
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)
|
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)
|
16
|
+
|
17
|
+
it 'can retrieve the middle term' do
|
18
|
+
|
19
|
+
middleterm = $syllogism_aaa1.middle
|
20
|
+
middleterm.label.should == 'mortal things'
|
21
|
+
end
|
22
|
+
|
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)
|
28
|
+
|
29
|
+
middleterm = syllogism_test.middle
|
30
|
+
middleterm.should == 'Error: this is not a three term syllogism'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'can retrieve conclusion' do
|
34
|
+
conclusion = $syllogism_aaa1.conclusion
|
35
|
+
conclusion.should == $conclusionproposition
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'can retrieve major proposition' do
|
39
|
+
major = $syllogism_aaa1.major
|
40
|
+
major.should == $majorproposition
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'can retrieve minor proposition' do
|
45
|
+
major = $syllogism_aaa1.major
|
46
|
+
major.should == $majorproposition
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'can retrive minor term from the minor propositions' do
|
50
|
+
minorterm = $syllogism_aaa1.minorterm
|
51
|
+
minorterm.label.should == 'living things'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'can retrive major term from the major propositions' do
|
55
|
+
majorterm = $syllogism_aaa1.majorterm
|
56
|
+
majorterm.label.should == 'dogs'
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'can retrieve mood of syllogism' do
|
60
|
+
mood = $syllogism_aaa1.mood
|
61
|
+
mood.label.should == 'AAA'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'can retrieve figure object of syllogism' do
|
65
|
+
figure = $syllogism_aaa1.figure
|
66
|
+
figure.label.should == 1
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'can test for undistributed middle fallacy on AAA1 syllogism' do
|
70
|
+
validity = $syllogism_aaa1.undistributed_middle_test
|
71
|
+
validity.should == true
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'can test for undistributed middle fallacy on AAA2 syllogism' do
|
75
|
+
validity = $syllogism_aaa2.undistributed_middle_test
|
76
|
+
validity.should == false
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'can test for illicit major fallacy on AAA1 syllogism' do
|
80
|
+
validity = $syllogism_aaa1.illicit_major_test
|
81
|
+
validity.should == true
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'can test for illicit minor fallacy on AAA1 syllogism' do
|
85
|
+
validity = $syllogism_aaa1.illicit_minor_test
|
86
|
+
validity.should == true
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'can test for exclusive premises fallacy on AAA1 syllogism' do
|
90
|
+
validity = $syllogism_aaa1.exclusive_premises_test
|
91
|
+
validity.should == true
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'can test for affirmative conclusion from negative premise fallacy on AAA1 syllogism' do
|
95
|
+
validity = $syllogism_aaa1.affirm_from_neg_test
|
96
|
+
validity.should == true
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'can test for negative conclusion from affirmative premises fallacy on AAA1 syllogism' do
|
100
|
+
validity = $syllogism_aaa1.neg_from_affirms_test
|
101
|
+
validity.should == true
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'can test for overall validity on AAA1 syllogism' do
|
105
|
+
validity = $syllogism_aaa1.validity
|
106
|
+
validity.should == true
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'can return a human readable form of the syllogism' do
|
110
|
+
label = $syllogism_aaa1.label
|
111
|
+
label.should == "All mortal things are dogs\nAll living things are mortal things\nAll living things are dogs"
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'can return true if this syllogism is a three term syllogism' do
|
115
|
+
result = $syllogism_aaa1.three_term?
|
116
|
+
result.should == true
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
|
data/spec/term_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'catlogic'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
describe 'term object' do
|
6
|
+
it 'can return term as string' do
|
7
|
+
term = Term.new('dogs')
|
8
|
+
result = term.label
|
9
|
+
result.should == 'dogs'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'can return term opposite as string' do
|
13
|
+
term = Term.new('dogs')
|
14
|
+
opposite = term.opposite
|
15
|
+
result = opposite.label
|
16
|
+
result.should == 'non-dogs'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'can return correct distribution for subject term' do
|
20
|
+
term = Term.new('dogs')
|
21
|
+
quantity = Quantity.new('universal')
|
22
|
+
result = term.distribution_subject(quantity)
|
23
|
+
result.label.should == 'distributed'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'can return correct distribution for predicate term' do
|
27
|
+
term = Term.new('dogs')
|
28
|
+
quality = Quality.new('affirmative')
|
29
|
+
result = term.distribution_predicate(quality)
|
30
|
+
result.label.should == 'undistributed'
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: catlogic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeffrey C. Witt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A gem for building categorial propositions and syllogisms
|
70
|
+
email:
|
71
|
+
- jeffreycwitt@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".ruby-gemset"
|
79
|
+
- ".ruby-version"
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin2/.idea/.name
|
85
|
+
- bin2/.idea/bin.iml
|
86
|
+
- bin2/.idea/encodings.xml
|
87
|
+
- bin2/.idea/misc.xml
|
88
|
+
- bin2/.idea/modules.xml
|
89
|
+
- bin2/.idea/scopes/scope_settings.xml
|
90
|
+
- bin2/.idea/vcs.xml
|
91
|
+
- bin2/.idea/workspace.xml
|
92
|
+
- bin2/displayInferredTruths.rb
|
93
|
+
- bin2/getAllValidPropositions.rb
|
94
|
+
- bin2/testCombineSets.rb
|
95
|
+
- bin2/testIfUnique.rb
|
96
|
+
- bin2/testPremisePair.rb
|
97
|
+
- bin2/testProposition.rb
|
98
|
+
- bin2/testPropositionType.rb
|
99
|
+
- bin2/testQuantity.rb
|
100
|
+
- bin2/testReduceToUniqueSet.rb
|
101
|
+
- bin2/testSyllogism.rb
|
102
|
+
- bin2/testSyllogismForm.rb
|
103
|
+
- catlogic.gemspec
|
104
|
+
- lib/catlogic.rb
|
105
|
+
- lib/catlogic/distribution.rb
|
106
|
+
- lib/catlogic/figure.rb
|
107
|
+
- lib/catlogic/form.rb
|
108
|
+
- lib/catlogic/mood.rb
|
109
|
+
- lib/catlogic/premise_collection.rb
|
110
|
+
- lib/catlogic/premise_pair.rb
|
111
|
+
- lib/catlogic/proposition.rb
|
112
|
+
- lib/catlogic/proposition_type.rb
|
113
|
+
- lib/catlogic/quality.rb
|
114
|
+
- lib/catlogic/quantity.rb
|
115
|
+
- lib/catlogic/syllogism.rb
|
116
|
+
- lib/catlogic/term.rb
|
117
|
+
- lib/catlogic/version.rb
|
118
|
+
- spec/distribution_spec.rb
|
119
|
+
- spec/figure_spec.rb
|
120
|
+
- spec/form_spec.rb
|
121
|
+
- spec/mood_spec.rb
|
122
|
+
- spec/premise_pair_spec.rb
|
123
|
+
- spec/proposition_spec.rb
|
124
|
+
- spec/proposition_type_spec.rb
|
125
|
+
- spec/quality_spec.rb
|
126
|
+
- spec/quantity_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/syllogism_spec.rb
|
129
|
+
- spec/term_spec.rb
|
130
|
+
homepage: ''
|
131
|
+
licenses:
|
132
|
+
- MIT
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.4.5
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: A gem for building categorial propositions and syllogisms
|
154
|
+
test_files:
|
155
|
+
- spec/distribution_spec.rb
|
156
|
+
- spec/figure_spec.rb
|
157
|
+
- spec/form_spec.rb
|
158
|
+
- spec/mood_spec.rb
|
159
|
+
- spec/premise_pair_spec.rb
|
160
|
+
- spec/proposition_spec.rb
|
161
|
+
- spec/proposition_type_spec.rb
|
162
|
+
- spec/quality_spec.rb
|
163
|
+
- spec/quantity_spec.rb
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/syllogism_spec.rb
|
166
|
+
- spec/term_spec.rb
|