alloy

Is this Alloy model cheating?

杀马特。学长 韩版系。学妹 提交于 2019-12-25 01:36:42
问题 Some Request for Comments (RFCs) have these two rules: 1. Each comma character must be escaped with a backslash. 2. A backslash that is not being used to escape a comma must be escaped with a backslash. Here are valid values: A\,B A\\\,B A\\\\\\\,B Here are invalid values: A\\,B A,B A\\\B I created two Alloy models. My second Alloy model has two signatures for backslashes: sig Backslash extends Char {} sig EscapedBackslash extends Char {} The latter, of course, represents a double backslash.

disjoint union and Cartesian product in Alloy

a 夏天 提交于 2019-12-25 01:20:20
问题 I have two set comprehension predicates (uniary) as bellow in Alloy: pred A (o : Object){ .. } pred B (o : Object) { ..} I would like to define predicates, one of which is disjoint union and another one is Cartesian product of A and B. PS: To define their union and intersection I can define the following predicate: pred Union(o : Object){ A[o] or B[o] } pred Inter(o:Object){ A[o] and B[o] } I would like to get similar predicates for Cartesian product and disjoint union. Thanks 回答1: You may be

Alloy programming for example network configuration

蓝咒 提交于 2019-12-24 18:54:30
问题 Suppose there are 8 pcs and 1 switch, I want to divide three subnets.how to use alloy language program?Can you give an example? 回答1: The following models a small network. sig IP {} some sig Subnet { range : some IP } abstract sig Node { ips : some IP } sig Router extends Node { subnets : IP -> lone Subnet } { ips = subnets.Subnet all subnet : Subnet { lone subnets.subnet subnets.subnet in subnet.range } } sig PC extends Node {} { one ips } let routes = { disj s1, s2 : Subnet | some r : Router

How to constrain the number of following backslashes to an odd number? to an even number?

不打扰是莪最后的温柔 提交于 2019-12-24 07:47:43
问题 next is a binary relation. This string: A\\\,B is modeled by this next table: Consider the first column of the first row of the table. It's value is A. From A we can get to Backslash0, then Backslash1, then Backslash2, then Backslash3, then Comma0, and then B. So, the number of Backslashes between A and the first reachable non-backslash value (which in this case is Comma0) is an odd number (3). Yea! That is what I want. If the first reachable non-backslash value was a non-comma, then the

Using set comprehension on binary relationships in Alloy

筅森魡賤 提交于 2019-12-24 03:02:07
问题 I have the following signatures: sig Id, Grade {} sig Foo { result : Id -> Grade } Now I want to create a function that takes in a foo variable and returns all associating Foo -> Grade relationships: fun results[ id : Id ]: Foo -> Grade { //return all Foo->Grade binary relationships such that "id -> grade" in Foo.result } i.e. So if the "result" relationship is like this: (foo0, id0, grade0) (foo0, id1, grade0) (foo0, id2, grade1) (foo1, id0, grade2) (foo1, id3, grade3) (foo2, id0, grade0)

Modeling a completely connected graph in Alloy

安稳与你 提交于 2019-12-23 20:13:18
问题 I'm trying to get my feet wet with Alloy (also relatively new-ish to formal logic as well), and I'm trying to start with a completely connected graph of nodes. sig Node { adj : set Node } fact { adj = ~adj -- symmetrical no iden & adj -- no loops all n : Node | Node in n.*adj -- connected } pred ex { } run ex for exactly 3 Node As you can see from the image, Nodes 0 and 1 aren't connected. I thought that my fact was enough to make it completely connected...but perhaps I missed something. 回答1:

Alloy built-in integer math functions don't work in imported files

放肆的年华 提交于 2019-12-22 06:56:30
问题 I have an alloy model in avlTree.als. This model uses integer arithmetic, specifically the plus and minus functions. This model has some assertions in it, and I can run those just fine using the Alloy Analyzer GUI. I have another alloy model in test.als. This model imports avlTree (using "open avlTree") and then has some assertions about the relations in the avlTree model. But when I try to run these assertions in the Alloy Analyzer GUI, I get the following message: A syntax error has

Experiences with using Alloy in real-world projects

陌路散爱 提交于 2019-12-20 09:20:58
问题 I have been interested in formal methods for some time. I have used formal methods to reason about some very specific sub-areas of a few projects I have been working on. I was never able to convince other team members to try the same let alone specify an entire domain with a formal method. One method I have found particularly interesting is Alloy. I think that it may "scale" better as foundation for an entire project because it is conceptually and notationally very close to actual programming

Why does Alloy tell me that 3 >= 10?

梦想与她 提交于 2019-12-20 04:23:15
问题 When debugging a perplexing problem in Alloy, I've used the evaluator to do 3 > 10 and get the result true . Am I missing something?! 回答1: Alloy integers are typically very narrow by normal standards, and they normally have a sort of 'wraparound' semantics. In the default scope, in Alloy 4.2 Int ranges from -8 to 7, and literal 8, 9, 10 are indistinguishable from literal -8, -7, -6. (The use of out-of-range values like literal 10 cannot be detected statically, because in principle Alloy

Provide Alloy with a “pool” of custom Strings

佐手、 提交于 2019-12-20 02:30:41
问题 I'm interested in using the String type of Alloy, (especially due to the fact it allows the use of special character). I noticed that in order to add a given String to an instance, it is sufficient to include it in an expression. e.g. fact stringInsert{ none!="a"+"b"+"c" } will lead to the creation of atoms "a","b" and "c" in any generated instances. Now my question is, is there a way to declare a pool of strings,defining all possible string atoms that might occur in satisfiable instances,