viewing terms through maps
play

Viewing -terms through Maps Masahiko Sato Kyoto University Randy - PowerPoint PPT Presentation

Viewing -terms through Maps Viewing -terms through Maps Masahiko Sato Kyoto University Randy Pollack Harvard University Helmut Schwichtenberg University of Munich Takafumi Sakurai Chiba University Version of April 28, 2013 Viewing


  1. Viewing λ -terms through Maps Viewing λ -terms through Maps Masahiko Sato Kyoto University Randy Pollack Harvard University Helmut Schwichtenberg University of Munich Takafumi Sakurai Chiba University Version of April 28, 2013

  2. Viewing λ -terms through Maps Outline Motivation The Intuition Maps Lambda terms with maps Syntax and well formedness Hole filling Use of parameters Λ : Raw λ -terms Working with Λ The βη -calculus Conclusion

  3. Viewing λ -terms through Maps Motivation Motivation: Formal representation of binding with natural reasoning ◮ Concrete: inductively definable in (say) Coq and HOL. ◮ Eliminates nominal: needs extensionality and quotients. ◮ Canonical: α -equivalence is identity. ◮ Eliminates McKinna and Pollack representation (from 1993). ◮ Reasoning: structural. ◮ Eliminates pure de Bruijn. ◮ Reasoning without equivariance, name swapping, special derived induction principles, etc. ◮ Eliminates locally nameless and Sato canonical representations. ??? The representation of this talk makes some progress.

  4. Viewing λ -terms through Maps The Intuition Intuition: Maps for binding ◮ Map s generalize the notion of occurrance . ◮ Maps are binary trees over 0 and 1 . ◮ Example: ◮ Occurrences of x in ( xz )( yz ) represented by map ( 10 )( 00 ) . ◮ Occurrences of z in ( xz )( yz ) represented by map ( 01 )( 01 ) . λ -term S = λ xyz . ( xz )( yz ) is represented ◮ ( 10 00 ) \ ( 00 10 ) \ ( 01 01 ) \ ( ✷✷ ✷✷ ) (We drop some parentheses for readability.) ◮ Bound positions represented only by constant ✷ (called box ).

  5. Viewing λ -terms through Maps The Intuition Open terms ✷ may occur unbound. ◮ ✷ is a distinguished constant. ◮ ◮ We accept ✷ as a term. 1 \ ✷ represents λ z . z . ◮ 0 \ ✷ represents λ x . z . ◮ Unbound box is available for binding or substitution, ◮ 1 \ 0 \ ✷ represents λ z . λ x . z . ◮ ◮ Free variables may occur in terms, ◮ the informal term λ z . ( xz ) is written as ( 0 1 ) \ ( x ✷ ) . ◮ There are no bound names or de Bruijn indices.

  6. Viewing λ -terms through Maps The Intuition Well-formedness conditions needed ◮ Free variables cannot be bound: ◮ maps can only bind ✷ , 0 \ x is a term, 1 \ x is not a term. ◮ ◮ We will show how to bind names. ◮ Want canonical representation: one representative per λ -term. 0 \ 1 \ ✷ is our notation for λ x . λ x . x (which equals λ y . λ x . x ) ◮ 1 \ 1 \ ✷ is not a term. ◮ ◮ Substitution: Consider the term ( 0 1 ) \ ( ✷ ✷ ) ; ◮ position ( 1 0 ) (the red ✷ ) is free, ◮ substitute ( ✷ ✷ ) in that position, ◮ get ( 0 1 ) \ (( ✷ ✷ ) ✷ ) which is not a term because 0 is not a position in ( ✷ ✷ ) . ◮ The solution: identify maps 0 and ( 0 0 ) .

  7. Viewing λ -terms through Maps The Intuition Compare with other notations ◮ Abstraction by names (raw terms or nominal terms): ◮ Binding information shared between binding occurrences and bound occurrences (shared names). ◮ Substitution may require α -conversion of the base term. ◮ Abstraction by indexes (de Bruijn): ◮ Binding information only at bound occurrences (indexes). ◮ At binding point, only λ to mark structure. ◮ Substitution may require de Bruijn lifting of the implanted term. ◮ Abstraction by maps: ◮ Binding information only at binding occurrences (maps). ◮ At bound points, only ✷ to mark structure. ◮ No adjustment required for substitution.

  8. Viewing λ -terms through Maps The Intuition Formalization ◮ Everything that follows is formalized in Isabelle/HOL. ◮ The apparent quotients and partial functions are coded in HOL without any actual quotienting of datatypes or “domain predicates” of functions. ◮ Correctness of the map representation is proved w.r.t. Nominal Isabelle. ◮ Independently, correctness of the map representation is proved w.r.t. de Bruijn nameless terms in Minlog. ◮ However our favorite form of the map approach is not representable in HOL or easily representable in Coq: ◮ Requires induction-recursion or induction-induction.

  9. Viewing λ -terms through Maps Maps Maps, M , defined inductively ◮ Maps are binary trees over 0 and 1 , with the identification ( 0 0 ) = 0 . ◮ Can formalize this inductively without quotienting using an auxiliary type M + not containing 0 : m + ∈ M + n + ∈ M + 1 ∈ M + inl ( m + ) ∈ M + inr ( n + ) ∈ M + m + ∈ M + n + ∈ M + cons ( m + , n + ) ∈ M + ◮ Extend M + with 0 to get M m + ∈ M + m + ∈ M 0 ∈ M

  10. Viewing λ -terms through Maps Maps Map application ◮ For “cons” on M we define:  0 if m = n = 0 ,   inl ( m ) if m � = 0 and n = 0 ,  mapp ( m , n ) := inr ( n ) if m = 0 and n � = 0 ,   cons ( m , n ) if m � = 0 and n � = 0 .  (Eliding explicit inclusion of M + in M .) ◮ Write ( m n ) for mapp ( m , n ) , ( m 1 m 2 m 3 ) for (( m 1 m 2 ) m 3 ) , etc. mapp is injective. ◮

  11. Viewing λ -terms through Maps Maps Orthoganality on maps ◮ A symmetric orthogonality relation ⊥ : m ′ ⊥ n ′ m ⊥ n mm ′ ⊥ nn ′ m ⊥ 0 0 ⊥ n m ⊥ n means: ◮ m and n have the same shape ◮ m and n bind different positions in that shape. ◮ 0 has every shape and binds no positions. ◮

  12. Viewing λ -terms through Maps Lambda terms with maps Syntax and well formedness Lambda terms as a subtype ◮ Symbolic expressions ( S ) are raw syntax: S ∈ S T ∈ S m ∈ M S ∈ S x ∈ S ✷ ∈ S ( S T ) ∈ S m \ S ∈ S ◮ Well formedness ( m | S ; m divides S ): m | S n | T 0 | x 0 | ✷ 1 | ✷ mn | ST m | T n | T m ⊥ n m | ( n \ T ) m | S means ◮ “ S is well-formed and m is a position of unbound boxes in S ”. m | S = ⇒ 0 | S . ◮ 0 | S means “ S is well formed”. ◮

  13. Viewing λ -terms through Maps Lambda terms with maps Syntax and well formedness Aside: Syntax and well-formedness simultaneously L is a type. ◮ M ∈ L N ∈ L x ∈ L ✷ ∈ L ( M N ) ∈ L m ∈ M M ∈ L m | M m \ M ∈ L ◮ Divides is a relation | ⊆ M × L . m | M n | N 0 | x 0 | ✷ 1 | ✷ ( m n ) | ( M N ) m | N n | N m ⊥ n m | ( n \ N ) ◮ Not simultaneous inductive definition due to L in the type of | . ◮ Need induction-induction or induction-recursion to formalize.

  14. Viewing λ -terms through Maps Lambda terms with maps Hole filling Hole filling ◮ Define the partial operation M m [ P ] : L × M × L → L : ✷ 1 [ P ] := P . ✷ 0 [ P ] := ✷ . x 0 [ P ] := x . ( M N ) ( m n ) [ P ] := ( M m [ P ] N n [ P ]) if m | M and n | N . ( n \ N ) m [ P ] := n \ ( N m [ P ]) if m | ( n \ N ) . ◮ Only defined if m | M ( m is a position of unbound holes in M ). ◮ Hole filling is a homomorphism, even going under binders. ◮ Hole filling respects well-formedness: m | M ∧ 0 | N = ⇒ 0 | M m [ N ] . ◮ Why is the last equation well-formed?

  15. Viewing λ -terms through Maps Lambda terms with maps Use of parameters Parameters: map, skeleton, abstraction ◮ map , M x , computes the map of all the occurrences of x in M . ◮ skel , M x , replaces all occurrences of x in M by ✷ . map : X × L → M skel : X × L → L � 1 � ✷ if x = y , if x = y , y x := y x := 0 if x � = y . y if x � = y . ✷ x := ✷ . ✷ x := 0 . ( M N ) x := ( M x N x ) . ( M N ) x := ( M x N x ) . ( m \ M ) x := m \ M x . ( m \ M ) x := M x . ◮ With map and skel can define abstraction of a name from a term. lam ( x , M ) := M x \ M x lam ( x , M ) does not contain x . ◮

  16. Viewing λ -terms through Maps Lambda terms with maps Use of parameters Substitution defined by hole filling subst : L × X × L → L M { x \ P } := ( M x ) M x [ P ] . ◮ Some provable equations of substitution � P if x = y , y { x \ P } = y if x � = y . ✷ { x \ P } = ✷ . ( M N ) { x \ P } = ( M { x \ P } N { x \ P } ) if 0 | M and 0 | N . ( m \ M ) { x \ P } = ( m \ M { x \ P } ) if m | M . ◮ These equations eliminate substitution on concrete terms. ◮ Substitution is a homomorphism. ◮ There are no name-freshness conditions on these equations.

  17. Viewing λ -terms through Maps Lambda terms with maps Use of parameters Substitution lemma of λ -calculus: better proof If x � = y and x ♯ P , then M { x \ N }{ y \ P } = M { y \ P }{ x \ N { y \ P }} . ◮ In named representations (including locally nameless and nominal) this proof requires choosing a fresh name. ◮ When M = λ z . M ′ we must assume z ♯ ( x , y , N , P ) ◮ By equivariance, strengthened induction principle, . . . Our proof ◮ By induction on (well-formedness of) M . ◮ Each case completely solved by equational reasoning. ◮ Using the equations of substitution and the IH. ◮ No need for fresh names to appy the equations of substitution.

  18. Viewing λ -terms through Maps Λ : Raw λ -terms Datatype Λ of raw λ -syntax K ∈ Λ L ∈ Λ K ∈ Λ x ∈ Λ ✷ ∈ Λ ( K L ) ∈ Λ lam ( x , K ) ∈ Λ ◮ Define map ( K x ) and skel ( K x ) on Λ K x computes the map of occurrences of x in K . ◮ K x replaces every x in K with ✷ . ◮ map : X × λ → M skel : X × λ → λ � � 1 if x = y , if x = y , ✷ y x := y x := 0 if x � = y . y if x � = y . ✷ x := ✷ . ✷ x := 0 . ( K L ) x := ( K x L x ) . ( K L ) x := ( K x L x ) . � 0 � lam ( y , K ) if x = y , if x = y , lam ( y , K ) x := lam ( y , K ) x := lam ( y , K x ) K x if x � = y . if x � = y .

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend