A Statistical Transformation Tool for Natural Semantics

semanticscholar(2017)

Cited 0|Views0
No score
Abstract
Natural semantics has become a popular approach among programming language researchers. It is used for specifying many aspects of programming languages. Codes of many programming languages can be transformed into natural semantics. A simple tool is proposed to aid in the development of natural semantics. The tool involves statistics and transformations. The tool has been implemented, and since the target language is Pizza the tool has a good performance. INTRODUCTION Design and specifications of the semantics of a programming language requires a number of tasks, such as statistics and transformations. Tools help to perform these tasks quickly and accurately. There are many tools designed to aid in the development of semantics. Some of such tools are: TYPOL which is an implementation of natural semantics [1]. TYPOL may be compiled into Prolog or a functional notation based on attribute grammars. The CENTURE system, a generic interactive environment, when provided with the description of a particular programming language it produces a language specific environment [2]. LATOS, a light weight animation tool for operational semantics. It takes as input a superset of Miranda and produce a proper declarative program which can be typechecked and executed by the appropriate language system [3]. LATOS can be compiled into Miranda and subsequently into Haskell. RML, the Relational Meta-language System which compiles natural semantics specifications into C [4]. The ASF+SDF Meta-environment, a specification environment based on the ASF+SFD formalism which combines the Algebraic Specification Formalism (SDF). This environment is an interactive environment that supports the specification of language [5]. Pattern matching is fundamental in our transformation, it is accomplished by a test of significance such as the ttest or ANOVA. Analysis of variance (ANOVA) is a statistical method used to test differences between two or more means [6]. The T-test is a common method for comparing the mean of one group to a value or the mean of one group to another. Ttests are very useful because they usually perform well in the face of minor to moderate departures from normality of the underlying group distributions [7]. The contribution of this paper is to show that it is possible to build a useful tool with simple means to transform natural semantics into Pizza programming language. 2. SPECIFICATION OF NATURAL SEMANTICS Natural semantics of a programming language is represented by a set of inference rules as shown in Figure 1. International Journal of Applied Engineering Research ISSN 0973-4562 Volume 12, Number 10 (2017) pp. 2555-2558 © Research India Publications. http://www.ripublication.com 2556 Figure 1: Inference Rules of Natural Semantics Syntax of Axioms and Rules : The syntax of an inference rule is described as follows:  Each rule has a number of premises written above the solid line, and one conclusion written below the solid line.  A rule may has a side condition written to the right of the solid line. This condition must be a Boolean expression  Rules with no premises are called axioms and the solid line is then omitted. An axiom without side condition has the following syntax: And an axiom with side condition has the form:  Rules and axioms contain patterns and expressions. A pattern indicated by the letter P is a t‐tuple (t=0 or t > 1), an n‐ary constructor symbol Cn (n > 0), or a variable v.  The syntax of the patterns can be one of the following:  A pattern is irrefutable if it contains only tuples and variables. A pattern with constructor symbols is refutable.  An expression indicated by letter E, is an n-ary constructor symbol Cn (n > 0), an application of a 2‐ary constructor symbol, or a list of variables vs. The syntax of the expressions can be written as:  About the labeled arrows on the syntax of Axioms and rules, each label on the arrow represent the current relation. Simplifying Rules : To make the implementation of the natural semantics easier we introduce some simplifications to the rules.  Each rule with n premises and a side condition (if Eb) will be considered as a rule with (n+1) premises and no side condition. So if we have a rule of the form: Then this rule is represented as follows: Where →id is the equality relation.  Since an axiom is a rule with 0 premises, so the distinction between axioms and rules will be dropped.  Any pattern P of the form (P1...Pn) will be considered as a pattern of the form Cn P1⋯ Pn. For example the pattern (x,y,z) can be written as Triple(x,y,z). COMPILING PATTERN MATCHING Pattern matching is an integral part of our transformation. It is the mechanism by which relations inspect arguments in order to locate relevant inference rules. What is pattern matching : Pattern matching is a general operation that is used in many different application areas. Abstractly, a pattern is a description of a set of values. Matching a value against a pattern determines whether the value is in the set denoted by the pattern. There are different matching problems depends on the different kinds of values and patterns they deal with. In string matching, values are finite strings and patterns are regular expressions. A string matching problem is to find the occurrence of a pattern of m characters (P=P1,..., Pm) in a general very much longer text string (T=T1,..., Tn). The solution has application in editors and information retrieval programs. String matching is implemented using various kinds of augmented finite automate [8]. Term matching is a built-in feature in modern functional programming languages such as Standard ML [9], and Haskell [10]. It is used to define functions by case analysis on their arguments. Term matching, is implemented by top-down methods. Tree matching is similar to term matching, it is often used in International Journal of Applied Engineering Research ISSN 0973-4562 Volume 12, Number 10 (2017) pp. 2555-2558 © Research India Publications. http://www.ripublication.com 2557 applications based on rewriting, such as term-rewriting or code selection [11], [12]. Compiling term matching : Pattern matching allows complex nested patterns, and also partial overlap between different equations. The purpose of compiling pattern matching is to reduce this complexity, making the resulting code more efficient. A function definition f can be expressed using the rules in figure 1 as shown in figure 2, where ERROR means an error expression and ⎸is an operation defined as: Figure 2: Inference Rules with ⎸operation and ERROR The specification in Figure 2 means that given a term to be executed we will try to match each rule in turn. First try the first rule, if the match succeed, the expression E1 will be returned. If the match of the first rule not succeeded try the second rule if the match succeeded the expression E2 will be returned and so on. Consider the case in which non of the rules succeeded the match in this case an error should be raised. This technique is called pattern-matching. Pattern Matching in Pizza : Pizza introduces algebraic data types with pattern matching, it includes support for visitor style patterns directly in the language. Since Pizza supports pattern matching the above meaning can be expressed in Pizza by using case statements and exception handling. The Pizza code equivalent to the function definition in Figure 2 is written as shown in Figure 3. Figure 3: An Equivalent Pizza Code IMPLEMENTATION OVERVIEW In this section we introduce a summary of the implementation strategy to transform natural semantics specifications into an executable Pizza code. The transformation is based on Wadler's algorithm for compiling pattern matching [13]. Wadler introduced a function match which is the core if the compilation process. This function transforms an expression uses pattern matching, into an equivalent case-expression. The transformation done by the introduced tool is composed of two main steps: match the premises, and match the conclusion. Each of these steps is described in details as follows: 1. As we have seen each rule which specifies natural semantics consists of a number of premises and one conclusion. This step takes the list of premises, and apply the function match to each of the premises. The result will be a case-expression. 2. In this step we apply the function match again to the conclusion and the case expression resulting from first step. International Journal of Applied Engineering Research ISSN 0973-4562 Volume 12, Number 10 (2017) pp. 2555-2558 © Research India Publications. http://www.ripublication.com
More
Translated text
AI Read Science
Must-Reading Tree
Example
Generate MRT to find the research sequence of this paper
Chat Paper
Summary is being generated by the instructions you defined