Packages

Guesswork is a logic programming library for Elixir. It is heavily inspired by Prolog, but attempts to use idiomatic Elixir when expressing problems and their solutions.

Current section

Files

Jump to
guesswork CHANGELOG.md
Raw

CHANGELOG.md

# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.7.0] - 2024-12-29
### Added
- Added code coverage tracking.
- Added `Guesswork.Arithmetic.Polynomial`, which allows the user to input a simple
equation, and then translates it into logical constraints
(`Guesswork.Constraint.Arithmetic`).
- A new protocol, `Guesswork.Constraint` has been added that allows multi
directional relationships to be defined.
These constraints are stored using a trie in answer sets and now replace
computations in bindings as well as test computations and stop conditions.
- To facilitate this `Guesswork.Ast.Is` now supports a `halt_on_error` option
that turns it into a stop condition.
- These constraints now support relationships beyond simple equality, including
less than, greater than, less than or equal or, and greater than or equal to.
- Constraints can be displayed along with answer sets.
- Added a new server, `Guesswork.Constraint.Arithmetic.InternalVariable` that can
be run by the user and enables short, readable, and unique variables.
### Fixed
- `Guesswork.KnowledgeBase.Collection.deffact/2` and
`Guesswork.KnowledgeBase.Collection.deffalsehood/2` now accept variables and
follow normal matching rules.
This replaces `Guesswork.Ast.Wildcard` and allows values to be propagated across
the statement.
- The definitions in `Guesswork.KnowledgeBase.Collection` now all use
standard function syntax.
This changes the type of `Guesswork.Ast.Fact` some, so now the `:relationship`
is an atom.
- Constraints are now removed as their variables fall out of scope.
- Resolving a rule now returns a closure that takes an env and returns an
answer stream instead of just returning a stream (changing the return type of
`Guesswork.Ast.Statement.resolve/2`).
This allows values to be substituted incrementally instead of just unioned.
As a side-effect of this change the negated value used for constraints (and
only constraints) is reset when resolving a rule.
- As a result of the changes to fact resolution, precomputation is now done at
the fact level with an ets cache.
This can create problems with recursive rules so the default `precompute_count`
is now 0.
### Removed
- `Guesswork.Ast.Stop` has been removed in favor of constraints.
## [0.6.0] - 2024-10-10
### Added
- Added `Guesswork.Ast.Stop`, allowing users to state conditions where the answer
set stream should terminate.
- Added a factorial example to showcase recursion.
- Added a new `Guesswork.Ast.Wildcard` (which can be built in terms with `:_`)
term that matches anything but itself.
- `Guesswork.Ast.KnowledgeBase.Collection.defrule/3` will now emit a warning if
a recursive rule is created with no base case fact.
Note that the fact must be declared first.
- `Guesswork.Ast.KnowledgeBase.Collection.defrule/3` now accepts its definition
in a `do` block.
When multiple clauses are in that block, they are grouped via
`Guesswork.Ast.And`.
### Fixed
- When `Guesswork.Ast.Fact`s pull rules from the knowledge base, it how suffixes the
variables with the recursion depth (which is now tracked the
`Guesswork.Ast.Statement.Opts`).
This stops multiple recursive calls to rules from creating variables that should
be distinct but have the same display and different values (which stopped
queries that used recursion from ever finding a valid result set).
- Fixed bug where substitutions for non atom values would error on
`Guesswork.Ast.Fact`s.
- `negated` has been moved to `Guesswork.Ast.Statement.Opts`, simplifying the
signature, use, and documentation of `Guesswork.Ast.Statement.resolve/2`.
- Fixed bug where `Guesswork.Ast.Is` did not properly report it's variables.
- `Guesswork.Ast.Is` now resolves computation before the answer stream is created
when all inputs are concrete.
- Fixed the type spec of `Guesswork.Ast.Is.new/3` to indicate that the inputs can
be concrete.
## [0.5.0] - 2024-09-17
### Added
- `BitString` is now included in the `Guesswork.Ast.Term` implementations.
- `Guesswork.Ast.And` and `Guesswork.Ast.Or` now check their arguments for
`Guesswork.Ast.Fact` that are repeated with the same arguments and condense
and pre-computes them using `Guesswork.Ast.Precomputed`.
This ensures that work isn't overly repeated.
- Added a shift scheduling example.
- Added a Makefile for common targets.
- Added query benchmarks with tracked results.
- Telemetry now tracks precomputed streams.
### Fixed
- `Guesswork.Answer.Result` now keeps the underlying data as a
`Guesswork.Answer.Binding.value()`, and only transforms it into a string when
building the `Kino` render.
- When rules are extracted and their answer sets calculated, variables that fall
out of scope are removed.
This should stop the bug where internal variables shared between reused rules
would conflict and disqualify valid answer sets.
This has also allowed the removal of variable ids.
- `StreamSplit.take_and_drop/2` is now used to partially evaluate streams instead
of `Enum.take/2` and `Stream.drop/2`.
This will ensure that the old values are actually removed from streams instead
of lazy operations building up.
## [0.4.4] - 2024-09-08
### Added
- CI jobs now run a dry run release to check for problems.
### Fixed
- Fixed examples to not include unused functions.
## [0.4.3] - 2024-09-07
### Fixed
- Fixed the file list in mix.exs to not include non-existent files.
## [0.4.2] - 2024-09-07
### Fixed
- Include dependency cache in release job so that publish works.
## [0.4.1] - 2024-09-07
### Fixed
- Fixed CI bug where hex wasn't pulled and so releases didn't make it to hex.pm.
## [0.4.0] - 2024-09-07
### Added
- `Ast.term/1` now supports the pin operator for pulling in external values and
elixir expressions.
- Added `ExDoc` support.
- Telemetry has been added to the library:
- A new module `Guesswork.Telemetry` holds a GenServer that tracks spans and
metrics.
- Queries now have their own struct that allow tracking of queries by id.
- `Guesswork.Answer.Result.run/2` now reports a span that allows queries to be
tracked and timed.
- All assignments, substitutions, and tests are tracked (per query).
- Unions are now tracked in spans.
- A new example has been added to walk through this system.
- Simple benchmarks have been added to support telemetry operations.
- This project should now release to hex.pm and build a gitlab release on every
merge to master.
### Fix
- Fixed bug where tests continued to be processed even after one failed.
## [0.3.0] - 2024-07-23
### Added
- `Ast.term/1` accepts entities other than atoms.
- Added support for a `one_of` operator that assigns a stream to a variable.
- Added support for an `is` operator that assigns computation.
- Falsehoods can now be added to collections.
- Added support for a `set` operator that assigns a value to a variable.
- Added a new, default, empty collection the `query/2` defaults to.
- `Result.new/2` has been renamed to `Result.run/2` for consistency with `Stream`.
- `Fact` now evaluates rules lazily in case there is a loop.
- New, high level tests have been added to verify the entire system.
- Added an example for pythagorean triples.
### Fixed
- Nots are now properly respected such that `l_not(l_and(set(x, 1), set(x, 2)))` is
valid.
- Ands now evaluate their clauses such that infinite streams of answer sets can be
properly evaluated.
- The macros used to define rules and terms now take functions instead of un-exported
terms.
## [0.2.0] - 2024-06-27
### Added
- Added Credo linter.
- Added Dialyzer static analysis.
- Added a ci pipeline for MR quality control.
- Added a top level function for running queries.
- Added the classic family tree example.
- Added a `term/1` macro to make the process of making terms easier.
- Added implementations of `String.Chars` for all terms that mirrors the syntax
of `term/1`.
- Knowledge bases have been generalized to use a behavior, which is taken advantage
of with the new `Guesswork.KnowledgeBase.Collection` which makes it easy to create
static collections of rules and facts.
- Add LICENSE.
- Added a new `Guesswork.Answer.Result` module that makes it easier to evaluate and
display values on livebook.
### Fixed
- When facts are resolved they now search both for matching facts and matching
rules.
- Variables now create an internal id that is used for comparison within answer
sets so that separate variables with the same display name don't conflict.
- Fixed a bug in `And` where any repeating variable was seen as a conflict.
- `Statement.resolve/2` and `Guesswork.query/2` both return streams so that large
problem spaces don't create issues.
## [0.1.0] - 2024-06-19
- init