MathFin
Map / Positions and markets / MathFin.Contracts.Core

A reified payoff language

MathFin.Contracts.CoreMSC 91G20JEL G13 source

Payoff ι and Contract ι represent what an instrument pays, independently of any stochastic model. Market outcomes enter through Scenario ι = ι → ℝ≥0 → ℝ; a stochastic model is a law on that type, and appears only from Pricing/Value.lean onward.

Every other payoff in this library — Models/BlackScholes/Call.lean, Digital.lean, CappedCall.lean — is written inline as a lambda inside the integral that prices it, so the payoff and the model are the same syntactic object. This file separates them, which is what lets Models/BlackScholes/BlackScholes.lean price a capped call by composing two European call values rather than by evaluating a third integral.

Payments at a random date

Contract.pay fixes its date. Contract.payAtHit i A amount pays at the first time the observed underlying i enters the set A (Scenario.hitTime, Mathlib's hittingAfter of the observed path), which is how a payment at a default time is written: the underlying is the default indicator 1{τ ≤ u} and A = [1, ∞). The model-free results below hold for every contract; the integrability theorem of Contracts/Adapted.lean is for Contract.FixedDated ones, since a hitting time of an arbitrary path is not measurable and an unbounded discount factor evaluated at it need not be integrable.

Deliberately absent

Branching contracts (ifThen), currency, and the lifecycle layer (outstanding notional, termination, partial redemption). Each is additive and each waits for the corpus entry that forces it; see docs/specs/2026-08-16-contracts-tower-design.md §2.3.

Main definitions

  • Scenario ι: a market scenario ι → ℝ≥0 → ℝ, the realized value of each underlying at each time.
  • Payoff ι: payoff formulas as data (constants, observations, add, sub, mul, max, min, indicatorLt, and rpow with an ℝ≥0 exponent); Payoff.eval interprets one against a scenario.
  • Payoff.obsList: the (underlying, date) observations a payoff reads, found syntactically.
  • Contract.obsList: the observations a contract's payoffs read.
  • Scenario.hitTime: the first time the observed underlying i lies in A, as Mathlib's hittingAfter of the observed path.
  • Contract ι: contracts built from zero, pay t amount, payAtHit i A amount, both and scale.
  • Contract.cashflows: the list of (time, amount) cashflows of a contract along a scenario.
  • Contract.FixedDated: the contract contains no payAtHit.
  • Contract.dates: the payment dates of a contract's pay nodes.
  • Contract.pathPV: the present value of a contract along one scenario path, for a discount function D : ℝ≥0 → ℝ.

Main results

  • Contract.pathPV_both, Contract.pathPV_scale — pathPV is additive over both and homogeneous over scale. These are what Pricing/Value.lean integrates to get linearity of value.
  • Contract.pathPV_const — a constant discount factor comes out of pathPV.
  • Payoff.eval_congr, Contract.cashflows_congr — a payoff, and a fixed-dated contract's cash flows, are the same on two scenarios that agree at the observations they read (Payoff.obsList, Contract.obsList). Pricing/Value.lean lifts this to models that agree almost surely (Contract.value_congr_ae).
  • Contract.pathPV_congr — a fixed-dated contract's present value depends on the scenario only at c.obsList and on the discount factor only at c.dates. Pricing/Value.lean lifts this to models whose observations have one law (Contract.value_eq_of_map_observation_eq).

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).

This file takes his separation of the payoff object from the probability law. The type design is ours: a typed underlying index rather than String keys, a single inductive rather than a mutual NumExpr / BoolExpr pair, and ℝ≥0 time matching Filtration ℝ≥0 mΩ.

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

Tags

contract language, reified payoff, contract DSL, Bilokon, Peyton Jones, payment at default time, MSC 91G20, JEL G13

Import neighbourhood

Above: what it imports. Below: what imports it.

Corpus entries

mf-contract-pathpv-both · contracts.json · full statement
Contract Pathwise PV is Additive Over both

pathPV is additive over Contract.both: the pathwise present value of two combined contracts along one fixed scenario is the sum of their pathwise present values, for any discount curve D. Purely a finite-list-sum fact about pathPV -- no integral, measure or integrability hypothesis is involved yet.

Declarations 19

defMathFin.Contracts.Scenariosource
Type u_2 → Type u_2

A market scenario: for each underlying i : ι and time t : ℝ≥0, its realized value. A stochastic model is a probability law on this type.

inductiveMathFin.Contracts.Payoffsource
Type u_2 → Type u_2

A payoff formula, reified as data rather than written inline as a lambda. Independent of any scenario until Payoff.eval interprets it against one.

defMathFin.Contracts.Payoff.evalsource
{ι : Type u_1} → Scenario ι → Payoff ι → ℝ

Interpret a Payoff against a Scenario, producing its realized value.

defMathFin.Contracts.Payoff.obsListsource
{ι : Type u_1} → Payoff ι → List (ι × NNReal)

The (underlying, date) observations a Payoff reads, found syntactically. An over-approximation: Payoff.mul (.const 0) (.obs i t) evaluates to 0 on every scenario, yet lists (i, t).

