dtmc
const int phase = 4096;
const int maxr = 127;
const int mrep = 128;
formula success =
((rep<mrep & ((t1=((freq<=c)?train:1-train) & f1<=c) | (t1=((freq<=c)?1-train:train) & f1>c)))
| (rep=mrep & ((send=1 & freq<=f1) | (send>1 & freq<f1)) & ((t1=((freq<=c)?train:1-train) & f1<=c) | (t1=((freq<=c)?1-train:train) & f1>c)))
| (rep=mrep-1 & c<16 & swap & ((t1=((freq<=c)?train:1-train) & f1<=c+1) | (t1=((freq<=c)?1-train:train) & f1>c+1)) & ((f1=1 & freq>=15) | (f1=2 & freq=16)))
| (rep=mrep-1 & c<16 & !swap & ((t1=((freq<=c)?1-train:train) & f1<=c+1) | (t1=((freq<=c)?train:1-train) & f1>c+1)) & ((f1=1 & freq>=15) | (f1=2 & freq=16)))
| (rep=mrep-1 & c=16 & (t1=((f1=1)?1-train:train)) & ((f1=1 & freq>=15) | (f1=2 & freq=16)))
| (rep=mrep & c<16 & swap & ((t1=((freq<=c)?train:1-train) & f1<=c+1) | (t1=((freq<=c)?1-train:train) & f1>c+1)) & f1<=freq+2)
| (rep=mrep & c<16 & !swap & ((t1=((freq<=c)?1-train:train) & f1<=c+1) | (t1=((freq<=c)?train:1-train) & f1>c+1)) & f1<=freq+2)
| (rep=mrep & c=16 & (t1=((f1=1)?1-train:train)) & f1<=freq+2 & c=16));
formula swap = (((c=2)|(c=4)|(c=6)|(c=8)|(c=10)|(c=12)|(c=14)|(c=16)));
formula swap2 = ((((c=2)|(c=4)|(c=6)|(c=8)|(c=10)|(c=12)|(c=14))) & freq=c+1) | (c=16 & freq=1)
| ((((c=1)|(c=3)|(c=5)|(c=7)|(c=9)|(c=11)|(c=13)|(c=15))) & freq!=c+1);
formula sleep = (receiver=0 & y1=1);
formula hear = (freq1=freq & train1=train & send=1);
module receiver1
y1 : [0..2*maxr+1];
receiver : [0..3];
freq1 : [0..16];
train1 : [0..1];
[time] receiver=0 & y1=1 -> (y1'=y1-1);
[] receiver=0 & y1=0 & success -> (receiver'=1) & (freq1'=f1) & (train1'=t1);
[] receiver=0 & y1=0 & !success -> (receiver'=0) & (y1'=1);
[time] receiver=1 & !hear -> (y1'=y1);
[] receiver=1 & hear -> (receiver'=2) & (y1'=2) & (freq1'=0) & (train1'=0);
[time] receiver=2 & y1>0 -> (y1'=y1-1);
[reply] receiver=2 & y1=0 -> 1/(maxr+1) : (receiver'=3) & (y1'=0)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*1)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*2)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*3)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*4)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*5)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*6)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*7)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*8)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*9)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*10)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*11)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*12)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*13)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*14)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*15)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*16)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*17)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*18)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*19)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*20)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*21)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*22)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*23)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*24)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*25)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*26)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*27)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*28)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*29)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*30)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*31)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*32)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*33)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*34)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*35)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*36)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*37)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*38)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*39)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*40)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*41)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*42)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*43)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*44)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*45)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*46)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*47)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*48)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*49)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*50)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*51)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*52)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*53)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*54)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*55)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*56)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*57)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*58)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*59)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*60)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*61)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*62)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*63)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*64)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*65)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*66)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*67)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*68)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*69)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*70)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*71)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*72)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*73)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*74)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*75)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*76)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*77)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*78)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*79)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*80)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*81)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*82)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*83)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*84)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*85)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*86)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*87)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*88)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*89)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*90)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*91)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*92)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*93)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*94)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*95)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*96)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*97)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*98)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*99)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*100)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*101)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*102)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*103)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*104)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*105)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*106)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*107)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*108)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*109)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*110)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*111)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*112)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*113)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*114)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*115)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*116)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*117)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*118)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*119)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*120)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*121)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*122)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*123)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*124)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*125)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*126)
+ 1/(maxr+1) : (receiver'=3) & (y1'=2*127);
[time] receiver=3 & y1>0 -> (y1'=y1-1);
[] receiver=3 & y1=0 & success -> (receiver'=1) & (freq1'=f1) & (train1'=t1);
[] receiver=3 & y1=0 & !success -> (receiver'=0) & (y1'=1);
endmodule
module frequency1
z1 : [1..phase];
f1 : [1..16];
t1 : [0..1];
[time] !sleep & z1<phase -> (z1'=z1+1);
[time] !sleep & z1=phase & f1<16 -> (z1'=1) & (f1'=f1+1);
[time] !sleep & z1=phase & f1=16 -> (z1'=1) & (f1'=1) & (t1'=1-t1);
[time] sleep & z1<=2048 -> (z1'=z1+2048);
[time] sleep & z1>2048 & f1<16 -> (z1'=z1-2048) & (f1'=f1+1);
[time] sleep & z1>2048 & f1=16 -> (z1'=z1-2048) & (f1'=1) & (t1'=1-t1);
[reply] true -> (f1'=(f1<16)?f1+1:1) & (t1'=(f1<16)?t1:1-t1);
endmodule
module sender
send : [1..3];
freq : [1..16];
train : [0..1];
c : [1..16];
rep : [1..mrep];
[time] !sleep & send=1 & (((freq=1)|(freq=3)|(freq=5)|(freq=7)|(freq=9)|(freq=11)|(freq=13)|(freq=15))) & freq!=c -> (freq'=freq+1);
[time] !sleep & send=1 & (((freq=1)|(freq=3)|(freq=5)|(freq=7)|(freq=9)|(freq=11)|(freq=13)|(freq=15))) & freq=c -> (freq'=freq+1) & (train'=1-train);
[time] !sleep & send=1 & (((freq=2)|(freq=4)|(freq=6)|(freq=8)|(freq=10)|(freq=12)|(freq=14)|(freq=16))) -> (send'=2);
[time] !sleep & send=2 -> (send'=3);
[time] !sleep & send=3 & freq<16 & freq!=c -> (send'=1) & (freq'=freq+1);
[time] !sleep & send=3 & freq<16 & freq=c -> (send'=1) & (freq'=freq+1) & (train'=1-train);
[time] !sleep & send=3 & freq=16 & rep<mrep & c!=16 -> (send'=1) & (freq'=1) & (train'=1-train) & (rep'=rep+1);
[time] !sleep & send=3 & freq=16 & rep<mrep & c=16 -> (send'=1) & (freq'=1) & (rep'=rep+1);
[time] !sleep & send=3 & freq=16 & rep=mrep -> (send'=1) & (freq'=1) & (train'=swap?1-train:train) & (c'=c=16?1:c+1) & (rep'=1);
[time] sleep & rep<=64 -> (rep'=rep+64);
[time] sleep & rep>64 -> (rep'=rep-64) & (c'=c=16?1:c+1) & (train'=swap2?1-train:train);
endmodule
const int mrec;
module replies
rec : [0..mrec];
[time] rec<mrec -> (rec'=rec);
[reply] rec<mrec -> (rec'=min(rec+1,mrec));
[] rec=mrec -> (rec'=rec);
endmodule
const int k;
const int T;
init
receiver=0 & y1=0 & freq1=0 & train1=0 &
rec=0 &
f1=k & t1=T &
(send=1 |((freq=2)|(freq=4)|(freq=6)|(freq=8)|(freq=10)|(freq=12)|(freq=14)|(freq=16)))
endinit
rewards "time"
[time] !(receiver=0 & y1=1) : 1;
[time] receiver=0 & y1=1 : 2048;
endrewards