Skip to main content

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.

Metadata

Release files for logicalinduction 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for logicalinduction 0.1.6
File Size Uploaded Provenance
logicalinduction-0.1.6.tar.gz 15.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for logicalinduction 0.1.6
File Interpreter ABI Platform
logicalinduction-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 31.5 kB

Release files / logicalinduction-0.1.6.tar.gz

Download URL logicalinduction-0.1.6.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
127fcfd535506ee74299ca0e79e16a79354a1217e402e07583e5c7cc763d2374
BLAKE2b-256 checksum
How to use checksums
f7f810190a58a65d6c64d78465afb012e9ae562662f64732711277f409039348
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.7

Release files / logicalinduction-0.1.6-py3-none-any.whl

Download URL logicalinduction-0.1.6-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9925d4491f406574653ddd5e3cdafc026443b41bdf0480cac1e2bd671963776e
BLAKE2b-256 checksum
How to use checksums
ef2a3912084c7c7ac3721d9b11ba8e296e3215447ad96b7c12f11b3e4fd0ce40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.7

Security for logicalinduction 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page