Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lindgren price dynamics: dot product, partial derivatives, Hamiltonian, optimal velocity

Definition
LindgrenPriceDynamics

by LG · Sep 30, 2026 · Mathlib 0df444a (Lean v4.33.1)

dynamic-programminggeneral-equilibriumhamilton-jacobi-bellmanlyapunov-stability

Shared definitions for the price-adjustment model of Lindgren (2022). There are lll commodities; price vectors are p∈Rlp\in\mathbb R^lp∈Rl.

  1. Contraction (eq. (1)): ⟨x,y⟩=∑i=1lxiyi\langle x,y\rangle=\sum_{i=1}^l x_iy_i⟨x,y⟩=∑i=1l​xi​yi​.
  2. Price partial derivative and gradient: ∂f/∂pi\partial f/\partial p_i∂f/∂pi​ at ppp, and ∇f(p)=(∂f/∂p1,…,∂f/∂pl)\nabla f(p)=(\partial f/\partial p_1,\dots,\partial f/\partial p_l)∇f(p)=(∂f/∂p1​,…,∂f/∂pl​).
  3. Time partial derivative of a function F(t,p)F(t,p)F(t,p): ∂F/∂t\partial F/\partial t∂F/∂t, the derivative of τ↦F(τ,p)\tau\mapsto F(\tau,p)τ↦F(τ,p).
  4. Aggregate expenditure: E(p)=∑j=1nλjej(p)E(p)=\sum_{j=1}^n\lambda_je_j(p)E(p)=∑j=1n​λj​ej​(p).
  5. Hamiltonian (eq. (8)), as a function of the control vvv, with ggg standing for ∇J\nabla J∇J:
Hm,E,g(v)=12m⟨v,v⟩+E+⟨g,v⟩.H_{m,E,g}(v)=\tfrac12 m\langle v,v\rangle+E+\langle g,v\rangle .Hm,E,g​(v)=21​m⟨v,v⟩+E+⟨g,v⟩.
  1. Optimal price velocity (eq. (9)): v(t,p)=−1m∇pJ(t,p)v(t,p)=-\tfrac1m\nabla_pJ(t,p)v(t,p)=−m1​∇p​J(t,p).

These are the objects in which the HJB equation, the price-velocity evolution equation and the Lyapunov condition of the paper are stated.

Formalization Note Partial derivatives are Fréchet derivatives applied to standard basis vectors; as usual in Mathlib, they return 000 where the function is not differentiable, and 1/m1/m1/m is 000 when m=0m=0m=0.

Definition code
import Mathlib

/-!
# Lindgren (2022): price-adjustment dynamics — shared definitions

Source: J. Lindgren, *General Equilibrium with Price Adjustments — A Dynamic Programming
Approach*, Analytics 2022, 1, 27–34, https://doi.org/10.3390/analytics1010003.

There are `l` commodities (prices `p : Fin l → ℝ`) and `n` agents.
-/

namespace LindgrenPriceDynamics

/-- The implicit-summation contraction `x^i y_i = ∑_{i=1}^l x_i y_i` of eq. (1). -/
noncomputable def dot {l : ℕ} (x y : Fin l → ℝ) : ℝ := ∑ i, x i * y i

/-- Partial derivative `∂f/∂p_i` of a function of the price vector, i.e. the Fréchet
derivative of `f` at `p` applied to the `i`-th standard basis vector. -/
noncomputable def pricePartial {l : ℕ} (f : (Fin l → ℝ) → ℝ) (p : Fin l → ℝ) (i : Fin l) : ℝ :=
  fderiv ℝ f p (Pi.single i 1)

/-- Price gradient `∇f(p) = (∂f/∂p_1, …, ∂f/∂p_l)`. -/
noncomputable def priceGrad {l : ℕ} (f : (Fin l → ℝ) → ℝ) (p : Fin l → ℝ) : Fin l → ℝ :=
  fun i => pricePartial f p i

/-- Partial time derivative `∂F/∂t (t, p)` of a function of time and prices. -/
noncomputable def timePartial {l : ℕ} (F : ℝ → (Fin l → ℝ) → ℝ) (t : ℝ) (p : Fin l → ℝ) : ℝ :=
  deriv (fun τ => F τ p) t

/-- Aggregate expenditure `λ^j e_j(p) = ∑_{j=1}^n λ_j e_j(p)` (the running cost in eq. (7)). -/
noncomputable def aggregateExpenditure {n l : ℕ} (lam : Fin n → ℝ) (e : Fin n → (Fin l → ℝ) → ℝ)
    (p : Fin l → ℝ) : ℝ :=
  ∑ j, lam j * e j p

