2021-04-30 09:16:01 -04:00
|
|
|
|
|
|
|
\section{Classification System}\seclabel{class}
|
|
|
|
\index{classification}
|
2021-05-18 12:16:11 -04:00
|
|
|
A \dfn{classification} is a user-defined abstraction that describes
|
2021-04-30 09:16:01 -04:00
|
|
|
(``classifies'') arbitrary data.
|
|
|
|
Classifications can be used as predicates, generating functions, and can be
|
|
|
|
composed into more complex classifications.
|
|
|
|
Nearly all conditions in \tame{} are specified using classifications.
|
|
|
|
|
|
|
|
\index{first-order logic!sentence}
|
|
|
|
\index{classification!coupling}
|
2021-05-18 12:16:11 -04:00
|
|
|
All classifications represent \dfn{first-order sentences}---%
|
2021-04-30 09:16:01 -04:00
|
|
|
that is,
|
2021-05-18 12:16:11 -04:00
|
|
|
they contain no \dfn{free variables}.
|
2021-04-30 09:16:01 -04:00
|
|
|
Intuitively,
|
|
|
|
this means that all variables within a~classification are
|
2021-05-18 12:16:11 -04:00
|
|
|
\dfn{tightly coupled} to the classification itself.
|
2021-04-30 09:16:01 -04:00
|
|
|
This limitation is mitigated through use of the template system.
|
|
|
|
|
2021-05-18 10:06:32 -04:00
|
|
|
\begin{axiom}[Classification Introduction]\axmlabel{class-intro}
|
2021-05-14 12:05:17 -04:00
|
|
|
\todo{Symbol in place of $=$ here ($\equiv$ not appropriate).}
|
|
|
|
\begin{alignat}{3}
|
|
|
|
&\xml{<classify as="$c$" }&&\xml{yields="$\gamma$" desc}&&\xml{="$\_$"
|
|
|
|
$\alpha$>}\label{eq:xml-classify} \\
|
2021-05-18 16:11:25 -04:00
|
|
|
&\quad \MFam{M^0}jJkK &&\VFam{v^0}jJ &&\quad s^0 \nonumber\\[-4mm]
|
2021-05-14 12:05:17 -04:00
|
|
|
&\quad \quad\vdots &&\quad\vdots &&\quad \vdots \nonumber\\
|
2021-05-18 16:11:25 -04:00
|
|
|
&\quad \MFam{M^l}jJkK &&\VFam{v^m}jJ &&\quad s^n \nonumber\\[-3mm]
|
2021-05-14 12:05:17 -04:00
|
|
|
&\xml{</classify>}
|
|
|
|
% NB: This -50mu needs adjustment if you change the alignment above!
|
|
|
|
&&\mspace{-50mu}= \Classify^c_\gamma\left(\odot,M,v,s\right), \nonumber
|
|
|
|
\end{alignat}
|
|
|
|
|
|
|
|
\noindent
|
|
|
|
where
|
|
|
|
|
|
|
|
\begin{align}
|
2021-05-18 10:06:32 -04:00
|
|
|
J &\subset\Int \neq\emptyset, \\
|
|
|
|
\forall{j\in J}\Big(K_j &\subset\Int \neq\emptyset\Big), \\
|
|
|
|
\forall{k}\Big(M^k &: J \rightarrow K_{j\in J} \rightarrow \Real\Big),
|
2021-05-14 12:05:17 -04:00
|
|
|
\label{eq:class-matrix} \\
|
|
|
|
\forall{k}\Big(v^k &: J \rightarrow \Real\Big), \\
|
|
|
|
\forall{k}\Big(s^k &\in\Real\Big), \\
|
|
|
|
\alpha &\in\Set{\epsilon,\, \texttt{any="true"}}, \label{eq:xml-any-domain}
|
|
|
|
\end{align}
|
|
|
|
|
|
|
|
\noindent
|
|
|
|
and the monoid~$\odot$ is defined as
|
|
|
|
|
|
|
|
\begin{equation}\label{eq:classify-rel}
|
|
|
|
\odot = \begin{cases}
|
|
|
|
\Monoid\Bool\land\true &\alpha = \epsilon,\\
|
|
|
|
\Monoid\Bool\lor\false &\alpha = \texttt{any="true"}.
|
|
|
|
\end{cases}
|
|
|
|
\end{equation}
|
2021-05-18 10:06:32 -04:00
|
|
|
\end{axiom}
|
2021-05-14 12:05:17 -04:00
|
|
|
|
|
|
|
|
2021-05-18 10:06:32 -04:00
|
|
|
% This TODO was the initial motivation for this paper!
|
|
|
|
\todo{Emphasize index sets, both relationships and nonempty.}
|
2021-05-14 12:05:17 -04:00
|
|
|
We use a $4$-tuple $\Classify\left(\odot,M,v,s\right)$ to represent a
|
|
|
|
$\odot_1$-classification
|
|
|
|
(a classification with the binary operation $\land$ or~$\lor$)
|
|
|
|
consisting of a combination of matrix~($M$), vector~($v$), and
|
|
|
|
scalar~($s$) matches,
|
|
|
|
rendered above in columns.\footnote{%
|
|
|
|
The symbol~$\odot$ was chosen since the binary operation for a monoid
|
|
|
|
is~$\bullet$
|
|
|
|
(see \secref{monoids})
|
|
|
|
and~$\odot$ looks vaguely like~$(\bullet)$,
|
|
|
|
representing a portion of the monoid triple.}
|
|
|
|
A $\land$-classification is pronounced ``conjunctive classification'',
|
|
|
|
and $\lor$ ``disjunctive''.\footnote{%
|
2021-05-11 16:37:08 -04:00
|
|
|
Conjunctive and disjunctive classifications used to be referred to,
|
|
|
|
respectively,
|
2021-05-18 12:16:11 -04:00
|
|
|
as \dfn{universal} and \dfn{existential},
|
2021-05-11 16:37:08 -04:00
|
|
|
referring to fact that
|
2021-05-13 15:50:13 -04:00
|
|
|
$\forall\Set{a_0,\ldots,a_n}(a) \equiv a_0\land\ldots\land a_n$,
|
2021-05-11 16:37:08 -04:00
|
|
|
and similarly for $\exists$.
|
|
|
|
This terminology has changed since all classifications are in fact
|
|
|
|
existential over their matches' index sets,
|
2021-05-14 12:05:17 -04:00
|
|
|
and so the terminology would otherwise lead to confusion.}
|
|
|
|
|
|
|
|
The variables~$c$ and~$\gamma$ are required in~\tame{} but are both optional
|
|
|
|
in our notation~$\Classify^c_\gamma$,
|
|
|
|
and can be used to identify the two different data representations of
|
|
|
|
the classification.\footnote{%
|
|
|
|
\xpath{classify/@yields} is optional in the grammar of \tame{},
|
|
|
|
but the compiler will generate one for us if one is not provided.
|
|
|
|
As such,
|
|
|
|
we will for simplicity consider it to be required here.}
|
|
|
|
|
|
|
|
$\alpha$~serves as a placeholder for an optional \xml{any="true"},
|
|
|
|
with $\emptystr$~representing the empty string in~\eqref{eq:xml-any-domain}.
|
|
|
|
Note the wildcard variable matching \xmlattr{desc}---%
|
|
|
|
its purpose is only to provide documentation.
|
|
|
|
|
2021-05-18 12:13:32 -04:00
|
|
|
\begin{corollary}[$\odot$ Commutative Monoid]\corlabel{odot-monoid}
|
|
|
|
$\odot$ is a commutative monoid in \axmref{class-intro}.
|
2021-05-18 10:06:32 -04:00
|
|
|
\end{corollary}
|
|
|
|
\begin{proof}
|
|
|
|
By \axmref{class-intro},
|
|
|
|
$\odot$ must be a monoid.
|
|
|
|
Assume $\alpha=\epsilon$.
|
|
|
|
Then,
|
|
|
|
$\odot = \Monoid\Bool\land\true$,
|
|
|
|
which is proved by \lemref{monoid-land}.
|
|
|
|
Next, assume $\alpha=\texttt{any="true"}$.
|
|
|
|
Then,
|
|
|
|
$\odot = \Monoid\Bool\lor\false$,
|
|
|
|
which is proved by \lemref{monoid-land}.
|
|
|
|
\end{proof}
|
|
|
|
|
2021-05-18 12:13:32 -04:00
|
|
|
\index{classification!commutativity}
|
|
|
|
\index{compiler!classification commutativity}
|
|
|
|
While \axmref{class-intro} seems to imply an ordering to matches,
|
|
|
|
users of the language are free to specify matches in any order
|
|
|
|
and the compiler will rearrange matches as it sees fit.
|
|
|
|
This is due to the commutativity of~$\odot$ as proved by
|
|
|
|
\corref{odot-monoid},
|
|
|
|
and not only affords great ease of use to users of~\tame{},
|
|
|
|
but also great flexibility to compiler writers.
|
2021-05-18 10:06:32 -04:00
|
|
|
|
2021-05-18 14:09:27 -04:00
|
|
|
For notational convenience,
|
|
|
|
we will let
|
|
|
|
|
|
|
|
\begin{align}
|
|
|
|
\odot^\land &= \Monoid\Bool\land\true, \\
|
|
|
|
\odot^\lor &= \Monoid\Bool\lor\false.
|
|
|
|
\end{align}
|
|
|
|
|
2021-05-18 10:06:32 -04:00
|
|
|
|
|
|
|
\def\cpredmatseq{{M^0_j}_k \bullet\cdots\bullet {M^l_j}_k}
|
|
|
|
\def\cpredvecseq{v^0_j\bullet\cdots\bullet v^m_j}
|
|
|
|
\def\cpredscalarseq{s^0\bullet\cdots\bullet s^n}
|
2021-05-14 12:05:17 -04:00
|
|
|
|
2021-05-18 10:06:32 -04:00
|
|
|
|
|
|
|
\begin{axiom}[Classification-Predicate Equivalence]\axmlabel{class-pred}
|
2021-05-14 12:05:17 -04:00
|
|
|
Let $\Classify^c_\gamma\left(\Monoid\Bool\bullet e,M,v,s\right)$ be a
|
2021-05-18 10:06:32 -04:00
|
|
|
classification by~\axmref{class-intro}.
|
2021-05-14 12:05:17 -04:00
|
|
|
We then have the first-order sentence
|
|
|
|
\begin{equation*}
|
|
|
|
c \equiv
|
2021-05-18 10:06:32 -04:00
|
|
|
{} \Exists{j\in J}{\Exists{k\in K_j}\cpredmatseq\bullet\cpredvecseq}
|
|
|
|
\bullet\cpredscalarseq.
|
2021-05-14 12:05:17 -04:00
|
|
|
\end{equation*}
|
2021-05-18 10:06:32 -04:00
|
|
|
\end{axiom}
|
|
|
|
|
|
|
|
|
|
|
|
\begin{axiom}[Classification Yield]\axmlabel{class-yield}
|
|
|
|
Let $\Classify^c_\gamma\left(\Monoid\Bool\bullet e,M,v,s\right)$ be a
|
|
|
|
classification by~\axmref{class-intro}.
|
|
|
|
Then,
|
2021-05-18 14:15:52 -04:00
|
|
|
|
2021-05-18 10:06:32 -04:00
|
|
|
\begin{align}
|
|
|
|
r &= \begin{cases}
|
|
|
|
2 &M\neq\emptyset, \\
|
|
|
|
1 &M=\emptyset \land v\neq\emptyset, \\
|
|
|
|
0 &M\union v = \emptyset,
|
|
|
|
\end{cases} \\
|
|
|
|
\exists{j\in J}\Big(\exists{k\in K_j}\Big(
|
|
|
|
\Gamma^2_{j_k} &= \cpredmatseq\bullet\cpredvecseq\bullet\cpredscalarseq
|
|
|
|
\Big)\Big), \\
|
|
|
|
%
|
|
|
|
\exists{j\in J}\Big(
|
|
|
|
\Gamma^1_j &= \cpredvecseq\bullet\cpredscalarseq
|
|
|
|
\Big), \\
|
|
|
|
%
|
|
|
|
\Gamma^0 &= \cpredscalarseq. \\
|
|
|
|
%
|
|
|
|
\gamma &= \Gamma^r.
|
|
|
|
\end{align}
|
|
|
|
\end{axiom}
|
|
|
|
|
|
|
|
\begin{theorem}[Classification Composition]\thmlabel{class-compose}
|
|
|
|
Classifications may be composed to create more complex classifications
|
|
|
|
using the classification yield~$\gamma$ as in~\axmref{class-yield}.
|
|
|
|
This interpretation is equivalent to \axmref{class-pred} by
|
|
|
|
\begin{equation}
|
|
|
|
c \equiv \Exists{j\in J}{
|
|
|
|
\Exists{k\in K_j}{\Gamma^2_{j_k}}
|
|
|
|
\bullet \Gamma^1_j
|
|
|
|
}
|
|
|
|
\bullet \Gamma^0.
|
|
|
|
\end{equation}
|
|
|
|
\end{theorem}
|
|
|
|
|
|
|
|
\def\eejJ{\equiv \exists{j\in J}\Big(}
|
|
|
|
|
|
|
|
\begin{proof}
|
|
|
|
Expanding each~$\Gamma$ in \axmref{class-yield},
|
|
|
|
we have
|
|
|
|
|
|
|
|
\begin{alignat*}{3}
|
|
|
|
c &\eejJ\Exists{k\in K_j}{\Gamma^2_{j_k}}
|
|
|
|
\bullet \Gamma^1_j
|
|
|
|
\Big)
|
|
|
|
\bullet \Gamma^0
|
|
|
|
&&\text{by \axmref{class-yield}} \\
|
|
|
|
%
|
|
|
|
&\eejJ\exists{k\in K_j}\Big(
|
|
|
|
\cpredmatseq \bullet \cpredvecseq \bullet \cpredscalarseq
|
|
|
|
\Big) \\
|
|
|
|
&\hphantom{\eejJ}\;\cpredvecseq \bullet \cpredscalarseq \Big)
|
|
|
|
\bullet \cpredscalarseq, \\
|
|
|
|
%
|
|
|
|
&\eejJ\exists{k\in K_j}\Big(\cpredmatseq\Big)
|
|
|
|
\bullet \cpredvecseq \bullet \cpredscalarseq \\
|
|
|
|
&\hphantom{\eejJ}\;\cpredvecseq \bullet \cpredscalarseq \Big)
|
|
|
|
\bullet \cpredscalarseq,
|
|
|
|
&&\text{by \dfnref{quant-conn}} \\
|
|
|
|
%
|
|
|
|
&\eejJ\exists{k\in K_j}\Big(\cpredmatseq\Big)
|
|
|
|
&&\text{by \dfnref{prop-taut}} \\
|
|
|
|
&\hphantom{\eejJ}\;\cpredvecseq \bullet \cpredscalarseq \Big)
|
|
|
|
\bullet \cpredscalarseq, \\
|
|
|
|
%
|
|
|
|
&\eejJ\exists{k\in K_j}\Big(\cpredmatseq\Big)
|
|
|
|
&&\text{by \dfnref{quant-conn}} \\
|
|
|
|
&\hphantom{\eejJ}\;\cpredvecseq\Big) \bullet \cpredscalarseq
|
|
|
|
\bullet \cpredscalarseq, \\
|
|
|
|
%
|
|
|
|
&\eejJ\exists{k\in K_j}\Big(\cpredmatseq\Big)
|
|
|
|
&&\text{by \dfnref{prop-taut}} \\
|
|
|
|
&\hphantom{\eejJ}\;\cpredvecseq\Big)
|
|
|
|
\bullet \cpredscalarseq.
|
|
|
|
\tag*{\qedhere} \\
|
|
|
|
\end{alignat*}
|
|
|
|
\end{proof}
|
|
|
|
|
|
|
|
|
|
|
|
\begin{lemma}[Classification Predicate Vacuity]\lemlabel{class-pred-vacu}
|
|
|
|
Let $\Classify^c_\gamma\left(\Monoid\Bool\bullet e,\emptyset,\emptyset,\emptyset\right)$
|
|
|
|
be a classification by~\axmref{class-intro}.
|
|
|
|
$\odot$ is a monoid by \corref{odot-monoid}.
|
|
|
|
Then $c \equiv \gamma \equiv e$.
|
|
|
|
\end{lemma}
|
|
|
|
\begin{proof}
|
|
|
|
First consider $c$.
|
|
|
|
\begin{alignat}{3}
|
|
|
|
c &\equiv \Exists{j\in J}{\Exists{k}{e}\bullet e} \bullet e
|
|
|
|
\qquad&&\text{by \dfnref{monoid-seq}} \label{p:cri-c} \\
|
|
|
|
&\equiv \Exists{j\in J}{e \bullet e} \bullet e
|
|
|
|
&&\text{by \dfnref{quant-elim}} \\
|
|
|
|
&\equiv \Exists{j\in J}{e} \bullet e
|
|
|
|
&&\text{by \ref{eq:monoid-identity}} \\
|
|
|
|
&\equiv e \bullet e
|
|
|
|
&&\text{by \dfnref{quant-elim}} \\
|
|
|
|
&\equiv e.
|
|
|
|
&&\text{by \ref{eq:monoid-identity}}
|
|
|
|
\end{alignat}
|
|
|
|
|
|
|
|
For $\gamma$,
|
|
|
|
we have $r=0$ by \axmref{class-yield},
|
|
|
|
and so by similar steps as~$c$,
|
|
|
|
$\gamma=\Gamma^r=e$.
|
|
|
|
Therefore $c\equiv e$.
|
|
|
|
\end{proof}
|
|
|
|
|
|
|
|
|
2021-05-18 14:09:27 -04:00
|
|
|
\begin{figure}[h]\label{fig:always-never}
|
|
|
|
\begin{alignat*}{3}
|
|
|
|
\begin{aligned}
|
|
|
|
\xml{<classify }&\xml{as="always" yields="alwaysTrue"} \xmlnl
|
|
|
|
&\xml{desc="Always true" />}
|
|
|
|
\end{aligned}
|
|
|
|
\quad&=\quad
|
|
|
|
\Classify^\texttt{always}_\texttt{alwaysTrue}
|
|
|
|
&&\left(\odot^\land,\emptyset,\emptyset,\emptyset\right). \\
|
|
|
|
%
|
|
|
|
\begin{aligned}
|
|
|
|
\xml{<classify }&\xml{as="never" yields="neverTrue"} \xmlnl
|
|
|
|
&\xml{any="true"} \xmlnl
|
|
|
|
&\xml{desc="Never true" />}
|
|
|
|
\end{aligned}
|
|
|
|
\quad&=\quad
|
|
|
|
\Classify^\texttt{never}_\texttt{neverTrue}
|
|
|
|
&&\left(\odot^\lor,\emptyset,\emptyset,\emptyset\right).
|
|
|
|
\end{alignat*}
|
|
|
|
\caption{\tameclass{always} and \tameclass{never} from package
|
|
|
|
\tamepkg{core/base}.}
|
|
|
|
\end{figure}
|
|
|
|
|
|
|
|
Figure~\ref{fig:always-never} demonstrates \lemref{class-pred-vacu} in the
|
2021-05-18 15:06:35 -04:00
|
|
|
definitions of the classifications \tameclass{always} and
|
|
|
|
\tameclass{never}.
|
2021-05-18 14:09:27 -04:00
|
|
|
These classifications are typically referenced directly for clarity rather
|
|
|
|
than creating other vacuous classifications,
|
|
|
|
encapsulating \lemref{class-pred-vacu}.
|
|
|
|
|
|
|
|
|
2021-05-18 10:06:32 -04:00
|
|
|
\begin{theorem}[Classification Rank Independence]\thmlabel{class-rank-indep}
|
|
|
|
Let $\odot=\Monoid\Bool\bullet e$.
|
|
|
|
Then,
|
|
|
|
\begin{equation}
|
|
|
|
\Classify_\gamma\left(\odot,M,v,s\right)
|
|
|
|
\equiv \Classify\left(
|
|
|
|
\odot,
|
|
|
|
\Classify_{\gamma'''}\left(\odot,M,\emptyset,\emptyset\right),
|
|
|
|
\Classify_{\gamma''}\left(\odot,\emptyset,v,\emptyset\right),
|
|
|
|
\Classify_{\gamma'}\left(\odot,\emptyset,\emptyset,s\right)
|
|
|
|
\right).
|
|
|
|
\end{equation}
|
|
|
|
\end{theorem}
|
|
|
|
|
|
|
|
\begin{proof}
|
|
|
|
First,
|
|
|
|
by \axmref{class-yield},
|
|
|
|
observe these special cases following from \lemref{class-pred-vacu}:
|
|
|
|
|
|
|
|
\begin{alignat}{3}
|
|
|
|
\Gamma'''^2 &= \cpredmatseq, \qquad&&\text{assuming $v\union s=\emptyset$} \\
|
|
|
|
\Gamma''^1 &= \cpredvecseq, &&\text{assuming $M\union s=\emptyset$}\\
|
|
|
|
\Gamma'^0 &= \cpredscalarseq. &&\text{assuming $M\union v=\emptyset$}
|
|
|
|
\end{alignat}
|
|
|
|
|
|
|
|
By \thmref{class-compose},
|
|
|
|
we must prove
|
|
|
|
|
|
|
|
\begin{align}
|
|
|
|
\Exists{j\in J}{
|
|
|
|
\Exists{k\in K_j}{\cpredmatseq}
|
|
|
|
\bullet \cpredvecseq
|
|
|
|
}
|
|
|
|
\bullet \cpredscalarseq \nonumber\\
|
|
|
|
\equiv c \equiv
|
|
|
|
\Exists{j\in J}{
|
|
|
|
\Exists{k\in K_j}{\gamma'''_{j_k}}
|
|
|
|
\bullet \gamma''_j
|
|
|
|
}
|
|
|
|
\bullet \gamma'. \label{eq:rank-indep-goal}
|
|
|
|
\end{align}
|
|
|
|
|
|
|
|
By \axmref{class-yield},
|
|
|
|
we have $r'''=2$, $r''=1$, and $r'=0$,
|
|
|
|
and so $\gamma'''=\Gamma'''^2$,
|
|
|
|
$\gamma''=\Gamma''^1$,
|
|
|
|
and $\gamma'=\Gamma'^0$.
|
|
|
|
By substituting these values in~\ref{eq:rank-indep-goal},
|
|
|
|
the theorem is proved.
|
|
|
|
\end{proof}
|
2021-05-11 16:37:08 -04:00
|
|
|
|
2021-05-14 12:05:17 -04:00
|
|
|
\begin{corollary}[Classification As Proposition]
|
|
|
|
Classifications with $M\union v=\emptyset$ or with constant index sets can
|
|
|
|
be represented by propositional logic
|
|
|
|
(that is---without first-order logic).
|
|
|
|
\end{corollary}
|
|
|
|
\begin{proof}
|
2021-05-18 10:06:32 -04:00
|
|
|
Assume $M\union v=\emptyset$.
|
|
|
|
By \thmref{class-rank-indep},
|
2021-05-14 12:05:17 -04:00
|
|
|
|
2021-05-18 10:06:32 -04:00
|
|
|
\begin{align*}
|
|
|
|
c &\equiv \cpredscalarseq,
|
|
|
|
\end{align*}
|
2021-05-14 12:05:17 -04:00
|
|
|
|
2021-05-18 10:06:32 -04:00
|
|
|
\noindent
|
|
|
|
which is a propositional formula.
|
2021-05-14 12:05:17 -04:00
|
|
|
|
|
|
|
Similarly,
|
|
|
|
if we define our index set~$J$ to be constant
|
|
|
|
(such that it is known at compile-time)\footnote{%
|
|
|
|
Alternatively,
|
|
|
|
we could set an upper bound for~$J$,
|
|
|
|
always expand into that upper bound,
|
2021-05-18 10:06:32 -04:00
|
|
|
and then let undefined values of $v^m_j$ be~$e$.},
|
2021-05-14 12:05:17 -04:00
|
|
|
we are then able to eliminate existential quantification over~$J$
|
|
|
|
as follows:
|
|
|
|
Then,
|
|
|
|
|
2021-05-18 10:06:32 -04:00
|
|
|
\begin{align}\label{eq:prop-vec}
|
|
|
|
c &\equiv \Exists{j\in J}{\cpredvecseq}, \nonumber\\
|
|
|
|
&\equiv \left(v^0_0\bullet\cdots\bullet v^m_0\right)
|
|
|
|
\lor\cdots\lor
|
|
|
|
\left(v^0_{|J|-1}\bullet\cdots\bullet v^m_{|J|-1}\right),
|
|
|
|
\end{align}
|
2021-05-14 12:05:17 -04:00
|
|
|
\noindent
|
|
|
|
which is a propositional formula.
|
|
|
|
|
2021-05-18 10:06:32 -04:00
|
|
|
Similarly,
|
|
|
|
for matrices,
|
|
|
|
|
|
|
|
\begin{align}
|
|
|
|
c &\equiv \Exists{j\in J}{\Exists{k\in K_j}{\cpredmatseq}}, \nonumber\\
|
|
|
|
&\equiv \Exists{j\in J}{
|
|
|
|
\left({M^0_j}_0\bullet\cdots\bullet{M^0_j}_{|K_j|-1}\right)
|
|
|
|
\lor\cdots\lor
|
|
|
|
\left({M^l_j}_0\bullet\cdots\bullet{M^l_j}_{|K_j|-1}\right)
|
|
|
|
},
|
|
|
|
\end{align}
|
|
|
|
\noindent
|
|
|
|
and then proceed as in~\ref{eq:prop-vec}.
|
2021-05-14 12:05:17 -04:00
|
|
|
\end{proof}
|
|
|
|
|
|
|
|
\INCOMPLETE{The classification definitions are incomplete!}
|
|
|
|
|
|
|
|
These definitions may also be used as a form of pattern matching to look up
|
|
|
|
a corresponding variable.
|
2021-04-30 09:16:01 -04:00
|
|
|
For example,
|
2021-05-14 12:05:17 -04:00
|
|
|
if we have $\Classify^\texttt{foo}$ and want to know its \xmlattr{yields},
|
|
|
|
we can write~$\Classify^\texttt{foo}_\gamma$ to bind the
|
|
|
|
\xmlattr{yields} to~$\gamma$.\footnote{%
|
|
|
|
This is conceptually like a symbol table lookup in the compiler.}
|
|
|
|
|
|
|
|
\mremark{Note that these illustrate \emph{scalar} values only.}
|
|
|
|
Consider the following classification $\Classify^\texttt{cost-exceeded}$.
|
2021-04-30 09:16:01 -04:00
|
|
|
Let~\tameparam{cost} be a scalar parameter.
|
|
|
|
|
|
|
|
\index{classification!classify@\xmlnode{classify}}
|
|
|
|
\begin{lstlisting}
|
|
|
|
<classify as="cost-exceeded" desc="Cost of item is too expensive">
|
|
|
|
<t:match-gt on="cost" value="100.00" />
|
|
|
|
</classify>
|
|
|
|
\end{lstlisting}
|
|
|
|
|
|
|
|
\noindent
|
|
|
|
is then equivalent to the proposition
|
|
|
|
|
|
|
|
\begin{equation*}
|
|
|
|
\tameclass{cost-exceeded} \equiv \tameparam{cost} > 100.00.
|
|
|
|
\end{equation*}
|
|
|
|
|
|
|
|
\index{classification!domain}
|
2021-05-10 14:28:37 -04:00
|
|
|
A classification is either \true or~\false.
|
2021-04-30 09:16:01 -04:00
|
|
|
Let $\tameparam{cost}=150.00$.
|
|
|
|
Then,
|
|
|
|
|
|
|
|
\begin{align*}
|
|
|
|
\tameclass{cost-exceeded} & \equiv \tameparam{cost} > 100.00 \\
|
|
|
|
& \equiv 150.00 > 100.00 \\
|
|
|
|
& \equiv \true.
|
|
|
|
\end{align*}
|
|
|
|
|
2021-05-18 12:16:11 -04:00
|
|
|
Each \xmlnode{match} of a classification is a~\dfn{predicate}.
|
2021-05-10 14:28:37 -04:00
|
|
|
Multiple predicates are by default joined by conjunction:
|
2021-04-30 09:16:01 -04:00
|
|
|
|
|
|
|
\begin{lstlisting}
|
|
|
|
<classify as="pool-hazard" desc="Hazardous pool">
|
|
|
|
<match on="diving_board" />
|
|
|
|
<t:match-lt on="pool_depth_ft" value="8" />
|
|
|
|
</classify>
|
|
|
|
\end{lstlisting}
|
|
|
|
|
|
|
|
\noindent
|
|
|
|
is equivalent to the proposition
|
|
|
|
|
|
|
|
\begin{equation*}
|
|
|
|
\tameclass{pool-hazard} \equiv \tameparam{diving\_board}
|
2021-05-13 15:50:13 -04:00
|
|
|
\land \tameparam{pool\_depth\_ft} < 8.
|
2021-04-30 09:16:01 -04:00
|
|
|
\end{equation*}
|
|
|
|
|
|
|
|
|
|
|
|
\subsection{Matches}
|
2021-05-11 16:50:11 -04:00
|
|
|
\todo{Non-scalar values.}
|
2021-04-30 09:16:01 -04:00
|
|
|
\begin{definition}[Match Equality]
|
|
|
|
\begin{equation*}
|
|
|
|
\xml{<match on="$x$" value="$y$" />} \equiv x = y.
|
|
|
|
\end{equation*}
|
|
|
|
\end{definition}
|
|
|
|
|
|
|
|
\begin{definition}[Match Equality Short Form]
|
|
|
|
\begin{equation*}
|
|
|
|
\xml{<match on="$x$" />}
|
|
|
|
\equiv \xml{<match on="$x$" value="TRUE" />}.
|
|
|
|
\end{equation*}
|
|
|
|
\end{definition}
|
|
|
|
|
|
|
|
\begin{definition}[Match Equality Long Form]
|
|
|
|
\begin{alignat*}{2}
|
|
|
|
\xml{<match on="$x$" value="$y$" />}
|
|
|
|
&\equiv {}&&\xml{<match on="$x$">} \\
|
|
|
|
& &&\quad \xml{<c:eq>} \\
|
|
|
|
& &&\quad\quad \xml{<c:value-of name="$y$">} \\
|
|
|
|
& &&\quad \xml{</c:eq>} \\
|
|
|
|
& &&\xml{</match>} \\
|
|
|
|
&\equiv {}&&\xml{<t:match-eq on="$x$" value="$y$" />}.
|
|
|
|
\end{alignat*}
|
|
|
|
\end{definition}
|
|
|
|
|
|
|
|
\begin{definition}[Match Membership Equivalence]
|
|
|
|
When $T$ is a type defined with \xmlnode{typedef},
|
|
|
|
|
|
|
|
\begin{equation*}
|
|
|
|
\xml{<match on="$x$" anyOf="$T$" />} \equiv x \in T.
|
|
|
|
\end{equation*}
|
|
|
|
\end{definition}
|