Core C++

4.1. Declaration🔗

Definition4.1.1
Group: Variables, update and commands. (9)
Group member previews
Preview
Definition 4.2.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 3
Statement dependency previews
Preview
Definition 2.1.5
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 3
Reverse dependency previews
Preview
Definition 4.2.1
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Every local declaration has an initialiser, by the grammar. It allocates a fresh location and extends \rho for the following commands. With auto, \tau is the type of the initialiser.

\dfrac{\Gamma \vdash e : \tau \qquad \tau \neq \mathsf{void}}{\Gamma \vdash \tau\ x = e \dashv \Gamma[x \mapsto \tau]}\;\textsf{(T-Decl)}

\dfrac{\Gamma \vdash e : \tau \qquad \tau \neq \mathsf{void}}{\Gamma \vdash \mathtt{auto}\ x = e \dashv \Gamma[x \mapsto \tau]}\;\textsf{(T-Auto)}

\dfrac{\rho, \sigma \vdash e \Rightarrow v, \sigma' \qquad (\ell, \sigma'') = \mathrm{alloc}(\sigma', v)}{\rho, \sigma \vdash \tau\ x = e \Rightarrow \mathsf{normal}, \rho[x \mapsto \ell], \sigma''}\;\textsf{(Decl)}

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.1.1●2 definitions
  • opaquedefined in CoreCpp/Typing.lean
    complete
    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.lean
    complete
    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, ρ', σ'