:-dynamic obs/2,conn/2,val/2,nand2_table/3,and2_table/3, not1_table/2,id1_table/2,xor2_table/3,eq2_table/3,nor2_table/3, or2_table/3,nand4_table/5,and4_table/5. obs(out(inpt0, cain3), 0). obs(out(inpt0, cain2), 0). obs(out(inpt0, cain1), 0). obs(out(inpt0, cain0), 0). obs(out(inpt0, cbin3), 0). obs(out(inpt0, cbin2), 0). obs(out(inpt0, cbin1), 0). obs(out(inpt0, cbin0), 0). obs(out(inpt0, ccin3), 0). obs(out(inpt0, ccin2), 0). obs(out(inpt0, ccin1), 0). obs(out(inpt0, ccin0), 0). obs(out(or2, cout3), 0). obs(out(or2, cout2), 0). obs(out(or2, cout1), 0). obs(out(or2, cout0), 1). ic([ obs(out(or2, cout3), 0), val(out(or2, cout3), 1)],ag1). ic([ obs(out(or2, cout3), 1), val(out(or2, cout3), 0)],ag1). ic([ obs(out(or2, cout2), 0), val(out(or2, cout2), 1)],ag1). ic([ obs(out(or2, cout2), 1), val(out(or2, cout2), 0)],ag1). ic([ obs(out(or2, cout1), 0), val(out(or2, cout1), 1)],ag1). ic([ obs(out(or2, cout1), 1), val(out(or2, cout1), 0)],ag1). ic([ obs(out(or2, cout0), 0), val(out(or2, cout0), 1)],ag1). ic([ obs(out(or2, cout0), 1), val(out(or2, cout0), 0)],ag1). agents([ag1]). %revisable(ab(_)). % % Propagation of values thru connections % val( in(Type,Name,Nr), V ) :- conn( in(Type,Name,Nr), out(Type2,Name2) ), val( out(Type2,Name2), V ). % % input observations % val( out(inpt0, Name), V ) :- obs( out(inpt0, Name), V ). % % computation of a component's output value % val( out(not1,Name), V ) :- not ab(Name), val( in(not1,Name,1), W), not1_table(W,V). val( out(not1,Name), V ) :- ab(Name), val( in(not1,Name,1), W), id1_table(W,V). val( out(xor2,Name), V ) :- not ab(Name), val( in(xor2,Name,1), W1), val( in(xor2,Name,2), W2), xor2_table(W1,W2,V). val( out(xor2,Name), V ) :- ab(Name), val( in(xor2,Name,1), W1), val( in(xor2,Name,2), W2), eq2_table(W1,W2,V). val( out(or2,Name), V ) :- not ab(Name), val( in(or2,Name,1), W1), val( in(or2,Name,2), W2), or2_table(W1,W2,V). val( out(or2,Name), V ) :- ab(Name), val( in(or2,Name,1), W1), val( in(or2,Name,2), W2), nor2_table(W1,W2,V). val( out(nor2,Name), V ) :- not ab(Name), val( in(nor2,Name,1), W1), val( in(nor2,Name,2), W2), nor2_table(W1,W2,V). val( out(nor2,Name), V ) :- ab(Name), val( in(nor2,Name,1), W1), val( in(nor2,Name,2), W2), or2_table(W1,W2,V). val( out(nand2,Name), V ) :- not ab(Name), val( in(nand2,Name,1), W1), val( in(nand2,Name,2), W2), nand2_table(W1,W2,V). val( out(nand2,Name), V ) :- ab(Name), val( in(nand2,Name,1), W1), val( in(nand2,Name,2), W2), and2_table(W1,W2,V). val( out(and2,Name), V ) :- not ab(Name), val( in(and2,Name,1), W1), val( in(and2,Name,2), W2), and2_table(W1,W2,V). val( out(and2,Name), V ) :- ab(Name), val( in(and2,Name,1), W1), val( in(and2,Name,2), W2), nand2_table(W1,W2,V). val( out(and4,Name), V ) :- not ab(Name), val( in(and4,Name,1), W1), val( in(and4,Name,2), W2), val( in(and4,Name,3), W3), val( in(and4,Name,4), W4), and4_table(W1,W2,W3,W4,V). val( out(and4,Name), V ) :- ab(Name), val( in(and2,Name,1), W1), val( in(and2,Name,2), W2), val( in(and2,Name,3), W3), val( in(and2,Name,4), W4), nand4_table(W1,W2,W3,W4,V). not1_table(0,1). not1_table(1,0). id1_table(0,0). id1_table(1,1). xor2_table(0,0,0). xor2_table(0,1,1). xor2_table(1,0,1). xor2_table(1,1,0). eq2_table(0,0,1). eq2_table(0,1,0). eq2_table(1,0,0). eq2_table(1,1,1). nor2_table(0,0,1). nor2_table(0,1,0). nor2_table(1,0,0). nor2_table(1,1,0). or2_table(0,0,0). or2_table(0,1,1). or2_table(1,0,1). or2_table(1,1,1). nand2_table(0,0,1). nand2_table(0,1,1). nand2_table(1,0,1). nand2_table(1,1,0). and2_table(0,0,0). and2_table(0,1,0). and2_table(1,0,0). and2_table(1,1,1). nand4_table(0,0,0,0,1). nand4_table(0,0,0,1,1). nand4_table(0,0,1,0,1). nand4_table(0,0,1,1,1). nand4_table(0,1,0,0,1). nand4_table(0,1,0,1,1). nand4_table(0,1,1,0,1). nand4_table(0,1,1,1,1). nand4_table(1,0,0,0,1). nand4_table(1,0,0,1,1). nand4_table(1,0,1,0,1). nand4_table(1,0,1,1,1). nand4_table(1,1,0,0,1). nand4_table(1,1,0,1,1). nand4_table(1,1,1,0,1). nand4_table(1,1,1,1,0). and4_table(0,0,0,0,0). and4_table(0,0,0,1,0). and4_table(0,0,1,0,0). and4_table(0,0,1,1,0). and4_table(0,1,0,0,0). and4_table(0,1,0,1,0). and4_table(0,1,1,0,0). and4_table(0,1,1,1,0). and4_table(1,0,0,0,0). and4_table(1,0,0,1,0). and4_table(1,0,1,0,0). and4_table(1,0,1,1,0). and4_table(1,1,0,0,0). and4_table(1,1,0,1,0). and4_table(1,1,1,0,0). and4_table(1,1,1,1,1). conn(in(not1, cI33, 1), out(inpt0, cain0)). conn(in(not1, cI24, 1), out(inpt0, cain1)). conn(in(not1, cI15, 1), out(inpt0, cain2)). conn(in(not1, cI6, 1), out(inpt0, cain3)). conn(in(not1, cI34, 1), out(inpt0, cbin0)). conn(in(not1, cI74, 1), out(inpt0, cbin0)). conn(in(not1, cI25, 1), out(inpt0, cbin1)). conn(in(not1, cI65, 1), out(inpt0, cbin1)). conn(in(not1, cI16, 1), out(inpt0, cbin2)). conn(in(not1, cI56, 1), out(inpt0, cbin2)). conn(in(not1, cI7, 1), out(inpt0, cbin3)). conn(in(not1, cI47, 1), out(inpt0, cbin3)). conn(in(not1, cI75, 1), out(inpt0, ccin0)). conn(in(not1, cI66, 1), out(inpt0, ccin1)). conn(in(not1, cI57, 1), out(inpt0, ccin2)). conn(in(not1, cI48, 1), out(inpt0, ccin3)). conn(in(and2, cI36, 1), out(inpt0, cbin0)). conn(in(and2, cI36, 2), out(not1, cI33)). conn(in(and2, cI27, 1), out(inpt0, cbin1)). conn(in(and2, cI27, 2), out(not1, cI24)). conn(in(and2, cI18, 1), out(inpt0, cbin2)). conn(in(and2, cI18, 2), out(not1, cI15)). conn(in(and2, cI9, 1), out(inpt0, cbin3)). conn(in(and2, cI9, 2), out(not1, cI6)). conn(in(and2, cI35, 1), out(inpt0, cain0)). conn(in(and2, cI35, 2), out(not1, cI34)). conn(in(and2, cI77, 1), out(inpt0, ccin0)). conn(in(and2, cI77, 2), out(not1, cI74)). conn(in(and2, cI26, 1), out(inpt0, cain1)). conn(in(and2, cI26, 2), out(not1, cI25)). conn(in(and2, cI68, 1), out(inpt0, ccin1)). conn(in(and2, cI68, 2), out(not1, cI65)). conn(in(and2, cI17, 1), out(inpt0, cain2)). conn(in(and2, cI17, 2), out(not1, cI16)). conn(in(and2, cI59, 1), out(inpt0, ccin2)). conn(in(and2, cI59, 2), out(not1, cI56)). conn(in(and2, cI8, 1), out(inpt0, cain3)). conn(in(and2, cI8, 2), out(not1, cI7)). conn(in(and2, cI50, 1), out(inpt0, ccin3)). conn(in(and2, cI50, 2), out(not1, cI47)). conn(in(and2, cI76, 1), out(inpt0, cbin0)). conn(in(and2, cI76, 2), out(not1, cI75)). conn(in(and2, cI67, 1), out(inpt0, cbin1)). conn(in(and2, cI67, 2), out(not1, cI66)). conn(in(and2, cI58, 1), out(inpt0, cbin2)). conn(in(and2, cI58, 2), out(not1, cI57)). conn(in(and2, cI49, 1), out(inpt0, cbin3)). conn(in(and2, cI49, 2), out(not1, cI48)). conn(in(nor2, cI5, 1), out(and2, cI35)). conn(in(nor2, cI5, 2), out(and2, cI36)). conn(in(nor2, cI4, 1), out(and2, cI26)). conn(in(nor2, cI4, 2), out(and2, cI27)). conn(in(nor2, cI3, 1), out(and2, cI17)). conn(in(nor2, cI3, 2), out(and2, cI18)). conn(in(nor2, cI2, 1), out(and2, cI8)). conn(in(nor2, cI2, 2), out(and2, cI9)). conn(in(nor2, cI46, 1), out(and2, cI76)). conn(in(nor2, cI46, 2), out(and2, cI77)). conn(in(nor2, cI45, 1), out(and2, cI67)). conn(in(nor2, cI45, 2), out(and2, cI68)). conn(in(nor2, cI44, 1), out(and2, cI58)). conn(in(nor2, cI44, 2), out(and2, cI59)). conn(in(nor2, cI43, 1), out(and2, cI49)). conn(in(nor2, cI43, 2), out(and2, cI50)). conn(in(and4, cvote_ab, 1), out(nor2, cI2)). conn(in(and4, cvote_ab, 2), out(nor2, cI3)). conn(in(and4, cvote_ab, 3), out(nor2, cI4)). conn(in(and4, cvote_ab, 4), out(nor2, cI5)). conn(in(and4, cvote_bc, 1), out(nor2, cI43)). conn(in(and4, cvote_bc, 2), out(nor2, cI44)). conn(in(and4, cvote_bc, 3), out(nor2, cI45)). conn(in(and4, cvote_bc, 4), out(nor2, cI46)). conn(in(or2, cvote_out, 1), out(and4, cvote_ab)). conn(in(or2, cvote_out, 2), out(and4, cvote_bc)). conn(in(not1, cI85, 1), out(or2, cvote_out)). conn(in(and2, cI86, 1), out(or2, cvote_out)). conn(in(and2, cI86, 2), out(inpt0, cbin3)). conn(in(not1, cI93, 1), out(or2, cvote_out)). conn(in(and2, cI94, 1), out(or2, cvote_out)). conn(in(and2, cI94, 2), out(inpt0, cbin2)). conn(in(not1, cI101, 1), out(or2, cvote_out)). conn(in(and2, cI102, 1), out(or2, cvote_out)). conn(in(and2, cI102, 2), out(inpt0, cbin1)). conn(in(not1, cI109, 1), out(or2, cvote_out)). conn(in(and2, cI110, 1), out(or2, cvote_out)). conn(in(and2, cI110, 2), out(inpt0, cbin0)). conn(in(and2, cI87, 1), out(not1, cI85)). conn(in(and2, cI87, 2), out(inpt0, ccin3)). conn(in(and2, cI95, 1), out(not1, cI93)). conn(in(and2, cI95, 2), out(inpt0, ccin2)). conn(in(and2, cI103, 1), out(not1, cI101)). conn(in(and2, cI103, 2), out(inpt0, ccin1)). conn(in(and2, cI111, 1), out(not1, cI109)). conn(in(and2, cI111, 2), out(inpt0, ccin0)). conn(in(or2, cout3, 1), out(and2, cI86)). conn(in(or2, cout3, 2), out(and2, cI87)). conn(in(or2, cout2, 1), out(and2, cI94)). conn(in(or2, cout2, 2), out(and2, cI95)). conn(in(or2, cout1, 1), out(and2, cI102)). conn(in(or2, cout1, 2), out(and2, cI103)). conn(in(or2, cout0, 1), out(and2, cI110)). conn(in(or2, cout0, 2), out(and2, cI111)).