Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Operation;
- enum LTLFormula {
- BinOp(Operation, Box<LTLFormula>, Box<LTLFormula>),
- UnaryOp(Operation, Box<LTLFormula>),
- Terminal(String),
- }
- struct Automaton<'a> {
- subformulas: Vec<&'a LTLFormula>,
- combinations: Vec<usize>,
- graph: Graph,
- }
- struct Graph {
- nodes: Vec<Node>,
- }
- struct Node {
- subformulas: usize,
- neighbors: Vec<usize>,
- }
- impl Node {
- fn iter_terminals<'a>(&self, a: &'a Automaton) -> impl Iterator<Item=&'a str> {
- materialize_subformulas(&a.subformulas, self.subformulas).filter_map(|x| match x {
- LTLFormula::Terminal(s) => Some(s.as_str()),
- _ => None,
- })
- }
- }
- fn decompose_formula<'a>(f: &'a LTLFormula) -> impl Iterator<Item=&'a LTLFormula> {
- unimplemented!();
- Vec::new().into_iter()
- }
- fn is_cool<'a>(x: impl Iterator<Item=&'a LTLFormula>) -> bool {
- unimplemented!();
- }
- impl<'a> Automaton<'a> {
- fn new(full_formula: &'a LTLFormula) -> Self {
- let subformulas: Vec<_> = decompose_formula(full_formula).collect();
- let combinations: Vec<_> = make_combinations(subformulas.len())
- .filter(|&x| is_cool(materialize_subformulas(&subformulas, x))).collect();
- let nodes = combinations.iter().map(|&x| {
- let neighbors = combinations.iter().enumerate().filter(|(_, &y)| is_connected(&subformulas, x, y)).map(|(i, _)| i).collect();
- Node {
- subformulas: x,
- neighbors,
- }
- }).collect();
- let graph = Graph { nodes };
- Automaton {
- subformulas,
- combinations,
- graph,
- }
- }
- }
- fn is_connected(subformulas: &Vec<<LFormula>, combinations_a: usize, combinations_b: usize) -> bool {
- unimplemented!();
- }
- fn make_combinations(number_of_subformulas: usize) -> impl Iterator<Item=usize> {
- let max = 1 << number_of_subformulas;
- (0..max)
- }
- fn materialize_subformulas<'a>(subformulas: &'a Vec<&'a LTLFormula>, index: usize) -> impl Iterator<Item=&'a LTLFormula> {
- subformulas.iter().cloned().enumerate().filter(move |(i, x)| {
- (index & (1usize << i)) != 0
- }).map(|(_, x)| x)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement