Article View: comp.lang.prolog
Article #140Solving 4 queens using boolean constraint
From: Mattias Waldau
Date: Mon, 06 Apr 1992 10:57
Date: Mon, 06 Apr 1992 10:57
52 lines
2135 bytes
2135 bytes
I tried to solve the 4 queens problem using the boolean constraint solver of SICStus 2.1#1 using the cardinality predicate. I assume that :- bool:sat(card([0-1],[A,B,C,D])). that at most one of the boolean variables A, B, C and D is true. :- fourQueens(A). hasn't found a solution in several minutes. fourQueens(q(r(S11, S12, S13, S14), r(S21, S22, S23, S24), r(S31, S32, S33, S34), r(S41, S42, S43, S44))) :- %% rows bool:sat(card([0-1],[S11, S12, S13, S14])), bool:sat(card([0-1],[S21, S22, S23, S24])), bool:sat(card([0-1],[S31, S32, S33, S34])), bool:sat(card([0-1],[S41, S42, S43, S44])), %% columns bool:sat(card([0-1],[S11, S21, S31, S41])), bool:sat(card([0-1],[S12, S22, S32, S42])), bool:sat(card([0-1],[S13, S23, S33, S43])), bool:sat(card([0-1],[S14, S24, S34, S44])), %% diag left-right bool:sat(card([0-1],[S14])), bool:sat(card([0-1],[S13, S24])), bool:sat(card([0-1],[S12, S23, S34])), bool:sat(card([0-1],[S11, S22, S33, S44])), bool:sat(card([0-1],[S21, S32, S43])), bool:sat(card([0-1],[S31, S42])), bool:sat(card([0-1],[S41])), %% diag right-left bool:sat(card([0-1],[S11])), bool:sat(card([0-1],[S12, S21])), bool:sat(card([0-1],[S13, S22, S31])), bool:sat(card([0-1],[S14, S23, S32, S41])), bool:sat(card([0-1],[S24, S33, S42])), bool:sat(card([0-1],[S34, S43])), bool:sat(card([0-1],[S44])). -- Mattias Waldau Computing Science Department mattias@emil.csd.uu.se P.O. Box 520, S-751 20 Uppsala, Sweden Phone: +46-18-181055
Technical Details
Message-ID:
<1992Apr6.105730.13467@corax.udac.uu.se>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-beacon!eru.mt.luth.se!lunic!sunic!corax.udac.uu.se!corax.udac.uu.se!mattiasShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-beacon!eru.mt.luth.se!lunic!sunic!corax.udac.uu.se!corax.udac.uu.se!mattias From: mattias@meryl.csd.uu.se (Mattias Waldau) Newsgroups: comp.lang.prolog Subject: Solving 4 queens using boolean constraint Message-ID: <1992Apr6.105730.13467@corax.udac.uu.se> Date: 6 Apr 92 10:57:30 GMT Article-I.D.: corax.1992Apr6.105730.13467 Sender: news@corax.udac.uu.se Distribution: comp.lang.prolog Organization: /home/meryl/csd/mattias/.organization Lines: 52