Prolog and Automatic Language Implementation Systems

نویسندگان

  • Marjan MERNIK
  • Matej ČREPINŠEK
چکیده

syntax n ∈ Num x ∈ Var a ∈ Aexp a ::= n | x | a1 + a2 | a1 * a2 | a1 a2 Semantic domains Integer = {... -3, -2, -1, 0, 1, 2, 3 ...} Truth-Value = {true, false} State = Var → Integer Semantic valuation functions N: Num → Integer A: Aexp → State → Integer A [[n]] = λs. N [[n]] A [[x]] = λs. s x A [[a1 + a2]] = λs. A [[a1]] s + A [[a2]] s A [[a1 * a2]] = λs. A [[a1]] s * A [[a2]] s 6 Prolog and Automatic Language Implementation Systems ISSN 1335-8243 © 2005 Faculty of Electrical Engineering and Informatics, Technical University of Košice, Slovak Republic A [[a1 a2]] = λs. A [[a1]] s A [[a2]] s /* A : Aexp -> State -> Integer */ a(X,State,apply(lambda(_,X),State)) :integer(X). a(X,State,apply(lambda(_,Val),State):atom(X), lookup(X, State, Val). a(+(A1,A2),State,add(A1_den,A2_den)) :a(A1, State, A1_den), a(A2, State, A2_den). a(*(A1,A2),State,mull(A1_den,A2_den)):a(A1, State, A1_den), a(A2, State, A2_den). a(-(A1,A2),State,sub(A1_den,A2_den)) :a(A1, State, A1_den), a(A2, State, A2_den). lookup(X,[X,Y|_],Y). lookup(X,[_,_|Rest],Y) :lookup(X, Rest, Y). evaluate(Program, State, Integer) :a(Program, State, Lambda_code), lambda_machine(Lambda_code,Integer). Fig. 7 Prolog interpreter of While language Again, rapid language implementation is obtained and language can be tested by writing simple programs such as: ?a(+(7, 9),[],R). R = add(apply(lambda(_288,7),[]), apply(lambda(_318,9),[])) ?evaluate(+(7, 9), [], R). R = 16 ?evaluate(+(7, i), [I, 1], R). R = 8

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Modelling using UML diagrams of an Intelligent System for the Automatic Demonstration of Geometry Theorems

In this work will be presented the design of an intelligent system destined for development process of demonstrating abilities for geometry theorems. This system will make available to user a proof assistant which will allow interactive vizualization of several demonstrations for the same theorem, demonstrations that have been generated by using three specific methods for automatic demonstratio...

متن کامل

Automated Program Generation for and by Model Transformation Systems

Model transformation systems are graph transformation systems that perform translations between languages defined by a corresponding metamodel as the type graph. The current paper proposes a reflective method for the automatic generation of the implementation for such transformation systems derived from a high–level specification consisting of a set of graph transformation rules and a control f...

متن کامل

Automatic Acquisition of Digitized Newspapers via Internet

After our previous works on modelling a database of newspapers and designing a specially suited retrieval language, we are now developing an application to automatically acquire, summarize and store newspaper documents published in distinct web resources. This paper describes the current implementation of the acquisition process which includes the recognison of document types and the abstractio...

متن کامل

QD-Janus: a Sequential Implementation of Janus in Prolog

Janus is a language designed for distributed constraint programming. This paper describes QDJanus, a sequential implementation of Janus in Prolog. The compiler uses a number of novel analyses and optimizations to improve the performance of the system. The choice of Prolog as the target language for a compiler, although unusual, is motivated by the following: (i) the semantic gap between Janus a...

متن کامل

History on the implementation and compilation of Prolog

Prolog, abbreviation for PROgrammation en LOGique, was designed in 1972 by Philippe Roussel, Alain Colmerauer at the University of AixMarseille and Robert Kowalski at the University of Edinburgh [1]. Since 1972, Prolog has been one of the most popular logical programming language based on Horn clause logic. Intrigued by the interesting history of Prolog, I decided to learn the nature of the des...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1998