15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Definition 236 We will write (−A) as A and (A∗B) as A ∗ B (and similarly for +).<br />

Furthermore we will write variables such as x71 as x71 and elide brackets for sums and<br />

products according to their usual precedences.<br />

Example 237 σ(((−(x1∗x2))+(x3∗x4))) = x1 ∗ x2 + x3 ∗ x4<br />

: Do not confuse + and ∗ (Boolean sum and product) with their arithmetic counterparts.<br />

(as members of a formal language they have no meaning!)<br />

c○: Michael Kohlhase 134<br />

Now that we have defined the formal language, we turn the process of giving the strings a meaning.<br />

We make explicit the idea of providing meaning by specifying a function that assigns objects that<br />

we already understand to representations (strings) that do not have a priori meaning.<br />

The first step in assigning meaning is to fix a set of objects what we will assign as meanings: the<br />

“universe (of discourse)”. To specify the meaning mapping, we try to get away with specifying<br />

as little as possible. In our case here, we assign meaning only to the constants and functions and<br />

induce the meaning of complex expressions from these. As we have seen before, we also have to<br />

assign meaning to variables (which have a different ontological status from constants); we do this<br />

by a special meaning function: a variable assignment.<br />

Boolean Expressions: Semantics via Models<br />

Definition 238 A model 〈U, I〉 for Ebool is a set U of objects (called the universe) together<br />

with an interpretation function I on A with I(Cbool) ⊆ U, I(F 1 bool ) ⊆ F(U; U), and<br />

I(F 2 bool ) ⊆ F(U 2 ; U).<br />

Definition 239 A function ϕ: V → U is called a variable assignment.<br />

Definition 240 Given a model 〈U, I〉 and a variable assignment ϕ, the evaluation function<br />

Iϕ : Ebool → U is defined recursively: Let c ∈ Cbool, a, b ∈ Ebool, and x ∈ V , then<br />

Iϕ(c) = I(c), for c ∈ Cbool<br />

Iϕ(x) = ϕ(x), for x ∈ V<br />

Iϕ(a) = I(−)(Iϕ(a))<br />

Iϕ(a + b) = I(+)(Iϕ(a), Iϕ(b)) and Iϕ(a ∗ b) = I(∗)(Iϕ(a), Iϕ(b))<br />

U = {T, F} with 0 ↦→ F, 1 ↦→ T, + ↦→ ∨, ∗ ↦→ ∧, − ↦→ ¬.<br />

U = Eun with 0 ↦→ /, 1 ↦→ //, + ↦→ div, ∗ ↦→ mod, − ↦→ λx.5.<br />

U = {0, 1} with 0 ↦→ 0, 1 ↦→ 1, + ↦→ min, ∗ ↦→ max, − ↦→ λx.1 − x.<br />

c○: Michael Kohlhase 135<br />

Note that all three models on the bottom of the last slide are essentially different, i.e. there is<br />

no way to build an isomorphism between them, i.e. a mapping between the universes, so that all<br />

Boolean expressions have corresponding values.<br />

To get a better intuition on how the meaning function works, consider the following example.<br />

We see that the value for a large expression is calculated by calculating the values for its subexpressions<br />

and then combining them via the function that is the interpretation of the constructor<br />

at the head of the expression.<br />

Evaluating Boolean Expressions<br />

Example 241 Let ϕ := [T/x1], [F/x2], [T/x3], [F/x4], and I =<br />

{0 ↦→ F, 1 ↦→ T, + ↦→ ∨, ∗ ↦→ ∧, − ↦→ ¬}, then<br />

73

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!