The util/ordering module and ordered subsignatures

前端 未结 2 1146
[愿得一人]
[愿得一人] 2021-01-25 12:24

Consider the following Alloy model:

open util/ordering[C]

abstract sig A {}
sig B extends A {}
sig C extends A {}

pred show {}
run show for 7

2条回答
  •  轮回少年
    2021-01-25 12:45

    Short answer: the phenomena reported result from the rules for default and implicit scopes; those rules are discussed in section B.7.6 of the Language Reference.

    Longer answer:

    The eventual suspicion that I should look at the semantics of scope specifications more closely proved to be warranted. In the example shown here, the rules work out exactly as documented:

    • For run show for 7, signature A has a default scope of 7; so do B and C. The use of the util/ordering module forces the number of C atoms to 7; that also exhausts the quota for signature A, which leaves signature B with an implicit scope of 0.

    • For run show for 2 but 3 B, signature A has a default scope of 2, and B has an explicit scope of 3. This leaves signature C with an implicit signature of 2 minus 3, or negative 1. That appears to count as an inconsistency; scope bounds are expected to be natural numbers.

    • For run show for 2 but 3 B, 3 C, signature A gets an implicit bound of 6 (the sum of its subsignatures' bounds).

    As a way of gaining a better understanding of the scope rules, it proved useful to this user to execute all of the following commands:

    run show for 3
    run show for 3 but 2 C
    run show for 3 but 2 B
    run show for 3 but 2 B,  2 C
    run show for 3 but 2 A
    run show for 3 but 2 A, 2 C
    run show for 3 but 2 A, 2 B
    run show for 3 but 2 A, 2 B, 2 C
    

    I'll leave this question in place for other answers and in the hope that it may help some other users.

提交回复
热议问题