Skip to content

Commit 972423c

Browse files
committed
ty
1 parent 91cceb8 commit 972423c

File tree

18 files changed

+99
-81
lines changed

18 files changed

+99
-81
lines changed

src/kdrag/contrib/fast/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949

5050

5151
def ctxptr(ctx: z3.Context):
52-
return ffibuilder.cast("void *", ctx.ctx.value) # type: ignore
52+
return ffibuilder.cast("void *", ctx.ctx.value) # type: ignore[possibly-missing-attribute]
5353

5454

5555
def astptr(ast: z3.AstRef):
56-
return ffibuilder.cast("void *", ast.as_ast().value) # type: ignore
56+
return ffibuilder.cast("void *", ast.as_ast().value)
5757

5858

5959
def intify(ptr):

src/kdrag/contrib/pcode/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ def sym_execute(
750750
elif max_insns <= 0:
751751
res.append(SimState(memstate1, pc1, path_cond))
752752
else:
753-
todo.append((memstate1, pc1, max_insns, path_cond)) # type: ignore
753+
todo.append((memstate1, pc1, max_insns, path_cond))
754754
return res
755755

756756
def execute_block(self, memstate: MemState, addr: int) -> list[SimState]:

src/kdrag/hypothesis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ def val_of_sort(
238238
return smt_datatype_val(s)
239239
else:
240240
# return smt_generic_val(s) # This is really slow. We're better off just throwing an error
241-
if slow_generic:
242-
return smt_generic_val(s)
243-
else:
244-
raise NotImplementedError(f"Don't know how to generate values for {s}")
241+
# if slow_generic:
242+
# return smt_generic_val(s)
243+
# else:
244+
raise NotImplementedError(f"Don't know how to generate values for {s}")
245245

246246

247247
# def expr_of_sort(s: smt.SortRef):

src/kdrag/kernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __call__(self, *args: "smt.ExprRef | Proof"):
8787
a if isinstance(a, smt.ExprRef) else smt._py2expr(a)
8888
for a in args[n : n + i]
8989
]
90-
acc = instan(subargs, acc) # type: ignore
90+
acc = instan(subargs, acc)
9191
n += i
9292
elif smt.is_implies(self.thm):
9393
x = args[n]

src/kdrag/notation.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,19 @@ def GenericDispatch(default_factory) -> SortDispatch:
240240

241241
or_ = SortDispatch(name="or_", pointwise=True)
242242
"""Sort based dispatch for `|` syntax"""
243-
smt.ExprRef.__or__ = lambda x, y: or_(x, y) # type: ignore
243+
smt.ExprRef.__or__ = lambda x, y: or_(x, y) # type: ignore[invalid-assignment]
244244
smt.QuantifierRef.__or__ = lambda x, y: or_(x, y) # type: ignore
245245
or_.register(smt.BoolSort(), smt.Or)
246246

247247
invert = SortDispatch(name="invert", pointwise=True)
248248
"""Sort based dispatch for `~` syntax"""
249-
smt.ExprRef.__invert__ = lambda x: invert(x) # type: ignore
249+
smt.ExprRef.__invert__ = lambda x: invert(x) # type: ignore[invalid-assignment]
250250
smt.QuantifierRef.__invert__ = lambda x: invert(x) # type: ignore
251251
invert.register(smt.BoolSort(), smt.Not)
252252

253253
lt = SortDispatch(name="lt", pointwise=True)
254254
"""Sort based dispatch for `<` syntax"""
255-
smt.ExprRef.__lt__ = lambda x, y: lt(x, y) # type: ignore
255+
smt.ExprRef.__lt__ = lambda x, y: lt(x, y) # type: ignore[invalid-assignment]
256256
lt.register(smt.IntSort(), lambda x, y: x < y)
257257
lt.register(smt.RealSort(), lambda x, y: x < y)
258258
# Conceptually this kind of makes sense, but SubSet is the more natural thing.
@@ -261,51 +261,51 @@ def GenericDispatch(default_factory) -> SortDispatch:
261261

262262
le = SortDispatch(name="le", pointwise=True)
263263
"""Sort based dispatch for `<=` syntax"""
264-
smt.ExprRef.__le__ = lambda x, y: le(x, y) # type: ignore
264+
smt.ExprRef.__le__ = lambda x, y: le(x, y) # type: ignore[invalid-assignment]
265265
le.register(smt.IntSort(), lambda x, y: x <= y)
266266
le.register(smt.RealSort(), lambda x, y: x <= y)
267267
# le.register(smt.BoolSort(), lambda x, y: smt.Implies(x, y))
268268

269269
ge = SortDispatch(name="ge", pointwise=True)
270270
"""Sort based dispatch for `>=` syntax"""
271-
smt.ExprRef.__ge__ = lambda x, y: ge(x, y) # type: ignore
271+
smt.ExprRef.__ge__ = lambda x, y: ge(x, y) # type: ignore[invalid-assignment]
272272
ge.register(smt.IntSort(), lambda x, y: x >= y)
273273
ge.register(smt.RealSort(), lambda x, y: x >= y)
274274
# ge.register(smt.BoolSort(), lambda x, y: smt.Implies(y, x))
275275

276276
gt = SortDispatch(name="gt", pointwise=True)
277277
"""Sort based dispatch for `>` syntax"""
278-
smt.ExprRef.__gt__ = lambda x, y: gt(x, y) # type: ignore
278+
smt.ExprRef.__gt__ = lambda x, y: gt(x, y) # type: ignore[invalid-assignment]
279279
gt.register(smt.IntSort(), lambda x, y: x > y)
280280
gt.register(smt.RealSort(), lambda x, y: x > y)
281281
# gt.register(smt.BoolSort(), lambda x, y: smt.And(x, smt.Not(y)))
282282

283283
# contains cannot work because python demands a concrete bool.
284284
# contains = SortDispatch(name="contains")
285-
# smt.ExprRef.__contains__ = lambda x, y: contains(x, y) # type: ignore
285+
# smt.ExprRef.__contains__ = lambda x, y: contains(x, y)
286286

287287
eq = SortDispatch(name="eq", default=smt.Eq)
288288
"""Sort based dispatch for `==` syntax"""
289-
smt.ExprRef.__eq__ = lambda x, y: eq(x, y) # type: ignore
289+
smt.ExprRef.__eq__ = lambda x, y: eq(x, y) # type: ignore[invalid-assignment]
290290

291291

292292
ne = SortDispatch(name="ne", default=smt.NEq)
293293
"""Sort based dispatch for `!=` syntax"""
294-
smt.ExprRef.__ne__ = lambda x, y: ne(x, y) # type: ignore
294+
smt.ExprRef.__ne__ = lambda x, y: ne(x, y) # type: ignore[invalid-assignment]
295295

296296
wf = SortDispatch(name="wf")
297297
"""`wf` is a special predicate for well-formedness. It is auto inserted by QForAll and QExists."""
298-
smt.ExprRef.wf = lambda x: wf(x) # type: ignore
298+
smt.ExprRef.wf = lambda x: wf(x)
299299

300300
measure = SortDispatch(name="measure")
301301
"""`measure is an Int value associated with an ExprRef for use in defining well-founded recursion."""
302-
# smt.ExprRef.measure = lambda x: measure(x) # type: ignore
303-
measure.register(smt.IntSort(), lambda x: smt.Abs(x)) # type: ignore
302+
# smt.ExprRef.measure = lambda x: measure(x)
303+
measure.register(smt.IntSort(), lambda x: smt.Abs(x))
304304
measure.register(smt.BoolSort(), lambda x: smt.If(x, smt.IntVal(1), smt.IntVal(0)))
305305

306306
choose = SortDispatch(name="choose")
307307
"""Sort based dispatch for Hilbert choice operator."""
308-
# smt.ExprRef.choose = lambda P: choose(P) # type: ignore
308+
# smt.ExprRef.choose = lambda P: choose(P)
309309

310310
# These are of questionable utility, but conceptually should be here.
311311
forall = SortDispatch(name="forall")
@@ -356,7 +356,7 @@ def induct_default(x, P):
356356

357357
induct = SortDispatch(name="induct", default=induct_default)
358358
"""Sort based dispatch for induction principles. Should instantiate an induction scheme for variable x and predicate P"""
359-
smt.ExprRef.induct = lambda x, P: induct(x, P) # type: ignore
359+
smt.ExprRef.induct = lambda x, P: induct(x, P)
360360

361361

362362
def induct_int(x, P):

src/kdrag/parsers/microlean.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def sort(tree: Tree, env: Env) -> smt.SortRef:
135135
return smt.ArraySort(sort(left, env), sort(right, env))
136136
# return smt.ArraySort(*(sort(s) for s in left.children), sort(right,env))
137137
case Tree("bitvecsort", [n]):
138-
n1 = int(n) # type: ignore
138+
n1 = int(n)
139139
return smt.BitVecSort(n1)
140140
case Tree("sortlit", [name]):
141141
if name == "Int":
@@ -203,10 +203,10 @@ def quant(vs, body_tree, q, env) -> smt.QuantifierRef:
203203
def _pattern_head(tree, env: Env) -> smt.ExprRef:
204204
match tree:
205205
case Tree("const", [name, *attrs]):
206-
res = env[name] # type: ignore
206+
res = env[name]
207207
for attr in attrs:
208-
res = getattr(res, str(attr)) # type: ignore
209-
return res # type: ignore
208+
res = getattr(res, str(attr))
209+
return res
210210
case Tree("pat_app", [inner]):
211211
return _pattern_head(inner, env)
212212
case _:
@@ -223,20 +223,20 @@ def pattern(tree, env: Env, expected_sort: smt.SortRef | None) -> smt.ExprRef:
223223
text = str(n)
224224
if "." in text:
225225
return smt.RealVal(text)
226-
return int(text) # type: ignore
226+
return int(text) # type: ignore[invalid-return-type]
227227
case Tree("const", [name, *attrs]):
228228
if name in env.locals or name in env.globals:
229-
res = env[name] # type: ignore
229+
res = env[name]
230230
else:
231231
if expected_sort is None:
232232
raise ValueError("Cannot infer sort for pattern variable", name)
233233
res = smt.Const(str(name), expected_sort)
234234
env[str(name)] = res
235235
for attr in attrs:
236-
res = getattr(res, str(attr)) # type: ignore
236+
res = getattr(res, str(attr))
237237
if isinstance(res, smt.FuncDeclRef) and res.arity() == 0:
238238
return res()
239-
return res # type: ignore
239+
return res
240240
case Tree("true", []):
241241
return smt.BoolVal(True)
242242
case Tree("false", []):
@@ -264,12 +264,12 @@ def expr(tree, env: Env, expected_sort: Optional[smt.SortRef] = None) -> smt.Exp
264264
text = str(n)
265265
if "." in text:
266266
return smt.RealVal(text)
267-
return int(text) # type: ignore
267+
return int(text) # type: ignore[invalid-return-type]
268268
case Tree("const", [name, *attrs]):
269-
res = env[name] # type: ignore
269+
res = env[name]
270270
for attr in attrs:
271-
res = getattr(res, str(attr)) # type: ignore
272-
return res # type: ignore
271+
res = getattr(res, str(attr))
272+
return res
273273
case Tree("true", []):
274274
return smt.BoolVal(True)
275275
case Tree("false", []):

src/kdrag/parsers/tptp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from enum import Enum
1010
from typing import Any, Optional, cast
1111

12-
import lark # type: ignore[reportMissingImports]
12+
import lark
1313
import kdrag.smt as smt
1414

1515
# https://github.com/inpefess/tptp-lark-parser/blob/master/tptp_lark_parser/resources/TPTP.lark
@@ -459,7 +459,7 @@ def _type_repr_to_sort(
459459
rng_sort = self._type_repr_to_sort(rng)
460460
if isinstance(rng_sort, tuple):
461461
rng_doms, rng_rng = rng_sort
462-
dom_sorts.extend(cast(list[smt.SortRef], rng_doms)) # type: ignore
462+
dom_sorts.extend(cast(list[smt.SortRef], rng_doms))
463463
rng_sort = rng_rng
464464
return (
465465
cast(list[smt.SortRef], dom_sorts),

src/kdrag/reflect.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -449,37 +449,37 @@ def rec(expr: ast.expr) -> smt.ExprRef:
449449
# case ast.UnaryOp(ast.UAdd(), operand):
450450
# return +rec(operand)
451451
case ast.UnaryOp(ast.Not(), operand):
452-
return ~rec(operand) # type: ignore
452+
return ~rec(operand)
453453
case ast.UnaryOp(ast.USub(), operand):
454-
return -rec(operand) # type: ignore
454+
return -rec(operand)
455455
case ast.UnaryOp(ast.Invert(), operand):
456-
return ~rec(operand) # type: ignore
456+
return ~rec(operand)
457457
case ast.UnaryOp(_, operand):
458458
raise NotImplementedError(f"UnaryOp {expr.op}")
459459
case ast.BinOp(left=l, op=ast.Add(), right=r):
460-
return rec(l) + rec(r) # type: ignore
460+
return rec(l) + rec(r)
461461
case ast.BinOp(left=l, op=ast.Sub(), right=r):
462-
return rec(l) - rec(r) # type: ignore
462+
return rec(l) - rec(r)
463463
case ast.BinOp(left=l, op=ast.Mult(), right=r):
464-
return rec(l) * rec(r) # type: ignore
464+
return rec(l) * rec(r)
465465
case ast.BinOp(left=l, op=ast.Div(), right=r):
466-
return rec(l) / rec(r) # type: ignore
466+
return rec(l) / rec(r)
467467
case ast.BinOp(left=l, op=ast.Mod(), right=r):
468-
return rec(l) % rec(r) # type: ignore
468+
return rec(l) % rec(r)
469469
case ast.BinOp(left=l, op=ast.Pow(), right=r):
470-
return rec(l) ** rec(r) # type: ignore
470+
return rec(l) ** rec(r)
471471
case ast.BinOp(left=l, op=ast.LShift(), right=r):
472-
return rec(l) << rec(r) # type: ignore
472+
return rec(l) << rec(r)
473473
case ast.BinOp(left=l, op=ast.RShift(), right=r):
474-
return rec(l) >> rec(r) # type: ignore
474+
return rec(l) >> rec(r)
475475
case ast.BinOp(left=l, op=ast.BitOr(), right=r):
476-
return rec(l) | rec(r) # type: ignore
476+
return rec(l) | rec(r)
477477
case ast.BinOp(left=l, op=ast.BitXor(), right=r):
478-
return rec(l) ^ rec(r) # type: ignore
478+
return rec(l) ^ rec(r)
479479
case ast.BinOp(left=l, op=ast.BitAnd(), right=r):
480-
return rec(l) & rec(r) # type: ignore
480+
return rec(l) & rec(r)
481481
case ast.BinOp(left=l, op=ast.FloorDiv(), right=r):
482-
return rec(l) // rec(r) # type: ignore
482+
return rec(l) // rec(r)
483483
case ast.BoolOp(op=ast.And(), values=values):
484484
return smt.And(*map(rec, values))
485485
case ast.BoolOp(op=ast.Or(), values=values):
@@ -495,13 +495,13 @@ def rec(expr: ast.expr) -> smt.ExprRef:
495495
case ast.NotEq():
496496
acc.append(left != right)
497497
case ast.Lt():
498-
acc.append(left < right) # type: ignore
498+
acc.append(left < right)
499499
case ast.LtE():
500-
acc.append(left <= right) # type: ignore
500+
acc.append(left <= right)
501501
case ast.Gt():
502-
acc.append(left > right) # type: ignore
502+
acc.append(left > right)
503503
case ast.GtE():
504-
acc.append(left >= right) # type: ignore
504+
acc.append(left >= right)
505505
case _:
506506
raise NotImplementedError(f"Compare {op}")
507507
left = right
@@ -696,7 +696,7 @@ def reflect(f, globals=None) -> smt.FuncDeclRef:
696696
assert z3fun.arity() == z3fun1.arity() and all(
697697
z3fun.domain(i) == z3fun1.domain(i) for i in range(z3fun.arity())
698698
)
699-
return functools.update_wrapper(z3fun1, f) # type: ignore
699+
return functools.update_wrapper(z3fun1, f) # type: ignore[invalid-return-type]
700700

701701

702702
def datatype(s: str, locals=None, globals=None) -> smt.DatatypeSortRef:

src/kdrag/smt.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,12 @@ class ExprRef(AstRef):
593593
...
594594
def __xor__(self, other): # -> ExprRef:
595595
...
596+
def __lshift__(self, other): # -> ExprRef:
597+
...
598+
def __rshift__(self, other): # -> ExprRef:
599+
...
600+
def __pow__(self, other): # -> ExprRef:
601+
...
596602
def __invert__(self): # -> ExprRef:
597603
...
598604
def __call__(self, *args): # -> ExprRef:

src/kdrag/solvers/egraph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def dot(self, filename: str = "egraph") -> graphviz.Digraph:
351351
eclasses = self.eclasses()
352352

353353
for eid, funcs in eclasses.items():
354-
with dot.subgraph(name=f"cluster_{eid}") as c: # type: ignore
354+
with dot.subgraph(name=f"cluster_{eid}") as c:
355355
assert c is not None
356356
c.attr(style="dotted,rounded")
357357
rep = f"e_rep_{eid}"

0 commit comments

Comments
 (0)