I'm considering a simple toy model. The spacetime is flat with $d$ space dimensions. Using cartesian coordinates, the spacetime metric is Minkowskian : $$\tag{1} ds^2 = dt^2 - dx_1^2 - dx_2^2 - dx_3^2 - \ldots - dx_d^2. $$ A massless scalar field $\Phi$ is propagating in that spacetime according to the following PDE : $$\tag{2} \frac{\partial^2 \Phi}{\partial \, t^2} - \frac{\partial^2 \Phi}{\partial \, x_1^2} - \frac{\partial^2 \Phi}{\partial \, x_2^2} - \frac{\partial^2 \Phi}{\partial \, x_3^2} - \ldots - \frac{\partial^2 \Phi}{\partial \, x_d^2} = 0. $$ Of course, $d \ge 1$ is just any integer. But what if it becomes a dynamical variable, dependant on the value of $\Phi$? I'm not considering an extension to real values ; $d$ would still be an integer, but that could vary from place to place in spacetime : $d = 1$ in some patch of spacetime while $d = 2$ or $d = 3$ in other parts of spacetime. Matching the patches boundaries could be done a bit like a thickless string ($d = 1$) smoothly getting a thickness (cylindrical surface ; $d = 2$), then getting a bulk ($d = 3$), etc, but I'm not sure this is actually making any sense.
How could we make sense of this idea of a dynamical spacetime dimension, and define the dynamics of $d$ now considered as a kind of a new scalar field? (constrainted on integers ?).
Introducing some variable scale factors, I was thinking about an infinite metric like this : $$\tag{3} ds^2 = dt^2 - a_1^2(t, x)\, dx_1^2 - a_2^2(t, x)\, dx_2^2 - a_3^2(t, x)\, dx_3^2 - a_4^2(t, x)\, dx_4^2 - \ldots, $$ where $a_i(t, x)$ are new dynamical variables and $i = 1, 2, 3, \dots, \infty$. In a one dimensional space ($d = 1$), $a_i = 0$ for all $i = 2, 3, \dots, \infty$. If space is two dimensional ($d = 2$), then $a_i = 0$ for all $i = 3, 4, \dots, \infty$, etc.
I'm "visualizing" these dynamical dimensions as an infinity of closed loops ; $0 \le x_i < 2 \pi \ell$, all fluctuating at a tiny scale ($a_i$ randomly pulsating and oscillating, such that $a_i \approx 0$ for most $i > 1$), then suddenly blowing up if the scalar field $\Phi$ gets a special high value, locally or globally. When the spacetime is getting (or losing) some new (old) local space dimension, it would define a dimensional phase transition.
How could we obtain the Einstein (or FLRW) equations for such an infinite metric like (3) above, especially if $a_i$ depends on $t$ only? Was this idea already considered before?