program extraction from nested definitions
play

Program Extraction from Nested Definitions Kenji Miyamoto 1 , , - PowerPoint PPT Presentation

Program Extraction from Nested Definitions Kenji Miyamoto 1 , , Fredrik Nordvall Forsberg 2 , , and Helmut Schwichtenberg 1 1 Ludwig Maximilian University, Munich 2 Swansea University, Wales Supported by the Marie Curie Initial


  1. Program Extraction from Nested Definitions Kenji Miyamoto 1 , ˚ , Fredrik Nordvall Forsberg 2 , ˚ , ˚˚ and Helmut Schwichtenberg 1 1 Ludwig Maximilian University, Munich 2 Swansea University, Wales ˚ Supported by the Marie Curie Initial Training Network in Mathematical Logic – MALOA – From MAthematical LOgic to Applications, PITN-GA-2009-238381. ˚˚ Supported by EPSRC grant EP/G033374/1, Theory and applications of induction-recursion. 26.07.2013 ITP 2013, Rennes K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  2. Outline Proof assistant Minlog and the theory TCF behind it to study computational meaning of proofs. Case study in exact real arithmetic. K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  3. Note on listrev.scm We inductively define predicate A of arity p L N , L N , L N q . A p u , v , w q means that the append of u and v is w . ( A ` @ v A prs , v , v q , 0 ) ( A ` @ u , v , w , x p A p u , v , w q Ñ A p x :: u , v , x :: w qq . 1 ) The above formulas are adopted as the introduction axioms of A . We inductively define R of arity p L N , L N q as follows. ( R ` R prs , rsq , 0 ) ( R ` @ u , v , w , x p R p u , v q Ñ A p v , x :: rs , w q Ñ R p x :: u , w qq . 1 ) K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  4. Note on listrev.scm From the proof of the proposition @ v D w R p v , w q we extracted a term λ u p R L N L N u rs λ x , v , w p R L N L N w p x :: rsq λ y , p y :: qqq of type L N Ñ L N . We can export the term to Haskell. module Main where import Data.List ----- Algebras ------------------ type Nat = Integer ----- Recursion operators ------- listRec :: [alpha] -> alpha1 -> (alpha -> ([alpha] -> (alpha1 -> alpha1))) -> alpha1 listRec [] a f = a listRec (b : z) a f = ((f b) z) (listRec z a f) K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  5. Note on listrev.scm ----- Program constants --------- cLA :: [Nat] -> [Nat] -> [Nat] cLA = \ v0 -> (\ v1 -> (listRec v1 v0 (\ x2 -> (\ v3 -> (:) x2)))) cLR :: [Nat] -> [Nat] cLR = \ v0 -> (listRec v0 [] (\ x1 -> (\ v2 -> (cLA (x1 : []))))) --------------------------------- rev :: [Nat] -> [Nat] rev = cLR apd :: [Nat] -> [Nat] -> [Nat] apd = cLA --------------------------------- main :: IO () main = putStrLn "" K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  6. Constants and axioms The recursion operator R ρ L α came from induction on lists. R ρ L α : L α Ñ ρ Ñ p α Ñ L α Ñ ρ Ñ ρ q Ñ ρ, R ρ L α rs M 0 M 1 “ M 0 , R ρ L α p x :: u q M 0 M 1 “ M 1 x u p R ρ L α u M 0 M 1 q . We relate R ρ L α with the induction on list, which come from the totality predicate T L . p T L q ` 0 , p T L q ` @ nc T L rs , x , u p Q p x q Ñ T L p u q Ñ T L p x :: u qq , 1 @ nc u p T L u Ñ P rs Ñ @ nc p T L q ´ x , u p Q p x q Ñ T L u Ñ Pu Ñ P p x :: u qq Ñ Pu q . where Q is a parameter predicate of arity p α q . We refer to p T L q ´ by elimination axiom or induction. We formally relate a term and a formula via realizability r . For example, we expect: “Constructor” r “introduction axiom”, “Recursion operator” r “elimination axiom”, Let A be a formula with proof M . We can compute: the type τ p A q of potential realizers of A . a realizer (extracted term) et p M q τ p A q of A (program extraction). K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  7. Realizability Realizability is a way to think about a computational solution of a problem expressed by a formula. We work in first-order minimal logic with implication and universal quantifiers. The realizability relation is: t r A Ñ B : “ @ x p x r A Ñ t p x q r B q , t r @ x A : “ @ x p t p x q r A q . We consider non-computational variants of Ñ and @ . t r A Ñ nc B : “ @ x p x r A Ñ t r B q , t r @ nc x A : “ @ x p t r A q . We call Ñ and @ computational . Ñ , @ and Ñ nc , @ nc are logically the same, but computationally different due to the realizability relation. Conjunction, disjunction and the existential quantifier are defined as inductive definitions. In contrast to the BHK-interpretation we also consider concrete prime formulas, namely, inductively defined predicates. s : “ I r p t ,� t r I � s q . where I r is an inductive predicate, called a witnessing predicate , defined for each I . K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  8. Witnessing predicates Consider the predicate T L whose arity is p L α q . p T L q ` T L rs , 0 @ nc p T L q ` x , u p Qx Ñ T L u Ñ T L p x :: u qq . 1 where Q is a predicate parameter of arity p α q , an arbitrary type parameter. The type of an inductive predicate I , namely, τ p I q is the algebra whose constructor types are the types of the introduction axioms. Consider T L . By τ the introduction axioms go to the constructor types ξ, α Ñ ξ Ñ ξ, which define the list algebra L α . We define the witnessing predicate T r L of arity p τ p T L q , L α q as follows. L q ` T r p T r L prs , rsq , 0 L q ` @ nc x , y , u , v p Q ˚ p y , x q Ñ T r L p v , u q Ñ T r p T r L p y :: v , x :: u qq . 1 where Q ˚ is a predicate parameter of arity p τ p Q q , α q . K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  9. Program extraction The notion of proof is given in natural deduction, which is represented in lambda terms. We define the program extraction et . Definition (Program extraction) Let M A be a proof A . We define et p M A q by induction on the construction of M A . et p u A q : “ x τ p A q where x u A is uniquely associated with u A , u A et p I ` et p I ´ q : “ R τ i q : “ C i , ι , et pp λ u A M B q A Ñ c B q : “ λ x τ p A q et pp λ u A M B q A Ñ nc B q : “ et p M q , p et p M qq , u et p M A Ñ c B N A q : “ et p M q et p N q , et p M A Ñ nc B N A q : “ et p M q , et pp λ x ρ M A q @ c x A q : “ λ x ρ et p M q , et pp λ x ρ M A q @ nc A q : “ et p M q , x et pp M @ c et pp M @ nc x A r q A p r q q : “ et p M q r , A r q A p r q q : “ et p M q . x The following theorem claims that the program extraction finds a realizer. Theorem (Soundness) Let A be a formula and M be a proof of A under assumptions B i for i ă k. Then, there is a proof of et p M q r A under the assumptions u B i for i ă k. i K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  10. Branching trees We consider arbitrarily branching trees based on the following nested algebra Nt . Lf Nt , Br L Nt Ñ Nt . We can think about the combinations of the finiteness and the infiniteness. finite branching / finite height, infinite branching / finite height, finite branching / infinite height, infinite branching / infinite height. We construct trees of finite branching / infinite height by using co R ρ Nt , the corecursion operator on Nt . The type of co R ρ Nt and R ρ Nt are: co R ρ Nt : ρ Ñ p ρ Ñ U ` L Nt ` ρ q Ñ Nt , R ρ Nt : Nt Ñ ρ Ñ p L Nt ˆ ρ Ñ ρ q Ñ ρ « Nt Ñ p U Ñ ρ q Ñ p L Nt ˆ ρ Ñ ρ q Ñ ρ « Nt Ñ p U ` L Nt ˆ ρ Ñ ρ q Ñ ρ. K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  11. Corecursion operators The outcome is determined by the result of applying the second argument to the first argument. co R ρ Nt : ρ Ñ p ρ Ñ U ` L Nt ` ρ q Ñ Nt , co R τ Nt ÞÑ λ u , v p Case vu of inl pq Ñ Lf inr x Ñ Br p M Nt ` τ Ñ Nt x r id , λ z p co R τ Nt zv qsqq . λ α L α where for f α Ñ σ and g β Ñ σ we define r f , g s α ` β Ñ σ by r f , g sp inl x α q “ f p x q , r f , g sp inr y β q “ g p y q . The map operator M constructs subtrees at each branch. M ρ Ñ σ λ α L α : L ρ Ñ p ρ Ñ σ q Ñ L σ , λ α L α rs ρ f “ rs σ , M ρ Ñ σ M ρ Ñ σ λ α L α p x :: u q f “ f p x q :: M ρ Ñ σ λ α L α u f . Destructors are given for each algebra as follows: D Nt : Nt Ñ U ` L Nt , D Nt p Lf q “ inl pq , D Nt p Br u q “ inr u . K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

  12. Coinductive definitions For an inductive predicate I we define its companion coinductive predicate co I . Let T L α p Q q be a predicate stating a finite list of objects in Q . @ nc T L α rs , x , u p Qx Ñ T L α u Ñ T L α p x :: u qq . Define T Nt of arity p Nt q to be: p T Nt q ` T Nt p Lf q , 0 p T Nt q ` @ nc u p T L Nt p T Nt qp u q Ñ T Nt p Br u qq . 1 The coinductive predicate co T Nt of arity p Nt q is defined by the clause axiom co T Nt , the dual of p T Nt q ` 0 and p T Nt q ` 1 . @ nc a p co T Nt p a q Ñ a “ Lf _ D u p T L Nt p co T Nt qp u q ^ a “ Br u qq . p co T Nt q ´ The greatest-fixed-point axiom (or coinduction ) is given as follows: @ nc a p Pa Ñ@ nc a p Pa Ñ a “ Lf _ D u p T L Nt p co T Nt _ P qp u q ^ a “ Br u qq Ñ p co T Nt q ` co T Nt p a qq . It states that co T Nt is bigger than any competitor P that looks like co T Nt in p co T Nt q ´ . The realizability relation is extended to coinductive definitions. The program extraction is as well: et p co I ´ q : “ D τ p I q , et p co I ` q : “ co R ρ τ p I q . K. Miyamoto, F. Nordvall Forsberg and H. Schwichtenberg Program Extraction from Nested Definitions

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend