# Path: xform_expr_basic.py
# def expr_neg(expr):
#     new = expr_neg_if_possible(expr)
#     if new:
#         return new
# 
#     return EXPR("NEG", expr)


from core import *
from xform_expr_basic import expr_neg
))

RULES.append((
    EXPR("^", V("x"), V("x")),
    lambda W: VALUE(0)
))

RULES.append((
    EXPR("+", V("x"), VALUE(0)),
    lambda W: W["x"]
))

RULES.append((
    EXPR("^", V("x"), VALUE(0)),
    lambda W: W["x"]
))

RULES.append((
    EXPR("&", VALUE(V("x1")), VALUE(V("x2"))),
    lambda W: VALUE(W["x1"] & W["x2"])
))

RULES.append((
    EXPR("-", VALUE(V("x1")), VALUE(V("x2"))),
    lambda W: VALUE(W["x1"] - W["x2"])
))

RULES.append((
    EXPR(V("rel_op"), EXPR("+", V("x1"), V("x2")), VALUE(0)),
    lambda W: W["rel_op"] in ("==", "!=", "<", "<=", ">=", ">"),

# Path: xform_expr_basic.py
# def expr_neg(expr):
#     new = expr_neg_if_possible(expr)
#     if new:
#         return new
# 
#     return EXPR("NEG", expr)


# Path: xform_expr_infer.py
from core import *
from xform_expr_basic import expr_neg

))

RULES.append((
    EXPR("^", V("x"), V("x")),
    lambda W: VALUE(0)
))

RULES.append((
    EXPR("+", V("x"), VALUE(0)),
    lambda W: W["x"]
))

RULES.append((
    EXPR("^", V("x"), VALUE(0)),
    lambda W: W["x"]
))

RULES.append((
    EXPR("&", VALUE(V("x1")), VALUE(V("x2"))),
    lambda W: VALUE(W["x1"] & W["x2"])
))

RULES.append((
    EXPR("-", VALUE(V("x1")), VALUE(V("x2"))),
    lambda W: VALUE(W["x1"] - W["x2"])
))

RULES.append((
    EXPR(V("rel_op"), EXPR("+", V("x1"), V("x2")), VALUE(0)),
    lambda W: W["rel_op"] in ("==", "!=", "<", "<=", ">=", ">"),

    lambda W: EXPR(W["rel_op"], W["x1"], expr_neg(W["x2"]))