コード例 #1
0
ファイル: plan_validator.py プロジェクト: aiplan4eu/upf
 def _push_with_children_to_stack(self, expression: FNode, **kwargs):
     """Add children to the stack."""
     if expression.is_forall() or expression.is_exists():
         self.stack.append((True, expression))
     else:
         super(walkers.Simplifier,
               self)._push_with_children_to_stack(expression, **kwargs)
コード例 #2
0
ファイル: plan_validator.py プロジェクト: aiplan4eu/upf
    def _compute_node_result(self, expression: FNode, **kwargs):
        """Apply function to the node and memoize the result.
        Note: This function assumes that the results for the children
              are already available.
        """
        key = self._get_key(expression, **kwargs)
        if key not in self.memoization:
            try:
                f = self.functions[expression.node_type]
            except KeyError:
                f = self.walk_error

            if not (expression.is_forall() or expression.is_exists()):
                args = [self.memoization[self._get_key(s, **kwargs)] \
                        for s in self._get_children(expression)]
                self.memoization[key] = f(expression, args=args, **kwargs)
            else:
                self.memoization[key] = f(expression,
                                          args=expression.args,
                                          **kwargs)
        else:
            pass
コード例 #3
0
ファイル: proto_writer.py プロジェクト: aiplan4eu/upf
    def walk_operator(self, expression: model.FNode,
                      args: List[proto.Expression]) -> proto.Expression:
        sub_list = []
        sub_list.append(
            proto.Expression(
                atom=proto.Atom(symbol=map_operator(expression.node_type)),
                list=[],
                kind=proto.ExpressionKind.Value("FUNCTION_SYMBOL"),
                type="",
            ))
        # forall/exists: add the declared variables from the payload to the beginning of the parameter list.
        if expression.is_exists() or expression.is_forall():
            sub_list.extend([
                self._protobuf_writer.convert(p)
                for p in expression.variables()
            ])

        sub_list.extend(args)
        return proto.Expression(
            atom=None,
            list=sub_list,
            kind=proto.ExpressionKind.Value("FUNCTION_APPLICATION"),
            type="",
        )