# Abstract Syntax
The following grammar [(Mosses2025CSE)] summarises the abstract syntax of *Scm*
expressions $\text{E} : \text{Exp}$
with integers $\text{Z} : \text{Int}$,
constants $\text{K} : \text{Con}$ and
identifiers $\text{I} : \text{Ide}$.
The meta-variable $\text{E}^* : \text{Exp}^*$ implicitly ranges over arbitrary sequences of expressions.
@latex
@/latex
$$\begin{align}
\text{K} & ::=
\text{Z} \mid \text{\tt \#t} \mid \text{\tt \#f}
\\
\text{E} & ::=
\text{K} \mid \text{I} \mid \texttt ( \text{E}_0~\text{E}^* \texttt ) \mid \text{\tt (lambda} ~ \text{I} ~ \text{E} \texttt ) \mid
\text{\tt (if} ~ \text{E}_0 ~ \text{E}_1 ~ \text{E}_2 \texttt ) \mid \text{\tt (set!} ~ \text{I} ~ \text{E} \texttt )
\end{align}$$
@latex
@/latex
In the following Agda embedding of the above grammar, the abstract syntax of sequences `E⋆ : Exp⋆` is made explicit:
the empty sequence is represented by `␣␣␣` , and sequence prefixing by `E ␣␣ E⋆`.
```agda
{-# OPTIONS --rewriting --confluence-check #-}
module Examples.Scm.Abstract-Syntax where
open import Data.String.Base public using (String)
Ide = String
variable I : Ide
open import Data.Integer.Base public renaming (ℤ to Int) using ()
data Con : Set where
int : Int → Con
#t : Con
#f : Con
variable K : Con
mutual
data Exp : Set where
con : Con → Exp
ide : Ide → Exp
⦅_␣_⦆ : Exp → Exp⋆ → Exp
⦅lambda_␣_⦆ : Ide → Exp → Exp
⦅if_␣_␣_⦆ : Exp → Exp → Exp → Exp
⦅set!_␣_⦆ : Ide → Exp → Exp
data Exp⋆ : Set where
␣␣␣ : Exp⋆
_␣␣_ : Exp → Exp⋆ → Exp⋆
variable E : Exp; E⋆ : Exp⋆
mutual
data Body : Set where
␣␣_ : Exp → Body
⦅define_␣_⦆ : Ide → Exp → Body
⦅begin_⦆ : Body⁺ → Body
data Body⁺ : Set where
␣␣_ : Body → Body⁺
_␣␣_ : Body → Body⁺ → Body⁺
data Prog : Set where
␣␣␣ : Prog
␣␣_ : Body⁺ → Prog
variable B : Body; B⁺ : Body⁺; Π : Prog
```
[(Mosses2025CSE)]: https://doi.org/10.1145/3759427.3760369