Beispiel #1
0
 def apply(self, args: Tuple) -> Boolean:
     C1 = args[0]
     C2 = args[1]
     for e in C2:
         if e in C1:
             return Boolean(True)
     return Boolean(False)
Beispiel #2
0
 def apply(self, x):
     if x.size() == 0:
         return Boolean.create(False)
     for i in range(1, x.size()):
         if self.evaluator.apply(x.get(i)).bool_value():
             return Boolean.create(True)
     return Boolean.create(False)
Beispiel #3
0
    def apply(self, x):
        matchTuple = x.get(0)
        zipTerm = x.get(1)
        sub_f = x.get(2)

        zipTerm = self.evaluator.apply(zipTerm)

        zipList = []
        for t in zipTerm:
            zipList.append(t)

        for i in range(len(zipList) - 1):
            if len(zipList[i]) != len(zipList[i + 1]):
                return Boolean.create(False)

        for i in range(len(zipList[0])):
            zipArgs = [None] * len(zipList)
            for j in range(len(zipList)):
                zipArgs[j] = zipList[j].get(i)

            zipTuple = Tuple(zipArgs)
            s = matchTuple.match(zipTuple)
            if not self.evaluator.apply(sub_f.substitute(s)).bool_value():
                return Boolean.create(False)

        return Boolean.create(True)
Beispiel #4
0
    def apply(self, x):
        if len(x) != 3:
            raise ValueError(x, ": ", Exists.ExistsHelp)

        matchTerm = x.get(0)
        collTerm = self.evaluator.apply(x.get(1))

        if not isinstance(collTerm, Collection) and \
           not isinstance(collTerm, Tuple):
            raise ValueError(
                x.get(2) + " not a CollectionTerm or TupleTerm " +
                Exists.ExistsHelp)

        if isinstance(collTerm, Collection):
            collection = collTerm
        else:
            list = []
            for i in range(collTerm.size()):
                list.add(collTerm.get(i))
            collection = List(list)

        constraints = x.get(2)

        for t in collection:
            s = matchTerm.match(t)

            if s is None:
                continue

            conSub = constraints.substitute(s)

            if self.evaluator.apply(conSub).bool_value():
                return Boolean.create(True)
        return Boolean.create(False)
Beispiel #5
0
 def apply(self, args: Tuple) -> Boolean:
     C = args[0]
     e = args[1]
     for e_c in C:
         if e.match(e_c) is not None:
             return Boolean(True)
     return Boolean(False)
Beispiel #6
0
    def apply(self, x):
        targets = x.get(0)
        types = x.get(1)
        if not isinstance(targets, Tuple):
            return Boolean.create(True)

        for i in range(targets.size()):
            idx = min(i, types.size() - 1)
            con = Tuple([TYPE, Tuple([QUOTE, targets.get(i)]), types.get(idx)])
            if not self.evaluator.apply(con).bool_value():
                return Boolean.create(False)
        return Boolean.create(True)
Beispiel #7
0
    def apply(self, x):
        from_term = self.evaluator.apply(x.get(0))
        to_term = self.evaluator.apply(x.get(1))
        matchConstraint = x.get(2)

        s = from_term.match(to_term)

        if s is None:
            return Boolean.create(False)

        return self.evaluator.apply(matchConstraint.substitute(s))
Beispiel #8
0
 def apply(self, x):
     return Boolean.create(isinstance(x, Real))
Beispiel #9
0
 def apply(self, x):
     return Boolean.create(isinstance(x, Variable))
Beispiel #10
0
 def apply(self, x):
     return Boolean.create(isinstance(x, KeyValue))
Beispiel #11
0
 def apply(self, x):
     return Boolean.create(not x.bool_value())
Beispiel #12
0
 def apply(self, x):
     return Boolean.create(isinstance(x, Tuple))
Beispiel #13
0
 def apply(self, x):
     return Boolean.create(isinstance(x, FunctionReference))
Beispiel #14
0
 def apply(self, x):
     return Boolean.create(x[0] != x[1])
Beispiel #15
0
 def apply(self, args):
     return Boolean.create(args.get(0) <= args.get(1))
Beispiel #16
0
 def apply(self, x):
     return Boolean.create(True)
Beispiel #17
0
 def apply(self, x):
     return Boolean.create(isinstance(x, Integer))
Beispiel #18
0
 def apply(self, x):
     return Boolean.create(isinstance(x, Numerical))
Beispiel #19
0
 def apply(self, x):
     return Boolean.create(isinstance(x, String))
Beispiel #20
0
 def apply(self, x):
     return Boolean.create(isinstance(x, Symbolic))
Beispiel #21
0
 def apply(self, args: Tuple) -> Boolean:
     C = args[0]
     k = args[1]
     return Boolean.create(C.contains_key(k))
Beispiel #22
0
 def apply(self, args: Tuple) -> Boolean:
     C = args[0]
     e = args[1]
     return Boolean(C.contains(e))
Beispiel #23
0
 def apply(self, args: Tuple) -> Boolean:
     x = args.get(0)
     y = args.get(1)
     sub = x.match(y)
     return Boolean.create(sub is not None)
Beispiel #24
0
 def apply(self, args: Tuple) -> Boolean:
     C1 = args[0]
     C2 = args[1]
     return Boolean(C1.contains_all(C2))
Beispiel #25
0
 def apply(self, term):
     return Boolean.create(self.check(self.type_def, term))
Beispiel #26
0
 def apply(self, x):
     return Boolean.create(isinstance(x, Collection))