Git Product home page Git Product logo

jiprolog's Introduction

JIProlog

JIProlog Logo

JIProlog is a Prolog interpreter, pure Java 100%, cross-platform and Open Source.

JIProlog offers a high degree of compliance with official and de facto Prolog standards. It also supports built-in predicates and other features common to major Prolog systems.

JIProlog enhances the Java platform by adding the power of Prolog language and extends Prolog by adding the Java framework.

JIProlog integrates Prolog and Java languages in a very fascinating way. It allows calling Prolog predicates from Java without dealing with native code (JNI) and allows invoking Java methods from Prolog as they were predicates.

JIProlog supplies a complete API to link Prolog and Java languages from both sides. The API is composed by three parts:

  • Java calls Prolog;
  • Prolog calls Java;
  • Prolog links JDBC databases.

By design, JIProlog is compliant with Web 3.0 and the mobile world.

Born in later 1998 from an idea by Ugo Chirico, JIProlog has been developed by using cutting edge technologies and following the needs of real world applications.

The home of JIProlog is: http://www.jiprolog.com

JIProlog is open source and it is release under AGPLv 3.0 or under commercial license.

The source code is available on GitHub: https://github.com/jiprolog/

See also:

jiprolog's People

Contributors

jasonm23 avatar jiprolog avatar pmoura avatar ugochirico 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

jiprolog's Issues

JIConsole keyboard gets confused after an error

I tried the new JIConsole. I could do a write(hello), nl. Then I tried
[user]. But the later didn't work. Then I tried again write(hello), nl,

but then the keyboard was confused I could not enter ( and ), instead
it showed me 8 and 9, when I pressed the corresponding keys. As it

happens, I am using a swiss keyboard.

grafik

Improved user experience feature

Each time I do some searching on the web about JVM implementation of Prolog, I get to this resource. And for about 3d time I find it almost unusable, mostly by lack of next common practices:

  • No 'Getting Started' page on http://www.jiprolog.com and no other kind of info as well. So a newcomer has to guess what to do.
  • No way (or at least easy/intuitive way) to access the jar library of the Prolog itself
  • No example of simple hello world program to start with by example

EOF should give the term end_of_file in read/1.

If I am not completely wrong, but according to the ISO core
standard, read/1 should give end_of_file when EOF. It seems$

you return an empty list. I get end_of_file when I use get_char/1,
but with read/1 I don't get end_of_file when I press ^D return.

grafik

Add API code in JIPEngine

public Collection getGlobalDataBase() { Collection databases = new Vector(); for (JIPClausesDatabase jipClausesDatabase : m_globalDB.m_clauseTable.values()) { databases.add(jipClausesDatabase); } return databases; }

public boolean clause(final JIPTerm term) { Collection databases = getDataBase(); for (JIPClausesDatabase jipClausesDatabase : databases) { Enumeration enumeration = jipClausesDatabase.clauses(); while (enumeration.hasMoreElements()) { Clause clause = (Clause) enumeration.nextElement(); JIPClause jipClause = new JIPClause(clause); if (term.unifiable(jipClause)) { return true; } } } return false; }

public Collection getDataBase() { Collection databases = new Vector(); for (JIPClausesDatabase jipClausesDatabase : m_globalDB.m_clauseTable.values()) { if (jipClausesDatabase.isDynamic()) { databases.add(jipClausesDatabase); } } return databases; }

External Library

Currently the interpreter fails to load external libraries. eg :-include("csv.pl"). or use_module(library(csv)).

Any help is deeply appreciated.
Thanks

Debug output on query

Trying out jiprolog for the first time (old time prologer from the 1970s). Doing the tutorial I get a series of debug messages before my code executes (hello world).

fail env(debug,on)
fail var(1150)
fail fail
fail <(1150,0)
fail >(1150,1200)
fail ;(<(1150,0),>(1150,1200))
fail var(fx)
fail fail
fail fail
fail operator_specifier(fx,infix)
fail operator_specifier(fx,postfix)
fail fail
fail var(400)
fail fail
fail <(400,0)
fail >(400,1200)
fail ;(<(400,0),>(400,1200))
fail var(fx)
fail fail
fail fail
fail operator_specifier(fx,infix)
fail operator_specifier(fx,postfix)
fail fail
hello world

I attempted to rebuild the project myself, but the ant script seems incomplete. Advise.

quicksort example hangs, no way to kill it?

I started running my benchmarks on JIProlog. I noticed that
the predicate qsort cannot be redefined. So I renamed it to
quicksort. But then the benchmark hangs at quicksort:

grafik

I also didn't find a way to kill it, except closing the window.

Flag domain_error

According to my very limited understanding of Prolog flags, the following should work (i.e., test(A) should have one solution, A = 1, and then there should be no more solutions) :

:- create_prolog_flag(test_flag, true, []).

