Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pgbiel/typst-truthtable
A library for generating truth tables
https://github.com/pgbiel/typst-truthtable
Last synced: about 1 month ago
JSON representation
A library for generating truth tables
- Host: GitHub
- URL: https://github.com/pgbiel/typst-truthtable
- Owner: PgBiel
- License: mit
- Created: 2023-03-28T21:04:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-12T01:28:28.000Z (over 1 year ago)
- Last Synced: 2024-08-05T10:09:11.950Z (5 months ago)
- Size: 392 KB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# typst-truthtable
A library for generating truth tables## Usage
Compose logic expressions with the logic operators: `l-and(a, b)`, `l-or(a, b)`,
`l-imp(a, b)`, `l-iff(a, b)`, `l-not(a)`, where `a` and `b` can be either
other expressions created with operators, atomic variables/propositions
(which can be created with `"name"` or
`l-var("name", repr: $custom_representation$)`), and boolean values
(`true` or `false`).Then, for any expression, you may write `#truth-table(expr)` to generate its
truth table.Note that it gets ugly if there are too many columns, so make sure to mark any
excessive columns with `skip: true` (e.g. `l-and(a, b, skip: true))` will not show
the possible values for "a and b" in the table).You may also create your own _n_-ary operator by invoking `l-operator("ITS_NAME", a, b, ..other_children, value: variable_mapping => {/* calculate truth value based on a dict (VARIABLE_NAME: true_or_false) */}, repr: $my_operators_appearance$)`. Regarding `value`, note that you may get your children's
truth value based on the given variable map with `(child.value)(variable_mapping)`.See `examples/` for some examples.
![image](https://user-images.githubusercontent.com/9021226/228386381-96bcfdb2-76a5-4966-8d21-31a06887345d.png)