{"id":13537468,"url":"https://github.com/tuProlog/2p-kt","last_synced_at":"2025-04-02T04:30:53.797Z","repository":{"id":36992801,"uuid":"230784338","full_name":"tuProlog/2p-kt","owner":"tuProlog","description":"A Kotlin Multi-Platform ecosystem for symbolic AI","archived":false,"fork":false,"pushed_at":"2025-03-26T02:53:07.000Z","size":12625,"stargazers_count":100,"open_issues_count":90,"forks_count":15,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T01:08:42.329Z","etag":null,"topics":["2p","java","javascript","js","jvm","kotlin","kotlin-multi-platform","kotlin-multiplatform","logic-programming","prolog","simbolic-ai","symbolic","tuprolog"],"latest_commit_sha":null,"homepage":"http://tuprolog.unibo.it","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuProlog.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.md","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-29T17:51:34.000Z","updated_at":"2025-03-22T08:31:20.000Z","dependencies_parsed_at":"2023-10-02T07:50:42.772Z","dependency_job_id":"dc564203-75fe-4567-894e-be44594e3c17","html_url":"https://github.com/tuProlog/2p-kt","commit_stats":{"total_commits":3189,"total_committers":17,"mean_commits":"187.58823529411765","dds":0.4672311069300721,"last_synced_commit":"037ff662e752118fd831304c9ed8fd77d8e9e87b"},"previous_names":[],"tags_count":189,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuProlog%2F2p-kt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuProlog%2F2p-kt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuProlog%2F2p-kt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuProlog%2F2p-kt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuProlog","download_url":"https://codeload.github.com/tuProlog/2p-kt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246756977,"owners_count":20828804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["2p","java","javascript","js","jvm","kotlin","kotlin-multi-platform","kotlin-multiplatform","logic-programming","prolog","simbolic-ai","symbolic","tuprolog"],"created_at":"2024-08-01T09:00:59.383Z","updated_at":"2025-04-02T04:30:48.785Z","avatar_url":"https://github.com/tuProlog.png","language":"Kotlin","readme":"# 2P-Kt\n\n### Some quick links:\n\n* [Home Page](http://tuprolog.unibo.it)\n* [GitHub Repository](https://github.com/tuProlog/2p-kt) (public repository)\n* [GitLab Repository](https://gitlab.com/pika-lab/tuprolog/2p-in-kotlin) (dismissed)\n* [NPM Repository](https://www.npmjs.com/org/tuprolog) (where JS releases are hosted)\n* [Maven Central Repository](https://search.maven.org/search?q=g:it.unibo.tuprolog) (where all stable releases are hosted)\n* [GitHub Maven Repository](https://github.com/orgs/tuProlog/packages?repo_name=2p-kt) (where all releases are hosted, there including dev releases)\n* [Documentation](http://pika-lab.gitlab.io/tuprolog/2p-in-kotlin/) (work in progress)\n* [Presentation](https://github.com/tuProlog/2p-kt-presentation/releases/latest) (currently describing the main API of 2P-Kt)\n\n## Intro\n\n![The 2P logo](https://raw.githubusercontent.com/tuProlog/2p-kt/master/.img/logo.png)\n\n[tuProlog](https://www.cs.nmsu.edu/ALP/2013/10/tuprolog-making-prolog-ubiquitous/) (2P henceforth) is a multi-paradigm \nlogic programming framework written in Java.\n\n2P-Kt is a Kotlin-based and multi-platform reboot of 2P.\nIt consists of an open ecosystem for Symbolic Artificial Intelligence (AI).\nFor this reason, 2P-Kt consists of a number of incrementally inter-dependent modules aimed at supporting symbolic \nmanipulation and reasoning in an extensible and flexible way.\n\nA complete overview about modules and their dependencies is provided by the following diagram: \n\n![2P-Kt project map](https://gitlab.com/pika-lab/tuprolog/2p-in-kotlin/raw/master/.img/project-map.png)\n\nAs shown in the project map, 2P-Kt currently focuses on supporting knowledge representation and automatic reasoning through logic programming, \nby featuring:\n\n* a module for logic terms and clauses representation, namely `core`,\n\n* a module for logic unification representation, namely `unify`,\n\n* a module for in-memory indexing and storing logic theories, as well as other sorts of collections of logic clauses, namely `theory`,\n\n* a module providing generic API for resolution of logic queries, namely `solve`, coming with several implementations \n(e.g. `solve-classic` and `solve-streams`, targetting Prolog ISO Standard compliant resolution),\n\n* a module providing generic API for the probabilistic resolution of logic queries via _probabilistic logic programming_\n  (PLP), namely `solve-plp`, coming with an implementation targetting [ProbLog](https://dtai.cs.kuleuven.be/problog/) \n  (`solve-problog`)\n  - leveraging on module `:bdd`, which provides a multi-platform implementation of [binary decision diagrams](https://en.wikipedia.org/wiki/Binary_decision_diagram) (BDD) \n\n* a module providing OR-concurrent resolution facilities, namely `solve-concurrent`, \n    \n* a number of modules (i.e., the many `dsl-*` modules) supporting a Prolog-like, Domain Specific Language (DSL) \naimed at bridging the logic programming with the Kotlin object-oriented \\\u0026 functional environment,\n  - further details are provided in [this paper](http://ceur-ws.org/Vol-2706/paper14.pdf)\n\n* two parsing modules: one aimed at parsing terms, namely `parser-core`, and the other aimed at parsing theories, \nnamely `parser-theory`,\n\n* two serialisation-related modules: one aimed at (de)serialising terms and clauses, namely `serialize-core`, and the \nother aimed at  (de)serialising terms theories, namely `serialize-theory`,\n\n* a module for using Prolog via a command-line interface, namely `repl`,\n\n* a module for using Prolog via a graphical user interface (GUI), namely `ide`,\n\n* a module for using PLP (and, in particular, ProbLob) via a GUI, namely `ide-plp`.\n    \nThe modular, unopinionated architecture of 2P-Kt is deliberately aimed at supporting and encouraging extensions towards \nother sorts of symbolic AI systems than Prolog---such as ASP, tabled-Prolog, concurrent LP, etc.\n\nFurthermore, 2P-Kt is developed as in _pure_, __multi-platform__ Kotlin project. \nThis brings two immediate advantages:\n1. it virtually supports several platforms, there including JVM, JS, Android, and Native (even if, currently, only JVM, \nJS and Android are supported),\n2. it consists of a very minimal and lightweight library, only leveraging on the Kotlin _common_ library, as it cannot \ncommit to any particular platform standard library.\n\n## Users\n2P-Kt can either be used as a command-line program or as a Kotlin, JVM, Android, or JS library.\n\nThe 2P-Kt executables are currently available for download on the [Releases section](https://github.com/tuProlog/2p-kt/releases) of the\nGitHub repository.\n\nThe 2P-Kt modules for JVM, Android, or Kotlin users are currently available for import \non [Maven Central](https://search.maven.org/search?q=g:it.unibo.tuprolog), under the `it.unibo.tuprolog` group ID (not \nto be confused with the `it.unibo.alice.tuprolog`, which contains the old Java-based implementation).\nThe same modules are available through an _ad-hoc_ [Maven repository](https://github.com/orgs/tuProlog/packages?repo_name=2p-kt) as well, \nhosted by GitHub.\n\nThe 2P-Kt modules for JS users, are available for import on NPM, under the [`@tuprolog` organization](https://www.npmjs.com/org/tuprolog).\n\n### End users\n\n#### Graphical User Interface\n\nIf you need a GUI for your Prolog interpreter, you can rely on the 2P-Kt IDE which is available on the [Releases section of the \nGitHub repository](https://github.com/tuProlog/2p-kt/releases). \n\nThe page of the [latest release](https://github.com/tuProlog/2p-kt/releases/latest) of 2P-Kt exposes a number of _Assets_.\nThere, the one named:\n```\n2p-ide-VERSION-redist.jar\n```\nis the self-contained, executable Jar containing the 2P-Kt-based Prolog interpreter (`VERSION` may vary depending on the\nactual release version).\n\nAfter you download the `2p-ide-VERSION-redist.jar`, you can simply launch it by running:\n```bash\njava -jar 2p-ide-VERSION-redist.jar\n```\nHowever, if you have properly configured the JVM on your system, it may be sufficient to just double-click on the \naforementioned JAR to start the IDE.\nIn any case, running the JAR should make the following window appear:\n\n![A screenshot of the 2P-Kt IDE](https://gitlab.com/pika-lab/tuprolog/2p-in-kotlin/raw/master/.img/2p-kt-ide.png)\n\nThere, one may query the 2P-Kt Prolog interpreter against the currently opened theory file, which can of course be \nloaded from the user's file system by pressing \u003ckbd\u003eFile\u003c/kbd\u003e and then \u003ckbd\u003eOpen...\u003c/kbd\u003e.\n\nTo issue a query, the user must write it in the query text field, at the center of the application.\nBy either pressing \u003ckbd\u003eEnter\u003c/kbd\u003e while the cursor is on the query text field, or by clicking on the \u003ckbd\u003eSolve\u003c/kbd\u003e \n(resp. \u003ckbd\u003eSolve all\u003c/kbd\u003e) button, the user can start a new resolution process, aimed at solving the provided query.\nFurther solutions can be explored by clicking on the \u003ckbd\u003eNext\u003c/kbd\u003e (resp. \u003ckbd\u003eAll next\u003c/kbd\u003e) button over and over again.\nThe \u003ckbd\u003eNext\u003c/kbd\u003e (resp. \u003ckbd\u003eAll next\u003c/kbd\u003e) button shall appear in place of \u003ckbd\u003eSolve\u003c/kbd\u003e (resp. \u003ckbd\u003eSolve all\u003c/kbd\u003e)\nif and when further solutions are available for the current query.\n\nOne may also compute all the unexplored solutions at once by clicking on the \u003ckbd\u003eSolve all\u003c/kbd\u003e \n(resp. \u003ckbd\u003eAll next\u003c/kbd\u003e) button.\nAvoid this option in case of your query is expected to compute an unlimited amount of solutions.\n\nTo perform a novel query, they user may either:\n- write the new query in the query text field, and then press \u003ckbd\u003eEnter\u003c/kbd\u003e, or\n- click on the \u003ckbd\u003eStop\u003c/kbd\u003e button, write the new query in the query text field, and then press the \u003ckbd\u003eSolve\u003c/kbd\u003e \n  (resp. \u003ckbd\u003eSolveNext\u003c/kbd\u003e) button again.\n  \nThe \u003ckbd\u003eReset\u003c/kbd\u003e button cleans up the status of the solver, clearing any side effect possibly provoked by previous\nqueries (including assertions, retractions, prints, warnings, loading of libraries, operators, or flags).\n\nFinally, users may inspect the current status of the solver by leveraging the many tabs laying at the bottom of the IDE.\nThere,\n- the _Solutions_ tab is aimed at showing the Prolog interpreter's answers to the user's queries;\n- the _Stdin_ tab is aimed at letting the user provide some text the Prolog interpreter's standard input stream;\n- the _Stdout_ tab is aimed at showing the Prolog interpreter's standard output stream;\n- the _Stderr_ tab is aimed at showing the Prolog interpreter's standard error stream;\n- the _Warnings_ tab is aimed at showing any warning possibly generated by the Prolog interpreter while computing;\n- the _Operators_ tab is aimed at showing the current content Prolog interpreter's operator table;\n- the _Flags_ tab is aimed showing the actual values of all the flags currently defined with the Prolog interpreter;\n- the _Libraries_ tab is aimed at letting the user inspect the currently loaded libraries and the predicates, operators, and functions they import;\n- the _Static_ (resp. _Dynamic_) _KB_ tab is aimed at letting the user inspect the current content of the Prolog interpreter's static (resp. dynamic) knowledge base.\n\nAny of these tabs may be automatically updated after a solution to some query is computed. \nWhenever something changes w.r.t. the previous content of the tab, an asterisk will appear close to the tab name, to notify an update in that tab.\n  \n#### Command Line Interface\n\nIf you just need a command-line Prolog interpreter, you can rely on the 2P-Kt REPL which is available on the [Releases section of the \nGitHub repository](https://github.com/tuProlog/2p-kt/releases). \n\nThe page of the [latest release](https://github.com/tuProlog/2p-kt/releases/latest) of 2P-Kt exposes a number of _Assets_.\nThere, the one named:\n```\n2p-repl-VERSION-redist.jar\n```\nis the self-contained, executable Jar containing the 2P-Kt-based Prolog interpreter (`VERSION` may vary depending on the\nactual release version).\n\nAfter you download the `2p-repl-VERSION-redist.jar`, you can simply launch it by running:\n```bash\njava -jar 2p-repl-VERSION-redist.jar\n```\nThis should start an interactive read-eval-print loop accepting Prolog queries.\nA normal output should be as follows:\n```\n# 2P-Kt version LAST_VERSION_HERE\n\n?- \u003cwrite your dot-terminated Prolog query here\u003e.\n```\n\nFor instance:\n\n![A screenshot of the 2P-Kt CLI](https://gitlab.com/pika-lab/tuprolog/2p-in-kotlin/raw/master/.img/2p-kt-repl.png)\n\nOther options or modes of execution are supported.\nOne can explore them via the program help, which can be displayed by running:\n```bash\njava -jar 2p-repl-VERSION-redist.jar --help\n```\nThis should display a message similar to the following one:\n```\nUsage: java -jar 2p-repl.jar [OPTIONS] COMMAND [ARGS]...\n\n  Start a Prolog Read-Eval-Print loop\n\nOptions:\n  -T, --theory TEXT  Path of theory file to be loaded\n  -t, --timeout INT  Maximum amount of time for computing a solution (default:\n                     1000 ms)\n  --oop              Loads the OOP library\n  -h, --help         Show this message and exit\n\nCommands:\n  solve  Compute a particular query and then terminate\n```\n\n### Gradle users\n\nTo import the 2P-Kt module named `2P_MODULE` (version `2P_VERSION`) into your Kotlin-based project leveraging on Gradle, \nyou simply need to declare the corresponding dependency in your `build.gradle(.kts)` file:\n ```kotlin\n// assumes Gradle's Kotlin DSL\ndependencies {\n    implementation(\"it.unibo.tuprolog\", \"2P_MODULE\", \"2P_VERSION\")\n}\n ``` \nIn this way, the dependencies of `2P_MODULE` should be automatically imported. \n\nThe step above, requires you to tell Gradle to either use Maven Central or our GitHub repository (or both) as a source \nfor dependency lookup. You can do it as follows:\n```kotlin\n// assumes Gradle's Kotlin DSL\nrepositories {\n    maven(\"https://maven.pkg.github.com/tuProlog/2p-kt\")\n    mavenCentral()\n}\n``` \n\n\u003e Authentication may be required in case the GitHub repository is exploited\n\n#### JVM-only projects with Gradle\n\nRemember to add the `-jvm` suffix to `2P_MODULE` in case your project only targets the JVM platform:\n ```kotlin\n// assumes Gradle's Kotlin DSL\ndependencies {\n    implementation(\"it.unibo.tuprolog\", \"2P_MODULE-jvm\", \"2P_VERSION\")\n}\n ``` \n\n### Maven users\n\nTo import the 2P-Kt module named `2P_MODULE` (version `2P_VERSION`) into your Kotlin-based project leveraging on Maven,\nyou simply need to declare the corresponding dependency in your `pom.xml` file:\n ```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eit.unibo.tuprolog\u003c/groupId\u003e\n    \u003cartifactId\u003e2P_MODULE\u003c/artifactId\u003e\n    \u003cversion\u003e2P_VERSION\u003c/version\u003e\n\u003c/dependency\u003e\n ``` \nIn this way, the dependencies of `2P_MODULE` should be automatically imported. \n\nThe step above, requires you to tell Maven to either use Maven Central or our GitHub repository (or both) as a source \nfor dependency lookup. You can do it as follows:\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003egithub-2p-repo\u003c/id\u003e\n        \u003curl\u003ehttps://maven.pkg.github.com/tuProlog/2p-kt\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n``` \n\n\u003e Authentication may be required in case the GitHub repository is exploited\n\n#### JVM-only projects with Maven\n\nRemember to add the `-jvm` suffix to `2P_MODULE` in case your project only targets the JVM platform:\n ```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eit.unibo.tuprolog\u003c/groupId\u003e\n    \u003cartifactId\u003e2P_MODULE-jvm\u003c/artifactId\u003e\n    \u003cversion\u003e2P_VERSION\u003c/version\u003e\n\u003c/dependency\u003e\n ``` \n\n### NPM users (JavaScript-only projects)\n\nThe 2P-Kt software is available as a JavaScript library as well, on NPM, under the  [`@tuprolog` organization](https://www.npmjs.com/org/tuprolog).\nTo import the `2P_MODULE` into your `package.json`, it is sufficient to declare your dependency as follows:\n```json\n{\n  \"dependencies\": {\n    \"@tuprolog/2P_MODULE\": \"^2P_MODULE_VERSION\"\n  }\n}\n```\nNotice that the JS dependencies of `2P_MODULE` should be automatically imported. \n\n## Developers\n\nWorking with the 2P-Kt codebase requires a number of tools to be installed and properly configured on your system:\n- JDK 11+ (please ensure the `JAVA_HOME` environment variable is properly) configured\n- Kotlin 1.5.10+\n- Gradle 7.1+ (please ensure the `GRADLE_HOME` environment variable is properly configured)\n- Git 2.20+\n\n### Develop 2P-Kt with IntelliJ Idea\n\nTo participate in the development of 2P-Kt, we suggest the [IntelliJ Idea](https://www.jetbrains.com/idea/download/) IDE. \nThe free, _Community_ version will be fine. \n\n#### Recommended configuration\nYou will need the __Kotlin__ plugin for IntelliJ Idea. \nThis is usually installed upon Idea's very first setup wizard.\nHowever, one may easily late-install such plugin through the IDE's Plugins settings dialog.\nTo open such dialog, use \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eShift\u003c/kbd\u003e+\u003ckbd\u003eA\u003c/kbd\u003e, then search for \"Plugins\"\n\n#### Importing the project\n\n1. Clone this repository in a folder of your preference using `git clone` appropriately\n\n0. Open IntellJ Idea. \nIf a project opens automatically, select \"Close project\". \nYou should be on the welcome screen of IntelliJ idea, with an aspect similar to this image: \n![IntelliJ Welcome Screen](https://www.jetbrains.com/help/img/idea/2018.2/ideaWelcomeScreen.png)\n\n0. Select \"Import Project\"\n\n0. Navigate your file system and find the folder where you cloned the repository. \n**Do not select it**. \nOpen the folder, and you should find a lowercase `2p-in-kotlin` folder. \nThat is the correct project folder, created by `git` in case you cloned without specifying a different folder name. \nOnce the correct folder has been selected, click \u003ckbd\u003eOk\u003c/kbd\u003e\n\n0. Select \"Import Project from external model\"\n\n0. Make sure \"Gradle\" is selected as external model tool\n\n0. Click \u003ckbd\u003eFinish\u003c/kbd\u003e\n\n0. If prompted to override any `.idea` file, try to answer \u003ckbd\u003eNo\u003c/kbd\u003e. It's possible that IntelliJ refuses to proceed, in which case click \u003ckbd\u003eFinish\u003c/kbd\u003e again, then select \u003ckbd\u003eYes\u003c/kbd\u003e\n\n0. A dialog stating that \"IntelliJ IDEA found a Gradle build script\" may appear, in such case answer \u003ckbd\u003eImport Gradle Project\u003c/kbd\u003e\n\n0. Wait for the IDE to import the project from Gradle. The process may take several minutes, due to the amount of dependencies. Should the synchronization fail, make sure that the IDE's Gradle is configured correctly:\n\n0. In 'Settings -\u003e Build, Execution, Deployment -\u003e Build Tools \u003e Gradle', for the option 'Use Gradle from' select 'gradle-wrapper.properties file'. Enabling auto-import is also recommended\n\n### Developing the project\nContributions to this project are welcome. Just some rules:\n\n* We use [git flow](https://github.com/nvie/gitflow), so if you write new features, please do so in a separate `feature/` branch\n\n* We recommend forking the project, developing your stuff, then contributing back via pull request directly from the Web interface\n\n* Commit often. Do not throw pull requests with a single giant commit adding or changing the whole world. Split it in multiple commits and request a merge to the mainline often\n\n* Stay in sync with the `develop` branch: pull often from `develop` (if the build passes), so that you don't diverge too much from the main development line\n\n* Do not introduce low quality or untested code. Merge requests will be reviewed before merge.\n\n\n#### Building the project\nWhile developing, you can rely on IntelliJ to build the project, it will generally do a very good job.\nIf you want to generate the artifacts, you can rely on Gradle. Just point a terminal on the project's root and issue\n\n```bash\n./gradlew build\n```\n\nThis will trigger the creation of the artifacts the executions of the tests, the generation of the documentation and of the project reports.\n\n#### Versioning\n\nThe 2P project leverages on [Semantic Versioning](https://semver.org/) (SemVer, henceforth).\n\nIn particular, SemVer is enforced by the current Gradle configuration, which features [DanySK](https://github.com/DanySK)'s [Git sensitive SemVer Gradle Plugin](https://github.com/DanySK/git-sensitive-semantic-versioning-gradle-plugin).\nThis implies it is strictly forbidden in this project to create tags whose label is not a valid SemVar string.\n\nNotice that the 2P project is still in its initial development stage---as proven by the major number equal to `0` in its version string.\nAccording to SemVer, this implies anything _may_ change at any time, as the public API _should not_ be considered stable.\n\n#### Issue tracking\n\nIf you meet some problem in using or developing 2P, you are encouraged to signal it through the project [\"Issues\" section](https://github.com/tuProlog/2p-kt/issues) on GitHub.\n","funding_links":[],"categories":["Libraries","人工智能"],"sub_categories":["Artificial Intelligence"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FtuProlog%2F2p-kt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FtuProlog%2F2p-kt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FtuProlog%2F2p-kt/lists"}