tensai-logic 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a3d517ace3ab485484c60554172fba6deaaf0bdfb1c05890e1a037f74efe14cb
4
+ data.tar.gz: 71b98b45c8d346728f0980c42e7ea570ef77b460c6fb3e30c0078a113ee14023
5
+ SHA512:
6
+ metadata.gz: 3ad51401b841a499cbec0e11b3ff1df4e11a33f3f0f12ab5bb0efeabb617e34a9f04def3adbe9475aaa5021986f3a382a2393843cad722ffb7f4c0ea2517c183
7
+ data.tar.gz: 0ae73fef220915259f0b666cc9dfb357602a7bf57b89872a78530433e5878a0a722d54f08a179ec5b10b7decb27b8cfc87cecb2678dd88f095b1fa05ed14764c
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in tensai.gemspec
6
+ gemspec
7
+
8
+ group :development, :test do
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop', '~> 0.74'
11
+ gem 'rubocop-rspec', '~> 1.35'
12
+ gem 'guard', '~> 2.15'
13
+ gem 'guard-rspec', '~> 4.7'
14
+ gem 'pry-byebug', '~> 3.7'
15
+ gem 'factory_bot', '~> 5.0'
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,133 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tensai-logic (0.1.1)
5
+ tensai-core (~> 0.1.7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (6.0.0)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ zeitwerk (~> 2.1, >= 2.1.8)
16
+ ast (2.4.0)
17
+ byebug (11.0.1)
18
+ coderay (1.1.2)
19
+ concurrent-ruby (1.1.5)
20
+ diff-lcs (1.3)
21
+ dry-configurable (0.8.3)
22
+ concurrent-ruby (~> 1.0)
23
+ dry-core (~> 0.4, >= 0.4.7)
24
+ dry-container (0.7.2)
25
+ concurrent-ruby (~> 1.0)
26
+ dry-configurable (~> 0.1, >= 0.1.3)
27
+ dry-core (0.4.9)
28
+ concurrent-ruby (~> 1.0)
29
+ dry-equalizer (0.2.2)
30
+ dry-inflector (0.1.2)
31
+ dry-logic (1.0.3)
32
+ concurrent-ruby (~> 1.0)
33
+ dry-core (~> 0.2)
34
+ dry-equalizer (~> 0.2)
35
+ dry-types (1.2.0)
36
+ concurrent-ruby (~> 1.0)
37
+ dry-container (~> 0.3)
38
+ dry-core (~> 0.4, >= 0.4.4)
39
+ dry-equalizer (~> 0.2, >= 0.2.2)
40
+ dry-inflector (~> 0.1, >= 0.1.2)
41
+ dry-logic (~> 1.0, >= 1.0.2)
42
+ factory_bot (5.1.1)
43
+ activesupport (>= 4.2.0)
44
+ ffi (1.11.1)
45
+ formatador (0.2.5)
46
+ guard (2.15.1)
47
+ formatador (>= 0.2.4)
48
+ listen (>= 2.7, < 4.0)
49
+ lumberjack (>= 1.0.12, < 2.0)
50
+ nenv (~> 0.1)
51
+ notiffany (~> 0.0)
52
+ pry (>= 0.9.12)
53
+ shellany (~> 0.0)
54
+ thor (>= 0.18.1)
55
+ guard-compat (1.2.1)
56
+ guard-rspec (4.7.3)
57
+ guard (~> 2.1)
58
+ guard-compat (~> 1.1)
59
+ rspec (>= 2.99.0, < 4.0)
60
+ i18n (1.7.0)
61
+ concurrent-ruby (~> 1.0)
62
+ jaro_winkler (1.5.3)
63
+ listen (3.2.0)
64
+ rb-fsevent (~> 0.10, >= 0.10.3)
65
+ rb-inotify (~> 0.9, >= 0.9.10)
66
+ lumberjack (1.0.13)
67
+ method_source (0.9.2)
68
+ minitest (5.12.2)
69
+ nenv (0.3.0)
70
+ notiffany (0.1.3)
71
+ nenv (~> 0.1)
72
+ shellany (~> 0.0)
73
+ parallel (1.17.0)
74
+ parser (2.6.5.0)
75
+ ast (~> 2.4.0)
76
+ pry (0.12.2)
77
+ coderay (~> 1.1.0)
78
+ method_source (~> 0.9.0)
79
+ pry-byebug (3.7.0)
80
+ byebug (~> 11.0)
81
+ pry (~> 0.10)
82
+ rainbow (3.0.0)
83
+ rb-fsevent (0.10.3)
84
+ rb-inotify (0.10.0)
85
+ ffi (~> 1.0)
86
+ rspec (3.8.0)
87
+ rspec-core (~> 3.8.0)
88
+ rspec-expectations (~> 3.8.0)
89
+ rspec-mocks (~> 3.8.0)
90
+ rspec-core (3.8.2)
91
+ rspec-support (~> 3.8.0)
92
+ rspec-expectations (3.8.5)
93
+ diff-lcs (>= 1.2.0, < 2.0)
94
+ rspec-support (~> 3.8.0)
95
+ rspec-mocks (3.8.2)
96
+ diff-lcs (>= 1.2.0, < 2.0)
97
+ rspec-support (~> 3.8.0)
98
+ rspec-support (3.8.3)
99
+ rubocop (0.75.0)
100
+ jaro_winkler (~> 1.5.1)
101
+ parallel (~> 1.10)
102
+ parser (>= 2.6)
103
+ rainbow (>= 2.2.2, < 4.0)
104
+ ruby-progressbar (~> 1.7)
105
+ unicode-display_width (>= 1.4.0, < 1.7)
106
+ rubocop-rspec (1.36.0)
107
+ rubocop (>= 0.68.1)
108
+ ruby-progressbar (1.10.1)
109
+ shellany (0.0.1)
110
+ tensai-core (0.1.7)
111
+ dry-types (~> 1.1)
112
+ thor (0.20.3)
113
+ thread_safe (0.3.6)
114
+ tzinfo (1.2.5)
115
+ thread_safe (~> 0.1)
116
+ unicode-display_width (1.6.0)
117
+ zeitwerk (2.1.10)
118
+
119
+ PLATFORMS
120
+ ruby
121
+
122
+ DEPENDENCIES
123
+ factory_bot (~> 5.0)
124
+ guard (~> 2.15)
125
+ guard-rspec (~> 4.7)
126
+ pry-byebug (~> 3.7)
127
+ rspec (~> 3.0)
128
+ rubocop (~> 0.74)
129
+ rubocop-rspec (~> 1.35)
130
+ tensai-logic!
131
+
132
+ BUNDLED WITH
133
+ 2.0.1
data/Guardfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: 'bundle exec rspec' do
4
+ require 'guard/rspec/dsl'
5
+ dsl = Guard::RSpec::Dsl.new(self)
6
+
7
+ rspec = dsl.rspec
8
+ watch(rspec.spec_helper) { rspec.spec_dir }
9
+ watch(rspec.spec_support) { rspec.spec_dir }
10
+ watch(rspec.spec_files)
11
+
12
+ # Ruby files
13
+ ruby = dsl.ruby
14
+ dsl.watch_spec_files_for(ruby.lib_files)
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tensai/util/initializer'
4
+
5
+ module Tensai
6
+ module Logic
7
+ #
8
+ # Entity
9
+ #
10
+ class Entity
11
+ include Util::Initializer.new(
12
+ name: Name
13
+ )
14
+
15
+ def inspect
16
+ "#{self.class.to_s.split('::').last}(#{name})"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tensai
4
+ module Logic
5
+ #
6
+ # Formula
7
+ #
8
+ class Formula; end
9
+ end
10
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tensai/types'
4
+ require 'tensai/util/initializer'
5
+
6
+ require_relative '../predicate'
7
+
8
+ module Tensai
9
+ module Logic
10
+ module Formulas
11
+ #
12
+ # Atomic formula
13
+ #
14
+ class Atom
15
+ include Util::Initializer.new(
16
+ predicate: Tensai::Types::Instance(Predicate),
17
+ values: Tensai::Types::Hash
18
+ )
19
+
20
+ def after_initialize
21
+ raise ArgumentError, "Invalid values #{values} for predicate #{predicate}" unless predicate.accepts? values
22
+ end
23
+
24
+ def inspect
25
+ "(#{predicate.name} #{values.map { |name, value| "#{name}: #{value.inspect}" }.join(', ')})"
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tensai
4
+ module Logic
5
+ #
6
+ # Formula
7
+ #
8
+ module Formulas; end
9
+ end
10
+ end
11
+
12
+ require_relative 'formulas/atom'
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'set'
4
+
5
+ require 'tensai/types'
6
+ require 'tensai/util/initializer'
7
+
8
+ require_relative 'variable'
9
+
10
+ module Tensai
11
+ module Logic
12
+ #
13
+ # Predicate
14
+ #
15
+ class Predicate
16
+ include Util::Initializer.new(
17
+ name: Name,
18
+ variables: Tensai::Types::Array.of(Tensai::Types::Instance(Variable))
19
+ )
20
+
21
+ def after_initialize
22
+ raise ArgumentError, 'All variable names must be unique' if variable_names.size < variables.size
23
+ end
24
+
25
+ def accepts?(values)
26
+ Set.new(values.keys) == variable_names &&
27
+ variables.all? { |v| v.accepts? values[v.name] }
28
+ end
29
+
30
+ def inspect
31
+ "(#{name} #{variables.map(&:inspect).join(' ')})"
32
+ end
33
+
34
+ private
35
+
36
+ def variable_names
37
+ @variable_names ||= Set.new(variables.map(&:name))
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tensai/types'
4
+ require 'tensai/util/initializer'
5
+
6
+ require_relative 'entity'
7
+
8
+ module Tensai
9
+ module Logic
10
+ #
11
+ # Variable
12
+ #
13
+ class Variable
14
+ include Util::Initializer.new(
15
+ name: Name,
16
+ type: Tensai::Types::Instance(Class).default { Entity }
17
+ )
18
+
19
+ def accepts?(value)
20
+ return value.type <= type if value.is_a? Variable
21
+
22
+ value.is_a? type
23
+ end
24
+
25
+ def inspect
26
+ "?#{name} - #{type.name.split('::').last}"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tensai
4
+ module Logic
5
+ VERSION = '0.1.1'
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tensai/types'
4
+
5
+ module Tensai
6
+ # Logic and Reasoning
7
+ module Logic
8
+ Name = Types::Strict::Symbol
9
+ end
10
+ end
11
+
12
+ require 'tensai/logic/entity'
13
+ require 'tensai/logic/formula'
14
+ require 'tensai/logic/formulas'
15
+ require 'tensai/logic/predicate'
16
+ require 'tensai/logic/variable'
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'tensai/logic/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'tensai-logic'
9
+ spec.version = Tensai::Logic::VERSION
10
+ spec.authors = ['Kevin Fischer']
11
+ spec.email = ['kfischer_okarin@yahoo.co.jp']
12
+
13
+ spec.summary = 'Logic Framework'
14
+ spec.homepage = 'https://github.com/kfischer-okarin/tensai'
15
+ spec.license = 'MIT'
16
+
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/kfischer-okarin/tensai/tree/master/logic'
20
+ # spec.metadata['changelog_uri'] = 'https://github.com/kfischer-okarin/tensai/CHANGELOG.md'
21
+ else
22
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
23
+ end
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = 'exe'
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ['lib']
33
+
34
+ spec.add_dependency 'tensai-core', '~> 0.1.7'
35
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tensai-logic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Fischer
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-10-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tensai-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.7
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.7
27
+ description:
28
+ email:
29
+ - kfischer_okarin@yahoo.co.jp
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - Guardfile
38
+ - lib/tensai/logic.rb
39
+ - lib/tensai/logic/entity.rb
40
+ - lib/tensai/logic/formula.rb
41
+ - lib/tensai/logic/formulas.rb
42
+ - lib/tensai/logic/formulas/atom.rb
43
+ - lib/tensai/logic/predicate.rb
44
+ - lib/tensai/logic/variable.rb
45
+ - lib/tensai/logic/version.rb
46
+ - tensai-logic.gemspec
47
+ homepage: https://github.com/kfischer-okarin/tensai
48
+ licenses:
49
+ - MIT
50
+ metadata:
51
+ homepage_uri: https://github.com/kfischer-okarin/tensai
52
+ source_code_uri: https://github.com/kfischer-okarin/tensai/tree/master/logic
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.0.6
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Logic Framework
72
+ test_files: []