Leibniz

1 program Added 2026-02-28T14:06:25Z Agent: claude-codeModel: claude-sonnet-4-6WebSearch: enabled Evidence Report issue View issues
Aliases: —
Provenance: commit e27b2b3583 · authored 2026-02-28T15:06:58+01:00 · agent claude-code · model claude-sonnet-4-6

Sources mentioning this language

1 source · not in taxonomy (canonical name didn't match any upstream)
LLM (this repo) · 1

Related languages

Leda (0.15)Lego (0.15)Lens (0.15)Less (0.15)Lefty (0.14)

LLM-contributed programs

Boolean Algebra

Provenance: commit e27b2b3583 · authored 2026-02-28T15:06:58+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch enabled
code.scrbl · added: 2026-02-28T14:06:25Z
#lang leibniz

@title{Boolean algebra}
@author{Konrad Hinsen}

@context["boolean" #:use "builtins/truth"]{
@section{Logical operations}

The following operators are defined on terms of sort @sort{boolean}:

@tabular[#:sep @hspace[1]
         @list[ @list["NOT:"  @op{¬(boolean) : boolean}]
                @list["AND:"  @op{boolean ∧ boolean : boolean}]
                @list["OR:"   @op{boolean ∨ boolean : boolean}]
                @list["XOR:"  @op{boolean ⊻ boolean : boolean}] ]]

@subsection{Rewrite rules}

@subsubsection{Eliminate NOT and OR}

NOT is replaced by XOR with @term{true}:
  @inset{@rule{¬(X) ⇒ true ⊻ X ∀ X:boolean}}

OR is replaced by XOR and AND:
  @inset{@rule{X ∨ Y ⇒ X ⊻ Y ⊻ (X ∧ Y) ∀ X:boolean  ∀ Y:boolean}}

@subsubsection{Simplify AND relations}

AND is @term{false} if one of its arguments is @term{false}:
  @inset{@rule{X ∧ false ⇒ false ∀ X:boolean}
         @rule{false ∧ X ⇒ false ∀ X:boolean}}

If one argument of AND is @term{true}, the result is the other argument:
  @inset{@rule{X ∧ true ⇒ X ∀ X:boolean}
         @rule{true ∧ X ⇒ X ∀ X:boolean}}

If the two arguments to AND are equal, they are also equal to the result:
  @inset{@rule{X ∧ X ⇒ X ∀ X:boolean}}

@subsubsection{Simplify XOR relations}

XOR with @term{false} leaves truth values unchanged:
  @inset{@rule{X ⊻ false ⇒ X ∀ X:boolean}
         @rule{false ⊻ X ⇒ X ∀ X:boolean}}

If the two arguments to XOR are equal, the result is @term{false}:
  @inset{@rule{X ⊻ X ⇒ false ∀ X:boolean}}

@subsubsection{Standardize combinations of XOR and AND}

The above rules will reduce any boolean expression to a combination of XOR and AND
operations that allow no further simplification. However, it is still possible that
logically equal expressions are rewritten into distinct syntactical forms, making it
difficult to verify that they are equal. The following rule standardizes results
by replacing XOR inside AND by AND inside XOR:
  @inset{@rule{X ∧ (Y ⊻ Z) ⇒ (X ∧ Y) ⊻ (X ∧ Z)
               ∀ X:boolean  ∀ Y:boolean   ∀ Z:boolean}}


@subsection{Tests}

Truth table for Not:
  @inset{@test{¬(false) ⇒ true}
         @test{¬(true) ⇒ false}}

Truth table for AND:
  @inset{@test{false ∧ false ⇒ false}
         @test{false ∧ true ⇒ false}
         @test{true ∧ false ⇒ false}
         @test{true ∧ true ⇒ true}}

Truth table for OR:
  @inset{@test{false ∨ false ⇒ false}
         @test{false ∨ true ⇒ true}
         @test{true ∨ false ⇒ true}
         @test{true ∨ true ⇒ true}}

Truth table for XOR:
  @inset{@test{false ⊻ false ⇒ false}
         @test{false ⊻ true ⇒ true}
         @test{true ⊻ false ⇒ true}
         @test{true ⊻ true ⇒ false}}

}

Contribute — propose a file extension

Tell us where to find evidence about Leibniz (mapped to pl/leibniz). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Leibniz/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← Legs LeLisp →