Simple python3 implementation of microKanren with lots of type annotations for clarity

Overview

MicroKanren-py

This is (yet another) python implementation of microKanren. It's a reasonably 1:1 translation of the code provided in the paper, but everything has type annotations to make it more obvious what data is being passed around and how.

Running

  • clone the repo, cd into it
  • $ poetry install

Tests

$ poetry run pytest

REPL

$ poetry run python

>>> from microkanren import *
You might also like...
Micropython-wifimanager-esp8266 - Simple Wifi Manager for ESP8266 using MicroPython

micropython-wifimanager-esp8266 Simple Wifi Manager for ESP8266 using MicroPytho

A simple program to make MSI Modern 15 speaker and microphone mute led work.

MSI Modern 15 sound led fixup for linux A simple program to fix the MSI Modern 15 speaker and microphone mute LEDs. Installation Requirements pulsectl

Simple Microservice to control 433Mhz wireless sockets over HTTP, e.g. on a RaspberryPi
Simple Microservice to control 433Mhz wireless sockets over HTTP, e.g. on a RaspberryPi

REST-light is a simple microservice to control 433Mhz wireless sockets over HTTP, e.g. on a RaspberryPi. The main usage is an easy integration of 433M

Detic ros - A simple ROS wrapper for Detic instance segmentation using pre-trained dataset
Detic ros - A simple ROS wrapper for Detic instance segmentation using pre-trained dataset

Detic ros - A simple ROS wrapper for Detic instance segmentation using pre-trained dataset

A simple portable USB MIDI controller based on Raspberry-PI Pico and a 16-button keypad, written in Circuit Python

RPI-Pico-16-BTn-MIDI-Controller-using-CircuitPython A simple portable USB MIDI controller based on Raspberry-PI Pico, written in Circuit Python. Link

Code and build instructions for Snap, a simple Raspberry Pi and LED machine to show you how expensive the electricyty is at the moment

Code and build instructions for Snap, a simple Raspberry Pi and LED machine to show you how expensive the electricyty is at the moment. On row of LEDs shows the cost of the hour, the other row the cost of the day.

A simple non-official manager interface I'm using for my Raspberry Pis.
A simple non-official manager interface I'm using for my Raspberry Pis.

My Raspberry Pi Manager Overview I have two Raspberry Pi 4 Model B devices that I hooked up to my two TVs (one in my bedroom and the other in my new g

Pihole-eink-display - A simple Python script to display PiHole statistics on an eInk Display
Pihole-eink-display - A simple Python script to display PiHole statistics on an eInk Display

Pihole-eink-display - A simple Python script to display PiHole statistics on an eInk Display

Doughskript interpreter for converting simple command sequences into executable Arduino C++ code.

Doughskript interpreter for converting simple command sequences into executable Arduino C++ code.

Comments
  • fix: concurrent fresh calls should create distinct vars

    fix: concurrent fresh calls should create distinct vars

    latest improvements broke fresh when we have concurrent calls with the same names:

    conj(
        fresh(lambda x: eq(x, 'hello')),
        fresh(lambda x: eq(x, 'bye')),
    )
    

    The two lambdas should create distinct variables so we should end up with two substitutions with the first x == 'hello', second x == 'bye'

    opened by davidrusu 0
  • Use meaningful names in the substitutions

    Use meaningful names in the substitutions

    As it stands, terms are given unique numeric values to avoid collisions, but this makes parsing the results a bit difficult since we have to reverse-engineer which fresh was called first.

    We can use pythons inspect module to pull out the parameter names from the functions passed to fresh.

    This pr still appends the counter to the names to ensure we keep each term fresh, but we could be smarter to avoid appending a counter if this is the first time we've seen a name.

    I also modified fresh to allow for multiple new terms introduced at once

    opened by davidrusu 0
  • bug in `fresh`

    bug in `fresh`

    Example:

    disj(
        fresh (lambda x: conj(
            eq(x,0), 
            eq(x,1))), 
        fresh(lambda x: eq(x,2)))({})
    

    Expected behaviour: we should get a result of {x2: 2}

    Instead, we get {x: 2}. The way fresh currently works, there would be no valid solutions coming out of the first conj so it wouldn't know about any of the xs. I think we have to keep a running list of variables the whole way through like in the original paper, but maybe a set of names instead of the counter they use. We could also be clever and use a collections.Counter to save the lookup time?

    opened by Erik-J-D 0
Owner
Erik Derohanian
Erik Derohanian
A module for cross-platform control of the mouse and keyboard in python that is simple to install and use.

PyUserInput PyUserInput is a group project so we've moved the project over to a group organization: https://github.com/PyUserInput/PyUserInput . That

Paul Barton 1k Dec 27, 2022
Simple Python script to decode and verify an European Health Certificate QR-code

A simple Python script to decode and verify an European Health Certificate QR-code.

Mathias Panzenböck 61 Oct 5, 2022
This is a Virtual Keyboard which is simple yet effective to use.

Virtual-Keyboard This is a Virtual KeyBoard which can track finger movements and lets you type anywhere ranging from notepad to even web browsers. It

Jehan Patel 3 Oct 1, 2021
A simple Python script for toggling Philips Hue Lights by clapping

LightsClap A simple Python script for toggling Philips Hue Lights by clapping Usage pip3 install -r requirements.txt python3 main.py and press the Ent

Flux Industries 2 Nov 16, 2021
A Simple Python KeyLogger App

✨ Kurulum Uygulamayı bilgisayarınızda kullana bilmek için bazı işlemler yapmanız gerekiyor. Aşağıdaki yönlendirmeleri takip ederek bunu yapabilirsiniz

VorteX 7 Jun 11, 2022
A simple Picobot project implemented in Python

Python-Picobot A simple Picobot project implemented in Python About Explanation This is my first programming project. Picobot use rules.txt file which

Shayan Shiravani 0 Apr 3, 2022
Simple Weather Check base on Hefeng api, Work on raspberry Pi

Simple Weather Check base on Hefeng api, Work on raspberry Pi

Retr0mous 28 Sep 17, 2022
A simple small scale electric car was build which can be driven by remote control and features a fully autonomous parking procedure.

personal-autonomous-parking-car-raspberry A simple electric car model was build using Raspbery pi. The car has remote control and autonomous operation

Kostas Ziovas 2 Jan 26, 2022
This application works with serial communication. Use a simple gui to send and receive serial data from arduino and control leds and motor direction

This application works with serial communication. Use a simple gui to send and receive serial data from arduino and control leds and motor direction

ThyagoKZKR 2 Jul 18, 2022
PyLog - Simple keylogger that uses pynput to listen to keyboard input.

Simple keylogger that uses pynput to listen to keyboard input. Outputs to a text file and the terminal. Press the escape key to stop.

null 1 Dec 29, 2021