File: union_sort.py

package info (click to toggle)
z3 4.13.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 33,364 kB
  • sloc: cpp: 501,803; python: 16,788; cs: 10,567; java: 9,687; ml: 3,282; ansic: 2,531; sh: 162; javascript: 37; makefile: 32
file content (20 lines) | stat: -rw-r--r-- 543 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Copyright Microsoft Corporation 2019
# This example illustrates the use of union types
# from the Python API. It is given as an example
# as response to #2215.

from z3 import *

u = Datatype('IntOrString')
u.declare('IntV', ('int', IntSort()))
u.declare('StringV', ('string', StringSort()))
IntOrString = u.create()
StringV = IntOrString.StringV
IntV = IntOrString.IntV

print(IntV(1))
print(StringV(StringVal("abc")))
print(IntV(1).sort())
print(IntV(1) == StringV(StringVal("abc")))
s = String('s')
print(simplify(IntV(1) == StringV(s)))