2022-04-04 19:49:30 -07:00
|
|
|
Quickstart Guide
|
|
|
|
|
================
|
|
|
|
|
|
|
|
|
|
First, we create two constants ``x`` and ``y`` of sort ``Real``,
|
|
|
|
|
and two constants ``a`` and ``b`` of sort ``Integer``.
|
|
|
|
|
Notice that these are *symbolic* constants, but not actual values.
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../../examples/api/python/pythonic/quickstart.py
|
2022-05-02 13:13:00 -07:00
|
|
|
:language: python
|
|
|
|
|
:dedent: 4
|
|
|
|
|
:start-after: docs-pythonic-quickstart-1 start
|
|
|
|
|
:end-before: docs-pythonic-quickstart-1 end
|
2022-04-04 19:49:30 -07:00
|
|
|
|
|
|
|
|
We define the following constraints regarding ``x`` and ``y``:
|
|
|
|
|
|
|
|
|
|
.. math::
|
|
|
|
|
|
|
|
|
|
(0 < x) \wedge (0 < y) \wedge (x + y < 1) \wedge (x \leq y)
|
|
|
|
|
|
|
|
|
|
We check whether there is a solution to these constraints:
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../../examples/api/python/pythonic/quickstart.py
|
2022-05-02 13:13:00 -07:00
|
|
|
:language: python
|
|
|
|
|
:dedent: 4
|
|
|
|
|
:start-after: docs-pythonic-quickstart-2 start
|
|
|
|
|
:end-before: docs-pythonic-quickstart-2 end
|
2022-04-04 19:49:30 -07:00
|
|
|
|
|
|
|
|
In this case, there is, so we get output:
|
|
|
|
|
|
|
|
|
|
.. code:: text
|
|
|
|
|
|
|
|
|
|
[x = 1/6, y = 1/6]
|
|
|
|
|
|
|
|
|
|
We can also get an explicit model (assignment) for the constraints.
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../../examples/api/python/pythonic/quickstart.py
|
2022-05-02 13:13:00 -07:00
|
|
|
:language: python
|
|
|
|
|
:dedent: 4
|
|
|
|
|
:start-after: docs-pythonic-quickstart-3 start
|
|
|
|
|
:end-before: docs-pythonic-quickstart-3 end
|
2022-04-04 19:49:30 -07:00
|
|
|
|
|
|
|
|
With the model, we can evaluate variables and terms:
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../../examples/api/python/pythonic/quickstart.py
|
2022-05-02 13:13:00 -07:00
|
|
|
:language: python
|
|
|
|
|
:dedent: 4
|
|
|
|
|
:start-after: docs-pythonic-quickstart-4 start
|
|
|
|
|
:end-before: docs-pythonic-quickstart-4 end
|
2022-04-04 19:49:30 -07:00
|
|
|
|
|
|
|
|
This will print:
|
|
|
|
|
|
|
|
|
|
.. code:: text
|
|
|
|
|
|
|
|
|
|
x: 1/6
|
|
|
|
|
y: 1/6
|
|
|
|
|
x - y: 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
We can also get these values in other forms:
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../../examples/api/python/pythonic/quickstart.py
|
2022-05-02 13:13:00 -07:00
|
|
|
:language: python
|
|
|
|
|
:dedent: 4
|
|
|
|
|
:start-after: docs-pythonic-quickstart-5 start
|
|
|
|
|
:end-before: docs-pythonic-quickstart-5 end
|
2022-04-04 19:49:30 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Next, we assert the same assertions as above, but with integers.
|
|
|
|
|
This time, there is no solution, so "no solution" is printed.
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../../examples/api/python/pythonic/quickstart.py
|
2022-05-02 13:13:00 -07:00
|
|
|
:language: python
|
|
|
|
|
:dedent: 4
|
|
|
|
|
:start-after: docs-pythonic-quickstart-6 start
|
|
|
|
|
:end-before: docs-pythonic-quickstart-6 end
|
2022-04-04 19:49:30 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Example
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
.. api-examples::
|
2025-08-23 17:09:10 -05:00
|
|
|
<examples>/api/python/pythonic/quickstart.py
|
2022-04-04 19:49:30 -07:00
|
|
|
<examples>/api/python/quickstart.py
|
|
|
|
|
<examples>/api/cpp/quickstart.cpp
|
2025-08-23 17:09:10 -05:00
|
|
|
<examples>/api/c/quickstart.c
|
2022-04-04 19:49:30 -07:00
|
|
|
<examples>/api/java/QuickStart.java
|
|
|
|
|
<examples>/api/smtlib/quickstart.smt2
|