About Grammatical Framework MAxime AMBLARD January 8, 2003 This report is based on the article of Aarne Ranta : Grammatical Framework, A Type-Theorical Grammar Formalism, to appear, J. Functional Programming, 2003 (http ://www.math.chalmers.se/∼aarne/articles/gf-jfp.ps.gz)

Introduction The name of GF (Grammatical Framework) is derived from Logical Frameworks. A Logical Framework is a generic system used to write and uses mathematical theories with a logical calculus. Therefore, GF does not only work with the syntax of these calculi ; the notion of well-formed formula in them, but their semantic, the notion of valid judgement. The Grammatical Framework is a framework for writing and using grammars. GF-grammars have special format. They do not have only syntax in the usual linguistic sense, but also semantics in logical sense. Therefore, GF extends linguistic grammar formalism to semantic notion and logical formalism to syntactic notion. GF is only a Logical Framework enriched with wider possibility of concrete syntax. The purpose of GF is to enable a syntactic and semantic accurate description of languages. The functionalities that GF defines - in a generic way for any grammar of appropriate form - include : parsing, generation, semantic verification by type checking, paraphrasing, stepwise editing, and meaning-preserving translation. GF has been designed to make easier defining sublanguage, typically very limited fragments of entire languages used in specific technical areas. In this report, we will see in the first part, theoretical concepts used for define GF. Next, we will see the most important difference between GF and other programming language : concrete and abstract syntax. In the third part, we will see how we can use GF for multilingual. The fourth part gives a brief description of implementation of GF. Finally, we will see an example of using of GF.

1 1.1

Theoretical basis of GF Theoretical context

GF is based on the λ-calculus The λ-calculus is a formal system designed to investigate function definition, function application and recursion. It was introduced by Alonzo Church in the 1930’s. In the beginning, he tried to construct a complete formal system for the foundations of mathematics. The λ-calculus is spring from one part of Church’s researches. It is used to study computability and especially what a computable function is. Later, the λ-calculus was accepted for providing the base for practical programming languages such that LISP and Scheme. In fact, λ-expressions can be understood locally - their dependence on their environment is entirely through their free variables. The fruitful interaction of theoretical work on the λ-calculus and the development of programming languages gave rise to several families of functional programming languages such that the ML and Miranda/Haskell families. The other conceptual contribution of λ-calculus comes from the fact that the terms can be viewed as constructive proofs : λ-calculus allows the mathematical expression of the Curry Howard Isomorphism, which is a very deep correspondence between proof theory - the mathematical analysis of mathematical reasoning and concrete programming theory. This Isomorphism makes correspondence between type and logic formula, which is the cross of two different worlds. Researches about type theory are based on the last point for more than 15 years.

1

1.2

Theoretical approach of GF

Ranta has made a link between linguistic and type theory by showing that morphologic and syntactic formalisms could be rewritten in typed λ-calculus with dependent type. We could define a type as dependent type : Arrays of n elements is a type whose dependent type is : (n :nat)(array n) 1.2.1

Martin-L¨ of ’s higher-level type theory

GF is a variant of Martin-L¨ of ’s higher-level type theory. Martin-L¨of is a Swedish philosopher who has defined a dependent type theory for constructive mathematics, which generalised the natural deduction of Gentzen. The formal system of Martin-L¨ of Type Theory was developed with semantics and proof theory : – Semantics refer here on both to the intuitive informal meaning explanations developed by Martin-L¨of in the tradition of intuitionistic philosophy of mathematics, and hand to metamathematical modelling. Such a modelling has provided mathematical rigorous proofs of consistency, decidability of the formal judgement, and other essential properties of the system. – Proof theory refers to the part of logic in which proofs are considered as mathematical objects and as such it becomes the subject of metamathematical studies. The development of Type Theory was influenced by the proof-theoretic tradition. Earlier papers used to discuss typical proof-theoretic issues such that proof normalisation and proof-theoretic strength (ordinal analysis). 1.2.2

Specification of GF

GF has metavariables and rules for concrete syntax, based on type-theoretical grammar (Ranta 1991), but it differs from Martin-L¨ of’s theory in two ways : it has no predefined basic types and it has metavariables to stand for undefined constructions, which are used for type checking and users’ interactions. Then types are formed by instantiations of variables in basic types and by dependent function type formation. Basic type declarations are annotated by definitions of linearization types, which define the behaviour of objects of those types in linearization. Linearization types have a structure of their own, definable in simple type theory. Other approaches exist like Automath by N.G. de Bruijn - which is a language designed in the late sixties in order to represent mathematical proof in computer - or calculus of constructions by T. Coquand and G. Huet (1985) - a flexive system which gives the possibility to directly define some predicates with dependent types. 1.2.3

Logical Framework and Coquand’s algorithm

GF is an extension of Logical Framework (LF) which was made by Harper-Honsell-Plotkin. They have developed a technology for building partial proof. It is used for proof assistant which allows the mechanise of reasoning with the specification conformity. GF uses the same algorithm that is used in Coq : the Coquand’s algorithm (1996). GF extends this algorithm by a treatment of metavariables and constraints. Furthermore, GF replaces the axiom type : type by the parametric axiom scheme for basic types. GF’s type checker is thus generic over languages with arbitrary basic types. Ensuring the completeness of the parsing algorithm makes metavariables necessary in GF, whereas with ordinary Logical Frameworks we may choose to do with them. It is because they lack overloading and make proofs which are always explicit in expressions. The use of dependent type in grammar rules lays out semantically malformed expressions in a straightforward way. They simply cannot be constructed according to the typing rules. Such restrictions on forms of syntactic combinations by means of dependent types can be contrasted with other approaches.

2

Abstract and concrete syntaxes

A grammar is composed of an abstract syntax and a concrete syntax. The concept of abstract syntax comes from universal algebra. It was defined in the article of P. Landin, The next 700 programming languages, 1966. Definition 1 We call abstract syntax of a language, the level of trees and their construction rules. It is a set of declarations and functions.

2

Definition 2 We call concrete syntax the set of rules translating trees into strings. For a natural language, it will be ASCI code. We must have different representations for the two different syntaxes. An abstract grammar will be a tree, and a concrete syntax a string. Moreover, from a set of linearization rules, GF extracts a parser. Thus can translate a sentence into a syntax tree. If the representation of a concrete syntax of a mathematical expression is : x ∗ (y + z) then this representation for abstract syntax is : (∗ (x)(+ (y)(z))) Example 1 For 1 + 0 the concrete syntax, we have Sum Zero One for abstract syntax. In addition, we can translate one on the other : From definition of the sum, zero and one : cat Exp ; fun Zero : Exp ; fun One : Exp ; fun Sum : Exp →Exp → Exp ; pattern Zero = ”0” ; pattern One = ”1” ; pattern Sum x y = x ++ ”+” ++ y ; we can parse or linearize : > p -cat=Exp "1 + 0" Sum One Zero > l Sum One Zero 1 + 0 The fun judgement of GF belongs to the abstract syntax, and is essentially typing declarations for functional constants. The lin judgement belongs to the concrete syntax. A complete GF grammar has a corresponding lin judgement for every fun judgement. The concrete syntax is the most different point between GF and the other programming language (Coq, Isabel, etc...) ; only GF has a consistent concrete syntax.

3

Multilingual-grammar

For linguistic, we consider that we know an abstract syntax and we want to have concrete syntax for natural language. GF give us that with type theory and calculus as we have seen upper. The task is to define morphologic variations on recursive tree to get several interpretations in concrete syntax from an abstract syntax. Definition 3 A multilingual-grammar has one abstract syntax but many concrete syntaxes. It’s the linearization of the syntax tree that changes to different concrete syntaxes. We call interlingua this common abstract syntax. Example 2 From definition, for English : lin Zero = s = ”zero” ; lin One = s=”one” lin sum x y = s = ”the” ++ ”sum” ++ ”of” ++ x.s ++ ”and” ++ y.s. We can linearize in two ways : > l Sum One Zero 1 + 0 the sum of one and zero The most important point for multilingual is that we build a proof only for the abstract syntax and it could be derived in much concrete syntaxes. If we use a concrete syntax for a natural language like English, all states are finite, so GF gives us a simple context-free parser and we can linearize into other languages. We have a translator between several languages by the pivot language. Then, instead of having n2 translators, we have n. Nevertheless, context-free format does not work so well for the description of natural language. The most important challenge for multilingual is : word order, morphological variation and appearance-disappearance of words.

4

Implementation of GF GF was implemented in Haskell (Version 1.0). The main parts of the code are composed : 3

– grammar compiler : lexer, parser, type cheker, partial evaluator and parser generator – command line interpreter : functions to read grammar files and use grammars in batch mode – syntax editor : functions to edit GF interactively. The syntax editor is based on an abstract command language built upon a zipper. It can be used through different user interface : we have a line based editor, a graphical editor written in Fudgets (Carlsson and Hallgren, 1998), an experimental speech-based editor (Ranta and Cooper, 2001), and a Java GUI client communicating with a GF server via an XML-based protocol. It supports different construction modes : – one-step refine : replaces metavariable with a function head – parse-refine : replaces metavariable with a parse result – delete : replaces subtree with a metavariable – wrap : embes subtree as a function argument – tactic : tries to find a refinement automatically Haskell was chosen as implementation language for two reasons : it is a good general-purpose programming language, and it allows to connect smoothly with some other programs written in Haskell - in particular, the proof editor Alfa (Hallgren, 2000). GF is conforming to the Haskell 98 standard (Peyton Jones and Hudghes, 1999) and can be compiled with all standard compilers and interpreters. Users who do not write grammars themselves typically use GF via the graphical interactive editor. For a grammar developers, and writers of batch programs, there is a command language and a shell, also permitting scripts. Haskell programmers can access GF through an API module. This makes it possible to include GF functionalities and use GF grammars in other Haskell programs.

5

Example

French verbs are presented in the authoritative Bescherelle. They have three persons, two numbers, two genders, four tenses and six modes. But the inflection tables display only 51 verb forms, not 288, that would be the case if the forms were simply cross-products of all parameters. The following system is a straightforward GF formalization of the Bescherelle : param Nombre Personne Genre Temps TSubj TPart NPImper VForm

= = = = = = = = | | | | |

Sg | Pl ; P1 | P2 | P3 ; Masc | Fem ; Pres | Imparf | Passe | Futur ; SPres | SImparf ; PPres | PPasse Genre Nombre ; SgP2 | PlP1 | PlP2 ; Inf Ind Temps Nombre Personne Cond Nombre Personne Subj TSubj Nombre Personne Imper NPImper Part TPart ;

Aarne Rante has written the grammar specification in GF for recognizing French verbs, based on the Bescherelle. You can find the code at : http ://www.math.chalmers.se/∼aarne/GF0/grammars/conjugaison/ The linearization of a verb gives the list of all the possible forms that it could take : > l courir courir cours courais cours courais court courait courons courions courez couriez courent couraient

courus courus courut cour^umes cour^utes coururent

courrai courras courra courrons courrez courront

courrais courrais courrait courrions courriez courraient

4

coure coures coure courions couriez courent

courusse courusses cour^ut courussions courussiez courussent

cours courons courez

courant

couru

courus

courue

courues

GF recognizes a verb in any form it takes by parsing : > p "couraient" courir GF has identified the normal form of the verb courir. Moreover, GF could identify all forms the verb has taken, by morphologic analysis, and, if the analysis is ambiguous, GF lists the possibility : > ma "courus" courus courir +V+Part (PPasse Masc Pl) courir +V+Ind Passe Sg P2 courir +V+Ind Passe Sg P1

Conclusion GF is applied to the prototyping of multilingual documentation systems. Small GF grammars have been written for several languages : English, Finnish, French, German, Italian, and Swedish. Abstract GF representations can be used as XML objects : from well-formed syntax tree grammars, one can generate XML-objects. Therefore GF offers interactive programming. GF has two experimental applications : in the Multilanguage Theory and Technology group of Xerox, and in HiBase of NET/HUT (Nokia Networks and Helsinki University of Technology) for mobile network of telephony. GF is used for the design of a persistent industrial functional programming language, where it provides a concrete syntax and a type-checker at the same time. We can thus say that GF is the result of an intelligent collaboration between linguist and data processing. I only could reproach to this article to be extremely detailed which has made very difficult the presentation without loss of meaning. In spite of everything, GF seems to be a powerful tool for computational linguistic. It is a pity that is an isolated example. We thus saw how from a linguistic point of view, GF is a powerful tool for creation and manipulation of grammar, in particular for natural language, allowing among others, the implementation of the multilingual. Moreover, with logic theory, GF offers a safe type on allowing an interactive construction of new well-founded grammars. Finally, all these aspects give to GF a quite effective implementation, which is pertinent in the industrial world. Even if these specifications do not make it usable as automatic translators of natural languages. GF seems to be a very good precision tool. For more information about GF, see the GF’s home page : http ://www.math.chalmers.se/∼aarne/GF/

Acknowledgement Gerard HUET who has directed this report.

bibliography Chantal Berline, ”A presentation of the Curry-Howard Correspondence”, Course Notes, 1997 Gerard Huet, ”Constructive Computation Theory”, Course Notes, 1992-2002 Jim Larson , ”An Introduction to Lambda Calculus and Scheme”, J.P.L., 1996 Aarne Ranta, ”Grammatical Framework, A Type-Theorical Grammar Formalism”, J.F.P., 2003 Aarne Ranta, ”Computational Semantics in Type Theory”, Gothenburg University, 2001 Aarne Ranta and Petri Mcnp, ”The Type Theory and type checker of GF”, Colloquium, Logics, and Implementations of High-Level Programming Languages, Paris, 1999 A. Ranta. ”Bescherelle bricol”, 2001. http http http http

:///www.math.chalmers.se/∼aarne/GF/ ://www.xrce.xerox.com/competencies/content-analysis/past-projects/gf/ ://coq.inria.fr ://www.wikipedia.org 5

About Grammatical Framework

Jan 8, 2003 - is a generic system used to write and uses mathematical theories with a logical calculus. .... command line interpreter : functions to read grammar files and use grammars in ... delete : replaces subtree with a metavariable.

97KB Sizes 1 Downloads 230 Views

Recommend Documents

Grammatical Errors
http://grammarist.com/articles/grammarly-review/. British​ ​English​ ​vs.​ ​American​ ​English​ ​Test. For this test, we'll create a series of sentences that contain distinctly British spelling and. grammatical structures. § The

Hierarchical Grammatical Evolution
in the language de ned by the grammar (the phenotype) by means ... to weakly comply to the variational inheritance principle, stating. Permission to make digital ...

Hierarchical Grammatical Evolution
Jul 19, 2017 - ant Weighted HGE (WHGE), two novel genotype-phenotype map- ... ability to evolve programs in any language, using a user-provided.

Evolvability in Grammatical Evolution
and context-free languages; •Computing methodologies → Heuris- ... classroom use is granted without fee provided that copies are not made or distributed ... Figure 1: From Fitness Cloud to Fitness-Probability Cloud. ..... Figure 3: AEP vs. genoty

Grammatical Evolution and Corporate Failure ... Accounts
Kingston Business School, London. Conor Ryan .... business, to legal bankruptcy followed by liquidation of the firm's .... representing the programs as parse trees, as in traditional .... table that each model only employed a small subset of these.

Evolvability in Grammatical Evolution
each candidate solution. ... Figure 1: From Fitness Cloud to Fitness-Probability Cloud. ... the crossover operator, a pair of parents is needed but only the best.

Evolvability in Grammatical Evolution
share the same phenotype? 4Often ..... Lu, Li, and Yao, “Fitness-probability cloud and a measure of problem hardness for evolutionary algorithms”. Medvet ...

Spandanam_Worksheet of various grammatical terms for SSLC ...
Vanka was writing a letter to his grandfather. 2. He posted the letter without writing the address. 3. ... Conditional Sentences. Conditionals If-clause Main clause. First conditional Simple present ... Spandanam_Worksheet of various grammatical term

Grammatical evolution - Evolutionary Computation, IEEE ... - IEEE Xplore
definition are used in a genotype-to-phenotype mapping process to a program. ... evolutionary process on the actual programs, but rather on vari- able-length ...

Christiansen Grammar Evolution: grammatical ...
Computer Science. Chomsky ... they have been little used in computer science to formally ...... the requirements for the degree of Master of Science in Computer.

Inferring universals from grammatical variation
plane) is the crucial element, since for any roll-call vote we are interested in who voted 'Yea' .... In two dimensions, there are only 24 errors across 1250 data points. ..... the Quotative near the center of the vertical area. ... by a Present or I

