Skip to content
This repository has been archived by the owner on Oct 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6 from marcofavorito/develop
Browse files Browse the repository at this point in the history
Release 0.2.1
  • Loading branch information
marcofavorito authored Oct 9, 2019
2 parents 6584556 + 23a4f1b commit dae78aa
Show file tree
Hide file tree
Showing 22 changed files with 878 additions and 598 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ matrix:
include:
- python: 3.7
env: TOXENV=py37
- python: 3.7
env: TOXENV=flake8
# - python: 3.7
# env: TOXENV=flake8
# - python: 3.7
# env: TOXENV=mypy
- python: 3.7
Expand Down
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@
## 0.2.0 (2019-10-06)

* Main refactoring of the package. No new features.

## 0.2.1 (2019-10-09)

* Replace parsing library PLY with [Lark](https://github.com/lark-parser/lark).
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ include CONTRIBUTING.md
include HISTORY.md
include LICENSE
include README.md
include Pipfile
include Pipfile.lock

recursive-include flloat *
recursive-include tests *

recursive-exclude * __pycache__
recursive-exclude * *.py[co]

Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ mkdocs = "*"
markdown-include = "*"

[packages]
ply = "*"
pythomata = "==0.2.0"
lark-parser = "*"

[requires]
python_version = "3.7"
15 changes: 7 additions & 8 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 51 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A Python implementation of the [FLLOAT](https://github.com/RiccardoDeMasellis/FL


* Free software: Apache 2.0 license
* Documentation: https://marcofavorito.github.io/flloat/
* Documentation: [https://marcofavorito.github.io/flloat/](https://marcofavorito.github.io/flloat/)

## Dependencies

Expand All @@ -26,65 +26,57 @@ to get all the needed dependencies.
## Install

- from [PyPI](https://pypi.org/project/flloat/):

pip install flloat

```
pip install flloat
```
- or, from source (`master` branch):

pip install git+https://github.com/marcofavorito/flloat.git

```
pip install git+https://github.com/marcofavorito/flloat.git
```

- or, clone the repository and install:

git clone htts://github.com/marcofavorito/flloat.git
cd flloat
pip install .

pip install .

```
git clone htts://github.com/marcofavorito/flloat.git
cd flloat
pip install .
```
## How to use

* Parse a LDLf formula:

```python
from flloat.parser.ldlf import LDLfParser

from flloat.parser.ldlf import LDLfParser

parser = LDLfParser()
formula_string = "<true*; A & B>tt"
formula = parser(formula_string) # returns a LDLfFormula

print(formula) # prints "<((true)* ; (A & B))>(tt)"
print(formula.find_labels()) # prints {A, B}
parser = LDLfParser()
formula_string = "<true*; A & B>tt"
formula = parser(formula_string) # returns a LDLfFormula

print(formula) # prints "<((true)* ; (A & B))>(tt)"
print(formula.find_labels()) # prints {A, B}
```

* Evaluate it over finite traces:

```python

from flloat.semantics.traces import FiniteTrace

t1 = FiniteTrace.from_symbol_sets([
{},
{"A"},
{"A"},
{"A", "B"},
{}
])
formula.truth(t1, 0) # True

from flloat.semantics.traces import FiniteTrace

t1 = FiniteTrace.from_symbol_sets([
{},
{"A"},
{"A"},
{"A", "B"},
{}
])
formula.truth(t1, 0) # True
```

* Transform it into an automaton (``pythomata.DFA`` object):

```python
dfa = formula.to_automaton()

dfa = formula.to_automaton()

# print the automaton
dfa.to_dot("./automaton.DFA")

# print the automaton
dfa.to_dot("./automaton.DFA")
```

Notice: `to_dot` requires [Graphviz](https://graphviz.gitlab.io/download/).
Expand All @@ -93,27 +85,26 @@ For info about how to use a `pythomata.DFA` please look at the [Pythomata docs](
* The same for a LTLf formula:

```python

from flloat.parser.ltlf import LTLfParser
from flloat.semantics.traces import FiniteTrace

# parse the formula
parser = LTLfParser()
formula_string = "F (A & !B)"
formula = parser(formula_string)

# evaluate over finite traces
t1 = FiniteTrace.from_symbol_sets([
{},
{"A"},
{"A"},
{"A", "B"}
])
assert formula.truth(t1, 0)

# from LTLf formula to DFA
dfa = formula.to_automaton()
assert dfa.accepts(t1.trace)
from flloat.parser.ltlf import LTLfParser
from flloat.semantics.traces import FiniteTrace

# parse the formula
parser = LTLfParser()
formula_string = "F (A & !B)"
formula = parser(formula_string)

# evaluate over finite traces
t1 = FiniteTrace.from_symbol_sets([
{},
{"A"},
{"A"},
{"A", "B"}
])
assert formula.truth(t1, 0)

# from LTLf formula to DFA
dfa = formula.to_automaton()
assert dfa.accepts(t1.trace)
```

## Features
Expand Down
Loading

0 comments on commit dae78aa

Please sign in to comment.