Representation of 3-queens problem as boolean expression for SAT solver











up vote
0
down vote

favorite












The nxn queens problem is if the is a solution where n queens can exists on a nxn board with the rules of chess, 1 per row,col,diagonal. I am trying to represent the nxn queens problem where n=3 in propositional form. so we define 9 Boolean variables, let a,b,c, represent the entries on row 1, d,e,f the entries on row 2, and g,h,i represent the entires on row 3. So given the rules we have the following propositional formula:



Exactly one queen on top row : (a∨b∨c) ∧ ~( a∧b∧c)



Exactly one queen on middle row : (d∨e∨f) ∧ ~( d∧e∧f)



Exactly one queen on bottom row: (g∨h∨i) ∧ ~( g∧h∧i)



Exactly one queen on left column : (a∨d∨g) ∧ ~( a∧d∧g)



Exactly one queen one queen on middle column : (b∨d∨h) ∧ ~( b∧d∧h)



Exactly one queen on right column: (c∨e∨i) ∧ ~( c∧e∧i)



No two queens on the same diagonal: ~(a∨e∨i) ∧ ~( c∧e∧d)



However, this returns satisfiable on the sat solver, yet we know that the nxn queens problem is only solvable for n>3, so my representation must be false.










share|cite|improve this question






















  • You meant (a∨b∨c) ∧ ~( a∧b) ∧ ~( a∧c) ∧ ~( b∧c). For the $n$-queens you might want to implement $n mapsto n+a_i$ in SAT, so you can define the rule $sum_i a_i = 1$
    – reuns
    Nov 16 at 20:18












  • yeah that makes sense, thanks!
    – Ben French
    Nov 16 at 20:23















up vote
0
down vote

favorite












The nxn queens problem is if the is a solution where n queens can exists on a nxn board with the rules of chess, 1 per row,col,diagonal. I am trying to represent the nxn queens problem where n=3 in propositional form. so we define 9 Boolean variables, let a,b,c, represent the entries on row 1, d,e,f the entries on row 2, and g,h,i represent the entires on row 3. So given the rules we have the following propositional formula:



Exactly one queen on top row : (a∨b∨c) ∧ ~( a∧b∧c)



Exactly one queen on middle row : (d∨e∨f) ∧ ~( d∧e∧f)



Exactly one queen on bottom row: (g∨h∨i) ∧ ~( g∧h∧i)



Exactly one queen on left column : (a∨d∨g) ∧ ~( a∧d∧g)



Exactly one queen one queen on middle column : (b∨d∨h) ∧ ~( b∧d∧h)



Exactly one queen on right column: (c∨e∨i) ∧ ~( c∧e∧i)



No two queens on the same diagonal: ~(a∨e∨i) ∧ ~( c∧e∧d)



However, this returns satisfiable on the sat solver, yet we know that the nxn queens problem is only solvable for n>3, so my representation must be false.










share|cite|improve this question






















  • You meant (a∨b∨c) ∧ ~( a∧b) ∧ ~( a∧c) ∧ ~( b∧c). For the $n$-queens you might want to implement $n mapsto n+a_i$ in SAT, so you can define the rule $sum_i a_i = 1$
    – reuns
    Nov 16 at 20:18












  • yeah that makes sense, thanks!
    – Ben French
    Nov 16 at 20:23













up vote
0
down vote

favorite









up vote
0
down vote

favorite











The nxn queens problem is if the is a solution where n queens can exists on a nxn board with the rules of chess, 1 per row,col,diagonal. I am trying to represent the nxn queens problem where n=3 in propositional form. so we define 9 Boolean variables, let a,b,c, represent the entries on row 1, d,e,f the entries on row 2, and g,h,i represent the entires on row 3. So given the rules we have the following propositional formula:



Exactly one queen on top row : (a∨b∨c) ∧ ~( a∧b∧c)



Exactly one queen on middle row : (d∨e∨f) ∧ ~( d∧e∧f)



Exactly one queen on bottom row: (g∨h∨i) ∧ ~( g∧h∧i)



Exactly one queen on left column : (a∨d∨g) ∧ ~( a∧d∧g)



Exactly one queen one queen on middle column : (b∨d∨h) ∧ ~( b∧d∧h)



Exactly one queen on right column: (c∨e∨i) ∧ ~( c∧e∧i)



No two queens on the same diagonal: ~(a∨e∨i) ∧ ~( c∧e∧d)



However, this returns satisfiable on the sat solver, yet we know that the nxn queens problem is only solvable for n>3, so my representation must be false.










share|cite|improve this question













The nxn queens problem is if the is a solution where n queens can exists on a nxn board with the rules of chess, 1 per row,col,diagonal. I am trying to represent the nxn queens problem where n=3 in propositional form. so we define 9 Boolean variables, let a,b,c, represent the entries on row 1, d,e,f the entries on row 2, and g,h,i represent the entires on row 3. So given the rules we have the following propositional formula:



Exactly one queen on top row : (a∨b∨c) ∧ ~( a∧b∧c)



Exactly one queen on middle row : (d∨e∨f) ∧ ~( d∧e∧f)



Exactly one queen on bottom row: (g∨h∨i) ∧ ~( g∧h∧i)



Exactly one queen on left column : (a∨d∨g) ∧ ~( a∧d∧g)



Exactly one queen one queen on middle column : (b∨d∨h) ∧ ~( b∧d∧h)



Exactly one queen on right column: (c∨e∨i) ∧ ~( c∧e∧i)



No two queens on the same diagonal: ~(a∨e∨i) ∧ ~( c∧e∧d)



However, this returns satisfiable on the sat solver, yet we know that the nxn queens problem is only solvable for n>3, so my representation must be false.







logic boolean-algebra






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Nov 16 at 20:14









Ben French

547




547












  • You meant (a∨b∨c) ∧ ~( a∧b) ∧ ~( a∧c) ∧ ~( b∧c). For the $n$-queens you might want to implement $n mapsto n+a_i$ in SAT, so you can define the rule $sum_i a_i = 1$
    – reuns
    Nov 16 at 20:18












  • yeah that makes sense, thanks!
    – Ben French
    Nov 16 at 20:23


















  • You meant (a∨b∨c) ∧ ~( a∧b) ∧ ~( a∧c) ∧ ~( b∧c). For the $n$-queens you might want to implement $n mapsto n+a_i$ in SAT, so you can define the rule $sum_i a_i = 1$
    – reuns
    Nov 16 at 20:18












  • yeah that makes sense, thanks!
    – Ben French
    Nov 16 at 20:23
















You meant (a∨b∨c) ∧ ~( a∧b) ∧ ~( a∧c) ∧ ~( b∧c). For the $n$-queens you might want to implement $n mapsto n+a_i$ in SAT, so you can define the rule $sum_i a_i = 1$
– reuns
Nov 16 at 20:18






You meant (a∨b∨c) ∧ ~( a∧b) ∧ ~( a∧c) ∧ ~( b∧c). For the $n$-queens you might want to implement $n mapsto n+a_i$ in SAT, so you can define the rule $sum_i a_i = 1$
– reuns
Nov 16 at 20:18














yeah that makes sense, thanks!
– Ben French
Nov 16 at 20:23




yeah that makes sense, thanks!
– Ben French
Nov 16 at 20:23










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted











Exactly one queen on top row : (a∨b∨c) ∧ ~( a∧b∧c)




This is wrong, as it still allows two queens in the same row



So do:



$$(a lor b lor c) land neg (a land b) land neg (a land c) land neg (b land c)$$



... same for the others ...






share|cite|improve this answer





















    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3001596%2frepresentation-of-3-queens-problem-as-boolean-expression-for-sat-solver%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted











    Exactly one queen on top row : (a∨b∨c) ∧ ~( a∧b∧c)




    This is wrong, as it still allows two queens in the same row



    So do:



    $$(a lor b lor c) land neg (a land b) land neg (a land c) land neg (b land c)$$



    ... same for the others ...






    share|cite|improve this answer

























      up vote
      1
      down vote



      accepted











      Exactly one queen on top row : (a∨b∨c) ∧ ~( a∧b∧c)




      This is wrong, as it still allows two queens in the same row



      So do:



      $$(a lor b lor c) land neg (a land b) land neg (a land c) land neg (b land c)$$



      ... same for the others ...






      share|cite|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted







        Exactly one queen on top row : (a∨b∨c) ∧ ~( a∧b∧c)




        This is wrong, as it still allows two queens in the same row



        So do:



        $$(a lor b lor c) land neg (a land b) land neg (a land c) land neg (b land c)$$



        ... same for the others ...






        share|cite|improve this answer













        Exactly one queen on top row : (a∨b∨c) ∧ ~( a∧b∧c)




        This is wrong, as it still allows two queens in the same row



        So do:



        $$(a lor b lor c) land neg (a land b) land neg (a land c) land neg (b land c)$$



        ... same for the others ...







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Nov 16 at 20:18









        Bram28

        58.5k44185




        58.5k44185






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3001596%2frepresentation-of-3-queens-problem-as-boolean-expression-for-sat-solver%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Probability when a professor distributes a quiz and homework assignment to a class of n students.

            Aardman Animations

            Are they similar matrix