Z3
Z3 is a high-performance theorem prover developed at Microsoft Research. It is a built-in tool of GenAIScript. Z3 is used to solve logical formulas and can be used for various applications, including program verification, constraint solving, and symbolic execution.
GenAIScript uses the WebAssembly-based z3-solver npm package to run Z3.
Z3 tool
The z3
tool (in system.z3) script wraps Z3 as a LLM tool that can be used in GenAIScript.
The tool takes a SMTLIB2 formula as input and returns the Z3 output.
script({ tools: "z3"})
script({ title: "Use Z3 tool to solve SMT2 problems", tools: "z3",})
$`Solve the following problems using Z3:
(declare-const a Int)(declare-fun f (Int Bool) Int)(assert (< a 10))(assert (< (f a true) 100))(check-sat)
The tool won’t handle arbitrary problems, which takes us to the agent.
Z3 agent
The z3
agent (in system.agent-z3) script wraps the z3
tool with a LLM that can (try to) formalize arbitrary problems to SMTLIB2.
script({ tools: ["agent_z3"],})
$`Solve the following problems using Z3:
Imagine we have a number called 'a' that is smaller than 10.We also have a special machine called 'f' that takes a number and a 'true'/'false' answer,and it gives back another number.When we put the number 'a' and the answer “true” into this machine,the number it gives us is smaller than 100.`