Universit`a degli Studi di Firenze - web.math.unifi.itweb.math.unifi.it/users/lomuto/phd.pdf ·...

95
Universit ` a degli Studi di Firenze Dipartimento di Matematica “U.Dini” Dottorato di Ricerca in Matematica, XX ciclo Clelia Lomuto Tesi di Dottorato FORMALIZATION OF ABSTRACT SIMPLICIAL HOMOLOGY IN THE HIGHER ORDER LOGIC Settore disciplinare: MAT/03 Direttore della ricerca Dott. Marco Maggesi Coordinatore del Dottorato Prof. Mario Primicerio

Transcript of Universit`a degli Studi di Firenze - web.math.unifi.itweb.math.unifi.it/users/lomuto/phd.pdf ·...

Universita degli Studi di FirenzeDipartimento di Matematica “U.Dini” Dottorato

di Ricerca in Matematica, XX ciclo

Clelia Lomuto

Tesi di Dottorato

FORMALIZATION OF ABSTRACT SIMPLICIAL

HOMOLOGY IN THE HIGHER ORDER LOGIC

Settore disciplinare: MAT/03

Direttore della ricercaDott. Marco Maggesi

Coordinatore del DottoratoProf. Mario Primicerio

Contents

Introduction 5

1 HOL Light 9

1.1 Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.2 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1.3 Theorems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1.4 Axioms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1.5 Inference Rules . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.6 Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2 Simplicial Complexes 15

2.1 First Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.2 Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.4 Connected Components . . . . . . . . . . . . . . . . . . . . . 20

3 Numtrie 25

4 Z-modules 35

5 Boundary map 41

5.1 Boundary map . . . . . . . . . . . . . . . . . . . . . . . . . . 41

5.2 Boundary map on numtries . . . . . . . . . . . . . . . . . . . 45

Conclusions 49

A Theorems 51

A.1 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

A.2 Numtries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

A.3 Sums of integers . . . . . . . . . . . . . . . . . . . . . . . . . 66

A.4 Free Z-modules . . . . . . . . . . . . . . . . . . . . . . . . . . 68

A.5 Binary relations . . . . . . . . . . . . . . . . . . . . . . . . . . 77

A.6 Simplicial complexes . . . . . . . . . . . . . . . . . . . . . . . 79

A.7 Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

3

Contents

A.8 Connected components . . . . . . . . . . . . . . . . . . . . . . 82A.9 Sign of an index in a simplex . . . . . . . . . . . . . . . . . . 87A.10 The boundary operator . . . . . . . . . . . . . . . . . . . . . 89A.11 Computation of the boundary operator . . . . . . . . . . . . . 90

Bibliography 93

4

Introduction

Computers have been increasingly employed in several ways and with differ-ent pourposes to support the mathematical research since their invention.In this fertile environment, computer theorem checking had a rapid and as-tonishing developement over the last years.

Thanks to the recent achievements, computer proofs are now sproutingup in several fields. On one hand, the concrete possibility of transcribingtraditional proofs into formal proofs has important cultural and philosoph-ical consequences. On the other hand, a great impulse to the developementof computer checked mathematics comes from industrial applications whereformal methods have been successfully applied to the verification of soft-ware and hardware and, broadly speacking, to certify the correct design ofa variety of critical systems (as, for instance, in avionics).

A presentation of this emerging discipline with a perspective on therecent achievements and their applications can be found in the December2008 issue of Notices of the AMS, enterely dedicated to formal theoremproving (see [7], [9], [13], [30].)

In this thesis we present a computer formalization of the basics of theAbstract Simplicial Homology. From the point of view of formal mathe-matics we can think that there are three main activities, deaply linked toeach other: defining, proving, computing. The aim of this thesis is to showhow, in the study of simplicial homology, all these three activities can beperformed with the help of a computer program.

There are numerous computer programs, known as proof assistants, thatcan check or even partially construct formal proofs written in a suitableformal proof language. Several of them have been significantly used forformalization of mathematics. For instance: Coq[3], Isabelle[16], HOL4 [15],HOL Light[10], Mizar[19], Matita[18], Phox [22] and ProofPower[21].

The choice of a particular proof assistant over another is in some respectarbitrary. In this thesis our choice has fallen on HOL Light. HOL Light is aninteractive theorem prover, developed by John Harrison and implementedin OCaml. It is a member of the HOL (Higher Order Logic) family whichincludes several other well-knonw provers like HOL4, Isabelle and Proof-Power. One of its appealing feature is that, compared to other systems,both its logical foundations and its implementation are unusually simple.

5

Introduction

This work has been partially inspired by the work of Francis Sergeraertand Xavier Dousson on the Kenzo program [25][26]. Kenzo is a computerprogram dedicated to computations in Algebraic Topology. A long termproject and future developement of our work could be the implementationand certification of some significant ideas developed in the Kenzo system.In this respect we want to cite the work of Thierry Coquand and ArnaudSpiwack [4] which aims to a formalization of the Kenzo system inside theCalculus of Inductive Constructions with a strongly intuitionistic approach.

Homology Theory supplies the way of computing invariants and prop-erties of topologial spaces. We have constructed a formal basis that allowsseveral further developments. In the future developements we plan to writealgorithms for evaluating expressions in free Z-modules and give an ax-iomatic definition of homological complex and related constructions. Moreambitious goals may include the formalization of theorems connecting ho-mology and topological invariants like dimension, orientability, genus andEulero-Poincare characteristic and compute them in meaningful examples.General references about Algebraic Topology and Homology Theory can befound in the following texts [27], [24], [6], [28], [14], [17] and [8].

The thesis has the following structure.In chapter 1, we give a brief introduction of HOL Light as foundational

system designed for doing mathematical proofs. We describe explicitely thebasic components of the HOL Light system: terms, types, theorems, rulesof inferences and axioms.

In chapter 2 we introduce the definition of abstract simplicial complexand state the first basic results, then we define the notion of generators andwe prove that every simplicial complex has a minimal set of generators andwe construct a conversion that computes explicitely the simplicial complexgenerated by a finite collection of finite sets of numbers and a conversionthat computes the minimal set of generators of a simplicial complex. Thenwe give some interesting examples of simplicial complexes as cones and sus-pensions and we define the n-dimensional sphere as suspensions. Finally wedefine the notion of connected components and we compute the connectedcomponents of a point and of a set contained in a simplicial complex.

In chapter 3 we develop a computationally efficient representation of fi-nite sets of natural numbers. We construct a new type :numtrie, wherean element of type :numtrie is a binary tree with labeled leaf edges, thenwe associate every finite set of numbers with an element of type :numtrie

and we define for numtries the usual set operations and prove their ba-sic properties analogous to properties of sets. We provide conversions fortransforming a set given in the usual set enumerations into a :numtrie andviceversa.

In chapter 4 we formalize the notion of free modules over the ring ofintegers. Thus we introduce a new type :A zmod, where an object of type:A zmod can be thought as a vector with integer coefficients indexed by an

6

Introduction

other type :A. We define the basic operations and prove several standardalgebraic identities. Finally we define the submodules and prove their basicproperties.

In chapter 5 we define the chain complex of a simplicial complex andthe boundary map associated with a simplicial complex. We prove the wellknown principle that a boundary of a boundary is zero. Then, using therepresentation of sets of numbers as numtries we construct an algorithm tocompute the boundary map.

In the appendix we give the complete list of the statements of the the-orems proved. The whole size of our library is 230Kb and contains about600 theorems.

7

Introduction

8

Chapter 1

HOL Light

HOL Light (Lightweight Higher Order Logic) is a foundational system de-signed for doing mathematical proofs on a computer. The basic componentsof the HOL Light system are its terms, types, theorems, rules of inferenceand axioms. Each is briefly described hereunder.

1.1 Terms

Terms are the basic mathematical objects of HOL Light system. We mustdistinguish between abstract and concrete syntax of HOL. The abstract syn-tax of a term, which HOL deals with internally, is a tree-like CAML datastructure. It says how the term is built up from its componenents. Thisinternal representation is convenient to manipulate, but we prefer to repre-sent terms by a linear sequence of characters, the concrete syntax. To enterterms into the system we type them between backquotes, the HOL’s parserautomatically attempts to parse anything in backquotes into the internalrepresentation, and its prettyprinter performs an inverse mapping back toconcrete syntax. For example, if some different variants of the input aremapped to the same internal representation by the parser, they are printedin the same way

# ‘(x) + 1‘;;

val it : term = ‘x + 1‘

# ‘x + (1)‘;;

val it : term = ‘x + 1‘

Malformed expressions will not be parsed at all:

9

Chapter 1. HOL Light

# ‘x + +‘;;

Exception: Failure "term after binary operator expected".

We can disable the automatic prettyprinting using the following Ocaml di-rective:

# #remove_printer print_qterm;;

# ‘x + 1‘;;

val it : term =

Comb (Comb (Const ("+", ‘:num->num->num‘), Var ("x", ‘:num‘)),

Comb (Const ("NUMERAL", ‘:num->num‘),

Comb (Const ("BIT1", ‘:num->num‘), Const ("_0", ‘:num‘))))

The syntax of HOL Light is based on λ-calculus, a formalism inventedby Alonzo Church [2]. In HOL, as in λ-calculus, there are only four typesof terms:

• Variables

• Constants

• Applications

• Abstractions

Constants and variables are the building-blocks of terms. There are twoprimitive constants: the equality symbol (=) and the Hilbert choice operator(ε).

By application, sometimes also called combination, we mean applicationof a function to an argument, which is a composite term built from subtermsfor the function and argument. The concrete syntax for the application of afunction f to an argument t is f(t). HOL, following λ-calculus convention,allows the parentheses to be omitted.

Abstraction is a converse operation to application (see the BETA rulein section 1.5). Given a variable x and a term t, the lambda-abstractionλx.t means ‘the function of x that yields t’. In HOL’s concrete syntax thebackslash is used, e.g. ‘\x. x+1‘. One of the advantages of abstractions isthat they make variable dependencies and binding explicit.

HOL’s term representation makes no special provision for functions ofmore than one argument. The trick used is to make the function take itsarguments ‘one at a time’. For instance, rather than considering addition asan operation N × N → N, consider it as a function N → (N → N). It takesa single argument say n, and yields a new function of one argument thatadds n to its argument. This intermediate function is applied to the second

10

Chapter 1. HOL Light

argument, say m, and yields the final result n + m. So we represents inHOL n + m as (+n)(m). This trick is known as currying, after the logicianHaskell Curry [5].

1.2 Types

To avoid paradoxes, as the well-known Russel’s one, Church augmented λ-calculus with a theory of types, derived from Russell’s system. HOL Lightfollows this system: in HOL Light every term has a well-defined type, thatsays what kind of mathematical object the term represents (numbers, sets,functions).

By convention, a colon is written before the name of a type, for examplewe write the type of the natural number 1 as :num or 1:num.

There are only two primitive types :bool (the boolean type) and :ind

(the infinite type, that will be explicited by the Dedekind’s axiom of infinityin the section 1.4). All the others types are generated from these using thetype constructor → or through a mechanism for creating a new type that isin bijection with a nonempty subset of an existing type.

Note that in HOL, there is no separate notion of sets of elements (drawnfrom some global‘universe’set U ) and predicates or ‘characteristic functions’U → bool.

HOL Light extends Church’s system introducing also ‘type variables’.Terms with variable type are generic, and can have various types resultingfrom fixing the names of the type variables. For instance, the equalityrelation has type α → α → bool where α is a type variable. This means itcan be used with any type replacing α.

1.3 Theorems

In HOL Light a theorem is expressed in sequent form

p1, . . . , pn ⊢ p

where p1, . . . , pn and p are terms of type :bool. The terms p1, . . . , pn arethe assumptions and p is the conclusion of the theorem.

There is a notion of when a formula has been proved using the acceptedmethods of proof, and these methods have been chosen so that anythingprovable is also true. Initially, the only theorems of HOL are axioms, andthe only way of creating new theorems is to apply a limited set of primitiverules of inference.

1.4 Axioms

There are only three mathematical axioms.

11

Chapter 1. HOL Light

The first is the η-equivalence of λ-calculus wich is a weak form of theaxiom of extensionality, it asserts that a function is determined by the valuesthat it takes on all imputs:

∀f.(λx.fx) = f.

The second is Dedekind’s axiom of infinity, it asserts the existence of afunction of type :ind → ind that is one-to-one but not onto, i.e. that thetype :ind is not finite:

∃f : ind → ind.(ONE ONEf) ∧ ¬(ONTOf)

Finally the Axiom of Choice says that the Hilbert choice operator ε

applied to a predicate P chooses a term that satisfies the predicate, providedthe predicate is satisfiable:

∀Px.Px ⇒ P (εP )

1.5 Inference Rules

The system has ten inference rules. Each rule is written with the conclusionbelow a line and the hypotheses above and with the name of the inferencerule at the right.

The first two rules state that equality is reflexive and transitive

⊢ s = sREFL

Γ ⊢ s = u ∆ ⊢ u = tΓ ∪ ∆ ⊢ s = t

TRANS

MK COMB says that equal functions applied to equal arguments give equalresults. Of course we assume that the types agree.

Γ ⊢ s = t ∆ ⊢ u = vΓ ∪ ∆ ⊢ s(u) = t(v)

MK COMB

The rule ABS says that if two expressions involving x are equal, then thefunctions from x to those values are equal. It requires that x is not a freevariable in any of the assumptions of Γ.

Γ ⊢ s = tΓ ⊢ (λx.s) = (λx.t)

ABS

The following rule expresses the fact that combination and abstractionare converse operations: the application of the function that takes an argu-ment x to t to an argument x gives t.

12

Chapter 1. HOL Light

⊢ (λx.t)x = tBETA

ASSUME says that from p we can conclude p. Of course, p must have type:bool

p ⊢ pASSUME

EQ MP connects equality with deduction: if p and q are equal and we candeduce p, then we can deduce q.

Γ ⊢ p = q ∆ ⊢ p

Γ ∪ ∆ ⊢ qEQ MP

This rule also connects equality and deduction: it says that if we candeduce p from q and q from p, then p and q are equal, under the accumulatedassumptions.

Γ ⊢ p ∆ ⊢ p

(Γ \ {q}) ∪ (∆ \ {p}) ⊢ p = qDEDUCT ANTISYM RULE

The rule INST says that if p is true for variables x1, . . . , xn, then we canreplace these variables by terms of the same type and we still get some-thing true; INST TYPE expresses the same fact, but for substitution of typevariables.

Γ[t1, . . . , tn] ⊢ p[t1, . . . , tn]

Γ[x1, . . . , xn] ⊢ p[x1, . . . , xn]INST

Γ[β1, . . . , βn] ⊢ p[β1, . . . , βn]

Γ[α1, . . . , αn] ⊢ p[α1, . . . , αn]INST TYPE

1.6 Conversions

In HOL Light computational algorithms take shape of conversions. A con-version is simply an inference rule of type :term → thm that given a termt, returns an equational theorem of the form ⊢ t = t, that is, it proves thatthe term it was given is equal to some other term, possibly the same as theoriginal. For instance, there are many conversions that evaluate expressionsinvolving arithmetic operations on natural numbers:

NUM_ADD_CONV ‘2 + 2‘;;

# val it : thm = |- 2 + 2 = 4

NUM_MULT_CONV ‘9 * 6‘;;

13

Chapter 1. HOL Light

# val it : thm = |- 9 * 6 = 54

NUM_EXP_CONV ‘2 EXP 8‘;;

# val it : thm = |- 2 EXP 8 = 256

We can put together basic conversions into more complex one using genericfunctions called conversionals. For example, the conversional THENC takestwo conversions and returns the new conversion that results from applyingthe first conversion and then applying the second to the result. Consider forexample

(BETA_CONV THENC NUM_ADD_CONV) ‘(\x. x + 2) 1‘;;

# val it : thm = |- (\x. x + 2) 1 = 3

where the conversion BETA CONV maps the term ‘(\x.u)v‘ to the theorem‘|- (\x.u)v = u[v/x]‘ using the primitive inference rule BETA.

14

Chapter 2

Simplicial Complexes

2.1 First Definitions

An abstract simplicial complex C is a finite collection of finite sets of naturalnumbers, closed under the operation of taking subsets. To formalize thisnotion in HOL light we introduce the definition of SIMPLICIAL

let SIMPLICIAL = new_definition

‘!C. SIMPLICIAL C <=>

(!s t. s IN C /\ t SUBSET s ==> t IN C) /\

FINITE C /\

(!s. s IN C ==> FINITE s)‘

The elements of a simplicial complex C are called simplexes. The elementsof a simplex are called vertexes. Given a simplex s ∈ C of cardinality i + 1,we say that s is a simplex of dimension i or an i-dimensional simplex. If asimplicial complex is not empty, the empty set is the only −1-dimensionalsimplex. The dimension of a simplicial complex C is defined to be themaximum of the dimensions of its simplexes.

So, we define in HOL the dimension of a simplex SIMPLEX DIM

let SIMPLEX_DIM = new_definition

‘SIMPLEX_DIM (s:num->bool) = &(CARD s) - &1‘

and introducing the function FMAX that returns the maximum value of a setof integer numbers, we can define the dimension of a simplicial complex too.

let FMAX = new_definition

15

Chapter 2. Simplicial Complexes

‘FMAX s = ITSET max s (&0)‘

let SIMPLICIAL_DIM = new_definition

‘SIMPLICIAL_DIM (C:(num->bool)->bool) =

FMAX {SIMPLEX_DIM s | s IN C}‘

Note that these definitions of dimension are not strictly related to simplicialcomplexes, but they concern generic sets of natural numbers.

The conversion SIMPLICIAL CONV, when applied to a finite collection offinite sets of numbers, returns the value T if it is a simplicial complex and F

otherwise. For example

SIMPLICIAL_CONV ‘SIMPLICIAL {{0,1},{},{0},{1}}‘;;

# val it : thm = |- SIMPLICIAL {{0, 1}, {}, {0}, {1}} <=> T

SIMPLICIAL_CONV ‘SIMPLICIAL {{0,1},{},{1}}‘;;

# val it : thm = |- SIMPLICIAL {{0, 1}, {}, {1}} <=> F

2.2 Generators

We say that a simplicial complex C is generated by a finite collection offinite sets of natural numbers D if C consists of all the elements of D andtheir subsets. Conversely given a finite collection of finite sets of numbersC, the closure of C with respect to subsets is a simplicial complex. In HOLLight we call this closure SIMPLICIAL GENERATED,

let SIMPLICIAL_GENERATED = new_definition

‘!C. SIMPLICIAL_GENERATED (C:(num->bool)->bool) =

{s | ?t. t IN C /\ s SUBSET t}‘

it’s easy to show that it is a simplicial complex for every finite collection offinite sets of numbers.

SIMPLICIAL_SIMPLICIAL_GENERATED

|- !C. SIMPLICIAL (SIMPLICIAL_GENERATED C) <=>

(FINITE C /\ (!s. s IN C ==> FINITE s))

Every simplicial complex can be described in trivial way as SIMPLICIAL GENERATED

of a suitable collection of sets.

16

Chapter 2. Simplicial Complexes

SIMPLICIAL_GENERATED_THM

|- !C. SIMPLICIAL C ==> (SIMPLICIAL_GENERATED C = C)

Every simplicial complex C admits a minimal set of generators which isgiven by the simplexes that are not proper subsets of any simplex in C. Wecall MIN GEN the minimal set of generators.

let MIN_GEN = new_definition

‘MIN_GEN (C:(num->bool)->bool) =

{s | s IN C /\ (!t. t IN C /\ s SUBSET t ==> s=t)}‘

Using the following set-theoretical theorem

EXISTS_MAXIMAL_SET

|- !P. ~(P={}) /\ FINITE P ==>

(?s. s IN P /\ (!t. t IN P /\ s SUBSET t ==> s = t))

we have proved that MIN GEN is a set of generators and that is actuallyminimal.

SIMPLICIAL_GENERATED_MIN_GEN

|- !C. FINITE C ==> SIMPLICIAL_GENERATED C =

SIMPLICIAL_GENERATED (MIN_GEN C)

MIN_GEN_MINIMALITY

|- !C D. C = SIMPLICIAL_GENERATED D ==> MIN_GEN C SUBSET D

Moreover we have constructed the conversion SIMPLICIAL GENERATED CONV

that computes explicitly the simplicial complex generated by a finite collec-tion of sets of numbers. Consider for instance the simplicial complex calledBJORNER:

let BJORNER = new_definition

‘BJORNER = SIMPLICIAL_GENERATED

{ {1,2,3}, {1,2,5}, {1,2,6}, {1,3,4}, {1,3,6}, {1,4,5},

{2,3,4}, {2,3,5}, {2,4,6}, {3,5,6}, {4,5,6} }‘;;

Applying SIMPLICIAL GENERATED CONV we get all the elements of BJORNER

17

Chapter 2. Simplicial Complexes

# (REWRITE_CONV [BJORNER] THENC

SIMPLICIAL_GENERATED_CONV) ‘BJORNER‘;;

val it : thm =

|- BJORNER =

{{}, {2}, {2, 6}, {2, 6, 4}, {2, 6, 1}, {2, 4},

{2, 4, 3}, {2, 5}, {2, 5, 1}, {2, 5, 3}, {2, 1},

{2, 1, 3}, {2, 3}, {6}, {6, 4}, {6, 4, 5},

{6, 5}, {6, 5, 3}, {6, 1}, {6, 1, 3}, {6, 3}, {4},

{4, 5}, {4, 5, 1}, {4, 1}, {4, 1, 3}, {4, 3}, {5},

{5, 1}, {5, 3}, {1}, {1, 3}, {3}}

We have also a conversion called MIN GEN CONV that computes the minimalset of generators:

MIN_GEN_CONV ‘MIN_GEN {{}, {2}, {2, 1}, {2, 1, 3},

{2, 3}, {1}, {1, 3}, {3}}‘;;

# val it : thm =

|- MIN_GEN {{}, {2}, {2, 1}, {2, 1, 3},

{2, 3}, {1}, {1, 3}, {3}} = {{3, 1, 2}}

2.3 Examples

Given a collection of sets of natural numbers C and a natural number a, thecone over C of vertex a is given by the collection of all the sets s such thats \ {a} ∈ C.

let CONE = new_definition

‘!C. CONE (C:(num->bool)->bool) a =

C UNION {s | ?t. t IN C /\ (s = a INSERT t)}‘

The cone of vertex a over a simplicial complex C is again a simplicial com-plex.

SIMPLICIAL_CONE

|- !C a. SIMPLICIAL C ==> SIMPLICIAL (CONE C a)

18

Chapter 2. Simplicial Complexes

The suspension of a collection of sets of natural numbers C of vertex a andb is the union of the cones over C of vertexes a and b respectively and, justas for cones, the suspension over a simplicial complex is again a simplicialcomplex.

let SUSPENSION = new_definition

‘!C a b. SUSPENSION (C:(num->bool)->bool) a b =

(CONE C a) UNION (CONE C b)‘

SIMPLICIAL_SUSPENSION

|- !C a b. SIMPLICIAL C ==> SIMPLICIAL (SUSPENSION C a b)

The most important example of suspension are the n-dimensional spheres,that we define recursively as follows:

let SPHERE = define

‘SPHERE 0 = {{}, {0}, {1}} /\

(!n. SPHERE (SUC n) = SUSPENSION (SPHERE n) (2*n+2) (2*n+3))‘

The operations CONE and SUSPENSION commute with SIMPLICIAL GENERATED

SIMPLICIAL_GENERATED_CONE

|- !D a. CONE (SIMPLICIAL_GENERATED D) a =

SIMPLICIAL_GENERATED (CONE D a)

SIMPLICIAL_GENERATED_SUSPENSION

|- !D a b. SUSPENSION (SIMPLICIAL_GENERATED D) a b =

SIMPLICIAL_GENERATED (SUSPENSION D a b)

We can define n-dimensional spheres also through a suitable set of genera-tors, that we call GEN SPHERE

let GEN_SPHERE = define

‘GEN_SPHERE 0 = {{0},{1}} /\

(!n. GEN_SPHERE (SUC n) =

{x | ?y. y IN GEN_SPHERE n /\

(x = (2*n+2) INSERT y \/ x = (2*n+3) INSERT y )})‘

19

Chapter 2. Simplicial Complexes

GEN_SPHERE_THM

|- !n. SPHERE n = SIMPLICIAL_GENERATED (GEN_SPHERE n)

2.4 Connected Components

In this section we want to define and compute the connected components ofa simplicial complex. Given a simplicial complex C, we say that two numbersare equivalent with respect to the relation VLINK C if exists a simplex in C

which contains both of them. Note that most of the following definitionsmake sense for a generic collection of sets of natural numbers.

let VLINK = new_definition

‘!C x y. VLINK C x y <=>

(?s. s IN C /\ x IN s /\ y IN s)‘

The following property allows us to decide if two numbers are linked.

VLINK_RULES

|- (!C x y. VLINK {} x y <=> F) /\

(!C x y. VLINK ({} INSERT C) x y <=> VLINK C x y) /\

(!C s x y. VLINK (s INSERT C) x y <=>

x IN s /\ y IN s \/ VLINK C x y)

We can easily prove that VLINK is reflexive and symmetric. In order toobtain an equivalence relation we consider the transitive closure EQVLINK

of VLINK, where the transitive closure TC of a relation R is defined as thesmallest transitive relation that contains R.

let TC_RULES,TC_INDUCT,TC_CASES = new_inductive_definition

‘(!x y. R x y ==> TC R x y) /\

(!(x:A) y z. TC R x y /\ TC R y z ==> TC R x z)‘

let EQVLINK = new_definition

‘!C. EQVLINK C = TC (VLINK C)‘

Connected components of C are the equivalence classes of EQVLINK, to com-pute them we need some notions concerning binary relations.

We define the field of a binary relation, FL, as the set of elements whichare in relation with an other one.

20

Chapter 2. Simplicial Complexes

let FL = new_definition

‘!R. FL R = {x | (?y. R x y) \/ (?y. R y x)}‘

The set STCLASS R x is the equivalence class of the element x with respectto the symmetrical and transitive closure of the binary relation R.

let STCLASS = new_definition

‘!R x. STCLASS R x = {y | STC R x y}‘

REACHABLE R s is the set of the elements reachable from the set s throughthe relation R.

let REACHABLE = new_definition

‘!R s. REACHABLE R s = {x | ?a. a IN s /\ R a x}‘

Hence the equivalence class of an element x is exactly the set of elementsreachable by STC R.

STCLASS_EQ_REACHABLE

|- !R x. STCLASS R x = REACHABLE (STC R) {x}

The field of EQVLINK is the same of VLINK.

FL_EQVLINK

|- !C. FL (EQVLINK C) = UNIONS C

We call VCOMPONENT C x the connected component of C that contains x.

let VCOMPONENT = new_definition

‘!C. VCOMPONENT C x = STCLASS (EQVLINK C) x‘

We say that the set s is VCONNECTED C if it is an equivalence class withrespect to the relation EQVLINK

let VCONNECTED = new_definition

‘!C s. VCONNECTED C s <=>

(!x y. x IN s /\ y IN s ==> EQVLINK C x y)‘

We call VCOMPONENTS C the set of the connected components of C

21

Chapter 2. Simplicial Complexes

let VCOMPONENTS = new_definition

‘!C. VCOMPONENTS C = {VCOMPONENT C x | x | x IN UNIONS C}‘

The connected components VCOMPONENTS C are VCONNECTED C and they givea partition of the field of EQVLINK.

VCONNECTED_VCOMPONENT

|- !C x. VCONNECTED C (VCOMPONENT C x)

DISJOINT_VCOMPONENT

|- !C x y. VCOMPONENT C x = VCOMPONENT C y \/

DISJOINT (VCOMPONENT C x) (VCOMPONENT C y)

We call VREACHABLE the set of elements reachable by the reflexive closure ofEQVLINK.

VREACHABLE = new_definition

‘!C s. VREACHABLE C s = REACHABLE (RC (EQVLINK C)) s‘

IN_VREACHABLE

|- !C s x. x IN VREACHABLE C s <=>

x IN s \/ ?a. a IN s /\ EQVLINK C a x

The connected component of an element belonging to the field of EQVLINK

is given by the set of the elements reachable from the singleton {x}.

VCOMPONENT_EQ_VREACHABLE

|- !C x. VCOMPONENT C x = if x IN UNIONS C

then VREACHABLE C {x} else {}

Now, to compute exactly the connected component of an element we usethe following theorem

VREACHABLE_COMPUTE

|- !C s. VREACHABLE C s =

let D,E = PARTITION (DISJOINT s) C in

if E = {} then s else VREACHABLE D (s UNION UNIONS E)

where, given a predicate P and a set s and remembering that in HOL Lightpredicates and sets both amount to the same thing, COLLECT P s is theintersection between s and P

22

Chapter 2. Simplicial Complexes

COLLECT

|- !P s. COLLECT P s = {x | x IN s /\ P x}

and PARTITION P s is the partition of the set s given by the predicate P

PARTITION

|- !P s. PARTITION P s = COLLECT P s,COLLECT ((~) o P) s

Since we can compute PARTITION, we have constructed the conversionsVCOMPONENT CONV and VCOMPONENTS CONV that compute the connected com-ponent of an element and the set of the connected components of a simplicialcomplex. See for instance the 3-dimensional sphere, that we can computeusing the conversion SPHERE CONV:

SPHERE_CONV ‘SPHERE 3‘;;

# val it : thm =

|- SPHERE 3 =

{{}, {6}, {7}, {4}, {6, 4}, {7, 4}, {5}, {6, 5}, {7, 5},

{2},{6, 2}, {7, 2}, {4, 2}, {6, 4, 2}, {7, 4, 2}, {5, 2},

{6, 5, 2}, {7, 5, 2}, {3}, {6, 3}, {7, 3}, {4, 3},

{6, 4, 3}, {7, 4, 3}, {5, 3}, {6, 5, 3}, {7, 5, 3}, {0},

{6, 0}, {7, 0}, {4, 0}, {6, 4, 0}, {7, 4, 0}, {5, 0},

{6, 5, 0}, {7, 5, 0}, {2, 0}, {6, 2, 0}, {7, 2, 0},

{4, 2, 0}, {6, 4, 2, 0}, {7, 4, 2, 0}, {5, 2, 0},

{6, 5, 2, 0}, {7, 5, 2, 0}, {3, 0}, {6, 3, 0}, {7, 3, 0},

{4, 3, 0}, {6, 4, 3, 0}, {7, 4, 3, 0}, {5, 3, 0},

{6, 5, 3, 0}, {7, 5, 3, 0}, {1}, {6, 1}, {7, 1}, {4, 1},

{6, 4, 1}, {7, 4, 1}, {5, 1}, {6, 5, 1}, {7, 5, 1},

{2, 1}, {6, 2, 1}, {7, 2, 1}, {4, 2, 1}, {6, 4, 2, 1},

{7, 4, 2, 1}, {5, 2, 1}, {6, 5, 2, 1}, {7, 5, 2, 1},

{3, 1}, {6, 3, 1}, {7, 3, 1}, {4, 3, 1}, {6, 4, 3, 1},

{7, 4, 3, 1}, {5, 3, 1}, {6, 5, 3, 1}, {7, 5, 3, 1}}

we have

(LAND_CONV SPHERE_CONV THENC VCOMPONENT_CONV)

‘VCOMPONENT (SPHERE 3) 3‘;;

23

Chapter 2. Simplicial Complexes

# val it : thm = |- VCOMPONENT (SPHERE 3) 3 =

{3, 0, 4, 6, 7, 5, 1, 2}

(RAND_CONV SPHERE_CONV THENC VCOMPONENTS_CONV)

‘VCOMPONENTS (SPHERE 3)‘;;

# val it : thm = |- VCOMPONENTS (SPHERE 3) =

{{2, 6, 4, 5, 1, 3, 7, 0}}

Note that we use the conversionals LAND CONV and RAND CONV that apply theconversion SPHERE CONV to the left hand argument and to the right handargument of the binary operators respectively.

Finally we say that a simplicial complex C is connected if the union ofall the elements belonging to the sets of C is connected.

let CONNECTED_COMPLEX = new_definition

‘!C. CONNECTED_COMPLEX C <=> VCONNECTED C (UNIONS C)‘

Hence we have proved that every cone and every nonempty suspension isconnected, so every n-sphere is a connected simplicial complex.

CONNECTED_COMPLEX_CONE

|- !C a. CONNECTED_COMPLEX (CONE C a)

CONNECTED_COMPLEX_SUSPENSION

|- !C a b c. c IN UNIONS C ==>

CONNECTED_COMPLEX (SUSPENSION C a b)

CONNECTED_COMPLEX_SPHERE

|- !n. ~(n = 0) ==> CONNECTED_COMPLEX (SPHERE n)

24

Chapter 3

Numtrie

Since we are concerned with collections of finite sets of natural numbers, weneed to develop a computationally efficient representation of them.

Our library is based on the so called trie (or prefix tree) representation.A modified version of this library has been included for release in the nextdevelopment snapshot of the HOL Light system.

We start by defining the new type :numtrie inductively by means ofthe constructors numempty, numzero and numnode. We use the functiondefine type, it always returns two theorems (in our case numtrie INDUCT

and numtrie RECUR), the first a kind of induction theorem for the new type,the second a justification of definition by primitive recursion. These twotheorems together identify the type up to isomorphism.

let numtrie_INDUCT, numtrie_RECUR = define_type

"numtrie = numempty

| numzero

| numnode numtrie numtrie"

numtrie_INDUCT

|- !P. P numempty /\

P numzero /\

(!a0 a1. P a0 /\ P a1 ==> P (numnode a0 a1))

==> (!x. P x)

numtrie_RECUR

|- !f0 f1 f2.

?fn. fn numempty = f0 /\

fn numzero = f1 /\

(!a0 a1. fn (numnode a0 a1) =

f2 a0 a1 (fn a0) (fn a1))

25

Chapter 3. Numtrie

An element of type :numtrie is a binary tree whose leaf edges can benumempty or numzero. So with every element of type :numtrie we asso-ciate a finite set of natural numbers in the following way. We associate withnumempty and numzero the empty set and the singleton {0} respectively. Incase of a numnode we consider only the leaf edges of kind numzero and leaveout the other ones. To associate with every numzero leaf edge a naturalnumber we start from 0 and we go back to the root along a maximal pathapplying the map n 7→ 2n + 1 if we go through the left edge of a numnode

and the map n 7→ 2n if we go through the right one.Hence with the element

numnode numzero numempty

we associate the singleton {1} and with the element

numnode numempty numzero

we associate the singleton {0}. Consider another example, the element

numnode (numnode numzero numepty) numzero

represents the set 0, 3, indeed the left subtree

numnode numzero numepty

corresponds to 1 and going back to the root we have 2×1+1 = 3. The rightsubtree is made of the only leaf edge numzero, which gives 2 × 0 = 0. Notethat this representation is not unique, in fact for instance both the elementsnumzero and numnode numempty numzero represent the set {0}. Moreovera finite set of natural numbers can be represented by infinite numtries, forexample the empty set is represented by numempty and by all the numtries

that have all the leaf edges of kind numempty.We define by induction NUMTRIE MEM, a relation between a natural num-

ber and an element of type numtrie, analogous to the relation of set mem-bership. A number n is in relation NUMTRIE MEM with a numtrie s if n

belongs to the set of numbers associated to s.

let NUMTRIE_MEM_RULES, NUMTRIE_MEM_INDUCT, NUMTRIE_MEM_CASES =

new_inductive_definition

‘NUMTRIE_MEM 0 numzero /\

(!s t n. NUMTRIE_MEM n s ==>

NUMTRIE_MEM (2*n+1) (numnode s t)) /\

(!s t n. NUMTRIE_MEM n t ==>

NUMTRIE_MEM (2*n) (numnode s t))‘

We have proved three different theorems that give us rewrite rules forNUMTRIE MEM:

26

Chapter 3. Numtrie

NUMTRIE_MEM_CLAUSES

|- (!n. NUMTRIE_MEM n numempty <=> F) /\

(!n. NUMTRIE_MEM n numzero <=> n = 0) /\

(!s t n. NUMTRIE_MEM n (numnode s t) <=>

NUMTRIE_MEM (n DIV 2) (if ODD n then s else t))

BINARY_NUMTRIE_MEM

|- (!n. ~NUMTRIE_MEM n numempty) /\

(!n. NUMTRIE_MEM n numzero <=> n = 0) /\

(!s t. NUMTRIE_MEM 0 (numnode s t) <=>

NUMTRIE_MEM 0 t) /\

(!s t n. NUMTRIE_MEM (2 * n + 1) (numnode s t) <=>

NUMTRIE_MEM n s) /\

(!s t n. NUMTRIE_MEM (2 * n) (numnode s t) <=>

NUMTRIE_MEM n t)

ARITH_NUMTRIE_MEM

|- (!n. ~NUMTRIE_MEM n numempty) /\

(!s n. NUMTRIE_MEM (NUMERAL n) s <=> NUMTRIE_MEM n s) /\

(!n. NUMTRIE_MEM n numzero <=> n = _0) /\

(!s t n. NUMTRIE_MEM (BIT1 n) (numnode s t) <=>

NUMTRIE_MEM n s) /\

(!s t n. NUMTRIE_MEM (BIT0 n) (numnode s t) <=>

NUMTRIE_MEM n t)

The theorem BINARY NUMTRIE MEM uses the binary representation of naturalnumbers by means of the constructors 0, 2*n+1, 2*n given by

num_BINARY_SPLIT

|- !n. n = 0 \/ (?m. n = 2 * m + 1) \/

(?m. ~(m = 0) /\ n = 2 * m)

The theorem ARITH NUMTRIE MEM uses the internal representation of HOLLight: numerals are prettyprinted forms of an internal binary representationusing the constants 0,BIT0, BIT1, NUMERAL.

BIT0 = |- !n. BIT0 n = n + n

BIT1 = |- !n. BIT1 n = SUC (n + n)

27

Chapter 3. Numtrie

NUMERAL = |- !n. NUMERAL n = n

These constants are sufficient to express any number in binary. For example,we implement 37 as:

NUMERAL (BIT1 (BIT0 (BIT1 (BIT0 (BIT0 (BIT1 _0))))))

We may wonder why we use the constant NUMERAL at all, instead of just usingBIT0, BIT1 and 0. The reason is that in that case one number becomes asubterm of another (e.g. 1 is a subterm of 2), which can lead to somesurprising accidental rewrites. Besides, the NUMERAL constant is a useful tagfor the prettyprinter. Note that this representation is not unique. ¿Fromnow on we specify by prefixes ARITH and BINARY theorems about internaland binary representation of natural numbers respectively. BINARY theoremsare especially useful in proofs, ARITH ones are optimized for computing byrewrites.

By the relationship NUMTRIE MEM we can define the operator NUMTRIE.It assigns to every element of type :numtrie the relative set of naturalnumbers.

let NUMTRIE = new_definition

‘!t. NUMTRIE t = {n | NUMTRIE_MEM n t}‘

The theorem NUMTRIE CLAUSES makes explicit the way of assigning a setof natural numbers to each numtrie, whereas FINITE NUMTRIE asserts thatelements of type :numtrie represent finite sets.

NUMTRIE_CLAUSES

|- NUMTRIE numempty = {} /\

NUMTRIE numzero = {0} /\

(!s t. NUMTRIE (numnode s t) =

IMAGE (\n. 2*n+1) (NUMTRIE s) UNION

IMAGE (\n. 2*n) (NUMTRIE t))

FINITE_NUMTRIE

|- !t. FINITE (NUMTRIE t)

Now we can introduce the conversion NUMTRIE NUMTRIE CONV, it gives us anefficient algorithm for the computation of the set associated with a numtrie.

28

Chapter 3. Numtrie

NUMTRIE_NUMTRIE_CONV

‘NUMTRIE (numnode (numnode (numnode numzero numempty) numzero)

(numnode numzero

(numnode numzero numempty)))‘

# val it : thm =

|- NUMTRIE

(numnode (numnode (numnode numzero numempty) numzero)

(numnode numzero (numnode numzero numempty))) =

{4, 2, 1, 7}

The operation NUMTRIE MKNODE constructs a ”minimal” node from two ele-ments of type :numtrie.

let NUMTRIE_MKNODE = define

‘NUMTRIE_MKNODE numempty numempty = numempty /\

NUMTRIE_MKNODE numempty numzero = numzero /\

NUMTRIE_MKNODE numzero numempty =

numnode numzero numempty /\

NUMTRIE_MKNODE numzero numzero =

numnode numzero numzero /\

(!s t r. NUMTRIE_MKNODE (numnode s t) r =

numnode (numnode s t) r) /\

(!s t r. NUMTRIE_MKNODE r (numnode s t) =

numnode r (numnode s t))‘

In the same way like we do for sets we can define for elements of type:numtrie a notion of singleton, operations of intersection and union, insert-ing and deleting a natural number from a numtrie.

let NUMTRIE_SING = define

‘!n. NUMTRIE_SING n =

if n = 0 then

numzero

else if ODD n then

numnode (NUMTRIE_SING (n DIV 2)) numempty

else

numnode numempty (NUMTRIE_SING (n DIV 2))‘

let NUMTRIE_INSERT = define

‘(!n. NUMTRIE_INSERT n numempty = NUMTRIE_SING n) /\

(!n. NUMTRIE_INSERT n numzero =

if n = 0 then

29

Chapter 3. Numtrie

numzero

else if ODD n then

numnode (NUMTRIE_SING (n DIV 2)) numzero

else

numnode numempty (NUMTRIE_INSERT (n DIV 2) numzero)) /\

(!s t n. NUMTRIE_INSERT n (numnode s t) =

if ODD n then

numnode (NUMTRIE_INSERT (n DIV 2) s) t

else

numnode s (NUMTRIE_INSERT (n DIV 2) t))‘

let NUMTRIE_UNION = define

‘(!s. NUMTRIE_UNION s numempty = s) /\

(!s. NUMTRIE_UNION numempty s = s) /\

NUMTRIE_UNION numzero numzero = numzero /\

(!s t. NUMTRIE_UNION (numnode s t) numzero =

numnode s (NUMTRIE_UNION t numzero)) /\

(!s t. NUMTRIE_UNION numzero (numnode s t) =

numnode s (NUMTRIE_UNION t numzero)) /\

(!s t r q. NUMTRIE_UNION (numnode s t)(numnode r q) =

numnode (NUMTRIE_UNION s r)(NUMTRIE_UNION t q))‘

Like for NUMTRIE MEM, we have proved theorems of type BINARY and ARITH

for this operations and properties analogous to properties of set operations.The following theorems connect previous operations to the operator NUMTRIE

NUMTRIE_SING_THM

|- !n. NUMTRIE (NUMTRIE_SING n) = {n}

NUMTRIE_INSERT_THM

|- !t n. NUMTRIE (NUMTRIE_INSERT n t) = n INSERT NUMTRIE t

NUMTRIE_UNION_THM

|- !s t. NUMTRIE (NUMTRIE_UNION s t) =

NUMTRIE s UNION NUMTRIE t

Two elements of type numtrie satisfy the relation NUMTRIE EQ if they havethe same elements, i.e. if they represent the same set

let NUMTRIE_EQ = new_definition

30

Chapter 3. Numtrie

‘!s t. NUMTRIE_EQ s t <=>

(!n. NUMTRIE_MEM n s <=> NUMTRIE_MEM n t)‘

NUMTRIE_EQ_THM

|- !s t. NUMTRIE_EQ s t <=> NUMTRIE s = NUMTRIE t

The relation NUMTRIE EQ is very useful because it is difficult to comparedirectly finite sets of natural numbers, but it is straight comparing tworepresentation by numtries rewriting the following theorem.

NUMTRIE_EQ_RULES

|- (!s. NUMTRIE_EQ s s) /\

~NUMTRIE_EQ numzero numempty /\

~NUMTRIE_EQ numempty numzero /\

(!s t. NUMTRIE_EQ (numnode s t) numempty <=>

NUMTRIE_EQ s numempty /\ NUMTRIE_EQ t numempty) /\

(!s t. NUMTRIE_EQ numempty (numnode s t) <=>

NUMTRIE_EQ s numempty /\ NUMTRIE_EQ t numempty) /\

(!s t. NUMTRIE_EQ (numnode s t) numzero <=>

NUMTRIE_EQ s numempty /\ NUMTRIE_EQ t numzero) /\

(!s t. NUMTRIE_EQ numzero (numnode s t) <=>

NUMTRIE_EQ s numempty /\ NUMTRIE_EQ t numzero) /\

(!s1 s2 t1 t2. NUMTRIE_EQ (numnode s1 t1)

(numnode s2 t2) <=>

NUMTRIE_EQ s1 s2 /\ NUMTRIE_EQ t1 t2)

Hence, using the following

EQ_NUMTRIE_EQ

|- !s t. FINITE s /\ FINITE t ==>

( s = t <=> NUMTRIE_EQ (MK_NUMTRIE s) (MK_NUMTRIE t))

we can define the conversion EQ SET CONV that establishes if two finite setsof numbers are the same

EQ_SET_CONV ‘{3,1,4} = {3,4,1}‘;;

# val it : thm = |- {3, 1, 4} = {3, 4, 1} <=> T

EQ_SET_CONV ‘{3,1,4,7} = {3,4,1}‘;;

# val it : thm = |- {3, 1, 4, 7} = {3, 4, 1} <=> F

31

Chapter 3. Numtrie

Finally we can define also the relations of inclusion NUMTRIE SUBSET anddisjunction NUMTRIE DISJOINT of numtries.

In the same way as for equality, the relation NUMTRIE SUBSET enablesus to define the conversion SUBSET CONV, that establishes if a finite set ofnumbers is a subset of an other one.

The operator MK NUMTRIE is an injective operator that associate to everyfinite set of natural numbers an element of type :numtrie that correspondsto it via the operator NUMTRIE.

let MK_NUMTRIE = define

‘!s. MK_NUMTRIE s = ITSET NUMTRIE_INSERT s numempty‘

NUMTRIE_MK_NUMTRIE

|- !s. FINITE s ==> NUMTRIE (MK_NUMTRIE s) = s

MK_NUMTRIE_INJ

|- !x y. FINITE x /\ FINITE y ==>

(MK_NUMTRIE x = MK_NUMTRIE y ==> x = y)

Since the representation of sets of numbers by elements of type :numtrie isnot unique, the operator NUMTRIE is not injective and is not the inverse ofMK NUMTRIE. The operator MK NUMTRIE picks out from these representationsthe canonical one as defined here below.

let NUMTRIE_CANONICAL_RULES, NUMTRIE_CANONICAL_INDUCT,

NUMTRIE_CANONICAL_CASES =

new_inductive_definition

‘NUMTRIE_CANONICAL numempty /\

NUMTRIE_CANONICAL numzero /\

(!s t. NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t /\

~(s = numempty)

==> NUMTRIE_CANONICAL (numnode s t)) /\

(!s t. NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t /\

~(t = numempty) /\ ~(t = numzero)

==> NUMTRIE_CANONICAL (numnode numempty t))‘

The following theorem holds

CANONICAL_MK_NUMTRIE

|- !s. FINITE s ==> NUMTRIE_CANONICAL (MK_NUMTRIE s)

32

Chapter 3. Numtrie

Every finite set of natural numbers is represented by a canonical element oftype :numtrie,

EXISTS_NUMTRIE

|- !t. FINITE t ==>

?!s. t = NUMTRIE s /\ NUMTRIE_CANONICAL s

The collection of canonical numtries is closed under all the operations de-fined above, for example under NUMTRIE UNION

CANONICAL_NUMTRIE_UNION

|- !s t. NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t ==>

NUMTRIE_CANONICAL (NUMTRIE_UNION s t)

If we restrict us to canonical numtries the NUMTRIE operator is injectiveand it is the inverse of MK NUMTRIE.

CANONICAL_NUMTRIE_INJ

|- !s t. NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t

==> (s = t <=> NUMTRIE s = NUMTRIE t)

MK_NUMTRIE_NUMTRIE

|- !t. NUMTRIE_CANONICAL t ==> MK_NUMTRIE (NUMTRIE t) = t

33

Chapter 3. Numtrie

34

Chapter 4

Z-modules

Our aim is to formalize simplicial homology with integer coefficients. For thispurpose we must first provide a notion of module over the ring of integers Z.We will restrict ourselves to free complexes (i.e., complexes of free modules)so we formalize only the notion of free module over Z. Hence we introduce anew type :A zmod which is bijective with the type of the maps from :A andthe type of integers :int. Thus, an object of type :A zmod can be thoughtas a vector with integer coefficients indexed by an other type :A.

To make a new type definition we use the function new type definition.It introduces a new type in bijection with a nonempty subset of an existingtype. More precisely, the call

new basic type definition "ty" ("mk","dest") th

where th is a theorem of the form |- ?x.P x (say x has type rep) willintroduce a new type called ty plus two new constants mk:rep->ty anddest:ty->rep, and return a theorem asserting that mk and dest establisha bijection between the universe of the new type ty and the subset of thetype rep identified by the predicate P:

|- (!a. mk(dest a) = a) / (!r. P r <=> dest(mk r) = r)

In our case we don’t want to restrict us to a proper subset of the universeof type :A int; the constants zmod and zmod fun correspond to constructor(mk) and destructor (dest) which establish a bijection between the types :Azmod and :A->int.

let zmod_tybij =

REWRITE_RULE []

(new_type_definition "zmod" ("zmod", "zmod_fun")

(prove (‘?f:A->int. T‘, REWRITE_TAC[])))

35

Chapter 4. Z-modules

val zmod_tybij : thm =

|- (!a. zmod (zmod_fun a) = a) /\

(!r. zmod_fun (zmod r) = r)

We denote by zzero the element corresponding to null function.

let zzero = new_definition

‘zzero = zmod (\i. &0)‘

and by zvec the standard generators

let zvec = new_definition

‘!k. zvec k = zmod (\i. if i=k then &1 else &0)‘

After defining the basic operations of addition, subtraction and scalar mul-tiplication, we proved a lot of standard algebraic identities as, for instance,commutativity and associavity of addition

ZMOD_ADD_SYM

|- !x y z. x + y = y + x

ZMOD_ADD_ASSOC

|- !x y z. x + (y + z) = (x + y) + z

or distributivity of scalar multiplication over sum

ZMOD_ADD_LDISTRIB

|- !c y z. c ** (y + z) = c ** y + c ** z

ZMOD_ADD_RDISTRIB

|- !c d z. (c + d) ** z = c ** z + d ** z

We call zsupport of an element of type :A zmod the set of indexes withnonzero coefficient

let zsupport = new_definition

‘!x. zsupport x = {i | ~(zmod_fun x i = &0)}‘

36

Chapter 4. Z-modules

We want to define a boundary operator, so we need to sum elements of type:A zmod over an index set. The new summation operation :zsum can suma function into elements of type :A zmod over a finite1 set whose elementshave any type.

let zsum = new_definition

‘!f s. zsum s f = zmod (\i. isum s (\a. zmod_fun (f a) i))‘

We proved several theorems about zsum concerning operations over indexsets or operations between functions.

ZSUM_CLAUSES

|- !f. zsum {} f = zzero) /\ (!x f s. FINITE(s)

==> (zsum (x INSERT s) f =

if x IN s then zsum s f else f(x) + zsum s f))

ZSUM_UNION

|- !f s t. FINITE s /\ FINITE t /\ DISJOINT s t

==> (zsum (s UNION t) f = zsum s f + zsum t f)

ZSUM_ADD

|- !f g s. FINITE s ==>

zsum s (\x. f(x) + g(x)) = zsum s f + zsum s g)

Moreover we proved that every element of type :A zmod can be written asfinite sum of standard generators.

ZVEC_AS_BASIS

|- !x. x = zsum (zsupport x) (\i. zmod_fun x i ** zvec i)

The operator zhom lifts a function f defined from a set s of elements of type:A into the universe of type :B zmod to a function from the set f(s) intothe universe of type :B zmod.

let zhom = new_definition

‘!(s:A->bool) (f:A -> B zmod) (x: A zmod).

zhom f s x = zsum s (\a. zmod_fun x a ** (f a))‘

1Actually the set can be infinite provided the function has finite support.

37

Chapter 4. Z-modules

So that the following property holds.

ZHOM_ZVEC

|- !s f i. zhom f s(zvec i) = if i IN s then f i else zzero

Defining linearity for a function f from the universe of type :A zmod intothe universe of type :B zmod

let LINEAR = new_definition

‘!f:A zmod -> B zmod.

LINEAR f <=>

(!x y. f (x + y) = f x + f y) /\

(!c x. f (c ** x) = c ** f x)‘

we have

ZHOM_LINEAR

|- !s f. FINITE s ==> LINEAR (zhom f s)

LINEAR_ZVEC_0

|- !f x. LINEAR f /\ (!i. f (zvec i) = zzero) /\

FINITE (zsupport x) ==>

f x = zzero

It can be defined a notion of submodule

let zsubmod = new_definition

‘!(m:A zmod->bool). zsubmod m <=>

~(m = {}) /\

(!x y. x IN m /\ y IN m ==> x - y IN m) /\

(!c x. x IN m ==> c ** x IN m)‘

and we can verify that the element zzero belongs to every submodule, thatthe singleton {0} and the universe are submodules and the intersection oftwo submodules is a submodule too.

ZZERO_IN_ZSUBMOD

|- !m. zsubmod m ==> zzero IN m

38

Chapter 4. Z-modules

ZSUBMOD_ZZERO

|- zsubmod {zzero}

ZSUBMOD_UNIV

|- zsubmod UNIV

INTER_ZSUBMOD

|- !m n. zsubmod m /\ zsubmod n ==> zsubmod (m INTER n)

The kernel of a linear map is a submodule

let zkernel = new_definition

‘!(f:A zmod->B zmod). zkernel f = {x | f x = zzero}‘

ZSUBMOD_ZKERNEL

|- !f. LINEAR f ==> zsubmod (zkernel f)

and the image of a submodule by a linear map is a submodule.

ZSUBMOD_IMAGE

|- !f s. LINEAR f /\ zsubmod s ==> zsubmod (IMAGE f s)‘

The submodule generated by a set s is the intersection of all submodulescontaining the set s.

let zgen = new_definition

‘!s. zgen s = {x| !m. zsubmod m /\ s SUBSET m ==> x IN m}‘

ZSUBMOD_ZGEN

|- !s. zsubmod zgen s

The empty set generates the trivial submodule {zzero}.

ZGEN_EMPTY

|- zgen {} = {zzero}

The following two theorems describe the submodule generated by a standardgenerator.

39

Chapter 4. Z-modules

ZGEN_ZVEC

|- !s. zgen {zvec s} =

{x | !t. ~(t = s) ==> zmod_fun x t = &0}

IN_ZGEN_ZVEC

|- !i x. x IN zgen {zvec i} <=> ?c. x = c ** zvec i

The submodule generated by a finite set s can be written as the set of linearcombinations of elements of s

let zjoin = new_definition

‘!(u:(A zmod) zmod). zjoin u =

zsum UNIV (\v. zmod_fun u v ** v)‘

ZJOIN_DEF2

|- !u. zjoin u = zsum (zsupport u) (\v. zmod_fun u v ** v)

let zcomb = new_definition

‘!s. zcomb s = {x | ?u. zsupport u SUBSET s /\ x = zjoin u}‘

We have indeed the following theorems

ZCOMB_ZSUBMOD

|- !s. FINITE s ==> zsubmod (zcomb s)

ZGEN_ZCOMB

|- !s. FINITE s ==> zgen s = zcomb s‘

40

Chapter 5

Boundary map

5.1 Boundary map

Given a simplicial complex C, for every i ∈ Z we call Fi(C) the set of i-dimensional simplexes of C, i.e. the simplexes of cardinality i + 1. For eachs ∈ Fi(C), let es indicate the corresponding basis vector in Z

Fi(C), the Z-vector space of the functions from Fi(C) to Z. Every element of Z

Fi(C) is aformal sum of elements of type es with coefficients in Z and s ∈ Fi(C) andis called k-chain. The i-boundary

∂i : ZFi(C) → Z

Fi−1(C)

is defined as∂i(es) =

j∈s

sign(j, s)es\{j}

where sign(j, s) = (−1)i−1 if j is the i-th element of s when the elements ofs are listed in increasing order. If i > SIMPLICIAL DIM C or i < −1then Z

Fi(C) = 0 and we define ∂i = 0.We call chain complex of C the pair F (C), ∂, where

F (C) = ⊕Fi(C)

and∂ = ⊕∂i

∂ is called boundary operator.One of the most important result concerning bound operator is that

∂i ◦ ∂i+1 = 0 for every i.

41

Chapter 5. Boundary map

The following pictures provides geometric motivation for the definitionof the boundary map:

0

1

-∂0

r

r

0 −

1 −

0 AA

AA

AA

AA

AA

AA

������������

1

2

-∂1

�������������� A

AAAAAAAAAAAU

0 2

0 2

1 1

Figure 5.1: Boundary maps

Now we want to formalize in HOL Light this notion of boundary opera-tor. We call FF C i the set of i-dimensional faces of C

let FF = new_definition

‘FF C i = {s | s IN C /\ SIMPLEX_DIM s = i}‘

and instead of functions from FF C i to Z we consider the Z-module ofelements of type :(num->bool) zmod with support in FF C i.

let ZCC = new_definition

‘!C i. ZCC C i = {x | zsupport x SUBSET FF C i}‘

We introduce the function sign that associates to every set of numbers andevery natural number the value 1 or −1.

42

Chapter 5. Boundary map

let sign = define

‘! j s. sign j s = (-- &1) pow CARD {n |(n IN s) /\ n < j}‘

We can compute the function sign using the following theorems

SIGN_INSERT

|- !j i s. sign j (i INSERT s) = (if i IN s

then sign j s

else if j <= i then sign j s else --sign j s)

SIGN_DELETE

|- !j x s. FINITE s /\ x IN s

==> sign j (s DELETE x) =

(if x < j then --sign j s else sign j s)

Hence, remembering that the operator zhom lifts a function f defined from aset s of elements of type :A into the universe of type :B zmod to a functionfrom the set f(s) into the universe of type :B zmod, we define ZOP BOUND

C the boundary operator associated with a simplicial complex C.

let ZOP_BOUND = define

‘!C. ZOP_BOUND C =

zhom (\s. zsum s (\j. sign j s ** zvec (s DELETE j))) C‘

And we have as above

ZOP_BOUND_IN_ZCC

|- !C x i. SIMPLICIAL C /\ x IN ZCC C (i + &1)

==> ZOP_BOUND C x IN ZCC C i

The main theoretical result of this section is the well-known principle thata boundary of a boundary is zero, that is zzero.

ZOP_BOUND_THM

|- !C x. SIMPLICIAL C ==>

ZOP_BOUND C (ZOP_BOUND C x) = zzero

The proofs proceeds in several steps.

We have shown that the operator ZOP BOUND is linear.

43

Chapter 5. Boundary map

LINEAR_ZOP_BOUND

|- !C. SIMPLICIAL C ==> LINEAR (ZOP_BOUND C)

So we verify the identity on the generators zvec, using the fact that ZOP BOUND

has a more easy expression on them.

ZOP_BOUND_ZVEC

|- !C s. ZOP_BOUND C (zvec s) =

if s IN C then

zsum s (\j. sign j s ** zvec (s DELETE j))

else zzero

ZVEC_THM

|- !C s. SIMPLICIAL C ==>

ZOP_BOUND C (ZOP_BOUND C (zvec s)) = zzero

and then using the following theorem

LINEAR_ZVEC_0

|- !f x. LINEAR f /\ (!i. f (zvec i) = zzero)

/\ FINITE (zsupport x) ==> f x = zzero

we can extend by linearity the result to elements of finite support

FINITE_ZSUPPORT_THM

|- !C x. SIMPLICIAL C /\ FINITE (zsupport x)

==> ZOP_BOUND C (ZOP_BOUND C (x)) = zzero

Now, in order to extend this result, we must prove that for every elementthere exists an element of finite support that has the same boundary.

We define ZFSI the set of elements that are zzero out of C, i.e. the setof elements with support in C.

ZFSI_ZSUPPORT

|- !C. ZFSI C = {s | zsupport s SUBSET C}

By the operation ZLOC we can cancel all the components of an element outof C and then we get an element with finite support and the same boundary.

44

Chapter 5. Boundary map

let ZLOC = new_definition

‘ZLOC C x =

zmod (\s. if s IN C then zmod_fun x s else &0)‘

ZLOC_LEMMA

|- !C x . (ZLOC C x) IN ZFSI C /\

(ZOP_BOUND C x = ZOP_BOUND C (ZLOC C x))

5.2 Boundary map on numtries

With the aim of computing explicitly the boundary associated with a simpli-cial complex we introduce a notion of boundary for numtries that respectsthe representation of finite sets of numbers as numtries.

First we define NUMTRIE SIGN in immediate way.

let NUMTRIE_SIGN_THM = define

‘!j s. NUMTRIE_SIGN j s = sign j (NUMTRIE s)‘

NUMTRIE_SIGN

|- (!j. NUMTRIE_SIGN j numempty = &1) /\

(!j. NUMTRIE_SIGN j numzero = if j = 0

then &1 else -- &1) /\

(!j s t. NUMTRIE_SIGN j (numnode s t) = if j = 0 then &1

else NUMTRIE_SIGN (j DIV 2) s *

NUMTRIE_SIGN (SUC j DIV 2) t)

Thanks to theorems of kind ARITH and BINARYwe can compute NUMTRIE SIGN.In fact we have constructed the conversion NUMTRIE SIGN CONV

NUMTRIE_SIGN_CONV

‘NUMTRIE_SIGN 3 (numnode numzero

(numnode numzero numempty))‘;;

# val it : thm =

|- NUMTRIE_SIGN 3 (numnode numzero

(numnode numzero numempty)) = &1

The second step is to define the summation of numtries

45

Chapter 5. Boundary map

let zsumnt = new_definition

‘!s. zsumnt s = zsum (NUMTRIE s)‘

So we can define ZOP BOUND NUMTRIE

let ZOP_BOUND_NUMTRIE = new_definition

‘!C. ZOP_BOUND_NUMTRIE C =

zhom (\s. zsumnt s

(\j. (NUMTRIE_SIGN j s) ** zvec (NUMTRIE_DELETE j s))) C‘

We have now to verify that ZOP BOUND NUMTRIE respects the representationof sets of numbers as numtries.

Given a map f from the universe of type :A to the universe of type :B,the function ZMOD MAP f defined below goes from the universe of type :B

zmod to the universe of type :A zmod in the obvious way. Since the functionMK NUMTRIE is determined only over finite sets we use the function TR insteadof ZMOD MAP(MK NUMTRIE).

let ZMOD_MAP = new_definition

‘!(f:A->B) y. ZMOD_MAP f y = zmod(\i. zmod_fun y (f i))‘

let TR = new_definition

‘!x. TR x = zmod (\s. if FINITE s

then zmod_fun x (MK_NUMTRIE s)

else &0)‘

ZOP_BOUND_NUMTRIE_THM

|- !C. SIMPLICIAL C ==>

ZOP_BOUND C = TR o ZOP_BOUND_NUMTRIE

(IMAGE MK_NUMTRIE C) o

ZMOD_MAP (NUMTRIE)

The conversion ZOP BOUND NUMTRIE CONV computes ZOP BOUND NUMTRIE as-sociated with the image of a simplicial complex.

See for instance the simplicial complex ZIEGLER, given below by its min-imal set of generators

let ZIEGLER = new_definition

‘ZIEGLER = SIMPLICIAL_GENERATED

{ {1,2,3,4}, {1,2,5,6}, {2,3,6,7}, {3,4,7,8}, {4,1,8,5},

{1,5,6,9},{1,6,2,9}, {1,2,4,9}, {1,4,8,9}, {1,8,5,9},

46

Chapter 5. Boundary map

{2,5,6,10}, {2,6,7,10}, {2,7,3,10}, {2,3,1,10},

{2,1,5,10},{3,6,7,8}, {3,2,4,8}, {3,2,6,8}, {4,5,7,8},

{4,1,3,7}, {4,1,5,7} }‘

We can use the conversion ZOP BOUND NUMTRIE CONV together with the con-version SIMPLICIAL GENERATED CONV to compute the value of the bound-ary of MK NUMTRIE ZIEGLER on the standard generator (zvec (MK NUMTRIE

(1,2,3,4))).

(REWRITE_CONV[ZIEGLER] THENC

SIMPLICIAL_GENERATED_CONV THENC

ZOP_BOUND_NUMTRIE_CONV)

‘ZOP_BOUND_NUMTRIE

(IMAGE MK_NUMTRIE (ZIEGLER))

(zvec (MK_NUMTRIE ({1,2,3,4})))‘;;

# val it : thm =

|- ZOP_BOUND_NUMTRIE (IMAGE MK_NUMTRIE ZIEGLER)

(zvec (MK_NUMTRIE {1, 2, 3, 4})) =

zvec (numnode numzero

(numnode numzero

(numnode numzero numempty))) +

zvec

(numnode (numnode numzero numempty)

(numnode numzero (numnode numzero numempty))) +

-- &1 **

zvec

(numnode (numnode numzero numzero)

(numnode numempty (numnode numzero numempty))) +

-- &1 **

zvec (numnode (numnode numzero numzero)

(numnode numzero numempty))

47

Chapter 5. Boundary map

48

Conclusions

In this thesis we have developed a HOL Light library of definitions andtheorems concerning Abstract Simplicial Homology.

First we have formalized the concept of abstract simplicial complex andother related basic notions. We have developed a way of describing a sim-plicial complex via a suitable set of generators and we have proved thatevery simplicial complex can be generated by a minimal set of generators.We have also defined some interesting examples of simplicial complexes likecones, suspensions and spheres.

We further have formalized the concept of connectiveness, defining theconnected components of a simplicial complex and we have proved thatspheres are connected.

In order to define the chain complex of a simplicial complex and theboundary map associated to a simplicial complex, we have formalized thebasics of the theory of free modules over the ring of integers. Then we havedefined the chain complex and the boundary map of a simplicial complexand we have proved the well known property that a bondary of a boundaryis zero.

Homology is a general tool to define and compute important topologicalinvariants and this gives to the theory a strong constructive flavor and makesit especially appealing to mechanization. We made a constant effort toexploit the computational nature of the theory by writing algorithms anddecision procedures at each stage of the development.

In order to have an efficient way of computing we have developed a rep-resentation of finite sets of natural numbers by prefix trees. A modifiedversion of this library has been included for release in the next develop-ment snapshot of the HOL Light system. Thanks to this representation wehave constructed a conversion that computes explicitely the bound operatorassociated with a simplicial complex.

In the appendix we give the complete list of the statements of the theo-rems proved. Complessively the whole size of our library is 230Kb and con-tains about 600 theorems. The complete sources of our developement can befound at the following address: http://www.math.unifi.it/users/lomuto/

49

Conclusions

50

Appendix A

Theorems

A.1 Sets

COLLECT

|- !P s. COLLECT P s = {x | x IN s /\ P x}

COLLECT_CLAUSES

|- (!P. COLLECT P {} = {}) /\

(!P s x.

COLLECT P (x INSERT s) =

(if P x then x INSERT COLLECT P s else COLLECT P s))

DELETE_THM

|- !s t x.

s DELETE x = t <=>

~(x IN s) /\ s = t \/ ~(x IN t) /\ s = x INSERT t

DELETE_THM2

|- !P s x. P s /\ P (x INSERT s) ==> (!t. t DELETE x = s ==> P t)

DISJOINTS

|- !u. DISJOINTS u <=>

(!s t. s IN u /\ t IN u /\ ~(s = t) ==> DISJOINT s t)

DISJOINTS_DISJOINT

|- !u s t. DISJOINTS u /\ s IN u /\ t IN u /\ ~(s = t) ==> DISJOINT s t

FINITE_FINITE_SUBSETS

|- !C. FINITE C /\ (!t. t IN C ==> FINITE t)

==> FINITE {p | ?t. t IN C /\ p SUBSET t}

FINITE_RECURSION_EMPTY

|- !f b.

(!x y s. ~(x = y) ==> f x (f y s) = f y (f x s))

==> ITSET f {} b = b

FINITE_RECURSION_INSERT

|- !f b x s.

(!x y s. ~(x = y) ==> f x (f y s) = f y (f x s)) /\ FINITE s

==> ITSET f (x INSERT s) b =

(if x IN s then ITSET f s b else f x (ITSET f s b))

IMAGE_EMPTY

|- !f. IMAGE f {} = {}

51

Appendix A. Theorems

IMAGE_ID_THM

|- !f s. (!x. x IN s ==> f x = x) ==> IMAGE f s = s

IMAGE_INSERT

|- !f s x. IMAGE f (x INSERT s) = f x INSERT IMAGE f s

INSERT_UNION_BIS

|- !s t x. x INSERT s UNION t = x INSERT (s UNION t)

IN_COLLECT

|- !P s x. x IN COLLECT P s <=> x IN s /\ P x

IN_SUBSETS

|- !x s. x IN SUBSETS s <=> x SUBSET s

PARTITION

|- !P s. PARTITION P s = COLLECT P s,COLLECT ((~) o P) s

PARTITION_CLAUSES

|- (!P. PARTITION P {} = {},{}) /\

(!P s x.

PARTITION P (x INSERT s) =

(let a,b = PARTITION P s in

if P x then x INSERT a,b else a,x INSERT b))

SET_ALL

|- !P s. SET_ALL P s <=> (!x. x IN s ==> P x)

SET_ALL_CLAUSES

|- (!P. SET_ALL P {}) /\

(!P s x. SET_ALL P (x INSERT s) <=> P x /\ SET_ALL P s)

SET_ALL_UNION

|- !P s t. SET_ALL P (s UNION t) <=> SET_ALL P s /\ SET_ALL P t

SET_EQ_COMPUTE

|- !s t. s = t <=> SET_ALL (\x. x IN t) s /\ SET_ALL (\x. x IN s) t

SET_EX

|- !P s. SET_EX P s <=> (?x. x IN s /\ P x)

SET_EX_CLAUSES

|- (!P. ~SET_EX P {}) /\

(!P s x. SET_EX P (x INSERT s) <=> P x \/ SET_EX P s)

SUBSETS

|- !s. SUBSETS s = {t | t SUBSET s}

SUBSETS_EMPTY

|- SUBSETS {} = {{}}

SUBSETS_IMAGE

|- !f. (!x y. f x = f y ==> x = y)

==> (!s. SUBSETS (IMAGE f s) = IMAGE (IMAGE f) (SUBSETS s))

SUBSETS_INSERT

|- !s a.

SUBSETS (a INSERT s) =

SUBSETS s UNION IMAGE ((INSERT) a) (SUBSETS s)

SUBSETS_THM

52

Appendix A. Theorems

|- !x s. x IN {t | t SUBSET s} <=> x SUBSET s

UNIONS_PSUBSET

|- !s t.

UNIONS s PSUBSET t <=>

UNIONS s SUBSET t /\ (?x. x IN t /\ (!r. r IN s ==> ~(x IN r)))

A.2 Numtries

ARITH_NUMTRIEK

|- (!acc k. NUMTRIEK acc k numempty = acc) /\

(!acc k. NUMTRIEK acc k numzero = k _0 INSERT acc) /\

(!acc k s t.

NUMTRIEK acc k (numnode s t) =

NUMTRIEK (NUMTRIEK acc (k o BIT1) s) (k o BIT0) t)

ARITH_NUMTRIE_DELETE

|- (!s n. NUMTRIE_DELETE (NUMERAL n) s = NUMTRIE_DELETE n s) /\

(!n. NUMTRIE_DELETE n numempty = numempty) /\

(!n. NUMTRIE_DELETE n numzero = (if n = _0 then numempty else numzero)) /\

(!s t.

NUMTRIE_DELETE _0 (numnode s t) =

NUMTRIE_MKNODE s (NUMTRIE_DELETE _0 t)) /\

(!s t n.

NUMTRIE_DELETE (BIT1 n) (numnode s t) =

NUMTRIE_MKNODE (NUMTRIE_DELETE n s) t) /\

(!s t n.

NUMTRIE_DELETE (BIT0 n) (numnode s t) =

NUMTRIE_MKNODE s (NUMTRIE_DELETE n t))

ARITH_NUMTRIE_INSERT

|- (!s n. NUMTRIE_INSERT (NUMERAL n) s = NUMTRIE_INSERT n s) /\

(!n. NUMTRIE_INSERT n numempty = NUMTRIE_SING n) /\

NUMTRIE_INSERT _0 numzero = numzero /\

(!s t n.

NUMTRIE_INSERT _0 (numnode s t) = numnode s (NUMTRIE_INSERT _0 t)) /\

(!n. NUMTRIE_INSERT (BIT1 n) numzero = numnode (NUMTRIE_SING n) numzero) /\

(!n. NUMTRIE_INSERT (BIT0 n) numzero =

(if n = _0

then numzero

else numnode numempty (NUMTRIE_INSERT n numzero))) /\

(!s t n.

NUMTRIE_INSERT (BIT1 n) (numnode s t) =

numnode (NUMTRIE_INSERT n s) t) /\

(!s t n.

NUMTRIE_INSERT (BIT0 n) (numnode s t) =

numnode s (NUMTRIE_INSERT n t))

ARITH_NUMTRIE_MEM

|- (!n. ~NUMTRIE_MEM n numempty) /\

(!s n. NUMTRIE_MEM (NUMERAL n) s <=> NUMTRIE_MEM n s) /\

(!n. NUMTRIE_MEM n numzero <=> n = _0) /\

(!s t n. NUMTRIE_MEM (BIT1 n) (numnode s t) <=> NUMTRIE_MEM n s) /\

(!s t n. NUMTRIE_MEM (BIT0 n) (numnode s t) <=> NUMTRIE_MEM n t)

ARITH_NUMTRIE_SING

|- (!n. NUMTRIE_SING (NUMERAL n) = NUMTRIE_SING n) /\

NUMTRIE_SING _0 = numzero /\

(!n. NUMTRIE_SING (BIT1 n) = numnode (NUMTRIE_SING n) numempty) /\

53

Appendix A. Theorems

(!n. NUMTRIE_SING (BIT0 n) =

(if n = _0 then numzero else numnode numempty (NUMTRIE_SING n)))

BINARY_BIT

|- (!n. 2 * n + 1 = BIT1 n) /\ (!n. 2 * n = BIT0 n)

BINARY_DISTINCT

|- (!n. ~(2 * n + 1 = 0)) /\

(!n. ~(0 = 2 * n + 1)) /\

(!n. 2 * n = 0 <=> n = 0) /\

(!n. 0 = 2 * n <=> n = 0) /\

(!m n. ~(2 * m + 1 = 2 * n)) /\

(!m n. ~(2 * m = 2 * n + 1))

BINARY_DIV_2

|- 0 DIV 2 = 0 /\ (!n. (2 * n + 1) DIV 2 = n) /\ (!n. (2 * n) DIV 2 = n)

BINARY_INJ2

|- !m. 2 * m = 0 <=> m = 0

BINARY_INJECTIVE

|- (!m n. 2 * m + 1 = 2 * n + 1 <=> m = n) /\

(!m n. 2 * m = 2 * n <=> m = n)

BINARY_NUMTRIE_DELETE

|- (!n. NUMTRIE_DELETE n numempty = numempty) /\

(!n. NUMTRIE_DELETE n numzero = (if n = 0 then numempty else numzero)) /\

(!s t.

NUMTRIE_DELETE 0 (numnode s t) =

NUMTRIE_MKNODE s (NUMTRIE_DELETE 0 t)) /\

(!s t n.

NUMTRIE_DELETE (2 * n + 1) (numnode s t) =

NUMTRIE_MKNODE (NUMTRIE_DELETE n s) t) /\

(!s t n.

NUMTRIE_DELETE (2 * n) (numnode s t) =

NUMTRIE_MKNODE s (NUMTRIE_DELETE n t))

BINARY_NUMTRIE_INSERT

|- (!n. NUMTRIE_INSERT n numempty = NUMTRIE_SING n) /\

NUMTRIE_INSERT 0 numzero = numzero /\

(!s t. NUMTRIE_INSERT 0 (numnode s t) = numnode s (NUMTRIE_INSERT 0 t)) /\

(!n. NUMTRIE_INSERT (2 * n + 1) numzero =

numnode (NUMTRIE_SING n) numzero) /\

(!n. NUMTRIE_INSERT (2 * n) numzero =

(if n = 0

then numzero

else numnode numempty (NUMTRIE_INSERT n numzero))) /\

(!s t n.

NUMTRIE_INSERT (2 * n + 1) (numnode s t) =

numnode (NUMTRIE_INSERT n s) t) /\

(!s t n.

NUMTRIE_INSERT (2 * n) (numnode s t) =

numnode s (NUMTRIE_INSERT n t))

BINARY_NUMTRIE_INSERT_MKNODE

|- (!s t.

NUMTRIE_INSERT 0 (NUMTRIE_MKNODE s t) =

NUMTRIE_MKNODE s (NUMTRIE_INSERT 0 t)) /\

(!s t m.

NUMTRIE_INSERT (2 * m + 1) (NUMTRIE_MKNODE s t) =

NUMTRIE_MKNODE (NUMTRIE_INSERT m s) t) /\

(!s t m.

54

Appendix A. Theorems

NUMTRIE_INSERT (2 * m) (NUMTRIE_MKNODE s t) =

NUMTRIE_MKNODE s (NUMTRIE_INSERT m t))

BINARY_NUMTRIE_MEM

|- (!n. ~NUMTRIE_MEM n numempty) /\

(!n. NUMTRIE_MEM n numzero <=> n = 0) /\

(!s t. NUMTRIE_MEM 0 (numnode s t) <=> NUMTRIE_MEM 0 t) /\

(!s t n. NUMTRIE_MEM (2 * n + 1) (numnode s t) <=> NUMTRIE_MEM n s) /\

(!s t n. NUMTRIE_MEM (2 * n) (numnode s t) <=> NUMTRIE_MEM n t)

BINARY_NUMTRIE_MEM_MKNODE

|- (!s t n. NUMTRIE_MEM 0 (NUMTRIE_MKNODE s t) <=> NUMTRIE_MEM 0 t) /\

(!s t n.

NUMTRIE_MEM (2 * n + 1) (NUMTRIE_MKNODE s t) <=> NUMTRIE_MEM n s) /\

(!s t n. NUMTRIE_MEM (2 * n) (NUMTRIE_MKNODE s t) <=> NUMTRIE_MEM n t)

BINARY_NUMTRIE_SING

|- NUMTRIE_SING 0 = numzero /\

(!n. NUMTRIE_SING (2 * n + 1) = numnode (NUMTRIE_SING n) numempty) /\

(!n. NUMTRIE_SING (2 * n) =

(if n = 0 then numzero else numnode numempty (NUMTRIE_SING n)))

BINARY_ODD

|- ~ODD 0 /\ (!n. ODD (2 * n + 1)) /\ (!n. ~ODD (2 * n))

CANONICAL_MK_NUMTRIE

|- !s. FINITE s ==> NUMTRIE_CANONICAL (MK_NUMTRIE s)

CANONICAL_NUMTRIE_INJ

|- !s t.

NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t

==> (s = t <=> NUMTRIE s = NUMTRIE t)

CANONICAL_NUMTRIE_INSERT

|- !s x. NUMTRIE_CANONICAL s ==> NUMTRIE_CANONICAL (NUMTRIE_INSERT x s)

CANONICAL_NUMTRIE_INSERT_NUMEMPTY

|- !x. NUMTRIE_CANONICAL (NUMTRIE_INSERT x numempty)

CANONICAL_NUMTRIE_INSERT_NUMZERO

|- !x. NUMTRIE_CANONICAL (NUMTRIE_INSERT x numzero)

CANONICAL_NUMTRIE_INTER

|- !s t.

NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t

==> NUMTRIE_CANONICAL (NUMTRIE_INTER s t)

CANONICAL_NUMTRIE_MKNODE

|- !s t.

NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t

==> NUMTRIE_CANONICAL (NUMTRIE_MKNODE s t)

CANONICAL_NUMTRIE_SING

|- !n. NUMTRIE_CANONICAL (NUMTRIE_SING n)

CANONICAL_NUMTRIE_UNION

|- !s t.

NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t

==> NUMTRIE_CANONICAL (NUMTRIE_UNION s t)

DELETE_INSERT_0_NUMTRIE_SING

|- !n. ~(n = 0)

55

Appendix A. Theorems

==> NUMTRIE_DELETE 0 (NUMTRIE_INSERT 0 (NUMTRIE_SING n)) =

NUMTRIE_SING n

EQ_NUMTRIE_EQ

|- !s t.

FINITE s /\ FINITE t

==> (s = t <=> NUMTRIE_EQ (MK_NUMTRIE s) (MK_NUMTRIE t))

EQ_NUMTRIE_SUBSET

|- !s t.

FINITE s /\ FINITE t

==> (s SUBSET t <=> NUMTRIE_SUBSET (MK_NUMTRIE s) (MK_NUMTRIE t))

EXISTS_NUMTRIE

|- !t. FINITE t ==> (?!s. t = NUMTRIE s /\ NUMTRIE_CANONICAL s)

FINITE_NUMTRIE

|- !t. FINITE (NUMTRIE t)

FINITE_RECURSION_IDEMP

|- !f b.

(!x y s. ~(x = y) ==> f x (f y s) = f y (f x s)) /\

(!x s. f x (f x s) = f x s)

==> ITSET f {} b = b /\

(!x s. FINITE s ==> ITSET f (x INSERT s) b = f x (ITSET f s b))

IN_NUMTRIE

|- !t n. n IN NUMTRIE t <=> NUMTRIE_MEM n t

IN_NUMTRIEK

|- !t k acc x.

x IN NUMTRIEK acc k t <=>

x IN acc \/ (?y. x = k y /\ NUMTRIE_MEM y t)

MK_NUMTRIE

|- !s. MK_NUMTRIE s = ITSET NUMTRIE_INSERT s numempty

MK_NUMTRIE_CPLX

|- !C. MK_NUMTRIE_CPLX C = IMAGE MK_NUMTRIE C

MK_NUMTRIE_CPLX_CLAUSES

|- MK_NUMTRIE_CPLX {} = {} /\

(!C s.

MK_NUMTRIE_CPLX (s INSERT C) =

MK_NUMTRIE s INSERT MK_NUMTRIE_CPLX C)

MK_NUMTRIE_CPLX_NUMTRIE_CPLX_EQ

|- !C. (!s. s IN C ==> NUMTRIE_CANONICAL s)

==> MK_NUMTRIE_CPLX (NUMTRIE_CPLX C) = C

MK_NUMTRIE_DELETE

|- !y x.

FINITE x

==> MK_NUMTRIE (x DELETE y) = NUMTRIE_DELETE y (MK_NUMTRIE x)

MK_NUMTRIE_INJ

|- !x y. FINITE x /\ FINITE y ==> MK_NUMTRIE x = MK_NUMTRIE y ==> x = y

MK_NUMTRIE_NUMTRIE

|- !t. NUMTRIE_CANONICAL t ==> MK_NUMTRIE (NUMTRIE t) = t

MK_NUMTRIE_RULES

56

Appendix A. Theorems

|- MK_NUMTRIE {} = numempty /\

(!n s.

FINITE s

==> MK_NUMTRIE (n INSERT s) = NUMTRIE_INSERT n (MK_NUMTRIE s))

NOT_ODD_SPLIT_THM

|- !n. ~ODD n ==> (?m. n DIV 2 = m /\ n MOD 2 = 0 /\ n = 2 * m)

NUMTRIE

|- !t. NUMTRIE t = {n | NUMTRIE_MEM n t}

NUMTRIEK

|- (!acc k. NUMTRIEK acc k numempty = acc) /\

(!acc k. NUMTRIEK acc k numzero = k 0 INSERT acc) /\

(!acc k s t.

NUMTRIEK acc k (numnode s t) =

NUMTRIEK (NUMTRIEK acc (\n. k (2 * n + 1)) s) (\n. k (2 * n)) t)

NUMTRIE_CALC

|- !t. NUMTRIE t = NUMTRIEK {} NUMERAL t

NUMTRIE_CANONICAL

|- NUMTRIE_CANONICAL numempty /\

NUMTRIE_CANONICAL numzero /\

(!s t.

NUMTRIE_CANONICAL (numnode s t) <=>

NUMTRIE_CANONICAL s /\

NUMTRIE_CANONICAL t /\

(~(s = numempty) \/ ~(t = numempty) /\ ~(t = numzero)))

NUMTRIE_CANONICAL_CASES

|- !a. NUMTRIE_CANONICAL a <=>

a = numempty \/

a = numzero \/

(?s t.

a = numnode s t /\

NUMTRIE_CANONICAL s /\

NUMTRIE_CANONICAL t /\

~(s = numempty)) \/

(?s t.

a = numnode numempty t /\

NUMTRIE_CANONICAL s /\

NUMTRIE_CANONICAL t /\

~(t = numempty) /\

~(t = numzero))

NUMTRIE_CANONICAL_INDUCT

|- !NUMTRIE_CANONICAL’. NUMTRIE_CANONICAL’ numempty /\

NUMTRIE_CANONICAL’ numzero /\

(!s t.

NUMTRIE_CANONICAL’ s /\

NUMTRIE_CANONICAL’ t /\

~(s = numempty)

==> NUMTRIE_CANONICAL’ (numnode s t)) /\

(!s t.

NUMTRIE_CANONICAL’ s /\

NUMTRIE_CANONICAL’ t /\

~(t = numempty) /\

~(t = numzero)

==> NUMTRIE_CANONICAL’ (numnode numempty t))

==> (!a. NUMTRIE_CANONICAL a

==> NUMTRIE_CANONICAL’ a)

57

Appendix A. Theorems

NUMTRIE_CANONICAL_RULES

|- NUMTRIE_CANONICAL numempty /\

NUMTRIE_CANONICAL numzero /\

(!s t.

NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t /\ ~(s = numempty)

==> NUMTRIE_CANONICAL (numnode s t)) /\

(!s t.

NUMTRIE_CANONICAL s /\

NUMTRIE_CANONICAL t /\

~(t = numempty) /\

~(t = numzero)

==> NUMTRIE_CANONICAL (numnode numempty t))

NUMTRIE_CLAUSES

|- NUMTRIE numempty = {} /\

NUMTRIE numzero = {0} /\

(!s t.

NUMTRIE (numnode s t) =

IMAGE (\n. 2 * n + 1) (NUMTRIE s) UNION

IMAGE (\n. 2 * n) (NUMTRIE t))

NUMTRIE_CPLX

|- !C. NUMTRIE_CPLX C = IMAGE NUMTRIE C

NUMTRIE_CPLX_CLAUSES

|- NUMTRIE_CPLX {} = {} /\

(!C s. NUMTRIE_CPLX (s INSERT C) = NUMTRIE s INSERT NUMTRIE_CPLX C)

NUMTRIE_CPLX_MK_NUMTRIE_CPLX_EQ

|- !C. (!s. s IN C ==> FINITE s) ==> NUMTRIE_CPLX (MK_NUMTRIE_CPLX C) = C

NUMTRIE_DELETE

|- (!n. NUMTRIE_DELETE n numempty = numempty) /\

(!n. NUMTRIE_DELETE n numzero = (if n = 0 then numempty else numzero)) /\

(!s t n.

NUMTRIE_DELETE n (numnode s t) =

(if ODD n

then NUMTRIE_MKNODE (NUMTRIE_DELETE (n DIV 2) s) t

else NUMTRIE_MKNODE s (NUMTRIE_DELETE (n DIV 2) t)))

NUMTRIE_DELETE_INSERT

|- !s x.

NUMTRIE_CANONICAL s

==> NUMTRIE_DELETE x (NUMTRIE_INSERT x s) =

(if NUMTRIE_MEM x s then NUMTRIE_DELETE x s else s)

NUMTRIE_DELETE_INSERT_COMM

|- !s x y.

NUMTRIE_CANONICAL s /\ ~(x = y)

==> NUMTRIE_DELETE y (NUMTRIE_INSERT x s) =

NUMTRIE_INSERT x (NUMTRIE_DELETE y s)

NUMTRIE_DELETE_INSERT_COMM_NUMZERO

|- !x y.

~(x = y)

==> NUMTRIE_DELETE y (NUMTRIE_INSERT x numzero) =

NUMTRIE_INSERT x (NUMTRIE_DELETE y numzero)

NUMTRIE_DELETE_INSERT_NUMZERO

|- !n m.

~(m = n) /\ ~(m = 0)

58

Appendix A. Theorems

==> NUMTRIE_DELETE m (NUMTRIE_INSERT n numzero) =

NUMTRIE_INSERT n numzero

NUMTRIE_DELETE_INSERT_NUMZERO2

|- !m. NUMTRIE_DELETE m (NUMTRIE_INSERT m numzero) =

(if m = 0 then numempty else numzero)

NUMTRIE_DELETE_NOT_MEM

|- !s x.

NUMTRIE_CANONICAL s /\ ~NUMTRIE_MEM x s ==> NUMTRIE_DELETE x s = s

NUMTRIE_DELETE_SING

|- (!m. NUMTRIE_DELETE m (NUMTRIE_SING m) = numempty) /\

(!x y. ~(x = y) ==> NUMTRIE_DELETE y (NUMTRIE_SING x) = NUMTRIE_SING x)

NUMTRIE_DELETE_THM

|- !s n. NUMTRIE (NUMTRIE_DELETE n s) = NUMTRIE s DELETE n

NUMTRIE_DISJOINT

|- (!s. NUMTRIE_DISJOINT s numempty) /\

(!s. NUMTRIE_DISJOINT numempty s) /\

~NUMTRIE_DISJOINT numzero numzero /\

(!s t.

NUMTRIE_DISJOINT numzero (numnode s t) <=>

NUMTRIE_DISJOINT t numzero) /\

(!s t.

NUMTRIE_DISJOINT (numnode s t) numzero <=>

NUMTRIE_DISJOINT t numzero) /\

(!s1 s2 t1 t2.

NUMTRIE_DISJOINT (numnode s1 t1) (numnode s2 t2) <=>

NUMTRIE_DISJOINT s1 s2 /\ NUMTRIE_DISJOINT t1 t2)

NUMTRIE_DISJOINT_CASES

|- !a0 a1.

NUMTRIE_DISJOINT a0 a1 <=>

a1 = numempty \/

a0 = numempty \/

(?s t.

a0 = numzero /\ a1 = numnode s t /\ NUMTRIE_DISJOINT t numzero) \/

(?s t.

a0 = numnode s t /\ a1 = numzero /\ NUMTRIE_DISJOINT t numzero) \/

(?s1 s2 t1 t2.

a0 = numnode s1 t1 /\

a1 = numnode s2 t2 /\

NUMTRIE_DISJOINT s1 s2 /\

NUMTRIE_DISJOINT t1 t2)

NUMTRIE_DISJOINT_EMPTY_INTER

|- !s t. NUMTRIE_DISJOINT s t <=> NUMTRIE_EMPTY (NUMTRIE_INTER s t)

NUMTRIE_DISJOINT_INDUCT

|- !NUMTRIE_DISJOINT’. (!s. NUMTRIE_DISJOINT’ s numempty) /\

(!s. NUMTRIE_DISJOINT’ numempty s) /\

(!s t.

NUMTRIE_DISJOINT’ t numzero

==> NUMTRIE_DISJOINT’ numzero (numnode s t)) /\

(!s t.

NUMTRIE_DISJOINT’ t numzero

==> NUMTRIE_DISJOINT’ (numnode s t) numzero) /\

(!s1 s2 t1 t2.

NUMTRIE_DISJOINT’ s1 s2 /\

NUMTRIE_DISJOINT’ t1 t2

59

Appendix A. Theorems

==> NUMTRIE_DISJOINT’ (numnode s1 t1)

(numnode s2 t2))

==> (!a0 a1.

NUMTRIE_DISJOINT a0 a1

==> NUMTRIE_DISJOINT’ a0 a1)

NUMTRIE_DISJOINT_RULES

|- (!s. NUMTRIE_DISJOINT s numempty) /\

(!s. NUMTRIE_DISJOINT numempty s) /\

(!s t.

NUMTRIE_DISJOINT t numzero

==> NUMTRIE_DISJOINT numzero (numnode s t)) /\

(!s t.

NUMTRIE_DISJOINT t numzero

==> NUMTRIE_DISJOINT (numnode s t) numzero) /\

(!s1 s2 t1 t2.

NUMTRIE_DISJOINT s1 s2 /\ NUMTRIE_DISJOINT t1 t2

==> NUMTRIE_DISJOINT (numnode s1 t1) (numnode s2 t2))

NUMTRIE_DISJOINT_THM

|- !s t. NUMTRIE_DISJOINT s t <=> DISJOINT (NUMTRIE s) (NUMTRIE t)

NUMTRIE_EMPTY

|- NUMTRIE_EMPTY numempty /\

~NUMTRIE_EMPTY numzero /\

(!s t.

NUMTRIE_EMPTY (numnode s t) <=> NUMTRIE_EMPTY s /\ NUMTRIE_EMPTY t)

NUMTRIE_EMPTY_CASES

|- !a. NUMTRIE_EMPTY a <=>

a = numempty \/

(?s t. a = numnode s t /\ NUMTRIE_EMPTY s /\ NUMTRIE_EMPTY t)

NUMTRIE_EMPTY_EQ_EMPTY

|- !s. NUMTRIE_EMPTY s <=> NUMTRIE_EQ s numempty

NUMTRIE_EMPTY_INDUCT

|- !NUMTRIE_EMPTY’. NUMTRIE_EMPTY’ numempty /\

(!s t.

NUMTRIE_EMPTY’ s /\ NUMTRIE_EMPTY’ t

==> NUMTRIE_EMPTY’ (numnode s t))

==> (!a. NUMTRIE_EMPTY a ==> NUMTRIE_EMPTY’ a)

NUMTRIE_EMPTY_MKNODE

|- !s t.

NUMTRIE_EMPTY (NUMTRIE_MKNODE s t) <=>

NUMTRIE_EMPTY s /\ NUMTRIE_EMPTY t

NUMTRIE_EMPTY_RULES

|- NUMTRIE_EMPTY numempty /\

(!s t.

NUMTRIE_EMPTY s /\ NUMTRIE_EMPTY t ==> NUMTRIE_EMPTY (numnode s t))

NUMTRIE_EMPTY_THM

|- !s. NUMTRIE_EMPTY s <=> NUMTRIE s = {}

NUMTRIE_EQ

|- !s t. NUMTRIE_EQ s t <=> (!n. NUMTRIE_MEM n s <=> NUMTRIE_MEM n t)

NUMTRIE_EQ_CANONICAL

|- !s t.

NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t

60

Appendix A. Theorems

==> (s = t <=> NUMTRIE_EQ s t)

NUMTRIE_EQ_CANONICAL_IMP_EQ

|- !s t.

NUMTRIE_CANONICAL s /\ NUMTRIE_CANONICAL t /\ NUMTRIE_EQ s t

==> s = t

NUMTRIE_EQ_REFL

|- !s. NUMTRIE_EQ s s

NUMTRIE_EQ_RULES

|- (!s. NUMTRIE_EQ s s) /\

~NUMTRIE_EQ numzero numempty /\

~NUMTRIE_EQ numempty numzero /\

(!s t.

NUMTRIE_EQ (numnode s t) numempty <=>

NUMTRIE_EQ s numempty /\ NUMTRIE_EQ t numempty) /\

(!s t.

NUMTRIE_EQ numempty (numnode s t) <=>

NUMTRIE_EQ s numempty /\ NUMTRIE_EQ t numempty) /\

(!s t.

NUMTRIE_EQ (numnode s t) numzero <=>

NUMTRIE_EQ s numempty /\ NUMTRIE_EQ t numzero) /\

(!s t.

NUMTRIE_EQ numzero (numnode s t) <=>

NUMTRIE_EQ s numempty /\ NUMTRIE_EQ t numzero) /\

(!s1 s2 t1 t2.

NUMTRIE_EQ (numnode s1 t1) (numnode s2 t2) <=>

NUMTRIE_EQ s1 s2 /\ NUMTRIE_EQ t1 t2)

NUMTRIE_EQ_SUBSET

|- !s t. NUMTRIE_EQ s t <=> NUMTRIE_SUBSET s t /\ NUMTRIE_SUBSET t s

NUMTRIE_EQ_SYM

|- !s t. NUMTRIE_EQ s t ==> NUMTRIE_EQ t s

NUMTRIE_EQ_SYM_EQ

|- !s t. NUMTRIE_EQ s t <=> NUMTRIE_EQ t s

NUMTRIE_EQ_THM

|- !s t. NUMTRIE_EQ s t <=> NUMTRIE s = NUMTRIE t

NUMTRIE_EQ_TRANS

|- !r s t. NUMTRIE_EQ r s /\ NUMTRIE_EQ s t ==> NUMTRIE_EQ r t

NUMTRIE_INSERT

|- (!n. NUMTRIE_INSERT n numempty = NUMTRIE_SING n) /\

(!n. NUMTRIE_INSERT n numzero =

(if n = 0

then numzero

else if ODD n

then numnode (NUMTRIE_SING (n DIV 2)) numzero

else numnode numempty (NUMTRIE_INSERT (n DIV 2) numzero))) /\

(!s t n.

NUMTRIE_INSERT n (numnode s t) =

(if ODD n

then numnode (NUMTRIE_INSERT (n DIV 2) s) t

else numnode s (NUMTRIE_INSERT (n DIV 2) t)))

NUMTRIE_INSERT_ASSORPTION

|- !t n. NUMTRIE_MEM n t ==> NUMTRIE_INSERT n t = t

61

Appendix A. Theorems

NUMTRIE_INSERT_COMM

|- !s x y.

NUMTRIE_INSERT x (NUMTRIE_INSERT y s) =

NUMTRIE_INSERT y (NUMTRIE_INSERT x s)

NUMTRIE_INSERT_EQ_NUMZERO

|- !s x.

NUMTRIE_INSERT x s = numzero <=>

x = 0 /\ (s = numzero \/ s = numempty)

NUMTRIE_INSERT_INSERT

|- !t n. NUMTRIE_INSERT n (NUMTRIE_INSERT n t) = NUMTRIE_INSERT n t

NUMTRIE_INSERT_NONEMPTY

|- !s x. ~(NUMTRIE_INSERT x s = numempty)

NUMTRIE_INSERT_NUMZERO_SING

|- !n. NUMTRIE_INSERT n numzero = NUMTRIE_INSERT 0 (NUMTRIE_SING n)

NUMTRIE_INSERT_SING_COMM

|- !x y.

NUMTRIE_INSERT x (NUMTRIE_SING y) =

NUMTRIE_INSERT y (NUMTRIE_SING x)

NUMTRIE_INSERT_THM

|- !t n. NUMTRIE (NUMTRIE_INSERT n t) = n INSERT NUMTRIE t

NUMTRIE_INTER

|- (!s. NUMTRIE_INTER numempty s = numempty) /\

(!s. NUMTRIE_INTER s numempty = numempty) /\

NUMTRIE_INTER numzero numzero = numzero /\

(!s t. NUMTRIE_INTER numzero (numnode s t) = NUMTRIE_INTER numzero t) /\

(!s t. NUMTRIE_INTER (numnode s t) numzero = NUMTRIE_INTER numzero t) /\

(!s1 s2 t1 t2.

NUMTRIE_INTER (numnode s1 t1) (numnode s2 t2) =

NUMTRIE_MKNODE (NUMTRIE_INTER s1 s2) (NUMTRIE_INTER t1 t2))

NUMTRIE_INTER_COMM

|- !s t. NUMTRIE_INTER s t = NUMTRIE_INTER t s

NUMTRIE_INTER_NUMZERO

|- (!s. NUMTRIE_INTER numzero s =

(if NUMTRIE_MEM 0 s then numzero else numempty)) /\

(!s. NUMTRIE_INTER s numzero =

(if NUMTRIE_MEM 0 s then numzero else numempty))

NUMTRIE_INTER_THM

|- !s t. NUMTRIE (NUMTRIE_INTER s t) = NUMTRIE s INTER NUMTRIE t

NUMTRIE_MEM_CASES

|- !a0 a1.

NUMTRIE_MEM a0 a1 <=>

a0 = 0 /\ a1 = numzero \/

(?s t n. a0 = 2 * n + 1 /\ a1 = numnode s t /\ NUMTRIE_MEM n s) \/

(?s t n. a0 = 2 * n /\ a1 = numnode s t /\ NUMTRIE_MEM n t)

NUMTRIE_MEM_CLAUSES

|- (!n. NUMTRIE_MEM n numempty <=> F) /\

(!n. NUMTRIE_MEM n numzero <=> n = 0) /\

(!s t n.

NUMTRIE_MEM n (numnode s t) <=>

NUMTRIE_MEM (n DIV 2) (if ODD n then s else t))

62

Appendix A. Theorems

NUMTRIE_MEM_DELETE

|- !s m n.

NUMTRIE_MEM m (NUMTRIE_DELETE n s) <=> ~(m = n) /\ NUMTRIE_MEM m s

NUMTRIE_MEM_INDUCT

|- !NUMTRIE_MEM’. NUMTRIE_MEM’ 0 numzero /\

(!s t n.

NUMTRIE_MEM’ n s

==> NUMTRIE_MEM’ (2 * n + 1) (numnode s t)) /\

(!s t n.

NUMTRIE_MEM’ n t

==> NUMTRIE_MEM’ (2 * n) (numnode s t))

==> (!a0 a1. NUMTRIE_MEM a0 a1 ==> NUMTRIE_MEM’ a0 a1)

NUMTRIE_MEM_INSERT

|- !s m n. NUMTRIE_MEM m (NUMTRIE_INSERT n s) <=> m = n \/ NUMTRIE_MEM m s

NUMTRIE_MEM_INTER

|- !n s t.

NUMTRIE_MEM n (NUMTRIE_INTER s t) <=>

NUMTRIE_MEM n s /\ NUMTRIE_MEM n t

NUMTRIE_MEM_MK_NUMTRIE

|- !s x. FINITE s ==> (NUMTRIE_MEM x (MK_NUMTRIE s) <=> x IN s)

NUMTRIE_MEM_RULES

|- NUMTRIE_MEM 0 numzero /\

(!s t n. NUMTRIE_MEM n s ==> NUMTRIE_MEM (2 * n + 1) (numnode s t)) /\

(!s t n. NUMTRIE_MEM n t ==> NUMTRIE_MEM (2 * n) (numnode s t))

NUMTRIE_MEM_SING

|- !n m. NUMTRIE_MEM m (NUMTRIE_SING n) <=> m = n

NUMTRIE_MEM_THM

|- !s n. NUMTRIE_MEM n s <=> n IN NUMTRIE s

NUMTRIE_MEM_UNION

|- !s t n.

NUMTRIE_MEM n (NUMTRIE_UNION s t) <=>

NUMTRIE_MEM n s \/ NUMTRIE_MEM n t

NUMTRIE_MKNODE

|- NUMTRIE_MKNODE numempty numempty = numempty /\

NUMTRIE_MKNODE numempty numzero = numzero /\

NUMTRIE_MKNODE numzero numempty = numnode numzero numempty /\

NUMTRIE_MKNODE numzero numzero = numnode numzero numzero /\

(!s t r. NUMTRIE_MKNODE (numnode s t) r = numnode (numnode s t) r) /\

(!s t r. NUMTRIE_MKNODE r (numnode s t) = numnode r (numnode s t))

NUMTRIE_MKNODE_NODE

|- !a0 a1.

~(a0 = numempty) \/ ~(a1 = numempty) /\ ~(a1 = numzero)

==> NUMTRIE_MKNODE a0 a1 = numnode a0 a1

NUMTRIE_MKNODE_SING_LEFT

|- !x. NUMTRIE_MKNODE (NUMTRIE_SING x) numempty =

numnode (NUMTRIE_SING x) numempty

NUMTRIE_MKNODE_SING_NUMZERO

|- !n. NUMTRIE_MKNODE (NUMTRIE_SING n) numzero =

numnode (NUMTRIE_SING n) numzero /\

63

Appendix A. Theorems

NUMTRIE_MKNODE (NUMTRIE_SING n) numzero =

numnode (NUMTRIE_SING n) numzero

NUMTRIE_MKNODE_SING_RIGHT

|- !x. NUMTRIE_MKNODE numempty (NUMTRIE_SING x) =

(if x = 0 then numzero else numnode numempty (NUMTRIE_SING x))

NUMTRIE_MK_NUMTRIE

|- !s. FINITE s ==> NUMTRIE (MK_NUMTRIE s) = s

NUMTRIE_SING

|- !n. NUMTRIE_SING n =

(if n = 0

then numzero

else if ODD n

then numnode (NUMTRIE_SING (n DIV 2)) numempty

else numnode numempty (NUMTRIE_SING (n DIV 2)))

NUMTRIE_SING_EQ_NUMZERO

|- !n. NUMTRIE_SING n = numzero <=> n = 0

NUMTRIE_SING_INSERT

|- !n. NUMTRIE_SING n = NUMTRIE_INSERT n numempty

NUMTRIE_SING_NONEMPTY

|- !n. ~(NUMTRIE_SING n = numempty)

NUMTRIE_SING_THM

|- !n. NUMTRIE (NUMTRIE_SING n) = {n}

NUMTRIE_SUBSET

|- !s t. NUMTRIE_SUBSET s t <=> (!n. NUMTRIE_MEM n s ==> NUMTRIE_MEM n t)

NUMTRIE_SUBSET_REFL

|- !s. NUMTRIE_SUBSET s s

NUMTRIE_SUBSET_RULES

|- (!s. NUMTRIE_SUBSET numempty s) /\

(!s. NUMTRIE_SUBSET s s) /\

~NUMTRIE_SUBSET numzero numempty /\

(!s t.

NUMTRIE_SUBSET (numnode s t) numempty <=>

NUMTRIE_SUBSET s numempty /\ NUMTRIE_SUBSET t numempty) /\

(!s t.

NUMTRIE_SUBSET (numnode s t) numzero <=>

NUMTRIE_SUBSET s numempty /\ NUMTRIE_SUBSET t numzero) /\

(!s t.

NUMTRIE_SUBSET numzero (numnode s t) <=> NUMTRIE_SUBSET numzero t) /\

(!s1 s2 t1 t2.

NUMTRIE_SUBSET (numnode s1 t1) (numnode s2 t2) <=>

NUMTRIE_SUBSET s1 s2 /\ NUMTRIE_SUBSET t1 t2)

NUMTRIE_SUBSET_THM

|- !s t. NUMTRIE_SUBSET s t <=> NUMTRIE s SUBSET NUMTRIE t

NUMTRIE_SUBSET_TRANS

|- !r s t. NUMTRIE_SUBSET r s /\ NUMTRIE_SUBSET s t ==> NUMTRIE_SUBSET r t

NUMTRIE_UNION

|- (!s. NUMTRIE_UNION s numempty = s) /\

(!s. NUMTRIE_UNION numempty s = s) /\

NUMTRIE_UNION numzero numzero = numzero /\

64

Appendix A. Theorems

(!s t.

NUMTRIE_UNION (numnode s t) numzero =

numnode s (NUMTRIE_UNION t numzero)) /\

(!s t.

NUMTRIE_UNION numzero (numnode s t) =

numnode s (NUMTRIE_UNION t numzero)) /\

(!s t r q.

NUMTRIE_UNION (numnode s t) (numnode r q) =

numnode (NUMTRIE_UNION s r) (NUMTRIE_UNION t q))

NUMTRIE_UNION_COMM

|- !s t. NUMTRIE_UNION s t = NUMTRIE_UNION t s

NUMTRIE_UNION_NUMEMPTY

|- !s t. NUMTRIE_UNION s t = numempty <=> s = numempty /\ t = numempty

NUMTRIE_UNION_NUMZERO

|- !s t.

NUMTRIE_UNION s t = numzero <=>

s = numempty /\ t = numzero \/

s = numzero /\ t = numempty \/

s = numzero /\ t = numzero

NUMTRIE_UNION_THM

|- !s t. NUMTRIE (NUMTRIE_UNION s t) = NUMTRIE s UNION NUMTRIE t

ODD_SPLIT_THM

|- !n. ODD n ==> (?m. n DIV 2 = m /\ n MOD 2 = 1 /\ n = 2 * m + 1)

num_BINARY_INDUCT

|- !P. P 0 /\

(!n. P n ==> P (2 * n + 1)) /\

(!n. ~(n = 0) /\ P n ==> P (2 * n))

==> (!n. P n)

num_BINARY_SPLIT

|- !n. n = 0 \/ (?m. n = 2 * m + 1) \/ (?m. ~(m = 0) /\ n = 2 * m)

num_INDUCTION_STRONG

|- !P. (!n. (!m. m < n ==> P m) ==> P n) ==> (!n. P n)

numtrie_CASES

|- !x. x = numempty \/ x = numzero \/ (?a0 a1. x = numnode a0 a1)

numtrie_DISTINCT

|- ~(numempty = numzero) /\

(!a0’ a1’. ~(numempty = numnode a0’ a1’)) /\

(!a0’ a1’. ~(numzero = numnode a0’ a1’))

numtrie_INDUCT

|- !P. P numempty /\

P numzero /\

(!a0 a1. P a0 /\ P a1 ==> P (numnode a0 a1))

==> (!x. P x)

numtrie_INJ

|- !a0 a1 a0’ a1’.

numnode a0 a1 = numnode a0’ a1’ <=> a0 = a0’ /\ a1 = a1’

numtrie_RECUR

|- !f0 f1 f2.

?fn. fn numempty = f0 /\

65

Appendix A. Theorems

fn numzero = f1 /\

(!a0 a1. fn (numnode a0 a1) = f2 a0 a1 (fn a0) (fn a1))

A.3 Sums of integers

ISUM’_CLAUSES

|- (!f acc. isum’ acc {} f = acc) /\

(!f s x acc.

isum’ acc (x INSERT s) f =

(if x IN s then isum’ acc s f else isum’ (f x + acc) s f))

ISUM_0

|- !s. isum s (\n. &0) = &0

ISUM_ADD

|- !f g s. FINITE s ==> isum s (\x. f x + g x) = isum s f + isum s g

ISUM_CLAUSES

|- (!f. isum {} f = &0) /\

(!x f s.

FINITE s

==> isum (x INSERT s) f =

(if x IN s then isum s f else f x + isum s f))

ISUM_DIFF

|- !f s t.

FINITE s /\ t SUBSET s ==> isum (s DIFF t) f = isum s f - isum t f

ISUM_EQ

|- !f g s. (!x. x IN s ==> f x = g x) ==> isum s f = isum s g

ISUM_EQ_0

|- !f s. (!x. x IN s ==> f x = &0) ==> isum s f = &0

ISUM_EQ_SUPERSET

|- !f s t.

FINITE t /\

t SUBSET s /\

(!x. x IN t ==> f x = g x) /\

(!x. x IN s /\ ~(x IN t) ==> f x = &0)

==> isum s f = isum t g

ISUM_IMAGE

|- !f g s.

(!x y. x IN s /\ y IN s /\ f x = f y ==> x = y)

==> isum (IMAGE f s) g = isum s (g o f)

ISUM_IMAGE_GEN

|- !f g s.

FINITE s

==> isum s g =

isum (IMAGE f s) (\y. isum {x | x IN s /\ f x = y} g)

ISUM_INFINITE_SUPPORT

|- !f s. INFINITE (support (+) f s) ==> isum s f = &0

ISUM_ISUM’

|- isum = isum’ (&0)

66

Appendix A. Theorems

ISUM_ISUM_PRODUCT

|- !s t x.

FINITE s /\ (!i. i IN s ==> FINITE (t i))

==> isum s (\i. isum (t i) (x i)) =

isum {i,j | i IN s /\ j IN t i} (\(i,j). x i j)

ISUM_ISUM_RESTRICT

|- !R f s t.

FINITE s /\ FINITE t

==> isum s (\x. isum {y | y IN t /\ R x y} (\y. f x y)) =

isum t (\y. isum {x | x IN s /\ R x y} (\x. f x y))

ISUM_LMUL

|- !f c s. isum s (\x. c * f x) = c * isum s f

ISUM_RESTRICT_SET

|- !s f r.

FINITE s

==> isum {x | x IN s /\ P x} f =

isum s (\x. if P x then f x else &0)

ISUM_RMUL

|- !f c s. isum s (\x. f x * c) = isum s f * c

ISUM_SING

|- !f x. isum {x} f = f x

ISUM_SUB

|- !f g s. FINITE s ==> isum s (\x. f x - g x) = isum s f - isum s g

ISUM_SUPERSET

|- !f u v.

FINITE u /\ u SUBSET v /\ (!x. x IN v /\ ~(x IN u) ==> f x = &0)

==> isum v f = isum u f

ISUM_SUPERSET_BIS

|- !f u v.

u SUBSET v /\ (!x. x IN v /\ ~(x IN u) ==> f x = &0)

==> isum v f = isum u f

ISUM_SUPPORT

|- !f s. isum (support (+) f s) f = isum s f

ISUM_SWAP

|- !f s t.

FINITE s /\ FINITE t

==> isum s (\i. isum t (f i)) = isum t (\j. isum s (\i. f i j))

ISUM_SWAP2

|- !f s t.

FINITE s /\ FINITE t

==> isum s (\i. isum t (\j. f i j)) =

isum t (\j. isum s (\i. f i j))

ISUM_UNION

|- !f s t.

FINITE s /\ FINITE t /\ DISJOINT s t

==> isum (s UNION t) f = isum s f + isum t f

ITERATE_CASES2

|- !op f s.

iterate op s f =

67

Appendix A. Theorems

(if FINITE (support op f s)

then iterate op (support op f s) f

else neutral op)

MONOIDAL_INT_ADD

|- monoidal (+)

NEUTRAL_INT_ADD

|- neutral (+) = &0

SUBSET_IMP_SUPPORT_SUBSET

|- !op f s t. s SUBSET t ==> support op f s SUBSET support op f t

isum

|- isum = iterate (+)

isum’

|- !f s acc.

isum’ acc s f =

(if FINITE (support (+) f s) then acc + isum s f else &0)

A.4 Free Z-modules

FINITE_ZSUPPORT_ZVEC

|- !s. FINITE (zsupport (zvec s))

FORALL_ZMOD_THM

|- (!x. P x) <=> (!f. P (zmod f))

INTER_ZSUBMOD

|- !m n. zsubmod m /\ zsubmod n ==> zsubmod (m INTER n)

IN_ZCOMB

|- !s x. x IN zcomb s <=> (?u. zsupport u SUBSET s /\ x = zjoin u)

IN_ZGEN_ZVEC

|- !i x. x IN zgen {zvec i} <=> (?c. x = c ** zvec i)

IN_ZKERNEL

|- !f x. x IN zkernel f <=> f x = zzero

IN_ZSUPPORT

|- !i x. i IN zsupport x <=> ~(zmod_fun x i = &0)

LINEAR

|- !f. LINEAR f <=>

(!x y. f (x + y) = f x + f y) /\ (!c x. f (c ** x) = c ** f x)

LINEAR_ADD

|- !f. LINEAR f ==> (!x y. f (x + y) = f x + f y)

LINEAR_CMUL

|- !f. LINEAR f ==> (!c x. f (c ** x) = c ** f x)

LINEAR_COMPOSITION

|- !f g. LINEAR f /\ LINEAR g ==> LINEAR (f o g)

LINEAR_NEG

|- !f x. LINEAR f ==> f (--x) = --f x

68

Appendix A. Theorems

LINEAR_SUB

|- !f. LINEAR f ==> (!x y. f (x - y) = f x - f y)

LINEAR_ZSUM

|- !f g s. FINITE s /\ LINEAR f ==> f (zsum s g) = zsum s (f o g)

LINEAR_ZVEC_0

|- !f x.

LINEAR f /\ (!i. f (zvec i) = zzero) /\ FINITE (zsupport x)

==> f x = zzero

LINEAR_ZZERO

|- !f. LINEAR f ==> f zzero = zzero

MONOIDAL_ZMOD_ADD

|- monoidal (+)

NEUTRAL_ZMOD_ADD

|- neutral (+) = zzero

SUPPORT_ZSUPPORT

|- !f. support (+) f (:?90338) = zsupport (zmod f)

ZCOMB_SUPERSET

|- !s. s SUBSET zcomb s

ZCOMB_ZSUBMOD

|- !s. FINITE s ==> zsubmod (zcomb s)

ZGEN_EMPTY

|- zgen {} = {zzero}

ZGEN_ZCOMB

|- !s. FINITE s ==> zgen s = zcomb s

ZGEN_ZVEC

|- !s. zgen {zvec s} = {x | !t. ~(t = s) ==> zmod_fun x t = &0}

ZGEN_ZZERO

|- zgen {zzero} = {zzero}

ZHOM_ADD

|- !s f x y. FINITE s ==> zhom f s (x + y) = zhom f s x + zhom f s y

ZHOM_CMUL

|- !s f c x. FINITE s ==> zhom f s (c ** x) = c ** zhom f s x

ZHOM_IMAGE

|- !f g s.

(!x y. x IN s /\ y IN s /\ f x = f y ==> x = y)

==> zhom g (IMAGE f s) = zhom (g o f) s o ZMOD_MAP f

ZHOM_LINEAR

|- !s f. FINITE s ==> LINEAR (zhom f s)

ZHOM_SWAP_ZVEC

|- !f g s t i.

i IN s

==> zhom g t (zhom f s (zvec i)) = zhom (zhom g t o f) s (zvec i)

ZHOM_ZSUM

69

Appendix A. Theorems

|- !s g f t.

FINITE s /\ FINITE t

==> zhom f t (zsum s g) = zsum s (zhom f t o g)

ZHOM_ZVEC

|- !s f i. zhom f s (zvec i) = (if i IN s then f i else zzero)

ZHOM_ZZERO

|- !f s. (!i. i IN s ==> f i = zzero) ==> (!x. zhom f s x = zzero)

ZJOIN_CMUL

|- !u c. zjoin (c ** u) = c ** zjoin u

ZJOIN_DEF2

|- !u. zjoin u = zsum (zsupport u) (\v. zmod_fun u v ** v)

ZJOIN_SUB

|- !u v s.

zsupport u SUBSET s /\ zsupport v SUBSET s /\ FINITE s

==> zjoin (u - v) = zjoin u - zjoin v

ZJOIN_SUPERSET

|- !u s.

FINITE s /\ zsupport u SUBSET s

==> zjoin u = zsum s (\v. zmod_fun u v ** v)

ZJOIN_ZVEC

|- !v. zjoin (zvec v) = v

ZJOIN_ZZERO

|- zjoin zzero = zzero

ZMOD_ADD2_SUB2

|- !a b c d. (a + b) - (c + d) = a - c + b - d

ZMOD_ADD_AC

|- m + n = n + m /\ (m + n) + p = m + n + p /\ m + n + p = n + m + p

ZMOD_ADD_ASSOC

|- !x y z. x + y + z = (x + y) + z

ZMOD_ADD_LDISTRIB

|- !c y z. c ** (y + z) = c ** y + c ** z

ZMOD_ADD_LID

|- !x. zzero + x = x

ZMOD_ADD_LINV

|- !x. --x + x = zzero

ZMOD_ADD_RDISTRIB

|- !c d z. (c + d) ** z = c ** z + d ** z

ZMOD_ADD_RID

|- !x. x + zzero = x

ZMOD_ADD_RINV

|- !x. x + --x = zzero

ZMOD_ADD_SUB

|- !x y. (x + y) - x = y

70

Appendix A. Theorems

ZMOD_ADD_SUB2

|- !x y. x - (x + y) = --y

ZMOD_ADD_SYM

|- !x y. x + y = y + x

ZMOD_CMUL_ASSOC

|- !c d z. c ** d ** z = (c * d) ** z

ZMOD_CMUL_LID

|- !x. &1 ** x = x

ZMOD_CMUL_LNEG

|- !c y. --c ** y = --(c ** y)

ZMOD_CMUL_LZERO

|- !x. &0 ** x = zzero

ZMOD_CMUL_RNEG

|- !c y. c ** --y = --(c ** y)

ZMOD_CMUL_RZERO

|- !c. c ** zzero = zzero

ZMOD_EQ_ADD_LCANCEL

|- !x y z. x + y = x + z <=> y = z

ZMOD_EQ_ADD_LCANCEL_0

|- !x y. x + y = x <=> y = zzero

ZMOD_EQ_ADD_RCANCEL

|- !x y z. x + z = y + z <=> x = y

ZMOD_EQ_ADD_RCANCEL_0

|- !x y. x + y = y <=> x = zzero

ZMOD_EQ_CMUL_LCANCEL

|- !c y z. c ** y = c ** z <=> c = &0 \/ y = z

ZMOD_EQ_CMUL_RCANCEL

|- !c d z. c ** z = d ** z <=> c = d \/ z = zzero

ZMOD_EQ_NEG2

|- !x y. --x = --y <=> x = y

ZMOD_EQ_SUB_LADD

|- !x y z. x = y - z <=> x + z = y

ZMOD_EQ_SUB_RADD

|- !x y z. x - y = z <=> x = z + y

ZMOD_EXTENSION

|- !x y. x = y <=> (!i. zmod_fun x i = zmod_fun y i)

ZMOD_LNEG_UNIQ

|- !x y. x + y = zzero <=> x = --y

ZMOD_MAP

|- !f y. ZMOD_MAP f y = zmod (\i. zmod_fun y (f i))

ZMOD_MAP_COMPOSE

|- !f g. ZMOD_MAP (g o f) = ZMOD_MAP f o ZMOD_MAP g

71

Appendix A. Theorems

ZMOD_MAP_ID

|- ZMOD_MAP (\x. x) = (\x. x)

ZMOD_NEG_0

|- --zzero = zzero

ZMOD_NEG_ADD

|- !x y. --(x + y) = --x + --y

ZMOD_NEG_CMUL2

|- !c y. --c ** --y = c ** y

ZMOD_NEG_EQ

|- !x y. --x = y <=> x = --y

ZMOD_NEG_EQ_0

|- !x. --x = zzero <=> x = zzero

ZMOD_NEG_LCMUL

|- !c y. --(c ** y) = --c ** y

ZMOD_NEG_MINUS1

|- !x. --x = -- &1 ** x

ZMOD_NEG_NEG

|- !x. -- --x = x

ZMOD_NEG_RCMUL

|- !c y. --(c ** y) = c ** --y

ZMOD_NEG_SUB

|- !x y. --(x - y) = y - x

ZMOD_RNEG_UNIQ

|- !x y. x + y = zzero <=> y = --x

ZMOD_SUB

|- !x y. x - y = x + --y

ZMOD_SUB_0

|- !x y. x - y = zzero <=> x = y

ZMOD_SUB_ADD

|- !x y. x - y + y = x

ZMOD_SUB_ADD2

|- !x y. y + x - y = x

ZMOD_SUB_LDISTRIB

|- !c d z. (c - d) ** z = c ** z - d ** z

ZMOD_SUB_LNEG

|- !x y. --x - y = --(x + y)

ZMOD_SUB_LZERO

|- !x. zzero - x = --x

ZMOD_SUB_NEG2

|- !x y. --x - --y = y - x

ZMOD_SUB_REFL

72

Appendix A. Theorems

|- !x. x - x = zzero

ZMOD_SUB_RNEG

|- !x y. x - --y = x + y

ZMOD_SUB_RZERO

|- !x. x - zzero = x

ZMOD_SUB_SUB

|- !x y. x - y - x = --y

ZMOD_SUB_SUB2

|- !x y. x - (x - y) = y

ZMOD_SUB_TRIANGLE

|- !a b c. a - b + b - c = a - c

ZMOD_TORSIONFREE

|- !c y. c ** y = zzero <=> c = &0 \/ y = zzero

ZSUBMOD_CLOSED_ADD

|- !m x y. zsubmod m /\ x IN m /\ y IN m ==> x + y IN m

ZSUBMOD_CLOSED_CMUL

|- !m x c. zsubmod m /\ x IN m ==> c ** x IN m

ZSUBMOD_CLOSED_SUB

|- !m x y. zsubmod m /\ x IN m /\ y IN m ==> x - y IN m

ZSUBMOD_IMAGE

|- !f s. LINEAR f /\ zsubmod s ==> zsubmod (IMAGE f s)

ZSUBMOD_NOT_EMPTY

|- !m. zsubmod m ==> ~(m = {})

ZSUBMOD_UNIV

|- zsubmod (:(A)zmod)

ZSUBMOD_ZGEN

|- !s. zsubmod (zgen s)

ZSUBMOD_ZKERNEL

|- !f. LINEAR f ==> zsubmod (zkernel f)

ZSUBMOD_ZZERO

|- zsubmod {zzero}

ZSUM’_CLAUSES

|- (!f acc. zsum’ acc {} f = acc) /\

(!f s x acc.

zsum’ acc (x INSERT s) f =

(if x IN s then zsum’ acc s f else zsum’ (f x + acc) s f))

ZSUM_0

|- !s. zsum s (\n. zzero) = zzero

ZSUM_ADD

|- !f g s. FINITE s ==> zsum s (\x. f x + g x) = zsum s f + zsum s g

ZSUM_CLAUSES

|- (!f. zsum {} f = zzero) /\

(!f x s.

73

Appendix A. Theorems

FINITE s

==> zsum (x INSERT s) f =

(if x IN s then zsum s f else f x + zsum s f))

ZSUM_DIFF

|- !f s t.

FINITE s /\ t SUBSET s ==> zsum (s DIFF t) f = zsum s f - zsum t f

ZSUM_EQ

|- !f g s. (!x. x IN s ==> f x = g x) ==> zsum s f = zsum s g

ZSUM_EQ_0

|- !f s. (!x. x IN s ==> f x = zzero) ==> zsum s f = zzero

ZSUM_EQ_SUPERSET

|- !f s t.

FINITE t /\

t SUBSET s /\

(!x. x IN t ==> f x = g x) /\

(!x. x IN s /\ ~(x IN t) ==> f x = zzero)

==> zsum s f = zsum t g

ZSUM_IMAGE

|- !f g s.

(!x y. x IN s /\ y IN s /\ f x = f y ==> x = y)

==> zsum (IMAGE f s) g = zsum s (g o f)

ZSUM_IMAGE_GEN

|- !f g s.

FINITE s

==> zsum s g =

zsum (IMAGE f s) (\y. zsum {x | x IN s /\ f x = y} g)

ZSUM_LCMUL

|- !f c s. zsum s (\x. c ** f x) = c ** zsum s f

ZSUM_RESTRICT_SET

|- !s f P.

FINITE s

==> zsum {x | x IN s /\ P x} f =

zsum s (\x. if P x then f x else zzero)

ZSUM_SING

|- !f x. zsum {x} f = f x

ZSUM_SUB

|- !f g s. FINITE s ==> zsum s (\x. f x - g x) = zsum s f - zsum s g

ZSUM_SUPERSET

|- !f u v.

FINITE u /\ u SUBSET v /\ (!x. x IN v /\ ~(x IN u) ==> f x = zzero)

==> zsum v f = zsum u f

ZSUM_SUPPORT

|- !f s. zsum (support (+) f s) f = zsum s f

ZSUM_SWAP

|- !f s t.

FINITE s /\ FINITE t

==> zsum s (\i. zsum t (f i)) = zsum t (\j. zsum s (\i. f i j))

ZSUM_SWAP2

74

Appendix A. Theorems

|- !f s t.

FINITE s /\ FINITE t

==> zsum s (\i. zsum t (\j. f i j)) =

zsum t (\j. zsum s (\i. f i j))

ZSUM_UNION

|- !f s t.

FINITE s /\ FINITE t /\ DISJOINT s t

==> zsum (s UNION t) f = zsum s f + zsum t f

ZSUM_ZSUM_PRODUCT

|- !s t x.

FINITE s /\ (!i. i IN s ==> FINITE (t i))

==> zsum s (\i. zsum (t i) (x i)) =

zsum {i,j | i IN s /\ j IN t i} (\(i,j). x i j)

ZSUM_ZSUM_RESTRICT

|- !R f s t.

FINITE s /\ FINITE t

==> zsum s (\x. zsum {y | y IN t /\ R x y} (\y. f x y)) =

zsum t (\y. zsum {x | x IN s /\ R x y} (\x. f x y))

ZSUPPORT_ADD

|- !x y. zsupport (x + y) SUBSET zsupport x UNION zsupport y

ZSUPPORT_CMUL

|- !x c. zsupport (c ** x) = (if c = &0 then {} else zsupport x)

ZSUPPORT_CMUL_NONZERO

|- !x c. ~(c = &0) ==> zsupport (c ** x) = zsupport x

ZSUPPORT_EMPTY

|- !z. zsupport z = {} <=> z = zzero

ZSUPPORT_NEG

|- !x. zsupport (--x) = zsupport x

ZSUPPORT_SUB

|- !x y. zsupport (x - y) SUBSET zsupport x UNION zsupport y

ZSUPPORT_SUPPORT

|- !x. zsupport x = support (+) (zmod_fun x) (:?90317)

ZSUPPORT_ZVEC

|- !x. zsupport (zvec x) = {x}

ZSUPPORT_ZZERO

|- zsupport zzero = {}

ZVEC_AS_BASIS

|- !x. x = zsum (zsupport x) (\i. zmod_fun x i ** zvec i)

ZVEC_NONZERO

|- !k. ~(zvec k = zzero)

ZVEC_ZHOM

|- !x. x = zhom zvec (zsupport x) x

ZZERO_IN_ZSUBMOD

|- !m. zsubmod m ==> zzero IN m

zcomb

75

Appendix A. Theorems

|- !s. zcomb s = {x | ?u. zsupport u SUBSET s /\ x = zjoin u}

zgen

|- !s. zgen s = {x | !m. zsubmod m /\ s SUBSET m ==> x IN m}

zhom

|- !s f x. zhom f s x = zsum s (\a. zmod_fun x a ** f a)

zhom_th

|- !s f x i.

zmod_fun (zhom f s x) i =

isum s (\a. zmod_fun x a * zmod_fun (f a) i)

zjoin

|- !u. zjoin u = zsum (:(A)zmod) (\v. zmod_fun u v ** v)

zjoin_th

|- !u i.

zmod_fun (zjoin u) i =

isum (:(A)zmod) (\v. zmod_fun u v * zmod_fun v i)

zkernel

|- !f. zkernel f = {x | f x = zzero}

zmod_add

|- !x y. x + y = zmod (\i. zmod_fun x i + zmod_fun y i)

zmod_add_th

|- !x y i. zmod_fun (x + y) i = zmod_fun x i + zmod_fun y i

zmod_cmul

|- !n x. n ** x = zmod (\i. n * zmod_fun x i)

zmod_cmul_th

|- !x c i. zmod_fun (c ** x) i = c * zmod_fun x i

zmod_eq

|- !f g. zmod f = zmod g <=> f = g

zmod_fun_eq

|- !x y. zmod_fun f = zmod_fun g <=> f = g

zmod_fun_th

|- !x. zmod (zmod_fun x) = x

zmod_neg

|- !x. --x = zmod (\i. --zmod_fun x i)

zmod_neg_th

|- !x i. zmod_fun (--x) i = --zmod_fun x i

zmod_sub

|- !x y. x - y = zmod (\i. zmod_fun x i - zmod_fun y i)

zmod_sub_th

|- !x y i. zmod_fun (x - y) i = zmod_fun x i - zmod_fun y i

zmod_th

|- !f. zmod_fun (zmod f) = f

zmod_tybij

|- (!a. zmod (zmod_fun a) = a) /\ (!r. zmod_fun (zmod r) = r)

76

Appendix A. Theorems

zsubmod

|- !m. zsubmod m <=>

~(m = {}) /\

(!x y. x IN m /\ y IN m ==> x - y IN m) /\

(!c x. x IN m ==> c ** x IN m)

zsum

|- !f s. zsum s f = zmod (\i. isum s (\a. zmod_fun (f a) i))

zsum’

|- !f s acc.

zsum’ acc s f =

zmod (\i. isum’ (zmod_fun acc i) s (\a. zmod_fun (f a) i))

zsum’_th

|- !f s acc i.

zmod_fun (zsum’ acc s f) i =

isum’ (zmod_fun acc i) s (\a. zmod_fun (f a) i)

zsum_th

|- !f s i. zmod_fun (zsum s f) i = isum s (\a. zmod_fun (f a) i)

zsupport

|- !x. zsupport x = {i | ~(zmod_fun x i = &0)}

zvec

|- !k. zvec k = zmod (\i. if i = k then &1 else &0)

zvec_th

|- !i k. zmod_fun (zvec k) i = (if i = k then &1 else &0)

zzero

|- zzero = zmod (\i. &0)

zzero_th

|- !i. zmod_fun zzero i = &0

A.5 Binary relations

DISJOINTS_STCLASSES

|- !R. DISJOINTS (STCLASSES R)

DISJOINT_STCLASS

|- !R x y.

STCLASS R x = STCLASS R y \/ DISJOINT (STCLASS R x) (STCLASS R y)

ELT_IN_STCLASS

|- !x. x IN STCLASS R x <=> x IN FL R

FL

|- !R. FL R = {x | (?y. R x y) \/ (?y. R y x)}

FL_SC

|- !R. FL (SC R) = FL R

FL_STC

|- !R. FL (STC R) = FL R

77

Appendix A. Theorems

FL_TC

|- !R. FL (TC R) = FL R

IN_FL

|- !R x. x IN FL R <=> (?y. R x y) \/ (?y. R y x)

IN_FL_SC

|- !R x. x IN FL R <=> (?y. SC R x y)

IN_FL_STC

|- !R x. x IN FL R <=> (?y. STC R x y)

IN_FL_STC_REFL

|- !R x. x IN FL R <=> STC R x x

IN_FL_TC

|- !R x. x IN FL R <=> (?y. TC R x y) \/ (?y. TC R y x)

IN_REACHABLE

|- !R s x. x IN REACHABLE R s <=> (?a. a IN s /\ R a x)

IN_STCLASS

|- !R x y. y IN STCLASS R x <=> STC R x y

IN_STCLASSES

|- !R s. s IN STCLASSES R <=> (?x. x IN FL R /\ s = STCLASS R x)

MAXIMAL_STCLASS

|- !R x t.

x IN FL R /\ STCONNECTED R t /\ STCLASS R x SUBSET t

==> t = STCLASS R x

REACHABLE

|- !R s. REACHABLE R s = {x | ?a. a IN s /\ R a x}

REACHABLE_EMPTY

|- !R. REACHABLE R {} = {}

REFL_IN_FL

|- !R x.

(!x y z. R x y /\ R y z ==> R x z) /\ (!x y. R x y ==> R y x)

==> (R x x <=> x IN FL R)

STCLASS

|- !R x. STCLASS R x = {y | STC R x y}

STCLASSES

|- !R. STCLASSES R = {STCLASS R x | x | x IN FL R}

STCLASSES_THM

|- !R C.

STCLASSES R = C <=>

DISJOINTS C /\

(!s. s IN C ==> ~(s = {})) /\

(!s. s IN C ==> STCONNECTED R s) /\

FL R = UNIONS C /\

(!s t. s IN C /\ STCONNECTED R t /\ s SUBSET t ==> s = t)

STCLASS_EMPTY

|- !R x. STCLASS R x = {} <=> ~(x IN FL R)

STCLASS_EQ_REACHABLE

78

Appendix A. Theorems

|- !R x. STCLASS R x = REACHABLE (STC R) {x}

STCLASS_INJ

|- !R x y. x IN FL R ==> (STCLASS R x = STCLASS R y <=> STC R x y)

STCONNECTED

|- !R s. STCONNECTED R s <=> (!x y. x IN s /\ y IN s ==> STC R x y)

STCONNECTED_STCLASS

|- !R x. STCONNECTED R (STCLASS R x)

STCONNECTED_SUBSET_STCLASS

|- !R t x. STCONNECTED R t /\ x IN t ==> t SUBSET STCLASS R x

UNIONS_STCLASSES

|- !R. UNIONS (STCLASSES R) = FL R

A.6 Simplicial complexes

CONE

|- !a C. CONE C a = C UNION {s | ?t. t IN C /\ s = a INSERT t}

CONE_AS_IMAGE

|- !C a. CONE C a = C UNION IMAGE ((INSERT) a) C

CONE_THM

|- !C a. SIMPLICIAL C ==> CONE C a = {s | s DELETE a IN C}

FACES

|- !s. FACES s = {t | t SUBSET s /\ SIMPLEX_DIM s = SIMPLEX_DIM t + &1}

FF

|- !C i. FF C i = {s | s IN C /\ SIMPLEX_DIM s = i}

FINITE_CONE

|- !C a. FINITE (CONE C a) <=> FINITE C

FMAX

|- !s. FMAX s = ITSET max s (&0)

IN_CONE

|- !C a s. SIMPLICIAL C ==> (s IN CONE C a <=> s DELETE a IN C)

SIMPLEX_DIM

|- !s. SIMPLEX_DIM s = &(CARD s) - &1

SIMPLEX_DIM_CLAUSES

|- SIMPLEX_DIM {} = -- &1 /\

(!x s.

FINITE s

==> SIMPLEX_DIM (x INSERT s) =

(if x IN s then SIMPLEX_DIM s else SIMPLEX_DIM s + &1))

SIMPLEX_DIM_EMPTY

|- SIMPLEX_DIM {} = -- &1

SIMPLEX_DIM_INSERT

|- !x s.

FINITE s

79

Appendix A. Theorems

==> SIMPLEX_DIM (x INSERT s) =

(if x IN s then SIMPLEX_DIM s else SIMPLEX_DIM s + &1)

SIMPLEX_DIM_PAIR

|- !n m. ~(n = m) ==> SIMPLEX_DIM {n, m} = &1

SIMPLEX_DIM_SING

|- !n. SIMPLEX_DIM {n} = &0

SIMPLEX_FINITE

|- !C s. SIMPLICIAL C /\ s IN C ==> FINITE s

SIMPLICIAL

|- !C. SIMPLICIAL C <=>

(!s t. s IN C /\ t SUBSET s ==> t IN C) /\

FINITE C /\

(!s. s IN C ==> FINITE s)

SIMPLICIAL_CONE

|- !C a. SIMPLICIAL C ==> SIMPLICIAL (CONE C a)

SIMPLICIAL_DIM

|- !C. SIMPLICIAL_DIM C = FMAX {SIMPLEX_DIM s | s IN C}

SIMPLICIAL_EMPTY

|- SIMPLICIAL {{}}

SIMPLICIAL_EMPTY_COMPLEX

|- SIMPLICIAL {}

SIMPLICIAL_FACES

|- !C s t. SIMPLICIAL C /\ s IN C /\ t SUBSET s ==> t IN C

SIMPLICIAL_FINITE

|- !C. SIMPLICIAL C ==> FINITE C

SIMPLICIAL_SING

|- !n. SIMPLICIAL {{}, {n}}

SIMPLICIAL_SPHERE

|- !n. SIMPLICIAL (SPHERE n)

SIMPLICIAL_SUSPENSION

|- !C a b. SIMPLICIAL C ==> SIMPLICIAL (SUSPENSION C a b)

SIMPLICIAL_UNION

|- !B C. SIMPLICIAL B /\ SIMPLICIAL C ==> SIMPLICIAL (B UNION C)

SPHERE

|- SPHERE 0 = {{}, {0}, {1}} /\

(!n. SPHERE (SUC n) = SUSPENSION (SPHERE n) (2 * n + 2) (2 * n + 3))

SPHERE_THM

|- !n. SPHERE n =

(if n = 0

then {{}, {0}, {1}}

else SUSPENSION (SPHERE (PRE n)) (2 * n) (2 * n + 1))

SUSPENSION

|- !C a b. SUSPENSION C a b = CONE C a UNION CONE C b

ZFF

80

Appendix A. Theorems

|- !C i. ZFF C i = {f | !s. ~(s IN FF C i) ==> f s = &0}

A.7 Generators

EXISTS_MAXIMAL_SET

|- !P. ~(P = {}) /\ FINITE P

==> (?s. s IN P /\ (!t. t IN P /\ s SUBSET t ==> s = t))

FINITE_SIMPLICIAL_GENERATED

|- !C. FINITE (SIMPLICIAL_GENERATED C) <=>

FINITE C /\ (!s. s IN C ==> FINITE s)

IN_SIMPLICIAL_GENERATED

|- !C s. s IN SIMPLICIAL_GENERATED C <=> (?t. t IN C /\ s SUBSET t)

IN_SIMPLICIAL_GENERATED_INSERT

|- !s t C.

s IN SIMPLICIAL_GENERATED (t INSERT C) <=>

s SUBSET t \/ s IN SIMPLICIAL_GENERATED C

MIN_GEN

|- !C. MIN_GEN C = {s | s IN C /\ (!t. t IN C /\ s SUBSET t ==> s = t)}

MIN_GEN_DEF2

|- !C. MIN_GEN C = {s | s IN C /\ ~(?t. t IN C /\ s PSUBSET t)}

MIN_GEN_INSERT

|- !C s.

FINITE C

==> MIN_GEN (s INSERT C) =

MIN_GEN

(if s IN SIMPLICIAL_GENERATED C

then C

else s INSERT (C DIFF SIMPLICIAL_GENERATED {s}))

MIN_GEN_MINIMALITY

|- !C D. C = SIMPLICIAL_GENERATED D ==> MIN_GEN C SUBSET D

MIN_GEN_MIN_GEN

|- !C. MIN_GEN (MIN_GEN C) = MIN_GEN C

MIN_GEN_REC

|- !C Acc. MIN_GEN_REC C Acc = MIN_GEN (C UNION Acc)

MIN_GEN_REC_EMPTY

|- !Acc. MIN_GEN_REC {} Acc = MIN_GEN Acc

MIN_GEN_REC_EMPTY2

|- !C. MIN_GEN_REC C {} = MIN_GEN C

MIN_GEN_REC_THM

|- !C Acc s.

FINITE C /\ FINITE Acc

==> MIN_GEN_REC (s INSERT C) Acc =

MIN_GEN_REC C

(if s IN SIMPLICIAL_GENERATED Acc

then Acc

else s INSERT (Acc DIFF SIMPLICIAL_GENERATED {s}))

81

Appendix A. Theorems

MIN_GEN_SIMPLICIAL_GENERATED_THM

|- !C. MIN_GEN C = MIN_GEN (SIMPLICIAL_GENERATED C)

MIN_GEN_SIMPLICIAL_GENERATED_THM2

|- !C D.

SIMPLICIAL_GENERATED C = SIMPLICIAL_GENERATED D

==> MIN_GEN C = MIN_GEN D

MIN_GEN_UNION

|- !C D.

FINITE C /\ FINITE D

==> MIN_GEN (C UNION D) = MIN_GEN (MIN_GEN C UNION MIN_GEN D)

SIMPLICIAL_GENERATED

|- !C. SIMPLICIAL_GENERATED C = {s | ?t. t IN C /\ s SUBSET t}

SIMPLICIAL_GENERATED_AS_UNIONS

|- !C. SIMPLICIAL_GENERATED C = UNIONS (IMAGE SUBSETS C)

SIMPLICIAL_GENERATED_EMPTY

|- SIMPLICIAL_GENERATED {} = {}

SIMPLICIAL_GENERATED_INSERT

|- !C s.

SIMPLICIAL_GENERATED (s INSERT C) = SIMPLICIAL_GENERATED C <=>

s IN SIMPLICIAL_GENERATED C

SIMPLICIAL_GENERATED_MINIMALITY

|- !D C. SIMPLICIAL D /\ C SUBSET D ==> SIMPLICIAL_GENERATED C SUBSET D

SIMPLICIAL_GENERATED_MIN_GEN

|- !C. FINITE C

==> SIMPLICIAL_GENERATED C = SIMPLICIAL_GENERATED (MIN_GEN C)

SIMPLICIAL_GENERATED_THM

|- !C. SIMPLICIAL C ==> SIMPLICIAL_GENERATED C = C

SIMPLICIAL_GENERATED_UNION

|- !C D.

SIMPLICIAL_GENERATED (C UNION D) =

SIMPLICIAL_GENERATED C UNION SIMPLICIAL_GENERATED D

SIMPLICIAL_SIMPLICIAL_GENERATED

|- !C. SIMPLICIAL (SIMPLICIAL_GENERATED C) <=>

FINITE C /\ (!s. s IN C ==> FINITE s)

SUBSET_MIN_GEN

|- !C. MIN_GEN C SUBSET C

SUBSET_SIMPLICIAL_GENERATED

|- !C. C SUBSET SIMPLICIAL_GENERATED C

A.8 Connected components

CONE_CLAUSES

|- (!a. CONE {} a = {}) /\

(!C s a. CONE (s INSERT C) a = s INSERT (a INSERT s) INSERT CONE C a)

CONNECTED_COMPLEX

82

Appendix A. Theorems

|- !C. CONNECTED_COMPLEX C <=> VCONNECTED C (UNIONS C)

CONNECTED_COMPLEX_CONE

|- !C a. CONNECTED_COMPLEX (CONE C a)

CONNECTED_COMPLEX_EMPTY

|- CONNECTED_COMPLEX {}

CONNECTED_COMPLEX_SPHERE

|- !n. ~(n = 0) ==> CONNECTED_COMPLEX (SPHERE n)

CONNECTED_COMPLEX_STARLIKE

|- !C c. (!x. x IN UNIONS C ==> VLINK C x c) ==> CONNECTED_COMPLEX C

CONNECTED_COMPLEX_SUSPENSION

|- !C a b c. c IN UNIONS C ==> CONNECTED_COMPLEX (SUSPENSION C a b)

CONNECTED_COMPLEX_THM

|- !C. CONNECTED_COMPLEX C <=>

(!x y. x IN UNIONS C /\ y IN UNIONS C ==> EQVLINK C x y)

CONNECTED_COMPLEX_UNION

|- !C1 C2 x.

CONNECTED_COMPLEX C1 /\

CONNECTED_COMPLEX C2 /\

x IN UNIONS C1 /\

x IN UNIONS C2

==> CONNECTED_COMPLEX (C1 UNION C2)

DISJOINTS_VCOMPONENTS

|- !C. DISJOINTS (VCOMPONENTS C)

DISJOINT_VCOMPONENT

|- !C x y.

VCOMPONENT C x = VCOMPONENT C y \/

DISJOINT (VCOMPONENT C x) (VCOMPONENT C y)

ELT_IN_VCOMPONENT

|- !x. x IN VCOMPONENT C x <=> x IN UNIONS C

EQVLINK

|- !C. EQVLINK C = TC (VLINK C)

EQVLINK_CASES_L

|- !C x z.

EQVLINK C x z <=> VLINK C x z \/ (?y. EQVLINK C x y /\ VLINK C y z)

EQVLINK_CASES_R

|- !C x z.

EQVLINK C x z <=> VLINK C x z \/ (?y. VLINK C x y /\ EQVLINK C y z)

EQVLINK_DISJOINTS

|- !C. DISJOINTS C ==> EQVLINK C = VLINK C

EQVLINK_INC_LEMMA

|- !C1 C2.

(!s. s IN C1 ==> VCONNECTED C2 s) <=>

(!x y. EQVLINK C1 x y ==> EQVLINK C2 x y)

EQVLINK_INC_VLINK

|- !C x y. VLINK C x y ==> EQVLINK C x y

83

Appendix A. Theorems

EQVLINK_INDUCT

|- !R C.

(!x y. VLINK C x y ==> R x y) /\ (!x y z. R x y /\ R y z ==> R x z)

==> (!a0 a1. EQVLINK C a0 a1 ==> R a0 a1)

EQVLINK_INDUCT_L

|- !R C.

(!x y. VLINK C x y ==> R x y) /\

(!x y z. R x y /\ VLINK C y z ==> R x z)

==> (!x y. EQVLINK C x y ==> R x y)

EQVLINK_INDUCT_R

|- !R C.

(!x y. VLINK C x y ==> R x y) /\

(!x y z. VLINK C x y /\ R y z ==> R x z)

==> (!x y. EQVLINK C x y ==> R x y)

EQVLINK_IN_UNIONS

|- !C x y. EQVLINK C x y ==> x IN UNIONS C

EQVLINK_MONOTONE

|- !C D x y.

(!s. s IN C ==> (?t. t IN D /\ s SUBSET t)) /\ EQVLINK C x y

==> EQVLINK D x y

EQVLINK_REFL

|- !C x. EQVLINK C x x <=> x IN UNIONS C

EQVLINK_SUBSET

|- !C D x y. C SUBSET D /\ EQVLINK C x y ==> EQVLINK D x y

EQVLINK_SUSPENSION_LEMMA1

|- !C a b x. x IN UNIONS C ==> EQVLINK (SUSPENSION C a b) a x

EQVLINK_SUSPENSION_LEMMA2

|- !C a b x. x IN UNIONS C ==> EQVLINK (SUSPENSION C a b) b x

EQVLINK_SYM

|- !C x y. EQVLINK C x y ==> EQVLINK C y x

EQVLINK_TRANS

|- !C x y z. EQVLINK C x y /\ EQVLINK C y z ==> EQVLINK C x z

FL_EQVLINK

|- !C. FL (EQVLINK C) = UNIONS C

FL_VLINK

|- !C. FL (VLINK C) = UNIONS C

INSERT_UNIONS_LEMMA

|- !a s. ~(s = {}) ==> a INSERT UNIONS s = UNIONS (IMAGE ((INSERT) a) s)

IN_VCOMPONENT

|- !C x y. y IN VCOMPONENT C x <=> EQVLINK C x y

IN_VCOMPONENTS

|- !C s. s IN VCOMPONENTS C <=> (?x. x IN UNIONS C /\ s = VCOMPONENT C x)

IN_VREACHABLE

|- !C s x. x IN VREACHABLE C s <=> x IN s \/ (?a. a IN s /\ EQVLINK C a x)

IN_VREACHABLES

84

Appendix A. Theorems

|- !C K s. s IN VREACHABLES C K <=> (?k. k IN K /\ s = VREACHABLE C k)

IN_VREACHABLE_INDUCT

|- !C s P.

(!x. x IN s ==> P x) /\ (!x y. VLINK C x y /\ P x ==> P y)

==> (!x. x IN VREACHABLE C s ==> P x)

MAXIMAL_VCOMPONENT

|- !C x t.

x IN UNIONS C /\ VCONNECTED C t /\ VCOMPONENT C x SUBSET t

==> t = VCOMPONENT C x

NOT_EQVLINK_EMPTY_COMPLEX

|- !x y. ~EQVLINK {} x y

SC_EQVLINK

|- !C. SC (EQVLINK C) = EQVLINK C

SC_VLINK

|- !C. SC (VLINK C) = VLINK C

SPHERE_NOT_EMPTY

|- !n. ~(SPHERE n = {})

STC_EQVLINK

|- !C. STC (EQVLINK C) = EQVLINK C

STC_VLINK

|- !C. STC (VLINK C) = EQVLINK C

SUSPENSION_CLAUSES

|- (!a b. SUSPENSION {} a b = {}) /\

(!C s a b.

SUSPENSION (s INSERT C) a b =

s INSERT (a INSERT s) INSERT (b INSERT s) INSERT SUSPENSION C a b)

SUSPENSION_SYM

|- !C a b. SUSPENSION C a b = SUSPENSION C b a

TC_EQVLINK

|- !C. TC (EQVLINK C) = EQVLINK C

UNIONS_CONE

|- !C a. UNIONS (CONE C a) = (if C = {} then {} else a INSERT UNIONS C)

UNIONS_SUSPENSION

|- !C a b.

UNIONS (SUSPENSION C a b) =

(if C = {} then {} else a INSERT b INSERT UNIONS C)

UNIONS_VCOMPONENTS

|- !C. UNIONS (VCOMPONENTS C) = UNIONS C

VCOMPONENT

|- !x C. VCOMPONENT C x = STCLASS (EQVLINK C) x

VCOMPONENTS

|- !C. VCOMPONENTS C = {VCOMPONENT C x | x | x IN UNIONS C}

VCOMPONENTS_EMPTY

|- VCOMPONENTS {} = {}

85

Appendix A. Theorems

VCOMPONENTS_STCLASSES

|- !C. VCOMPONENTS C = STCLASSES (EQVLINK C)

VCOMPONENT_EMPTY

|- !C x. VCOMPONENT C x = {} <=> ~(x IN UNIONS C)

VCOMPONENT_EQ_VREACHABLE

|- !C x. VCOMPONENT C x = (if x IN UNIONS C then VREACHABLE C {x} else {})

VCOMPONENT_INJ

|- !C x y.

x IN UNIONS C

==> (VCOMPONENT C x = VCOMPONENT C y <=> EQVLINK C x y)

VCONNECTED

|- !C s. VCONNECTED C s <=> (!x y. x IN s /\ y IN s ==> EQVLINK C x y)

VCONNECTED_STCONNECTED

|- !C. VCONNECTED C = STCONNECTED (EQVLINK C)

VCONNECTED_VCOMPONENT

|- !C x. VCONNECTED C (VCOMPONENT C x)

VLINK

|- !C x y. VLINK C x y <=> (?s. s IN C /\ x IN s /\ y IN s)

VLINK_CLASS

|- !C x. VLINK C x = UNIONS (COLLECT (\s. x IN s) C)

VLINK_MONOTONE

|- !C D x y.

(!s. s IN C ==> (?t. t IN D /\ s SUBSET t)) /\ VLINK C x y

==> VLINK D x y

VLINK_REFL

|- !x. VLINK C x x <=> x IN UNIONS C

VLINK_RULES

|- (!C x y. VLINK {} x y <=> F) /\

(!C x y. VLINK ({} INSERT C) x y <=> VLINK C x y) /\

(!C s x y. VLINK (s INSERT C) x y <=> x IN s /\ y IN s \/ VLINK C x y)

VLINK_SET_EX

|- !C x y. VLINK C x y <=> SET_EX (\s. x IN s /\ y IN s) C

VLINK_SUBSET

|- !C D x y. C SUBSET D /\ VLINK C x y ==> VLINK D x y

VLINK_SUBSET_THM

|- !C x y.

(!s t. s IN C /\ t SUBSET s ==> t IN C)

==> (VLINK C x y <=> {x, y} IN C)

VLINK_SYM

|- !C x y. VLINK C x y ==> VLINK C y x

VLINK_UNION

|- !C D x y. VLINK (C UNION D) x y <=> VLINK C x y \/ VLINK D x y

VREACHABLE

|- !C s. VREACHABLE C s = REACHABLE (RC (EQVLINK C)) s

86

Appendix A. Theorems

VREACHABLES

|- !K C. VREACHABLES C K = {VREACHABLE C s | s IN K}

VREACHABLES_EMPTY

|- !C. VREACHABLES C {} = {}

VREACHABLES_EMPTY_COMPLEX

|- !K. VREACHABLES {} K = K

VREACHABLE_COMPUTE

|- !C s.

VREACHABLE C s =

(let D,E = PARTITION (DISJOINT s) C in

if E = {} then s else VREACHABLE D (s UNION UNIONS E))

VREACHABLE_EMPTY

|- !C. VREACHABLE C {} = {}

VREACHABLE_EMPTY_COMPLEX

|- !s. VREACHABLE {} s = s

VREACHABLE_IDEMP

|- !C s.

VREACHABLE C s = s <=> (!t. t IN C ==> DISJOINT s t \/ t SUBSET s)

VREACHABLE_INC

|- !C s. s SUBSET VREACHABLE C s

VREACHABLE_LEMMA1

|- !C s.

VREACHABLE C s =

VREACHABLE C (s UNION UNIONS {t | t IN C /\ ~DISJOINT s t})

VREACHABLE_LEMMA2

|- !C s. VREACHABLE C s = VREACHABLE {t | t IN C /\ ~(t SUBSET s)} s

VREACHABLE_LEMMA3

|- !C D s.

(!t. t IN C ==> t IN D /\ t SUBSET s)

==> VREACHABLE C s SUBSET VREACHABLE D s

VREACHABLE_MONO

|- !C s t. s SUBSET t ==> VREACHABLE C s SUBSET VREACHABLE C t

A.9 Sign of an index in a simplex

ARITH_NUMTRIE_SIGN

|- (!s n. NUMTRIE_SIGN (NUMERAL n) s = NUMTRIE_SIGN n s) /\

(!n. NUMTRIE_SIGN n numempty = &1) /\

(!n. NUMTRIE_SIGN n numzero = (if n = _0 then &1 else -- &1)) /\

(!s t. NUMTRIE_SIGN _0 (numnode s t) = &1) /\

(!s t n.

NUMTRIE_SIGN (BIT1 n) (numnode s t) =

NUMTRIE_SIGN n s * NUMTRIE_SIGN (SUC n) t) /\

(!s t n.

NUMTRIE_SIGN (BIT0 n) (numnode s t) =

NUMTRIE_SIGN n s * NUMTRIE_SIGN n t)

BINARY_NUMTRIE_SIGN

87

Appendix A. Theorems

|- (!j. NUMTRIE_SIGN j numempty = &1) /\

(!j. NUMTRIE_SIGN j numzero = (if j = 0 then &1 else -- &1)) /\

(!s t. NUMTRIE_SIGN 0 (numnode s t) = &1) /\

(!n s t.

NUMTRIE_SIGN (2 * n + 1) (numnode s t) =

NUMTRIE_SIGN n s * NUMTRIE_SIGN (SUC n) t) /\

(!n s t.

NUMTRIE_SIGN (2 * n) (numnode s t) =

NUMTRIE_SIGN n s * NUMTRIE_SIGN n t)

NUMTRIE_SIGN

|- (!j. NUMTRIE_SIGN j numempty = &1) /\

(!j. NUMTRIE_SIGN j numzero = (if j = 0 then &1 else -- &1)) /\

(!j s t.

NUMTRIE_SIGN j (numnode s t) =

(if j = 0

then &1

else NUMTRIE_SIGN (j DIV 2) s * NUMTRIE_SIGN (SUC j DIV 2) t))

NUMTRIE_SIGN_0

|- !s. NUMTRIE_SIGN 0 s = &1

NUMTRIE_SIGN_THM

|- !j s. NUMTRIE_SIGN j s = sign j (NUMTRIE s)

SIGN_0

|- !s. sign 0 s = &1

SIGN_DELETE

|- !j x s.

FINITE s /\ x IN s

==> sign j (s DELETE x) = (if x < j then --sign j s else sign j s)

SIGN_DISJOINT_UNION

|- !j s t. DISJOINT s t ==> sign j (s UNION t) = sign j s * sign j t

SIGN_EMPTY

|- !j. sign j {} = &1

SIGN_INSERT

|- !j i s.

sign j (i INSERT s) =

(if i IN s

then sign j s

else if j <= i then sign j s else --sign j s)

SIGN_NUMTRIE_LEMMA1

|- !j s.

~(j = 0)

==> sign j (IMAGE (\n. 2 * n + 1) (NUMTRIE s)) =

sign (j DIV 2) (NUMTRIE s)

SIGN_NUMTRIE_LEMMA2

|- !j t.

~(j = 0)

==> sign j (IMAGE (\n. 2 * n) (NUMTRIE t)) =

sign (SUC j DIV 2) (NUMTRIE t)

sign

|- !j s. sign j s = -- &1 pow CARD {n | n IN s /\ n < j}

88

Appendix A. Theorems

A.10 The boundary operator

FINITE_ZSUPPORT_THM

|- !C x.

SIMPLICIAL C /\ FINITE (zsupport x)

==> ZOP_BOUND C (ZOP_BOUND C x) = zzero

IN_FF

|- !C i s. s IN FF C i <=> s IN C /\ SIMPLEX_DIM s = i

IN_ZCC

|- !C i. x IN ZCC C i <=> (!y. ~(y IN FF C i) ==> zmod_fun x y = &0)

IN_ZCC_FINITE_ZSUPPORT

|- !x C j.

x IN ZCC C j /\ FINITE (zsupport x)

==> x = zsum (FF C j) (\i. zmod_fun x i ** zvec i)

IN_ZFSI

|- !C x. x IN ZFSI C <=> (!i. ~(i IN C) ==> zmod_fun x i = &0)

LINEAR_ZOP_BOUND

|- !C. SIMPLICIAL C ==> LINEAR (ZOP_BOUND C)

SIMPLEX_DIM_DELETE

|- !x s.

FINITE s

==> SIMPLEX_DIM (s DELETE x) =

(if x IN s then SIMPLEX_DIM s - &1 else SIMPLEX_DIM s)

ZCC

|- !C i. ZCC C i = {x | zsupport x SUBSET FF C i}

ZFSI

|- !C. ZFSI C = {x | !s. ~(s IN C) ==> zmod_fun x s = &0}

ZFSI_FINITE_ZSUPPORT

|- !C x. SIMPLICIAL C /\ x IN ZFSI C ==> FINITE (zsupport x)

ZFSI_ZSUPPORT

|- !C. ZFSI C = {s | zsupport s SUBSET C}

ZLOC

|- !C x. ZLOC C x = zmod (\s. if s IN C then zmod_fun x s else &0)

ZLOC_IN_ZCC

|- !C x i. x IN ZCC C i ==> ZLOC C x IN ZCC C i

ZLOC_LEMMA

|- !C x. ZLOC C x IN ZFSI C /\ ZOP_BOUND C x = ZOP_BOUND C (ZLOC C x)

ZLOC_ZOP_BOUND

|- !C x. ?y. y IN ZFSI C /\ ZOP_BOUND C x = ZOP_BOUND C y

ZMOD_ADD_IN_ZCC

|- !C i x y. x IN ZCC C i /\ y IN ZCC C i ==> x + y IN ZCC C i

ZMOD_CMUL_IN_ZCC

|- !C i x c. x IN ZCC C i ==> c ** x IN ZCC C i

ZMOD_FUN_ZOP_BOUND_EQ_0

|- !C x y. ~(y IN C) /\ SIMPLICIAL C ==> zmod_fun (ZOP_BOUND C x) y = &0

89

Appendix A. Theorems

ZMOD_SUB_IN_ZCC

|- !C i x y. x IN ZCC C i /\ y IN ZCC C i ==> x - y IN ZCC C i

ZOP_BOUND

|- !C. ZOP_BOUND C =

zhom (\s. zsum s (\j. sign j s ** zvec (s DELETE j))) C

ZOP_BOUND_IN_ZCC

|- !C x i.

SIMPLICIAL C /\ x IN ZCC C (i + &1) ==> ZOP_BOUND C x IN ZCC C i

ZOP_BOUND_IN_ZCC_LEMMA

|- !C x i.

SIMPLICIAL C /\ x IN ZCC C (i + &1) /\ FINITE (zsupport x)

==> ZOP_BOUND C x IN ZCC C i

ZOP_BOUND_THM

|- !C x. SIMPLICIAL C ==> ZOP_BOUND C (ZOP_BOUND C x) = zzero

ZOP_BOUND_ZVEC

|- !C s.

ZOP_BOUND C (zvec s) =

(if s IN C

then zsum s (\j. sign j s ** zvec (s DELETE j))

else zzero)

ZSUBMOD_ZCC

|- !C i. zsubmod (ZCC C i)

ZVEC_THM

|- !C s. SIMPLICIAL C ==> ZOP_BOUND C (ZOP_BOUND C (zvec s)) = zzero

ZZERO_IN_ZCC

|- !C i. zzero IN ZCC C i

A.11 Computation of the boundary operator

NUMTRIE_SIGN_MK_NUMTRIE

|- !j s. FINITE s ==> NUMTRIE_SIGN j (MK_NUMTRIE s) = sign j s

TR

|- !x. TR x =

zmod (\s. if FINITE s then zmod_fun x (MK_NUMTRIE s) else &0)

ZOP_BOUND_NUMTRIE

|- !C. ZOP_BOUND_NUMTRIE C =

zhom

(\s. zsumnt s (\j. NUMTRIE_SIGN j s ** zvec (NUMTRIE_DELETE j s)))

C

ZOP_BOUND_NUMTRIE_THM

|- !C. SIMPLICIAL C

==> ZOP_BOUND C =

TR o ZOP_BOUND_NUMTRIE (IMAGE MK_NUMTRIE C) o ZMOD_MAP NUMTRIE

ZSUMNT_CLAUSES

|- (!f. zsumnt numempty f = zzero) /\

(!f. zsumnt numzero f = f 0) /\

90

Appendix A. Theorems

(!x f s.

zsumnt (NUMTRIE_INSERT x s) f =

(if NUMTRIE_MEM x s then zsumnt s f else f x + zsumnt s f))

zsumnt

|- !s. zsumnt s = zsum (NUMTRIE s)

91

Bibliography

[1] AA.VV. The QED manifesto. In Proceedings of the 12th InternationalConference on Automated Deduction, pages 238–251. Springer-Verlag,1994.

[2] Alonzo Church. A formulation of the simple theory of types. Journalof Symbolic Logic, 5:56–68, 1940.

[3] The Coq proof assistant. Url: http://coq.inria.fr/.

[4] Thierry Coquand and Arnaud Spiwack. Towards constructive homolog-ical algebra in type theory. In Proceedings of 14th Symposium, Calcule-mus 2007, 6th International Conference, MKM 2007. Springer, 2007.

[5] H. B. Curry. Grundlagen der Kombinatorischen Logik. Amer. J. Math.,52(4):789–834, 1930.

[6] William Fulton. Algebraic topology, volume 153 of Graduate Texts inMathematics. Springer-Verlag, New York, 1995. A first course.

[7] Georges Gonthier. Formal proof—the four-color theorem. NoticesAmer. Math. Soc., 55(11):1382–1393, 2008.

[8] Marvin J. Greenberg. Lectures on algebraic topology. W. A. Benjamin,Inc., New York-Amsterdam, 1967.

[9] Thomas C. Hales. Formal proof. Notices Amer. Math. Soc.,55(11):1370–1380, 2008.

[10] John Harrison. The HOL Light theorem prover. Url:http://www.cl.cam.ac.uk/~jrh13/hol-light/.

[11] John Harrison. Formalized mathematics. Technical Re-port 36, Turku Centre for Computer Science (TUCS), Lem-minkaisenkatu 14 A, FIN-20520 Turku, Finland, 1996. Url:http://www.cl.cam.ac.uk/users/jrh/papers/form-math3.html.

[12] John Harrison. HOL Light tutorial (for ver-sion 2.20). Freely available on the Internet at

93

Bibliography

http://www.cl.cam.ac.uk/~jrh13/hol-light/tutorial_220.pdf,2006.

[13] John Harrison. Formal proof—theory and practice. Notices Amer.Math. Soc., 55(11):1395–1406, 2008.

[14] P. J. Hilton and S. Wylie. Homology theory: An introduction to alge-braic topology. Cambridge University Press, New York, 1960.

[15] (hol4.

[16] Isabelle. Url: http://www.cl.cam.ac.uk/Research/HVG/Isabelle/.

[17] William S. Massey. A basic course in algebraic topology, volume 127 ofGraduate Texts in Mathematics. Springer-Verlag, New York, 1991.

[18] The matita proof assistant. Url: http://matita.cs.unibo.it/.

[19] The Mizar Project. Url: http://web.cs.ualberta.ca/~piotr/Mizar/.

[20] Mizar system. Url: http://mizar.uw.bialystok.pl/.

[21] ProofPower home page. Url: http://www.lemma-one.com/ProofPower/.

[22] C. Raffalli. The PhoX proof assistant.Url: http://www.lama.univ-savoie.fr/~raffalli/phox.html.

[23] Christophe Raffalli and Rene David. Computer assisted teaching inmathematics. In Workshop on 35 years of Automath (Avril 2002, Edin-gurgh), 2002.

[24] Joseph J. Rotman. An introduction to homological algebra. Universi-text. Springer, New York, second edition, 2009.

[25] Julio Rubio and Francis Sergeraert. Constructive algebraic topology.Bull. Sci. Math., 126(5):389–412, 2002.

[26] Francis Sergeraert. The Kenzo program. Url:http://www-fourier.ujf-grenoble.fr/~sergerar/Kenzo/.

[27] I. M. Singer and John A. Thorpe. Lecture notes on elementary topologyand geometry. Scott, Foresman and Co., Glenview, Ill., 1967.

[28] Edwin H. Spanier. Algebraic topology. McGraw-Hill Book Co., NewYork, 1966.

[29] Freek Wiedijk. Comparing mathematical provers. In Andrea As-perti, Bruno Buchberger, and James Davenport, editors, MathematicalKnowledge Management, number 2594 in Lecture Notes on ComputerScience, pages 188–202. Springer, 2003. Proceedings of MKM 2003.

94

Bibliography

[30] Freek Wiedijk. Formal proof—getting started. Notices Amer. Math.Soc., 55(11):1408–1417, 2008.

95