コード例 #1
0
void
btor_extract_lambdas (Btor * btor)
{
  assert (btor);

  unsigned num_lambdas;
  double start, delta;
  BtorPtrHashTable *map_value_index, *map_lambda_base;
  BtorMemMgr *mm;

  start = btor_time_stamp ();

  mm = btor->mm;
  /* maps for each array values to stacks of indices */
  map_value_index = btor_new_ptr_hash_table (mm, 0, 0);
  /* contains the base array for each write chain */
  map_lambda_base = btor_new_ptr_hash_table (mm, 0, 0);
  btor_init_substitutions (btor);

  /* collect lambdas that are at the top of lambda chains */
  collect_indices_writes (btor, map_value_index, map_lambda_base);
  /* top level equality pre-initialization */
  collect_indices_top_eqs (btor, map_value_index);
  num_lambdas = extract_lambdas (btor, map_value_index, map_lambda_base);
  btor_delete_ptr_hash_table (map_lambda_base);
  btor_delete_ptr_hash_table (map_value_index);

  btor_substitute_and_rebuild (btor, btor->substitutions, 0);
  btor_delete_substitutions (btor);
  delta = btor_time_stamp () - start;
  BTOR_MSG (btor->msg, 1,
            "extracted %u lambdas in %.3f seconds", num_lambdas, delta);
}
コード例 #2
0
ファイル: btorsat.c プロジェクト: hellok/kint
int
btor_sat_sat (BtorSATMgr * smgr, int limit)
{
  double start = btor_time_stamp ();
  int res;
  assert (smgr != NULL);
  assert (smgr->initialized);
  btor_msg_sat (smgr, 2, "calling SAT solver %s", smgr->name);
  assert (!smgr->satcalls || smgr->inc_required);
  smgr->satcalls++;
  res = smgr->api.sat (smgr, limit);
  smgr->sat_time += btor_time_stamp () - start;
  return  res;
}
コード例 #3
0
void
btor_eliminate_applies (Btor * btor)
{
  assert (btor);

  int num_applies, num_applies_total = 0, round;
  double start, delta;
  BtorPtrHashTable *apps;
  BtorNode *app, *fun;
  BtorNodeIterator it;
  BtorHashTableIterator h_it;
  BtorMemMgr *mm;

  if (btor->lambdas->count == 0)
    return;

  start = btor_time_stamp ();

  mm = btor->mm;
  round = 1;

  /* NOTE: in some cases substitute_and_rebuild creates applies that can be
   * beta-reduced. this can happen when parameterized applies become not
   * parameterized. hence, we beta-reduce applies until fix point.
   */
  do
    {
      apps = btor_new_ptr_hash_table (mm,
                                      (BtorHashPtr) btor_hash_exp_by_id,
                                      (BtorCmpPtr) btor_compare_exp_by_id);

      /* collect function applications */
      btor_init_node_hash_table_iterator (&h_it, btor->lambdas);
      while (btor_has_next_node_hash_table_iterator (&h_it))
        {
          fun = btor_next_node_hash_table_iterator (&h_it);

          btor_init_apply_parent_iterator (&it, fun);
          while (btor_has_next_apply_parent_iterator (&it))
            {
              app = btor_next_apply_parent_iterator (&it);

              if (btor_find_in_ptr_hash_table (apps, app))
                continue;

              if (app->parameterized)
                continue;

              btor_insert_in_ptr_hash_table (apps, btor_copy_exp (btor, app));
            }
        }

      num_applies = apps->count;
      num_applies_total += num_applies;
      BTOR_MSG (btor->msg, 1, "eliminate %d applications in round %d",
                num_applies, round);

      btor_substitute_and_rebuild (btor, apps, -1);

      btor_init_node_hash_table_iterator (&h_it, apps);
      while (btor_has_next_node_hash_table_iterator (&h_it))
        btor_release_exp (btor, btor_next_node_hash_table_iterator (&h_it));
      btor_delete_ptr_hash_table (apps);
      round++;
    }
  while (num_applies > 0);

#ifndef NDEBUG
  btor_init_node_hash_table_iterator (&h_it, btor->lambdas);
  while (btor_has_next_node_hash_table_iterator (&h_it))
    {
      fun = btor_next_node_hash_table_iterator (&h_it);

      btor_init_apply_parent_iterator (&it, fun);
      while (btor_has_next_apply_parent_iterator (&it))
        {
          app = btor_next_apply_parent_iterator (&it);
          assert (app->parameterized);
        }
    }
#endif

  delta = btor_time_stamp () - start;
  btor->time.betareduce += delta;
  BTOR_MSG (btor->msg, 1, "eliminated %d function applications in %.1f seconds",
            num_applies_total, delta);
  assert (btor_check_all_hash_tables_proxy_free_dbg (btor));
  assert (btor_check_all_hash_tables_simp_free_dbg (btor));
  assert (btor_check_unique_table_children_proxy_free_dbg (btor));
}
コード例 #4
0
void
btor_process_skeleton (Btor * btor)
{
  BtorPtrHashTable * ids;
  BtorNodePtrStack unmark_stack;
  int count, fixed;
  BtorNodePtrStack work_stack;
  BtorMemMgr * mm = btor->mm;
  BtorHashTableIterator it;
  double start, delta;
  int res, lit, val;
  BtorNode * exp;
  LGL * lgl;

  start = btor_time_stamp ();

  ids = btor_new_ptr_hash_table (mm,
          (BtorHashPtr) btor_hash_exp_by_id,
          (BtorCmpPtr) btor_compare_exp_by_id);

  lgl = lglinit ();
  lglsetprefix (lgl, "[lglskel] ");

  if (btor->options.verbosity.val >= 2)
    {
      lglsetopt (lgl, "verbose", btor->options.verbosity.val - 1);
      lglbnr ("Lingeling", "[lglskel] ", stdout);
      fflush (stdout);
    }
  else
    lglsetopt (lgl, "verbose", -1);        

  count = 0;

  BTOR_INIT_STACK (work_stack);
  BTOR_INIT_STACK (unmark_stack);

  btor_init_node_hash_table_iterator (&it, btor->synthesized_constraints);
  btor_queue_node_hash_table_iterator (&it, btor->unsynthesized_constraints);
  while (btor_has_next_node_hash_table_iterator (&it))
    {
      count++;
      exp = btor_next_node_hash_table_iterator (&it);
      assert (btor_get_exp_width (btor, exp) == 1);
      process_skeleton_tseitin (btor, lgl,
        &work_stack, &unmark_stack, ids, exp);
      lgladd (lgl, process_skeleton_tseitin_lit (ids, exp));
      lgladd (lgl, 0);
    }

  BTOR_RELEASE_STACK (mm, work_stack);

  while (!BTOR_EMPTY_STACK (unmark_stack))
    {
      exp = BTOR_POP_STACK (unmark_stack);
      assert (!BTOR_IS_INVERTED_NODE (exp));
      assert (exp->mark);
      exp->mark = 0;
    }

  BTOR_RELEASE_STACK (mm, unmark_stack);

  BTOR_MSG (btor->msg, 1, "found %u skeleton literals in %d constraints",
                ids->count, count);

  res = lglsimp (lgl, 0);

  if (btor->options.verbosity.val)
    {
      BTOR_MSG (btor->msg, 1, "skeleton preprocessing result %d", res);
      lglstats (lgl);
    }

  fixed = 0;

  if (res == 20)
    {
      BTOR_MSG (btor->msg, 1, "skeleton inconsistent");
      btor->inconsistent = 1;
    }
  else
    {
      assert (res == 0 || res == 10);
      btor_init_node_hash_table_iterator (&it, ids);
      while (btor_has_next_node_hash_table_iterator (&it))
        {
          exp = btor_next_node_hash_table_iterator (&it);
          assert (!BTOR_IS_INVERTED_NODE (exp));
          lit = process_skeleton_tseitin_lit (ids, exp);
          val = lglfixed (lgl, lit);
          if (val)
            {
              if (!btor_find_in_ptr_hash_table (
                    btor->synthesized_constraints, exp) &&
                  !btor_find_in_ptr_hash_table (
                    btor->unsynthesized_constraints, exp))
                {
                  if (val < 0)
                    exp = BTOR_INVERT_NODE (exp);
                  btor_assert_exp (btor, exp);
                  btor->stats.skeleton_constraints++;
                  fixed++;
                }
            }
          else
            {
              assert (!btor_find_in_ptr_hash_table (
                         btor->synthesized_constraints, exp));
              assert (!btor_find_in_ptr_hash_table (
                         btor->unsynthesized_constraints, exp));
            }
        }
    }

  btor_delete_ptr_hash_table (ids);
  lglrelease (lgl);

  delta = btor_time_stamp () - start;
  btor->time.skel += delta;
  BTOR_MSG (btor->msg, 1,
      "skeleton preprocessing produced %d new constraints in %.1f seconds",
      fixed, delta);
  assert (btor_check_id_table_mark_unset_dbg (btor));
}