\section{Summary}
    \input{sections/7.summary}

\section*{Acknowledgements}
This research received funding from the Flemish Government under the ``Onderzoeksprogramma Artificiële Intelligentie (AI) Vlaanderen'' programme.

The authors thank Maurice Bruynooghe for his review of the drafts of this paper.

    \bibliographystyle{packages/kr}

\section{Introduction}

\newcommand{{\mathcal{I}}}{{\mathcal{I}}}
\newcommand{\ensuremath{\mathit{hasFever}}}{\ensuremath{\mathit{hasFever}}}
\newcommand{\ensuremath{\mathit{sneezes}}}{\ensuremath{\mathit{sneezes}}}
\newcommand{\ensuremath{\mathit{coughs}}}{\ensuremath{\mathit{coughs}}}

\ignore{
    With the advent of strong solver technologies from SAT, CP, SMT, ASP, \dots, it becomes possible for those with interest in the nature of knowledge in  all its complexity and variation, to study real software applications from a Knowledge Representation and Reasoning (KRR) point of view, to analyze the sort of knowledge available in them, to  study the sorts of inferences that would help to solve problems arising in those domains, and to implement such solutions. Often such experiments  pose interesting new  challenges on the KR level  suggesting new language constructs or sometimes a new role for concepts  that were introduced before in philosophical logic papers, of  which the relevance to software problems was unclear so far. Being able to implement the language constructs makes a big difference: we can evaluate the solution.

    \todo{remove duplication in next paragraph. Or remove both per Joost.}

    Thanks to the development of powerful solvers in SAT, SMT, ASP, CP, and MILP, the field of Knowledge Representation (KR) has entered a new phase: the age of computational Knowledge Representation, where such tools are used as reasoning engines to perform tasks and help solve problems by applying the suitable form of reasoning on some knowledge base expressed in an expressive KR language.

    \ignore{Piere:I suspect that our use of `inference engine` is not standard: it usually refers to the engine behind rule-based systems.  I prefer "reasoning engine".  It also matches better with KRR = Knowledge Representation and *Reasoning* }
}

The power of a  KR language for compact expression of knowledge lies for an important extent in the way it allows us to abstract over certain types of objects, e.g., to quantify, count, or sum over them.
Classical First Order logic (FO) is a much stronger KR language than Propositional Calculus (PC) because it allows to quantify over domain objects.
Still, the abstraction power of FO is limited, e.g., it does not allow to count or sum over domain objects satisfying some condition.
Many first-order modeling languages are therefore extended to support \emph{aggregates}.
Likewise, one can only quantify over individuals in the domain, not over relations and functions.
This is resolved in Second Order logic (SO).

In this paper, we argue that in some KR applications, we want to abstract (i.e., quantify, count, sum, \dots) not over relations and functions, but over certain {\em concepts} that are available in the knowledge base vocabulary, as the following example will show.

\ignore{
    These concepts may be zero order, i.e., object concepts such ``earth'' or ``moon'', or first order, such as sets of patients exhibiting specific symptoms of a disease.
    \ignore{``\st{symptoms of diseases that different patients may show.}'' was een beetje verwarrend, omdat dit een predicaat `Patient(symptoms)' lijkt te beschrijven, maar het beschrijft een groep aan `symptom(Patient)' predicaten!}
}

\begin{example}
Consider a corona testing protocol.
A person is to be tested if she shows at least 2 of the following symptoms: fever, coughing and sneezing.
The set of persons showing a symptom is represented by a unary predicate ranging over persons, i.e., $\ensuremath{\mathit{hasFever}}{}/1$, $\ensuremath{\mathit{coughs}}{}/1$, and $\ensuremath{\mathit{sneezes}}{}/1$.
Leaving first order behind us, assume that the set of symptoms is represented by predicate $Symptom/1$.

Testing is expressed as a unary predicate $\mathit{test1}/1$, ranging over persons.
Informally, this predicate is to be defined along the following lines (while freely extending the syntax of FO with the ``$\#$'' cardinality operator on a set):
\begin{equation}
    \label{eq1}
    \forall p : test1(p) \Leftrightarrow 2\leq  \# \{ x | Symptom(x) \land x(p)\}
\end{equation}
Alternatively, assume another  test is to be taken iff the patient shows all 3 symptoms. Now the definition is along the following lines:
\begin{equation}
    \label{eq2}
    \forall p : test2(p) \Leftrightarrow \forall x (Symptom(x) \Rightarrow x(p))
    \end{equation}
\end{example}

The question is: what is the nature of the variable $x$ and the predicate $Symptom$? Over what sorts of values does $x$ range?

At first sight, one might think that $x$ ranges over sets of persons and, hence, that it is a second order variable. \ignore{That, at least, was our first impression in this and similar examples. In retrospect, it is not difficult to see that this is \emph{incorrect}.} An easy `possible world' analysis refutes this idea.
Consider a state of affairs where everybody has all 3 symptoms.
Formally, in a structure ${\mathcal{I}}$ abstracting such a state, the interpretations of the symptoms are identical:  $\ensuremath{\mathit{hasFever}}^{\mathcal{I}}=\ensuremath{\mathit{coughs}}^{\mathcal{I}}=\ensuremath{\mathit{sneezes}}^{\mathcal{I}}$.
The set in Eq.~\ref{eq1},
\begin{equation*}
   \{x|x=\ensuremath{\mathit{hasFever}}^{\mathcal{I}} \lor x=\ensuremath{\mathit{coughs}}^{\mathcal{I}} \lor x=\ensuremath{\mathit{sneezes}}^{\mathcal{I}}\}
\end{equation*}
is a singleton, and the condition for the first test is not satisfied for any $p$, not even for poor Bob who has all three symptoms.

\ignore{
    Thus, in rule (1), $p$ cannot be a second order variable, abstracting over sets of domain elements.
    Instead, it abstracts over the intension of the $Symptom$ symbols.
    It so happens that, in rule (2), $p$ can be seen either as a second order variable or as an intensional variable: in both cases, the formula has the same models.

    In later sections, we will see that second order variables are not subsumed in any way by intensional variables, rather, they tackle different problems.
    Both are of value, but they are not interchangable, and we need to learn to distinguish them.
}

\begin{figure*}[t]
    \centering
    \includegraphics[width=0.8\textwidth]{images/Intensions.png}
    \caption{We extend structures in classical logic with objects representing the intension of symbols in the ontology}
        \label{fig:interpretation}
\end{figure*}

A different idea is that $x$ is ranging over {\em symbols}: the symbols \ensuremath{\mathit{hasFever}}{}, \ensuremath{\mathit{coughs}}{}, \ensuremath{\mathit{sneezes}}{}.
This sort of variable is generally found in meta programming, of the kind investigated in, e.g., Logic Programming (\cite{DBLP:journals/logcom/BarklundDCL00}) or Hilog~(\cite{chen1993hilog}).
Again, it is not difficult to see that also this is not really the case.
Assume for the sake of insight, that the team working on this application is international, and the French group has introduced the predicate $\mathit{estFievreux}/1$, French for ``has fever''.
Thus, \ensuremath{\mathit{hasFever}}{} and $\mathit{estFievreux}$ are {\em synonymous}.
Clearly, $\mathit{John}$ whose only symptom is fever, does not need to be tested.
However, because $\mathit{isFievreux}$ and \ensuremath{\mathit{hasFever}}{} are different symbols, the meta programming view of the first definition would define $\mathit{test1}$ to erroneously hold for $\mathit{John}$.
\ignore{
    Pierre:I'd rather use 2 synonyms in the example (e.g. sneezing and sternutation), rather than take a translation.  Or use antonyms, e.g. short and tall ?} \ignore{Marc: I like fever and fievre.}

The view that we elaborate in this paper, is that the abstraction in both examples
is over {\em concepts}.
For context, consider that the first phase of a rigorous approach to building a KR specification is the selection of a formal ontology $\voc$  of symbols representing relevant {\em  concepts} of the application field.
These concepts can be identified with the user's \emph{informal interpretations} of the symbols in the ontology of the domain.
The informal interpretation is in practice a crucial concept in all knowledge representation applications: it is the basis of all actions of formal knowledge representation, and of all acts of interpreting formal results of computation in the application domain.
Connecting concepts to informal interpretations provides a good intuitive explanation of what concepts are and how they are relevant in a KR context.

A concept is  not a value, but takes on a particular value  in any particular state of affairs.
Since the informal meaning of symbols is known, the synonymity relation $\sim_s$ is known too, and it is an equivalence relation  on $\voc$.  Synonymous symbols have the same arity and type.

Formally, in the logic, an ontology symbol $\sigma$ has one \emph{intension} and, for each structure ${\mathcal{I}}$, one \emph{extension} (Fig. \ref{fig:interpretation}).
Synomymous symbols $\sigma_1$, $\sigma_2$ have the same intension, and, in every structure ${\mathcal{I}}$, the same extension.
The extension of $\sigma$ in a structure is its interpretation, aka value, in that structure.
It is a relation or function, of a precise arity, over the universe of discourse; in formulae, it is denoted simply by $\sigma$.

In classical FO logic, a structure only has the extensions of symbols.
For our purpose, we extend a structure to also have the intension of symbols.
This intension  is \emph{rigid} in the sense that it is the same in every extended structure.
In formulae, the intension of $\sigma$ is denoted by $\deref{\sigma}$.
Finally, we introduce the \emph{value functor} $\$(\cdot)$: when applied to an intension, it returns its interpretation in the current structure.

\ignore{
\begin{figure}[h]
    \centering
    \begin{tikzpicture}
        [roundnode/.style={draw=black, ellipse, minimum width=70pt, align=center},]

        \node              (syntax)                                 {Syntax};
        \node              (semantics)   [right = 4 cm of syntax]   {Semantics};
        \node[roundnode]   (symbol1)     [below =0.3 cm of syntax]         {$\deref{\sigma}$};
        \node[roundnode]   (concept)     [below =0.3 cm of semantics]        {Concept};
        \node[roundnode]   (symbol)      [below =0.6 cm of symbol1]         {$\sigma$\\ $\$(\deref{\sigma})$};
        \node[roundnode]   (value)       [below =0.5 cm of concept]      {Relation or\\function};

        \draw[->] (symbol1.east) -- (concept.west) node[midway, above]{interpretation};
        \draw[->] (symbol.north east) -- (concept.south west) node[midway, below, rotate=13]{intension};
        \draw[->] (concept.south) -- (value.north) node[midway, right=0.1cm]{value};
        \draw[->] (symbol.east) -- (value.west) node[midway, below]{interpretation};

    \end{tikzpicture}
    \caption{Intension and interpretation}
        \label{fig:interpretation}
\end{figure}
}

\ignore{
    \begin{figure}[h]
        \centering
        \begin{tikzpicture}
            [roundnode/.style={draw=black, ellipse, minimum width=70pt, align=center},]

            \node[roundnode]      (symbol)                              {Symbol $\sigma$};
            \node[roundnode]      (concept)         [above right = 0.55cm and 1 cm of symbol]                    {Concept $\deref{\sigma}$};
            \node[roundnode]      (value)           [below right = 0.35cm and 1 cm of concept]                  {Set or\\function};

            \draw[->] (symbol.east) -- (value.west) node[midway, below]{interpretation};
            \draw[->] (symbol.north east) -- (concept.west) node[midway, left=0.1cm]{intension (`)};
            \draw[->] (concept.east) -- (value.north west) node[midway, right=0.1cm]{interpretation (\$)};

        \end{tikzpicture}
        \caption{Intension and interpretation}
            \label{fig:interpretation}
    \end{figure}
}

In the example, the intension of the symbols  $\ensuremath{\mathit{hasFever}}$ and $\mathit{estFievreux}/1$ are the same object denoted $\deref{\ensuremath{\mathit{hasFever}}}$ (or $\deref{\mathit{estFievreux}}$) which is the abstraction of the concept of people having fever.
The symbol $Symptom$ denotes the set containing the intensions  $\deref{\ensuremath{\mathit{hasFever}}}, \deref{\ensuremath{\mathit{coughs}}}$ and $\deref{\ensuremath{\mathit{sneezes}}}$.
In any particular structure, the $\ensuremath{\mathit{hasFever}}{}$ symbol has an interpretation which is a set of elements abstracting the set of people having fever  in the state of affairs.
This set is also the value of the $\deref{\ensuremath{\mathit{hasFever}}}$ intension.
Suppose we want to count the concepts in $Symptom$ whose value (a set) contains person $p$.
The following formula expresses the testing protocol:
\begin{equation}
\label{eq:rule1}
    \forall p : test1(p) \Leftrightarrow 2\leq  \# \{ x | Symptom(x) \land \$(x)(p)\}
\end{equation}

\ignore{
    remove next 2 paragraphs and expand in contribution.
    However, formula~(\ref{eq:rule1}) is incorrect because $x$ quantifies not only over concepts, but also over domain elements, while the value function $\$$ has meaning only for arguments that are concepts.
    Furthermore, when the value of a concept $x$ is not a unary relation, $\$(x)(p)$ makes no sense.
    Under strict evaluation, the sentence would make no sense either.

    Thus, one of the challenges of defining the logic is to find a flexible mechanism to ensure that a formula makes sense.
    The mechanism should be defined at the syntactical level: it should not depend on the particular interpretation of symbols, such as $\mathit{Symptom}$, to avoid performance issues.
    We introduce such a mechanism, and show that its complexity is linear with the length of the formula.
}

In the current state of the art of Knowledge Representation, one might consider, as we once did, applying the common KR technique of \emph{reification}, rather than laboriously extending KR languages as we do.
In this particular case, one could introduce object symbols  $\mathit{Fever}, \mathit{Sneezing}, \mathit{Coughing}$ (under the Unique Name Assumption), and a predicate, $\mathit{Has}$.
We can now represent that Bob has fever by the atom $\mathit{Has}(\mathit{Bob},\mathit{Fever})$.
The testing protocols can then be formalized (in a proper extension of FO) as:
\begin{gather*}
    \begin{split}
        \forall x : &\mathit{Symptom}(x) \Leftrightarrow \\
        &x=\mathit{Fever} \lor x=\mathit{Sneezing} \lor x=\mathit{Coughing}
    \end{split}\\
    \begin{split}
        \forall p : \mathit{test1}(x) \Leftrightarrow 2\leq  \# \{ x | \mathit{Symptom}(x) \land \mathit{Has}(p,x)\}
    \end{split}
\end{gather*}

Still, we believe that our study is valuable for two reasons.
First, we improve the scientific understanding of the problem, thus helping avoid using KR encoding tricks to circumvent it.
Second, our logic is more \emph{elaboration tolerant}.
Per \cite{mccarthy1998elaboration}, ``a formalism is elaboration tolerant to the extent that it is convenient to modify a set of facts expressed in the formalism to take into account new phenomena or changed circumstances''.
Elaboration tolerance is a desirable feature of formalisms used in AI applications, and in particular in knowledge representation.
\ignore{The simplest kind of elaboration is the addition of new formulas.}
Consider a knowledge base that, initially, does not contain rule~(\ref{eq1}).
Per standard KR practice, it would use predicates such as $\ensuremath{\mathit{hasFever}}{}/1$ to encode symptoms.
Then, circumstances change, and rule~(\ref{eq1}) must be introduced.
A formalism that requires rewriting the knowledge base using reified symptoms is not elaboration tolerant.
Our formalism, by contrast, would not require any change to the initial knowledge base.

\ignore{
    There are two reasons why we do not follow this road here.
    First, reification is a useful KR encoding technique but such techniques do not give insight in the nature of the underlying knowledge.
    We believe it is important to look at the problem from a more theoretical angle.

    Second, reification has also downsides: Imagine a large on-going project, with many users and many knowledge components partially based on the same vocabulary. Assume at some point, some group of symbols needs to be reified to express a proposition.
    Unless care is taken, this has impact on all components of the applications that use the symbols being reified, it may confuse users, reduce the readability of the knowledge representation, and it may easily introduce errors.
    It seems to us that future KR systems might better be equipped with language constructs that support such applications without the need for reification.\dmar{I think we can add here the problem that occurred in my pre-dock work on FM. Namely, imagine that you have a set of unary functions, but their type does not have to match. If we introduce objects representing these functions (funs) and want to introduce function val(value, funs)->value, you can not do it, since what is the type of value.}
}

