Build an effectful handler that maps Term ops → Lean.Expr builders. *depth* is the number of forallE binders above the expression scope. Variable ``var_names[i]`` maps to ``bvar(depth - 1 - i)``.
(eb: ExprBuilder, var_names, var_ops, depth)
| 121 | |
| 122 | |
| 123 | def _make_expr_handler(eb: ExprBuilder, var_names, var_ops, depth): |
| 124 | """Build an effectful handler that maps Term ops → Lean.Expr builders. |
| 125 | |
| 126 | *depth* is the number of forallE binders above the expression scope. |
| 127 | Variable ``var_names[i]`` maps to ``bvar(depth - 1 - i)``. |
| 128 | """ |
| 129 | int_ops = defdata.dispatch(int) |
| 130 | h = {} |
| 131 | |
| 132 | for i, name in enumerate(var_names): |
| 133 | bv = eb.mk_bvar(depth - 1 - i) |
| 134 | h[var_ops[name]] = (lambda bv=bv: lambda: bv)(bv) |
| 135 | |
| 136 | def coerce(x): |
| 137 | return eb.mk_int(x) if isinstance(x, int) else x |
| 138 | |
| 139 | h[int_ops.__add__] = lambda a, b: eb.mk_int_add(coerce(a), coerce(b)) |
| 140 | h[int_ops.__sub__] = lambda a, b: eb.mk_int_sub(coerce(a), coerce(b)) |
| 141 | h[int_ops.__mul__] = lambda a, b: eb.mk_int_mul(coerce(a), coerce(b)) |
| 142 | h[int_ops.__gt__] = lambda a, b: eb.mk_int_gt(coerce(a), coerce(b)) |
| 143 | h[int_ops.__ge__] = lambda a, b: eb.mk_int_ge(coerce(a), coerce(b)) |
| 144 | h[int_ops.__lt__] = lambda a, b: eb.mk_int_lt(coerce(a), coerce(b)) |
| 145 | h[int_ops.__le__] = lambda a, b: eb.mk_int_le(coerce(a), coerce(b)) |
| 146 | return h |
| 147 | |
| 148 | |
| 149 | def _build_vc_expr(eb: ExprBuilder, vc_term, var_names, var_ops, precond_terms): |
no test coverage detected