GF: a Logical Framework for Grammars Aarne Ranta University of - - PowerPoint PPT Presentation

gf a logical framework for grammars
SMART_READER_LITE
LIVE PREVIEW

GF: a Logical Framework for Grammars Aarne Ranta University of - - PowerPoint PPT Presentation

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, Bjrn Bringert, Grgoire Dtrez, Ramona Enache,


slide-1
SLIDE 1

GF: a Logical Framework for Grammars

Aarne Ranta

University of Gothenburg and Digital Grammars AB

Estonian-Finnish Logic Meeting Rakvere, 15 November 2015

CLT

slide-2
SLIDE 2

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

slide-3
SLIDE 3

Outline

Demo Overview: interlingua and translation Hands-on coding

slide-4
SLIDE 4

Demo

slide-5
SLIDE 5

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

slide-6
SLIDE 6

Cloud

http://cloud.grammaticalframework.org/

slide-7
SLIDE 7

Overview: translation and interlingua

slide-8
SLIDE 8
slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12

Google translate 16 September 2015

slide-13
SLIDE 13
slide-14
SLIDE 14
  • ne 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 such a language depends upon the true philosophy.

Descartes, letter to Mersenne, 1629 http://www.autodidactproject.org/other/descartes-lg1.html

slide-15
SLIDE 15
slide-16
SLIDE 16
slide-17
SLIDE 17

Wikipedia

slide-18
SLIDE 18

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

slide-19
SLIDE 19

GF = Grammatical Framework

from

  • one universal grammar

to

  • a framework for defining grammars
  • hence, many special-purpose grammars
slide-20
SLIDE 20

GF = LF + concrete syntax

interlingua = logic = abstract syntax concrete syntax: mapping from an interlingua to a language

slide-21
SLIDE 21

To achieve precision

“all things which fall within the purview of the human mind” domain-specific interlinguas:

  • mathematics
  • tourist phrases
  • sports
  • etc, etc
slide-22
SLIDE 22

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

slide-23
SLIDE 23

http://www.grammaticalframework.org/demos/phrasebook

slide-24
SLIDE 24
  • 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/

slide-25
SLIDE 25

To achieve coverage

“a language of true philosophy” layered interlinguas:

  • semantic
  • syntactic
  • chunk-based
slide-26
SLIDE 26

word to word transfer syntactic transfer semantic interlingua

The Vauquois triangle

slide-27
SLIDE 27

Embedded interlinguas

slide-28
SLIDE 28

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

slide-29
SLIDE 29

GF resources: 30+ languages

Norwegian Danish Afrikaans Romanian Polish Russian Latvian Mongolian Urdu Punjabi Sindhi Greek Maltese Nepali Persian Latin Turkish Hebrew Arabic Amharic Swahili English Swedish German Dutch French Italian Spanish Catalan Bulgarian Finnish Estonian Japanese Thai Chinese Hindi

slide-30
SLIDE 30

GF community: 150+ members

slide-31
SLIDE 31

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.

slide-32
SLIDE 32

Translation model: multi-source multi-target compiler

slide-33
SLIDE 33

Compiling Java to JVM

00000100 00000101 00000110 01101000 01100000

1 + 2 * 3

slide-34
SLIDE 34

Word alignments

00000100 00000101 00000110 01101000 01100000 1 + 2 * 3

slide-35
SLIDE 35

Abstract syntax

00000100 00000101 00000110 01101000 01100000

1 + 2 * 3

Add N1 Mul N2 N3

slide-36
SLIDE 36

More concrete syntaxes

00000100 00000101 00000110 01101000 01100000

1 + 2 * 3

Add N1 Mul N2 N3

the sum of 1 and the product of 2 and 3 la somme de 1 et du produit de 2 et de 3

slide-37
SLIDE 37

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”

slide-38
SLIDE 38

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

slide-39
SLIDE 39

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

slide-40
SLIDE 40

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}

slide-41
SLIDE 41

Agreement

Pred we_NP (Compl love_TV) she_NP we love her Pred she_NP (Compl love_TV) we_NP she loves us

slide-42
SLIDE 42

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}

slide-43
SLIDE 43

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)
slide-44
SLIDE 44

GF forms of judgement

cat C fun f : C1)-> … -> Cn)-> C lincat C = T lin f = t : A1

  • -> … -> An
  • -> Ao
slide-45
SLIDE 45

GF with dependent types

cat C (x1 : A1)...(xn : An) fun f : (x1 : A1) -> … -> (xn : An) -> A lincat C = T lin f = t : A1

  • -> … -> An
  • -> Ao
slide-46
SLIDE 46

GF functional programming

  • per f : T = t

param P = C1 P1 | … | Cn Pn module system functors libraries binary runtime (PGF = Portable Grammar Format)

slide-47
SLIDE 47

GF source

slide-48
SLIDE 48

GF source

probability model

slide-49
SLIDE 49

GF source

probability model PGF binary GF compiler

slide-50
SLIDE 50

PGF binary PGF runtime system

slide-51
SLIDE 51

PGF binary PGF runtime system user interface

slide-52
SLIDE 52

PGF binary PGF runtime system user interface another PGF binary

slide-53
SLIDE 53

PGF binary PGF runtime system custom user interface generic user interface PGF runtime system generic grammar

domain

specific

White: free, open-source (LGPL/BSD). Green: a business idea

slide-54
SLIDE 54

Hands-on coding

slide-55
SLIDE 55

http://cloud.grammaticalframework.org/gfse/

slide-56
SLIDE 56