GithubHelp home page GithubHelp logo

dizys / nyu-ai-lab-2 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 37 KB

NYU Artificial Intelligence Course Lab 2: A BNF to CNF converter and generic DPLL solver

License: MIT License

Python 97.82% ANTLR 0.89% Makefile 0.95% Shell 0.33%
python bnf-parser bnf-to-cnf dpll-solver antlr4

nyu-ai-lab-2's Introduction

nyu-ai-lab-2

NYU Artificial Intelligence Course Lab 2: A BNF to CNF converter and generic DPLL solver. BNF parser is built with ANTLR4.

This implementation properly handles grouping (()) and symbol _ in atom's names.

Prerequisite

  • Python 3.8+

Getting-started

Switch to Python 3.8 on CIMS machines

The Python version has to at least have full type hint support, thus requiring Python 3.8+.

module load python-3.8

If successful, the command python3 --version should give you:

$ python3 --version
Python 3.8.6

Install dependencies/packages

Install Python packages used in this lab by running the following command:

pip3 install -r requirements.txt

or if you want to specify ANTLR4 runtime manually:

pip3 install antlr4-python3-runtime==4.9.3

Script usages

The main entrance is a python script, not a binary. It is in Shebang style, thus can be executed directly.

Use ./solver -h command to see the usage:

usage: solver [-h] [-v] -m MODE inputfile

A BNF to CNF converter and DPLL solver.

positional arguments:
  inputfile             input file path

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         verbose output
  -m MODE, --mode MODE  solver mode, should be one of "cnf", "dpll" or
                        "solver"

Examples:

$ ./solver -m cnf input.txt
$ ./solver -m dpll -v input.txt
$ ./solver -m solver -v input.txt

Project structure

project
├─solving                       solving python module
│  ├─bnf_parser                     BNF parser python module
│  │  ├─__init__.py                     Module initialization
│  │  ├─bnf_listener.py                 BNF parser tree walk listener
│  │  ├─bnf_node.py                     BNF parser output custom tree node
│  │  ├─bnf_tree.py                     Function to call parser and generate tree
│  │  ├─BNFLexer.py                     BNF lexer generated by ANTLR4
│  │  └─BNFParser.py                    BNF parser generated by ANTLR4
│  │
│  ├─__init__.py                    Module initialization
│  ├─bnf.py                         Text/CNF converter and BNF to CNF converter
│  └─dpll.py                        DPLL solver
│
├─solver                        Main entrance python script (shebang style)
├─requirements.txt              Python packages used in this project
└─README.md                     The file you're reading

nyu-ai-lab-2's People

Contributors

dizys avatar

Watchers

 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.