Skip to content
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
13 changes: 13 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Lemma",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
"postCreateCommand": "./install.sh",
"remoteEnv": {
"PATH": "${containerEnv:PATH}:/home/vscode/.local/bin:/home/vscode/.elan/bin"
},
"customizations": {
"vscode": {
"extensions": ["leanprover.lean4"]
}
}
}
54 changes: 53 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- name: Lint
run: cd pipeline && ruff check . && ruff format --check .

- name: Build the Explorer
run: cd pipeline && python -m lemma.cli --root .. site

- name: Python tests
run: cd pipeline && python -m pytest -q

Expand All @@ -51,4 +54,53 @@ jobs:
cd pipeline
python -m lemma.cli --root .. formalize --offline
python -m lemma.cli --root .. report --no-build
git -C .. diff --stat -- README.md reports/library.md || true
git -C .. diff --stat -- README.md reports/library.md
git -C .. diff --exit-code -- Lemma scripts README.md

fresh-clone-report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Lean 4 from the release tarball
run: |
set -euo pipefail
curl -sSL -o lean.tar.zst "https://github.com/leanprover/lean4/releases/download/v4.15.0/lean-4.15.0-linux.tar.zst"
mkdir -p "$HOME/lean"
tar --zstd -xf lean.tar.zst -C "$HOME/lean" --strip-components=1
rm lean.tar.zst
echo "$HOME/lean/bin" >> "$GITHUB_PATH"

- uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: make report with no earlier build reproduces the checked-in numbers
run: |
make install PY=python
make report PY=python
git diff --exit-code -- Lemma scripts README.md
test -z "$(git status --porcelain -- reports/failed Lemma)"

installer:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: One-line install from a pipe, as a new user runs the script
env:
LEMMA_REPO_URL: file://${{ github.workspace }}
LEMMA_HOME: ${{ runner.temp }}/lemma
run: bash < install.sh

- name: Commands work after install
run: |
"$HOME/.local/bin/lemma" doctor
"$HOME/.local/bin/lemma" tour
"$HOME/.local/bin/lemma" compare Exhaustion Vigor
"$HOME/.local/bin/lemma" new --name "ci draft" --definition "A check of the draft path" \
--citation "CI" --category AffectiveState --level Individual --horizon Weekly --part Energy
40 changes: 40 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: explorer

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Build the Explorer from the checked-in reports
run: |
python -m pip install -e pipeline
python -m lemma.cli --root . site

- uses: actions/upload-pages-artifact@v3
with:
path: site

- id: deployment
uses: actions/deploy-pages@v4
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ dist/
.env
reports/_scratch/
.DS_Store

# Generated by lemma new and lemma site
drafts/
site/
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ All notable changes to the kernel, the primitive vocabulary and the
pipeline. The kernel follows semantic versioning (`KERNEL_VERSION` in
`Lemma/Kernel/Basic.lean`).

## Pipeline 0.2.0 (unreleased)

The kernel, the library, the checks and every report stay as released in 0.1.0.

### Access for readers without Lean
- Lemma Explorer: a generated, self-contained web page for browsing constructs, comparing definitions, reading disagreements and the agenda, drafting a construct, and downloading tables as CSV.
- Commands `lemma doctor`, `tour`, `find`, `show`, `compare`, `new`, `try`, `site`. Compiler replies are explained in plain language.
- `install.sh` for one-step setup on macOS and Linux, with a Codespaces configuration for every other platform.

### Curation
- `config/curation.yaml` holds the findings, cautions and starting collections, with counts filled from the compiler report.
- Guides under `docs/`: getting started, reading the results, glossary, commands.

### Assurance
- Tests hold the plain-language overlap rule to every overlap the compiler reports, the browser logic to the Python logic, and a generated draft to a real compile.
- CI runs the installer on Ubuntu and macOS.

## Kernel 0.1.0, library 0.1.0, pipeline 0.1.0 (2026-11-01)

Initial release accompanying the Stage 1 proposal.
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Modeled on the Mathlib contribution guidelines: small, reviewed additions
to a shared library, with conventions enforced by the compiler where the
compiler can, and by review where it cannot.

## Contributing without Lean