test(A) :-
  current_prolog_flag(test_flag, true),
  A = 1
  .

But instead, while I do get the one solution I expect, I then get an error, like so:

Exception in thread "main" com.ugos.jiprolog.engine.JIPRuntimeException: error(domain_error(prolog_flag,test_flag),context(error(domain_error(prolog_flag,test_flag)),file(undefined,0)))
	at com.ugos.jiprolog.engine.H.unify(Error1.java:35)
	at com.ugos.jiprolog.engine.i.a(BuiltIn.java:38)
	at com.ugos.jiprolog.engine.BuiltInPredicate.a(BuiltInPredicate.java:79)
	at com.ugos.jiprolog.engine.PrologObject.b(PrologObject.java:84)
	at com.ugos.jiprolog.engine.aX.a(WAM.java:413)
	at com.ugos.jiprolog.engine.aX.b(WAM.java:179)
	at com.ugos.jiprolog.engine.JIPQuery.nextSolution(JIPQuery.java:84)
	at jiptest.Main.main(Main.java:46)

Am I doing something wrong? It seems like incorrect behavior to throw an error, here.

JIProlog 4.1.6.1

Non-conforming `writeq/1`

* JIProlog - Java Internet Prolog
* Version: 3.1.0-2
* Copyright (c) 1999-2007 By Ugo Chirico.
* All rights reserved
* http://www.ugosweb.com/jiprolog
* License: Shareware
***************************************

JIP:-writeq((*)=(*)).
* = *Yes

JIP:-writeq('/*').
/*Yes

JIP:-

See #27 and #35 for expected results.

((See above link for more))

Package/Documentation Issues

First try with JIProlog leaves me stuck.

  • Version 4.1.5.1 has no download of the complete release, only the library jar file. No instructions anywhere on how to get to run a console.
  • Downloaded Version 4.1.4.1, which has a complete release including console and samples.
  • Tried JDBC connection as outlined in the wiki and sample files. Copy and paste from sample file gives:

JIP:-extern(employee/4, "com.ugos.JIProlog.extensions.database.TextClausesDatabase", "c:/JIProlog30/samples/ExternalDB/employee.txt"). error(existence_error(procedure,'com.ugos.JIProlog.extensions.database.TextClausesDatabase'),context(extern(/(employee,4),'.'(...), '.'(...)),file(undefined,0)))
To me, this reads as if the TextClausesDatabase class is nowhere to be found. Wiki mentions jpixdb.jar, but this is nowhere to be found.

How to proceed?

Bug when writing a % character

With JIProlog 4.1.6.1:

JIP:-write_canonical('%'), nl.
%
Yes

But it should be:

JIP:-write_canonical('%'), nl.
'%'
Yes

This bug breaks the logtalk_tester script in Logtalk 3.36.0.

read_term/3 bug when reading the end of file

JIProlog 4.1.6.1 and previous versions have a read_term/3 bug when reading the end of file. If the option variable_names/1 is used, its value is not bound by the call. This bug results in an instantiation error when the Logtalk compiler tries to report variable naming issues.

Built-in predicate request: function_property/2

Latest versions of LVM and Trealla Prolog implement a function_property/2 built-in predicate, which provides similar functionality to the de facto standard predicate_property/2 built-in predicate, allowing checking or enumerating the properties of a given arithmetic function. The function_property/2 predicate allows clean checking if an arithmetic function is defined, simplifying e.g. portability linter checks for arithmetic expressions. The first argument is a function template (e.g. abs(_)) and the second argument is the property. Four properties are specified:

  • built_in (function is a defined built-in arithmetic function)
  • foreign (function is a defined arithmetic function implemented using the FLI)
  • static (function is a static arithmetic function)
  • dynamic (function is a dynamic arithmetic function)

The dynamic is meant for Prolog systems that allow runtime definition of new arithmetic functions (e.g. LVM). Built-in and foreign functions usually also have the static property.

The predicate spec is:

Template:
function_property(Function, Property)
Modes and number of proofs:
function_property(+callable, ?function_property) - zero_or_more

Exceptions:

  • Function is a variable:
    instantiation_error
  • Function is neither a variable nor a callable term:
    type_error(callable, Function)
  • Property is neither a variable nor an atom:
    type_error(atom, Property)
  • Property is an atom but not a valid function property:
    domain_error(function_property, Property)

Examples:

Check that popcount/1 is a built-in arithmetic function:

?- function_property(popcount(_), built_in).
true.

Would it be possible to add this predicate to JIProlog?

Non conforming div/2 function implementation

In JIProlog 4.1.6, the implementation of the ISO Prolog standard div/2 arithmetic function is not compliant. E.g. wrongly returning a float instead of an integer:

JIP:- N is 4 div 2.
Yes
N = 2.0

See the latest Logtalk git version for a set of tests for this function (in tests/prolog/predicates/is_2).

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.