MCPcopy Create free account
hub / github.com/BasisResearch/lean.py / FiniteSetMap

Function FiniteSetMap

lean_py/z3/core.py:3726–3742  ·  view source on GitHub ↗

Map function f over finite set s.

(f: FuncDeclRef, s: ArrayRef)

Source from the content-addressed store, hash-verified

3724
3725
3726def FiniteSetMap(f: FuncDeclRef, s: ArrayRef) -> ArrayRef:
3727 """Map function f over finite set s."""
3728 sort = s._sort
3729 if not isinstance(sort, ArraySortRef):
3730 raise TypeError("FiniteSetMap requires set (array) argument")
3731 dom = sort.domain()
3732 i = Const("__fsm_i", f._range)
3733 x = Const("__fsm_x", dom)
3734 # {f(x) | x in s} == {y | exists x, x in s /\ f(x) == y}
3735 # Simplified: use Lambda over the range
3736 fx = f(x)
3737 mem = BoolRef(SelectNode(s._ast, x._ast), _merge(s._vars, x._vars))
3738 body = And(mem, fx == i)
3739 exists_body = Exists([x], body)
3740 lam = Lambda(i, exists_body)
3741 result_sort = SetSort(f._range)
3742 return ArrayRef(lam._ast, result_sort, _merge(s._vars, frozenset([(f._name, f._ast_sort)])))
3743
3744
3745def FiniteSetFilter(f: FuncDeclRef, s: ArrayRef) -> ArrayRef:

Callers

nothing calls this directly

Calls 10

SelectNodeClass · 0.90
ConstFunction · 0.85
BoolRefClass · 0.85
_mergeFunction · 0.85
AndFunction · 0.85
ExistsFunction · 0.85
LambdaFunction · 0.85
SetSortFunction · 0.85
ArrayRefClass · 0.85
domainMethod · 0.45

Tested by

no test coverage detected