pub struct ELTLSpecificationBuilder<'a, T: ThresholdAutomaton> {
ta: &'a T,
properties: Vec<ELTLProperty>,
}Expand description
Builder for building an ELTLSpecification over a threshold automaton
§Example
use taco_threshold_automaton::general_threshold_automaton::builder::GeneralThresholdAutomatonBuilder;
use taco_threshold_automaton::expressions::{IntegerExpression, ComparisonOp, Location, Variable};
use taco_model_checker::eltl::{ELTLExpression, ELTLSpecificationBuilder};
let ta = GeneralThresholdAutomatonBuilder::new("test_ta1")
.with_variables(vec![
Variable::new("var1"),
Variable::new("var2"),
Variable::new("var3"),
])
.unwrap()
.with_locations(vec![
Location::new("loc1"),
Location::new("loc2"),
])
.unwrap()
.initialize()
.build();
let mut builder = ELTLSpecificationBuilder::new(&ta);
let expr1 = ELTLExpression::LocationExpr(
Box::new(IntegerExpression::Atom(Location::new("loc1"))),
ComparisonOp::Eq,
Box::new(IntegerExpression::Const(2)),
);
let expr2 = ELTLExpression::LocationExpr(
Box::new(IntegerExpression::Atom(Location::new("loc2"))),
ComparisonOp::Eq,
Box::new(IntegerExpression::Const(0)),
);
builder.add_expressions(vec![
("spec1".to_string(), expr1),
("spec2".to_string(), expr2),
]).unwrap();
let spec = builder.build();
assert_eq!(spec.expressions().len(), 2);
assert!(spec.expressions().iter().any(|(name, _)| name == "spec1"));
assert!(spec.expressions().iter().any(|(name, _)| name == "spec2"));Fields§
§ta: &'a TThreshold automaton associated with the expressions
properties: Vec<ELTLProperty>Collection of tuples of expression names and the ELTL expression
Implementations§
Source§impl<T: ThresholdAutomaton> ELTLSpecificationBuilder<'_, T>
impl<T: ThresholdAutomaton> ELTLSpecificationBuilder<'_, T>
Sourcefn check_for_unknown_identifier<S>(
&self,
expr: &IntegerExpression<S>,
) -> Result<(), InternalELTLExpressionBuilderError>where
S: Atomic,
Self: IsDeclared<S>,
fn check_for_unknown_identifier<S>(
&self,
expr: &IntegerExpression<S>,
) -> Result<(), InternalELTLExpressionBuilderError>where
S: Atomic,
Self: IsDeclared<S>,
Check if all identifiers in the expression are known
Returns () if no unknown identifier is found, otherwise the name of
the unknown identifier
Sourcefn check_contains_parameter_expression(
expr: &ELTLExpression,
) -> Result<(), InternalELTLExpressionBuilderError>
fn check_contains_parameter_expression( expr: &ELTLExpression, ) -> Result<(), InternalELTLExpressionBuilderError>
Check whether an ELTL expression contains a parameter expression
Sourcefn replace_trivial_expressions(expr: ELTLExpression) -> ELTLExpression
fn replace_trivial_expressions(expr: ELTLExpression) -> ELTLExpression
Replaces parameter expressions that do not contain parameters
Sourcefn validate_property(
&self,
expr: &ELTLExpression,
) -> Result<(), InternalELTLExpressionBuilderError>
fn validate_property( &self, expr: &ELTLExpression, ) -> Result<(), InternalELTLExpressionBuilderError>
Check if all atoms in the expression are known in the threshold automaton associated with the builder and that all location expressions are valid
Sourcepub fn add_expression(
&mut self,
name: String,
expr: ELTLExpression,
) -> Result<(), ELTLExpressionBuilderError>
pub fn add_expression( &mut self, name: String, expr: ELTLExpression, ) -> Result<(), ELTLExpressionBuilderError>
Add a new ELTL expression to the specification
This function checks if all atoms in the expression are known in the threshold automaton associated with the builder. If an unknown atom is found, an error is returned. Otherwise the expression is added to the specification.
This function also returns an error if the name of the expression is already used in the specification.
Sourcepub fn add_expressions(
&mut self,
expressions: impl IntoIterator<Item = ELTLProperty>,
) -> Result<(), ELTLExpressionBuilderError>
pub fn add_expressions( &mut self, expressions: impl IntoIterator<Item = ELTLProperty>, ) -> Result<(), ELTLExpressionBuilderError>
Add multiple ELTL expressions to the specification
This function checks if all atoms in the expression are known in the threshold automaton associated with the builder. If an unknown atom is found, an error is returned. Otherwise the expression is added to the specification.
This function also returns an error if the name of the expression is already used in the specification.
Sourcepub fn build(self) -> ELTLSpecification
pub fn build(self) -> ELTLSpecification
Build the ELTL specification
Returns the ELTL specification containing all added expressions
Trait Implementations§
Source§impl<T: ThresholdAutomaton> IsDeclared<Location> for ELTLSpecificationBuilder<'_, T>
impl<T: ThresholdAutomaton> IsDeclared<Location> for ELTLSpecificationBuilder<'_, T>
Source§fn is_declared(&self, obj: &Location) -> bool
fn is_declared(&self, obj: &Location) -> bool
Source§impl<T: ThresholdAutomaton> IsDeclared<Parameter> for ELTLSpecificationBuilder<'_, T>
impl<T: ThresholdAutomaton> IsDeclared<Parameter> for ELTLSpecificationBuilder<'_, T>
Source§fn is_declared(&self, obj: &Parameter) -> bool
fn is_declared(&self, obj: &Parameter) -> bool
Source§impl<T: ThresholdAutomaton> IsDeclared<Variable> for ELTLSpecificationBuilder<'_, T>
impl<T: ThresholdAutomaton> IsDeclared<Variable> for ELTLSpecificationBuilder<'_, T>
Source§fn is_declared(&self, obj: &Variable) -> bool
fn is_declared(&self, obj: &Variable) -> bool
Auto Trait Implementations§
impl<'a, T> Freeze for ELTLSpecificationBuilder<'a, T>
impl<'a, T> RefUnwindSafe for ELTLSpecificationBuilder<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for ELTLSpecificationBuilder<'a, T>where
T: Sync,
impl<'a, T> Sync for ELTLSpecificationBuilder<'a, T>where
T: Sync,
impl<'a, T> Unpin for ELTLSpecificationBuilder<'a, T>
impl<'a, T> UnwindSafe for ELTLSpecificationBuilder<'a, T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more