# ---------- Variables ---------- # boolean.variable('b') boolean.variable('c') # ---------- Rewrite rules ---------- # # not(true) -> false. boolean.rewrite_rule(boolean.not_(boolean.true()), boolean.false()) # not(false) -> true. boolean.rewrite_rule(boolean.not_(boolean.false()), boolean.true()) # and(b, false) -> false. boolean.rewrite_rule(boolean.and_(boolean.b(), boolean.false()), boolean.false()) # and(b, true) -> b. boolean.rewrite_rule(boolean.and_(boolean.b(), boolean.true()), boolean.b()) # or(b, false) -> b. boolean.rewrite_rule(boolean.or_(boolean.b(), boolean.false()), boolean.b()) # or(b, true) -> true. boolean.rewrite_rule(boolean.or_(boolean.b(), boolean.true()), boolean.true()) generic = GenericSort() generic.operation('equal', (generic, generic)) boolean.rewrite_rule(generic.equal(boolean.b(), boolean.c()), boolean.equal(boolean.b(), boolean.c()))
if i < 26: c_upper = c.upper() else: c_upper = None for j, c2 in enumerate(chars): if j < 26: c2_upper = c2.upper() else: c2_upper = None if c == c2: rhs = boolean.true() else: rhs = boolean.false() char.rewrite_rule(char.equal(char.__dict__[c](), char.__dict__[c2]()), rhs) if c_upper: if c_upper == c2: rhs = boolean.true() else: rhs = boolean.false() char.rewrite_rule( char.equal(char.__dict__[c_upper](), char.__dict__[c2]()), rhs) if c2_upper: if c == c2_upper: rhs = boolean.true() else: rhs = boolean.false()