Hello World

This example shows the very basic usage of the API. We create a solver, declare a Boolean variable and check whether it is entailed (by true, as nothing has been asserted to the solver).

examples/api/cpp/helloworld.cpp

 1/******************************************************************************
 2 * This file is part of the cvc5 project.
 3 *
 4 * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
 5 * in the top-level source directory and their institutional affiliations.
 6 * All rights reserved.  See the file COPYING in the top-level source
 7 * directory for licensing information.
 8 * ****************************************************************************
 9 *
10 * A very simple cvc5 example.
11 */
12
13#include <cvc5/cvc5.h>
14
15#include <iostream>
16
17using namespace cvc5;
18
19int main()
20{
21  TermManager tm;
22  Solver slv(tm);
23  Term helloworld = tm.mkConst(tm.getBooleanSort(), "Hello World!");
24  std::cout << helloworld << " is " << slv.checkSatAssuming(helloworld)
25            << std::endl;
26  return 0;
27}