Reasoning About Sound Programs Emilio Jesús Gallego Arias Joint work with O. Hermant & P . Jouvelot MINES ParisTech, PSL Research University, France Rennes, 15 Avril 2015
Software verification?
Software verification? What is our gain?
Let’s assume a simple IIR filter: smooth n “ p 1 ´ c q ¨ x n ` c ¨ smooth n ´ 1
Let’s assume a simple IIR filter: smooth n “ p 1 ´ c q ¨ x n ` c ¨ smooth n ´ 1 What would we like to know about it?
smooth n “ p 1 ´ c q ¨ x n ` c ¨ smooth n ´ 1 Natural questions are: § Frequency response; § Stability; § Linearity/Time Invariance. Standard DSP theory gives answers.
smooth n “ p 1 ´ c q ¨ x n ` c ¨ smooth n ´ 1 Natural questions are: § Frequency response; § Stability; § Linearity/Time Invariance. Standard DSP theory gives answers. What about the implementation of the filter? We dive into the realm of PL theory!
smooth n “ p 1 ´ c q ¨ x n ` c ¨ smooth n ´ 1 Natural questions are: § Frequency response; § Stability; § Linearity/Time Invariance. Standard DSP theory gives answers. What about the implementation of the filter? We dive into the realm of PL theory! Paradigm shift!
Faust § Functional PL for digital signal processing. § Synchronous paradigm, geared towards audio. § Programs: circuits/block diagrams with feedback. § Semantics: streams of samples. § Efficiency is crucial . § Created in 2000 by Yann Orlarey et al. at GRAME. § Mature, compiles to more than 14 platforms.
Faust’s Ecosystem Users: § Grame: Multiple projects, main developer. § Stanford: Class/books on signal processing, STK instrument toolkit, Faust2android, Mephisto. . . § Ircam: Acoustic libraries, effects libraries,. . . § Other: Guitarix, moForte guitar, etc...
Faust’s Ecosystem Users: § Grame: Multiple projects, main developer. § Stanford: Class/books on signal processing, STK instrument toolkit, Faust2android, Mephisto. . . § Ircam: Acoustic libraries, effects libraries,. . . § Other: Guitarix, moForte guitar, etc... It has its market! Much easier than dwelling into C.
Faust’s Ecosystem Users: § Grame: Multiple projects, main developer. § Stanford: Class/books on signal processing, STK instrument toolkit, Faust2android, Mephisto. . . § Ircam: Acoustic libraries, effects libraries,. . . § Other: Guitarix, moForte guitar, etc... It has its market! Much easier than dwelling into C. Recent Events: § Faust day at Stanford, LAC 2015. § Faust program competition ( e 2,000). § FEEVER project :)
Syntax and Well-Formedness TERM $ ! : 1 Ñ 0 ID $ _ : 1 Ñ 1 PAR $ f 1 : i 1 Ñ o 1 ¨ ¨ ¨ $ f n : i n Ñ o n n n ÿ ÿ $ p f 1 , . . . , f n q : i j Ñ o j j j COMP $ f : i Ñ k $ g : k Ñ o $ p f : g q : i Ñ o PAN $ f : i Ñ k $ g : k ˚ n Ñ o 0 ă k ^ 0 ă n $ f ă : g : i Ñ o
Feedback FEED $ f : o g ` i f Ñ i g ` o f $ g : i g Ñ o g $ f „ g : i f Ñ i g ` o f Diagram for + „ sin :
Back to the Filter smooth n “ p 1 ´ c q x n ` c ¨ smooth n ´ 1 Using Faust: smooth(c) = *(1-c) : + „ *(c) [For c = 0.9]
Feedback Delay Network fdnrev(N, dp, freqs, durs, loopgainmax) = delaylines „ (delayfilters : feedbackmatrix) where delaylines = rep(N,i,delay(dp[i]))); delayfilters = rep(N,filter(freqs,durs)); feedbackmatrix = bhadamard(N);
Feedback Delay Network fdnrev(N, dp, freqs, durs, loopgainmax) = delaylines „ (delayfilters : feedbackmatrix) where delaylines = rep(N,i,delay(dp[i]))); delayfilters = rep(N,filter(freqs,durs)); feedbackmatrix = bhadamard(N);
PL & Faust § Causal/Synchronous Programming. See next week’s talk! § Functional Reactive Programming/Arrows. § String Diagrams, Monoidal Closed Categories. § Stream/Data Flow Programming.
PL & Faust § Causal/Synchronous Programming. See next week’s talk! § Functional Reactive Programming/Arrows. § String Diagrams, Monoidal Closed Categories. § Stream/Data Flow Programming. Data-intensive vs control-intensive require quite different control techniques. [Berry, 2000]
PL & Faust § Causal/Synchronous Programming. See next week’s talk! § Functional Reactive Programming/Arrows. § String Diagrams, Monoidal Closed Categories. § Stream/Data Flow Programming. Data-intensive vs control-intensive require quite different control techniques. [Berry, 2000] Spectral processing may open a new gap from all of those!
PL & Faust § Causal/Synchronous Programming. See next week’s talk! § Functional Reactive Programming/Arrows. § String Diagrams, Monoidal Closed Categories. § Stream/Data Flow Programming. Data-intensive vs control-intensive require quite different control techniques. [Berry, 2000] Spectral processing may open a new gap from all of those! Some related DSL: VOBLA, Ziria, Halide, Darkroom, Julia.
DSP & Faust § Real-time Linear Processing. § Real-time Non-linear Processing. § Frequency Domain Processing. § Non-necessarily causal. § Filters, Feedback Networks, Interpolation. § Windowing! § Numerical issues. § Nyquist/precision/aliasing.
Verification in DSP/Faust Use mechanized techniques to ensure correct behavior.
Verification in DSP/Faust Use mechanized techniques to ensure correct behavior. § Model checking/automata. § Program analysis/logics. § Strong type systems/correct by construction.
Verification in DSP/Faust Use mechanized techniques to ensure correct behavior. § Model checking/automata. § Program analysis/logics. § Strong type systems/correct by construction. § Main efforts in DSP audio are numeric so far [Souari,Tahar, et al].
Verification in DSP/Faust Use mechanized techniques to ensure correct behavior. § Model checking/automata. § Program analysis/logics. § Strong type systems/correct by construction. § Main efforts in DSP audio are numeric so far [Souari,Tahar, et al]. § Other non-DSP efforts (Antescofo, [Poncelet et. al]).
Verification in DSP/Faust Use mechanized techniques to ensure correct behavior. § Model checking/automata. § Program analysis/logics. § Strong type systems/correct by construction. § Main efforts in DSP audio are numeric so far [Souari,Tahar, et al]. § Other non-DSP efforts (Antescofo, [Poncelet et. al]). Problems with Audio: bad sound, stability/glitches, under/overflows, time, safety/security, remote distribution. We need more!
A Case Study: Stability Test-bed: use Coq Coq is a theorem prover that provides very strong evidence as compared to Mathlab, etc. . .
A Case Study: Stability Test-bed: use Coq Coq is a theorem prover that provides very strong evidence as compared to Mathlab, etc. . . Stability of Smooth When is smooth stable? smooth n “ p 1 ´ c q x n ` c ¨ smooth n ´ 1
A Case Study: Stability Test-bed: use Coq Coq is a theorem prover that provides very strong evidence as compared to Mathlab, etc. . . Stability of Smooth When is smooth stable? smooth n “ p 1 ´ c q x n ` c ¨ smooth n ´ 1 Smooth is stable when c Ps 0 , 1 r . Formally: @ i P r a , b s , c Ps 0 , 1 rÑ smooth p c q i P r a , b s Let’s build a mechanized constructive proof.
What’s the plan? 1. Define the syntax of Faust inside Coq.
What’s the plan? 1. Define the syntax of Faust inside Coq. 2. Define a representation for (sampled) sound.
What’s the plan? 1. Define the syntax of Faust inside Coq. 2. Define a representation for (sampled) sound. 3. Link the two: Interpretation.
What’s the plan? 1. Define the syntax of Faust inside Coq. 2. Define a representation for (sampled) sound. 3. Link the two: Interpretation. 4. Define a logic to simplify reasoning.
What’s the plan? 1. Define the syntax of Faust inside Coq. 2. Define a representation for (sampled) sound. 3. Link the two: Interpretation. 4. Define a logic to simplify reasoning. 5. Verify!
Mechanized Semantics for Streams § Coinductive semantics [Boulmé, et al]: problematic. § Didn’t consider PACO, etc. . . . § Our wish: Sequences S of a base type R [Auger2013]
Mechanized Semantics for Streams § Coinductive semantics [Boulmé, et al]: problematic. § Didn’t consider PACO, etc. . . . § Our wish: Sequences S of a base type R [Auger2013] Soundness needs stronger semantics (also [Guatto2014]): � $ f : i Ñ o � n : � R ˆ . . . ˆ R � n Ñ � R ˆ . . . ˆ R � n l jh n l jh n o i Index by number of steps; equality of streams more intensional wrt to ( N Ñ R ).
The Second Piece: Real Analysis What about the base type R ? § Reals not in Mathcomp – algebraic structures good enough for most of our experiments so far. § There are lots of work to do here. We lack convenient complex numbers, exponentials, etc...
The Second Piece: Real Analysis What about the base type R ? § Reals not in Mathcomp – algebraic structures good enough for most of our experiments so far. § There are lots of work to do here. We lack convenient complex numbers, exponentials, etc...
Proving Stability We could do the proof directly in Coq; it is not difficult, but a bit cumbersome in general. What is worse, the same patterns with minor variations are repeated in each proof: Not practical.
Recommend
More recommend