1. A computer-implemented method, comprising: identifying, by a processor, one or more terminal nodes in a digraph, wherein a terminal node is a primitive that results in an action within a rule; back-walking primitives up the digraph from each terminal node to a corresponding parent terminal node or a root of the digraph, whichever is first; identifying chains of back-walked primitives for each of the one or more terminal nodes, wherein based on the chain having a parent terminal node, each chain consists of a respective terminal node and any primitives up to but not including a corresponding parent terminal node, and wherein based on the chain not having parent terminal node, each chain consists of up to and including the root of the digraph when the back-walking reaches the root; merging, into a corresponding new single chain, each set of any two or more chains of the identified chains that intersect on a decision operation; mapping each of the chains to a respective rule, wherein one or more terminal nodes in each particular chain map to a head of a corresponding rule, and other primitives of the particular chain map to a body of the corresponding rule; constructing a semantic language based on each of the chains of a plurality of rules in the digraph; and automatically generating a knowledgebase based on the semantic language.