• Keine Ergebnisse gefunden

Foundations of Higher-Order Logic

N/A
N/A
Protected

Academic year: 2022

Aktie "Foundations of Higher-Order Logic"

Copied!
7
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

3. Foundations of Higher-Order Logic 3.0

Chapter 3

Foundations of Higher-Order Logic

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 136

3. Foundations of Higher-Order Logic 3.0

Overview of Chapter

3. Foundations of Higher-Order Logic 3.1 Introduction

3.2 Foundation of HOL

3.3 Conservative Extension of Theories

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 137

3. Foundations of Higher-Order Logic 3.0

Overview

1. Introduction to higher-order logic 2. Foundation of higher-order logic 3. Conservative extension of theories

3. Foundations of Higher-Order Logic 3.1 Introduction

Section 3.1

Introduction

(2)

3. Foundations of Higher-Order Logic 3.1 Introduction

A bit of history and context

Gottlob Frege proposed a system on which (he thought) all

mathematics could be derived (in principle): Begriffssschrift (1879)

Bertrand Russell found paradox in Frege’s system and proposed the Ramified Theory of Types

Wrote Principia Mathematica with Whitehead, an attempt at developing basic mathematics completely formally

(“My intellect never recovered from the strain”)

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 140

3. Foundations of Higher-Order Logic 3.1 Introduction

Russel’s paradox

Theorem

Let S ={x |x <x}, then S ∈S if and only if S <S Proof.

IfS ∈S, thenS <S.

IfS <S, thenS ∈S.

Remark

Thus, we found a mathematical contradiction.

Logical point of view: we derivedF ↔ ¬F whereF ≡(S ∈S); thus, we can deriveFalse, and consequently, every formula.

To solve the problem, it is not sufficient to

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 141

3. Foundations of Higher-Order Logic 3.1 Introduction

Approaches to avoid inconsistencies

Type theory:

I Russel: Use a hierarchy of types to avoid self-referential expressions

I A. Church proposed a simple type theory (1940)

I many approaches extend Church’s type theory (HOL, Calculus of constructions, etc.)

Set theoryis often seen asthebasis for mathematics.

I Zermelo-Fraenkel, Bernays-Goedel,. . .

I Set theories distinguish between sets and classes.

I Consistency maintained as some collections are „too big“ to be sets, e.g., class of all sets is not a set. A class cannot belong to another class (let alone a set)! Set theory

Remark

Web-page listing approaches to formalize mathematics and logics:

3. Foundations of Higher-Order Logic 3.1 Introduction

Aspects of HOL

Higher-order logic (HOL) is anexpressive foundationfor

I mathematics: analysis, algebra,. . .

I computer science: program correctness, hardware verification,. . .

Reasoning in HOL is classical.

Still important:modelingof problems (now in HOL).

Still important:derivingrelevant reasoning principles.

(3)

3. Foundations of Higher-Order Logic 3.1 Introduction

Aspects of HOL (2)

HOL offerssafety through strength:

I small kernel of constants and axioms

I safety via conservative (definitional) extensions

Contrast with

I weaker logics (e.g., propositional logic, FOL): can’t define much

I axiomatic extensions: can lead to inconsistency Bertrand Russell:

“The method of "postulating" what we want has many advantages;

they are the same as the advantages of theft over honest toil.”

(Introduction to Mathematical Philosophy, 1919)

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 144

3. Foundations of Higher-Order Logic 3.1 Introduction

Choice of Isabelle/HOL

Rationale for Isabelle/HOL

We useIsabelle/HOL, the HOL specialization of the generic proof assistant Isabelle:

HOL vs. set theory:

I types are helpful for computer science applications

I HOL is sufficiently expressive for most applications (in general, ZF set theory is more expressive)

I “If you prefer ML to Lisp, you will probably prefer HOL to ZF” (quote by Larry Paulson)

Isabelle/HOL vs. other HOL systems: pragmatic advantages overthe HOL systemorPVS

Constructive alternatives for HOL:CoqorNuprl, classical reasoning not supported

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 145

3. Foundations of Higher-Order Logic 3.1 Introduction

About the term „higher-order logic“

1st-order: supports functions and predicates over individuals (0th-order objects) and quantification of individuals:

x,y.R(x,y)−→R(y,x)

2nd-order: supports functions and predicates that have first-order functions as arguments or results and allow quantification over first-order predicates and functions:

P.∀m.P0∧(∀n.Pn−→P(Sucn))−→Pm ...

„higher order“ ! union of all finite orders

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Section 3.2

Foundation of HOL

(4)

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Starting remarks

Simplification

In the rest of this chapter, we only consider

