CS792 Notes Henkin Models, Soundness and Completeness Arranged by Alexandra Stefan March 24, 2005 These notes are a summary of chapters 4.5.1-4.5.5 from [1]. 1 Review indexed family of sets: A s, where s is an index from a given set of indexes S. signature: Σ = (S, F) where S is a set of sorts and F is a collection of pairs f : s 1... s k s with s 1,..., s k, s S. Note that in the collection F, no f occurs in two distinct pairs. λ signature Σ (with the notations used in our chapter) Σ = (B, C) where B is the set of base types (or type constants ) and C is a collection of pairs c : σ. c is called a term constant of type σ. Note that σ needs to be correct. well-formed contexts Γ (each variable occurs at most one in the context) We will refer to the following inference rules. Note that in every such rule, we assume the context is well-formed. Γ M : σ (add var) Γ, x : τ M : σ axioms: Γ, x : σ M : τ Γ λx : σ.m : σ τ Γ (λx : σ.m)n = [N/x]M : τ ( Intro) (β) Γ λx : σ.mx = M : σ τ (η) What is the difference between an algebra and a model? 1
2 General models and the meanings of terms Goal we are looking for a model that: gives meaning to each type and term constant, makes sense of applications and lambda abstractions. If f A σ τ and a A σ then we must be able to apply f to x. Every lambda abstraction must have an interpretation in our model : Take A σ τ to be the set of all functions from A σ to A τ. : You wish it was that simple! Why can t you do it? Remember the major goal. We want a model for PCF (program computable functions). Recursive functions are central to computation. Fixed points are needed to interpret recursive definitions. In order to deal with this we have the fix operator. this operator returns the fixed point of the function it is applied to, therefore it each function in its domain must have a fixed point. fix σ : (σ σ) σ and fix σ M = M(fix σ M). In our setting the fix operator will be a term constant and it needs to have a value in some set. (For the above example it would be in A (σ σ) σ ). But if a set A σ has at least two elements, then there exists at least one function f : A σ A σ that does not have a fixed point. Therefore we need to define a more complex model the Henkin model. Such a model must respect three conditions: it must be an applicative structure it must be extensional it must respect the environment model condition 3 Applicative structures and extensionality Definition 3.1. A typed applicative structure A for λ signature Σ is a tuple {A σ }, {App σ,τ }, Const of families of sets and mappings indexed by type expressions over the type constants from Σ. For each σ and τ we assume the following conditions. A σ is a set, App σ,τ is a map App σ,τ : A σ τ (A σ A τ ), Const is a map from term constants of Σ to elements of the union of all the A σ s such that if c : σ, then Const(c) A σ 2
The map App σ,τ allows us to use every element of A σ τ as a function from A σ A τ. Const gives meaning for the term constants. The extensionality condition is equivalent to saying that the interpretation of a function type must be some set of functions. Definition 3.2. An applicative structure is extensional if it satisfies the condition: For all f, g A σ τ, if for all d A σ,app σ,τ f d = App σ,τ g d then f = g. This condition says that function App σ,τ must be one-to-one from A σ τ into the set of functions from A σ to A τ. The following is an example of a non-extensional applicative structure. (Example 4.5.1. in [1]) Let Σ be a signature and H be a (possibly infinite) type assignment H = {x 1 : σ 1, x 2 : σ 2,... }. We can define an applicative structure as follows: T = {T σ }, {App σ,τ }, Const T σ = {M Γ M : σ for some finite Γ H} App σ,τ MN = MN for every M A σ τ and N A σ, Const(c) = c. If for every type σ, there is an assignment x : σ in H for some variable x then T is extensional. Otherwise, if there exists σ such that T σ is empty, then any two elements of T σ τ will be extensionally equal(vacuously), so extensionality will fail if T σ τ has at least two elements. 4 Environment model condition We need to give meaning/interpretation to variables. For this we define an environment: Definition 4.1. An environment η for an applicative structure is a mapping from variables to the union of all A σ. If Γ is a type environment we say that η satisfies Γ, written η = Γ, if η(x) A σ for every x : σ Γ. If η is any environment for A, and d A σ, then η[x d] is the mapping: { d if y = x, η[x d](y) = η(y) otherwise. Definition 4.2. An applicative structure A satisfies the environment model condition if the following clauses define a meaning function A on terms Γ M : σ and environments η such that η = Γ. This function must be total. A c : σ η = Const(c) A x : σ x : σ η = η(x) A Γ, x : σ M : τ η = A Γ M : τ η A Γ MN : τ η = App σ,τ (A Γ M : σ τ η)(a Γ N : σ η) A Γ, x : σ M : σ τ η = the unique f A σ τ such that d A σ.app σ,τ fd = A Γ, x : σ M : τ η[x d]. When can the last clause fail? Remember the current setting. The main reason for using induction on typing derivations is that in defining the meaning of a lambda abstraction Γ λx : σ.m : σ τ, we ned to refer to the meaning of M in typing context Γ, x : σ. if we know that Γ λx : σ.m : σ τ is typed according to rule ( Intro), then we are guaranteed that Γ, x : σ is well-formed. Note that otherwise we would have a problem when the bounded variable occurs free in the body of the lambda abstraction, e.g., term x : σ λx : τ.x. 3
Example [the full set-theoretic function hierarchy over the natural numbers]: Define a Henkin model for the signature with only one base type nat as follows: A nat is the set of natural numbers, A σ τ be the set of all functions from A σ to A τ, App σ,τ f x = f(x). Work out the meaning of λx : nat nat, λy : nat.xy. Notation:In the following, if the model A is not important or known, we will not specify it in the meaning function. We will write Γ M : σ η instead of Γ M : σ η. Since we have used typing derivations in defining our meaning function, we need to show that the meaning of a well-typed term, does not depend on what typing derivation. We have a coherence problem here because we interpret syntactic expressions, using some extra information that is not uniquely determined by the expressions themselves. In our case, this information is the typing derivation. The following is an example of a coherence theorem. It will prove that our meaning function does not depend on the typing derivation. Lemma 4.1. Suppose that and are derivations of typings Γ M : σ and Γ M : σ, respectively, and that Γ and Γ give the same type to every x free in M. Then Γ M : σ η = Γ M : σ η where the meanings are defined using and respectively. 5 Type and equational soundness Since there are two proof systems, one for proving typing assertions and one for equations, there are two forms of soundness for λ and other typed lambda calculi. Theorem 5.1 (Type Soundness). If Γ M : σ is a provable typing assertion, then for every Henkin model A and every environment η for A s.t. η = Γ, it holds that A Γ M : σ η A σ. This lemma says that well-typed λ terms, do not contain type errors. Example: a signature that gives addition the type + : nat nat nat and a Henkin model that interprets + as a binary function on A nat. Definition 5.1. A Henkin model A and environment η, such that η = Γ, satisfy an equation Γ M = N : σ, written: A, η = Γ M = N : σ if A Γ M : σ η = A Γ M : σ η. We say that model A satisfies an equation Γ M = N : σ if for all environments η satisfying Γ, model A and environment η satisfy this equation. Definition 5.2. A set of typed equations E semantically implies another typed equation Γ M = N : σ if every Henkin model A that satisfies E (every equation in E) also satisfies Γ M = N : σ. We use the following notation for semantic implication: E = Γ M = N : σ. Theorem 5.2 (Soundness). For every set E of typed equations, if E Γ M = N : σ, then E = Γ M = N : σ. 4
6 Completeness for Henkin models without empty types We do not have completeness for Henkin models without extending the proof system. We add the following inference rule for reasoning about nonempty types: Γ, x : σ M = N : τ Γ M = N : τ x not free in M, N (nonempty) Theorem 6.1. Let E be any lambda theory closed under the rule (nonempty). Then there is a Henkin model A, with no A σ =, satisfying precisely the equations belonging to E. Proof. The theorem can be proved directly using a term model construction. References [1] John C. Mitchell : Foundations of Programming Languages. 5