https://github.com/qbixxx/lambdacalculusengine
Lambda interpreter built in Scala. Supports CbN, CbV and Free Variables calculations.
https://github.com/qbixxx/lambdacalculusengine
functional functional-programming lambda lambda-calculus lambda-function lambda-functions sbt scala scala3
Last synced: 2 months ago
JSON representation
Lambda interpreter built in Scala. Supports CbN, CbV and Free Variables calculations.
- Host: GitHub
- URL: https://github.com/qbixxx/lambdacalculusengine
- Owner: qbixxx
- License: gpl-3.0
- Created: 2024-05-25T17:51:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-17T11:07:41.000Z (9 months ago)
- Last Synced: 2025-05-07T04:46:16.133Z (2 months ago)
- Topics: functional, functional-programming, lambda, lambda-calculus, lambda-function, lambda-functions, sbt, scala, scala3
- Language: Scala
- Homepage:
- Size: 162 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# λ.Lambda Calculus Engine


Lambda interpreter built in Scala. Supports AST View, CbN, CbV and Free Variables calculations.
## Lambda Expression Symbols available:
- **"λ"**: The lambda symbol represents the beginning of an abstraction.
- **" "**: The space allows for separating the argument from the function in an application.
- **"."**: The dot allows for separating the argument from the body of an abstraction.
- **"("**: The left parenthesis allows for representing the beginning of an application.
- **")"**:" The right parenthesis allows for representing the end of an application.
- **string**: Any other string, different from the ones above, will be interpreted as a variable.## Commands and syntax:
1. `The Lambda expression must follow the syntax structure defined as:`
- `<λexp> ::=`
- `` #Variable
- ` <λexp>` #Abstraction
- ` <λexp> <λexp> ` #Application2. `set `
- `set call-by-name` (default strategy)
- `set call-by-value`
- `set free-variables`3. `exit`
## IO Examples:
| Expression | Call-by-Name Result | Call-by-Value Result |
| ---------- | ------------------- | -------------------- |
| `(λx.λy.y (λx.(x x) λx.(x x)))` | `λy.y` | Infinite recursion |
| `(λx.λx.(y x) z)` | `λx.(y x)` | `λx.(y x)` |
| `(λx.λy.x y)` | `λy*.y` | `λy*.y` |
| `(λy.λb.b ((λf.λb.f b) b))` | `λb*.b*` | `λb*.b*` |
| `(λf.(f λx.λy.x) ((λx.λy.λf.((f x) y) a) b))` | `a` | `a` |## To do:
* Add boolean and arithmetic expressions support## Compilation:
The project uses Scala 3.3.3 and sbt.
For running the program open the sbt interpreter using:
````shell
sbt
````
- Compile with:
````shell
compile
````
- And execute with:
````shell
run
````
- For exiting the program:
````shell
exit
````## Demo run:
Note: If you run the project on Windows, use the symbol "/" instead of the symbol "λ" as PowerShell does not support it.