UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine1 CSE 503 – Software Engineering Lecture 3: An introduction to Alloy Rob DeLine 5 Apr 2004.

Slides:



Advertisements
Similar presentations
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 2.
Advertisements

Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2013 Lecture 4.
– Seminar in Software Engineering Cynthia Disenfeld
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Alloy Vatche Ishakian Boston University- CS511 March/24/2008 Contributors: Andrei Lapets, Michalis Potamias, Mark Reynolds.
Chapter 2 Logic Circuits.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Preliminaries/ Chapter 1: Introduction. Definitions: from Abstract to Linear Algebra.
Algebraic Properties: The Rules of Algebra Be Cool - Follow The Rules!
Boolean Algebra Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
CSE 311 Foundations of Computing I Lecture 6 Predicate Logic, Logical Inference Spring
UML Unified Modeling Language. What is UML? Unified Modeling Language (UML) is a standardized, general-purpose modeling language in the field of software.
Chapter 2 Languages.
Systems of Linear Equation and Matrices
Chap. 2 Matrices 2.1 Operations with Matrices
Inequalities and Proof
By: Hector L Contreras SSGT / USMC
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
Binomial Coefficients, Inclusion-exclusion principle
Computer Science 210 Computer Organization Introduction to Boolean Algebra.
4-2 binary fields and binary vector spaces Special Thanks to Dr. Samir Al-Ghadhban & EE430 Students.
Homework Review notes Complete Worksheet #1. Homework Let A = {a,b,c,d}, B = {a,b,c,d,e}, C = {a,d}, D = {b, c} Describe any subset relationships. 1.
CS6133 Software Specification and Verification
Dr. Shazzad Hosain Department of EECS North South Universtiy Lecture 04 – Part A Knowledge Representation and Reasoning.
1 Bisimulations as a Technique for State Space Reductions.
Logical Database Design (1 of 3) John Ortiz Lecture 6Logical Database Design (1)2 Introduction  The logical design is a process of refining DB schema.
Unit 2, Lesson 2: The Distributive Property and Factoring.
Digraphs and Relations Warm Up. The Divisibility Relation Let “|” be the binary relation on N×N such that a|b (“a divides b”) iff there is an n ∈ N such.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Properties and Mental Computation p. 80. Math talk What are some math properties that we use? Why do you think we have them? Do you ever use them?
CSE 311 Foundations of Computing I Lecture 17 Structural Induction Spring
UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine1 CSE 503 – Software Engineering Lecture 7: Process calculi and refinement Rob DeLine 19 Apr.
CSE 311 Foundations of Computing I Lecture 7 Logical Inference Autumn 2012 CSE
CompSci 102 Discrete Math for Computer Science
Relations and their Properties
Arjav Dave Jitendra Gupta Nishit Shah. Agenda  Overview  Alloy Architecture  Alloy Specification Language  Alloy Analyzer Demo  Comparisons  Conclusion.
Chapter 2 With Question/Answer Animations. Section 2.1.
1.2 Field Axioms (Properties) Notes on a Handout.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
Properties of Algebra (aka all the rules that holds the math together!)
November 2003Computational Morphology III1 CSA405: Advanced Topics in NLP Xerox Notation.
Matrices and Determinants
Strings and Languages Denning, Section 2.7. Alphabet An alphabet V is a finite nonempty set of symbols. Each symbol is a non- divisible or atomic object.
ECE DIGITAL LOGIC LECTURE 6: BOOLEAN ALGEBRA Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 02/01/2016.
§R1∪R2§R1∪R2 §R 1 ∩R 2 R1-R2R1-R2 2.4 Operations on Relations.
CSE-291: Ontologies in Data Integration Department of Computer Science & Engineering University of California, San Diego CSE-291: Ontologies in Data Integration.
1 Chapter 3 Regular Languages.  2 3.1: Regular Expressions (1)   Regular Expression (RE):   E is a regular expression over  if E is one of:
MATRICES. Introduction Matrix algebra has several uses in economics as well as other fields of study. One important application of Matrices is that it.
ALLOY: A Formal Methods Tool Glenn Gordon Indiana University of Pennsylvania COSC 481- Formal Methods Dr. W. Oblitey 26 April 2005.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
1 CS 352 Introduction to Logic Design Lecture 2 Ahmed Ezzat Boolean Algebra and Its Applications Ch-3 + Ch-4.
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
English for Economic Informatics I Tomáš Foltýnek Theoretical Foundations of Informatics.
Alloy Analyzer 4 Tutorial Session 3: Static Modeling Greg Dennis and Rob Seater Software Design Group, MIT.
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
CSE 503 – Software Engineering
Real Numbers, Algebra, and Problem Solving
Basic Logic Gates 1.
CSE 311 Foundations of Computing I
Model the non-negative even integers
Number Properties Magic Book Foldable
Number Properties Magic Book Foldable
Properties of Numbers Lesson 1-3.
CSE 503 – Software Engineering
Presentation transcript:

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine1 CSE 503 – Software Engineering Lecture 3: An introduction to Alloy Rob DeLine 5 Apr 2004

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine2 Where we are Problem frames let us be methodical about the problem Now we’ll be methodical about the system behavior  Explore system behavior before committing to design details  Ensure that the system has desired properties System properties have different flavors  Safety property: “The system does not do something bad.”  Liveness property: “The system (eventually) does something good.”  Functional property: “The system computes what we want.” To explore properties, we formally model the system  A model abstracts some aspect of the system and its environment  Different languages emphasize different types of behavior  Different languages come with different theorems and tools

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine3 Different languages for different properties Explore the structure of the system’s state  Model system state as sets and relations in Alloy  Use Alloy to see if possible state configurations uphold properties Explore states the system can reach through operations  Model system as a state transition system  Use a model checker to see if possible traces uphold properties Explore communication patterns in concurrent systems  Model system as processes exchanging messages  Use a process calculus to prove refinements Explore functional properties of algorithms  Model system state as predicates  Use Hoare logic to prove algorithm’s effect on the system state

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine4 Class schedule For the next four weeks  Monday: the syntax/semantics of the notation, use of the tool  Wednesday: case studies, practice modeling together  Assignments will give you individual practice at modeling Tools  May 5/7: Alloy  May 12/14: Promela/SPIN  May 19/21: CCS and Pi  May 26/28: Hoare logic, plus ESC/Java or Boogie/Spec#

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine5 Alloy is based on relations Basic concepts  Atoms are indivisible, immutable, uninterpreted  Relations are sets of tuples of one or more atoms { (a,x), (b,x), (c,y) } Alloy treats all values uniformly as relations  There’s no syntax in the language for atoms or sets  An “set” is a relation with tuples of size 1: { (a), (b), (c) }  An “atom” or scalar is a relation with one tuple of size 1: { (a) }  You don’t need to worry about undefined values or special cases a b c x y ax bx cy

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine6 Equality of relations { (a), (b) } { (a), (a) } { (a,b) } { (a,b), (c,d) } { (a,b), (a,b) } { (a,a) } { (b), (a) } { (a) } { (b,a) } { (c,d), (a,b) } { (a,b) } { (a) } = = != = =

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine7 “Set” operations { (a), (b) } + { (c), (d) } = { (a,b) } + { (a,b), (c,d) } = { (a), (b) } & { (b), (c) } = { (a,b), (b,b) } & { (a,a), (a,b) } = { (a), (b) } – { (b) } = { (a,b), (b,c) } – { (b,c), (c,d) } = { (a), (b), (c), (d) } { (a,b), (c,d) } { (b) } { (a,b) } { (a) } { (a,b) } Union (+), intersection (&), and difference (-)

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine8 Join: Relational composition General pattern:  Find left tuple that ends in atom that begins right tuple  Concatenate the two tuples, eliminating common atom { (a 1,…,a n ) }. { (a n,…,a m ) } = { (a 1,…,a n-1,a n+1,…,a m ) } Join mimics fields access in languages with records  Let X be an object with an f field X = { (o 1 ) }  Let F be a relation mapping an object to the contents of its f field F = { (o 1,x 1 ), (o 2,x 2 ), (o 3,x 2 ) }  X.F = { (o 1 ) }. { (o 1,x 1 ), (o 2,x 2 ), (o 3,x 2 ) } = { (x 1 ) }  Uniformly lets you get the fields of multiple objects X = { (o 1 ), (o 2 ) } X.F = { (x 1 ), (x 2 ) }

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine9 Join practice { (a) }. { (a,b) } = { (a,b) }. { (b,c) } = { (a) }. { (c,d) } = { (a),(b) }. { (a,c),(b,d),(a,e) } = { (b) } { (a,c) } { } { (c),(d),(e) }

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine10 Cross product { (a) } -> { (b) } = { (a) } -> { (b,c) } = { (a,b) } -> { (c) } = { (a),(b) } -> { (c),(d) } = { (a,b) } { (a,b,c) } { (a,c), (a,d), (b,c), (b,d) } Product R -> S: Concatenate every x in R to every y in S

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine11 Relational operators Transpose (~) reverses the tuples in the set ~ { (a,b), (b,c) } = { (b,a), (c,b) } Transitive closure (^): ^R = limit of R + R.R + R.R.R + … ^ { (a,b), (b,c) } = { (a,b), (b,c), (a,c) } Useful constants  Empty relation:none [e]  Universal relation:univ [e]  Identity relation:iden [e](e is a scalar or set)  Type of the result determined by the type of e Reflexive transitive closure (*): *(S->S) = ^(S->S) + iden [S] * { (a,b), (b,c) } = { (a,a), (a,b), (b,b), (b,c), (c,c), (a,c) }

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine12 Logical operators Negation! Fnot F ConjunctionF && GF and G DisjunctionF || GF or G ImplicationF => GF implies G(! F || G) If then elseF => G,HF implies G else HF=>G && !F=>H Bi-implicationF GF iff GF=>G && G=>F

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine13 Quantifiers all x:e | Funiversal; F is true for every x in e some x:e | Fexistential; F is true for at least one x in e no x:e | F F is true for no x in e sole x:e | F F is true for at most one (and possibly no) x in e one x:e | F F is true for exactly one x in e Several variables can be quantified over at once. E.g., one x:e, y: f | F exactly one way to pick x and y that makes F true If you want the variables to be distinct, use disj: one disj x, y : e | F

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine14 Set comprehensions Set comprehensions construct sets and relations directly from properties. { x:e | F } — the set of atoms x from e for which F holds { x : Person | no x.spouse } is the set of unmarried people Can also use comprehensions to construct relations, by declaring more than one variable { x:e, y: f | F} creates a binary relation.

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine15 Toplevel declarations Alloy provides declarations to organize your specification  module – break your specification into manageable pieces  sig – declare new sets and relations  fact – record axioms about your sets and relations (not checked)  fun – name and abbreviate expressions  assert – write conditions that you want to check Alloy provides commands to invoke its constraint engine  check – try to find a counterexample for an assertion  run – try to find an instance of a function

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine16 Signatures Signatures introduce sets and relations sig Name { /* the set of name atoms */ } sig Person { // new set of person atoms name : Name,// new relation Person -> Name spouse : Person, parents: Person, childWith : Person -> Person } Multiplicity markers add contraints on relations  S m->n T where m and n can be ?zero or one !exactly one +one or more option Person, set Person,

UW CSE 503 ▪ Software Engineering ▪ Spring 2004 ▪ Rob DeLine17 Facts Facts add axioms about your sets and relations fact { all p : Person | p.spouse.spouse = p } It’s handy to add these as part of a sig sig Person { // new set of person atoms name : Name,// new relation Person -> Name spouse : option Person, parents: set Person, childWith : Person -> Person } { // extra block adds facts about “this” this !in spouse }