[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"GmdIKvMhRz":3},"# Call-by-Push-Value\n\nThis is a proof development on the metatheory of call-by-push-value,\nwhich makes heavy use of mutual induction,\nsince the syntax of terms is mutually defined.\n\n```\nA ::= Unit | A + A | A × A | U B\nB ::= A → B | B & B | F A\n\nv ::= x | () | inl v | inr v | (v, v) | {v}\nm ::= v! | λx. m | m v | return v | let x ← m in m\n  | case v of {inl x => m; inr x => m}\n  | let (x, y) = v in m\n  | ⟨m, m⟩ | m.1 | m.2\n```\n\nThis means that everything from reduction to typing to the logical relation\nare all mutually defined, and eliminating them generally requires mutual induction.\n\n## Development structure and dependency graph\n\nThe structure of the proofs begins with the usual basics.\n\n* RTC.lean: Reflexive, transitive closure of binary relations\n* Syntax.lean: Syntax, renaming, substitution, and contexts\n* Typing.lean: Typing rules, renaming, and weakening\n* Evaluation.lean: Evaluation of (closed) commands,\n  which doesn't evaluate under binders and branches\n* CK.lean: CK machine semantics, with soundness and completeness\n  with respect to evaluation\n* Reduction.lean: Small-step reduction semantics for values and commands,\n  which reduces everywhere to normal form\n\nThe primary goal of the development is to prove strong normalization:\nall reduction paths are normalizing.\n\n* NormalInd.lean: An inductive characterization of strongly normal and neutral terms,\n  as well as a notion of strong reduction.\n* NormalAcc.lean: The traditional definition of strong normalization\n  as an accessibility predicate with respect to reduction.\n* OpenSemantics.lean: A logical relation between types and sets of terms\n  that are backwards closed with respect to strong reduction.\n* Soundness.lean: Semantic typing, defined in terms of the logical relation,\n  and the fundamental theorem that syntactic typing implies semantic typing.\n* Normalization.lean: Syntactic typing implies semantic typing\n  implies strong normalization (inductive)\n  implies strong normalization (traditional).\n\nRemaining proof files show interesting properties of CBPV.\n\n* LeftmostOutermost.lean: A deterministic single-step reduction semantics\n  based on strong reduction, proven to step to normal forms.\n* ClosedSemantics.lean: A logical relations proof that closed, well-typed terms\n  are strongly normalizing with respect to evaluation.\n* Equivalence.lean: A logical equivalence between closed terms of a type\n  with respect to evaluation (subsumes the unary logical relation).\n* CBV.lean, CBN.lean: Translations from STLC with fine-grained CBV and CBN semantics,\n  along with proofs that they preserve well-typedness and CK machine semantics.\n* Lazy.lean: Levy's \"lazy\" translation, but directly to CBPV,\n  as outlined in [this blog post](https://ionathan.ch/2025/11/06/strict-let.html)\n* Antisubstitution.lean (fails checking): An unused substitution lemma,\n  similar to the antirenaming lemma.\n\n```\n        ╭──────────RTC──────┬─────────╮\n        ├───────┬──Syntax───┼─────────┤\n        │       │           │         │\n        ╽       ╽           ╽         ╽\nEvaluation    Typing    NormalInd    Reduction\n  │   │       │ │  │        │  │         │    \n  │   ╽       ╽ │  │        ╽  ╰─────────│────╼ LeftmostOutermost\n  │   CK ─╼ CBV │  │  OpenSemantics      │      Antisubstitution\n  │ Lazy ╾─ CBN │  │    │                │\n  ╽             ╽  ╽    ╽                ╽\n  ClosedSemantics  Soundness         NormalAcc\n  Equivalence             │           │\n                          ╽           ╽\n                          Normalization\n```\n\n## When to `@[simp]` and `@[reducible]`\n\nNot all definitions are added to the default `simp` set.\nAs a general rule, a definition should be added if it is not a type-level term\nand:\n\n* It matches on an argument; or\n* It does not match on an argument, but is not used in other definitions.\n\nFor instance, `Syntax.cons` matches on naturals,\nand we want it to be in the simp set so that it reduces on constructors.\nHowever, `Syntax.lift` doesn't match on an argument and is used in `Syntax.renameCom`,\nso we don't want it to be in the simp set,\nsince it will always reduce too far when simplifying `renameCom`,\nand prevent theorems about `renameCom` and `lift` from applying.\nAs another example, `ClosedSemantics.semCtxt` is used within `ClosedSemantics.semCom`,\nso it shouldn't be in the simp set, but `semCom` itself can be.\n\nType-level definitions, especially recursive ones,\noften represent predicates that could otherwise be encoded as inductives.\n`ClosedSemantics.𝒱` and `ClosedSemantics.𝒞` are such definitions,\nin contrast with the inductives `OpenSemantics.𝒱` and `OpenSemantics.𝒞`.\nThe definitions should be explicitly unfolded as needed,\ncorresponding with invoking `cases` on the corresponding inductives.\nOtherwise, simplification may again reduce too far\nand prevent theorems from applying.\n\nType-level definitions which are just type aliases\nshould be marked as `@[reducible]` so that instances for typeclasses\non the aliased types can be used.\nIn particular, definitions consisting of applications of `RTC.RTC`\nneed to be `@[reducible]` so that `calc` can find the `Trans` instances.\n",1777138843585]