2.1 The While Programming Language Flashcards
What is a programming language? What does every language need?
A precise language for giving instructions.
Needs: Syntax: form programs are allowed to take
Semantics: what a program means
Define the grammar of while:
S ::==
b ::==
a ::==
S ::== a | skip | S1;S2| if b then S1 else S2 | while b do S | (S)
b ::== true | false | a1 = a2 | a1 ≤ a2 | ¬b | b1 ∧ b2 | (b)
a ::== v | n | a1 + a2 | a1 - a2 | a1 x a2 | (a)
how can we extend the while language?
if b then s = if b then s else skip
a1 < a2 = ¬ ( a2 ≤ a1 )
a1 > a2 = ¬ ( a1 ≤ a2 )
a1 != a2 = ¬ (a1 = a2)
what does this mean:
⇒
We execute program S in state σ to give a new program S’ and state σ’
Give state modification notation
σ[x↦2]
are these states:
[x↦y]
[x+ y ↦2]
No