circuit(switch(Sw1,VSw1,C1), 
 	bulb(B1,L1,VB1,C1), 
 	switch(Sw2,VSw2,C2), 
 	bulb(B2,L2,VB2,C2), 
 	switch(Sw3,VSw3,CSw3), 
 	bulb(B3,L3,VB3,CB3), 
 	N1+N2+N3) :- 
 VSw3 = VB3, 
 sum(VSw1, VB1, V1), % 9 options 
 sum(V1,VB3,+), % 1 option 
 sum(VSw2,VB2,VB3), % 9 options 
 switch(Sw1,VSw1,C1), % 2 options 
 bulb(B1,L1,VB1,C1), % 4 options 
 switch(Sw2,VSw2,C2), % 2 options 
 bulb(B2,L2,VB2,C2), % 4 options 
 switch(Sw3,VSw3,CSw3),% 2 options 
 bulb(B3,L3,VB3,CB3), % 4 options 
 sum(CSw3,CB3,C3), % 9 options 
 sum(C2,C3,C1), % 9 options 
 num(L1,N1), 
 num(L2,N2), 
 num(L3,N3). 


%blub(Mode,Light,Volts,Amps) 
bulb(blown,dark, _Any, 0). 
bulb(ok, light, +, +). 
bulb(ok, light, -, -). 
bulb(ok, dark, 0, 0). 

%num(Light, Glow). %switch(State,Volts,Amps) 
num( dark, 0). 
num( light, 1). 

switch(on, 0, _Any).
switch(off, _Any, 0). 

%sum(X,Y,Z). 
sum(+,+,+). sum(+,0,+). sum(+,-,_Any). 
sum(0,+,+). sum(0,0,0). sum(0,-,-). 
sum(-,+,_Any). sum(-,0,-). sum(-,-,-). 