defMathFin.Contracts.Scenario.hitTimesource
{ι : Type u_1} → Scenario ι → ι → Set ℝ → WithTop NNReal

The first time the observed underlying i of a scenario lies in A: Mathlib's hittingAfter of the process u ↦ s i u at time 0, which is ⊤ if it never does. It is the infimum of the times at which the observation is in A, so it is attained when the path is right continuous and A closed.

inductiveMathFin.Contracts.Contractsource
Type u_2 → Type u_2

A contract: what gets paid, when, built from Payoffs by combination.

defMathFin.Contracts.Contract.cashflowssource
{ι : Type u_1} → Scenario ι → Contract ι → List (NNReal × ℝ)

The list of (time, amount) cashflows a Contract generates along a given Scenario.

defMathFin.Contracts.Contract.FixedDatedsource
{ι : Type u_1} → Contract ι → Prop

A contract pays at fixed dates if it contains no payAtHit: the dates of its cashflows are then the same in every scenario.

defMathFin.Contracts.Contract.pathPVsource
{ι : Type u_1} → (NNReal → ℝ) → Scenario ι → Contract ι → ℝ

The present value of a Contract along one scenario path, given a discount factor D : ℝ≥0 → ℝ.

theoremMathFin.Contracts.Contract.pathPV_payAtHit_of_eqsource
∀ {ι : Type u_1} (D : NNReal → ℝ) (s : Scenario ι) {i : ι} {A : Set ℝ} {τ : NNReal} (a : Payoff ι), s.hitTime i A = ↑τ → Contract.pathPV D s (Contract.payAtHit i A a) = D τ * Payoff.eval s a

A payment at the hitting time, when the underlying does hit A, at the time τ: the discounted amount at τ.

theoremMathFin.Contracts.Contract.pathPV_payAtHit_of_eq_topsource
∀ {ι : Type u_1} (D : NNReal → ℝ) (s : Scenario ι) {i : ι} {A : Set ℝ} (a : Payoff ι), s.hitTime i A = ⊤ → Contract.pathPV D s (Contract.payAtHit i A a) = 0

A payment at the hitting time is nothing if the underlying never hits A.

theoremMathFin.Contracts.Contract.pathPV_bothsource
∀ {ι : Type u_1} (D : NNReal → ℝ) (s : Scenario ι) (a b : Contract ι), Contract.pathPV D s (a.both b) = Contract.pathPV D s a + Contract.pathPV D s b
theoremMathFin.Contracts.Contract.pathPV_scalesource
∀ {ι : Type u_1} (D : NNReal → ℝ) (s : Scenario ι) (c : ℝ) (a : Contract ι), Contract.pathPV D s (Contract.scale c a) = c * Contract.pathPV D s a
theoremMathFin.Contracts.Contract.pathPV_constsource
∀ {ι : Type u_1} (a : ℝ) (s : Scenario ι) (c : Contract ι), Contract.pathPV (fun x => a) s c = a * Contract.pathPV (fun x => 1) s c

A constant discount factor comes out of pathPV: discounting every cashflow by a is discounting the undiscounted present value by a.

theoremMathFin.Contracts.Payoff.eval_congrsource
∀ {ι : Type u_1} {s s' : Scenario ι} (a : Payoff ι), (∀ p ∈ a.obsList, s p.1 p.2 = s' p.1 p.2) → Payoff.eval s a = Payoff.eval s' a

A payoff evaluates the same on two scenarios that agree at the observations it reads.

defMathFin.Contracts.Contract.obsListsource
{ι : Type u_1} → Contract ι → List (ι × NNReal)

The (underlying, date) observations a Contract reads (those of its payoffs; the dates of a payAtHit are not listed, which is why the congruence below asks for FixedDated).

theoremMathFin.Contracts.Contract.cashflows_congrsource
∀ {ι : Type u_1} {s s' : Scenario ι} (c : Contract ι), c.FixedDated → (∀ p ∈ c.obsList, s p.1 p.2 = s' p.1 p.2) → Contract.cashflows s c = Contract.cashflows s' c

A fixed-dated contract generates the same cash flows along two scenarios that agree at the observations it reads.

defMathFin.Contracts.Contract.datessource
{ι : Type u_1} → Contract ι → List NNReal

The payment dates of a contract: the dates of its pay nodes. A payAtHit pays at a date the scenario decides and lists none, which is why the congruence below asks for FixedDated.

theoremMathFin.Contracts.Contract.pathPV_congrsource
∀ {ι : Type u_1} {D D' : NNReal → ℝ} {s s' : Scenario ι} (c : Contract ι), c.FixedDated → (∀ t ∈ c.dates, D t = D' t) → (∀ p ∈ c.obsList, s p.1 p.2 = s' p.1 p.2) → Contract.pathPV D s c = Contract.pathPV D' s' c

A fixed-dated contract reads a scenario only at its observations and a discount factor only at its payment dates: two discount factors that agree on c.dates, along two scenarios that agree on c.obsList, give the same present value.