<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>M. (2020). A logical and ontological framework for
knowledge discovery on gene regulatory networks. Case study: Bile Acid and Xenobiotic System
(BAXS). Journal of Bioinformatics and Genomics</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <article-id pub-id-type="doi">10.1006/jmbi.1997.0951</article-id>
      <title-group>
        <article-title>1. Introduction: Controlled Natural Language (CNL)</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Jacinto A. Dávila Quintero</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Universidad de Los Andes</institution>
          ,
          <addr-line>Mérida</addr-line>
          ,
          <country country="VE">Venezuela</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2024</year>
      </pub-date>
      <volume>5</volume>
      <issue>2</issue>
      <fpage>78</fpage>
      <lpage>94</lpage>
      <abstract>
        <p>A controlled natural language (CNL) is a simplified version of a natural language designed to be more precise and unambiguous. Only specific terms are allowed, reducing lexical ambiguity. The arrangement of words is strictly defined to ensure clarity. A model is normally developed to represent those particular aspects of a language and to embody a controlled form of the language for specific purposes. Language models come in many forms. In this paper, we use formulas, organized as logic programs, to describe relationships between objects. Large Language Models (LLMs) are also models. They fit into the category of mathematical models. Before the advent of deep learning and LLMs, language modeling was primarily based on statistical methods. Grammars can be considered models of languages, too. Combining the strengths of grammar and LLMs can significantly enhance language generation and understanding. The literature review was conducted with the assistance of the Gemini language model, which helped identify key studies and relevant information.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;model</kwd>
        <kwd>controlled natural language</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>• Logical English [10]: Syntactic sugar for logic programs.</p>
      <p>• InsurLE [5]: A refined form of Logical English to write contracts for the Insurance Industry.</p>
    </sec>
    <sec id="sec-2">
      <title>1.1. Challenges of CNLs</title>
      <p>While CNLs ofer many advantages, they also present challenges: The restrictions imposed on CNLs
can limit their ability to express complex ideas. Developing efective natural language processing tools
for CNLs can be challenging. How to improve the ability of humans to generate sentences of a CNL.
Writing in a CNL can be harder than reading in CNL.</p>
      <p>To address those challenges, researchers appeal to modelling techniques to focus on particular aspects
of a natural language in order to produce a CNL. A model is normally developed to represent those
particular aspects of a language and to embody a controlled form of the language for specific purposes.
To understand the many ways in which models can help to control a natural language, we also explore
the concepts of language models and grammars.</p>
      <sec id="sec-2-1">
        <title>2. What is a Model?</title>
        <p>A model is a simplified representation of something. It helps understand, analyze, or predict the behavior
of a system or object without dealing with full complexity. Models come in many forms:
• Physical models: These are tangible representations, like a miniature car or a globe.
• Conceptual models: These are abstract representations, like a diagram or a flowchart.
• Mathematical models: These use equations and formulas to describe relationships between
variables. Language models and grammars are normally classified under this category.
• Computer models: These are simulated environments created using software.</p>
        <p>Models are expected to have some epistemological properties: Models must explain and predict the
behaviour of a system, even if partially. Predictability seems harder to achieve, as the model must
replicate correctly the dynamics of the real system. However, explainability has become a more
appreciate property as the model becomes a learning device for humans, explaining why the system
behaves the way it does or should behave.</p>
      </sec>
      <sec id="sec-2-2">
        <title>3. Large Language Models are models</title>
        <p>Large Language Models (LLMs) are indeed models. They fit into the category of mathematical models.
They can be seen as complex systems of equations (neural networks) designed to represent and predict
language patterns under certain conditions:
• They are simplified representations: LLMs don’t capture the full complexity of human language,
but they implicitly model key aspects like grammar, semantics, and context.
• They are used for prediction: Given a prompt, an LLM predicts the most likely continuation of
the text.
• They are based on data: LLMs are trained on massive amounts of text data to learn language
patterns.</p>
        <p>At some point we used to believe that LLMs were not models, because they are a black box,
