quinta-feira, 2 de outubro de 2014

Logical Spreadsheets and Websheets

Logical spreadsheets: Similar to a traditional spreadsheet where the cells can be related using formulas, cells in a logical spreadsheet are related / constrained using logical expressions. Consider the following example of a logical spreadsheet which has three cells: start, end, and duration and two logical constraints (a) start time < end time and (b) start time + duration = end time.
StartEndDuration
Play around with the above logical spreadsheet. For instance, try entering 9:00 am as the start time and then choose 1:00 pm as the end time. The duration will be automatically filled in as 4 hours. The duration is italicized to indicate that it is a computed value rather than one entered directly. Now, remove your choice of 1:00 pm for the end time by choosing the empty value (the top choice) from the menu, and choose a value for the duration. Note that the end time is automatically filled in. Traditional spreadsheets for e.g., MS Excel do not support bi-directional propagation of values.
In addition, logical spreadsheets can sometimes resolve conflicts automatically. For example, if you choose 9:00 am as the start time and then choose 8:00 am as the end time, the start time will automatically be erased because it is inconsistent with your choice of end time. Alternatively, a spreadsheet can keep the inconsistent values but alert the user to the problem. For example, try entering a start time of 9:00 am, an end time of 1:00 pm, and a duration of 1 hour. These three choices are incompatible, so the spreadsheet indicates the inconsitency by coloring the three choices red.
Websheets: A logical spreadsheet need not look like a traditional spreadsheet (e.g. MS Excel) at all i.e. the cells of a logical spreadsheet need not be necessarily laid-out in a grid. The idea behind websheets is that any DOM element (for e.g. checkbox, dropdown, radio, input field, or button) of a HTML page can be turned into a cell of a logical spreadsheet. One can then characterize the behavior of the webpage using logical rules that constrain the value of these cells. One practical application of websheets is to design, validate and manage smart HTML-forms in a declarative fashion.
The programsheets used by CS Masters students at Stanford is a real-world example of websheets in action. Click on the following URL to view a Stanford MSCS programsheet. Note that the programsheet has been altered for demonstration purposes.
Stanford MSCS programsheet
Every form element in the programsheet (for e.g., the checkboxes  or , or the SPAN element that captures the Breadth requirement "At least 3 of the following:") can be seen as cells in a logical spreadsheet. Interacting with these form elements changes the truth values of the associated cells. For example, clicking on the checkbox labeled CS 103 sets the truth value of the cell / proposition cs103 to true.
In addition, you'll observe that after certain interactions for e.g., when three breadth courseshave been selected, the color of the SPAN element corresponding to the Breadth Requirement turns from red to black. This visual feedback is used to let students (who are filling in the programsheet) know whether or not they have satisfied the appropriate program requirements. We note that the logical constraints that capture the program requirements are not explicitly rendered in the above programsheet (only the English equivalent is rendered). Examples of (modified) logical constraints that used in the programsheet are as follows.
cs103 ∨ logicApprovallogicReqSatisfied
cs103¬logicApproval
logicApproval¬cs103
The above logical sentences constrain truth value of the propositon logicReqSatisfied to be true(causing the color of SPAN element "Logic, Automata, and Complexity" to turn from red toblack) if one of the following actions is performed.
  • The checkbox  is checked (which causes the proposition cs103 to be true), or
  • One of the non-empty options under the dropdown Approval is selected (causing logicApproval to be true).
In addition, these two actions are mutually exclusive i.e. selecting CS 103 (and thereby setting the truth value of cs103 to true) causes the value of the dropdown menu Approval to be empty (thus changing the truth value of logicApproval to false).
Thought-exercise: Can you think of another simple application of websheets in action that you have encountered in this course?
Note: In this application there is uni-directional propagation of values.
Hint: Feedback is the key!

Nenhum comentário:

Postar um comentário