You selected power.pl

% power indecies for sged06.pl
% date: 2007.5.6

swing(L->W,J) :- 
   winning(W),
   select(J,W,L),
   % j(J), subtract(W,[J],L),  % an alternative code 
   loosing(L).


inspect_swing:-
   %write('game:'),
   %display_win,
   j(J),
   nl,
   write(agent:J),
   swing(S,J),
   nl,
   write(S),
   fail.

inspect_swing:-
   nl,
   write('complete').


/*

?- [sged06].
% sged06 compiled 0.00 sec, 336 bytes

Yes
?- make_n_agents(3).

Yes
?- model(A,B).

A = states:[a, b, c]
B = agents:[1, 2, 3] 

Yes
?- gen_win(W,[monotonic:yes,proper:yes]),verify_win,
   inspect_swing,nl,fail.

game:[[1, 2, 3], [1, 2], [1, 3], [1]]
 + :[monotonic, proper, strong]
 - :[weak(vetoers):[1], inessential(dictator):1]
agent:1
[2, 3]->[1, 2, 3]
[2]->[1, 2]
[3]->[1, 3]
[]->[1]
agent:2
agent:3
complete

game:[[1, 2, 3], [1, 2], [1, 3], [2, 3]]
 + :[monotonic, proper, strong, not weak, essential]
 - :[]
agent:1
[2]->[1, 2]
[3]->[1, 3]
agent:2
[1]->[1, 2]
[3]->[2, 3]
agent:3
[1]->[1, 3]
[2]->[2, 3]
complete

game:[[1, 2, 3], [1, 2], [1, 3]]
 + :[monotonic, proper, essential]
 - :[not strong:[1], weak(vetoers):[1]]
agent:1
[2, 3]->[1, 2, 3]
[2]->[1, 2]
[3]->[1, 3]
agent:2
[1]->[1, 2]
agent:3
[1]->[1, 3]
complete

game:[[1, 2, 3], [1, 2], [2, 3], [2]]
 + :[monotonic, proper, strong]
 - :[weak(vetoers):[2], inessential(dictator):2]
agent:1
agent:2
[1, 3]->[1, 2, 3]
[1]->[1, 2]
[3]->[2, 3]
[]->[2]
agent:3
complete

game:[[1, 2, 3], [1, 2], [2, 3]]
 + :[monotonic, proper, essential]
 - :[not strong:[1, 3], weak(vetoers):[2]]
agent:1
[2]->[1, 2]
agent:2
[1, 3]->[1, 2, 3]
[1]->[1, 2]
[3]->[2, 3]
agent:3
[2]->[2, 3]
complete

game:[[1, 2, 3], [1, 2]]
 + :[monotonic, proper, essential]
 - :[not strong:[1, 3], weak(vetoers):[1, 2]]
agent:1
[2, 3]->[1, 2, 3]
[2]->[1, 2]
agent:2
[1, 3]->[1, 2, 3]
[1]->[1, 2]
agent:3
complete

game:[[1, 2, 3], [1, 3], [2, 3], [3]]
 + :[monotonic, proper, strong]
 - :[weak(vetoers):[3], inessential(dictator):3]
agent:1
agent:2
agent:3
[1, 2]->[1, 2, 3]
[1]->[1, 3]
[2]->[2, 3]
[]->[3]
complete

game:[[1, 2, 3], [1, 3], [2, 3]]
 + :[monotonic, proper, essential]
 - :[not strong:[1, 2], weak(vetoers):[3]]
agent:1
[3]->[1, 3]
agent:2
[3]->[2, 3]
agent:3
[1, 2]->[1, 2, 3]
[1]->[1, 3]
[2]->[2, 3]
complete

game:[[1, 2, 3], [1, 3]]
 + :[monotonic, proper, essential]
 - :[not strong:[1, 2], weak(vetoers):[1, 3]]
agent:1
[2, 3]->[1, 2, 3]
[3]->[1, 3]
agent:2
agent:3
[1, 2]->[1, 2, 3]
[1]->[1, 3]
complete

game:[[1, 2, 3], [2, 3]]
 + :[monotonic, proper, essential]
 - :[not strong:[1, 2], weak(vetoers):[2, 3]]
agent:1
agent:2
[1, 3]->[1, 2, 3]
[3]->[2, 3]
agent:3
[1, 2]->[1, 2, 3]
[2]->[2, 3]
complete

game:[[1, 2, 3]]
 + :[monotonic, proper, essential]
 - :[not strong:[1, 2], weak(vetoers):[1, 2, 3]]
agent:1
[2, 3]->[1, 2, 3]
agent:2
[1, 3]->[1, 2, 3]
agent:3
[1, 2]->[1, 2, 3]
complete

No
?-

*/


