{"id":24289305,"url":"https://github.com/rla/llj","last_synced_at":"2026-05-29T12:31:37.248Z","repository":{"id":4213029,"uuid":"5333903","full_name":"rla/llj","owner":"rla","description":"LLJ - Logic Language for JVM","archived":false,"fork":false,"pushed_at":"2012-08-07T21:33:07.000Z","size":212,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T01:25:18.074Z","etag":null,"topics":["jvm","logic-language","programming-language","prolog"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-07T21:31:58.000Z","updated_at":"2019-08-13T15:07:23.000Z","dependencies_parsed_at":"2022-06-29T10:52:32.260Z","dependency_job_id":null,"html_url":"https://github.com/rla/llj","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rla/llj","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rla%2Fllj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rla%2Fllj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rla%2Fllj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rla%2Fllj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rla","download_url":"https://codeload.github.com/rla/llj/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rla%2Fllj/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33652979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jvm","logic-language","programming-language","prolog"],"created_at":"2025-01-16T10:51:50.876Z","updated_at":"2026-05-29T12:31:37.232Z","avatar_url":"https://github.com/rla.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"LLJ - Logic Language for JVM\n============================\n\nLLJ is Prolog-like logic language for running on JVM. It allows close\nintegration with Java libraries. LLJ was developed in 2008-2010. The\ncode is fairly commented and covered with various test cases.\n\nDifferences from real Prolog\n----------------------------\n\n* Code is loaded through Java classpath\n* Module names correspond to Java classpath entries\n* Syntax is based on UTF-8\n* Terms can be arbitrary Java objects\n* No term/goal expansion\n* No DCG's\n* No custom operators\n* Assert/retract can only be used for ground predicates\n* Most ISO-Prolog standard predicates are not implemented\n\nDependencies\n------------\n\nFor embedded usage there are no dependencies other than the Java Runtime Environment (\u003e= 1.6). The\ninteractive top-level command-line interface requires [jline](http://jline.sourceforge.net/) to be\nin the classpath.\n\nCompiling\n---------\n\nCompiling requires JDK (\u003e= 1.6) and Maven. Run Maven goal `mvn package` to build the jar\nfile into `target/llj.jar`.\n\nUsage\n-----\n\nExample module (queens benchmark):\n\n```prolog\n:- module(ee:pri:rl:llj:benchmark:queens, [\n\tqueens/2,\n\tcount/2\n]).\n\n:- import(llj:list).\n:- import(llj:lang).\n:- import(llj:findall).\n\ncount(N, C):-\n\tfindall(_, queens(N,_), L),\n\tlength(L, C).\n\nqueens(N,Qs) :-\n\trange(1,N,Ns),\n\tqueens(Ns,[],Qs).\n\nqueens([],Qs,Qs).\nqueens(UnplacedQs,SafeQs,Qs) :-\n\tselect(UnplacedQs,UnplacedQs1,Q),\n\tnot_attack(SafeQs,Q),\n\tqueens(UnplacedQs1,[Q|SafeQs],Qs).\n\nnot_attack(Xs,X) :-\n\tnot_attack(Xs,X,1).\n\nnot_attack([],_,_) :- !.\nnot_attack([Y|Ys],X,N) :-\n\tX =\\= Y+N, X =\\= Y-N,\n\tN1 is N+1,\n\tnot_attack(Ys,X,N1).\n\nselect([X|Xs],Xs,X).\nselect([Y|Ys],[Y|Zs],X) :- select(Ys,Zs,X).\n\nrange(N,N,[N]) :- !.\nrange(M,N,[M|Ns]) :-\n\tM \u003c N,\n\tM1 is M+1,\n\trange(M1,N,Ns).\n```\n\nExample code of using LLJ from Java:\n\n```java\npublic class MemberExample {\n\t\n\tpublic static void main(String[] args) throws LLJException {\n\t\n\t\t// Creates new LLJ context\n\t\tLLJContext context = new LLJContext(\"llj:list\");\n\t\t\n\t\t// Creates new LLJ query\n\t\tRuntimeQuery query = context.createQuery(\"member(X, [1,2,3])\");\n\t\t\n\t\t// Executes the query for the first answer\n\t\tif (query.execute()) {\n\t\t\tSystem.out.println(\"First answer: \" + query.getBinding(\"X\"));\n\t\t}\n\t\t\n\t\t// Tries to find more answers\n\t\twhile (query.hasMore()) {\n\t\t\tSystem.out.println(\"Also: \" + query.getBinding(\"X\"));\n\t\t}\n\t}\n}\n```\n\nThe `LLJContext` class is thread safe while `RuntimeQuery` must be used only by a single\nthread at once. Multiple `RuntimeQuery` classes can be executed at once on the same context\nat the same time.\n\nDefining predicates through Java code (this is example from `llj:io` module):\n\n```java\npublic class Io implements JavaModule {\n\n\t@Predicate(name=\"list_files\", arity = 2)\n\tpublic AbstractGoal listFiles2(JavaCallGoal goal) throws Exception {\n\t\tFile file = goal.getObject(0, File.class);\n\t\tgoal.setVar(1, RuntimeListStruct.fromArray(file.listFiles()));\n\t\t\n\t\treturn goal.G;\n\t}\n}\n```\n\nSimilar\n-------\n\n* [WProlog](http://waitaki.otago.ac.nz/~michael/wp/) is a Prolog implementation on JVM.\n  While it lacks cut, arithmetics, modules and arithmetics I got some of my implementation ideas from it.\n* [XProlog](http://www.iro.umontreal.ca/~vaucher/XProlog/AA_README) enhanced version of WProlog.\n\nAuthors\n-------\n\n* [Raivo Laanemets](https://github.com/rla)\n\nSome of the test cases were taken from example code\nof the excellent book [Learn Prolog Now!](http://www.learnprolognow.org/).\n\nLicense\n-------\n\nLLJ is distributed under LGPL license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frla%2Fllj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frla%2Fllj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frla%2Fllj/lists"}