Peters McLuhan's Grammatical Theology.pdf
Technology is behind the Medieval Centre [at the University of Toronto]?” asked. McLuhan in 1973 (Gordon 1997, 323). In his Cambridge dissertation we have a ...

The influence of grammatical features on linearization ...
XP. 3. DP. X'. John 3. X. DP. Mary. Richards (2010) also states that Distinctness only affects functional heads which enter the derivation as feature bundles and that Distinctness effects arise before vocabulary insertion. ...... This means, that ass

Comprehension of Grammatical and Emotional Prosody Is Impaired in ...
tional intent to patterns of stress or emphasis within an utter-. ance, to cues to syntactic .... results obtained from each of the prosodic tests, in order to. ascertain the ...... cept and slope of the curve and then applying the following. formula

Grammatical Sketch of Zacatepec Chatino by ...
mass migration by the younger generation of men, and recently even by young ..... historically monosyllabic words such as 'cloud' ko2, bearing the same tone as ...

Syntactical Similarity Learning by means of Grammatical Evolution
on input data which consist of triplets of data points (a, b, c) labelled with the .... when X and Y are perfectly separated, o(X, Y ; p)=0, Vp. The value of p is used.

pdf-173\grammatical-borrowing-in-cross-linguistic-perspective ...
... the apps below to open or edit this item. pdf-173\grammatical-borrowing-in-cross-linguistic-per ... roaches-to-language-typology-ealt-by-matras-yaron.pdf.

Road Traffic Rules Synthesis using Grammatical ...
Keywords: Simulation, Road traffic model, Stochastic evolution, Driver- less cars. 1 Introduction and related work. Car driving is one of the tasks that in a not far ...

Road Traffic Rules Synthesis using Grammatical ...
fitness → , simulated with those rules ... a language for defining rules applicable to the model. 3 ... input: a list A of actions and a set R of rules.

Syntactical Similarity Learning by means of Grammatical Evolution
by a similarity learning algorithm have proven very powerful in many different application ... a virtual machine that we designed and implemented. The virtual ..... pattern (e.g., telephone numbers, or email addresses) from strings which do not.

Grammatical roles, Coherence Relations, and the ...
he__lower-ASP__head__NEG__speak. Yesterday old Zhang met ..... 26a–b below are representative examples from the movie script: (26) a. 陈军从舞会上回来 ...

humans rapidly learn grammatical structure in a new musical scale
provide evidence that a domain-general statistical learn- ing mechanism may account for much of the human appreciation for music. Received January 15, 2009 ...