/Jalog

An interpreter for a Prolog-like language with Java-like arithmetic written in Java. For documentation and runtime support see https://github.com/JalogTeam/JalogTeam.github.io

Primary LanguageJavaOtherNOASSERTION

Jalog

An interpreter for a Prolog-like language with Java-like arithmetic written in Java

Jalog differs significanly from ISO Standard Prolog.

Prolog is a logic programming language associated with artificial intelligence and computational linguistics. [Wikipedia]

Jalog makes traditional artificial intelligence techniques available to a wide variety of devices and applications.

Version 1.5 2024-07-11

Other versions

Authors

Mikko Levanto
Ari Okkonen ari.okkonen@gmail.com

Download

In order to use Jalog you need Java runtime environment (JRE).

Get Jalog interpreter: Download JAR

New in 1.5

The main addition is reading and writing of text files.

New or improved predicates

  • closefile(SymbolicFileName)
  • consult(Filename)
  • consult_data(Filename, DatabaseName)
  • consult_dir(ConsultDirname)
  • deletefile(FileName)
  • dynamic(PredicateIndicator, DatabaseName)
  • existfile(FileName)
  • file_str(FileName, StringVariable)
  • include(Filename)
  • openappend(SymbolicFileName, FileName)
  • openread(SymbolicFileName, FileName)
  • openwrite(SymbolicFileName, FileName)
  • readdevice(SymbolicFileName)
  • readln(StringVariable)
  • save(FileName)
  • save(FileName, DatabaseName)
  • subchar(String, Position, Char)
  • term_str(Domain, Term, String)
  • writedevice(SymbolicFileName)

Usage

Stand-alone Jalog

X:>java -jar jalog.jar <compiler_options> <program_name> <program_arguments>

  <compiler_options>
      -v Show version information
      -r=name - Permits reading.
      -w=name - Permits writing.
      -m=name - Permits modifying, reading and writing.
      -a=name - Permits appending.
    The name can be a file name or a diretory name. If directory, refers to all
    files in the directory and subdirectories.
    The = character can be replaced with the : character.
    Multiple r, w, m, and a options are permitted.
  <program_name> - complete file name - no default extensions
  <program_arguments> - as the program needs them

This is shown when Jalog is run without parameters.

Integrated Jalog

A Jalog program can be called from a Java program. The purpose of this arrangement is to facilitate using Java for the input and output including the user interface, and the Prolog like language for problem solving and planning purposes.

Interface documentation

Demo example with Java main program and called Jalog program:

Jalog Sudoku Example

Demo examples about Android integration:

Simple interfacing example
Android integration of the Sudoku example

Intended use

Jalog gives ability to use Prolog style reasoning whereever Java can be used. Prolog helps the programmer to concentrate on the problem instead of the solution algorithm. Examples: finding routes, solving puzzles like Sudoku, ...

See examples in test directory for implemented features.

Jalog language

Annotated animated execution example - This shows step by step what happens when a Prolog program runs.

Jalog Quick Reference - Built in predicates explained.

Jalog Language Reference - Lays out the elements and the syntax of the language.

Other resources

Prolog material by Prof. Joseph Goguen

License

Jalog is distributed under The MIT License

Copyright (c) 2019 JalogTeam: Mikko Levanto, Ari Okkonen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Version history

1.5 2024-07-11 Added reading and writing of text files.

1.4.1 2024-03-13 Indexing in strings corrected

1.4 2023-09-07 More built-in predicates

1.3 2021-08-17 Integration to Android supported.

1.1.0 2021-02-02 More options for consult.

1.0.0 2020-08-25 First release

0.4 2019-08-06 Build system for jar file: build_jar.bat.

0.3 2019-07-24 Interface test completed and integrated to regression test.

0.2 2012-04-20 Minor corrections. Debug timing disabled.

0.1 2012-03-13 Initial version. Capable of solving Sudoku.