unaccountable from a symbolic point of view. We changed our opinion after considering that LLMs do represent
the grammatical rules of a language, even if they do so in a representation that is not symbolically
meaningful. What counts here is that the LLM can actually predict the syntax of expressions in natural
language. Thus, with LLMs, predictability takes over from explainability, an unusual turn of events.</p>
        <p>While LLMs might not be physical or conceptual models in the traditional sense, they are mathematical
models that have proven very efective at parsing and generating human language. LLMs are stochastic
functions because they randomly select their actual output from a given list of candidates. That creates
the illusion of diferent possible outputs for the same input. However, as with any other discrete
machine, random selection can only be approximated by some chaotic functions, which are actually
deterministic and can be replicated. LLMs essentially learn to predict the next word in a sequence. This
might seem simple, but it is the foundation for their capabilities.</p>
        <p>(Answer Generated by AI tool Gemini begins) The general process involves:
1. Data Ingestion: LLMs are trained on vast amounts of text data. This could be books,
articles, code, or any form of written text.
2. Tokenization: The text is broken down into smaller units called tokens. These can be
words, subwords, or characters.
3. Embedding: Each token is converted into a numerical representation called an
embedding. This representation captures the semantic and syntactic meaning of the
token.
4. Neural Network Architecture: The model uses a complex neural network architecture,
often based on the Transformer model. This architecture allows the model to process
information sequentially and capture dependencies between words.
5. Training: The model learns to predict the next token in a sequence given the previous
tokens. This process is repeated millions of times, refining the model’s ability to parse
and generate text.</p>
        <p>The key elements for the operation of an LLM are: 1) the attention mechanism, which
allows the model to focus on diferent parts of the input sequence when making predictions;
2) the Transformer Architecture and possibly 3) Transfer Learning: by which the LLM can
be fine-tuned on specific tasks, such as translation or summarization, after initial training
on a massive dataset.</p>
        <p>(Answer Generated by AI tool Gemini ends)</p>
      </sec>
      <sec id="sec-2-3">
        <title>4. Traditional Language Modeling</title>
        <p>
          Before the advent of deep learning and LLMs, language modeling was primarily based on statistical
methods. Statistical Language Models relied on analyzing large corpora of text to identify patterns
and probabilities of word sequences [3]; [19]; [4]; [17]; [14]; [16]; [8]; [15]; [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ] and have been widely
applied to bioinformatics, by treating DNA sequences as words of a language [13]. The most advanced
include N-gram models which consider sequences of N words (n-grams) and calculate the probability
of the next word given the previous N words. While simple, they were efective for basic tasks like
speech recognition and machine translation. Another important development in stochastic language
models are the Hidden Markov Models (HMMs). HMM models assume that the underlying state of the
language is hidden, and they use probabilistic techniques to infer these states. HMMs have been widely
used in speech recognition.
        </p>
        <p>
          While these methods laid the groundwork for language modeling, they faced a number of limitations.
Data sparsity, limited context and lack of generalization became apparent as the complexity of language
tasks increased. Deep learning and LLMs, based on neural networks with newer architectures like
Transformers [22]; [18]; [20]; [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ], overcome some of these limitations, but not all and introduced theirs
own. Thus, the combination of the diferent types of models became an obvious target of new attempts
to produce better models.
        </p>
      </sec>
      <sec id="sec-2-4">
        <title>5. Grammars as Models of Languages</title>
        <p>A grammar is a set of rules that define the structure of a language. In essence, it is a formal system that
attempts to capture the regularities and patterns found in natural language. Many grammatical theories,
like context-free grammars or dependency grammars, are formal models that use mathematical or
symbolic representations to describe language structure. Grammars aim to generate all and only the
well-formed sentences of a language. In this sense, they act as a generative model, even when there is
no stochastic process underneath as in the LLMs. Other grammars are primarily descriptive, aiming to
accurately represent the structure of a language as it is used, but they still function as models of that
language. And grammars can be used to justify the structuring of sentences, by referring to the rules
and the types of the components involved.</p>
        <p>Despite those promises, it is important to note that grammars often simplify the complexity of a
natural language, focusing on core syntactic patterns. No grammar can perfectly capture all aspects of
a natural language, which is constantly evolving and exhibiting variation.</p>
        <p>To ground this analysis, however, it is worth comparing, with a simple example, a grammar with an
