Code Monkey home page Code Monkey logo

pylambda's Introduction

pylambda: a lambda calculus interpreter written in python

1. Dependencies
---------------

pylamdbda relies on PLY (Python Lex Yacc). 
You can find it at http://www.dabeaz.com/ply/
or install with 
$ pip3 install ply


2. Running the interpreter
--------------------------

From your shell, type 

$ make run

and you will enter the pylambda interpreter, whose prompt consist
of three '>', just like the python shell.
Time to play:

>>> (\x.x)
(\x.x)

So, what happened here? We have entered the term (\x.x) ('\' is an
alias for 'lambda') and we got the same term back. If you think about it,
(\x.x) is in 'normal form', so it cannot be 'reduced'.

Let's try with something more complicated:

>>>((\x.xx))(\a.az)z
(\x.xx)(\a.az)z  ->  (\a.az)z(\a.az)z
(\a.az)z(\a.az)z  ->  zz(\a.zz)z
zz(\a.zz)z  ->  zzzz
zzzz

Here, the interpreter picked up the expression we entered and 'reduced'
it to its 'normal form', via a multi-step 'beta reduction'. 
As one can notice, the choice of the 'redex' to reduce at every step
is made following a 'leftmost-outermost' strategy.


3. Future work
--------------

pylambda is in its very early stages. It needs

- better handling of lexical and syntax errors
- a suite of tests
- some *good* doc

Moreover, it would be nice to provide, with the next releases,
support for the following stuff:

- alpha-conversion
- church numerals
- typed lambda calculus

pylambda's People

Contributors

kid-a avatar simoncourtenage avatar charles-fox avatar

Stargazers

 avatar Rimmer avatar kashio2021 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.