1 Introducing ASML ASML version 2, “Steps and Updates ” Lecture 9 Software Engineering COMP201.

Slides:



Advertisements
Similar presentations
IF statement (i) Single statement. IF ( logical expression ) statement Example: read(*,*) a if (a. lt. 0) a = -a write(*,*) a Or read(*,*) a if (a < 0)
Advertisements

ICE1341 Programming Languages Spring 2005 Lecture #13 Lecture #13 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Statement-Level Control Structures
1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
3 Decision Making: Equality and Relational Operators A condition is an expression that can be either true or false. Conditions can be formed using the.
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
I210 review Fall 2011, IUB. Python is High-level programming –High-level versus machine language Interpreted Language –Interpreted versus compiled 2.
1 Introducing ASML Enumerations, Conditionals and Loops, Quantifiers Lecture 13 Software Engineering COMP201.
1 Introducing ASML Classes, Structured Values, Sets, Sequences Lecture 11 Software Engineering COMP201.
Formal Specification - Techniques for the unambiguous specification of software Objectives: To explain why formal specification techniques help discover.
ITERATIVE CONSTRUCTS: DOLIST Dolist is an iterative construct (a loop statement) consisting of a variable declaration and a body The body states what happens.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
A loop is a repetition control structure. it causes a single statement or block to be executed repeatedly What is a loop?
1 Introducing ASML Methods, Values, Constraints, Constants, Variables Lecture 10 Software Engineering COMP201.
1 Introducing ASML Methods, Values, Constraints, Constants, Variables, Sets, Sequences Lecture 11, 12 Software Engineering COMP201.
1 Introducing ASML Sequences, Parallel evaluation, Maps, Non-Determinism Lecture 12 Software Engineering COMP201.
Bash, part 2 Prof. Chris GauthierDickey COMP Unix Tools.
Software Engineering, COMP201 Slide 1 Lectures 9,10 Formal Specifications.
TODAY’S LECTURE Review Chapter 2 Go over exercises.
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
Introduction to ASMs Dumitru Roman Digital Enterprise Research Institute
Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 2: Major Concepts of Programming.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
REPETITION CITS1001. Scope of this lecture Repetition for loops while loops 2.
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Grouping objects Introduction to collections 5.0.
Controlling Execution Programming Right from the Start with Visual Basic.NET 1/e 8.
Control Structures By Shyam Gurram. Control Structure In this chapter we have two different types of structures. Conditional Structure Iterative Control.
Built-in Data Structures in Python An Introduction.
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Introduction to Loops For Loops. Motivation for Using Loops So far, everything we’ve done in MATLAB, you could probably do by hand: Mathematical operations.
April 16, ICE 1341 – Programming Languages (Lecture #14) In-Young Ko Programming Languages (ICE 1341) Lecture #14 Programming Languages (ICE 1341)
1 Iterative Statements Repeated execution of a (compound) statement by iteration or recursion –Iteration is statement level –Recursion is unit-level control.
GROUPING OBJECTS CITS1001. Lecture outline The ArrayList collection Process all items: the for-each loop 2.
Unit 6 Repetition Processing Instructor: Brent Presley.
Language Find the latest version of this document at
Control flow Ruth Anderson UW CSE 160 Spring
Fortran: Control Structures Session Three ICoCSIS.
Control flow Ruth Anderson UW CSE 160 Winter
Arrays and Loops. Learning Objectives By the end of this lecture, you should be able to: – Understand what a loop is – Appreciate the need for loops and.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Lecture III Syntax ● Statements ● Output ● Variables ● Conditions ● Loops ● List Comprehension ● Function Calls ● Modules.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Python - Loops and Iteration
Ruth Anderson UW CSE 160 Winter 2017
Arrays, For loop While loop Do while loop
Chapter 10 Programming Fundamentals with JavaScript
Objectives After studying this chapter, you should be able to:
Java Programming Loops
Control Structures: for & while Loops
T. Jumana Abu Shmais – AOU - Riyadh
Ruth Anderson UW CSE 140 Winter 2014
Formal Specifications
Michael Ernst UW CSE 140 Winter 2013
CSC215 Lecture Control Flow.
Statement-Level Control Structures
For loops Taken from notes by Dr. Neil Moore
Java Programming Loops
Introduction to Programming
Conditional Loops Counted Loops
CSC215 Lecture Control Flow.
EE 194/BIO 196: Modeling biological systems
Class code for pythonroom.com cchsp2cs
Selamat Datang di “Programming Essentials in Python”
Presentation transcript:

1 Introducing ASML ASML version 2, “Steps and Updates ” Lecture 9 Software Engineering COMP201

2 The Executable Specification Language - ASML 2 Compiler asmlc [name of the program] Example D:\>asmlc test.asml D:\> test.exe

3 I. Steps The general syntax for steps is Step [label] [stopping-condition] statement block a statement block consists of indented statement that follow a label is an optional string, number of identifier followed by a colon (“:”) stopping condition is any these forms: until fixpoint until expression while expression A step can be introduced independently or as part of sequence of steps in the form: step …

4 Stopping for fixed point “until fixed point” enum EnumMode Initial Started Finished var mode = Initial var count = 0 Main() step until fixpoint if mode = Initial then mode :=Started count:=1 if mode = Started and count < 10 then count:= count+1 if mode = Started and count >=10 then mode:= Finished Initial Started Finished if count < 10 then count:= count+1 count  10 count:= 1

5 Stopping for conditions “while” & “until” while expression until expression var x as Integer = 1 Main() step while x < 10 WriteLine(x) x:= x + 1 var x as Integer = 1 Main() step until x > 9 WriteLine(x) x:= x + 1 Running each of these examples produces nine steps. It will print numbers: 1,2,3,4,5,6,7,8 and 9 as output Either while or until may be used to give an explicit stopping condition for iterated sequential steps of the machine.

6 Conditions eq= ne  lt < gt > in  notin  subset  superset  subseteq  superseteq 

7 Sequences of steps var F as File? = undef var Fcontents as String = “” Main () step 1: F :=open(“mfile.txt”) step 2: FContents :=fread (F,1) step 3: FContents := FContents + fread (F,1) step 4: writeln (FContents) The syntax step … step … indicates a sequence of steps that will be performed in order Labels after the “step” keyword are optional but helpful as documentation.

8 Be wary ! Be wary of introducing unnecessary steps This can occur if two operations are really not order-dependent but are given as two sequential steps, regardless It is very easy to fall into this trap, since most people are used to the sequential structures used by other programming languages

9 Iteration over collections Another common idiom for iteration is to do one step per element in some finite collection such as a set or sequence step foreach ident 1 in expr 1, ident 2 in expr 2 … statement-block myList = [1,2,3] Main() step foreach i in myList WriteLine (i) Sequential, step-based iteration is available for sets as well as sequences, but in the case of sets, the order is not specified

10 Guidelines for using steps SituationYou choose … operations occur in a fixed order sequence of steps each operation must be done in order iterated steps with stopping condition “while”,“until” operations must be done in sequence, one after another iteration over collection “foreach” operations can be done without order iteration over collection “forall” Repeat an operation until no more changes occur fixed-point stopping condition “until fixed point”

11 II. Updates “How are variables updated?” A program defines state variables and operations The most important concept is that state is a dictionary of (name,value) pairs Each name identifies an occurrence for state variables Operations may propose new values for state variables But effect of these changes is only visible in subsequent step

12 The update statement Update symbol “: =” (reads as “gets”) var x = 0 var y = 1 Main() step WriteLine(“In the first step, x =” + x) // x is 0 WriteLine (“In the first step, y =” + y) // y is 1 x:=2 step // updates occur here WriteLine(“In the second step, x =” + x)//x is 2 WriteLine(“In the second step, y =” + y)//y is 1

13 Delayed effect of updates Updates don’t actually occur until the step following the one in which they are written var x = 0 var y = 1 Main() step WriteLine(“In the first step, x =” + x) // x is 0 WriteLine(“In the first step, y =” + y) // y is 1 step x:=2 WriteLine (“In the second step, x =” + x) // x is 0 step WriteLine (“In the third step, x =” + x) // x is 2

14 When updates occur in C, Javain ASML temp = x x = y y = temp step x:= y y:=x Swapping values All updates given within a single step occur simultaneously at the end of the step. Conceptually, the updates are applied “in between” the steps.

15 Consistency of updates a)The order within a step does not matter, but all of updates in the step must be consistent b)None of the updates given within a step may contradict each other c)If updates do contradict, then they are called “inconsistent updates” and an error occur Inconsistent update Error: CLASH in the update set step x:=1 x:=2 we don’t know which of the two should take effect

