Colored intersection types: a bridge between linear logic and higher-order model-checking Charles Grellois (joint work with Paul-Andr´ e Melli` es) PPS & LIAFA — Universit´ e Paris 7 TYPES conference — May 18th, 2015 Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 1 / 21
Model-checking higher-order programs A well-known approach in verification: model-checking. Construct a model M of a program Specify a property ϕ in an appropriate logic Make them interact: the result is whether M ϕ � When the model is a word, a tree. . . of actions: translate ϕ to an equivalent automaton: �→ A ϕ ϕ Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 2 / 21
Model-checking higher-order programs For higher-order programs with recursion: M is a higher-order tree: a tree produced by a higher-order recursion schemes (HORS) over which we run an alternating parity tree automaton (APT) A ϕ corresponding to a monadic second-order logic (MSO) formula ϕ . Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 3 / 21
Higher-order recursion schemes � = S L Nil G = L x = if x ( L ( data x ) ) A HORS is a kind of deterministic higher-order grammar. Rewrite rules have (higher-order) parameters. “Everything” is simply-typed. Rewriting produces a tree �G� . Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 4 / 21
Higher-order recursion schemes � = S L Nil G = L x = if x ( L ( data x ) ) Rewriting starts from the start symbol S : L S → G Nil Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 4 / 21
Higher-order recursion schemes � = S L Nil G = L x = if x ( L ( data x ) ) if L Nil L → G Nil data Nil Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 4 / 21
Higher-order recursion schemes � = S L Nil G = L x = if x ( L ( data x ) ) if Nil if if data L Nil L → G Nil data data data Nil Nil Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 4 / 21
Higher-order recursion schemes � = S L Nil G = L x = if x ( L ( data x ) ) if Nil if data if �G� is an infinite non-regular tree. . . . Nil data It is our model M . data Nil Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 4 / 21
Higher-order recursion schemes � = S L Nil G = L x = if x ( L ( data x ) ) HORS can alternatively be seen as simply-typed λ -terms with free variables of order at most 1 (= tree constructors) and simply-typed recursion operators Y σ : ( σ ⇒ σ ) ⇒ σ . Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 4 / 21
Higher-order recursion schemes � = S L Nil G = L x = if x ( L ( data x ) ) HORS can alternatively be seen as simply-typed λ -terms with free variables of order at most 1 (= tree constructors) and simply-typed recursion operators Y σ : ( σ ⇒ σ ) ⇒ σ . Here : G ( Y o ⇒ o ( λ L .λ x . if x ( L ( data x )))) Nil � Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 4 / 21
Alternating parity tree automata For a MSO formula ϕ , �G� � ϕ iff an equivalent APT A ϕ has a run over �G� . APT = alternating tree automata (ATA) + parity condition. Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 5 / 21
Alternating tree automata ATA: non-deterministic tree automata whose transitions may duplicate or drop a subtree. Typically: δ ( q 0 , if ) = (2 , q 0 ) ∧ (2 , q 1 ). Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 6 / 21
Alternating tree automata ATA: non-deterministic tree automata whose transitions may duplicate or drop a subtree. Typically: δ ( q 0 , if ) = (2 , q 0 ) ∧ (2 , q 1 ). q 0 q 0 if if q 0 q 1 Nil if if if data if data if data if − → A ϕ . . . . . . . . . Nil data Nil data Nil data data data data Nil Nil Nil Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 6 / 21
Alternating tree automata ATA: non-deterministic tree automata whose transitions may duplicate or drop a subtree. Typically: δ ( q 0 , if ) = (2 , q 0 ) ∧ (2 , q 1 ). This infinite process produces a run-tree of A ϕ over �G� . It is an infinite, unranked tree. Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 6 / 21
Alternating tree automata and intersection types A key remark (Kobayashi 2009): δ ( q 0 , if ) = (2 , q 0 ) ∧ (2 , q 1 ) can be seen as the intersection typing if : ∅ ⇒ ( q 0 ∧ q 1 ) ⇒ q 0 refining the simple typing if : o ⇒ o ⇒ o Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 7 / 21
Alternating tree automata and intersection types In a derivation typing if T 1 T 2 : δ . . . . ∅ ⊢ if : ∅ ⇒ ( q 0 ∧ q 1 ) ⇒ q 0 ∅ . . App ∅ ⊢ if T 1 : ( q 0 ∧ q 1 ) ⇒ q 0 Γ 1 ⊢ T 2 : q 0 Γ 1 ⊢ T 2 : q 1 App ∅ ⊢ if T 1 T 2 : q 0 Intersection types naturally lift to higher-order – and thus to G , which finitely represents �G� . Theorem (Kobayashi) ∅ ⊢ G : q 0 iff the ATA A ϕ has a run-tree over �G� . A step towards decidability. . . Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 8 / 21
Intersection types and linear logic A ⇒ B = ! A ⊸ B A program of type A ⇒ B duplicates or drops elements of A and then uses linearly (= once) each copy Just as intersection types. Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 9 / 21
Intersection types and linear logic A ⇒ B = ! A ⊸ B Two interpretations of the exponential modality: Quantitative models Qualitative models (Relational semantics) (Scott semantics) ! A = M fin ( A ) ! A = P fin ( A ) [ [ o ⇒ o ] ] = M fin ( Q ) × Q [ [ o ⇒ o ] ] = P fin ( Q ) × Q { q 0 , q 0 , q 1 } { q 0 , q 1 } [ q 0 , q 0 , q 1 ] � = [ q 0 , q 1 ] = Unbounded multiplicities Order closure Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 9 / 21
� � � � � � � � � Intersection types and linear logic Models of linear logic and intersection types (refining simple types): Bucciareli − Ehrhard � Non-idempotent types Rel Rel ! de Carvalho Ehrhard , G − M Ehrhard � Idempotent types Scott Scott ! Terui Fundamental idea: derivations of the intersection type systems compute denotations in the associated model. Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 10 / 21
� � � ✤ � � � � � � � � Intersection types and linear logic Models of linear logic and intersection types (refining simple types): Bucciareli − Ehrhard � Non-idempotent types Rel Rel ! de Carvalho Ehrhard , G − M Ehrhard � Idempotent types Scott Scott ! Terui � q 0 ∧ q 0 ∧ q 1 → q 0 [ q 0 , q 0 , q 1 ] ⊸ q 0 ❴ ❴ � q 0 ∧ q 1 → q 0 { q 0 , q 1 } ⊸ q 0 ✤ Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 10 / 21
� � � � � � � � � Intersection types and linear logic Models of linear logic and intersection types (refining simple types): Bucciareli − Ehrhard � Non-idempotent types Rel Rel ! de Carvalho Ehrhard , G − M Ehrhard � Idempotent types Scott Scott ! Terui Important remark: in order to connect idempotent types with a denotational model ( → invariance modulo βη ), one needs subtyping. Subtyping appears naturally in the Scott model, as the order closure condition. In the relational semantics/non-idempotent types: no such requirement. But unbouded multiplicities. . . Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 10 / 21
Four theorems: inductive version We obtain a theorem for every corner of our “equivalence square”: Theorem In the relational semantics, q 0 ∈ [ [ G ] ] iff the ATA A φ has a finite run-tree over �G� . Theorem With non-idempotent intersection types, ⊢ G : q 0 the ATA A φ has a finite run-tree over �G� . iff Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 11 / 21
Four theorems: inductive version We obtain a theorem for every corner of our “equivalence square”: Theorem In the Scott semantics, q 0 ∈ [ [ G ] ] iff the ATA A φ has a finite run-tree over �G� . Theorem With idempotent intersection types (+ subtyping), ⊢ G : q 0 iff the ATA A φ has a finite run-tree over �G� . Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 11 / 21
An infinitary model of linear logic Restrictions to finiteness: for Rel and non-idempotent types: lack of a countable multiplicity ω . Recall that tree constructors are free variables. . . for idempotent types: just need to allow infinite (or circular) derivations. for Scott : interpret Y as the gfp. In Rel , we introduce a new exponential A �→ � A s.t. [ [ � A ] ] = M count ([ [ A ] ]) (finite-or-countable multisets) Charles Grellois (PPS & LIAFA) Colored intersection types May 18th, 2015 12 / 21
Recommend
More recommend