Third edition of Artificial Intelligence: foundations of computational agents, Cambridge University Press, 2023 is now available (including the full text).

12.6.3 Building Structures for Non-terminals

You can add an extra argument to the predicates to represent a parse tree, forming a rule such as

sentence(T0,T2,s(NP,VP))←
     noun_phrase(T0,T1,NP)∧
     verb_phrase(T1,T2,VP).

which means that the parse tree for a sentence is of the form s(NP,VP), where NP is the parse tree for the noun phrase and VP is the parse tree for the verb phrase.

This is important if you want some result from the syntactic analysis, not just to know whether the sentence is syntactically valid. The notion of a parse tree is a simplistic form of what is required because it does not adequately represent the meaning or "deep structure" of a sentence. For example, you would really like to recognize that "Alex taught the AI course" and "the AI course was taught by Alex" have the same meaning, only differing in the active or passive voice.