private static void caseSize1(CClausule clausule, CLiteralSet newLiteral, CClausuleSet newClausules)
        {
            // U'j
            CLiteral y1 = CLiteral.generateLiteral(); // y1j
            newLiteral.addLiteral(y1);

            CLiteral y2 = CLiteral.generateLiteral(); // y2j
            newLiteral.addLiteral(y2);

            // C'j
            bool[] direct = new bool[3];
            CLiteral[] clausuleLiteral = new CLiteral[3];

            clausuleLiteral[0] = clausule.getClausuleLiterals()[0]; // z1
            direct[0] = clausule.getAreDirect()[0];

            clausuleLiteral[1] = y1; // y1j
            direct[1] = true;

            clausuleLiteral[2] = y2; // y2j
            direct[2] = true;
            newClausules.addClausule(new CClausule(clausuleLiteral, direct)); // {z1, y1j, y2j}

            direct[1] = false; // ¬y1j
            direct[2] = true;  // y2j
            newClausules.addClausule(new CClausule(clausuleLiteral, direct)); // {z1, ¬y1j, y2j}

            direct[1] = true;  // y1j
            direct[2] = false; // ¬y2j
            newClausules.addClausule(new CClausule(clausuleLiteral, direct)); // {z1, y1j, ¬y2j}

            direct[1] = false; // ¬y1j
            direct[2] = false; // ¬y2j
            newClausules.addClausule(new CClausule(clausuleLiteral, direct)); // {z1, ¬y1j, ¬y2j}
        }
        public CClausule(CLiteral[] literals, bool[] areDirect)
        {
            setSize(literals.Count());

            setClausuleLiterals(new CLiteral[literals.Count()]);
            for (int i = 0; i < literals.Count(); i++)
                _clausuleLiterals[i] = literals[i];

            setAreDirect(new bool[getSize()]);
            for (int i = 0; i < getSize(); i++)
                _areDirect[i] = areDirect[i];
        }
        private void example1()
        {
            bool[] directs = new bool[1];
            CLiteral[] ls = new CLiteral[1];
            ls[0] = CLiteral.generateLiteral(true);
            directs[0] = true;

            CLiteralSet literalSet = new CLiteralSet();
            for (int i = 0; i < ls.Count(); i++)
                literalSet.addLiteral(ls[i]);

            CClausuleSet clausuleSet = new CClausuleSet();
            clausuleSet.addClausule(new CClausule(ls, directs));

            CSATProblem problem = new CSATProblem(literalSet, clausuleSet);

            txOutput.Text = problem.toString();

            txOutput.Text += problem.isSatisfactible().ToString() + Environment.NewLine;

            txOutput.Text += CProblemReduction.reduct(problem).toString();
        }
 public void addLiteral(CLiteral l)
 {
     _literals.Add(l);
 }
 public void setClausuleLiterals(CLiteral[] clausuleLiterals)
 {
     this._clausuleLiterals = clausuleLiterals;
 }
        private static void caseSize4(CClausule clausule, CLiteralSet newLiteral, CClausuleSet newClausules)
        {
            bool[] direct = new bool[3];
            CLiteral[] clausuleLiteral = new CLiteral[3];

            clausuleLiteral[0] = clausule.getClausuleLiterals()[0]; // z1
            direct[0] = clausule.getAreDirect()[0];

            clausuleLiteral[1] = clausule.getClausuleLiterals()[1]; // z2
            direct[1] = clausule.getAreDirect()[1];

            CLiteral l = CLiteral.generateLiteral(); // y1j
            newLiteral.addLiteral(l);
            clausuleLiteral[2] = l;
            direct[2] = true;

            newClausules.addClausule(new CClausule(clausuleLiteral, direct)); // {z1, z2, y1j}

            for (int i = 0; i < clausule.getSize() - 4; i++) { // 1 <= i <= k-4
                clausuleLiteral[0] = l; // ¬yij
                direct[0] = false;

                clausuleLiteral[1] = clausule.getClausuleLiterals()[i + 2]; // zi+2
                direct[1] = clausule.getAreDirect()[i + 2];

                l = CLiteral.generateLiteral(); // yi+1j
                clausuleLiteral[2] = l;
                newLiteral.addLiteral(l);
                direct[2] = true;

                newClausules.addClausule(new CClausule(clausuleLiteral, direct)); // {{¬yij, zi+2, yi+1j} ; 1 <= i <= k-4}
            }

            clausuleLiteral[0] = l; // ¬yk - 3j
            direct[0] = false;

            clausuleLiteral[1] = clausule.getClausuleLiterals()[clausule.getSize() - 2]; // zk - 1
            direct[1] = clausule.getAreDirect()[clausule.getSize() - 2];

            clausuleLiteral[2] = clausule.getClausuleLiterals()[clausule.getSize() - 1]; // zk
            direct[2] = clausule.getAreDirect()[clausule.getSize() - 1];

            newClausules.addClausule(new CClausule(clausuleLiteral, direct)); // {¬yk-3j, zk-j, zk}
        }