A Lisp Subset Based on MathML - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

A Lisp Subset Based on MathML

Description:

ci compose-fn /ci lambda bvar ci f1 /ci /bvar bvar ci f2 /ci ... apply /xml-scheme !-- (define compose-fn (lambda (f1 f2) (lambda (n) (f1 (f2 n) ... – PowerPoint PPT presentation

Number of Views:62
Avg rating:3.0/5.0
Slides: 14
Provided by: yxie6
Category:
Tags: mathml | based | compose | lisp | subset

less

Transcript and Presenter's Notes

Title: A Lisp Subset Based on MathML


1
A Lisp Subset Based on MathML
  • Yuzhen Xie Stephen M. Watt Luca Padovani
  • June 2002

The University of Western Ontario
2
Introduction
  • Interest XML representation for programming
    languages
  • Exploration content MathML as an expression for
    a functional programming language, a Lisp subset
  • Development XML-Scheme interpreter in Java
  • Demonstration content MathML is quite sufficient
    for this purpose
  • Suggestion potential of a web scripting language
    encoded in XML (possibly based on MathML)

3
Content MathML as the Nucleus of a Functional
Programming Language
  • Focus of XML structure
  • Potential to create a programming language
    framework in XML, i.e. control, data flow,
    functions, format of message passing, etc.
  • Advantages of programs in XML format
    standardization of the encoding format,
    independence of the delivery medium, etc.

4
Content MathML as the Nucleus of a Functional
Programming Language (contd)
  • Selection of the programming language
  • Lisp S-Expressions
  • Content markup of MathML as an expression
  • - lambda constructs and definitions
  • apply, lambda, piecewise, declare, and
    csymbol
  • - recursive use of container elements
  • - nested building of constructs
  • - flexibility provided by csymbol, e.g. for
    cons, and ()
  • - types

5
Content MathML as the Nucleus of a Functional
Programming Language (contd)
  • Content MathML as an expression example
  • MathML content markup of
  • (define reverse-subtract (lambda (x y) (- y
    x))) is
  • ltdeclaregt
  • ltcigtreverse-subtractlt/cigt
  • ltlambdagt
  • ltbvargtltcigtxlt/cigtlt/bvargt
  • ltbvargtltcigtylt/cigtlt/bvargt
  • ltapplygt
  • ltminus/gt
  • ltcigtylt/cigt
  • ltcigtxlt/cigt
  • lt/applygt
  • lt/lambdagt
  • lt/declaregt

6
XML-Scheme Syntax and Grammar
  • Most of the first class operators, constants and
    symbols, expressions, and function definitions
    are represented in the core content elements of
    MathML
  • csymbol element is used to create symbols having
    a particular meaning in Scheme but that are not
    part of the core content elements in MathML
    cons, car, cdr, (), null?
  • Additional top element xml-scheme
  • Defined syntax rules for expression reduction and
    parameter passing e.g. apply and ci

7
A complete example of XML-Scheme program that
uses , -, , cons, if, lambda, and define
  • lt!-- (define my_abs (lambda (x)
  • (if (lt x 0) (- x) ( x)))) --gt
  • ltdeclaregt
  • ltcigtmy_abslt/cigt
  • ltlambdagt
  • ltbvargtltcigtxlt/cigtlt/bvargt
  • ltbvargtltcigtxlt/cigtlt/bvargt
  • ltpiecewisegt
  • ltpiecegt
  • ltapplygtltminus/gtltcigtxlt/cigtlt/applygt
  • ltapplygtltlt/gtltcigtxlt/cigtltcngt0lt/cngt
  • lt/applygt
  • lt/piecegt
  • ltotherwisegt
  • ltapplygtltplus/gtltcigtxlt/cigtlt/applygt
    lt/otherwisegt
  • lt/piecewisegt
  • lt/lambdagt
  • lt/declaregt
  • lt?xml version1.0
  • encodingUTF-8?gt
  •  
  • ltxml-schemegt
  • lt!-- (define my_pair (cons 1 -1)) --gt
  • ltdeclaregt
  • ltcigtmy_pairlt/cigt
  • ltapplygt
  • ltcsymbolgtconslt/csymbolgt
  • ltcngt1lt/cngt
  • ltcngt-1lt/cngt
  • lt/applygt
  • lt/declaregt

8
A complete example of XML-Scheme program that
uses , -, , cons, if, lambda, and define
  • lt!-- (define my_double
  • (lambda (x) ( 2 x))) --gt
  • ltdeclaregt
  • ltcigtmy_doublelt/cigt
  • ltlambdagt
  • ltbvargtltcigtxlt/cigtlt/bvargt
  • ltapplygt
  • lttimes/gt
  • ltcngt2lt/cngt
  • ltcigtxlt/cigt
  • lt/applygt
  • lt/lambdagt
  • lt/declaregt
  • lt!-- (define compose-fn (lambda (f1 f2)
  • lambda (n) (f1 (f2 n))))) --gt
  • ltdeclaregt
  • ltcigtcompose-fnlt/cigt
  • ltlambdagt
  • ltbvargtltcigtf1lt/cigtlt/bvargt
  • ltbvargtltcigtf2lt/cigtlt/bvargt
  • ltlambdagt
  • ltbvargtltcigtnlt/cigtlt/bvargt
  • ltapplygt
  • ltcigtf1lt/cigt
  • ltapplygt
  • ltcigtf2lt/cigt
  • ltcigtnlt/cigt
  • lt/applygt
  • lt/applygt
  • lt/lambdagt
  • lt/lambdagt
  • lt/declaregt

9
A complete example of XML-Scheme program that
uses , -, , cons, if, lambda, and define
(contd)
  • lt!-- (define compose-fn (lambda (f1 f2)
  • (lambda (n) (f1 (f2 n))))) --gt
  • ltdeclaregt
  • ltcigtcompose-fnlt/cigt
  • ltlambdagt
  • ltbvargtltcigtf1lt/cigtlt/bvargt
  • ltbvargtltcigtf2lt/cigtlt/bvargt
  • ltlambdagt
  • ltbvargtltcigtnlt/cigtlt/bvargt
  • ltapplygt
  • ltcigtf1lt/cigt
  • ltapplygt
  • ltcigtf2lt/cigt
  • ltcigtnlt/cigt
  • lt/applygt
  • lt/applygt
  • lt/lambdagt
  • lt/lambdagt
  • lt/declaregt
  • lt!-- (define myfun
  • (compose-fn my_abs my_double))--gt
  • ltdeclaregt
  • ltcigtmyfunlt/cigt
  • ltapplygt
  • ltcigtcompose-fnlt/cigt
  • ltcigtmy_abslt/cigt
  • ltcigtmy_doublelt/cigt
  • lt/applygt
  • lt/declaregt
  •  lt!-- (myfun (car my_pair)) --gt
  • ltapplygt
  • ltcigtmyfunlt/cigt
  • ltapplygt
  • ltcsymbolgtcarlt/csymbolgt
  • ltcigtmy_pairlt/cigt
  • lt/applygt
  • lt/applygt
  •  

10
XML-Scheme Interpreter
11
Quotation
  • A PHP fragment
  • lt?
  • print("ltulgt")
  • for (ix 0 ix lt count(stuff) ix)
  • print("ltligt ix. stuff(ix) lt/ligt\n")
  • ?gt
  • Structure difficult to maintain -- note missing
    lt/ulgt.
  • Potential using Lisp-style quasi-quoting
    mechanism for XML documents in a natural,
    structured manner
  • Lisp example
  • (list ,( 1 2) 4) gt (list 3 4)

12
Quotation (contd)
  • Proposition
  • - A scripting model for XHTML documents as
    quasi-quoted data
  • - Scripting components are in XML syntax
  • - Evaluation is indicated by the unquoting
    mechanism as comma in Scheme

ltligt ltxsunquotegt ltmapplygt
ltmcigtmy_funlt/mcigt
ltmapplygt
ltmcsymbolgtcdrlt/mcsymbolgt
ltmcigtmy_pairlt/mcigt lt/mapplygt
lt/mapplygt lt/xsunquotegt lt/ligt
lt/ulgt
lt...xmlnsxs "http//www.orcca.on.ca/MathML/XML-S
cheme" xmlnsm"http//www.w3.org/TR/MathML2"gt
ltulgt ltligt ltpgt A fragment of
quasi-quoted data in XML format lt/pgt lt/ligt
ltligt ltxsunquotegt ltmapplygt
ltmcigtmy_funlt/mcigt
ltmapplygt ltmcsymbolgtcarlt/mcsymbo
lgt ltmcigtmy_pairlt/mcigt
lt/mapplygt lt/mapplygt
lt/xsunquotegt lt/ligt
13
Concluding Remarks
  • Prototype of XML-Scheme interpreter
  • Implementation of a basic set of Scheme
    operators, lambda calculus and definitions
  • Feasibility of content MathML to represent a
    simple functional programming language, Scheme
  • Potential uses of programming languages
    represented in XML, in particular, a new family
    of scripting languages for Web pages
Write a Comment
User Comments (0)
About PowerShow.com