Docstoc

05 Simple Type Theory

Document Sample
05 Simple Type Theory Powered By Docstoc
					    SE 2F03 Fall 2005


05 Simple Type Theory

    Instructor: W. M. Farmer

   Revised: 22 November 2005




                               1
Theory-Oriented vs.
Practice-Oriented Logics
 • Most traditional logics are theory oriented: they are
   designed to be studied and used in theory only.
   – Examples: First-order logic, Zermelo-Fraenkel set
     theory.

 • A practice-oriented logic is intended for actual use in
   practice by engineers, scientists, mathematicians, and
   students.
   – Often are modifications of traditional logics.
   – Examples: Versions of Church’s type theory used in
     the HOL, IMPS, Isabelle, ProofPower, PVS, and TPS
     systems.

 • The logic of a mechanized mathematics system needs to
   be practice oriented.

                                                     2
Attributes of a Practice-Oriented Logic
 • Expressivity

 • Clarity

 • Naturalness

 • Conciseness




                                   3
Issue 1: Conditional Expressions
 • A conditional expression is an expression whose
   value depends on specified conditions.
   – Example: “If C then v1 else v2.”

 • Conditional formulas can be expressed using implication
   and conjunction.
   – Example: (p(x) ⇒ q(x)) ∧ (¬p(x) ⇒ r(x)).

 • Conditional terms can be expressed with an if-then-else
   term constructor or with tables.
   – Example: if(0 ≤ x, x, −x).
   – Example:
        condition   value
          x<0        −x
          x=0         0
          x>0         x

                                                     4
Issue 2: Function Abstraction
 • A function abstraction is an expression that defines a
   function from an expression containing variables written
   formally as λ x . t in computer science and as x → t in
   mathematics.
   – Example: λ x . x2.
   – This is called lambda-notation.

 • Informal notation for function abstraction in
   mathematical practice is ambiguous.
   – Example: f (x) = x2.
   – Does this example mean the function f is defined as
     x2 or that the function f applied to x is x2?

 • Lambda-notation allows functions to be defined directly
   and unambiguously.
   – Example: f = (λ x . x2 + x ∗ y + 2 ∗ y).
                                                     5
Issue 3: Definite and Indefinite
Description

 • A definite description is an expression of the form
   “the x such that A” written formally as ι x . A.
   – Example: ι x . 0 ≤ x ∧ x ∗ x = 2.

 • An indefinite description is an expression of the form
   “some x such that A” written formally as x . A.
   – Example:    x . x ∗ x = 2.

 • Definite descriptions, and to a lesser extent indefinite
   descriptions, are quite common in mathematical practice,
   but they often occur in a disguised form.

 • Improper definite and indefinite descriptions are
   undefined.
                                                     6
Issue 4: Types
 • A type is a syntactic object α that denotes a set Dα of
   values.
   – α and Dα are often confused with each other.
   – Types are also called sorts.

 • Types are used to:
   –   Restrict the scope of variables.
   –   Control the formation of expressions.
   –   Organize values.
   –   Classify expressions by their values.

 • In mathematical practice, types are informal and used
   mainly for restricting the scope of variables.

 • There is a wide range of type systems.

 • Types are also sometimes used as “mini-specifications”.

                                                     7
Issue 5: Higher-Order Values
 • A higher-order value is a value constructed from other
   values.
   – Examples: Sets, functions, relations, tuples, sequences,
     and algebras.
   – A practice-oriented logic needs to support reasoning
     with high-order values including quantification over
     higher-order values.

 • A higher-order value may be constructed from values of
   the same kind.
   – Examples: A set of sets, a function that maps
     functions to functions, a relation between relations.

 • A function f : A × B → C can be represented in three
   ways:
   – As a binary function from A and B to C.
   – As a unary function from A × B to C.
   – As a curryed function from A to B → C.
                                                       8
Issue 6: Undefinedness
• A mathematical term is undefined if it has no prescribed
  meaning or if it denotes a value that does not exist.
  – Undefined terms are commonplace in mathematics.

• Sources of undefinedness:
                                       √
  1. Improper function applications: −4.
  2. Improper definite descriptions:
       “the x such that x2 = 4”.
  3. Improper indefinite descriptions:
       “some x such x2 = −4”.

• A practice-oriented logic needs a way of handling
  undefinedness:
  –   Traditional approach to undefinedness
  –   Unspecified values
  –   Error values
  –   Ill-formed terms
                                                      9
Issue 7: Polymorphism

 • An operator is polymorphic if it can be applied to
   expressions of different types.

 • Polymorphic operators are not usually needed in
   mathematical practice since, by convention, operators
   can be applied to all expressions (but the applications
   may be undefined).

 • A practice-oriented logic needs polymorphic operators in
   some form:
   – Type variables.
   – Macro-abbreviations.
   – All values are members of a universal class.



                                                        10
Issue 8: Syntax as Values

 • An expression has a two meanings:
   1. The value it denotes.
   2. Its syntactic construction.

 • Both meanings are important in mathematics, but the
   distinction between them is often confused.

 • A practice-oriented logic needs to be able to reason about
   both meanings of an expression.




                                                       11
What is Simple Type Theory?
• A simple, elegant, highly expressive, and practical logic.
  – Familiar to some computer scientists but not to many
    mathematicians, engineers, and other scientists.
  – Also known as higher-order logic.

• Most popular form of type theory.
  – Types are used to classify expressions by value and
    control the formation of expressions.
  – Classical: nonconstructive, 2-valued.
  – Higher order: quantification over functions.
  – Can be viewed as a “function theory”.

• Natural extension of first-order logic.
  – Based on the same principles as first-order logic.
  – Includes nth-order logic for all n ≥ 1.
                                                       12
Some Versions of Simple Type Theory
• Church’s type theory is a version of simple type theory
  with lambda-notation introduced by A. Church in 1940.

• STT is a very simple version of Church’s type theory.
  – Addresses issues 1,2,3,4,5.

• BESTT is a more practical version of Church’s type
  theory with type variables and support for reasoning with
  tuples, lists, and sets.
  – Addresses issues 1,2,3,4,5,6,7.




                                                     13
References

1. P. B. Andrews, An Introduction to Mathematical Logic
   and Type Theory: To Truth through Proof, Second
   Edition, Kluwer, 2002.

2. A. Church, “A formulation of the simple theory of types”,
   Journal of Symbolic Logic 5: 56–68, 1940.

3. W. Farmer, “The seven virtues of simple type theory”,
   SQRL Report No. 18, 30 pp., McMaster University, 2003
   (revised 2005).

4. W. Farmer,“A basic extended simple type theory”, SQRL
   Report No. 14, 12 pp., McMaster University, 2003
   (revised 2004).


                                                      14
Syntax of STT: Types

• A type of STT is defined by the following rules:

     T1             (Type of individuals)
          type[ι]

     T2             (Type of truth values)
          type[∗]

        type[α], type[β]
     T3                  (Function type)
         type[(α → β)]


• Let T denote the set of types of STT.




                                                    15
Syntax of STT: Symbols

• The logical symbols of STT are:
  – Function application: @ (hidden).
  – Function abstraction: λ.
  – Equality: =.
  – Definite description: I (capital iota).
  – An infinite set V of symbols called variables.

• A language of STT is a pair L = (C, τ ) where:
  – C is a set of symbols called constants.
  – τ : C → T is a total function.




                                                    16
Syntax of STT: Expressions
• An expression E of type α of a STT language
  L = (C, τ ) is defined by the following rules:
         x ∈ V, type[α]
     E1                   (Variable)
        exprL[(x : α), α]
              c∈C
     E2                   (Constant)
          exprL[c, τ (c)]
        exprL[A, α], exprL[F, (α → β)]
     E3                                (Application)
               exprL[F (A), β]
        x ∈ V, type[α], exprL[B, β]
     E4                               (Abstraction)
        exprL[(λ x : α . B), (α → β)]
          exprL[E1, α], exprL[E2, α]
     E5                              (Equality)
             exprL[(E1 = E2), ∗]
        x ∈ V, type[α], exprL[A, ∗]
     E6                             (Definite description)
            exprL[(I x : α . A), α]
                                                  17