pivotal(L->W,J,'to win') :- 
   swing(L->W,J).

pivotal(W->L,J,'to loose') :- 
   loosing(L),
   select(J,L,W),
   % j(J), subtract(L,[J],W),  % an alternative code
   winning(W).

inspect_pivotal:-
   %write('game:'),
   %display_win,
   j(J),
   nl,
   write(agent:J),
   pivotal(S,J,T),
   nl,
   write(S:T),
   fail.

inspect_pivotal:-
   nl,
   write('complete').

/*

?- gen_win(W,[monotonic:no(I),proper:yes,strong:yes]),verify_win,
inspect_pivotal,nl,fail.

game:[[1, 2, 3], [1, 2], [1], [2]]
 + :[proper, strong, not weak, essential]
 - :[nonmonotonic: ([1], [1, 3])]
agent:1
([2, 3]->[1, 2, 3]):to win
([]->[1]):to win
agent:2
([1, 3]->[1, 2, 3]):to win
([]->[2]):to win
agent:3
([1]->[1, 3]):to loose
([2]->[2, 3]):to loose
complete

game:[[1, 2, 3], [1, 3], [1], [3]]
 + :[proper, strong, not weak, essential]
 - :[nonmonotonic: ([1], [1, 2])]
agent:1
([2, 3]->[1, 2, 3]):to win
([]->[1]):to win
agent:2
([1]->[1, 2]):to loose
([3]->[2, 3]):to loose
agent:3
([1, 2]->[1, 2, 3]):to win
([]->[3]):to win
complete

game:[[1, 2, 3], [1], [2], [3]]
 + :[proper, strong, not weak, essential]
 - :[nonmonotonic: ([1], [1, 2])]
agent:1
([2, 3]->[1, 2, 3]):to win
([]->[1]):to win
([2]->[1, 2]):to loose
([3]->[1, 3]):to loose
agent:2
([1, 3]->[1, 2, 3]):to win
([]->[2]):to win
([1]->[1, 2]):to loose
([3]->[2, 3]):to loose
agent:3
([1, 2]->[1, 2, 3]):to win
([]->[3]):to win
([1]->[1, 3]):to loose
([2]->[2, 3]):to loose
complete

game:[[1, 2, 3], [2, 3], [2], [3]]
 + :[proper, strong, not weak, essential]
 - :[nonmonotonic: ([2], [1, 2])]
agent:1
([2]->[1, 2]):to loose
([3]->[1, 3]):to loose
agent:2
([1, 3]->[1, 2, 3]):to win
([]->[2]):to win
agent:3
([1, 2]->[1, 2, 3]):to win
([]->[3]):to win
complete

No
?- 

*/



% unanimity-based coalition formation
%--------------------------------------------------------------

unanimity_in_coalition_for_xy(strict,S, RN,(X,Y)):-
   agents(N),
   rr(RN),
   coalition(S),
   b((X,Y)), % pair of alternatives
   % check preference profile restricted to the coalition 
   \+ (
     nth1(K,RN,RJ),
     nth1(K,N,J),
     member(J,S),
     \+ p((X,Y),RJ)
   ).


unanimity_in_coalition_for_xy(weak,S, RN,(X,Y)):-
   agents(N),
   rr(RN),
   coalition(S),
   b((X,Y)), % pair of alternatives
   % check preference profile restricted to the coalition 
   \+ (
     nth1(K,RN,RJ),
     nth1(K,N,J),
     member(J,S),
     \+ r((X,Y),RJ)
   ).

% Above two are equivalent either if the ordering is linear or
% if the simple game is proper and strong (See Gaertner, p.40).

% demo

/*

?- display_domain.

current domain: ACITZN
[base domain=l:linear]

Yes
?- unanimity_in_coalition_for_xy(strict,S, RN,XY).

S = [1, 2, 3]
RN = [[+, +, +], [+, +, +], [+, +, +]]
XY = a, b ;

S = [1, 2, 3]
RN = [[+, +, +], [+, +, +], [+, +, +]]
XY = a, c ;

Yes
?- 

*/



%--------------------------------------------------------------
% the cores of a simple game / effectivity function
%--------------------------------------------------------------
% the core <--d the set of undominated outcomes based on unanimity.

:- dynamic mode_dominance/2.