LLM.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>5.1. Grammar vs. LLM: A Simple Example</title>
      <sec id="sec-3-1">
        <title>5.1.1. Grammar (Rule-Based)</title>
        <p>Consider a simple grammar for generating basic English sentences:
(Answer Generated by AI tool Gemini begins)
Sentence -&gt; NounPhrase VerbPhrase
NounPhrase -&gt; Determiner Noun
VerbPhrase -&gt; Verb
Determiner -&gt; "the" | "a"
Noun -&gt; "cat" | "dog"</p>
        <p>Verb -&gt; "sleeps" | "barks"</p>
      </sec>
      <sec id="sec-3-2">
        <title>5.1.2. LLM (Data-Driven)</title>
        <p>This grammar can generate sentences like: "The cat sleeps" and "A dog barks".
However, this grammar is very limited and cannot generate complex sentences or handle
real-world language nuances.
(Answer Generated by AI tool Gemini ends)
(Answer Generated by AI tool Gemini begins)
An LLM, on the other hand, would learn from vast amounts of text data. It would identify
patterns and relationships between words without explicit rules. For example, given a
prompt with "The cat...", an LLM might generate:
• "The cat sleeps peacefully."
• "The cat chased the mouse."
• "The cat is on the mat."
(Answer Generated by AI tool Gemini ends)</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>5.2. Key Diferences between a grammar and an LLM</title>
      <p>A grammar is normally a rule-based, limited model with vocabulary and structure. It can be queried
top-down: given an expression as a goal to validate, or bottom-up: given sub-expressions to be combined
into a valid sentence of the language. The LLM, on the other hand is data-driven. It works bottom-up,
learns patterns from vast amounts of text and can generate more diverse and complex text.</p>
      <sec id="sec-4-1">
        <title>6. Combining Grammars and LLMs: A partial taxonomy of approaches</title>
        <p>(Answer Generated by AI tool Gemini begins)
Combining the strengths of grammar and LLMs can significantly enhance language
generation and understanding. Here are some potential approaches:
1. Grammar-Guided LLM Generation:
• Constraint-based generation: Use a grammar to define the structural constraints
of the output. The LLM then generates text within these constraints. This can
improve the grammatical correctness and coherence of the generated text.
• Grammar-informed decoding: Incorporate grammatical knowledge into the
decoding process of the LLM. This can be achieved by assigning higher probabilities
to grammatically correct sequences. Which means that the decoding process
produces candidates that are tested for correctness by the grammar.
2. LLM-Enhanced Grammar Induction:
3. Hybrid Models:
• Grammar extraction: Use LLMs to extract grammatical patterns from large
amounts of text data. This can help in automatically constructing or refining
grammars.
• Grammar evaluation: LLMs can be used to evaluate the quality of generated text
based on a given grammar. This can help in grammar refinement.
• Grammar-augmented neural networks: Combine neural networks with formal
grammar components. This approach can leverage the strengths of both models.
• Sequence-to-sequence models with grammar injection: Incorporate grammatical
information into the input sequence of a sequence-to-sequence model.</p>
        <p>(Answer Generated by AI tool Gemini ends)</p>
      </sec>
      <sec id="sec-4-2">
        <title>7. Preparing for a comprehensive, hybrid approach: a logic programming grammar for a domain specific controlled natural language</title>
        <p>Consider the following expression for an insurance contract (variables in bold, operators in red):
we will cover
any amount which you are legally liable to pay
in respect of
a damage which is a
1 bodily injury or
2 personal injury or
3 property damage or
4 nuisance or
5 trespass
if the damage occurs during the period of insurance
and the damage occurs in connection with the business.</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>7.1. Grammar of InsurLE</title>
      <p>We are enriching a CNL, InsurLE [5], with respect to the original syntax of LE [10], [11] to recognize
expressions such as the one above. The most important improvements in InsurLE with respect to LE are
the enhanced conclusions which embed restrictive relative clauses and other conditions in themselves.
We call them large literals in the grammar (here simplified as a Definite Clause Grammar, DCG):
large_literal_
large_literal_
we will cover, description_.</p>
      <p>we will not cover, description_.</p>
      <p>A description will eventually be any of those complex statements in the conclusions of the rules in
