For example, if statement $\langle S \rightarrow P \rangle$ is the content of a task, then it can and only can be accessed from the concepts named by terms $S$, $P$, $\langle S \rightarrow P \rangle$, and the compound terms with $\langle S \rightarrow P \rangle$ as a component, such as $\langle\langle S \rightarrow P \rangle \Rightarrow Q\rangle$ . For the last cases, $\langle S \rightarrow P \rangle$ must be at a level of depth that it is directly identified in an inference rule. For example, statement $\langle\langle\langle S \rightarrow P \rangle \Rightarrow Q\rangle \rightarrow R \rangle$ can be directly accessed from the concepts named by $R$ and $\langle\langle S \rightarrow P \rangle \Rightarrow Q\rangle$ , but not directly from those named by $S$, $P$, and $\langle S \rightarrow P \rangle$, because each inference rule only parses the syntactic structures of its premises to a certain (usually 1 or 2) level of depth.
More Info
If a Term is not an atomic term, that means it is a compound of multiple terms. As such, the Term contains a list of components.
In the current code, the list of components contains components at all levels of granularity (i.e., terms are recursively added).
Then, when Links are created, they are created for all terms in that list. However, TermLinks and TaskLinks should only be linked for the top-level components. We could call these top-level components "subterms" to differentiate them.
Furthermore, we can't forget to link to the superterms.
E.g., first-order Task e.g., $\langle a \rightarrow b \rangle$ could be a subterm of $\langle a \rightarrow b \rangle \Rightarrow \langle c \rightarrow d \rangle$.
The Task should be linked from the superterm $\langle a \rightarrow b \rangle \Rightarrow \langle c \rightarrow d \rangle$ as well.
Technical Report
More Info
If a Term is not an atomic term, that means it is a compound of multiple terms. As such, the Term contains a list of components.
In the current code, the list of components contains components at all levels of granularity (i.e., terms are recursively added). Then, when Links are created, they are created for all terms in that list. However, TermLinks and TaskLinks should only be linked for the top-level components. We could call these top-level components "subterms" to differentiate them.
Furthermore, we can't forget to link to the superterms. E.g., first-order Task e.g., $\langle a \rightarrow b \rangle$ could be a subterm of $\langle a \rightarrow b \rangle \Rightarrow \langle c \rightarrow d \rangle$. The Task should be linked from the superterm $\langle a \rightarrow b \rangle \Rightarrow \langle c \rightarrow d \rangle$ as well.
For an easy visual of how the links should be, see the image below from the OpenNARS wiki: See https://user-images.githubusercontent.com/24262360/61996593-d9923780-b063-11e9-9d9d-5eeaa332aeea.png