- Clone the repository
git clone git@github.com:icsofteng/iprove.git
- Run
npm install
to sync the dependencies. - Run
npm install -g nodemon
to install the node.js watcher
cd /usr/local/lib
sudo curl -O http://www.antlr.org/download/antlr-4.7.1-complete.jar
export CLASSPATH=".:/usr/local/lib/antlr-4.7.1-complete.jar:$CLASSPATH"
alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.7.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
alias grun='java org.antlr.v4.gui.TestRig'
- In one terminal window, run
nodemon server.js
. - In another terminal, run
npm run build-dev
. - To run the tests, run
npm test
- Rename
src/parser/iProveVisitor.js
temporarily tovisitor.js
- Run
antlr4 -Dlanguage=JavaScript -visitor src/parser/iProve.g4
- Delete
src/parser/iProveVisitor.js
- Rename
src/parser/visitor.js
toiProveVisitor.js
{ type: 'literal', value: true } (assert true)
{ type: 'literal', value: false } (assert false)
{ type: 'literal', value: 'P' } (assert P)
{ type: 'binary', symbol: 'implies', lhs: expr1, rhs: expr2 } (assert (=> expr1 expr2))
{ type: 'binary', symbol: 'iff', lhs: expr1, rhs: expr2 } (assert (iff expr1 expr2))
{ type: 'binary', symbol: 'and', lhs: expr1, rhs: expr2 } (assert (and expr1 expr2))
{ type: 'binary', symbol: 'or', lhs: expr1, rhs: expr2 } (assert (or expr1 expr2))
{ type: 'unary', symbol: 'not', value: expr } (assert (not expr))
{ type: 'assume', value: expr } (assert (expr))
First Order:
{ type: 'quantifier', symbol: 'forall', variable: 'x', value: expr} (assert (forall ((x Type)) (expr)))
{ type: 'quantifier', symbol: 'exists', variable: 'x', value: expr} (assert (exists ((x Type)) (expr)))
{ type: 'variable', value: 'x'} x
{ type: 'relation', name: 'animal', params: [{variable|constant}]} (animal x y)
{ type: 'constant', value: 'Frank' } Frank
Funcdef:
e.g.
define friends(Person, Person): Bool
{type:'funcDef', name:'friends', params:[{type: 'type', value: 'Person'}, {type: 'type', value: 'Person'}], returnType: {type:'type', value: 'Bool'}}
(declare-fun friends (Person Person) Bool)
let John, Bob: Person
friends(John, Bob)
Types for Quantifier:
forall x:Int (positive(x) <=> nonzero(x))
{ type: 'quantifier', symbol: 'forall', variable: {type:variable, value:x, varType:Int}, value: expr}
forall x:Int forall y:human forall z:money (Store(x,y) <=> make(z))
- Print
declare-sort Type
- Loop through
relations
and foreach print(declare-fun name (Type (, Type)*) Bool)
- Loop through
constants
and foreach print(declare-const [symbol] Type)
- Loop through
literals
and foreach print(declare-const [symbol] Bool)
- Loop through rules and print
(assert [rule])
- Negate final rule
- End with (check-sat)
- Response "unsat" if goal is true