Giter VIP home page Giter VIP logo

typst-prooftree's Introduction

Prooftrees

This package is for constructing proof trees in the style of natural deduction or the sequent calculus, for typst 0.7.0. Please do open issues for bugs etc :)

Features:

  • Inferences can have arbitrarily many premises.
  • Inference lines can have left and/or right labels¹
  • Configurable² per tree and per line: premise spacing, the line stroke, etc... .
  • They're proof trees.

¹ The placement of labels is currently very primitive, and requires much user intervention.

² Options are quite limited.

Usage

The user interface is inspired by bussproof's; a tree is constructed by a sequence of 'lines' that state their number of premises. src/prooftrees.typ contains the documentation and the main functions needed.

The code for some example trees can be seen in examples/prooftree_test.typ.

Examples

A single inference would be:

#import "@preview/prooftrees:0.1.0"

#prooftree.tree(
    prooftree.axi[$A => A$],
    prooftree.uni[$A => A, B$]
)

A more interesting example:

#import "@preview/prooftrees:0.1.0"

#prooftree.tree(
    prooftree.axi[$B => B$],
    prooftree.uni[$B => B, A$],
    prooftree.uni[$B => A, B$],
        prooftree.axi[$A => A$],
        prooftree.uni[$A => A, B$],
    prooftree.bin[$B => A, B$]
)

An n-ary inference can be made:

#import "@preview/prooftrees:0.1.0"

#prooftrees.tree(
    prooftrees.axi(pad(bottom: 2pt, [$P_1$])),
    prooftrees.axi(pad(bottom: 2pt, [$P_2$])),
    prooftrees.axi(pad(bottom: 2pt, [$P_3$])),
    prooftrees.axi(pad(bottom: 2pt, [$P_4$])),
    prooftrees.axi(pad(bottom: 2pt, [$P_5$])),
    prooftrees.axi(pad(bottom: 2pt, [$P_6$])),
    prooftrees.nary(6)[$C$],
)

Known Issues:

Superscripts and subscripts clip with the line

The boundaries of blocks containing math do not expand enough for sub/pscripts; I think this is a typst issue. Short-term fix: add manual vspace or padding in the cell.

Implementation

The placement of the line and conclusion is calculated using measure on the premises and labels, and doing geometric arithmetic with these values.

typst-prooftree's People

Contributors

david-davies avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.