Skip to content

Commit 3532e69

Browse files
committed
Init
1 parent 9b734bd commit 3532e69

35 files changed

Lines changed: 2290 additions & 302 deletions

.github/workflows/deploy.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build and Deploy Book
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
# Allow the deploy job to publish to GitHub Pages.
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
# Allow only one concurrent deployment; let in-progress runs finish.
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: false
20+
21+
jobs:
22+
build:
23+
name: Build book
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
# Installs the toolchain pinned in `lean-toolchain`, runs `lake build`
30+
# (elaborating every chapter / type-checking all proofs), and caches
31+
# `.lake` so the verso and iris-lean dependency builds are reused.
32+
- name: Build and check proofs
33+
uses: leanprover/lean-action@v1
34+
with:
35+
build: true
36+
37+
# `lake build` above already compiled everything; this runs the
38+
# `textbook` executable to render the HTML book and extract the
39+
# example code into `_out/`.
40+
- name: Render book and extract example code
41+
run: lake exe textbook
42+
43+
- name: Assemble site (html + code.zip)
44+
run: |
45+
rm -rf _site
46+
mkdir -p _site
47+
cp -r _out/html-multi/. _site/
48+
(cd _out && zip -r "$GITHUB_WORKSPACE/_site/code.zip" example-code)
49+
50+
# On PRs the full build above already runs, catching breakage early.
51+
# Only upload the Pages artifact for push/manual runs that will deploy
52+
# (this also avoids restricted-permission warnings on PRs from forks).
53+
- name: Upload Pages artifact
54+
if: github.event_name != 'pull_request'
55+
uses: actions/upload-pages-artifact@v3
56+
with:
57+
path: _site
58+
59+
deploy:
60+
name: Deploy to GitHub Pages
61+
needs: build
62+
runs-on: ubuntu-latest
63+
# Publish only for pushes to main and manual runs — never for PRs.
64+
if: github.event_name != 'pull_request'
65+
environment:
66+
name: github-pages
67+
url: ${{ steps.deployment.outputs.page_url }}
68+
steps:
69+
- name: Deploy
70+
id: deployment
71+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Lean / Lake build artifacts
2+
.lake
3+
4+
# Book build outputs
5+
_out
6+
out
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ open Verso.Doc Elab
1111
open Verso.ArgParse
1212
open Lean
1313

14-
namespace TextbookTemplate
14+
namespace BookGen
1515

1616
block_extension Block.savedLean (file : String) (source : String) where
1717
data := .arr #[.str file, .str source]
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/-
22
Copyright (c) 2024-2025 Lean FRO LLC. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Author: David Thrane Christiansen
4+
Author: David Thrane Christiansen, Zongyuan Liu
55
-/
66

77
import Std.Data.HashMap
88
import VersoManual
9-
import TextbookTemplate
9+
import IrisTutorialBook
1010

1111
open Verso Doc
1212
open Verso.Genre Manual
1313

1414
open Std (HashMap)
1515

16-
open TextbookTemplate
16+
open BookGen
1717

1818

1919
-- Computes the path of this very `main`, to ensure that examples get names relative to it
@@ -31,7 +31,7 @@ partial def buildExercises (mode : Mode) (logError : String → IO Unit) (cfg :
3131
let code := (← part text |>.run {}).snd
3232
let dest := cfg.destination / "example-code"
3333
let some mainDir := mainFileName.parent
34-
| throw <| IO.userError "Can't find directory of `TextbookTemplateMain.lean`"
34+
| throw <| IO.userError "Can't find directory of `BookGenMain.lean`"
3535

3636
IO.FS.createDirAll <| dest
3737
for ⟨fn, f⟩ in code do
@@ -86,4 +86,4 @@ def config : RenderConfig where
8686
emitHtmlMulti := .immediately
8787
htmlDepth := 2
8888

89-
def main := manualMain (%doc TextbookTemplate) (extraSteps := [buildExercises]) (config := config)
89+
def main := manualMain (%doc IrisTutorialBook) (extraSteps := [buildExercises]) (config := config)

IrisTutorial.lean

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import IrisTutorial.Basics
2+
import IrisTutorial.Pure
3+
import IrisTutorial.Lang
4+
import IrisTutorial.Specifications
5+
import IrisTutorial.Persistently
6+
import IrisTutorial.LinkedLists
7+
import IrisTutorial.Later
8+
import IrisTutorial.Arrays
9+
import IrisTutorial.GrPredicates
10+
import IrisTutorial.ResourceAlgebra
11+
import IrisTutorial.Invariants
12+
import IrisTutorial.Timeless
13+
import IrisTutorial.StructuredConc
14+
import IrisTutorial.Counter
15+
import IrisTutorial.SpinLock
16+
import IrisTutorial.TicketLock
17+
import IrisTutorial.TicketLockAdvanced
18+
import IrisTutorial.Adequacy
19+
import IrisTutorial.MergeSort
20+
import IrisTutorial.CustomRa
21+
import IrisTutorial.Ofe

IrisTutorial/Adequacy.lean

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import VersoManual
2+
import BookGen.Meta.Lean
3+
4+
open Verso.Genre Manual
5+
open Verso.Genre.Manual.InlineLean
6+
open BookGen
7+
8+
set_option pp.rawOnError true
9+
10+
#doc (Manual) "Adequacy" =>
11+
12+
This chapter has not yet been ported. The Rocq source is
13+
`iris-tutorial/theories/adequacy.v`.

IrisTutorial/Arrays.lean

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import VersoManual
2+
import BookGen.Meta.Lean
3+
4+
open Verso.Genre Manual
5+
open Verso.Genre.Manual.InlineLean
6+
open BookGen
7+
8+
set_option pp.rawOnError true
9+
10+
#doc (Manual) "Arrays in HeapLang" =>
11+
12+
This chapter has not yet been ported. The Rocq source is
13+
`iris-tutorial/theories/arrays.v`.

0 commit comments

Comments
 (0)