def beta_reduce(term): if not qterm.is_combination(term): return term if qterm.is_abstraction(term.operator): return substitute(term.operand, term.operator.bound, term.operator.body) return term
def apply_to_term(self, term): if qterm.is_atom(term): return self.apply_to_atom(term) elif qterm.is_combination(term): return self.apply_to_combination(term) elif qterm.is_abstraction(term): return self.apply_to_abstraction(term) else: raise Exception('unrecognized term')