1) Express the meaning of binary and decimal number by denotational method.Use t
ID: 3594629 • Letter: 1
Question
1) Express the meaning of binary and decimal number by denotational method.Use this meaning of decimal numbers in defining expression which may involve + And * operator between decimal numbers or variables.
2) Extend the concept of expression to Boolean expression which may contain variables or binary number and may involve same operators. Write a denotational expression for representing the meaning of this Boolean expression.
Please focus only on question 2. Question 2 is in direct reference to question 1, therefore it was relevant to place question 1 in the submision. Thanks!
Explanation / Answer
Solution :
1. The Denotational Method is also know as Denotational semantics. It is based on recursive method .It defines each language entities like mathematical object and function that maps mathematical objects to corresponding functions/entities . The method is named denotational because the mathematical object denote the meaning of their corresponding language entity .
To describe the meaning of a binary number using denotational method we associate the actual meaning with each rule that has a single terminal symbol in its RHS. let's take the entities as ‘0’ and ‘1’. these entities are decimal equivalent too.
Syntax of binary number:
<bin_num> 0
| 1
| <bin_num> 0
| <bin_num> 1
Basically Denotation method consists of set of non negative decimal integer values . we can show binary vlaues defined wrt denotational method as below :
•The function Mbin ,for the above grammar, is defined as follows:
Mbin(‘0’) = 0
Mbin(‘1’) = 1
Mbin(<bin_num> ‘0’) = 2 * Mbin(<bin_num>)
Mbin(<bin_num> ‘1’) = 2 * Mbin(<bin_num>) + 1
Decimal number denotational syntax:
Mdec('0')=0, Mdec('1') =1, …, Mdec('9') = 9
Mdec(<dec_num> '0') = 10 * Mdec(<dec_num>)
Mdec(<dec_num> '1’) = 10 * Mdec(<dec_num>) + 1
…
Mdec(<dec_num> '9') = 10 * Mdec(<dec_num>) + 9
Solution 2 :
We will write binary expression and denotational expression for a set of number taken as below :
s = {<i1, v1>, <i2, v2>, …, <in, vn>}
here i -- varibale and v is current value .
Binary Expression :
<expr> ® <dec_num> | <var> | <binary_exp>
<binary_exp> ® <left_exp> <operator> <right_exp>
<left_exp> ® <dec_num> | <var>
Denotational expression :
Me(<expr>, s) = case <expr> of
<dec_num> = Mdec(<dec_num>, s)
<var> = if VARMAP(<var>, s) == undef
then error
else VARMAP(<var>, s)
<binary_expr> = if (Me(<binary_expr>.<left_expr>, s) == undef OR
Me(<binary_expr>.<right_expr>, s) = undef)
then error
else if (<binary_expr>.<operator> == ‘+’ then
Me(<binary_expr>.<left_expr>, s) +
Me(<binary_expr>.<right_expr>, s)
else Me(<binary_expr>.<left_expr>, s) *
Me(<binary_expr>.<right_expr>, s)
<right_exp> ® <dec_num> | <var>
<operator> ® + | *
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.