This is an example in native CVC language:
isblue: STRING -> BOOLEAN;
ASSERT isblue("sky");
ASSERT isblue("water");
QUERY isblue("sky"); //valid
QUERY isblue("pig"); //invalid
How would I write it using the C++ API for CVC4? Couldn't find any documentation on how to do this.
There are some API examples in the source distribution that might help you. In particular, examples/api/combination.cpp creates some functions and predicates and makes some assertions:
https://github.com/CVC4/CVC4/blob/master/examples/api/combination.cpp
In your case, you'll create a predicate type with ExprManager::mkFunctionType(), then you construct an "isblue" predicate with ExprManager::mkVar() giving it that type. It will look something like this (assuming you've done "using namespace CVC4" and #included <cvc4/cvc4.h>):
Then you can assert and query applications of your predicate: