diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..fa782b8
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..bc9dc65
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..7816306
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..748a0cc
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/.classpath b/AlgebraicDataflowArchitectureModel/.classpath
index 3e99697..9d5db7b 100644
--- a/AlgebraicDataflowArchitectureModel/.classpath
+++ b/AlgebraicDataflowArchitectureModel/.classpath
@@ -1,12 +1,13 @@
+
-
+
diff --git a/AlgebraicDataflowArchitectureModel/.settings/org.eclipse.jdt.core.prefs b/AlgebraicDataflowArchitectureModel/.settings/org.eclipse.jdt.core.prefs
index 263a512..d0dc81b 100644
--- a/AlgebraicDataflowArchitectureModel/.settings/org.eclipse.jdt.core.prefs
+++ b/AlgebraicDataflowArchitectureModel/.settings/org.eclipse.jdt.core.prefs
@@ -1,9 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=13
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=14
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=13
+org.eclipse.jdt.core.compiler.compliance=14
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -12,4 +12,4 @@
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
-org.eclipse.jdt.core.compiler.source=13
+org.eclipse.jdt.core.compiler.source=14
diff --git a/AlgebraicDataflowArchitectureModel/AlgebraicDataflowArchitectureModel.iml b/AlgebraicDataflowArchitectureModel/AlgebraicDataflowArchitectureModel.iml
new file mode 100644
index 0000000..0d73431
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/AlgebraicDataflowArchitectureModel.iml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Accounts.model b/AlgebraicDataflowArchitectureModel/models/Accounts.model
new file mode 100644
index 0000000..24710ee
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/Accounts.model
@@ -0,0 +1,7 @@
+channel CIO1 {
+ out accounts(l:List, signup(name:Str)) = append(l, {"name": name})
+}
+
+channel CIO2(uid:Int) {
+ out accounts.{uid}.name(n:Str, changeName(name)) = name
+}
diff --git a/AlgebraicDataflowArchitectureModel/models/Algo.model b/AlgebraicDataflowArchitectureModel/models/Algo.model
deleted file mode 100644
index 6228431..0000000
--- a/AlgebraicDataflowArchitectureModel/models/Algo.model
+++ /dev/null
@@ -1,12 +0,0 @@
-channel turnA{
- ref handsB(b:List, drawA(target:Int, guess:Int, b, d))
- ref deck(d:List, drawA(target, guess, b, d))
- out handsA(a:List, drawA(target, guess, b, d)) == if(eq(get(b, target), guess), cons(tuple(fst(head(d)), false), a), cons(tuple(fst(head(d)), true), a))
- out handsB(a:List, drawA(target, guess, b, d)) == if(eq(get(b, target), guess), set(a, target, tuple(fst(get(a, target)), true)), a)
- out deck(t:List, drawA(target, guess, b, d)) == tail(d)
-}
-channel turnAA{
- ref handsB(b:List, selectA(target:Int, guess:Int, attacker:Int, b))
- out handsA(a:List, selectA(target, guess, attacker, b)) == if(eq(get(b, target), guess), a, set(a, attacker, tuple(fst(get(a, attacker)), true)))
- out handsB(a:List, selectA(target, guess, attacker, b)) == if(eq(get(b, target), guess), set(a, target, tuple(fst(get(a, target)), true)), a)
-}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Algolike.model b/AlgebraicDataflowArchitectureModel/models/Algolike.model
index 97aef04..8ea8dc2 100644
--- a/AlgebraicDataflowArchitectureModel/models/Algolike.model
+++ b/AlgebraicDataflowArchitectureModel/models/Algolike.model
@@ -6,25 +6,25 @@
guessB := 0
}
channel targetAInput{
- out targetA(t:Int, setTargetA(a:Int)) == a
+ out targetA(t:Int, setTargetA(a:Int)) = a
}
channel targetBInput{
- out targetB(t:Int, setTargetB(b:Int)) == b
+ out targetB(t:Int, setTargetB(b:Int)) = b
}
channel attackerAInput{
- out attackerA(t:Int, setAttackerA(a:Int)) == a
+ out attackerA(t:Int, setAttackerA(a:Int)) = a
}
channel attackerBInput{
- out attackerB(t:Int, setAttackerB(b:Int)) == b
+ out attackerB(t:Int, setAttackerB(b:Int)) = b
}
channel guessAInput{
- out guessA(t:Int, setGuessA(a:Int)) == a
+ out guessA(t:Int, setGuessA(a:Int)) = a
}
channel guessBInput{
- out guessB(t:Int, setGuessB(b:Int)) == b
+ out guessB(t:Int, setGuessB(b:Int)) = b
}
channel addDeck{
- out deck(d:List, addCard(num:Integer)) == cons(tuple(num, false), d)
+ out deck(d:List, addCard(num:Integer)) = cons(tuple(num, false), d)
}
channel drawAInput{
@@ -32,21 +32,21 @@
ref targetA(t:Int, drawAndAttackA(t, g, b))
ref guessA(g:Int, drawAndAttackA(t, g, b))
ref handsB(b:List, drawAndAttackA(t, g, b))
- out resultByDrawingA(sda:Tuple, drawAndAttackA(t, g, b)) == tuple(eq(fst(get(b, t)), g), t)
+ out resultByDrawingA(sda:Tuple, drawAndAttackA(t, g, b)) = tuple(fst(get(b, t)) == g, t)
}
channel inputDrawArgsA{
- in resultByDrawingA(sda:Tuple, drawA(sucTrg, d)) == sucTrg
+ in resultByDrawingA(sda:Tuple, drawA(sucTrg, d)) = sucTrg
ref deck(d:List, drawA(sucTrg, d))
- out handsA(outA:List, drawA(sucTrg, d)) == if(fst(sucTrg),
- sortByKey(cons(tuple(fst(head(d)),false), outA)),
+ out handsA(outA:List, drawA(sucTrg, d)) = if(fst(sucTrg),
+ sortByKey(cons(tuple(fst(head(d)), false), outA)),
sortByKey(cons(tuple(fst(head(d)), true), outA)))
- out handsB(outB:List, drawA(sucTrg, d)) == if(fst(sucTrg),
+ out handsB(outB:List, drawA(sucTrg, d)) = if(fst(sucTrg),
set(outB, snd(sucTrg), tuple(fst(get(outB, snd(sucTrg))), true)),
outB)
- out deck(t:List, drawA(sucTrg, d)) == tail(t)
+ out deck(t:List, drawA(sucTrg, d)) = tail(t)
}
channel selectAInput{
@@ -54,14 +54,14 @@
ref targetA(t:Int, selectAndAttackA(a, t, g, b))
ref guessA(g:Int, selectAndAttackA(a, t, g, b))
ref handsB(b:List, selectAndAttackA(a, t, g, b))
- out resultBySelectingA(ssa:Tuple, selectAndAttackA(a, t, g, b)) == tuple(eq(fst(get(b, t)), g), t, a)
+ out resultBySelectingA(ssa:Tuple, selectAndAttackA(a, t, g, b)) = tuple(fst(get(b, t)) == g, t, a)
}
channel inputSelectArgA{
- in resultBySelectingA(ssa, selectA(sucTrgAtk)) == sucTrgAtk
- out handsA(outA, selectA(sucTrgAtk)) == if(fst(sucTrgAtk),
+ in resultBySelectingA(ssa, selectA(sucTrgAtk)) = sucTrgAtk
+ out handsA(outA, selectA(sucTrgAtk)) = if(fst(sucTrgAtk),
outA,
set(outA, snd(snd(sucTrgAtk)), tuple(fst(get(outA, snd(snd(sucTrgAtk)))), true)))
- out handsB(outB, selectA(sucTrgAtk)) == if(fst(sucTrgAtk),
+ out handsB(outB, selectA(sucTrgAtk)) = if(fst(sucTrgAtk),
set(outB, fst(snd(sucTrgAtk)), tuple(fst(get(outB, fst(snd(sucTrgAtk)))), true)),
outB)
}
@@ -69,21 +69,21 @@
ref targetB(t:Int, drawAndAttackB(t, g, a))
ref guessB(g:Int, drawAndAttackB(t, g, a))
ref handsA(a:List, drawAndAttackB(t, g, a))
- out resultByDrawingB(sdb:Tuple, drawAndAttackB(t, g, a)) == tuple(eq(fst(get(a, t)), g), t)
+ out resultByDrawingB(sdb:Tuple, drawAndAttackB(t, g, a)) = tuple(fst(get(a, t)) == g, t)
}
channel inputDrawArgsB{
- in resultByDrawingB(sdb:Tuple, drawB(sucTrg, d)) == sucTrg
+ in resultByDrawingB(sdb:Tuple, drawB(sucTrg, d)) = sucTrg
ref deck(d:List, drawB(sucTrg, d))
- out handsB(outB:List, drawB(sucTrg, d)) == if(fst(sucTrg),
+ out handsB(outB:List, drawB(sucTrg, d)) = if(fst(sucTrg),
sortByKey(cons(tuple(fst(head(d)),false), outB)),
sortByKey(cons(tuple(fst(head(d)), true), outB)))
- out handsA(outA:List, drawB(sucTrg, d)) == if(fst(sucTrg),
+ out handsA(outA:List, drawB(sucTrg, d)) = if(fst(sucTrg),
set(outA, snd(sucTrg), tuple(fst(get(outA, snd(sucTrg))), true)),
outA)
- out deck(t:List, drawB(sucTrg, d)) == tail(t)
+ out deck(t:List, drawB(sucTrg, d)) = tail(t)
}
channel selectBInput{
@@ -91,23 +91,23 @@
ref targetB(t:Int, selectAndAttackB(atk, t, g, a))
ref guessB(g:Int, selectAndAttackB(atk, t, g, a))
ref handsA(a:List, selectAndAttackB(atk, t, g, a))
- out resultBySelectingB(ssb:Tuple, selectAndAttackB(atk, t, g, a)) == tuple(eq(fst(get(a, t)), g), t, atk)
+ out resultBySelectingB(ssb:Tuple, selectAndAttackB(atk, t, g, a)) = tuple(fst(get(a, t)) == g, t, atk)
}
channel inputSelectArgB{
- in resultBySelectingB(ssb, selectB(sucTrgAtk)) == sucTrgAtk
- out handsB(outB, selectB(sucTrgAtk)) == if(fst(sucTrgAtk),
+ in resultBySelectingB(ssb, selectB(sucTrgAtk)) = sucTrgAtk
+ out handsB(outB, selectB(sucTrgAtk)) = if(fst(sucTrgAtk),
outB,
set(outB, snd(snd(sucTrgAtk)), tuple(fst(get(outB, snd(snd(sucTrgAtk)))), true)))
- out handsA(outA, selectB(sucTrgAtk)) == if(fst(sucTrgAtk),
+ out handsA(outA, selectB(sucTrgAtk)) = if(fst(sucTrgAtk),
set(outA, fst(snd(sucTrgAtk)), tuple(fst(get(outA, fst(snd(sucTrgAtk)))), true)),
outA)
}
channel judgeA{
- in handsA(a:List, judge(j)) == j
- out loseA(la:Bool, judge(j)) == eq(length(extractFaceDown(j)), 0)
+ in handsA(a:List, judge(j)) = j
+ out loseA(la:Bool, judge(j)) = length(extractFaceDown(j)) == 0
}
channel judgeB{
- in handsB(b:List, judge(j)) == j
- out loseB(lb:Bool, judge(j)) == eq(length(extractFaceDown(j)), 0)
+ in handsB(b:List, judge(j)) = j
+ out loseB(lb:Bool, judge(j)) = length(extractFaceDown(j)) == 0
}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Base.model b/AlgebraicDataflowArchitectureModel/models/Base.model
index ac44843..bb460e4 100644
--- a/AlgebraicDataflowArchitectureModel/models/Base.model
+++ b/AlgebraicDataflowArchitectureModel/models/Base.model
@@ -1,13 +1,13 @@
channel CIO{
- out r1(x1:Int, set1(y1:Int)) == y1
- out r1(x1, e) == x1
+ out r1(x1:Int, set1(y1:Int)) = y1
+ out r1(x1, e) = x1
}
channel CIO2{
- out r2(x2:Int, set2(y2:Int)) == y2
- out r2(x2, e) == x2
+ out r2(x2:Int, set2(y2:Int)) = y2
+ out r2(x2, e) = x2
}
channel C1{
- in r1(x1, update(x1:Int, y1:Int, x2:Int, y2:Int)) == y1
- in r2(x2, update(x1, y1, x2, y2)) == y2
- out r3(x3:Int, update(x1, y1, x2, y2)) == x1 + y1 + x2 + y2
+ in r1(x1, update(x1:Int, y1:Int, x2:Int, y2:Int)) = y1
+ in r2(x2, update(x1, y1, x2, y2)) = y2
+ out r3(x3:Int, update(x1, y1, x2, y2)) = x1 + y1 + x2 + y2
}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Bug.model b/AlgebraicDataflowArchitectureModel/models/Bug.model
deleted file mode 100644
index f31727b..0000000
--- a/AlgebraicDataflowArchitectureModel/models/Bug.model
+++ /dev/null
@@ -1,7 +0,0 @@
-channel CIO{
- out aUa(a, input(x:Int)) == x
-}
-channel C1{
- in aUa(a, update(x)) == x
- out aUb(b, update(x)) == x + 3
-}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Citrus.model b/AlgebraicDataflowArchitectureModel/models/Citrus.model
new file mode 100644
index 0000000..bcea2b2
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/Citrus.model
@@ -0,0 +1,75 @@
+channel Signup {
+ out accounts(accDB:Map, signup(aid:Str)) = insert(accDB, aid, {"favorites": nil, "books": nil})
+}
+
+channel CreateBook(aid:Str) {
+ out accounts.{aid}.books(bookList:List, createBook(title:Str)) = append(bookList, {"title": title, "todos": nil, "favorited": nil})
+}
+
+channel DeleteAccount {
+ out accounts(accDB:Map, deleteAccount(aid:Str)) = if(contains(accDB, aid), delete(accDB, aid), accDB)
+}
+
+channel ChangeAccountName {
+ out accounts(accDB:Map, changeAccountId(aid:Str, newAid:Str)) = if(aid == newAid, accDB, delete(insert(accDB, newAid, lookup(accDB, aid)), aid))
+}
+
+channel ChangeBookName(aid:Str, bid:Int) {
+ out accounts.{aid}.books.{bid}.title(title:Str, changeBookName(newTitle)) = newTitle
+}
+
+channel DeleteBook(aid:Str) {
+ out accounts.{aid}.books(bookList:List, deleteBook(bid:Int)) = if(bid < length(bookList), remove(bookList, bid), bookList)
+}
+
+channel CreateToDo(aid:Str, bid:Int) {
+ out accounts.{aid}.books.{bid}.todos(toDoDB:Map, createtodo(year:Str, month:Str, day:Str, title:Str)) =
+ if(
+ contains(toDoDB,year),
+ if(
+ contains(lookup(toDoDB,year),month),
+ if(
+ contains(lookup(lookup(toDoDB,year),month),day),
+ insert(toDoDB,year,insert(lookup(toDoDB,year),month,insert(lookup(lookup(toDoDB,year),month),day,append(lookup(lookup(lookup(toDoDB,year),month),day),{"title":title,"check":false})))),
+ insert(toDoDB,year,insert(lookup(toDoDB,year),month,insert(lookup(lookup(toDoDB,year),month),day,append(nil,{"title":title,"check":false}))))
+ ),
+ insert(toDoDB,year,insert(lookup(toDoDB,year),month,insert(nil,day,append(nil,{"title":title,"check":false}))))
+ ),
+ insert(toDoDB,year,insert(nil,month,insert(nil,day,append(nil,{"title":title,"check":false}))))
+ )
+}
+
+channel ChangeToDoName(aid:Str, bid:Int, year:Str, month:Str, day:Str, tid:Int) {
+ out accounts.{aid}.books.{bid}.todos.{year}.{month}.{day}.{tid}.title(title:Str, changeToDoName(newTitle)) = newTitle
+}
+
+channel ChangeCheck(aid:Str, bid:Int, year:Str, month:Str, day:Str, tid:Int) {
+ out accounts.{aid}.books.{bid}.todos.{year}.{month}.{day}.{tid}.check(check:Bool, changeCheck(newCheck)) = newCheck
+}
+
+channel DeleteToDo(aid:Str, bid:Int) {
+ out accounts.{aid}.books.{bid}.todos(toDoDB:Map, deleteToDo(year:Str, month:Str, day:Str, tid:Int)) = insert(toDoDB,
+ year,
+ insert(lookup(toDoDB, year),
+ month,
+ insert(lookup(lookup(toDoDB, year), month),
+ day,
+ remove(lookup(lookup(lookup(toDoDB, year), month), day),
+ tid))))
+}
+
+channel AddFavorited(aid:Str, bid:Int) {
+ out accounts.{aid}.books.{bid}.favorited(faList:List, addFavorited(o_aid:Str)) = if(aid==o_aid,
+ faList,
+ if(contains(faList, o_aid),
+ remove(faList, indexOf(faList, o_aid)),
+ append(faList, o_aid)))
+ out accounts.{o_aid}.favorites(aDB:Map, addFavorited(o_aid:Str))
+ = if(aid==o_aid,
+ aDB,
+ if(contains(aDB, aid),
+ if(contains(lookup(aDB, aid), bid),
+ insert(aDB, aid, remove(lookup(aDB, aid), indexOf(lookup(aDB, aid), bid))),
+ insert(aDB, aid, append(lookup(aDB, aid), bid))),
+ insert(aDB, aid, append(nil, bid))))
+}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Clock.dtram b/AlgebraicDataflowArchitectureModel/models/Clock.dtram
new file mode 100644
index 0000000..bbeb6dc
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/Clock.dtram
@@ -0,0 +1,27 @@
+model {
+channel CIO1 {
+ out min(m: Int, tick) = (m + 1) % 60
+}
+channel HourUpdate {
+ in hour(h: Int, update(h2)) = h2
+ out hour_ang(h_ang: Double, update(h2)) = h2 / 6 * PI
+}
+channel MinUpdate {
+ in min(m, update(m2)) = m2
+ out min_ang(m_ang: Double, update(m2)) = m2 / 30 * PI
+}
+channel Clock {
+ in min(m, update(m2)) = m2
+ out hour(h, update(m2)) = if(m2 == 0, (h + 1) % 24, h)
+}
+}
+geometry {
+ node c HourUpdate:520,340,30,30
+ node c MinUpdate:520,100,30,30
+ node c Clock:280,220,30,30
+ node r min_ang:670,100,80,30
+ node r min:250,100,80,30
+ node r hour:270,340,80,30
+ node r hour_ang:680,340,80,30
+ node ioc CIO1:100,100,30,30
+}
diff --git a/AlgebraicDataflowArchitectureModel/models/Clock.model b/AlgebraicDataflowArchitectureModel/models/Clock.model
new file mode 100644
index 0000000..0ecb11b
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/Clock.model
@@ -0,0 +1,15 @@
+channel CIO1 {
+ out min(m: Int, tick) = (m + 1) % 60
+}
+channel HourUpdate {
+ in hour(h: Int, update(h2)) = h2
+ out hour_ang(h_ang: Double, update(h2)) = h2 / 6 * PI
+}
+channel MinUpdate {
+ in min(m, update(m2)) = m2
+ out min_ang(m_ang: Double, update(m2)) = m2 / 30 * PI
+}
+channel Clock {
+ in min(m, update(m2)) = m2
+ out hour(h, update(m2)) = if(m2 == 0, (h + 1) % 24, h)
+}
diff --git a/AlgebraicDataflowArchitectureModel/models/CustomerOffice.model b/AlgebraicDataflowArchitectureModel/models/CustomerOffice.model
index f140bff..5714436 100644
--- a/AlgebraicDataflowArchitectureModel/models/CustomerOffice.model
+++ b/AlgebraicDataflowArchitectureModel/models/CustomerOffice.model
@@ -1,33 +1,21 @@
-channel C_CustomerAOff_In {
- out customerA_off(c:String, setOff(x)) == x
- out customerA_off(c, e) == c
+channel AddCustomer {
+ out customers(csDB:Map, addCustomer(uid:Str, office:Str)) = insert(csDB, uid, {"office": office})
}
-channel C_CustomerBOff_In {
- out customerB_off(c:String, setOff(x)) == x
- out customerB_off(c, e) == c
+channel AddCampany {
+ out companies(cmDB:Map, addCampany(cid:Str, address:Str)) = insert(cmDB, cid, {"address": address})
}
-channel C_CompanyC1Add_In {
- out companyC1_add(a:String, setAdd(y)) == y
- out companyC1_add(a, e) == a
+channel SetCustomerOffice(uid:Str) {
+ out customers.{uid}.office(prevCid:Str, setOffice(cid)) = cid
}
-channel C_CompanyC2Add_In {
- out companyC2_add(a:String, setAdd(y)) == y
- out companyC2_add(a, e) == a
+channel SetCompanyAddress(cid:Str) {
+ out companies.{cid}.address(prevAdd:Str, setAddress(add)) = add
}
-channel CA {
- in customerA_off(c, sync(z, u, v)) == z
- in companyC1_add(a1, sync(z, u, v)) == u
- in companyC2_add(a2, sync(z, u, v)) == v
- out customerA_add(a3:String, sync(z, u, v)) == if(eq(z, C1), u, if(eq(z, C2), v, null))
-}
-
-channel CB {
- in customerB_off(c, sync(z, u, v)) == z
- in companyC1_add(a1, sync(z, u, v)) == u
- in companyC2_add(a2, sync(z, u, v)) == v
- out customerB_add(a3:String, sync(z, u, v)) == if(eq(z, C1), u, if(eq(z, C2), v, null))
+channel UpdateCustomerAddress(uid:Str) {
+ in customers.{uid}.office(prevCid, updateCustomerAddress(cid, add)) = cid
+ in companies.{cid}.address(prevAdd, updateCustomerAddress(cid, add)) = add
+ out customers.{uid}.address(prevAdd, updateCustomerAddress(cid, add)) = add
}
diff --git a/AlgebraicDataflowArchitectureModel/models/Game.model b/AlgebraicDataflowArchitectureModel/models/Game.model
index bc90ba4..1952ff0 100644
--- a/AlgebraicDataflowArchitectureModel/models/Game.model
+++ b/AlgebraicDataflowArchitectureModel/models/Game.model
@@ -1,32 +1,32 @@
channel CIO {
- out force(f:Double, action(x:Double)) == x
- out time(t:Double, action(x)) == t + 0.01
- out force(f, e) == x
- out time(t, e) == t + 0.01
+ out force(f:Double, action(x:Double)) = x
+ out time(t:Double, action(x)) = t + 0.01
+ out force(f, e) = x
+ out time(t, e) = t + 0.01
}
channel CIO2 {
- out velocity(v:Double, setVel(x:Double)) == x
- out velocity(v, e) == x
+ out velocity(v:Double, setVel(x:Double)) = x
+ out velocity(v, e) = x
}
channel CIO3 {
- out mass(m:Double, setMass(x:Double)) == x
- out mass(m, e) == m
+ out mass(m:Double, setMass(x:Double)) = x
+ out mass(m, e) = m
}
channel C1 {
- in force(f, update1(y, z)) == y
- in mass(m, update1(y, z)) == z
- out acceleration(a: Double, update1(y, z)) == y / z
+ in force(f, update1(y, z)) = y
+ in mass(m, update1(y, z)) = z
+ out acceleration(a: Double, update1(y, z)) = y / z
}
channel C2 {
- in acceleration(a, update2(z)) == z
- out velocity(v:Double, update2(z)) == v + 0.01 * z
+ in acceleration(a, update2(z)) = z
+ out velocity(v:Double, update2(z)) = v + 0.01 * z
}
channel C3 {
- in velocity(v, update3(u)) == u
- out position(p:Double, update3(u)) == p + 0.01 * u
+ in velocity(v, update3(u)) = u
+ out position(p:Double, update3(u)) = p + 0.01 * u
}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/GameEngine.model b/AlgebraicDataflowArchitectureModel/models/GameEngine.model
new file mode 100644
index 0000000..8c6f525
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/GameEngine.model
@@ -0,0 +1,104 @@
+init {
+ enemy := {
+ "position": {"x": 0.0, "y": 0.0, "z": 0.0},
+ "rotation": {"x": 0.0, "y": 0.0, "z": 0.0},
+ "id": "001"
+ }
+}
+
+native channel SceneUpdateEvent {
+ out scene.time(time: Long, updateEvent(dt: Long)) = time + dt
+}
+
+native channel SceneUpdate {
+ in scene(curSc: Json, update(curSc, nextSc)) = nextSc
+}
+
+native channel CameraPositionUpdate {
+ in scene.camera.transform.position(curPos: Json, updatePosition(nextPos.x, nextPos.y, nextPos.z)) = nextPos
+}
+
+native channel CameraRotationUpdate {
+ in scene.camera.transform.rotation(curRot: Json, updateRotation(nextRot.x, nextRot.y, nextRot.z)) = nextRot
+}
+
+native channel CameraScaleUpdate {
+ in scene.camera.transform.scale(curScale: Json, updateScale(nextScale.x, nextScale.y, nextScale.z)) = nextScale
+}
+
+native channel CameraProjectionUpdate {
+ in scene.camera.projection(curProj: Json, updateProjection(curProj, nextProj)) = nextProj
+}
+
+native channel EntityPositionUpdate(eid: Str) {
+ in scene.entities.{eid}.transform.position(curPos: Json, updatePosition(nextPos.x, nextPos.y, nextPos.z)) = nextPos
+}
+
+native channel EntityRotationUpdate(eid: Str) {
+ in scene.entities.{eid}.transform.rotation(curRot: Json, updateRotation(nextRot.x, nextRot.y, nextRot.z)) = nextRot
+}
+
+native channel EntityScaleUpdate(eid: Str) {
+ in scene.entities.{eid}.transform.scale(curScale: Json, updateScale(nextScale.x, nextScale.y, nextScale.z)) = nextScale
+}
+
+native channel EntitySpriteUpdate(eid: Str) {
+ in scene.entities.{eid}.mesh(curMesh: Json, updateSprite(spritePath: Str)) = {"type": "sprite", "sprite": spritePath}
+}
+
+native channel KeyEvent(kno: Int) {
+ out scene.keys.{kno}.state(curState: Int, keyEvent(nextState)) = nextState
+}
+
+native channel TimersUpdated {
+ in timers(curTimers: Map, update(curTimers, nextTimers)) = nextTimers
+}
+
+native channel TimerEvent(tid: Str) {
+ out timers.{tid}.count(count: Long, tick()) = count + 1
+}
+
+channel StartTimer {
+ out timers(timers: Map, startTimer(tid: Str, interval: Long)) = insert(timers, tid, {"interval": interval, "count": 0})
+}
+
+channel ClearTimer {
+ out timers(timers: Map, clearTimer(tid: Str)) = delete(timers, tid)
+}
+
+channel AddSprite {
+ out scene.entities(entityDB: Map, addSprite(eid: Str, spritePath: Str)) = insert(entityDB, eid, {
+ "transform": {
+ "position": {"x": 0.0, "y": 0.0, "z": 0.0},
+ "rotation": {"x": 0.0, "y": 0.0, "z": 0.0},
+ "scale": {"x": 1.0, "y": 1.0, "z": 1.0}
+ },
+ "mesh": {"type": "sprite", "sprite": spritePath}
+ })
+}
+
+channel MoveEntity(eid: Str) {
+ out scene.entities.{eid}.transform.position(curPos: Json, move(x: Double, y: Double, z: Double)) = {"x": x, "y": y, "z": z}
+}
+
+channel RotateEntity(eid: Str) {
+ out scene.entities.{eid}.transform.rotation(curRot: Json, rotate(x: Double, y: Double, z: Double)) = {"x": x, "y": y, "z": z}
+}
+
+channel UpdateEnemy(tid: Str) {
+ in timers.{tid}.count(curCount: Long, updateEnemy(nextCount)) = nextCount
+ out enemy.position(curPos: Json, updateEnemy(nextCount)) = {"x": curPos.x, "y": curPos.y + 5, "z": curPos.z}
+ out enemy.rotation(curRot: Json, updateEnemy(nextCount)) = {"x": curRot.x, "y": curRot.y, "z": curRot.z + 5}
+}
+
+channel MoveEnemy {
+ in enemy.position(curPos: Json, moveEnemy(nextPos, nextRot, nextId)) = nextPos
+ in enemy.id(curId: Str, moveEnemy(nextPos, nextRot, nextId)) = nextId
+ out scene.entities.{nextId}.transform.position(curPos: Json, moveEnemy(nextPos, nextRot, nextId)) = nextPos
+}
+
+channel RotateEnemy {
+ in enemy.rotation(curRot: Json, rotateEnemy(nextPos, nextRot, nextId)) = nextRot
+ in enemy.id(curId: Str, rotateEnemy(nextPos, nextRot, nextId)) = nextId
+ out scene.entities.{nextId}.transform.rotation(curRot: Json, rotateEnemy(nextPos, nextRot, nextId)) = nextRot
+}
diff --git a/AlgebraicDataflowArchitectureModel/models/GroupChat.model b/AlgebraicDataflowArchitectureModel/models/GroupChat.model
new file mode 100644
index 0000000..634ddf0
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/GroupChat.model
@@ -0,0 +1,27 @@
+channel Signup {
+ out accounts(acDB:Map, signUp(aid:Str)) = insert(acDB, aid, {"notifications": nil})
+}
+
+channel HasRead(aid:Str) {
+ out accounts.{aid}.notifications(ntMap:Map, hasRead(gid:Str)) = delete(ntMap, gid)
+}
+
+channel CreateGroup {
+ out groups(grDB:Map, createGroup(gid:Str)) = insert(grDB, gid, {"members": nil, "messages": nil})
+}
+
+channel AddGroupMember(gid:Str) {
+ out groups.{gid}.members(memList:List, addGroupMember(aid:Str)) = append(memList, aid)
+}
+
+channel PostMessage(gid:Str) {
+ out groups.{gid}.messages(mesList:List, postMessage(message:Str)) = append(mesList, message)
+}
+
+channel Notify(gid:Str) {
+ in groups.{gid}.messages(prevMesList, notify(m)) = mesList
+ for EachMember(mno:Int) {
+ ref groups.{gid}.members.{mno}(m.{mno}:Str, notify(m))
+ out accounts.{m.{mno}}.notifications(prevNtMap:Map, notify(m)) = insert(prevNtMap, gid, true)
+ }
+}
diff --git a/AlgebraicDataflowArchitectureModel/models/Hello.model b/AlgebraicDataflowArchitectureModel/models/Hello.model
deleted file mode 100644
index 46bb932..0000000
--- a/AlgebraicDataflowArchitectureModel/models/Hello.model
+++ /dev/null
@@ -1,3 +0,0 @@
-channel cio {
- out r1(x1:Int,set(x2)) == x2
-}
diff --git a/AlgebraicDataflowArchitectureModel/models/Hello2.model b/AlgebraicDataflowArchitectureModel/models/Hello2.model
deleted file mode 100644
index 4815cf6..0000000
--- a/AlgebraicDataflowArchitectureModel/models/Hello2.model
+++ /dev/null
@@ -1,3 +0,0 @@
-channel cio {
- out r1(x1:Int,set(x2:Int)) == x2:Int
-}
diff --git a/AlgebraicDataflowArchitectureModel/models/HelloWorld.model b/AlgebraicDataflowArchitectureModel/models/HelloWorld.model
deleted file mode 100644
index 44aa310..0000000
--- a/AlgebraicDataflowArchitectureModel/models/HelloWorld.model
+++ /dev/null
@@ -1,7 +0,0 @@
-channel cio {
- out r1(x1:Int,set(x2:Int)) == x2:Int
-}
-channel c2 {
- in r1(x1:Int,update(x2:Int)) == x2:Int
- out r2(y1:Int,update(x2:Int)) == (x2:Int+1)
-}
diff --git a/AlgebraicDataflowArchitectureModel/models/InventoryManagement.model b/AlgebraicDataflowArchitectureModel/models/InventoryManagement.model
new file mode 100644
index 0000000..578d56c
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/InventoryManagement.model
@@ -0,0 +1,7 @@
+channel ItemRegistration {
+ out inventory(itemDB:Map, registerItem(itemId:Str, itemName:Str, quantity:Int)) = insert(itemDB, itemId, {"count": quantity, "name": itemName})
+}
+
+channel ReceivingOrShipping(itemId:Str) {
+ out inventory.{itemId}.count(prev_quantity:Int, receiveOrShip(quantity:Int)) = prev_quantity + quantity
+}
diff --git a/AlgebraicDataflowArchitectureModel/models/JumpGame.model b/AlgebraicDataflowArchitectureModel/models/JumpGame.model
index 1981df9..43b8d0c 100644
--- a/AlgebraicDataflowArchitectureModel/models/JumpGame.model
+++ b/AlgebraicDataflowArchitectureModel/models/JumpGame.model
@@ -1,7 +1,8 @@
init {
force := pair(0.0, 0.0)
time := 0.0
- move := pair(0.0, 0.0)
+ movex := 0.0
+ movey := 0.0
mass := 1.0
ground := true
acceleration := pair(0.0, 0.0)
@@ -12,59 +13,59 @@
gameover := false
}
channel CIO {
- out force(f:Pair, gravity(y:Double)) == pair(0.0, y)
- out time(t:Double, gravity(y)) == t + 0.01
+ out force(f:Pair, gravity(y:Double)) = pair(0.0, y)
+ out time(t:Double, gravity(y)) = t + 0.01
}
channel CIO2 {
- out movex(x:Double, run(x2:Double)) == x2
+ out movex(x:Double, run(x2:Double)) = x2
}
channel CIO3 {
- out movey(y:Double, jump(y2:Double)) == y2
+ out movey(y:Double, jump(y2:Double)) = y2
}
channel CIO4 {
- out mass(m:Double, setMass(x:Double)) == x
+ out mass(m:Double, setMass(x:Double)) = x
}
channel CIO5 {
- out ground(g:Bool, openHole) == false
- out ground(g, closeHole) == true
+ out ground(g:Bool, openHole) = false
+ out ground(g, closeHole) = true
}
channel C1 {
ref onground(o, update1(f2, m2, o))
- in force(f, update1(f2, m2, o)) == f2
- in mass(m, update1(f2, m2, o)) == m2
- out acceleration(a:Pair, update1(f2, m2, o)) == if(o, pair(left(f2) / m2, 0.0), pair(left(f2) / m2, right(f2) / m2))
+ in force(f, update1(f2, m2, o)) = f2
+ in mass(m, update1(f2, m2, o)) = m2
+ out acceleration(a:Pair, update1(f2, m2, o)) = if(o, pair(left(f2) / m2, 0.0), pair(left(f2) / m2, right(f2) / m2))
}
channel C2 {
ref onground(o, update3(a2, o))
- in acceleration(a, update3(a2, o)) == a2
- out velocity(v:Pair, update3(a2, o)) == if(and(o, lt(right(v), 0.0)),
+ in acceleration(a, update3(a2, o)) = a2
+ out velocity(v:Pair, update3(a2, o)) = if(o && right(v) < 0.0,
pair(left(v) + 0.01 * left(a2), 0.0),
pair(left(v) + 0.01 * left(a2), right(v) + 0.01 * right(a2)))
}
channel C3 {
ref onground(o, update4(x2, o))
- in movex(x, update4(x2, o)) == x2
- out velocity(v:Pair, update4(x2, o)) == if(o, pair(x2, right(v)), v)
+ in movex(x, update4(x2, o)) = x2
+ out velocity(v:Pair, update4(x2, o)) = if(o, pair(x2, right(v)), v)
}
channel C4 {
ref onground(o, update5(x2, o))
- in movey(y, update5(y2, o)) == y2
- out velocity(v:Pair, update5(y2, o)) == if(o, pair(left(v), y2), v)
+ in movey(y, update5(y2, o)) = y2
+ out velocity(v:Pair, update5(y2, o)) = if(o, pair(left(v), y2), v)
}
channel C5 {
- in velocity(v, update6(v2, g)) == v2
+ in velocity(v, update6(v2, g)) = v2
ref ground(g, update6(v2, g))
- out position(p:Pair, update6(v2, g)) == if(and(eq(g, true), lt(right(p) + 0.01 * right(v2), 0.0)),
+ out position(p:Pair, update6(v2, g)) = if(g == true && right(p) + 0.01 * right(v2) > 0.0,
pair(left(p) + 0.01 * left(v2), 0.0),
pair(left(p) + 0.01 * left(v2), right(p) + 0.01 * right(v2)))
}
channel C6 {
- in position(p, update2(p2, g2)) == p2
- in ground(g, update2(p2, g2)) == g2
- out onground(o:Bool, update2(p2, g2)) == and(eq(g2, true), le(right(p2), 0.0))
+ in position(p, update2(p2, g2)) = p2
+ in ground(g, update2(p2, g2)) = g2
+ out onground(o:Bool, update2(p2, g2)) = (g2 == true && right(p2) <= 0.0)
}
channel C7 {
- in position(p, update7(p2)) == p2
- out clear(c:Bool, update7(p2)) == if(gt(left(p2), 100.0), true, false)
- out gameover(go:Bool, update7(p2)) == if(lt(right(p2), -1.0), true, false)
+ in position(p, update7(p2)) = p2
+ out clear(c:Bool, update7(p2)) = (left(p2) > 100.0)
+ out gameover(go:Bool, update7(p2)) = (right(p2) < -1.0)
}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Kinematics.model b/AlgebraicDataflowArchitectureModel/models/Kinematics.model
new file mode 100644
index 0000000..3d10af4
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/Kinematics.model
@@ -0,0 +1,20 @@
+channel CIO {
+ out force(f:Double, action(x)) = x
+ out time(t:Double, action(x)) = t + 0.01
+}
+
+channel C1 {
+ in force(f, update1(y, m)) = y
+ in mass(m, update1(y, m)) = m
+ out acceleration(a:Double, update1(y, m)) = y / m
+}
+
+channel C2 {
+ in acceleration(a, update2(z)) = z
+ out velocity(v:Double, update2(z)) = v + 0.01 * z
+}
+
+channel C3 {
+ in velocity(v, update3(u)) = u
+ out position(p:Double, update3(u)) = p + 0.01 * u
+}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Kinetics.model b/AlgebraicDataflowArchitectureModel/models/Kinetics.model
deleted file mode 100644
index 5218206..0000000
--- a/AlgebraicDataflowArchitectureModel/models/Kinetics.model
+++ /dev/null
@@ -1,20 +0,0 @@
-channel CIO {
- out force(f:Double, action(x)) == x
- out time(t:Double, action(x)) == t + 0.01
-}
-
-channel C1 {
- in force(f, update1(y, m)) == y
- in mass(m, update1(y, m)) == m
- out acceleration(a:Double, update1(y, m)) == y / m
-}
-
-channel C2 {
- in acceleration(a, update2(z)) == z
- out velocity(v:Double, update2(z)) == v + 0.01 * z
-}
-
-channel C3 {
- in velocity(v, update3(u)) == u
- out position(p:Double, update3(u)) == p + 0.01 * u
-}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/NemophilaAccounts.model b/AlgebraicDataflowArchitectureModel/models/NemophilaAccounts.model
new file mode 100644
index 0000000..0158d26
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/NemophilaAccounts.model
@@ -0,0 +1,86 @@
+channel CIO_CreateAccount {
+ out accounts(acList:List, createAccount(name:Str)) = append(acList, {
+ "name": name,
+ "posts": nil,
+ "newFriend": null,
+ "delReqFriend": null,
+ "newRequesting": null,
+ "friends": nil,
+ "requesting": nil,
+ "requested": nil,
+ })
+}
+
+channel CIO_ChangeName(uid:Str) {
+ out accounts.{uid}.name(prevName:Str, changeName(name)) = name
+}
+
+channel CIO_CreatePost(uid:Str) {
+ out accounts.{uid}.posts(postsList:List, createPost(comment:Str)) = cons(comment:Str, postsList)
+}
+
+channel CIO_DeletePost(uid:Str) {
+ out accounts.{uid}.posts(postsList:List, deletePost(pid:Str)) = remove(postsList, pid:Str)
+}
+
+channel CIO_PostRequesting(sendId:Str) {
+ out accounts.{sendId}.newRequesting(preNewResuesting:Str, postRequesting(recvId:Str)) = recvId
+}
+
+channel C_AddRequesting(sendId:Str) {
+ in accounts.{sendId}.newRequesting(preNewResuesting:Str, sync1(recvId:Str, sendRequested:Map, recvRequesting:Map, sendFriends:Map)) = recvId
+ ref accounts.{sendId}.friends(sendFriends:Map, sync1(recvId:Str, sendRequested:Map, recvRequesting:Map, sendFriends:Map))
+ ref accounts.{sendId}.requested(sendRequested:Map, sync1(recvId:Str, sendRequested:Map, recvRequesting:Map, sendFriends:Map))
+ ref accounts.{recvId}.requesting(recvRequesting:Map, sync1(recvId:Str, sendRequested:Map, recvRequesting:Map, sendFriends:Map))
+
+ out accounts.{sendId}.requesting(sendRequesting:Map, sync1(recvId:Str, sendRequested:Map, recvRequesting:Map, sendFriends:Map)) = if(contains(sendFriends:Map, recvId) == true,
+ sendRequesting,
+ insert(sendRequesting:Map, recvId:Str, true))
+ out accounts.{recvId}.requested(recvRequested:Map, sync1(recvId:Str, sendRequested:Map, recvRequesting:Map, sendFriends:Map)) = if(contains(sendFriends:Map, recvId) == true,
+ recvRequested,
+ insert(recvRequested:Map, sendId:Str, true))
+}
+
+channel CIO_RejectRequest(recvId:Str) {
+ out accounts.{sendId}.requesting(sendRequesting:Map, rejectRequest(sendId:Str)) = delete(sendRequesting:Map, recvId:Str)
+ out accounts.{recvId}.requested(recvRequested:Map, rejectRequest(sendId:Str)) = delete(recvRequested:Map, sendId:Str)
+}
+
+channel CIO_AdmitFriend(recvId:Str) {
+ out accounts.{recvId}.newFriend(preNewFriend:Str, admitFriend(sendId:Str)) = sendId
+}
+
+channel C_AddFriend(recvId:Str) {
+ in accounts.{recvId}.newFriend(preSendId:Str, sync2(sendId:Str, preSendTing:Map, preRecvTed:Map)) = sendId
+ ref accounts.{sendId}.requesting(preSendTing:Map, sync2(sendId:Str, preSendTing:Map, preRecvTed:Map))
+ ref accounts.{recvId}.requested(preRecvTed:Map, sync2(sendId:Str, preSendTing:Map, preRecvTed:Map))
+
+ out accounts.{sendId}.friends(sendFriends:Map, sync2(sendId:Str, preSendTing:Map, preRecvTed:Map)) = if(contains(preSendTing:Map, recvId) == true && contains(preRecvTed:Map, sendId) == true,
+ insert(sendFriends, recvId:Str, true),
+ sendFriends)
+ out accounts.{recvId}.friends(recvFriends:Map, sync2(sendId:Str, preSendTing:Map, preRecvTed:Map)) = if(contains(preSendTing:Map, recvId) == true && contains(preRecvTed:Map, sendId) == true,
+ insert(recvFriends, sendId:Str, true),
+ recvFriends)
+ out accounts.{sendId}.requesting(sendRequesting:Map, sync2(sendId:Str, preSendTing:Map, preRecvTed:Map)) = if(contains(preSendTing:Map, recvId) == true && contains(preRecvTed:Map, sendId) == true,
+ delete(sendRequesting:Map, recvId:Str),
+ sendRequesting)
+ out accounts.{recvId}.requested(recvRequested:Map, sync2(sendId:Str, preSendTing:Map, preRecvTed:Map)) = if(contains(preSendTing:Map, recvId) == true && contains(preRecvTed:Map, sendId) == true,
+ delete(recvRequested:Map, sendId:Str),
+ recvRequested)
+}
+
+channel CIO_DeleteFriendRequest(sendId:Str) {
+ out accounts.{sendId}.delReqFriend(preDelReqFriend:Str, deleteFriend(recvId:Str)) = recvId
+}
+
+channel CIO_DeleteFriend(sendId:Str) {
+ in accounts.{sendId}.delReqFriend(preRecvId:Str, sync3(recvId:Str, preSendFriends:Map, preRecvFriends:Map)) = recvId
+ ref accounts.{sendId}.friends(preSendFriends:Map, sync3(recvId:Str, preSendFriends:Map, preRecvFriends:Map))
+ ref accounts.{recvId}.friends(preRecvFriends:Map, sync3(recvId:Str, preSendFriends:Map, preRecvFriends:Map))
+ out accounts.{sendId}.friends(sendFriends:Map, sync3(recvId:Str, preSendFriends:Map, preRecvFriends:Map)) = if(contains(preSendFriends:Map, recvId) == true || contains(preRecvFriends:Map, sendId) == true,
+ delete(sendFriends:Map, recvId:Str),
+ sendFriends)
+ out accounts.{recvId}.friends(recvFriends:Map, sync3(recvId:Str, preSendFriends:Map, preRecvFriends:Map)) = if(contains(preSendFriends:Map, recvId) == true || contains(preRecvFriends:Map, sendId) == true,
+ delete(recvFriends:Map, sendId:Str),
+ recvFriends)
+}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/OnlineBattleGame.model b/AlgebraicDataflowArchitectureModel/models/OnlineBattleGame.model
new file mode 100644
index 0000000..d91b144
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/OnlineBattleGame.model
@@ -0,0 +1,31 @@
+channel Signup {
+ out accounts(acDB:Map, signUp(aid:Str, name:Str)) = insert(acDB, aid, {"name": name})
+}
+
+channel ChangeName(aid:Str) {
+ out accounts.{aid}.name(prevName:Str, changeName(name)) = name
+}
+
+channel CreateRoom {
+ out rooms(rmDB:Map, createRoom(rid:Str, blueId:Str, redId:Str)) = insert(rmDB, rid, {"blue_id": blueId, "red_id": redId})
+}
+
+channel ChangeRedId(rid:Str) {
+ out rooms.{rid}.red_id(prevRedId:Str, changeRedId(redId)) = redId
+}
+
+channel ChangeBlueId(rid:Str) {
+ out rooms.{rid}.blue_id(prevBlueId:Str, changeBlueId(blueId)) = blueId
+}
+
+channel UpdateRedName(rid:Str) {
+ in rooms.{rid}.red_id(prevAid:Str, updateRedName(aid, name)) = aid
+ in accounts.{aid}.name(prevName:Str, updateRedName(aid, name)) = name
+ out rooms.{rid}.red_name(prevName:Str, updateRedName(aid, name)) = name
+}
+
+channel UpdateBlueName(rid:Str) {
+ in rooms.{rid}.blue_id(prevAid:Str, updateBlueName(aid, name)) = aid
+ in accounts.{aid}.name(prevName:Str, updateBlueName(aid, name)) = name
+ out rooms.{rid}.blue_name(prevName:Str, updateBlueName(aid, name)) = name
+}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/POS.dtram b/AlgebraicDataflowArchitectureModel/models/POS.dtram
index dc3d2d1..d1cb11c 100644
--- a/AlgebraicDataflowArchitectureModel/models/POS.dtram
+++ b/AlgebraicDataflowArchitectureModel/models/POS.dtram
@@ -1,18 +1,18 @@
model {
channel CIO {
- out payment(p:Int, purchase(x:Int)) == x
+ out payment(p:Int, purchase(x:Int)) = x
}
channel C3 {
- in history(h, update3(u)) == u
- out total(t:Int, update3(u)) == sum(u)
+ in history(h, update3(u)) = u
+ out total(t:Int, update3(u)) = sum(u)
}
channel C1 {
- in payment(p, update1(y)) == y
- out points(l:Int, update1(y)) == floor(y * 0.05)
+ in payment(p, update1(y)) = y
+ out points(l:Int, update1(y)) = floor(y * 0.05)
}
channel C2 {
- in payment(p, update2(z)) == z
- out history(h:List, update2(z)) == cons(z, h)
+ in payment(p, update2(z)) = z
+ out history(h:List, update2(z)) = cons(z, h)
}
}
geometry {
diff --git a/AlgebraicDataflowArchitectureModel/models/POS.model b/AlgebraicDataflowArchitectureModel/models/POS.model
index 150c106..c15c931 100644
--- a/AlgebraicDataflowArchitectureModel/models/POS.model
+++ b/AlgebraicDataflowArchitectureModel/models/POS.model
@@ -1,15 +1,15 @@
channel CIO {
- out payment(p:Int, purchase(x:Int)) == x
+ out payment(p:Int, purchase(x:Int)) = x
}
channel C3 {
- in history(h, update3(u)) == u
- out total(t:Int, update3(u)) == sum(u)
+ in history(h, update3(u)) = u
+ out total(t:Int, update3(u)) = sum(u)
}
channel C1 {
- in payment(p, update1(y)) == y
- out points(l:Int, update1(y)) == floor(y * 0.05)
+ in payment(p, update1(y)) = y
+ out points(l:Int, update1(y)) = floor(y * 0.05)
}
channel C2 {
- in payment(p, update2(z)) == z
- out history(h:List, update2(z)) == cons(z, h)
+ in payment(p, update2(z)) = z
+ out history(h:List, update2(z)) = cons(z, h)
}
diff --git a/AlgebraicDataflowArchitectureModel/models/POS2.model b/AlgebraicDataflowArchitectureModel/models/POS2.model
index 6ae676d..0ee31d2 100644
--- a/AlgebraicDataflowArchitectureModel/models/POS2.model
+++ b/AlgebraicDataflowArchitectureModel/models/POS2.model
@@ -1,14 +1,14 @@
channel CIO {
- out payment(p:Int, purchase(x:Int)) == x
+ out payment(p:Int, purchase(x:Int)) = x
}
channel C1 {
- in payment(p1, update1(y)) == y
- out points(l:Int, update1(y)) == floor(y * 0.05)
+ in payment(p1, update1(y)) = y
+ out points(l:Int, update1(y)) = floor(y * 0.05)
}
channel C2 {
- in payment(p1, update2(z)) == z
- out history(h:List, update2(z)) == cons(z, h)
- out total(t:Int, update2(z)) == z + t
+ in payment(p1, update2(z)) = z
+ out history(h:List, update2(z)) = cons(z, h)
+ out total(t:Int, update2(z)) = z + t
}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/SimpleAddressBook.model b/AlgebraicDataflowArchitectureModel/models/SimpleAddressBook.model
new file mode 100644
index 0000000..9a9f38a
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/SimpleAddressBook.model
@@ -0,0 +1,11 @@
+channel Init {
+ out book.owner(pre_name: Str, init(name: Str)) = name
+}
+
+channel Add {
+ out book.addr(pre_addr: Map, add(name: Str, addr: Str)) = insert(pre_addr, name, addr)
+}
+
+channel Del {
+ out book.addr(pre_addr: Map, del(name: Str)) = delete(pre_addr, name)
+}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/SimpleTwitter.model b/AlgebraicDataflowArchitectureModel/models/SimpleTwitter.model
new file mode 100644
index 0000000..486fafb
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/SimpleTwitter.model
@@ -0,0 +1,7 @@
+channel Signup {
+ out accounts(accountDB:Map, signUp(accountId:Str, name:Str)) = insert(accountDB, accountId, {"name": name, "tweets": nil})
+}
+
+channel Tweet(accountId:Str) {
+ out accounts.{accountId}.tweets(tweetList:List, tweet(contents:Str)) = append(tweetList, contents)
+}
diff --git a/AlgebraicDataflowArchitectureModel/models/SimpleUI.model b/AlgebraicDataflowArchitectureModel/models/SimpleUI.model
new file mode 100644
index 0000000..e003d9a
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/SimpleUI.model
@@ -0,0 +1,122 @@
+init {
+ screenTemplates := {
+ "000": {"widgets": {"001": {"type": "textInput", "text": "", "state": 0, "visible": true},
+ "002": {"type": "button", "text": "Next", "state": 0, "visible": true}},
+ "layout": true},
+ "001": {"widgets": {"003": {"type": "label", "text": "label", "state": 0, "visible": true},
+ "004": {"type": "button", "text": "Back", "state": 0, "visible": true}},
+ "layout": true}
+ }
+}
+
+native channel ScreenUpdate {
+ in screen(curSc: Json, update(curSc, nextSc)) = nextSc
+}
+
+native channel SetLayout {
+ in screen.layout(curLayout: Bool, setLayout(nextLayout)) = nextLayout
+}
+
+native channel SetVisible(wid: Str) {
+ in screen.widgets.{wid}.visible(curVisible: Bool, setVisible(nextVisible)) = nextVisible
+}
+
+native channel SetText(wid: Str) {
+ in screen.widgets.{wid}.text(curText: Str, setText(nextText)) = nextText
+}
+
+native channel SetX(wid: Str) {
+ in screen.widgets.{wid}.x(curX: Int, setX(nextX)) = nextX
+}
+
+native channel SetY(wid: Str) {
+ in screen.widgets.{wid}.y(curY: Int, setY(nextY)) = nextY
+}
+
+native channel SetWidth(wid: Str) {
+ in screen.widgets.{wid}.width(curWidth: Int, setWidth(nextWidth)) = nextWidth
+}
+
+native channel SetHeight(wid: Str) {
+ in screen.widgets.{wid}.height(curHeight: Int, setHeight(nextHeight)) = nextHeight
+}
+
+native channel MouseEvent(wid: Str) {
+ out screen.widgets.{wid}.state(curState: Int, mouseEvent(nextState)) = nextState
+}
+
+native channel TextEvent(wid: Str) {
+ out screen.widgets.{wid}.text(curText: Str, textEvent(nextText)) = nextText
+}
+
+channel ChangeCurScreen {
+ out curScreen(curScId: Str, changeCurScreen(nextScId)) = nextScId
+}
+
+channel ScreenTransition {
+ in curScreen(curScId: Str, transScreen(nextScId, screen)) = nextScId
+ ref screenTemplates.{nextScId}(screen, transScreen(nextScId, screen))
+ out screen(curS, transScreen(nextScId, screen)) = screen
+}
+
+channel ChangeCurScreen {
+ out curScreen(curScId: Str, changeCurScreen(nextScId)) = nextScId
+}
+
+channel ScreenTransition {
+ in curScreen(curScId: Str, transScreen(nextScId, screen)) = nextScId
+ ref screenTemplates.{nextScId}(screen, transScreen(nextScId, screen))
+ out screen(curS, transScreen(nextScId, screen)) = screen
+}
+
+channel EventDispatch(wid: Str) {
+ in screen.widgets.{wid}.state(curState: Int, dispatchEvent(curScId, wid, nextState)) = nextState
+ ref curScreen(curScId: Str, dispatchEvent(curScId, wid, nextState))
+ out screenTemplates.{curScId}.widgets.{wid}.state(curState: Int, dispatchEvent(curScId, wid, nextState)) = nextState
+}
+
+channel EventHandler1(scId: Str, wid: Str) {
+ in screenTemplates.{scId="000"}.widgets.{wid="002"}.state(curState: Int, handleEvent1(nextState)) = nextState
+ out curScreen(curScId: Str, handleEvent1(nextState)) = if(nextState == 0, "001", curScId)
+}
+
+channel EventHandler2(scId: Str, wid: Str) {
+ in screenTemplates.{scId="001"}.widgets.{wid="004"}.state(curState: Int, handleEvent2(nextState)) = nextState
+ out curScreen(curScId: Str, handleEvent2(nextState)) = if(nextState == 0, "000", curScId)
+}
+
+channel ChangeLayout {
+ out screen.layout(curLayout: Bool, changeLayout(layout)) = layout
+}
+
+channel ChangeX(wid: Str) {
+ out screen.widgets.{wid}.x(curX: Int, changeX(x)) = x
+}
+
+channel ChangeY(wid: Str) {
+ out screen.widgets.{wid}.y(curY: Int, changeY(y)) = y
+}
+
+channel AddButton {
+ out screen.widgets(widgets: Map, addButton(wid: Str, text: Str)) = insert(widgets, wid, {"type": "button", "text": text, "state": 0})
+}
+
+channel AddLabel {
+ out screen.widgets(widgets: Map, addLabel(wid: Str, text: Str)) = insert(widgets, wid, {"type": "label", "text": text, "state": 0})
+}
+
+channel AddTextInput {
+ out screen.widgets(widgets: Map, addTextInput(wid: Str)) = insert(widgets, wid, {"type": "textInput", "text": "", "state": 0})
+}
+
+channel AddMovableButton {
+ out screen.widgets(widgets: Map, addMovableButton(wid: Str, text: Str, x: Int, y: Int, width: Int, height: Int)) = insert(widgets, wid, {"type": "button", "text": text, "x": x, "y": y, "width": width, "height": height, "state": 0})
+}
+
+channel AddMovableLabel {
+ out screen.widgets(widgets: Map, addMovableLabel(wid: Str, text: Str, x: Int, y: Int, width: Int, height: Int)) = insert(widgets, wid, {"type": "label", "text": text, "x": x, "y": y, "width": width, "height": height, "state": 0})
+}
+
+channel AddMovableTextInput {
+ out screen.widgets(widgets: Map, addMovableTextInput(wid: Str, x: Int, y: Int, width: Int, height: Int)) = insert(widgets, wid, {"type": "textInput", "text": "", "x": x, "y": y, "width": width, "height": height, "state": 0})
+}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/StockManagement.model b/AlgebraicDataflowArchitectureModel/models/StockManagement.model
index b133f44..4528cb7 100644
--- a/AlgebraicDataflowArchitectureModel/models/StockManagement.model
+++ b/AlgebraicDataflowArchitectureModel/models/StockManagement.model
@@ -4,47 +4,47 @@
}
channel CIO_enter {
- out arrival(s:Tuple, arrive(item:Str, num:Int)) == tuple(item, num)
+ out arrival(s:Tuple, arrive(item:Str, num:Int)) = tuple(item, num)
}
channel CIO_req {
- out request(r:Tuple, req(item:Str, num:Int)) == tuple(item, num)
+ out request(r:Tuple, req(item:Str, num:Int)) = tuple(item, num)
}
channel C1 {
- in arrival(ar, update1(ar2, st)) == ar2
+ in arrival(ar, update1(ar2, st)) = ar2
ref stock(st:Map, update1(ar2, st))
- out available(av:Tuple, update1(ar2, st)) == tuple(fst(ar2), snd(ar2) + lookup(st, fst(ar2)))
+ out available(av:Tuple, update1(ar2, st)) = tuple(fst(ar2), snd(ar2) + lookup(st, fst(ar2)))
}
channel C2 {
- in available(av, update2(av2, sh)) == av2
+ in available(av, update2(av2, sh)) = av2
ref shortage(sh, update2(av2, sh))
- out deriver(dr:Tuple, update2(av2, sh)) == if(ge(snd(av2), lookup(sh, fst(av2))),
+ out deriver(dr:Tuple, update2(av2, sh)) = if(snd(av2) >= lookup(sh, fst(av2)),
tuple(fst(av2), lookup(sh, fst(av2)), snd(av2) - lookup(sh, fst(av2))),
tuple(fst(av2), 0, snd(av2)))
- out shortage(s, update2(av2, sh)) == if(ge(snd(av2), lookup(s, fst(av2))),
+ out shortage(s, update2(av2, sh)) = if(snd(av2) >= lookup(s, fst(av2)),
insert(s, fst(av2), 0),
s)
}
channel C3 {
- in deriver(dr, update3(dr2)) == dr2
- out stock(st, update3(dr2)) == insert(st, fst(dr2), snd(snd(dr2)))
+ in deriver(dr, update3(dr2)) = dr2
+ out stock(st, update3(dr2)) = insert(st, fst(dr2), snd(snd(dr2)))
}
channel C4 {
- in deriver(dr, update4(dr2)) == dr2
- out shipping(sp:Tuple, update4(dr2)) == tuple(fst(dr2), fst(snd(dr2)))
+ in deriver(dr, update4(dr2)) = dr2
+ out shipping(sp:Tuple, update4(dr2)) = tuple(fst(dr2), fst(snd(dr2)))
}
channel C5 {
- in request(rq, update5(rq2, st)) == rq2
+ in request(rq, update5(rq2, st)) = rq2
ref stock(st, update5(rq2, st))
- out deriver(dr, update5(rq2, st)) == if(ge(lookup(st, fst(rq2)), snd(rq2)),
+ out deriver(dr, update5(rq2, st)) = if(lookup(st, fst(rq2)) >= snd(rq2),
tuple(fst(rq2), snd(rq2), lookup(st, fst(rq2)) - snd(rq2)),
tuple(fst(rq2), 0, lookup(st, fst(rq2))))
- out shortage(sh, update5(rq2, st)) == if(ge(lookup(st, fst(rq2)), snd(rq2)),
+ out shortage(sh, update5(rq2, st)) = if(lookup(st, fst(rq2)) >= snd(rq2),
sh,
insert(sh, fst(rq2), lookup(sh, fst(rq2)) + snd(rq2)))
}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/StockManagement2.model b/AlgebraicDataflowArchitectureModel/models/StockManagement2.model
index 6ee866a..36d6966 100644
--- a/AlgebraicDataflowArchitectureModel/models/StockManagement2.model
+++ b/AlgebraicDataflowArchitectureModel/models/StockManagement2.model
@@ -4,10 +4,10 @@
}
channel CIO_enter {
- out deriver(s:Tuple, arrive(item:Str, num:Int)) == tuple(item, num, num)
+ out deriver(s:Tuple, arrive(item:Str, num:Int)) = tuple(item, num, num)
}
channel C3 {
- in deriver(dr, update3(dr2)) == dr2
- out shipping(sp:Tuple, update3(dr2)) == tuple(fst(dr2), fst(snd(dr2)))
+ in deriver(dr, update3(dr2)) = dr2
+ out shipping(sp:Tuple, update3(dr2)) = tuple(fst(dr2), fst(snd(dr2)))
}
diff --git a/AlgebraicDataflowArchitectureModel/models/Test.model b/AlgebraicDataflowArchitectureModel/models/Test.model
deleted file mode 100644
index a8a1348..0000000
--- a/AlgebraicDataflowArchitectureModel/models/Test.model
+++ /dev/null
@@ -1,9 +0,0 @@
-channel CIO {
- out a(x:Int, set(n:Int)) == n
-}
-
-channel C1 {
- in a(x, update(y)) == y
- out b(z, update(y)) == y + 1
- out c(v, update(y)) == v + y
-}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Timer.model b/AlgebraicDataflowArchitectureModel/models/Timer.model
new file mode 100644
index 0000000..83a66d5
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/Timer.model
@@ -0,0 +1,15 @@
+native channel TimersUpdated {
+ in timers(curTimers: Map, update(curTimers, nextTimers)) = nextTimers
+}
+
+native channel TimerEvent(tid: Str) {
+ out timers.{tid}.count(count: Long, tick()) = count + 1
+}
+
+channel StartTimer {
+ out timers(timers: Map, startTimer(tid: Str, interval: Long)) = insert(timers, tid, {"interval": interval, "count": 0})
+}
+
+channel ClearTimer {
+ out timers(timers: Map, clearTimer(tid: Str)) = delete(timers, tid)
+}
diff --git a/AlgebraicDataflowArchitectureModel/models/TravelDistance.model b/AlgebraicDataflowArchitectureModel/models/TravelDistance.model
new file mode 100644
index 0000000..07d12db
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/TravelDistance.model
@@ -0,0 +1,13 @@
+channel CX {
+ out pos_x(prev_x: Double, setX(cur_x: Double)) = cur_x
+}
+
+channel CY {
+ out pos_y(prev_y: Double, setY(cur_y: Double)) = cur_y
+}
+
+channel C {
+ in pos_x(prev_x, move(dx, dy)) = prev_x + dx
+ in pos_y(prev_y, move(dx, dy)) = prev_y + dy
+ out dist(prev_d, move(dx, dy)) = prev_d + sqrt(dx * dx + dy * dy)
+}
diff --git a/AlgebraicDataflowArchitectureModel/models/Triangle.model b/AlgebraicDataflowArchitectureModel/models/Triangle.model
new file mode 100644
index 0000000..cf3d0e0
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/Triangle.model
@@ -0,0 +1,13 @@
+channel cio1 {
+ out base(x: Double, setBase(x2)) = x2
+}
+
+channel cio2 {
+ out height(y: Double, setHeight(y2)) = y2
+}
+
+channel triangle {
+ in base(x, update(x2, y2)) = x2
+ in height(y, update(x2, y2)) = y2
+ out hypothenuse(z: Double, update(x2, y2)) = sqrt(x2 * x2 + y2 * y2)
+}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Triangle2.model b/AlgebraicDataflowArchitectureModel/models/Triangle2.model
new file mode 100644
index 0000000..5067fa0
--- /dev/null
+++ b/AlgebraicDataflowArchitectureModel/models/Triangle2.model
@@ -0,0 +1,13 @@
+channel cio1 {
+ out base(x: Double, setBase(x2)) = x2
+}
+
+channel cio2 {
+ out height(y: Double, setHeight(y2)) = y2
+}
+
+channel triangle {
+ in base(x, update: Tuple) = fst(update)
+ in height(y, update) = snd(update)
+ out hypothenuse(z: Double, update) = sqrt(fst(update) * fst(update) + snd(update) * snd(update))
+}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/Twitter.model b/AlgebraicDataflowArchitectureModel/models/Twitter.model
index 57de3b3..e5c46a8 100644
--- a/AlgebraicDataflowArchitectureModel/models/Twitter.model
+++ b/AlgebraicDataflowArchitectureModel/models/Twitter.model
@@ -1,47 +1,20 @@
-channel a_Tweet {
- out a_tweets(l:List, a_tweet(t:Str, time:Long)) == cons(tuple(time, t), l)
+channel SignUp {
+ out accounts(acDB:Map, signup(id:Str, name:Str)) = insert(acDB, id, {"name": name, "tweets": nil, "followees": nil, "timeline": nil})
}
-channel a_Follow {
- out a_following(f:List, a_follow(u:Int)) == cons(u, f)
+channel Tweet(id:Str) {
+ out accounts.{id}.tweets(twList:List, tweet(text:Str, time:Long)) = append(twList, {"time": time, "text": text})
}
-channel a_Home {
- in a_tweets(la1, update_a(f2, la2, lb2, lc2)) == la2
- in b_tweets(lb1, update_a(f2, la2, lb2, lc2)) == lb2
- in c_tweets(lc1, update_a(f2, la2, lb2, lc2)) == lc2
- in a_following(f, update_a(f2, la2, lb2, lc2)) == f2
- out a_timeline(t:List, update_a(f2, la2, lb2, lc2)) == merge(la2, if(contains(f2,2), merge(lb2, if(contains(f2,3), lc2, nil)), if(contains(f2,3), lc2, nil)))
+channel AddFollowee(id:Str) {
+ out accounts.{id}.followees(fwList:List, addFollowee(flwId:Str)) = append(fwList, flwId)
}
-channel b_Tweet {
- out b_tweets(l:List, b_tweet(t:Str, time:Long)) == cons(tuple(time, t), l)
-}
-
-channel b_Follow {
- out b_following(f:List, b_follow(u:Int)) == cons(u, f)
-}
-
-channel b_Home {
- in a_tweets(la1, update_b(f2, la2, lb2, lc2)) == la2
- in b_tweets(lb1, update_b(f2, la2, lb2, lc2)) == lb2
- in c_tweets(lc1, update_b(f2, la2, lb2, lc2)) == lc2
- in b_following(f, update_b(f2, la2, lb2, lc2)) == f2
- out b_timeline(t:List, update_b(f2, la2, lb2, lc2)) == merge(lb2, if(contains(f2,1), merge(la2, if(contains(f2,3), lc2, nil)), if(contains(f2,3), lc2, nil)))
-}
-
-channel c_Tweet {
- out c_tweets(l:List, c_tweet(t:Str, time:Long)) == cons(tuple(time, t), l)
-}
-
-channel c_Follow {
- out c_following(f:List, c_follow(u:Int)) == cons(u, f)
-}
-
-channel c_Home {
- in a_tweets(la1, update_c(f2, la2, lb2, lc2)) == la2
- in b_tweets(lb1, update_c(f2, la2, lb2, lc2)) == lb2
- in c_tweets(lc1, update_c(f2, la2, lb2, lc2)) == lc2
- in c_following(f, update_c(f2, la2, lb2, lc2)) == f2
- out c_timeline(t:List, update_c(f2, la2, lb2, lc2)) == merge(lc2, if(contains(f2,1), merge(la2, if(contains(f2,2), lb2, nil)), if(contains(f2,2), lb2, nil)))
-}
+channel UpdateTimeline(myId:Str) {
+ in accounts.{myId}.tweets(t1:List, m) = m.myTweets
+ for EachFollowee(no:Int) {
+ in accounts.{myId}.followees.{no}(id:Str, m) = m.flw.{no}.id
+ in accounts.{m.flw.{no}.id}.tweets(t2:List, m) = m.flw.{no}.tweets
+ }
+ out accounts.{myId}.timeline(l:List, m) = merge(m.myTweets, m.flw)
+}
\ No newline at end of file
diff --git a/AlgebraicDataflowArchitectureModel/models/WOS.dtram b/AlgebraicDataflowArchitectureModel/models/WOS.dtram
index 45f640c..81b0779 100644
--- a/AlgebraicDataflowArchitectureModel/models/WOS.dtram
+++ b/AlgebraicDataflowArchitectureModel/models/WOS.dtram
@@ -1,17 +1,17 @@
model {
channel CIO2 {
- out highest(h:Double, reset(v)) == v
+ out highest(h:Double, reset(v)) = v
}
channel CIO1 {
- out temp_f(p:Double, observe(x)) == x
+ out temp_f(p:Double, observe(x)) = x
}
channel C1{
- in temp_f(q:Double, conversion(y)) == y
- out temp_c(r:Double, conversion(z)) == (z-32) / 1.8
+ in temp_f(q:Double, conversion(y)) = y
+ out temp_c(r:Double, conversion(z)) = (z-32) / 1.8
}
channel C2{
- in temp_f(q:Double, update(y)) == y
- out highest(h:Double, update(z)) == if(gt(z, h), z, h)
+ in temp_f(q:Double, update(y)) = y
+ out highest(h:Double, update(z)) = if(z >= h, z, h)
}
}
geometry {
diff --git a/AlgebraicDataflowArchitectureModel/models/WeatherObservationSystem.model b/AlgebraicDataflowArchitectureModel/models/WeatherObservationSystem.model
index 2cd84d7..0096407 100644
--- a/AlgebraicDataflowArchitectureModel/models/WeatherObservationSystem.model
+++ b/AlgebraicDataflowArchitectureModel/models/WeatherObservationSystem.model
@@ -1,14 +1,14 @@
channel CIO2 {
- out highest(h:Double, reset(v)) == v
+ out highest(h:Double, reset(v)) = v
}
channel CIO1 {
- out temp_f(p:Double, observe(x)) == x
+ out temp_f(p:Double, observe(x)) = x
}
channel C1{
- in temp_f(q:Double, conversion(y)) == y
- out temp_c(r:Double, conversion(z)) == (z-32) / 1.8
+ in temp_f(q:Double, conversion(y)) = y
+ out temp_c(r:Double, conversion(z)) = (z-32) / 1.8
}
channel C2{
- in temp_f(q:Double, update(y)) == y
- out highest(h:Double, update(z)) == if(gt(z, h), z, h)
+ in temp_f(q:Double, update(y)) = y
+ out highest(h:Double, update(z)) = if(z >= h, z, h)
}
diff --git a/AlgebraicDataflowArchitectureModel/src/algorithms/DataTransferModelAnalyzer.java b/AlgebraicDataflowArchitectureModel/src/algorithms/DataTransferModelAnalyzer.java
index 836227a..f54aea4 100644
--- a/AlgebraicDataflowArchitectureModel/src/algorithms/DataTransferModelAnalyzer.java
+++ b/AlgebraicDataflowArchitectureModel/src/algorithms/DataTransferModelAnalyzer.java
@@ -24,41 +24,47 @@
*/
static public DataFlowGraph createDataFlowGraphWithStateStoringAttribute(DataTransferModel model) {
DataFlowGraph graph = model.getDataFlowGraph();
- Collection channels = new HashSet<>(model.getIOChannels());
+ Collection channels = new HashSet<>(model.getInputChannels());
channels.addAll(model.getChannels());
for (Channel channel: channels) {
for (ChannelMember member: ((DataTransferChannel) channel).getOutputChannelMembers()) {
- boolean flag = !member.getStateTransition().isRightUnary(); // The state does not need to be stored if the state transition function is right unary.
- for (Node node : graph.getNodes()) {
- if (((ResourceNode) node).getResource().equals(member.getResource())) {
- setStoreAttribute(flag, (ResourceNode) node);
+ boolean toBeStored = !member.getStateTransition().isRightUnary(); // The state does not need to be stored if the state transition function is right unary.
+ for (Node node : graph.getResourceNodes()) {
+ if (((ResourceNode) node).getInSideResources().contains(member.getResource())) {
+ setStoreAttribute((ResourceNode) node, toBeStored);
}
}
}
}
- for (Node node : graph.getNodes()) {
+ for (Node node: graph.getResourceNodes()) {
HashSet inChannels = new HashSet<>();
- for(Edge pre : ((ResourceNode) node).getInEdges()) {
- inChannels.add(((DataFlowEdge) pre).getChannel());
+ for(Edge inEdge: ((ResourceNode) node).getInEdges()) {
+ if (inEdge instanceof DataFlowEdge) {
+ DataFlowEdge dfEdge = (DataFlowEdge) inEdge;
+ if (dfEdge.isChannelToResource()) {
+ inChannels.add(((ChannelNode) dfEdge.getSource()).getChannel());
+ }
+ }
}
if ((inChannels.size() > 1)) {
- setStoreAttribute(true, (ResourceNode) node);
+ // If the resource has multiple input channels, then the state of the resource needs to be stored.
+ setStoreAttribute((ResourceNode) node, true);
} else if (((ResourceNode) node).getAttribute() == null) {
- setStoreAttribute(false, (ResourceNode) node);
+ setStoreAttribute((ResourceNode) node, false);
}
}
return graph;
}
- static private void setStoreAttribute(boolean flag, ResourceNode node) {
+ static private void setStoreAttribute(ResourceNode node, boolean toBeStored) {
NodeAttribute attr = node.getAttribute();
StoreAttribute store;
if (attr != null && attr instanceof NodeAttribute) {
store = (StoreAttribute) attr;
- store.setNeeded(store.isNeeded() || flag);
+ store.setNeeded(store.isNeeded() || toBeStored);
} else {
store = new StoreAttribute();
- store.setNeeded(flag);
+ store.setNeeded(toBeStored);
node.setAttribute(store);
}
}
@@ -69,17 +75,17 @@
* @return annotated data flow graph
*/
static public DataFlowGraph annotateWithSelectableDataTransferAttiribute(DataFlowGraph graph) {
- List nodes = new ArrayList<>(graph.getNodes());
+ List resNodes = new ArrayList<>(graph.getResourceNodes());
// set push only attributes
- for (Node n: graph.getNodes()) {
- if (nodes.contains(n) && ((StoreAttribute) ((ResourceNode) n).getAttribute()).isNeeded()) {
- nodes.remove(n);
- trackEdges(n, nodes);
+ for (Node resNode: graph.getResourceNodes()) {
+ if (resNodes.contains(resNode) && ((StoreAttribute) ((ResourceNode) resNode).getAttribute()).isNeeded()) {
+ resNodes.remove(resNode);
+ trackEdges(resNode, resNodes);
}
}
// set push/pull attributes to the remaining edges
for (Edge e : graph.getEdges()) {
- if (((DataFlowEdge) e).getAttribute() == null) {
+ if (!((DataFlowEdge) e).isChannelToResource() && ((DataFlowEdge) e).getAttribute() == null) {
PushPullAttribute ppat = new PushPullAttribute();
ppat.addOption(PushPullValue.PUSHorPULL);
ppat.addOption(PushPullValue.PUSH);
@@ -90,16 +96,19 @@
return graph;
}
- static private void trackEdges(Node n, List nodes) {
+ static private void trackEdges(Node resNode, List resNodes) {
// recursively set push only attributes to input side edges
- for (Edge e : ((ResourceNode) n).getInEdges()) {
- PushPullAttribute ppat = new PushPullAttribute();
- ppat.addOption(PushPullValue.PUSH);
- ((DataFlowEdge) e).setAttribute(ppat);
- Node n2 = e.getSource();
- if (nodes.contains(n2)) {
- nodes.remove(n2);
- trackEdges(n2, nodes);
+ for (Edge chToRes : ((ResourceNode) resNode).getInEdges()) {
+ Node chNode = chToRes.getSource();
+ for (Edge resToCh : ((ChannelNode) chNode).getInEdges()) {
+ PushPullAttribute ppat = new PushPullAttribute();
+ ppat.addOption(PushPullValue.PUSH);
+ ((DataFlowEdge) resToCh).setAttribute(ppat);
+ Node resNode2 = resToCh.getSource();
+ if (resNodes.contains(resNode2)) {
+ resNodes.remove(resNode2);
+ trackEdges(resNode2, resNodes);
+ }
}
}
}
diff --git a/AlgebraicDataflowArchitectureModel/src/algorithms/TypeInference.java b/AlgebraicDataflowArchitectureModel/src/algorithms/TypeInference.java
index d29070d..ca92529 100644
--- a/AlgebraicDataflowArchitectureModel/src/algorithms/TypeInference.java
+++ b/AlgebraicDataflowArchitectureModel/src/algorithms/TypeInference.java
@@ -13,6 +13,7 @@
import javax.xml.crypto.Data;
import models.Node;
+import models.algebra.Constant;
import models.algebra.Expression;
import models.algebra.Position;
import models.algebra.Symbol;
@@ -22,7 +23,10 @@
import models.dataConstraintModel.Channel;
import models.dataConstraintModel.ChannelMember;
import models.dataConstraintModel.DataConstraintModel;
+import models.dataConstraintModel.JsonType;
+import models.dataConstraintModel.ResourceHierarchy;
import models.dataConstraintModel.ResourcePath;
+import models.dataConstraintModel.Selector;
import models.dataConstraintModel.StateTransition;
import models.dataFlowModel.DataTransferModel;
import models.dataFlowModel.ResourceNode;
@@ -42,6 +46,8 @@
static private Map pairComponentTypes = new HashMap<>();
static private Map, Type> mapTypes = new HashMap<>();
static private Map> mapComponentTypes = new HashMap<>();
+ static private Map