Exemplo n.º 1
0
static composite_t *update2(eterm_t f, occ_t x, occ_t y, occ_t v) {
  occ_t aux[2];

  aux[0] = x;
  aux[1] = y;
  return new_update_composite(pos_occ(f), 2, aux, v);
}
Exemplo n.º 2
0
/*
 * 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);
}
Exemplo n.º 3
0
/*
 * Test constructors
 */
static composite_t *apply2(eterm_t f, occ_t x, occ_t y) {
  occ_t aux[2];

  aux[0] = x;
  aux[1] = y;
  return new_apply_composite(pos_occ(f), 2, aux);
}
Exemplo n.º 4
0
static void test_equalities(uint32_t n) {
  uint32_t k, l;
  arena_t m;

  init_arena(&m);
  for (k=0; k<n; k++) {
    arena_push(&m);
    for (l=0; l<n; l++) {
      show_label(k);
      if (k != l) show_label(l);

      test_eq(&m, pos_occ(k), pos_occ(l));
      test_eq(&m, pos_occ(k), neg_occ(l));
      test_eq(&m, neg_occ(k), pos_occ(l));
      test_eq(&m, neg_occ(k), neg_occ(l));
      printf("\n");
    }
    arena_pop(&m);
  }
  delete_arena(&m);
}
Exemplo n.º 5
0
static void test_disjunctions(uint32_t n) {
  uint32_t t1, t2, t3;
  arena_t m;

  init_arena(&m);
  for (t1=0; t1<n; t1++) {
    arena_push(&m);

    for (t2=0; t2<n; t2++) {
      for (t3=0; t3<n; t3++) {
	show_label(t1);
	if (t1 != t2) show_label(t2);
	if (t1 != t3 && t2 != t3) show_label(t3);
	test_or3(&m, pos_occ(t1), pos_occ(t2), pos_occ(t3));
	printf("\n");
      }
    }

    arena_pop(&m);
  }
  delete_arena(&m);
}
Exemplo n.º 6
0
static void build_composites() {
  composite[0] = pair(pos_occ(a), neg_occ(a));
  composite[0]->id = 100;
  composite[1] = pair(pos_occ(a), pos_occ(a));
  composite[1]->id = 101;
  composite[2] = pair(neg_occ(a), pos_occ(a));
  composite[2]->id = 102;
  composite[3] = pair(neg_occ(a), neg_occ(a));
  composite[3]->id = 103;

  composite[4] = pair(pos_occ(a), true_occ);
  composite[4]->id = 104;
  composite[5] = pair(pos_occ(a), false_occ);
  composite[5]->id = 105;
  composite[6] = pair(neg_occ(a), pos_occ(b));
  composite[6]->id = 106;
  composite[7] = pair(neg_occ(a), neg_occ(b));
  composite[7]->id = 107;

  composite[8] = apply2(f, pos_occ(c), pos_occ(c));
  composite[8]->id = 108;
  composite[9] = update2(f, pos_occ(c), neg_occ(d), pos_occ(h));
  composite[9]->id = 109;

  composite[10] = lambda(pos_occ(a), 0);
  composite[10]->id = 110;
  composite[11] = lambda(pos_occ(a), 1);
  composite[11]->id = 110;
}
Exemplo n.º 7
0
void print_class_of_term(FILE *f, egraph_t *egraph, eterm_t t) {
  print_class_of_occ(f, egraph, pos_occ(t));
}
Exemplo n.º 8
0
/*
 * Test 1: construct simple terms, push/pop
 */
static void test1(void) {
  eterm_t tx, ty;
  occ_t x, y;
  type_t u;

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

  init_solver(&egraph, &core);

  u = yices_new_uninterpreted_type();

  // create x and y
  printf("---> building x and y\n");
  tx = egraph_make_variable(&egraph, u);
  x = pos_occ(tx);

  ty = egraph_make_variable(&egraph, u);
  y = pos_occ(ty);

  // test push/pop
  printf("---> push\n");
  smt_push(&core);

  // create (eq x y)
  printf("---> building (eq x y)\n");
  (void) egraph_make_eq(&egraph, x, y);

  // create (eq y y)
  printf("---> building (eq x x)\n");
  (void) egraph_make_eq(&egraph, y, y);

  print_solver(&egraph, &core);

  // empty push
  printf("---> push\n");
  smt_push(&core);

  // start search + propagate + end_search
  printf("---> propagation test 1\n");
  start_search(&core);
  smt_process(&core);
  end_search_unknown(&core);
  print_solver(&egraph, &core);

  printf("---> pop 1\n");
  smt_pop(&core);
  print_solver(&egraph, &core);

  // start search + propagate + end_search
  printf("---> propagation test 2\n");
  start_search(&core);
  smt_process(&core);
  end_search_unknown(&core);
  print_solver(&egraph, &core);


  printf("---> pop 2\n");
  smt_pop(&core);
  print_solver(&egraph, &core);

  // reset
  reset_solver(&egraph, &core);
  print_solver(&egraph, &core);

  delete_solver(&egraph, &core);
}