Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curryst:0.4.0 #1546

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/preview/curryst/0.4.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Rémi Hutin - Paul Adam - Malo <@MDLC01>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
149 changes: 149 additions & 0 deletions packages/preview/curryst/0.4.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Curryst

A Typst package for typesetting proof trees.


## Import

You can import the latest version of this package with:

```typst
#import "@preview/curryst:0.4.0": rule, proof-tree
```

## Basic usage

To display a proof tree, you first need to create a tree, using the `rule` function. Its first argument is the conclusion, and the other positional arguments are the premises. It also accepts a `name` for the rule name, displayed on the right of the bar, as well as a `label`, displayed on the left of the bar.

```typ
#let tree = rule(
label: [Label],
name: [Rule name],
[Conclusion],
[Premise 1],
[Premise 2],
[Premise 3]
)
```

Then, you can display the tree with the `proof-tree` function:

```typ
#proof-tree(tree)
```

In this case, we get the following result:

![A proof tree with three premises, a conclusion, and a rule name.](examples/usage.svg)

Proof trees can be part of mathematical formulas:

```typ
Consider the following tree:
$
Pi quad = quad #proof-tree(
rule(
$phi$,
$Pi_1$,
$Pi_2$,
)
)
$
$Pi$ constitutes a derivation of $phi$.
```

![The rendered document.](examples/math-formula.svg)

You can specify a rule as the premises of a rule in order to create a tree:

```typ
#proof-tree(
rule(
name: $R$,
$C_1 or C_2 or C_3$,
rule(
name: $A$,
$C_1 or C_2 or L$,
rule(
$C_1 or L$,
$Pi_1$,
),
),
rule(
$C_2 or overline(L)$,
$Pi_2$,
),
)
)
```

![The rendered tree.](examples/rule-as-premise.svg)

As an example, here is a natural deduction proof tree generated with Curryst:

![The rendered tree.](examples/natural-deduction.svg)

<details>
<summary>Show code</summary>

```typ
#let ax = rule.with(name: [ax])
#let and-el = rule.with(name: $and_e^ell$)
#let and-er = rule.with(name: $and_e^r$)
#let impl-i = rule.with(name: $scripts(->)_i$)
#let impl-e = rule.with(name: $scripts(->)_e$)
#let not-i = rule.with(name: $not_i$)
#let not-e = rule.with(name: $not_e$)

#proof-tree(
impl-i(
$tack (p -> q) -> not (p and not q)$,
not-i(
$p -> q tack not (p and not q)$,
not-e(
$ underbrace(p -> q\, p and not q, Gamma) tack bot $,
impl-e(
$Gamma tack q$,
ax($Gamma tack p -> q$),
and-el(
$Gamma tack p$,
ax($Gamma tack p and not q$),
),
),
and-er(
$Gamma tack not q$,
ax($Gamma tack p and not q$),
),
),
),
)
)
```
</details>


## Advanced usage

The `proof-tree` function accepts multiple named arguments that let you customize the tree:

<dl>
<dt><code>prem-min-spacing</code></dt>
<dd>The minimum amount of space between two premises.</dd>

<dt><code>title-inset</code></dt>
<dd>The amount width with which to extend the horizontal bar beyond the content. Also determines how far from the bar labels and names are displayed.</dd>

<dt><code>stroke</code></dt>
<dd>The stroke to use for the horizontal bars.</dd>

<dt><code>horizontal-spacing</code></dt>
<dd>The space between the bottom of the bar and the conclusion, and between the top of the bar and the premises.</dd>

<dt><code>min-bar-height</code></dt>
<dd>The minimum height of the box containing the horizontal bar.</dd>

<dt><code>dir</code></dt>
<dd>The orientation of the proof tree (either <code>btt</code> or <code>ttb</code>, <code>btt</code> being the default).</dd>
</dl>

For more information, please refer to the documentation in [`curryst.typ`](curryst.typ).
Loading
Loading