Git Product home page Git Product logo

lambda-calculus-telegram-bot's Introduction

λ-Calculus Telegram Bot

@λ-Calculus Bot is a Telegram bot based in a lambda-calculus interpreter created by Alonzo Church.

Features

  • λ-Calculus interpreter
  • Prefix and infix macro support
  • Telegram Bot
  • Graph visualization

Getting Started

Method 1: Try telegram bot

You'll need to have telegram installed and an account. For more information, please visit telegram.org.

You can access the bot through the @lambda_calculus_bot account.

Method 2: Build own telegram bot

1. Install dependencies

The following dependencies are required:

  • python3 version 3.7 or later
  • pip
  • antlr4 version 4.10 or later
  • graphviz
  • telegram

After the installation of those packages, we'll install the following python packages:

pip install antlr4-tools                # version 4.10 or later
pip install antlr4-python3-runtime      # version 4.10 or later
pip install python-telegram-bot         # version 20.0 or later
pip install pydot

2. Get source code

To get the source code, you can simply download the zip file, or you can clone this repository by typing:

git clone https://github.com/BernatBC/Lambda-Calculus-Telegram-Bot.git

3. Setting up a Telegram Bot

Message the Telegram account @BotFather and follow its instructions to create your own bot.

After that, create a file token.txt inside the repository directory and paste the token generated by the @BotFather account.

For more information, please visit the Telegram Bot Guide.

4. Run locally

From the repository directory, run the following command:

python3 achurch.py

Finally, you can chat with the bot created.

Method 3: Execute from terminal

1. Install dependencies

The following dependencies are required:

  • python3 version 3.7 or later
  • pip
  • antlr4

After the installation of those packages, we'll install the following python packages:

pip install antlr4-tools                # version 4.10 or later
pip install antlr4-python3-runtime      # version 4.10 or later

2. Get source code

To get the source code, you can simply download the zip file, or you can clone this repository by typing:

git clone https://github.com/BernatBC/Lambda-Calculus-Telegram-Bot.git

3. Run locally

Finally, from the repository directory, run the following command:

python3 achurch.py terminal

lambda-calculus-telegram-bot's People

Contributors

bernatbc avatar

Watchers

 avatar

lambda-calculus-telegram-bot's Issues

Beta-reduction not working

When input is
N2≡λs.λz.s(s(z))
N3≡λs.λz.s(s(s(z)))
N2 N3
it outputs
(λz.(λz.(((z(z(zz)))((z(z(zz)))((z(z(zz)))(z(z(zz))))))(((z(z(zz)))((z(z(zz)))((z(z(zz)))(z(z(zz))))))(((z(z(zz)))((z(z(zz)))((z(z(zz)))(z(z(zz))))))((z(z(zz)))((z(z(zz)))((z(z(zz)))(z(z(zz)))))))))))

but it should output

λz.λz1.z(z(z(z(z(z(z(z(zz1))))))))

Find limits

There're graph image limit, as well sometimes there's a time limit exception

TO DO: Tasca 5 macros amb notació infixa

En aquesta tasca heu de permetre la definició de macros amb notació infixa. En aquests cas els noms seran símbols no alfabètics i la seva implementació serà similar a les macros amb notació prefixa. Veieu l’exemple següent:
`
? N2≡λs.λz.s(s(z))
N2 ≡ (λs.(λz.(s(sz))))
? N3≡λs.λz.s(s(s(z)))
N2 ≡ (λs.(λz.(s(sz))))
N3 ≡ (λs.(λz.(s(s(sz)))))
? +≡λp.λq.λx.λy.(px(qxy))
N2 ≡ (λs.(λz.(s(sz))))
N3 ≡ (λs.(λz.(s(s(sz)))))

  • ≡ (λp.(λq.(λx.(λy.((px)((qx)y))))))
    ? N2+N3
    Arbre:
    (((λp.(λq.(λx.(λy.((px)((qx)y))))))(λs.(λz.(s(sz)))))(λs.(λz.(s(s(sz))))))
    β-reducció:
    ((λp.(λq.(λx.(λy.((px)((qx)y))))))(λs.(λz.(s(sz))))) → (λq.(λx.(λy.(((λs.(λz.(s(sz))))x)((qx)y)))))
    β-reducció:
    ((λq.(λx.(λy.(((λs.(λz.(s(sz))))x)((qx)y)))))(λs.(λz.(s(s(sz)))))) → (λx.(λy.(((λs.(λz.(s(sz))))x)(((λs.(λz.(s(s(sz)))))x)y))))
    β-reducció:
    ((λs.(λz.(s(sz))))x) → (λz.(x(xz)))
    β-reducció:
    ((λz.(x(xz)))(((λs.(λz.(s(s(sz)))))x)y)) → (x(x(((λs.(λz.(s(s(sz)))))x)y)))
    β-reducció:
    ((λs.(λz.(s(s(sz)))))x) → (λz.(x(x(xz))))
    β-reducció:
    ((λz.(x(x(xz))))y) → (x(x(xy)))
    Resultat:
    (λx.(λy.(x(x(x(x(xy)))))))
    `

Reduct macro

Give an option to reduct a macro.
For example:
N18≡ (((λp.(λq.(λx.(λy.((px)((qx)y))))))(((λp.(λq.(λx.(λy.((px)((qx)y))))))(((λp.(λq.(λx.(λy.((px)((qx)y))))))(λs.(λz.(s(s(sz))))))(λs.(λz.(s(s(sz)))))))(((λp.(λq.(λx.(λy.((px)((qx)y))))))(λs.(λz.(s(s(sz))))))(λs.(λz.(s(s(sz))))))))(((λp.(λq.(λx.(λy.((px)((qx)y))))))(λs.(λz.(s(s(sz))))))(λs.(λz.(s(s(sz)))))))
/reduct N18
N18=(λu.(λo.(u(u(u(u(u(u(u(u(u(u(u(u(u(u(u(u(u(uo))))))))))))))))))))

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.