GF: a Logical Framework for Grammars Aarne Ranta University of Gothenburg and Digital Grammars AB Estonian-Finnish Logic Meeting Rakvere, 15 November 2015 CLT
Contributors Krasimir Angelov, Björn Bringert, Grégoire Détrez, Ramona Enache, Erik de Graaf, Thomas Hallgren, Qiao Haiyan, Kaarel Kaljurand, Chotiros Kairoje, Prasanth Kolachina, Hans Leiß, Inari Listenmaa, Peter Ljunnglöf, K.V.S. Prasad, Scharolta Siencnik, Christina Unger, Daniel Vidal, Shafqat Virk, Liza Zimina 50+ GF Resource Grammar Library contributors 150+ GF-dev members
Outline Demo Overview: interlingua and translation Hands-on coding
Demo
Mobile https://play.google.com/store/apps/details?id=org.grammaticalframework.ui.android https://itunes.apple.com/us/app/gf-offline-translator/id1023328422?mt=8
Cloud http://cloud.grammaticalframework.org/
Overview: translation and interlingua
Google translate 16 September 2015
one can learn to name every one of the infinite series of numbers, and thus to write infinitely many different words in an unknown language . The same could be done for all the other words necessary to express all the other things which fall within the purview of the human mind . the discovery of s uch a language depends upon the true philosophy . Descartes, letter to Mersenne, 1629 http://www.autodidactproject.org/other/descartes-lg1.html
Wikipedia
LF = Logical Framework from - one universal logic to - a framework for defining logics - hence, many special-purpose logics Theory: higher-level type theory 1984 Implementations: LF, ALF, Coq, Agda
GF = Grammatical Framework from - one universal grammar to - a framework for defining grammars - hence, many special-purpose grammars
GF = LF + concrete syntax interlingua = logic = abstract syntax concrete syntax : mapping from an interlingua to a language
To achieve precision “ all things which fall within the purview of the human mind” domain-specific interlinguas : - mathematics - tourist phrases - sports - etc, etc
TitleParagraph DefinitionTitle DefPredParagraph type_Sort A_Var contractible_Pred (ExistCalledProp a_Var (ExpSort (VarExp A_Var)) (FunInd centre_of_contraction_Fun) (ForAllProp (BaseVar x_Var) (ExpSort (VarExp A_Var)) (ExpProp (equalExp (VarExp a_Var) (VarExp x_Var))))) FormatParagraph EmptyLineFormat TitleParagraph DefinitionTitle DefPredParagraph (mapSort (mapExp (VarExp A_Var) (VarExp B_Var))) f_Var equivalence_Pred (ForAllProp (BaseVar y_Var) (ExpSort (VarExp B_Var)) (PredProp contractible_Pred (AliasInd (AppFunItInd fiber_Fun) (FunInd (ExpFun (ComprehensionExp x_Var (VarExp A_Var) (equalExp (AppExp f_Var (VarExp x_Var)) (VarExp y_Var)))))))) DefPropParagraph (ExpProp (equivalenceExp (VarExp A_Var) (VarExp B_Var))) (ExistSortProp (equivalenceSort (mapExp (VarExp A_Var) (VarExp B_Var)))) FormatParagraph EmptyLineFormat TitleParagraph LemmaTitle TheoremParagraph (ForAllProp (BaseVar A_Var) type_Sort (PredProp equivalence_Pred (AliasInd (FunInd identity_map_Fun) (FunInd (ExpFun (DefExp (identityMapExp (VarExp A_Var)) (TypedExp (BaseExp (lambdaExp x_Var (VarExp A_Var) (VarExp x_Var))) (mapExp (VarExp A_Var) (VarExp A_Var))))))))) FormatParagraph EmptyLineFormat TitleParagraph ProofTitle AssumptionParagraph (ConsAssumption (ForAssumption y_Var (ExpSort (VarExp A_Var)) (LetAssumption (FunInd (ExpFun (DefExp (fiberExp (VarExp y_Var) (VarExp A_Var)) (ComprehensionExp x_Var (VarExp A_Var) (equalExp (VarExp x_Var) (VarExp y_Var)))))) (AppFunItInd (fiberWrt_Fun (FunInd (ExpFun (identityMapExp (VarExp A_Var)))))))) (BaseAssumption (LetExpAssumption (barExp (VarExp y_Var)) (TypedExp (BaseExp (pairExp (VarExp y_Var) (reflexivityExp (VarExp A_Var) (VarExp y_Var)))) (fiberExp (VarExp y_Var) (VarExp A_Var)))))) ConclusionParagraph (AsConclusion (ForAllProp (BaseVar y_Var) (ExpSort (VarExp A_Var)) (ExpProp (equalExp (pairExp (VarExp y_Var) (reflexivityExp (VarExp A_Var) (VarExp y_Var))) (VarExp y_Var)))) (ApplyLabelConclusion id_induction_Label (ConsInd (FunInd (ExpFun (VarExp y_Var))) (ConsInd (FunInd (ExpFun (TypedExp (BaseExp (VarExp x_Var)) (VarExp A_Var)))) (ConsInd (FunInd (ExpFun (TypedExp (BaseExp (VarExp z_Var)) (idPropExp (VarExp x_Var) (VarExp y_Var))))) BaseInd))) (DisplayExpProp (equalExp (pairExp (VarExp x_Var) (VarExp z_Var)) (VarExp y_Var))))) ConclusionSoThatParagraph (ForConclusion (BaseVar y_Var) (ExpSort (VarExp A_Var)) (ApplyLabelConclusion sigma_elimination_Label (ConsInd (FunInd (ExpFun (TypedExp (BaseExp (VarExp u_Var)) (fiberExp (VarExp y_Var) (VarExp A_Var))))) BaseInd) (ExpProp (equalExp (VarExp u_Var) (VarExp y_Var))))) (PredProp contractible_Pred (FunInd (ExpFun (fiberExp (VarExp y_Var) (VarExp A_Var))))) ConclusionParagraph (PropConclusion (PredProp equivalence_Pred (FunInd (ExpFun (TypedExp (BaseExp (identityMapExp (VarExp A_Var))) (mapExp (VarExp A_Var) (VarExp A_Var))))))) QEDParagraph https://github.com/GrammaticalFramework/gf-contrib/tree/master/homotopy-typetheory
http://www.grammaticalframework.org/demos/phrasebook
● Svängrumsytan utanför dörren lutar 3% i sidled. ● The turning space outside the gate tilts 3% sideways. ● Kääntymätila oven ulkopuolella kallistuu 3% sivusuunnassa. UttSTD (PredUttTD (AdvNPTD (DetCNTD (DetQuant DefArt NumSg) (UseNTD svängrumsyta_NTD)) (PrepNPTD utanför_Prep (DetCNTD (DetQuant DefArt NumSg) (UseNTD dörr_NTD)))) (AdvVPTD (luta_VPTD (ProcentMeasure 3)) i_sidled_AdvTD)) http://www.t-d.se/sv/TD2/
To achieve coverage “ a language of true philosophy” layered interlinguas : - semantic - syntactic - chunk-based
The Vauquois triangle semantic interlingua syntactic transfer word to word transfer
Embedded interlinguas
A brief history of GF 1994: AR, Type-Theoretical Grammar , OUP 1998: Multilingual Document Authoring at Xerox 2010: MOLTO (Multilingual Online Translation) FP7 2014: GF Offline Translator, Android and iOS
GF resources: 30+ languages Norwegian Danish Afrikaans English Swedish German Dutch French Italian Spanish Catalan Romanian Bulgarian Finnish Estonian Polish Japanese Thai Chinese Hindi Russian Latvian Mongolian Urdu Punjabi Sindhi Greek Maltese Nepali Persian Latin Turkish Hebrew Arabic Amharic Swahili
GF community: 150+ members
The GF book A. Ranta. Grammatical Framework: Programming with Multilingual Grammars , CSLI, Stanford, 2011. Chinese translation by Prof. Yan Tian: 语 法框架 为 多种自 然 语 言 语 法 编 程 , Shanghai Jiao Tong University Press, 2014.
Translation model: multi-source multi-target compiler
Compiling Java to JVM 00000100 00000101 1 + 2 * 3 00000110 01101000 01100000
Word alignments 00000100 1 00000101 + 2 00000110 * 01101000 3 01100000
Abstract syntax 00000100 Add 00000101 1 + 2 * 3 00000110 N1 Mul 01101000 01100000 N2 N3
More concrete syntaxes 00000100 1 + 2 * 3 00000101 Add 00000110 01101000 N1 Mul 01100000 N2 N3 the sum of 1 and the la somme de 1 et du product of 2 and 3 produit de 2 et de 3
How it is defined Abstract syntax fun Add : Exp -> Exp -> Exp Concrete syntax, Java lin Add x y = x ++ “+” ++ y Concrete syntax, JVM lin Add x y = x ++ y ++ “01100000”
Compiling to natural language Concrete syntax, English lin Add x y = “the sum of” ++ x ++ “and” ++ y Concrete syntax, French lin Add x y = “la somme” ++ de x ++ “et” ++ de y
Subject-verb-object predication abstract fun Pred : NP -> VP -> S fun Compl : TV -> NP -> VP concrete SVO: lin Pred np vp = np ++ vp lin Compl tv np = tv ++ np SOV: lin Pred np vp = np ++ vp lin Compl tv np = np ++ tv
What about VSO? Linearization can produce strings or records . Each category has a linearization type lincat S, NP = Str lincat VP = {verb : Str ; obj : Str} lin Pred np vp = vp.verb ++ np ++ vp.obj lin Compl tv np = {verb = tv ; obj = np}
Agreement Pred we_NP (Compl love_TV) she_NP we love her Pred she_NP (Compl love_TV) we_NP she loves us
Agreement lincat TV = Number => Str lincat NP = {s : Case => Str ; n : Number} lin she_NP = { s = table {Nom => “she” ; Acc => “her”} ; n = Sg } lin Pred np vp = np.s ! Nom ++ vp ! np.n lin Compl tv np = table {n => tv ! n ++ np.s !Acc}
Expressivity of GF GF source language - type theory + functional programming - static type checking - module system PGF machine language - Portable Grammar Format (binary) - PMCFG (Parallel Multiple Context-Free Grammar)
GF forms of judgement cat C fun f : C 1 )-> … -> C n )-> C lincat C = T o -> … -> A n o -> A o lin f = t : A 1
GF with dependent types cat C (x 1 : A 1 )...(x n : A n ) fun f : (x 1 : A 1 ) -> … -> (x n : A n ) -> A lincat C = T o -> … -> A n o -> A o lin f = t : A 1
GF functional programming oper f : T = t param P = C 1 P 1 | … | C n P n module system functors libraries binary runtime (PGF = Portable Grammar Format)
GF source
probability model GF source
probability model GF compiler PGF GF binary source
PGF PGF runtime binary system
PGF user interface PGF runtime binary system
Recommend
More recommend