Expressing set properties in Alloy

Slides:



Advertisements
Similar presentations
Representing Relations
Advertisements

Reflexive example: AB = AB Symmetric example: AB = BA
Binary Relations Binary Relations on Real Numbers.
8.3 Representing Relations. Consider the following relations on A={1,2,3,4} Consider the matrixM R1 = | | | | | | | |
Deductive Reasoning, 2-3 9/1/02 …\sec2_3.ppt.
The Engineering Design of Systems: Models and Methods
Relations - review A binary relation on A is a subset of A×A (set of ordered pairs of elements from A) Example: A = {a,b,c,d,e} R = { (a,a),(a,b),(b,b),(b,c),
Discrete Mathematics Lecture # 16 Inverse of Relations.
1 Representing Relations Part 2: directed graphs.
Relations binary relations xRy on sets x  X y  Y R  X  Y Example: “less than” relation from A={0,1,2} to B={1,2,3} use traditional notation 0 < 1,
Discrete Mathematics Lecture#11.
Relation. Relations Recall the definition of the Cartesian (Cross) Product: The Cartesian Product of sets A and B, A x B, is the set A x B = { : x  A.
Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a.
Module #21 - Relations Representing Relations Rosen 6 th ed., Ch. 8.
Module #18: Relations, part I
Unit Unit 04 Relations IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP1 Unit 4 Relations.
1 ©Amit Mitra & Amar Gupta AGGREGATION Reading Assignment Supplementary module 5 Object Aggregation.
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
Chapter 2 Section 5. Objective  Students will make a connection between reasoning in Algebra and reasoning in Geometry.
CHAPTER 3 FUZZY RELATION and COMPOSITION. 3.1 Crisp relation Product set Definition (Product set) Let A and B be two non-empty sets, the product.
Chapter Thirteen Identity and Philosophical Problems of Symbolic Logic.
Section 4.4 Properties of Relations. Order Relations Draw an arrow diagram for the relation R defined on the set {1,2,3,4} such that
CS 103 Discrete Structures Lecture 19 Relations. Chapter 9.
Discrete Mathematics Lecture # 15 Types of Relations (contd.)
Chapter Relations and Their Properties
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
Chapter 4.2 Notes: Apply Congruence and Triangles
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Lesson 3: Properties Algebra 1 CP Mrs.Mongold. Identity and Equality Properties Additive Identity- any number plus zero equals that number.
Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and B = {a,b} {( 0, a), (
Section 7.3: Representing Relations In this section, we will cover two ways to represent a relation over a finite set other than simply listing the relation.
Relational Proposition. Definitions of 2 Basic Key Concepts 1.What is a Proposition? A proposition is a statement that may either be true or false 2.A.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 41 May 7, 2008.
Lecture 7: Relations Dr Andrew Purkiss-Trew Cancer Research UK Mathematics for Computing.
Module Code MA1032N: Logic Lecture for Week Autumn.
1.3 Properties of Numbers 8/24/16. Common Core State Standards Interpret complicated expressions by viewing one or more of their parts as a single entity.
Using Alloy to Design a Safe Traffic Light System
Relations and Their Properties
4.2-Congruence & Triangles
Chapter 2 Sets Homework 3 Given U = { 1, 2, 3, 4, 5, 6, 7, 8, 9 } as a set universe and the sets : A = { 1, 2, 3, 4, 5 }, B = { 4, 5, 6, 7 }, C = { 5,
Model Land and Seafloor Surfaces using Alloy
Navigating through Alloy relations
Using Alloy to Solve the Einstein Puzzle
Relations and Their Properties
8.1 Relations and Their Properties
Chapter 4.2 Notes: Apply Congruence and Triangles
Model the non-negative even integers
Each hotel guest has a set of keys and no two guests have the same key
Modeling Inference Rules
Use Alloy to model and find a solution to the Farmer, Goat, Cabbage, and Wolf problem Roger L. Costello July 14, 2018.
Multiple Inheritance Roger L. Costello March 24, 2018.
2.6 Proving Statements about Angles
NAME THAT PROPERTY! For each of the equations below,
Introduction to Relations and Functions
Sculpting Alloy Models
Standard: MCC9-12.A.REI.1 – Explain each step in solving a simple equation as following from the equality of numbers asserted at the previous step,
Encapsulation in Alloy
Congruence and Triangles
Desktop model Roger L. Costello March 24, 2018 Desktop0 Desktop1
Apply Congruence and Triangles:
2.6 Proving Statements about Angles
Expressing set properties in Alloy
Model Land and Seafloor Surfaces using Alloy (Part 3)
The root cause of all security failures
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
How to create easy-to-read Alloy models
Lecture # 16 Inverse of Relations
Relations 12/7/2019.
4.4 Properties of Relations
Presentation transcript:

Expressing set properties in Alloy Roger L. Costello March 10, 2018

Want to learn sets? Learn Alloy! Want to learn Alloy? Learn sets! Certain properties of binary relations are so frequently encountered that they have been given names, including reflexive, symmetric, transitive, and connected. All these apply only to relations in a set, i.e., in A x A, not to relations from A to B.

Reflexive property Given a set A and a relation R in A, R is reflexive if and only if all the ordered pairs of the form (x, x) are in R for every x in A. Example: Take the set A = { 1, 2, 3 } and the relation R1 = { (1,1), (1,2), (2,2), (2,3), (3,3), (3,1) } in A. R1 is reflexive because it contains the ordered pairs (1,1), (2,2), and (3,3). 1 2 3

Each person has the same birthday as themself Take the set A = the set of human beings and the relation R2 = ‘has the same birthday’. R2 is reflexive because it contains the ordered pairs: Roger Costello has the same birthday as Stan Efferding. Roger Costello has the same birthday as Roger Costello. Stan Efferding has the same birthday as Roger Costello. Stan Efferding has the same birthday as Stan Efferding. … R2 = { (Roger Costello, Stan Efferding), (Roger Costello, Roger Costello), (Stan Efferding, Roger Costello), (Stan Efferding, Stan Efferding), … }

Alloy expression that constrains pairs of elem atoms to be reflexive sig A {} sig Test { R: A -> A } { (A <: iden) in R // Constrain R to be reflexive } assert isReflexive { all x: A | (x -> x) in Test.R } check isReflexive

iden sig A {} sig Test { R: A -> A } { (A <: iden) in R // Constrain R to be reflexive } assert isReflexive { all x: A | (x -> x) in Test.R } check isReflexive Test0 A0 A1 A2

Reflexive Transitive Symmetric Connected Nonsymmetric Nonreflexive 1 2 3 4 1 2 3 4 5 6 7 8 1 2 3 1 2 3 Nonsymmetric Nonreflexive Nontransitive Nonconnected 1 2 3 1 2 3 4 1 2 3 1 2 3 4 5 6 7 8 Intransitive Asymmetric Irreflexive 1 2 3 4 1 2 3 1 2 3

Injective Functional Not Injective Not Functional 1 2 1 2 3 4 3 5 1 2

The ordering module We have used the ordering module to order sets, e.g., open util/ordering[Snapshot] // Order the set of Snapshots in the goat, cabbage, wolf model open util/ordering[House] // Order the set of Houses in the Einstein model open util/ordering[Desktop] // Order the set of Desktops in the Desktop model

The ordering module creates ordered pairs from your set When the ordering module is called with a set then all these functions are suddenly available on the set: first, last, next. first returns the first atom. last returns the last atom. next returns a set of pairs, such as this: next first returns the first Snapshot first.next returns the second Snapshot first.next.next returns the third Snapshot And so forth Snapshot0 Snapshot1 Snapshot1 Snapshot2 Snapshot2 Snapshot3

next: Snapshot Snapshot1 Snapshot3 Snapshot2 Snapshot0 Ordering Module first last next: Snapshot0 Snapshot1 Snapshot2 Snapshot3

Which of these properties do we want the relation (ordered pairs) to have? 1 2 3 Reflexive Transitive Symmetric 4 5 6 7 8 Connected Nonreflexive Irreflexive Nontransitive Intransitive Nonsymmetric Asymmetric Nonconnected

Which of these properties do we want the relation (ordered pairs) to have? 1 2 3 Reflexive Transitive Symmetric 4 5 6 7 8 Connected Nonreflexive Irreflexive Nontransitive Intransitive Nonsymmetric Asymmetric Nonconnected

Injective Functional Not Injective Not Functional 1 2 1 2 3 4 3 5 1 2

sig A {} one sig Ord { First: A, Next: A -> A } { no x: A | (x -> First) in Next // First is the first atom in the list irreflexive [A, Next] // Constrain Next to be irreflexive intransitive [A, Next] // Constrain Next to be intransitive asymmetric [A, Next] // Constrain Next to be asymmetric nonconnected [A, Next] // Constrain Next to be non-connected injective [A, Next] // Constrain Next to be injective functional [A, Next] // Constrain Next to be functional #Next = minus[#A, 1] // Constraint Next to contain all atoms in A }

Hold on! The ordering module also creates a prev function The prev function allows you to traverse to the previous atom in the list. The below graphic is not accurate, how should it be changed? first last next: Snapshot0 Snapshot1 Snapshot2 Snapshot3

Arrows must go both directions first last next Snapshot0 Snapshot1 Snapshot2 Snapshot3 prev

Now which of these properties do we want the relation (ordered pairs) to have? 1 2 3 Reflexive Transitive Symmetric 4 5 6 7 8 Connected Nonreflexive Irreflexive Nontransitive Intransitive Nonsymmetric Asymmetric Nonconnected

Which of these properties do we want the relation (ordered pairs) to have? 1 2 3 Reflexive Transitive Symmetric 4 5 6 7 8 Connected Nonreflexive Irreflexive Nontransitive Intransitive Nonsymmetric Asymmetric Nonconnected

Injective Functional Not Injective Not Functional 1 2 1 2 3 4 3 5 1 2

irreflexive [A, Next] // Constrain Next to be irreflexive sig A {} one sig Ord { First: A, Next: A -> A } { no x: A | (x -> First) in Next // First is the first atom in the list irreflexive [A, Next] // Constrain Next to be irreflexive intransitive [A, Next] // Constrain Next to be intransitive symmetric [A, Next] // Constrain Next to be symmetric nonconnected [A, Next] // Constrain Next to be non-connected injective [A, Next] // Constrain Next to be injective functional [A, Next] // Constrain Next to be functional #Next = minus[#A, 1] // Constraint Next to contain all atoms in A } Do Labs 5,6