Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
File size: 134,091 Bytes
4365a98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
(*                (c) Copyright, Bill Richter 2013                           *)
(*          Distributed under the same license as HOL Light                  *)
(*                                                                           *)
(* An ongoing readable.ml port of Multivariate/topology.ml with 3 features:  *)
(* 1) A topological space will be an ordered pair Ξ± = (X, L), where L is the *)
(* the set of open sets on X.  topology.ml defines a topological space to be *)
(* just L, and the topspace X is defined as UNIONS L.                        *)
(* 2) Result about Connectiveness, limit points, interior and closure  are   *)
(* first proved for general topological spaces and then specialized to       *)
(* Euclidean space.                                                          *)
(* 3)All general topology theorems using subtopology Ξ± u have antecedent     *)
(* u βŠ‚ topspace Ξ±.                                                           *)
(* The math character ━ is used for DIFF.                                    *)
(* This file, together with from_topology.ml, shows that all of              *)
(* Multivariate/topology.ml is either ported/modified here, or else run on   *)
(* top of this file.                                                         *)
(* Thanks to Vince Aravantinos for improving the proofs of OPEN_BALL,        *)
(* CONNECTED_OPEN_IN_EQ, CONNECTED_CLOSED_IN_EQ and INTERIOR_EQ.             *)

needs "RichterHilbertAxiomGeometry/readable.ml";;
needs "Multivariate/determinants.ml";;

ParseAsInfix("βˆ‰",(11, "right"));;

let NOTIN = NewDefinition `;
  βˆ€a l. a βˆ‰ l ⇔ Β¬(a ∈ l)`;;

let DIFF_UNION = theorem `;
  βˆ€u s t.  u ━ (s βˆͺ t) = (u ━ s) ∩ (u ━ t)
  by set`;;

let DIFF_INTER = theorem `;
  βˆ€u s t.  u ━ (s ∩ t) = (u ━ s) βˆͺ (u ━ t)
  by set`;;

let DIFF_REFL = theorem `;
  βˆ€u t.  t βŠ‚ u β‡’ u ━ (u ━ t) = t
  by set`;;

let DIFF_SUBSET = theorem `;
  βˆ€u s t.  s βŠ‚ t  β‡’  s ━ u βŠ‚ t ━ u
  by set`;;

let DOUBLE_DIFF_UNION = theorem `;
  βˆ€A s t. A ━ s ━ t = A ━ (s βˆͺ t)
  by set`;;

let SUBSET_COMPLEMENT = theorem `;
  βˆ€s t A.  s βŠ‚ A  β‡’  (s βŠ‚ A ━ t ⇔ s ∩ t = βˆ…)
  by set`;;

let COMPLEMENT_DISJOINT = theorem `;
  βˆ€A s t.  s βŠ‚ A  β‡’  (s βŠ‚ t ⇔ s ∩ (A ━ t) = βˆ…)
  by set`;;

let COMPLEMENT_DUALITY = theorem `;
  βˆ€A s t. s βŠ‚ A ∧ t βŠ‚ A  β‡’  (s = t ⇔ A ━ s = A ━ t)
  by set`;;

let COMPLEMENT_DUALITY_UNION = theorem `;
  βˆ€A s t.  s βŠ‚ A ∧ t βŠ‚ A ∧ u βŠ‚ A  β‡’  (s = t βˆͺ u ⇔ A ━ s = (A ━ t) ∩ (A ━ u))
  by set`;;

let SUBSET_DUALITY = theorem `;
  βˆ€s t u.  t βŠ‚ u  β‡’  s ━ u βŠ‚ s ━ t
  by set`;;

let COMPLEMENT_INTER_DIFF = theorem `;
  βˆ€A s t. s βŠ‚ A  β‡’  s ━ t = s ∩ (A ━ t)
  by set`;;

let INTERS_SUBSET = theorem `;
  βˆ€f t. Β¬(f = βˆ…) ∧ (βˆ€s. s ∈ f β‡’ s βŠ‚ t)  β‡’  INTERS f βŠ‚ t
  by set`;;

let IN_SET_FUNCTION_PREDICATE = theorem `;
  βˆ€x f P. x ∈ {f y | P y}  ⇔  βˆƒy. x = f y ∧ P y
  by set`;;

let INTER_TENSOR = theorem `;
  βˆ€s s' t t'.  s βŠ‚ s' ∧ t βŠ‚ t'  β‡’  s ∩ t βŠ‚ s' ∩ t'
  by set`;;

let UNION_TENSOR = theorem `;
  βˆ€s s' t t'.  s βŠ‚ s' ∧ t βŠ‚ t'  β‡’  s βˆͺ t βŠ‚ s' βˆͺ t'
  by set`;;

let ExistsTensorInter = theorem `;
  βˆ€F G H.  (βˆ€x y. F x ∧ G y  β‡’ H (x ∩ y))  β‡’
    (βˆƒx. F x) ∧ (βˆƒy. G y) β‡’ (βˆƒz. H z)
  by fol`;;

let istopology = NewDefinition `;
  istopology (X, L)  ⇔
  (βˆ€U. U ∈ L  β‡’  U βŠ‚ X)  ∧  βˆ… ∈ L  ∧  X ∈ L  ∧
  (βˆ€s t. s ∈ L ∧ t ∈ L  β‡’ s ∩ t ∈ L)  ∧ βˆ€k. k βŠ‚ L  β‡’  UNIONS k ∈ L`;;

let UnderlyingSpace = NewDefinition `;
  UnderlyingSpace Ξ± = FST Ξ±`;;

let OpenSets = NewDefinition `;
  OpenSets Ξ± = SND Ξ±`;;

let ExistsTopology = theorem `;
  βˆ€X. βˆƒΞ±. istopology Ξ±  ∧  UnderlyingSpace Ξ± = X

  proof
    intro_TAC βˆ€X;
    consider L such that L = {U | U βŠ‚ X}     [Lexists] by fol;
    exists_TAC (X, L);
    rewrite istopology IN_ELIM_THM Lexists UnderlyingSpace;
    set;
  qed;
`;;

let topology_tybij_th = theorem `;
  βˆƒt. istopology t
  by fol ExistsTopology`;;

let topology_tybij =
  new_type_definition "topology" ("mk_topology","dest_topology")
  topology_tybij_th;;

let ISTOPOLOGYdest_topology = theorem `;
  βˆ€Ξ±. istopology (dest_topology Ξ±)
  by fol topology_tybij`;;

let OpenIn = NewDefinition `;
  βˆ€Ξ±. open_in Ξ± = OpenSets (dest_topology Ξ±)`;;

let topspace = NewDefinition `;
  βˆ€Ξ±. topspace Ξ± = UnderlyingSpace (dest_topology  Ξ±)`;;

let TopologyPAIR = theorem `;
  βˆ€Ξ±.  dest_topology Ξ± = (topspace Ξ±, open_in Ξ±)
  by rewrite PAIR_EQ OpenIn topspace UnderlyingSpace OpenSets`;;

let Topology_Eq = theorem `;
  βˆ€Ξ± Ξ².  topspace Ξ± =  topspace Ξ²  ∧  (βˆ€U. open_in Ξ± U ⇔ open_in Ξ² U)
    ⇔ Ξ± = Ξ²

  proof
    intro_TAC βˆ€Ξ± Ξ²;
    eq_tac     [Right] by fol;
    intro_TAC H1 H2;
    dest_topology Ξ± = dest_topology Ξ²     [] by simplify TopologyPAIR PAIR_EQ H1 H2 FUN_EQ_THM;
    fol - topology_tybij;
  qed;
`;;

let OpenInCLAUSES = theorem `;
  βˆ€Ξ± X. topspace Ξ± = X  β‡’
    (βˆ€U. open_in Ξ± U  β‡’  U βŠ‚ X)  ∧  open_in Ξ± βˆ…  ∧  open_in Ξ± X  ∧
    (βˆ€s t. open_in Ξ± s ∧ open_in Ξ± t  β‡’ open_in Ξ± (s ∩ t))  ∧
    βˆ€k. (βˆ€s. s ∈ k β‡’ open_in Ξ± s)  β‡’  open_in Ξ± (UNIONS k)

  proof
    intro_TAC βˆ€Ξ± X, H1;
    consider L such that L = open_in Ξ±     [Ldef] by fol;
    istopology (X, L)     [] by fol H1 Ldef TopologyPAIR PAIR_EQ ISTOPOLOGYdest_topology;
    fol Ldef - istopology IN SUBSET;
  qed;
`;;

let OPEN_IN_SUBSET = theorem `;
  βˆ€Ξ± s.  open_in Ξ± s  β‡’  s βŠ‚ topspace Ξ±
  by fol OpenInCLAUSES`;;

let OPEN_IN_EMPTY = theorem `;
  βˆ€Ξ±. open_in Ξ± βˆ…
  by fol OpenInCLAUSES`;;

let OPEN_IN_INTER = theorem `;
  βˆ€Ξ± s t. open_in Ξ± s ∧ open_in Ξ± t  β‡’  open_in Ξ± (s ∩ t)
  by fol OpenInCLAUSES`;;

let OPEN_IN_UNIONS = theorem `;
  βˆ€Ξ± k. (βˆ€s. s ∈ k β‡’ open_in Ξ± s)  β‡’  open_in Ξ± (UNIONS k)
  by fol OpenInCLAUSES`;;

let OpenInTopspace = theorem `;
  βˆ€Ξ±.  open_in Ξ± (topspace Ξ±)
  by fol OpenInCLAUSES`;;

let OPEN_IN_UNION = theorem `;
  βˆ€Ξ± s t. open_in Ξ± s ∧ open_in Ξ± t  β‡’  open_in Ξ± (s βˆͺ t)

  proof
    intro_TAC βˆ€Ξ± s t, H;
    βˆ€x. x ∈ {s, t} ⇔ x = s ∨ x = t     [] by fol IN_INSERT NOT_IN_EMPTY;
    fol - UNIONS_2 H OPEN_IN_UNIONS;
  qed;
`;;

let OPEN_IN_TOPSPACE = theorem `;
  βˆ€Ξ±. open_in Ξ± (topspace Ξ±)
  by fol OpenInCLAUSES`;;

let OPEN_IN_INTERS = theorem `;
  βˆ€Ξ± s. FINITE s ∧ Β¬(s = βˆ…) ∧ (βˆ€t. t ∈ s  β‡’  open_in Ξ± t)
    β‡’ open_in Ξ± (INTERS s)

  proof
    intro_TAC βˆ€Ξ±;
    rewrite IMP_CONJ;
    MATCH_MP_TAC FINITE_INDUCT;
    rewrite INTERS_INSERT NOT_INSERT_EMPTY FORALL_IN_INSERT;
    intro_TAC βˆ€x s, H1, xWorks sWorks;
    assume Β¬(s = βˆ…)     [Nonempty] by simplify INTERS_0 INTER_UNIV xWorks;
    fol xWorks Nonempty H1 sWorks OPEN_IN_INTER;
  qed;
`;;

let OPEN_IN_SUBOPEN = theorem `;
  βˆ€Ξ± s.  open_in Ξ± s ⇔ βˆ€x. x ∈ s β‡’ βˆƒt. open_in Ξ± t ∧ x ∈ t ∧ t βŠ‚ s

  proof
    intro_TAC βˆ€Ξ± s;
    eq_tac     [Left] by set;
    intro_TAC ALLtExist;
    consider f such that
    βˆ€x. x ∈ s  β‡’  open_in Ξ± (f x) ∧ x ∈ f x ∧ f x βŠ‚ s     [fExists] by fol ALLtExist SKOLEM_THM_GEN;
    s = UNIONS (IMAGE f s)     [] by set -;
    fol - fExists FORALL_IN_IMAGE OPEN_IN_UNIONS;
  qed;
`;;

let closed_in = NewDefinition `;
  βˆ€Ξ± s.  closed_in Ξ± s  ⇔
      s βŠ‚ topspace Ξ± ∧ open_in Ξ± (topspace Ξ± ━ s)`;;

let CLOSED_IN_SUBSET = theorem `;
  βˆ€Ξ± s. closed_in Ξ± s   β‡’  s βŠ‚ topspace Ξ±
  by fol closed_in`;;

let CLOSED_IN_EMPTY = theorem `;
  βˆ€Ξ±. closed_in Ξ± βˆ…
  by fol closed_in EMPTY_SUBSET DIFF_EMPTY OPEN_IN_TOPSPACE`;;

let CLOSED_IN_TOPSPACE = theorem `;
  βˆ€Ξ±. closed_in Ξ± (topspace Ξ±)
  by fol closed_in SUBSET_REFL DIFF_EQ_EMPTY OPEN_IN_EMPTY`;;

let CLOSED_IN_UNION = theorem `;
  βˆ€Ξ± s t. closed_in Ξ± s ∧ closed_in Ξ± t  β‡’  closed_in Ξ± (s βˆͺ t)

  proof
    intro_TAC βˆ€Ξ± s t, Hst;
    fol Hst closed_in DIFF_UNION UNION_SUBSET OPEN_IN_INTER;
  qed;
`;;

let CLOSED_IN_INTERS = theorem `;
  βˆ€Ξ± k.  Β¬(k = βˆ…) ∧ (βˆ€s. s ∈ k β‡’ closed_in Ξ± s)  β‡’  closed_in Ξ± (INTERS k)

  proof
    intro_TAC βˆ€Ξ± k, H1 H2;
    consider X such that X = topspace Ξ±     [Xdef] by fol;
    simplify GSYM Xdef closed_in DIFF_INTERS SIMPLE_IMAGE;
    fol H1 H2 Xdef INTERS_SUBSET closed_in FORALL_IN_IMAGE OPEN_IN_UNIONS;
  qed;
`;;

let CLOSED_IN_FORALL_IN = theorem `;
  βˆ€Ξ± P Q.  Β¬(P = βˆ…) ∧ (βˆ€a. P a β‡’ closed_in Ξ± {x | Q a x})  β‡’
    closed_in Ξ± {x | βˆ€a. P a β‡’ Q a x}

  proof
    intro_TAC βˆ€Ξ± P Q, Pnonempty H1;
    consider f such that f = {{x | Q a x} | P a}     [fDef] by fol;
    Β¬(f = βˆ…)     [fNonempty] by set fDef Pnonempty;
    (βˆ€a. P a β‡’ closed_in Ξ± {x | Q a x})  ⇔  (βˆ€s. s ∈ f β‡’ closed_in Ξ± s)     [] by simplify fDef FORALL_IN_GSPEC;
    closed_in Ξ± (INTERS f)     [] by fol fNonempty H1 - CLOSED_IN_INTERS;
    MP_TAC -;
    {x | βˆ€a. P a β‡’ x ∈ {x | Q a x}} = {x | βˆ€a. P a β‡’ Q a x}     [] by set;
    simplify fDef INTERS_GSPEC -;
  qed;
`;;

let CLOSED_IN_INTER = theorem `;
  βˆ€Ξ± s t. closed_in Ξ± s ∧ closed_in Ξ± t β‡’ closed_in Ξ± (s ∩ t)

  proof
    intro_TAC βˆ€Ξ± s t, Hs Ht;
    rewrite GSYM INTERS_2;
    MATCH_MP_TAC CLOSED_IN_INTERS;
    set Hs Ht;
  qed;
`;;

let OPEN_IN_CLOSED_IN_EQ = theorem `;
  βˆ€Ξ± s. open_in Ξ± s  ⇔  s βŠ‚ topspace Ξ± ∧ closed_in Ξ± (topspace Ξ± ━ s)

  proof
    intro_TAC βˆ€Ξ± s;
    simplify closed_in SUBSET_DIFF OPEN_IN_SUBSET;
    fol SET_RULE [X ━ (X ━ s) = X ∩ s  ∧  (s βŠ‚ X β‡’ X ∩ s = s)] OPEN_IN_SUBSET;
  qed;
`;;

let OPEN_IN_CLOSED_IN = theorem `;
  βˆ€s. s βŠ‚ topspace Ξ±
    β‡’ (open_in Ξ± s ⇔ closed_in Ξ± (topspace Ξ± ━ s))
  by fol OPEN_IN_CLOSED_IN_EQ`;;

let OPEN_IN_DIFF = theorem `;
  βˆ€Ξ± s t.  open_in Ξ± s ∧ closed_in Ξ± t  β‡’  open_in Ξ± (s ━ t)

  proof
    intro_TAC βˆ€Ξ± s t, H1 H2;
    consider X such that X = topspace Ξ±     [Xdef] by fol;
    fol COMPLEMENT_INTER_DIFF OPEN_IN_SUBSET - H1 H2 closed_in OPEN_IN_INTER;
  qed;
`;;

let CLOSED_IN_DIFF = theorem `;
  βˆ€Ξ± s t.  closed_in Ξ± s ∧ open_in Ξ± t  β‡’  closed_in Ξ± (s ━ t)

  proof
    intro_TAC βˆ€Ξ± s t, H1 H2;
    consider X such that X = topspace Ξ±     [Xdef] by fol;
    fol COMPLEMENT_INTER_DIFF H1 - OPEN_IN_SUBSET SUBSET_DIFF DIFF_REFL H2 closed_in CLOSED_IN_INTER;
  qed;
`;;

let CLOSED_IN_UNIONS = theorem `;
  βˆ€Ξ± s.  FINITE s ∧ (βˆ€t. t ∈ s β‡’ closed_in Ξ± t)
    β‡’ closed_in Ξ± (UNIONS s)

  proof
    intro_TAC βˆ€Ξ±;
    rewrite IMP_CONJ;
    MATCH_MP_TAC FINITE_INDUCT;
    fol UNIONS_INSERT UNIONS_0 CLOSED_IN_EMPTY IN_INSERT CLOSED_IN_UNION;
  qed;
`;;

let subtopology = NewDefinition `;
  βˆ€Ξ± u.  subtopology Ξ± u = mk_topology (u, {s ∩ u | open_in Ξ± s})`;;

let IstopologySubtopology = theorem `;
  βˆ€Ξ± u:A->bool. u βŠ‚ topspace Ξ±  β‡’  istopology (u, {s ∩ u | open_in Ξ± s})

  proof
    intro_TAC βˆ€Ξ± u, H1;
    βˆ… = βˆ… ∩ u ∧ open_in Ξ± βˆ…     [emptysetOpen] by fol INTER_EMPTY OPEN_IN_EMPTY;
    u = topspace α ∩ u ∧ open_in α (topspace α)     [uOpen] by fol OPEN_IN_TOPSPACE H1 INTER_COMM SUBSET_INTER_ABSORPTION;
    βˆ€s' s. open_in Ξ± s' ∧ open_in Ξ± s  β‡’  open_in Ξ± (s' ∩ s)  ∧
    (s' ∩ u) ∩ (s ∩ u) = (s' ∩ s) ∩ u     [interOpen]
    proof
      intro_TAC βˆ€s' s, H1 H2;
      set MESON [H1; H2; OPEN_IN_INTER] [open_in α (s' ∩ s)];
    qed;
    βˆ€k. k βŠ‚ {s | open_in Ξ± s}  β‡’  open_in Ξ± (UNIONS k)  ∧
    UNIONS (IMAGE (λs. s ∩ u) k) = (UNIONS k) ∩ u     [unionsOpen]
    proof
      intro_TAC βˆ€k, kProp;
      open_in Ξ± (UNIONS k)     [] by fol kProp SUBSET IN_ELIM_THM OPEN_IN_UNIONS;
      simplify - UNIONS_IMAGE UNIONS_GSPEC INTER_UNIONS;
    qed;
    {s ∩ u | open_in α s} = IMAGE (λs. s ∩ u) {s | open_in α s}     [] by set;
    simplify istopology IN_SET_FUNCTION_PREDICATE LEFT_IMP_EXISTS_THM INTER_SUBSET - FORALL_SUBSET_IMAGE;
    fol  emptysetOpen uOpen interOpen unionsOpen;
  qed;
`;;

let OpenInSubtopology = theorem `;
  βˆ€Ξ± u s. u βŠ‚ topspace Ξ± β‡’
    (open_in (subtopology Ξ± u) s  ⇔  βˆƒt. open_in Ξ± t ∧ s = t ∩ u)

  proof
    intro_TAC βˆ€Ξ± u s, H1;
    open_in (subtopology α u) = OpenSets (u,{s ∩ u | open_in α s})     [] by fol subtopology H1 IstopologySubtopology topology_tybij OpenIn;
    rewrite - OpenSets PAIR_EQ SND EXTENSION IN_ELIM_THM;
  qed;
`;;

let TopspaceSubtopology = theorem `;
  βˆ€Ξ± u. u βŠ‚ topspace Ξ±  β‡’  topspace (subtopology Ξ± u) = u

  proof
    intro_TAC βˆ€Ξ± u , H1;
    topspace (subtopology α u) = UnderlyingSpace (u,{s ∩ u | open_in α s})     [] by fol subtopology H1 IstopologySubtopology topology_tybij topspace;
    rewrite - UnderlyingSpace PAIR_EQ FST;
    fol  INTER_COMM H1 SUBSET_INTER_ABSORPTION;
  qed;
`;;

let OpenInRefl = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  open_in (subtopology Ξ± s) s
  by fol TopspaceSubtopology OPEN_IN_TOPSPACE`;;

let ClosedInRefl = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  closed_in (subtopology Ξ± s) s
  by fol TopspaceSubtopology CLOSED_IN_TOPSPACE`;;

let ClosedInSubtopology = theorem `;
  βˆ€Ξ± u C.  u βŠ‚ topspace Ξ±  β‡’
    (closed_in (subtopology Ξ± u) C  ⇔  βˆƒD. closed_in Ξ± D ∧ C = D ∩ u)

  proof
    intro_TAC βˆ€Ξ± u C, H1;
    consider X such that
    X = topspace Ξ± ∧ u βŠ‚ X     [Xdef] by fol H1;
    closed_in (subtopology Ξ± u) C  ⇔
    βˆƒt. C βŠ‚ u ∧ t βŠ‚ X ∧ open_in Ξ± t ∧ u ━ C = t ∩ u     [] by fol closed_in H1 Xdef OpenInSubtopology OPEN_IN_SUBSET TopspaceSubtopology;
    closed_in (subtopology Ξ± u) C  ⇔
    βˆƒD. C βŠ‚ u ∧ D βŠ‚ X ∧ open_in Ξ± (X ━ D) ∧ u ━ C = (X ━ D) ∩ u     []
    proof
      rewrite -;
      eq_tac     [Left]
      proof
        STRIP_TAC;     exists_TAC X ━ t;
        ASM_SIMP_TAC H1 OPEN_IN_SUBSET DIFF_REFL SUBSET_DIFF;
      qed;
      STRIP_TAC;     exists_TAC X ━ D;
      ASM_SIMP_TAC SUBSET_DIFF;
    qed;
    simplify - GSYM Xdef H1 closed_in;
    βˆ€D C. C βŠ‚ u ∧ u ━ C = (X ━ D) ∩ u  ⇔  C = D ∩ u     [] by set Xdef DIFF_REFL INTER_SUBSET;
    fol -;
  qed;
`;;

let OPEN_IN_SUBTOPOLOGY_EMPTY = theorem `;
  βˆ€Ξ± s. open_in (subtopology Ξ± βˆ…) s  ⇔  s = βˆ…

  proof
    simplify EMPTY_SUBSET OpenInSubtopology INTER_EMPTY;
    fol  OPEN_IN_EMPTY;
  qed;
`;;

let CLOSED_IN_SUBTOPOLOGY_EMPTY = theorem `;
  βˆ€Ξ± s. closed_in (subtopology Ξ± βˆ…) s  ⇔  s = βˆ…

  proof
    simplify EMPTY_SUBSET ClosedInSubtopology INTER_EMPTY;
    fol  CLOSED_IN_EMPTY;
  qed;
`;;

let SUBTOPOLOGY_TOPSPACE = theorem `;
  βˆ€Ξ±. subtopology Ξ± (topspace Ξ±) = Ξ±

  proof
    intro_TAC βˆ€Ξ±;
    topspace (subtopology Ξ± (topspace Ξ±)) = topspace Ξ±     [topXsub] by simplify SUBSET_REFL TopspaceSubtopology;
    simplify topXsub GSYM Topology_Eq;
    fol MESON [SUBSET_REFL] [topspace Ξ± βŠ‚ topspace Ξ±] OpenInSubtopology OPEN_IN_SUBSET SUBSET_INTER_ABSORPTION;
  qed;
`;;

let OpenInImpSubset = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  β‡’
    open_in (subtopology Ξ± s) t  β‡’  t βŠ‚ s
  by fol OpenInSubtopology INTER_SUBSET`;;

let ClosedInImpSubset = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  β‡’
    closed_in (subtopology Ξ± s) t  β‡’  t βŠ‚ s
  by fol ClosedInSubtopology INTER_SUBSET`;;

