Functions, mappings, and bound variables
Read an input-output contract and distinguish free inputs from names bound inside its rule.
Notes
Separate the contract from its workers
Read a function declaration as an input-output contract, its maps-to clause as the rule, and operator-bound names as local workers inside that rule.
Read contract, then rule
$$f:\mathbb{R}^n\to\mathbb{R},\qquad x\mapsto\sum_{i=1}^n w_i x_i$$
The function accepts a real vector, pairs each coordinate with a weight, adds the products, and returns one real scalar.
Use a fresh bound name
$$\sum_{i=1}^n w_i x_i\;\not\equiv\;\sum_{x=1}^n w_x\,x_x$$
Tempting reading: Renaming the bound index i to x even though x already names the free vector input.
Protect the free input
A bound name may change only to a fresh name. Reusing x captures the free input and changes the expression instead of merely relabelling a local counter.
Track free and local names
$$g:\mathcal{X}\to\mathbb{R}^d,\qquad x\mapsto\mathbb{E}_{z\sim p}[h(x,z)]$$
A paper defines a vector-valued function through an expectation over a latent variable.
Mark each variable's scope
Record the domain, codomain, and rule; keep x free from the mapping declaration, mark z as bound by the expectation, and verify that h averages to a d-vector.