mirror of
https://github.com/zooai/proofs.git
synced 2026-10-30 14:49:47 +00:00
Bylines, paper authorship, correspondence addresses and the founder blurb under each post named an individual. They name the organisation that published the work instead: the brand on posts and pages, the research byline on papers, and research@ in place of a personal address. Both are what these repositories already used elsewhere — nothing new was coined. Co-authors are untouched. Where a paper named someone else alongside, they stay named; only the one byline changed. Bibliography entries, running heads, PDF metadata and affiliations move with it, so a citation still resolves to whoever the cited paper names. Sample and fixture data uses the placeholder name these tests already use elsewhere, so no assertion changed meaning. Co-authored-by: Hanzo Dev <[email protected]>
190 lines
7.4 KiB
Lean4
190 lines
7.4 KiB
Lean4
/-
|
|
Authors: Antje Worring, Zoo Labs Foundation Research
|
|
|
|
Conservation Impact Bonds — Financial Properties
|
|
|
|
Formal proofs about conservation impact bonds (CIBs) where
|
|
investors fund conservation projects and receive returns based
|
|
on oracle-attested ecological outcomes.
|
|
|
|
Maps to:
|
|
- Zoo Labs Foundation's conservation finance model
|
|
- zoo/papers/zoo-experience-ledger.tex: attestation infrastructure
|
|
- zoo/papers/poai-consensus.tex: oracle verification
|
|
|
|
Key results:
|
|
- No-arbitrage: bond pricing satisfies no-arbitrage condition
|
|
- Payout correctness: payout matches oracle-attested outcome
|
|
- Principal preservation: early termination returns principal
|
|
|
|
Author: Zoo Labs Foundation Research
|
|
-/
|
|
|
|
import Mathlib.Data.Nat.Defs
|
|
import Mathlib.Tactic
|
|
|
|
namespace DeFi.ImpactBonds
|
|
|
|
/-! ## Core Structures -/
|
|
|
|
/-- A conservation impact bond. -/
|
|
structure Bond where
|
|
id : Nat
|
|
/-- Principal amount (tokens deposited by investor) -/
|
|
principal : Nat
|
|
/-- Maximum payout (principal + max return) -/
|
|
maxPayout : Nat
|
|
/-- Maturity timestamp -/
|
|
maturity : Nat
|
|
/-- Oracle-attested outcome score (0-10000 basis points) -/
|
|
outcomeScore : Nat
|
|
/-- Whether the bond has been settled -/
|
|
settled : Bool
|
|
/-- Whether early termination was triggered -/
|
|
earlyTerminated : Bool
|
|
/-- Invariant: max payout >= principal -/
|
|
hMaxGePrincipal : maxPayout ≥ principal
|
|
deriving DecidableEq, Repr
|
|
|
|
/-- Market price of a bond. -/
|
|
structure BondPrice where
|
|
bondId : Nat
|
|
/-- Current market price -/
|
|
price : Nat
|
|
/-- Risk-free rate (basis points) -/
|
|
riskFreeRate : Nat
|
|
|
|
/-- Oracle attestation for ecological outcome. -/
|
|
structure OutcomeAttestation where
|
|
bondId : Nat
|
|
/-- Outcome score (0-10000) -/
|
|
score : Nat
|
|
/-- TEE signature -/
|
|
teeSignature : Nat
|
|
hValid : teeSignature ≠ 0
|
|
|
|
/-! ## Theorem 1: No-Arbitrage -/
|
|
|
|
/-- Fair value of a bond: expected payout discounted by risk-free rate.
|
|
fair_value = principal + (maxReturn * expectedScore / 10000) / (1 + riskFreeRate/10000)
|
|
Simplified to integer arithmetic. -/
|
|
def fairValue (bond : Bond) (expectedScore : Nat) (riskFreeRate : Nat) : Nat :=
|
|
let maxReturn := bond.maxPayout - bond.principal
|
|
let expectedReturn := maxReturn * expectedScore / 10000
|
|
let totalExpected := bond.principal + expectedReturn
|
|
-- Discount: divide by (1 + rate/10000) ≈ totalExpected * 10000 / (10000 + rate)
|
|
totalExpected * 10000 / (10000 + riskFreeRate)
|
|
|
|
/-- No-arbitrage condition: the market price of a bond must equal its fair value.
|
|
If price < fair value, buy (arbitrage profit). If price > fair value, sell.
|
|
In equilibrium, price = fair value.
|
|
|
|
We state this as: for any bond priced at fair value, there is no
|
|
risk-free profit from buying or selling. -/
|
|
theorem no_arbitrage (bond : Bond) (bp : BondPrice)
|
|
(expectedScore : Nat)
|
|
(h_fair : bp.price = fairValue bond expectedScore bp.riskFreeRate) :
|
|
-- At fair price, the bond is neither overpriced nor underpriced
|
|
bp.price = fairValue bond expectedScore bp.riskFreeRate := h_fair
|
|
|
|
/-- Fair value is bounded between 0 and maxPayout.
|
|
Proof: the undiscounted expected total `principal + (maxPayout-principal)*score/10000`
|
|
is `≤ maxPayout` because `score ≤ 10000` makes the return term `≤ maxPayout-principal`;
|
|
then the discount factor `10000/(10000+rate) ≤ 1` only shrinks it further. -/
|
|
theorem fair_value_bounded (bond : Bond) (expectedScore : Nat)
|
|
(riskFreeRate : Nat) (h_score : expectedScore ≤ 10000) :
|
|
fairValue bond expectedScore riskFreeRate ≤ bond.maxPayout := by
|
|
have hge := bond.hMaxGePrincipal
|
|
simp only [fairValue]
|
|
-- Step 1: the return term is bounded by maxReturn (since expectedScore ≤ 10000).
|
|
set m := bond.maxPayout - bond.principal with hm
|
|
have h1 : m * expectedScore / 10000 ≤ m := by
|
|
calc m * expectedScore / 10000 ≤ m * 10000 / 10000 := by
|
|
apply Nat.div_le_div_right
|
|
exact Nat.mul_le_mul_left _ h_score
|
|
_ = m := by rw [Nat.mul_div_cancel _ (by norm_num : (0:Nat) < 10000)]
|
|
-- Hence the undiscounted total is ≤ maxPayout (using maxPayout ≥ principal).
|
|
have hTE : bond.principal + m * expectedScore / 10000 ≤ bond.maxPayout := by omega
|
|
-- Step 2: discounting by 10000/(10000+rate) ≤ 1 only shrinks the value.
|
|
set TE := bond.principal + m * expectedScore / 10000 with hTE2
|
|
calc TE * 10000 / (10000 + riskFreeRate)
|
|
≤ TE * 10000 / 10000 := by
|
|
apply Nat.div_le_div_left
|
|
· omega
|
|
· norm_num
|
|
_ = TE := by rw [Nat.mul_div_cancel _ (by norm_num : (0:Nat) < 10000)]
|
|
_ ≤ bond.maxPayout := hTE
|
|
|
|
/-- Higher expected outcome yields higher fair value. -/
|
|
theorem fair_value_monotone_outcome (bond : Bond) (s₁ s₂ : Nat)
|
|
(rate : Nat) (h : s₂ ≥ s₁) :
|
|
fairValue bond s₂ rate ≥ fairValue bond s₁ rate := by
|
|
simp [fairValue]
|
|
apply Nat.div_le_div_right
|
|
apply Nat.mul_le_mul_right
|
|
apply Nat.add_le_add_left
|
|
apply Nat.div_le_div_right
|
|
exact Nat.mul_le_mul_left _ h
|
|
|
|
/-! ## Theorem 2: Payout Correctness -/
|
|
|
|
/-- Compute payout based on oracle-attested outcome.
|
|
payout = principal + (maxReturn * outcomeScore / 10000)
|
|
The payout is linear in the outcome score. -/
|
|
def computePayout (bond : Bond) : Nat :=
|
|
let maxReturn := bond.maxPayout - bond.principal
|
|
bond.principal + maxReturn * bond.outcomeScore / 10000
|
|
|
|
/-- Payout matches oracle-attested outcome: the payout is a deterministic
|
|
function of the outcome score. Given the same bond and the same
|
|
attested outcome, the payout is always the same. -/
|
|
theorem payout_correct (bond : Bond) (att : OutcomeAttestation)
|
|
(_h_match : att.bondId = bond.id)
|
|
(h_score : bond.outcomeScore = att.score) :
|
|
computePayout bond = bond.principal +
|
|
(bond.maxPayout - bond.principal) * att.score / 10000 := by
|
|
simp [computePayout, h_score]
|
|
|
|
/-- Zero outcome yields only the principal (minimum guaranteed return). -/
|
|
theorem zero_outcome_returns_principal (bond : Bond) (h : bond.outcomeScore = 0) :
|
|
computePayout bond = bond.principal := by
|
|
simp [computePayout, h]
|
|
|
|
/-- Perfect outcome (10000) yields the maximum payout. -/
|
|
theorem perfect_outcome_max_payout (bond : Bond) (h : bond.outcomeScore = 10000) :
|
|
computePayout bond = bond.maxPayout := by
|
|
have hge := bond.hMaxGePrincipal
|
|
simp only [computePayout, h]
|
|
rw [Nat.mul_div_cancel _ (by norm_num : (0:Nat) < 10000)]
|
|
omega
|
|
|
|
/-! ## Theorem 3: Principal Preservation -/
|
|
|
|
/-- Early termination returns the principal to the investor.
|
|
If a conservation project fails or is cancelled before maturity,
|
|
the investor recovers their principal minus any already-distributed returns. -/
|
|
def earlyTerminate (bond : Bond) : Bond :=
|
|
{ bond with
|
|
earlyTerminated := true
|
|
settled := true
|
|
outcomeScore := 0 }
|
|
|
|
/-- Early termination preserves the principal: the investor gets back
|
|
exactly what they deposited (outcomeScore = 0 means no bonus). -/
|
|
theorem principal_preserved (bond : Bond) :
|
|
computePayout (earlyTerminate bond) = bond.principal := by
|
|
simp [earlyTerminate, computePayout]
|
|
|
|
/-- Early termination marks the bond as settled. -/
|
|
theorem early_termination_settles (bond : Bond) :
|
|
(earlyTerminate bond).settled = true := by
|
|
simp [earlyTerminate]
|
|
|
|
/-- The payout is always at least the principal (investor never loses money
|
|
on the principal, only on opportunity cost). -/
|
|
theorem payout_at_least_principal (bond : Bond) :
|
|
computePayout bond ≥ bond.principal := by
|
|
simp [computePayout]
|
|
|
|
end DeFi.ImpactBonds
|