Certified Symbolic Management of Financial Multi-Party Contracts Patrick Bahr 1 Jost Berthold 2 Martin Elsman 3 1 IT University of Copenhagen 2 Commonwealth Bank of Australia 3 University of Copenhagen ICFP 2015
Example: American Option Contract in natural language ◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1 . 1 of USD. 2 / 13
Example: American Option Contract in natural language ◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1 . 1 of USD. Translation into our contract language if obs ( X exercises option , 0) within 90 then 100 × (EUR( Y → X ) & (1 . 1 × USD( X → Y ))) else ∅ 2 / 13
Example: American Option Contract in natural language ◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1 . 1 of USD. Translation into our contract language if obs ( X exercises option , 0) within 90 then 100 × (EUR( Y → X ) & (1 . 1 × USD( X → Y ))) else ∅ 2 / 13
Example: American Option Contract in natural language ◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1 . 1 of USD. Translation into our contract language if obs ( X exercises option , 0) within 90 then 100 × (EUR( Y → X ) & (1 . 1 × USD( X → Y ))) else ∅ 2 / 13
Example: American Option Contract in natural language ◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1 . 1 of USD. Translation into our contract language if obs ( X exercises option , 0) within 90 then 100 × (EUR( Y → X ) & (1 . 1 × USD( X → Y ))) else ∅ 2 / 13
Example: American Option Contract in natural language ◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1 . 1 of USD. Translation into our contract language if obs ( X exercises option , 0) within 90 then 100 × (EUR( Y → X ) & (1 . 1 × USD( X → Y ))) else ∅ 2 / 13
Example: American Option Contract in natural language ◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1 . 1 of USD. Translation into our contract language if obs ( X exercises option , 0) within 90 then 100 × (EUR( Y → X ) & (1 . 1 × USD( X → Y ))) else ∅ 2 / 13
Example: American Option Contract in natural language ◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1 . 1 of USD. Translation into our contract language if obs ( X exercises option , 0) within 90 then 100 × (EUR( Y → X ) & (1 . 1 × USD( X → Y ))) else ∅ 2 / 13
Goals ◮ Combinators that capture financial contracts ◮ time constraints ◮ external events/data ◮ multi-party ◮ portfolios 3 / 13
Goals ◮ Combinators that capture financial contracts ◮ Symbolic analysis of contracts 3 / 13
Goals ◮ Combinators that capture financial contracts ◮ Symbolic analysis of contracts ◮ Certified implementation 3 / 13
Overview ◮ Denotational semantics based on cash-flows ◮ Type system � causality ◮ Reduction semantics ◮ Formalised in the Coq theorem prover ◮ Certified implementation via code extraction 4 / 13
An Overview of the Contract Language Contract combinators ◮ ∅ ◮ a ( p → q ) ◮ c 1 & c 2 ◮ e × c ◮ if e within d then c 1 else c 2 5 / 13
An Overview of the Contract Language Contract combinators ◮ ∅ ◮ d ↑ c ◮ a ( p → q ) ◮ let x = e in c ◮ c 1 & c 2 ◮ e × c ◮ if e within d then c 1 else c 2 5 / 13
An Overview of the Contract Language Contract combinators ◮ ∅ ◮ d ↑ c ◮ a ( p → q ) ◮ let x = e in c ◮ c 1 & c 2 ◮ e × c ◮ if e within d then c 1 else c 2 Expression Language Real-valued and Boolean-valued expressions, extended by obs ( l , d ) observe the value of l at time d acc ( f , d , e ) accumulation over the last d days 5 / 13
Example: Credit Default Swap Bond if obs ( X defaults , 0) within 30 then ∅ else 1000 × EUR( X → Y ) 6 / 13
Example: Credit Default Swap Bond if obs ( X defaults , 0) within 30 then ∅ else 1000 × EUR( X → Y ) Credit Default Swap (10 × EUR( Y → Z )) & if obs ( X defaults , 0) within 30 then 900 × EUR ( Z → Y ) else ∅ 6 / 13
Example: Credit Default Swap Bond C bond = if obs ( X defaults , 0) within 30 then ∅ else 1000 × EUR( X → Y ) Credit Default Swap C CDS = (10 × EUR( Y → Z )) & if obs ( X defaults , 0) within 30 then 900 × EUR ( Z → Y ) else ∅ 6 / 13
Example: Credit Default Swap Bond C bond = if obs ( X defaults , 0) within 30 then ∅ else 1000 × EUR( X → Y ) Credit Default Swap C CDS = (10 × EUR( Y → Z )) & if obs ( X defaults , 0) within 30 then 900 × EUR ( Z → Y ) else ∅ C bond & C CDS 6 / 13
Example: Credit Default Swap Bond C bond = if obs ( X defaults , 0) within 30 then ∅ else 1000 × EUR( X → Y ) Credit Default Swap C CDS = (10 × EUR( Y → Z )) & if obs ( X defaults , 0) within 30 then 900 × EUR ( Z → Y ) else ∅ C bond & C CDS ≡ (10 × EUR( Y → Z )) & if obs ( X defaults , 0) within 30 then 900 × EUR ( Z → Y ) else 1000 × EUR( X → Y ) 6 / 13
Denotational Semantics � · � · : Contr × Env → CashFlow � c � ρ = T 0 T 1 T 2 T 3 T 4 . . . time 0 1 2 3 4 � c � ρ ∈ CashFlow = N → Transactions T i ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R 7 / 13
Denotational Semantics � · � · : Contr × Env → CashFlow � c � ρ = T 0 T 1 T 2 T 3 T 4 . . . time 0 1 2 3 4 R 0 R 1 R 2 R 3 R 4 . . . � c � ρ ∈ CashFlow = N → Transactions T i ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R 7 / 13
Denotational Semantics � · � · : Contr × Env → CashFlow � c � ρ = T 0 T 1 T 2 T 3 T 4 . . . time − 4 − 3 − 2 − 1 0 1 2 3 4 R − 4 R − 3 R − 2 R − 1 . . . R 0 R 1 R 2 R 3 R 4 . . . � c � ρ ∈ CashFlow = N → Transactions T i ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R 7 / 13
Denotational Semantics � · � · : Contr × Env → CashFlow � c � ρ = T 0 T 1 T 2 T 3 T 4 . . . time − 4 − 3 − 2 − 1 0 1 2 3 4 R − 4 R − 3 R − 2 R − 1 . . . R 0 R 1 R 2 R 3 R 4 . . . ρ � c � ρ ∈ CashFlow = N → Transactions T i ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R 7 / 13
Denotational Semantics � · � · : Contr × Env → CashFlow � c � ρ = T 0 T 1 T 2 T 3 T 4 . . . time − 4 − 3 − 2 − 1 0 1 2 3 4 R − 4 R − 3 R − 2 R − 1 . . . R 0 R 1 R 2 R 3 R 4 . . . ρ � c � ρ ∈ CashFlow = N → Transactions T i ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R 7 / 13
Denotational Semantics � · � · : Contr × Env → CashFlow � c � ρ = T 0 T 1 T 2 T 3 T 4 . . . time − 4 − 3 − 2 − 1 0 1 2 3 4 R − 4 R − 3 R − 2 R − 1 . . . R 0 R 1 R 2 R 3 R 4 . . . ρ � c � ρ ∈ CashFlow = N → Transactions T i ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R 7 / 13
Type System Time-Indexed Types ◮ e : Real t , e : Bool t value of e available at time t (and later) ◮ c : Contr t no obligations strictly before t 8 / 13
Type System Time-Indexed Types ◮ e : Real t , e : Bool t value of e available at time t (and later) ◮ c : Contr t no obligations strictly before t Typing Rules Γ ⊢ e : Real s Γ ⊢ c : Contr s t ≤ s Γ ⊢ e × c : Contr t l ∈ Label τ t ≤ s t ≤ 0 Γ ⊢ a ( p → q ) : Contr t Γ ⊢ obs ( l , t ) : τ s . . . 8 / 13
Type System Time-Indexed Types ◮ e : Real t , e : Bool t value of e available at time t (and later) ◮ c : Contr t no obligations strictly before t Typing Rules Γ ⊢ e : Real s Γ ⊢ c : Contr s t ≤ s Γ ⊢ e × c : Contr t l ∈ Label τ t ≤ s t ≤ 0 Γ ⊢ a ( p → q ) : Contr t Γ ⊢ obs ( l , t ) : τ s . . . 8 / 13
Reduction Semantics T ⇒ ρ c ′ = c 9 / 13
Reduction Semantics T ⇒ ρ c ′ = c � c � ˆ ρ = T 0 T 1 T 2 T 3 T 4 T 5 . . . time 0 1 2 3 4 5 6 � c ′ � ˆ ρ = 9 / 13
Reduction Semantics T ⇒ ρ c ′ = c � c � ˆ ρ = T 0 T 1 T 2 T 3 T 4 T 5 . . . time 0 1 2 3 4 5 6 � c ′ � ˆ ρ = 9 / 13
Reduction Semantics T 0 ⇒ ρ c ′ = c � c � ˆ ρ = T 0 T 1 T 2 T 3 T 4 T 5 . . . time 0 1 2 3 4 5 6 � c ′ � ˆ ρ = 9 / 13
Reduction Semantics T 0 ⇒ ρ c ′ = c � c � ˆ ρ = T 0 T 1 T 2 T 3 T 4 T 5 . . . time 0 1 2 3 4 5 6 � c ′ � ˆ ρ = 9 / 13
Reduction Semantics T 0 ⇒ ρ c ′ = c � c � ˆ ρ = T 0 T 1 T 2 T 3 T 4 T 5 . . . time 0 1 2 3 4 5 6 � c ′ � ˆ ρ = T 1 T 2 T 3 T 4 T 5 T 6 . . . 9 / 13
Reduction Semantics T 0 ⇒ ρ c ′ = c � c � ˆ ρ = T 0 T 1 T 2 T 3 T 4 T 5 . . . time 0 1 2 3 4 5 6 � c ′ � ˆ ρ = T 1 T 2 T 3 T 4 T 5 T 6 . . . 9 / 13
Recommend
More recommend