Syntax of STT: Conventions

• Eα denotes an expression E of type α.

• Parentheses and the types of variables may be dropped
  when meaning is not lost.




                                                  18
Semantics of STT: Standard Models
• A standard model for a language L = (C, τ ) of STT is
  a triple M = (D, I, e) where:
  – D = {Dα : α ∈ T } is a set of nonempty domains (sets).
  – D∗ = {t, f}, the domain of truth values.
  – Dα→β is the set of all functions from Dα to Dβ .
  – I maps each c ∈ C to an element of Dτ (c).
  – e maps each α ∈ T to a member of Dα.

• A variable assignment into M is a function that maps
  each expression (x : α) to an element of Dα.

• Given a variable assignment ϕ into M , an expression
  (x : α), and d ∈ Dα, let ϕ[(x : α) → d] be the variable
  assignment ϕ into M such that ϕ ((x : α)) = d and
  ϕ (v) = ϕ(v) for all v = (x : α).

                                                       19
Semantics of STT: Valuation Function
The valuation function for a standard model M = (D, I, e)
for a language L = (C, τ ) of STT is the binary function V M
that satisfies the following conditions for all variable
assignments ϕ into M and all expressions E of L:
                           M
1. Let E is (x : α). Then Vϕ (E) = ϕ((x : α)).
                    M
2. Let E ∈ C. Then Vϕ (E) = I(E).
                         M        M       M
3. Let E be F (A). Then Vϕ (E) = Vϕ (F )(Vϕ (A)).
                                    M
4. Let E be (λ x : α . Bβ ). Then Vϕ (E) is the f : Dα → Dβ
                                        M
   such that, for each d ∈ Dα, f (d) = Vϕ[(x:α)→d](Bβ ).

                            M        M             M
5. Let E be (E1 = E2). If Vϕ (E1) = Vϕ (E2), then Vϕ (E) =
                 M
   t; otherwise Vϕ (E) = f.

6. Let E be (I x : α . A). If there is a unique d ∈ Dα such that
     M                          M                       M
   Vϕ[(x:α)→d](A) = t, then Vϕ (E) = d; otherwise Vϕ (E) =
   e(α).
                                                          20
Abbreviations
 T                means   (λ x : ∗ . x) = (λ x : ∗ . x).
 F                means   (λ x : ∗ . T) = (λ x : ∗ . x).
 (¬A∗)            means   A∗ = F.
 (Aα = Bα)        means   ¬(Aα = Bα).
 (A∗ ∧ B∗)        means   (λ f : ∗ → (∗ → ∗) . f (T)(T)) =
                          (λ f : ∗ → (∗ → ∗) . f (A∗)(B∗)).
 (A∗ ∨ B∗)        means   ¬(¬A∗ ∧ ¬B∗).
 (A∗ ⇒ B∗)        means   ¬A∗ ∨ B∗.
 (A∗ ⇔ B∗)        means   A∗ = B∗.
 (∀ x : α . A∗)   means   (λ x : α . A∗) = (λ x : α . T).
 (∃ x : α . A∗)   means   ¬(∀ x : α . ¬A∗).
 ⊥α               means   I x : α . x = x.
 if(A∗, Bα, Cα)   means   I x : α . (A∗ ⇒ x = Bα) ∧ (¬A∗ ⇒ x = Cα)
                          where x does not occur in A∗, Bα, or Cα.



                                                       21
Expressivity
 • Theorem. There is a faithful interpretation of nth-order
   logic in STT for all n ≥ 1.

 • Most mathematical notions can be directly and naturally
   expressed in STT.

 • Examples:
     equiv-rel = λ p : (ι → (ι → ∗)) .
      ∀ x : ι . p(x)(x) ∧
      ∀ x, y : ι . p(x)(y) ⇒ p(y)(x) ∧
      ∀ x, y, z : ι . (p(x)(y) ∧ p(y)(z)) ⇒ p(x)(z)

     compose = λ f : (ι → ι) . λ g : (ι → ι) . λ x : ι . f (g(x))

     inv-image = λ f : (ι → ι) . λ s : (ι → ∗) .
       I s : (ι → ∗) . ∀ x : ι . s (x) ⇔ s(f (x))

                                                             22
