{"id":14455929,"url":"https://github.com/Trismegiste/Prolog","last_synced_at":"2025-08-28T11:32:11.960Z","repository":{"id":57072874,"uuid":"13687513","full_name":"Trismegiste/Prolog","owner":"Trismegiste","description":"Warren Abstract Machine - A embedded Prolog compiler and virtual machine for PHP","archived":false,"fork":false,"pushed_at":"2024-05-31T08:39:21.000Z","size":560,"stargazers_count":32,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-25T06:37:57.188Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://en.wikipedia.org/wiki/Prolog","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Trismegiste.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-10-18T19:43:38.000Z","updated_at":"2025-03-04T05:19:03.000Z","dependencies_parsed_at":"2024-12-25T17:30:52.418Z","dependency_job_id":"66895352-176c-44e1-a053-3e6a09664b11","html_url":"https://github.com/Trismegiste/Prolog","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"145c4bdf5ee935aadb163550fc63df5a98a74bb6"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Trismegiste/Prolog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trismegiste%2FProlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trismegiste%2FProlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trismegiste%2FProlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trismegiste%2FProlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Trismegiste","download_url":"https://codeload.github.com/Trismegiste/Prolog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trismegiste%2FProlog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272491463,"owners_count":24943668,"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","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"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":[],"created_at":"2024-09-01T15:01:19.546Z","updated_at":"2025-08-28T11:32:11.633Z","avatar_url":"https://github.com/Trismegiste.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Trismegiste/Prolog\n\n[![Build Status](https://secure.travis-ci.org/Trismegiste/Prolog.png?branch=master)](http://travis-ci.org/Trismegiste/Prolog)\n\n## A [Warren's Abstract Machine][1]\nOriginal java version by Stefan Büttcher.\u003cbr/\u003e\nPHP port and PhpUnit tests by Florent Genette.\n\nVersion 1.4\n\n## What ?\nA Warren Abstract Machine (WAM) is a virtual machine (like a JVM for Java) for\n[Prolog][2]. This library is intended to run on PHP 5.4.\nProlog is a logic language which solve problems with an [inference engine][3].\n\n\nDavid Warren wrote in \"WAM - A tutorial reconstruction\" :\n\u003cblockquote\u003e\u003cp\u003eThe WAM is an abstract machine consisting of a memory architecture and instruction\nset tailored to Prolog. It can be realised efficiently on a wide range of\nhardware, and serves as a target for portable Prolog compilers. It has now become\naccepted as a standard basis for implementing Prolog.\u003c/p\u003e\u003c/blockquote\u003e\n\nWikipedia says :\n\u003cblockquote\u003e\u003cp\u003eProlog has its roots in first-order logic, a formal logic, and unlike many\nother programming languages, Prolog is declarative: the program logic is\nexpressed in terms of relations, represented as facts and rules. A computation\nis initiated by running a query over these relations.\u003c/p\u003e\u003c/blockquote\u003e\n\nAs you can see, Prolog has nearly no instructions nor loops nor ifs nor gotos.\nThe only thing you have to do is to enounce absolute truths.\nAt that point, Mr Spock says : \"Fascinating\"\n\nStop the chatty chat, I recommand wikipedia and the excellent book by\nHassan Aït-Kaci in the doc directory.\n\n## Is it usefull ?\nLike any other \u003ca href=\"http://en.wikipedia.org/wiki/Domain-specific_language\"\u003eDSL\u003c/a\u003e,\nProlog has a very limited scope but sometimes it can simplify some problem like :\n\n * You need a rule engine\n * You want to avoid big boring sequences of if-else-switch to implement some business intelligence\n * You need a big bunch of Chain of Responsability which changes every week\n * You face a logic problem with non deterministic path\n\n## Can I haZ example ?\nLook at the file basket.pro : it's a set of marketing rules for gift and discount\nbased on the content of a cart. For functional tests, I have also added many\nprograms like list operations (see 'append', it is very fun), family trees,\neight queen problem and hanoi problem.\n\n## Why port a forty-year-old language in PHP ?\n### (from a ten-year-old release in Java  ?)\nWell, first thing it is a matter of taste. Even with 3 hundreds years, JS Bach\nis still the best musician in the Multiverse. Second, I am not saying Prolog\ncan solve anything, no. I think there is one language one can use for one\nspecific coding problem. As you know : \"one language is not enough\".\nSee http://memeagora.blogspot.fr/2006/12/polyglot-programming.html\n\nI also think, like any other language, we, programmers, have some responsability\nto keep this knowledge alive, and today the best way is to port this WAM to PHP.\nIt's not nostalgia, it's just recollection about these pioneers of computer\nprogramming like Von Neumann or Turing.\n\n## Some notes about this port\nI went through a lot a trouble thanks the \"soft-typing\" of PHP and the damned\n\"===\" but even if I still prefer Java and strong typing, the managing of\nstrings and arrays in PHP is awsum. There's probably much optimizations to do\nsince the design was not thought for PHP. The good thing is my knowledge of PHP\ninternals has improved.\n\n## Some notes about perfs\nYes, this WAM is slow compared to SWI-Prolog. If you need a lot of recursions\nor a big set of datas, I don't think this piece of software is for you.\n\nAs I wrote, this is for specific problems where the imperative programming paradigm\nis irrelevant. This is not the only paradigm : Think declarative programming !\nAnd if you like this and want to go further, look at the Clojure language.\n\n## Running test\nTo run all tests. I have splitted the test suite into two groups to extract lengthy stress tests.\n``` bash\nphpunit\n```\n\n## I want to fork, can I ?\nYes you can ! But don't forget to test new features or changes !\n\nToday, this library has XXX assertions, it took me a lot of time but it\nwas mandatory before refactoring this to make it as a modern PHP library.\n\nThere is still a lot to do : a CLI compiler, a better (abstract) filesystem,\nupdating the metalogic clause known as 'retract', adding features like 'bagof' and\n'findall' but don't forget the tests and documentations because I'll never merge\na PR for new features if it's not tested and commented.\n\n## I found a bug, what can I do ?\n * Fork it with Github !\n * Write a new test in the class IFoundABugTest to show the bug\n * Make a Pull Request for the faulty test\n * I merge the new test\n * Someone (you, me, anyone) fix it and make a Pull Request for the fix\n * Eventually I'll refactor IFoundABugTest class to move the test in the right place\n\nI like TDD for debugging. Sometimes it's annoying but it is always\nfor the best, specially accross the net. With the help of TravisCI, tracking bugs\nis a piece of cake.\n\n## Also appears in\n\n * Symfony2 bundle for this lib with extra GUI features : [WamBundle][4]\n * A CLI tool for converting hepburn notation to hiragana for japanese names : [Hiragana][5]\n\n## Licence\n![cc-by-sa](http://i.creativecommons.org/l/by-sa/3.0/88x31.png)\n\nThis work is provided with the Creative Commons Attribution Share Alike 3.0 Licence.\nIt means you must keep my name and must provide any derivative works with this licence.\nYou can make money with this as long as you follow these rules. In other words :\n\n    licence(wam_bundle, cc_by_sa_3).\n    derivate_work_from(your_work, wam_bundle).\n    licence(X, L) :- derivate_work_from(X, Y), licence(Y, L).\n    price(wam_bundle, 0).\n    price(your_work, _).\n\n## Contributors\n * Lead : [Trismegiste](https://github.com/Trismegiste)\n\n## Special thanks\n * [Igor Wiedler](https://github.com/igorw) to bring the idea for decoupling this library\nfrom its symfony dependencies\n\n[1]: http://en.wikipedia.org/wiki/Warren_Abstract_Machine\n[2]: http://en.wikipedia.org/wiki/Prolog\n[3]: http://en.wikipedia.org/wiki/Inference_engine\n[4]: https://github.com/Trismegiste/WamBundle\n[5]: https://github.com/Trismegiste/Hiragana","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTrismegiste%2FProlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTrismegiste%2FProlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTrismegiste%2FProlog/lists"}