/lambda-haskell

Primary LanguageHaskellOtherNOASSERTION

Lambda Calculus Interpreter

This project is a Lambda Calculus Interpreter implemented in Haskell. It allows you to parse Lambda Calculus expressions from strings, evaluate them, and perform various operations on them. The interpreter supports both standard Lambda Calculus expressions as well as Church numerals and predefined encodings.

Features

  • Parsing: Parse Lambda Calculus expressions from strings using a parser implemented with Parsec library.
  • Evaluation: Evaluate Lambda Calculus expressions using a nameless representation and reduction rules.
  • Church Numerals: Support for Church numerals, including parsing and evaluation.
  • Predefined Encodings: Support for predefined encodings such as succ, pred, plus, sub, true, false, and, or, and not.
  • Error Handling: Handle parsing errors and invalid expressions gracefully.

Getting Started

To get started with the Lambda Calculus Interpreter, follow these steps:

  1. Clone the Repository: Clone this repository to your local machine using the following command:

    git clone https://github.com/your_username/lambda-calculus-interpreter.git
  2. Navigate to the Project Directory: Change directory to the project folder:

    cd lambda-calculus-interpreter
  3. Build and Run: Build and run the project using the Haskell compiler (GHC):

    stack build
  4. Input Lambda Expressions: Enter Lambda Calculus expressions when prompted and observe the evaluation results.

Usage

The Lambda Calculus Interpreter provides a simple command-line interface for interacting with Lambda Calculus expressions. Upon running the Main executable, you'll be prompted to input Lambda Calculus expressions. You can enter expressions using standard Lambda Calculus syntax or use predefined encodings such as succ, pred, etc.

Here's an example of how to run the interpreter:

stack ghci
ghci> repl
> (@true @true) @false
Result: (LAMBDA t'. (LAMBDA f'. t'))
> (@or @false) @true
Result: (LAMBDA t'. (LAMBDA f'. t'))
> quit
Exiting
ghci> 

Upon running the interpreter, you'll see a prompt where you can enter Lambda Calculus expressions:

Enter a Lambda Calculus expression:

Enter your expression at the prompt and press Enter. The interpreter will then parse and evaluate the expression, displaying the result.