Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
 def _preprocess_(cls, name, sort):
     if name and not name[0].isupper():
         raise IvyError("Bad variable name: {!r}".format(name))
     return name, sort
Exemplo n.º 9
0
 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