let OpenInSubtopologyUnion = theorem `;
  βˆ€Ξ± s t u.  t βŠ‚ topspace Ξ±  ∧  u βŠ‚ topspace Ξ±  β‡’
    open_in (subtopology α t) s  ∧  open_in (subtopology α u) s
    β‡’  open_in (subtopology Ξ± (t βˆͺ u)) s

  proof
    intro_TAC βˆ€Ξ± s t u, Ht Hu;
    simplify Ht Hu Ht Hu UNION_SUBSET OpenInSubtopology;
    intro_TAC sOpenSub_t sOpenSub_u;
    consider a b such that
    open_in α a  ∧  s = a ∩ t  ∧
    open_in α b  ∧  s = b ∩ u     [abExist] by fol sOpenSub_t sOpenSub_u;
    exists_TAC a ∩ b;
    set MESON [abExist; OPEN_IN_INTER] [open_in α (a ∩ b)] abExist;
  qed;
`;;

let ClosedInSubtopologyUnion = theorem `;
  βˆ€Ξ± s t u.  t βŠ‚ topspace Ξ±  ∧  u βŠ‚ topspace Ξ±  β‡’
    closed_in (subtopology α t) s  ∧  closed_in (subtopology α u) s
    β‡’  closed_in (subtopology Ξ± (t βˆͺ u)) s

  proof
    intro_TAC βˆ€Ξ± s t u, Ht Hu;
    simplify Ht Hu Ht Hu UNION_SUBSET ClosedInSubtopology;
    intro_TAC sClosedSub_t sClosedSub_u;
    consider a b such that
    closed_in α a  ∧  s = a ∩ t  ∧
    closed_in α b  ∧  s = b ∩ u     [abExist] by fol sClosedSub_t sClosedSub_u;
    exists_TAC a ∩ b;
    set MESON [abExist; CLOSED_IN_INTER] [closed_in α (a ∩ b)] abExist;
  qed;
`;;

let OpenInSubtopologyInterOpen = theorem `;
  βˆ€Ξ± s t u.  u βŠ‚ topspace Ξ±  β‡’
    open_in (subtopology α u) s  ∧  open_in α t
    β‡’ open_in (subtopology Ξ± u) (s ∩ t)

  proof
    intro_TAC βˆ€Ξ± s t u, H1, sOpenSub_t tOpen;
    consider a b such that
    open_in α a  ∧  s = a ∩ u  ∧  b = a ∩ t     [aExists] by fol sOpenSub_t H1 OpenInSubtopology;
    fol - tOpen OPEN_IN_INTER INTER_ACI H1 OpenInSubtopology;
  qed;
`;;

let OpenInOpenInter = theorem `;
  βˆ€Ξ± u s.  u βŠ‚ topspace Ξ±  β‡’ open_in Ξ± s
    β‡’  open_in (subtopology Ξ± u) (u ∩ s)
  by fol INTER_COMM OpenInSubtopology`;;

let OpenOpenInTrans = theorem `;
  βˆ€Ξ± s t.  open_in Ξ± s ∧ open_in Ξ± t ∧ t βŠ‚ s
    β‡’ open_in (subtopology Ξ± s) t
  by fol OPEN_IN_SUBSET SUBSET_INTER_ABSORPTION OpenInSubtopology`;;

let ClosedClosedInTrans = theorem `;
  βˆ€Ξ± s t.  closed_in Ξ± s ∧ closed_in Ξ± t ∧ t βŠ‚ s
    β‡’ closed_in (subtopology Ξ± s) t
  by fol CLOSED_IN_SUBSET SUBSET_INTER_ABSORPTION ClosedInSubtopology`;;

let OpenSubset = theorem `;
  βˆ€Ξ± s t.  t βŠ‚ topspace Ξ±  β‡’
    s βŠ‚ t  ∧  open_in Ξ± s β‡’ open_in (subtopology Ξ± t) s
  by fol OpenInSubtopology SUBSET_INTER_ABSORPTION`;;

let ClosedSubsetEq = theorem `;
  βˆ€Ξ± u s.  u βŠ‚ topspace Ξ±  β‡’
    closed_in Ξ± s  β‡’  (closed_in (subtopology Ξ± u) s  ⇔  s βŠ‚ u)
  by fol ClosedInSubtopology INTER_SUBSET SUBSET_INTER_ABSORPTION`;;

let ClosedInInterClosed = theorem `;
  βˆ€Ξ± s t u.  u βŠ‚ topspace Ξ±  β‡’
        closed_in (subtopology α u) s ∧ closed_in α t
        β‡’ closed_in (subtopology Ξ± u) (s ∩ t)

  proof
    intro_TAC βˆ€Ξ± s t u, H1, sClosedSub_t tClosed;
    consider a b such that
    closed_in α a  ∧  s = a ∩ u  ∧  b = a ∩ t     [aExists] by fol sClosedSub_t H1 ClosedInSubtopology;
    fol - tClosed CLOSED_IN_INTER INTER_ACI H1 ClosedInSubtopology;
  qed;
`;;

let ClosedInClosedInter = theorem `;
  βˆ€Ξ± u s.  u βŠ‚ topspace Ξ±  β‡’
    closed_in Ξ± s  β‡’  closed_in (subtopology Ξ± u) (u ∩ s)
  by fol INTER_COMM ClosedInSubtopology`;;

let ClosedSubset = theorem `;
  βˆ€Ξ± s t.  t βŠ‚ topspace Ξ±  β‡’
    s βŠ‚ t  ∧  closed_in Ξ± s  β‡’  closed_in (subtopology Ξ± t) s
  by fol ClosedInSubtopology SUBSET_INTER_ABSORPTION`;;

let OpenInSubsetTrans = theorem `;
  βˆ€Ξ± s t u.  u βŠ‚ topspace Ξ±  ∧  t βŠ‚ topspace Ξ±  β‡’
    open_in (subtopology Ξ± u) s  ∧  s βŠ‚ t  ∧  t βŠ‚ u
    β‡’ open_in (subtopology Ξ± t) s

  proof
    intro_TAC βˆ€Ξ± s t u, uSubset tSubset;
    simplify uSubset tSubset OpenInSubtopology;
    intro_TAC sOpen_u s_t t_u;
    consider a such that
    open_in α a  ∧  s = a ∩ u     [aExists] by fol uSubset sOpen_u OpenInSubtopology;
    set aExists s_t t_u;
  qed;
`;;

let ClosedInSubsetTrans = theorem `;
  βˆ€Ξ± s t u.  u βŠ‚ topspace Ξ±  ∧  t βŠ‚ topspace Ξ±  β‡’
        closed_in (subtopology Ξ± u) s  ∧  s βŠ‚ t  ∧  t βŠ‚ u
        β‡’ closed_in (subtopology Ξ± t) s

  proof
    intro_TAC βˆ€Ξ± s t u, uSubset tSubset;
    simplify uSubset tSubset ClosedInSubtopology;
    intro_TAC sClosed_u s_t t_u;
    consider a such that
    closed_in α a  ∧  s = a ∩ u     [aExists] by fol uSubset sClosed_u ClosedInSubtopology;
    set aExists s_t t_u;
  qed;
`;;

let OpenInTrans = theorem `;
  βˆ€Ξ± s t u.  t βŠ‚ topspace Ξ±  ∧  u βŠ‚ topspace Ξ±  β‡’
    open_in (subtopology α t) s   ∧  open_in (subtopology α u) t
    β‡’ open_in (subtopology Ξ± u) s

  proof
    intro_TAC βˆ€Ξ± s t u, H1 H2;
    simplify H1 H2 OpenInSubtopology;
    fol H1 H2 OpenInSubtopology OPEN_IN_INTER INTER_ASSOC;
  qed;
`;;

let OpenInTransEq = theorem `;
  βˆ€Ξ± s t.  t βŠ‚ topspace Ξ±  ∧  s βŠ‚ topspace Ξ±  β‡’
    ((βˆ€u. open_in (subtopology Ξ± t) u  β‡’  open_in (subtopology Ξ± s) t)
    ⇔ open_in (subtopology Ξ± s) t)
  by fol OpenInTrans OpenInRefl`;;

let OpenInOpenTrans = theorem `;
  βˆ€Ξ± u s.  u βŠ‚ topspace Ξ±  β‡’
    open_in (subtopology Ξ± u) s ∧ open_in Ξ± u  β‡’  open_in Ξ± s
  by fol OpenInSubtopology OPEN_IN_INTER`;;

let OpenInSubtopologyTrans = theorem `;
  βˆ€Ξ± s t u.  t βŠ‚ topspace Ξ±  ∧  u βŠ‚ topspace Ξ±  β‡’
    open_in (subtopology α t) s  ∧  open_in (subtopology α u) t
    β‡’ open_in (subtopology Ξ± u) s

  proof
    simplify OpenInSubtopology;
    fol  OPEN_IN_INTER INTER_ASSOC;
  qed;
`;;

let SubtopologyOpenInSubopen = theorem `;
  βˆ€Ξ± u s.  u βŠ‚ topspace Ξ± β‡’
    (open_in (subtopology Ξ± u) s  ⇔
    s βŠ‚ u  ∧  βˆ€x. x ∈ s β‡’ βˆƒt. open_in Ξ± t  ∧  x ∈ t  ∧  t ∩ u βŠ‚ s)

  proof
    intro_TAC βˆ€Ξ± u s, H1;
    rewriteL OPEN_IN_SUBOPEN;
    simplify H1 OpenInSubtopology;
    eq_tac     [Right] by fol SUBSET IN_INTER;
    intro_TAC H2;
    conj_tac     [Left]
    proof     simplify SUBSET;     fol H2 IN_INTER;     qed;
    intro_TAC βˆ€x, xs;
    consider t such that
    open_in Ξ± t ∧ x ∈ t ∩ u ∧ t ∩ u βŠ‚ s     [tExists] by fol H2 xs;
    fol  - IN_INTER;
  qed;
`;;

let ClosedInSubtopologyTrans = theorem `;
  βˆ€Ξ± s t u.  t βŠ‚ topspace Ξ±  ∧  u βŠ‚ topspace Ξ±  β‡’
    closed_in (subtopology α t) s  ∧  closed_in (subtopology α u) t
    β‡’ closed_in (subtopology Ξ± u) s

  proof
    simplify ClosedInSubtopology;
    fol  CLOSED_IN_INTER INTER_ASSOC;
  qed;
`;;

let ClosedInSubtopologyTransEq = theorem `;
  βˆ€Ξ± s t.  t βŠ‚ topspace Ξ±  ∧  s βŠ‚ topspace Ξ±  β‡’
    ((βˆ€u. closed_in (subtopology Ξ± t) u  β‡’  closed_in (subtopology Ξ± s) t)
    ⇔ closed_in (subtopology Ξ± s) t)

  proof
    intro_TAC βˆ€Ξ± s t, H1 H2;
    fol H1 H2 ClosedInSubtopologyTrans CLOSED_IN_TOPSPACE;
  qed;
`;;

let ClosedInClosedTrans = theorem `;
  βˆ€Ξ± s t.  u βŠ‚ topspace Ξ±  β‡’
    closed_in (subtopology Ξ± u) s ∧ closed_in Ξ± u β‡’ closed_in Ξ± s
  by fol ClosedInSubtopology CLOSED_IN_INTER`;;

let OpenInSubtopologyInterSubset = theorem `;
  βˆ€Ξ± s u v.  u βŠ‚ topspace Ξ±  ∧  v βŠ‚ topspace Ξ±  β‡’
    open_in (subtopology Ξ± u) (u ∩ s)  ∧  v βŠ‚ u
    β‡’ open_in (subtopology Ξ± v) (v ∩ s)

  proof
    simplify OpenInSubtopology;
    set;
  qed;
`;;

let OpenInOpenEq = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  β‡’
    open_in Ξ± s  β‡’  (open_in (subtopology Ξ± s) t  ⇔  open_in Ξ± t ∧ t βŠ‚ s)
  by fol OpenOpenInTrans OPEN_IN_SUBSET TopspaceSubtopology OpenInOpenTrans`;;

let ClosedInClosedEq = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  β‡’  closed_in Ξ± s  β‡’
    (closed_in (subtopology Ξ± s) t  ⇔  closed_in Ξ± t ∧ t βŠ‚ s)
  by fol ClosedClosedInTrans CLOSED_IN_SUBSET TopspaceSubtopology ClosedInClosedTrans`;;

let OpenImpliesSubtopologyInterOpen = theorem `;
  βˆ€Ξ± u s.  u βŠ‚ topspace Ξ±  β‡’
    open_in Ξ± s  β‡’  open_in (subtopology Ξ± u) (u ∩ s)
    by fol OpenInSubtopology INTER_COMM`;;

let OPEN_IN_EXISTS_IN = theorem `;
  βˆ€Ξ± P Q.  (βˆ€a. P a β‡’ open_in Ξ± {x | Q a x})  β‡’
    open_in Ξ± {x | βˆƒa. P a ∧ Q a x}

  proof
    intro_TAC βˆ€Ξ± P Q, H1;
    consider f such that f = {{x | Q a x} | P a}     [fDef] by fol;
    (βˆ€a. P a β‡’ open_in Ξ± {x | Q a x})  ⇔  (βˆ€s. s ∈ f β‡’ open_in Ξ± s)     [] by simplify fDef FORALL_IN_GSPEC;
    MP_TAC MESON [H1; -; OPEN_IN_UNIONS] [open_in Ξ±  (UNIONS f)];
    simplify fDef UNIONS_GSPEC;
    set;
  qed;
`;;

let Connected_DEF = NewDefinition `;
  βˆ€Ξ±. Connected Ξ± ⇔
    Β¬(βˆƒe1 e2. open_in Ξ± e1  ∧  open_in Ξ± e2  ∧  topspace Ξ± = e1 βˆͺ e2  ∧
    e1 ∩ e2 = βˆ…  ∧  Β¬(e1 = βˆ…)  ∧  Β¬(e2 = βˆ…))`;;

let ConnectedClosedHelp = theorem `;
  βˆ€Ξ± e1 e2. topspace Ξ± = e1 βˆͺ e2  ∧  e1 ∩ e2 = βˆ…  β‡’
    (closed_in Ξ± e1  ∧  closed_in Ξ± e2  ⇔  open_in Ξ± e1  ∧  open_in Ξ± e2)

  proof
    intro_TAC βˆ€Ξ± e1 e2, H1 H2;
    e1 = topspace Ξ± ━ e2  ∧  e2 = topspace Ξ± ━ e1     [e12Complements] by set H1 H2;
    fol H1 SUBSET_UNION e12Complements OPEN_IN_CLOSED_IN_EQ;
  qed;
`;;

let ConnectedClosed = theorem `;
  βˆ€Ξ±. Connected Ξ±  ⇔
    Β¬(βˆƒe1 e2. closed_in Ξ± e1  ∧  closed_in Ξ± e2  ∧
    topspace Ξ± = e1 βˆͺ e2  ∧  e1 ∩ e2 = βˆ…  ∧  Β¬(e1 = βˆ…) ∧ Β¬(e2 = βˆ…))

  proof
    rewrite Connected_DEF;
    fol ConnectedClosedHelp;
  qed;
`;;

let ConnectedOpenIn = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    (Connected (subtopology Ξ± s)  ⇔  Β¬(βˆƒe1 e2.
    open_in (subtopology α s) e1  ∧  open_in (subtopology α s) e2  ∧
    s βŠ‚ e1 βˆͺ e2  ∧  e1 ∩ e2 = βˆ…  ∧  Β¬(e1 = βˆ…)  ∧  Β¬(e2 = βˆ…)))

  proof
    simplify Connected_DEF TopspaceSubtopology;
    fol SUBSET_REFL OpenInImpSubset UNION_SUBSET SUBSET_ANTISYM;
  qed;
`;;

let ConnectedClosedIn = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    (Connected (subtopology Ξ± s)  ⇔  Β¬(βˆƒe1 e2.
    closed_in (subtopology α s) e1  ∧  closed_in (subtopology α s) e2  ∧
    s βŠ‚ e1 βˆͺ e2  ∧  e1 ∩ e2 = βˆ…  ∧  Β¬(e1 = βˆ…)  ∧  Β¬(e2 = βˆ…)))

  proof
    simplify ConnectedClosed TopspaceSubtopology;
    fol SUBSET_REFL ClosedInImpSubset UNION_SUBSET SUBSET_ANTISYM;
  qed;
`;;

let ConnectedSubtopology = theorem `;
  βˆ€Ξ± s. s βŠ‚ topspace Ξ±  β‡’
    (Connected (subtopology Ξ± s)  ⇔
    Β¬(βˆƒe1 e2. open_in Ξ± e1  ∧  open_in Ξ± e2  ∧  s βŠ‚ e1 βˆͺ e2  ∧
    e1 ∩ e2 ∩ s = βˆ…  ∧  Β¬(e1 ∩ s = βˆ…)  ∧  Β¬(e2 ∩ s = βˆ…)))

  proof
    intro_TAC βˆ€Ξ± s, H1;
    simplify H1 Connected_DEF OpenInSubtopology TopspaceSubtopology;
    AP_TERM_TAC;
    eq_tac     [Left]
    proof
    intro_TAC H2;
    consider t1 t2 such that
    open_in Ξ± t1  ∧  open_in Ξ± t2  ∧  s = (t1 ∩ s) βˆͺ (t2 ∩ s)  ∧
    (t1 ∩ s) ∩ (t2 ∩ s) = βˆ…  ∧  Β¬(t1 ∩ s = βˆ…)  ∧  Β¬(t2 ∩ s = βˆ…)     [t12Exist] by fol H2;
    s βŠ‚ t1 βˆͺ t2  ∧  t1 ∩ t2 ∩ s = βˆ…     [] by set t12Exist;
    fol t12Exist -;
    qed;
    rewrite LEFT_IMP_EXISTS_THM;
    intro_TAC βˆ€e1 e2, e12Exist;
    exists_TAC e1 ∩ s;
    exists_TAC e2 ∩ s;
    set e12Exist;
  qed;
`;;

let ConnectedSubtopology_ALT = theorem `;
  βˆ€Ξ± s. s βŠ‚ topspace Ξ±  β‡’
    (Connected (subtopology Ξ± s)  ⇔
    βˆ€e1 e2. open_in Ξ± e1  ∧  open_in Ξ± e2  ∧
    s βŠ‚ e1 βˆͺ e2  ∧  e1 ∩ e2 ∩ s = βˆ…
    β‡’ e1 ∩ s = βˆ…  ∨  e2 ∩ s = βˆ…)

  proof     simplify ConnectedSubtopology;     fol;     qed;
`;;

let ConnectedClosedSubtopology = theorem `;
  βˆ€Ξ± s. s βŠ‚ topspace Ξ±  β‡’
    (Connected (subtopology Ξ± s)  ⇔
    Β¬(βˆƒe1 e2. closed_in Ξ± e1  ∧  closed_in Ξ± e2  ∧  s βŠ‚ e1 βˆͺ e2  ∧
    e1 ∩ e2 ∩ s = βˆ…  ∧  Β¬(e1 ∩ s = βˆ…)  ∧  Β¬(e2 ∩ s = βˆ…)))

  proof
    intro_TAC βˆ€Ξ± s, H1;
    simplify H1 ConnectedSubtopology;
    AP_TERM_TAC;
    eq_tac     [Left]
    proof
      rewrite LEFT_IMP_EXISTS_THM;
      intro_TAC βˆ€e1 e2, e12Exist;
      exists_TAC topspace Ξ± ━ e2;
      exists_TAC topspace Ξ± ━ e1;
      simplify OPEN_IN_SUBSET H1 SUBSET_DIFF DIFF_REFL closed_in e12Exist;
      set H1 e12Exist;
    qed;
    rewrite LEFT_IMP_EXISTS_THM;
    intro_TAC βˆ€e1 e2, e12Exist;
    exists_TAC topspace Ξ± ━ e2;
    exists_TAC topspace Ξ± ━ e1;
    e1 βŠ‚ topspace Ξ±  ∧  e2 βŠ‚ topspace Ξ±     [e12Top] by fol closed_in e12Exist;
    simplify DIFF_REFL SUBSET_DIFF e12Top OPEN_IN_CLOSED_IN;
    set H1 e12Exist;
  qed;
`;;

let ConnectedClosedSubtopology_ALT = theorem `;
  βˆ€Ξ± s. s βŠ‚ topspace Ξ±  β‡’
    (Connected (subtopology Ξ± s)  ⇔
    βˆ€e1 e2. closed_in Ξ± e1  ∧  closed_in Ξ± e2  ∧
    s βŠ‚ e1 βˆͺ e2  ∧  e1 ∩ e2 ∩ s = βˆ…
     β‡’ e1 ∩ s = βˆ…  ∨  e2 ∩ s = βˆ…)

  proof     simplify ConnectedClosedSubtopology;     fol;     qed;
`;;

let ConnectedClopen = theorem `;
  βˆ€Ξ±. Connected Ξ±  ⇔
    βˆ€t. open_in Ξ± t ∧ closed_in Ξ± t  β‡’  t = βˆ… ∨ t = topspace Ξ±

  proof
    intro_TAC βˆ€Ξ±;
    simplify Connected_DEF closed_in TAUT [(Β¬a ⇔ b) ⇔ (a ⇔ Β¬b)] NOT_FORALL_THM NOT_IMP DE_MORGAN_THM;
    eq_tac     [Left]
    proof
      rewrite LEFT_IMP_EXISTS_THM;     intro_TAC βˆ€e1 e2, H1 H2 H3 H4 H5 H6;
      exists_TAC e1;
      e1 βŠ‚ topspace Ξ±  ∧  e2 = topspace Ξ± ━ e1  ∧  Β¬(e1 = topspace alpha)     [] by set H3 H4 H6;
      fol H1 - H2 H5;
    qed;
    rewrite LEFT_IMP_EXISTS_THM;     intro_TAC βˆ€t, H1;
    exists_TAC t;     exists_TAC topspace Ξ± ━ t;
    set H1;
  qed;
`;;

let ConnectedClosedSet = theorem `;
  βˆ€Ξ± s. s βŠ‚ topspace Ξ±  β‡’  closed_in Ξ± s  β‡’
    (Connected (subtopology Ξ± s)  ⇔  Β¬(βˆƒe1 e2.
    closed_in α e1  ∧  closed_in α e2  ∧
    Β¬(e1 = βˆ…)  ∧  Β¬(e2 = βˆ…)  ∧  e1 βˆͺ e2 = s  ∧  e1 ∩ e2 = βˆ…))

  proof
    intro_TAC βˆ€Ξ± s, H1, H2;
    simplify H1 ConnectedClosedSubtopology;
    AP_TERM_TAC;
    eq_tac     [Left]
    proof
      rewrite LEFT_IMP_EXISTS_THM;     intro_TAC βˆ€e1 e2, H3 H4 H5 H6 H7 H8;
      exists_TAC e1 ∩ s;     exists_TAC e2 ∩ s;
      simplify H2 H3 H4 H7 H8 CLOSED_IN_INTER;
      set H5 H6;
    qed;
    rewrite LEFT_IMP_EXISTS_THM;     intro_TAC βˆ€e1 e2, H3 H4 H5 H6 H7 H8;
    exists_TAC e1;     exists_TAC e2;
    set H3 H4 H7 H8 H5 H6;
  qed;
`;;

let ConnectedOpenSet = theorem `;
  βˆ€Ξ± s.  open_in Ξ± s  β‡’
    (Connected (subtopology Ξ± s) ⇔
    Β¬(βˆƒe1 e2.  open_in Ξ± e1  ∧  open_in Ξ± e2  ∧
    Β¬(e1 = βˆ…)  ∧  Β¬(e2 = βˆ…)  ∧  e1 βˆͺ e2 = s  ∧  e1 ∩ e2 = βˆ…))

  proof
    intro_TAC βˆ€Ξ± s, H1;
    simplify H1 OPEN_IN_SUBSET ConnectedSubtopology;
    AP_TERM_TAC;
    eq_tac     [Left]
    proof
      rewrite LEFT_IMP_EXISTS_THM;     intro_TAC βˆ€e1 e2, H3 H4 H5 H6 H7 H8;
      exists_TAC e1 ∩ s;     exists_TAC e2 ∩ s;
      e1 βŠ‚ topspace Ξ±  ∧  e2 βŠ‚ topspace Ξ±     [e12Subsets] by fol H3 H4 OPEN_IN_SUBSET;
      simplify H1 H3 H4 OPEN_IN_INTER H7 H8;
      set e12Subsets H5 H6;
    qed;
    rewrite LEFT_IMP_EXISTS_THM;     intro_TAC βˆ€e1 e2, H3 H4 H5 H6 H7 H8;
    exists_TAC e1;     exists_TAC e2;
    set H3 H4 H7 H8 H5 H6;
  qed;
`;;

