C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Kernel language semantics Carlos Varela RPI Adapted with permission.

Slides:



Advertisements
Similar presentations
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Programming Techniques Accumulators, Difference Lists (VRH ) Carlos Varela.
Advertisements

C. Varela; Adapted from S. Haridi and P. Van Roy1 Declarative Programming Techniques Lazy Execution (VRH 4.5) Carlos Varela RPI Adapted with permission.
1 Compiler Construction Intermediate Code Generation.
Lambda Calculus and Lisp PZ03J. Lambda Calculus The lambda calculus is a model for functional programming like Turing machines are models for imperative.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model From kernel to practical language (CTM 2.6) Exceptions (CTM.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Memory management, Exceptions, From kernel to practical language.
1 Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Single assignment store Kernel language syntax Carlos Varela.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Data Abstraction and State Abstract Data Types (3.7) State/Data Abstraction(6.1, 6.3, 6.4.1,
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
C. Varela; Adapted w. permission from S. Haridi and P. Van Roy1 Introduction to Programming Concepts Carlos Varela RPI Adapted with permission from: Seif.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Data Abstraction, State, and Objects Abstract Data Types (VRH 3.7) State / Data Abstraction(VRH.
C. Varela; Adapted from S. Haridi and P. Van Roy1 Object-Oriented Programming Active Objects (VRH 7.8) Carlos Varela RPI Adapted with permission from:
C. Varela; Adapted from S. Haridi and P. Van Roy1 Object-Oriented Programming Objects, Classes and Inheritance (VRH 7.1-4) Polymorphism (VRH 6.4.3) Carlos.
C. Varela; Adapted with permission from S. Haridi and P. Van Roy1 Declarative Concurrency (VRH4) Carlos Varela RPI Adapted with permission from: Seif Haridi.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Memory management, Exceptions, From kernel to practical language.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Programming Techniques Non-declarative needs (VRH 3.8) Program design in the.
Functional programming: LISP Originally developed for symbolic computing First interactive, interpreted language Dynamic typing: values have types, variables.
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Programming Techniques Declarativeness, iterative computation (VRH 3.1-2) Higher-order.
Introduction Even though the syntax of Scheme is simple, it can be very difficult to determine the semantics of an expression. Hacker’s approach: Run it.
S. Haridi and P. Van Roy1 Declarative Concurrency Seif Haridi KTH Peter Van Roy UCL.
9/10/2015CS2104, Lecture 81 Programming Language Concepts, COSC Lecture 8 (Multiple) Threads Semantics.
© 2002 P. Van Roy and S. Haridi 1 Teaching Programming with the Kernel Language Approach October 7, 2002 Functional and Declarative Programming in Education.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Memory management (CTM 2.5) Carlos Varela RPI April 6, 2015.
S. Haridi and P. Van Roy1 Lazy Execution Seif Haridi KTH Peter Van Roy UCL.
1 Causal-Consistent Reversible Debugging Ivan Lanese Focus research group Computer Science and Engineering Department University of Bologna/INRIA Bologna,
1 Lecture 2: Basic Control and Procedures Per Brand.
Semantics. Semantics is a precise definition of the meaning of a syntactically and type-wise correct program. Ideas of meaning: –Operational Semantics.
C. Varela; Adapted w. permission from S. Haridi and P. Van Roy1 Functional Programming: Lists, Pattern Matching, Recursive Programming (CTM Sections ,
11/23/2015CS2104, Lecture 41 Programming Language Concepts, COSC Lecture 4 Procedures, last call optimization.
Chapter 3 Part II Describing Syntax and Semantics.
S. Haridi and P. Van Roy1 Introduction to Programming Seif Haridi KTH Peter Van Roy UCL.
C. Varela1 Logic Programming (PLP 11, CTM 9.1) Terms, Resolution, Unification, Search, Backtracking (Prolog) Relational Computation Model (Oz) Carlos Varela.
S. Haridi and P. Van Roy1 Declarative Computation Model Seif Haridi KTH Peter Van Roy UCL.
Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications Chapter.
C. Varela1 Logic Programming (CTM ) Constraint Programming: Constraints and Computation Spaces Carlos Varela Rennselaer Polytechnic Institute.
Formal Semantics of Programming Languages 虞慧群 Topic 2: Operational Semantics.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Higher-Order Programming: Iterative computation (CTM Section 3
Chapter 2: Lambda Calculus
Functional Programming: Lists, Pattern Matching, Recursive Programming (CTM Sections , 3.2, , 4.7.2) Carlos Varela RPI September 12,
Names and Attributes Names are a key programming language feature
Carlos Varela Rennselaer Polytechnic Institute November 11, 2016
Carlos Varela Rennselaer Polytechnic Institute September 5, 2017
Higher-Order Programming: Iterative computation (CTM Section 3
Carlos Varela RPI September 22, 2017 Adapted with permission from:
Graph-Based Operational Semantics
Declarative Programming Techniques Accumulators (CTM 3. 4
Carlos Varela Rensselaer Polytechnic Institute December 5, 2017
Carlos Varela Rensselaer Polytechnic Institute November 14, 2017
Declarative Computation Model Kernel language semantics (Non-)Suspendable statements (VRH ) Carlos Varela RPI October 11, 2007 Adapted with.
Declarative Programming Techniques Declarativeness, iterative computation (CTM ) Higher-order programming (CTM 3.6) Abstract data types (CTM.
Object-Oriented Programming Encapsulation Control/Visibility (VRH 7. 3
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Higher-Order Programming: Closures, procedural abstraction, genericity, instantiation, embedding. Control abstractions: iterate, map, reduce, fold, filter.
UNIT V Run Time Environments.
Declarative Programming Techniques Accumulators (CTM 3. 4
Introduction to Programming Concepts (VRH )
Declarative Computation Model Single assignment store (VRH 2
Introduction to Programming Concepts
Declarative Programming Techniques Accumulators (CTM 3. 4
Corresponds with Chapter 5
Carlos Varela Rennselaer Polytechnic Institute September 6, 2019
Presentation transcript:

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Kernel language semantics Carlos Varela RPI Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy2 Kernel language syntax  s  ::= skip empty statement |  x  =  y  variable-variable binding |  x  =  v  variable-value binding |  s 1   s 2  sequential composition |local  x  in  s 1  end declaration |if  x  then  s 1  else  s 2  end conditional |{  x   y 1  …  y n  } procedural application |case  x  of  pattern  then  s 1  else  s 2  end pattern matching  v  ::= proc { $  y 1  …  y n  }  s 1  end |... value expression  pattern  ::=... The following defines the syntax of a statement,  s  denotes a statement

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy3 Examples local X in X = 1 end local X Y T Z in X = 5 Y = 10 T = (X>=Y) if T then Z = X else Z = Y end {Browse Z} end local S T in S = proc {$ X Y} Y = X*X end {S 5 T} {Browse T} end

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy4 Procedure abstraction Any statement can be abstracted to a procedure by selecting a number of the ’free’ variable identifiers and enclosing the statement into a procedure with the identifiers as parameters if X >= Y then Z = X else Z = Y end Abstracting over all variables proc {Max X Y Z} if X >= Y then Z = X else Z = Y end end Abstracting over X and Z proc {LowerBound X Z} if X >= Y then Z = X else Z = Y end end

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy5 Computations (abstract machine) A computation defines how the execution state is transformed step by step from the initial state to the final state A single assignment store  is a set of store variables, a variable may be unbound, bound to a partial value, or bound to a group of other variables An environment E is mapping from variable identifiers to variables or values in , e.g. {X  x 1, Y  x 2 } A semantic statement is a pair (  s , E ) where  s  is a statement ST is a stack of semantic statements

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy6 Computations (abstract machine) A computation defines how the execution state is transformed step by step from the initial state to the final state The execution state is pair ( ST,  ) ST is a stack of semantic statements A computation is a sequence of execution states ( ST 0,  0 )  ( ST 1,  1 )  ( ST 2,  2 ) ...

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy7 Semantics To execute a program (i.e., a statement)  s  the initial execution state is ( [ (  s ,  ) ],  ) ST has a single semantic statement (  s ,  ) The environment E is empty, and the store  is empty [... ] denotes the stack At each step the first element of ST is popped and execution proceeds according to the form of the element The final execution state (if any) is a state in which ST is empty

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy8 Calculating with environments E is mapping from identifiers to entities (both store variables and values) in the store The notation E(  y  ) retrieves the entity associated with the identifier  x  from the store The notation E + {  y  1  x 1,  y  2  x 2,...,  y  n  x n } –denotes a new environment E’ constructed from E by adding the mappings {  y  1  x 1,  y  2  x 2,...,  y  n  x n } – E’(  z  ) is x k if  z  is equal to  y  k, otherwise E’(  z  ) is equal to E(  z  ) The notation E| {  y  1,  y  2,...,  y  n } denotes the projection of E onto the set {  y  1,  y  2,...,  y  n }, i.e., E restricted to the members of the set

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy9 Calculating with environments (2) E = { X  1, Y  [2 3], Z  x i } E’ = E + { X  2} E’( X ) = 2, E( X ) = 1 E| {X,Y} restricts E to the ’domain’ {X,Y}, i.e., it is equal to { X  1, Y  [2 3]}

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy10 Calculating with environments (3) local X in X = 1(E) local X in X = 2(E’) {Browse X} end(E) {Browse X} end

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy11 skip The semantic statement is ( skip, E) Continue to next execution step

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy12 skip The semantic statement is ( skip, E) Continue to next execution step ( skip, E) ST  +  +

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy13 Sequential composition The semantic statement is (  s 1   s 2 , E) Push (  s 2 , E) and then push (  s 1 , E) on ST Continue to next execution step (  s 1   s 2 , E) ST  (  s 1 , E) (  s 2 , E) ST  + +

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy14 Variable declaration The semantic statement is ( local  x  in  s  end, E) Create a new store variable x in the Store Let E’ be E+{  x   x}, i.e. E’ is the same as E but the identifier  x  is mapped to x. Push (  s , E’) on ST Continue to next execution step

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy15 Variable declaration The semantic statement is ( local X in  s  end, E) ( local X in  s  end, ) ST  (  s , ) ST ’’ + + E E X = x i xixi unbound  +

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy16 Variable-variable equality The semantic statement is (  x  =  y , E ) Bind E(  x  ) and E(  y  ) in the store

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy17 Variable-value equality The semantic statement is (  x  =  v , E ) Where  v  is a record, a number, or a procedure Construct the value in the store and refer to it by the variable y. Bind E(  x  ) and y in the store We have seen how to construct records and numbers, but what is a procedure value?

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy18 Lexical scoping Free and bound identifier occurrences An identifier occurrence is bound with respect to a statement  s  if it is in the scope of a declaration inside  s  A variable identifier is declared either by a ‘local’ statement, as a parameter of a procedure, or implicitly declared by a case statement An identifier occurrence is free otherwise In a running program every identifier is bound (i.e., declared)

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy19 Lexical scoping (2) P YY Yproc {P X} local Y in Y = 1 {Browse Y} end X = Y end Bound Occurrences Free Occurrences

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy20 Lexical scoping (3) Reslocal Arg1 Arg2 in Arg1 = 111*111 Arg2 = 999*999 Res = Arg1*Arg2 end Bound Occurrences Free Occurrences This is not a runnable program!

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy21 Lexical scoping (4) Reslocal Res in local Arg1 Arg2 in Arg1 = 111*111 Arg2 = 999*999 Res = Arg1*Arg2 end {Browse Res} end

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy22 Lexical scoping (5) Q Q local P Q in proc {P} {Q} end proc {Q} {Browse hello} end local Q in proc {Q} {Browse hi} end {P} end end

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy23 Procedure values Constructing a procedure value in the store is not simple because a procedure may have external references Q Q local P Q in Q = proc {$} {Browse hello} end P = proc {$} {Q} end local Q in Q = proc {$} {Browse hi} end {P} end end

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy24 Procedure values (2) Q Q local P Q in Q = proc {$} {Browse hello} end P = proc {$} {Q} end local Q in Q = proc {$} {Browse hi} end {P} end end x1x1 (, ) Q proc {$} {Q} end Q  x 2 x2x2 (, ) proc {$} {Browse hello} end Browse  x 0 P

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy25 Procedure values (3) The semantic statement is ( proc {  x   y 1 ...  y n  }  s  end, E)  y 1 ...  y n  are the (formal) parameters of the procedure Other free identifiers of  s  are called external references  z 1 ...  z k  These are defined by the environment E where the procedure is declared (lexical scoping) The contextual environment of the procedure CE is E | {  z 1 ...  z k  } When the procedure is called CE is used to construct the environment of  s  ( proc {$  y 1 ...  y n  }  s  end, CE)

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy26 Procedure values (4) Procedure values are pairs: ( proc {$  y 1 ...  y n   s  end, CE) They are stored in the store just as any other value ( proc {$  y 1 ...  y n  }  s  end, CE)

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy27 Procedure introduction The semantic statement is (  x  = proc {$  y 1 ...  y n  }  s  end, E) Environment is {  x   x P,... } Create a new procedure value of the form: ( proc { $  y 1 ...  y n  }  s  end, CE), refer to it by the variable x P Bind the store variable E(  x  ) to x P Continue to next execution step

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy28 Suspendable statements  s  ::= … |if  x  then  s 1  else  s 2  end conditional |{  x   y 1  …  y n  } procedural application |case  x  of pattern matching  pattern  then  s 1  else  s 2  end The remaining statements require  x  to be bound in order to execute The activation condition (E(  x  ) is determined), i.e., bound to a number, record or a procedure value

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy29 Life cycle of a thread Running Terminated Suspended ST not empty Top(ST) activation condition is true A B A & B / Execute not A /Terminate A & not B/ Suspend B/Resume

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy30 Conditional The semantic statement is ( if  x  then  s 1  else  s 2  end, E) The activation condition (E(  x  ) is determined) is true: –If E(  x  ) is not Boolean ( true, false ), raise an error –E(  x  ) is true, push (  s 1 , E) on the stack –E(  x  ) is false, push (  s 2 , E) on the stack The activation condition (E(  x  ) is determined) is false: suspend

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy31 Procedure application The semantic statement is ( {  x   y 1  …  y n  }, E) The activation condition (E(  x  ) is determined) is true: –If E(  x  ) is not procedure value, or a procedure with arity that is not equal to n, raise an error –E(  x  ) is ( proc { $  z 1 ...  z n  }  s  end, CE), push (  s , CE + {  z 1   E(  y 1  ) …  z n   E(  y n  )} ) on the stack The activation condition (E(  x  ) is determined) is false: suspend

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy32 Case statement The semantic statement is ( case  x  of  l  (  f 1  :  x 1  …  f n  :  x n  ) then  s 1  else  s 2  end, E) The activation condition (E(  x  ) is determined) is true: –The label of E(  x  ) is  l  and its arity is [  f 1  …  f n  ]: push ( local  x 1  =  x .  f 1  …  x n  =  x .  f n  in  s 1  end, E) on the stack –Otherwise push (  s 2 , E) on the stack The activation condition (E(  x  ) is determined) is false: suspend

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy33 Execution examples local Max C in proc {Max X Y Z}  s  3 if X >= Y then Z=X else Z=Y end end {Max 3 5 C} end s2s2 s1s1

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy34 Execution examples (2) Initial state ([(  s  1,  )],  ) After local Max C in … ( [(  s  2, { Max  m, C  c}) ], {m, c} ) After Max binding ( [(  s  4, { Max  m, C  c}) ], {m = ( proc {$ X Y Z}  s  3 end,  ), c} ) local Max C in proc {Max X Y Z}  s  3 if X >= Y then Z=X else Z=Y end end  s  4 {Max 3 5 C} end s2s2 s1s1

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy35 Execution examples (3) After Max binding ( [(  s  4, { Max  m, C  c}) ], {m = ( proc {$ X Y Z}  s  3 end,  ), c} ) After procedure call ( [(  s  3, { X  t 1, Y  t 2, Z  c}) ], {m = ( proc {$ X Y Z}  s  3 end,  ), t 1 =3, t 2 =5, c} ) local Max C in proc {Max X Y Z}  s  3 if X >= Y then Z=X else Z=Y end end  s  4 {Max 3 5 C} end s2s2 s1s1

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy36 Execution examples (4) After procedure call ( [(  s  3, { X  t 1, Y  t 2, Z  c}) ], {m = ( proc {$ X Y Z}  s  3 end,  ), t 1 =3, t 2 =5, c} ) After T = (X>=Y) ( [(  s  3, { X  t 1, Y  t 2, Z  c, T  t}) ], {m = ( proc {$ X Y Z}  s  3 end,  ), t 1 =3, t 2 =5, c, t=false} ) ( [(Z=Y, { X  t 1, Y  t 2, Z  c, T  t}) ], {m = ( proc {$ X Y Z}  s  3 end,  ), t 1 =3, t 2 =5, c, t=false} ) local Max C in proc {Max X Y Z}  s  3 if X >= Y then Z=X else Z=Y end end  s  4 {Max 3 5 C} end s2s2 s1s1

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy37 Execution examples (5) ( [(Z=Y, { X  t 1, Y  t 2, Z  c, T  t}) ], {m = ( proc {$ X Y Z}  s  3 end,  ), t 1 =3, t 2 =5, c, t=false} ) ( [ ], {m = ( proc {$ X Y Z}  s  3 end,  ), t 1 =3, t 2 =5, c=5, t=false} ) local Max C in proc {Max X Y Z}  s  3 if X >= Y then Z=X else Z=Y end end  s  4 {Max 3 5 C} end s2s2 s1s1

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy38 Procedures with external references local LB Y C in Y = 5 proc {LB X Z}  s  3 if X >= Y then Z=X else Z=Y end end {LB 3 C} end s2s2 s1s1

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy39 Procedures with external references local LB Y C in Y = 5 proc {LB X Z}  s  3 if X >= Y then Z=X else Z=Y end end {LB 3 C} end s2s2 s1s1 The procedure value of LB is ( proc {$ X Z}  s  3 end, { Y  y}) The store is {y = 5, …}

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy40 Procedures with external references local LB Y C in Y = 5 proc {LB X Z}  s  3 if X >= Y then Z=X else Z=Y end end {LB 3 C} end s2s2 s1s1 The procedure value of LB is ( proc {$ X Z}  s  3 end, { Y  y}) The store is {y = 5, …} STACK: [( {LB T C}, { Y  y, LB  lb, C  c, T  t}) ] STORE: {y = 5, lb = ( proc {$ X Z}  s  3 end, { Y  y}), t = 3, c}

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy41 Procedures with external references local LB Y C in Y = 5 proc {LB X Z}  s  3 if X >= Y then Z=X else Z=Y end end {LB 3 C} end s2s2 s1s1 STACK: [( {LB T C}, { Y  y, LB  lb, C  c, T  t}) ] STORE: {y = 5, lb = ( proc {$ X Z}  s  3 end, { Y  y}), t = 3, c} STACK: [(  s  3, { Y  y, X  t, Z  c}) ] STORE: {y = 5, lb = ( proc {$ X Z}  s  3 end, { Y  y}), t = 3, c}

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy42 Procedures with external references local LB Y C in Y = 5 proc {LB X Z}  s  3 if X >= Y then Z=X else Z=Y end end {LB 3 C} end s2s2 s1s1 STACK: [(  s  3, { Y  y, X  t, Z  c}) ] STORE: {y = 5, lb = ( proc {$ X Z}  s  3 end, { Y  y}), t = 3, c} STACK: [(Z=Y, { Y  y, X  t, Z  c}) ] STORE: {y = 5, lb = ( proc {$ X Z}  s  3 end, { Y  y}), t = 3, c} STACK: [ ] STORE: {y = 5, lb = ( proc {$ X Z}  s  3 end, { Y  y}), t = 3, c = 5}

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy43 Exercises 1.Explain the difference between static binding and dynamic binding. Does dynamic binding require keeping an environment in a closure (procedure value)? Why or why not? 2.VRH Exercise 2.2 (page 107) 3.VRH Exercise 2.7 (page 108) –translate example to kernel language and execute using operational semantics. 4.Write an example of a program that suspends. Now, write an example of a program that never terminates. Use the operational semantics to prove suspension or non- termination.

C. Varela; Adapted w/permission from S. Haridi and P. Van Roy44 Exercises 5.Translate the following function to the kernel language fun {AddList L1 L2} case L1 of H1|T1 then case L2 of H2|T2 then H1+H2|{AddList T1 T2} end else nil end end Using the operational semantics, execute the call {AddList [1 2] [3 4]} 6.Read VRH Sections