Skip to content

Commit 19f549b

Browse files
xaionaro@dx.centerxaionaro@dx.center
authored andcommitted
Start playing with Lean
1 parent da51da9 commit 19f549b

35 files changed

+2055
-21
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Lean Proofs & Differential Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
proofs:
10+
name: Lean 4 Proofs
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: leanprover/lean-action@v1
16+
with:
17+
build-args: ""
18+
lake-package-directory: proofs
19+
20+
differential:
21+
name: Differential Tests (Lean <-> Go)
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-go@v5
27+
with:
28+
go-version: "1.24"
29+
30+
- uses: leanprover/lean-action@v1
31+
with:
32+
build-args: ""
33+
lake-package-directory: proofs
34+
35+
- name: Run differential tests
36+
run: make test-differential

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ capi/manifests/.gen_*.yaml
2929
cligen
3030
ndkcli
3131
build/
32+
/.lake

Main.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import ProofsTmp
2+
3+
def main : IO Unit :=
4+
IO.println s!"Hello, {hello}!"

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ BUILD_DIR := build
2525

2626
.PHONY: all capi specs idiomatic clean regen fixtures test lint check-examples check-no-capi \
2727
e2e e2e-build e2e-examples e2e-examples-test e2e-audio \
28-
ndkcli ndkcli-commands ndkcli-release install-ndk
28+
ndkcli ndkcli-commands ndkcli-release install-ndk \
29+
proofs test-differential
2930

3031
all: specs capi idiomatic
3132

@@ -97,6 +98,15 @@ regen: clean specs capi idiomatic
9798
test:
9899
go test $$(go list ./... | grep -v -E '/(capi|cmd|tests|examples)/|/ndk/[a-z][a-z0-9]*$$') -count=1
99100

101+
# Build Lean 4 proofs (requires elan/lake toolchain).
102+
proofs:
103+
cd proofs && lake build
104+
105+
# Run differential tests comparing Go implementations against Lean oracle.
106+
# Requires: elan/lake toolchain. Builds the oracle automatically.
107+
test-differential: proofs
108+
go test ./tools/pkg/capigen/ ./tools/pkg/idiomgen/ -run TestDifferential -v
109+
100110
# Verify cmd/ and examples/ do not import capi packages.
101111
check-no-capi:
102112
@if grep -rl '"github.com/xaionaro-go/ndk/capi' cmd/ examples/ 2>/dev/null; then \

ProofsTmp.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- This module serves as the root of the `ProofsTmp` library.
2+
-- Import modules here that should be built as part of the library.
3+
import ProofsTmp.Basic

ProofsTmp/Basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def hello := "world"

lakefile.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name = "proofs_tmp"
2+
version = "0.1.0"
3+
defaultTargets = ["proofs_tmp"]
4+
5+
[[lean_lib]]
6+
name = "ProofsTmp"
7+
8+
[[lean_exe]]
9+
name = "proofs_tmp"
10+
root = "Main"

lean-toolchain

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leanprover/lean4:v4.16.0
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Lean Action CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: leanprover/lean-action@v1

proofs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.lake

0 commit comments

Comments
 (0)