# Encoding company-controls_decision-facts.gringo

Name company-controls_decision-facts.gringo [Root]    Unclassified (114)    Company Controls (3) Martin Gebser Martin Gebser and Roland Kaminski A Gringo encoding of Company Controls. (Grounded into facts, but less efficient than Gringo encoding with weight constraints) 2009-03-27 12:58 2009-05-10 18:18 Decision Version of Company Controls checkForMaxControls/1company/1owns/3 controls/2 No No Search (Martin Gebser) number(0..51). pcontrollable(Y) :- company(Y), 51 [ owns(X,Y,N) : owns(X,Y,N) : N > 0 = N ]. own(X,Y,N) :- pcontrollable(Y), owns(X,Y,M), N = [ owns(X,Y,O) : owns(X,Y,O) = O ], 51 > N, N > 0. own(X,Y,51) :- pcontrollable(Y), owns(X,Y,M), N = [ owns(X,Y,O) : owns(X,Y,O) = O ], N > 50. own(X,Y,51) :- owns(X,Z,M), pcontrollable(Y), own(X,Z,51), own(Z,Y,51). owned(X,Y,N) :- own(X,Y,M), N = max [ own(X,Y,O) : own(X,Y,O) = O ]. pcontroller(X) :- owned(X,Y,51). reach(X,Y) :- pcontrollable(X;Y), owned(X,Y,N). reach(X,Y) :- pcontroller(X), pcontrollable(Y), owned(X,Y,N). reach(X,Z) :- pcontroller(X), pcontrollable(Y;Z), owned(X,Y,N), reach(Y,Z). first(X,Y) :- owned(X,Y,M), not owned(W,Y,O) : owned(W,Y,O) : X > W. last(X,Y) :- owned(X,Y,M), not owned(W,Y,O) : owned(W,Y,O) : W > X. prec(X,Z,Y) :- owned(X,Y,M), owned(Z,Y,N), X > Z, not owned(W,Y,O) : owned(W,Y,O) : X > W : W > Z. threshold(X,Y,51) :- pcontroller(X), reach(X,Y), not owned(X,Y,N) : owned(X,Y,N). threshold(X,Y,51-N) :- pcontroller(X), reach(X,Y), owned(X,Y,N), N != 51. has(X,Z,Y,T) :- first(Z,Y), threshold(X,Y,T). has(X,Z,Y,T-N) :- first(Z,Y), threshold(X,Y,T), Z != X, owned(Z,Y,N), controls(X,Z), T-N > 0. has(X,Z,Y,0) :- first(Z,Y), threshold(X,Y,T), Z != X, owned(Z,Y,N), controls(X,Z), 0 >= T-N. has(X,Z,Y,N) :- prec(Z,W,Y), threshold(X,Y,T), has(X,W,Y,N), number(N), T >= N. has(X,Z,Y,N-M) :- prec(Z,W,Y), threshold(X,Y,T), has(X,W,Y,N), number(N), T >= N, Z != X, owned(Z,Y,M), controls(X,Z), N-M > 0. has(X,Z,Y,0) :- prec(Z,W,Y), threshold(X,Y,T), has(X,W,Y,N), number(N), T >= N, Z != X, owned(Z,Y,M), controls(X,Z), 0 >= N-M. controls(X,Y) :- owned(X,Y,51). controls(X,Y) :- last(Z,Y), has(X,Z,Y,0). control(X,N) :- pcontroller(X), N = { controls(X,Y) : controls(X,Y) }. :- checkForMaxControls(X), control(X,N), control(Y,M), M > N. :- checkForMaxControls(X), not pcontroller(X), pcontroller(Y). #hide. #show controls/2.