Chapter 2 of my dissertation covers a lot about the syntax of Dyna https://matthewfl.com/papers/mfl-dissertation.pdf
As refset said in the other comment, In Dyna, terms return values like a function in a functional programming language. Hence, when you write
word(I)
this returns the value defined by the `word` function. E.g. word(0) = "Hello".
This is different from typical logic programming languages like Prolog in that if you write foo(X, bar(Y))
then you are "calling" the term `foo`, but then `bar` ends up being a structured-term that gets unified with the second argument of `foo`. Prolog provides this shortcut as "calling" `bar` doesn't make sense in this case, as `bar` only would return the value `true`, which isn't particularly useful.In Dyna, we provide square brackets to create structured-terms as both calling the term "bar" and creating the structured-term bar can be useful. E.g. the Prolog expression `foo(X, bar(Y))` would be equivalent to the dyna `foo(X, bar[Y])`.
For the aggregator `max=`, this is looping over the different possible values on the right-hand-side and selecting the value that is the max. Hence in
phrase(X,I,K) max= phrase(Y,I,K) \* rule(X,Y).
this is looping over the variable `Y` and selecting the one that is maximal. Using `max=` on phrase(X,I,I+1) max= rule(X, word(I)).
is done because we want all of the right-hand-sides to use the same aggregator so that we can aggregate between different rules that contribute to `phrase/3`.