Quus
A Ruby implementation of Saul Kripke's "quus" function from Wittgenstein on Rules and Private Language.
What is Quus?
In Kripke's famous thought experiment, he introduces the "quus" function (⊕) to illustrate the problem of rule-following:
x ⊕ y = x + y, if x, y ≤ 57
otherwise 5
This gem brings this philosophical concept to Ruby, allowing you to explore the distinction between "plus" and "quus" in your code.
Installation
Add this line to your application's Gemfile:
gem 'quus'And then execute:
$ bundle install
Or install it yourself as:
$ gem install quus
Usage
Basic Usage
require 'quus'
# Using the ⊕ operator (Kripke's notation)
68 ⊕ 57 # => 5
2 ⊕ 4 # => 6
# Using the method form
68.quus(57) # => 5
2.quus(4) # => 6
# Using the module method
Quus.quus(68, 57) # => 5
Quus.quus(2, 4) # => 6Kripke's Famous Example
# For arguments ≤ 57, quus behaves like plus
57 ⊕ 57 # => 114
# But for larger arguments, it returns 5
68 ⊕ 57 # => 5Configuration
You can customize the limit and constant values:
Quus.configure do |config|
config.quus_limit = 100 # Change the limit from 57 to 100
config.quus_constant = 10 # Change the constant from 5 to 10
end
68 ⊕ 57 # => 125 (now adds because both ≤ 100)
101 ⊕ 50 # => 10 (returns the new constant)
# Reset to defaults
Quus.reset_configuration!Experimental: Change the Game
For a dramatic demonstration of the indistinguishability between "plus" and "quus", you can temporarily replace the + operator:
# WARNING: This modifies Integer#+ globally within the block!
Quus.change_game do
68 + 57 # => 5 (plus becomes quus!)
2 + 4 # => 6
end
68 + 57 # => 125 (back to normal)Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests.
To install this gem onto your local machine, run bundle exec rake install.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/a5-stable/quus.
License
The gem is available as open source under the terms of the MIT License.