-
Notifications
You must be signed in to change notification settings - Fork 0
/
LTS.java
59 lines (48 loc) · 1.59 KB
/
LTS.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class LTS {
HashSet<Process> processes;
public LTS(HashSet<Process> processes) {
this.processes = processes;
}
public HashSet<Process> forAll(HashSet<Process> set, char action) {
HashSet<Process> a = (HashSet)this.processes.clone();
for (Process p : processes) {
for (Transition t : p.transitions) {
if (t.action == action) {
if (!set.contains(t.end))
a.remove(p);
}
}
}
return a;
}
public HashSet<Process> exists(HashSet<Process> set, char action) {
HashSet<Process> a = new HashSet<>();
for (Process p : processes) {
for (Transition t : p.transitions) {
if (t.action == action) {
if (set.contains(t.end))
a.add(p);
}
}
}
return a;
}
public HashSet<Process> and(HashSet<Process> set1, HashSet<Process> set2) {
HashSet<Process> out = (HashSet)set1.clone();
out.retainAll(set2);
return out;
}
public HashSet<Process> or(HashSet<Process> set1, HashSet<Process> set2) {
HashSet<Process> out = (HashSet)set1.clone();
out.addAll(set2);
return out;
}
public HashSet<Process> c(HashSet<Process> set) {
HashSet<Process> out = (HashSet)processes.clone();
out.removeAll(set);
return out;
}
}