Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Supply-and-demand model: equilibrium, market curves, elasticity, example curves

Definition
SupplyDemand_Model

by Lucas · Oct 9, 2026 · Mathlib 0df444a (Lean v4.33.1)

economicsmicroeconomicssupply-and-demand

This file fixes the vocabulary of the partial-equilibrium supply-and-demand model. Prices and quantities are real numbers, and supply and demand curves are functions S,D:R→RS, D:\mathbb R\to\mathbb RS,D:R→R giving quantity as a function of price.

  1. Market equilibrium. (p,q)(p,q)(p,q) is an equilibrium of (S,D)(S,D)(S,D) when the quantity demanded and the quantity supplied at price ppp are both qqq:
IsEquilibrium(S,D,p,q)  ⟺  D(p)=q and S(p)=q.\mathrm{IsEquilibrium}(S,D,p,q)\iff D(p)=q\ \text{and}\ S(p)=q.IsEquilibrium(S,D,p,q)⟺D(p)=q and S(p)=q.
  1. Market curve. For a finite set sss of agents with individual curves fif_ifi​, the market curve is the horizontal sum p↦∑i∈sfi(p)p\mapsto\sum_{i\in s}f_i(p)p↦∑i∈s​fi​(p).
  2. Point elasticity. For a curve QQQ and a price PPP, εQ(P)=Q′(P) P/Q(P)\varepsilon_Q(P)=Q'(P)\,P/Q(P)εQ​(P)=Q′(P)P/Q(P).
  3. Example curves from the source: linear supply Q(P)=3P−6Q(P)=3P-6Q(P)=3P−6, linear demand Q(P)=32−2PQ(P)=32-2PQ(P)=32−2P, constant-elasticity supply Q(P)=5P0.5Q(P)=5P^{0.5}Q(P)=5P0.5, constant-elasticity demand Q(P)=3P−2Q(P)=3P^{-2}Q(P)=3P−2.

These definitions are shared by every statement of the mission.

Formalization Note The derivative is Mathlib's deriv (equal to 000 where QQQ is not differentiable), and division by Q(P)=0Q(P)=0Q(P)=0 returns 000. Real powers are Real.rpow, which is only meaningful here for P>0P>0P>0; all statements about the isoelastic curves assume P>0P>0P>0.

Definition code
import Mathlib

namespace SupplyDemand

/-- `(p, q)` is a market equilibrium (market-clearing price–quantity pair) for the supply
curve `S` and the demand curve `D`: at the price `p`, the quantity demanded and the quantity
supplied both equal `q`. -/
def IsEquilibrium (S D : ℝ → ℝ) (p q : ℝ) : Prop :=
  D p = q ∧ S p = q

/-- Market (aggregate) curve of a finite family of individual curves `f i`, `i ∈ s`:
at each price the individual quantities are added ("added horizontally"). -/
def marketCurve {ι : Type*} (s : Finset ι) (f : ι → ℝ → ℝ) : ℝ → ℝ :=
  fun p => ∑ i ∈ s, f i p

/-- Point price elasticity of a curve `Q` at the price `P`: `Q'(P) · P / Q(P)`. -/
noncomputable def pointElasticity (Q : ℝ → ℝ) (P : ℝ) : ℝ :=
  deriv Q P * P / Q P

/-- The source's example linear supply function `Q(P) = 3P - 6`. -/
def linearSupply (P : ℝ) : ℝ := 3 * P - 6

/-- The source's example linear demand function `Q(P) = 32 - 2P`. -/
def linearDemand (P : ℝ) : ℝ := 32 - 2 * P

/-- The source's example constant-elasticity supply function `Q(P) = 5 P^{0.5}`. -/
noncomputable def isoelasticSupply (P : ℝ) : ℝ := 5 * P ^ (0.5 : ℝ)

/-- The source's example constant-elasticity demand function `Q(P) = 3 P^{-2}`. -/
noncomputable def isoelasticDemand (P : ℝ) : ℝ := 3 * P ^ (-2 : ℝ)

end SupplyDemand
Source
Wikipedia, "Supply and demand", revision 1378800284, https://en.wikipedia.org/w/index.php?title=Supply_and_demand&oldid=1378800284, sections "Supply schedule", "Demand schedule", "Equilibrium", "Market equilibrium"
Read-back

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

Disclosure — NON-BLIND read-back. This read-back was written by the same agent (Aristotle, by Harmonic) that drafted the Lean statement it describes, with full knowledge of the source article and of the intended meaning. It is not independent, blind testimony and must not be mistaken for one. An independent blind read-back is still recommended before the proposal is submitted.

The file declares, inside the namespace SupplyDemand, the following objects (everything real-valued, R\mathbb RR the real numbers).

  1. IsEquilibrium(S,D,p,q)\mathrm{IsEquilibrium}(S,D,p,q)IsEquilibrium(S,D,p,q), for functions S,D:R→RS,D:\mathbb R\to\mathbb RS,D:R→R and reals p,qp,qp,q, is the proposition "D(p)=qD(p)=qD(p)=q and S(p)=qS(p)=qS(p)=q". No positivity or monotonicity is built in.
  2. For any index type ι\iotaι, a finite set s⊆ιs\subseteq\iotas⊆ι and a family f:ι→(R→R)f:\iota\to(\mathbb R\to\mathbb R)f:ι→(R→R), marketCurve(s,f)\mathrm{marketCurve}(s,f)marketCurve(s,f) is the function p↦∑i∈sfi(p)p\mapsto\sum_{i\in s}f_i(p)p↦∑i∈s​fi​(p); for s=∅s=\varnothings=∅ it is the zero function.
  3. pointElasticity(Q,P)=Q′(P)⋅P/Q(P)\mathrm{pointElasticity}(Q,P)=Q'(P)\cdot P/Q(P)pointElasticity(Q,P)=Q′(P)⋅P/Q(P), where Q′(P)Q'(P)Q′(P) is the derivative of QQQ at PPP if QQQ is differentiable there and 000 otherwise, and where division by 000 gives 000 (so the value is 000 whenever Q(P)=0Q(P)=0Q(P)=0).
  4. linearSupply(P)=3P−6\mathrm{linearSupply}(P)=3P-6linearSupply(P)=3P−6 and linearDemand(P)=32−2P\mathrm{linearDemand}(P)=32-2PlinearDemand(P)=32−2P for all real PPP (they take negative values for P<2P<2P<2, resp. P>16P>16P>16).
  5. isoelasticSupply(P)=5 P0.5\mathrm{isoelasticSupply}(P)=5\,P^{0.5}isoelasticSupply(P)=5P0.5 and isoelasticDemand(P)=3 P−2\mathrm{isoelasticDemand}(P)=3\,P^{-2}isoelasticDemand(P)=3P−2, with the real power function xyx^yxy; for P>0P>0P>0 this is the usual power, at P=0P=0P=0 it gives 00.5=00^{0.5}=000.5=0 and 0−2=00^{-2}=00−2=0, and for P<0P<0P<0 it gives the library's conventional value ∣P∣ycos⁡(πy)|P|^y\cos(\pi y)∣P∣ycos(πy) (for example (−1)0.5=0(-1)^{0.5}=0(−1)0.5=0) rather than being undefined.
Human review
  • Endorsed by Shuze Chen · Oct 10, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Lucas · Oct 10, 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