Giter Club home page Giter Club logo

lambda's Introduction

lambda - an educational lambda calculus language

lambda is a programming language purely based on the (untyped) lambda calculus and its beta-reduction.

Installation

Installation can (and should) be done with stack, so stack must be installed prior. If you are on Linux, you can install stack via your distributions package manager, on macOS it can be installed via brew and for windows there exists a dedicated installer. See https://docs.haskellstack.org/en/stable/install_and_upgrade/ for detailed instructions.

Next clone the repository (or download and extract it somewhere)

# clone
git clone https://github.com/christofsteel/lambda.git

Now enter the cloned repository lambda and install it (If you downloaded the zip you have to enter the extracted folder. It is usually called lambda-master)

cd lambda
stack init
stack install

Running

There are three ways to run lambda

  1. Call with a file
lambda -f examples/exampleA.l
  1. Call with a string
lambda "let I=\x.x; printNF I I"
  1. Open a REPL
lambda -r

See lambda --help for a complete list of arguments

Terms

The basic syntax for creating term is,

  • any alphanumeric string is a variable. In addition the ' and the _ symbol are allowed. (e.g. a, x', 8, ab_8) The _ symbol on its own is no Variable
  • a \ followed by one or more variables, then a . and another term is an abstraction. (e.g. \x.x, \x y.x)
  • a (Space) denotes the abstraction. (e.g. p q, (\x.x.) q), p q s)

Parentheses are optional. If they are not present, the binding of operators follow the usual conventions for lambda calculus.

Other Commands

To form a program you can use the following commands

Command Description
import File Imports a file and executes it
let Variable = Term Defines a Variable to be expanded to a Term in later commands
print Text Prints Text without a newline
printLN Text Prints Text with a newline
printT Term Prints the definition of a Term
printNF Term Calculates the normal form for a Term and prints it
printNFMax Int Term As printNF but only computes a given number of steps
traceNF Term Calculates the normal form for a Term and prints every step
traceNFMax Int Term As traceNF but only computes a given number of steps
step Variable Applies beta reduction on the term stored in the Variable
set Option Value Sets an Option to a Value (see below)
get Option Prints the value for an Option
addRev Variable Notes, that terms corresponding to the Variable will be printed as the Variable, not as the Term
delRev Variable Removes the Variable from the above list
showRev Shows all variables, that will not be shown as lambdaterms

Configuration

The following Options exist and can be set with set

Option Possible Values Default Value Descrition
utf8 True, False False Show a real lambda, beta and arrow
explicit True, False False Shows every parentheses
pnat True, False True Interpret natural numbers as church numerals
rnat True, False False If a Term looks like a church numeral, show the number
ps1 Any String LAMBDA Prompt to show in REPL mode
steps Any natural number 100 Steps to calculate in REPL mode

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.