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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a4c518dea8c0143286b978109c6b817f405594d7b0b5b6594d3a064ad939a02
4
- data.tar.gz: c5de24d6472be0aa3266924734f52052ca8171fa36c8605bc44c302f0027298e
3
+ metadata.gz: a6611c1ac7aedc538dbf5d55944bff8e98c780fe2951e23f1b4f6c1d09a25de3
4
+ data.tar.gz: 37d5b0b6458e970dff65057733e06783f1e40bac8135d09a69e74f37c7259b76
5
5
  SHA512:
6
- metadata.gz: abacbd989dcd3255bf90038ed25bc01362994610272067eff8f42cc5ac3ecbd4f8680c717d09232c079923c41b4e19286963b2249894565055e19f0681b920e3
7
- data.tar.gz: 22d3ed160079a7ed1e96074fec616272dee0fb96516eb788bcc80830257407708ba41555ba65987095a4af57fdbd0c5d757325e3ab6f07abad3159962d789801
6
+ metadata.gz: f6faccb91d838b5e9834ce178b2530ba02a5ba2dbd09319b61ae3225cd04e73d76fcb35c29f4948ab1bba43ce91582f97bd3722dfcfe31db7a29cebdf17b4028
7
+ data.tar.gz: '09feaa85885909252e80cc2e6987056df2388d7fb5e4dae8399d2fb574c455c058f4e2174f7085eaed0803954cb5680940de00ca1329f5a3e2864d906940e36b'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syllogism (0.1.0)
4
+ syllogism (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
@@ -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
- WffChecker.new(self).any?
80
+ formula_checker.any?
73
81
  end
74
82
 
75
83
  def unknown
@@ -1,3 +1,3 @@
1
1
  class Syllogism
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -5,9 +5,13 @@ class Syllogism
5
5
  end
6
6
 
7
7
  def any?
8
- WELL_FORMED_FORMULAS.any? do |formula|
9
- atom_types == formula
10
- end
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.1.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-05-26 00:00:00.000000000 Z
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: