def _preprocess_(cls, variables, formula): variables = tuple(variables) if set(variables) != free_variables(formula): raise IvyError("Free variables {} must match formula: {}".format(variables, formula)) if not all(type(v) is Var and first_order_sort(v.sort) for v in variables): raise IvyError("Concept variables must be first-order: {}".format(variables)) return variables, formula
def _preprocess_(cls, variables, body): if len(variables) == 0: raise IvyError("Must quantify over at least one variable") if not all(type(v) is Var for v in variables): raise IvyError("Can only quantify over variables") if body.sort not in (Boolean, TopS): raise SortError("Quantified body must be Boolean: {}", body) return frozenset(variables), body
def _preprocess_(cls, name, variables, formula): if not isinstance(name,str): raise IvyError("Concept name {} is not a string".format(name)) variables = tuple(variables) # if set(variables) != free_variables(formula): # raise IvyError("Free variables {} must match formula: {}".format(variables, formula)) if not all(type(v) is Var and first_order_sort(v.sort) for v in variables): raise IvyError("Concept variables must be first-order: {}".format(variables)) return name,variables, formula
def _preprocess_(cls, variables, formula): variables = tuple(variables) if set(variables) != free_variables(formula): raise IvyError("Free variables {} must match formula: {}".format(variables, formula)) if not all(type(v) is Var and type(v.sort) is FunctionSort and v.sort.range == Boolean for v in variables): raise IvyError("ConceptCombiner variables must be relational: {}".format(variables)) return variables, formula
def _preprocess_(cls, name, variables, body): if not all(type(v) is Var for v in variables): raise IvyError("Can only abstract over variables") # TODO: check the name after we decide on valid names return name, tuple(variables), body
def _preprocess_(cls, variables, body): if not all(type(v) is Var for v in variables): raise IvyError("Can only abstract over variables") return tuple(variables), body
def _preprocess_(cls, *sorts): if len(sorts) == 0: raise IvyError("Must have range sort") if any(not first_order_sort(s) for s in sorts): raise IvyError("No high order functions") return sorts
def _preprocess_(cls, name, sort): if name and not name[0].isupper(): raise IvyError("Bad variable name: {!r}".format(name)) return name, sort
def _preprocess_(cls, name, variables, environ, body): assert environ is None or isinstance(environ, str) if not all(type(v) is Var for v in variables): raise IvyError("Can only abstract over variables") # TODO: check the name after we decide on valid names return name, tuple(variables), environ, body