def __init__(self, applied_to_arg, root_variable): """ :param applied_to_arg: spf.mr.lambda_.logical_expr.LogicalExpression, :param root_variable: spf.mr.lambda_.logical_expr.LogicalExpression, :return: """ super(ApplyAndSimplify, self).__init__(False) self.applied_once_already = False self.applied_to_arg = applied_to_arg self.root_variable = root_variable self.old_variables_to_new = {} self.arg_vars = GetVariables.of(self.applied_to_arg)
def term_application(expr, arg): new_args = [arg] return Literal(Variable(expr.get_type()) if expr in GetVariables.of(arg) else expr, new_args)
def literal_application(literal, arg): new_args = [arg for arg in literal.get_arguments()] new_args.append(ReplaceVariablesIfPresent.of(arg, GetVariables.of(literal))) return Literal(literal.get_predicate(), new_args)