doc-src/isac/CTP-userinterfaces.tex
author Andreas Schulhofer <andreas.schulhofer@student.tugraz.at>
Tue, 11 Jan 2011 08:10:03 +0100
branchdecompose-isar
changeset 38099 a3cae5ca93eb
parent 38096 4872b10c8747
parent 38098 35218563ed7b
child 38100 905c8bfcf39a
permissions -rwxr-xr-x
merged
neuper@38077
     1
\documentclass{article}
neuper@38077
     2
\usepackage{a4}
neuper@38077
     3
\usepackage{times}
neuper@38077
     4
\usepackage{latexsym}
neuper@38077
     5
\bibliographystyle{alpha}
neuper@38077
     6
\usepackage{graphicx}
neuper@38077
     7
neuper@38077
     8
\def\isac{${\cal I}\mkern-2mu{\cal S}\mkern-5mu{\cal AC}$}
neuper@38077
     9
\def\sisac{{\footnotesize${\cal I}\mkern-2mu{\cal S}\mkern-5mu{\cal AC}$}}
neuper@38077
    10
\def\Problem{ {\tt Problem }}
neuper@38077
    11
neuper@38091
    12
\title{Userinterfaces for Computer Theorem Provers.\\
neuper@38091
    13
	Contributions to Isabelle
neuper@38077
    14
}
neuper@38077
    15
neuper@38077
    16
\author{G. Schafhauser, A. Schulhofer, M. Steger\\
neuper@38077
    17
Knowledge Management Institute (KMI)\\
neuper@38077
    18
TU Graz}
neuper@38077
    19
neuper@38077
    20
\begin{document}
neuper@38077
    21
\maketitle
neuper@38077
    22
\abstract{
neuper@38077
    23
TODO}
neuper@38077
    24
neuper@38096
    25
\section{Introduction}\label{intro}
neuper@38096
    26
Computer Theorem Provers (CTPs \footnote{The term CTP is used to address two different things in this paper: (1) the academic discipline comprising respective theories as well as (2) the products developed within this discipline, the provers and the respective technology.}) have a tradition as long as Computer Algebra Systems (CAS), another kind of mathematics assistants. However, CTPs task of proving is more challenging than calculating; so, in contrary to CASs, CTPs are not yet in widespread use --- not yet, because CTPs are on the step into industrial use in the current decade: Safe-critical software requires to be proven correct more and more \cite{db:dom-eng}, and the technology of CTP becomes ready to accomplish the task of efficiently proving hundreds of proof obligations.
neuper@38077
    27
neuper@38096
    28
The present shift of the predominant user group from academic experts to software engineers raises novel user requirements for graphical user interfaces (GUI) of CTP. CTPs will become components of integrated development environments, and the knowledge bases have to scale up to industrial size.
neuper@38096
    29
neuper@38096
    30
Two issues are particularly challenging: First, the knowledge bases (containing specifications, programs, tests etc) are under joint construction of many engineers. So requirements concerning cooperative work arise as already known from distributed repositories and version management.
neuper@38096
    31
neuper@38096
    32
Second, CTP tends to exhaust resources in memory and in runtime. So, CTP will take profit from multicore processors upcoming in this decade --- and CTP are best suited to meet the architectural challenges raised by parallel programming, since this kind of mathematics assistants generally follow rigorous architectural principles and are comparably easy to adapt to these challenges \cite{makarius:isa-scala-jedit}.
neuper@38096
    33
neuper@38096
    34
\medskip The paper is organised as follows: First a survey on CTP is given, Sect.\ref{ctp-techn} introduces two prominent CTPs, Sect.\ref{gui-coq-isa} describes their present user interfaces and Sect.\ref{gui-requir} goes into details with the novel requiremtns mentioned. Then Isabelle's plans for re-designing the user interface are presented: Sect.\ref{ml-users} motivates the strategy of how to approach the users' world, Sect.\ref{scala-medi} describes the rather recent programming language Scala connecting the world of languages for mathematics with the users' world and Sect.\ref{actors} goes into details with Scala's actor library. Finally possible contributions of the \sisac-team at TUG are discussed and prerequisites for such contributions presented: Sect.\ref{struct-der} presents a format for calculations particularily appropriate for education, which requires CTP support, Sect.\ref{plugin} describes plug-in technology required and Sect.\ref{netbeans} notes crucial details of proper project set-up in an integrated development environment.
neuper@38077
    35
neuper@38077
    36
%Georg
neuper@38077
    37
\section{State of the art in CTP Interfaces}
neuper@38077
    38
neuper@38077
    39
\subsection{A European technology: Coq and Isabelle}\label{ctp-techn}
neuper@38089
    40
%     http://en.wikipedia.org/wiki/Coq\\
neuper@38089
    41
%     http://coq.inria.fr/
neuper@38089
    42
%
neuper@38089
    43
%     http://en.wikipedia.org/wiki/Isabelle\_(theorem\_prover)\\
neuper@38089
    44
%     http://isabelle.in.tum.de/index.html
neuper@38089
    45
%
neuper@38089
    46
%why math -- functional: some of the languages have been specifically designed for constructing software for symbolic computation (SC). 
neuper@38089
    47
%%+ required for \ref{ml-users}
neuper@38089
    48
%
neuper@38089
    49
%SC http://en.wikipedia.org/wiki/Symbolic\_computation
neuper@38089
    50
%% mainly does not compute numerical values, but terms containing variables like functions (symbols)
neuper@38089
    51
%
neuper@38089
    52
%The LCF project
neuper@38089
    53
%http://hopl.murdoch.edu.au/showlanguage.prx?exp=8177
neuper@38089
    54
%specifically designed a 'meta language' (ML)
neuper@38089
    55
%http://en.wikipedia.org/wiki/ML\_(programming\_language)
neuper@38089
    56
%\cite{pl:milner97}
neuper@38089
    57
%for developing CTP
neuper@38089
    58
\subsubsection{Standard ML}
neuper@38089
    59
Standard ML is a general-purpose, modular, functional programming language. 
neuper@38089
    60
Programs written in Standard ML consist of expressions to be evaluated, as opposed to statements or commands. 
neuper@38089
    61
SML is a modern descendant of the ML programming language used in the Logic for Computable Functions (LCF) theorem-proving project. 
neuper@38089
    62
It is invented by Robin Milner. %http://en.wikipedia.org/wiki/Standard_M 
neuper@38089
    63
\subsubsection{Coq}
neuper@38089
    64
Coq is an interactive theorem prover, developed in France. The team leader is Senior Scientist Benjamin Werner. 
neuper@38089
    65
Coq is in Objective Caml programmed, an ML based programming language.
neuper@38089
    66
