Pricing a contract: value, its linearity, and the martingale seam
A Contract is still model-agnostic data until it meets a stochastic model. Scenario becomes a random variable once a model X : ι → ℝ≥0 → Ω → ℝ and an outcome ω : Ω are fixed (scenarioAt); Contract.value integrates the resulting pathPV against a measure Q and a deflator D : ℝ≥0 → Ω → ℝ, each outcome's cash flows discounted along that outcome's path t ↦ D t ω. It is a price when Q is a pricing measure of a market whose deflator is D (Market.price). A deterministic discount curve is the deflator fun t _ ↦ D t.
This file's connection to the market vocabulary is through Martingale, not IsEMM: value_deliverAsset's pricing identity needs a Q-martingale price process and Q a probability measure, nothing more. The mutual-absolute-continuity content that makes a martingale measure an equivalent one — IsEMM's ac/ac' fields — is not needed by anything here; it lives in ContinuousMarket.lean (isEMM_noArbitrageSimple), where it is load-bearing.
Main definitions
scenarioAt — the scenario read off a model X at a single outcome ω.Contract.value — the pricing integral ∫ ω, c.pathPV (D · ω) (scenarioAt X ω) ∂Q under a deflator D.Contract.observation — what a fixed-dated contract reads at an outcome: the model at its observations and the deflator at its payment dates; Contract.pvOf, its present value as a function of that.zeroCurve — the zero curve t ↦ 𝔼_Q[D t] of a deflator: the value of one unit paid at t.
Main results
Contract.value_pay — a single cash flow is worth the integral of its deflated payoff; Contract.value_payFlows — a schedule of them, the sum.Contract.value_scale, Contract.value_both — value is homogeneous and additive, inherited from pathPV_scale and pathPV_both. The two carry different hypotheses on purpose: value_scale needs none, because integral_const_mul holds unconditionally in Mathlib's Bochner integral (it returns 0 off the integrable set on both sides), while value_both genuinely needs both summands integrable — integral_add is false without them. That asymmetry, not a uniform "linearity", is the honest content of this pair.Contract.value_payFlows_sub, Contract.value_payFlows_add_sub — a schedule whose payoffs are a signed sum of the payoffs of other schedules (in the model, outcome by outcome) is worth the same signed sum of their values.Contract.value_deliverAsset — a contract that simply delivers the asset S at time T is worth ∫ ω, S 0 ω ∂Q today, given S is a Q-martingale and Q a probability measure. Mechanically this is conditional-expectation machinery (condExp_ae_eq + integral_condExp), the same kind value_process_martingale uses, evaluated at the fixed times 0 and T — it carries no equivalence content, so it is stated against Martingale directly rather than the library's IsEMM bundle, whose ac/ac' fields this argument never needs.Contract.value_eq_of_pathPV_eq, value_fixedFlows_deterministic — a contract whose deflated present value is the same along every outcome is worth that amount; a schedule of fixed cash flows on a deterministic curve is one.Contract.value_congr_ae — a fixed-dated contract has the same value in two models that agree almost surely at the (underlying, date) observations it reads (Contract.obsList).Contract.value_eq_of_map_observation_eq — law invariance: a fixed-dated contract has the same value in two models, on two sample spaces, whose observations and deflators at the contract's dates have one law (Contract.value_eq_integral_map).Contract.value_process_martingale — the conditional-expectation value process of a contract is a Q-martingale. Carries no Integrable hypothesis: martingale_condExp is unconditional, because Mathlib's Bochner integral returns the junk value 0 off the integrable set, and the constant-0 process is trivially a martingale — so the theorem is honest but its content lives entirely in the integrable case. It is also stated with no IsEMM hypothesis: it is martingale_condExp specialized to a contract's cashflows, true for any Q with a SigmaFiniteFiltration, not a fact about the pricing measure. Shipping it with an IsEMM hypothesis would misattribute a conditional-expectation fact to the EMM structure — and, as value_deliverAsset above shows, no theorem in this file has any actual EMM content to misattribute it to.
Source
The layered separation of contract semantics from pricing semantics, and the framing "the contract is not the model", are due to Paul Bilokon, The Contract Is Not the Model: Proof-Carrying Exotic Derivatives and the Economics of Model Risk (working paper, 9 August 2026; Mathematical Finance, Imperial College London), with code at <https://github.com/thalesians/lean_contracts> (Apache-2.0). That paper in turn builds on the compositional contract-DSL of Peyton Jones, Eber and Seward (2000) and the certified-contract work of Bahr, Berthold and Elsman (2015) and Annenkov (2018).
Bilokon separates pricing semantics from contract semantics — a pricing model is a law over deterministic scenarios — and that separation is his; but his PricingModel.value integrates a function never shown measurable and his value_eq_of_pathPV_eq is congrArg under the integral, whereas this file's linearity carries real integrability hypotheses and its delivery-of-asset identity is a genuine martingale-pricing fact (Martingale.condExp_ae_eq chained through integral_condExp), not an unconditional integral congruence.
No code is copied from lean_contracts; every definition and proof here is written for this library. See docs/specs/2026-08-16-contracts-tower-design.md §6 for the full credit line.
References
- P. Bilokon, The Contract Is Not the Model [Bilokon2026]
- D. Brigo and F. Mercurio, Interest Rate Models --- Theory and Practice [BrigoMercurio2006], sec. 1.2
- J. C. Hull, Options, Futures, and Other Derivatives [Hull], 1.1
- S. E. Shreve, Stochastic Calculus for Finance II: Continuous-Time Models [ShreveSCFII], 5.2; ch. 5
Tags
contract pricing, risk-neutral valuation, pricing measure, martingale pricing, discounted payoff, cash flow valuation, MSC 91G20, MSC 60G44, JEL G13
Import neighbourhood
Above: what it imports. Below: what imports it.
Corpus entries
mf-contract-value-linear · contracts.json · full statement
Contract Value is Additive Over both
Contract.value is additive over Contract.both, given both summands' discounted pathwise present values are Q-integrable: the value of a combined contract is the sum of the two values. Unlike value_scale (unconditional, since integral_const_mul holds even off the integrable set), this direction genuinely needs both integrability hypotheses -- integral_add is false without them.
mf-contract-value-deliver-asset · contracts.json · full statement
Value of Delivering a Martingale Asset
A contract that simply delivers a Q-martingale asset S at time T, undiscounted, is worth today's Q-expectation of S at time 0: value = integral S_0 dQ. Proved from Martingale.condExp_ae_eq chained through integral_condExp; needs only that S is a Q-martingale and Q a probability measure, no equivalent-martingale-measure (IsEMM) content.
mf-contract-fixed-flows-zero-curve · contracts.json · full statement
Under a Stochastic Discount Factor, a Fixed Schedule Is Priced off the Zero Curve
For a stochastic discount factor D : time -> outcome -> R, a probability measure Q, and a schedule of fixed cash flows c_i at times t_i (i < n) with each D(t_i) Q-integrable, the schedule's value under D (the Q-expectation of its present value discounted along each outcome's path of D) equals its Contract.value on the deterministic curve P(0, t) = E_Q[D(t)], in every model. The stochastic discount factor reaches a contract that observes nothing only through its zero curve.
Declarations 26
defMathFin.Contracts.scenarioAtsource {ι : Type u_1} → {Ω : Type u_2} → (ι → NNReal → Ω → ℝ) → Ω → Scenario ιThe scenario read off a model at a single outcome.
defMathFin.Contracts.Contract.valuesource {ι : Type u_1} → {Ω : Type u_2} → {mΩ : MeasurableSpace Ω} → Measure Ω → (NNReal → Ω → ℝ) → (ι → NNReal → Ω → ℝ) → Contract ι → ℝThe value of a Contract under a measure Q and a deflator D : ℝ≥0 → Ω → ℝ: the Q-expectation of its present value along each outcome ω, each cash flow at t multiplied by D t ω, against a model X that reifies each Scenario observation as a random variable.
The deflator is stochastic: a short-rate model's D t = exp(−∫₀ᵗ r_s ds), or a market's N 0 / N t for a numéraire N. A deterministic discount curve D : ℝ≥0 → ℝ is the deflator fun t _ ↦ D t.
theoremMathFin.Contracts.Contract.value_paysource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} (Q : Measure Ω) (D : NNReal → Ω → ℝ) (X : ι → NNReal → Ω → ℝ) (t : NNReal) (a : Payoff ι), Contract.value Q D X (Contract.pay t a) = ∫ (ω : Ω), D t ω * Payoff.eval (scenarioAt X ω) a ∂QThe value of a single cash flow is the integral of its deflated payoff. Every instrument that pays once (Contracts/Instruments/Options.lean) reaches its closed form in a model by rewriting through this lemma.
theoremMathFin.Contracts.Contract.value_scalesource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} (Q : Measure Ω) (D : NNReal → Ω → ℝ) (X : ι → NNReal → Ω → ℝ) (r : ℝ) (a : Contract ι), Contract.value Q D X (Contract.scale r a) = r * Contract.value Q D X avalue is homogeneous under scale, unconditionally: integral_const_mul holds even off the integrable set (both sides are 0 there), so no integrability hypothesis is needed.
theoremMathFin.Contracts.Contract.value_bothsource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} (Q : Measure Ω) (D : NNReal → Ω → ℝ) (X : ι → NNReal → Ω → ℝ) (a b : Contract ι), Integrable (fun ω => Contract.pathPV (fun t => D t ω) (scenarioAt X ω) a) Q → Integrable (fun ω => Contract.pathPV (fun t => D t ω) (scenarioAt X ω) b) Q → Contract.value Q D X (a.both b) = Contract.value Q D X a + Contract.value Q D X bvalue is additive under both, given both summands are integrable — integral_add is false without that hypothesis on either side, unlike value_scale's unconditional case.
theoremMathFin.Contracts.Contract.value_payFlowssource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} (Q : Measure Ω) (D : NNReal → Ω → ℝ) (X : ι → NNReal → Ω → ℝ) (t : ℕ → NNReal) (a : ℕ → Payoff ι) (n : ℕ), (∀ i < n, Integrable (fun ω => D (t i) ω * Payoff.eval (scenarioAt X ω) (a i)) Q) → Contract.value Q D X (payFlows t a n) = ∑ i ∈ Finset.range n, Contract.value Q D X (Contract.pay (t i) (a i))A schedule of payments is worth the sum of its payments, given each deflated payoff is integrable.
theoremMathFin.Contracts.Contract.value_payFlows_subsource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} (Q : Measure Ω) (D : NNReal → Ω → ℝ) (X : ι → NNReal → Ω → ℝ) (t : ℕ → NNReal) (a c d : ℕ → Payoff ι) (n : ℕ), (∀ i < n, ∀ (ω : Ω), Payoff.eval (scenarioAt X ω) (a i) = Payoff.eval (scenarioAt X ω) (c i) - Payoff.eval (scenarioAt X ω) (d i)) → (∀ i < n, Integrable (fun ω => D (t i) ω * Payoff.eval (scenarioAt X ω) (c i)) Q) → (∀ i < n, Integrable (fun ω => D (t i) ω * Payoff.eval (scenarioAt X ω) (d i)) Q) → Contract.value Q D X (payFlows t a n) = Contract.value Q D X (payFlows t c n) - Contract.value Q D X (payFlows t d n)A schedule whose payoffs are a signed sum of two schedules' payoffs is worth the signed sum of their values. If in the model X the payoff a i is c i - d i at every outcome, the schedule payFlows t a n is worth payFlows t c n minus payFlows t d n, given integrable deflated payoffs for the two. This is value_both, value_scale and the sum of value_payFlows at the level of the payoff identity, so an identity between payoffs (a pointwise algebra fact) becomes an identity between values.
theoremMathFin.Contracts.Contract.value_payFlows_add_subsource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} (Q : Measure Ω) (D : NNReal → Ω → ℝ) (X : ι → NNReal → Ω → ℝ) (t : ℕ → NNReal) (a b c d : ℕ → Payoff ι) (n : ℕ), (∀ i < n, ∀ (ω : Ω), Payoff.eval (scenarioAt X ω) (a i) = Payoff.eval (scenarioAt X ω) (b i) + Payoff.eval (scenarioAt X ω) (c i) - Payoff.eval (scenarioAt X ω) (d i)) → (∀ i < n, Integrable (fun ω => D (t i) ω * Payoff.eval (scenarioAt X ω) (b i)) Q) → (∀ i < n, Integrable (fun ω => D (t i) ω * Payoff.eval (scenarioAt X ω) (c i)) Q) → (∀ i < n, Integrable (fun ω => D (t i) ω * Payoff.eval (scenarioAt X ω) (d i)) Q) → Contract.value Q D X (payFlows t a n) = Contract.value Q D X (payFlows t b n) + Contract.value Q D X (payFlows t c n) - Contract.value Q D X (payFlows t d n)A schedule whose payoffs are b i + c i - d i is worth b + c - d: the three-term form of value_payFlows_sub, for a payoff identity of the type max a b + min a b = a + b.
theoremMathFin.Contracts.Contract.value_deliverAssetsource ∀ {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {𝓕 : Filtration NNReal mΩ} {S : NNReal → Ω → ℝ} {Q : Measure Ω} [IsProbabilityMeasure Q], Martingale S 𝓕 Q → ∀ (T : NNReal), Contract.value Q (fun x x_1 => 1) (fun x => S) (Contract.pay T (Payoff.obs () T)) = ∫ (ω : Ω), S 0 ω ∂QUnder a Q-martingale S and Q a probability measure, a contract that simply delivers the asset S at time T, undeflated, is worth ∫ ω, S 0 ω ∂Q today — the Q-price of S at time 0. This is Martingale.condExp_ae_eq between 0 and T chained through integral_condExp: a martingale-plus-probability-measure fact evaluated at fixed times, the same conditional-expectation machinery value_process_martingale uses. It carries no equivalence content — Q need not be an EMM for S, only a probability measure under which S is a martingale — so it is stated against Martingale directly rather than the library's IsEMM bundle, whose ac/ac' fields this argument never needs; that mutual-absolute-continuity content lives elsewhere (ContinuousMarket.isEMM_noArbitrageSimple).
theoremMathFin.Contracts.Contract.value_process_martingalesource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {Q : Measure Ω} {𝓕 : Filtration NNReal mΩ} [SigmaFiniteFiltration Q 𝓕] (D : NNReal → Ω → ℝ) (X : ι → NNReal → Ω → ℝ) (c : Contract ι), Martingale (fun t => Q[fun ω => Contract.pathPV (fun s => D s ω) (scenarioAt X ω) c | ↑𝓕 t]) 𝓕 QThe conditional-expectation value process of a contract is a Q-martingale. Needs no Integrable hypothesis — martingale_condExp is unconditional, so a non-integrable contract just gives the constant-0 martingale (Bochner junk value); the theorem's content is the integrable case. Needs no EMM hypothesis either: it is a property of conditional expectation, not of the pricing measure — no theorem in this file needs IsEMM; value_deliverAsset needs only Martingale S 𝓕 Q and [IsProbabilityMeasure Q].
theoremMathFin.Contracts.Contract.value_congr_aesource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {Q : Measure Ω} {D : NNReal → Ω → ℝ} {X Y : ι → NNReal → Ω → ℝ} (c : Contract ι), c.FixedDated → (∀ p ∈ c.obsList, ∀ᵐ (ω : Ω) ∂Q, X p.1 p.2 ω = Y p.1 p.2 ω) → Contract.value Q D X c = Contract.value Q D Y cA fixed-dated contract has the same value in two models that agree almost surely at the observations it reads. The models need not agree anywhere else: this is what lets a model that is only Brownian up to a horizon price a contract whose dates lie before it.
theoremMathFin.Contracts.Contract.value_eq_of_pathPV_eqsource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {Q : Measure Ω} [IsProbabilityMeasure Q] {D : NNReal → Ω → ℝ} (X : ι → NNReal → Ω → ℝ) {c : Contract ι} {v : ℝ}, (∀ (ω : Ω), Contract.pathPV (fun t => D t ω) (scenarioAt X ω) c = v) → Contract.value Q D X c = vA contract whose deflated present value is the same along every outcome is worth that amount, under any probability measure.
theoremMathFin.Contracts.value_fixedFlows_deterministicsource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {Q : Measure Ω} [IsProbabilityMeasure Q] (D : NNReal → ℝ) (X : ι → NNReal → Ω → ℝ) (t : ℕ → NNReal) (c : ℕ → ℝ) (n : ℕ), Contract.value Q (fun s x => D s) X (fixedFlows t c n) = ∑ i ∈ Finset.range n, D (t i) * c iOn a deterministic discount curve, in every model, a schedule of fixed cash flows is worth ∑ D(tᵢ) cᵢ. Under a stochastic deflator it is worth the same sum on the zero curve t ↦ 𝔼_Q[D t] (value_fixedFlows).
defMathFin.Contracts.Contract.observationsource {ι : Type u_1} → {Ω : Type u_2} → (c : Contract ι) → (NNReal → Ω → ℝ) → (ι → NNReal → Ω → ℝ) → Ω → ({ p // p ∈ c.obsList } → ℝ) × ({ t // t ∈ c.dates } → ℝ)What a fixed-dated contract reads from a model X and a deflator D at an outcome ω: the model at each of its observations (c.obsList) and the deflator at each of its payment dates (c.dates).
defMathFin.Contracts.Contract.fillScenariosource {ι : Type u_1} → (c : Contract ι) → ({ p // p ∈ c.obsList } → ℝ) → Scenario ιThe scenario an observation fills in: the observed value at each of c.obsList, 0 elsewhere.
defMathFin.Contracts.Contract.fillDatessource {ι : Type u_1} → (c : Contract ι) → ({ t // t ∈ c.dates } → ℝ) → NNReal → ℝThe discount factor an observation fills in: the observed value at each of c.dates, 0 elsewhere.
defMathFin.Contracts.Contract.pvOfsource {ι : Type u_1} → (c : Contract ι) → ({ p // p ∈ c.obsList } → ℝ) × ({ t // t ∈ c.dates } → ℝ) → ℝThe present value of a contract as a function of what it reads.
theoremMathFin.Contracts.Contract.pathPV_eq_pvOfsource ∀ {ι : Type u_1} {Ω : Type u_2} (c : Contract ι), c.FixedDated → ∀ (D : NNReal → Ω → ℝ) (X : ι → NNReal → Ω → ℝ) (ω : Ω), Contract.pathPV (fun t => D t ω) (scenarioAt X ω) c = c.pvOf (c.observation D X ω)A fixed-dated contract's deflated present value along ω is its present value read off the observation at ω.
theoremMathFin.Contracts.Contract.measurable_observationsource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} (c : Contract ι) {D : NNReal → Ω → ℝ}, (∀ (t : NNReal), Measurable (D t)) → ∀ {X : ι → NNReal → Ω → ℝ}, (∀ (i : ι) (t : NNReal), Measurable (X i t)) → Measurable (c.observation D X)theoremMathFin.Contracts.Contract.measurable_pvOfsource ∀ {ι : Type u_1} (c : Contract ι), c.FixedDated → Measurable c.pvOftheoremMathFin.Contracts.Contract.value_eq_integral_mapsource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} (c : Contract ι), c.FixedDated → ∀ (Q : Measure Ω) {D : NNReal → Ω → ℝ}, (∀ (t : NNReal), Measurable (D t)) → ∀ {X : ι → NNReal → Ω → ℝ}, (∀ (i : ι) (t : NNReal), Measurable (X i t)) → Contract.value Q D X c = ∫ (z : ({ p // p ∈ c.obsList } → ℝ) × ({ t // t ∈ c.dates } → ℝ)), c.pvOf z ∂Measure.map (c.observation D X) QThe value of a fixed-dated contract is an integral against the law of what it reads: the Q-law of its observation, for a measurable model and deflator.
theoremMathFin.Contracts.Contract.value_eq_of_map_observation_eqsource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {Ω' : Type u_3} {mΩ' : MeasurableSpace Ω'} (c : Contract ι), c.FixedDated → ∀ {Q : Measure Ω} {Q' : Measure Ω'} {D : NNReal → Ω → ℝ} {D' : NNReal → Ω' → ℝ} {X : ι → NNReal → Ω → ℝ} {X' : ι → NNReal → Ω' → ℝ}, (∀ (t : NNReal), Measurable (D t)) → (∀ (i : ι) (t : NNReal), Measurable (X i t)) → (∀ (t : NNReal), Measurable (D' t)) → (∀ (i : ι) (t : NNReal), Measurable (X' i t)) → Measure.map (c.observation D X) Q = Measure.map (c.observation D' X') Q' → Contract.value Q D X c = Contract.value Q' D' X' cLaw invariance. A fixed-dated contract has the same value in two models, on two sample spaces, whose observations have the same law: if (X, D) at the contract's observations and payment dates has one law under Q and under Q', the values agree. The value depends on the model only through that law, which is what lets a model built on one concrete space define a price in every market with the same law.
defMathFin.Contracts.zeroCurvesource {Ω : Type u_2} → {mΩ : MeasurableSpace Ω} → Measure Ω → (NNReal → Ω → ℝ) → NNReal → ℝThe zero curve of a deflator, P(0, t) = 𝔼_Q[D t]: the value of one unit paid at t.
theoremMathFin.Contracts.value_fixedFlowssource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {Q : Measure Ω} {D : NNReal → Ω → ℝ} (X : ι → NNReal → Ω → ℝ) (t : ℕ → NNReal) (c : ℕ → ℝ) (n : ℕ), (∀ i < n, Integrable (D (t i)) Q) → Contract.value Q D X (fixedFlows t c n) = ∑ i ∈ Finset.range n, zeroCurve Q D (t i) * c iA schedule of fixed cash flows is priced off the zero curve: under a deflator with each D tᵢ integrable, fixedFlows t c n is worth ∑ P(0, tᵢ) cᵢ.
theoremMathFin.Contracts.value_fixedFlows_eq_zeroCurvesource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {Q : Measure Ω} [IsProbabilityMeasure Q] {D : NNReal → Ω → ℝ} (X : ι → NNReal → Ω → ℝ) (t : ℕ → NNReal) (c : ℕ → ℝ) (n : ℕ), (∀ i < n, Integrable (D (t i)) Q) → Contract.value Q D X (fixedFlows t c n) = Contract.value Q (fun s x => zeroCurve Q D s) X (fixedFlows t c n)A deflator reaches a fixed schedule only through its zero curve: its value under D is its value on the deterministic curve zeroCurve Q D, in every model.
theoremMathFin.Contracts.value_fixedFlows_of_zeroCurve_eqsource ∀ {ι : Type u_1} {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {Q : Measure Ω} {D : NNReal → Ω → ℝ} (X : ι → NNReal → Ω → ℝ) (t : ℕ → NNReal) (c : ℕ → ℝ) (n : ℕ) {P : NNReal → ℝ}, (∀ i < n, zeroCurve Q D (t i) = P (t i)) → (∀ i < n, P (t i) ≠ 0) → Contract.value Q D X (fixedFlows t c n) = ∑ i ∈ Finset.range n, P (t i) * c iA closed-form zero curve prices a fixed schedule: if 𝔼_Q[D tᵢ] = P(tᵢ) ≠ 0 at each payment date, the schedule is worth ∑ P(tᵢ) cᵢ. Integrability is not assumed: a function whose integral is nonzero is integrable.