Skip to content

Explain Pine's SBVR in docs/SBVR.md - #329

Open
Ereski wants to merge 1 commit into
masterfrom
readme-revamp
Open

Ereski wants to merge 1 commit into
masterfrom
readme-revamp

Conversation

@Ereski

@Ereski Ereski commented Dec 2, 2019

Copy link
Copy Markdown
Contributor
  • Explain SBVR as understood by Pine in more programmer-friendly
    terms
  • Map out how Pine interprets SBVR's structured english

@Ereski
Ereski requested review from Page- and alexandrosm December 2, 2019 09:54
Comment thread docs/SBVR.md
@@ -0,0 +1,355 @@
# SBVR in Pine.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this document to stand on its own, I think it helps to provide an introductory paragraph and a tiny working example of an SBVR model that readers can carry in their minds as they read through the document. It could start as follows:

*SBVR* stands for "Semantics of Business Vocabulary and Business Rules" and
provides a way to capture specifications in natural language and represent
them in formal logic, so they can be machine processed. This document describes
how Pine understands SBVR. You can use the [sbvr lab](http://www.sbvr.co/) as a
companion to this document. For the deep dive, check out the [SBVR spec](http://www.omg.org/spec/SBVR/).

Here is an example model expressed in SBVR:

<a minimal pilot model>

Comment thread docs/SBVR.md Outdated
Vocabulary: <vocabulary-name>
```

Every new definition is part of the last declared vocabulary. If no vocabulary has been explicitly declared, a `Default` vocabulary is implicitly assumed. Within vocabularies, term declarations introduces _types_:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be expanded a bit here: in what sense is a term a type?

@Ereski Ereski Dec 6, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the explanation I put:

Terms are types: they represent a collection of instances that obey an uniform "interface" defined through fact types and rules.

Comment thread docs/SBVR.md Outdated
Comment thread docs/SBVR.md

### Database Table Name

The `Database Table Name` defines the name of the database table.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What implication does this have? Can this attribute only be applied to Terms?

Comment thread docs/SBVR.md Outdated
| `It is forbidden that` | It is obligatory that not |
| `It is permitted that` | It is not obligatory that not |

Currently Pine parses modalities but assumes they are all equivalent to necessities. It also assumes that rules that can be represented directly in SQL (schema, UNIQUE/NOT NULL/etc) are alethic, and everything else deontic.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting, never fully understood how we differentiate between the two. Can we add an example of a deontic rule here? Also, we should explicitly mention the runtime cost that is associated with the two: as the first comes for "free" since they are enforced by the DB, but we have to explicitly check for other rules after an insert/update. What happens in practice if a deontic rule is violated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within SBVR, the difference is about what to expect: violations of alethic rules are not expected at all, while violations of deontic rules are not desired but possible. As far as the database is concerned, the difference is how you get an error: either the DB refuses to work (alethic, can't do anything about that unless you change the schema behind Pine's back) or a a validation check fails (deontic, user-driver check that can be ignored). I haven't gone down the code path dealing with validation checks though.

It's hard to talk about runtime costs and the alethic/deontic split in practice because it depends on the DB, the Pine version, and how you phrase your constraint. The basic gist seems to be that if Pine sees an opportunity to encode a constraint into the schema, it takes it. Everything else is put into validation checks.

But regardless, SBVR modalities are completely irrelevant in practice. You could scrap them without losing functionality (even impossible is treated as necessary), so I don't think it makes much sense to delve into that.

@Ereski
Ereski force-pushed the readme-revamp branch 2 times, most recently from 6c82d0e to b2d6285 Compare December 6, 2019 04:21
@Ereski
Ereski requested a review from a team February 26, 2020 14:47
- Explain SBVR as understood by Pine in more programmer-friendly
  terms
- Map out how Pine interprets SBVR's structured english

Change-type: patch
Signed-off-by: Carol Schulze <carol@balena.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants