Skip to content

Conversation

ammaraskar
Copy link
Contributor

Trying to use z3.SeqMapI from the Python api results in the following error:

Traceback (most recent call last):
  File "z3_messing_around.py", line 6, in <module>
    map_to_index = z3.SeqMapI(
                   ^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/z3/z3.py", line 11344, in SeqMapI
    ctx = _get_ctx(f, s)
          ^^^^^^^^^^^^^^
TypeError: _get_ctx() takes 1 positional argument but 2 were given

With the following testing script:

import z3

nums = z3.Const('nums', z3.SeqSort(z3.IntSort()))
mapped_nums = z3.Const('mapped_nums', nums.sort())

index, value = z3.Ints("index value")
map_to_index = z3.SeqMapI(
    z3.Lambda([index, value], index),
    z3.IntVal(0),
    nums,
)
s = z3.Solver()

s.add(z3.Length(nums) == 3)
s.add(map_to_index == mapped_nums)

print(s.sexpr())
print("SAT: ", s.check())
print(s.model())

@NikolajBjorner NikolajBjorner merged commit eb4e28d into Z3Prover:master Apr 4, 2025
1 check passed
@ammaraskar ammaraskar deleted the patch-1 branch April 4, 2025 23:02
arbipher pushed a commit to arbipher/z3 that referenced this pull request Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants