how to convert linear equation to cnf












1












$begingroup$


I'm working on reduction from binary puzzle problem into sat.
one of the game's rule is that in each row/column numbers of 1s equals to numbers of 0. I found a solution but it's exponential.

Therefore, I need to turn the equation:
$X_1+ X_2+..... +X_{2n} =n$ , $X_i$ is $0$ or $1$, to cnf.










share|cite|improve this question











$endgroup$












  • $begingroup$
    Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match many users' quality standards, so it may attract downvotes, or be put on hold. To prevent that, please edit the question. This will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
    $endgroup$
    – José Carlos Santos
    Dec 6 '18 at 8:24
















1












$begingroup$


I'm working on reduction from binary puzzle problem into sat.
one of the game's rule is that in each row/column numbers of 1s equals to numbers of 0. I found a solution but it's exponential.

Therefore, I need to turn the equation:
$X_1+ X_2+..... +X_{2n} =n$ , $X_i$ is $0$ or $1$, to cnf.










share|cite|improve this question











$endgroup$












  • $begingroup$
    Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match many users' quality standards, so it may attract downvotes, or be put on hold. To prevent that, please edit the question. This will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
    $endgroup$
    – José Carlos Santos
    Dec 6 '18 at 8:24














1












1








1





$begingroup$


I'm working on reduction from binary puzzle problem into sat.
one of the game's rule is that in each row/column numbers of 1s equals to numbers of 0. I found a solution but it's exponential.

Therefore, I need to turn the equation:
$X_1+ X_2+..... +X_{2n} =n$ , $X_i$ is $0$ or $1$, to cnf.










share|cite|improve this question











$endgroup$




I'm working on reduction from binary puzzle problem into sat.
one of the game's rule is that in each row/column numbers of 1s equals to numbers of 0. I found a solution but it's exponential.

Therefore, I need to turn the equation:
$X_1+ X_2+..... +X_{2n} =n$ , $X_i$ is $0$ or $1$, to cnf.







logic satisfiability






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Dec 6 '18 at 9:01









Glorfindel

3,41981830




3,41981830










asked Dec 6 '18 at 8:13









Romy Adi BuchbutRomy Adi Buchbut

61




61












  • $begingroup$
    Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match many users' quality standards, so it may attract downvotes, or be put on hold. To prevent that, please edit the question. This will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
    $endgroup$
    – José Carlos Santos
    Dec 6 '18 at 8:24


















  • $begingroup$
    Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match many users' quality standards, so it may attract downvotes, or be put on hold. To prevent that, please edit the question. This will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
    $endgroup$
    – José Carlos Santos
    Dec 6 '18 at 8:24
















$begingroup$
Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match many users' quality standards, so it may attract downvotes, or be put on hold. To prevent that, please edit the question. This will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
$endgroup$
– José Carlos Santos
Dec 6 '18 at 8:24




$begingroup$
Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match many users' quality standards, so it may attract downvotes, or be put on hold. To prevent that, please edit the question. This will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
$endgroup$
– José Carlos Santos
Dec 6 '18 at 8:24










1 Answer
1






active

oldest

votes


















0












$begingroup$

Another way to say, $X_1+ X_2+dots +X_{2n} =n$ where $X_i$ is $0$ or $1$ is to say, $exists_{=n}(X_1+ X_2+dots+X_{2n})$, meaning that exactly n of the literals are true.



The CNF for this can be split into two subproblems, "n or fewer of the literals are true" and "n or more of the literals are true". When these two groups of constraints are put together, the intersection is "exactly n of the literals are true".



1) To state the constraint: "n or more of the literals are true", generate all combinations of the literals taken $n+1$ at time.



For example, given the elements:



(x₁, x₂, x₃, x₄, x₅, x₆)


The CNF for "no fewer than 3 three are true" is generated by taking the literals four at a time:



(x₁, x₂, x₃, x₄)
(x₁, x₂, x₃, x₅)
(x₁, x₂, x₃, x₆)
(x₁, x₂, x₄, x₅)
(x₁, x₂, x₄, x₆)
(x₁, x₂, x₅, x₆)
(x₁, x₃, x₄, x₅)
(x₁, x₃, x₄, x₆)
(x₁, x₃, x₅, x₆)
(x₁, x₄, x₅, x₆)
(x₂, x₃, x₄, x₅)
(x₂, x₃, x₄, x₆)
(x₂, x₃, x₅, x₆)
(x₂, x₄, x₅, x₆)
(x₃, x₄, x₅, x₆)


2) To state the constraint: "n or fewer of the literals are true", generate all combinations of the negated literals taken $n+1$ at time.



For example, given the elements:



(x₁, x₂, x₃, x₄, x₅, x₆)


The CNF for "no more than 3 three are true" is generated by taking the negated literals four at a time:



(~x₁, ~x₂, ~x₃, ~x₄)
(~x₁, ~x₂, ~x₃, ~x₅)
(~x₁, ~x₂, ~x₃, ~x₆)
(~x₁, ~x₂, ~x₄, ~x₅)
(~x₁, ~x₂, ~x₄, ~x₆)
(~x₁, ~x₂, ~x₅, ~x₆)
(~x₁, ~x₃, ~x₄, ~x₅)
(~x₁, ~x₃, ~x₄, ~x₆)
(~x₁, ~x₃, ~x₅, ~x₆)
(~x₁, ~x₄, ~x₅, ~x₆)
(~x₂, ~x₃, ~x₄, ~x₅)
(~x₂, ~x₃, ~x₄, ~x₆)
(~x₂, ~x₃, ~x₅, ~x₆)
(~x₂, ~x₄, ~x₅, ~x₆)
(~x₃, ~x₄, ~x₅, ~x₆)


Last, concatenate the two CNFs to generate all solutions to the linear formula where the only half of the literals are true :-)






share|cite|improve this answer











