Skip to content

Commit 7054e81

Browse files
committed
Merge branch 'master' of github.com:mvcisback/py-metric-temporal-logic
2 parents 9933323 + ccaaa6d commit 7054e81

File tree

1 file changed

+59
-40
lines changed

1 file changed

+59
-40
lines changed

README.md

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,58 @@ To begin, we import `mtl`.
3232
import mtl
3333
```
3434

35-
## Propositional logic (using parse api)
35+
There are **two** APIs for interacting with the `mtl` module. Namely, one can specify the MTL expression using:
36+
1. [Python Operators](#python-operator-api).
37+
2. [Strings + The parse API](#string-based-api).
38+
39+
We begin with the Python Operator API:
40+
41+
## Python Operator API
42+
43+
### Propositional logic (using python syntax)
44+
```python
45+
a, b = mtl.parse('a'), mtl.parse('b')
46+
phi0 = ~a
47+
phi1 = a & b
48+
phi2 = a | b
49+
50+
# TODO: add
51+
phi3 = a ^ b
52+
phi4 = a.iff(b)
53+
phi5 = a.implies(b)
54+
```
55+
56+
57+
### Modal Logic (using python syntax)
58+
59+
```python
60+
a, b = mtl.parse('a'), mtl.parse('b')
61+
62+
# Eventually `a` will hold.
63+
phi1 = a.eventually()
64+
65+
# `a & b` will always hold.
66+
phi2 = (a & b).always()
67+
68+
# `a` until `b`
69+
phi3 = a.until()
70+
71+
# `a` weak until `b`
72+
phi4 = a.weak_until(b)
73+
74+
# Whenever `a` holds, then `b` holds in the next two time units.
75+
phi5 = (a.implies(b.eventually(lo=0, hi=2))).always()
76+
77+
# We also support timed until.
78+
phi6 = a.timed_until(b, lo=0, hi=2)
79+
80+
# `a` holds in two time steps.
81+
phi7 = a >> 2
82+
```
83+
84+
## String based API
85+
86+
### Propositional logic (parse api)
3687
```python
3788
# - Lowercase strings denote atomic predicates.
3889
phi0 = mtl.parse('atomicpred')
@@ -49,20 +100,7 @@ phi6 = mtl.parse('~a')
49100
phi7 = mtl.parse('~(a)')
50101
```
51102

52-
## Propositional logic (using python syntax)
53-
```python
54-
a, b = mtl.parse('a'), mtl.parse('b')
55-
phi0 = ~a
56-
phi1 = a & b
57-
phi2 = a | b
58-
59-
# TODO: add
60-
phi3 = a ^ b
61-
phi4 = a.iff(b)
62-
phi5 = a.implies(b)
63-
```
64-
65-
## Modal Logic (parser api)
103+
### Modal Logic (parser api)
66104

67105
```python
68106
# Eventually `x` will hold.
@@ -90,34 +128,15 @@ phi6 = mtl.parse('(a U[0, 2] b)')
90128
phi7 = mtl.parse('XX a')
91129
```
92130

93-
## Modal Logic (using python syntax)
94131

95-
```python
96-
a, b = mtl.parse('a'), mtl.parse('b')
97-
98-
# Eventually `a` will hold.
99-
phi1 = a.eventually()
100-
101-
# `a & b` will always hold.
102-
phi2 = (a & b).always()
103-
104-
# `a` until `b`
105-
phi3 = a.until()
106-
107-
# `a` weak until `b`
108-
phi4 = a.weak_until(b)
109-
110-
# Whenever `a` holds, then `b` holds in the next two time units.
111-
phi5 = (a.implies(b.eventually(lo=0, hi=2))).always()
132+
## Boolean Evaluation
112133

113-
# We also support timed until.
114-
phi6 = a.timed_until(b, lo=0, hi=2)
134+
Given a property `phi`, one can evaluate is a timeseries satisifies `phi`. Time Series can either be
135+
defined using a dictionary mapping atomic predicate names to lists of (`time`, `val`) pairs **or** using
136+
the [DiscreteSignals](https://github.com/mvcisback/DiscreteSignals) API (used internally).
115137

116-
# `a` holds in two time steps.
117-
phi7 = a >> 2
118-
```
138+
There are two types of evaluation. One uses the boolean semantics of MTL and the other uses Signal Temporal Logic like semantics.
119139

120-
## Boolean Evaluation
121140
```python
122141
# Assumes piece wise constant interpolation.
123142
data = {
@@ -139,7 +158,7 @@ print(phi(data, dt=0.2, quantitative=False))
139158
# output: True
140159
```
141160

142-
## Quantitative Evaluate
161+
## Quantitative Evaluate (Signal Temporal Logic)
143162
```python
144163
# Assumes piece wise constant interpolation.
145164
data = {

0 commit comments

Comments
 (0)