def optimization_patterns():
    global CACHE_PATTERNS
    if CACHE_PATTERNS:
        return CACHE_PATTERNS

    # Replace and AND with a False value with False
    p1 = SimplePattern("types:LogicalOperator AND op:and", "types:Constant AND value:False")
    p1.replacement = ast.Constant(False)

    p2 = SimplePattern("types:LogicalOperator AND op:and", None, "types:Constant AND value:False")
    p2.replacement = ast.Constant(False)

    # Replace OR with a True value with True
    p3 = SimplePattern("types:LogicalOperator AND op:or", "types:Constant AND value:True")
    p3.replacement = ast.Constant(True)

    p4 = SimplePattern("types:LogicalOperator AND op:or", None, "types:Constant AND value:True")
    p4.replacement = ast.Constant(True)

    # Replace a simple negation
    p5 = SimplePattern("types:NegateOperator", "types:Constant AND value:True")
    p5.replacement = ast.Constant(False)

    p6 = SimplePattern("types:NegateOperator", "types:Constant AND value:False")
    p6.replacement = ast.Constant(True)

    # Remove a no-op push result
    p7 = SimplePattern("types:PushResult", "types:Constant AND value:False")
    p7.replacement = ast.Constant(False)

    # Remove Both nodes when possible
    p8 = SimplePattern("types:Both", "types:Constant AND value:False", "types:Constant AND value:False")
    p8.replacement = ast.Constant(False)

    # Special pattern that replaces Both with one of the children
    p9 = ExtraBothPattern()

    # Remove logical operators when the short-circuit path is useless
    p10 = ShortCircuitLogicalPattern()

    # Remove dead branches
    p11 = DeadBranchPattern()

    # Remove empty sets
    p12 = SimplePattern("types:LiteralSet AND value:frozenset([])")
    p12.replacement = ast.Empty()

    # Replace "Empty contains *" with False
    p13 = SimplePattern("types:ContainsOperator", "types:Empty,Undefined")
    p13.replacement = ast.Constant(False)

    # Remove empty sets (python3)
    p14 = SimplePattern("types:LiteralSet AND value:frozenset()")
    p14.replacement = ast.Empty()

    CACHE_PATTERNS = [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14]
    return CACHE_PATTERNS
Returns the patterns relevant for optimizations
dataset/ETHPy150Open armon/pypred/pypred/optimizer.py/optimization_patterns