def cross(l_goals, r_goals): """Takes a list of constraints T <= X and a list of constraints X <= U and returns the set of constraints T <= U for every U and T. We take the empty telescope. Arguments: - `l_goals`: a list of goals of the form T <= X - `r_goals`: a list of goals of the form X <= U """ return [Goal(e.nullctxt(), e.Sub(c.prop.lhs, d.prop.rhs))\ for c in l_goals for d in r_goals]
def min_type(types, ctxt): """Get the minimum of a list of types. Since it can be undecidable to compare types in general, we take T <= U iff it can be proven using destruct >> trivial. Return None if no minimum is found. Arguments: - `types`: a list of types - `ctxt`: a goal context """ for t in types: min_list = [Goal(e.nullctxt(), e.Sub(t, u))\ for u in types] min_goal = Goals('min_goal', ctxt, goals=min_list) min_goal.solve_with(trivial) if min_goal.is_solved(): return t return None
def visit_sub(self, expr, *args, **kwargs): lhs = self.visit(expr.lhs) rhs = self.visit(expr.rhs) return e.Sub(lhs, rhs)
def visit_sub(self, expr): lhs = self.visit(expr.lhs) rhs = self.visit(expr.rhs) return e.Sub(lhs, rhs)