Light Dialectica program extraction from a classical Fibonacci proof using an optimization of Gödel s technique towards the extraction of more efficient programs from classical proofs Mircea Dan HERNEST Project LogiCal Paris, FRANCE and GKLI Munich, GERMANY DCM 06 Talk in Venice, 16 July 2006 Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 1 / 19
Outline 1 The program extraction Problem Specifying the wanted behaviour of programs A weakly extensional Arithmetic for Göedel functionals 2 The Light Functional Dialectica Interpretation From Gödel s Dialectica to the Light Dialectica The Contraction Problem 3 Conclusions and Further Work Applicability of Light Dialectica??? Open research... Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 2 / 19
Outline 1 The program extraction Problem Specifying the wanted behaviour of programs A weakly extensional Arithmetic for Göedel functionals 2 The Light Functional Dialectica Interpretation From Gödel s Dialectica to the Light Dialectica The Contraction Problem 3 Conclusions and Further Work Applicability of Light Dialectica??? Open research... Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 2 / 19
Outline 1 The program extraction Problem Specifying the wanted behaviour of programs A weakly extensional Arithmetic for Göedel functionals 2 The Light Functional Dialectica Interpretation From Gödel s Dialectica to the Light Dialectica The Contraction Problem 3 Conclusions and Further Work Applicability of Light Dialectica??? Open research... Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 2 / 19
Why x y G(x, y) specifications? [G Goal Formula] Specifications describe wanted behavior for our Program. Programs have inputs x and outputs y. Therefore specifications are formulas x y G(x, y) where G(x, y) is a formula describing the desired relationship between the given input x and the desired output y. Exists proof P of x y G(x, y) in some logical system S. We want to be able to uniformly produce by an Algorithm a program t which realizes the given specification, i.e., x G(x, t(x)) is provable in some (other) logical system S. Such Algorithms taking inputs P are Program Extraction procedures and the term t is called extracted program. Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 3 / 19
Classical versus Constructive proofs Recall that P is a proof of x y G(x, y) in the logical system S! G can be arbitrary only when S is constructive, otherwise... Constructive means intuitionistic plus Markov s Principle : zg 0 (z) zg 0 (z) or }{{} cl z G 0 (z) zg 0 (z) z Only extraction techniques based on Gödel s Dialectica interpretation allow Markov s Principle (as axiom) in S. Refined A translation first brings the Minimal Logic proof [minimal intuitionistic \ F ] of x cl y G(x, y) to a corresponding intuitionistic proof of x y G(x, y) Kreisel s Modified Realizability applies to the latter. G can be a goal formula i.e., more than quantifier-free. Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 4 / 19
The term system a lambda-variant of Göedel s T 0) All finite types generated from ι and o by the rule σ, τ (στ) 1) tt o, ff o, the selector If o τ τ τ τ (usual if-then-else), equality = ι ι o 2) 0 ι (zero), S ι τ (ι τ τ) ι τ (successor) and Gödel s recursor Rτ 3) And ooo : λp, q. If o p q ff Imp ooo : λp, q. If o p q tt n n 4) the n-selector Ifτ n {}}{{}}{ of type o... o τ... τ τ τ, s.t. Ifτ 1 : If τ and If n τ : λp 1,..., p n, x n+1, x n,..., x 1. If τ p 1 (If n 1 τ p 2... p n x n+1 x n... x 2 ) x 1 If n τ (r 1,..., r n, t n+1, t n,..., t 1 ) selects the first t i with i 1, n for which r i is false, if it exists, otherwise t n+1 if all {r i } n i=1 are true 5) s = σ1...σ n σ t : x σ 1 1... x σn n (s x 1... x n = σ t x 1... x n ), σ {o, ι} s = o t : at(s) at(t), s = ι t : at(= s t) extensionally defined equality at is the unique predicate symbol of WE Z Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 5 / 19
The logical axioms and rules of system WE Z (1/2) Ax + : z 1 [ A(z 1 ) z 2 A(z 2 ) ] AxEFQ : A 0) Ax + : z 1 [ A(z 1 ) z 2 A(z 2 ) ] (Ex-Falso-Quodlibet) Ax : z 1 A(z 1 ) z 2 [ A(z 2 ) B ] B Ax : z 1 A(z 1 ) z 2 [ A(z 2 ) B ] B 1) Deduction from (arbitrary, undischarged) assumption: A A 2) A B A l, A B B r, A, B A B +, A, A B B z A(z) 3) [ z A(z) A(z) z,t ] z,t VC 2 (z, t), A(t) A(t) z A(z) + z VC 1 (z) VC 1 (z) : z does not occur free in any undischarged assumption VC 2 (z, t) : no free variable of t gets quantified in A after substit. Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 6 / 19
The logical axioms and rules of system WE Z (2/2) 4) [A]... /B A B +, particular set of instances of A discharged; if at least two A get discharged (contraction) then ncm-fc(a) restriction applies: if A contains (at least) a positive universal or a negative existential (regular) quantifier then A must not contain any ncm quantifier (, ) case when we say that A is computationally relevant (otherwise A is comput. irrelevant) P: A(z) 5) + z VC 1 (z) and VC 3 (z, P) : z is not free in any of the t z A(z) involved by,t in the proof P (Berger) and z is also not free in the computationally relevant contraction formulas of P Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 7 / 19
Extensionality/Compatibility and Induction rules E σ,τ : z στ, x σ, y σ. x = σ y zx = τ zy must be forbidden A 0 COMPAT σ with the restriction that. all undischarged assumptions used s = σ t in the proof of s = σ t (here denoted A 0 ) B(s) B(t) are quantifier-free IR 0 equivalent to IA, IR in WE Z.. A(tt) A(ff) p o A(p) A(0) z (A(z) A(Sz)) (Boolean Induction Axiom) z A(z) R τ x y 0 = τ x R τ x y (Sz) = τ y(z, R τ x y z) } : AxR τ Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 8 / 19
Weakly extensional Arithmetics WE Z, WE Z, WE Z + System WE Z obtained from WE Z by ignoring ncm quantifiers 0) Prime formulas decidable: at(t) at(t) by definition of 1) Exists unique bijective association of boolean terms to qfr formulas A 0 t A0 such that A 0 at(t A0 ) 2) Case Distinction over qfr formulas: (A 0 A) ( A 0 A) A 3) Disjunction Elimination n i=1 (A i B) ( n i=1 A i B) System WE Z + obtained by adding to WE Z the following: AxMK : cl z A 0 (z) z A 0 (z) AxIP : [ x A 0 (x) y B(y) ] y [ x A 0 (x) B(y) ] AxAC : x y B(x, y) Y x B(x, Y (x)) Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 9 / 19
Göedel s functional Dialectica interpretation 0) A translation of proofs which includes a translation of formulas. 1) A(a) A D x y A D (x; y; a) with a all free vars of formula A 2) A D is qfr for Göedel s Dialectica, not necess for Light Dialectica 3) Recursive syntactic translation from proofs in Constructive Arithmetic (or Classical Arithmetic, modulo the double-negation translation) to proofs in Intuitionistic Arithmetic such that positive occurrences of and negative occurrences of in the proof s conclusion formula get actually realized by terms in Gödel s T. 4) Contraction Problem: choose between a number of realizers according to a boolean term associated to the contraction formula; Diller-Nahm: postpone all choices to the very end by collecting all candidates and making a single final global choice; Monotone (or Bounded) Dialectica: use a Howard (or Bezem) majorant of the candidates extract majorants for the realizers. Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 10 / 19
The Light Dialectica interpretation of formulas A D (A D : A) for prime formulas A (A B) D x, u y, v [ (A B) D : A D (x; y; a) B D (u; v; b) ] (A B) D Y, U x, v [ (A B) D : A D (x; Y (x, v)) B D (U(x); v) ] ( za(z, a)) D z, x y [ ( za(z, a)) D (z, x; y; a) : A D (x; y; z, a) ] ( za(z, a)) D x y [ ( za(z, a)) D (x; y; a) : z A D (x; y; z, a) ] ( za(z, a)) D X z, y [ ( za(z, a)) D (X; z, y; a) : A D (X(z ); y; z, a) ] ( za(z, a)) D x y [ ( za(z, a)) D (x; y; a) : z A D (x; y; z, a) ] Here is a mapping which assigns to every given variable z a completely new variable z which has the same type of z. Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 11 / 19
Exact realizer synthesis by the LD-interpretation Extraction and Soundness Theorem: There exists an algorithm which, given at input a proof P : {C i } n i=1 + A will produce at output 1) the tuples of terms T and {T i } n i=1 2) the tuples of variables {x i } n i=1 and y 3) the verifying proof P D : {C i D (x i; T i (x, y))} n i=1 A D (T (x); y) where x : x 1,..., x n. Moreover, 1 variables x and y are all completely new (not occur in P) 2 the free variables of T and {T i } n i=1 are among the free variables of A and {C i } n i=1 ( the free variable condition (FVC) for programs extracted by the (L)D-interpretation ) [ x, y not occur free in the extracted terms {T i } n i=1 and T ] Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 12 / 19
Implication Introduction with Contraction [A]... /B A B + n 1, z n+1 {}}{ z,..., z and x x n+2,..., x m : {A D (z; T i (z, x, y))} n+1 i=1, {Ci D (x i; T i (z, x, y))} m i=n+2 B D (T (z, x); y) 1) Same tuple z produced by n + 1 m discharged instances of A 2) ncm-fc(a) = tuples {T i } n+1 i=1 are all of length 0 or A D is qfr 3) If {T i } n+1 i=1 non-null = their equalization is a must: S : λx, z, y. If n τ (t D A [z; T 1 ],..., t D A [z; T n ], T n+1 (z, x, y), T n,..., T 1 ) we can now cancell all {A D } n+1 i=1 by a single + in the verifying proof {A D (z; S(x, z, y))} n+1 i=1, {Ci D (x i; S i (x, z, y))} m i=n+2 B D (S(x, z); y) {C i D (x i; S i (x, z, y))} m i=n+2 A D (z; S(x, z, y)) B D (S(x, z); y) Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 13 / 19
Computationally-redundant Contraction - an example Warning: A and B are here the same as on the previous slide!!! A, A B B {C i D (x i ; S i(x, y ))} n+1 i=1 A D (S (x ); y ) {CD i (x i ; S i (x, z, y))} m i=n+2 A D (z; S(x, z, y)) B D (S(x, z); y) λx, y. S i (x, S(x, S (x ), y)), if 1 i n + 1 T i : λx, y. S i (x, S (x ), y), if n + 1 < i m T : λx. S(x, S (x )) Extraction and Soundness Theorem: {C i D (x i; T i (x, y))} m i=1 B D (T (x); y) Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 14 / 19
Contraction involved by usual Induction Rule (worst) We are given P b : C b A(0) and P s : C s z(a(z) A(Sz)) C s C b C b (C s A(z)). C s P s C s A(z) z(a(z) A(Sz)) A(z) A(z) A(Sz) A(Sz) first cancell C s (with contraction) and subsequently C b (without contraction) to get C b (C s A(z)) C b (C s A(Sz)) = z[(c b (C s A(z))) C b (C s A(Sz))] = by -premised Induction Rule that z(c b (C s A(z))) from which we recover the usual conclusion C b, C c za(z) Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 15 / 19
Clear-cut practical example - classical Fibonacci MINLOG program extracted by Light Dialectica (after normalization) [n 0 ]π 1 (R IN (IN@IN) (0@1){[n 1, p IN@IN ]π 2 (p)@(π 1 (p) + π 2 (p))}n 0 ) Exactly the usual algorithm computing the n-th Fibonacci number. [G, n 1 ]π 1 π 2 (R IN=>IN@(IN@IN)@(IN@IN) ((0@0@0)@0@1){[n 2, p][if[if(gπ 1 π 1 (p)π 1 π 2 π 1 (p)) [If(G(Sπ 1 π 1 (p))π 2 π 2 π 1 (p))(g(s(sπ 1 π 1 (p)))(π 1 π 2 π 1 (p) + π 2 π 2 π 1 (p)))tt]tt] (n 2 @π 2 (p))(π 1 (p))]@π 2 π 2 (p)@π 1 π 2 (p) + π 2 π 2 (p)}n 1 ) This by Gödel s Dialectica If-tests are only due to the Contraction formula, integrated in extracted program The BBS Refined A-translation yields a more complex program: [n] R IN (IN IN IN) IN ([f IN IN IN ] f 0 1) ([m, H, g IN IN IN ] H ([p, q] H ([k, l] g l (k + l)))) n ([k, l]k) uses the type-2 functional H (IN IN IN) IN, within the recursion Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 16 / 19
Attempts to apply Light Dialectica - a negative result Dickson-2-2 Lemma: For any two functions f, g : IN IN defined within the set of natural numbers IN there exist indexes i < j such that both f (i) f (j) and g(i) g(j). Classical proof within Minimal Arithmetic uses 3 times the Minimum Principle (relative to unary predicate variable Q IN ): h IN IN. cl zq(z) cl x. ( y. h(y) < h(x) Q(y)) Q(x) Not possible to use an ncm version of cl x in none of the 3 instances of Minimum Principle... but x is positive universal quantified in a Contraction formula (thus computationally relevant)...... impossible to avoid any of the 3 contractions. These contractions are involved by Induction and the realizing program must contain 3 times Gödel s recursor R τ (as iterator). Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 17 / 19
Short List of related Papers I M.-D. Hernest and U. Kohlenbach. A complexity analysis of functional interpretations. Theoretical Computer Science, 338(1-3):200 246, 2005. M.-D. Hernest. A comparison between two techniques of program extraction from classical proofs. In M. Baaz, J. Makovsky, and A. Voronkov, editors, CSL 2003: Extended Posters, vol. VIII of Kurt Gödel Society s Collegium Logicum, pp. 99 102. Springer Verlag, 2004. U. Kohlenbach and P. Oliva. Proof mining: a systematic way of analysing proofs in Mathematics. Proc. of the Steklov Inst. of Mathem., 242:136 164, 2003. Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 18 / 19
Short List of related Papers II M.-D. Hernest, Light Functional Interpretation, LNCS 3634 (2005), pp. 477 492, CSL 2005. U. Berger, W. Buchholz, and H. Schwichtenberg. Refined program extraction from classical proofs. Annals of Pure and Applied Logic, 114:3 25, 2002. C. Raffalli. Getting results from programs extracted from classical proofs. Theoretical Computer Science, 323(1-3):49 70, 2004. C. Paulin-Mohring and B. Werner. Synthesis of ML programs in the system Coq. Journal of Symbolic Computation, 15(5/6):607 640, 1993. Mircea Dan HERNEST (LogiCal) Light Dialectica on Fibonacci DCM 06, Venice, 16 July 2006 19 / 19