def test_typ(): s1 = "kansas:s" EXPECT_TRUE(Typ.check_equivalence(Typ.create(T_ENTITY), typ(s1))) s2 = [ "lambda", "$0", "e", [ "and", ["state:t", "$0"], [ "exists", "$1", ["and", ["state:t", "$1"], ["loc:t", "mississippi_river:r", "$1"], ["next_to:t", "$0", "$1"]], ], ], ] EXPECT_TRUE(Typ.check_equivalence(Typ.create((T_ENTITY, T_TRUTH)), typ(s2))) s3 = ["argmin", "$0", ["city:t", "$0"], ["population:i", "$0"]] EXPECT_TRUE(Typ.check_equivalence(Typ.create(T_ENTITY), typ(s3))) s4 = "equals:t" EXPECT_TRUE(Typ.check_equivalence(Typ.create((T_ENTITY, T_ENTITY, T_TRUTH)), typ(s4)))
def subexps_typed(sexp, t): return subexps(sexp, lambda x: Typ.check_equivalence(typ(x), t))