mode_dominance( win(weak), off).
mode_dominance( win(strict), on).
%mode_dominance( eff, off).

swap_mode_dominance(A->B):-
   switch_mode_dominance(A->B).

enforce_mode_dominance(B):-
   mode_dominance(B,off),
   switch_mode_dominance(_->B),
   !.

enforce_mode_dominance(B):-
   mode_dominance(B,on).

switch_mode_dominance(A->B):-
   retract( mode_dominance( A, on)),
   retract( mode_dominance( B, off)),
   assert( mode_dominance( A, off)),
   assert( mode_dominance( B, on)).


% dominance (or blocking) relations and cores
% of a simple game / effectivity function
%--------------------------------------------------------------

x_dominates_y_via(win(strict), (X,Y),C,RN):-
   win(C,yes),
   unanimity_in_coalition_for_xy(strict,C,RN,(X,Y)).

x_dominates_y_via(win(weak), (X,Y),C,RN):-
   win(C,yes),
   unanimity_in_coalition_for_xy(weak,C,RN,(X,Y)).
%  % additional
%   \+ \+ (member(R,RN),p((X,Y),R)).

x_dominates_y_via(eff, (B,Y),C,RN):-
   eff(C,B),
   B \=[],
   x(Y),
   \+ member(Y,B),
   (var(RN)->rr( RN);true),
   forall(
     member(X,B),
     unanimity_in_coalition_for_xy(weak,C,RN,(X,Y))
%     unanimity_in_coalition_for_xy(strict,C,RN,(X,Y))
   ).

x_dominates_y_via((X,Y),C,RN):-
   mode_dominance( T, on),
   x_dominates_y_via(T, (X,Y),C,RN).

x_dominates_y((X,Y),RN):-
   mode_dominance( win(T), on),
   dop((X,Y)),
   (var(RN)->rr( RN);true),
   \+ \+ x_dominates_y_via(win(T),(X,Y),_,RN).

x_dominates_y((B,Y),RN):-
   mode_dominance( eff, on),
   event(B,_),
   x(Y),
   (var(RN)->rr( RN);true),
   \+ \+ x_dominates_y_via(eff,(B,Y),_,RN).

% undominates/2 
% sensitive to the background mode effectiveness parameter

undominated_alt(Y,RN):-
   x(Y),
   rr(RN),
   \+ x_dominates_y((_,Y),RN).



% The cores
%--------------------------------------------------------------

core(C, RN):-
   rr( RN),
   findall( X, undominated_alt(X, RN), C).

core(weak, C, RN):- core(C, RN).

core(strong, C, RN):- strong_core(C, RN).


inspect_empty_core:-
   forall((core([],RN),nl,write(RN:'=>')),
    (
     forall(member(R,RN),
      (
       id_r(_:A,R),write(A))
      )
    )
   ).

inspect_all_empty_core(L):-
   findall(RN,core([],RN),L).

inspect_all_empty_core_sorted(L0):-
   findall(R0,(core([],RN),sort(RN,R0)),L),
   sort(L,L0).

inspect_empty_core_sorted:-
   inspect_all_empty_core_sorted(L0),
   forall((member(RN,L0),nl,write(RN:'=>')),
    (
     forall(member(R,RN),
      (
       id_r(_:A,R),write(A))
      )
    )
   ).


inspect_value_restriction(X,T,RN) :-
   x(X), value_type(T),
   \+ (
     member(R,RN),
     value(T:X,(a,b,c),R)
   )
   ->
   write('=> not':T:X)
   ;
   write('=> a latin square').


