130 likes | 149 Views
Learn about formal specification, why it is important, and how to use the Alloy modeling language for precise and automated analysis. Follow a step-by-step tutorial to understand the basics of Alloy specification and checking assertions with the Alloy Analyzer.
E N D
Formal Specification with Alloy http://flic.kr/p/8W2C1k
What are you goingto learn about today? • Formal specification • What? • Why? • Alloy modeling language http://flic.kr/p/8JpkTg
What is formal specification? • Mathematical description (or model) • Extremely precise Z notation
Why formal specification? • Overcomes problems with natural language • NL imprecise • NL ambiguous (has multiple interpretations) • Formal models amenable to • Automated analysis • Proofs
Recall: Iterative development process Formal specification can be used during a variety of tasksHowever, it’s probably most often used in… http://en.wikipedia.org/wiki/File:Iterative_development_model_V2.jpg
Alloy specification language • Model entities and relationships using sets/relations • Model constraints/assertions using first-order logic • Alloy analyzer • Input: Properties of the model • Output: Confirmation or counterexample
Activity: Stepping throughan Alloy tutorial • Tell me what each segment of Alloy spec means • I will draw names at random http://flic.kr/p/5dfuqL
Step 1 sig FSObject { parent: lone Dir } sig Dir extends FSObject { contents: set FSObject } sig File extends FSObject { }
Step 2 sig FSObject { parent: lone Dir } sig Dir extends FSObject { contents: set FSObject } sig File extends FSObject { } fact { all d: Dir, o: d.contents | o.parent = d } fact { File + Dir = FSObject }
Step 3 sig FSObject { parent: lone Dir } sig Dir extends FSObject { contents: set FSObject } sig File extends FSObject { } fact { all d: Dir, o: d.contents | o.parent = d } fact { File + Dir = FSObject } one sig Root extends Dir { } { no parent } fact { FSObject in Root.*contents }
Step 4 sig FSObject { parent: lone Dir } sig Dir extends FSObject { contents: set FSObject } sig File extends FSObject { } fact { all d: Dir, o: d.contents | o.parent = d } fact { File + Dir = FSObject } one sig Root extends Dir { } { no parent } fact { FSObject in Root.*contents } assert acyclic { no d: Dir | d in d.^contents } check acyclic for 5
Step 5 sig FSObject { parent: lone Dir } sig Dir extends FSObject { contents: set FSObject } sig File extends FSObject { } fact { all d: Dir, o: d.contents | o.parent = d } fact { File + Dir = FSObject } one sig Root extends Dir { } { no parent } fact { FSObject in Root.*contents } assert acyclic { no d: Dir | d in d.^contents } check acyclic for 5 assert oneRoot { one d: Dir | no d.parent } check oneRoot for 5 assert oneLocation { all o: FSObject | lone d: Dir | o in d.contents } check oneLocation for 5
Summary • Formal specification with Alloy • Specifying signatures and facts • Checking assertions with the Alloy Analyzer http://flic.kr/p/YSY3X