ct(initializeEmptyNode, ( not(emptyNode(_)) ),( add(emptyNode(_)) )). ct(registerService(S), ( serviceNode(S), upStateRelation(R,S,S) %not(fieldDefT(FLAG , CLASS, _, 'flag', _)), %new_id(R),new_id(S) ),( %replace(upStateRelation(R,S,S),activeStateRelation(R,S,S)) delete(upStateRelation(R,S,S)), add(activeStateRelation(_a,S,S)) %add(fieldDefT(FLAG , CLASS, type(basic, int, 0), 'flag', null)) )). ct(unregisterService(S), ( serviceNode(S), activeStateRelation(A,S,S), not( serviceNode(S2), backupStateRelation(_b,S,S2) ) ),( delete(activeStateRelation(A,S,S)), add(upStateRelation(_u,S,S)) )). ct(standbyService(A,U), ( serviceNode(A), serviceNode(U), A \= U, upStateRelation(Ru,U,U), activeStateRelation(_a,A,A), not( backupStateRelation(B,A,U) ) %new_id(B) ),( delete(upStateRelation(Ru,U,U)), add(standbyStateRelation(_s,U,U)), add(backupStateRelation(B,A,U)) )). ct(detachService(A,S), ( serviceNode(A), serviceNode(S), A \= S, standsyStateRelation(Rs,S,S), activeStateRelation(_a,A,A), backupStateRelation(B,A,S) %new_id(B) ),( delete(backupStateRelation(B,A,S)), delete(standbyStateRelation(Rs,S,S)), add(upStateRelation(_u,S,S)) )). ct(failoverService(D,S), ( serviceNode(D), serviceNode(S), D \= S, standbyStateRelation(Rs,S,S), downStateRelation(_d,D,D), backupStateRelation(B,D,S) ),( delete(standbyStateRelation(Rs,S,S)), delete(backupStateRelation(B,D,S)), add(activeStateRelation(_a,S,S)) )). ct(powerOnService(E), ( emptyNode(E) ),( add(serviceNode(A)), add(upStateRelation(_,A,A)), delete(emptyNode(E)) )). % let's say we can only have 6 services %not( % serviceNode(S1), % serviceNode(S2), % S1 \= S2, % serviceNode(S3), % S1 \= S3, S2 \= S3, % serviceNode(S4), % S1 \= S4, S2 \= S4, S3 \= S4, % serviceNode(S5), % S1 \= S5, S2 \= S5, S3 \= S5, S4 \= S5, % serviceNode(S6), % S1 \= S6, S2 \= S6, S3 \= S6, S4 \= S6, S5 \= S6 %) ct(removeService(D), ( serviceNode(D), downStateRelation(Rd,D,D), not( serviceNode(S), D \= S, backupStateRelation(_,D,S) ) ),( delete(downStateRelation(Rd,D,D)), delete(serviceNode(D)), add(emptyNode(_)) )). open_world_cts([ powerOnService,standbyService,detachService,failoverService, registerService,unregisterService,removeService,initializeEmptyNode ]).