-
Notifications
You must be signed in to change notification settings - Fork 0
/
inequality.mac
25 lines (17 loc) · 896 Bytes
/
inequality.mac
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
load(graphs);
prefix("~");
"~"(x) := not(x);
matchfix("∩[","]");
∩[x,y] := intersection(setify(x),setify(y));
matchfix("∪[","]");
∪[x,y] := union(setify(x),setify(y));
matchfix("eq[","]");
eq[x,y] := is(equal(x,y));
infix("<<",80,80);
infix(">>",80,80);
"<<"(a,b):= (transitive(b > a), ~emptyp(shortest_path(get_unique_vertex_by_label(string(a),G),get_unique_vertex_by_label(string(b),G),G)));
">>"(a,b):= b << a;
preds(w) := sublist(facts(),lambda([z],~emptyp(∩[listofvars(w),listofvars(z)]) and eq[op(w),op(z)]));
transitive(EQ) := (flatten(map(args,preds(EQ))), G : make_graph(map(string,∪[args(EQ),flatten(map(args,preds(EQ)))]),lambda([w,z],w < z),directed=true), for v in vertices(G) do
for u in vertices(G) do
if eval_string(get_vertex_label(v,G)) < eval_string(get_vertex_label(u,G)) then add_edge([v,u],G),G);