Skip to main content

A computable algorithm for quantifying uncertainty

Project description

Continuous integration

Logical induction in Python

This repository contains code to support the guide to logical induction for software engineers (which has not yet been published). It consists of a straightforward python implementation of the logical induction algorithm published by Garrabrant et al in 2018. I have prioritized simplicity over efficiency.

To run the example code:

$ git clone git@github.com:monasticacademy/logical-induction.git
$ cd logical-induction
$ python examples/two_updates.py

after update 1:
  the sky is blue                          1.000000
  the sky is blue | the sky is green       0.000000

after update 2:
  the sky is green  the world is round    0.000000
  the sky is blue                          0.000000
  the sky is blue | the sky is green       1.000000

Organization of the code

The main interface is the LogicalInductor class in inductor.py:

class LogicalInductor(object):
    ...

    def update(self, observation, trading_algorithm):
        """
        Given: 
         * An observation
         * A trading algorithm
        Return:
         * A belief state
        
        Implements the logical induction algorithm as per 5.4.1 in the paper
        """

The update function takes as input an observation, which is a logical sentence that is to be taken to be true from here on, and a trading algorithm, which is a set of formulas specifying trades to be executed that the logical inductor will set its credences in order to avoid being exploited by.

The representation of logical sentences is implemented in sentence.py and works as follows. The class sentence.Atom represents a claim about the world not further reducible by logical connectives such as AND, OR, NOT. Its constructor takes a string, which can be anything and is only to help humans keep track of what is going on. The other classes in this file implement conjunctions, disjunctions, logical negation, and material implication.

The representation of trading formulas is implemented in formula.py. A trading formula is a simple language for expressing buy/sell trades that a logical inductor must not be exploited by. The classes in this file follow section A.2 from the paper.

The representation of belief states and histories of is in credence.py. A belief state is a map from sentences to credences, and a history of belief states is a list of belief states.

The code in enumerator.py provides various routines for enumerating possible worlds.

The code in example/two_updates.py instantiates a logical inductor and feeds it two observations, printing out the credences it receives in response.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logicalinduction-0.1.6.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logicalinduction-0.1.6-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file logicalinduction-0.1.6.tar.gz.

File metadata

  • Download URL: logicalinduction-0.1.6.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for logicalinduction-0.1.6.tar.gz
Algorithm Hash digest
SHA256 127fcfd535506ee74299ca0e79e16a79354a1217e402e07583e5c7cc763d2374
MD5 8fb4e638abeb33f4ba7bb22696e790b1
BLAKE2b-256 f7f810190a58a65d6c64d78465afb012e9ae562662f64732711277f409039348

See more details on using hashes here.

File details

Details for the file logicalinduction-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for logicalinduction-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9925d4491f406574653ddd5e3cdafc026443b41bdf0480cac1e2bd671963776e
MD5 2e5689eccf7c85ff76afec8a7b7e85bd
BLAKE2b-256 ef2a3912084c7c7ac3721d9b11ba8e296e3215447ad96b7c12f11b3e4fd0ce40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page