$endgroup$













    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',
    autoActivateHeartbeat: false,
    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%2f3028213%2fhow-to-convert-linear-equation-to-cnf%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









    0












    $begingroup$

    Another way to say, $X_1+ X_2+dots +X_{2n} =n$ where $X_i$ is $0$ or $1$ is to say, $exists_{=n}(X_1+ X_2+dots+X_{2n})$, meaning that exactly n of the literals are true.



    The CNF for this can be split into two subproblems, "n or fewer of the literals are true" and "n or more of the literals are true". When these two groups of constraints are put together, the intersection is "exactly n of the literals are true".



    1) To state the constraint: "n or more of the literals are true", generate all combinations of the literals taken $n+1$ at time.



    For example, given the elements:



    (x₁, x₂, x₃, x₄, x₅, x₆)


    The CNF for "no fewer than 3 three are true" is generated by taking the literals four at a time:



    (x₁, x₂, x₃, x₄)
    (x₁, x₂, x₃, x₅)
    (x₁, x₂, x₃, x₆)
    (x₁, x₂, x₄, x₅)
    (x₁, x₂, x₄, x₆)
    (x₁, x₂, x₅, x₆)
    (x₁, x₃, x₄, x₅)
    (x₁, x₃, x₄, x₆)
    (x₁, x₃, x₅, x₆)
    (x₁, x₄, x₅, x₆)
    (x₂, x₃, x₄, x₅)
    (x₂, x₃, x₄, x₆)
    (x₂, x₃, x₅, x₆)
    (x₂, x₄, x₅, x₆)
    (x₃, x₄, x₅, x₆)


    2) To state the constraint: "n or fewer of the literals are true", generate all combinations of the negated literals taken $n+1$ at time.



    For example, given the elements:



    (x₁, x₂, x₃, x₄, x₅, x₆)


    The CNF for "no more than 3 three are true" is generated by taking the negated literals four at a time:



    (~x₁, ~x₂, ~x₃, ~x₄)
    (~x₁, ~x₂, ~x₃, ~x₅)
    (~x₁, ~x₂, ~x₃, ~x₆)
    (~x₁, ~x₂, ~x₄, ~x₅)
    (~x₁, ~x₂, ~x₄, ~x₆)
    (~x₁, ~x₂, ~x₅, ~x₆)
    (~x₁, ~x₃, ~x₄, ~x₅)
    (~x₁, ~x₃, ~x₄, ~x₆)
    (~x₁, ~x₃, ~x₅, ~x₆)
    (~x₁, ~x₄, ~x₅, ~x₆)
    (~x₂, ~x₃, ~x₄, ~x₅)
    (~x₂, ~x₃, ~x₄, ~x₆)
    (~x₂, ~x₃, ~x₅, ~x₆)
    (~x₂, ~x₄, ~x₅, ~x₆)
    (~x₃, ~x₄, ~x₅, ~x₆)


    Last, concatenate the two CNFs to generate all solutions to the linear formula where the only half of the literals are true :-)






    share|cite|improve this answer











    $endgroup$


















      0












      $begingroup$

      Another way to say, $X_1+ X_2+dots +X_{2n} =n$ where $X_i$ is $0$ or $1$ is to say, $exists_{=n}(X_1+ X_2+dots+X_{2n})$, meaning that exactly n of the literals are true.



      The CNF for this can be split into two subproblems, "n or fewer of the literals are true" and "n or more of the literals are true". When these two groups of constraints are put together, the intersection is "exactly n of the literals are true".



      1) To state the constraint: "n or more of the literals are true", generate all combinations of the literals taken $n+1$ at time.



      For example, given the elements:



      (x₁, x₂, x₃, x₄, x₅, x₆)


      The CNF for "no fewer than 3 three are true" is generated by taking the literals four at a time:



      (x₁, x₂, x₃, x₄)
      (x₁, x₂, x₃, x₅)
      (x₁, x₂, x₃, x₆)
      (x₁, x₂, x₄, x₅)
      (x₁, x₂, x₄, x₆)
      (x₁, x₂, x₅, x₆)
      (x₁, x₃, x₄, x₅)
      (x₁, x₃, x₄, x₆)
      (x₁, x₃, x₅, x₆)
      (x₁, x₄, x₅, x₆)
      (x₂, x₃, x₄, x₅)
      (x₂, x₃, x₄, x₆)
      (x₂, x₃, x₅, x₆)
      (x₂, x₄, x₅, x₆)
      (x₃, x₄, x₅, x₆)


      2) To state the constraint: "n or fewer of the literals are true", generate all combinations of the negated literals taken $n+1$ at time.



      For example, given the elements:



      (x₁, x₂, x₃, x₄, x₅, x₆)


      The CNF for "no more than 3 three are true" is generated by taking the negated literals four at a time:



      (~x₁, ~x₂, ~x₃, ~x₄)
      (~x₁, ~x₂, ~x₃, ~x₅)
      (~x₁, ~x₂, ~x₃, ~x₆)
      (~x₁, ~x₂, ~x₄, ~x₅)
      (~x₁, ~x₂, ~x₄, ~x₆)
      (~x₁, ~x₂, ~x₅, ~x₆)
      (~x₁, ~x₃, ~x₄, ~x₅)
      (~x₁, ~x₃, ~x₄, ~x₆)
      (~x₁, ~x₃, ~x₅, ~x₆)
      (~x₁, ~x₄, ~x₅, ~x₆)
      (~x₂, ~x₃, ~x₄, ~x₅)
      (~x₂, ~x₃, ~x₄, ~x₆)
      (~x₂, ~x₃, ~x₅, ~x₆)
      (~x₂, ~x₄, ~x₅, ~x₆)
      (~x₃, ~x₄, ~x₅, ~x₆)


      Last, concatenate the two CNFs to generate all solutions to the linear formula where the only half of the literals are true :-)






      share|cite|improve this answer











      $endgroup$
















        0












        0








        0





        $begingroup$

        Another way to say, $X_1+ X_2+dots +X_{2n} =n$ where $X_i$ is $0$ or $1$ is to say, $exists_{=n}(X_1+ X_2+dots+X_{2n})$, meaning that exactly n of the literals are true.



        The CNF for this can be split into two subproblems, "n or fewer of the literals are true" and "n or more of the literals are true". When these two groups of constraints are put together, the intersection is "exactly n of the literals are true".



        1) To state the constraint: "n or more of the literals are true", generate all combinations of the literals taken $n+1$ at time.



        For example, given the elements:



        (x₁, x₂, x₃, x₄, x₅, x₆)


        The CNF for "no fewer than 3 three are true" is generated by taking the literals four at a time:



        (x₁, x₂, x₃, x₄)
        (x₁, x₂, x₃, x₅)
        (x₁, x₂, x₃, x₆)
        (x₁, x₂, x₄, x₅)
        (x₁, x₂, x₄, x₆)
        (x₁, x₂, x₅, x₆)
        (x₁, x₃, x₄, x₅)
        (x₁, x₃, x₄, x₆)
        (x₁, x₃, x₅, x₆)
        (x₁, x₄, x₅, x₆)
        (x₂, x₃, x₄, x₅)
        (x₂, x₃, x₄, x₆)
        (x₂, x₃, x₅, x₆)
        (x₂, x₄, x₅, x₆)
        (x₃, x₄, x₅, x₆)


        2) To state the constraint: "n or fewer of the literals are true", generate all combinations of the negated literals taken $n+1$ at time.



        For example, given the elements:



        (x₁, x₂, x₃, x₄, x₅, x₆)


        The CNF for "no more than 3 three are true" is generated by taking the negated literals four at a time:



        (~x₁, ~x₂, ~x₃, ~x₄)
        (~x₁, ~x₂, ~x₃, ~x₅)
        (~x₁, ~x₂, ~x₃, ~x₆)
        (~x₁, ~x₂, ~x₄, ~x₅)
        (~x₁, ~x₂, ~x₄, ~x₆)
        (~x₁, ~x₂, ~x₅, ~x₆)
        (~x₁, ~x₃, ~x₄, ~x₅)
        (~x₁, ~x₃, ~x₄, ~x₆)
        (~x₁, ~x₃, ~x₅, ~x₆)
        (~x₁, ~x₄, ~x₅, ~x₆)
        (~x₂, ~x₃, ~x₄, ~x₅)
        (~x₂, ~x₃, ~x₄, ~x₆)
        (~x₂, ~x₃, ~x₅, ~x₆)
        (~x₂, ~x₄, ~x₅, ~x₆)
        (~x₃, ~x₄, ~x₅, ~x₆)


        Last, concatenate the two CNFs to generate all solutions to the linear formula where the only half of the literals are true :-)






        share|cite|improve this answer











        $endgroup$



        Another way to say, $X_1+ X_2+dots +X_{2n} =n$ where $X_i$ is $0$ or $1$ is to say, $exists_{=n}(X_1+ X_2+dots+X_{2n})$, meaning that exactly n of the literals are true.



        The CNF for this can be split into two subproblems, "n or fewer of the literals are true" and "n or more of the literals are true". When these two groups of constraints are put together, the intersection is "exactly n of the literals are true".



        1) To state the constraint: "n or more of the literals are true", generate all combinations of the literals taken $n+1$ at time.



        For example, given the elements:



        (x₁, x₂, x₃, x₄, x₅, x₆)


        The CNF for "no fewer than 3 three are true" is generated by taking the literals four at a time:



        (x₁, x₂, x₃, x₄)
        (x₁, x₂, x₃, x₅)
        (x₁, x₂, x₃, x₆)
        (x₁, x₂, x₄, x₅)
        (x₁, x₂, x₄, x₆)
        (x₁, x₂, x₅, x₆)
        (x₁, x₃, x₄, x₅)
        (x₁, x₃, x₄, x₆)
        (x₁, x₃, x₅, x₆)
        (x₁, x₄, x₅, x₆)
        (x₂, x₃, x₄, x₅)
        (x₂, x₃, x₄, x₆)
        (x₂, x₃, x₅, x₆)
        (x₂, x₄, x₅, x₆)
        (x₃, x₄, x₅, x₆)


        2) To state the constraint: "n or fewer of the literals are true", generate all combinations of the negated literals taken $n+1$ at time.



        For example, given the elements:



        (x₁, x₂, x₃, x₄, x₅, x₆)


        The CNF for "no more than 3 three are true" is generated by taking the negated literals four at a time:



        (~x₁, ~x₂, ~x₃, ~x₄)
        (~x₁, ~x₂, ~x₃, ~x₅)
        (~x₁, ~x₂, ~x₃, ~x₆)
        (~x₁, ~x₂, ~x₄, ~x₅)
        (~x₁, ~x₂, ~x₄, ~x₆)
        (~x₁, ~x₂, ~x₅, ~x₆)
        (~x₁, ~x₃, ~x₄, ~x₅)
        (~x₁, ~x₃, ~x₄, ~x₆)
        (~x₁, ~x₃, ~x₅, ~x₆)
        (~x₁, ~x₄, ~x₅, ~x₆)
        (~x₂, ~x₃, ~x₄, ~x₅)
        (~x₂, ~x₃, ~x₄, ~x₆)
        (~x₂, ~x₃, ~x₅, ~x₆)
        (~x₂, ~x₄, ~x₅, ~x₆)
        (~x₃, ~x₄, ~x₅, ~x₆)


        Last, concatenate the two CNFs to generate all solutions to the linear formula where the only half of the literals are true :-)







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited Dec 11 '18 at 7:45

























        answered Dec 8 '18 at 18:12









        Raymond HettingerRaymond Hettinger

        46119




        46119






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3028213%2fhow-to-convert-linear-equation-to-cnf%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

            Sphinx de Gizeh

            Dijon

            Langue