// Constants definition // // Automaton definition // automaton evader contr_var: e, p, x; // e position of the evader // p position of the pursuer // x timer synclabs: jump; loc ClkW: while 0 <= e <= 40 & 0 <= p <= 40 & x <= 2 wait {e'==5 & -0.5 <= p' <= 6 & x'==1} when (p == 0) sync jump do {e'==e & p'==40 & x'==x} goto ClkW; when (p == 40) sync jump do {e'==e & p'==0 & x'==x} goto ClkW; when (x >= 2) & (0 < e < 40) & (6*e - 5*p > 40) sync jump do {e'==e & p'==p & x'==0} goto ClkW; when (x >= 2) & (0 < e < 40) & (6*e - 5*p <= 40) sync jump do {e'==e & p'==p & x'==0} goto CntrClkW; when (e == 0) sync jump do {e'==e & p'==p & x'==x} goto Rescued; when (e == 40) sync jump do {e'==e & p'==p & x'==x} goto Rescued; loc CntrClkW: while 0 <= e <= 40 & 0 <= p <= 40 & x <= 2 wait {e'==-5 & -0.5 <= p' <= 6 & x'==1} when (p == 0) sync jump do {e'==e & p'==40 & x'==x} goto CntrClkW; when (p == 40) sync jump do {e'==e & p'==0 & x'==x} goto CntrClkW; when (x >= 2) & (0 < e < 40) & (6*e - 5*p > 40) sync jump do {e'==e & p'==p & x'==0} goto ClkW; when (x >= 2) & (0 < e < 40) & (6*e - 5*p <= 40) sync jump do {e'==e & p'==p & x'==0} goto CntrClkW; when (e == 0) sync jump do {e'==e & p'==p & x'==x} goto Rescued; when (e == 40) sync jump do {e'==e & p'==p & x'==x} goto Rescued; loc Rescued: while true wait {e'==0 & p'==0 & x'==0 }; initially: ClkW & x == 2 & e == 20 & p == 10; end // Compute the reachable set // region=evader.reachable; // // Output to file // // List regions (pairs of locations names and linear formulas) region.print("evader_regions.txt", 0); // Sequence of vertices in floating point form. // Can be plotted with gnuplot // Project on e and p region.project_to(e, p); region.print("evader.txt", 2); // Safety verification // // definition of bad states forbidden = evader.{$ & e == p}; reach_set = evader.is_reachable(forbidden); reach_set.intersection_assign(forbidden); echo "The intersection between the reachable set and the bad region is:"; reach_set.is_empty;