Crates.io | telo |
lib.rs | telo |
version | 0.1.0 |
source | src |
created_at | 2022-09-17 11:53:16.072401 |
updated_at | 2022-09-17 11:53:16.072401 |
description | Temporal specifications in Rust |
homepage | |
repository | https://github.com/ltentrup/telo |
max_upload_size | |
id | 668146 |
size | 69,249 |
With telo, you can specify temporal properties using linear-time temporal logic (LTL). Those specifications can be transformed into monitoring automata, which can detect violations of safety specifications during runtime.
use telo::{*, predicate::*, monitor::*};
// Step 1: define predicates
const LIMIT: i32 = 123;
let mut builder = Predicates::builder();
let above_limit = builder.new_predicate(ClosurePredicate::new(
|val: &i32| *val >= LIMIT,
"value is above LIMIT",
));
let predicates = builder.build();
// Step 2: define temporal specification
let property = Property::never(Property::atomic(above_limit));
// Step 3: transform to monitoring automaton
let automaton = property.to_monitoring_automaton(&predicates);
// Step 4: runtime monitoring
let mut monitor = Monitor::new(predicates, automaton);
for value in 0..LIMIT {
assert!(monitor.next_state(&value));
}
assert!(!monitor.next_state(&LIMIT)); // the property is violated
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.