a core syntax of HOL (not the rich syntax of Isabelle/HOL)

a version of HOL without parameterized types (not the richer type system of Isabelle/HOL; cf. [GordonMelham93] for a version with parametric polymorphism)

Goals:

Learn the semantics and axiomatic foundation of HOL

Learn some meta-level properties about HOL

Deepen the understanding of what verification is about

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 148

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Basic HOL Syntax (1)

Types:

τ::=bool |ind|τ⇒τ

I boolandindare also calledoandiin the literature [Chu40, And86]

I no user-defined type constructors, e.g.,bool list

I no polymorphic type definitions, e.g.,αlist

Terms: LetVbe a set of variables andCa set of constants:

T ::=V | C | (T T) | λV.T

I Terms are simply-typed.

I Terms of typeboolare called(well-formed) formulas.

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 149

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Basic HOL Syntax (2)

Theconstantsof HOL are typed and include at least:

True,False :: bool

_=_ :: α⇒α⇒bool (for all typesα∈τ) _−→_ :: bool⇒boolbool

ι_ :: (α⇒bool)⇒α (for all typesα∈τ)

ιis called thedescription operator:

ιp yields the unique elementx for which(p x)isTrue, if such a uniquex exists. Otherwise, it yields an arbitrary value (of typeα).

Note that in Isabelle/HOL, the provisos „for all typesα∈τ“ can be expressed by type variables.

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

HOL Semantics

Intuitively an extension of many-sorted semantics with functions

I FOL (w/o sorts): formulas are interpreted in a structure consisting of a domain/universe and functions/predicates

hD,(fi)i∈F,(pi)i∈Pi

I Many-sorted FOL: there is a domain for each sortsSwhereSis finite; functions/predicates have a sorted signature:

h(Ds)sS,(fi)iF,(pi)iPi

I HOL: domainDis indexed by (infinitely many) types

Our presentation ignores polymorphism on the object-logical level, it is treated on the meta-level, though (for a version covering

object-level parametric polymorphism cf. [GordonMelham93]).

(5)

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Universes are prerequisite for HOL models

Definition (Universe)

A collection of setsUis called auniverse, if it satisfies the following closure conditions:

Inhab: EachX ∈ Uis a nonempty set Sub: IfX ∈ U andY ,0⊆X, thenY ∈ U Prod: IfX,Y ∈ UthenX ×Y ∈ Uwhere

Y is the Cartesian product ({{x},{x,y}}encodes(x,y)) Pow: IfX ∈ U thenP(X) ={Y :Y ⊆X} ∈ U

Infty:U contains an infinite set of individuals

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 152

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Remarks on universes U

Representation of function spaces in universes:

X ⇒Y is the set of all (total) functions fromX toY where a function is represented by its graph

I ForXandYnonempty,XY is a nonempty subset ofP(X×Y)

I From closure conditions: IfX,Y ∈ U, thenXY∈ U.

Universes have two distinguished sets:

Unit: A distinguished set{1}with exactly one element

Bool: A distinguished set{T,F}with exaclty two element sets (existence follows fromInftyandSub)

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 153

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Frames

Definition (frame) LetU be a universe.

Aframeis a collection(Dα)ατwithDα ∈ Ufor allα∈τand

Dbool ={T,F}

Dind =X whereX is some infinite set ofindividuals

Dαβ ⊆ Dα ⇒ Dβ, i.e. somecollection of functions fromDα toDβ Examples

Some of the subsetsDαβ might contain, e.g.,

the identity function, others do not

only the computable functions

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Interpretations

Definition (Interpretation)

Aninterpretationh(Dα)ατ,Jiconsists of a frame(Dα)ατ and a function J mapping the constants of typeαto elements ofDα:

J(True) =T andJ(False) =F

J(=ααbool)is the identity onDα

J(−→boolboolbool)denotes the implication funtion overDbool, i.e., b −→b0 =

( F ifb

=T andb0 =F T otherwise

(6)

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Interpretations (2)

J(ιbool)α)∈(Dα ⇒ Dbool)⇒ Dα denotes the function the(p) =

( a ifp= (λx.x =a)

y otherwise, wherey is some element ofDα Remark

We have to make sure that

the interpretations of the constants are elements of the frame

all definable functions are elements of the frame

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 156

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Generalized models

Definition (Generalized models)

An interpretationM=h(Dα)ατ,Jiis a(general) model for HOLiff there is a binary functionVM such that for all type-indexed families of variable assignmentsρ= (ρα)ατ:

(a) VM(ρ,xα) =ρα(xα)

(b) VM(ρ,c) =J(c), for constantsc (c) VM(ρ,sαβtα) =VM(ρ,s)VM(ρ,t)

i.e., the value of the functionVM(ρ,s)at the argumentVM(ρ,t) (d) VMxα.tβ) =“the function fromDαintoDβwhose value

