訳者(丸山 智)注: この文書は、 https://www.swi-prolog.org/windows.html の翻訳の一部です(以前は swi-Prolog を Windows にインストールしたときに C:/Program files/swipl/doc/windows.html がありましたが、8.2.3-1 for Windows 64bit ではなくなっています)。 この翻訳についての正確性は保証しません。この翻訳を利用したことにより損害が発生したとしても、 訳者は一切責任を負いません。
SWI-Prolog の実行ファイル swipl-win.exe は スタートメニュー から起動するか、
Prolog プログラムテキストがある .pl
ファイルを Windows エクスプローラーで開くかする。
1
.PL ファイル拡張子は変更しうる。
3.2節参照。.
インストールされたフォルダ(デフォルトはC:\Program Files\swipl) には、
サブフォルダがあり、その中には likes.pl ファイルというデモファイルが含まれている。
Prolog のアプリケーションで下記のコマンドを入力する。
引用符を正しく入力し、コマンドはピリオド (.) で終了させること。
?- [swi('demo/likes')].
Prolog をスタートメニューから起動したときは、オプション--win_app
を通過している。
これはローカルの MyDocuments\Prolog
からスタートしたことを表す。もしこのフォルダがなければ作られる。
プログラムをロードしたあと、プログラムについて Prlog のクエリーを問うことができる。
次のクエリーは Prolog に `sam' が好きな食べ物を尋ねている。
このシステムは、ある
X についてのゴールが発見できれば X = <value>
の形で回答する。
他の回答が知りたければ、セミコロン (;) かスペースバーをタイプすればよい。
他の回答が不要であればreturnキーをタイプすればよい。
Prolog はフルストップ (.) を出力して出力を完了する。これは、
return がタイプされたときか
これ以上回答がないときである。
もし Prolog が回答を(これ以上)見つけられないときは、false を出力する。
最後に、Prolog はクエリーやプログラムにエラーがあればエラーメッセージを回答する。
?- likes(sam, X). X = dahl ; X = tandoori ; ... X = chips. ?-
Note that the answer written by Prolog is a valid Prolog program that, when executed, produces the same set of answers as the original program.
SWI-Prolog コンソールはswipl-win.exeで提供され、 よく使われるコマンドにアクセスするメニューがある。 全てのメニューを詳細に説明はしないものとする。とはいえ、例外もある。
swipl.ini
that contains commonly
used settings in comments.編集のオプションは3種類ある。One is to run an editor of choice in a separate window and use the make/0 command described below to reload modified files. In addition to this option Prolog can be used to locate predicates, modules and loaded files by specifying the editor of choice for use with the edit/1 command, described below. This is achieved by editing the personalisation file (see section 1.3) and following the instructions in the comments.
The default editor is the built-in editor called PceEmacs. This editor provides colourisation support based on real-time parsing and cross-reference analysis of the program.
Other options for editing include GNU-Emacs, SWI-Prolog-Editor and the Eclipse-based PDT environment. See http://www.swi-prolog.org/IDE.html for an up-to-date overview.
この節ではごく簡単に、環境を制御するための、重要な、また共通に使われる SWI-Prolog の述語を述べる。
\
, (エスケープが必要),
または、POSIX 標準である/
を使う。
ソースコードでは、互換性から /
を使うことを勧める。
Prolog のリスト ([ ... ]) は consult コマンドでは省略される。
ファイル拡張子 (.pl
他の拡張子も同様) は省略可能である. 以下例を述べる。
?- consult(likes). |
カレントフォルダ(pwd/0参照) から likes.pl をロードする。 |
?- ['C:/Program Files/pl/demo/likes'] |
絶対パスを使って likes.pl をロードする。 |
?- ['C: |
上記に同じ。Windows スタイルのパス名を使う。 |
.pl
file in the explorer,
edit this file. Also available from the menu.?- gtrace, run.
and finally you can include it in
your program to start tracing at a particular point or under a
particular condition:
..., (var(X) -> gtrace ; true), ...,
http://www.mingw.org にある MinGW やコンパチブルな参照フォーマットを使うことで、 C や C++ で書いたコードを SWI-Prolog に組み込んだり、述語として呼び出すことができたりする。 また、C/C++ のアプリケーションに SWI-Prolog を埋め込むこともできる。
Details on how to interact with Prolog are in the SWI-Prolog
reference manual. The mailing list archives and TWiki web provide
problems and solutions to the many problems that may occur.
Documentation of the SWI-cpp.h
C++ include file is
available from the package
documentation. This section only discusses some Windows-specific
issues.
現在の SWI-Prolog は MinGW でコンパイル・リンクしているので、 MSVC を使ったコンパイル拡張や SWI-Prolog を MSVC プロジェクトに組み込んだことについて、 はっきりしたことは言えない。
コメントは SWI-Prolog メーリングリストに出すか、 mailto:bugs@swi-prolog.org にメールすること(併用も可)。
First of all, add the include
folder of the installation
to the search path for headers and the lib
folder to the
search path for libraries. Both DLLs (extensions) or embedded
executables should link to
libswipl.dll.a
and, if appropriate, to the multithreaded
DLL version of the MSVC runtime library.
To create extensions, create a Win32 DLL. To embed Prolog, care
should be taken that Prolog can find the Prolog installation. For
development, the simplest way to ensure this is by adding インストール bin
folder to the %PATH%
environment and calling PL_initialise() as illustrated below. PL_initialise()
uses the path of the loaded libswipl.dll
module to find the
Prolog installation folder.2When
using the C++ interface from SWI-cpp.h
, these comments
apply to the arguments for PlEngine().
{ static char *av[] = { "libswipl.dll", NULL }; if ( !PL_initialise(1, av) ) { <error> } }
To create an executable that does not rely on Prolog one must create
a saved state of the required Prolog code and attach this to the
executable. Creating saved states is described with qsave_program/2
in the reference manual. This can be attached to a state using the DOS
command below to create final.exe
from the executable
produced by MSVC and the generated saved state.
> copy /b file.exe+file.state final.exe
The swipl-ld.exe automates most of the above complications and
provides compatibility for common tasks on many platforms supported by
SWI-Prolog. To use it with MinGW, set the PATH
environment
variables to include the SWI-Prolog binary folder as well as the MinGW
binary folders (typically C:\MinGW\bin
) to find
gcc. An extension myext.dll
can be created from the
source myext.c
using the command below. Add -v
to see what commands are executed by swipl-ld.exe.
> swipl-ld.exe -shared -o myext myext.c
An embedded executable is created from C, C++ and Prolog files using
> swipl-ld.exe -o myexe file.c ... file.pl ...
SWI-Prolog は Windows XP またはそれより後(XP, Vista, Windows-7) を必要とする。 SWI-Prolog のダウンロードサイトではこれより古い Windows バージョンで動く古いバイナリもある。 32 ビットと 64 ビットの両方のインストーラーを提供している。
デフォルトでは Prolog は拡張子に.pl
を使う。
残念なことに、この拡張子は Perl 言語と衝突する。
もし同じ Windows 機で両方のプログラムを動かしたいなら、 インストールで異なる拡張子を代替として選ぶことができる。
代替拡張子としては .pro
が一般に使われる。
互換性を問題となるのならば、この別拡張子はロードファイル、すなわち全体プログラムをロードするソースファイルにのみ用い、
ライブラリや他のファイルからロードされるファイルには通常の .pl 拡張子を用いることを勧める。
次表はインストールされたコンポーネントの一覧である。 (32-bits) or (64-bits) という注釈をつけているものもある。 この理由は 64 ビットバージョンは最近のツールでビルドしているので、 名前付け規約が異なるからである。将来は一緒になるだろう。
プログラム | |
bin\swipl-win.exe | Default Windows application for interactive use. |
bin\swipl.exe | Console-based version for scripting purposes. |
ユーティリティ | |
bin\swipl-ld.exe | Linker front-end to make single-file mixed Prolog/C/C++ executables. |
bin\swipl-rc.exe | Manipulate Prolog resource files. |
重要なディレクトリ | |
bin | Executables and DLL files |
library | Prolog library |
boot | Sources for system predicates |
include | C/C++ header files for embedding or to create extensions |
xpce | XPCE graphics system |
xpce\prolog\lib | XPCE/Prolog library |
DLL や他のサポートファイル | |
boot32.prc | Initial Prolog state (32-bits) |
boot64.prc | Initial Prolog state (64-bits) |
\bin\libswipl.dll | The Prolog kernel |
\bin\plterm.dll | The window for swipl-win.exe |
\bin\pthreadVC2.dll | POSIX thread runtime library (64-bits) |
拡張 DLL (プラグイン) | |
\bin\cgi.dll | Gather CGI GET and POST arguments |
\bin\double_metaphone.dll | Soundex (sounds similar) |
\bin\memfile.dll | In-memory temporary `files' |
\bin\odbc4pl.dll | ODBC interface |
\bin\plregtry.dll | Windows registry interface |
\bin\porter_stem.dll | Porter stemming implementation |
\bin\random.dll | Portable random number generator |
\bin\rdf_db.dll | RDF database |
\bin\readutil.dll | Fast reading utility |
\bin\sgml2pl.dll | SGML/XML parser |
\bin\socket.dll | Prolog socket interface |
\bin\table.dll | Access structured files as tables |
\bin\time.dll | Timing and alarm library |
\bin\xpce2pl.dll | The XPCE graphics system |
\bin\zlib1.dll | Compression library (32-bits) |
\bin\zlibwapi.dll | Compression library (64-bits) |
\bin\zlib4pl.dll | Compression library interface |
ファイルタイプ.pl
や選ばれた代替タイプ (section 3.2を見よ)は
swipl-win.exe と関連付けられている。
選ばれたフォルダ (デフォルト SWI-Prolog) はスタートメニューに加えアレ、
Prolog や他の関連ユーティリティへのショートカットを維持する。
以下のレジストリキーが使われている。64 ビットバージョンは Prolog
のかわりにProlog64
を使っている。同じマシンで 32 ビットと 64 ビット両方のインストールができるようにするためである。
注意:.pl
ファイルをオープンするのはインストールされた Prolog のバージョンに結び付けられたものだけである。
HKEY_LOCAL_MACHINE | |
fileExtension | Extension used for Prolog files |
group | Start menu group |
home | Installation directory |
HKEY_CURRENT_USER | |
Note: thread-windows store the same info in sub-keys | |
Height | Height of window in character units |
Width | Width of window in character units |
X | Left edge of window in pixel units |
Y | Top edge of window in pixel units |
SaveLines | Number of lines available for scrollback |
インストーラーは、(Vista 以降のバージョンで)ショートカットやレジストリーキーを書き込むレベルとして、
管理者
実行レベルを要求する。
If you want a desktop entry for SWI-Prolog, right-drag
swipl-win.exe to the desktop and select `Create shortcut'. Then
edit the properties and add --win_app
to the command line
to make the application start in MyDocuments\Prolog
.
The SWI-Prolog website is located at http://www.swi-prolog.org/.
The SWI-Prolog license allows it to be used in a wide variety of environments, including closed-source commercial applications. In practice, redistribution and embedding is allowed, as long as modifications to the SWI-Prolog source are published following the Free Software rules.
The SWI-Prolog kernel and foreign libraries are licensed under the Lesser General Public License (LGPL). The Prolog files are licensed under the normal General Public License GPL with an additional statement that allows for embedding in proprietary software:
As a special exception, if you link this library with other files compiled with a Free Software compiler to produce an executable, this library does not by itself cause the resulting executable to be covered by the GNU General Public License. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License.
This exception is a proven construct used for libgcc, the GNU C-compiler runtime library.
There are several ways to support SWI-Prolog:
Sponsoring development has several benefits: (1) it solves your bottlenecks, (2) others help debugging it, and (3) it strengthens SWI-Prolog's position, which gives you better guarantees that the system remains actively developed and makes it easier to find resources and programmers.