Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you call variables are (technically) called uninterpreted constants in Z3. Values (such as <code>1</code>, <code>true</code>, <code>#x01</code>) are called interpreted constants. So, in principle, a fast way to check whether <code>a</code> is a "variable" can be done using the following piece of code:</p> <pre><code>is_const(a) and a.decl().kind() == Z3_OP_UNINTERPRETED </code></pre> <p>This piece of code works for everything, but datatypes. After trying your example, I realized that Z3 is incorrectly returning <code>Z3_OP_UNINTERPRETED</code> for datatype constructors. I fixed that for Z3 4.2. In the meantime, you can use the following workaround where the function <code>is_datatype_const_value(a)</code> returns <code>True</code> is <code>a</code> is a constant constructor.</p> <pre><code>def is_datatype_sort(s): return s.kind() == Z3_DATATYPE_SORT def is_datatype_constructor(x): s = x.sort() if is_datatype_sort(s): n = s.num_constructors() f = x.decl() for i in range(n): c = s.constructor(i) if eq(c, f): return True return False # Return True if x is a constant constructor, that is, a constructor without arguments. def is_datatype_const_value(x): return is_const(x) and is_datatype_constructor(x) </code></pre> <p>Then, the following code catches all uninterpreted constants:</p> <pre><code> is_const(a) and a.decl().kind() == Z3_OP_UNINTERPRETED and not is_datatype_const_value(a) </code></pre> <p>The following link contains a complete example. <a href="http://rise4fun.com/Z3Py/vjb" rel="nofollow">http://rise4fun.com/Z3Py/vjb</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload