Design of Semantics by Abstract Interpretation
Total Page:16
File Type:pdf, Size:1020Kb
…/… Design of Semantics by Abstract Interpretation -- Abstraction of the relational into a nondeterministic Plotkin/- Smyth/Hoare denotational/functional semantics; -- Abstraction of the natural/demoniac relational into a determin istic denotational/functional semantics;Scott’ssemantics; Patrick COUSOT -- Abstraction of nondeterministic denotational semantics to weakest École Normale Supérieure precondition/strongest postcondition predicate transformer se DMI, 45, rue d’Ulm mantics; 75230 Paris cedex 05 Abstraction of predicate transformer semantics to à la Hoare France -- ax ;Programproofmethods; [email protected] iomatic semantics http://www.dmi.ens.fr/ cousot Extension to the λ-calculus. ˜ • MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, am Montag, dem 2. Juni 1997 um 14.15 Uhr 1 1 Extended version of the invited address at MFPS XIII, CMU, Pittsburgh, March 24, 1997 © P. Cousot 1 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 3 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 Content Application of abstract interpretation ideas to the design of formal semantics: Examples of Abstract Interpretations Examples of abstract interpretations; • Abstraction of fixpoint semantics; • -- Maximal trace semantics of nondeterministic transition systems; -- Abstraction of the trace into a natural/demoniac/angelic relational semantics; …/… © P. Cousot 2 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 4 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 Applications of Abstract Interpretation Program Analysis by Abstract Interpretation (Bit-vector) data flow analysis; • Mainly used for specifying program analyzers constructively derived Strictness analysis and comportment analysis (generalizing strictness, • • from a formal semantics; termination, projection and PER analysis); Such analyzers can be used to statically and fully automatically de Binding time analysis; • • termine run-time properties of programs; Pointer analysis; • Such run-time information can be used in complement to classical pro Set/grammar-based analysis; • • gram provers, model-checkers, … for program verification (abstract Data dependence analysis (e.g. for vectorization/parallelization); • debugging, …) and transformation (compiler optimization, partial Descriptive/soft and prescriptive (polymorphic) typing and type in • evaluation, parallelization, …); ference; We will show that abstract interpretation can be used to relate and Effect systems; • • design program semantics (and program proof methods). … • © P. Cousot 5 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 7 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 Approximation Program Debugging by Abstract Interpretation Syntox 4, 5 by François Bourdoncle: interval analysis for Pascal • programs; The central idea of abstract interpretation 2, 3 is that of approxima • For abstract debugging,theusercanprovide: tion; • A program analyzer computes a finite approximation of the infinite -- Invariant assertions: {% … %}, • set of possible run-time behaviors of the program for all possible -- Intermittent assertions: {% … ? %} (termination is required by execution environments (inputs, interrupts, …); {% true ? %} before final end.), A program semantics specifies an approximation of the run-time At each program point the analysis provides for each numerical vari • • program behaviors in all possible execution environments abstracting able v acorrespondinginvariantintervalassertion(v[l..h]). A away from implementation details. star (*)ononeofthebounds(first: First Condition ,next: », previous: «)indicatesanecessary condition in the form of a run-time check to be inserted in the program for the user assertions to be sat 2 P. Cousot and R. Cousot. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Conference Record of the Fourth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages,pages 238–252, Los Angeles, California, 1977. ACM Press, New York, New York, usa. isfied. A sharp # indicates a possible overflow. 3 P. Cousot and R. Cousot. Systematic design of program analysis frameworks. In Conference Record of the Sixth Annual ACM SIG PLAN-SIGACT Symposium on Principles of Programming Languages, pages 269–282, San Antonio, Texas, 1979. ACM Press, New York, New York, usa. © P. Cousot 6 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 8 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 4 F. Bourdoncle, Abstract Debugging of Higher-Order Imperative Languages ,Proc.PLDI’93,ACMPress,1993,pp.46–55. 5 http://www.ensmp.fr/ bourdonc/syntox.tar.Z © P. Cousot 9 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 11 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 10 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 12 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 Arithmetic x =1mod2 • congruences 8: y =0mod2 ∧ Interval x [0, 2] mod 4 • ∈ congruences 9: y =[0, 1] mod 3 ∧ 8 P. Granger. Static analysis of arithmetical congruences. Int. J. of Comp. Math.,30:165–190,1989. 9 F. Masdupuy. Semantic analysis of interval congruences. In D. Bjørner, M. Broy, and I.V. Pottosin, editors, Proc. FMPA,Academgorodok, Novosibirsk, Russia, LNCS 735, pages 142–155. Springer-Verlag, June 28–July 2, 1993. © P. Cousot 13 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 15 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 Examples of independent numerical abstractions Examples of relational numerical abstractions Signs 6: x>0 • 10 y>0 Linear equalities : 3x +4y =1 ∧ • − Intervals 7:1x 5 • ≤ ≤ Simple sections 11:1x 5 1 y 4 • ≤ ≤ ∧ ≤ ≤ 1 y 4 ∧ ≤ ≤ 3 x + y 7 ∧ ≤ ≤ 6 P. Cousot & R. Cousot. Systematic design of program analysis frameworks. In 6th POPL, pages 269–282, San Antonio, Texas, 1979. ACM Press. 10 M. Karr. Affine relationships among variables of a program. Acta Inf. ,6:133–151,1976. 7 P. Cousot and R. Cousot. Static determination of dynamic properties of programs. In Proc. 2nd International Symposium on Programming, 11 V. Balasundaram and K. Kennedy. A technique for summarizing data access and its use in parallelism enhancing transformations. In pages 106–130. Dunod, 1976. SIGPLAN’89 PLDI, pages 41–53, Portland, Ore., June 21–23, 1989. © P. Cousot 14 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 16 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 Linear inequalities 12:3x + y 7 • ≥ 2x + y 11 ∧ ≤ y 1 ∧ ≥ x +3y 13 ∧ ≤ Linear 2x + y =1mod2 • Abstraction of Fixpoint Semantics congruences 13: y =0mod2 ∧ 12 P. Cousot and N. Halbwachs. Automatic discovery of linear restraints among variables of a program. In 5th POPL,pages84–97,Tucson, Arizona, 1978. ACM Press. 13 P. Granger. Static analysis of linear congruence equalities among variables of a program. In S. Abramsky and T.S.E. Maibaum, editors, TAPSOFT’91, Proc. Int. Joint Conf. on Theory and Practice of Software Development ,Brighton,U.K.,Volume1(CAAP’91),LNCS493, pages 169–192. Springer-Verlag, 1991. © P. Cousot 17 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 19 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 Trapezoidal congruences 14, 15: Fixpoint Semantics Specification D, F • & ' D, , , Semantic domain • & ( ⊥ *' -- D, poset & (' -- infimum ⊥ -- (partially defined) least upper bound * F D m D Total monotone semantic transformer • ∈ +−→ " The iterates of F from are assumed to be well-defined: F 0 = , • ⊥ ⊥ F δ+1 = F (F δ)andF λ =" F δ , λ limit ordinal; δ<*λ " The semantics is S =lfp( F = F $ where $ is the order of the • iterates (i.e. the least ordinal⊥ such that F (F $)=F $). 14 F. Masdupuy. Using abstract interpretation to detect array data dependencies. In Proc. International Symposium on Supercomputing,pages 19–27, Fukuoka, Japan, Nov. 1991. Kyushu U. Press. 15 F. Masdupuy. Array operations abstraction using semantic analysis of trapezoid congruences. In Proc. ACM International Conference on Supercomputing, ICS’92,pages226–235,WashingtonD.C.,July1992. © P. Cousot 18 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 © P. Cousot 20 MPI-Kolloquium, Max-Planck-Institut für Informatik, Saarbrücken, 2. Juni 1997 Benefits of a Fixpoint Presentation of the Semantics By approximation, fixpoints directly lead to iterative program analy • sis algorithms 17, 18; Fixpoint presentation of the semantics is not always possible (without Many other equivalent possible presentations 16: • • further refinement of the semantic domain). -- equational, -- constraint, -- closure condition, -- rule-based, -- game-theoretic; 17 P. Cousot and R. Cousot. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Conference Record of the Fourth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages,pages 238–252, Los Angeles, California, 1977. ACM Press, New York, New York, usa. 16 P. Cousot and R. Cousot. Compositional and inductive semantic definitions in fixpoint,