Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of 'private' keyword in Alloy? Meaning of 'enum' declaration?

Tags:

alloy

The Alloy 4 grammar allows signature declarations (and some other things) to carry a private keyword. It also allows Allow specifications to contain enumeration declarations of the form

enum nephews { hughie, louis, dewey }
enum ducks { donald, daisy, scrooge, nephews }

The language reference doesn't (as far as I can tell) describe the meaning of either the private keyword or the enum construct.

Is there documentation available? Or are they in the grammar as constructs that are reserved for future specification?

like image 493
C. M. Sperberg-McQueen Avatar asked Oct 06 '22 22:10

C. M. Sperberg-McQueen


1 Answers

This is my unofficial understanding of those two keywords.

enum nephews { hughie, louis, dewey }

is semantically equivalent to

open util/ordering[nephews] as nephewsOrd

abstract sig nephews {}

one sig hughie extends nephews {}
one sig louis extends nephews {}
one sig dewey extends nephews {}

fact {
  nephewsOrd/first = hughie
  nephewsOrd/next = hughie -> louis + louis -> dewey
}

The private keyword means that if a sig has the private attribute, its label is private within the same module. The same applies for private fields and private functions.

like image 54
Aleksandar Milicevic Avatar answered Oct 10 '22 01:10

Aleksandar Milicevic