Skip to content

Latest commit

 

History

History
87 lines (66 loc) · 3.53 KB

README.md

File metadata and controls

87 lines (66 loc) · 3.53 KB

Dusa Language

Dusa is an implementation of finite-choice logic programming, which takes ideas from logic programming in both Datalog and answer set programming.

Run static checks Coverage Status NPM Module

Dusa was initially developed by Rob Simmons and Chris Martens while Rob attended Recurse Center in Fall 2023. Recurse Center is a great place to think about ambitious projects like this in a supportive environment full of interesting people!

Command-line quickstart

The dusa command-line program can be run directly from npx, the only requirement is that you are using Node v22 or above. The examples used here can be found on github.

The command-line utility requires one positional argument, a Dusa program, and if given no other arguments will return a single solution in JSON format.

npx dusa examples/mutual-exclusion.dusa

The -n flag controls the number of solutions returned. This command will return 2 solutions:

npx dusa examples/mutual-exclusion.dusa -n0

Including the -q <pred> flag will print only certain predicates instead of the full database of facts.

npx dusa examples/cky-parsing.dusa -n0 -q goal
npx dusa examples/character-creation.dusa -n3 -q a_story
npx dusa examples/rock-paper-scissors.dusa -n5 -q eventually

Including the -c <pred> flag will print only the number of facts about a certain predicate that exist, instead of a list of all the values associated with that fact.

npx dusa examples/rock-paper-scissors.dusa -n3 -c move
npx dusa examples/rock-paper-scissors.dusa -n3 -c move -q eventually

You can assert additional facts on the command line with -a. Adding two edges to the graph coloring example in examples/graph-coloring.dusa removes all solutions.

npx dusa examples/graph-coloring.dusa -n5 -q isBlue
npx dusa examples/graph-coloring.dusa -n5 -q isBlue -a '{"name":"edge", "args":[{"name":"a"}, {"name":"d"}]}' -a '{"name":"edge", "args":[{"name":"c"}, {"name":"d"}]}'

The -f option allows you to include files containing lists of JSON facts.

npx dusa examples/canonical-reps.dusa -f examples/graph-data-32.json -q isRep

License

All documentation and examples in the docs and examples directories and subdirectories therein are MIT-licensed, but the Dusa implementation in JavaScript is, at present, only licensed under the GNU General Public License v3.0 (see LICENSE).

Dusa is presently under the GPL is to make it easy for many people to use the software while maintaining some ownership of software that took a fair amount of time and expertise to develop. If the GPL is an issue for you or your company but you'd like to use it, I'd be delighted to discuss making that possible, and if you want to sponsor me to relicense Dusa more permissively, I wouldn't take much convincing. --- Rob