Moving from version 6

C#Prolog version 7 is a complete rewrite, written from scratch. It keeps the name, but it is a different library from version 6 and earlier.

What changed

  • The engine, the term types, and the C# API were designed again for modern .NET. Version 7 does not contain the code of the old implementation.
  • The API is not compatible. Code that uses version 6 needs changes.
  • The library is split into CSProlog.Core and CSProlog.Syntax. The CSProlog package brings in both, so updating the CSProlog package from version 6 to version 7 gives you the new implementation.
  • Version 7 targets .NET 11.

The old API and the new API

Version 6 Version 7
new PrologEngine(persistentCommandHistory: false) new PrologEngine()
engine.ConsultFromString(text) engine.Consult(text)
engine.GetFirstSolution(query).Solved engine.Solve(query).Any()
engine.GetAllSolutions(null, query) engine.Solve(query), with foreach
// Version 6
var prolog = new PrologEngine(persistentCommandHistory: false);
prolog.ConsultFromString("human(socrates).");
var solution = prolog.GetFirstSolution(query: "human(socrates).");
Console.WriteLine(solution.Solved);

// Version 7
var engine = new PrologEngine();
engine.Consult("human(socrates).");
Console.WriteLine(engine.Solve("human(socrates).").Any());

Features of version 6 that version 7 does not have

Version 6 had many extra predicates, such as SQL, XML, JSON, and date and time predicates. Version 7 starts with the core of ISO Prolog, and more will be added over time. See Builtin predicates for what is there now.

The old version

The source code of version 6 and earlier, with its whole commit history, stays available on the vnext/master branch. Version 6 also stays available on NuGet.

Thanks

C#Prolog was first written by John Pool of Amersfoort, the Netherlands, who improved it from 2007 to 2015. In 2015, J. Sakamoto imported it into GitHub, and published versions 5 and 6 on NuGet as the CSProlog package. Josh Ahlstrom, @michelvosje, and many other people helped along the way.

Version 7 is a new implementation, but it would not exist without all this work. Many thanks to John Pool, and to all the contributors of the earlier versions.

An unhandled error has occurred. Reload 🗙