now working bisimilarity
This commit is contained in:
@ -1,21 +1,11 @@
|
|||||||
use std::collections::{BTreeSet, HashMap};
|
use std::collections::{BTreeSet, HashMap};
|
||||||
|
|
||||||
use petgraph::visit::{EdgeIndexable, EdgeRef, IntoEdgeReferences, IntoEdges, IntoNodeReferences, NodeIndexable};
|
use petgraph::visit::{ EdgeIndexable,
|
||||||
|
EdgeRef,
|
||||||
|
IntoEdgeReferences,
|
||||||
|
IntoEdges,
|
||||||
|
IntoNodeReferences,
|
||||||
|
NodeIndexable };
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn print_type_of<T>(_: &T) {
|
|
||||||
println!("type: {}", std::any::type_name::<T>());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct GraphPartition<'a, G>
|
struct GraphPartition<'a, G>
|
||||||
where
|
where
|
||||||
@ -30,6 +20,25 @@ where
|
|||||||
blocks: BTreeSet<u32>
|
blocks: BTreeSet<u32>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn equal_vectors<T>(a: &Vec<T>, b: &Vec<T>) -> bool
|
||||||
|
where
|
||||||
|
T: PartialEq
|
||||||
|
{
|
||||||
|
for el in a {
|
||||||
|
if !b.contains(el) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for el in b {
|
||||||
|
if !a.contains(el) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, G> GraphPartition<'a, G>
|
impl<'a, G> GraphPartition<'a, G>
|
||||||
where
|
where
|
||||||
G: EdgeIndexable + NodeIndexable + IntoEdgeReferences + IntoNodeReferences
|
G: EdgeIndexable + NodeIndexable + IntoEdgeReferences + IntoNodeReferences
|
||||||
@ -74,12 +83,13 @@ where
|
|||||||
&self,
|
&self,
|
||||||
label: &G::EdgeRef,
|
label: &G::EdgeRef,
|
||||||
s: &(usize, G::NodeId)
|
s: &(usize, G::NodeId)
|
||||||
) -> Vec<(usize, G::NodeId)>
|
) -> Vec<u32>
|
||||||
where <G as IntoEdgeReferences>::EdgeRef: PartialEq
|
where <G as IntoEdgeReferences>::EdgeRef: PartialEq
|
||||||
{
|
{
|
||||||
let mut val = vec![];
|
let mut val = vec![];
|
||||||
for el in self.graphs[s.0].edges(s.1).filter(|x| x == label) {
|
for el in self.graphs[s.0].edges(s.1).filter(|x| x == label) {
|
||||||
val.push((s.0, el.target()));
|
let tmp = (s.0, el.target());
|
||||||
|
val.push(*self.node_to_block.get(&tmp).unwrap());
|
||||||
}
|
}
|
||||||
val
|
val
|
||||||
}
|
}
|
||||||
@ -99,15 +109,13 @@ where
|
|||||||
|
|
||||||
let reachable_blocks_s = self.reachable_blocks(label, s);
|
let reachable_blocks_s = self.reachable_blocks(label, s);
|
||||||
|
|
||||||
'outer: for t in nodes {
|
for t in nodes {
|
||||||
let reachable_blocks_t = self.reachable_blocks(label, t);
|
let reachable_blocks_t = self.reachable_blocks(label, t);
|
||||||
for rbt in reachable_blocks_t {
|
if equal_vectors(&reachable_blocks_s, &reachable_blocks_t) {
|
||||||
if !reachable_blocks_s.contains(&rbt) {
|
b1.push(t);
|
||||||
b2.push(*t);
|
} else {
|
||||||
continue 'outer;
|
b2.push(*t);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
b1.push(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if b2.is_empty() {
|
if b2.is_empty() {
|
||||||
|
|||||||
@ -11,8 +11,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Basic set of entities.
|
/// Basic set of entities.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize,
|
#[derive(Clone, Debug, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||||
Deserialize)]
|
|
||||||
pub struct RSset {
|
pub struct RSset {
|
||||||
pub identifiers: BTreeSet<IdType>,
|
pub identifiers: BTreeSet<IdType>,
|
||||||
}
|
}
|
||||||
@ -118,6 +117,12 @@ impl Default for RSset {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for RSset {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.identifiers.eq(&other.identifiers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl IntoIterator for RSset {
|
impl IntoIterator for RSset {
|
||||||
type Item = IdType;
|
type Item = IdType;
|
||||||
type IntoIter = std::collections::btree_set::IntoIter<Self::Item>;
|
type IntoIter = std::collections::btree_set::IntoIter<Self::Item>;
|
||||||
@ -491,7 +496,7 @@ impl Default for RSsystem {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// RSlabel
|
// RSlabel
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd)]
|
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialOrd)]
|
||||||
pub struct RSlabel {
|
pub struct RSlabel {
|
||||||
pub available_entities: RSset,
|
pub available_entities: RSset,
|
||||||
pub context: RSset,
|
pub context: RSset,
|
||||||
@ -555,6 +560,19 @@ impl Default for RSlabel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for RSlabel {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.available_entities == other.available_entities &&
|
||||||
|
self.context == other.context &&
|
||||||
|
self.t == other.t &&
|
||||||
|
self.reactants == other.reactants &&
|
||||||
|
self.reactants_absent == other.reactants_absent &&
|
||||||
|
self.inhibitors == other.inhibitors &&
|
||||||
|
self.inhibitors_present == other.inhibitors_present &&
|
||||||
|
self.products == other.products
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// RSassertOp
|
// RSassertOp
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@ -4,4 +4,4 @@ Context: [({a,b}.{a}.{a,c}.x + {a,b}.{a}.{a}.nill)]
|
|||||||
Reactions: ([{a,b}, {c}, {b}])
|
Reactions: ([{a,b}, {c}, {b}])
|
||||||
|
|
||||||
|
|
||||||
Bisimilarity ("testing/adversarial.system") > Print
|
Bisimilarity ("testing/first.system") > Print
|
||||||
|
|||||||
Reference in New Issue
Block a user