To summarize, the main contributions of the paper are as follows.
We argue that in some KR applications, it is useful to abstract over concepts in quantification and aggregates.
We analyse the connection to well-known intensional logic (Section~\ref{sec:intensional-logic})
, and explain how to distinguish this from second order quantification and meta-programming (Section ~\ref{sec:related}).
We explain how to extend a simple predicate logic so that every ontology symbol has an intensional and an extensional component~(Section~\ref{sec:FoConcept}).
We show that this may lead to non-sensical sentences, and we restrict our syntax to avoid them.
In Section~\ref{sec:FoInt}, we extend FO($\cdot$), a model-based knowledge representation language, and illustrate the benefits of the extension in different applications~(Section \ref{sec:examples}).
\ignore{We also briefly report on a model expansion system, called IDP-Z3, which supports FO($\cdot$) with such extension.}

\section{``Concepts'' in Logic}
\label{sec:intensional-logic}

The notions of a ``concept'' and of its ``value'' in a particular state of affairs that we attempt to study here are closely related, if not identical,  to the broadly studied distinction between \emph{intension} and \emph{extension}, \emph{meaning} and \emph{designation}, or \emph{sense} and \emph{reference} as studied in philosophical and intensional logic.
The close relation between the two urges us to detail the role of concepts or ``intensions'' in intensional logic, and to make the comparison with our approach.

In philosophical logic, the concepts of \emph{intension} and \emph{extension} have been investigated at least since Frege (for a historical overview see \cite{sep-logic-intensional}).
A prototypical example concerns the ``morning star'' and ``evening star'', i.e., the star visible in the east around sunrise, and in the west around sunset.
These words have two different intensions (i.e., they refer to two different concepts), but as it happens, in the current state of affairs, their extensions (i.e., their interpretation) are the same: the planet also known as Venus.

Early key contributors in this study are Frege, Church, Carnap and Montague.
The intensional logics of Montague, of Tich\'y, and of Gallin, are typed modal logics based on \emph{Kripke semantics} in which expressions at any level of the type hierarchy have associated intensions.
They provide notations to access the intension and the extension of expressions.
They also provide modal operators to talk about the different values that expressions may have in the \emph{current} and in \emph{accessible} worlds.

The principles of intensions of higher order objects are similar to those of the base level (domain objects), leading Fitting in several papers (\citeyear{fitting2004first,sep-logic-intensional}) to develop  a simplified logic FOIL where only expressions at the base level of the type hierarchy have intensions.

For example, in the logic FOIL~(\cite{fitting2004first}), the intension of  $\mathit{EveningStar}$ is the mapping from possible worlds to the extension of $\mathit{EveningStar}$ in that world.
We can express that the \emph{extension} of $\mathit{MorningStar}$ in the current world, equals the \emph{extension} of $\mathit{EveningStar}$ in a (possibly different) \emph{accessible} world:
\begin{equation}
    [\lambda x(\diamond (\mathit{EveningStar}=x))] (\mathit{MorningStar})
\end{equation}
Here the lambda expression binds variable $x$ to the extension of $\mathit{MorningStar}$ in the current world, and the ``$\diamond$'' modal operator is used to indicate an accessible world.
This statement would be true, e.g., in the view of a scientist that may not have evidence that both are the same but \emph{accepts it as a possibility}.

A comparison between the work presented in this paper and the  intensional logics in philosophical logic, is not easy. Even if the notion of intension versus extension is underlying the problems that we study here, the focus in our study is on very different aspects of intensions than in philosophical logic. As  a result, the logic developed here differs quite strongly from intensional logics.

An important difference is the lack of modal logic machinery in our logic to analyse the difference between intensions and extensions.
In our logic, a symbol has an extension (aka interpretation) in different possible worlds, but there are no modal operators to ``talk'' about the extension in other worlds than the current one.

On the other hand, our study is on aspects that occur more often in daily KR  applications. This is why we stress the link between intensions  and the pragmatically important concept of informal interpretation of symbols.  In such KR applications, problems such as the symptom example  easily occur (see Section~\ref{sec:examples}). They can  be analyzed and demonstrated and solved in a  logic much closer to standard logic. An important difference is that we provide an abstraction mechanism through which we can quantify over, and count, intensional objects (aka concepts). Compared to FOIL, we associate intensions to predicate and function symbols of any arity even though, as hinted earlier, it poses additional challenges to ensure the syntactical correctness of formulae.
We will address these by introducing guards.
By contrast, FOIL associates intensions only to intensional objects of arity 0, like $\mathit{Morningstar}$, avoiding the issue. Last but not least, our research also includes the extension of an existing  reasoning engine for the proposed logic, such that statements such as (3) can be written and used to solve problems.

\section{FO with Concepts}
\label{sec:FoConcept}

Below, we describe how first order logic, in its simplest form, can be extended to support quantification over concepts.
The language, FO(Concept), is purposely simple, to explain the essence of our ideas.
We present the syntax~(\ref{sec:syntax}), the semantics~(\ref{sec:semantics}), and alternative formulations of the extension~(\ref{sec:alt}).

\subsection{Syntax}
\label{sec:syntax}

We want to extend the FO syntax of terms over vocabulary \voc{} with these four new constructing rules:
\begin{itemize}
    \item[+] $\numeral{n}$ is a term if $\numeral{n}$ is a numeral, i.e., a symbol denoting an integer;
    \item[+] $\#\{x_1,\dots,x_n:\phi\}$ is a term if $x_1,\dots,x_n$ are variables and $\phi$ a formula;
    \item[+] $\deref{\sigma}$ is a term if $\sigma \in \voc$,
    \item[+] $\val{x}(t_1,\ldots,t_n)$ is a term if $x$ is a variable, and $t_1, \ldots, t_n$ are terms over \voc{}.
\end{itemize}

The last rule is problematic, however.
In a structure ${\mathcal{I}}$ extended as we propose, $x$ ranges not only over the domain of ${\mathcal{I}}
, but also over the set of concepts corresponding to the symbols in \voc{}: when the value of $x$ is such a concept, $\val{x}$ is its extension; but when $x$ is not such a concept, $\val{x}$ is undefined.
Furthermore, the value assigned to $x$ may be the concept of a predicate symbol: in that case, $\val{x}(t_1,\ldots,t_n)$ is not a term.
Finally, the value of $x$ may be the concept of a function of arity $m \neq n$: in that case, $\val{x}(t_1,\ldots,t_n)$ is not a well-formed term.

For example, $\val{x}()$ is not a well-formed term in the following cases (among others):
\begin{itemize}
    \item $[x=1]$ where $1$ denotes an element of the domain of discourse;
    \item $[x=\deref{p}]$ where $p$ is a predicate symbol;
    \item $[x=\deref{f}]$ where f is a function symbol of arity 1.
\end{itemize}

Essentially, whereas in FO, arities of function and predicate symbols are known from the vocabulary, and taken into account in the definition of well-formed composite terms and atoms by requesting that the number of arguments matches the arity, this now has become impossible due to the lack of information about $\val{x}$.
Thus, to define well-formed terms, we need more information about the variables occurring in them.
We formalize that information in a typing function.

\newcommand{\guards{t}}{\guards{t}}
\newcommand{\guards{f}}{\guards{f}}

We call $\gamma$ a \emph{typing function} if it maps certain variables $x$ to pairs $(k,n)$ where $k$ is either \predi{} or \funci{}, and $n$ is a natural number.
Informally, when a variable $x$ is mapped to $(k,n)$ by $\gamma$, we know that $x$ is a concept, of kind $k$ and arity $n$.
For a given $\gamma$, we define $\gamma[x:(k,n)]$ to be the function $\gamma'$  identical to $\gamma$ except that $\gamma'(x)=(k,n)$.

This allows us to define the notion of well-formed term and formula:

\begin{definition}
    We define that a string  $e$  is a \emph{well-formed term} over $\voc$ given a typing function $\gamma$ (denoted $\gamma \guards{t} e$)  by induction:
    \begin{itemize}
        \item $\gamma \guards{t} x$ if $x$ is a variable;
        \item $\gamma \guards{t} f(t_1,..,t_n)$ if $f$ is an n-ary function symbol of $\voc$ and for each $i$, $\gamma\guards{t} t_i$;
        \item[+] $\gamma \guards{t} \numeral{n}$ if $\numeral{n}$ is a numeral, a symbol denoting the corresponding natural number $n$;
        \item[+] $\gamma \guards{t} \#\{x_1,\dots,x_n:\phi\}$ if $x_1,\dots,x_n$ are variables and $\gamma\guards{f} \phi$;
        \item[+] $\gamma \guards{t} \deref{\sigma}$ if $\sigma \in \voc$;
        \item[+] $\gamma \guards{t} \$(x)(t_1,\dots,t_n)$ if x is a variable, $\gamma(x)=(\funci{}, n)$ and for each $i \in [1,n]$, $\gamma\guards{t} t_i$.
    \end{itemize}
\end{definition}