/*

?- display_domain.

current domain: ACITZN
[base domain=l:linear]

Yes
?- mode_dominance(A,on).

A = win(strict) 

Yes
?- gen_win(W,[monotonic:yes,proper:yes,strong:yes]),\+ \+ core([],_),
verify_win, inspect_empty_core,nl,fail.

game:[[1, 2, 3], [1, 2], [1, 3], [2, 3]]
 + :[monotonic, proper, strong, not weak, essential]
 - :[]
[[+, -, -], [-, -, +], [+, +, +]]: =>ZIA
[[-, -, +], [+, -, -], [+, +, +]]: =>IZA
[[-, -, -], [+, +, -], [-, +, +]]: =>NTC
[[+, +, -], [-, -, -], [-, +, +]]: =>TNC
[[+, -, -], [+, +, +], [-, -, +]]: =>ZAI
[[+, +, +], [+, -, -], [-, -, +]]: =>AZI
[[-, -, -], [-, +, +], [+, +, -]]: =>NCT
[[-, +, +], [-, -, -], [+, +, -]]: =>CNT
[[-, -, +], [+, +, +], [+, -, -]]: =>IAZ
[[+, +, +], [-, -, +], [+, -, -]]: =>AIZ
[[+, +, -], [-, +, +], [-, -, -]]: =>TCN
[[-, +, +], [+, +, -], [-, -, -]]: =>CTN

No
?- name_domain('ZIA',L).

L = [[+, -, -], [-, -, +], [+, +, +]] 

Yes
?- name_domain('NTC',L).

L = [[-, -, -], [+, +, -], [-, +, +]] 

Yes
?- A is 12/(6^3).

A = 0.0555556 

Yes
?- gen_win(W,[monotonic:yes,proper:yes,strong:yes]),\+ \+ core([],_),
verify_win,core([],RN),nl,write(RN),
inspect_value_restriction(X,T,RN),
fail.

game:[[1, 2, 3], [1, 2], [1, 3], [2, 3]]
 + :[monotonic, proper, strong, not weak, essential]
 - :[][[+, -, -], [-, -, +], [+, +, +]]
[[-, -, +], [+, -, -], [+, +, +]]=> a latin square
[[-, -, -], [+, +, -], [-, +, +]]=> a latin square
[[+, +, -], [-, -, -], [-, +, +]]=> a latin square
[[+, -, -], [+, +, +], [-, -, +]]=> a latin square
[[+, +, +], [+, -, -], [-, -, +]]=> a latin square
[[-, -, -], [-, +, +], [+, +, -]]=> a latin square
[[-, +, +], [-, -, -], [+, +, -]]=> a latin square
[[-, -, +], [+, +, +], [+, -, -]]=> a latin square
[[+, +, +], [-, -, +], [+, -, -]]=> a latin square
[[+, +, -], [-, +, +], [-, -, -]]=> a latin square
[[-, +, +], [+, +, -], [-, -, -]]=> a latin square

No
?- switch_mode_dominance(A).

A = win(strict)->win(weak) 

Yes
?- display_domain.

current domain: ACITZN
[base domain=l:linear]

Yes
?- gen_win(W,[monotonic:yes,proper:yes,strong:yes]),\+ \+ core([],_),
verify_win,core([],RN),nl,write(RN),
inspect_value_restriction(X,T,RN),
fail.

game:[[1, 2, 3], [1, 2], [1, 3], [2, 3]]
 + :[monotonic, proper, strong, not weak, essential]
 - :[]
[[+, -, -], [-, -, +], [+, +, +]]=> a latin square
[[-, -, +], [+, -, -], [+, +, +]]=> a latin square
[[-, -, -], [+, +, -], [-, +, +]]=> a latin square
[[+, +, -], [-, -, -], [-, +, +]]=> a latin square
[[+, -, -], [+, +, +], [-, -, +]]=> a latin square
[[+, +, +], [+, -, -], [-, -, +]]=> a latin square
[[-, -, -], [-, +, +], [+, +, -]]=> a latin square
[[-, +, +], [-, -, -], [+, +, -]]=> a latin square
[[-, -, +], [+, +, +], [+, -, -]]=> a latin square
[[+, +, +], [-, -, +], [+, -, -]]=> a latin square
[[+, +, -], [-, +, +], [-, -, -]]=> a latin square
[[-, +, +], [+, +, -], [-, -, -]]=> a latin square

No
?- 

?- chdom(A),display_domain.

current domain: ABCFIJOSTWZnN
[base domain=t:transitive]

A = l:linear->t:transitive 

Yes
?- switch_mode_dominance(A).

A = win(weak)->win(strict) 

Yes
?- gen_win(W,[monotonic:yes,proper:yes,strong:yes]),\+ \+ core([],_),
verify_win,
    inspect_all_empty_core(L),length(L,N),A is N/(14^3).

game:[[1, 2, 3], [1, 2], [1, 3], [2, 3]]
 + :[monotonic, proper, strong, not weak, essential]
 - :[]

W = [[1, 2, 3], [1, 2], [1, 3], [2, 3]]
L = [[[+, -, -], [-, -, +], [+, +, +]], [[-, -, +], [+, -, -], [+, +, +]], [[-, -, -], [+, +, -], [-, +, +]], [[+, +, -], [-, -, -], [-, +|...]], [[+, -, -], [+, +|...], [-|...]], [[+, +|...], [+|...], [...|...]], [[-|...], [...|...]|...], [[...|...]|...], [...|...]|...]
N = 12
A = 0.00437318 

Yes
?- switch_mode_dominance(A).

A = win(strict)->win(weak) 

Yes
?- gen_win(W,[monotonic:yes,proper:yes,strong:yes]),\+ \+ core([],_),
verify_win,
    inspect_all_empty_core(L),length(L,N),A is N/(14^3).

game:[[1, 2, 3], [1, 2], [1, 3], [1]]
 + :[monotonic, proper, strong]
 - :[weak(vetoers):[1], inessential(dictator):1]

W = [[1, 2, 3], [1, 2], [1, 3], [1]]
L = [[[0, +, +], [+, +, +], [+, +, +]], [[0, 0, 0], [+, +, +], [+, +, +]], [[-, -, 0], [+, +, +], [+, +, +]], [[+, 0, -], [+, +, +], [+, +|...]], [[0, +, +], [0, +|...], [+|...]], [[0, 0|...], [0|...], [...|...]], [[-|...], [...|...]|...], [[...|...]|...], [...|...]|...]
N = 676
A = 0.246356 ;

game:[[1, 2, 3], [1, 2], [1, 3], [2, 3]]
 + :[monotonic, proper, strong, not weak, essential]
 - :[]

W = [[1, 2, 3], [1, 2], [1, 3], [2, 3]]
L = [[[0, +, +], [0, +, +], [+, +, +]], [[-, +, +], [0, +, +], [+, +, +]], [[-, 0, +], [0, +, +], [+, +, +]], [[-, -, +], [0, +, +], [+, +|...]], [[0, 0, 0], [0, +|...], [+|...]], [[-, -|...], [0|...], [...|...]], [[0|...], [...|...]|...], [[...|...]|...], [...|...]|...]
N = 1090
A = 0.39723 ;

game:[[1, 2, 3], [1, 2], [2, 3], [2]]
 + :[monotonic, proper, strong]
 - :[weak(vetoers):[2], inessential(dictator):2]

W = [[1, 2, 3], [1, 2], [2, 3], [2]]
L = [[[+, +, +], [0, +, +], [+, +, +]], [[0, +, +], [0, +, +], [+, +, +]], [[-, +, +], [0, +, +], [+, +, +]], [[-, 0, +], [0, +, +], [+, +|...]], [[-, -, +], [0, +|...], [+|...]], [[+, +|...], [0|...], [...|...]], [[0|...], [...|...]|...], [[...|...]|...], [...|...]|...]
N = 676
A = 0.246356 ;

game:[[1, 2, 3], [1, 3], [2, 3], [3]]
 + :[monotonic, proper, strong]
 - :[weak(vetoers):[3], inessential(dictator):3]

W = [[1, 2, 3], [1, 3], [2, 3], [3]]
L = [[[+, +, +], [+, +, +], [0, +, +]], [[0, +, +], [+, +, +], [0, +, +]], [[-, +, +], [+, +, +], [0, +, +]], [[-, 0, +], [+, +, +], [0, +|...]], [[-, -, +], [+, +|...], [0|...]], [[+, +|...], [+|...], [...|...]], [[0|...], [...|...]|...], [[...|...]|...], [...|...]|...]
N = 676
A = 0.246356 ;

No
?- 


?- chdom(A->q:B),display_domain.

current domain: ABCEFIJKMOPRSTWXZnN
[base domain=q:quasi-transitive]

A = t:transitive
B = quasi-transitive 

Yes
?- switch_mode_dominance(A).

A = win(weak)->win(strict) 

Yes
?- gen_win(W,[monotonic:yes,proper:yes,strong:yes]),\+ \+ core([],_),
verify_win,
    inspect_all_empty_core(L),length(L,N),A is N/(19^3).

game:[[1, 2, 3], [1, 2], [1, 3], [2, 3]]
 + :[monotonic, proper, strong, not weak, essential]
 - :[]

W = [[1, 2, 3], [1, 2], [1, 3], [2, 3]]
L = [[[+, -, -], [-, -, +], [+, +, +]], [[-, -, +], [+, -, -], [+, +, +]], [[-, -, -], [+, +, -], [-, +, +]], [[+, +, -], [-, -, -], [-, +|...]], [[+, -, -], [+, +|...], [-|...]], [[+, +|...], [+|...], [...|...]], [[-|...], [...|...]|...], [[...|...]|...], [...|...]|...]
N = 12
A = 0.00174953 ;

No
?-

*/






return to front page.