Draft a construct in the [Explorer](https://sumervaid.github.io/lemma/#draft) or with `lemma new`, then open a [discussion](https://github.com/sumervaid/lemma/discussions/1) with the source paper. Corrections to a reading of a source are as valuable as new entries, and they need no code.

## What a contribution is

- **A theory module** under `Lemma/Theories/<Theory>.lean`: the constructs a
Expand Down
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ endif
PY ?= python3
LEMMA ?= $(PY) -m lemma.cli

.PHONY: help install build test test-lean test-python lint format formalize check score distinct verify report clean
.PHONY: help setup doctor tour site install build test test-lean test-python lint format formalize check score distinct verify report clean

help:
@echo "make setup one-step setup: Python environment, Lean, compiled library"
@echo "make doctor state what works on this machine"
@echo "make tour the curated findings"
@echo "make site build the Explorer at site/index.html"
@echo "make install install the Python pipeline (editable) and dev tools"
@echo "make build lake build (kernel, library, theories, accepted generated modules)"
@echo "make test lake build LemmaTests (#guard_msgs) + pytest + ruff"
Expand All @@ -25,6 +29,18 @@ help:
@echo "make verify write a review sheet for human verification"
@echo "make report formalize + check + score + distinct + precision; refreshes README numbers"

setup:
./install.sh

doctor:
cd pipeline && $(LEMMA) --root .. doctor

tour:
cd pipeline && $(LEMMA) --root .. tour

site:
cd pipeline && $(LEMMA) --root .. site

install:
$(PY) -m pip install -e pipeline[dev]

Expand Down
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
# Lemma

[![CI](https://github.com/sumervaid/lemma/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/sumervaid/lemma/actions/workflows/ci.yml)
[![Explorer](https://img.shields.io/badge/Explorer-open_in_browser-0b5cad.svg)](https://sumervaid.github.io/lemma/)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
[![Lean 4.15.0](https://img.shields.io/badge/Lean-4.15.0-blue.svg)](lean-toolchain)

A type system for organizational constructs and propositions, built on Lean 4, with an AI pipeline that formalizes papers into the type system and a scorer that ranks typed propositions by how badly they need empirical verification.

Sumer Vaid, Harvard Business School. Apache-2.0. Research prototype accompanying the Stage 1 proposal to the *Organization Science* special issue on AI-Enabled Frontiers in Organizational Science.

## Start here

| Goal | Route | Setup |
|---|---|---|
| Browse constructs, compare definitions, test an idea | [Lemma Explorer](https://sumervaid.github.io/lemma/) | None |
| Run the compiler with no local install | [Open a Codespace](https://codespaces.new/sumervaid/lemma) | A GitHub account |
| Run the compiler on a laptop | One line below, for macOS or Linux | About five minutes |
| Reproduce the proposal | [For reviewers](#for-reviewers) | Lean 4.15.0 with Python 3.11 or later |

```bash
curl -fsSL https://raw.githubusercontent.com/sumervaid/lemma/main/install.sh | bash
lemma tour
```

[Getting started](docs/getting-started.md) walks through each route with no prior knowledge of Lean. [Reading the results](docs/reading-results.md) explains each output, with [a glossary](docs/glossary.md) and [a command list](docs/commands.md).

## For reviewers

Lean 4.15.0 with Python 3.11 or later must be on the path.
Lean 4.15.0 with Python 3.11 or later must be on the path. `make setup` installs both inside the repository.

```bash
make install
Expand Down Expand Up @@ -103,6 +120,8 @@ To run the pipeline with a live model instead of fixtures, point `LEMMA_LLM_BASE

## How to add a construct or a theory

Scholars without Lean can draft in the [Explorer](https://sumervaid.github.io/lemma/#draft) or with `lemma new`, then open a [discussion](https://github.com/sumervaid/lemma/discussions/1). The rest of this section is for direct contributions.

One theory per module under `Lemma/Theories/`, one construct per definition, a citation docstring on every definition, and an overlap declaration for every overlap the compiler reports. `CONTRIBUTING.md` has the checklist.

```lean
Expand Down Expand Up @@ -172,10 +191,13 @@ Lemma/Library/ primitives and base categories
Lemma/Theories/ pilot library, one module per theory
Lemma/Generated/ accepted machine formalizations (pipeline output)
LemmaTests/ #guard_msgs tests pinning compiler messages
pipeline/ Python package `lemma` (formalize, check, score, distinct, verify)
pipeline/ Python package `lemma`, including the Explorer and the reader commands
install.sh one-step setup for macOS and Linux
docs/ guides for readers with no Lean background
fixtures/ paper summaries, fixture formalizations, correlations.csv
bibliography/ curated source list counted by `lemma check`
config/scoring.yaml scorer weights
config/curation.yaml findings and collections shown by `lemma tour` and the Explorer
reports/ generated reports (library, agenda, distinctness, papers, failed modules)
verification/ human review sheets and precision
scripts/report.lean the Lean script that dumps the registries
Expand Down
74 changes: 74 additions & 0 deletions config/curation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Curated reading of the pilot library, shared by `lemma tour` and the Explorer.
# Counts appear as {placeholders} filled from reports/library.json, so a count
# here can never drift from the compiler. A test resolves every name below.

status: >-
Pilot status. Curated entries are the author's readings of {papers_curated_sources} sources.
Pipeline entries come from hand-written fixtures, with no model run.
Correlations on file are placeholder or recalled values. Precision is unmeasured.

findings:
- title: Exhaustion and vigor reduce to one part
body: >-
The library defines both from Energy at one scope, so the compiler reports identical
definitions. The library then records a declared distinction with a stated reason.
caution: The part assignment is the author's reading. The compiler reports what the definitions contain.
compare: [Burnout.Exhaustion, Engagement.Vigor]
- title: Cynicism and dedication show the same pattern
body: >-
Both read identification with work at one scope. The field debated this bipolarity for a
decade, while the compiler surfaces the pair at the moment of definition.
caution: A shared part leaves the empirical question open. Correlations on file await a source check.
compare: [Burnout.Cynicism, Engagement.Dedication]
- title: Two burnout models disagree on one path
body: >-
The sequential model asserts cynicism precedes reduced efficacy. The process model asserts
a null relation at the same scope and boundary.
caution: The reading of Leiter 1993 behind the null awaits a check against the source.
view: disagreements
- title: Challenge demands pull task performance two ways
body: >-
Composition through exhaustion implies a negative path. A direct claim in the library
states a positive relation, which restates the challenge-stressor paradox as a type conflict.
caution: An implied sign describes one mediating path, separate from any total effect.
view: disagreements
- title: "{implied_untested} implied pairs lack a direct claim in the library"
body: >-
Chaining existing claims yields pairs no library entry states. The agenda ranks them for
attention alongside registered claims resting on thin evidence.
caution: Absence from the library differs from absence from the literature. Many pairs may already have tests.
view: agenda
- title: "{formalization_failures} of {papers_pipeline_total} pipeline papers were refused"
body: >-
Each refusal names the missing piece, whether an absent part, an absent aggregation rule,
or a process theory lacking a measurement model.
caution: Hand-written fixtures produced these outcomes in order to exercise the pipeline. No model ran.
view: disagreements

collections:
- title: Burnout and engagement
blurb: The bipolarity question, with facets side by side.
constructs:
- Burnout.Burnout
- Burnout.Exhaustion
- Burnout.Cynicism
- Burnout.ReducedEfficacy
- Engagement.Engagement
- Engagement.Vigor
- Engagement.Dedication
- Engagement.Absorption
- title: Energy across theories
blurb: Constructs from separate literatures resting on one part.
constructs:
- Thriving.Vitality
- Engagement.Vigor
- ShiromVigor.ShiromVigor
- Burnout.Exhaustion
- title: Demands and resources
blurb: Three vocabularies for strain.
constructs:
- JDR.JobDemands
- JDR.JobResources
- COR.Resources
- ERI.Effort
- ERI.Reward
45 changes: 45 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Commands

## For readers

These commands read the checked-in reports. `new` and `try` also run the compiler when Lean is present.

| Command | Purpose |
|---|---|
| `lemma` | Show a short menu |
| `lemma doctor` | State what works on this machine, with next steps |
| `lemma tour` | Print the curated findings with their cautions |
| `lemma find WORDS` | Search constructs, claims and parts |
| `lemma show NAME` | Print one construct in plain language |
| `lemma compare A B` | Set two constructs side by side |
| `lemma new` | Write a construct from plain answers, then check the draft |
| `lemma try FILE` | Check a draft file, with the compiler's reply explained |
| `lemma site --open` | Build the Explorer, then open the page in a browser |

`lemma new` also takes every answer as a flag, for scripted use. Run `lemma new --help` for the list.

## For maintainers

| Command | Purpose |
|---|---|
| `lemma formalize` | Paper to module to compiler |
| `lemma check` | Compiler report at `reports/library.json` |
| `lemma score` | Verification agenda at `reports/agenda.md` |
| `lemma distinct` | Definitional against empirical distinctness |
| `lemma verify` | Review sheet, or precision from labelled sheets |
| `lemma report` | All reports, plus the README numbers |

## Make targets

| Target | Purpose |
|---|---|
| `make setup` | Run `install.sh` |
| `make install` | Install the pipeline into the active Python |
| `make build` | Compile the library |
| `make test` | Lean tests, Python tests, lint |
| `make report` | Regenerate every report |
| `make site` | Build the Explorer at `site/index.html` |

## Curating the Explorer

`config/curation.yaml` holds the findings, cautions and starting collections shown by `lemma tour` and the Explorer. Counts appear as placeholders filled from the compiler report. A test resolves every construct name in the file.
Loading
Loading