(The four rules with a ``+'' bullet are those we add to FO's classical definition of terms.)

\begin{definition}

    We define that a string $\phi$ is a \emph{well-formed formula} over $\voc$ given $\gamma$ (denoted $\gamma \guards{f} \phi$) by induction:

    \begin{itemize}
        \item $\gamma\guards{f} \Tr$, $\gamma\guards{f}\Fa$;
        \item $\gamma \guards{f} p(t_1,\dots,t_n)$ if $p$ is an n-ary predicate of $\voc$ and \\
            for each $i \in [1,n]$, $\gamma\guards{t} t_i$;
        \item $\gamma \guards{f} (\lnot \phi)$ if $\gamma \guards{f} \phi$;
        \item $\gamma \guards{f} (\phi \lor \psi)$ if $\gamma \guards{f} \phi$ and $\gamma \guards{f} \psi$;
        \item $\gamma \guards{f} \exists x: \phi$ if $x$ is a variable and $\gamma \guards{f} \phi$;
        \item $\gamma \guards{f} t_1=t_2$ if   $\gamma\guards{t} t_1$ and $\gamma\guards{t} t_2$;
        \item[+] $\gamma \guards{f} t_1 \leq t_2$ if $\gamma\guards{t} t_1$ and $\gamma\guards{t} t_2$\\
            and $t_1$ and $t_2$ are numerals or cardinality aggregates;
        \item[+] $\gamma \guards{f} (\ite{x::k/n}{\phi}{\psi})$ if $x$ is a variable, \\
            $k$ is either \predi{} or \funci{}, $n$ is a natural number, \\
            $\gamma[x:(k,n)] \guards{f} \phi$ and $\gamma\guards{f} \psi$;
        \item[+] $\gamma \guards{f} \$(x)(t_1,\dots,t_n)$ if $x$ is a variable,  \\
        $\gamma(x)=(\predi{},n)$ and for each $i \in [1,n]$, $\gamma\guards{t} t_i$.
    \end{itemize}

\end{definition}

Notice that, because of the aggregate term rule, these definitions are mutually recursive.
Also, due to their constructive nature, well-formed terms and formulae can be arbitrarily large, but always finite.

Formulae of the form
\begin{equation*}
    \phi \land \psi, \phi\Rightarrow\psi, \phi\Leftrightarrow\psi, \forall x : \phi
\end{equation*}
are defined through their usual equivalences
\begin{equation*}
    \lnot(\lnot \phi \lor \lnot \psi), \neg\phi\lor\psi, (\phi \land \psi) \lor (\neg\phi \land \neg \psi), \neg\exists x : \neg \phi
\end{equation*}
and are not further discussed.
The other comparison operators, $<, >, \ge$, can be defined similarly.

Let $\emptycontext$ be the typing function with empty domain.
We  say  that $\phi$ is a \emph{well-formed formula} over $\voc$ if $\emptycontext\guards{f} \phi$.

\begin{example}
    Here is a well-formed version of the cardinality sub-formula of Equation~\ref{eq:rule1}:
    \begin{align*}
        \# \{ x | &\ite{x::\predi{}/1}{Symptom(x) \land \$(x)(p)}{\\&false}\}
    \end{align*}
\end{example}

We say that $Symptom(x) \land \$(x)(p)$ is \emph{guarded} by the $x::\predi{}/1$ condition, and that the formula is \emph{well-guarded}.

Note that, in this logic, a value $\val{x}$ cannot occur in a formula without immediately being applied to a tuple of arguments.

\paragraph{Complexity}

The determination of the well-formedness of a formula can be performed by backward reasoning, applying the appropriate inductive rule at each step based on the syntactic structure of the formula under consideration.
Notice that the quantifications occurring in the formula are eliminated by the reasoning.
Assuming a unit cost for executing each inductive step, the complexity of the computation is thus linear with the number of sub-formulae, i.e., with the length of the formula.

\subsection{Semantics}
\label{sec:semantics}

Let an \emph{ontology} \Ont{} be a pair of a vocabulary $\voc$ and a synonymity relation $\synrel$ .
Let $\eqcl{\sigma}$ be the equivalence class of symbol $\sigma$ in \Ont{} (or any equivalent witness of this equivalence class),
and $\intdom{}$ be the set of such equivalence classes (or witnesses).
Recall that all synonymous symbols have the same type and arity.

In the philosophical papers about intensional logic, the class of concept is open.
Here, however, we want to quantify only over the concepts that are interpretations of symbols in \voc{}, not over any concepts.
In essence, we want to quantify over $\intdom{}$.

Hence, to define the semantics of FO(Concept), we extend the notion of a structure to include $\intdom{}$ and an additional mapping from concepts to their value.

\begin{definition}
    A \emph{(total) structure} \struct{} over ontology \Ont{} consists of:
    \begin{itemize}
        \item an object domain $D$ containing $\mathds{N}$,

        \item a (total) mapping from predicate symbols $p/n$ in \voc{} to n-ary relations $p^{\mathcal{I}}$ over $D \cup \intdom{}$,
        \item a (total) mapping from function symbols $f/n$ in \voc{} to $n$-ary functions $f^{\mathcal{I}}$ over $D \cup \intdom{}$,

        \item[+] a (total) mapping $\$^\struct{}$ from concepts in \intdom{} to relations and functions over $D \cup \intdom{}$.
    \end{itemize}
\end{definition}

$\$^\struct{}$ interprets the value function ``$\$(\cdot)$''

We now define a notion of \emph{coherency} for structures $\struct{}$, expressing that synonyms have the same value or, more formally, that $\$(\deref{\sigma}) = \sigma$ for any $\sigma$.
\begin{definition}
    A total structure $\struct{}$ over \Ont{} is \emph{coherent} iff
    \begin{itemize}
        \item for every predicate symbol $p \in \voc{}$, $\$^\struct{}{(\eqcl{p})} = p^{\mathcal{I}}$
        \item for every function symbol $f \in \voc{}$, $\$^\struct{}(\eqcl{f}) = f^{\mathcal{I}}$.
    \end{itemize}
\end{definition}

From now on, we consider only coherent structures.

We define a \emph{variable assignment} $\nu$ as a mapping of variables to elements in $D \cup \intdom{}$.
A variable assignment extended so that the mapping of $x$ is $d$ is denoted $\nu[x:d]$.

We introduce the ternary \emph{valuation} function, that maps terms $t$ (resp. formulae $\phi$), structures \struct{} and variable assignment $\nu$ to values $v \in D \cup \intdom$ (resp. to booleans).

\begin{definition}
\label{def:term_value}
    We partially define the value $v$ of well-formed $t$ in (\struct{}, $\nu$) (denoted $\eval{t} = v$) by induction:
    \begin{itemize}
        \item $\eval{x}=\nu(x)$ if $x$ is a variable in the domain of $\nu$;
        \item $\eval{f(t_1, \ldots, t_n)}=f^{\mathcal{I}}(\eval{t_1}, \ldots, \eval{t_n})$ if \\
            $f$ is an $n$-ary function symbol and \\
            $\eval{t_1}, \ldots, \eval{t_n}$ are defined;
        \item[+] $\eval{\numeral{n}}=n$ if $n$ is the integer denoted by $\numeral{n}$;
        \item[+] $\eval{\#\{x_1,\dots,x_n:\phi\}}=m$ if $\llbracket \phi \rrbracket^{\mathcal{I}}_{\nu[x1:d1]\dots[xn:dn]}$ \\
             is defined for every $d1,\dots, dn \in D \cup \intdom{}$,\\
             $m$ is an integer, and\\
             $\#\{\eval{x_1},\dots,\eval{x_n}:\llbracket \phi \rrbracket^{\mathcal{I}}_{\nu[x1:d1]\dots[xn:dn]} = \Tr\}=m $
        \item[+] $\eval{\deref{S}}=\eqcl{S}$;
        \item[+] $\eval{\$(x)(t_1,\ldots, t_n)}=\$^\struct{}(\eval{x})(\eval{t_1}, \ldots, \eval{t_n})$ if\\
            $\eval{x}$ is a concept in \intdom{} mapped by $\$^\struct{}$ to an $n$-ary function,
            and $\eval{t_1}, \ldots, \eval{t_n}$ are defined;
        \item[+] $\eval{t}$ is undefined in all the other cases.
    \end{itemize}
\end{definition}

\begin{definition}
\label{def:form_value}
    We partially define the truth value $v$ of well-formed $\phi$ in (\struct{}, $\nu$) (denoted $\eval{\phi} = v$) by induction:

    \begin{itemize}
        \item $\eval{\Tr} = \Tr$; $\eval{\Fa} = \Fa$;
        \item $\eval{p(t_1, \ldots, t_n)}=p^{\mathcal{I}}(\eval{t_1}, \ldots, \eval{t_n})$ if\\
            $p$ is a $n$-ary predicate symbol and\\
            $\eval{t_1}, \ldots, \eval{t_n}$ are defined;
        \item $\eval{\lnot \phi} = \lnot \eval{\phi}$ if $\eval{\phi}$ is defined;
        \item $\eval{\phi \lor \psi} = \eval{\phi} \lor \eval{\psi}$ if $\eval{\phi}$ and $\eval{\psi}$ are defined;
        \item $\eval{\exists x: \phi} = (\exists d \in D \cup \intdom{}: \llbracket \phi \rrbracket^{\mathcal{I}}_{\nu[x:d]})$ if \\
            $\llbracket \phi \rrbracket^{\mathcal{I}}_{\nu[x:d]}$ is defined for every $d\in D \cup \intdom{}$;
         \item $\eval{t_1 = t_2} = (\eval{t_1}=\eval{t_2})$ if \\
            and $\eval{t_1}$ and $\eval{t_2}$ are defined;
         \item $\eval{t_1 \le t_2} = (\eval{t_1}\le\eval{t_2})$ if \\
            and $\eval{t_1}$ and $\eval{t_2}$ are defined and integers;
        \item[+] $\eval{\ite{x::k/n}{\phi}{\psi}} = \eval{\phi}$ if $\eval{x}$ is a concept in \intdom{} mapped by $\$^\struct{}$ to an $n$-ary predicate or function according to $k$,
            and $\eval{\phi}$ is defined;
        \item[+] $\eval{\ite{x::k/n}{\phi}{\psi}} = \eval{\psi}$ if $\eval{x}$ is not a concept in \intdom{} mapped by $\$^\struct{}$ to an $n$-ary predicate or function according to $k$,
            and $\eval{\psi}$ is defined;
        \item[+] $\eval{\$(x)(t_1,\dots,t_n)} = \$^\struct{}(\eval{x})(\eval{t_1}, \ldots, \eval{t_n})$ if\\
            $\eval{x}$ is a concept in \intdom{} mapped by $\$^\struct{}$ to an $n$-ary predicate, and $\eval{t_1}, \ldots, \eval{t_n}$ are defined;
        \item[+] $\eval{\phi}$ is undefined in all the other cases.

    \end{itemize}
\end{definition}

\begin{theorem}
    The truth value $\eval{\phi}$ is defined for every well-formed formula $\phi$ over \voc{}, every total structure $\struct{}$ over (\voc{}, \synrel), and every variable assignment $\nu$ that assigns a value to all free variables of $\phi$.
\end{theorem}

This can be proven by parallel induction over the definitions of well-formed formulae (and terms) and of their value, applying the properties of $\struct{}$ and $\nu$ when needed.
Indeed, the conditions in the inductive rules of the valuation function match the conditions in the inductive rules of well-formed formulae (and terms).

A \emph{sentence} is a well-formed formula without free variables.
We say a total structure \struct{} \emph{satisfies} sentence $\phi$ iff $\eval{\phi} = \Tr$ for any $\nu$. This is also denoted $\struct \models \phi$.
Coherent structures \struct{} that satisfy sentence $\phi$ are called \emph{models} of $\phi$.

The complexity of decision and search problems in FO(Concept) is the same as in FO.
This is because the domain of structures is extended only with a fixed constant-sized set of elements (and not over higher order objects).
For example, deciding the existence of a model of a FO(Concept) theory with an input domain $D$ is an NP problem (measured in the size of $D$).

\subsection{Alternative formulations}
\label{sec:alt}

FO could be extended to support quantification over concepts in other ways than the one above.

Instead of the $\ite{..}{..}{..}$ construct, we could use $\lor$ (and $\land$) with non-strict evaluation.
Well-guarded quantifications would then be written as follows:
\begin{align}
    \exists x: (x::\predi{}/1) \land \$(x)(p).\\
    \forall x: (x::\predi{}/1) \implies \$(x)(p).
\end{align}

Also, instead of giving \emph{partial} definitions of values (Def.~\ref{def:term_value} and~\ref{def:form_value}), we could give \emph{total} definitions by assigning an arbitrary value when the term (resp. formula) is undefined.
We would then show that this arbitrary value does not matter in well-formed formula.
\section{Extending \fodot with intensions}
\label{sec:FoInt}

We now discuss how we extended the Knowledge Representation language called \fodot to support quantifications over intensions.

\fodot knowledge bases encode knowledge of a particular problem domain.
Such knowledge bases are used to perform a variety of reasoning tasks, using generic methods provided by reasoning engines, such as IDP-Z3~(\cite{IDP-Z3paper}).

\fodot is First Order logic extended with the following extensions:
\begin{itemize}
    \item[+] types: the vocabulary may include custom types, in addition to the built-in types (e.g., \lstinline|Int, Bool|).  Each n-ary symbol has a type signature of the form
    \begin{lstlisting}[language=IDP]
    T1**...**Tn->T\end{lstlisting}
    specifying their domain and range.
     T is \lstinline|Bool| for predicates.
     Formula must be well-typed, i.e., predicates and functions must be applied to arguments of the correct type.
    \item[+] equality: \lstinline|t1=t2| is a formula, where \lstinline|t1| and \lstinline|t2| are terms.
    \item[+] arithmetic over integers and rationals: arithmetic operators (\lstinline|+,-,*,/|) and comparisons (e.g., \lstinline|=<|) are interpreted functions.
    \item[+] binary quantification: \lstinline|?x \in P: p(x).| (where \lstinline|P| is a type or predicate) is equivalent to \lstinline|?x: P(x) & p(x).|
    \item[+] aggregates, such as \lstinline|#{x \in P: p(x)}| (count of \lstinline|x| in \lstinline|P| satisfying \lstinline|p|) and \lstinline|sum(lambda x \in P: f(x))| (sum of \lstinline|f(x)| over P).
    \item[+] $\ite{..}{..}{..}$ formula
    \item[+] (inductive) definitions~(\cite{DBLP:journals/tocl/DeneckerT08}): \fodot theory consists of a set of formulas as described above and a set of (potentially inductive) definitions. Such a definition is represented as a set of rules of the form:
    \[\forall x_1\in T_1,\dots,x_m\in T_n: p(t_1,\dots,t_n) \leftarrow \psi\]
    where $\psi$ is a \fodot formula.

\end{itemize}

\ignore{
    In \fodot, identifiers, i.e., nullary symbols denoting the same elements of $D \cup \mathcal{I}$ in all interpretations are not followed by $()$.}
The reference manual of \fodot is available online\footnote{\url{http://docs.idp-z3.be/en/latest/FO-dot.html}}.

To allow reasoning about concepts, we have extended \fodot with the `` \lstinline|`.| '' operator (to refer to the intension of a symbol) and the ``\lstinline|$(.)|'' operator (to refer to the interpretation of a concept), as described in Section 3 for FO(Concept).

An issue arises in expressions of the form
\begin{lstlisting}[language=IDP]
    $(x)(t1,...,tn)
\end{lstlisting}
$x$ must be a \lstinline|Concept|, the arguments \lstinline|t1,...,tn| must be of appropriate types and number for the predicate or function \lstinline|$(x)|, and \lstinline|$(x)(t1,...,tn)| must be of the type expected by its parent expression.

To address this issue and to support the writing of well-guarded formulae, we have introduced types for the concepts having a particular type signature:
\begin{lstlisting}[language=IDP]
    Concept[T1**..**Tn -> T]
\end{lstlisting}
The interpretation of this type is the set of concepts with signature \lstinline|T1**..**Tn -> T|.
Note that \lstinline|T1,..,Tn, T| themselves can be conceptual types.

The well-formedness and semantics of quantifications over a conceptual type :
\begin{lstlisting}[language=IDP]
    ?x\in Concept[T1**..**Tn -> T]:
        $(x)(t1, .., tn).
\end{lstlisting}
is defined by extending the concept of guards (Section~\ref{sec:syntax}), and considering the following equivalent statement with guards:
\begin{lstlisting}[language=IDP]
    ?x: if x::[T1**..**Tn -> T]
        then $(x)(t1,..,tn) else false.
\end{lstlisting}
where \lstinline|x::[T1**..**Tn -> T]| is a guard specifying the types of the arguments of $x$, and the type of \lstinline|$(x)(t1,...,tn)|.
The definitions of the typing function $\gamma$ (Section~\ref{sec:syntax}), and of well-formed formulae and their semantics are updated accordingly.

The syntax of \fodot allows applying the ``\lstinline|$(.)|'' operator to expressions (not just to variables), e.g., in atom \lstinline|$(expr)()|.
The type of \lstinline|expr| must be a conceptual type with appropriate signature.
An example can be found in Section~\ref{sec:Intl} below.

\ignore{ OLD

    \ignore{
        Notice that we denote the intension of a symbol by \lstinline|`symbol| (and not \lstinline|`(symbol)|).
        We made the choice to not support synonyms of concepts, to reduce the language complexity.
        $\alpha$ is thus a bijection between ontology symbols and concepts.
        In \fodot, \lstinline|`symbol| is actually a concept identifier, i.e., a nullary function that uniquely identifies a concept;
        identifiers are denoted without parenthesis (thus, \lstinline|`symbol|, not \lstinline|`symbol()|).
    }

    The notion of guard is thus extended with conditions of the form:
    \begin{lstlisting}[language=IDP]
        x::[T1**..**Tn -> T]
    \end{lstlisting}
    where \lstinline|T1,...,Tn| specifies the types of the arguments of the extension of $x$, and \lstinline|T| the type of \lstinline|$(x)(t1,...,tn)|.
    The definition of the typing function $\gamma$ is updated accordingly.

    To further simplify the writing of well-guarded formula, we introduced ``subtypes'' of the \lstinline|Concept| type:
    \begin{lstlisting}[language=IDP]
        Concept[T1**..**Tn -> T]
    \end{lstlisting}
    The extension of this subtype is the set of concepts with that particular type signature.
    These subtypes can occur where types occur: in symbol declarations and in quantifications.

    The syntax of \fodot is extended to allow applying the ``\lstinline|$(.)|'' operator to expressions (not just to variables), e.g., in atom \lstinline|$(expr)()|.
    An example can be found in Section~\ref{sec:Intl} below.
    When \lstinline|expr| is properly guarded to ensure its definedness, the atom can be rewritten as \lstinline[language=IDP]|?y in T: y=expr & $(y)()|, where \lstinline|T| is the type of \lstinline|expr|.

}
\ignore{
    Finally, the \lstinline|\$(.)| operator can be used in quantification, e.g.,

    \begin{lstlisting}[language=IDP]
        !c in Concept[()->T]:
          ?x in $(output_domain(c)): p()=x.
        \end{lstlisting}
}

\paragraph{Implementation}
We have updated the IDP-Z3 reasoning engine~(\cite{IDP-Z3}) to support such quantification over concepts.
IDP-Z3 transforms \fodot theories into the input language of the Z3 SMT solver~(\cite{de2008z3}) to perform various reasoning tasks.

A quantification
\begin{lstlisting}[language=IDP]
    ? x in Concept[T1**..**Tn->T]: expr(x).
\end{lstlisting}
is transformed into a disjunction of \lstinline|expr(c)| expressions, where \lstinline|c| is a \lstinline|Concept[T1**..**Tn->T]|.
Occurrences of
\begin{lstlisting}[language=IDP]
    $(c)(t1,..tn)
\end{lstlisting}
within \lstinline|expr(c)| are transformed into \lstinline|p(t1,..tn)| where \lstinline|p| is the symbol denoting concept \lstinline|c|
(Our implementation currently does not support synonymous concepts).
The resulting formula is an FO sentence that can be submitted to Z3.

\section{Examples in \fodot}
\label{sec:examples}

In this section, we explore a few examples where quantifications over concepts proved essential to accurately model the knowledge available within a domain in an elaboration tolerant way, i.e., without reification.
These examples come from a broad range of applications.

The examples can be run online\footnote{\url{https://tinyurl.com/Intensions}} using the IDP-Z3 reasoning engine.

\subsection{Symptoms Analysis}
In symptoms analysis, we model a policy for deciding whether to perform additional testing of patients, based on a set of symptoms.
The core of the knowledge can be expressed through the vocabulary shown in Listing~\ref{lst:symptoms-voc}.
This ontology introduces, among others, a type \lstinline|Patient|, four predicates designating the `risks', i.e., symptoms (\lstinline|hasFever|, \lstinline|coughs|, and \lstinline|sneezes|) and alarming factors (\lstinline|highRisk|), and a predicate over intensions called \lstinline|riskFactor|.
Finally, it introduces the \lstinline|severity| function and the \lstinline|test| predicate which should hold for those patients needing subsequent testing.
\begin{lstlisting}[language=IDP, caption={Vocabulary for the Symptoms Analysis example}, label={lst:symptoms-voc}]
vocabulary V {
  type Patient

  hasFever : Patient -> Bool
  coughs   : Patient -> Bool
  sneezes  : Patient -> Bool
  highRisk : Patient -> Bool

  riskFactor: Concept[Patient->Bool]->Bool
  severity  : Patient -> Int
  test      : Patient -> Bool
}
\end{lstlisting}

\lstinline|riskFactor| is defined as:
\begin{lstlisting}[language=IDP]
    riskFactor := {`hasFever, `coughs,
                   `sneezes, `highRisk}.
\end{lstlisting}

\lstinline|severity| is defined as the number of risk factors that the patient exhibits:

\begin{lstlisting}[language=IDP]
    !x\inPatient: severity(x) =
        #{rf\inriskFactor: $(rf)(x)}.
\end{lstlisting}
This statement is well-formed thanks to the guards implicit in the quantification over \lstinline|Concept[Patient -> Bool]|.

We can then express the constraint that a patient needs testing if he has at least three risk factors:

\begin{lstlisting}[language=IDP]
    !x\inPatient: test(x) <=> 3=<severity(x).
\end{lstlisting}

This approach is used to solve the more elaborate May 2021 DM Community challenge\footnote{\url{https://dmcommunity.org/challenge/challenge-may-2021/}} about Covid\footnote{\url{https://tinyurl.com/Intensions}}.

\ignore{
    Note that considering \lstinline|rf| a second-order logic variable is unsatisfactory as a solution.

    \begin{lstlisting}[language=IDP]
    // second-order
    !x\in Patient: severity(x) = #{rf\in riskFactor: rf(x)}.
    \end{lstlisting}
    \todo{quantification ?}
    Indeed, if everybody have all the symptoms, the set of relations would contain only one element, and nobody would be tested.

    If instead, we were to use reification,

    we would run into trouble if one of the symptoms would depend on constraints while another is defined using rules.
    \todo{exclude ?}
}

\subsection{International law}
\label{sec:Intl}
Since 1990, the European Union has adopted legislation to fight against money laundering and terrorist financing.
It creates various obligations for the parties in a business relationship, such as verifying the identity of the counter-party.
The member states have to transpose the directive into national laws.
The national laws must meet the minimum obligations set forth in the EU directive.

In our simplified example, the EU directive requires the verification of identity in any transaction with a value above 1M€;  a national law might set the threshold at 500K€ instead.
Similarly, the EU directive might require a bank to send a report to their authority at least quarterly, but a country might require a monthly report.

Our goal is then to express the requirement that the national obligations are stricter than the EU ones.
We choose an ontology in which ``has a lower value'' means ``stricter''.
We also use a mapping from the parameters of the national laws to their equivalent parameter in the EU law.

\begin{lstlisting}[language=IDP, caption={Theory for the International law example}, label={lst:intl}]
vocabulary {
    type Country
    threshold, period: Country -> Int
    obligation: Concept[Country->Int]->Bool
    thresholdEU, periodEU: () -> Int
    mapping: Concept[Country->Int]->
        Concept[()->Int]
}
theory {
    obligation := {`threshold, `period}
    mapping := {
        `threshold ->`thresholdEU,
        `period -> `periodEU}

    // each national obligation must be stricter than the European obligation.
    !o\inobligation: !c\inCountry:
      $(o)(c)=<$(mapping(o))().
}
\end{lstlisting}

This example could be written in \fodot without the machinery of concepts: the last axioms could be instantiated for every relevant obligations.
However, our formalism is more concise.

Notice that an expression (not a variable) is applied to the value operator: \lstinline|$(mapping(o))()|.
Because \lstinline|o| is a \lstinline|Concept[Country->Int]| by quantification, it is in the domain of \lstinline|mapping|, and \lstinline|mapping(o)| has type \lstinline|Concept[()->Int]|.
Its value is thus a nullary function of range \lstinline|Int|.

\subsection{Word disambiguation}

A law may be ambiguous.
For example, in ``Parents must feed their children'', the word ``children'' may mean either ``biological'' or ``legal children''.
This statement has two meanings, each inducing its own class of possible states of affairs. In the theory below, the ambiguity is captured by the intensional constant \lstinline|childConcept()| that could refer to either the biological or legal child concept. An assignment to this constant corresponds to a disambiguation of the sentence.

\begin{lstlisting}[language=IDP, caption={Ontology for Word disambiguation}, label={lst:disamb}]
vocabulary V {
    type Person, Word
    biologicalChildof, legalChildOf, feeds:
      Person ** Person -> Bool
    child: Word
    childConcept:
      ()->Concept[Person**Person->Bool]
}}
\end{lstlisting}

The theory has these axioms:

\begin{lstlisting}[language=IDP, caption={theory for Word disambiguation}, label={lst:disambT}]
    childConcept() \in
      {`biologicalChildof, `legalChildOf}.

    !p1, p2\inPerson:
      $(childConcept())(p1, p2) =>
        feeds(p1, p2).
\end{lstlisting}

Each structure that satisfies the axioms will include an interpretation of \lstinline|childConcept| that is consistent with the interpretation of \lstinline|feeds|.
Imagine the legislator has provided a set of good examples (structures) of situations where the intended law holds and some examples  contain a parent feeding only the legal but not the biological children, then, in those examples,  our solver can exclude  ~\lstinline|`biologicalChildof| as a possible interpretation and we can resolve the ambiguity.

\subsection{Templates}

Intensional objects can be used to define templates.
The following example serves to define the transitive closure of all binary predicates in $\voc$ over type \lstinline|Node|.

\begin{lstlisting}[language=IDP, caption={Theory for transitive closure}, label={lst:TransClos}]
vocabulary {
    type Node
    graph1, graph2: Node ** Node -> Bool
    TransClos: Concept[Node**Node->Bool]
               ** Node ** Node -> Bool
}
theory {
  {!r\inConcept[Node**Node->Bool]:!x,y\inNode:
      TransClos(r, x, y) <- $(r)(x,y).
   !r\inConcept[Node**Node->Bool]:!x,z\inNode:
      TransClos(r, x, z) <-
        (?y\inNode:TransClos(r,x,y)
                  &TransClos(r,y,z)).
    }
}
\end{lstlisting}

\ignore{
    Notice that the domain of \lstinline|TransClos| is declared in the vocabulary using the \lstinline|Concept[Node**Node->Bool]| sub-type instead of the \lstinline|Concept| type.
    In the latter case, the rules in the definition would have to be quantified over \lstinline|Concept|~(to fully cover the domain of \lstinline|TransClos|), and appropriate guards would have to be added to their body using the $\ite{..}{..}{..}$ construct, to make them well-formed.
    This would make the rules considerably more complex to write.
}
Contrary to the previous examples, this example could be implemented using second order logic and predicates:
the first argument of \lstinline|TransClos| would range over all binary relations with a \lstinline|Node**Node->Bool| type signature.
This is the approach used by, e.g., ~(\cite{dasseville2015semantics}).
A second order definition of \lstinline|TransClos| would be more general (but also computationally more complex): it would not only define the transitive closure of all binary relations with a \lstinline|Node**Node->Bool| type signature in $\voc$ but also of {\em any} such relation that exists in the structure.
Sometimes, that kind of expressivity is needed, as discussed in the next section.

\ignore{
    \subsection{\set{} Game}
    Our next example is a single-player version of the \set{} game, as described in~\cite{davis2003card}.

    It is played with a deck of cards. Every card in this deck features a shape\footnote{Diamond, squiggle, or oval}, of a certain color\footnote{Red, green, or purple.}, with a certain fill pattern\footnote{Solid, striped, or open.} occurring between one and three times, leading to 81 ($3^4$) unique cards.
    Number, fill, color and shape itself are called the four attributes of a card.
    See \textbf{Figure}~\ref{fig:set} for an example of three \set{} cards, each differing with one another on all four attributes.

    The aim of the \set{} game is for the player to select, out of twelve randomly drawn cards, a \emph{set} of three card such that, for each of the four attributes, the three selected cards either have all the same value, or all different values.
    \textbf{Figure}~\ref{fig:set} thus forms a valid \emph{set}, as do the three cards of \textbf{Figure}~\ref{fig:alt-set}, where the cards have the same shape and fill but differ in color and number.

    As a possible modelling, we suggest the following vocabulary:

    \begin{lstlisting}[language=IDP]
    vocabulary {
        type Card := { 1..12 } //The set of cards

        //Possible values of the features
        type Color := {red, green, purple}
        type Number := {one, two, three}
        type Fill := {solid, striped, open}
        type Shape := {diamond, squiggle, oval}

        attributes : (Concept) -> Bool

        color      : (Card) -> Color
        number     : (Card) -> Number
        fill       : (Card) -> Color
        shape      : (Card) -> Shape

        set        : (Card)

        alldifferent : (Concept) -> Bool
        same         : (Concept) -> Bool
    }
    \end{lstlisting}

    Using this vocabulary, we can model the knowledge in the \set{} game, including a justification for every set \emph{why} exactly it forms a valid set, i.e., which attributes are all different and which attributes are shared by all three cards in the set.

    \begin{lstlisting}[language=IDP]
    attributes('color) & attributes('number) & attributes('fill) & attributes('shape).
     ! attribute\in attributes : if isFunc(attribute)	 & #(attribute, 1) then alldifferent(attribute) <=> #{v : ?c\in set : attribute(c) = v} = 3 else ~alldifferent(attribute).
    ! attribute\in attributes : if isFunc(attribute)	 & #(attribute, 1) then same(attribute) <=> #{v : ?c\in set : attribute(c) = v} = 1 else ~same(attribute).

    #{ att\in attributes : alldifferent(att) | same(att)} = 4.

    #{ x: set(x) } = 3.
    \end{lstlisting}

    \begin{figure*}

    \caption{\todo[inline]{Create missing figure}Three example set cards.\label{fig:set}}
    \end{figure*}

    \begin{figure*}
    \caption{\todo[inline]{Create missing figure}Three example set cards.\label{fig:other-set}}
    \end{figure*}
}
\section{Related Work}
\label{sec:related}

We discussed the relation between intensional logic and our work in Section~\ref{sec:intensional-logic}.
We now discuss the relation with other work.

\ignore{
    \marc{Marcs introduction introduces FOIL hence, first FOIL has to be discussed, then HILOG. Also, by now, FOIL was presented well enough by the intro, so that this section can be moved to the end of the paper. Did HILOG intensionally want to have intensional predicates? I dont think so, it wanted to have some form of higher order predicates.   We analyse HILOG from the perspective of intensional logic, and explain that it can be seen as a very special form of intensional logic extension of Prolog, where with any predicate intensional symbol and any arity, a separate concept is attached. In the semantics of HILOG, any occurrence of the intensional symbol is mapped to the concept of the right arity based on the number of arguments that syntactically occur with the symbol.}

    \marc{ Hier volgt een soort opsomming van hoe onze logica ineen zit. Niet compleet. Dat moet ergens staan, lijkt me. Maar het hoeft niet in related work natuurlijk.
    In the view of this paper, ontology symbols have an intension and, in every state of affairs, an extension. Informally, the intension associated with a symbol is the concept that is the users  informal interpretation of the symbol in the application domain. Formally, it is an atomic object, determined by the symbol itself modulo the synonym table. It has associated attributes and the value function returning the extension, the designation, the reference, the value, of the intension in the contextual possible world. The intension itself is  independent of the structure. Informally, the  extension of an intension depends on the state of affairs and is its value in it. Formally, the extension in some structure is the value of the symbol in the structure.  In logic expressions, occurrences of a symbol are interpreted as references to the extension of the symbol. The operator '$\cdot$ is used to refer to the intension of the symbol itself.  Vice versa, the $\$(\cdot)$ operator returns the extension of an intensional object in the contextual structure. }

    In philosophical logic, the concepts of \emph{intension} and \emph{extension} (or, meaning and designation, or sense and reference)  have been investigated at least since Frege (for a historical overview see \cite{sep-logic-intensional}).
    Early key contributions were by Frege, Church, Carnap and Montague.
    The intensional logics of Montague, of Tich\'y, and of Gallin, are modal logics where intensions are generalized to all types in simple type theory and expressions at any level of the type hierarchy have associated intensions.
    However, the principles of intensions of higher order objects are similar to those of the base level (domain objects) leading  Fitting in several papers (\cite{fitting2004first,sep-logic-intensional}) to develop  a simplified logic FOIL where only intensional objects of the base level of the type hierarchy are present.

    Our main goal was to demonstrate other aspects of intensions that are relevant in the  context of  certain applications of knowledge representation and automated reasoning.
    As such, the logic developed here differs quite strongly from intensional logics.
    An important difference is the lack of modal logic machinery to analyse the difference between intensions and extensions.
    In intensional logics, modal contexts are used for analysing situations where symbols have other extensions than in the contextual state of affairs.
    E.g., to express  that the morning star is the evening star although  not necessarily so:
    \[MorningStar=EveningStar \land \neg \square (MorningStar=EveningStar) \]
    In our logic, an intension has a different value in different structures, but there are no modal operators to ``talk'' about the extensions in other states of affairs than in the contextual one. \todo{Evt. verduidelijken verschil actual vs contextual}
    \todo[inline]{Hier lijkt me een goede plek om je mail van 10/09 te addresseren:}

    \mvdh{
    As a result, it is natural for intensional logics such as FOIL to assume a given Kripke structure, and subsequently analyse it with FOIL formulae.
    Seen descriptively, most FOIL theories have infinitely many Kripke structures that correspond to a (consistent) FOIL model.
    An important contribution of our logic, however, is that it allows solving concrete computational problems through inferences on one of its theories.
    Consequently, it is very important that the formulae in our logic are of a descriptive nature: they describe very specific models that can be derived through inference.
    Although our resulting logic lacks the ability to perform modal analysis, we note that many real world problems can be described without modals.
    }
    \todo{Echt als bijdrage formuleren, inclusief evt. nadelen zoals het gebrek aan modale analyses}

    Compared to intensional logics in philosophical logic, the focus in this study is on different aspects of intensions, aspects that can  be analyzed and demonstrated in a  logic much closer to standard logic (extended with aggregate symbols).
    One contribution of this paper is that on the informal level, we identify the notion of intension of a symbol with the user's informal interpretation of the symbol in the application domain.
    The informal interpretation is in practice a crucial concept in all knowledge representation applications.
    Connecting intensions to informal interpretation provides a good intuitive explanation of what intensions are and how they are relevant in a KR context.

    At the formal level, significant differences between our logic and intensional logics are: the introduction of $Concept$
    \todo[inline]{Dit is momenteel niet zo (we beperken ons tot untyped), en in de getypeerde versie noemden we dat niet $Concept$, al is de naam misschien beter} as a separate type collecting all intensions, the introduction of attributes describing aspects of the concept (e.g., arity and type of arguments making up the type of the concept), and the introduction of the explicit operators $'(\cdot)$ and $\$(\cdot)$.
    The second one replaces the expressions $(\lambda x: t)(\sigma)$ used in, e.g., FOIL to select the extension of an an intension $\sigma$ in the contextual structure, rather than $\$(\sigma)$ in our logic.
    But these small changes have a big impact on the language.

    Indeed, while in intensional logics in general, every intension occurs on a well-typed argument position allowing to detect its type and its arity, this is no longer the case in our logic. To ensure syntactical correctness of formulae, we introduced \emph{guards}.
}

\paragraph{Second Order quantification and relations}

A contribution of this work is to clarify the utility of being able to quantify over concepts in the vocabulary and to show how it differs from quantifying over sets or functions as in second order quantification.
Certainly in the case of predicate or function intensions, it is our own experience that it is easy to confuse the two.
We showed in the introduction the need for quantification over intensions as opposed to over second or higher order objects (relations or functions).
However, the quantification over intensions cannot replace quantification over second order.
A clear cut example of second order quantification and relation occurs in the \emph{graph mining problem} (\cite{DBLP:journals/amai/HallenPJD19}).

\begin{example} An occurrence of a graph, called the \emph{pattern} $p$, in graph $g$ corresponds to a homomorphism, a function $h$ from nodes of $p$ to nodes of $g$ that preserves edges.
The following expression intends to define $\mathit{hom/1}$ as the collection of occurrences of $p$ in $g$.
    \[\forall h: hom(h) \Leftrightarrow (\forall x\forall y: p(x,y) \Leftrightarrow g(h(x),h(y)))\]
\end{example}

The question is: over what sorts of values does $h$ range (in the context of a structure ${\mathcal{I}}$)?  Over the set of  intensions of unary function symbols in $\voc$? There may be none! Or over the set of all binary relations between nodes of the pattern and the graph in ${\mathcal{I}}$?  Clearly, over the latter. Hence, $h$ is a second order variable and $\mathit{hom/1}$ a second order predicate symbol.

\paragraph{HiLog}

In the context of computational logic, we are not aware of languages supporting quantification over concepts, at least not in the sense understood in this paper.
One computational logic that mentions ``intensions'' in its definition is HiLog~(\cite{chen1993hilog}).
Hilog is a powerful declarative programming language, used in the Flora-2 system (\cite{conf/coopis/YangKZ03}).
But it soon becomes clear that  ``intension'' there is to be interpreted differently than here.
HiLog is an extension of logic programming formalism with a higher-order syntax and  a first order semantics.
Skimming over the details of HiLog's definition, what is important is that a HiLog structure associates with every symbol both a so-called ``intension'' (in practice, the symbol itself) and a class of ``extensional'' values:
for every number n, an n-ary relation and an n-ary total function in the domain of the structure.
As such, one cannot associate a clear-cut relational or functional concept to a HiLog symbol; it is more like a collection of relational and functional concepts, one for each arity n.
That makes it incomparable to our logic and to most intensional logics.

In HiLog, because a symbol can be applied to tuples of any length and any type, any formula is well-formed.
Thus, the concept of guards is unnecessary.
The developer of a knowledge base in HiLog cannot benefit from the automatic detection of the syntactical errors that our method provides.

\ignore{ templates
    HiLogs main goal is to offer generalized predicate definitions.

    For example, one can define the transitive closure $Transclos(g)$  of the binary relation associated with the symbol $g$:
    \[ \begin{array}{l}
    TransClos(g)(x,y) \leftarrow g(x,y).\\
    TransClos(g)(x,z) \leftarrow TransClos(g)(x,y), TransClos(g)(y,z)
    \end{array}
    \]

    This facility is not offered in our language, but vice versa, none of the examples of our logic can be modelled in HiLog.
    \mvdh{Hier is zeker een woordje extra nodig}
    \marc{Hilog is not a logic to represent absence of knowledge of p and q}
    \pierre{It is easy to transform the above definition into a definition of $TransClos(g, x, y)$ in our language.  The problem is with the signature of $TransClos$: what is the type of the second and third argument ?  If we introduced a built-in type $Object$, whose extension is the whole domain of discourse, we could declare $TransClos : Symbol \times Object \times Object \rightarrow Bool$ as a partial function.}
    \todo{Maurice: at this point you have to confront HiLog with our
    template example and point out the difference.}
}
HiLog is a programming language: an HiLog program is meant to be run to perform only one form of reasoning: querying.
By contrast, our implementation in IDP-Z3 allows many forms of reasoning, such as model expansion or propagation (\cite{IDP-Z3paper}).
Unlike HiLog, IDP-Z3 supports the computation of aggregates.

\ignore{
    HiLog is a rule-based language, it does not extend FO like our logic does.
    Strictly speaking it cannot represent a disjunction $p\lor q$ without adding extraneous symbols.
    None of the examples of our logic can be modelled in HiLog.
    \todo{This statement does not seem correct}
        HiLog is implemented in Flora-2~\cite{yang2005flora} and partially in XSB~(\cite{swift2012xsb}) systems.
}

\ignore{

    We identify two major lines of related work; firstly, the work around HiLog~(\cite{chen1993hilog}), that ``combines advantages of higher-order syntax with the simplicity of first-order semantics''. Secondly, the work on intensions in the context of modal logics, as studied by Fitting~\cite{fitting2004first}.

    In HiLog, as in our approach, every (parameter) symbol is associated with an \emph{intension}. \marc{"intension": is that our terminology or theirs?}\todo{Should we stress their use of parameter vs our use of function / predicate symbols here?}
    Their higher-order syntax allows variables that range over these intensions, and allows these intensions, represented by the symbol name itself, to occur as arguments in predicate heads or predicate calls.
    Although the resulting logic bears resemblance to ours, important differences can be found in syntax, in semantics, and in spirit.

    Specifically, HiLog refers to these intensions using the symbol itself, thereby recuperating the higher-order syntax, while we propose a dereference operator that maps every symbol onto its intension.
    While this may seem trivial, we argue there are multiple shortcomings of this approach when working out a clear semantic meaning of intensions in \emph{Knowledge Representation}:
    Using standard higher-order syntax for intensional occurrences impedes the unification of intensional knowledge and higher-order\footnote{We also refer to this as extensional knowledge.} knowledge within a single system.
    Such a unified system is worthwhile as, while overlap exists, there are clear examples for both, as shown in \secref{}.

    It is of course possible to distinguish extensional occurrences syntactically instead, but we see two reasons advising against this approach:
    First, the syntax of higher-order logic has been standard for years, and repurposing it should not be done lightly.
    Second, not distinguishing intensional occurrences impoverishes the distinction between intensional and extensional occurrences; consider, for example, the occurrence of the symbol $P$ in its application $P(t)$, which is clearly extensional but not distinguished as such in HiLog.
    \todo[inline]{Argument $P(t)$ is extensional: If it's not, then a higher order quantification cannot use the regular application (), as it would expect something intensional, e.g., no higher-order sentence \lstinline[mathescape]{!P : P(x)}}

    Semantically, it is important to note that HiLog considers parameter symbols to have a single \emph{intension} but multiple \emph{extensions}; a single symbol is associated with different extensions according to the different roles it can assume in a sentence: as a constant, a function or a predicate, the latter two with any arbitrary arity.
    Any symbol can thus occur in any role and is assigned an extension for any such role.
    This is in stark contrast to our approach, where a symbol can occur extensionally in only a single role and with a single arity.

    The semantic difference described above leads not only to an important difference in semantic structures, but also in spirit: as intensions, to us, are associated to symbols from the ontology, we have encountered no examples of \emph{intensions} in knowledge representation that permit multiple extensions of differing arity.
    \todo{Express this in a better way...}

    A final distinction between HiLog and our system can be found in the foundations of HiLog as a Logic Program, with only a single Herbrand model, where choice and search must be encoded separately, as oppposed to a knowledge base system such as ours, which has multiple models and permits a number of different inferences such as satisfiability checking, model expansion or minimization on the same knowledge specification.

    A different study of intensionality, specific to the context of modal logics, can be found in \cite{fitting2004first}.
    Here, a first-order modal logic called \FOIL{} is introduced.
    In this logic, \emph{intensions} allow distinguishing on some level $the morning star$ from the $the evening star$, even though, in a typical frame of reference, both refer to the same object, i.e., Venus.
    In much the same way, our logic allows the distinction between the people who are feverish, represented by the predicate $fever$, and those who are sneezing, represented by $sneezing$, to be made, even in structures where both are assigned the exact same extension.

    However, some fundamental differences arise when we consider that in the semantics of \FOIL{}, the mapping of symbols to intensions is dependent on the \emph{possible worlds} of the associated modal logic, while in our logic, the mapping of symbols to intensions is rigid.
    Furthermore, their logic effectively allows only constants to have an intension.

}

\section{Summary}
As our examples illustrate, it is often useful in knowledge-intensive applications to quantify over concepts, i.e., over the intensions of the symbols in an ontology.
An intension is an atomic object representing the informal interpretation of the symbol in the application domain.

First Order logic and \fodot can be extended to allow such quantifications in an elaboration tolerant way.
Appropriate guards should be used to ensure that formulae in such extensions are well-formed: we propose a method to verify such well-formedness with a complexity that is linear with the length of the formula.

While related to modal logic, the logic introduced here differs quite strongly from it.
It has no modal operators to talk about the extension of a symbol in other worlds than the contextual one, but it offers mechanisms to quantify and count intensional objects.

\ignore{

    \dmar{I have written a few sentences for the summary. Please check these, add or change it :)}

    Knowledge representation languages should be expressive in the sense that they can encode many classes of knowledge. Besides expressivity, language should provide constructs that allow the natural and compact representation of knowledge.

    We notice in various real applications that a set of properties should hold for distinct concepts. Sometimes we can get over this problem by reifying these concepts into explicit objects. This technique is practical in many cases. However, as soon as reified function symbols have different codomains, this approach fails. Therefore, sometimes it is convenient to talk about concepts rather than their value. Allowing intensional objects is a straightforward approach for this problem. The plain syntax and semantics proposed in this paper make it natural and unequivocally.

    Extending language with intensional objects results in language constructs that allow great compactness. It is relevant to notice that there is no difference in the expressivity of the language.\pierre{I would dispute that.  It is "polynomially" more expressive.} \dmar{I don't understand. What is polynomially more expressive. I think there is no statement you can express with FO(io) and can not with FO(). I have a feeling that we are mismatching what is expressivity.} One can express the same theory with or without the use of intensional objects. However, in many cases, one can significantly reduce the size of a formalization.

    \marc{I think that expressivity is a dangerous term here. Lets think deeper and be more precise. In each example, we have in mind a range of instantiations and a property that holds in this range of instantiations. We have have a language taht can express this property, once and for all. And then we may notice that without this langauge feature, we are forced to introduce instantiation-specific axioms: different axioms for different instantiations. Moreover, the different axiom may polynomially grow in size with some measure of the instantiation. Can we prove this? In any case, from a KR point of view, there is undeniably value in such sort of language primitive. I think we should say this: `` there is undeniable KR value in such a language primitive". }

    \marc{But what I have missed so far is the comparative analysis with higher order logic. }

}

\section{Implementation}
\todo{update}

We have extended our $FO(\cdot$) implementation to support intensional objects as proposed in this paper.
Its source code is available on-line~\cite{IDP-Z3}.
It is written in python and uses the Z3 Satisfiability Modulo Theories (SMT) solver as a back-end~\cite{de2008z3}.

The engine uses a ground-and-solve approach: formulae quantified over a finite set of values are instantiated for each value in the set, starting from the outermost quantifiers.
This approach applies to formulae quantified over $Symbol$, the set of intensional symbols automatically created by analysis of the vocabulary.
Crucially, the built-in introspection functions, such as $arity$, are immediately evaluated after instantiation with a particular symbol.
Thus, they do not appear in grounded formulae.
Furthermore, the expressions in which they appear, are grounded in a non-strict manner, as explained in the formal semantics section.

This non-strict grounding can be used by the knowledge expert to ensure that $\$(s)$ is applied to appropriate tuples of arguments, by guarding $\$(s)$ with appropriate applications of introspection function.
For example, in
\begin{align*}
    \forall s \in Symbol:&arity(s) = 0 \land output\_domain(s)=Bool \\
    & \land \$(s)().
\end{align*}
$\$(s)()$ is grounded only with propositional symbols.

The inference of the type of a quantified variable is performed just before grounding the quantified formula: at that time, any outer quantification is already grounded.
For example, in
\begin{align*}
    \forall s \in Symbol: & arity(s) = 1 \land output\_domain(s)=Bool \\
    & \land \forall x: \$(s)(x).
\end{align*}
the type of $x$ is inferred for each unary predicate.

\maurice{implementation uses "\$" instead of "'" for dereferencing?Ground the dereferencing formula of your running example toillustrate the grounding}
\section{Introduction}
A logic is in no small part characterized by the things that can be quantified over within the language. \todo{`In propositional logic, no quantification is possible'?} In \emph{first order} logic, we can quantify over domain elements.
Turning to \emph{higher order} logic, we can additionally quantify over \emph{sets} of \emph{domain elements}.
Our study of logic as a knowledge representation (KR) language, however, has led us to believe that logic needs another form of quantification in order to be a great KR language. \todo{For readability, drop either `as a representation language' or `to be a great KR language'.}

In a KR application of logic, a \emph{vocabulary}, sometimes also referred to as \emph{ontology}, introduces symbols for \emph{concepts} that exist within the knowledge domain;
exactly these concepts from the knowledge domain are of interest to the new type of quantification that we suggest.
We often find ourselves wanting to identify, quantify or count concepts, for example:
\begin{itemize}
\item In a medically oriented knowledge base, we introduce the predicates $\mathit{Sneezing}$, $\mathit{Coughing}$ and $\mathit{Fever}$.
Later on, we want to write a constraint that counts the number of symptoms that patients exhibit.

\item In a knowledge base detailing a card game, functions such as $\mathit{Color}$, $\mathit{Shape}$ and $\mathit{Fill}$ describe properties of each of the cards.
One of game's rules says that for a valid selection of cards, every property must either be of \emph{identical} or \emph{unique} value, for example, four cards with identical shape and fill but of all different colors form a valid selection.

\item One more example would be nice \ldots
\end{itemize}

\noindent If quantification over concepts is not supported directly, constraints such as those suggested above are often expressed using \emph{reification}~\cite{} or \emph{higher order} logic.
In \textbf{Section}~\ref{}, we give an overview of these approaches and detail the benefits we believe that direct support for quantification over concepts has to offer.

\todo[inline]{Ergens hier moet komen wat dan precies *onze* approach is, maar ik heb wat moeite met de plaatsing \& het benodigde detail. Blijven we oppervlakkig, en geven we detail in een latere sectie waar we dieper kunnen ingaan op intensie, synoniemen en datgene uit de figuur (\ref{fig:fig1}) hieronder?
`We propose two new language construct: one language construct that, for a given vocabulary \emph{symbol}, refers to the \emph{concept} it represents, also called its \emph{intension}; the second construct refers for a given \emph{concept} to its \emph{value} in the interpretation.'}

We refer to the \emph{concept} \st{from the knowledge domain} that a vocabulary symbol represents as the symbol's \emph{intension}; this is in contrast to a symbol's \emph{extension}, which refers to a symbol's value within a \emph{model} or \emph{interpretation}.
This distinction has previously been studied in linguistics and modal logics~\ref{}.
In these studies, sentences such as ``the morning star is the evening star'' illustrate that human knowledge is sensitive to \emph{intensions}, i.e., it is not \emph{extensional}.
To see this, reflect on the knowledge the previous sentence offers compared to a sentence such as ``the morning star is the morning star''.
By considering quantification over intensions rather than quantification over symbols, as a meta-programming approach would do, we hope to one day synthetise these lines of research. \todo{I think a sentiment like this should be included, but should be expressed better?}
\textbf{Section}~\ref{} discusses in more detail the notion of `intension' in related literature.

In \textbf{Section}~\ref{}, we introduce the semantics for first order logic extended with intensions. In \textbf{Section}~\ref{}, we detail the implementation of a knowledge base system supporting the extension.

\begin{figure}
\includegraphics[width=\linewidth]{Images/SecondDraftDiagram}
\caption{The interaction of the new $'\cdot$ and $\$(\cdot)$ language constructs, w.r.t. straightforward occurrence of a vocabulary symbol. \label{fig:fig1}}
\end{figure}

\section{Motivation}
\marc{I find this a fairly well-written motivation. I can see that it has much in common with the introduction that I wrote. But I think I wrote it  in a more direct way. Here, the structure is by providing a problem and then exploring different erroneous ways how to do this; leading to the solution. But that is a difficult road. My  introduction assumes we know basically quite well what we say: Test somebody if she has at least two symptoms. we just have to analyse it. .. So, I think this motivation should go.   }

Over the years, first order logic has benefited from many extensions: inductive definitions to formalize definitional knowledge, arithmetic including aggregates, uninterpreted and partial functions, \ldots .

For each of these extensions, one or more examples problem statements can be given that depend on knowledge that is either difficult or even impossible to express in standard first order logic without the extension.

In this paper, we introduce the \emph{symptoms triage} problem, and claim it supports our need for a language extension we call \emph{intensional objects}:

\begin{example}[Symptoms Triage]
A number of patients present themselves to a triage center for diagnosis, as they present one or more symptoms of a disease.
The symptoms in question are coughing, sneezing and fever.
The triage system decides who has to undergo subsequent testing, based on the \emph{number of symptoms} each patient presents; specifically, they test anyone who presents \emph{at least} two symptoms.
\end{example}

A straightforward representation of the knowledge in this problem could introduce the predicates $\mathit{Coughing}$, $\mathit{Sneezing}$ and $\mathit{Fever}$. Naively, the following first order constraint could model the condition that (only) patients who exhibit at least two symptoms are kept for testing ($\mathit{Test}$).

\[
\forall x . \mathit{Test}(x) \Leftrightarrow \left(\begin{array}{c}
	(\mathit{Coughing}(x) \land \mathit{Sneezing}(x))\ \lor \\
	(\mathit{Coughing}(x) \land \mathit{Fever}(x))\ \lor \\
	(\mathit{Sneezing}(x) \land \mathit{Fever}(x)) \\
\end{array}\right)
\]

However, it soon becomes clear that this approach does not scale well and is very fragile to changing requirements such as taking into account additional symptoms, or changing the number of symptoms that patients must present.
Consider the amount of work to be done if the list of possible symptoms were to be extended with `loss of smell' and `loss of taste', and/or if the threshold for testing was raised to \emph{three} symptoms.

While this approach shows the knowledge underlying the problem can clearly be expressed using first order logic, the resulting theory is definitely not elaboration tolerant~\cite{}. \mvdh{Add ref to elaboration tolerance (McCarthy)! + Some sentence about elaboration tolerance, and a statement it is a property to be desired by any knowledge specification / KR language?}

A second approach would be to use the same ontology of predicates $\mathit{Coughing}$, $\mathit{Sneezing}$ and $\mathit{Fever}$, and to try and express the testing condition using an aggregate.
The underlying concept of an aggregate is a set expression $\{ \overline{x} \mid \phi \}$ where $\overline{x}$ is a tuple of fresh variables, and $\phi$ expresses a condition for $\overline{x}$ to be in the set; we can then count the number of elements in the set using the cardinality aggregate function ($\#$).
For the threshold constraint, this would give us:
\begin{gather*}
\forall x .  \mathit{Test}(x) \Leftrightarrow \\
\#\left\{ s \left| \begin{array}{c}
s \in \{\mathit{Coughing}, \mathit{Sneezing}, \mathit{Fever}	\} \land \\
s(x)
\end{array}
\right.
\right\} \geq 2
\end{gather*}

\noindent These aggregate expressions can easily be extended w.r.t. the symptoms in the set to be counted and the threshold the count must exceed.

However, a closer assessment of the expression above suggests that we have left first order logic behind us, and have resorted to using higher order logic when expressing the set of symptoms to be counted, both when expressing the condition for symptoms to be present in the aggregate argument set ($s \in \{\mathit{Coughing},\ldots\}$), as well as in the aggregate argument set itself.

Even worse, and surprisingly, the constraint suggested above is not even semantically correct!
Specifically, due to the extensional semantics of higher order logic and sets, we can only conclude that in, for example, a model where the people who sneeze are exactly those who cough and have a fever as well, the higher order set \emph{contains just a single value}.
Slightly foreshadowing our eventual proposal, we do note that resorting to multi-sets, which have an intrinsic ability to differentiate elements that have the same value, offers some solution to the semantic problem. \mvdh{So why don't we? `We claim, however, that our eventual solution offers a more rigorous and principled approach?' or something of the likes?} \marc{In my opinion, using  a multi-set based solution  is basically a fake solution, because it does not identify the nature of the objects that we quantify over. It could be technically ok, but it quite explicitly avoids to talk about the nature of the abstract objects: they are set occurrences that can occur multiple times, but what determines how many occurrences there are of a set?  Suppose Coughing, Sneezing and Fever have the same value, is this 1, 2 or 3 occurrences and why? Or if we use $Symptom(x) \land Symptom(y) \land x\neq y$ what is $Symptom$ ranging over? What does it mean that $x\neq y$ if $x, y$ range over sets?  It does not explain *at all* the link with intensional objects. I think/hope that this was done well in my proposed introduction.}

One final, radically different approach to the problem would be to perform a \emph{reification} of the different symptoms, leading to an ontology that consists of just a single \emph{binary} symbol $\mathit{Exhibits}$ to represent all knowledge about patients and their symptoms, considering a domain that contains elements not only for every patient but also for every possible symptom: the elements $\mathit{coughing}$, $\mathit{sneezing}$ and $\mathit{fever}$.

The threshold constraint can now be expressed as:
\[
\forall x . \mathit{Test}(x) \Leftrightarrow \#\left\{s \left|
\begin{array}{c} s\in \{\mathit{coughing}, \mathit{sneezing}, \mathit{fever}\} \\
\land\ \mathit{Exhibits}(s,x)
\end{array}
\right.
\right\} \geq 2
\]

This constraint is first order, and, thanks to its use of a set expression and cardinality function, is elaboration tolerant.
However, a major drawback of this approach is that we have resorted to a form of meta-representation that permeates our entire knowledge specification, having chosen a much more involved reified ontology over the straightforward ontology used previously.
While the resulting knowledge specification is now elaboration tolerant w.r.t. additional symptoms or different thresholds, it is highly likely that if the constraint of needing at least two symptoms was already an elaboration of an earlier problem, the road leading to this specification was fraught with changes and reformulations due to a change in ontology from the simple and straightforward representation to the reified meta-representation.\mvdh{Barring the approach of two different representations side by side supported using channeling constraints.}

Additionally, the reified ontology presents an additional drawback when considering that some symptoms \mvdh{(or more general, relations/criteria)} are specified by \emph{definitional knowledge}.
Consider, for example, an elaboration of the problem where we track confirmed disease cases ($\mathit{Sick}$), a binary close contact relation ($\mathit{Exposed}$) and summarize that in an additional symptom called $\mathit{HighRisk}$:
\begin{align*}
&\{\\
&\forall x . HighRisk(x) \leftarrow \exists y . \mathit{Exposed}(x,y) \land (\mathit{Sick}(y) \lor \mathit{HighRisk(y)}).\\
&\}
\end{align*}

It is straightforward to see that in a reified ontology, this definitional knowledge regarding the `high risk' symptom can only be expressed using auxiliary symbols, as the  relation $\mathit{Exhibits}$ can only be a defined symbol if we can provide definitional rules for \emph{every} symptom. \marc{I remember there was a good point here, but it is technical.}

We have given an overview of attempts to express the required knowledge of the \emph{symptoms triage} problem in an clear, simple and elaboration tolerant way, and discussed their drawbacks.
We can now propose our solution, which in some way can be seen as a synthesis of these earlier attempts.\mvdh{, based on the concept of \emph{intensions}.}

Note that in our ontologies, every symbol corresponds to a specific \emph{intension}.
This intension is the \emph{meaning} of a symbol, its formal definition.
This formal definition is there as soon as we compose our ontology, it is known without any notion of a domain, and thus strictly separate from its value, also referred to as \emph{its extension}, that is an element of the domain.

For an archetypical example of the importance of intensions, consider the two symbols ``morning star'' and ``evening star''.
The intension of the morning star is \emph{the first star you see in the morning}, while that of the evening star is \emph{the last star you see in the evening}.
The sentence \emph{``the morning star is the evening star''} holds informational content, whereas the sentence that \emph{``the morning star is the morning star''} conveys no information at all.
The difference, however, does not derive from a different value for both symbols, as the ``morning star'' and ``evening star'' both denote the planet Venus, extensionally.
Thus, we must conclude that (a) the intensions of both symbols are what lends the first sentence informational content, and (b) two symbols can share the same \emph{extension} without having the same \emph{intension}.

We argue that, in the approach that combines higher order logic with multisets, the way that multisets disambiguates between the different predicate symbols in a multiset, even when they designate the same (set) values, actually takes into account the \emph{intension} of each of the symbols.
Likewise, in the approach that modifies the ontology through reification, the domain elements introduced by the reification are, in fact, representatives of the \emph{intensions} of the original symbols, injected into the domain.
Thus, from a practical point of view, it would suffice to extend first order logic with a framework for reasoning with \emph{intensions}, including predicates and variables over intensions and language constructs that transform a symbol into its intension and vice versa.
This also allows for a much more satisfactory theoretical, knowledge representation point of view.

To illustrate our approach on the \emph{symptoms triage} puzzle, it suffices to know that our framework introduces the dereferencing language operator $'$ that maps every symbol to its intension\mvdh{or `intensional object'?}, and the apply language operator $\$$ that allows referring to the extension of any intensional object.
\footnote{\mvdh{While we do not consider such cases here, note that the existence of the apply language operator (correctly) implies that when two symbols share a single \emph{intension} (i.e., when they are synonyms), they also have the same \emph{extension}}}
We can then formalize the threshold constraint as:

\begin{gather*}
\forall x .  \mathit{Test}(x) \Leftrightarrow \\
\#\left\{ s \left| \begin{array}{c}
s \in \{\mathit{'Coughing}, \mathit{'Sneezing}, \mathit{'Fever}\}\ \land\\
\$(s)(x)
\end{array}
\right.\right\} \geq 2
\end{gather*}

\noindent where it is important to note the use of the two new operators: $'$ in the set containing the \emph{intensions} of $\mathit{Coughing}$, $\mathit{Sneezing}$ and $\mathit{Fever}$, and $\$$ in the check that $x$ is contained by the extension associated with $s$.

In this paper, we ... \todo[inline]{\mvdh{continue with an overview of the different sections, and what we achieve in each of them...}}

\todo[inline]{
Gerda: ``daarna kan er dan het verschil uitgelegd worden tussen een domain element, een higher-order element en een intensional object'':\\
\mvdh{
Een domain element zijn de mogelijke waarden van symbolen, zoals bepaald door het domein.
Een higher-order element is een relatie (of functie) over het domein.
Intensional objects zijn de intensies van de symbolen, vastgelegd door het vocabularium, (en 'als elementen ge\"injecteerd' in elk domein van structuren over dit vocabularium? Dit maakt het misschien ingewikkeld, maar lijkt wel noodzakelijk voor de consistentie, als we predicaten over intensies hebben...)
}
}

\section{Joost's Introduction}

Whenever we use classical first-order logic (FO) to represent some piece of knowledge, we first have to introduce \emph{symbols} to represent the \emph{domain concepts} that we wish to talk about. The formal semantics of FO will then assign a \emph{value} to each of these symbols. For instance, suppose we want to represent the information ``the actor Nicholas Cage has won an Oscar''.
\begin{itemize}
\item The concept ``the actor Nicholas Cage'' can be represented by, e.g., the constant $NickCage$ and an interpretation $S$ will assign to this constant a domain element $NickCage^S \in dom(S)$ as its value;
\item The concept ``winning an Oscar'' can be represented by a unary predicate $OscarWinner/1$ and an interpretation $S$ will assign to this predicate a unary relation $OscarWinner^S \subseteq dom(S)$.
\end{itemize}
Using these symbols, we can represent our knowledge by the following (atomic) formula $\varphi$:
\[
OscarWinner(NickCage)
\]
which of course has the formal semantics that: $S \models \phi$ if and only if $NickCage^S \in OscarWinner^S$.

It is clear, here, that whenever we use symbols (e.g., $NickCage$ or $OscarWinner$) in our formulas, these symbols actual refer to their \emph{values} in a certain structure $S$ (e.g.., the domain element $d = NickCage^S$ or the unary relation $OscarWinner^S$). This is of course the same as what also happens with symbols in almost any programming language: in an expression such as \verb|x + 9 * y|, the symbols \verb|x| and \verb|y| refer to their values. Some programming language include an operator that allows to ``quote'' a symbol, producing an expression that refers to the symbol itself, rather than to its value. For instance, the LISP expression \verb|(equal x y)| tests whether the values of \verb|x| and \verb|y| are equal (which may or may not be the case), whereas the expression verb|(equal 'x 'y)| tests whether the symbols \verb|x| and \verb|y| themselves are equal (which they are not).

In this paper, we introduce the same $'\sigma$ operator into classical FO and explore its uses from a knowledge representation perspective. In particular, we examine possible uses of this operator to quote not only constants, but also functions and relations. This allows us to do a kind of higher-order quantification, which is nevertheless---as we will show---quite different from classical higher-order quantification. We will also consider an extension of FO with aggregates, allowing the use of terms such as $\#\{ x : \varphi(x) \}$, representing the number of $x$ for which $\varphi(x)$ holds, since this will reveal a number of interesting use cases.

Throughout this paper, we assume that we construct our FO vocabularies in such a way that each domain concept is represented by a unique symbol. In other words, we do not consider situations in which the vocabulary contains ``synonyms'' (two distinct symbols that nevertheless represent the same concept, such as $Oscar$ and $AcademyAward$ might). This considerable simplifies the setting, since we can therefore, e.g., count concepts by simply counting symbols.

\section{Quoting constants}

The difference between a symbol's \emph{intension} (the concept that the symbol represents) and its \emph{extension} (the value of the symbol) has been well-studied in philosophy. Kripke famously discussed the example of Hesperus and Phosphorus being names for the concepts ``the evening star'' (= the intension of Hesperus) and ``the morning star'' (the intension of Phosphorus), whose extension is same in the world in which we live (namely, as it turns out, it is the planet Venus).  In our logic, we can introduce the vocabulary $\Sigma = \{ Hesperus, Phosphorus \}$ containing the two constants. The world in which we live can then be represented as the structure $S$ such that $dom(S) = \{ Venus \}$ and $Hesperus^S = Venus = Phosphorus^S$. It is then the case that $S \models Hesperus = Phosphorus$. However, no model exists for the sentence $'Hesperus = 'Phosphorus$, since both symbols are different.

In logic programming, it is common to make use of Herbrand interpretations, in which each constant is interpreted as itself. This restriction is often imposed on a meta-level, but our logic allows to express that a constant $C$ is a Herbrand constant by the following formula $H(C)$

\[ C = 'C.\]

For each structure $S$, $S \models H(C)$ if and only if $C^S = ('C)^S = C$, i.e., if $C$ is indeed a Herbrand constant in $S$.

\section{Syntax and semantics}

A \emph{vocabulary} $\Sigma$ is a set of \emph{symbols} $\upsigma$ and their associated signature, that satisfy these inductive rules:
\begin{itemize}
    \item \U and $\B$ are symbols with signature $\U \rightarrow \B$;
    \item a \emph{base type} $t$ is a symbol with signature $\U \rightarrow \B$
    (e.g., \U, $\B$, $\mathds{N}$, the \emph{intension type} $\In$, or any custom type);
    \item a \emph{typed symbol} $\sigma$ is a symbol with signature $\bar{\bt} \rightarrow \bt$, where $\bar{\bt}$ is a tuple of base types, and $\bt$ a base type.
\end{itemize}

Notice that we consider base types as symbols, so that they (and their intension) can occur in logic formula.

For each symbol $\upsigma$, $\tau(\upsigma)$ is its signature.
The \emph{arity} of $\upsigma$ is 1 for base types, and the length of the n-tuple in $\tau(\upsigma)$ for typed symbols.
The arity of a typed symbol can be 0.

A \emph{universe of discourse} $\mathscr{U}$ is a tuple $\langle \U^\mathscr{U}, \mathscr{U}_{int}, \mathscr{U}_{v}, \rangle$, such that:
\todo{or "domain of discourse" ?}
\begin{itemize}
    \item a set $\U^\mathscr{U}$, that includes the set of $\{\Tr, \Fa\}$ booleans and the set of \emph{intensions};
    \item $\mathscr{U}_{int}$ is a total mapping from base types $\bt$ \pierre{and some typed symbols ?} to their \emph{intensions}, noted $`\upsigma^{\mathscr{U}}$, i.e., a partial function from $\Sigma$ to the set of intensions;
    \item $\mathscr{U}_v$ is a total mapping from base types $\bt$ to their \emph{value}, $\bt^{\mathscr{U}}$, where $\bt^{\mathscr{U}}$ is a function from  $\U^\mathscr{U}$ to the set of booleans; the value of a base type specifies which elements of $\U^\mathscr{U}$ belong to the base type.
    \item $\mathscr{U}_v$ defines a partition of $\U^\mathscr{U}$, with one subset associated to each base type.
\end{itemize}

For example, the boolean function $\B^{\mathscr{U}}$ specifies the set $\{\Tr, \Fa\}$ of booleans, and $\In^{\mathscr{U}}$ specifies the set of intensions, distinct from $\B^{\mathscr{U}}$.
By abuse of language, we may call the "value of a base type" the set itself.
Each element of $\U^\mathscr{U}$ belongs to one base type.

The \emph{domain} $\bar{\bt}^\mathscr{U}$ is the cross-product of the sets associated with each type in tuple $\bar{\bt}$.

\ignore{
    A \emph{value of type} $\tau$ with signature $\bar{\bt} \rightarrow \bt$, in $\mathscr{U}$, is a total function from $\bar{\bt}^{\mathscr{U}}$ to $\bt^{\mathscr{U}}$.
}

A $\Sigma$-interpretation $\mathscr{I}$ is a tuple $\langle \mathscr{U}, \mathscr{I}_{int}, \mathscr{I}_v \rangle$, such that:
\begin{itemize}
    \item $\mathscr{U}$ is a universe of discourse for $\Sigma$;
    \item $\mathscr{I}_{int}$ is a total, surjective mapping from symbols $\upsigma$ to their intensions, noted $`\upsigma^{\mathscr{I}}$, i.e., a total surjective function from $\Sigma$ to $\In^{\mathscr{U}}$;
    \item $\mathscr{I}_v$ is a total mapping from symbols $\upsigma$ (with signature $\bar{\bt} \rightarrow \bt$) to their value, $\upsigma^{\mathscr{I}}$, where $\upsigma^{\mathscr{I}}$ is a total function from $\bar{\bt}^{\mathscr{U}}$ to $\bt^{\mathscr{U}}$;
    \item the intension (resp. value) of a base type in $\mathscr{I}$ is its intension (resp. value) in $\mathscr{U}$: $`t^{\mathscr{I}}=`t^{\mathscr{U}}$ and $t^{\mathscr{I}}=t^{\mathscr{U}}$;
    \item if any 2 symbols have identical intensions, then they have identical values.
    \todo{TODO: shuffling of arguments}
\end{itemize}

$\eval{\phi}{\mathscr{I}[x:d]}$ is an interpretation $\mathscr{I}$ where $\mathscr{I}_v$ is extended with the mapping from $x$ to $d$.

The symbol(s) mapped to intension $i$ in $\mathscr{I}$ are the \emph{denoting symbols} of $i$.
\ignore{An intension $i \in {\mathcal{I}}$ is \emph{denoted} in $\mathscr{I}$ iff it has at least one denoting symbol in $\mathscr{I}$.}
The (unique) \emph{value of the intension}, noted $\symb(i)^{\mathscr{I}}$, is the value of anyone of its denoting symbols, noted $\symb(i)$.
When an intension has only one denoting symbol, $\upsigma$, we have $\symb(`\upsigma) = \upsigma.$

\subsection{FO(Intension)}

$\bar{\Sigma}$ is the vocabulary $\Sigma$ extended with these symbols:
\begin{itemize}
    \item $`\upsigma: () \rightarrow \In$ for every symbol $\upsigma \in \Sigma$;
    \item $\m{arity}: \In \rightarrow \mathds{N}$;
    \item $\m{input}: (\In, \mathds{N}) \rightarrow \In$;
    \item $\m{output}: \In \rightarrow \In$;
    \item $\m{type}: \U \rightarrow \In$
\end{itemize}

$FO_{Int}(\Sigma)$ is the language $FO(\bar{\Sigma})$ augmented with the special function application $\$(i)(\bar{d})$, where $i$ is a formula, and $\bar{d}$ is a tuple of formulae.
More precisely, the set of formulae $FO_{Int}(\Sigma)$ is defined inductively as follows (beginning with the rules of FO):
\begin{itemize}
    \item $\m{true}$ and $\m{false}$ are formulae;
    \item a \emph{function application}, $\upsigma(\bar{d})$ is a formula if $\upsigma$ is a symbol in $\bar{\Sigma}$ and  $\bar{d}$ a tuple of formulae;
    \item $\lnot(\phi$), $(\phi) \lor (\psi)$ and $(\phi) = (\psi)$ are formulae if $\phi$ and $\psi$ are formulae;
    \item a \emph{variable} $x$ is a formula;
    \item an \emph{existentially quantified formula}, $\exists x \in t:(\phi)$ is a formula if $x$ is a variable, $t$ a base type, and $\phi$ a formula;
    \item an \emph{aggregate} $\#\{x \in t: \upsigma(x)\}$ is a formula
    \ignore{\item a symbol $`\sigma$ in $\bar{\Sigma} \setminus \Sigma$ is a formula;}
    \item $\$(i)(\bar{d})$ is a formula when $i$ is a formula, and $\bar{d}$ a tuple of formulae.
\end{itemize}
This minimal set of constructs can be extended with syntactic abbreviations such as $(\phi) \land (\psi$), $(\phi) \Rightarrow (\psi)$, and $\forall x: (\phi)$.
An $\m{if} (\phi) \m{then} (a) \m{else} (b)$ construct can also be added easily.

A \emph{free variable} $x$ is a variable that does not occur in the scope of a quantifier that declares $x$.
A formula $\phi$ is \emph{well-formed} iff it has no free variable.

We call $\delta_{\upsigma}$ the \emph{domain predicate} of symbol $\upsigma$: it associates the boolean value $\Tr$ to tuples that are in the domain of $\evali{\upsigma}$ (as specified by $ \tau(\upsigma)$ and \U), and $\Fa$ to any other tuples.

\ignore{
    Given an interpretation $\mathscr{I}$, we define the \emph{type of a well-formed formula} as:
    \begin{itemize}
        \item $\evali{\m{type}(\upsigma(\bar{d}))} = t \text{ where } \tau(\upsigma)= \bar{t} \rightarrow t$
        \item $\evali{\m{type}(\$(i)(\bar{d}))} = t \text{ where } \tau(\symb(i))= \bar{t} \rightarrow t$
        \item $\evali{\m{type}(\phi)} = `\B$ otherwise
    \end{itemize}
}

Given an interpretation $\mathscr{I}$, we define the value $\evali{\phi} (\in \U \cup \{\bot\})$ of a well-formed formula $\phi$ inductively, based on the syntactical structure of $\phi$:\footnote{$\uptau, \bar{d}, \phi, \psi, x, i$ are placeholders for sub-formula of the implied type)}

\footnotetext[1]{the rules above have precedence over this rule}
	\begingroup
	\allowdisplaybreaks
	\begin{align*}
	    \evali{true} &= \Tr\\
	    \evali{false} &= \Fa\\
	    \ignore{

        	\vals{t(\bar{d})} &=
            	\begin{cases}
            	    d \in t^{\mathscr{I}}, &\text{if } t \text{ is a type symbol } \land \bar{d} \cong (d),\\
    	            \bot, &\text{otherwise}. \\
            	\end{cases}\\
            	}

    	\vals{`\upsigma(\bar{d})} &=
        	\begin{cases}
        	    `\upsigma^{\mathscr{I}}, \text{i.e., the intension of } \upsigma \text{ in } \mathscr{I}, \text{ if } \bar{d} \cong ()\\
	            \bot, \text{otherwise}. \\
        	\end{cases}\\

    	\vals{arity(\bar{d})} &=
        	\begin{cases}
        	    \text{the arity of } \upsigma, \text{ if } \evali{\bar{d}} \cong (`\upsigma^{\mathscr{I}})
        	        \text{ and } `\upsigma^{\mathscr{I}} \in \In^{\mathscr{I}}\\
	            \bot, \text{otherwise}. \\
        	\end{cases}\\

    	\vals{input(\bar{d})} &=
        	\begin{cases}
        	    `t_j^{\mathscr{I}},
        	     &\text{ if } \evali{\bar{d}} \cong (`\upsigma^{\mathscr{I}}, j), `\upsigma^{\mathscr{I}} \in \In^{\mathscr{I}}, j \in \mathds{N} \\
        	        & \text{ and } \tau(\upsigma) \cong (t_1, ..., t_j, ..., t_n) \rightarrow t\\
	            \bot, &\text{otherwise}. \\
        	\end{cases}\\

    	\vals{output(\bar{d})} &=
        	\begin{cases}
        	    `t^{\mathscr{I}} , &\text{ if } \evali{\bar{d}} \cong (`\upsigma^{\mathscr{I}}), `\upsigma^{\mathscr{I}} \in \In^{\mathscr{I}} \\
        	        & \text{ and } \tau(\upsigma) \cong (t_1, ..., t_n) \rightarrow t\\
	            \bot, &\text{otherwise}. \\
        	\end{cases}\\

    	\vals{type(\bar{d})} &=
        	\begin{cases}
        	     `t^{\mathscr{I}} , &\text{ if } \bar{d} \cong (x) \text{ and $x$ in the scope of } \exists x \in t\\\
        	     `t^{\mathscr{I}} , &\text{ if } \bar{d} \cong (\upsigma(\bar{d})) \text{ and } \tau(\upsigma)\cong \bar{t} \rightarrow t\\
        	     `t^{\mathscr{I}} , &\text{ if } \bar{d} \cong (\$(i)(\bar{d})) \text{ and }  \tau(\symb(i))\cong \bar{t} \rightarrow t\\
	            `\B^{\mathscr{I}}, &\text{otherwise}. \\
        	\end{cases}\\

	    \evali{\upsigma(\bar{d})} &=
	        \begin{cases}
	            \text{if none of the above rules apply:}\\
	            \upsigma^{\mathscr{I}}(\evali{\bar{d}}), \text{if } \delta_\upsigma(\evali{\bar{d}}) = \Tr \\
	            \bot, \text{otherwise}. \\
	        \end{cases}\\

		\vals{\neg(\phi)} &=
    		\begin{cases}
        		\Tr, & \text{if } \vals{\phi} = \Tr;\\
        		\Fa, & \text{if } \vals{\phi} = \Fa;\\
        		\bot, &  \text{otherwise}.\\
    		\end{cases}\\

		\vals{(\phi) \lor (\psi)} &=
    		\begin{cases}
        		\Tr, & \text{if } (\vals{\phi} = \Tr \land \evali{type(\psi)}=`\B) \text{ or } (\vals{\phi} = \Fa \text{ and }\vals{\psi} = \Tr);\\
        		\Fa, & \text{if } \vals{\phi} = \Fa \text{ and } \vals{\psi} = \Fa;\\
        		\bot, & \text{otherwise.}
    		\end{cases}\\

		\vals{(\phi) = (\psi)} &=
    		\begin{cases}
        		\Tr, & \text{if } \vals{\phi} \neq \bot \text{ and } \evali{\m{type}(\phi)}=\evali{\m{type}(\psi)} \text{ and }  \vals{\phi} = \vals{\psi};\\
        		\Fa, & \text{if } \vals{\phi} \neq \bot \text{ and }\evali{\m{type}(\phi)}=\evali{\m{type}(\psi)} \text{ and } \vals{\psi} \neq \bot;\\
        		\bot, & \text{otherwise.}
    		\end{cases}\\

		\vals{\exists x \in t:\phi} &=
    		\begin{cases}
        		\Tr, &\text{if, for some } d \in t^\U, \eval{\phi}{\mathscr{I}[x:d]} = \Tr;\\
        		\Fa, &\text{if, for all } d \in t^\U, \eval{\phi}{\mathscr{I}[x:d]} = \Fa;\\
        		\bot, & \text{otherwise.}\\
    		\end{cases}\\

		\vals{\#\{x \in t: \upsigma(x)\}} &=
    		\begin{cases}
        		\text{number of $x$ in $t$ such that } \evali{\upsigma(x)} = \Tr, \text{if } \forall x \in t:
        		    \evali{\B(\upsigma(x))}=\Tr;\\
        		\bot,  \text{otherwise.}\\
    		\end{cases}\\

    	\evali{\$(i)(\bar{d})} &=
    		\begin{cases}
    		    \evali{f(\bar{d})} & \text{where f is } \symb(\evali{i}), \text{if } \tcc{i} \text{ and }  \evali{i} \in \In\\
    		    \bot,  & \text{otherwise.}
    		\end{cases}\\

    	\ignore{
        	\evali{\delta(i)(\bar{d})} &=
        		\begin{cases}
        		    \delta_{\sigma}(\evali{\bar{d}}) & \text{where } \sigma = \symb(\evali{i}), \text{if }  \evali{i} \in \In \\
        		    \bot,  & \text{otherwise.}
        		\end{cases}
    	}
	\end{align*}
	\endgroup
\todo{definitions ?}

Notice that:
\begin{itemize}
    \item a disjunction is asymetric: to be defined, its first operand must be defined; this reduces the computational complexity of checking definedness;
    \item $\evali{\$(\m{type}(\phi))(\phi)} = \Tr$, i.e., $\phi$ is a member of the value of the type of $\phi$;
    \item $\evali{\$(`\sigma)(\bar{d})} = \evali{\sigma(\bar{d})}$
\end{itemize}
\ignore{, and $\evali{\delta(`\sigma)(\bar{d})}$ is $\delta_\sigma(\evali{\bar{d}})$}

\subsection{Definedness}

We say that a formula $\phi$ is \emph{well-defined} iff $\evali{\phi}$ is defined (i.e., $\evali{\phi} \neq \bot$) for any $\mathscr{I}$.
We follow mathematical tradition by requiring sentences to be well-defined formula.

Following the approach presented in \cite{DBLP:journals/entcs/BerezinBSCGD05}, we define the \emph{well-defined condition} of a formula $\phi$, noted $\tcc{\phi}$, as follows:

\begin{equation*}
     \begin{split}
        \tcc{true} &\equiv true\\
        \tcc{false} &\equiv true\\
        \tcc{`\sigma(\bar{d})} &\equiv \bar{d} = () \\
        \tcc{\m{arity}(\bar{d})} &\equiv \bar{d} \cong (i) \land \In(i)\\
        \tcc{\m{input}(\bar{d})} &\equiv \bar{d} \cong (i, n) \land \In(i) \land \mathds{N}(n) \land 1 < n < \text{arity}(i)\\
        \tcc{\m{output}(\bar{d})} &\equiv \bar{d} \cong (i) \land \In(i)\\
        \tcc{\sigma(\bar{d})} &\equiv
            \ignore{\tcc{d_1} \land ... \land \tcc{d_n} \land} \delta_{\sigma}(\bar{d}) \\
        \tcc{\lnot(\phi)} &\equiv  \B(\phi) \\
        \tcc{(\phi) \lor (\psi)} &\equiv \B(\phi) \land (\m{type}(\phi)=`\B) \land (\phi \lor \B(\psi)) \\
        \tcc{(\phi) = (\psi)} &\equiv \tcc{\phi} \land \tcc{\psi} \land (\m{type}(\phi)=\m{type}(\psi))\\
        \tcc{\exists x \in t : \phi} &\equiv
            (\exists x \in t : \B(\phi) \land \phi) \lor (\forall x \in t : \B(\phi)) \\
        \tcc{\#\{x \in t: \upsigma(x)\}} &\equiv \forall x \in t: \B(\upsigma(x)) \\
        \tcc{\$(i)(\bar{d})} &\equiv
            \In(i) \land \tcc{(\symb(i)) (\bar{d})}  \\
        \ignore{
            \tcc{\delta(i)(\bar{d})} &\equiv
                \In(i) \land \tcc{(\symb(i)) (\bar{d})} \\
            }
     \end{split}
\end{equation*}

\ignore{
    The \emph{co-domain condition for $\Sigma$}, $\m{range}(\Sigma)$, states that the output-domain of every symbol is specified by its signature $\bar{t}_\upsigma \rightarrow t_\upsigma$: $\forall \upsigma \in \Sigma: \forall \bar{x} \in \bar{t}_\upsigma: \upsigma(\bar{x}) \in t_\upsigma$.
}

\paragraph{Theorem} $\phi$ is well-defined iff $\evali{\tcc{\phi}} = \Tr$ for any $\mathscr{I}$.

\paragraph{Proof}
Each rule of the well-defined condition is constructed by \emph{abstracting} (\cite{DBLP:conf/plilp/CousotC92}) the corresponding rule in the evaluation of a formula in $\mathscr{I}$: the abstract value is \Fa if the concrete value is $\bot$, \Tr otherwise.
Therefore, $\evali{\tcc{\phi}}$ is true whenever $\phi$ is defined.
The condition in the theorem expresses the requirement that $\phi$ be defined in every interpretation.

\paragraph{Example}
Consider $\Sigma = \{\U: \U \rightarrow \B, \B: \U \rightarrow \B, \In: \U \rightarrow \B, f: \In \rightarrow \In \}$.
$\bar{\Sigma}$ is $\Sigma \cup \{`\U, `\B, `\In, `f\}$
\ignore{
    The co-domain condition is
    \begin{equation*}
        \begin{split}
            &(\forall o \in \U: \U(o) \in \B)  \\
            \land &(\forall o \in \U: \B(o) \in \B)  \\
            \land &(\forall o \in \U: \In(o) \in \B)  \\
            \land &(\forall o \in \In: f(o) \in \In)  \\
            \land &(`\U() \in \In) \land (`\B() \in \In) \\
            \land &(`{\mathcal{I}}() \in \In) \land (`f() \in \In)
        \end{split}
    \end{equation*}
}

For $\phi \equiv (\exists x \in \In: \$(x)(x)=x)$, the well-defined condition $\tcc{\phi}$ is
\[
    (\exists x \in \In: \tcc{\$(x)(x)=x} \land \$(x)(x)=x) \lor (\forall x \in \In: \tcc{\$(x)(x)=x})
\]
One can show that $\evali{\tcc{\phi}}$ is \Fa, e.g., by considering $x=`\mathds{U}()$.
However, by adding an appropriate ``guard'', $\phi$ can be made well-defined:
\[
   \phi' \equiv \exists x \in \In: arity(x)=1 \land input(x,1)=output(x) \land \$(x)(x)=x
\]

By grounding, $\phi'$ reduces to $f(`f())=`f()$ whose well-defined condition $\In(`f())$ is \Tr in every $\mathscr{I}$.
Indeed, $\phi'$ is well-formed: it has a value in every interpretation.

\section{Use cases/examples}

\maurice{Why not enumerate the elements of type symbol? I understand, every function is a symbol. On the other hand, there is no need to dereference every function, so making explicit which ones will be used as concepts in the application adds clarity to the application code?}

Earlier, we show the ``Symptoms  Triage'' example, which demonstrates the power of intensional objects in one single statement. Now we will show a few more complex examples.

\subsection{Set game}
Our first example is a simplified\footnote{This game is played in multiple rounds where players consecutively make their moves. Since the dynamics of the game do not have an impact on what we want to demonstrate, we will keep it simple and limit our example to the one move of one player.} version of the Set game, which is described in ~\cite{davis2003card}.
Twelve cards are dealt from a deck of 81 different cards.
Each card has four distinct features: a shape (diamond, squiggle, oval), a number (one, two, or three), a fill (solid, striped, or open), and a color (red, green, or purple).
The player has a goal to find a \textit{magic set} from these 12 dealt cards.
\textit{Magic set} consist of exactly three cards, where for each feature, these three cards either have the same value, or all different values. We propose the following vocabulary for modelling of this problem:

\begin{lstlisting}[language=idptest]
vocabulary {
    type Card := { 1..12 } //The set of cards

    //Possible values of the features
    type Color := {red, green, purple}
    type Number := {one, two, three}
    type Fill := {solid, striped, open}
    type Shape := {diamond, squiggle, oval}

    //Differentiating symbols
    feature : (Symbol) -> Bool

    //Value of the feature for each card
    colorOf : (Card) -> Color
    numberOf : (Card) -> Number
    fillOf : (Card) -> Fill
    shapeOf : (Card) -> Shape

    sel : (Card) -> Bool//Selected cards
}
\end{lstlisting}

The input of the problem is a partial structure that interprets $colorOf$, $numberOf$, $fillOf$, and $shapeOf$ functions. The desired output is a full expansion of that structure that satisfies the goal of the game, giving the interpretation of $selected$, $feature$ and $same$.

It is clear that our statement of the goal of the game in natural language ranges over the features.
In FO, we cannot quantify a statement over the set of features.
To express that for each feature, the 3 selected cards must have either the same value, or all different values, we have to write a separate sentence for each feature.
With the intensional extension of FO however, we can quantify over vocabulary symbols and write these constraints as one statement. Here is the theory that expresses the game with such an extension:

\begin{lstlisting}[language=idptest]
theory {
    //The set of features
    feature := {`colorOf, `fillOf, `numberOf, `shapeOf}

    //All cards are different
    ! x , y in Card: x~=y => (? s in Symbol: feature(s) & $(s)(x) ~= $(s)(y)).

    //Selected cards constraint
    ! s in Symbol : feature(s) => (
        (! x in sel, y in sel: x ~= y =>
            $(s)(x) = $(s)(y)) |
        (! x in sel, y in sel: x ~= y =>
            $(s)(x) ~= $(s)(y))
    ).

    //Three cards are selected
    #{ x: selected(x) } = 3.
}
\end{lstlisting}

\subsection{Dangerous temperatures}

\pierre{I wish this example was more realistic.}

Assume we want to model a controller for a dynamic system of electrical devices in one house. There are many different properties of devices, and their value can be dependant on other devices. The house controller receives the values of the properties of all devices in intervals. The controller should ensure that the house is safe at any time point.

Among many different properties, let us focus on the temperature and up-time of the devices. Knowing the dangerous temperatures and up-time of each device, we would certainly like to have a property that no device exceeds the critical point at any moment.

For example, the laptop temperature should always be less than 100 degrees Celsius, while for an oven it should not exceed 400. Additionally, no device should work for more than 10 time units (time is abstract in our example) except for the light bulb which can work infinitely.

Important for this example is that parameters have different ordered codomains. So even if we abstract over parameters the problem remains, we need separate statements per property. But using intensions we can define functions that map symbols to symbols which is sufficient to overcome this problem.

We use the following simplified vocabulary to express this example:

\begin{lstlisting}[language=idptest]
vocabulary V {
    type Time := {1..100}
    type Temp := Int
    type Device := {laptop, oven, lightbulb}

    //Properties
    temp : (Time ** Device) -> Temp
    upTime : (Time ** Device) -> Time

    //Maximum of property per device
    maxTemp : (Device) -> Temp
    maxUpTime : (Device) -> Time

    //Properties to their maximums
    limits : (Symbol) -> Symbol

    //Set of properties
    property : (Symbol) -> Bool
}
\end{lstlisting}

We will omit the specification of a dynamic system as it is not in the primary scope of this paper.

The following formalization represents the described example:
\begin{lstlisting}[language=idptest]
theory T : V {
    //Action theory
    ...

    //Maximum temperatures and up-time
    maxTemp := {laptop -> 100, oven -> 350, lightbulb -> 150}
    maxUpTime := {lightbulb -> 100} else 10

    //Enumerations of prop and limits
    prop := {`temp, `upTime}
    limits := {`temp -> `maxTemp,`upTime -> `maxUpTime}

    //No device at any time point exceeds critical value for any parameter
    ! s in Symbol : prop(s) => (! t in Time : ! d in Device : $(s)(t,d) =< $(limits(s))(d)).
}
\end{lstlisting}

It is important to note how we abstract over functions with different codomain using another function that maps symbols to symbols.

\marc{I find this inherently a good example, but it took me too long to understand the point. Thee is a a set of attributes, each value ranging over some ordered cdomain, and each attribute having some minimal and maximal safe value. Can we express this property in one statement? Notice that I would also abstract over the order of the ordered domain of an attribute. }

\pierre{
A possible application in the legal field is in reasoning about degrees of relationship for calculation of the[inheritancetax](https://www.kbcbrussels.be/retail/en/family/inheritance-tax.html).
The IDP theory would define what is a parent, child, grand-parent, spouse, aunt and uncles, ... : these are relationships.
Now, some relationships are 1st order, 2nd order, ...  The order determines, among other things, the inheritance tax rate.
To find the heir and their tax rate, you would quantify over relationship types.
}

\marc{Yes, that is a nice example. Why dont you give it a try, Pierre? E.g., tax on inheritance for family of the 2nd level is double that of family of the first level.}

\section{Related Work}

The term \textit{intensional objects} is associated with intensional logic \cite{sep-logic-intensional}. An overview of the first-order intensional logic is available in the paper~\cite{fitting2004first}. Our approach mostly diverges from intensional logic in the sense of focusing on what objects are designating. Thus, concepts such as ``synonymy'' are not present in our logic. \marc{So, our approach is characterised by being a subset of Fittings? There must also be something we can do that he cant. And if not, then this paper should not be written.  Do you have a clear understanding of this?  I dont yet. Mayb it is my responsibility to find out. If somebody knows, please write a note on this here. What can we do that is not possible in Fitting's logic, and vice versa?  }

The motivation that drives us into the direction of intensional objects has a strong connection with concepts as higher-order logics, macros, or templates.

While higher-order semantics is different from intensional semantics, some logics combine their distinct features. For instance, HiLog~\cite{chen1993hilog} is a logic with higher-order syntax, while its model theory is first-order. Variables in HiLog range over a set of intensions, so it has intensional semantics. This idea has a strong relationship with ours. Treatment of HiLog predicate and function symbols depends on their place in a formula: when applied to arguments, they evaluate through their extension; when not applied, they are terms (intensions). HiLog syntax fits nicely in the context of logic programming. It is implemented in Flora-2~\cite{yang2005flora} and partially in XSB~\cite{swift2012xsb} systems.

By contrast, our syntax allows the knowledge expert to explicitly distinguish references to the value and to the concept itself.  \pierre{ remove ? On the other hand, extending FO($\cdot$) language with higher-order syntax would naturally lead to higher-order semantics. Thus, we have to discriminate between these two syntaxes. }
\section{Formal semantics}

\pierre{This section is kept for historical reason}

\maurice{I am missing the semantics of arity, argdom and val. Maybe, you should show the structure for your "running" example so that the reader has a better feeling of how this deviates from a standard structure? This is supposed to be the core of the paper(?) It looks a bit tiny}

A structure \struct{} over a vocabulary \voc{} consists of:
\begin{itemize}
\item a non-empty domain $D$, and an assignment of a disjoint set of domain elements for every type \type. Specifically, the type associated with $\mathbb{B}$ must be the set $\{True, False\}$, and the set \SymbolType{} must contain exactly one element for every function symbol in \voc{} except \arity{}, \argdom{} and \val{}.
\mvdh{If we keep functions and predicates separated, we should add an additional rule}
\item an assignment of an $n$-ary function over the domain for every function symbol $f \in \voc{}$,
\item an assignment of a domain element $d$ to every variable symbol $x$, and
\item an assignment of an element $f_{d}$ from the set assigned to \SymbolType{} for every function symbol $f$
\end{itemize}

We restrict structures based on the information in the type system: the function over $D$ assigned to every function $f$, and the domain element assigned to every variable $x$ must respect their respective types.

The assignment by \struct{} of functions over the domain $D$ to functions $f$ in \voc{} is called the \emph{valuation} function of \voc{}.
The value assigned to $f$ by this valuation function is written as $f^{\struct{}}$.

\marc{There is no notion of a model Yet? }
\section{Formal syntax}

\pierre{This section is kept for historical reason}

\pierre{
    A {\em definition} of a function $\sigma$ is a set of rules of the form $\forall \overline{x}: \forall y: \sigma(\overline{x})=y \leftarrow \phi(\overline{x},y).$, where $\overline{x}$ denotes a tuple of variables and $y$ a variable.
    Definitions that have several rules can be reduced to definitions with one rule by 1) renaming the head variables to a unique tuple $\overline{x}$ and $y$ and 2) joining the bodies of the rules by a disjunction.

    In the most general case, definitions may be recursive, containing rules that define a function in terms of the itself. The interpretation of a definition is then given by an iterative construction process of a lower- and upper-bound value for each element of the domain of $\sigma$ that reaches a fixed point corresponding to the value of the function for that element of the domain.
    In most legal applications however, definitions are not (co-)recursive: the dependency graph between function symbols implied by the definitions has no loop.
    In that case, and when a definition has only one rule, it simply states an equivalence between the head and the body of the (unique) rule.
    This interpretation of rules was implicit already in Clark's work on completion semantics
    For the sake of brevity, we'll limit our presentation to this simpler case.
}

Before we introduce the syntax of \langu{}, we sketch a simple type system, consisting of a set $\Delta$ of base types $\delta$ and their composite types, i.e. any type $(\delta_{1} \times \ldots \times \delta_{n}) \rightarrow \delta$.

Within the set of base types, we identify the types \SymbolType{} and \Bool{}.
The type \Bool{} is reserved for the well-known type of boolean values, while the type \SymbolType{} serves as the type of intensional objects.

A vocabulary $\voc$ consists of an infinite supply of typed variable symbols, and a finite set of typed symbols $f/n$, where $n \geq 0$ and $n$ is known as the \emph{arity} of the symbol.
Without loss of generality, we can refer to a symbol $f/n \in V$ as simply $f$, specifically when the arity is irrelevant or clear from context.
\marc{Variable symbols are often considered as logical symbols; the role of the vocabulary is mostly to be the set of concepts that we enrich logic with, to have a language to talk about the application domain.}

We note that symbols of the type $(\delta_{1} \times \ldots \times \delta_{n}) \rightarrow \Bool{}$ are commonly referred to as \emph{predicates}.
We will refer to variable symbols of the \SymbolType{} type as \emph{intensional} variables.\marc{What is the symbol type? \SymbolType{}? Then say so.}

In every vocabulary \voc{}, we also include the built-in function symbols $\arity/1$ and $\argdom/2$, and the built-in higher-order function $\val/1$.
These functions allow access to information about intensional objects, such as the arity or the range of definition for each of their arguments.
The function $\val/1$ will define the connection between intensional objects and their extensional value. \marc{This is verbose, redundant. Try to be direct and precise: ``The function $\val/1$ will define ... '' $\rightarrow$  give directly its specification.}

A term $t$ is either:
\begin{itemize}
\item a variable $x \in \voc$.
\item a symbol $f/n \in \voc$ applied to $n$ terms $t_1 \ldots t_n$, written as $f(t_1, \ldots, t_n)$.
\item the intension of a non built-in  symbol $S \in \voc$, written as $\deref{S}$, or \marc{Mathemtical language gets very unprecise here. I dont think any reader would understand what we mean here. It is absolutely necessary to specify that in logical sentences, we need to refer to the intension of a symbol at some occasions and to the extension at other occations, and that a language mechanism is necessary to make clear to what we want to refer. probably we should already have introduced an example showing the distinction. }

\item an application of the built-in higher-order function $\val/1$ to a term $t$, subsequently applied to a number of terms $t_1,\ldots,t_n$, written as $\val(t)(t_1,\ldots,t_n)$
\end{itemize}

\todo{use compactitem from paralist package?}

Writing \deref{S} instead of $S$, we are referring to the symbol $S$'s intension, an object of type \SymbolType{}, rather than its extension.
We refer to this as \emph{dereferencing} $S$.
Note that we exclude the \emph{built-in} functions $\arity$, $\argdom$ and $\val$ from being dereferenced. \marc{I think it is me who introduced the term dereferencing. Did you check dictionaries? It is probably wrong term. What we want to say is: in a sentenced we want to talk about the intensional value of a symbol or of the extensional value. So, a symbol refers to one or another, and we must be able to know which one it is. So I think ``referencing'' is a more correct term. }

A formula $\phi$ over a vocabulary \voc{} is defined inductively as
\begin{compactitem}
\item a term $t$,
\item $\lnot \phi$, $\phi \land \psi$, $\phi \lor \psi$, $\phi \Rightarrow \psi$ and $\phi \Leftrightarrow \psi$ where $\phi$ and $\psi$ are formulas,
\item $\forall x \in \type{} : \phi$ and $\exists x \in \type{} : \phi$ where $\phi$ is a formula and $x$ is a variable of \voc{}.
\item A definition, consisting of a set of rules of the form $\forall \overline{x} : \forall y \leftarrow \phi.$
\end{compactitem}
\mvdh{What about binary quants? Where does T come from? Unary predicate over Bool or a specific type.}

\maurice{I find it a bit weird to read that a term is a formula and then having to imagine what the negation, $\land$, $\lor$, ... of terms is(unless you mean a term of type boolean) Show your running example in this syntax.}