L4 - WHILE Semantics Flashcards

1
Q

What do semantics describe?

A

The behaviour of a program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Semantics abstract away from hardware, and ensures…

A

The program implements effective procedures

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are semantics independent of?

A

Machine independent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Store? What is their data structure?

A
  • Refers to all values that are assigned to variables in the program
  • Set of Key-Value pairs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Variable Binding?

A
  • A Variable,Value pair contained within the cartesian product of their respective sets.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How would a store be represented using X1, d1 notation…?

A

{X1:d1, X2:d2, …, Xn:dn}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the semantic symbol D represent?

A

The set of values in the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the semantics to perform a look up of X in a store?

A

Store_sign(X)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the semantics to perform a ‘find and replace’ operation in the store?

A

store_sign[X:=d]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the semantics for the union of all sets in this program i.e all values in the program.

A

(X,val) U (X,d)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What symbol is used to express the non-termination of a program?

A
  • Undefined
  • Upside down T
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What symbol is used to express the termination of a program?

A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the 2 semantics of programs?

A
  • Non-termination -> Upside down T
  • Termination -> e
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the semantics of the judgement command?

A

Describes the execution of commands from one store to another.

S |- Store1 -> Store2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the semantics of assignment commands?

A

Describes the assignment of a value to a variable.

X := E

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the semantics of conditional commands?

A
  • If E{St} → Execute the current if statement block

If E{Se} → Execute the else block

17
Q

What are the semantics of the While loop?

A

While expression E holds true, execute the statement block S.

18
Q

Expressions don’t have side effects. What does this mean?

A

They don’t change the state of the store.

19
Q

What are the semantics of the Constructor expression?

A

In cons expression, evaluate arguments from left to right, and then create the tree.

20
Q

What are the semantics for the hd or tl expressions?

A

For head expression, evaluate argument then create left subtree.

For tail expression, evaluate argument then create right subtree.