Skip to Main Content
We present aDeryaft, a novel technique for automating the writing of specifications in Alloy-a first-order relational logic with transitive closure. Alloy is particularly suitable for specifying structural properties of software, and has steadily been gaining popularity due to the rapid feedback that its SAT-based analyzer provides fully automatically. Alloy users however, still have to manually write specifications in a declarative language and use a paradigm that is different from the commonly used imperative programming paradigm. aDeryaft assists Alloy users in writing their specifications by providing a novel specification-writing approach, which is particularly tailored to users, such as engineers or practitioners in industry, who may not have much prior experience or proficiency in Alloy or similar logics. The user constructs by hand a few small concrete instances that represent the constraints of the software structure they want to specify. aDeryaft then fully automatically generates an executable Alloy specification, which represents the constraints that summarize the given structures. The generated specification is fully executable. For example, the Alloy Analyzer can use it to systematically enumerate a large number of concrete instances that satisfy the same constraints as the given instances. Indeed, a user may use aDeryaft to generate partial specifications while the user writes the rest of the specification by hand. To efficiently generate Alloy specifications, aDeryaft exploits the relational basis of Alloy and formulates graph properties that are likely to hold for the given instances. It then checks the properties for these instances and translates the valid properties into Alloy constraints, which it outputs as an Alloy specification. We illustrate aDeryaft's constraint generation on a variety of commonly used data structures.