简体   繁体   中英

Alloy - Count atoms used by other atoms

I'm trying to notice a change in atom relations to other atoms. Using the below signatures :

    sig Word, Definition{}

    sig Dictionary {
        def: Word -> lone Definition
    }

I then use a predicate to show what happens when you add a new relation to a Dictionary by having another Dictionary which is the same but with one more relation.

    pred addRelation [d,d':Dictionary,w:Word,f:Definition] { 
        d'.word = d.word + w -> f 
    }

To see if the number of Word atoms used by the first Dictionary increase I can show only the instances where this occurs using:

    #d'.def.Definition > #d.def.Definition

However, is there a way to see if the number of Definition atoms used by the second Dictionary atom has increased? I've been using trial and error in the Alloy Evaluator to try and find a value for this but have come up short.

Thanks!

Like this?

sig Word, Definition{}

sig Dictionary {
    def: Word -> lone Definition
}

pred addRelation [d,d':Dictionary,w:Word,f:Definition] { 
    d'.def = d.def + w -> f 
    #d'.def[Word] > #d.def[Word]
}
run addRelation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM