[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Notable declarative expressions?

  • From: "Costello, Roger L." <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Sun, 18 Dec 2016 18:19:45 +0000

Notable declarative expressions?

Hi Folks,

Do you have a notable declarative expression that you can share?

An XML Schema is a model; specifically, a data model. When you create an XML Schema, you are “data modeling.”

A key skill for modeling (both data modeling and software modeling) is the ability to think and express declaratively.

Below are two problems and their declarative expressions.

Problem #1

Declaratively express this constraint:

A set of nodes must form ring (cyclic) topology.

The following graphic shows a set of nodes with a ring topology:

Assume each node has a succ field, identifying its neighbor. How would you declaratively constrain the nodes to a ring topology?

Scroll down to see the answer …

Problem #2

Declaratively express the change in this pile of items:

Scroll down to see the answer …

 

 

 

 

 

 

 

 

 

 

 

Answer to Problem #1

Here is a declarative description of constraining nodes to form a ring topology:

All nodes must be reachable from any node
by following succ repeatedly.

Here is how the constraint is expressed in the modeling language called Alloy:

all n: Node | Node in n.^succ

For each Node n, the entire set of nodes must be in the set of nodes reachable by n.

The caret symbol denotes the set of nodes reachable from n.

Give a set of nodes, plus the above constraint expression, to a constraint satisfaction (SAT) tool and the SAT tool will decide if the nodes satisfy the constraint (i.e., the SAT tool will tell you if the nodes are in a ring structure).

Answer to Problem #2

Here is a declarative description of the change in the pile:

The pile after is equal to the pile before,
minus one item.

Here is how the constraint is expressed using the Alloy language:

before, after: Time | pile.after = pile.before - item

Important: That expression is not a recipe/algorithm/procedure for how to remove an item from the pile. Rather, it is a description of the pile after by comparing it to the pile before.

/Roger



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.