4.4. Sequence and block
The sequence carries the environment from one command to the next. A \mathsf{ret} interrupts the sequence.
\dfrac{}{\Gamma \vdash \varepsilon \dashv \Gamma}\;\textsf{(T-Seq-Empty)}
\dfrac{\Gamma \vdash c \dashv \Gamma_1 \qquad \Gamma_1 \vdash cs \dashv \Gamma_2}{\Gamma \vdash c\ cs \dashv \Gamma_2}\;\textsf{(T-Seq)}
\dfrac{}{\rho, \sigma \vdash \varepsilon \Rightarrow \mathsf{normal}, \rho, \sigma}\;\textsf{(Seq-Empty)}
\dfrac{\rho, \sigma \vdash c \Rightarrow \mathsf{normal}, \rho_1, \sigma_1 \qquad \rho_1, \sigma_1 \vdash cs \Rightarrow r, \rho_2, \sigma_2}{\rho, \sigma \vdash c\ cs \Rightarrow r, \rho_2, \sigma_2}\;\textsf{(Seq)}
\dfrac{\rho, \sigma \vdash c \Rightarrow \mathsf{ret}\,v, \rho_1, \sigma_1}{\rho, \sigma \vdash c\ cs \Rightarrow \mathsf{ret}\,v, \rho_1, \sigma_1}\;\textsf{(Seq-Ret)}
The implementations are partial, so Lean records opaque constants that carry the type and not the body, and no property of them is proved here.
Lean code for Definition4.4.1●2 definitions
Associated Lean declarations
-
CoreCpp.Typing.cmds[complete]
-
CoreCpp.Eval.cmds[complete]
-
CoreCpp.Typing.cmds[complete] -
CoreCpp.Eval.cmds[complete]
-
opaquedefined in CoreCpp/Typing.leancomplete
opaque CoreCpp.Typing.cmds (p : CoreCpp.Program) (τᵣ : CoreCpp.Ty) (Γ : CoreCpp.TEnv) : List CoreCpp.Cmd → CoreCpp.T CoreCpp.TEnv
opaque CoreCpp.Typing.cmds (p : CoreCpp.Program) (τᵣ : CoreCpp.Ty) (Γ : CoreCpp.TEnv) : List CoreCpp.Cmd → CoreCpp.T CoreCpp.TEnv
Γ ⊢ c₁ … cₙ ⊣ Γₙ, threading the context through the sequence. ``` ──────────── (T-Seq-Empty) Γ ⊢ c ⊣ Γ₁ Γ₁ ⊢ cs ⊣ Γ₂ Γ ⊢ ε ⊣ Γ ──────────────────────────── (T-Seq) Γ ⊢ c cs ⊣ Γ₂ ``` -
opaquedefined in CoreCpp/Eval.leancomplete
opaque CoreCpp.Eval.cmds (fs : CoreCpp.FunEnv) (ρ : CoreCpp.Env) (σ : CoreCpp.Store) : List CoreCpp.Cmd → CoreCpp.M (CoreCpp.Ctrl × CoreCpp.Env × CoreCpp.Store)
opaque CoreCpp.Eval.cmds (fs : CoreCpp.FunEnv) (ρ : CoreCpp.Env) (σ : CoreCpp.Store) : List CoreCpp.Cmd → CoreCpp.M (CoreCpp.Ctrl × CoreCpp.Env × CoreCpp.Store)
Command sequences. ``` ────────────────────────── (Seq-Empty) ρ, σ ⊢ ε ⇒ normal, ρ, σ ``` ``` ρ, σ ⊢ c ⇒ normal, ρ₁, σ₁ ρ₁, σ₁ ⊢ cs ⇒ r, ρ₂, σ₂ ──────────────────────────────────────────────────── (Seq) ρ, σ ⊢ c cs ⇒ r, ρ₂, σ₂ ``` The environment ρ₁ carries the binding of c to the rest of the sequence. ``` ρ, σ ⊢ c ⇒ ret v, ρ₁, σ₁ ───────────────────────────── (Seq-Ret) the return interrupts the sequence ρ, σ ⊢ c cs ⇒ ret v, ρ₁, σ₁ ```
-
CoreCpp.Typing.cmd[complete] -
CoreCpp.Eval.cmd[complete] -
CoreCpp.Eval.fresh[complete]
The block discards the extension of \rho and removes from \sigma the locations it allocated. The function Eval.fresh computes \rho' \setminus \rho restricted to the owned bindings, so the alias a reference declaration made never frees the location it names. Scope is the restoration of \rho, lifetime is the removal from \sigma.
\dfrac{\Gamma \vdash c_1 \ldots c_n \dashv \Gamma'}{\Gamma \vdash \{\, c_1 \ldots c_n \,\} \dashv \Gamma}\;\textsf{(T-Block)}
\dfrac{\rho, \sigma \vdash c_1 \ldots c_n \Rightarrow r, \rho', \sigma'}{\rho, \sigma \vdash \{\, c_1 \ldots c_n \,\} \Rightarrow r, \rho, \sigma' \setminus (\rho' \setminus \rho)}\;\textsf{(Block)}
Some of the implementations are partial, so Lean records opaque constants that carry the type and not the body, and no property of them is proved here.
Lean code for Definition4.4.2●3 definitions
Associated Lean declarations
-
CoreCpp.Typing.cmd[complete]
-
CoreCpp.Eval.cmd[complete]
-
CoreCpp.Eval.fresh[complete]
-
CoreCpp.Typing.cmd[complete] -
CoreCpp.Eval.cmd[complete] -
CoreCpp.Eval.fresh[complete]
-
opaquedefined in CoreCpp/Typing.leancomplete
opaque CoreCpp.Typing.cmd (p : CoreCpp.Program) (τᵣ : CoreCpp.Ty) (Γ : CoreCpp.TEnv) : CoreCpp.Cmd → CoreCpp.T CoreCpp.TEnv
opaque CoreCpp.Typing.cmd (p : CoreCpp.Program) (τᵣ : CoreCpp.Ty) (Γ : CoreCpp.TEnv) : CoreCpp.Cmd → CoreCpp.T CoreCpp.TEnv
Γ ⊢ c ⊣ Γ', under the return type τᵣ of the enclosing function.
-
opaquedefined in CoreCpp/Eval.leancomplete
opaque CoreCpp.Eval.cmd (fs : CoreCpp.FunEnv) (ρ : CoreCpp.Env) (σ : CoreCpp.Store) (c : CoreCpp.Cmd) : CoreCpp.M (CoreCpp.Ctrl × CoreCpp.Env × CoreCpp.Store)
opaque CoreCpp.Eval.cmd (fs : CoreCpp.FunEnv) (ρ : CoreCpp.Env) (σ : CoreCpp.Store) (c : CoreCpp.Cmd) : CoreCpp.M (CoreCpp.Ctrl × CoreCpp.Env × CoreCpp.Store)
ρ, σ ⊢ c ⇒ r, ρ', σ'
-
defdefined in CoreCpp/Eval.leancomplete
def CoreCpp.Eval.fresh (ρ ρ' : CoreCpp.Env) : List CoreCpp.Loc
def CoreCpp.Eval.fresh (ρ ρ' : CoreCpp.Env) : List CoreCpp.Loc
Locations a block allocated, the owned bindings of ρ' ∖ ρ, for scope exit. The bindings a reference declaration added alias locations that exist before or outside the block, and those locations stay in σ.