Skip to content

Commit 0910999

Browse files
authored
derive-it:1.0.0 (#3181)
1 parent b2f7005 commit 0910999

File tree

7 files changed

+792
-0
lines changed

7 files changed

+792
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 0rphee
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# derive-it
2+
3+
A Typst package to create Fitch-style natural deductions. Available on [Typst Universe](https://typst.app/universe/package/derive-it).
4+
5+
![Image of output](examples/example.png)
6+
7+
## Usage
8+
9+
This package provides two functions:
10+
11+
`ded-nat` is a function that expects:
12+
- `stcolor`: the stroke color of the indentation guides. Optional: Default is `black`.
13+
- `arr`: an array with the shape, it can be provided in two shapes.
14+
- 4 items: (dependency: text content, indentation: integer starting from 0, formula: text content, rule: text content).
15+
- 3 items: the same as above, but without the dependency.
16+
- `style-dep`: the styling function that will be applied to the dependencies. Optional: Default is `content => text(style: "italic", content)`.
17+
- `style-formula`: the styling function that will be applied to the formula. Optional: Default is `content => content`.
18+
- `style-rule`: the styling function that will be applied to the rule. Optional: Default is `content => text(style: "bold", content)`.
19+
20+
`ded-nat-boxed` is a function that returns the deduction in a `box` and expects:
21+
- `stcolor`: the stroke color of the indentation guides. Optional: Default is `black`.
22+
- `premises-and-conclusion`: bool, whether to automatically insert or not the premises and conclusion of the derivation above the lines. Optional: Default is `true`.
23+
- `premise-rule-text`: text content, used for finding the premises' formulas when `premises-and-conclusion` is set to `true`. Optional: Default is `"PR"`.
24+
- `arr`: an array with the shape, it can be provided in two shapes.
25+
- 4 items: (dependency: text content, indentation: integer starting from 0, formula: text content, rule: text content).
26+
- 3 items: the same as above, but without the dependency.
27+
- `style-dep`: the styling function that will be applied to the dependencies. Optional: Default is `content => text(style: "italic", content)`.
28+
- `style-formula`: the styling function that will be applied to the formula. Optional: Default is `content => content`.
29+
- `style-rule`: the styling function that will be applied to the rule. Optional: Default is `content => text(style: "bold", content)`.
30+
31+
32+
> Note: depending on your layout, this functions may fail to compile due to a high enough amount of indentation (due to the recursive implementation of the layout).
33+
> In my tests, depending on the content of the line, the compiler will panic at around 15-20 indentation levels.
34+
> ```typst
35+
> ("1", 16, $forall y ((Q y a and R y a) -> not Q a y)$, "TEST")
36+
> ```
37+
> ![Image of rendered test](examples/indentation-test.png)
38+
39+
40+
### Example
41+
42+
```typ
43+
#import "@preview/derive-it:1.0.0": *
44+
45+
#ded-nat(stcolor: black, arr:(
46+
("1", 0, $forall x (P x) and forall x (Q x)$, "PR"),
47+
("2", 0, $forall x (P x -> R x)$, "PR"),
48+
49+
("1", 0, $forall x (P x)$, "S 1"),
50+
("1", 0, $P a$, "IU 3"),
51+
("2", 0, $P a -> R a$, "IU 2"),
52+
("1,2", 0, $R a$, "MP 4, 5"),
53+
54+
("1,2", 0, $forall x (R x)$, "GU 6"),
55+
))
56+
57+
#ded-nat-boxed(stcolor: black, premises-and-conclusion: false, arr: (
58+
("1", 0, $forall x (S x b) and not forall y (P y -> Q b y)$, "PR"),
59+
("2", 0, $forall x forall y (Q x y -> not Q y x)$, "PR"),
60+
("3", 1, $not forall x (not P x) -> forall y (S y b -> Q b y)$, "Sup. RAA"),
61+
("1", 1, $not forall y (P y -> Q b y)$, "S 1"),
62+
("1", 1, $exists y not (P y -> Q b y)$, "EMC 4"),
63+
("6", 2, $not (P a -> Q b a)$, "Sup. IE 5"),
64+
("7", 3, $not (P a and not Q b a)$, "Sup. RAA"),
65+
("7", 3, $not P a or not not Q b a$, "DM 7"),
66+
("9", 4, $not P a$, "Sup. PC"),
67+
("9", 4, $not P a or Q b a$, "Disy. 9"),
68+
("", 3, $not P a -> (not P a or Q b a)$, "PC 9-10"),
69+
("12", 4, $not not Q b a$, "Sup. PC"),
70+
("12", 4, $Q b a$, "DN 12"),
71+
("12", 4, $not P a or Q b a$, "Disy. 13"),
72+
("", 3, $not not Q b a -> (not P a or Q b a)$, "PC 12-14"),
73+
("7", 3, $not P a or Q b a$, "Dil. 8,11,15"),
74+
("7", 3, $P a -> Q b a$, "IM 16"),
75+
("6,7", 3, $(P a -> Q b a) and not (P a -> Q b a)$, "Conj. 6, 17"),
76+
("6", 2, $P a and not Q b a$, "RAA 7-18"),
77+
("6", 2, $P a$, "S 19"),
78+
("6", 2, $exists x (P x)$, "GE 20"),
79+
("6", 2, $not forall x (not P x)$, "EMC 21"),
80+
("3,6", 2, $forall y (S y b -> Q b y)$, "MP 3, 22"),
81+
("3,6", 2, $S a b -> Q b a$, "IU 23"),
82+
("1", 2, $forall x (S x b)$, "S 1"),
83+
("1", 2, $S a b$, "IU 25"),
84+
("1,3,6", 2, $Q b a$, "MP 24, 25"),
85+
("6", 2, $not Q b a$, "S 19"),
86+
("1,3,6", 2, $Q b a or not exists y not (P y -> Q b y)$, "Disy. 27"),
87+
("1,3,6", 2, $not exists y not (P y -> Q b y)$, "MTP 28, 29"),
88+
("1,3", 1, $not exists y not (P y -> Q b y)$, "IE 5, 6, 30"),
89+
("1,3", 1, $not exists y not (P y -> Q b y) and exists y not (P y -> Q b y)$, "Conj. 5, 31"),
90+
91+
("1", 0, $not (not forall x (not P x) -> forall y ( S y b -> Q b y))$, "RAA 3-32"),
92+
))
93+
```
94+
95+
# Development
96+
97+
In order to compile locally `examples/example.typ` the command is:
98+
99+
```sh
100+
typst compile examples/example.typ --root .
101+
```
499 KB
Loading

0 commit comments

Comments
 (0)