SINA is a tool to compare two predicates written in Solidity, the smart contract programming language. PreDi determines if two predicates are equivalent or if one is stronger than the other.
- Tokenizes and parses each Solidity predicate into an Abstract Syntax Tree (AST)
- Simplifies AST using symbolic mathematics
- Compare predicates for equivalence and logical strength either using predefined rules (when applicable) or checking for satisfiability when pre-defined rules are not applicable.
Running the following command should suffice:
pip install predi
>>> from predi.comparator import Comparator
>>> comparator = Comparator()
>>> comparator.compare("a < b", "a <= b")
'The first predicate is stronger.'
>>> comparator.compare("a > b", "a <= b")
'The predicates are not equivalent and neither is stronger.'
- Python 3.8 or higher
- Install required packages using pip
pip install -r requirements.txt
To ensure everything is set up correctly, run the unit tests:
python -m unittest discover -s tests
To run an specific test:
python -m unittest tests.test_comparator.TestComparator.test_comparator
You can compare two predicates using the main.py
script. Here's an example:
$ python main.py "msg.sender == msg.origin" "msg.origin == msg.sender"
The predicates are equivalent.
$ python main.py "msg.sender == msg.origin && a >= b" "msg.sender == msg.origin"
The first predicate is stronger.
$ python main.py "msg.sender == msg.origin || a < b" "a < b"
The second predicate is stronger.