void print_egraph_conflict(FILE *f, egraph_t *egraph, ivector_t *expl_vector) {
  void *atom;
  uint32_t i, n;
  literal_t l;
  bvar_t v;

  n = expl_vector->size;
  for (i=0; i<n; i++) {
    l = expl_vector->data[i];
    v = var_of(l);
    if (bvar_has_atom(egraph->core, v)) {
      atom = bvar_atom(egraph->core, v);
      switch (atom_tag(atom)) {
      case EGRAPH_ATM_TAG:
	if (is_neg(l)) fputs("(not ", f);
	print_eterm(f, egraph, ((atom_t *) untag_atom(atom))->eterm);
	if (is_neg(l)) fputc(')', f);
	break;

      default:
	print_literal(f, l);
	break;
      }
    } else {
      print_literal(f, l);
    }
    if (i+1 < n) {
      fputc(' ', f);
    }
  }
  fflush(f);
}
/*
 * Print a value into the StringInfo provided by caller.
 */
static void
print_value(StringInfo s, Datum origval, Oid typid, bool isnull)
{
	Oid					typoutput;
	bool				typisvarlena;

	/* Query output function */
	getTypeOutputInfo(typid,
					  &typoutput, &typisvarlena);

	/* Print value */
	if (isnull)
		appendStringInfoString(s, "null");
	else if (typisvarlena && VARATT_IS_EXTERNAL_ONDISK(origval))
		appendStringInfoString(s, "unchanged-toast-datum");
	else if (!typisvarlena)
		print_literal(s, typid,
					  OidOutputFunctionCall(typoutput, origval));
	else
	{
		/* Definitely detoasted Datum */
		Datum		val;
		val = PointerGetDatum(PG_DETOAST_DATUM(origval));
		print_literal(s, typid, OidOutputFunctionCall(typoutput, val));
	}
}
Exemple #3
0
/*
 * Print binary and problem clauses
 */
void print_binary_clause(FILE *f, literal_t l1, literal_t l2) {
  fputc('{', f);
  print_literal(f, l1);
  fputc(' ', f);
  print_literal(f, l2);
  fputc('}', f);
}
Exemple #4
0
/*
 * Print n first elements of input array
 */
static void show_input(uint32_t n) {
  uint32_t i;

  fputc('(', stdout);
  if (n > 0) {
    print_literal(stdout, input[0]);
    for (i=1; i<n; i++) {
      fputc(' ', stdout);
      print_literal(stdout, input[i]);
    }
  }
  fputc(')', stdout);
}
Exemple #5
0
static void print_list_literal(struct list_literal *l, int depth)
{
    struct literal *piece;

    printf("%slist\n", indent(depth));
    for (piece = l->first; piece != NULL; piece = piece->next)
	print_literal(piece, depth+1);
    if (l->tail) {
	printf("%sdot\n", indent(depth));
	print_literal(l->tail, depth+1);
    }
    printf("%send list\n", indent(depth));
}
Exemple #6
0
/*
 * Print array as a vector
 */
static void print_bitvector(uint32_t n, literal_t *a) {
  uint32_t i;

  printf("[");
  if (n>0) {
    print_literal(stdout, a[0]);
    for (i=1; i<n; i++) {
      printf(" ");
      print_literal(stdout, a[i]);
    }
  }
  printf("]");
}
Exemple #7
0
/*
 * Print array a, formatted as a clause
 */
void print_litarray(FILE *f, uint32_t n, literal_t *a) {
  uint32_t i;

  fputc('{', f);
  if (n > 0) {
    print_literal(f, a[0]);
    for (i=1; i<n; i++) {
      fputc(' ', f);
      print_literal(f, a[i]);
    }
  }
  fputc('}', f);
}
/*
 * Test 2: build distinct terms
 */
