Getting Started

Before starting with this guide, one should follow the instructions for Installation.

A Quick Tour through pycarl

We start by launching the python 3 interpreter:

$ python3

First we import pycarl:

>>> import pycarl

Pycarl can use two different number types: gmp and cln. In this example we will use gmp numbers and therefore import the corresponding module:

>>> import pycarl.gmp

Simple arithmetic operations

We start by doing some simple arithmetic operations. First we create two variables x and y:

>>> pycarl.clear_variable_pool()
>>> x = pycarl.Variable("x")
>>> y = pycarl.Variable("y")

We perform some operations on polynomials by using the common arithmetic operations of python:

>>> pol1 = x * x + pycarl.gmp.Integer(2)
>>> pol2 = y + pycarl.gmp.Integer(1)
>>> result = pol1 * pol2
>>> print("({}) * ({}) = {}".format(pol1, pol2, result))
(x^2+2) * (y+1) = x^2*y+2*y+x^2+2