16 Total and partial updates An update of the variable can either be total or partial Total update is a simple replacement of variable’s value with a new value Partial updates apply to variables that have structure The left hand side of the update operation “ X : = val ” indicates whether the update is total or partial

17 Total update of a set-valued variable 1.The variable Students was, initially, an empty set 2.It was then updated to contain the names of the four students 3.Update became visible in the second step as the finial roster var Students as Set of String = {} Main() step WriteLine (“The initial roster is = ” + Students) Students := {“Bill”, “Carol”, “Ted”, “Alice”} step WriteLine (“The final roster is = ” + Students)

18 Partial update of a set-valued variable “ X : = val ” is update operation If X ends with an index form, then the update is partial If X ends with a variable name, then the update is total var Students as Set of String = {} Main() step WriteLine (“The initial roster is = ” + Students) Students(“Bill”) := true Students(“Carol”) := true Students(“Ted”) := true Students(“Alice”) := true step WriteLine (“The final roster is = ” + Students)

19 Updating a set-valued variable Updating the set Students with updating statement (*) removes “Bill ” from the set The update is partial in the sense that other students may be added to the set Students in the same step without contradiction var Students as Set of String = {} Main() step WriteLine (“The initial roster is = ” + Students) Students := {“Bill”, “Carol”, “Ted”, “Alice”} step WriteLine (“The current roster is = ” + Students) Students ( “Bill”) := false // ( * ) step WriteLine (“The final roster is = ” + Students)