5.4. Return
The return yields the control \mathsf{ret}\,v, which Seq-Ret and While-Ret propagate up to the call. The type of the expression is the return type \tau_r of the enclosing function.
\dfrac{\tau_r = \mathsf{void}}{\Gamma \vdash \mathtt{return} \dashv \Gamma}\;\textsf{(T-RetVoid)}
\dfrac{\Gamma \vdash e : \tau_r \qquad \tau_r \neq \mathsf{void}}{\Gamma \vdash \mathtt{return}\ e \dashv \Gamma}\;\textsf{(T-Ret)}
\dfrac{}{\rho, \sigma \vdash \mathtt{return} \Rightarrow \mathsf{ret}\,\mathsf{void}, \rho, \sigma}\;\textsf{(ReturnVoid)}
\dfrac{\rho, \sigma \vdash e \Rightarrow v, \sigma'}{\rho, \sigma \vdash \mathtt{return}\ e \Rightarrow \mathsf{ret}\,v, \rho, \sigma'}\;\textsf{(Return)}
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 Definition5.4.1●2 definitions
Associated Lean declarations
-
CoreCpp.Typing.cmd[complete]
-
CoreCpp.Eval.cmd[complete]
-
CoreCpp.Typing.cmd[complete] -
CoreCpp.Eval.cmd[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, ρ', σ'