-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlloy.rs
More file actions
51 lines (40 loc) · 1.21 KB
/
Alloy.rs
File metadata and controls
51 lines (40 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
abstract sig User {}
abstract sig Admin {}
sig Nasabah extends User {}
sig Bank extends Admin {}
sig CreditCard {
owner: Nasabah,
limit: Int,
balance: Int
}
sig Transaction {
payer: Nasabah,
payee: Bank,
amount: Int,
status: one StatusTransaction
}
sig StatusTransaction {
success, failure
}
// Rules
// Rule 1: Setiap kartu kredit dimiliki oleh satu Nasabah
fact CreditCardOwnership {
all c: CreditCard | one o: Nasabah | c.owner = o
}
// Rule 2: Jumlah transaksi harus non-negatif
fact NonNegativeTransaction {
all t: Transaction | t.amount >= 0
}
// Rule 3: Setiap transaksi harus memiliki status
fact TransactionStatus {
all t: Transaction | one s: StatusTransaction | t.status = s
}
// Rule 4: Transaksi sukses hanya dapat dilakukan oleh Nasabah
fact SuccessfulTransactionByNasabah {
all t: Transaction | t.status = StatusTransaction.success implies t.payer in Nasabah
}
// Rule 5: Transaksi ke Bank harus sukses
fact SuccessfulTransactionToBank {
all t: Transaction | t.payee in Bank implies t.status = StatusTransaction.success
}
run {} for 5 but 2 Nasabah, 3 Bank, 3 CreditCard, 5 Transaction, 2 StatusTransaction