Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. open util/integer
  2.  
  3. --UNIX time notation
  4. --Dates are the number of seconds from a reference date (for example 1th January 2018)
  5.  
  6. --SIGNATURES--  
  7. sig Float{}
  8.  
  9. abstract sig Bool{}
  10. one sig True extends Bool{}
  11. one sig False extends Bool{}
  12.  
  13. --it's the position of the user or the location searched by a company query
  14. sig Location{
  15. --latitude
  16. lat: one Float,
  17. --longitude
  18. long: one Float}
  19.  
  20. --the possible criteria that a company can choose
  21. -- for selecting a precise group of people in a query
  22. sig Criteria{
  23. --age criteria
  24. age: lone Int,
  25. --location criteria
  26. loc: lone Location,
  27. --gender criteria: female = 0, male = 1
  28. gen: lone Bool}
  29. {age>0}
  30.  
  31. --the possibile answer given
  32. sig Answer{
  33. --response
  34. answer: lone Bool,
  35. --id query that refers to the query
  36. idQuery: one Int}
  37. {idQuery>0}
  38.  
  39. --There are all the possible status of query is
  40.  abstract sig StatusQuery{}
  41. one sig SENT extends StatusQuery{}
  42. one sig ACCEPTED extends StatusQuery{}
  43. one sig DENIED extends StatusQuery{}
  44.  
  45. --The structure of a query from a company
  46. sig Query{
  47. --unique for each query
  48. idQ: one Int,
  49. --answer/s of the query
  50. ans: set Answer,
  51. --criteria of the query
  52. crit: one Criteria,
  53. --company that asks this query
  54. comp: one Company,
  55. --status of the query
  56. status: one StatusQuery}
  57. {idQ>0 and
  58. status = ACCEPTED implies (one a: ans | a.idQuery = idQ and a.answer = True)
  59. status = DENIED implies (one a: ans | a.idQuery = idQ and a.answer = False) and
  60. --all set of answer in query structure has to be related to that query
  61. all a: ans | a.idQuery = idQ
  62. }
  63.  
  64.  
  65. --parameters of health
  66. sig Cardiac{
  67. --first parameter : cardiac Rate
  68. p1: lone Float,
  69. --date ( year month day hour minute second ) of each parameter
  70. date: one Int}
  71. {date>0}
  72.  
  73. --The health status of each user
  74. sig Health{
  75. --fiscal code of the user
  76. fC: one String,
  77. --the cardiac rate of the user
  78. cardiac: one Cardiac,
  79. -- the position od the user
  80. position: one Location,
  81. --1 if is older than 60, 0 otherwise
  82. over60: one Bool,
  83. --1 if the ambulance is sent for an emergency
  84. ambulanceSent: one Bool}
  85.  
  86. --the warn that health parameter are under a certain threshold
  87. sig Warn{}
  88.  
  89. --abstract structure for all users subscribed
  90. abstract sig UserSubscribed{
  91. --name of the company or the user
  92. name: one String,
  93. --password of the selected by the user
  94. password: one String,
  95. -- email used to register the user
  96. email: one String
  97. }
  98.  
  99. --individual that download the app and register himself
  100. one sig User extends UserSubscribed{
  101. --id that identify in a unique way each user
  102. fiscalCode: one String,
  103. --gender of the user
  104. gender: one Bool,
  105. --date of the birth day
  106. birthDay: one Int,
  107. --age of the user
  108. age: one Int,
  109. --all the answers given by the user
  110. answeredQueries: set Answer,
  111. --all the warn given by the system
  112. warns: set Warn,
  113. --the heathStatus of the user
  114. healthS: one Health}
  115. {age>0}
  116.  
  117. --the third company that asks queries to the system
  118. one sig Company extends UserSubscribed{
  119. --id that identify in a unique way each company
  120. vta: one Int,
  121. --all the queries asked by the company
  122. askedQueries: set Query,
  123. --receivedHealthStatus
  124. receivedHealthStatus: set Health
  125. }
  126. {vta>0}
  127.  
  128.  
  129. --FACTS--
  130. -- No two distinct coinciding users
  131. fact OnlyUniqueUserSubscribed{
  132. no disj u1, u2: UserSubscribed | u1!=u2 and u1.email = u2.email}
  133.  
  134. --No two distinct users with the same fiscal code
  135. fact OnlyUniqueUser{
  136. no disj u1, u2: User | u1!=u2 and u1.fiscalCode = u2.fiscalCode}
  137.  
  138.  
  139. --No two distinct companies with the same vta
  140. fact OnlyUniqueCompany{
  141. no disj c1, c2: Company | c1!=c2 and c1.vta = c2.vta}
  142.  
  143.  
  144. --No two distinct queries with the same id
  145. fact OnlyUniqueQueries{
  146. no disj q1,q2: Query | q1!=q2 and q1.idQ = q2.idQ}
  147.  
  148. --ASSERTIONS--
  149. --all answers has to be linked to a query
  150. assert AnswersRelatedToQuery{
  151. all a: Answer | one q: Query | q in a.idQuery
  152. }
  153.  
  154.  
  155. --PREDICATES--
  156. pred sympleShow{
  157. #User <=2
  158. #Company <=1
  159. some q : Query | q.status = ACCEPTED
  160. some a : Answer | a.answer= True
  161. }
  162.  
  163. pred complexShow{
  164. #User >1
  165. #Company >1
  166. some q : Query | q.status = ACCEPTED
  167. some a : Answer | a.answer= True
  168. }
  169.  
  170. --run sympleShow for 6 but 8 int
  171. run sympleShow for 2 but exactly 10 String
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement