@@ -34,4 +34,13 @@ The theory discovery use case described in Sec. \ref{sec:usecase} is mostly desi

\end{itemize}

For some of these use cases it would be advantageous to look for views \emph{into} our working theory instead.

Note that even though the algorithm is in principle symmetric, some aspects often depend on the direction -- e.g. how we preprocess the theories, which constants we use as starting points or how we treat and evaluate the resulting (partial) views (see Sections \ref{sec:algparams}, \ref{sec:normalizeintra} and \ref{sec:normalizeinter}).

\ No newline at end of file

Note that even though the algorithm is in principle symmetric, some aspects often depend on the direction -- e.g. how we preprocess the theories, which constants we use as starting points or how we treat and evaluate the resulting (partial) views (see Sections \ref{sec:algparams}, \ref{sec:normalizeintra} and \ref{sec:normalizeinter}).

We present a general MKM utility that given a \MMT theory and an \MMT library $\cL$ finds

partial and total views into $\cL$.

Such a view-finder can be used to drive various MKM applications ranging from theory classification to library merging and refactoring.

We have presented the first and last of these and show that they are feasible. For the applications discussed but unrealized in this paper, we mainly need to determine the right application context and user interface.

\paragraph{Future Work}

The current view-finder is already efficient enough for the limited libraries we used for testing.

To increase efficiency, we plan to explore term indexing techniques~\cite{Graf:ti96} that support $1:n$ and even $n:m$ matching and unification queries.

The latter will be important for the library refactoring and merging applications which look for all possible (partial and total) morphisms in one or between two libraries.

As such library-scale operations will have to be run together with theory flattening to a fixed point and re-run upon every addition to the library, it will be important to integrate them with the \MMT build system and change management processes~\cite{am:doceng10,iancu:msc}.

\paragraph{Acknowledgments}

The authors gratefully acknowledge financial support from the OpenDreamKit Horizon 2020

European Research Infrastructures project (\#676541) and the DFG-funded project OAF: An

\caption{Theory Classification for beautiful sets}\label{fig:theory-classification-ex}

\end{figure}

\end{oldpart}

We reduce the theory classification problem to that of finding theory morphisms (views)

between \MMT theories. $\cL$: given a query theory $Q$, the viewfinder computes all

(total) views from $Q$ into a library $\cL$, and returns presentations of target theories

and the assignments made by the views.

\paragraph{Related Work}

Existing systems have so far only worked with explicitly given theory morphisms, e.g., in IMPS \cite{imps} or Isabelle \cite{isabelle}.

...

...

@@ -85,11 +79,12 @@ Instead, of theory morphisms inside a single corpus, they use machine learning t

Their results can roughly be seen as a single partial morphism from one corpus to the other.

\paragraph{Approach and Contribution}

Our contribution is twofold.

Firstly, we present a the design and implementation of a generic theory morphism finder that works with arbitrary corpora represented in MMT.

The algorithm tries to match two symbols by unifying their types.

This is made efficient by separating the term into a hashed representation of its abstract syntax tree (which serves as a fast plausibility check for pre-selecting matching candidates) and the list of symbol occurrences in the term, into which the algorithm recurses.

Our contribution is twofold. Firstly, we present a the design and implementation of a

generic theory morphism finder that works with arbitrary corpora represented in MMT. The

algorithm tries to match two symbols by unifying their types. This is made efficient by

separating the term into a hashed representation of its abstract syntax tree (which serves

as a fast plausibility check for pre-selecting matching candidates) and the list of symbol

occurrences in the term, into which the algorithm recurses.

Secondly, we apply this view finder in two concrete case studies: In the first, we start with an abstract theory and try to figure out if it already exists in the same library. In the second example, we write down a simple theory of commutative operators in one language to find all commutative operators in another library based on a different language.

...

...

@@ -98,5 +93,11 @@ In Section~\ref{sec:prelim}, we revise the basics of MMT and the representations

We will discuss some of our findings specifically regarding the PVS library as a case study.

\subsection{Normalization in PVS}\label{sec:normalizeinter}

PVS~\cite{pvs} is a proof assistant under active development, based on a higher-order logic with predicate subtyping and various convenience features such as record types, update expressions and inductive datatypes. In addition to the \emph{Prelude} library, which contains the most common domains of mathematical discourse and is shipped with PVS itself, there is a large library of formal mathematics developed and maintained by NASA~\cite{nasa}.

PVS~\cite{pvs} is a proof assistant under active development, based on a higher-order logic with predicate subtyping and various convenience features such as record types, update expressions and inductive datatypes. In addition to the \emph{Prelude} library, which contains the most common domains of mathematical discourse and is shipped with PVS itself, there is a large library of formal mathematics developed and maintained by NASA~\cite{PVSlibraries:url}.

\paragraph{} While features like subtyping and records are interesting challenges, we will concentrate on one specific idiosyncracy in PVS -- its prevalent use of \emph{theory parameters}.

...

...

@@ -110,17 +110,31 @@ We have tried the first two approaches regarding theory parameters -- i.e. the s

\caption{Results of Inter- and Intra-Library Viewfinding in the PVS NASA Library}\label{fig:pvsresults}

\end{figure}

Most of the results in the simple MitM$\to$NASA case are artifacts of the theory parameter treatments -- in fact only two of the 17 results seem accurate. In the covariant case, the first $n$ results look meaningful, the rest are spurious small morphisms that can easily be automatically identified as such.

\paragraph{} As an additional use case, we can examplary write down a theory for a commutative binary operator using the MitM foundation, while targeting the PVS Prelude library -- allowing us to find all commutative operators, as in Figure \ref{fig:use:pvs} (using the simple approach to theory parmeters).

With a theory from the NASA library as domain, the results are already too many to be properly evaluated by hand.

\paragraph{} As an additional use case, we can write down a theory for a commutative binary operator using the MitM foundation, while targeting the PVS Prelude library -- allowing us to find all commutative operators, as in Figure \ref{fig:use:pvs} (using the simple approach to theory parmeters).

\begin{figure}[ht]\centering

\fbox{\includegraphics[width=\textwidth]{pvs}}

\caption{Searching for Commutative Operators in PVS}\label{fig:use:pvs}

\end{figure}

This example also hints at a way to iteratively improve the results of the viewfinder: since we can find properties like commutativity and associativity, we can use the results to in turn inform a better normalization of the theory by exploiting these properties. This in turn would potentially allow for finding more views.

This example also hints at a way to iteratively improve the results of the viewfinder: since we can find properties like commutativity and associativity, we can use the results to in turn inform a better normalization of the theory by exploiting these properties. This in turn would potentially allow for finding more views.