Skip to content
Snippets Groups Projects
Commit 17382b39 authored by Cookiebowser's avatar Cookiebowser
Browse files

fixed bug in brelation

parent 947fb1f9
No related branches found
No related tags found
No related merge requests found
...@@ -350,6 +350,8 @@ impl<L, const LS: usize, R, const RS: usize, const REL_SIZE: usize> BRelation<L, ...@@ -350,6 +350,8 @@ impl<L, const LS: usize, R, const RS: usize, const REL_SIZE: usize> BRelation<L,
for left_idx in 0..LS { for left_idx in 0..LS {
for right_idx in 0..RS { for right_idx in 0..RS {
if other.rel[left_idx][right_idx] && !self.rel[left_idx][right_idx] { return false; } if other.rel[left_idx][right_idx] && !self.rel[left_idx][right_idx] { return false; }
// if self/left side contains an element that other/right side does not -> self not subset of other
if self.rel[left_idx][right_idx] && !other.rel[left_idx][right_idx] { return false; }
} }
} }
return true; return true;
......
...@@ -18,6 +18,11 @@ public class TestRelation extends TestRSE { ...@@ -18,6 +18,11 @@ public class TestRelation extends TestRSE {
testRSE("Range", "RangeAddition.strs"); testRSE("Range", "RangeAddition.strs");
} }
@Test
public void testSubset() throws Exception {
testRSE("RelationSubset", "RelationSubsetAddition.strs");
}
@Test @Test
public void testId() throws Exception { public void testId() throws Exception {
testRSE("Id", "IdAddition.strs"); testRSE("Id", "IdAddition.strs");
......
MACHINE RelationSubset
SETS FOO = {F1, F2, F3, F4}
VARIABLES r1, r2, res
INVARIANT
r1 : FOO <-> FOO
& r2 : FOO <-> FOO
& res : BOOL
INITIALISATION
r1 := {F1 |-> F2, F3 |-> F2}
; r2 := {F1 |-> F2, F2 |-> F4, F3 |-> F2, F3 |-> F4}
; res := FALSE
OPERATIONS
calculate = BEGIN IF r1 <: r2 THEN res := TRUE ELSE res := FALSE END END;
out <-- getRes = out := res
END
\ No newline at end of file
true
\ No newline at end of file
fn main() {
let mut machine = RelationSubset::new();
machine.calculate();
println!("{}", machine.getRes());
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment