kdrag.parsers.microlean.parse
- kdrag.parsers.microlean.parse(s: str, globals=None) ExprRef
- Parse a logical expression into an SMT expression. - >>> parse("x + 1", {"x": smt.Int("x")}) x + 1 >>> x, y = smt.Ints("x y") >>> assert parse("forall (x y : Int), x + 1 = 0 -> x = -1").eq( smt.ForAll([x, y], x + 1 == 0, x == -1)) >>> a = smt.Real("a") >>> assert parse("exists (a : Real), a * a = 2").eq(smt.Exists([a], a * a == 2)) >>> parse("fun (x : Int -> Int) => x 1 = 2") Lambda(x, x[1] == 2) >>> parse("fun (x : Int -> Int -> Int) => x 1 3 = 2") Lambda(x, x[1][3] == 2) >>> parse("f 3 2", {"f": smt.Function("f", smt.IntSort(), smt.IntSort(), smt.IntSort())}) f(3, 2) >>> parse("fun (x : Int) (y : Real) => x + y > 0") Lambda([x, y], ToReal(x) + y > 0) >>> parse(r"forall (x : Int), x >= 0 /\ x < 10") ForAll(x, And(x >= 0, x < 10)) >>> parse(r"forall (x : Int), x >= 0 && x < 10 -> x < 20") ForAll(x, Implies(And(x >= 0, x < 10), x < 20)) >>> parse(r"exists (x : (BitVec 32) -> BitVec 8), x 8 = 5") Exists(x, x[8] == 5) - Parameters:
- s (str) 
- Return type:
- ExprRef