Exemple #1
0
def replace_boolean_function_input(function_token, input_index, lispnode_list):
  """ Should replace the input_index th input of the function with the given
      function token with an if-than-else expression that takes the old
      boolean value, and returns #b1 if true of #b0 if false"""
  for lispnode in lispnode_list:
    for f in lispnode.find(function_token):
      if (len(f.parent.children) > input_index) and (f.parent.children[0] == f):
        replacement = LispNode("(ite "+str(f.parent.children[input_index+1])+\
                               " #b1 #b0)")
        replacement.parent = f.parent
        f.parent.children[input_index+1] = replacement
Exemple #2
0
def replace_boolean_function_input(function_token, input_index, lispnode_list):
    """ Should replace the input_index th input of the function with the given
      function token with an if-than-else expression that takes the old
      boolean value, and returns #b1 if true of #b0 if false"""
    for lispnode in lispnode_list:
        for f in lispnode.find(function_token):
            if (len(f.parent.children) > input_index) and (f.parent.children[0]
                                                           == f):
                replacement = LispNode("(ite "+str(f.parent.children[input_index+1])+\
                                       " #b1 #b0)")
                replacement.parent = f.parent
                f.parent.children[input_index + 1] = replacement
Exemple #3
0
def declare_fun_boolean_input(lispnode_list):
  "replace all declare-fun functions with Bool inputs with BitVec 1 inputs"
  for lispnode in lispnode_list:
    for f in lispnode.find("declare-fun"):
      if len(f.parent.children) > 2:
        function_token = f.parent.children[1]
        for input_index in range(len(f.parent.children[2].children)):
          input_description = f.parent.children[2].children[input_index]
          if input_description == "Bool":
            replacement = LispNode("(_ BitVec 1)")
            replacement.parent = f.parent.children[2]
            f.parent.children[2].children[input_index] = replacement
            replace_boolean_function_input(function_token, input_index,
                                             lispnode_list)
Exemple #4
0
def declare_fun_boolean_input(lispnode_list):
    "replace all declare-fun functions with Bool inputs with BitVec 1 inputs"
    for lispnode in lispnode_list:
        for f in lispnode.find("declare-fun"):
            if len(f.parent.children) > 2:
                function_token = f.parent.children[1]
                for input_index in range(len(f.parent.children[2].children)):
                    input_description = f.parent.children[2].children[
                        input_index]
                    if input_description == "Bool":
                        replacement = LispNode("(_ BitVec 1)")
                        replacement.parent = f.parent.children[2]
                        f.parent.children[2].children[
                            input_index] = replacement
                        replace_boolean_function_input(function_token,
                                                       input_index,
                                                       lispnode_list)