![Page 1: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/1.jpg)
PART 2: SYMMETRIC DELTA LENSES
BX with Triple Graph Grammars
![Page 2: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/2.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Delta Propagation
2
A Br
A'
a7!fpg
B'
b
r'
Nodes are models, arrows are deltas,
dashed outline indicates derived elements
forward propagation “completes the square”
Note: This is NOT a pushout square!
![Page 3: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/3.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Delta Propagation
3
A Br
A'
a7!fpg
B'
b
r'
A B
A'
r
a
7!bpg
B'
b
r'
Nodes are models, arrows are deltas,
dashed outline indicates derived elements
this (model synchronisation) is of course a simplification — we’ll have to deal with concurrent delta propagation
one day (model integration)
![Page 4: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/4.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Symmetric Delta Lenses (SDL)
4
Nodes are sets, arrows are total functions
AR ! B
… with all incidence conditions indicated on previous slide
pair of fpg and bpg functions forms a “lens” shape
(with some imagination)
MA MB�ABsrc trg
srcA
trgA trgB
srcB
�B�A
�AB ⇥�A
�AB ⇥�B
fpg
bpg
![Page 5: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/5.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Specifying SDLs
5
AR ! B given a triple space, how do
we specify an SDL?
Idea 1: Enumerate all squares:
A Br
A'
a7!fpg
B'
b
r'
A B
A'
r
a
7!bpg
B'
b
r'
![Page 6: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/6.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Exhaustive Enumeration
6
:DosagePlan
name = "Springfield General Hospital"
:Hospital :HospitalToDosagePlan
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
source target
![Page 7: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/7.jpg)
:DosagePlan
name = "Springfield General Hospital"
:Hospital :HospitalToDosagePlan
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
source target
name = "Springfield General Hospital"
:Hospital
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
prescribed
7!fpg
:DosagePlan:HospitalToDosagePlan
Brand = Ascriptin:Dosage
dosages
:MedicationToDosage
source
source
target
target
![Page 8: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/8.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Exhaustive enumeration
8
Idea 1: Enumerate all squares:
not really feasible… but why not?
we typically have infinitely many such squares
A Br
A'
a7!fpg
B'
b
r'
A B
A'
r
a
7!bpg
B'
b
r'
![Page 9: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/9.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Simultaneous, exhaustive enumeration
9
Idea 2: Enumerate all squares representing
combined fpg and bpg squares
A B
A'
r
a7!
fpg
B'
b
r'
7!bpg
![Page 10: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/10.jpg)
:DosagePlan
name = "Springfield General Hospital"
:Hospital :HospitalToDosagePlan
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
source target
name = "Springfield General Hospital"
:Hospital
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
prescribed
:DosagePlan:HospitalToDosagePlan
Brand = Ascriptin:Dosage
dosages
:MedicationToDosage
source
source
target
target
7!fpg
7!bpg
![Page 11: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/11.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
:DosagePlan:HospitalToDosagePlan
Brand = Ascriptin:Dosage
dosages
:MedicationToDosage
source
source
target
target
name = "Springfield General Hospital"
:Hospital
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
prescribed
Simultaneous, exhaustive enumeration
11
:DosagePlan
name = "Springfield General Hospital"
:Hospital :HospitalToDosagePlan
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
prescribedBrand = Ascriptin
:Dosage
dosages
:MedicationToDosage
source
source
target
target
:DosagePlan
name = "Springfield General Hospital"
:Hospital :HospitalToDosagePlan
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
source target
let’s use green (and red) to merge both corners of the square now in a single diagram
![Page 12: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/12.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Simultaneous, exhaustive enumeration
12
Idea 2: Enumerate all squares representing
combined fpg and bpg squares
A B
A'
r
a7!
fpg
B'
b
r'
7!bpg
still infeasible, but quite a nice idea…
Why?
• promotes “symmetrical” thinking and avoids favouring either fpg or bpg
• easier to enforce “good” lens specifications • we obviously only have to enumerate half of
all squares (still typically infinitely many)
![Page 13: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/13.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Simultaneous rules
13
Idea 3: specify infinitely many deltas using finitely many rules
(precondition and postcondition graph patterns)
![Page 14: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/14.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Simultaneous rules
14
:DosagePlan
name = "Springfield General Hospital"
:Hospital :HospitalToDosagePlan
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
prescribedBrand = Ascriptin
:Dosage
dosages
:MedicationToDosage
source
source
target
target
we just have to represent these concrete values as variables
![Page 15: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/15.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Simultaneous rules
15
:DosagePlan:Hospital :HospitalToDosagePlan
:Patient
:Doctor :Aspirin
patients
doctors
patients
pharmaceuticals
prescribedBrand = Ascriptin
:Dosage
dosages
:MedicationToDosage
source
source
target
target
why do we care about the doctor?
we should not fix the mapping to a brand
![Page 16: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/16.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Simultaneous rules
16
:DosagePlan:Hospital :HospitalToDosagePlan
:Patient
:Aspirin
patients
pharmaceuticals
prescribed
:Dosage
dosages
:MedicationToDosage
source
source
target
target
![Page 17: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/17.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Simultaneous rules
17
Idea 3: specify infinitely many deltas using finitely many rules
(precondition and postcondition graph patterns)
very important idea, as we’ve finally made the jump
to a finite specification
specifying all deltas this way is still a lot of work …
![Page 18: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/18.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Simultaneous, monotonic rules
18
Idea 4: only specify monotonic rules, i.e., only
describing purely creating deltas
:DosagePlan:Hospital :HospitalToDosagePlan
:Patient
:Aspirin
patients
pharmaceuticals
prescribed
:Dosage
dosages
:MedicationToDosage
source
source
target
target
composite deltas are decomposed into steps we
know how to deal with
deletion is handled by “rolling back” rule applications
![Page 19: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/19.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
:DosagePlan
name = "Springfield General Hospital"
:Hospital :HospitalToDosagePlan
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
source target
m
:DosagePlan:Hospital :HospitalToDosagePlan
:Patient
:Aspirin
patients
pharmaceuticals
source target :DosagePlan:Hospital :HospitalToDosagePlan
:Patient
:Aspirin
patients
pharmaceuticals
prescribed
:Dosage
dosages
:MedicationToDosage
source
source
target
target
p
Concrete deltas are derived via rule application
19
:DosagePlan
name = "Springfield General Hospital"
:Hospital :HospitalToDosagePlan
name = "Lisa":Patient
name = "Nick Riviera":Doctor
:Aspirin
patients
doctors patientspharmaceuticals
prescribed
:Dosage
dosages
:MedicationToDosage
source
source
target
target
m’
p’
precondition (LHS)
postcondition (RHS)
rule (production)
match (morphism)
host graph
result is constructed via a disjoint union of the RHS and host graph, and a subsequent
gluing of all elements with common image in the LHS
described creating delta
![Page 20: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/20.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Concrete deltas are derived via rule application
20
L R
G
p
m PO
G'
m'
p'this construction is a pushout
in the category of (typed, attributed) triple graphs and
triple graph morphisms
Nodes are triple graphs, arrows are triple graph morphisms
all you need to know: rule application is formal, always possible,
and is unique up to isomorphisms
![Page 21: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/21.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Implicit ignore rules
21
Idea 5: derive some “boring” rules by convention, i.e.,
assume they are specified implicitly
:DosagePlan:Hospital :HospitalToDosagePlan
source targetp1:
:DosagePlan:Hospital :HospitalToDosagePlan
:Patient
:Aspirin
patients
pharmaceuticals
prescribed
:Dosage
dosages
:MedicationToDosage
source
source
target
target
p2:
+:Patient
:Doctor
:Aspirin
p3:
p4:
p5:
:Hospital
:Patient
patients
:Hospital
:Doctor
doctors
:Hospital
:Aspirin
pharmaceuticals
:Doctor
:Patient
patients
p6 p7 p8 p9
for every element in the metamodel, that is not created by any rule
derive a minimal rule to create every object
and a minimal rule to create every link
these rules are called ignore rules as they are
only in one domain
![Page 22: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/22.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
From Triple Graph Grammars to Lenses
22
+MediSoft MediSupply
R
:DosagePlan:Hospital :HospitalToDosagePlan
source target
:DosagePlan:Hospital :HospitalToDosagePlan
:Patient
:Aspirin
patients
pharmaceuticals
prescribed
:Dosage
dosages
:MedicationToDosage
source
source
target
target
p1:
p2:
… and a finite set of monotonic, simultaneous triple rules, i.e., a
triple graph grammar
user supplies a triple space (via a triple of metamodels)
![Page 23: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/23.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
From Triple Graph Grammars to Lenses
23
+
MediSoft MediSupplyR
:DosagePlan:Hospital :HospitalToDosagePlan
source target
:DosagePlan:Hospital :HospitalToDosagePlan
:Patient
:Aspirin
patients
pharmaceuticals
prescribed
:Dosage
dosages
:MedicationToDosage
source
source
target
target
p1:
p2:
eMoflon
fpgbpg
a TGG tool does some “magic”
and produces a symmetric delta lens!
coming up: we’ll take a closer look at the “magic” involved and some formal properties used to control it
![Page 24: BX with Triple Graph Grammars PART 2: SYMMETRIC DELTA … · Anthony Anjorin: An Introduction To Triple Graph Grammars Symmetric Delta Lenses (SDL) 4 Nodes are sets, arrows are total](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76ee2b1a67261d6a1b0a3d/html5/thumbnails/24.jpg)
Anthony Anjorin: An Introduction To Triple Graph Grammars
Task 2: Your first Triple Graph Grammar
24
1. Install VirtualBox from www.virtualbox.org
2. Download this VM: https://db.tt/gYgQMShZ
3. Open VM, start Eclipse with shortcut on desktop
4. Choose workspaces/task2 as your workspace
5. Follow instructions from https://db.tt/g9uGurIs