Options

A bitwuzla::Bitwuzla instance is created from a configuration options bitwuzla::Options instance. This options instance must be configured before creating the Bitwuzla instance: after the Bitwuzla instance is created, configuration options are fixed and cannot be changed.

Bitwuzla supports three kinds of options: Boolean options, numeric options and options with option modes. The kind of an option can be queried via bool bitwuzla::Options::is_bool(Option option) const, bool bitwuzla::Options::is_numeric(Option option) const, and bool bitwuzla::Options::is_mode(Option option) const.

Boolean and numeric options are configured via void bitwuzla::Options::set(Option option, uint64_t value), and options with option modes are configured via void bitwuzla::Options::set(Option option, const std::string& value). Any option can also be configured via void bitwuzla::Options::set(const std::string &lng, const std::string &value), where lng is the long name of the option (e.g., "produce-models").

Additionally, it is also possible to configure options in batch via void bitwuzla::Options::set(const std::vector<std::string> &args), where args is a vector of command line option configuration strings, e.g., {"-i", "--produce-models=true", "--produce-unsat-cores true"}.

The configured value of Boolean and numeric options can be queried via uint64_t bitwuzla::Options::get(Option option) const, and the value of an option with modes can be queried via const std::string& bitwuzla::Options::get_mode(Option option) const.

The short name of an option can be queried via const char* bitwuzla::Options::shrt(Option option) const, its long name via const char* bitwuzla::Options::lng(Option option) const, its description via const char* bitwuzla::Options::description(Option option) const, and, if given option is an option with modes, its modes can be queried via std::vector<std::string> bitwuzla::Options::modes(Option option) const.

The option kind is defined via bitwuzla::Option. A comprehensive list of all configurable options is available here.

Example

The source code for this example can be found at examples/c/options.cpp.

/***
 * Bitwuzla: Satisfiability Modulo Theories (SMT) solver.
 *
 * Copyright (C) 2023 by the authors listed in the AUTHORS file at
 * https://github.com/bitwuzla/bitwuzla/blob/main/AUTHORS
 *
 * This file is part of Bitwuzla under the MIT license. See COPYING for more
 * information at https://github.com/bitwuzla/bitwuzla/blob/main/COPYING
 */

#include <bitwuzla/cpp/bitwuzla.h>

#include <iostream>

using namespace bitwuzla;

int
main()
{
  // First, create a Bitwuzla options instance.
  Options options;

  // Enable model generation, which expects a boolean configuration value.
  options.set(Option::PRODUCE_MODELS, true);

  // Increase the verbosity level, which expects an integer value.
  std::cout << "Previous verbosity level: " << options.get(Option::VERBOSITY)
            << std::endl;
  options.set(Option::VERBOSITY, 2);
  std::cout << "Current verbosity level: " << options.get(Option::VERBOSITY)
            << std::endl;

  // Now configure an option that has modes (a choice of configuration values).
  // First, query which bit-vector solver engine is set.
  std::cout << "Default bv solver: " << options.get_mode(Option::BV_SOLVER)
            << std::endl;
  // Then, select the propagation-based local search engine as solver engine.
  options.set(Option::BV_SOLVER, "prop");
  std::cout << "Current engine: " << options.get_mode(Option::BV_SOLVER)
            << std::endl;

  // Now, create a Bitwuzla instance with a new term manager.
  TermManager tm;
  Bitwuzla bitwuzla(tm, options);
  // Check sat (nothing to solve, input formula is empty).
  Result result = bitwuzla.check_sat();
  std::cout << "Expect: sat" << std::endl;
  std::cout << "Bitwuzla: " << result << std::endl;

  return 0;
}

OptionInfo

Bitwuzla offers a compact way to retrieve all information about a configuration option as a bitwuzla::OptionInfo object via bitwuzla::OptionInfo::OptionInfo(). This object is created per option and can be queried for the same information as bitwuzla::Options.