Coder Social home page Coder Social logo

amzils / amziprolog Goto Github PK

View Code? Open in Web Editor NEW
114.0 15.0 24.0 17.18 MB

Amzi! Prolog: complete system to interpret, build, run and debug Prolog programs, but also embed and query them similar to databases.

License: Other

Prolog 8.84% HTML 4.11% C++ 53.23% C 3.33% Batchfile 0.06% Makefile 1.80% Pascal 1.12% Java 12.59% VBA 1.21% CSS 0.02% Tcl 13.68%
prolog ide eclipse-plugin virtual-machine logic-programming

amziprolog's Introduction

Amzi! Prolog

Source code for the entire Amzi! Prolog system.

Amzi! Prolog is made of the following:

  • Prolog Virtual Machine -- Warren Abstrace Machine (WAM)
  • Logic Server -- a runtime library wrapping around the Prolog-VM, for executing, modifying, and interacting with compiled Prolog programs
  • C API and foreign language bindings -- the Logic Server API (LSAPI) to embed Logic Server into C and other languages, to allow:
    • asserting or retracting clauses (facts or rules) and querying logic bases
    • calling Prolog predicates
    • type specific operations on data (for lists and structures)
    • converting data between the host language and Prolog
    • adding extended predicates, and manipulating their parameters
    • error handling
  • Logic Server Extensions -- .lsx files that provide extended predicates/functions, implemented in other languages
  • Command line tools -- to interpret and debug (alis), compile (acmp), link (alnk) and execute (arun) Prolog programs
    • The Prolog listener alis is an interactive interpreter; the process is aka. REPL.
  • Eclipse IDE plugin -- for comfortable compiling, linking, and debugging

File types:

  • .pro -- Prolog source code (program or module)
  • .plm -- Compiled Prolog module (Prolog/WAM byte code file -- machine independent)
  • .xpl -- Executable Prolog library (a linked collection of .plm files)
  • .lsx -- Logic Server extension (a renamed DLL/SO file)

Common terms:

  • Logic base = knowledge base = Prolog program
  • The Logic Server is a service, with an interface similar to a database server, which allows to query and update the logic base (= Prolog program).
  • Loading of a source code file (.pro), then interpreting it, is called "consulting". This is in contrast to compiled files (.plm/.xpl), which are simply said to be "loaded".
    • Note: neither loading compiled code, nor consulting source code, will automatically execute the main/0 predicate -- use arun if you want that.

See also: Amzi! Prolog Quick Overview and the Detailed Amzi! Prolog Overview

Documentation

User's Guide and Reference
Programmer's Guide
Logic Server User's Guide and Reference

Prolog Articles / Whitepapers
Adventure in Prolog -- A tutorial/guided tour through Prolog
Building Expert Systems in Prolog -- An advanced tutorial

Eclipse

Videos:

Articles:

Repository Contents

The /engine folder contains Amzi! Prolog's core, made of the Prolog-VM and the Logic Server runtime library. The Logic Server's primary API is exposed in C and found under /engine, but has also various foreign language bindings found under /langbindings.

