Louden - PowerPoint PPT Presentation

About This Presentation
Title:

Louden

Description:

Louden's Simple Language for Describing Formal Semantics. program stmt-list ... one element of its domain I, to have value n. This can be expressed variously as ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 7
Provided by: josephn6
Category:
Tags: louden | variously

less

Transcript and Presenter's Notes

Title: Louden


1
Loudens Simple Language for Describing Formal
Semantics
  • program ? stmt-liststmt-list ? stmt
    stmt-list stmtstmt ? assign-stmt if-stmt
    while-stmtassign-stmt ?identifier
    exprif-stmt ? if expr then stmt-list else
    stmt-list fiwhile-stmt ? while expr do
    stmt-list odidentifier ? a b c ...
    z expr ? expr term expr - term
    termterm ? term factor factorfactor ? (
    expr ) number identifiernumber ? number
    digit digitdigit ? 0 1 2 3
    4 5 6 7 8 9
  • One oddity about Loudens little language In
    if-stmt (resp. while-stmt) the expr is evaluated
    in the current environment. If it is greater
    than 0, the then (resp. do) is executed otherwise
    the else is executed (resp. while is terminated).

2
A variety of notations
  • For our language, the semantic domain
    Environment, the set of all environments, is the
    collection of all (partial) functions mapping
    identifiers into Integer values. That
    is Environment Identifier ? Integer.
  • We might express an element of this set by a name
    such as Env or s.
  • The empty environment would be an empty map, one
    that doesnt map any identifier into any Integer
    value.
  • A function can be modified by changing its map at
    exactly one element of its domain I, to have
    value n. This can be expressed variously
    as Envn/I sn/I (relatively
    standard) n/iEnv n/Is (somewhat
    standard) I nEnv I ns (somewhat
    nonstandard) EnvIn (very nonstandard)

3
Logical Inference Rules
  • Inference rules are all of the following form
  • This inference rule embodies the transitive
    property

4
Structural Operational Semantics
  • Meaning is assigned to a program by reducing it
    (and its input) to the value it yields.
  • A reduction rule has either a syntactic component
    (or a mixture of sentactic components and
    semantic values) on the left side and a semantic
    value on the right side. Consider the rules for
    digits 0 gt 0 1 gt 1 2 gt 2 ... 9
    gt 9and the rules for numbers V 0 gt
    10V V 1 gt 10V 1 V 2 gt 10V
    2 ... V 9 gt 10V 9 V1 V2 gt V1 V2
    V1 - V2 gt V1 - V2 V1 V2 gt V1 V2
    ( V ) gt V ... etc.

2 1
gt 2 1
gt 2 1
gt 2 1
gt 3
5
Adding Assignment Changes Things Slightly
lta 2 3 Env0gt
gt a 5
gt lta 5 Env0gt
gt Env0a 5
gt a 5
lta 2 3 b a 4 a b - 5 Env0gt
gt ltb a 4 a b - 5 a 5gt
gt ltb 5 4 a b - 5 a 5gt
gt ltb 20 a b - 5 a 5gt
gt lta b - 5 a 5, b 20gt
gt lta 20 - 5 a 5, b 20gt
gt lta 20 - 5 a 5, b 20gt
gt lta 15 a 5, b 20gt
gt a 15, b 20
6
Control Flow is Not Much Harder
Write a Comment
User Comments (0)
About PowerShow.com