potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
601 stars 79 forks source link

The 'type' attribute of External AST node does not exist. #384

Closed ZhangShutao closed 2 years ago

ZhangShutao commented 2 years ago

According to the grammar and constructor method, an external statement has an attribute 'type.' However, when parsing an external node with VisitTransformer, the type attribute does not exist, and print(external), print(external.type) will get the following output:

#external fly(X) : bird(X). [false]
AttributeError: no attribute: type

When constructing with the following code:

external = clingo.ast.External(loc, fly, body, clingo.ast.Function(loc, 'false', [], True))

The false is an unfound function, and the output is

#external fly(X) : bird(X). [@false]

So here are my questions:

  1. What is the 'type' attribute?
  2. How to construct an external statement without parsing?
rkaminsk commented 2 years ago

Hello, you can always parse the statement you want to construct and print it's representation. You can then paste the resulting output and adjust it to your needs. Otherwise, the type can be true, false, or free for the initial truth value of the external atom.