the insurance contract. For the time being, we are parsing these:
description_
description_
description_
costsDescriptions, template_minus(is), lossDescription.
costsDescriptions, template_minus(is), claimDescription.</p>
      <p>costsDescriptions.</p>
      <p>A description can be some costs (at least one) followed by some built-in template (where the word "is"
has been removed) followed by a loss or a claim, such as: “a cost in respect of a loss”. But a description
can also be a description of a cost alone, like: “a cost which you are legally liable to pay”.</p>
      <p>The process would be as follows:
1. A potential insuree would ask (after inputting some extra expressions describing her/his
hypothetical case): What will you pay in this case?
2. The LLM adapts the question to the existing grammar and context, paraphrasing it into a query:
“we will cover which cost”
3. InsurLE parses the contract and the paraphrased input above. This is the translation into Prolog
of the rule above:
w e _ w i l l _ c o v e r ( A ) : −
i s _ a ( A , amount ) ,
y o u _ a r e _ l e g a l l y _ l i a b l e _ t o _ p a y ( A ) ,
i s _ a ( B , damage ) ,
i s _ i n _ r e s p e c t _ o f ( A , B ) ,
( i s _ a ( B , b o d i l y _ i n j u r y )
; i s _ a ( B , p e r s o n a l _ i n j u r y )
; i s _ a ( B , p r o p e r t y _ d a m a g e )
; i s _ a ( B , n u i s a n c e )
; i s _ a ( B , t r e s p a s s )
) ,
o c c u r s _ d u r i n g _ t h e _ p e r i o d _ o f _ i n s u r a n c e ( B ) ,
o c c u r s _ i n _ c o n n n e c t i o n _ w i t h _ t h e _ b u s i n e s s ( B ) .
4. The Prolog engine produces this answer:</p>
      <p>To test the feasibility of this approach, we prompted Google’s LLM, Gemini (1.5), with a set of
instructions to list the most common ways to ask the same question:</p>
      <p>andrew has afiliated with company at 2020-01-02.
that corresponds to the template</p>
      <p>*an entity* has afiliated with *an afiliate* at *a date*
and then map the corresponding alternatives as new entries to the Prolog dictionary used by Logical
English. Gemini produced the following list of variants of the query:
• who afiliated with which entity at which date.
• what entity afiliated with which company at which date.
• when did which entity afiliate with which other entity.
• on what date did which entity afiliate with which company.
• is there an afiliation between which entity and which company.</p>
      <p>• when did the afiliation between which entity and which company begin.</p>
      <p>(Answer Generated by AI tool Gemini ends)</p>
      <p>The Logical English parser has been updated accordingly and the example above can be verified 1 and
tested2 online, to demonstrate that an LLM could take queries from users and map them to relations in
a LE document. Notice that we don’t even need to guaranteed that the LLM produces a query that is
recognized by the CNL. In those cases, the system could reply that it does not understand the question.</p>
      <p>In these examples, the LLM is used only to paraphrase the inputs from users into expressions
understandable by the CNL. This may seems like a misuse of the LLM, but it exploits its parsing
capabilities and leaves the reasoning to the Logical engine, avoiding hallucinations altogether.</p>
      <sec id="sec-5-1">
        <title>8. Relevance of CNL, LLM, and Prolog to Education</title>
        <p>Artificial Intelligence, AI, challenges every aspect and element of human behaviour. As a consequence,
every aspect and element of what has been traditionally considered as intelligent behaviour is being
considered as a target for automation, even when there is evidence of its inherent complexity and
dificulty. Teaching is no exception to that. Many expect humans to be replaced by robots (or mobile
apps) at teaching, as an obvious step towards democratizing and leveraging access to knowledge for
everybody with, no so obvious, savings in preparation, deploying and maintenance of teachers.</p>
        <p>However, Teaching is a complex element of human behaviour in that it normally involves more that
one person. Somebody is trying to convey a meaningful message to others and these others are trying to
learn from what it is being displayed or, more commonly (and cheap), said. Language, natural language,
is at the heart of teaching as much as it is at the core of any other collective, human enterprise.</p>
        <p>The connections between Language and Logic are multi-dimensional and probably impossible to
