CSE307
Spring 2009
Stony Brook
Principles of Programming Languages
Annie Liu
Assignment 7
Handout A7
Apr. 30, 2009
Due May 10

Building Extras --- Showing Off (Extra Credit)

This assignment has one main goal: building extras to get extra credits:-). You may choose one of two main options: (1) generating logic programs for role activation and deactivation analysis, and (2) visualizing dependencies for role activation and deactivation.

Option 1: Analysis

This has two tasks: generating a logic program, and doing analysis. Task 1 is similar to task 1 in Assignment 6, except for two differences.

First, we generate rules with all atoms whose predicate is canActivate, canDeactivate, hasActivated, or isDeactivated, as opposed to generating edges with only the predicate name and role name in Assignment 6. For example, from the first rule in file ra

  (R1.1.1)
  canActivate(mgr, Register-RA-manager(mgr2)) <-
  hasActivated(mgr, RA-manager()),
  RA-manager-regs(n, mgr2),
  n=0
we generate the following rule:
  canA(Vmgr, rRegister_RA_manager(Vmgr2)) :- hasA(Vmgr, rRA_manager).
Note that, besides transforming role names as in Assignment 6 (so that they are proper constants in logic programs), we add an upper case V in front of other argument names (so that they are proper variables in logic programs), and for roles with no arguments, we remove ().

Second, we generate proper facts in logic programs too, as opposed to omitting them in Assignment 6. For example, from following rule in file spine

  (S1.1.3)
  canDeactivate(cli, cli, Spine-clinician(ra, org, spcty)) <-
we generate the following fact:
  canD(Vcli, Vcli, rSpine_clinician(Vra, Vorg, Vspcty)).

For another example, from the following rule in file ra

  (R3.1.1)
  canActivate(cli, Workgroup-member(org, group, spcty)) <-
  hasActivated(x, NHS-health-org-cert(org, start, end)),
  org@org.hasActivated(x, Register-team-member(cli, group, spcty)),
  Current-time() in [start, end]
we generate the following rule:
  canA(Vcli, rWorkgroup_member(Vorg, Vgroup, Vspcty)) :-
  hasA(Vx, rNHS_health_org_cert(Vorg, Vstart, Vend)),
  hasA(Vx, rRegister_team_member(Vcli, Vgroup, Vspcty)).

Also similar to Assignment 6, we generate rules for implicit dependencies for each role, except that we need to have the appropriate number of parameters. For example, for the role Workgroup-member, we generate the following two rules:

  hasA(X, rWorkgroup_member(Y1,Y2,Y3)) :- canA(X, rWorkgroup_member(Y1,Y2,Y3)).
  isD(X, rWorkgroup_member(Y1,Y2,Y3)) :- canD(Z, X, rWorkgroup_member(Y1,Y2,Y3)).

Task 2 asks you to find all facts that can be inferred from the generated logic program. You need to decide what queries to ask.

Option 2: Visualization

Consider each pair of an action and a role as built in Assignment 6 as a vertex in a graph, and each 4-tuple edge built as an edge in the graph.

Additionally, build such pairs from rules that have only the 4 kinds of activation/deactivation predicates in the conclusion, and call them source vertices. Also, build such pairs from rules that have only the 4 kinds of activation/deactivation predicates in the hypotheses, and call them target vertices.

Your task is to visualize all vertices (including source and target vertices) and edges in the graph. Your visual presentation should distinguish source vertices, target vertices, and other vertices, and distinguish edges for explicit and implicit dependencies, and the layout should be in a form that maximizes the ease of understanding the dependencies.

You may write such a visualization program yourself, but you are strongly suggested to find and use existing tools for graphical displays; you just have to give references and urls for where you find them. One possible such tool is Graphvis, but please feel free to try to find better tools if you can.

Want more extra credits?

Suggest specific things that you consider worthwhile and let me know. I will think about whether they are appropriate and let you know.

Note you have only 10 days for this assignment, shorter than usual, because you should spend enough time on the final review.


Handins

Hand in everything electronically, using Blackboard, by 5pm on the due date. Your handin should include your README file, code, test data, and anything else you have to show your work.

Grading

This assignment will be graded based on 100 points, allocated in proportion to the estimated amount of work for each part. You may do this assignment in a team of two people; the two people will receive the same points. Exceptionally well thought-out and well written work will receive appropriate extra credit. Extra credit work will be graded based on the estimated amount of extra work.