It has the ability to express  mathematical  assertions and check proof of mathematical  assertions. 
neuper@38089
    67
Furthermore Coq includes automatic theorem proving tactics and decision procedures.
neuper@38089
    68
Proof development in Coq is done through a language of tactics that allows a user-guided proof process. 
neuper@38089
    69
At the end, the user can check that tactics build lambda-terms. 
neuper@38089
    70
Another feature of Coq is “that it can automatically extract executable programs from specifications, as either Objective Caml 
neuper@38089
    71
or Haskell source code.“
neuper@38089
    72
Properties, programs and proofs are written a language called the Calculus of Inductive Constructions (CIC).
neuper@38089
    73
Coq is based on a type-checking algorithm, therefore Coq uses only typing judgements.
neuper@38089
    74
Coq supports a functional programming language.
neuper@38089
    75
(http://coq.inria.fr/a-short-introduction-to-coq)
neuper@38089
    76
\subsubsection{Isabelle}
neuper@38091
    77
Isabelle is an interactive theorem proving framework for high-level natural deduction proofs \cite{Paulson:Isa94}, written in Standard ML. 
neuper@38089
    78
Isabelle is developed at University of Cambridge (Larry Paulson), Technische Universität München (Tobias Nipkow) 
neuper@38089
    79
and Université Paris-Sud (Makarius Wenzel).
neuper@38089
    80
The most widespread instance of Isabelle nowadays is Isabelle/HOL, providing a higher-order logic theorem proving environment.
neuper@38089
    81
Isabelle/HOL includes several  specification tools, e.g. for datatypes, inductive definitions and functions with complex pattern matching.
neuper@38089
    82
Proofs are written in the structured proof language Isar. Isabelle implements several tools to increase the user's productivity in theorem proving. 
neuper@38089
    83
Isabelle's classical reasoner is used to check formulas. The simplifier can reason with and about equations. 
neuper@38089
    84
Linear arithmetic facts are proved automatically.
neuper@38089
    85
Isabelle provides notational support: new notations can be introduced, using normal mathematical symbols.
neuper@38089
    86
Definitions and proofs may include LaTeX source, from which Isabelle can automatically generate typeset documents.
neuper@38089
    87
Isabelle/HOL allows to turn executable specifications directly into code in SML, OCaml, and Haskell.
neuper@38089
    88
(http://www.cl.cam.ac.uk/research/hvg/Isabelle/overview.html)
neuper@38089
    89
\subsection{Userinterfaces for CTP: Coq and Isabelle}\label{gui-coq-isa}
neuper@38089
    90
%     CoqIDE, ..
neuper@38089
    91
%         http://coq.inria.fr/what-is-coq?q=node/57\\
neuper@38089
    92
%         earlier than Isabelle/jEdit
neuper@38089
    93
%
neuper@38089
    94
%     ProofGeneral for Isabelle
neuper@38089
    95
%         http://proofgeneral.inf.ed.ac.uk/\\
neuper@38089
    96
%         emacs stone age ?
neuper@38089
    97
\subsubsection{Coq Integrated Development Environment}
neuper@38089
    98
CoqIde is a graphical interface for Coq. It is written in Ocaml. (http://coq.inria.fr/cocorico/CoqIde)
neuper@38089
    99
Its main purpose is to allow the user to navigate forward and backward into a Coq vernacular file, 
neuper@38089
   100
executing corresponding commands or undoing them respectively. 
neuper@38089
   101
There are several  buffers for helping to write proof scripts.
neuper@38089
   102
Among all these buffers, there is always one which is the current running buffer, whose name is displayed on a green background,
neuper@38089
   103
which is the one where Coq commands are currently executed. 
neuper@38089
   104
Buffers may be edited as in any text editor, and classical basic editing commands (Copy/Paste, ...) are available.  
neuper@38089
   105
CoqIde provides also a feedback system for the user. 
neuper@38089
   106
Therefore the background is green when a command succeeds, otherwise an errormessage is displayed in the message window and the error location is underlined red.
neuper@38089
   107
CoqIDE offers only basic editing commands, therefore it is possible to launch another more sophisticated text editor. 
neuper@38089
   108
Furthermore CoqIde provides a proof wizard “for automatically trying to solve the current goal using simple tactics.”
neuper@38089
   109
Another features of this IDE are the customization options, which can be accessed by the Edit menu. 
neuper@38089
   110
This allows the user to change the apeareance of the IDE.
neuper@38077
   111
neuper@38077
   112
neuper@38089
   113
\begin{figure}[htbp]
neuper@38089
   114
\centering
neuper@38089
   115
%\includegraphics[bb=0 0 10 10]{coqide.png}
neuper@38091
   116
\includegraphics[scale=0.25]{fig/coqide}
neuper@38089
   117
\caption{CoqIDE main screen}
neuper@38089
   118
\end{figure}
neuper@38077
   119
neuper@38077
   120
neuper@38089
   121
(http://coq.inria.fr/V8.1/refman/Reference-Manual016.html)
neuper@38089
   122
\subsubsection{Proof General for Isabelle}
neuper@38089
   123
Proof General is a generic front-end for proof assistants, based on the customizable text editor Emacs.
neuper@38089
   124
Proof General has been developed at the LFCS in the University of Edinburgh with contributions from other sites.
neuper@38089
   125
Proof General comes ready-to-go for these proof assistants: Isabelle, Coq, PhoX, LEGO.
neuper@38089
   126
Proof General is used to write proof scripts. A Proof Script is a sequence of commands sent to theorem prover. 
neuper@38089
   127
The communication between the user and the theorem prover takes place via two or  more Emacs text widgets. 
neuper@38089
   128
Therefore the user sees only the output from the latest proof step.(proofgeneral.ps.gz)
neuper@38077
   129
neuper@38077
   130
neuper@38089
   131
Isabelle/Isar Proof General has full support for multiple file scripting, with dependencies between theories communicated between Isabelle and Proof General. 
neuper@38089
   132
There is full support for Unicode Tokens, using the Isabelle print mode for X Symbol tokens. Many Isabelle theories have X Symbol syntax already defined 
neuper@38089
   133
and it's easy to add to your own theories. 
neuper@38089
   134
(http://proofgeneral.inf.ed.ac.uk/fileshow.php?file=releases%2FProofGeneral%2Fisar%2FREADME)
neuper@38089
   135
\begin{figure}[htbp]
neuper@38089
   136
\centering
neuper@38091
   137
\includegraphics[scale=0.5]{fig/pgisabelle}
neuper@38089
   138
\caption{Proof General for Isabelle}%
neuper@38089
   139
\end{figure}
neuper@38089
   140
\subsubsection{Isabelle/Jedit}
neuper@38089
   141
jEdit is a text editor for programmers, written in Java.
neuper@38089
   142
Compared to fully-featured IDEs, such as Eclipse or Netbeans, jEdit is much 
neuper@38089
   143
smaller and better focused on its primary task of text editing.
neuper@38089
   144
The general look of the Isabelle/jEdit plugin is similar to existing Java IDEs.
neuper@38089
   145
The main Isabelle/jEdit plugin consists of ≈ 10 small Scala files  that augment some key jEdit components in order to provide a metaphor of asynchronous 
neuper@38089
   146
proof document editing. 
neuper@38089
   147
Isabelle/jEdit integrates the jEdit 4.3.2 framework  and some further  jEdit plugins. 
neuper@38089
   148
It also implements custom-made IsabelleText Unicode font that actually contains the usual Isabelle symbols that users expect from long 
neuper@38089
   149
years of Proof General X-Symbol support. 
neuper@38089
   150
The editor provides useful feedback, via semantic information from the processed document in the background. 
neuper@38089
   151
This achieves continuous proof checking based on our 
neuper@38089
   152
asynchronous prover toplevel. A lot of information can be directly attached 
neuper@38089
   153
to the source text, via coloring, tooltips, popups etc.
neuper@38077
   154
neuper@38077
   155
\subsection{Upcoming requirements for userinterfaces in CTP}\label{gui-requir}
neuper@38089
   156
%     @ interaction close to tty (Telegraph)\\
neuper@38089
   157
%       BUT: separate parts in {\em one} proof could be processed in parallel
neuper@38089
   158
%
neuper@38089
   159
%     @ http://www.informatik.uni-bremen.de/uitp/
neuper@38089
   160
%
neuper@38089
   161
%     @ ... see\\
neuper@38089
   162
%       http://www4.in.tum.de/~wenzelm/papers/async-isabelle-scala.pdf,\\
neuper@38089
   163
%       http://www4.in.tum.de/~wenzelm/papers/parallel-isabelle.pdf
neuper@38089
   164
After several decades, most proof assistants are still centered around TTY-based(Fußnote)  interaction in a
neuper@38089
   165
tight read-eval-print loop. All Emacs-based GUI's for CTPs follow this synchronous
neuper@38089
   166
model based on single commands with immediate response, meaning that the editor waits for the
neuper@38089
   167
prover after each command. As to multicore politics of leading semiconductor chip manufacturer,  parallelism in software technology has become very popular. 
neuper@38089
   168
Therefore the support of parallelism in CTP technology could improve the performance and the multiuser support. 
neuper@38089
   169
So it is necessary to use proof documents instead of proof scripts.  
neuper@38089
   170
Proof scripts are  sequences of commands however proof documents are  structured texts. 
neuper@38089
   171
So the proof document idea seems to guarantee the perfect support for parallelism in the CTP technology. 
neuper@38089
   172
(MW async-isabelle-scala.pdf)
neuper@38089
   173
\newpage
andreas@38098
   174
andreas@38098
   175
andreas@38098
   176
andreas@38098
   177
andreas@38098
   178
neuper@38077
   179
%Andreas
neuper@38077
   180
\section{Isabelle's plans for new user-interfaces}\label{gui-plans}
neuper@38089
   181
%       http://www4.in.tum.de/~wenzelm/papers/async-isabelle-scala.pdf,\\
neuper@38089
   182
%       http://www4.in.tum.de/~wenzelm/papers/parallel-isabelle.pdf
neuper@38089
   183
%
neuper@38089
   184
%theorem proving will be integrated into software development
neuper@38089
   185
%
neuper@38089
   186
%hundreds of proof obligations are generated during a software verification process 
neuper@38089
   187
%
neuper@38089
   188
%so the final goald of Isabelle's planning is integration with other software development tools in an integrated development environment (IDE).
neuper@38089
   189
%
neuper@38089
   190
%still many principal issues need to be clarified with respect to integration of CTP and other development tools. So engaging into details makes no sense at the present, and Isabelle will approach the final goal via experimental intermediate steps of integration.
andreas@38098
   191
The following observations lead to novel requirements for CTPS' userinterface:
neuper@38077
   192
neuper@38089
   193
\begin{itemize}
neuper@38089
   194
\item theorem proving will be integrated into software development
neuper@38089
   195
\item hundreds of proof obligations are generated during a software verification process
neuper@38089
   196
\item so the final goal of Isabelle's planning is integration with other software development tolls in an integrated development environment (IDE)
neuper@38089
   197
\item still many principal issues need to be clarified with respect to integration of CTP and other development tools. So engaging into details makes no sense at the present, and Isabelle will approach the final goal via experimental intermediate steps of integration
andreas@38098
   198
\item favorite IDE is the jEdit, because it is clearer than Eclipse or NetBeans. The reason behind this choice follows in section \ref{plugin}
neuper@38089
   199
\end{itemize}
neuper@38077
   200
andreas@38098
   201
These indicate design decisiouns are sketched in the sequel.
andreas@38098
   202
neuper@38077
   203
\subsection{Connect ML-world to the users' world via JVM}\label{ml-users}
neuper@38077
   204
In Sect.\ref{ctp-techn} reasons have been given, why mathematics software at the state-of-the-art cannot be written in Java or the like. On the other side, Sect.\ref{gui-requir} stated requirements for mathematical user interfaces, which cannot be accomplished by ML-like languages. These requirements can be best accomplished by languages like Java, which have powerful libraries available for convenient assembly of GUIs.
neuper@38077
   205
neuper@38089
   206
neuper@38089
   207
neuper@38089
   208
neuper@38077
   209
\paragraph{Example: a functional mathematics engine} as the experimental one in the \sisac-project is given by the following signature:
neuper@38077
   210
{\it
neuper@38077
   211
\begin{tabbing}
neuper@38077
   212
\=xx\=xxxxxxxxxxxxxxxxxxxxxxxxx\=\kill
neuper@38077
   213
\>signature INTERPRETER =\\
neuper@38077
   214
\>sig\\
neuper@38077
   215
\>\>type calcstate\\
neuper@38077
   216
\>\>type step = formula * position * tactic\\
neuper@38077
   217
\>\> \\
neuper@38077
   218
\>\>val do\_next : program $\rightarrow$ calcstate $\rightarrow$ (calcstate * step)\\
neuper@38077
   219
\>\>val apply\_tactic : program $\rightarrow$ calcstate $\rightarrow$ position $\rightarrow$ tactic $\rightarrow$ (calcstate * step list)\\
neuper@38077
   220
\>\>val apply\_formula : program $\rightarrow$ calcstate $\rightarrow$ position $\rightarrow$ formula $\rightarrow$ (calcstate * step list)\\
neuper@38077
   221
%\\
neuper@38077
   222
%\>\>val get\_next : program $\rightarrow$ calcstate $\rightarrow$ step\\
neuper@38077
   223
%\>\>val get\_applicable\_tactics : program $\rightarrow$ calcstate $\rightarrow$ tactic list\\
neuper@38077
   224
%\>\>val get\_intermediate : program $\rightarrow$ calcstate $\rightarrow$ position * position $\rightarrow$ step list\\
neuper@38077
   225
\>end
neuper@38077
   226
\end{tabbing}}
neuper@38077
   227
The three essential functions are \textit{do\_next}, which reads a \textit{program} for determining the next \textit{step} in a calculation, the function \textit{apply\_tactic}, which applies a \textit{tactic} input by the user to the current \textit{position} in a calculation and thus may produce a list of \textit{step}s and the function \textit{apply\_formula}, which applies an input \textit{formula} accordingly.
neuper@38077
   228
neuper@38077
   229
Now, the point with functional programming is, that the functions do {\em not} cause persistent updates in some memory, rather: all three functions above take the current state of the calculation, \textit{calcstate}, as an argument and after they have done they work return the updated \textit{calcstate}.
neuper@38077
   230
neuper@38077
   231
There are several advantages of this kind of programming: more straight forward verification, which is not discussed here, and other features. For instance, given the three functions above, it is easy to undo steps of calculations, or go back to an earlier step of calculations: one just needs to store the \textit{calcstate}s (in a list), even without knowing the details of the \textit{calcstate}, which thus can be encapsulated for internal access only.
andreas@38098
   232
andreas@38098
   233
\paragraph{Example: an object-oriented wrapper} as required for embedding the above mathematics engine into an object-oriented system. Such a wrapper may look like this:
andreas@38098
   234
andreas@38098
   235
\begin{verbatim}
andreas@38098
   236
   public class Calcstate
andreas@38098
   237
   {
andreas@38098
   238
     private Program program_;
andreas@38098
   239
     private Tree<Step> calcstate_;
andreas@38098
   240
     private Position position_;
andreas@38098
   241
     
andreas@38098
   242
     public Calcstate(Program program) {...}
andreas@38098
   243
     public Step do_next() {...}
andreas@38098
   244
     public List<Step> apply_tactic(Tactic tactic) {...}
andreas@38098
   245
     public List<Step> apply_formular(Formular formular) {...}
andreas@38098
   246
   }
andreas@38098
   247
\end{verbatim}
neuper@38077
   248
neuper@38077
   249
\subsection{Scala as a mediator between ML and JVM}\label{scala-medi}
andreas@38098
   250
Scala\cite{TODO} is a hybrid programming language. It combines object-oriented programming and functional programming. Scala runs on the Java Virtual Machine and is byte-code compatible with existing Java programs. The compilation model of Scala is nearly the same as the Java's model. So existing tools, libraries and applications can be used with Scala. The syntax of Scala is similar to Java and ML. A number of keywords plus the block syntax is adopted from Java and from ML the syntax for type annotation and declaration. The source-code is typically reduced, concisely and more compact compared to equivalent Java code.
andreas@38098
   251
andreas@38098
   252
Scala is pure object-oriented, this means every value is an object. The same is true for primitive data types, because compiler-generated byte code is using primitive data types. Known design patterns from OOP can be used with Scala as well. Data types and behaviors of objects are described by classes and traits\cite{[wiki]}. Traits not only consist of definitions, they also can contain implementations of methods. To avoid the problems of multiple inheritance, classes are able to extend various traits, this is a flexible mixin-based mechanism. The keyword Object is used to implement a Singleton-Class.
andreas@38098
   253
andreas@38098
   254
In Scala every function is a value, hence Scala is also a functional language. Functions in Scala are first-class objects, this means it is possible to pass a function as a parameter, return a function from a subroutine, or assign to a variable. Scala also supports case classes, which are used for pattern matching. Case classes are regular classes which export their constructor parameters\cite{[wiki-11-1s]}. Furthermore Scala supports higher-order functions, currying and allows functions to be nested.
andreas@38098
   255
neuper@38089
   256
Scala is more statically typed than Java, but is able to infer types by usage. So most static type declarations are optional. This static type system ensures a safe and coherent use of abstraction. Scala supports:
andreas@38098
   257
neuper@38089
   258
\begin{itemize}
neuper@38089
   259
\item generic classes
neuper@38089
   260
\item variance annotations
neuper@38089
   261
\item upper and lower type bounds
neuper@38089
   262
\item classes and abstract types as object members
neuper@38089
   263
\item compound types
neuper@38089
   264
\item explicitly typed self references
neuper@38089
   265
\item views
neuper@38089
   266
\item polymorphic methods
neuper@38089
   267
\end{itemize}
andreas@38098
   268
andreas@38098
   269
Static types need no explicit declaration but can be given to give the code some clarity.
andreas@38098
   270
andreas@38098
   271
Scala supports threads, but the Scala library contains an actor model\cite{TODO} inspired from Erlang\cite{TODO}. Concurrency and Scala actors follow in the next section.
neuper@38089
   272
neuper@38089
   273
%quellen
neuper@38089
   274
%%http://de.wikipedia.org/wiki/Scala_%28Programmiersprache%29
neuper@38089
   275
%%http://en.wikipedia.org/wiki/Scala_%28programming_language%29
neuper@38089
   276
%%http://creativekarma.com/ee.php/weblog/comments/why_scala_instead_of_java/
neuper@38089
   277
%%http://www.scalasolutions.com/scala
neuper@38089
   278
neuper@38077
   279
neuper@38077
   280
\subsection{Support for parallel processing}\label{actors}
andreas@38098
   281
Concurrency has lately become more and more attention, because multicore processors make concurrency very important for efficient program execution, by running multiple threads parallel and so concurrent programming gets indispensable and distributed computing,web services and mobile environments are naturally concurrent.
neuper@38089
   282
andreas@38098
   283
A very attractive model, because of the fact that it might addresses multicore processors and several techniques which are basically concurrent, is message-based concurrency. Most of these are based on the actor model.
andreas@38098
   284
andreas@38098
   285
%Most of the message passing systems, which are used in practice, are based on the actor model.
andreas@38098
   286
andreas@38098
   287
An actor is a concurrent process that executes a function. The state of an actor gets never shared, so it doesn't need to compete for locks of shared data. Actors own a mailbox where incoming messages are stored in. A mailbox is mainly a queue with several producers and one consumer, which are other actors. Actors share data by sending Messages which are sent asynchronously. Messages are unchangeable, so they don't require a lock. By creating new actors, by sending messages to known actors, or changing its behavior, an actor is able to reply to a message. The actor-based process is combined with pattern matching for messages.
andreas@38098
   288
andreas@38098
   289
The Erlang programming language is a functional programming language that supports message-based concurrency, which operates with actors. It was developed for real-time control systems. Such systems are telephone exchanges, network simulators and distributed resource controllers \cite{[IoC]}. These systems use a very popular lightweight implementation and a large number of concurrent processes, which can active simultaneously.
andreas@38098
   290
andreas@38098
   291
Operating system threads and threads of virtual machines are too heavyweight for the implementation of such processes. The standard concurrency for mainstream platforms were shared-memory threads with locks. Such a platform is the Java Virtual Machine (JVM), which suffers from high memory consumption and context-switching overhead.
neuper@38091
   292
The main reasons are:
neuper@38089
   293
\begin{enumerate}
neuper@38091
   294
\item quick exhaustion of virtual address space
neuper@38091
   295
\item locking mechanisms often lack suitable contention managers
neuper@38089
   296
\end{enumerate}
andreas@38098
   297
\cite{[IoC]}\\
andreas@38098
   298
For that reasons Erlang uses lightweight concurrent processes by its own run time system and not by the underlying operating system \cite{[IoC]} and the computations on these platforms are often modeled in an event-driven style, which is complicated and error-prone.
neuper@38091
   299
\paragraph{Two different strategies for concurrency} are being used for implementation. This two strategies often follow different programming models, the benefit of thread-based models is that they are easier to use, but they still suffer from the memory consumption and the context-switching. The event-based models are just the opposite of the thread-based, they are more efficient, but in massive designs they are very difficult.
neuper@38091
   300
andreas@38098
   301
\subparagraph{Thread-based implementation:} The behavior of a concurrent process is defined by implementing a thread-specific method. The execution state is maintained by an associated thread stack \cite{[2.P]}.
neuper@38091
   302
Supports blocking operations and can be executed on multicore processors in parallel.
neuper@38091
   303
andreas@38098
   304
\subparagraph{Event-based implementation:} The behavior is defined by a number of (non-nested) event-handlers which are called from inside an event loop. The execution state of a concurrent process is maintained by an associated record or object \cite{[2.P]}. Targets to a large number of actor which can be active simultaneously, because they are more lightweight.
neuper@38091
   305
andreas@38098
   306
\paragraph{Actors in Scala} are based on actors in Erlang. Scala uses the basic thread model of Erlang, but on the other hand all higher-level functions got implemented in the Scala library as classes or methods. The Scala-actors are a unification of the implementation models mentioned above and they are compatible with normal Virtual Machine (VM) thread. Normal VM threads can use the same communication and monitoring capabilities, because they are treated like an actor. A message-based concurrency seems to be more secure than shared-memory with locks, because accessing an actor's mailbox is race-free. The advantage of a implementation in a library is that it can be flexibly extended and adapted to new needs. The library makes use of Scala abstraction opportunities, like partial functions and pattern matching.
neuper@38091
   307
andreas@38098
   308
The main idea of this model is that an actor is able to wait for a message by using two different operations, which try to remove a message from the current actor's mailbox. To do so, a partial function must be given to the operation, that specifies a set of message patterns. These are {\itshape receive} and {\itshape react}. An actor can suspend with a full thread stack (receive) or it can suspend with just a continuation closure (react)\cite{[2.P]}. The first operation of an actor to wait for an message is equal to thread-based programming and the second operation to event-based programming.
neuper@38091
   309
andreas@38098
   310
\subparagraph{receive:}
andreas@38098
   311
$$\mathit{def}\;\mathit{receive}\mathit{[R]}(f: \mathit{PartialFunction}[Any, R]): \mathit{R}$$
andreas@38098
   312
The current actor's mailbox get scanned and if there is one message which matches one of the patterns declared in the partial function, the message is removed from the mailbox and the partial function is applied to the message, the result is returned. Otherwise the current thread blocks. Thus the receiving actor has the ability to execute normally when receiving a message which matches.  Note that receive retains the complete call stack of the receiving actor; the actor’s behavior is therefore a sequential program which corresponds to thread-based programming \cite{[2.P]}.
andreas@38098
   313
\subparagraph{react:}
neuper@38091
   314
$$\mathit{def}\;\mathit{react}(f: \mathit{PartialFunction}[Any, Unit]): \mathit{Nothing}$$
andreas@38098
   315
The action which is specified in the partial function is the last code that the current actor executes, if the message is matching. The partial function gets registered by the current actor and the underlying thread gets released. React has the return type Nothing, this means that the method never returns normally. When the actor receives a matching message, the earlier registered partial function gets called and the actor's execution gets continued. The partial function f which corresponds to a set of event handlers \cite{[2.P]}. 
andreas@38098
   316
andreas@38098
   317
For this implementation multiple actors are executed by multiple threads and therefore a thread pool is used. Whenever it is necessary the pool can be re sized, to support the operations of the thread-based and event-based model. If only operations of the event-based model are executed then the thread pool could be fixed. To avoid system-included deadlocks, if some actors use thread-based operations, the thread pool has to grow, because if there are outstanding tasks and every worker thread is occupied by a blocked actor, new threads are necessary.
andreas@38098
   318
andreas@38098
   319
Since the communication between actors takes place through asynchronous message passing, asynchronous operations get executed, tasks have to be created and submitted to a thread pool for execution. A new task is created, when an actor spawns a new actor or a message, which enables an actor to continue, is send to an actor which is suspended in a react operation or by calling react, where a message can be immediately removed from the mailbox.
andreas@38098
   320
andreas@38098
   321
%Event-Based Programming without Inversion of Control - Philipp Haller, Martin Odersky  [IoC]
andreas@38098
   322
%Scala actors: Unifying thread-based and event-based programming - Philipp Haller, Martin Odersky [2.P]
neuper@38089
   323
neuper@38077
   324
neuper@38077
   325
% Marco
neuper@38077
   326
\section{Planned contributions at TU Graz}
neuper@38077
   327
neuper@38077
   328
\subsection{Make Isabelle process structured derivations}\label{struct-der}
neuper@38077
   329
Structured Derivations (SD) is a format for calculational reasoning, which has been established by \cite{back-grundy-wright-98}. This is an example calculation:
neuper@38077
   330
{\it\begin{tabbing}
neuper@38077
   331
123\=123\=123\=123\=123\=123\=123\=123\=123\=123\=123\=123\=\kill
neuper@38077
   332
\> $\bullet$\> \Problem [ maximum\_by, calculus ]\\
neuper@38077
   333
\>\> $\vdash$\> $A = 2\cdot u\cdot v - u^2$\\
neuper@38077
   334
\>\> $\bullet$\> \Problem [make, diffable, funtion]\\
neuper@38077
   335
\>\> \dots\> $\overline{A}(\alpha) = 8\cdot r^2\cdot\sin\alpha\cdot\cos\alpha - 4\cdot r^2\cdot(\sin\alpha)^2$\\
neuper@38077
   336
\>\> $\bullet$\> \Problem [on\_interval, for\_maximum, differentiate, function]\\
neuper@38077
   337
\>\>\> $\vdash$\> $\overline{A}(\alpha) = 8\cdot r^2\cdot\sin\alpha\cdot\cos\alpha - 4\cdot r^2\cdot(\sin\alpha)^2$\\
neuper@38077
   338
\>\>\> $\bullet$\> \Problem [differentiate, funtion]\\
neuper@38077
   339
\>\>\> \dots\> $\overline{A}^\prime(\alpha) = 8\cdot r^2\cdot(-(\sin\alpha)^2+(\cos\alpha)^2 - 2\cdot\sin\alpha\cdot\cos\alpha)$\\
neuper@38077
   340
\>\>\> $\bullet$\> \Problem [on\_interval, goniometric, equation]\\
neuper@38077
   341
\>\>\> \dots\> $\alpha = \tan^{-1}(-1+\sqrt{2})$\\
neuper@38077
   342
\>\> \dots\> $\alpha = \tan^{-1}(-1+\sqrt{2})$\\
neuper@38077
   343
\>\> $\bullet$\> \Problem [tool, find\_values]\\
neuper@38077
   344
\>\> \dots\> [ $u=0.23\cdot r, \:v=0.76\cdot r$ ]\\
neuper@38077
   345
\> \dots\> [ $u=0.23\cdot r, \:v=0.76\cdot r$ ] %TODO calculate !
neuper@38077
   346
\end{tabbing}}
neuper@38077
   347
The plan is to use the machinery provided Isabelle/Isar as a 'logical operating system' ~\cite{isar-impl} and adapt the machinery such that is accepts SC in parallel to the Isar proof language~\cite{wenzel:isar}.
neuper@38077
   348
neuper@38077
   349
This plan involves the following details.
neuper@38077
   350
neuper@38077
   351
\subsection{Add a plug-in to jEdit}\label{plugin}
neuper@38089
   352
    % file structure, copied from example project ...
neuper@38089
   353
%Die von jEdit verfolgte Strategie im Bezug auf Plugin-Management und natürlich generell die totale Offenlegegung des Codes ist für ein Projekt wie Isabelle und auch für das Isac-Project an der TU ideal. Plugins lassen sich sehr einfach anfügen und durch die riesige Vielfalt von bereits bestehenden Plugins ist auch die Adaption von Plugins möglich bzw. zu empfehlen, denn warum sollte nicht bereits funktionierender Code verwendet werden?\\
m@38092
   354
The importance of connecting the ML-world with the world of user interfaces has been is discussed in Sect.\ref{ml-users}. jEdit follows these lines, it is an open-source, Java-based text editor that works on Windows, Mac OS X, and Linux. A big advantage of jEdit is, that there is a very good and also simple way to use and write a Plugin. There are a lot of useful and powerful Plugins available in the net and it is also possible to use a existing Plugin as part of a new one. Because of this facts, jEdit is very suitable for a project like Isabelle and also for the \sisac-project at TU-Graz.
m@38092
   355
m@38092
   356
Each jEdit-Plugin\footnote{To get more information about the jEdit infrastructure see: http://jedit.org/users-guide/plugin-intro} basically consists of source files, written in Java or Scala, XML-files and property files. The XML-Files are important for the administration of a Plugin and provides information like the name, author, ... of the Plugin. They are also containing small pieces of BeanShell code which is executed upon a user request. (Like pressing the 'start plugin' button.) So the XML-files provide the “glue” between user input and specific Plugin routines located in the source files. As you see, this files are used as interface between the Plugin and the jEdit engine itself.
m@38092
   357
neuper@38089
   358
Based on the jEdit API, you are allowed to design your code quit freely and don't have to use a prescribed way to implement your ideas.    
m@38092
   359
m@38092
   360
neuper@38089
   361
%isabell plugin beschreiben!!!!!!!!
neuper@38089
   362
The Isabelle-team also follow use this Plugin-structure. In the next paragraph the involved files will be described. The jEdit-Isabelle-Plugin consists of:
neuper@38089
   363
\begin{itemize}
m@38092
   364
\item one property file
m@38092
   365
\item three XML-files
neuper@38089
   366
\item 14 Scala-source-files
neuper@38089
   367
\end{itemize}
neuper@38089
   368
%Das vom Isabelle-Team erstellte jEdit-Plugin folgt natürlich auch dem oben erklärten Muster. Es wird nun genauer auf dieses Plugin eingegangen. The plugin consits of 14 scala-source-files, three xml-files and one property-file. 
m@38092
   369
\begin{description}
m@38092
   370
\item[Isabelle.props] The property-file \textit{Isabelle.props} contains general informations about the Isabelle-Plugin and the needed dependencies between Isabelle and the other used Plugins like sidekick.
m@38092
   371
\item[dockables.xml] The XML-file \textit{dockables.xml} is used to create the needed dock-able windows which are important to set up the GUI of the Plugin.
m@38092
   372
\item[actions.xml] In the file \textit{actions.xml}, the dockable windows are added to the window-manager \textit{wm} and there is also some Beanshell-code to activate the Isabelle-GUI.
m@38092
   373
\item[services.xml] The last XML-file is \textit{services.xml} and is used to create instances of needed jEdit-Plugins.
m@38092
   374
\end{description}
m@38092
   375
This four files are located in the folder \textit{plugin}.\\
m@38092
   376
m@38092
   377
The more interesting files, the scala-files of the Plugin, can be found in the 'src/jedit'-directory. In this directory you can find the file \textit{Dummy.java} which is a dummy class and is simply used to make javadoc work. Just forget about this file. Also there is a folder/package \textit{jedit} which contains all Scala-source-files. Now it is time to take a closer look on the source-files: 
m@38092
   378
\begin{description}
m@38092
   379
\item[plugin.scala] The file \textit{plugin.scala} is the main-file of the Isabelle-Plugin and there are two important parts. First the \textit{Isabelle object}. This object contains data like name and path and also few basic functions. The second part is the \textit{class Plugin} which is derived from EBPlugin. Here the basic methods \textit{handleMessage}, \textit{start} and \textit{stop} are implemented. Each jEdit-Plugin should have this methods because they are very important for the handling of the Plugin!
m@38092
   380
\item[dockable.scala] jEdit and also the Isabelle Plugin work with dock-able windows. This means that you can move around each single window and dock it somewhere on the screen. So it is possible to individualize the jEdit-GUI. To support this, the file \textit{dockable.scala} is needed. The file \textit{output-dockable.scala} is derived from \textit{dockable.scala} and is used to print the result/output in a dock-able window. The same thing with \textit{protocol-dockable.scala} and \textit{raw-output-dockable.scala}.
m@38092
   381
\item[scala-console.scala] The next interesting file is \textit{scala-console.scala} with the main-class Scala-Console. This class is used to expand the Console-Plugin in a way, that it is possible to interpret Scala-code with a Shell inside of jEdit.
m@38092
   382
\item[isabelle-sidekick.scala] The file \textit{isabelle-sidekick.scala} is related to the file \textit{scala-console.scala} because it is also used to adapt the Plugin Sidekick for Isabelle.
m@38092
   383
\item[document-model.scala, document-view.scala] The files \textit{document-model.scala} and \textit{document-view.scala} are used to connect the jEdit-buffer/the text-area to Isabelle. Both classes offer, upon others, methods to activate and deactivate this features.
m@38092
   384
\end{description}
m@38092
   385
There also some other source-files but they aren’t discussed here, because the main goal of this paragraph is to give a basic idea how a jEdit-Plugin should be set up and the remaining files are not as important for the Isabelle-Plugin-structure.
m@38092
   386
%\begin{itemize}
m@38092
   387
%\item $html_panel.scala$
m@38092
   388
%\item $isabelle_encoding.scala$
m@38092
   389
%\item $isabelle_hyperlinks.scala$
m@38092
   390
%\item $isabelle_options.scala$
m@38092
   391
%\item $isabelle_token_maker.scala$
m@38092
   392
%\item $isabelle_hyperlinks.scala$
m@38092
   393
%\end{itemize}
neuper@38089
   394
neuper@38089
   395
neuper@38089
   396
%  Like each other jEdit-Plugin also this 
neuper@38089
   397
neuper@38089
   398
%Das Konzept des frei wählbaren Designs ist am Beginn villeicht etwas schwierig umzusetzten, da es leichter ist, sich irgendwo anzulehnen bzw. ein bereits bestehendes sowie funktionierendes Konzept zu übernehmen. So wurden auch die ersten Schritte an der TU gemacht. Zu diesem Zweck wurde das von den Entwicklern von jEdit zur Verfügung gestellte plugin 'QuickNotepad' übernommen und in Scala übersetzt. Obwohl Scala eng mit Java verknüpft ist, war doch einiges an 'rewritting' notwendig bis das Scala-plugin lauffähig wurde. Die benötigten XML-files konnten dazu nahezu unberührt gelassen werden.\\
neuper@38077
   399
neuper@38077
   400
\subsection{Details of NetBeans projects}\label{netbeans}
neuper@38089
   401
%     Scala + Java: html project files
m@38092
   402
As described in the last paragraph, jEdit is a open-source-project. The jEdit-developers use a NetBeans-project to produce the source-code and so it is beneficial to use a NetBeans project too, because there is a quite good documentation about setting up a NetBeans-project with the jEdit-source.\footnote{See http://wiki.netbeans.org/NetbeansedJEdit for further information.} 
m@38092
   403
neuper@38089
   404
If you want to set up a new jEdit-Plugin-project you have to attend that you have to create some source-files and that there must be a connection to the jEdit-source because you will need to exchange data with the jEdit engine. This could probably look like: \textit{jEdit.getProperty("options.isabelle.isabelle")}\\
neuper@38089
   405
As shown above, the jEdit-source is needed to compile and build your Plugin. There are two ways to organize your project:
m@38092
   406
%\begin{itemize}
m@38092
   407
%\item with jEdit source code - two projects in one
m@38092
   408
%\item with jedit.jar library
m@38092
   409
%\end{itemize}
neuper@38089
   410
\subsubsection{Plugin with jEdit-source}
neuper@38089
   411
It is a good way to download the jEdit source as Netbeans project because then it is possible to add another subproject to the existing jEdit-NetBeans-project. As you see it is also possible to mix Scala and Java. A big advantage is, that debugging will now work really fine. If you want to set up a project like this, you should complete the following steps.
neuper@38089
   412
\begin{enumerate}
neuper@38089
   413
\item {Create a new NetBeans-project for your Plugin like \textit{example-plugin}. This will probably be a Scala-Project.}
neuper@38089
   414
\item Download (and try out) the \textit{jEdit-NetBeans-project}
neuper@38089
   415
\item at project \textit{example-plugin}: \textit{Project-browser} $\rightarrow$ Right-click at \textit{Libraries} $\rightarrow$ \textit{add Project...} and then choose the \textit{jEdit-NetBeans-project}.
neuper@38089
   416
\item at project \textit{example-plugin}: \textit{Project-browser} $\rightarrow$ Right-click at project-name-label $\rightarrow$ \textit{Properties} $\rightarrow$ \textit{Run} $\rightarrow$ \textit{Main Class:} org.gjt.sp.jedit.jEdit
neuper@38089
   417
\item compile and run
neuper@38089
   418
\end{enumerate}
neuper@38089
   419
neuper@38089
   420
\subsubsection{Plugin with jedit.jar}
neuper@38089
   421
It is also possible to use the \textit{jedit.jar} file. This file is already included in \$ISABELLE-HOME/contrib/jedit-4.3.2. Now you just have to follow this steps:
neuper@38089
   422
\begin{enumerate}
neuper@38089
   423
\item {Create a new NetBeans-project for your Plugin like \textit{example-plugin}. This will probably be a Scala-Project.}
neuper@38089
   424
\item at project \textit{example-plugin}: \textit{Project-browser} $\rightarrow$ Right-click at \textit{Libraries} $\rightarrow$ \textit{add JAR/Folder...} and then choose the \textit{jedit.jar} file.
neuper@38089
   425
\item at project \textit{example-plugin}: \textit{Project-browser} $\rightarrow$ Right-click at project-name-label $\rightarrow$ \textit{Properties} $\rightarrow$ \textit{Run} $\rightarrow$ \textit{Main Class:} org.gjt.sp.jedit.jEdit
neuper@38089
   426
\item compile and run
neuper@38089
   427
\end{enumerate}
neuper@38089
   428
This are two different ways to get started. It is difficult to say what is better because both versions have advantages. Now it is time to start coding your own Plugin but there are still a few things to think about. Remember, that a Plugin consists of source-, XML- and property-files. On default, NetBeans will just pack the source-files in the \textit{example-plugin.jar}-package. So you have to add a copy/move-routine in the \textit{build.xml} file of your NetBeans-project to get a complemented package.
neuper@38089
   429
\begin{itemize}
neuper@38089
   430
\item $\langle target name="-pre-jar"\rangle$
neuper@38089
   431
\item $	\langle copy $file="plugin/services.xml" todir="\${build.classes.dir}" $/\rangle$
neuper@38089
   432
\item $	\langle copy $file="plugin/dockables.xml" todir="\${build.classes.dir}" $/\rangle$
neuper@38089
   433
\item $	\langle copy $file="plugin/actions.xml" todir="\${build.classes.dir}" $/\rangle$	
neuper@38089
   434
\item $	\langle copy $file="plugin/Isabelle.props" todir="\${build.classes.dir}" $/\rangle$
neuper@38089
   435
\item $	\langle /target\rangle$
neuper@38089
   436
\end{itemize}
neuper@38089
   437
%* kurze aufzählung der xml-netbeans-files + erklärung\\
neuper@38089
   438
\subsubsection{NetBeans project files}
m@38092
   439
As you see in the paragraph above, it is also important to have basic knowledge about NetBeans, the project structure and how to change the operational sequences. A typical NetBeans-project consist of the source- and library-files and administrative XML- and property-files. In this paragraph the administrative part of the project is of note. The most important file is \textit{build.xml}. This file can be found in the project directory. There is also a folder \textit{nbproject} which contains the remaining XML- and property-files and also a folder \textit{private}, where individual user informations about the project is stored. The files in this \textit{private} folder are not important to describe (and they should not be pushed on the repository!).
m@38092
   440
m@38092
   441
A build-file like \textit{build.xml} contains one project and at least one (default) target. Targets contain task elements. Each task element of the build-file can have an id attribute and can later be referred to by the value supplied to this. So the id has to be unique. Such targets can be "run", "debug", "build", ... and can have dependencies to other targets. Tasks define what should happen, if a target is executed. So like in the example above, the target is \textit{pre-jar}, that means that this things will happen before the jar-package is packed. The tasks of this target are copying some files into the package.
m@38092
   442
neuper@38089
   443
The files inside the \textit{nbproject}-folder are not so important because some of it are generated from \textit{build.xml} and changes in this files are useless. Just the file project.properties is really interesting because this file gives a nice and tight overview about the project settings.
neuper@38077
   444
neuper@38077
   445
\subsection{Use interfaces between Java and Scala}\label{java-scala}
neuper@38089
   446
%     how are data exchanged between Scala and Java ...
m@38092
   447
jEdit is completely written in Java and the required plugin(s) for \sisac{ }will be coded in Scala - so there must be ways to exchange data between Java and Scala. One way is to connect this two worlds with the in 4.2 described XML-files. Here you need to use a third type of code to get an interface between Java and Scala code. But there is also a way to get a direct connection.
m@38092
   448
m@38092
   449
This link should be shown on the graphic-library \textit{Swing}. In both languages it is possible to use Swing which provides a lot of different shapes and useful functionality. So there is a Java-Swing and also a Scala-Swing-library. Now it is interesting to examine the connection between this two libraries.
m@38092
   450
m@38092
   451
In Scala a direct use of Java-Libs (like Java-Swing) is possible. So if you are Java-Programmer and want to use Java-Swing in Scala, you can simply type\\ \textit{import javax.swing.JButton}\footnote{http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JButton.html} to work with a Java-button. But you can also use the Scala-equivalent \textit{scala.swing.Button}\footnote{http://www.scala-lang.org/api/current/scala/swing/Button.html}. This two button-types will provide nearly the same functionality.
m@38092
   452
m@38092
   453
So what is the idea of creating a nearly similar library a second time? Why have the Scala-developers done such extra work? The answer is, that they have tried to improve and simplify the usage of the Swing-library(and many other libs too!). So big parts of this Scala-Libraries are just Wrapper-objects, Wrapper-Classes and Wrapper-Methods of already existing parts in Java-Libraries. Needless to say that they also added new useful shapes and functionality.
neuper@38089
   454
But there is one important question left: Is it possible to mix Scala- and Java-objects? And yes, it is possible. There is a really easy way to convert a Scala-object to the Java-equivalent:
neuper@38089
   455
\begin{enumerate}
neuper@38089
   456
\item \textit{import javax.swing.JButton}
neuper@38089
   457
\item \textit{import scala.swing.Button}
neuper@38089
   458
\item \textit{var b: scala.swing.Button}
neuper@38089
   459
\item \textit{var jb: javax.swing.JButton}
neuper@38089
   460
\item \textit{jb = b.peer}
neuper@38089
   461
\end{enumerate}
neuper@38089
   462
As the example above illustrates, a conversion of Scala- to Java-objects is possible. It looks easy but also a little bit useless. Why should you need this? Just imagine that there is a Plugin written in Scala and one coded in Java. With this connection between Scala and Java, it would be easy to connect this two Plugins! 
neuper@38089
   463
%Diesen direkten Zusammenhang zwischen Java und Scala soll anhand der Grafik-Bibliotheken Swing. Beide Sprachen stellen diese Grafik-Bibliotheken zur Verfügung (und darin auch eigene Shapes und Funktionalität). Es ist jedoch möglich, Java-Bibliotheken, wie eben auch Java-Swing in Scala zu verwenden. Ein JButton kann zum Beispiel mittels \textit{import javax.swing.JButton} eingebunden und damit sofort auch verwendet werden. Auch Scala stellt in seiner Swing-Bibliothek zur Verfügung: \textit{scala.swing.Button}. Es wird nahezu die selbe Funktionalität angeboten und teilweise die Erzeugung bzw. Verwendung vereinfacht(???). Man kann sich nun fragen, warum sich die Scala-Entwickler einerseit die Mühe gemacht haben die Verwendung Java-Swing, wie in Java selbst, möglich zu machen und andererseits mit Scala-Swing eine nahezu idente Alternative geschaffen haben. Die Antwort darauf zeigt wie der objektorientierte Teil von Scala in vielen Bereichen aufgebaut wurden. Es wurde kein neues Konzept für diese Grafikklassen entworfen sondern Wrapper-Objekte/Methoden/Klassen erstellt, die das Arbeiten mit diesen Grafikkomponenten erleichtern soll. Ein Letztes Problem bleibt noch: Es ist zwar sehr einfach ein Java-Swing-Objekt an einen Scala-Swing-Container (zb. Frame) anzubinden, da eine Konvertierung von Java-Komponente in ein Scala-Äquivalent ist problemlos möglich. ...
neuper@38077
   464
\section{Conclusion and future work}
neuper@38077
   465
neuper@38077
   466
neuper@38079
   467
\bibliography{CTP-userinterfaces}
neuper@38079
   468
%\bibliography{bib/math-eng,bib/bk,bib/RISC_2,bib/isac,bib/pl,bib/math,bib/pl}
neuper@38077
   469
\end{document}