Skip to content

Understanding basic examples.  #16

@arey0pushpa

Description

@arey0pushpa

Hi, I'm trying to create basic one level quantifier alternation and test all 4 possible cases. I have picked your first example as a basis.

 #include <string.h>
 #include <stdlib.h>  
 #include <stdio.h> 
 #include <assert.h>
 #include "../qdpll.h"

 int main (int argc, char** argv)
 {
      QDPLL *depqbf = qdpll_create ();
      qdpll_configure (depqbf, "--dep-man=simple");
      qdpll_configure (depqbf, "--incremental-use");

      qdpll_new_scope_at_nesting (depqbf, QDPLL_QTYPE_FORALL, 1);
      qdpll_add (depqbf, 1);
      qdpll_add (depqbf, 0);

      qdpll_new_scope_at_nesting (depqbf, QDPLL_QTYPE_EXISTS, 2);
      qdpll_add (depqbf, 2);
      qdpll_add (depqbf, 0);

      /* Add clause: 1 -2 0 */
      qdpll_add (depqbf, 1);
      qdpll_add (depqbf, -2);
      qdpll_add (depqbf, 0);

     /* Add clause: -1 2 0 */
      qdpll_add (depqbf, -1);
      qdpll_add (depqbf, 2);
      qdpll_add (depqbf, 0);

      qdpll_print (depqbf, stdout);

  unsigned int i = 0;
  QDPLLResult res;
  while ((res = qdpll_sat (depqbf)) == QDPLL_RESULT_SAT)
  {
      i++;
      if (i > 5) 
    break;
      fprintf (stderr, "\nResult after iteration %u: %u\n", i, res);
      /* Get current values for variables '1' and '2'. */
      QDPLLAssignment val1 = qdpll_get_value (depqbf, 1);
      QDPLLAssignment val2 = qdpll_get_value (depqbf, 2);
      fprintf (stderr, "Value of 1: %d\n", val1);
      fprintf (stderr, "Value of 2: %d\n", val2);
 
    // Block the previous result.
      qdpll_reset (depqbf);
      fprintf (stderr, "Adding a new blocking clause.\n");
      if (val1 != QDPLL_ASSIGNMENT_UNDEF)
          qdpll_add (depqbf, val1 == QDPLL_ASSIGNMENT_FALSE ? 1 : -1);
     if (val1 != QDPLL_ASSIGNMENT_UNDEF)
          qdpll_add (depqbf, val2 == QDPLL_ASSIGNMENT_FALSE ? 2 : -2);
          qdpll_add (depqbf, 0);
      fprintf (stderr, "Formula with blocking clause:\n");
      qdpll_print (depqbf, stderr);
   }
  qdpll_delete (depqbf);
 }

The formula is : Forall [x, Exists [y, (x || !y) && (!x || y) ) ] ]
Cases :

  1. Exists x , Exists y
    x = 1, y = 1. x = -1, y = -1.

  2. Forall x and Forall y : Unsat.

  3. Exists x, Forall y: Unsat. Everything is fine till now.

  4. Forall x, Exists y ... The output is not what i except. The solver goes on adding the -1 , 1 assignment. How to get assignments in case of satisfying formula in alternation of quantifiers. because this formula is true for every value in universe of discourse (True, False) for the variable x.

Also,
I can see that the tool simplifies formula. Is that basic "simplify" or does depqbf eliminates quantifer? for example in the case of Exists x, Forall y (case 3) it removes y from the formula. I would like to understand the over-ahead for that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions