COMPUTING FUNDAMENTALS 2

advertisement
Assignment for
Computing Fundamentals 2
DT249 B.Sc in Information Systems
and Information Technology,
Semester-1 2010-11
Your Name
Your Student Number
This assignment consists of three questions. You should place your solutions in this
document under each question. Please enter your name and student number above.
You must cite your references as follows
[Number,Author(s),Year].
The assignment was handed out in class Monday 29tt of November. The completed
assignment, in MS-Word or PDF, format, should be emailed to me at
Patrick.Browne@dit.ie on or before Wednesday the 12th of January.
The document should be emailed to me as:
YourStudentNumber.doc
OR
YourStudentNumber.pdf
Please replace the text YourStudentNumber in the above file name with your
actual student number. The solution should be written after the appropriate question
under the word Solution.
Question 1 [35 marks]
Q1.1. Describe the main components of an algebra. For each component show how
they are represented in CafeOBJ.
Solution1.1.
Q1.2. Define the following terms:
 A signature morphism.
 A specification morphism.
Solution1.2.
Q1.3. Briefly explain the overall meaning of the CafeOBJ modules FUN, MAP, and
DOUBLE. These modules are on the course web page in a file called MAP-LIST.cafe
. You do not have to explain the imports NAT and LIST. Note the constructor in LIST
is a comma. Explain in detail lines A and B in MAP.
mod! LIST {
[ List ]
op nil : -> List
op _,_ : List List -> List { constr assoc id: nil}
}
mod* FUN {
pr(TRIV)
op f_ : Elt -> Elt }
mod! MAP(F :: FUN){
pr(LIST)
[Elt < List ]
op map_ : List -> List
var N : Elt
var L1 : List
eq map nil = nil . -- line A
eq map (N , L1) = (f N ) , (map L1) . -}
mod! DOUBLE principal-sort Nat {
pr(NAT)
op double_ : Nat -> Nat
var N : Nat
eq double N = N + N . }
line B
Solution1.3.
Q1.4. In relation to the modules FUN and DOUBLE describe of the following CafeOBJ
view and make commands.
view MD from FUN to DOUBLE {sort Elt -> Nat, op f_ -> double_ } .
make MAP-double (MAP(MD)) .
Solution1.4.
Q1.5. In relation to the MAP-double module, what are the values of the following
expressions? Explain how the values were calculated.
red in MAP-double : map (2 , 4 , 8) .
red in MAP-double : map (x:Nat , 4 , 8) .
Solution1.5.
Q1.6. Describe one possible advantage of using the above mechanism of mapping a
function to the elements of a list.
Solution1.6.
Question 2 [35 marks]
Q2.1. What is formal concept analysis (FCA).
Solution2.1.
Q2.2. List 4 applications FCA. Describe one application in detail.
Solution2.2.
Q2.3. Table 1 represents information about family members and their attributes. An
X in a cell indicates that an object has that particular attribute. Use Concept Explorer
(CE) construct a concept lattice from the table.
Table 1
Append the last three digits of your student number to each object. Include a
screenshot of your completed lattice in your solution.
Solution2.3.
Q2.4 Using a drawing MS-Word or a drawing package (e.g. Paint, Gimp, etc.)
annotate each vertex of the lattice with the relevant set of objects and attributes. The
objects should be in upper case, and the attributes should be in lower case. Insert a
screenshot of your newly annotated lattice.
Solution2.4.
Q2.5. Did CE construct any vertices that did not directly correspond with the input
data? If so, explain why you think that the extra vertices were inserted automatically.
Solution2.5.
Q2.6. How would you decide on which object(s) a particular vertex represents? Give
an example.
Solution2.6.
Q2.7. Describe in English vertex object in the lattice. In practice which would be
developed first, the English description or the formal FCA lattice?
Solution2.7.
Q2.8. Table 2 represents information about a list of classical elements (objects) and
their attributes1. An X in a cell indicates that an object has that particular attribute.
Use Concept Explorer (CE) to construct a concept lattice from the table and include it
in your solution.
Solution2.8.
Table 2 A classical table of elements
Q2.9. With respect to lattice and table of elements, answer the following questions.
 Describe the formal context.
 Describe one formal concept.
 Describe and provide a diagram of the order filter (up set) of node labelled Air.
 Describe and provide a diagram of the order ideal (down set) of node labelled
Air.
 List all the elements (objects and attributes) at the top and the bottom of the
lattice.
Solution2.9.
Question 3 [30 marks]
Q3.1. Describe four attributes that can be attached to operations in CafeOBJ.
In general, what is the purpose of these attributes?
Solution3.2.
Q3.2. Load MINIMUM.cafe. Run the minimum (code below) function as follows:
red in MINIMUM : minimum(1,2) .
red in MINIMUM : minimum(2,1) .
Explain how the function minimum works. (hint set trace on)
mod! MINIMUM {
protecting(INT)
op minimum : Int Int -> Int {comm }
vars I J : Int
ceq minimum(I, J) = I if I <= J . }
Solution3.2.
Q3.3. What does it mean to say a signature is regular?
Solution3.3.
1
See: http://www.kheper.net/topics/cosmology/elements.html
Q3.4. For this question see CafeOBJ User's Manual ver.1.4.8 (Draft)
3.3.1 Well-formed Terms
3.3.3 Qualifying Terms
10.1 Check Command
Load and open AMBIGUOUS.cafe (code below) into CafeOBJ. Use Concept
Explorer to draw the sort hierarchy with sorts as objects operations as attributes for
AMBIGUOUS.cafe. Include the lattice in your solution.
Explain each of the reductions below.
mod AMBIGUOUS {
[B12 < B1 B2, A1 A2 ]
-- Overloaded constant x
op x : -> B1
op x : -> B2
op y : -> B2
op z : -> B12
-- Overloaded function g
op g : B1 -> A1
op g : B2 -> A2 }
-- Explain the outputs of the following reductions:
open AMBIGUOUS .
red y .
red z .
red g(y) .
red x .
red (x):B2 .
red g(x) .
red g((x):B1) .
red g((x):B2) .
red g(z) .
Solution3.4.
Q3.5. With AMBIGUOUS module still open, explain what the following command
does.
check regularity
Solution3.5.
Download