-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.lean
More file actions
45 lines (41 loc) Β· 3.03 KB
/
Copy pathMain.lean
File metadata and controls
45 lines (41 loc) Β· 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- SPDX-FileCopyrightText: Copyright (c) 2026 Objectionary.com
-- SPDX-License-Identifier: MIT
import PhiConfluence
open PhiConfluence Term Attr Binding
/-- Example Ο-programs (encoded as `Term`s) to normalize for the demo. -/
def examples : List (String Γ Term) :=
[ ("β₯ dispatched (Rdd)", dispatch bot (label "x")),
("nested dispatch (cong + Rdd)", dispatch (dispatch bot (label "x")) (label "y")),
("void attribute (Rnull)", dispatch (form [void (label "x")]) (label "x")),
("missing attribute (Rmiss)", app (form [attached phi xi]) (label "a") glob),
("already attached (Rover)", app (form [attached (label "x") glob]) (label "x") xi),
("apply Ο, a no-op (Rstay)", app (form [attached rho glob]) rho glob),
("decorator dispatch (Rphi)", dispatch (form [void phi]) (label "y")),
("positional rename (Ralpha)", dispatch (app (form [void (label "x")]) (alpha 0) glob) (label "y")),
("fill a void slot (Rcopy)", dispatch (app (form [void (label "x")]) (label "x") glob) (label "y")),
("Ο-feedback dispatch (Rdot)", dispatch (form [attached (label "x") bot]) (label "x")),
("normal form (no rule)", dispatch glob (label "x")) ]
def main : IO Unit := do
IO.println "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
IO.println " Ο-calculus normalization rules"
IO.println " (generated from phino's resources/*.yaml β the SAME source the"
IO.println " paper's Fig. 4 is rendered from; compare directly)"
IO.println "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
for r in normalizationRules do
IO.println s!" {ppRule r}"
IO.println " + congruence: a step may occur inside any subterm"
IO.println ""
IO.println " (The reducer below implements all eleven rules β dd, dc, null, over, stop,"
IO.println " miss, stay, phi, alpha, dot, copy β and `reduce_sound` proves every step it"
IO.println " takes is a genuine `Step`.)"
IO.println ""
IO.println "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
IO.println " Example reductions, computed by this prover's own reducer"
IO.println "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
for (name, e) in examples do
let steps := trace 100 e
IO.println s!" {name}:"
IO.println s!" {String.intercalate " β " (steps.map ppTerm)}"
IO.println ""
IO.println " (Each printed step is produced by `reduceStep`, and `reduce_sound` proves"
IO.println " every such step is a genuine `Step` β so the trace is certified.)"