TyPiCal is a type-based static analyzer for the pi-calculus. The current version of TyPiCal provides the following program analyses or program transformations: lock-freedom analysis, deadlock-freedom analysis, useless-code elimination, information flow analysis, and termination analysis. The former two analyses aim to statically analyze whether each communication succeeds or not. The lock-freedom analysis can answer, e.g., the following questions about the behavior of concurrent/distributed programs:
new philos in new fork1 in new fork2 in *philos?x.(let left=fst(x) in let right=snd(x) in left?w.right?w. /*** picks the left fork and then the right fork ***/ (left!() | right!() | eating!() | philos!(left,right))) | philos!(fork1,fork2) | philos!(fork1,fork2) | fork1!() | fork2!()The two philosophers try to pick the two forks in the same order, so that they do not get into a deadlock. The lock-freedom analyzer of TyPiCal produces the following output:
new philos in new fork1 in new fork2 in *philos??x.(let left=fst(x) in let right=snd(x) in left??w.right??w. /*** picks the left fork and then the right fork ***/ (left!!() | right!!() | eating!() | philos!!(left,right))) | philos!!(fork1,fork2) | philos!!(fork1,fork2) | fork1!!() | fork2!!()All the communications except eating1!() are marked by !! or ??, which mean that those communications eventually succeed. The above result implies that two philosophers can acquire forks infinitely often. Given the same program, the useless-code eliminator of TyPiCal produces the following output:
*eating!()Since the philosophers can acquire forks infinitely often, the whole process is actually observationally equivalent to *eating!().
If the second philosopher get forks in a different order:
new philos in new fork1 in new fork2 in *philos?x.(let left=fst(x) in let right=snd(x) in left?w.right?w. /*** picks the left fork and then the right fork ***/ (left!() | right!() | eating!() | philos!(left,right))) | philos!(fork1,fork2) | philos!(fork2,fork1) | fork1!() | fork2!()then, the output of the lock-freedom analyzer is:
new philos in new fork1 in new fork2 in *philos?x.(let left=fst(x) in let right=snd(x) in left?w.right?w. /*** picks the left fork and then the right fork ***/ (left!() | right!() | eating!() | philos!!(left,right))) | philos!!(fork1,fork2) | philos!!(fork2,fork1) | fork1!!() | fork2!!()So, we know that philosophers may not be able to eat (note that left?w and right?w are not annotated with ??). The useless-code eliminator does not eliminate any sub-process in this case. Consult README file in the distribution for more details.
Naoki Kobayashi, "Type Systems for Concurrent Programs," Proceedings of UNU/IIST 10th Anniversary Colloquium Springer LNCS 2757, pp.439-453The technical background of TyPiCal is described in more detail in the following paper.
Naoki Kobayashi, "A New Type System for Deadlock-Free Processes," CONCUR 2006, Springer LNCS 4137, pp.233-247, 2006.
Naoki Kobayashi, "Type-Based Information Flow Analysis for the Pi-Calculus," Acta Informatica, 42(4-5), pp.291-347, 2005.
Naoki Kobayashi and Davide Sangiorgi, "A Hybrid Type System for Lock-Freedom of Mobile Processes," CAV 2008, Springer LNCS, 2008.