The Prolog compiler, listener, and runner are found under /run. acmp, arun, and alis are the exact same executable, their actual purpose is identified by their filename only:

  • for arun, the engine/Logic Server simply executes the passed .xpl file
  • for alis it loads alis.xpl (source under /listen)
  • for acmp it loads acmp.xpl (found under /compile and the source under https://github.com/AmziLS/AmziPrologCompiler)

/linkrun contains the source for the Prolog linker. /libs contains Prolog libraries that will be compiled to .plm files.

A core extension to Prolog -- which provides OS related functions for handling files, directories, environment variables, and displaying message boxes -- is available under /extensions/osutils. Non-core extensions exist for ODBC, MySQL, Tcl/Tk, and sockets, which can be found in the /extensions folder.

Examples for all core Prolog uses, language bindings, and Prolog extensions are available under /samples.

Finally, apart from a simple Windows IDE (under /winIDE), there is also an Eclipse plugin that provides a more complete experience, found under /eclipse_plugin.

Building and Debugging

For building the whole system, see the /make subdirectory.

It is also possible to load the .sln files in Visual Studio for debugging.

  1. Make sure to adapt bin/amzi_vars_win32.bat and bin/amzi_vars_win64.bat to match the installation paths of the installed dependencies (as mentioned in the building instructions).
  2. Start Visual Studio from either Amzi Prolog 32 Bit Environment (Source).lnk or Amzi Prolog 64 Bit Environment (Source).lnk command line environments, to ensure all the necessary paths are set.
    • Enter devenv to start Visual Studio.

Releases

Releases are available as usual on GitHub, on the right side bar. They contain the built runtime library, and command line tools, but also samples, language bindings, Logic Server extensions, and a ready to use Eclipse plugin. It's the easiest way to get started.

License

Copyright (c) Amzi! inc. 2016, 2021
Licensed under the MIT Open Source License.

amziprolog's People

Contributors

bryant1410 avatar dennismerritt avatar fahadash avatar maelh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amziprolog's Issues

Some language bindings are not copied to the release directory

Currently, I am trying to fix the build system, so it can produce a ZIP release closely matching the previous ones.

Later, the issue where some language bindings do not get copied to \release, and therefore do not end up in a ZIP release, needs to be fixed as well.

Change repo's name to be something eyeball friendly

Generic words like 'distribution', 'interfaces' are not descriptive enough, they will cause a lot of confusion in search results. IMO, this repo's name should be something like 'amzi-prolog-distribution', and interfaces should be 'amzi-prolog-interfaces' Just a sugguestion

Linux Version

The current make files can be used to build on the Mac and Windows 32 and 64 environments. There are make files for Cent OS 64, but they haven't been brought up to date for release 10. With some modification (using the Mac files as examples) they could be used to build on any Unix platform.

--Dennis

Use msbuild instead of devenv in makefiles

Msbuild clutters the output with a lot of messages, and works slightly differently, which is why I kept the use of devenv.exe for now.

But switching eventually is a good idea, as msbuild deals better with usernames that have non-ASCII characters in it (devenv.exe will fail with strange error messages with such user names -- tracking that was the cause took a while).

Consider upgrading toolset and target platforms

The current Toolset (MSBuild version) the amzinet points to is 4.0 which is Visual Studio 2010/2012 and is old. The binaries built using old toolset did not work for me on Microsoft Azure, I have upgraded the toolset on my fork to 14.0 which is Visual Studio 2015 and it works.

Create a Nuget package for amzinet

The library amzinet cannot work with .NET Core because .NET Core prefers to work with libraries coming through Nuget packages as opposed to files placed in the directory.

The Nuget package has to be authentic and come from Amzi's official Nuget account on www.nuget.org to be trusted. The package should also include amzi.dll and a powershell script to add amzi.dll to the project and set the Build Action to Content and the Copy-To-Output-Directory to Copy Always

docs/make*.txt should also copy docs/winIDE

docs/winIDE should be copied to release/docs and to eclipse_plugin/workspace/com.amzi.prolog.help/doc

Also make sure that *_tox.xml files are in the appropriate location. wide_toc.xml for example is outdated and should not be there, instead the new version winIDE_toc.xml should replace it. But the location of the files in eclipse_plugin/workspace/com.amzi.prolog.help/ and docs/ don't match. Make sure this difference in placement is correct (and the missing files, too).

Socket connection logic server

Hello,
I am Joost Klep and I am developing a new program for diagnosis of arithmetical problems in primary education.
We installed Amzi-Prolog in Eclipse, and we try to start the sserver and sclient from
interfaces/samples/internet/sockets/.
Unfortunately we cannot find how to establish the connection.

We try this amzi-prolog code for the server side:

:- loadlsx(asock).
:- load(asock).

sdefine('SOCK_STREAM', 1).
sdefine('INADDR_ANY', 0).

main :-
write( main_0 ), nl,
wsaStartup(0x0101, Ver, HighVer, Desc, Status, MaxSockets, MaxUdpDg),
write( main_1 ), nl,
sdefine('SOCK_STREAM', SOCK_STREAM),
socket(SOCK_STREAM, 0, Sock),
write( main_3: Sock), nl,
sdefine('INADDR_ANY', INADDR_ANY),

MyPort = 50530,

writeq( main_4: bind(Sock, INADDR_ANY, MyPort)), nl,
bind(Sock, INADDR_ANY, MyPort),
write( main_5: Sock), nl,
listen(Sock, 1),
write( main_6:listening), nl,
repeat,
select([Sock], [Sock], [Sock], 0, 0, ReadList, WriteList, ErrorList),
catch(doreads(ReadList), X, endmain(Sock, X, Quit)),
Quit == yes.

endmain(Sock, X, yes) :-
closesocket(Sock),
wsaCleanup.

doreads([]).
doreads([Sock | Rest]) :-
accept(Sock, RAddr, RPort, NewSock),
send(NewSock, $Hello Client$, 0, NumSent),
recv(NewSock, Cmd, 4096, 0, NumRecv),
write(Cmd), nl,
closesocket(NewSock),
(Cmd == $shutdown$ ->
write($Shutting down server ...\n$),
throw(shutdown)
;
true
),
doreads(Rest).

And for the client side we use:

% NOTE!!! Uncomment the appropriate sdefine for your environment
% Linux & Windows
:- load( asock).

sdefine('SOCK_STREAM', 1).
% Solaris
%sdefine('SOCK_STREAM', 2).

main :-
wsaStartup(0x0101, Ver, HighVer, Desc, Status, MaxSockets, MaxUdpDg),
write( main_1), nl,
inet_addr($my personal ip addr$, NetAddr),
write( main_2:NetAddr), nl,
sdefine('SOCK_STREAM', SOCK_STREAM),
write( main_3:SOCK_STREAM), nl,
socket(SOCK_STREAM, 0, Sock),
write( main_4:Sock), nl,
connect(Sock, NetAddr, 50501),
write($Send what? $), read_string(Str),
send(Sock, Str, 0, NumSent),
recv(Sock, Buf, 4096, 0, NumRecv),
write(Buf),
closesocket(Sock),
wsaCleanup.

We hope anyone can help us, maybe by giving another example?
Question: are there any modules not working propery in windows 10?

Joost

samples/ here and samples/ in ZIP files in distribution repo differ

Probably all, but the Prolog samples should be moved to the samples/ dir in the interface repository, for a cleaner separation.

Currently samples are spread across various places, some containing more languages/projects than others.

Ideally, the apls distribution would only contain the core distribution, with a reference where to find more, if desired (i.e., by downloading the interface ZIP).

Makefiles choke sometimes on * and \ characters

For example langbindings\java\make_win64.txt

Would not execute @-sildel /Q amzi\ls\*.class properly and instead execute @-sildel /Q amzi\ls*.class, i.e., omitting one backslash, and therefore fail. Addiing quotes around "amzi\ls\*.class" fixed the issue.

There might be other places in makefiles, that are affected by it. Before changing them all, look up how GNU make handles paths and * and \ etc. under Windows.

Reenable _eclipse_plugin target when IDE plugin is merged

The _eclipse_plugin target in make\make_winXX.txt is temporarily disabled/commented out.

Reenable it when the eclipse IDE plugin is merged with the AmziPrologCore repository.

Also make sure to fix the issue where ".eclipseextension" is copied to "eclipse" in docs\make_winXX.txt, because the "eclipse" folder does not exist.

PHP and ?

Currently there are only two ways to connect Amzi! to Web applications. The CGI interface and the Java interface.

It would be nice if you could call Prolog from PHP. I've looked at this a little bit, and it seems both straight forward and difficult, as it requires rebuilding PHP as well, I think. Anyway, it would be nice to have Prolog better connected to the Web.

Other Web tools might also be appropriate as well.
--Dennis

Problem loading an amzi! prolog xpl file from a vba program

Problem loading an amzi! prolog xpl file from a vba program
I have a program that used an xpl compiled from an old version fo Amzi! prolog. Any use of that prolog or of the xpl says that the activation had been made too long ago and that I should reactivate that prolog. That prolog is installed on a PC whose network card doesn't work, so I cannot reactivate that prolog because of that. A technician intalled other partitions of win10 to which i cannot move the old prolog.

So I download the latest version of Amzi prolog to another pc with win11. I rebuilt the xpl file with the new prolog. when I run my program, the call to load the amzi.dll works (at last!), but when the program tries to load the xpl file i get a -1 error code. The absolute path of the xpl file mentioned in the program is identical to the one of the xpl file. Any solution? I must settle that rapidly

amzi_apls_win64 lacks atcltk.lsx

Present versions of 64 bit Amzi! Prolog don't have in binary distro the module atcltk.lsx.

I surmise it is not by design because the 32 bit version has it.

Possibly create source distribution analogon for `Configure Amzi Dirs (Release).bat`

When starting Visual Studio for compiling Amzi source code or starting Eclipse for plugin development, it is necessary to have a valid AMZI_DIR among other environment variable directories (see bin/amzi_vars_winXX.bat).

A file Configure Amzi Dirs (Source).bat would set such vars, without having to start Visual Studio (or Eclipse) from the command line as suggested now in the readme: https://github.com/AmziLS/AmziProlog#building-and-debugging

merge docs and \eclipse_plugin\workspace\com.amzi.prolog.help\doc

The directories match paritally, but not completely. WinMerge shows some files/folders missing in each of the compared directories.

docs\make_win64.txt copies some files from docs to \eclipse_plugin\workspace\com.amzi.prolog.help\doc

Look if it makes sense to remove the \eclipse_plugin\workspace\com.amzi.prolog.help\doc from version control, or at least ignore this folder, as it gets fully created by docs\make_win64.txt

How to install amziProlog on macos

Hi, I am a new guy to use AmziProlog. I found that there is no release for amziprolog on macos 12.1. I read the doc https://github.com/AmziLS/AmziProlog/blob/master/devdocs/amzi_build.md, and run make -f make_mac64.txt in compile directory. It reports

acmp alib
make: acmp: No such file or directory
make: *** [/abin/alib.plm] Error 1

Then I run make -f make_mac64.txt in make directory,. It reports:

find  -name *.o -exec rm {} \;
find: illegal option -- n
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
make: *** [dirs] Error 1

How to compile and install amziProlog on macos?
Thanks very much!

IDE plug-in is out-of-date

The Amzi! plug-in for Eclipse is out-of-date and brittle. It currently builds the plug-in on my Mac computer, but, for example, doesn't build under Windows. I don't know why. It also fails to build the stand-alone version of the Amzi! development environment, although it used to. I'm not sure what's changed. I'm looking for someone who understands Eclipse RCP development to get this project building smoothly on current versions of Eclipse.

(The old version, distributed with the 9.x release of Amzi!, works fine. The problem is rebuilding it.)
--Dennis

.NET "Any CPU" binaries not found

The Windows Binaries for amzinet.dll is built on AMD processor architecture and do not work on x64 or x86. Build one with "Any CPU" configuration. Assemblies referencing amzinet.dll are getting runtime errors.

Release configuration is broken for amzinet

The dotnet wrapper 'amzinet' is still broken because it is seeking an 'AMZI_DIR' directory in the environment which is not defined. This must be inherited from how the development work was done on this previously. I am simply going to define AMZI_DIR to point at the same lib directory that AMZI_DEV_DIR points to since lib contains release package anyway.

Linux Installation -- requesting clarifications

Hi everyone

I follow the instructions to install the AMZI by a makefile from Centos. The instructions that I followed are from:
https://github.com/AmziLS/apls/blob/master/devdocs/amzi_build.md
including a directory under /opt/amzi/apls ... et all.
I tried to do it as superuser (root). For 3 times, this makefile corrupted my system in /bin and /usr/bin , probably some warning should be include in that Makefile suggested: "do not use it as root" or something like that.

Well, in addition, could you provide a installation step-by-step, once that some variables from this make is unclear
see these lines:
..................................
SOURCE=$(APLS_SOURCE)
SUBDIRS = engine run link listen compile
RELEASE=$(APLS_RELEASE)
.................................
Normally, in SOURCE cames the path where the files to be compiled ...
if I did a clone of apls in /opt/amzi/
whose are the contents for APLS_SOURCE and APLS_RELEASE?
Well, someone can help me in this installation under any Linux?

Claudio

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.