static void test2(void) {
  uint32_t i;
  eterm_t aux;
  occ_t a[50];
  literal_t l;
  type_t tau;

  printf("***********************\n"
	 "*       TEST 2        *\n"
	 "***********************\n\n");

  init_solver(&egraph, &core);

  tau = yices_new_uninterpreted_type();

  printf("---> building a_0 ... a_49\n");
  for (i=0; i<50; i++) {
    aux = egraph_make_variable(&egraph, tau);
    a[i] = pos_occ(aux);
  }

  for (i=0; i<40; i++) {
    printf("---> creating (distinct a_%"PRIu32" ... a_%"PRIu32")\n", i, i+5);
    l = egraph_make_distinct(&egraph, 5, a+i);
    printf("---> result = ");
    print_literal(stdout, l);
    printf("\n");
  }

  print_solver(&egraph, &core);
  delete_solver(&egraph, &core);
}
Exemple #9
0
static void print_vector_literal(struct vector_literal *l, int depth)
{
    struct literal *piece;

    printf("%svector\n", indent(depth));
    for (piece = l->first; piece != NULL; piece = piece->next)
	print_literal(piece, depth+1);
    printf("%send vector\n", indent(depth));
}
static void print_bv_ite(FILE *f, bv_ite_t *ite) {
  fputs("(ite ", f);
  print_literal(f, ite->cond);
  fputc(' ', f);
  print_bvvar(f, ite->left);
  fputc(' ', f);
  print_bvvar(f, ite->right);
  fputc(')', f);
}
Exemple #11
0
static void test_orgate(literal_t l0, literal_t l1, literal_t l2) {
  boolgate_t *g0, *g;

  input[0] = l0;
  input[1] = l1;
  input[2] = l2;
  printf("\n--- Testing OR gate ---\n");
  printf("test: OR");
  show_input(3);
  fputc('\n', stdout);

  // test find 1
  g0 = gate_table_find(&table, orgate_tag(3), input);
  if (g0 == NULL) {
    printf("find: returned NULL\n");
  } else {
    printf("find: returned %p: ", g0);
    print_boolgate(stdout, g0);
    printf("\n");
    check_orgate(g0, l0, l1, l2);
  }

  // test get
  g = gate_table_get(&table, orgate_tag(3), input);
  assert(g != NULL);
  printf("get:  returned %p: ", g);
  print_boolgate(stdout, g);
  printf("\n");
  check_orgate(g, l0, l1, l2);
  if (g0 == NULL) {
    if (g->lit[3] != null_literal) {
      printf("*** hash consing inconsistency between find and get ***\n");
    } else {
      printf("new gate: setting output literal to: ");
      print_literal(stdout, pos_lit(12));
      g->lit[3] = pos_lit(12);
      printf("\n");
    }
  } else if (g != g0) {
    printf("*** hash consing bug ***\n");
  }

  // test find 2
  g0 = gate_table_find(&table, orgate_tag(3), input);
  if (g0 == NULL) {
    printf("find: returned NULL\n");
  } else {
    printf("find: returned %p: ", g0);
    print_boolgate(stdout, g0);
    printf("\n");
    check_orgate(g0, l0, l1, l2);
  }
  if (g0 != g) {
    printf("*** hash consing inconsistency between find and get ***\n");
  }
}
static void print_value(StringInfo s, TupleDesc tupdesc, HeapTuple tuple, int i) {
  bool typisvarlena;
  bool isnull;
  Oid typoutput;
  Form_pg_attribute attr = tupdesc->attrs[i];
  Datum origval = fastgetattr(tuple, i + 1, tupdesc, &isnull);
  Oid typid = attr->atttypid;
  getTypeOutputInfo(typid, &typoutput, &typisvarlena);
  if (isnull) {
    appendStringInfoString(s, "null");
  } else if (typisvarlena && VARATT_IS_EXTERNAL_ONDISK(origval)) {
    appendStringInfoString(s, "\"???unchanged-toast-datum???\"");
  } else if (!typisvarlena) {
    print_literal(s, typid, OidOutputFunctionCall(typoutput, origval));
  } else {
    Datum val = PointerGetDatum(PG_DETOAST_DATUM(origval));
    print_literal(s, typid, OidOutputFunctionCall(typoutput, val));
  }
}
static void print_literal_array(FILE *f, literal_t *a, uint32_t n) {
  uint32_t i;

  assert(n > 0);
  i = 0;
  for (;;) {
    print_literal(f, a[i]);
    i ++;
    if (i >= n) break;
    fputc(' ', f);
  }
}
Exemple #14
0
/*
 * Clause
 */
void print_clause(FILE *f, clause_t *cl) {
  uint32_t i;
  literal_t l;


  /*
   * Some problem clauses may be hidden (because one of their
   * literal is true. For such clauses, the first two literals
   * are negated.
   */
  if (cl->cl[0] < 0 || cl->cl[1] < 0) {

    fputc('[', f);
    print_literal(f, - cl->cl[0]);
    fputc(' ', f);
    print_literal(f, - cl->cl[1]);
    i = 2;
    l = cl->cl[i];
    while (l >= 0) {
      fputc(' ', f);
      print_literal(f, l);
      i ++;
      l = cl->cl[i];
    }
    fputc(']', f);

  } else {
    fputc('{', f);
    print_literal(f, cl->cl[0]);
    i = 1;
    l = cl->cl[i];
    while (l >= 0) {
      fputc(' ', f);
      print_literal(f, l);
      i ++;
      l = cl->cl[i];
    }
    fputc('}', f);
  }
}
Exemple #15
0
/*
 * Print assignment
 */
void print_boolean_assignment(FILE *f, smt_core_t *core) {
  prop_stack_t *stack;
  uint32_t i, n;
  literal_t l;

  stack = &core->stack;
  n = stack->top;
  for (i=0; i<n; i++) {
    l = stack->lit[i];
    fputc(' ', f);
    if (is_pos(l)) fputc(' ', f);
    print_literal(f, l);
    fprintf(f, " level = %"PRIu32"\n", core->level[var_of(l)]);
  }
}
Exemple #16
0
/*
 * Print conflict data
 */
void print_conflict(FILE *f, smt_core_t *core) {
  literal_t l;
  uint32_t i;

  if (core->inconsistent) {
    i = 0;
    l = core->conflict[i];
    if (l < 0) {
      fputs("Conflict: empty clause\n", f);
    } else {
      fputs("Conflict:", f);
      while (l >= 0) {
        fputc(' ', f);
        print_literal(f, l);
        i ++;
        l = core->conflict[i];
      }
      fputc('\n', f);
    }

  } else {
    fputs("No conflict\n", f);
  }
}
Exemple #17
0
static void print_literal_expr(struct literal_expr *e, int depth)
{
    print_literal(e->lit, depth);
}
Exemple #18
0
/*
 * Print unit clauses = all the literals in core->stack[0 .. core->nb_units-1]
 */
void print_unit_clause(FILE *f, literal_t l) {
  fputc('{', f);
  print_literal(f, l);
  fputc('}', f);
}