let ConnectedEmpty = theorem `;
  βˆ€Ξ±. Connected (subtopology Ξ± βˆ…)

  proof
    simplify Connected_DEF INTER_EMPTY EMPTY_SUBSET TopspaceSubtopology;
    fol UNION_SUBSET SUBSET_EMPTY;
  qed;
`;;

let ConnectedSing = theorem `;
  βˆ€Ξ± a. a ∈ topspace Ξ±  β‡’  Connected (subtopology Ξ± {a})

  proof
    simplify Connected_DEF SING_SUBSET TopspaceSubtopology;
    set;
  qed;
`;;

let ConnectedUnions = theorem `;
  βˆ€Ξ± P. (βˆ€s. s ∈ P β‡’ s βŠ‚ topspace Ξ±)  β‡’
    (βˆ€s. s ∈ P β‡’ Connected (subtopology Ξ± s)) ∧ Β¬(INTERS P = βˆ…)
        β‡’ Connected (subtopology Ξ± (UNIONS P))

  proof
    intro_TAC βˆ€Ξ± P, H1;
    simplify H1 ConnectedSubtopology UNIONS_SUBSET NOT_EXISTS_THM;
    intro_TAC allConnected PnotDisjoint, βˆ€[d/e1] [e/e2];
    consider a such that
    βˆ€t. t ∈ P β‡’ a ∈ t     [aInterP] by fol PnotDisjoint MEMBER_NOT_EMPTY IN_INTERS;
    ONCE_REWRITE_TAC TAUT [βˆ€p. Β¬p ⇔ p β‡’ F];
    intro_TAC dOpen eOpen Pde deDisjoint dNonempty eNonempty;
    a ∈ d ∨ a ∈ e     [adORae] by set aInterP Pde dNonempty;
    consider s x t y such that
    s ∈ P  ∧  x ∈ d ∩ s  ∧
    t ∈ P  ∧  y ∈ e ∩ t     [xdsANDyet] by set dNonempty eNonempty;
    d ∩ e ∩ s = βˆ…  ∧  d ∩ e ∩ t = βˆ…     [] by set - deDisjoint;
    (d ∩ s = βˆ…  ∨  e ∩ s = βˆ…)  ∧
    (d ∩ t = βˆ…  ∨  e ∩ t = βˆ…)     [] by fol xdsANDyet allConnected dOpen eOpen Pde -;
    set adORae xdsANDyet aInterP -;
  qed;
`;;

let ConnectedUnion = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  ∧  t βŠ‚ topspace Ξ±  ∧  Β¬(s ∩ t = βˆ…)  ∧
    Connected (subtopology α s) ∧ Connected (subtopology α t)
    β‡’ Connected (subtopology Ξ± (s βˆͺ t))

  proof
    rewrite GSYM UNIONS_2 GSYM INTERS_2;
    intro_TAC βˆ€Ξ± s t, H1 H2 H3 H4 H5;
    βˆ€u. u ∈ {s, t}  β‡’  u βŠ‚ topspace Ξ±     [stEuclidean] by set H1 H2;
    βˆ€u. u ∈ {s, t}  β‡’  Connected (subtopology Ξ± u)     [] by set H4 H5;
    fol stEuclidean - H3 ConnectedUnions;
  qed;
`;;

let ConnectedDiffOpenFromClosed = theorem `;
  βˆ€Ξ± s t u.  u βŠ‚ topspace Ξ±  β‡’
    s βŠ‚ t  ∧  t βŠ‚ u ∧ open_in Ξ± s  ∧  closed_in Ξ± t  ∧
    Connected (subtopology Ξ± u)  ∧  Connected (subtopology Ξ± (t ━ s))
    β‡’ Connected (subtopology Ξ± (u ━ s))

  proof
    ONCE_REWRITE_TAC TAUT
    [βˆ€a b c d e f g. (a ∧ b ∧ c ∧ d ∧ e ∧ f β‡’ g)  ⇔
    (a ∧ b ∧ c ∧ d β‡’ Β¬g β‡’ f β‡’ Β¬e)];
    intro_TAC βˆ€Ξ± s t u, uSubset, st tu sOpen tClosed;
    t ━ s βŠ‚ topspace Ξ±  ∧  u ━ s βŠ‚ topspace Ξ±     [] by fol uSubset sOpen OPEN_IN_SUBSET tClosed closed_in SUBSET_DIFF SUBSET_TRANS;
    simplify uSubset - ConnectedSubtopology;
    rewrite LEFT_IMP_EXISTS_THM;
    intro_TAC βˆ€[v/e1] [w/e2];
    intro_TAC vOpen wOpen u_sDisconnected vwDisjoint vNonempty wNonempty;
    rewrite NOT_EXISTS_THM;
    intro_TAC t_sConnected;
    t ━ s βŠ‚ v βˆͺ w  ∧  v ∩ w ∩ (t ━ s) = βˆ…     [] by set tu u_sDisconnected vwDisjoint;
    v ∩ (t ━ s) = βˆ…  ∨  w ∩ (t ━ s) = βˆ…     [] by fol t_sConnected vOpen wOpen -;
    case_split vEmpty | wEmpty by fol -;
    suppose v ∩ (t ━ s) = βˆ…;
      exists_TAC w βˆͺ s;     exists_TAC v ━ t;
      simplify vOpen wOpen sOpen tClosed OPEN_IN_UNION OPEN_IN_DIFF;
      set st tu u_sDisconnected vEmpty vwDisjoint wNonempty vNonempty;
    end;
    suppose w ∩ (t ━ s) = βˆ…;
      exists_TAC v βˆͺ s;     exists_TAC w ━ t;
      simplify vOpen wOpen sOpen tClosed OPEN_IN_UNION OPEN_IN_DIFF;
      set st tu u_sDisconnected wEmpty vwDisjoint wNonempty vNonempty;
    end;
  qed;
`;;

let ConnectedDisjointUnionsOpenUniquePart1 = theorem `;
  βˆ€Ξ± f f' s t a.  pairwise DISJOINT f ∧ pairwise DISJOINT f' ∧
    (βˆ€s. s ∈ f  β‡’  open_in Ξ± s ∧ Connected (subtopology Ξ± s) ∧ Β¬(s = βˆ…)) ∧
    (βˆ€s. s ∈ f'  β‡’  open_in Ξ± s ∧ Connected (subtopology Ξ± s) ∧ Β¬(s = βˆ…)) ∧
    UNIONS f = UNIONS f' ∧ s ∈ f ∧ t ∈ f' ∧ a ∈ s ∧ a ∈ t
     β‡’ s βŠ‚ t

  proof
    intro_TAC βˆ€Ξ± f f' s t a, pDISJf pDISJf' fConn f'Conn Uf_Uf' sf tf' a_s a_t;
    βˆ€s.  s ∈ f β‡’ s βŠ‚ topspace Ξ±     [fTop] by fol fConn OPEN_IN_SUBSET;
    βˆ€s.  s ∈ f' β‡’ s βŠ‚ topspace Ξ±     [f'Top] by fol f'Conn OPEN_IN_SUBSET;
    rewrite SUBSET;
    intro_TAC βˆ€[b], bs;
    assume ¬(b ∈ t)     [Contradiction] by fol;
    βˆƒe1 e2.  open_in Ξ± e1 ∧ open_in Ξ± e2 ∧ e1 ∩ e2 ∩ s = βˆ… ∧
     s βŠ‚ e1 βˆͺ e2 ∧ Β¬(e1 ∩ s = βˆ…) ∧ Β¬(e2 ∩ s = βˆ…)     []
     proof
       exists_TAC t;     exists_TAC UNIONS (f' DELETE t);
       simplify tf' f'Conn IN_DELETE OPEN_IN_UNIONS;
       conj_tac     [Right] by set sf Uf_Uf' a_s a_t sf bs Contradiction;
       MATCH_MP_TAC SET_RULE [βˆ€s t u. t ∩ u = βˆ… β‡’ t ∩ u ∩ s = βˆ…];
       rewrite INTER_UNIONS EMPTY_UNIONS FORALL_IN_GSPEC;
       rewrite IN_DELETE GSYM DISJOINT;
       fol pDISJf' tf' pairwise;
     qed;
     fol - sf fTop fConn ConnectedSubtopology;
  qed;
`;;

let ConnectedDisjointUnionsOpenUnique = theorem `;
  βˆ€Ξ± f f'.  pairwise DISJOINT f ∧ pairwise DISJOINT f' ∧
    (βˆ€s. s ∈ f  β‡’  open_in Ξ± s ∧ Connected (subtopology Ξ± s) ∧ Β¬(s = βˆ…)) ∧
    (βˆ€s. s ∈ f'  β‡’  open_in Ξ± s ∧ Connected (subtopology Ξ± s) ∧ Β¬(s = βˆ…)) ∧
    UNIONS f = UNIONS f'
    β‡’ f = f'

  proof
    MATCH_MP_TAC MESON [SUBSET_ANTISYM]
    [(βˆ€Ξ± s t. P Ξ± s t β‡’ P Ξ± t s) ∧ (βˆ€Ξ± s t. P Ξ± s t β‡’ s βŠ‚ t)
    β‡’ (βˆ€Ξ± s t. P Ξ± s t β‡’ s = t)];
    conj_tac     [Left] by fol;
    intro_TAC βˆ€Ξ± f f', pDISJf pDISJf' fConn f'Conn Uf_Uf';
    rewrite SUBSET;
    intro_TAC βˆ€[s], sf;
    consider t a such that
    t ∈ f' ∧ a ∈ s ∧ a ∈ t     [taExist] by set sf fConn Uf_Uf';
    MP_TAC ISPECL [Ξ±; f; f'; s; t] ConnectedDisjointUnionsOpenUniquePart1;
    MP_TAC ISPECL [Ξ±; f'; f; t; s] ConnectedDisjointUnionsOpenUniquePart1;
    fol pDISJf pDISJf' fConn f'Conn Uf_Uf' sf taExist SUBSET_ANTISYM taExist;
  qed;
`;;

let ConnectedFromClosedUnionAndInter = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ± ∧ closed_in Ξ± s ∧ closed_in Ξ± t ∧
    Connected (subtopology Ξ± (s βˆͺ t)) ∧ Connected (subtopology Ξ± (s ∩ t))
    β‡’ Connected (subtopology Ξ± s) ∧ Connected (subtopology Ξ± t)

  proof
    MATCH_MP_TAC MESON [] [(βˆ€Ξ± s t. P Ξ± s t β‡’ P Ξ± t s) ∧
    (βˆ€Ξ± s t. P Ξ± s t β‡’ Q Ξ± s) β‡’ βˆ€Ξ± s t. P Ξ± s t β‡’ Q Ξ± s ∧ Q Ξ± t];
    conj_tac     [Left] by fol UNION_COMM INTER_COMM;
    ONCE_REWRITE_TAC TAUT
    [βˆ€a b c d e f.  a ∧ b ∧ c ∧ d ∧ e β‡’ f  ⇔  a ∧ b ∧ c ∧ e ∧ Β¬f β‡’ Β¬d];
    intro_TAC βˆ€Ξ± s t, stUnionTop sClosed tClosed stInterConn  NOTsConn;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ± ∧ s ∩ t βŠ‚ topspace Ξ±     [stTop] by fol stUnionTop UNION_SUBSET INTER_SUBSET SUBSET_TRANS;
    simplify stUnionTop ConnectedClosedSubtopology;
    consider u v such that closed_in α u ∧ closed_in α v ∧
    Β¬(u = βˆ…) ∧ Β¬(v = βˆ…) ∧ u βˆͺ v = s ∧ u ∩ v = βˆ…     [sDisConn]
    proof
      MP_TAC ISPECL [Ξ±; s] ConnectedClosedSet;
      simplify stTop sClosed NOTsConn;
    qed;
    s ∩ t βŠ‚ u βˆͺ v  ∧  u ∩ v ∩ (s ∩ t) = βˆ…     [stuvProps] by set sDisConn;
    u ∩ (s ∩ t) = βˆ…  ∨  v ∩ (s ∩ t) = βˆ…     [] by fol stTop stInterConn sDisConn - ConnectedClosedSubtopology_ALT;
    case_split vstEmpty | ustEmpty by fol -;
    suppose v ∩ (s ∩ t) = βˆ…;
      exists_TAC t βˆͺ u;     exists_TAC v;
      simplify tClosed sDisConn CLOSED_IN_UNION;
      set stuvProps sDisConn vstEmpty;
    end;
    suppose u ∩ (s ∩ t) = βˆ…;
      exists_TAC t βˆͺ v;     exists_TAC u;
      simplify tClosed sDisConn CLOSED_IN_UNION;
      set stuvProps sDisConn ustEmpty;
    end;
  qed;
`;;

let ConnectedFromOpenUnionAndInter = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ± ∧ open_in Ξ± s ∧ open_in Ξ± t ∧
    Connected (subtopology Ξ± (s βˆͺ t)) ∧ Connected (subtopology Ξ± (s ∩ t))
    β‡’ Connected (subtopology Ξ± s) ∧ Connected (subtopology Ξ± t)

  proof
    MATCH_MP_TAC MESON [] [(βˆ€Ξ± s t. P Ξ± s t β‡’ P Ξ± t s) ∧
    (βˆ€Ξ± s t. P Ξ± s t β‡’ Q Ξ± s) β‡’ βˆ€Ξ± s t. P Ξ± s t β‡’ Q Ξ± s ∧ Q Ξ± t];
    conj_tac     [Left] by fol UNION_COMM INTER_COMM;
    ONCE_REWRITE_TAC TAUT
    [βˆ€a b c d e f.  a ∧ b ∧ c ∧ d ∧ e β‡’ f  ⇔  a ∧ b ∧ c ∧ e ∧ Β¬f β‡’ Β¬d];
    intro_TAC βˆ€Ξ± s t, stUnionTop sOpen tOpen stInterConn  NOTsConn;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ± ∧ s ∩ t βŠ‚ topspace Ξ±     [stTop] by fol stUnionTop UNION_SUBSET INTER_SUBSET SUBSET_TRANS;
    simplify stUnionTop ConnectedSubtopology;
    consider u v such that open_in α u ∧ open_in α v ∧
    Β¬(u = βˆ…) ∧ Β¬(v = βˆ…) ∧ u βˆͺ v = s ∧ u ∩ v = βˆ…     [sDisConn]
    proof
      MP_TAC ISPECL [Ξ±; s] ConnectedOpenSet;
      simplify stTop sOpen NOTsConn;
    qed;
    s ∩ t βŠ‚ u βˆͺ v  ∧  u ∩ v ∩ (s ∩ t) = βˆ…     [stuvProps] by set sDisConn;
    u ∩ (s ∩ t) = βˆ…  ∨  v ∩ (s ∩ t) = βˆ…     [] by fol stTop stInterConn sDisConn - ConnectedSubtopology_ALT;
    case_split vstEmpty | ustEmpty by fol -;
    suppose v ∩ (s ∩ t) = βˆ…;
      exists_TAC t βˆͺ u;     exists_TAC v;
      simplify tOpen sDisConn OPEN_IN_UNION;
      set stuvProps sDisConn vstEmpty;
    end;
    suppose u ∩ (s ∩ t) = βˆ…;
      exists_TAC t βˆͺ v;     exists_TAC u;
      simplify tOpen sDisConn OPEN_IN_UNION;
      set stuvProps sDisConn ustEmpty;
    end;
  qed;
`;;

let ConnectedInduction = theorem `;
  βˆ€Ξ± P Q s.  s βŠ‚ topspace Ξ±  β‡’  Connected (subtopology Ξ± s) ∧
    (βˆ€t a. open_in (subtopology Ξ± s) t ∧ a ∈ t  β‡’  βˆƒz. z ∈ t ∧ P z) ∧
    (βˆ€a. a ∈ s  β‡’  βˆƒt. open_in (subtopology Ξ± s) t ∧ a ∈ t ∧
    βˆ€x y. x ∈ t ∧ y ∈ t ∧ P x ∧ P y ∧ Q x β‡’ Q y)
    β‡’ βˆ€a b. a ∈ s ∧ b ∈ s ∧ P a ∧ P b ∧ Q a β‡’ Q b

  proof
    intro_TAC βˆ€Ξ± P Q s, sTop, sConn atOpenImplies_ztPz asImplies_atOpen_xytPxPyQxasImpliesQy, βˆ€a b, aINs bINs Pa Pb Qa;
    assume Β¬Q b     [NotQb] by fol;
    Β¬Connected (subtopology Ξ± s)     []
    proof
      simplify sTop ConnectedOpenIn;
      exists_TAC
      {b | βˆƒt. open_in (subtopology Ξ± s) t ∧ b ∈ t ∧ βˆ€x. x ∈ t ∧ P x β‡’ Q x};
      exists_TAC
      {b | βˆƒt. open_in (subtopology Ξ± s) t ∧ b ∈ t ∧ βˆ€x. x ∈ t ∧ P x β‡’ Β¬(Q x)};
      conj_tac     [Left]
      proof
        ONCE_REWRITE_TAC OPEN_IN_SUBOPEN;
        intro_TAC βˆ€[c];
        rewrite IN_ELIM_THM;
        MATCH_MP_TAC MONO_EXISTS;
        set atOpenImplies_ztPz;
      qed;
      conj_tac     [Left]
      proof
        ONCE_REWRITE_TAC OPEN_IN_SUBOPEN;
        intro_TAC βˆ€[c];
        rewrite IN_ELIM_THM;
        MATCH_MP_TAC MONO_EXISTS;
        set atOpenImplies_ztPz;
      qed;
      conj_tac     [Left]
      proof
        rewrite SUBSET IN_ELIM_THM IN_UNION;
        intro_TAC βˆ€[c], cs;
        MP_TAC SPECL [c] asImplies_atOpen_xytPxPyQxasImpliesQy;
        set cs;
      qed;
      conj_tac     [Right] by set aINs bINs Qa NotQb asImplies_atOpen_xytPxPyQxasImpliesQy Pa Pb;
      rewrite EXTENSION IN_INTER NOT_IN_EMPTY IN_ELIM_THM;
      intro_TAC βˆ€[c];
      ONCE_REWRITE_TAC TAUT [βˆ€p. Β¬p  ⇔  p β‡’ F];
      intro_TAC Qx NotQx;
      consider t such that
      open_in (subtopology Ξ± s) t ∧ c ∈ t ∧ (βˆ€x. x ∈ t ∧ P x β‡’ Q x)     [tExists] by fol Qx;
      consider u such that
      open_in (subtopology Ξ± s) u ∧ c ∈ u ∧ (βˆ€x. x ∈ u ∧ P x β‡’ Β¬Q x)     [uExists] by fol NotQx;
      MP_TAC SPECL [t ∩ u; c] atOpenImplies_ztPz;
      simplify tExists uExists OPEN_IN_INTER;
      set tExists uExists;
    qed;
    fol sConn -;
  qed;
`;;

let ConnectedEquivalenceRelationGen = theorem `;
  βˆ€Ξ± P R s.  s βŠ‚ topspace Ξ±  β‡’  Connected (subtopology Ξ± s) ∧
        (βˆ€x y z. R x y ∧ R y z β‡’ R x z) ∧
        (βˆ€t a. open_in (subtopology Ξ± s) t ∧ a ∈ t
               β‡’ βˆƒz. z ∈ t ∧ P z) ∧
        (βˆ€a. a ∈ s
             β‡’ βˆƒt. open_in (subtopology Ξ± s) t ∧ a ∈ t ∧
                     βˆ€x y. x ∈ t ∧ y ∈ t ∧ P x ∧ P y β‡’ R x y)
        β‡’ βˆ€a b. a ∈ s ∧ b ∈ s ∧ P a ∧ P b β‡’ R a b

  proof
    intro_TAC βˆ€Ξ± P R s, sTop, sConn Rtrans atOpenImplies_ztPz asImplies_atOpen_xytPxPyImpliesRxy, βˆ€a b, aINs bINs Pa Pb;
    βˆ€a.  a ∈ s ∧ P a  β‡’  βˆ€b c. b ∈ s ∧ c ∈ s ∧ P b ∧ P c ∧ R a b β‡’ R a c     []
    proof
      intro_TAC βˆ€[p/a], pINs Pp;
      MP_TAC ISPECL [Ξ±; P; Ξ»x. R p x; s] ConnectedInduction;
      rewrite sTop sConn atOpenImplies_ztPz;
      fol asImplies_atOpen_xytPxPyImpliesRxy Rtrans;
    qed;
    fol aINs Pa bINs Pb asImplies_atOpen_xytPxPyImpliesRxy -;
  qed;
`;;

let ConnectedInductionSimple = theorem `;
  βˆ€Ξ± P s.  s βŠ‚ topspace Ξ±  β‡’
        Connected (subtopology α s) ∧
        (βˆ€a. a ∈ s
             β‡’ βˆƒt. open_in (subtopology Ξ± s) t ∧ a ∈ t ∧
                     βˆ€x y. x ∈ t ∧ y ∈ t ∧ P x β‡’ P y)
        β‡’ βˆ€a b. a ∈ s ∧ b ∈ s ∧ P a β‡’ P b

  proof
    intro_TAC βˆ€Ξ± P s, sTop;
    MP_TAC ISPECL [α; (λx. T ∨ x ∈ s); P; s] ConnectedInduction;
    fol sTop;
  qed;
`;;

let ConnectedEquivalenceRelation = theorem `;
  βˆ€Ξ± R s.  s βŠ‚ topspace Ξ±  β‡’  Connected (subtopology Ξ± s)∧
    (βˆ€x y. R x y β‡’ R y x) ∧ (βˆ€x y z. R x y ∧ R y z β‡’ R x z) ∧
    (βˆ€a. a ∈ s β‡’
    βˆƒt. open_in (subtopology Ξ± s) t ∧ a ∈ t ∧ βˆ€x. x ∈ t β‡’ R a x)
    β‡’ βˆ€a b. a ∈ s ∧ b ∈ s β‡’ R a b

  proof
    intro_TAC βˆ€Ξ± R s, sTop, sConn Rcomm Rtrans asImplies_atOpen_xtImpliesRax;
    βˆ€a. a ∈ s β‡’ βˆ€b c. b ∈ s ∧ c ∈ s ∧ R a b β‡’ R a c     []
    proof
      intro_TAC βˆ€[p/a], pINs;
      MP_TAC ISPECL [Ξ±; Ξ»x. R p x; s] ConnectedInductionSimple;
       rewrite sTop sConn;
      fol asImplies_atOpen_xtImpliesRax Rcomm Rtrans;
    qed;
    fol asImplies_atOpen_xtImpliesRax -;
  qed;
`;;

let LimitPointOf = NewDefinition `;
  βˆ€Ξ± s. LimitPointOf Ξ± s  =  {x | s βŠ‚ topspace Ξ± ∧ x ∈ topspace Ξ± ∧
    βˆ€t. x ∈ t ∧ open_in Ξ± t  β‡’  βˆƒy. Β¬(y = x) ∧ y ∈ s ∧ y ∈ t}`;;

let IN_LimitPointOf = theorem `;
  βˆ€Ξ± s x.  s βŠ‚ topspace Ξ±  β‡’
    (x ∈ LimitPointOf Ξ± s  ⇔  x ∈ topspace Ξ± ∧
    βˆ€t. x ∈ t ∧ open_in Ξ± t  β‡’  βˆƒy. Β¬(y = x) ∧ y ∈ s ∧ y ∈ t)
  by simplify IN_ELIM_THM LimitPointOf`;;

let NotLimitPointOf = theorem `;
  βˆ€Ξ± s x.  s βŠ‚ topspace Ξ± ∧ x ∈ topspace Ξ±  β‡’
    (x βˆ‰ LimitPointOf Ξ± s  ⇔
    βˆƒt. x ∈ t  ∧  open_in Ξ± t  ∧  s ∩ (t ━ {x}) = βˆ…)

  proof
    ONCE_REWRITE_TAC TAUT [βˆ€a b. (a ⇔ b)  ⇔  (Β¬a  ⇔ Β¬b)];
    simplify βˆ‰ NOT_EXISTS_THM IN_LimitPointOf
    TAUT [βˆ€a b. Β¬(a ∧ b ∧ c)  ⇔  a ∧ b β‡’ Β¬c] GSYM MEMBER_NOT_EMPTY IN_INTER  IN_DIFF IN_SING;
     fol;
  qed;
`;;

let LimptSubset = theorem `;
  βˆ€Ξ± s t.  t βŠ‚ topspace Ξ±  β‡’
    s βŠ‚ t  β‡’  LimitPointOf Ξ± s βŠ‚ LimitPointOf Ξ± t

  proof
    intro_TAC βˆ€Ξ± s t, tTop, st;
    s βŠ‚ topspace Ξ±     [sTop] by fol tTop st SUBSET_TRANS;
    simplify tTop sTop IN_LimitPointOf SUBSET;
    fol st SUBSET;
  qed;
`;;

let ClosedLimpt = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    (closed_in Ξ± s  ⇔  LimitPointOf Ξ± s βŠ‚ s)

  proof
    intro_TAC βˆ€Ξ± s, H1;
    simplify H1 closed_in;
    ONCE_REWRITE_TAC OPEN_IN_SUBOPEN;
    simplify H1 IN_LimitPointOf SUBSET IN_DIFF;
    AP_TERM_TAC;
    ABS_TAC;
    fol OPEN_IN_SUBSET SUBSET;
  qed;
`;;

let LimptEmpty = theorem `;
  βˆ€Ξ± x.  x ∈ topspace Ξ±  β‡’  x βˆ‰ LimitPointOf Ξ± βˆ…
  by fol EMPTY_SUBSET IN_LimitPointOf OPEN_IN_TOPSPACE NOT_IN_EMPTY βˆ‰`;;

let NoLimitPointImpClosed = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  (βˆ€x. x βˆ‰ LimitPointOf Ξ± s)  β‡’  closed_in Ξ± s
  by fol ClosedLimpt SUBSET βˆ‰`;;

let LimitPointUnion = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’
    LimitPointOf Ξ± (s βˆͺ t)  =  LimitPointOf Ξ± s  βˆͺ  LimitPointOf Ξ± t

  proof
    intro_TAC βˆ€Ξ± s t, H1;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±     [stTop] by fol H1 UNION_SUBSET;
    rewrite EXTENSION IN_UNION;
    intro_TAC βˆ€x;
    assume x ∈ topspace α     [xTop] by fol H1 stTop IN_LimitPointOf;
    ONCE_REWRITE_TAC TAUT [βˆ€a b. (a ⇔ b)  ⇔  (Β¬a  ⇔ Β¬b)];
    simplify GSYM NOTIN DE_MORGAN_THM H1 stTop NotLimitPointOf xTop;
    eq_tac     [Left] by set;
    MATCH_MP_TAC ExistsTensorInter;
    simplify IN_INTER OPEN_IN_INTER;
    set;
  qed;
`;;

let Interior_DEF = NewDefinition `;
  βˆ€Ξ± s.  Interior Ξ± s =
    {x | s βŠ‚ topspace Ξ±  ∧  βˆƒt. open_in Ξ± t ∧ x ∈ t ∧ t βŠ‚ s}`;;

let Interior_THM = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Interior Ξ± s =
    {x | s βŠ‚ topspace Ξ±  ∧  βˆƒt. open_in Ξ± t ∧ x ∈ t ∧ t βŠ‚ s}
  by fol Interior_DEF`;;

let IN_Interior = theorem `;
  βˆ€Ξ± s x.  s βŠ‚ topspace Ξ±  β‡’
    (x ∈ Interior Ξ± s  ⇔  βˆƒt. open_in Ξ± t ∧ x ∈ t ∧ t βŠ‚ s)
  by simplify Interior_THM IN_ELIM_THM`;;

let InteriorEq = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    (open_in Ξ± s  ⇔  s = Interior Ξ± s)

  proof
    intro_TAC βˆ€Ξ± s, H1;
    rewriteL OPEN_IN_SUBOPEN;
    simplify EXTENSION H1 IN_Interior;
    set;
  qed;
`;;

let InteriorOpen = theorem `;
  βˆ€Ξ± s.  open_in Ξ± s  β‡’  Interior Ξ± s = s
  by fol OPEN_IN_SUBSET InteriorEq`;;

let InteriorEmpty = theorem `;
  βˆ€Ξ±. Interior Ξ± βˆ… = βˆ…
  by fol OPEN_IN_EMPTY EMPTY_SUBSET InteriorOpen`;;

let InteriorUniv = theorem `;
  βˆ€Ξ±. Interior Ξ± (topspace Ξ±) = topspace Ξ±
  by simplify OpenInTopspace InteriorOpen`;;

let OpenInterior = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  open_in Ξ± (Interior Ξ± s)

  proof
    ONCE_REWRITE_TAC OPEN_IN_SUBOPEN;
    fol IN_Interior SUBSET;
  qed;
`;;

let InteriorInterior = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    Interior Ξ±  (Interior Ξ± s) = Interior Ξ± s
  by fol OpenInterior InteriorOpen`;;

let InteriorSubset = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Interior Ξ± s βŠ‚ s

  proof
    intro_TAC βˆ€Ξ± s, H1;
    simplify SUBSET Interior_DEF IN_ELIM_THM;
    fol H1 SUBSET;
  qed;
`;;

let InteriorTopspace = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Interior Ξ± s βŠ‚ topspace Ξ±
  by fol SUBSET_TRANS InteriorSubset`;;

let SubsetInterior = theorem `;
  βˆ€Ξ± s t.  t βŠ‚ topspace Ξ±  β‡’  s βŠ‚ t  β‡’
    Interior Ξ± s βŠ‚ Interior Ξ± t
  by fol SUBSET_TRANS SUBSET IN_Interior SUBSET`;;

let InteriorMaximal = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  β‡’
    t βŠ‚ s ∧ open_in Ξ± t  β‡’  t βŠ‚ Interior Ξ± s
  by fol SUBSET IN_Interior SUBSET`;;

let InteriorMaximalEq = theorem `;
  βˆ€s t.  t βŠ‚ topspace Ξ±  β‡’
    open_in Ξ± s  β‡’  (s βŠ‚ Interior Ξ± t  ⇔  s βŠ‚ t)
  by fol InteriorMaximal SUBSET_TRANS InteriorSubset`;;

let InteriorUnique = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  β‡’
    t βŠ‚ s  ∧  open_in Ξ± t ∧  (βˆ€t'. t' βŠ‚ s ∧ open_in Ξ± t' β‡’ t' βŠ‚ t)
    β‡’ Interior Ξ± s = t
  by fol SUBSET_ANTISYM InteriorSubset OpenInterior InteriorMaximal`;;

let OpenSubsetInterior = theorem `;
  βˆ€Ξ± s t.  t βŠ‚ topspace Ξ±  β‡’
    open_in Ξ± s  β‡’  (s βŠ‚ Interior Ξ± t  ⇔  s βŠ‚ t)
  by fol InteriorMaximal InteriorSubset SUBSET_TRANS`;;

let InteriorInter = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  ∧  t βŠ‚ topspace Ξ±  β‡’
    Interior α (s ∩ t) = Interior α s ∩ Interior α t

  proof
    intro_TAC βˆ€Ξ± s t, sTop tTop;
    rewrite GSYM SUBSET_ANTISYM_EQ SUBSET_INTER;
    conj_tac     [Left] by fol sTop tTop SubsetInterior INTER_SUBSET;
    s ∩ t βŠ‚ topspace Ξ±     [] by fol sTop INTER_SUBSET SUBSET_TRANS;
    fol - sTop tTop OpenInterior OPEN_IN_INTER InteriorSubset InteriorMaximal INTER_TENSOR;
  qed;
`;;

let InteriorFiniteInters = theorem `;
  βˆ€Ξ± s.  FINITE s β‡’ Β¬(s = βˆ…) β‡’ (βˆ€t. t ∈ s β‡’ t βŠ‚ topspace Ξ±) β‡’
    Interior Ξ± (INTERS s) = INTERS (IMAGE (Interior Ξ±) s)

  proof
    intro_TAC βˆ€Ξ±;
    MATCH_MP_TAC FINITE_INDUCT;
    rewrite INTERS_INSERT IMAGE_CLAUSES IN_INSERT;
    intro_TAC βˆ€x s, sCase, xsNonempty, sSetOfSubsets;
    assume Β¬(s = βˆ…)     [sNonempty] by simplify INTERS_0 INTER_UNIV IMAGE_CLAUSES;
    simplify INTERS_SUBSET  sSetOfSubsets InteriorInter sNonempty sSetOfSubsets sCase;
  qed;
`;;

let InteriorIntersSubset = theorem `;
  βˆ€Ξ± f.  Β¬(f = βˆ…) ∧ (βˆ€t. t ∈ f β‡’ t βŠ‚ topspace Ξ±) β‡’
    Interior Ξ± (INTERS f)  βŠ‚  INTERS (IMAGE (Interior Ξ±) f)

  proof
    intro_TAC βˆ€Ξ± f, H1 H2;
    INTERS f βŠ‚ topspace Ξ±     [] by set H1 H2;
    simplify SUBSET IN_INTERS FORALL_IN_IMAGE - H2 IN_Interior;
    fol;
  qed;
`;;

let UnionInteriorSubset = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  ∧  t βŠ‚ topspace Ξ±  β‡’
    Interior Ξ± s βˆͺ Interior Ξ± t  βŠ‚  Interior Ξ± (s βˆͺ t)

  proof
    intro_TAC βˆ€Ξ± s t, sTop tTop;
    s βˆͺ t βŠ‚ topspace Ξ±     [] by fol sTop tTop UNION_SUBSET;
    fol sTop tTop - OpenInterior OPEN_IN_UNION InteriorMaximal UNION_TENSOR InteriorSubset;
  qed;
`;;

let InteriorEqEmpty = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    (Interior Ξ± s = βˆ…  ⇔  βˆ€t. open_in Ξ± t ∧ t βŠ‚ s  β‡’  t = βˆ…)
  by fol InteriorMaximal SUBSET_EMPTY OpenInterior SUBSET_REFL InteriorSubset`;;

let InteriorEqEmptyAlt = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    (Interior Ξ± s = βˆ…  ⇔  βˆ€t. open_in Ξ± t ∧ Β¬(t = βˆ…) β‡’ Β¬(t ━ s = βˆ…))

  proof
    simplify InteriorEqEmpty;
    set;
  qed;
`;;

let InteriorUnionsOpenSubsets = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  UNIONS {t | open_in Ξ± t ∧ t βŠ‚ s} = Interior Ξ± s

  proof
    intro_TAC βˆ€Ξ± s, H1;
    consider t such that
    t = UNIONS {f | open_in Ξ± f ∧ f βŠ‚ s}     [tDef] by fol;
    t βŠ‚ s  ∧  βˆ€f. f βŠ‚ s ∧ open_in Ξ± f β‡’ f βŠ‚ t     [] by set tDef;
    simplify H1 tDef - OPEN_IN_UNIONS IN_ELIM_THM InteriorUnique;
  qed;
`;;

let InteriorClosedUnionEmptyInterior = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    closed_in Ξ± s ∧ Interior Ξ± t = βˆ…  β‡’
    Interior Ξ± (s βˆͺ t) = Interior Ξ± s

  proof
    intro_TAC βˆ€Ξ± s t, H1 H2, H3 H4;
    s βˆͺ t βŠ‚ topspace Ξ±     [stTop] by fol H1 H2 UNION_SUBSET;
    Interior Ξ± (s βˆͺ t) βŠ‚ s     []
    proof
      simplify SUBSET stTop IN_Interior LEFT_IMP_EXISTS_THM;
      intro_TAC βˆ€[y] [O], openO yO Os_t;
      consider O' such that O' = (topspace Ξ± ━ s) ∩ O     [O'def] by fol -;
      O' βŠ‚ t     [O't] by set O'def Os_t;
      assume y βˆ‰ s     [yNOTs] by fol βˆ‰;
      y ∈ topspace Ξ± ━ s     [] by fol openO OPEN_IN_SUBSET yO SUBSET yNOTs IN_DIFF βˆ‰;
      y ∈ O'  ∧  open_in α O'     [] by fol O'def - yO IN_INTER H3 closed_in openO OPEN_IN_INTER;
      fol O'def - O't H2 IN_Interior SUBSET MEMBER_NOT_EMPTY H4;
    qed;
    fol SUBSET_ANTISYM H1 stTop OpenInterior - InteriorMaximal SUBSET_UNION SubsetInterior;
  qed;
`;;

let InteriorUnionEqEmpty = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’
    closed_in α s ∨ closed_in α t
    β‡’ (Interior Ξ± (s βˆͺ t) = βˆ…  ⇔  Interior Ξ± s = βˆ… ∧ Interior Ξ± t = βˆ…)

  proof
    intro_TAC βˆ€Ξ± s t, H1, H2;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±     [] by fol H1 UNION_SUBSET;
    eq_tac     [Left] by fol - H1 SUBSET_UNION SubsetInterior SUBSET_EMPTY;
    fol UNION_COMM - H2 InteriorClosedUnionEmptyInterior;
  qed;
`;;

let Closure_DEF = NewDefinition `;
  βˆ€Ξ± s.  Closure Ξ± s  =  s βˆͺ LimitPointOf Ξ± s`;;

let Closure_THM = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Closure Ξ± s  =  s βˆͺ LimitPointOf Ξ± s
  by fol Closure_DEF`;;

let IN_Closure = theorem `;
  βˆ€Ξ± s x.  s βŠ‚ topspace Ξ±  β‡’
    (x ∈ Closure Ξ± s  ⇔  x ∈ topspace Ξ± ∧
    βˆ€t. x ∈ t ∧ open_in Ξ± t  β‡’  βˆƒy. y ∈ s ∧ y ∈ t)

  proof
    intro_TAC βˆ€Ξ± s x, H1;
    simplify H1 Closure_THM IN_UNION IN_LimitPointOf;
    fol H1 SUBSET;
  qed;
`;;

let ClosureSubset = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  s βŠ‚ Closure Ξ± s
  by fol SUBSET IN_Closure`;;

let ClosureTopspace = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Closure Ξ± s βŠ‚ topspace Ξ±
  by fol SUBSET IN_Closure`;;

let ClosureInterior = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    Closure Ξ± s  =  topspace Ξ± ━ (Interior Ξ± (topspace Ξ± ━ s))

  proof
    intro_TAC βˆ€Ξ± s, H1;
    simplify H1 EXTENSION IN_Closure IN_DIFF IN_Interior SUBSET;
    fol OPEN_IN_SUBSET SUBSET;
  qed;
`;;

let InteriorClosure = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    Interior Ξ± s = topspace Ξ± ━ (Closure Ξ± (topspace Ξ± ━ s))
  by fol SUBSET_DIFF InteriorTopspace DIFF_REFL ClosureInterior`;;

let ClosedClosure = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  closed_in Ξ± (Closure Ξ± s)
  by fol closed_in ClosureInterior DIFF_REFL SUBSET_DIFF InteriorTopspace OpenInterior`;;

let SubsetClosure = theorem `;
  βˆ€Ξ± s t.  t βŠ‚ topspace Ξ±  β‡’  s βŠ‚ t  β‡’  Closure Ξ± s βŠ‚ Closure Ξ± t

  proof
    intro_TAC βˆ€Ξ± s t, tSubset, st;
    s βŠ‚ topspace Ξ±     [] by fol tSubset st SUBSET_TRANS;
    simplify tSubset - Closure_THM st LimptSubset UNION_TENSOR;
  qed;
`;;

let ClosureHull = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Closure Ξ± s = (closed_in Ξ±) hull s

  proof
    intro_TAC βˆ€Ξ± s, H1;
    MATCH_MP_TAC GSYM HULL_UNIQUE;
    simplify H1 ClosureSubset ClosedClosure Closure_THM UNION_SUBSET;
    fol LimptSubset CLOSED_IN_SUBSET ClosedLimpt SUBSET_TRANS;
  qed;
`;;

let ClosureEq = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  (Closure Ξ± s = s  ⇔  closed_in Ξ± s)
  by fol ClosedClosure ClosedLimpt Closure_THM SUBSET_UNION_ABSORPTION UNION_COMM`;;

let ClosureClosed = theorem `;
  βˆ€Ξ± s.  closed_in Ξ± s  β‡’  Closure Ξ± s = s
  by fol closed_in ClosureEq`;;

let ClosureClosure = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Closure Ξ± (Closure Ξ± s) = Closure Ξ± s
  by fol ClosureTopspace ClosureHull HULL_HULL`;;

let ClosureUnion = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±
    β‡’ Closure Ξ± (s βˆͺ t)  =  Closure Ξ± s βˆͺ Closure Ξ± t

  proof
    intro_TAC βˆ€Ξ± s t, H1;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±     [stTop] by fol H1 UNION_SUBSET;
    simplify H1 stTop Closure_THM LimitPointUnion;
    set;
  qed;
`;;

let ClosureInterSubset = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    Closure Ξ± (s ∩ t)  βŠ‚  Closure Ξ± s ∩ Closure Ξ± t
  by fol SUBSET_INTER INTER_SUBSET SubsetClosure`;;

let ClosureIntersSubset = theorem `;
  βˆ€Ξ± f.  (βˆ€s. s ∈ f β‡’ s βŠ‚ topspace Ξ±)  β‡’
    Closure Ξ± (INTERS f)  βŠ‚  INTERS (IMAGE (Closure Ξ±) f)

  proof
    intro_TAC βˆ€Ξ± f, H1;
    rewrite SET_RULE [s βŠ‚ INTERS f ⇔ βˆ€t. t ∈ f β‡’ s βŠ‚ t] FORALL_IN_IMAGE;
    intro_TAC βˆ€[s], sf;
    s βŠ‚ topspace Ξ±  ∧  INTERS f βŠ‚ s  ∧  INTERS f βŠ‚ topspace Ξ±     [] by set H1 sf;
    fol SubsetClosure -;
  qed;
`;;

let ClosureMinimal = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ t ∧ closed_in Ξ± t  β‡’  Closure Ξ± s βŠ‚ t
  by fol closed_in SubsetClosure ClosureClosed`;;

let ClosureMinimalEq = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  β‡’
    closed_in Ξ± t  β‡’  (Closure Ξ± s βŠ‚ t ⇔ s βŠ‚ t)
  by fol closed_in SUBSET_TRANS ClosureSubset ClosureMinimal`;;

let ClosureUnique = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ t ∧ closed_in Ξ± t ∧ (βˆ€u. s βŠ‚ u ∧ closed_in Ξ± u  β‡’  t βŠ‚ u)
    β‡’ Closure Ξ± s = t
  by fol closed_in SUBSET_ANTISYM_EQ ClosureMinimal SUBSET_TRANS ClosureSubset ClosedClosure`;;

let ClosureUniv = theorem `;
  βˆ€Ξ±.  Closure Ξ± (topspace Ξ±) =  topspace Ξ±
  by simplify SUBSET_REFL CLOSED_IN_TOPSPACE ClosureEq`;;

let ClosureEmpty = theorem `;
  Closure Ξ± βˆ… = βˆ…
  by fol EMPTY_SUBSET CLOSED_IN_EMPTY ClosureClosed`;;

let ClosureUnions = theorem `;
  βˆ€Ξ± f.  FINITE f  β‡’  (βˆ€ t. t ∈ f β‡’ t βŠ‚ topspace Ξ±)  β‡’
    Closure α (UNIONS f) = UNIONS {Closure α t | t ∈ f}

  proof
    intro_TAC βˆ€Ξ±;
    MATCH_MP_TAC FINITE_INDUCT;
    rewrite UNIONS_0 SET_RULE [{f x | x ∈ βˆ…} = βˆ…] ClosureEmpty UNIONS_INSERT
    SET_RULE [{f x | x ∈ a INSERT t} = (f a) INSERT {f x | x ∈ t}] IN_INSERT;
    fol UNION_SUBSET UNIONS_SUBSET IN_UNIONS ClosureUnion;
  qed;
`;;

let ClosureEqEmpty = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  (Closure Ξ± s = βˆ…  ⇔  s = βˆ…)
  by fol ClosureEmpty ClosureSubset SUBSET_EMPTY`;;

let ClosureSubsetEq = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  (Closure Ξ± s βŠ‚ s  ⇔  closed_in Ξ± s)
  by fol ClosureEq ClosureSubset SUBSET_ANTISYM`;;

let OpenInterClosureEqEmpty = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    open_in Ξ± s  β‡’  (s ∩ Closure Ξ± t = βˆ…  ⇔  s ∩ t = βˆ…)

  proof
    intro_TAC βˆ€Ξ± s t, H1 H2, H3;
    eq_tac     [Left] by fol H2 ClosureSubset INTER_TENSOR SUBSET_REFL SUBSET_EMPTY;
    intro_TAC stDisjoint;
    s βŠ‚ Interior Ξ± (topspace Ξ± ━ t)     [] by fol H2 SUBSET_DIFF H3 H1 H2 stDisjoint SUBSET_COMPLEMENT OpenSubsetInterior;
    fol H1 H2 InteriorTopspace - COMPLEMENT_DISJOINT H2 ClosureInterior;
  qed;
`;;

let OpenInterClosureSubset = theorem `;
  βˆ€Ξ± s t.  t βŠ‚ topspace Ξ±  β‡’
    open_in Ξ± s  β‡’  s ∩ Closure Ξ± t βŠ‚ Closure Ξ± (s ∩ t)

  proof
    intro_TAC βˆ€Ξ± s t, tTop, sOpen;
    s βŠ‚ topspace Ξ±     [sTop] by fol OPEN_IN_SUBSET sOpen;
    s ∩ t βŠ‚ topspace Ξ±     [stTop] by fol sTop sTop INTER_SUBSET SUBSET_TRANS;
    simplify tTop - Closure_THM UNION_OVER_INTER SUBSET_UNION SUBSET_UNION;
    s ∩ LimitPointOf Ξ± t  βŠ‚  LimitPointOf Ξ± (s ∩ t)     []
    proof
      simplify SUBSET IN_INTER tTop stTop IN_LimitPointOf;
      intro_TAC βˆ€[x], xs xTop xLIMt, βˆ€[O], xO Oopen;
      x ∈ O ∩ s  ∧  open_in α (O ∩ s)     [xOsOpen] by fol xs xO IN_INTER Oopen sOpen OPEN_IN_INTER;
      fol xOsOpen xLIMt IN_INTER;
    qed;
    simplify - UNION_TENSOR SUBSET_REFL;
  qed;
`;;

let ClosureOpenInterSuperset = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    open_in Ξ± s ∧ s βŠ‚ Closure Ξ± t  β‡’  Closure Ξ± (s ∩ t) = Closure Ξ± s

  proof
    intro_TAC βˆ€Ξ± s t, sTop tTop, sOpen sSUBtC;
    s ∩ t βŠ‚ topspace Ξ±     [stTop] by fol INTER_SUBSET sTop SUBSET_TRANS;
    MATCH_MP_TAC SUBSET_ANTISYM;
    conj_tac     [Left] by fol sTop INTER_SUBSET SubsetClosure;
    s  βŠ‚  Closure Ξ± (s ∩ t)     [] by fol tTop sOpen OpenInterClosureSubset SUBSET_REFL sSUBtC SUBSET_INTER SUBSET_TRANS;
    fol stTop - ClosedClosure ClosureMinimal;
  qed;
`;;

let ClosureComplement = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    Closure Ξ± (topspace Ξ± ━ s) = topspace Ξ± ━ Interior Ξ± s
  by fol InteriorClosure SUBSET_DIFF ClosureTopspace DIFF_REFL`;;

let InteriorComplement = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    Interior Ξ± (topspace Ξ± ━ s) = topspace Ξ± ━ Closure Ξ± s
  by fol SUBSET_DIFF InteriorTopspace DIFF_REFL ClosureInterior DIFF_REFL`;;

let ClosureInteriorComplement = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    topspace Ξ± ━ Closure Ξ± (Interior Ξ± s)
    = Interior Ξ± (Closure Ξ± (topspace Ξ± ━ s))
  by fol InteriorTopspace InteriorComplement ClosureComplement`;;

let InteriorClosureComplement = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    topspace Ξ± ━ Interior Ξ± (Closure Ξ± s)
    = Closure Ξ± (Interior Ξ± (topspace Ξ± ━ s))
  by fol ClosureTopspace SUBSET_TRANS InteriorComplement ClosureComplement`;;

let ConnectedIntermediateClosure = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ±  β‡’
    Connected (subtopology Ξ± s) ∧  s βŠ‚ t  ∧  t βŠ‚ Closure Ξ± s
    β‡’ Connected (subtopology Ξ± t)

  proof
    intro_TAC βˆ€Ξ± s t, sTop, sCon st tCs;
    t βŠ‚ topspace Ξ±     [tTop] by fol tCs sTop ClosureTopspace SUBSET_TRANS;
    simplify tTop ConnectedSubtopology_ALT;
    intro_TAC βˆ€[u] [v], uOpen vOpen t_uv uvtEmpty;
    u βŠ‚ topspace Ξ±  ∧  v βŠ‚ topspace Ξ±     [uvTop] by fol uOpen vOpen OPEN_IN_SUBSET;
    u ∩ s = βˆ…  ∨  v ∩ s = βˆ…     [] by fol sTop uvTop uOpen vOpen st t_uv uvtEmpty SUBSET_TRANS SUBSET_REFL INTER_TENSOR SUBSET_EMPTY sCon ConnectedSubtopology_ALT;
    s βŠ‚ topspace Ξ± ━ u  ∨  s βŠ‚ topspace Ξ± ━ v     [] by fol - sTop uvTop INTER_COMM SUBSET_COMPLEMENT;
    t βŠ‚ topspace Ξ± ━ u  ∨  t βŠ‚ topspace Ξ± ━ v     [] by fol SUBSET_DIFF - uvTop uOpen vOpen OPEN_IN_CLOSED_IN ClosureMinimal tCs SUBSET_TRANS;
    fol tTop uvTop - SUBSET_COMPLEMENT INTER_COMM;
  qed;
`;;

let ConnectedClosure = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Connected (subtopology Ξ± s) β‡’
    Connected (subtopology Ξ± (Closure Ξ± s))
  by fol ClosureTopspace ClosureSubset SUBSET_REFL ConnectedIntermediateClosure`;;

let ConnectedUnionStrong = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    Connected (subtopology α s)  ∧  Connected (subtopology α t)  ∧
    Β¬(Closure Ξ± s ∩ t = βˆ…)
    β‡’ Connected (subtopology Ξ± (s βˆͺ t))

  proof
    intro_TAC βˆ€Ξ± s t, sTop tTop, H2 H3 H4;
    consider p s' such that
    p ∈ Closure Ξ± s  ∧  p ∈ t  ∧  s' = p β•ͺ s     [pCst] by fol H4 MEMBER_NOT_EMPTY IN_INTER;
    s βŠ‚ s'  ∧  s' βŠ‚ Closure Ξ± s     [s_ps_Cs] by fol IN_INSERT SUBSET pCst sTop ClosureSubset INSERT_SUBSET;
    Connected (subtopology Ξ± (s'))     [s'Con] by fol sTop H2 s_ps_Cs ConnectedIntermediateClosure;
    s βˆͺ t = s' βˆͺ t  ∧  Β¬(s' ∩ t = βˆ…)     [] by fol pCst INSERT_UNION IN_INSERT IN_INTER MEMBER_NOT_EMPTY;
    fol s_ps_Cs sTop ClosureTopspace SUBSET_TRANS tTop - s'Con H3 ConnectedUnion;
  qed;
`;;

let InteriorDiff = theorem `;
  βˆ€Ξ± s t.   s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    Interior Ξ± (s ━ t) = Interior Ξ± s ━ Closure Ξ± t
  by fol ClosureTopspace InteriorTopspace COMPLEMENT_INTER_DIFF InteriorComplement SUBSET_DIFF InteriorInter`;;

let ClosedInLimpt = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    (closed_in (subtopology Ξ± t) s  ⇔
    s βŠ‚ t  ∧  LimitPointOf Ξ± s ∩ t βŠ‚ s)

  proof
    intro_TAC βˆ€Ξ± s t, H1 H2;
    simplify H2 ClosedInSubtopology;
    eq_tac     [Right]
    proof
      intro_TAC sSUBt LIMstSUBs;
      exists_TAC Closure Ξ± s;
      simplify H1 ClosedClosure Closure_THM INTER_COMM UNION_OVER_INTER;
      set sSUBt LIMstSUBs;
    qed;
    rewrite LEFT_IMP_EXISTS_THM;
    intro_TAC βˆ€[D], Dexists;
    LimitPointOf Ξ± (D ∩ t) βŠ‚ D     [] by fol Dexists CLOSED_IN_SUBSET INTER_SUBSET LimptSubset ClosedLimpt SUBSET_TRANS;
    fol Dexists INTER_SUBSET - SUBSET_REFL INTER_TENSOR;
  qed;
`;;

let ClosedInLimpt_ALT = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    (closed_in (subtopology Ξ± t) s  ⇔
    s βŠ‚ t  ∧  βˆ€x. x ∈ LimitPointOf Ξ± s ∧ x ∈ t β‡’ x ∈ s)
  by simplify SUBSET IN_INTER ClosedInLimpt`;;

let ClosedInInterClosure = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    (closed_in (subtopology Ξ± s) t  ⇔  s ∩ Closure Ξ± t = t)

  proof     simplify Closure_THM ClosedInLimpt;     set;     qed;
`;;

let InteriorClosureIdemp = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    Interior Ξ± (Closure Ξ± (Interior Ξ± (Closure Ξ± s)))
    = Interior Ξ± (Closure Ξ± s)

  proof
    intro_TAC βˆ€Ξ± s, H1;
    consider IC CIC such that
    IC = Interior α (Closure α s)  ∧  CIC = Closure α IC     [CICdef] by fol;
    Closure Ξ± s βŠ‚ topspace Ξ±     [Ctop] by fol H1 ClosureTopspace;
    IC βŠ‚ topspace Ξ±     [ICtop] by fol CICdef - H1 InteriorTopspace;
    CIC βŠ‚ topspace Ξ±     [CICtop] by fol CICdef - ClosureTopspace;
    IC βŠ‚ CIC     [ICsubCIC] by fol CICdef ICtop ClosureSubset;
    βˆ€u. u βŠ‚ CIC ∧ open_in Ξ± u β‡’ u βŠ‚ IC     [] by fol CICdef Ctop InteriorSubset SubsetClosure H1 ClosureClosure SUBSET_TRANS OpenSubsetInterior;
    fol CICdef CICtop ICsubCIC Ctop OpenInterior - InteriorUnique;
  qed;
`;;

let InteriorClosureIdemp = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    Interior Ξ± (Closure Ξ± (Interior Ξ± (Closure Ξ± s)))
    = Interior Ξ± (Closure Ξ± s)

  proof
    intro_TAC βˆ€Ξ± s, H1;
    Closure Ξ± s βŠ‚ topspace Ξ±     [Ctop] by fol H1 ClosureTopspace;
    consider IC CIC such that
    IC = Interior α (Closure α s)  ∧  CIC = Closure α IC     [ICdefs] by fol;
    IC βŠ‚ topspace Ξ±     [] by fol - Ctop H1 InteriorTopspace;
    CIC βŠ‚ topspace Ξ±  ∧  IC βŠ‚ CIC  ∧  βˆ€u. u βŠ‚ CIC ∧ open_in Ξ± u β‡’ u βŠ‚ IC     [] by fol ICdefs Ctop - ClosureTopspace ClosureSubset InteriorSubset SubsetClosure H1 ClosureClosure SUBSET_TRANS OpenSubsetInterior;
    fol ICdefs - Ctop OpenInterior InteriorUnique;
  qed;
`;;

let ClosureInteriorIdemp = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    Closure Ξ± (Interior Ξ± (Closure Ξ± (Interior Ξ± s)))
    = Closure Ξ± (Interior Ξ± s)

  proof
    intro_TAC βˆ€Ξ± s, H1;
    consider t such that t = topspace Ξ± ━ s     [tDef] by fol;
    t βŠ‚ topspace Ξ±  ∧  s = topspace Ξ± ━ t     [tProps] by fol - H1 SUBSET_DIFF DIFF_REFL;
    Interior Ξ± (Closure Ξ± t) βŠ‚ topspace Ξ±     [] by fol - ClosureTopspace InteriorTopspace;
    simplify tProps - GSYM InteriorClosureComplement InteriorClosureIdemp;
  qed;
`;;

let InteriorClosureDiffSpaceEmpty = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Interior Ξ± (Closure Ξ± s ━ s) = βˆ…

  proof
    intro_TAC βˆ€Ξ± s, H1;
    Closure Ξ± s ━ s βŠ‚ topspace Ξ±     [Cs_sTop] by fol H1 ClosureTopspace SUBSET_DIFF SUBSET_TRANS;
    assume Β¬(Interior Ξ± (Closure Ξ± s ━ s) = βˆ…)     [Contradiction] by fol;
    consider x such that
    x ∈ (Interior Ξ± (Closure Ξ± s ━ s))     [xExists] by fol - MEMBER_NOT_EMPTY;
    consider t such that
    open_in Ξ± t ∧ x ∈ t ∧ t βŠ‚ (s βˆͺ LimitPointOf Ξ± s) ━ s     [tProps] by fol - Cs_sTop IN_Interior Closure_DEF;
    t βŠ‚ LimitPointOf Ξ± s ∧ s ∩ (t ━ {x}) = βˆ…     [tSubLIMs] by set -;
    x ∈ LimitPointOf Ξ± s ∧ x βˆ‰ s     [xLims] by fol tProps - SUBSET IN_DIFF βˆ‰;
    fol H1 xLims IN_LimitPointOf tProps tSubLIMs NotLimitPointOf βˆ‰;
  qed;
`;;

let NowhereDenseUnion = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’
    (Interior Ξ± (Closure Ξ± (s βˆͺ t)) = βˆ…  ⇔
    Interior Ξ± (Closure Ξ± s) = βˆ…  ∧  Interior Ξ± (Closure Ξ± t) = βˆ…)

  proof
    intro_TAC βˆ€Ξ± s t, H1;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±     [] by fol H1 UNION_SUBSET;
    simplify H1 - ClosureUnion ClosureTopspace UNION_SUBSET ClosedClosure InteriorUnionEqEmpty;
  qed;
`;;

let NowhereDense = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    (Interior Ξ± (Closure Ξ± s) = βˆ… ⇔
    βˆ€t. open_in Ξ± t ∧ Β¬(t = βˆ…)  β‡’
    βˆƒu. open_in Ξ± u ∧ Β¬(u = βˆ…) ∧ u βŠ‚ t ∧ u ∩ s = βˆ…)

  proof
    intro_TAC βˆ€Ξ± s, H1;
    simplify H1 ClosureTopspace InteriorEqEmptyAlt;
    eq_tac     [Left]
    proof
      intro_TAC H2, βˆ€[t], tOpen tNonempty;
      exists_TAC t ━ Closure Ξ± s;
      fol tOpen H1 ClosedClosure OPEN_IN_DIFF tOpen tNonempty H2 SUBSET_DIFF H1 ClosureSubset
      SET_RULE [βˆ€s t A.  s βŠ‚ t  β‡’  (A ━ t) ∩ s = βˆ…];
    qed;
    intro_TAC H2, βˆ€[t], tOpen tNonempty;
    consider u such that
    open_in Ξ± u ∧ Β¬(u = βˆ…) ∧ u βŠ‚ t ∧ u ∩ s = βˆ…     [uExists] by simplify tOpen tNonempty H2;
    MP_TAC ISPECL [Ξ±; u; s] OpenInterClosureEqEmpty;
    simplify uExists OPEN_IN_SUBSET H1;
    set uExists;
  qed;
`;;

let InteriorClosureInterOpen = theorem `;
  βˆ€Ξ± s t.  open_in Ξ± s ∧ open_in Ξ± t  β‡’
    Interior α (Closure α (s ∩ t)) =
    Interior α (Closure α s) ∩ Interior α (Closure α t)

  proof
    intro_TAC βˆ€Ξ± s t, sOpen tOpen;
    s βŠ‚ topspace Ξ±     [sTop] by fol sOpen OPEN_IN_SUBSET;
    t βŠ‚ topspace Ξ±     [tTop] by fol tOpen OPEN_IN_SUBSET;
    rewrite SET_RULE [βˆ€s t u. u = s ∩ t  ⇔  s ∩ t βŠ‚ u ∧ u βŠ‚ s ∧ u βŠ‚ t];
    simplify sTop tTop INTER_SUBSET SubsetClosure ClosureTopspace SubsetInterior;
    s ∩ t βŠ‚ topspace Ξ±     [stTop] by fol INTER_SUBSET sTop SUBSET_TRANS;
    Closure Ξ± s βŠ‚ topspace Ξ±  ∧  Closure Ξ± t βŠ‚ topspace Ξ±     [CsCtTop] by fol sTop tTop ClosureTopspace;
    Closure Ξ± s ∩ Closure Ξ± t βŠ‚ topspace Ξ±     [CsIntCtTop] by fol - INTER_SUBSET SUBSET_TRANS;
    Closure Ξ± s ━ s βˆͺ Closure Ξ± t ━ t  βŠ‚  topspace Ξ±     [Cs_sUNIONCt_tTop] by fol CsCtTop SUBSET_DIFF UNION_SUBSET SUBSET_TRANS;
    simplify CsCtTop GSYM InteriorInter;
    Interior Ξ± (Closure Ξ± s ∩ Closure Ξ± t) βŠ‚ Closure Ξ± (s ∩ t)     []
    proof
      simplify CsIntCtTop InteriorTopspace ISPECL [topspace Ξ±] COMPLEMENT_DISJOINT stTop ClosureTopspace GSYM ClosureComplement GSYM InteriorComplement CsIntCtTop SUBSET_DIFF GSYM InteriorInter;
      closed_in Ξ± (Closure Ξ± s ━ s) ∧ closed_in Ξ± (Closure Ξ± t ━ t)     [] by fol sTop tTop ClosedClosure sOpen tOpen CLOSED_IN_DIFF;
      Interior Ξ± (Closure Ξ± s ━ s βˆͺ Closure Ξ± t ━ t) = βˆ…     [IntEmpty] by fol Cs_sUNIONCt_tTop - sTop tTop InteriorClosureDiffSpaceEmpty InteriorUnionEqEmpty;
      Closure Ξ± s ∩ Closure Ξ± t ∩ (topspace Ξ± ━ (s ∩ t))  βŠ‚
      Closure Ξ± s ━ s βˆͺ Closure Ξ± t ━ t     [] by set;
      fol Cs_sUNIONCt_tTop - SubsetInterior IntEmpty INTER_ACI SUBSET_EMPTY;
    qed;
    fol stTop ClosureTopspace - CsIntCtTop OpenInterior InteriorMaximal;
  qed;
`;;

let ClosureInteriorUnionClosed = theorem `;
  βˆ€Ξ± s t.   closed_in Ξ± s ∧ closed_in Ξ± t β‡’
    Closure Ξ± (Interior Ξ± (s βˆͺ t))  =
    Closure Ξ± (Interior Ξ± s) βˆͺ Closure Ξ± (Interior Ξ± t)

  proof
    rewrite closed_in;
    intro_TAC βˆ€Ξ± s t, sClosed tClosed;
    simplify sClosed tClosed ClosureTopspace UNION_SUBSET InteriorTopspace ISPECL [topspace Ξ±] COMPLEMENT_DUALITY_UNION;
    simplify sClosed tClosed UNION_SUBSET ClosureTopspace InteriorTopspace ClosureInteriorComplement DIFF_UNION SUBSET_DIFF InteriorClosureInterOpen;
  qed;
`;;

let RegularOpenInter = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    Interior α (Closure α s) = s ∧ Interior α (Closure α t) = t
    β‡’ Interior Ξ± (Closure Ξ± (s ∩ t)) = s ∩ t
  by fol ClosureTopspace OpenInterior InteriorClosureInterOpen`;;

let RegularClosedUnion = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    Closure α (Interior α s) = s  ∧  Closure α (Interior α t) = t
    β‡’ Closure Ξ± (Interior Ξ± (s βˆͺ t)) = s βˆͺ t
  by fol InteriorTopspace ClosureInteriorUnionClosed ClosedClosure`;;

let DiffClosureSubset = theorem `;
  βˆ€Ξ± s t.  s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±  β‡’
    Closure Ξ± s ━ Closure Ξ± t βŠ‚ Closure Ξ± (s ━ t)

  proof
    intro_TAC βˆ€Ξ± s t, sTop tTop;
    Closure Ξ± s ━ Closure Ξ± t βŠ‚ Closure Ξ± (s ━ Closure Ξ± t)     [] by fol sTop ClosureTopspace tTop ClosedClosure tTop closed_in OpenInterClosureSubset INTER_COMM COMPLEMENT_INTER_DIFF;
    fol - tTop ClosureSubset SUBSET_DUALITY sTop SUBSET_DIFF SUBSET_TRANS SubsetClosure;
  qed;
`;;

let Frontier_DEF = NewDefinition `;
  βˆ€Ξ± s.  Frontier Ξ± s = Closure Ξ± s ━ Interior Ξ± s`;;

let Frontier_THM = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Frontier Ξ± s = Closure Ξ± s ━ Interior Ξ± s
  by fol Frontier_DEF`;;

let FrontierTopspace = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Frontier Ξ± s βŠ‚ topspace Ξ±
  by fol Frontier_THM SUBSET_DIFF ClosureTopspace SUBSET_TRANS`;;

let FrontierClosed = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  closed_in Ξ± (Frontier Ξ± s)
  by simplify Frontier_THM ClosedClosure OpenInterior CLOSED_IN_DIFF`;;

let FrontierClosures = theorem `;
  βˆ€s.  s βŠ‚ topspace Ξ±  β‡’
    Frontier Ξ± s  =  (Closure Ξ± s) ∩ (Closure Ξ± (topspace Ξ± ━ s))
  by simplify SET_RULE [βˆ€A s t.  s βŠ‚ A ∧ t βŠ‚ A   β‡’  s ━ (A ━ t) = s ∩ t] Frontier_THM InteriorClosure ClosureTopspace SUBSET_DIFF`;;

let FrontierStraddle = theorem `;
  βˆ€Ξ± a s.  s βŠ‚ topspace Ξ±  β‡’  (a ∈ Frontier Ξ± s  ⇔
    a ∈ topspace Ξ±  ∧  βˆ€t. open_in Ξ± t ∧ a ∈ t  β‡’
    (βˆƒx. x ∈ s ∧ x ∈ t)  ∧  (βˆƒx. Β¬(x ∈ s) ∧ x ∈ t))

  proof
    simplify SUBSET_DIFF FrontierClosures IN_INTER SUBSET_DIFF IN_Closure IN_DIFF;
    fol OPEN_IN_SUBSET SUBSET;
  qed;
`;;

let FrontierSubsetClosed = theorem `;
  βˆ€Ξ± s.  closed_in Ξ± s  β‡’  (Frontier Ξ± s) βŠ‚ s
  by fol closed_in Frontier_THM ClosureClosed SUBSET_DIFF`;;

let FrontierEmpty = theorem `;
  βˆ€Ξ±.  Frontier Ξ± βˆ… = βˆ…
  by fol Frontier_THM EMPTY_SUBSET ClosureEmpty EMPTY_DIFF`;;

let FrontierUniv = theorem `;
  βˆ€Ξ±. Frontier Ξ± (topspace Ξ±) = βˆ…
  by fol Frontier_DEF ClosureUniv InteriorUniv DIFF_EQ_EMPTY`;;

let FrontierSubsetEq = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  ((Frontier Ξ± s) βŠ‚ s ⇔ closed_in Ξ± s)

  proof
    intro_TAC βˆ€Ξ± s, sTop;
    eq_tac     [Right] by fol FrontierSubsetClosed;
    simplify sTop Frontier_THM ;
    fol sTop InteriorSubset SET_RULE [βˆ€s t u. s ━ t βŠ‚ u ∧ t βŠ‚ u β‡’ s βŠ‚ u] ClosureSubsetEq;
  qed;
`;;

let FrontierComplement = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Frontier Ξ± (topspace Ξ± ━ s) = Frontier Ξ± s

  proof
    intro_TAC βˆ€Ξ± s, sTop;
    simplify sTop SUBSET_DIFF Frontier_THM ClosureComplement InteriorComplement;
    fol sTop InteriorTopspace ClosureTopspace SET_RULE [βˆ€ Top Int Clo.
    Int βŠ‚ Top ∧ Clo βŠ‚ Top  β‡’  Top ━ Int ━ (Top ━ Clo) = Clo ━ Int];
  qed;
`;;

let FrontierComplement = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Frontier Ξ± (topspace Ξ± ━ s) = Frontier Ξ± s

  proof
    intro_TAC βˆ€Ξ± s, sTop;
    simplify sTop SUBSET_DIFF Frontier_THM ClosureComplement InteriorComplement;
    fol sTop InteriorTopspace ClosureTopspace SET_RULE [βˆ€ Top Int Clo.
    Int βŠ‚ Top ∧ Clo βŠ‚ Top  β‡’  Top ━ Int ━ (Top ━ Clo) = Clo ━ Int];
  qed;
`;;

let FrontierDisjointEq = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±   β‡’  ((Frontier Ξ± s) ∩ s = βˆ…  ⇔  open_in Ξ± s)

  proof
    intro_TAC βˆ€Ξ± s, sTop;
    topspace Ξ± ━ s βŠ‚ topspace Ξ±     [COMPsTop] by fol sTop SUBSET_DIFF;
    simplify sTop GSYM FrontierComplement OPEN_IN_CLOSED_IN;
    fol COMPsTop GSYM FrontierSubsetEq FrontierTopspace SUBSET_COMPLEMENT;
  qed;
`;;

let FrontierInterSubset = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’  Frontier Ξ± (s ∩ t)  βŠ‚  Frontier Ξ± s βˆͺ Frontier Ξ± t

  proof
    intro_TAC βˆ€Ξ± s t, H1;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ± ∧ s ∩ t βŠ‚ topspace Ξ±     [] by fol H1 SUBSET_UNION INTER_SUBSET SUBSET_TRANS;
    simplify - Frontier_THM InteriorInter DIFF_INTER INTER_SUBSET SubsetClosure DIFF_SUBSET UNION_TENSOR;
  qed;
`;;

let FrontierUnionSubset = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’
    Frontier Ξ± (s βˆͺ t)  βŠ‚  Frontier Ξ± s βˆͺ Frontier Ξ± t

  proof
    intro_TAC βˆ€Ξ± s t, H1;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±     [stTop] by fol H1 SUBSET_UNION SUBSET_TRANS;
    simplify H1 - GSYM FrontierComplement DIFF_UNION;
    topspace Ξ± ━ s βˆͺ topspace Ξ± ━ t βŠ‚ topspace Ξ±     [] by fol SUBSET_DIFF UNION_SUBSET SUBSET_TRANS;
    fol - FrontierInterSubset;
  qed;
`;;

let FrontierInteriors = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    Frontier Ξ± s = topspace Ξ± ━ Interior Ξ± s ━ Interior Ξ± (topspace Ξ± ━ s)
  by simplify Frontier_THM ClosureInterior DOUBLE_DIFF_UNION UNION_COMM`;;

let FrontierFrontierSubset = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Frontier Ξ± (Frontier Ξ± s) βŠ‚ Frontier Ξ± s
  by fol FrontierTopspace Frontier_THM FrontierClosed ClosureClosed SUBSET_DIFF`;;

let InteriorFrontier = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Interior Ξ± (Frontier Ξ± s)  =
    Interior Ξ± (Closure Ξ± s) ━ Closure Ξ± (Interior Ξ± s)

  proof
    intro_TAC βˆ€Ξ± s, sTop;
    Frontier Ξ± s = Closure Ξ± s ∩ (topspace Ξ± ━ Interior Ξ± s)     [] by fol sTop Frontier_THM ClosureTopspace COMPLEMENT_INTER_DIFF;
    Interior Ξ± (Frontier Ξ± s)  =
    Interior Ξ± (Closure Ξ± s) ∩ (topspace Ξ± ━ Closure Ξ± (Interior Ξ± s))     [] by fol - sTop ClosureTopspace InteriorTopspace SUBSET_DIFF InteriorInter InteriorComplement;
    fol - sTop ClosureTopspace InteriorTopspace COMPLEMENT_INTER_DIFF;
  qed;
`;;

let InteriorFrontierEmpty = theorem `;
  βˆ€Ξ± s.  open_in Ξ± s ∨ closed_in Ξ± s  β‡’  Interior Ξ± (Frontier Ξ± s) = βˆ…
  by fol InteriorFrontier SET_RULE [βˆ€s t. s ━ t = βˆ… ⇔ s βŠ‚ t] OPEN_IN_SUBSET closed_in
  InteriorOpen ClosureTopspace InteriorSubset
  ClosureClosed InteriorTopspace ClosureSubset`;;

let FrontierFrontier = theorem `;
  βˆ€Ξ± s.  open_in Ξ± s ∨ closed_in Ξ± s  β‡’
    Frontier Ξ± (Frontier Ξ± s) = Frontier Ξ± s

  proof
    intro_TAC βˆ€Ξ± s, openORclosed;
    s βŠ‚ topspace Ξ±     [sTop] by fol openORclosed OPEN_IN_SUBSET closed_in;
    Frontier Ξ± (Frontier Ξ± s) = Closure Ξ± (Frontier Ξ± s)     [] by fol sTop FrontierTopspace Frontier_THM openORclosed InteriorFrontierEmpty DIFF_EMPTY;
    fol - sTop FrontierClosed ClosureClosed;
  qed;
`;;

let UnionFrontierPart1 = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’
    Frontier Ξ± s ∩ Interior Ξ± t  βŠ‚  Frontier  Ξ± (s ∩ t)

  proof
    intro_TAC βˆ€Ξ± s t, H1;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ± ∧ s ∩ t βŠ‚ topspace Ξ±     [stTop] by fol H1 SUBSET_UNION INTER_SUBSET SUBSET_TRANS;
    rewrite SUBSET IN_INTER;
    intro_TAC βˆ€[a], aFs aIt;
    consider O such that
    open_in Ξ± O ∧ a ∈ O ∧ O βŠ‚ t     [aOs] by fol aIt stTop IN_Interior;
    a ∈ topspace α     [] by fol stTop aFs FrontierTopspace SUBSET;
    simplify stTop FrontierStraddle -;
    intro_TAC βˆ€[P], Popen aP;
    a ∈ O ∩ P ∧ open_in α (O ∩ P)     [aOPopen] by fol aOs aP IN_INTER Popen OPEN_IN_INTER;
    consider x y such that
    x ∈ s ∧ x ∈ O ∩ P ∧ ¬(y ∈ s) ∧ y ∈ O ∩ P     [xExists] by fol aOs Popen OPEN_IN_INTER aOPopen stTop aFs FrontierStraddle;
    fol xExists aOs IN_INTER SUBSET;
  qed;
`;;

let UnionFrontierPart2 = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’
    Frontier Ξ± s ━ Frontier Ξ± t  βŠ‚
    Frontier Ξ± (s ∩ t) βˆͺ Frontier Ξ± (s βˆͺ t)

  proof
    intro_TAC βˆ€Ξ± s t, stTop;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±     [] by fol stTop SUBSET_UNION INTER_SUBSET SUBSET_TRANS;
    Frontier Ξ± s ━ Frontier Ξ± t = Frontier Ξ± s ∩ Interior Ξ± t  βˆͺ
    Frontier Ξ± (topspace Ξ± ━ s) ∩ Interior Ξ± (topspace Ξ± ━ t)     [] by fol - FrontierTopspace FrontierInteriors FrontierComplement
    SET_RULE [βˆ€A s t u. s βŠ‚ A  β‡’  s ━ (A ━ t ━ u) = s ∩ t βˆͺ s ∩ u];
    Frontier Ξ± s ━ Frontier Ξ± t  βŠ‚
    Frontier Ξ± (s ∩ t) βˆͺ  Frontier Ξ± (topspace Ξ± ━ (s βˆͺ t))     [] by simplify - stTop UnionFrontierPart1 UNION_TENSOR SUBSET_DIFF UNION_SUBSET DIFF_UNION;
    fol - stTop FrontierComplement;
  qed;
`;;

let UnionFrontierPart3 = theorem `;
  βˆ€Ξ± s t a.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’
    a ∈ Frontier Ξ± s ∧ a βˆ‰ Frontier Ξ± t  β‡’
    a ∈ Frontier Ξ± (s ∩ t)  ∨  a ∈ Frontier Ξ± (s βˆͺ t)

  proof
    intro_TAC βˆ€Ξ± s t a, H1;
    rewrite βˆ‰ GSYM IN_INTER GSYM IN_DIFF GSYM IN_UNION;
    fol H1 UnionFrontierPart2 SUBSET;
  qed;
`;;

let UnionFrontier = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’
    Frontier Ξ± s βˆͺ Frontier Ξ± t =
    Frontier Ξ± (s βˆͺ t) βˆͺ Frontier Ξ± (s ∩ t) βˆͺ Frontier Ξ± s ∩ Frontier Ξ± t

  proof
    intro_TAC βˆ€Ξ± s t, H1;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±     [stTop] by fol H1 SUBSET_UNION INTER_SUBSET SUBSET_TRANS;
    rewrite GSYM SUBSET_ANTISYM_EQ;
    conj_tac     [Right] by fol SET_RULE [βˆ€s t. s ∩ t βŠ‚ s βˆͺ t] stTop FrontierUnionSubset UNION_SUBSET FrontierInterSubset;
    rewrite SUBSET IN_INTER IN_UNION;
    fol H1 UnionFrontierPart3 INTER_COMM UNION_COMM βˆ‰;
  qed;
`;;

let ConnectedInterFrontier = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’
    Connected (subtopology Ξ± s) ∧ Β¬(s ∩ t = βˆ…) ∧ Β¬(s ━ t = βˆ…)
    β‡’ Β¬(s ∩ Frontier Ξ± t = βˆ…)

  proof
    intro_TAC βˆ€Ξ± s t, H1;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ±     [stTop] by fol H1 SUBSET_UNION SUBSET_TRANS;
    ONCE_REWRITE_TAC TAUT [βˆ€a b c d. a ∧ b ∧ c β‡’ Β¬d  ⇔  b ∧ c ∧ d β‡’ Β¬a];
    intro_TAC sINTERtNonempty sDIFFtNonempty sInterFtEmpty;
    simplify stTop ConnectedOpenIn;
    exists_TAC s ∩ Interior α t;
    exists_TAC s ∩ Interior Ξ± (topspace Ξ±  ━  t);
    simplify stTop SUBSET_DIFF OpenInterior OpenInOpenInter;
    Interior Ξ± t βŠ‚ t  ∧  Interior Ξ± (topspace Ξ± ━ t) βŠ‚ topspace Ξ± ━ t     [IntSubs] by fol stTop SUBSET_DIFF InteriorSubset;
    s  βŠ‚  Interior Ξ± t βˆͺ Interior Ξ± (topspace Ξ± ━ t)     [] by fol stTop sInterFtEmpty FrontierInteriors DOUBLE_DIFF_UNION COMPLEMENT_DISJOINT;
    set sDIFFtNonempty sINTERtNonempty IntSubs -;
  qed;
`;;

let InteriorClosedEqEmptyAsFrontier = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’
    (closed_in Ξ± s ∧ Interior Ξ± s = βˆ…  ⇔  βˆƒt. open_in Ξ± t ∧ s = Frontier Ξ± t)

  proof
    intro_TAC βˆ€Ξ± s, sTop;
    eq_tac     [Right] by fol OPEN_IN_SUBSET FrontierClosed InteriorFrontierEmpty;
    intro_TAC sClosed sEmptyInt;
    exists_TAC topspace Ξ± ━ s;
    fol sClosed closed_in sTop FrontierComplement Frontier_THM sEmptyInt DIFF_EMPTY ClosureClosed;
  qed;
`;;

let ClosureUnionFrontier = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Closure Ξ± s = s βˆͺ Frontier Ξ± s

  proof
    intro_TAC βˆ€Ξ± s, sTop;
    simplify sTop Frontier_THM;
    s βŠ‚ Closure Ξ± s ∧ Interior Ξ± s βŠ‚ s     [] by fol sTop ClosureSubset InteriorSubset;
    set -;
  qed;
`;;

let FrontierInteriorSubset = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Frontier Ξ± (Interior Ξ± s) βŠ‚ Frontier Ξ± s
  by simplify InteriorTopspace Frontier_THM InteriorInterior InteriorSubset SubsetClosure DIFF_SUBSET`;;

let FrontierClosureSubset = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  Frontier Ξ± (Closure Ξ± s) βŠ‚ Frontier Ξ± s
  by simplify ClosureTopspace Frontier_THM ClosureClosure ClosureTopspace ClosureSubset SubsetInterior SUBSET_DUALITY`;;

let SetDiffFrontier = theorem `;
  βˆ€Ξ± s.  s βŠ‚ topspace Ξ±  β‡’  s ━ Frontier Ξ± s = Interior Ξ± s

  proof
    intro_TAC βˆ€Ξ± s, sTop;
    simplify sTop Frontier_THM;
    s βŠ‚ Closure Ξ± s ∧ Interior Ξ± s βŠ‚ s     [] by fol sTop ClosureSubset InteriorSubset;
    set -;
  qed;
`;;

let FrontierInterSubsetInter = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’
    Frontier Ξ± (s ∩ t)  βŠ‚
    Closure Ξ± s ∩ Frontier Ξ± t  βˆͺ  Frontier Ξ± s ∩ Closure Ξ± t

  proof
    intro_TAC βˆ€Ξ± s t, H1;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ± ∧ s ∩ t βŠ‚ topspace Ξ±     [stTop] by fol H1 SUBSET_UNION INTER_SUBSET SUBSET_TRANS;
    simplify H1 stTop Frontier_THM InteriorInter;
    Closure Ξ± (s ∩ t) βŠ‚ Closure Ξ± s ∩ Closure Ξ± t     [] by fol stTop ClosureInterSubset;
    set -;
  qed;
`;;

let FrontierUnionPart1 = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’  Closure Ξ± s ∩ Closure Ξ± t = βˆ…
    β‡’ Frontier Ξ± s ∩ Interior Ξ± (s βˆͺ t) = βˆ…

  proof
    intro_TAC βˆ€Ξ± s t, H1, CsCtDisjoint;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ± ∧ s ∩ t βŠ‚ topspace Ξ±     [stTop] by fol H1 SUBSET_UNION INTER_SUBSET SUBSET_TRANS;
    Frontier Ξ± s ∩ Interior Ξ± (s βˆͺ t)  βŠ‚ topspace Ξ±     [FIstTop] by fol stTop FrontierTopspace INTER_SUBSET SUBSET_TRANS;
    Frontier Ξ± s ∩ Interior Ξ± (s βˆͺ t) ∩ (topspace Ξ± ━ Closure Ξ± t) = βˆ…     []
    proof
      simplify stTop GSYM InteriorComplement H1 SUBSET_DIFF InteriorInter Frontier_THM;
      Interior Ξ± (s βˆͺ t) ∩ Interior Ξ± (topspace Ξ± ━ t)  βŠ‚ Interior Ξ± s     [] by
      fol SET_RULE [βˆ€A s t. s βŠ‚ A  β‡’  (s βˆͺ t) ∩ (A ━ t) = s ━ t] H1 SUBSET_DIFF InteriorInter stTop SubsetInterior;
      set -;
    qed;
    Frontier Ξ± s ∩ Interior Ξ± (s βˆͺ t)  βŠ‚  Closure Ξ± t     [] by fol H1 CsCtDisjoint - FIstTop COMPLEMENT_DISJOINT INTER_ACI;
    fol SET_RULE [βˆ€ s t F I. s ∩ t = βˆ… ∧ F βŠ‚ s ∧ F ∩ I βŠ‚ t  β‡’  F ∩ I = βˆ…] CsCtDisjoint stTop Frontier_THM SUBSET_DIFF  -;
  qed;
`;;

let FrontierUnion = theorem `;
  βˆ€Ξ± s t.  s βˆͺ t βŠ‚ topspace Ξ±  β‡’  Closure Ξ± s ∩ Closure Ξ± t = βˆ…
    β‡’ Frontier Ξ± (s βˆͺ t) = Frontier Ξ± s βˆͺ Frontier Ξ± t

  proof
    intro_TAC βˆ€Ξ± s t, H1, CsCtDisjoint;
    s βŠ‚ topspace Ξ± ∧ t βŠ‚ topspace Ξ± ∧ s ∩ t βŠ‚ topspace Ξ±     [stTop] by fol H1 SUBSET_UNION INTER_SUBSET SUBSET_TRANS;
    MATCH_MP_TAC SUBSET_ANTISYM;
    simplify H1 FrontierUnionSubset Frontier_THM;
    Frontier Ξ± s ∩ Interior Ξ± (s βˆͺ t)  =  βˆ…  ∧
    Frontier Ξ± t ∩ Interior Ξ± (s βˆͺ t)  =  βˆ…     [usePart1] by fol H1 CsCtDisjoint FrontierUnionPart1 INTER_COMM UNION_COMM;
    Frontier Ξ± s βŠ‚ Closure Ξ± (s βˆͺ t)  ∧  Frontier Ξ± t βŠ‚ Closure Ξ± (s βˆͺ t)     [] by fol stTop Frontier_THM SUBSET_DIFF H1 SUBSET_UNION SubsetClosure SUBSET_TRANS;
    set usePart1 -;
  qed;
`;;

(* ------------------------------------------------------------------------- *)
(* The universal Euclidean versions are what we use most of the time.        *)
(* ------------------------------------------------------------------------- *)

let open_def = NewDefinition `;
  open s  ⇔  βˆ€x. x ∈ s β‡’ βˆƒe. &0 < e ∧ βˆ€x'. dist(x',x) < e β‡’ x' ∈ s`;;

let closed = NewDefinition `;
  closed s ⇔ open (UNIV ━ s)`;;

let euclidean = new_definition
 `euclidean = mk_topology (UNIV, open)`;;

let OPEN_EMPTY = theorem `;
  open βˆ…
  by rewrite open_def NOT_IN_EMPTY`;;

let OPEN_UNIV = theorem `;
  open UNIV
  by fol open_def IN_UNIV REAL_LT_01`;;

let OPEN_INTER = theorem `;
  βˆ€s t. open s ∧ open t β‡’ open (s ∩ t)

  proof
    intro_TAC βˆ€s t, sOpen tOpen;
    rewrite open_def IN_INTER;
    intro_TAC βˆ€x, xs xt;
    consider d1 such that
    &0 < d1 ∧ βˆ€x'. dist (x',x) < d1 β‡’ x' ∈ s     [d1Exists] by fol sOpen xs open_def;
    consider d2 such that
    &0 < d2 ∧ βˆ€x'. dist (x',x) < d2 β‡’ x' ∈ t     [d2Exists] by fol tOpen xt open_def;
    consider e such that &0 < e /\ e < d1 /\ e < d2     [eExists] by fol d1Exists d2Exists REAL_DOWN2;
    fol - d1Exists d2Exists REAL_LT_TRANS;
  qed;
`;;

let OPEN_UNIONS = theorem `;
  (βˆ€s. s ∈ f β‡’ open s)  β‡’  open (UNIONS f)
  by fol open_def IN_UNIONS`;;

let IstopologyEuclidean = theorem `;
    istopology (UNIV, open)
    by simplify istopology IN IN_UNIV SUBSET OPEN_EMPTY OPEN_UNIV OPEN_INTER OPEN_UNIONS`;;

let OPEN_IN = theorem `;
  open  =  open_in euclidean
  by fol euclidean topology_tybij IstopologyEuclidean TopologyPAIR PAIR_EQ`;;

let TOPSPACE_EUCLIDEAN = theorem `;
  topspace euclidean = UNIV
  by fol euclidean IstopologyEuclidean topology_tybij TopologyPAIR PAIR_EQ`;;

let OPEN_EXISTS_IN = theorem `;
  βˆ€P Q.  (βˆ€a. P a β‡’ open {x | Q a x})  β‡’  open {x | βˆƒa. P a ∧ Q a x}
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN OPEN_IN OPEN_IN_EXISTS_IN`;;

let OPEN_EXISTS = theorem `;
  βˆ€Q.  (βˆ€a. open {x | Q a x})  β‡’  open {x | βˆƒa. Q a x}

  proof
    intro_TAC βˆ€Q;
    (βˆ€a. T β‡’ open {x | Q a x}) β‡’ open {x | βˆƒa. T ∧ Q a x}     [] by simplify OPEN_EXISTS_IN;
    MP_TAC -;
    fol;
  qed;
`;;

let TOPSPACE_EUCLIDEAN_SUBTOPOLOGY = theorem `;
 βˆ€s. topspace (subtopology euclidean s) = s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN TopspaceSubtopology`;;

let OPEN_IN_REFL = theorem `;
  βˆ€s. open_in (subtopology euclidean s) s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN OpenInRefl`;;

let CLOSED_IN_REFL = theorem `;
  βˆ€s. closed_in (subtopology euclidean s) s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN ClosedInRefl`;;

let CLOSED_IN = theorem `;
  βˆ€s. closed  =  closed_in euclidean
  by fol closed closed_in TOPSPACE_EUCLIDEAN OPEN_IN SUBSET_UNIV EXTENSION IN`;;

let OPEN_UNION = theorem `;
  βˆ€s t.  open s ∧ open t  β‡’  open(s βˆͺ t)
  by fol OPEN_IN OPEN_IN_UNION`;;

let OPEN_SUBOPEN = theorem `;
  βˆ€s. open s ⇔ βˆ€x. x ∈ s β‡’ βˆƒt. open t ∧ x ∈ t ∧ t βŠ‚ s
  by fol OPEN_IN OPEN_IN_SUBOPEN`;;

let CLOSED_EMPTY = theorem `;
  closed βˆ…
  by fol CLOSED_IN CLOSED_IN_EMPTY`;;

let CLOSED_UNIV = theorem `;
  closed UNIV
  by fol CLOSED_IN TOPSPACE_EUCLIDEAN CLOSED_IN_TOPSPACE`;;

let CLOSED_UNION = theorem `;
  βˆ€s t.  closed s ∧ closed t  β‡’  closed(s βˆͺ t)
  by fol CLOSED_IN CLOSED_IN_UNION`;;

let CLOSED_INTER = theorem `;
  βˆ€s t.  closed s ∧ closed t  β‡’  closed(s ∩ t)
  by fol CLOSED_IN CLOSED_IN_INTER`;;

let CLOSED_INTERS = theorem `;
  βˆ€f. (βˆ€s. s ∈ f β‡’ closed s)  β‡’  closed (INTERS f)
  by fol CLOSED_IN CLOSED_IN_INTERS INTERS_0 CLOSED_UNIV`;;

let CLOSED_FORALL_IN = theorem `;
  βˆ€P Q.  (βˆ€a. P a β‡’ closed {x | Q a x})
    β‡’  closed {x | βˆ€a. P a β‡’ Q a x}

  proof
    intro_TAC βˆ€P Q;
    case_split Pnonempty | Pempty by fol;
    suppose Β¬(P = βˆ…);
      simplify CLOSED_IN Pnonempty CLOSED_IN_FORALL_IN;
    end;
    suppose P = βˆ…;
      {x | βˆ€a. P a β‡’ Q a x} = UNIV     [] by set Pempty;
      simplify - CLOSED_UNIV;
    end;
  qed;
`;;

let CLOSED_FORALL = theorem `;
  βˆ€Q. (βˆ€a. closed {x | Q a x}) β‡’ closed {x | βˆ€a. Q a x}

  proof
    intro_TAC βˆ€Q;
    (βˆ€a. T β‡’ closed {x | Q a x}) β‡’ closed {x | βˆ€a. T β‡’ Q a x}     [] by simplify CLOSED_FORALL_IN;
    MP_TAC -;
    fol;
  qed;
`;;

let OPEN_CLOSED = theorem `;
  βˆ€s.  open s  ⇔  closed(UNIV ━ s)
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN OPEN_IN CLOSED_IN OPEN_IN_CLOSED_IN`;;

let OPEN_DIFF = theorem `;
  βˆ€s t.  open s ∧ closed t  β‡’  open(s ━ t)
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN OPEN_IN CLOSED_IN OPEN_IN_DIFF`;;

let CLOSED_DIFF = theorem `;
  βˆ€s t.  closed s ∧ open t  β‡’  closed (s ━ t)
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN OPEN_IN CLOSED_IN CLOSED_IN_DIFF`;;

let OPEN_INTERS = theorem `;
  βˆ€s.  FINITE s ∧ (βˆ€t. t ∈ s β‡’ open t)  β‡’  open (INTERS s)
  by fol OPEN_IN OPEN_IN_INTERS INTERS_0 OPEN_UNIV`;;

let CLOSED_UNIONS = theorem `;
  βˆ€s.  FINITE s ∧ (βˆ€t. t ∈ s β‡’ closed t)  β‡’  closed (UNIONS s)
  by fol CLOSED_IN CLOSED_IN_UNIONS`;;

(* ------------------------------------------------------------------------- *)
(* Open and closed balls and spheres.                                        *)
(* ------------------------------------------------------------------------- *)

let ball = new_definition
  `ball(x,e) = {y | dist(x,y) < e}`;;

let cball = new_definition
  `cball(x,e) = {y | dist(x,y) <= e}`;;

let IN_BALL = theorem `;
 βˆ€x y e. y ∈ ball(x,e)  ⇔  dist(x,y) < e
  by rewrite ball IN_ELIM_THM`;;

let IN_CBALL = theorem `;
  βˆ€x y e. y ∈ cball(x, e)  ⇔  dist(x, y) <= e
  by rewrite cball IN_ELIM_THM`;;

let BALL_SUBSET_CBALL = theorem `;
  βˆ€x e. ball (x,e) βŠ‚ cball (x, e)

  proof
     rewrite IN_BALL IN_CBALL SUBSET;
     real_arithmetic;
  qed;
`;;

let OPEN_BALL = theorem `;
  βˆ€x e. open (ball (x,e))

  proof
    rewrite open_def ball IN_ELIM_THM;
    fol DIST_SYM REAL_SUB_LT REAL_LT_SUB_LADD REAL_ADD_SYM REAL_LET_TRANS DIST_TRIANGLE;
  qed;
`;;

let CENTRE_IN_BALL = theorem `;
  βˆ€x e. x ∈ ball(x,e)  ⇔  &0 < e
  by fol IN_BALL DIST_REFL`;;

let OPEN_CONTAINS_BALL = theorem `;
  βˆ€s. open s  ⇔  βˆ€x. x ∈ s β‡’ βˆƒe. &0 < e ∧ ball(x,e) βŠ‚ s
  by rewrite open_def SUBSET IN_BALL DIST_SYM`;;

let HALF_CBALL_IN_BALL = theorem `;
  βˆ€e. &0 < e  β‡’  &0 < e/ &2 ∧ e / &2 < e ∧ cball (x, e/ &2) βŠ‚ ball (x, e)

  proof
    intro_TAC βˆ€e, H1;
     &0 < e/ &2  ∧  e / &2 < e     [] by real_arithmetic H1;
     fol - SUBSET IN_CBALL IN_BALL REAL_LET_TRANS;
  qed;
`;;

let OPEN_IN_CONTAINS_CBALL_LEMMA = theorem `;
  βˆ€t s x.  x ∈ s  β‡’
    ((βˆƒe. &0 < e ∧ ball (x, e) ∩ t βŠ‚ s) ⇔
    (βˆƒe. &0 < e ∧ cball (x, e) ∩ t βŠ‚ s))
  by fol BALL_SUBSET_CBALL HALF_CBALL_IN_BALL INTER_TENSOR SUBSET_REFL SUBSET_TRANS`;;

(* ------------------------------------------------------------------------- *)
(* Basic "localization" results are handy for connectedness.                 *)
(* ------------------------------------------------------------------------- *)

let OPEN_IN_OPEN = theorem `;
  βˆ€s u.  open_in (subtopology euclidean u) s  ⇔  βˆƒt. open t ∧ (s = u ∩ t)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN OPEN_IN OpenInSubtopology INTER_COMM`;;

let OPEN_IN_INTER_OPEN = theorem `;
  βˆ€s t u.  open_in (subtopology euclidean u) s  ∧  open t
    β‡’ open_in (subtopology euclidean u) (s ∩ t)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN OPEN_IN OpenInSubtopologyInterOpen`;;

let OPEN_IN_OPEN_INTER = theorem `;
  βˆ€u s.  open s  β‡’  open_in (subtopology euclidean u) (u ∩ s)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN OPEN_IN OpenInOpenInter`;;

let OPEN_OPEN_IN_TRANS = theorem `;
  βˆ€s t.  open s  ∧  open t  ∧  t βŠ‚ s
    β‡’ open_in (subtopology euclidean s) t
  by fol OPEN_IN OpenOpenInTrans`;;

let OPEN_SUBSET = theorem `;
  βˆ€s t.  s βŠ‚ t  ∧  open s  β‡’  open_in (subtopology euclidean t) s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN OPEN_IN OpenSubset`;;

let CLOSED_IN_CLOSED = theorem `;
  βˆ€s u.
    closed_in (subtopology euclidean u) s  ⇔  βˆƒt. closed t ∧ (s = u ∩ t)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN ClosedInSubtopology INTER_COMM`;;

let CLOSED_SUBSET_EQ = theorem `;
  βˆ€u s.  closed s  β‡’  (closed_in (subtopology euclidean u) s  ⇔  s βŠ‚ u)
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN ClosedSubsetEq`;;

let CLOSED_IN_INTER_CLOSED = theorem `;
  βˆ€s t u.  closed_in (subtopology euclidean u) s  ∧  closed t
    β‡’ closed_in (subtopology euclidean u) (s ∩ t)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN ClosedInInterClosed`;;

let CLOSED_IN_CLOSED_INTER = theorem `;
  βˆ€u s. closed s  β‡’  closed_in (subtopology euclidean u) (u ∩ s)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN ClosedInClosedInter`;;

let CLOSED_SUBSET = theorem `;
  βˆ€s t.  s βŠ‚ t ∧ closed s  β‡’  closed_in (subtopology euclidean t) s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN ClosedSubset`;;

let OPEN_IN_SUBSET_TRANS = theorem `;
  βˆ€s t u.  open_in (subtopology euclidean u) s  ∧  s βŠ‚ t  ∧  t βŠ‚ u
    β‡’ open_in (subtopology euclidean t) s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN OpenInSubsetTrans`;;

let CLOSED_IN_SUBSET_TRANS = theorem `;
  βˆ€s t u.  closed_in (subtopology euclidean u) s  ∧  s βŠ‚ t  ∧  t βŠ‚ u
    β‡’ closed_in (subtopology euclidean t) s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN ClosedInSubsetTrans`;;

let OPEN_IN_CONTAINS_BALL_LEMMA = theorem `;
  βˆ€t s x.  x ∈ s  β‡’
    ((βˆƒE. open E  ∧  x ∈ E  ∧  E ∩ t βŠ‚ s)  ⇔
    (βˆƒe. &0 < e  ∧  ball (x,e) ∩ t βŠ‚ s))

  proof
    intro_TAC βˆ€ t s x, xs;
    eq_tac     [Right] by fol CENTRE_IN_BALL OPEN_BALL;
    intro_TAC H2;
    consider a such that
    open a ∧ x ∈ a ∧ a ∩ t βŠ‚ s     [aExists] by fol H2;
    consider e such that
    &0 < e ∧ ball(x,e) βŠ‚ a     [eExists] by fol - OPEN_CONTAINS_BALL;
    fol aExists - INTER_SUBSET GSYM SUBSET_INTER SUBSET_TRANS;
  qed;
`;;

let OPEN_IN_CONTAINS_BALL = theorem `;
  βˆ€s t.  open_in (subtopology euclidean t) s  ⇔
    s βŠ‚ t  ∧  βˆ€x. x ∈ s β‡’ βˆƒe. &0 < e ∧ ball(x,e) ∩ t βŠ‚ s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN SubtopologyOpenInSubopen GSYM OPEN_IN GSYM OPEN_IN_CONTAINS_BALL_LEMMA`;;

let OPEN_IN_CONTAINS_CBALL = theorem `;
  βˆ€s t.  open_in (subtopology euclidean t) s  ⇔
    s βŠ‚ t  ∧  βˆ€x. x ∈ s β‡’ βˆƒe. &0 < e ∧ cball(x,e) ∩ t βŠ‚ s
  by fol OPEN_IN_CONTAINS_BALL OPEN_IN_CONTAINS_CBALL_LEMMA`;;

let open_in = theorem `;
  βˆ€u s.  open_in (subtopology euclidean u) s   ⇔
    s βŠ‚ u  ∧
    βˆ€x. x ∈ s β‡’ βˆƒe. &0 < e ∧
    βˆ€x'. x' ∈ u ∧ dist(x',x) < e β‡’ x' ∈ s
  by rewrite OPEN_IN_CONTAINS_BALL IN_INTER SUBSET IN_BALL CONJ_SYM DIST_SYM`;;

(* ------------------------------------------------------------------------- *)
(* These "transitivity" results are handy too.                               *)
(* ------------------------------------------------------------------------- *)

let OPEN_IN_TRANS = theorem `;
  βˆ€s t u. open_in (subtopology euclidean t) s  ∧
    open_in (subtopology euclidean u) t
    β‡’ open_in (subtopology euclidean u) s

  proof
    intro_TAC βˆ€s t u;
    t βŠ‚ topspace euclidean  ∧  u βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    fol - OPEN_IN OpenInTrans;
  qed;
`;;

let OPEN_IN_TRANS_EQ = theorem `;
  βˆ€s t.  (βˆ€u. open_in (subtopology euclidean t) u
    β‡’  open_in (subtopology euclidean s) t)
    ⇔  open_in (subtopology euclidean s) t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN OpenInTransEq`;;

let OPEN_IN_OPEN_TRANS = theorem `;
  βˆ€u s.  open_in (subtopology euclidean u) s ∧ open u  β‡’  open s

  proof
    intro_TAC βˆ€u s, H1;
    u βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    fol - H1 OPEN_IN OpenInOpenTrans;
  qed;
`;;

let CLOSED_IN_TRANS = theorem `;
  βˆ€s t u.  closed_in (subtopology euclidean t) s  ∧
    closed_in (subtopology euclidean u) t
    β‡’ closed_in (subtopology euclidean u) s

  proof
    intro_TAC βˆ€s t u;
    t βŠ‚ topspace euclidean ∧ u βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    fol - ClosedInSubtopologyTrans;
  qed;
`;;

let CLOSED_IN_TRANS_EQ = theorem `;
  βˆ€s t.
    (βˆ€u. closed_in (subtopology euclidean t) u β‡’ closed_in (subtopology euclidean s) t)
    ⇔ closed_in (subtopology euclidean s) t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN ClosedInSubtopologyTransEq`;;

let CLOSED_IN_CLOSED_TRANS = theorem `;
  βˆ€s u. closed_in (subtopology euclidean u) s ∧ closed u β‡’ closed s

  proof
    intro_TAC βˆ€u s;
    u βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    fol - CLOSED_IN ClosedInClosedTrans;
  qed;
`;;

let OPEN_IN_SUBTOPOLOGY_INTER_SUBSET = theorem `;
  βˆ€s u v. open_in (subtopology euclidean u) (u ∩ s)  ∧  v βŠ‚ u
    β‡’ open_in (subtopology euclidean v) (v ∩ s)
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN OpenInSubtopologyInterSubset`;;

let OPEN_IN_OPEN_EQ = theorem `;
  βˆ€s t.  open s  β‡’  (open_in (subtopology euclidean s) t ⇔ open t ∧ t βŠ‚ s)
  by fol OPEN_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN OpenInOpenEq`;;

let CLOSED_IN_CLOSED_EQ = theorem `;
  βˆ€s t.  closed s  β‡’
    (closed_in (subtopology euclidean s) t ⇔ closed t ∧ t βŠ‚ s)
  by fol CLOSED_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN ClosedInClosedEq`;;

(* ------------------------------------------------------------------------- *)
(* Also some invariance theorems for relative topology.                      *)
(* ------------------------------------------------------------------------- *)

let OPEN_IN_INJECTIVE_LINEAR_IMAGE = theorem `;
  βˆ€f s t.  linear f ∧ (βˆ€x y. f x = f y β‡’ x = y) β‡’
    (open_in (subtopology euclidean (IMAGE f t)) (IMAGE f s) ⇔
    open_in (subtopology euclidean t) s)

  proof
    rewrite open_in FORALL_IN_IMAGE IMP_CONJ SUBSET;
    intro_TAC βˆ€f s t, H1, H2;
    βˆ€x s. f x ∈ IMAGE f s ⇔ x ∈ s     [fInjMap] by set H2;
    rewrite -;
    βˆ€x y. f x - f y = f (x - y)     [fSubLinear] by fol H1 LINEAR_SUB;
    consider B1 such that
    &0 < B1  ∧  βˆ€x. norm (f x) <= B1 * norm x     [B1exists] by fol H1 LINEAR_BOUNDED_POS;
    consider B2 such that
    &0 < B2  ∧  βˆ€x. norm x * B2 <= norm (f x)     [B2exists] by fol H1 H2 LINEAR_INJECTIVE_BOUNDED_BELOW_POS;
    AP_TERM_TAC;
    eq_tac     [Left]
    proof
      intro_TAC H3, βˆ€x, xs;
      consider e such that
      &0 < e  ∧  βˆ€x'. x' ∈ t β‡’ dist (f x',f x) < e β‡’ x' ∈ s     [eExists] by fol H3 xs;
      exists_TAC e / B1;
      simplify REAL_LT_DIV eExists B1exists;
      intro_TAC βˆ€x', x't;
      βˆ€x. norm(f x) <= B1 * norm(x)  ∧ norm(x) * B1 < e  β‡’  norm(f x) < e     [normB1] by real_arithmetic;
      simplify fSubLinear B1exists H3 eExists x't normB1 dist REAL_LT_RDIV_EQ;
    qed;
    intro_TAC H3, βˆ€x, xs;
    consider e such that
    &0 < e  ∧  βˆ€x'. x' ∈ t β‡’ dist (x',x) < e β‡’ x' ∈ s     [eExists] by fol H3 xs;
    exists_TAC e * B2;
    simplify REAL_LT_MUL eExists B2exists;
    intro_TAC βˆ€x', x't;
    βˆ€x. norm x <= norm (f x) / B2 ∧ norm(f x) / B2 < e  β‡’  norm x < e     [normB2] by real_arithmetic;
    simplify fSubLinear B2exists H3 eExists x't normB2 dist REAL_LE_RDIV_EQ REAL_LT_LDIV_EQ;
  qed;
`;;

add_linear_invariants [OPEN_IN_INJECTIVE_LINEAR_IMAGE];;

let CLOSED_IN_INJECTIVE_LINEAR_IMAGE = theorem `;
  βˆ€f s t. linear f ∧ (βˆ€x y. f x = f y β‡’ x = y)  β‡’
    (closed_in (subtopology euclidean (IMAGE f t)) (IMAGE f s)  ⇔
    closed_in (subtopology euclidean t) s)

  proof
    rewrite closed_in TOPSPACE_EUCLIDEAN_SUBTOPOLOGY;
    GEOM_TRANSFORM_TAC[];
  qed;
`;;

add_linear_invariants [CLOSED_IN_INJECTIVE_LINEAR_IMAGE];;

(* ------------------------------------------------------------------------- *)
(* Subspace topology results only proved for Euclidean space.                *)
(* ------------------------------------------------------------------------- *)

(* ISTOPLOGY_SUBTOPOLOGY can not be proved, as the definition of topology    *)
(* there is different from the one here.                                     *)

let OPEN_IN_SUBTOPOLOGY = theorem `;
  βˆ€u s.  open_in (subtopology euclidean u) s  ⇔
    βˆƒt. open_in euclidean t ∧ s = t ∩ u
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN OpenInSubtopology`;;

let TOPSPACE_SUBTOPOLOGY = theorem `;
  βˆ€u.  topspace(subtopology euclidean u) = topspace euclidean ∩ u

  proof
    intro_TAC βˆ€u;
    u βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    fol - TopspaceSubtopology INTER_COMM SUBSET_INTER_ABSORPTION;
  qed;
`;;

let CLOSED_IN_SUBTOPOLOGY = theorem `;
  βˆ€u s. closed_in (subtopology euclidean u) s  ⇔
  βˆƒt. closed_in euclidean t ∧ s = t ∩ u
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closed_in ClosedInSubtopology`;;

let OPEN_IN_SUBTOPOLOGY_REFL = theorem `;
  βˆ€u. open_in (subtopology euclidean u) u  ⇔  u βŠ‚ topspace euclidean
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN OPEN_IN_REFL`;;

let CLOSED_IN_SUBTOPOLOGY_REFL = theorem `;
  βˆ€u. closed_in (subtopology euclidean u) u  ⇔  u βŠ‚ topspace euclidean
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN_REFL`;;

let SUBTOPOLOGY_UNIV = theorem `;
  subtopology euclidean UNIV = euclidean

  proof
    rewrite GSYM Topology_Eq;
    conj_tac     [Left] by fol TOPSPACE_EUCLIDEAN TOPSPACE_EUCLIDEAN_SUBTOPOLOGY;
    rewrite GSYM OPEN_IN OPEN_IN_OPEN INTER_UNIV;
    fol;
  qed;
`;;

let SUBTOPOLOGY_SUPERSET = theorem `;
  βˆ€s.  topspace euclidean βŠ‚ s  β‡’  subtopology euclidean s = euclidean
  by simplify TOPSPACE_EUCLIDEAN UNIV_SUBSET SUBTOPOLOGY_UNIV`;;

let OPEN_IN_IMP_SUBSET = theorem `;
  βˆ€s t.  open_in (subtopology euclidean s) t  β‡’  t βŠ‚ s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN OpenInImpSubset`;;

let CLOSED_IN_IMP_SUBSET = theorem `;
  βˆ€s t.  closed_in (subtopology euclidean s) t  β‡’  t βŠ‚ s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN ClosedInImpSubset`;;

let OPEN_IN_SUBTOPOLOGY_UNION = theorem `;
  βˆ€s t u.  open_in (subtopology euclidean t) s  ∧
    open_in (subtopology euclidean u) s
    β‡’  open_in (subtopology euclidean (t βˆͺ u)) s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN OpenInSubtopologyUnion`;;

let CLOSED_IN_SUBTOPOLOGY_UNION = theorem `;
  βˆ€s t u.  closed_in (subtopology euclidean t) s  ∧
    closed_in (subtopology euclidean u) s
    β‡’  closed_in (subtopology euclidean (t βˆͺ u)) s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN ClosedInSubtopologyUnion`;;

(* ------------------------------------------------------------------------- *)
(* Connectedness.                                                            *)
(* ------------------------------------------------------------------------- *)

let connected_DEF = NewDefinition `;
  connected s  ⇔  Connected (subtopology euclidean s)`;;

let connected = theorem `;
  βˆ€s.  connected s  ⇔  Β¬(βˆƒe1 e2.
    open e1  ∧  open e2  ∧  s βŠ‚ e1 βˆͺ e2  ∧
    e1 ∩ e2 ∩ s = βˆ…  ∧  Β¬(e1 ∩ s = βˆ…)  ∧  Β¬(e2 ∩ s = βˆ…))
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN connected_DEF OPEN_IN ConnectedSubtopology`;;

let CONNECTED_CLOSED = theorem `;
  βˆ€s.  connected s ⇔
    Β¬(βˆƒe1 e2. closed e1  ∧  closed e2  ∧  s βŠ‚ e1 βˆͺ e2  ∧
    e1 ∩ e2 ∩ s = βˆ…  ∧  Β¬(e1 ∩ s = βˆ…)  ∧  Β¬(e2 ∩ s = βˆ…))
  by simplify connected_DEF CLOSED_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN connected_DEF CLOSED_IN ConnectedClosedSubtopology`;;

let CONNECTED_OPEN_IN = theorem `;
  βˆ€s. connected s  ⇔  Β¬(βˆƒe1 e2.
    open_in (subtopology euclidean s) e1 ∧
    open_in (subtopology euclidean s) e2 ∧
    s βŠ‚ e1 βˆͺ e2  ∧  e1 ∩ e2 = βˆ…  ∧  Β¬(e1 = βˆ…)  ∧  Β¬(e2 = βˆ…))
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN connected_DEF OPEN_IN ConnectedOpenIn`;;

let CONNECTED_OPEN_IN_EQ = theorem `;
  βˆ€s. connected s  ⇔  Β¬(βˆƒe1 e2.
    open_in (subtopology euclidean s) e1 ∧
    open_in (subtopology euclidean s) e2 ∧
    e1 βˆͺ e2 = s ∧ e1 ∩ e2 = βˆ… ∧
    Β¬(e1 = βˆ…) ∧ Β¬(e2 = βˆ…))
  by simplify connected_DEF Connected_DEF SUBSET_UNIV TOPSPACE_EUCLIDEAN TopspaceSubtopology EQ_SYM_EQ`;;

let CONNECTED_CLOSED_IN = theorem `;
  βˆ€s. connected s  ⇔  Β¬(βˆƒe1 e2.
    closed_in (subtopology euclidean s) e1 ∧
    closed_in (subtopology euclidean s) e2 ∧
    s βŠ‚ e1 βˆͺ e2  ∧  e1 ∩ e2 = βˆ…  ∧  Β¬(e1 = βˆ…)  ∧  Β¬(e2 = βˆ…))
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN connected_DEF CLOSED_IN ConnectedClosedIn`;;

let CONNECTED_CLOSED_IN_EQ = theorem `;
  βˆ€s. connected s  ⇔  Β¬(βˆƒe1 e2.
    closed_in (subtopology euclidean s) e1  ∧
    closed_in (subtopology euclidean s) e2  ∧
    e1 βˆͺ e2 = s  ∧  e1 ∩ e2 = βˆ…  ∧  Β¬(e1 = βˆ…)  ∧  Β¬(e2 = βˆ…))
  by simplify connected_DEF ConnectedClosed SUBSET_UNIV TOPSPACE_EUCLIDEAN TopspaceSubtopology EQ_SYM_EQ`;;

let CONNECTED_CLOPEN = theorem `;
  βˆ€s. connected s  ⇔
    βˆ€t. open_in (subtopology euclidean s) t  ∧
      closed_in (subtopology euclidean s) t β‡’ t = βˆ… ∨ t = s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN connected_DEF ConnectedClopen TopspaceSubtopology`;;

let CONNECTED_CLOSED_SET = theorem `;
  βˆ€s.  closed s β‡’
    (connected s  ⇔
    Β¬(βˆƒe1 e2. closed e1 ∧ closed e2 ∧
    Β¬(e1 = βˆ…)  ∧  Β¬(e2 = βˆ…)  ∧  e1 βˆͺ e2 = s  ∧  e1 ∩ e2 = βˆ…))
  by simplify connected_DEF CLOSED_IN  closed_in ConnectedClosedSet`;;

let CONNECTED_OPEN_SET = theorem `;
  βˆ€s.  open s  β‡’
    (connected s ⇔
    Β¬(βˆƒe1 e2.  open e1  ∧  open e2  ∧
    Β¬(e1 = βˆ…)  ∧  Β¬(e2 = βˆ…)  ∧  e1 βˆͺ e2 = s  ∧  e1 ∩ e2 = βˆ…))
  by simplify connected_DEF OPEN_IN ConnectedOpenSet`;;

let CONNECTED_EMPTY = theorem `;
  connected βˆ…
  by rewrite connected_DEF ConnectedEmpty`;;

let CONNECTED_SING = theorem `;
  βˆ€a. connected {a}

  proof
    intro_TAC βˆ€a;
    a ∈ topspace euclidean     [] by fol IN_UNIV TOPSPACE_EUCLIDEAN;
    fol - ConnectedSing connected_DEF;
  qed;
`;;

let CONNECTED_UNIONS = theorem `;
  βˆ€P.  (βˆ€s. s ∈ P β‡’ connected s) ∧ Β¬(INTERS P = βˆ…)
    β‡’ connected(UNIONS P)

  proof
    intro_TAC βˆ€P;
    βˆ€s. s ∈ P β‡’ s βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    fol - connected_DEF ConnectedUnions;
  qed;
`;;

let CONNECTED_UNION = theorem `;
  βˆ€s t.  connected s  ∧  connected t  ∧  Β¬(s ∩ t = βˆ…)
    β‡’ connected (s βˆͺ t)

  proof
    intro_TAC βˆ€s t;
    s βŠ‚ topspace euclidean  ∧  t βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    fol - connected_DEF ConnectedUnion;
  qed;
`;;

let CONNECTED_DIFF_OPEN_FROM_CLOSED = theorem `;
  βˆ€s t u.  s βŠ‚ t  ∧  t βŠ‚ u  ∧  open s  ∧  closed t  ∧
    connected u ∧ connected(t ━ s)
    β‡’  connected(u ━ s)
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN connected_DEF OPEN_IN CLOSED_IN ConnectedDiffOpenFromClosed`;;

let CONNECTED_DISJOINT_UNIONS_OPEN_UNIQUE = theorem `;
  βˆ€f f'.  pairwise DISJOINT f ∧ pairwise DISJOINT f' ∧
    (βˆ€s. s ∈ f β‡’ open s ∧ connected s ∧ Β¬(s = βˆ…)) ∧
    (βˆ€s. s ∈ f' β‡’ open s ∧ connected s ∧ Β¬(s = βˆ…)) ∧
    UNIONS f = UNIONS f'
    β‡’ f = f'
  by rewrite connected_DEF OPEN_IN ConnectedDisjointUnionsOpenUnique`;;

let CONNECTED_FROM_CLOSED_UNION_AND_INTER = theorem `;
  βˆ€s t.  closed s ∧ closed t ∧ connected (s βˆͺ t) ∧ connected (s ∩ t)
    β‡’ connected s ∧ connected t

  proof
    intro_TAC βˆ€s t;
    s βˆͺ t βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    fol -  connected_DEF CLOSED_IN ConnectedFromClosedUnionAndInter;
  qed;
`;;

let CONNECTED_FROM_OPEN_UNION_AND_INTER = theorem `;
  βˆ€s t.  open s ∧ open t ∧ connected (s βˆͺ t) ∧ connected (s ∩ t)
    β‡’ connected s ∧ connected t

  proof
    intro_TAC βˆ€s t;
    s βˆͺ t βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    fol -  connected_DEF OPEN_IN ConnectedFromOpenUnionAndInter;
  qed;
`;;

(* ------------------------------------------------------------------------- *)
(* Sort of induction principle for connected sets.                           *)
(* ------------------------------------------------------------------------- *)

let CONNECTED_INDUCTION = theorem `;
  βˆ€P Q s.  connected s ∧
    (βˆ€t a. open_in (subtopology euclidean s) t ∧ a ∈ t  β‡’  βˆƒz. z ∈ t ∧ P z) ∧
    (βˆ€a. a ∈ s  β‡’  βˆƒt. open_in (subtopology euclidean s) t ∧ a ∈ t ∧
    βˆ€x y. x ∈ t ∧ y ∈ t ∧ P x ∧ P y ∧ Q x β‡’ Q y)
    β‡’ βˆ€a b. a ∈ s ∧ b ∈ s ∧ P a ∧ P b ∧ Q a β‡’ Q b

  proof
    intro_TAC βˆ€P Q s;
    s βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    MP_TAC -;
    rewrite connected_DEF ConnectedInduction;
  qed;
`;;

let CONNECTED_EQUIVALENCE_RELATION_GEN_LEMMA = theorem `;
  βˆ€P R s.
        connected s ∧
        (βˆ€x y z. R x y ∧ R y z β‡’ R x z) ∧
        (βˆ€t a. open_in (subtopology euclidean s) t ∧ a ∈ t
               β‡’ βˆƒz. z ∈ t ∧ P z) ∧
        (βˆ€a. a ∈ s
             β‡’ βˆƒt. open_in (subtopology euclidean s) t ∧ a ∈ t ∧
                     βˆ€x y. x ∈ t ∧ y ∈ t ∧ P x ∧ P y β‡’ R x y)
        β‡’ βˆ€a b. a ∈ s ∧ b ∈ s ∧ P a ∧ P b β‡’ R a b

  proof
    intro_TAC βˆ€P R s;
    s βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    MP_TAC -;
    rewrite connected_DEF ConnectedEquivalenceRelationGen;
  qed;
`;;

let CONNECTED_EQUIVALENCE_RELATION_GEN = theorem `;
  βˆ€P R s.
        connected s ∧
        (βˆ€x y. R x y β‡’ R y x) ∧
        (βˆ€x y z. R x y ∧ R y z β‡’ R x z) ∧
        (βˆ€t a. open_in (subtopology euclidean s) t ∧ a ∈ t
               β‡’ βˆƒz. z ∈ t ∧ P z) ∧
        (βˆ€a. a ∈ s
             β‡’ βˆƒt. open_in (subtopology euclidean s) t ∧ a ∈ t ∧
                     βˆ€x y. x ∈ t ∧ y ∈ t ∧ P x ∧ P y β‡’ R x y)
        β‡’ βˆ€a b. a ∈ s ∧ b ∈ s ∧ P a ∧ P b β‡’ R a b

  proof
    intro_TAC βˆ€P R s;
    MP_TAC ISPECL [P; R; s] CONNECTED_EQUIVALENCE_RELATION_GEN_LEMMA;
    fol;
  qed;
`;;

let CONNECTED_INDUCTION_SIMPLE = theorem `;
  βˆ€P s.  connected s ∧ (βˆ€a. a ∈ s
    β‡’ βˆƒt. open_in (subtopology euclidean s) t ∧ a ∈ t ∧
    βˆ€x y. x ∈ t ∧ y ∈ t ∧ P x β‡’ P y)
    β‡’ βˆ€a b. a ∈ s ∧ b ∈ s ∧ P a β‡’ P b

  proof
    intro_TAC βˆ€P s;
    s βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    MP_TAC -;
    rewrite connected_DEF ConnectedInductionSimple;
  qed;
`;;

let CONNECTED_EQUIVALENCE_RELATION = theorem `;
  βˆ€R s.  connected s ∧
    (βˆ€x y. R x y β‡’ R y x) ∧ (βˆ€x y z. R x y ∧ R y z β‡’ R x z) ∧
    (βˆ€a. a ∈ s
    β‡’ βˆƒt. open_in (subtopology euclidean s) t ∧ a ∈ t ∧ βˆ€x. x ∈ t β‡’ R a x)
    β‡’ βˆ€a b. a ∈ s ∧ b ∈ s β‡’ R a b

  proof
    intro_TAC βˆ€R s;
    s βŠ‚ topspace euclidean     [] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN;
    MP_TAC -;
    rewrite connected_DEF ConnectedEquivalenceRelation;
  qed;
`;;

(* ------------------------------------------------------------------------- *)
(* Limit points.                                                             *)
(* ------------------------------------------------------------------------- *)

parse_as_infix ("limit_point_of",(12,"right"));;

let limit_point_of_DEF = NewDefinition `;
  x limit_point_of s  ⇔  x ∈ LimitPointOf euclidean s`;;

let limit_point_of = theorem `;
  x limit_point_of s  ⇔
    βˆ€t. x ∈ t ∧ open t  β‡’  βˆƒy. Β¬(y = x) ∧ y ∈ s ∧ y ∈ t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN IN_UNIV IN_LimitPointOf limit_point_of_DEF OPEN_IN`;;

let LIMPT_SUBSET = theorem `;
  βˆ€x s t.  x limit_point_of s ∧ s βŠ‚ t  β‡’  x limit_point_of t
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN limit_point_of_DEF LimptSubset SUBSET`;;

let CLOSED_LIMPT = theorem `;
  βˆ€s.  closed s  ⇔  βˆ€x. x limit_point_of s β‡’ x ∈ s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN IN_UNIV limit_point_of_DEF CLOSED_IN ClosedLimpt SUBSET`;;

let LIMPT_EMPTY = theorem `;
  βˆ€x.  Β¬(x limit_point_of βˆ…)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN IN_UNIV limit_point_of_DEF GSYM βˆ‰ LimptEmpty`;;

let NO_LIMIT_POINT_IMP_CLOSED = theorem `;
  βˆ€s. Β¬(βˆƒx. x limit_point_of s) β‡’ closed s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN IN_UNIV limit_point_of_DEF CLOSED_IN NoLimitPointImpClosed NOT_EXISTS_THM βˆ‰`;;

let LIMIT_POINT_UNION = theorem `;
  βˆ€s t x.  x limit_point_of (s βˆͺ t)  ⇔
    x limit_point_of s  ∨  x limit_point_of t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN IN_UNIV limit_point_of_DEF LimitPointUnion EXTENSION IN_UNION`;;

let LimitPointOf_euclidean = theorem `;
  βˆ€s.  LimitPointOf euclidean s = {x | x limit_point_of s}
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN IN_UNIV limit_point_of_DEF LimitPointOf IN_ELIM_THM EXTENSION`;;

(* ------------------------------------------------------------------------- *)
(* Interior of a set.                                                        *)
(* ------------------------------------------------------------------------- *)

let interior_DEF = NewDefinition `;
  interior = Interior euclidean`;;

let interior = theorem `;
  βˆ€s. interior s = {x | βˆƒt. open t ∧ x ∈ t ∧ t βŠ‚ s}
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF Interior_DEF OPEN_IN`;;

let INTERIOR_EQ = theorem `;
  βˆ€s.  interior s = s  ⇔  open s
  by simplify interior_DEF OPEN_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN InteriorEq EQ_SYM_EQ`;;

let INTERIOR_OPEN = theorem `;
  βˆ€s.  open s  β‡’  interior s = s
  by fol interior_DEF OPEN_IN InteriorOpen`;;

let INTERIOR_EMPTY = theorem `;
  interior βˆ… = βˆ…
  by fol interior_DEF OPEN_IN InteriorEmpty`;;

let INTERIOR_UNIV = theorem `;
  interior UNIV = UNIV
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF InteriorUniv`;;

let OPEN_INTERIOR = theorem `;
  βˆ€s. open (interior s)
  by simplify interior_DEF OPEN_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN  OpenInterior`;;

let INTERIOR_INTERIOR = theorem `;
  βˆ€s. interior (interior s) = interior s
  by simplify interior_DEF OPEN_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN  InteriorInterior`;;

let INTERIOR_SUBSET = theorem `;
  βˆ€s. interior s βŠ‚ s
  by simplify interior_DEF OPEN_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN  InteriorSubset`;;

let SUBSET_INTERIOR = theorem `;
  βˆ€s t.  s βŠ‚ t  β‡’  interior s βŠ‚ interior t
  by simplify interior_DEF OPEN_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN SubsetInterior`;;

let INTERIOR_MAXIMAL = theorem `;
  βˆ€s t.  t βŠ‚ s ∧ open t  β‡’  t βŠ‚ interior s
  by simplify interior_DEF OPEN_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN InteriorMaximal`;;

let INTERIOR_MAXIMAL_EQ = theorem `;
  βˆ€s t.  open s  β‡’  (s βŠ‚ interior t ⇔ s βŠ‚ t)
  by simplify interior_DEF OPEN_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN InteriorMaximalEq`;;

let INTERIOR_UNIQUE = theorem `;
  βˆ€s t.  t βŠ‚ s  ∧  open t ∧  (βˆ€t'. t' βŠ‚ s ∧ open t' β‡’ t' βŠ‚ t)
    β‡’ interior s = t
  by simplify interior_DEF OPEN_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN InteriorUnique`;;

let IN_INTERIOR = theorem `;
  βˆ€x s.  x ∈ interior s  ⇔  βˆƒe. &0 < e ∧ ball(x,e) βŠ‚ s

  proof
    simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF IN_Interior GSYM OPEN_IN;
    fol OPEN_CONTAINS_BALL SUBSET_TRANS CENTRE_IN_BALL OPEN_BALL;
  qed;
`;;

let OPEN_SUBSET_INTERIOR = theorem `;
  βˆ€s t.  open s  β‡’  (s βŠ‚ interior t  ⇔  s βŠ‚ t)
  by fol interior_DEF OPEN_IN SUBSET_UNIV TOPSPACE_EUCLIDEAN OpenSubsetInterior`;;

let INTERIOR_INTER = theorem `;
  βˆ€s t. interior (s ∩ t) = interior s ∩ interior t
  by simplify interior_DEF SUBSET_UNIV TOPSPACE_EUCLIDEAN InteriorInter`;;

let INTERIOR_FINITE_INTERS = theorem `;
  βˆ€s.  FINITE s  β‡’  interior (INTERS s) = INTERS (IMAGE interior s)

  proof
  intro_TAC βˆ€s, H1;
  assume Β¬(s = βˆ…)     [sNonempty] by simplify INTERS_0 IMAGE_CLAUSES INTERIOR_UNIV;
      simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN H1 sNonempty interior_DEF InteriorFiniteInters;
  qed;
`;;

let INTERIOR_FINITE_INTERS = theorem `;
  βˆ€s.  FINITE s  β‡’  interior (INTERS s) = INTERS (IMAGE interior s)

  proof
  intro_TAC βˆ€s, H1;
  assume s = βˆ…     [sEmpty] by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN H1 interior_DEF InteriorFiniteInters;
  rewrite INTERS_0 IMAGE_CLAUSES sEmpty INTERIOR_UNIV;
  qed;
`;;

let INTERIOR_INTERS_SUBSET = theorem `;
  βˆ€f.  interior (INTERS f) βŠ‚ INTERS (IMAGE interior f)

  proof
    intro_TAC βˆ€f;
    assume f = βˆ…     [fEmpty] by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF InteriorIntersSubset;
    rewrite INTERS_0 IMAGE_CLAUSES - INTERIOR_UNIV SUBSET_REFL;
  qed;
`;;

let UNION_INTERIOR_SUBSET = theorem `;
  βˆ€s t.  interior s βˆͺ interior t  βŠ‚  interior(s βˆͺ t)
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF UnionInteriorSubset`;;

let INTERIOR_EQ_EMPTY = theorem `;
  βˆ€s.  interior s = βˆ…  ⇔  βˆ€t. open t ∧ t βŠ‚ s β‡’ t = βˆ…
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF OPEN_IN InteriorEqEmpty`;;

let INTERIOR_EQ_EMPTY_ALT = theorem `;
  βˆ€s.  interior s = βˆ…  ⇔  βˆ€t. open t ∧ Β¬(t = βˆ…) β‡’ Β¬(t ━ s = βˆ…)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF OPEN_IN InteriorEqEmptyAlt`;;

let INTERIOR_UNIONS_OPEN_SUBSETS = theorem `;
  βˆ€s.  UNIONS {t | open t ∧ t βŠ‚ s} = interior s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF OPEN_IN InteriorUnionsOpenSubsets`;;

(* ------------------------------------------------------------------------- *)
(* Closure of a set.                                                         *)
(* ------------------------------------------------------------------------- *)

let closure_DEF = NewDefinition `;
  closure = Closure euclidean`;;

let closure = theorem `;
  βˆ€s.  closure s = s UNION {x | x limit_point_of s}
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF LimitPointOf_euclidean Closure_THM`;;

let CLOSURE_INTERIOR = theorem `;
  βˆ€s. closure s = UNIV ━ interior (UNIV ━ s)

  proof
    rewrite closure_DEF GSYM TOPSPACE_EUCLIDEAN interior_DEF;
    simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN ClosureInterior;
  qed;
`;;

let INTERIOR_CLOSURE = theorem `;
  βˆ€s.  interior s = UNIV ━ (closure (UNIV ━ s))

  proof
    rewrite closure_DEF GSYM TOPSPACE_EUCLIDEAN  interior_DEF;
    simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN InteriorClosure;
  qed;
`;;

let CLOSED_CLOSURE = theorem `;
  βˆ€s.  closed (closure s)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN closure_DEF ClosedClosure`;;

let CLOSURE_SUBSET = theorem `;
  βˆ€s.  s βŠ‚ closure s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN closure_DEF ClosureSubset`;;

let SUBSET_CLOSURE = theorem `;
  βˆ€s t.  s βŠ‚ t  β‡’  closure s βŠ‚ closure t
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF SubsetClosure`;;

let CLOSURE_HULL = theorem `;
  βˆ€s. closure s = closed hull s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN closure_DEF ClosureHull`;;

let CLOSURE_EQ = theorem `;
  βˆ€s.  closure s = s  ⇔  closed s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN closure_DEF ClosureEq`;;

let CLOSURE_CLOSED = theorem `;
  βˆ€s.  closed s  β‡’  closure s = s
  by fol CLOSED_IN closure_DEF ClosureClosed`;;

let CLOSURE_CLOSURE = theorem `;
  βˆ€s.  closure (closure s) = closure s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN closure_DEF ClosureClosure`;;

let CLOSURE_UNION = theorem `;
  βˆ€s t.  closure (s βˆͺ t)  =  closure s βˆͺ closure t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN closure_DEF ClosureUnion`;;

let CLOSURE_INTER_SUBSET = theorem `;
  βˆ€s t.  closure (s ∩ t)  βŠ‚  closure s ∩ closure t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN closure_DEF ClosureInterSubset`;;

let CLOSURE_INTERS_SUBSET = theorem `;
  βˆ€f.  closure (INTERS f)  βŠ‚  INTERS (IMAGE closure f)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN closure_DEF ClosureIntersSubset`;;

let CLOSURE_MINIMAL = theorem `;
  βˆ€s t.  s βŠ‚ t ∧ closed t  β‡’  closure s βŠ‚ t
  by fol CLOSED_IN closure_DEF ClosureMinimal`;;

let CLOSURE_MINIMAL_EQ = theorem `;
  βˆ€s t.  closed t  β‡’  (closure s βŠ‚ t ⇔ s βŠ‚ t)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN closure_DEF ClosureMinimalEq`;;

let CLOSURE_UNIQUE = theorem `;
  βˆ€s t.  s βŠ‚ t ∧ closed t ∧ (βˆ€t'. s βŠ‚ t' ∧ closed t' β‡’ t βŠ‚ t')
    β‡’ closure s = t
  by fol CLOSED_IN closure_DEF ClosureUnique`;;


let CLOSURE_EMPTY = theorem `;
  closure βˆ… = βˆ…
  by fol closure_DEF ClosureEmpty`;;

let CLOSURE_UNIV = theorem `;
  closure UNIV = UNIV
  by fol TOPSPACE_EUCLIDEAN closure_DEF ClosureUniv`;;

let CLOSURE_UNIONS = theorem `;
  βˆ€f.  FINITE f  β‡’  closure (UNIONS f) = UNIONS {closure s | s ∈ f}
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF ClosureUnions`;;

let CLOSURE_EQ_EMPTY = theorem `;
  βˆ€s.  closure s = βˆ…  ⇔  s = βˆ…
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF ClosureEqEmpty`;;

let CLOSURE_SUBSET_EQ = theorem `;
  βˆ€s.  closure s βŠ‚ s  ⇔  closed s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF CLOSED_IN ClosureSubsetEq`;;

let OPEN_INTER_CLOSURE_EQ_EMPTY = theorem `;
  βˆ€s t.  open s  β‡’  (s ∩ closure t = βˆ…  ⇔  s ∩ t = βˆ…)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF OPEN_IN OpenInterClosureEqEmpty`;;

let OPEN_INTER_CLOSURE_SUBSET = theorem `;
  βˆ€s t.  open s  β‡’  s ∩ closure t βŠ‚ closure (s ∩ t)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF OPEN_IN OpenInterClosureSubset`;;

let CLOSURE_OPEN_INTER_SUPERSET = theorem `;
  βˆ€s t.  open s ∧ s βŠ‚ closure t  β‡’  closure (s ∩ t) = closure s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF OPEN_IN ClosureOpenInterSuperset`;;

let CLOSURE_COMPLEMENT = theorem `;
  βˆ€s.  closure (UNIV ━ s) = UNIV ━ interior s

  proof
    rewrite closure_DEF GSYM TOPSPACE_EUCLIDEAN  interior_DEF;
    simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN ClosureComplement;
  qed;
`;;

let INTERIOR_COMPLEMENT = theorem `;
  βˆ€s.  interior (UNIV ━ s) = UNIV ━ closure s

  proof
    rewrite closure_DEF GSYM TOPSPACE_EUCLIDEAN  interior_DEF;
    simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN InteriorComplement;
  qed;
`;;

let CONNECTED_INTERMEDIATE_CLOSURE = theorem `;
  βˆ€s t.  connected s ∧ s βŠ‚ t ∧ t βŠ‚ closure s  β‡’  connected t
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF connected_DEF ConnectedIntermediateClosure`;;

let CONNECTED_CLOSURE = theorem `;
  βˆ€s.  connected s  β‡’  connected (closure s)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF connected_DEF ConnectedClosure`;;

let CONNECTED_UNION_STRONG = theorem `;
  βˆ€s t.  connected s ∧ connected t ∧ Β¬(closure s ∩ t = βˆ…)
        β‡’ connected (s βˆͺ t)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF connected_DEF ConnectedUnionStrong`;;

let INTERIOR_DIFF = theorem `;
  βˆ€s t.  interior (s ━ t) = interior s ━ closure t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF interior_DEF InteriorDiff`;;

let CLOSED_IN_LIMPT = theorem `;
  βˆ€s t.  closed_in (subtopology euclidean t) s  ⇔
    s βŠ‚ t  ∧  βˆ€x. x limit_point_of s ∧ x ∈ t β‡’ x ∈ s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF limit_point_of_DEF ClosedInLimpt_ALT`;;

let CLOSED_IN_INTER_CLOSURE = theorem `;
  βˆ€s t.  closed_in (subtopology euclidean s) t  ⇔  s ∩ closure t = t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF limit_point_of_DEF ClosedInInterClosure`;;

let INTERIOR_CLOSURE_IDEMP = theorem `;
  βˆ€s. interior (closure (interior (closure s))) = interior (closure s)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF interior_DEF InteriorClosureIdemp`;;

let CLOSURE_INTERIOR_IDEMP = theorem `;
  βˆ€s.  closure (interior (closure (interior s))) = closure (interior s)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF interior_DEF ClosureInteriorIdemp`;;

let INTERIOR_CLOSED_UNION_EMPTY_INTERIOR = theorem `;
  βˆ€s t.  closed s ∧ interior t = βˆ…  β‡’  interior (s βˆͺ t) = interior s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN interior_DEF InteriorClosedUnionEmptyInterior`;;

let INTERIOR_UNION_EQ_EMPTY = theorem `;
  βˆ€s t.  closed s ∨ closed t
        β‡’ (interior (s βˆͺ t) = βˆ…  ⇔  interior s = βˆ… ∧ interior t = βˆ…)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN interior_DEF InteriorUnionEqEmpty`;;

let NOWHERE_DENSE_UNION = theorem `;
  βˆ€s t.  interior (closure (s βˆͺ t)) = βˆ…  ⇔
        interior (closure s) = βˆ…  ∧  interior (closure t) = βˆ…
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF interior_DEF NowhereDenseUnion`;;

let NOWHERE_DENSE = theorem `;
  βˆ€s.  interior (closure s) = βˆ… ⇔
    βˆ€t. open t ∧ Β¬(t = βˆ…)  β‡’  βˆƒu. open u ∧ Β¬(u = βˆ…) ∧ u βŠ‚ t ∧ u ∩ s = βˆ…
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF closure_DEF OPEN_IN NowhereDense`;;

let INTERIOR_CLOSURE_INTER_OPEN = theorem `;
  βˆ€s t.  open s ∧ open t β‡’
    interior (closure (s ∩ t))  =  interior(closure s) ∩ interior (closure t)
  by simplify interior_DEF closure_DEF OPEN_IN InteriorClosureInterOpen`;;

let CLOSURE_INTERIOR_UNION_CLOSED = theorem `;
  βˆ€s t.  closed s ∧ closed t  β‡’
    closure (interior (s βˆͺ t))  = closure (interior s) βˆͺ closure (interior t)
  by simplify interior_DEF closure_DEF CLOSED_IN ClosureInteriorUnionClosed`;;

let REGULAR_OPEN_INTER = theorem `;
  βˆ€s t.  interior (closure s) = s ∧ interior (closure t) = t
    β‡’ interior (closure (s ∩ t)) = s ∩ t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF closure_DEF RegularOpenInter`;;

let REGULAR_CLOSED_UNION = theorem `;
  βˆ€s t.  closure (interior s) = s  ∧  closure (interior t) = t
    β‡’  closure (interior (s βˆͺ t)) = s βˆͺ t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF closure_DEF RegularClosedUnion`;;

let DIFF_CLOSURE_SUBSET = theorem `;
  βˆ€s t.  closure s ━ closure t βŠ‚ closure (s ━ t)
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF DiffClosureSubset`;;

(* ------------------------------------------------------------------------- *)
(* Frontier (aka boundary).                                                  *)
(* ------------------------------------------------------------------------- *)

let frontier_DEF = NewDefinition `;
  frontier = Frontier euclidean`;;

let frontier = theorem `;
  βˆ€s.  frontier s = (closure s) DIFF (interior s)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF closure_DEF interior_DEF Frontier_THM`;;

let FRONTIER_CLOSED = theorem `;
  βˆ€s. closed (frontier s)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF CLOSED_IN FrontierClosed`;;

let FRONTIER_CLOSURES = theorem `;
  βˆ€s.  frontier s  =  (closure s) ∩ (closure (UNIV ━ s))
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF closure_DEF FrontierClosures`;;

let FRONTIER_STRADDLE = theorem `;
  βˆ€a s.  a ∈ frontier s ⇔  βˆ€e. &0 < e β‡’
    (βˆƒx. x ∈ s ∧ dist(a,x) < e)  ∧  (βˆƒx. Β¬(x ∈ s) ∧ dist(a,x) < e)

  proof
    simplify SUBSET_UNIV IN_UNIV TOPSPACE_EUCLIDEAN frontier_DEF closure_DEF FrontierStraddle GSYM OPEN_IN;
    fol IN_BALL SUBSET OPEN_CONTAINS_BALL CENTRE_IN_BALL OPEN_BALL;
  qed;
`;;

let FRONTIER_SUBSET_CLOSED = theorem `;
  βˆ€s.  closed s  β‡’  (frontier s) βŠ‚ s
  by fol frontier_DEF CLOSED_IN FrontierSubsetClosed`;;

let FRONTIER_EMPTY = theorem `;
  frontier βˆ… = βˆ…
  by fol frontier_DEF FrontierEmpty`;;

let FRONTIER_UNIV = theorem `;
  frontier UNIV = βˆ…
  by fol frontier_DEF TOPSPACE_EUCLIDEAN FrontierUniv`;;

let FRONTIER_SUBSET_EQ = theorem `;
  βˆ€s. (frontier s) βŠ‚ s ⇔ closed s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF CLOSED_IN FrontierSubsetEq`;;

let FRONTIER_COMPLEMENT = theorem `;
  βˆ€s. frontier (UNIV ━ s) = frontier s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF FrontierComplement`;;

let FRONTIER_DISJOINT_EQ = theorem `;
  βˆ€s.  (frontier s) ∩ s = βˆ…  ⇔  open s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF OPEN_IN FrontierDisjointEq`;;

let FRONTIER_INTER_SUBSET = theorem `;
  βˆ€s t.  frontier (s ∩ t)  βŠ‚  frontier s βˆͺ frontier t
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF FrontierInterSubset`;;

let FRONTIER_UNION_SUBSET = theorem `;
  βˆ€s t.  frontier (s βˆͺ t)  βŠ‚  frontier s βˆͺ frontier t
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF FrontierUnionSubset`;;

let FRONTIER_INTERIORS = theorem `;
  frontier s = UNIV ━ interior(s) ━ interior(UNIV ━ s)
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF interior_DEF FrontierInteriors`;;

let FRONTIER_FRONTIER_SUBSET = theorem `;
  βˆ€s.  frontier (frontier s) βŠ‚ frontier s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF FrontierFrontierSubset`;;

let INTERIOR_FRONTIER = theorem `;
  βˆ€s.  interior (frontier s)  =  interior (closure s) ━ closure (interior s)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN interior_DEF frontier_DEF closure_DEF InteriorFrontier`;;

let INTERIOR_FRONTIER_EMPTY = theorem `;
  βˆ€s.  open s ∨ closed s  β‡’  interior (frontier s) = βˆ…
  by fol OPEN_IN CLOSED_IN interior_DEF frontier_DEF InteriorFrontierEmpty`;;

let UNION_FRONTIER = theorem `;
  βˆ€s t.  frontier s βˆͺ frontier t =
    frontier (s βˆͺ t) βˆͺ frontier (s ∩ t) βˆͺ frontier s ∩ frontier t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF UnionFrontier`;;

let CONNECTED_INTER_FRONTIER = theorem `;
  βˆ€s t.  connected s ∧ Β¬(s ∩ t = βˆ…) ∧ Β¬(s ━ t = βˆ…)
    β‡’  Β¬(s ∩ frontier t = βˆ…)
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN connected_DEF frontier_DEF ConnectedInterFrontier`;;

let INTERIOR_CLOSED_EQ_EMPTY_AS_FRONTIER = theorem `;
  βˆ€s. closed s ∧ interior s = βˆ…  ⇔  βˆƒt. open t ∧ s = frontier t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN CLOSED_IN interior_DEF OPEN_IN frontier_DEF InteriorClosedEqEmptyAsFrontier`;;

let FRONTIER_UNION = theorem `;
  βˆ€s t.  closure s ∩ closure t = βˆ…
    β‡’ frontier (s βˆͺ t) = frontier s βˆͺ frontier t
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF closure_DEF FrontierUnion`;;

let CLOSURE_UNION_FRONTIER = theorem `;
  βˆ€s. closure s = s βˆͺ frontier s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN closure_DEF frontier_DEF ClosureUnionFrontier`;;

let FRONTIER_INTERIOR_SUBSET = theorem `;
  βˆ€s.  frontier (interior s) βŠ‚ frontier s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF interior_DEF FrontierInteriorSubset`;;

let FRONTIER_CLOSURE_SUBSET = theorem `;
  βˆ€s.  frontier (closure s) βŠ‚ frontier s
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF closure_DEF FrontierClosureSubset`;;

let SET_DIFF_FRONTIER = theorem `;
  βˆ€s.  s ━ frontier s = interior s
  by simplify SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF interior_DEF SetDiffFrontier`;;

let FRONTIER_INTER_SUBSET_INTER = theorem `;
  βˆ€s t.  frontier (s ∩ t)  βŠ‚  closure s ∩ frontier t βˆͺ frontier s ∩ closure t
  by fol SUBSET_UNIV TOPSPACE_EUCLIDEAN frontier_DEF closure_DEF FrontierInterSubsetInter`;;