https://github.com/lukaspietzschmann/zigchr
A FreeCHR instance written in Zig
https://github.com/lukaspietzschmann/zigchr
constraint-programming zig
Last synced: about 1 month ago
JSON representation
A FreeCHR instance written in Zig
- Host: GitHub
- URL: https://github.com/lukaspietzschmann/zigchr
- Owner: LukasPietzschmann
- License: bsd-3-clause
- Created: 2024-09-17T19:23:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-10-27T11:25:51.000Z (5 months ago)
- Last Synced: 2025-11-30T18:38:29.240Z (4 months ago)
- Topics: constraint-programming, zig
- Language: Zig
- Homepage: https://lukas.pietzschmann.org/talks/zigtoberfest
- Size: 70.3 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ZigCHR
For the [talk](https://github.com/LukasPietzschmann/zigtoberfest-talk) I gave at Zigtoberfest 2024, I coded up a CHR embedding for Zig using the
FreeCHR framework.
If you want to learn more about FreeCHR, go ahead and read [this
paper](https://doi.org/10.1007/978-3-031-45072-3_14). If you want to know more about
cool properties that CHR can bring to your algorithms, visit [my website for the
talk](https://lukas.pietzschmann.org/talks/zigtoberfest)
## Project Structure
- `src/`: Here you can find two example on how to use the embedding.
- `lib/`: The embedding itself.
- `utils/`: Some useful data structures and functions unrelated to CHR.
## How to build it
For each file inside the `src` directory, there exists a step. So lets say you want to
build and run the _min_ example. You can run `zig build min` to do so. For all examples
present in this repo, you can pass the query constraints though the commandline like the
following: `zig build min -- 1 3 5`.
If you add your own file in the `src` folder, the build system will automatically
generate a step for you.
### Additional flags
You can pass different flags to the build process to control how much logs the embedding
produces:
- `-Dlog` enabled logging. The embedding will print which rules were fired with which
constraints, whats put into the store, ...
- `-Dnotag` wont print a constraints tag.
- `-Dmatchings` requires `-Dlog`. The embedding will print what combination of
constraints are considered.
- `-Dstore` requires `-Dlog`. The embedding will print the constraint store when it's
modified.