Project

quus

0.0
No release in over 3 years
A Ruby gem that implements Saul Kripke's philosophical 'quus' operation, demonstrating the problem of rule-following. The quus function (⊕) behaves like addition for small numbers but returns a constant for larger values.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 2.0
~> 13.0
~> 3.0
 Project Readme

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)    # => 6

Kripke's Famous Example

# For arguments ≤ 57, quus behaves like plus
57  57  # => 114

# But for larger arguments, it returns 5
68  57  # => 5

Configuration

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.