/-- The Hamiltonian of eq. (8), `H = ½ m v^i v_i + λ^j e_j + (∂J/∂p_i) v^i`,
written as a function of the control `v`, with `E = λ^j e_j` and `g = ∇J`. -/
noncomputable def hamiltonian {l : ℕ} (m E : ℝ) (g v : Fin l → ℝ) : ℝ :=
  (1 / 2) * m * dot v v + E + dot g v

/-- The optimal price velocity (feedback policy) of eq. (9): `v_i = -(1/m) ∂J/∂p_i`. -/
noncomputable def optimalVelocity {l : ℕ} (m : ℝ) (J : ℝ → (Fin l → ℝ) → ℝ) (t : ℝ)
    (p : Fin l → ℝ) : Fin l → ℝ :=
  fun i => -(1 / m) * pricePartial (J t) p i

end LindgrenPriceDynamics
Source
J. Lindgren, General Equilibrium with Price Adjustments — A Dynamic Programming Approach, Analytics 2022, 1, 27–34, https://doi.org/10.3390/analytics1010003, Section 2 (eqs. (1), (7), (8), (9))
Read-back

What the Lean code literally says, in plain math · Aristotle (Harmonic) — non-blind, same agent as drafter

Non-blind read-back. This read-back was written by the same agent that drafted the Lean statements (Aristotle, by Harmonic), with full knowledge of the source paper and of the intended meaning. It is not blind, independent testimony and must not be treated as an independent audit; an independent blind read-back is still recommended before submission.

All objects below are indexed by natural numbers lll (number of commodities) and, where relevant, nnn (number of agents). Vectors x∈Rlx\in\mathbb R^lx∈Rl are functions from {0,…,l−1}\{0,\dots,l-1\}{0,…,l−1} to R\mathbb RR.

  • dot: ⟨x,y⟩=∑ixiyi\langle x,y\rangle=\sum_{i}x_iy_i⟨x,y⟩=∑i​xi​yi​. For l=0l=0l=0 it is 000.
  • pricePartial f,p,if,p,if,p,i: for f:Rl→Rf:\mathbb R^l\to\mathbb Rf:Rl→R, the Fréchet derivative Df(p)Df(p)Df(p) evaluated on the iii-th standard basis vector eie_iei​, i.e. ∂f/∂pi(p)\partial f/\partial p_i(p)∂f/∂pi​(p). If fff is not differentiable at ppp this is 000 (not undefined).
  • priceGrad f,pf,pf,p: the vector (∂f/∂pi(p))i(\partial f/\partial p_i(p))_i(∂f/∂pi​(p))i​, with the same junk-value convention.
  • timePartial F,t,pF,t,pF,t,p: for F:R×Rl→RF:\mathbb R\times\mathbb R^l\to\mathbb RF:R×Rl→R (curried), the ordinary derivative at ttt of τ↦F(τ,p)\tau\mapsto F(\tau,p)τ↦F(τ,p); equal to 000 if that map is not differentiable at ttt.
  • aggregateExpenditure λ,e,p=∑j=1nλjej(p)\lambda,e,p=\sum_{j=1}^n\lambda_je_j(p)λ,e,p=∑j=1n​λj​ej​(p), for arbitrary real weights λj\lambda_jλj​ and arbitrary real functions eje_jej​ (no sign or regularity constraints); 000 if n=0n=0n=0.
  • hamiltonian m,E,g,v=12m⟨v,v⟩+E+⟨g,v⟩m,E,g,v=\tfrac12 m\langle v,v\rangle+E+\langle g,v\ranglem,E,g,v=21​m⟨v,v⟩+E+⟨g,v⟩, for arbitrary reals m,Em,Em,E (no sign condition on mmm) and vectors g,vg,vg,v.
  • optimalVelocity m,J,t,pm,J,t,pm,J,t,p: the vector with components −1m ∂J(t,⋅)/∂pi (p)-\tfrac1m\,\partial J(t,\cdot)/\partial p_i\,(p)−m1​∂J(t,⋅)/∂pi​(p). When m=0m=0m=0, 1/m1/m1/m is interpreted as 000, so the vector is 000.
Human review
  • Endorsed by Shuze Chen · Sep 30, 2026

    Confirmed by the moderator at approval.

  • Endorsed by LG · Sep 30, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me