Peano Arithmetic
• Let PA = (L, Γ) be the theory of STT such that:

  L = ({0, S}, τ ) where τ (0) = ι and τ (S) = ι → ι.

  Γ is the set of the following three formulas:

  1. 0 has no predecessor: ∀ x : ι . 0 = S(x).

  2. S is injective: ∀ x, y : ι . S(x) = S(y) ⇒ x = y.

  3. Induction principle:
     ∀P : ι → ∗ .
        P (0) ∧ (∀ x : ι . P (x) ⇒ P (S(x))) ⇒ ∀ x : ι . P (x).


• Theorem (Dedekind, 1888). PA has (up to
  isomorphism) a unique standard model M = (D, I, e)
  where Dι = {0, 1, 2, . . .}.

                                                             23
Incompleteness of STT

  Theorem. There is no sound and complete proof system
  for STT.

  Proof. Suppose P is a sound and complete proof system
                                           o
  for STT. By the soundness of P and G¨del’s Incom-
  pleteness Theorem, there is a sentence A such that (1)
  M |= A, where M is the unique standard model for PA (up
  to isomorphism), and (2) PA P A. By the completeness
  of P, (2) implies PA |= A and hence M |= A since M is
  the only standard model of PA, which contradicts (1). 2




                                                    24
A Proof System for STT (1)
• Axioms:

    A1 (Truth Values)
    ∀ f : ∗ → ∗ . (f (T∗) ∧ f (F∗)) ⇔ (∀ x : ∗ . f (x)).
    A2 (Leibniz’ Law)
    ∀ x, y : α . (x = y) ⇒ (∀ p : α → ∗ . p(x) ⇔ p(y)).
    A3 (Extensionality)
    ∀ f, g : α → β . (f = g) = (∀ x : α . f (x) = g(x)).
    A4 (Beta-Reduction)
    (λ x : α . Bβ )(Aα) = Bβ [x → Aα]
    provided Aα is free for x in Bβ .
    A5 (Proper Definite Description)
    (∃ ! x : α . A) ⇒ A[(x : α) → (I x : α . A)].
    A6 (Improper Definite Description)
    ¬(∃ ! x : α . A) ⇒ (I x : α . A) = ⊥α.
                                                           25
A Proof System for STT (2)

• Rule of inference:
    R (Equality Substitution)
    From Aα = Bα and C∗ infer the result of replacing one
    occurrence of Aα in C∗ by an occurrence of Bα.

• Call this proof system A.
  – Due to Andrews, 1963.

• Theorem (Jensen, 1969). A plus an axiom of infinity
  is equiconsistent with bounded Zermelo set theory.




                                                   26
Ways of Making STT More Practical

• Make the logic many-sorted by allowing several types of
  individuals, e.g., ι1, . . . , ιn.

• Add machinery for basic mathematical objects such as
  sets, tuples, and lists.

• Admit polymorphic operators like (λ x : t . x) by
  introducing type variables.

• Enrich the type system of STT with new machinery such
  as subtypes, dependent types, and user-defined type
  constructors.

• Modify the semantics of STT to include partial
  functions and undefined expressions.
                                                      27
Conclusion

 • Simple type theory is a logic that is effective for practice
   as well as theory—unlike first-order logic.
   – More expressive and more convenient.
   – Closer to mathematical practice.
   – Based on the same principles as first-order logic.
   – Includes the full machinery of first-order logic.
   – Integrates predicate logic, function theory, and type
     theory.

 • We recommend that simple type theory be incorporated
   into:
   – Logic courses offered by mathematics departments.
   – The undergraduate curriculum for computer science
     and software engineering students.

                                                        28

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:13
posted:11/5/2011
language:Spanish
pages:28