Adding allTransitions

This commit is contained in:
elvis
2025-06-12 16:23:39 +02:00
parent 4507b0194f
commit 75c10dc313
4 changed files with 279 additions and 26 deletions

View File

@ -31,9 +31,79 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// -------------------------------------------------------------------------
let env = grammar::EnvironmentParser::new().parse("[x = {a}.{b}.x , y = ({a,c}.y + {b,c}.y)]").unwrap();
let process = grammar::ContextParser::new().parse("[({a}.nil + x + y)]").unwrap();
// let env = grammar::EnvironmentParser::new().parse("[x = {a}.{b}.x , y = ({a,c}.y + {b,c}.y)]").unwrap();
// let process = grammar::ContextParser::new().parse("[({a}.nil + x + y)]").unwrap();
println!("{:?}", rsprocess::transitions::unfold(&env, &process));
// println!("{:?}", rsprocess::transitions::unfold(&env, &process));
// println!("--------------------");
// println!("{:?}", env);
// -------------------------------------------------------------------------
// allTransitions(sys([],[a,b],[],[react([a],[c],[a]),react([b],[d],[b])]) , Moves).
// let env = grammar::EnvironmentParser::new().parse("[]").unwrap();
// let process = grammar::ContextParser::new().parse("[]").unwrap();
// let sys = rsprocess::structure::RSsystem::from(*env,
// rsprocess::structure::RSset::from(vec!["a", "b"]),
// *process,
// vec![
// rsprocess::structure::RSreaction::from(
// rsprocess::structure::RSset::from(vec!["a"]),
// rsprocess::structure::RSset::from(vec!["c"]),
// rsprocess::structure::RSset::from(vec!["a"])
// ),
// rsprocess::structure::RSreaction::from(
// rsprocess::structure::RSset::from(vec!["b"]),
// rsprocess::structure::RSset::from(vec!["d"]),
// rsprocess::structure::RSset::from(vec!["b"])
// )
// ]);
// println!("all_transitions: {:?}", rsprocess::transitions::all_transitions(&sys));
// -------------------------------------------------------------------------
// parse_ctx("[({a}.nil + {b}.nil)]",Ks) , allTransitions(sys([],[],Ks,[react([a],[c],[a]),react([b],[d],[b])]),Moves).
let env = grammar::EnvironmentParser::new().parse("[]").unwrap();
let process = grammar::ContextParser::new().parse("[({a}.nil + {b}.nil)]").unwrap();
let sys = rsprocess::structure::RSsystem::from(*env,
rsprocess::structure::RSset::from(vec![]),
*process,
vec![
rsprocess::structure::RSreaction::from(
rsprocess::structure::RSset::from(vec!["a"]),
rsprocess::structure::RSset::from(vec!["c"]),
rsprocess::structure::RSset::from(vec!["a"])
),
rsprocess::structure::RSreaction::from(
rsprocess::structure::RSset::from(vec!["b"]),
rsprocess::structure::RSset::from(vec!["d"]),
rsprocess::structure::RSset::from(vec!["b"])
)
]);
println!("all_transitions: {:?}", rsprocess::transitions::all_transitions(&sys));
// -------------------------------------------------------------------------
// use std::rc::Rc;
// let mut a = rsprocess::structure::RSChoices::from(vec![
// (Rc::new(rsprocess::structure::RSset::from(vec!["a"])),
// Rc::new(rsprocess::structure::RSprocess::Nill)),
// ]);
// let b = rsprocess::structure::RSChoices::from(vec![
// (Rc::new(rsprocess::structure::RSset::from(vec!["b"])),
// Rc::new(rsprocess::structure::RSprocess::Nill)),
// ]);
// a.shuffle(b);
// println!("shuffle: {:?}", a);
println!("--------------------");
Ok(())
}