syllogism 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -1
- data/lib/syllogism.rb +6 -0
- data/lib/syllogism/statement.rb +9 -1
- data/lib/syllogism/version.rb +1 -1
- data/lib/syllogism/wff_checker.rb +7 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6611c1ac7aedc538dbf5d55944bff8e98c780fe2951e23f1b4f6c1d09a25de3
|
4
|
+
data.tar.gz: 37d5b0b6458e970dff65057733e06783f1e40bac8135d09a69e74f37c7259b76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6faccb91d838b5e9834ce178b2530ba02a5ba2dbd09319b61ae3225cd04e73d76fcb35c29f4948ab1bba43ce91582f97bd3722dfcfe31db7a29cebdf17b4028
|
7
|
+
data.tar.gz: '09feaa85885909252e80cc2e6987056df2388d7fb5e4dae8399d2fb574c455c058f4e2174f7085eaed0803954cb5680940de00ca1329f5a3e2864d906940e36b'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -35,8 +35,13 @@ end
|
|
35
35
|
|
36
36
|
# Entire arguments:
|
37
37
|
Syllogism['all P is S', 'j is P', 'j is S'].valid? # => true
|
38
|
-
|
39
38
|
Syllogism['no A is B', 'no C is A', 'no C is B'].valid? # => false
|
39
|
+
|
40
|
+
# Arguments with the same logical form are considered equivalent:
|
41
|
+
argument = Syllogism["all A is B", "some C is A", "some C is B"]
|
42
|
+
other_argument = Syllogism["all X is Y", "some Z is X", "some Z is Y"]
|
43
|
+
|
44
|
+
argument == other_argument # => true
|
40
45
|
```
|
41
46
|
|
42
47
|
## Development
|
data/lib/syllogism.rb
CHANGED
@@ -30,6 +30,12 @@ class Syllogism
|
|
30
30
|
@statements = statements
|
31
31
|
end
|
32
32
|
|
33
|
+
def ==(other)
|
34
|
+
premises.map(&:formula).sort == other.premises.map(&:formula) &&
|
35
|
+
conclusion.formula == other.conclusion.formula &&
|
36
|
+
valid? == valid?
|
37
|
+
end
|
38
|
+
|
33
39
|
def premises
|
34
40
|
@premises ||= statements.take(statements.length - 1)
|
35
41
|
end
|
data/lib/syllogism/statement.rb
CHANGED
@@ -25,6 +25,10 @@ class Syllogism
|
|
25
25
|
TermDistributor.new(self).call
|
26
26
|
end
|
27
27
|
|
28
|
+
def formula
|
29
|
+
formula_checker.formula
|
30
|
+
end
|
31
|
+
|
28
32
|
def general_terms
|
29
33
|
terms.select { |term| term.instance_of?(GeneralTerm) }
|
30
34
|
end
|
@@ -64,12 +68,16 @@ class Syllogism
|
|
64
68
|
|
65
69
|
TERM_TYPES = [GeneralTerm, SingularTerm].freeze
|
66
70
|
|
71
|
+
def formula_checker
|
72
|
+
@formula_checker ||= WffChecker.new(self)
|
73
|
+
end
|
74
|
+
|
67
75
|
def known_atoms?
|
68
76
|
unknown.none?
|
69
77
|
end
|
70
78
|
|
71
79
|
def known_formula?
|
72
|
-
|
80
|
+
formula_checker.any?
|
73
81
|
end
|
74
82
|
|
75
83
|
def unknown
|
data/lib/syllogism/version.rb
CHANGED
@@ -5,9 +5,13 @@ class Syllogism
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def any?
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
formula && !formula.empty?
|
9
|
+
end
|
10
|
+
|
11
|
+
def formula
|
12
|
+
@formula ||= WELL_FORMED_FORMULAS.find do |formula_type|
|
13
|
+
atom_types == formula_type
|
14
|
+
end.to_s
|
11
15
|
end
|
12
16
|
|
13
17
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syllogism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jayson Virissimo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Proof checker for arguments in Aristotle's term logic
|
14
14
|
email:
|