for eachz ∈ DαisVM(ρ[xz],t)

Ift is a term of typeα, thenVM(ρ,t)∈ Dα.

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 157

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Generalized Models - Facts (1)

IfMis a general model andρa variable assignment, thenVM(ρ,t)is uniquely determined, for every termt.

VM(ρ,t)is thevalueoft inMw.r.t. ρ.

Gives rise to the standard notion ofsatisfiability/validity:

I We writeVM, ρ|=φforVM(ρ, φ) =T.

I φissatisfiableinMifVM, ρ|=φfor some variable assignmentρ.

I φisvalidinMifVM, ρ|=φ, for every variable assignmentρ.

I φisvalid(in the general sense) ifφis valid in every general modelM.

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Generalized Models - Facts (2)

Not all interpretations are general models.

Closure conditions guarantee that every well-formed term has a value under every assignment, e.g.,

closure under functions: identity function fromDαtoDα must belong toDααso thatVM(ρ, λxα.x)is defined.

closure under application:

I ifDNis set of natural numbers and

I DNNN contains addition functionpwherep x y =x+y

I thenDN⇒N must containk x=2x+5

sincek =VM(ρ, λx.f (f x x)y)whereρ(f) =pandρ(y) =5.

(7)

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Standard models

Definition (Standard Models:)

Ageneral modelis astandard modeliff for allα, β∈τ,Dαβis the set of allfunctions fromDαtoDβ

Remarks

A standard model is a general model, but not necessarily vice versa.

Analogous definitions for satisfiability and validity w.r.t. standard models.

We can now re-introduce HOL in Isabelle’s meta-logic.

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 160

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Isabelle/HOL

The syntax of the core language is introduced by:

consts

True :: bool False :: bool

Not :: bool⇒bool ("‘¬_"’ [40] 40)

If :: [bool, ’a, ’a ]⇒’a ("‘if _ then _ else _)"’) The :: (’a⇒bool)’a (binder"‘THE"’ 10) All :: (’a⇒bool)⇒bool (binder"‘∀"’ 10) Ex :: (’a⇒bool)⇒bool (binder"‘∃"’ 10)

= :: [’a,’a]⇒bool (infixl50)

∧ :: [bool, bool]⇒bool (infixr 35)

∨ :: [bool, bool]⇒bool (infixr 30)

−→ :: [bool, bool]⇒bool (infixr 25)

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 161

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

Core definitions of HOL

defs

True_def: True ≡((λx ::bool.x) = (λx.x)) All_def: All(P) ≡(P = (λx.True))

Ex_def: Ex(P) ≡ ∀Q.(∀x.Px −→Q)−→Q False_def: False ≡(∀P.P)

not_def: ¬PP −→False

and_def: P∧Q ≡ ∀R.(P −→Q −→R)−→R

or_def: P∨Q ≡ ∀R.(P −→R)−→(Q −→R)−→R if_def: IfP×yTHEz :: 0a.(P =True−→z=x)∧ (P =False−→z =y)

3. Foundations of Higher-Order Logic 3.2 Foundation of HOL

The axioms and rules of HOL

axioms/rules

refl: "t=t"

subst: "~s =t; P(s)=⇒P(t)"

ext: "(Vx.f x =g x) =⇒(λx.f x) = (λx.g x)"

impl: "(P =⇒Q) =⇒P −→Q"

mp: "~P −→Q;P =⇒ Q"

iff: "(P −→Q)−→(Q −→P)−→(P =Q)"

True_or_False: "(P =True)∨(P=False)"

the_eq_trivial: "(THEx.x =b) = (b :: 0a)"

Referenzen

ÄHNLICHE DOKUMENTE

This is basically a copy of the STLC “one

Formal syntax and semantics of the specification language..

This may seem strange: if a new type is always isomorphic to a subset of an existing type, how is this construction going to lead to a “rich” collection of types for

True_def: True ≡ ((λ x :: bool.. Foundations of Higher-Order Logic 3.3 Conservative Extension of Theories. The nature

Formal syntax and semantics of the specification language. Introduction 1.3 Specification and Verification

A Proof System for Higher-Order Logic 4.1 Methods and Rules.. 4.2 Rewriting

Arnd Poetzsch-Heffter ( Software Technology Group Fachbereich Informatik Technische Universität Kaiserslautern) Specification and Verification with Higher-Order Logic

Having variables that range over predicates allows to write terms like. Ω def =