reduce. However, we can connect them using a device originally thought as a connection between
computing and logic. The expression (Kowalski, 1979) :</p>
        <p>Algorithm = Logic + Control
has been proposed to explain the relations between those concepts, in the context of algorithms been
considered as recipes to control computer devices. We could consider an automatic teacher (robot or
mobile app) as one of those algorithms, a CNL, which simulates a human teacher. Grammars rules
would represent the logic of the language. Other similar connections are envisage:
CNL = Logic + Control = Grammar rules + Control</p>
        <p>LLM = Logic’ ∪ Control’</p>
        <p>CNL = LLM + Control
Eventually, assuming that LLMs are very good representations (in practical terms) of Grammar rules:
On each expression, the terms Logic and Control may entail diferent objects. In the case of LLMs, Logic’
is expressed at the sub-symbolic level and therefore, it requires Control’: a diferent, very entangled
form of control (i.e. not a linear combination, which is why we use ∪).
1https://github.com/LogicalContracts/LogicalEnglish/tree/main/kb/4_afiliates_3.pl
2https://le.logicalcontracts.com/p/4_afiliates_3.pl</p>
        <p>All of the above is relevant in cases where the purpose is to develop an automatic assistance for
teaching. There are, however, many other ways in which LLMs and traditional AI software can be
integrated for teaching purposes. We recommend [21], for a comprehensive review of those possibilities.
Here, let us mention a few project that are being developed in the interception of CNL, Prolog and
LLMs:
• Develop a CNL for a specific domain (e.g., insurance contracts, law) and implement a Prolog
system to process CNL statements [5].
• Create a natural language interface for a Prolog-based system [11].
• Build an LLM-based system to extract knowledge from text and populate a Prolog knowledge
base [21].</p>
        <p>• Develop a Prolog-based chatbot that can generate human-like text using an LLM [21].</p>
        <p>By incorporating these elements into a curriculum, educators can provide students with a
comprehensive understanding of language, logic, and their applications in the real world. For a more in
depth analysis of the connections between Prolog, natural language processing and Logic and their
fundamental role in the future of science, we recommend [6].</p>
        <p>To know that LLMs, CNLs and grammars are all restricted models of a special system, that is to say a
human language, could be useful for teachers to participate in those discussions about automatic tutors
that, allegedly, aim to replace humans.</p>
      </sec>
      <sec id="sec-5-2">
        <title>9. Conclusion</title>
        <p>We have argued that a Controlled Natural Language, CNL, exists as long as there is a model for it.
Models come in many forms but, in the case of CNL, models normally take the form of a mathematical
function or logical representation with rules describing the relationships between its components. An
LLM is also a model if one considers the associate neural network as a mathematical function. Being
both based on some mathematical semantics, one would expect hybrid models that integrate them
to be feasible. We have explained how to integrate an LLM in the preprocessing of an input from an
user so that it can be matched against relations in a CNL with a knowledge base controlled by an
external Prolog engine. LLMs are very good parsers and these capabilities could be well exploited while
avoiding hallucinations. We look forward to developing and testing some of those models in particular
applications domains where idiosyncrasies cause diferential uses of natural languages, like in the
insurance industries. Ethical considerations, in particular, would benefit from being able to intervening
the interaction between humans and LLMs and verifying the truth conditions of any statement ofered
by the computer as an answer to a human user.</p>
      </sec>
      <sec id="sec-5-3">
        <title>Acknowledgments</title>
        <p>We acknowledge the support of the Gemini language model, developed by Google AI, which provided
assistance with literature review, data analysis, and writing support as indicated in the paper. We are
also very grateful to the reviewers for their insightful comments and suggestions.</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Akpokiro</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Martin</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Oluwadare</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          (
          <year>2022</year>
          ).
          <article-title>EnsembleSplice: Ensemble deep learning model for splice site prediction</article-title>
          .
          <source>BMC Bioinformatics</source>
          ,
          <volume>23</volume>
          (
          <issue>413</issue>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>Beder</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          , et al. (
          <year>2021</year>
          ).
          <article-title>Identifying essential genes across eukaryotes by machine learning</article-title>
          .
          <source>NAR Genomics and Bioinformatics</source>
          ,
          <volume>3</volume>
          (
          <issue>4</issue>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>