Domains VIII Sobolev Institute of Mathematics Novosibirsk Akademgorodok 11 - 15 September, 2007 A domain-theoretic characterisation of strong normalisation in the λ - R -calculus Ulrich Berger Swansea University 1 / 52
Introduction � The λ - R -calculus � Domain-theoretic semantics � Characterising strong normalisation � Types and totality � Applications � Conclusion � References � 2 / 52
Introduction The strong normalisation problem Given a higher type rewrite system - typically an extension of G¨ odel’s system T by constants and rewrite rules - how can we prove strong normalisation? 3 / 52
Introduction Strong normalisation via totality We define a domain model with totality such that for any rewrite system: if all constants are total, then all terms are strongly normalising. Advantages 1. Totality is often easy to prove (for example, the totality of G¨ odel’s primitive recursor is proved by a trivial induction). 2. Totality is compositional, hence it can be proved for each constant separately. 4 / 52
Introduction Example: G¨ odel’s system T β -conversion, ( λ x . M ) N → M [ N / x ], plus R A G 0 → A R A G ( n + 1) → G n ( R A G n ) Suppressing arguments that are not changed in the recursive call of R this simplifies to → R 0 A R ( n + 1) → G n ( R n ) In the following examples we use this simplified notation. 5 / 52
Introduction Example: Spector’s barrecursion if Y α < n then G ( α, n ) else H α n ( λ x . BR ( α x BR ( α, n ) → n , n + 1)) where x < 0 → F 0 < ( y + 1) → T ( x + 1) < ( y + 1) → x < y and α x n := λ m . if m = n then x else α m Think of ( α, n ) as coding the finite sequence [ α 0 , . . . , α ( n − 1)]. Hence ( α x n , n + 1) codes the sequence [ α 0 , . . . , α ( n − 1) , x ]. 6 / 52
Introduction Example: Open recursion Y α ( λ n , x , β. if x ≺ α n then OR ( α x ,β OR α → n ) else 0 ) where α x ,β = λ m . if m ≤ n then α x n m else β m . n Think of α as ranging over infinite sequences ordered lexicographically by ≺ . Hence α x ,β n , with x ≺ α n , ranges over all infinite sequences lexicographically below α . 7 / 52
Introduction From operational to denotational semantics The rewrite rules we have seen are all meaningful w.r.t. a domain semantics, since they can be viewed as recursive definition. That is, the denotational semantics of a constant is the least fixed point of the effectively continuous function explicitely defined by the rules. 8 / 52
Introduction Example: Nondeterministic choice x | | y → x x | | y → y ◮ Used by Kristiansen (CiE 2006) to characterise the nondeterministic polynomial hierarchy in terms of fragments of G¨ odel’s T . ◮ What is its denotational semantics? ◮ Can destroy termination: extending G¨ odel’s T by f 0 1 x → f x x x still terminates, but adding further | | yields | 1) → 2 f 0 1 (0 | f 0 1 (0 | | 1) → f (0 | | 1) (0 | | 1) (0 | | 1) (Toyama) 9 / 52
Introduction Nondeterministic denotational semantics We interpret terms as nondeterministic values, i.e. as finite sequences of deterministic values. The choice operator | | is interpreted as the concatenation operation. 10 / 52
Introduction From denotational semantics to strong normalisation We characterise strong normalisation by the denotational property of having a defined value. Altogether we have: [ [ M ] ] total ⇒ [ [ M ] ] � = ⊥ ⇔ M strongly normalising 11 / 52
Introduction The main ideas ◮ Adequacy for PCF (Plotkin): If a closed PCF-term of base type denotes a numeral in the domain model, then it weak head reduces to that numeral. ◮ Characterisation of strongly normalising (pure) λ -terms by intersection types (Pottinger). ◮ Intersection types as a filter model of λ -terms (Barendregt, Coppo, Dezani, van Bakel). The connection with intersection types was pointed out by Thomas Ehrhard. 12 / 52
Introduction Previous work ◮ “[ [ M ] ] � = ⊥ ⇒ SN ( M )” for deterministic rewrite systems, assuming SN for the underlying type theory (B 05). ◮ “[ [ M ] ] � = ⊥ ⇒ SN ( M )” for deterministic rewrite systems, unconditionally, using the “intersection types as filter models” idea (Coquand, Spiwack 06). New in this talk: ◮ Nondeterminism. ◮ Completeness: “[ [ M ] ] � = ⊥ ⇔ SN ( M )”. ◮ Abstract domain theory instead of formal typing rules. 13 / 52
The λ - R -calculus Terms Λ ∋ M , N ::= variable x | constructor (always includes T , F ) c | f constant | ( M , N ) pair | λ x . M abstraction | M N application | if ( M , N ) definition by cases Notation: if K then M else N := if ( M , N ) K . 14 / 52
The λ - R -calculus Rewrite systems For every constant f we assume a list R f of rules of the form f � P → M where ◮ � P is a list of patterns , i.e. terms built from constructors, variables and pairing, such that in � P no variable occurs more than once; ◮ M is a term with FV ( M ) ⊆ FV ( � P ); ◮ the length of the pattern list � P is fixed for each f (this fixed length is called the arity of f ); ◮ only finitely many left hand sides are allowed to be unifiable. 15 / 52
The λ - R -calculus Example → R A G 0 A R A G ( S , n ) → G n ( R A G n ) constant of arity 3 R 0 , S constructors A , G , n variables 16 / 52
The λ - R -calculus Reduction, K → K ′ Contracting a subterm of K which is not in a branch of an if -term, where contracts to ( λ x . M ) N M [ N / x ] if ( M , N ) T M if ( M , N ) F N f � ( f � P θ M θ P → M a rule, θ a substitutition) 17 / 52
The λ - R -calculus Strong normalisation A term M is strongly normalising , SN ( M ), if there is no infinite reduction sequence M → M ′ → M ′′ → . . . 18 / 52
The λ - R -calculus Safety A term is safe if (1) every constant f occurs only in contexts of the form f M 1 . . . M k where k is the arity of f , (2) no constructor or pair occurs as the left hand side of an application, (3) (inductively) all reducts are safe. Safety is usually guaranteed by typability. 19 / 52
Domain-theoretic semantics A strict reflexive Scott-domain D = C ⊥ ⊕ ( D ∗ ⊗ D ∗ ) ⊕ ( D ∗ ! → D ∗ ) C ⊥ flat domain of constructors D ∗ strict finite lists (non-deterministic values) ⊗ strict (or smash) product ⊕ strict (or coalesced) sum ! → strict function space The elements of D + := D \ ⊥ : c ( c a constructor) ( d , e ∈ D ∗ ( d , e ) + ) ( f : D ∗ → D ∗ , continuous, strict, � = ⊥ ) fun ( f ) 20 / 52
Domain-theoretic semantics Some important operations app ( fun ( f ) , d ) := f ( d ) app ( d , d ) := ⊥ , if d is a pair or a constructor d • e := [ app ( d , e ) | d ← d ] T ⊲ d := d F ⊲ d := [] match P : D ∗ → ( FV ( P ) → D ∗ ) ∗ match x ( d ) = [[ x �→ d ]] match c ( d ) = ( c ∈ d ) ⊲ [ ∅ ] [ η ∪ η ′ | ( e , e ′ ) ← d , η ← match P ( e ) , match ( P , Q ) ( d ) = η ′ ← match Q ( e ′ )] 21 / 52
Domain-theoretic semantics ] η ∈ D ∗ The value of a term: [ [ M ] [ [ x ] ] η = η ( x ) [ [ c ] ] = [ c ] [ [( M , N )] ] η = [([ [ M ] ] η, [ [ N ] ] η )] ] η • [ [ [ MN ] ] η = [ [ M ] [ N ] ] η [ fun ( λ d ∈ D ∗ . [ [ [ λ x . M ] ] η = [ M ] ] η [ x := d ])] [ fun ( λ d ∈ D ∗ . ( T ∈ d ⊲ [ + ( F ∈ d ⊲ [ [ [ if ( M , N )] ] η = [ M ] ] η ) + [ N ] ] η ))] [ fun k ( λ� d ∈ ( D ∗ ) k . [ [ f ] ] = ] η | ( � P ( � P �→ M ) ← R f , η ← match � concat [ [ [ M ] d ) ] )] where η : FV ( M ) → D ∗ and k = arity ( f ). 22 / 52
Domain-theoretic semantics The analogy with intersection types The relation U ⊑ [ [ M ] ] η, where U ranges over non-deterministic defined compacts, can be defined inductively, similar to typing judgements in the intersection type calculus ( η ⊢ M : U ). This has been carried out (without non-determinism) by Coquand and Spiwack. Hence, “[ [ M ] ] η � = ⊥ ”, which is equivalent to “ ∃ U ( U ⊑ [ [ M ] ] η )”, can be read as “ M is typeable”. 23 / 52
Characterising strong normalisation Strong normalisation theorem Set [ [ M ] ] := [ [ M ] ] η 0 where η 0 ( x ) := [] for all variables x . For every safe term M , [ [ M ] ] � = ⊥ ⇔ M is strongly normalising We sketch the proof of “ ⇒ ” (which doesn’t need the safety assumption). 24 / 52
Characterising strong normalisation Reducibility candidates A term is simple if it has neither of the following forms: c � N , ( M 1 , M 2 ) � N , λ x . M , if then M else N , f N 1 . . . N k where k < arity ( f ). A reducibility candidate is a set X of terms such that X ⊆ SN . RC1 If M ∈ X and M → M ′ , then M ′ ∈ X . RC2 If M is simple and ∀ M ′ ( M → M ′ ⇒ M ′ ∈ X ), then RC3 M ∈ X . X → Y := { M | ∀ N ( N ∈ X ⇒ MN ∈ Y ) } . X × Y := { ( M , N ) | M ∈ X , N ∈ Y } ( ⊆ Λ). RC3 ( X ) := the closure of X under the rule RC3 above. 25 / 52
Characterising strong normalisation Rank D = lim n D n , with canonical embeddings ǫ n : D n → D , where = {⊥} D 0 ! C ⊥ ⊕ ( D ∗ n ⊗ D ∗ n ) ⊕ ( D ∗ → D ∗ = n ) D n +1 n For compacts U ∈ D \ ⊥ and U ∈ D ∗ \ ⊥ we set min { n | n ∈ ǫ n ( D n ) } rk ( U ) := rk ( U ) := sup { rk ( U ) | U ∈ U } (the stage where U resp. U is constructed) 26 / 52
Recommend
More recommend