Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
/*{{{*/
body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}

a {color:[[ColorPalette::PrimaryMid]];}
a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
a img {border:0;}

h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}

.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}

.header {background:[[ColorPalette::PrimaryMid]];}
.headerShadow {color:[[ColorPalette::Foreground]];}
.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
.headerForeground {color:[[ColorPalette::Background]];}
.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}

.tabSelected{color:[[ColorPalette::PrimaryDark]];
	background:[[ColorPalette::TertiaryPale]];
	border-left:1px solid [[ColorPalette::TertiaryLight]];
	border-top:1px solid [[ColorPalette::TertiaryLight]];
	border-right:1px solid [[ColorPalette::TertiaryLight]];
}
.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
.tabContents .button {border:0;}

#sidebar {}
#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}

.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
	border:1px solid [[ColorPalette::PrimaryMid]];}
.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
	border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
	border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}

#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}

.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}

.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}

.tiddler .defaultCommand {font-weight:bold;}

.shadow .title {color:[[ColorPalette::TertiaryDark]];}

.title {color:[[ColorPalette::SecondaryDark]];}
.subtitle {color:[[ColorPalette::TertiaryDark]];}

.toolbar {color:[[ColorPalette::PrimaryMid]];}
.toolbar a {color:[[ColorPalette::TertiaryLight]];}
.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}

.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
.tagging .button, .tagged .button {border:none;}

.footer {color:[[ColorPalette::TertiaryLight]];}
.selected .footer {color:[[ColorPalette::TertiaryMid]];}

.sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;}
.sparktick {background:[[ColorPalette::PrimaryDark]];}

.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
.lowlight {background:[[ColorPalette::TertiaryLight]];}

.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}

.imageLink, #displayArea .imageLink {background:transparent;}

.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}

.viewer .listTitle {list-style-type:none; margin-left:-2em;}
.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}

.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}

.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
.viewer code {color:[[ColorPalette::SecondaryDark]];}
.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}

.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}

.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
.editorFooter {color:[[ColorPalette::TertiaryMid]];}

#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity:60)';}
/*}}}*/
/*{{{*/
* html .tiddler {height:1%;}

body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}

h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
h4,h5,h6 {margin-top:1em;}
h1 {font-size:1.35em;}
h2 {font-size:1.25em;}
h3 {font-size:1.1em;}
h4 {font-size:1em;}
h5 {font-size:.9em;}

hr {height:1px;}

a {text-decoration:none;}

dt {font-weight:bold;}

ol {list-style-type:decimal;}
ol ol {list-style-type:lower-alpha;}
ol ol ol {list-style-type:lower-roman;}
ol ol ol ol {list-style-type:decimal;}
ol ol ol ol ol {list-style-type:lower-alpha;}
ol ol ol ol ol ol {list-style-type:lower-roman;}
ol ol ol ol ol ol ol {list-style-type:decimal;}

.txtOptionInput {width:11em;}

#contentWrapper .chkOptionInput {border:0;}

.externalLink {text-decoration:underline;}

.indent {margin-left:3em;}
.outdent {margin-left:3em; text-indent:-3em;}
code.escaped {white-space:nowrap;}

.tiddlyLinkExisting {font-weight:bold;}
.tiddlyLinkNonExisting {font-style:italic;}

/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
a.tiddlyLinkNonExisting.shadow {font-weight:bold;}

#mainMenu .tiddlyLinkExisting,
	#mainMenu .tiddlyLinkNonExisting,
	#sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}

.header {position:relative;}
.header a:hover {background:transparent;}
.headerShadow {position:relative; padding:4.5em 0em 1em 1em; left:-1px; top:-1px;}
.headerForeground {position:absolute; padding:4.5em 0em 1em 1em; left:0px; top:0px;}

.siteTitle {font-size:3em;}
.siteSubtitle {font-size:1.2em;}

#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}

#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
#sidebarOptions {padding-top:0.3em;}
#sidebarOptions a {margin:0em 0.2em; padding:0.2em 0.3em; display:block;}
#sidebarOptions input {margin:0.4em 0.5em;}
#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
#sidebarOptions .sliderPanel input {margin:0 0 .3em 0;}
#sidebarTabs .tabContents {width:15em; overflow:hidden;}

.wizard {padding:0.1em 1em 0em 2em;}
.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
.wizardStep {padding:1em 1em 1em 1em;}
.wizard .button {margin:0.5em 0em 0em 0em; font-size:1.2em;}
.wizardFooter {padding:0.8em 0.4em 0.8em 0em;}
.wizardFooter .status {padding:0em 0.4em 0em 0.4em; margin-left:1em;}
.wizard .button {padding:0.1em 0.2em 0.1em 0.2em;}

#messageArea {position:fixed; top:2em; right:0em; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
.messageToolbar {display:block; text-align:right; padding:0.2em 0.2em 0.2em 0.2em;}
#messageArea a {text-decoration:underline;}

.tiddlerPopupButton {padding:0.2em 0.2em 0.2em 0.2em;}
.popupTiddler {position: absolute; z-index:300; padding:1em 1em 1em 1em; margin:0;}

.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
.popup .popupMessage {padding:0.4em;}
.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0em;}
.popup li.disabled {padding:0.4em;}
.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
.listBreak {font-size:1px; line-height:1px;}
.listBreak div {margin:2px 0;}

.tabset {padding:1em 0em 0em 0.5em;}
.tab {margin:0em 0em 0em 0.25em; padding:2px;}
.tabContents {padding:0.5em;}
.tabContents ul, .tabContents ol {margin:0; padding:0;}
.txtMainTab .tabContents li {list-style:none;}
.tabContents li.listLink { margin-left:.75em;}

#contentWrapper {display:block;}
#splashScreen {display:none;}

#displayArea {margin:1em 17em 0em 14em;}

.toolbar {text-align:right; font-size:.9em;}

.tiddler {padding:1em 1em 0em 1em;}

.missing .viewer,.missing .title {font-style:italic;}

.title {font-size:1.6em; font-weight:bold;}

.missing .subtitle {display:none;}
.subtitle {font-size:1.1em;}

.tiddler .button {padding:0.2em 0.4em;}

.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
.isTag .tagging {display:block;}
.tagged {margin:0.5em; float:right;}
.tagging, .tagged {font-size:0.9em; padding:0.25em;}
.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
.tagClear {clear:both;}

.footer {font-size:.9em;}
.footer li {display:inline;}

.annotation {padding:0.5em; margin:0.5em;}

* html .viewer pre {width:99%; padding:0 0 1em 0;}
.viewer {line-height:1.4em; padding-top:0.5em;}
.viewer .button {margin:0em 0.25em; padding:0em 0.25em;}
.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}

.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
table.listView {font-size:0.85em; margin:0.8em 1.0em;}
table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;}

.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
.viewer code {font-size:1.2em; line-height:1.4em;}

.editor {font-size:1.1em;}
.editor input, .editor textarea {display:block; width:100%; font:inherit;}
.editorFooter {padding:0.25em 0em; font-size:.9em;}
.editorFooter .button {padding-top:0px; padding-bottom:0px;}

.fieldsetFix {border:0; padding:0; margin:1px 0px 1px 0px;}

.sparkline {line-height:1em;}
.sparktick {outline:0;}

.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
.zoomer div {padding:1em;}

* html #backstage {width:99%;}
* html #backstageArea {width:99%;}
#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em 0.3em 0.5em;}
#backstageToolbar {position:relative;}
#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em 0.3em 0.5em;}
#backstageButton {display:none; position:absolute; z-index:175; top:0em; right:0em;}
#backstageButton a {padding:0.1em 0.4em 0.1em 0.4em; margin:0.1em 0.1em 0.1em 0.1em;}
#backstage {position:relative; width:100%; z-index:50;}
#backstagePanel {display:none; z-index:100; position:absolute; margin:0em 3em 0em 3em; padding:1em 1em 1em 1em;}
.backstagePanelFooter {padding-top:0.2em; float:right;}
.backstagePanelFooter a {padding:0.2em 0.4em 0.2em 0.4em;}
#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}

.whenBackstage {display:none;}
.backstageVisible .whenBackstage {display:block;}
/*}}}*/
/***
StyleSheet for use when a translation requires any css style changes.
This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which use a logographic writing system and need larger font sizes.
***/

/*{{{*/
body {font-size:0.8em;}

#sidebarOptions {font-size:1.05em;}
#sidebarOptions a {font-style:normal;}
#sidebarOptions .sliderPanel {font-size:0.95em;}

.subtitle {font-size:0.8em;}

.viewer table.listView {font-size:0.95em;}

.htmlarea .toolbarHA table {border:1px solid ButtonFace; margin:0em 0em;}
/*}}}*/
/*{{{*/
@media print {
#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none ! important;}
#displayArea {margin: 1em 1em 0em 1em;}
/* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
noscript {display:none;}
}
/*}}}*/
<!--{{{-->
<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
<div class='headerShadow'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
<div class='headerForeground'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
</div>
<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>
<div id='sidebar'>
<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>
<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>
</div>
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay'></div>
</div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar closeTiddler closeOthers +editTiddler > fields syncing permalink references jump'></div>
<div class='title' macro='view title'></div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
<div class='tagging' macro='tagging'></div>
<div class='tagged' macro='tags'></div>
<div class='viewer' macro='view text wikified'></div>
<div class='tagClear'></div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler deleteTiddler'></div>
<div class='title' macro='view title'></div>
<div class='editor' macro='edit title'></div>
<div macro='annotations'></div>
<div class='editor' macro='edit text'></div>
<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser'></span></div>
<!--}}}-->
To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:
* SiteTitle & SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
* MainMenu: The menu (usually on the left)
* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
You'll also need to enter your username for signing your edits: <<option txtUserName>>
These InterfaceOptions for customising TiddlyWiki are saved in your browser

Your username for signing your edits. Write it as a WikiWord (eg JoeBloggs)

<<option txtUserName>>
<<option chkSaveBackups>> SaveBackups
<<option chkAutoSave>> AutoSave
<<option chkRegExpSearch>> RegExpSearch
<<option chkCaseSensitiveSearch>> CaseSensitiveSearch
<<option chkAnimate>> EnableAnimations

----
Also see AdvancedOptions
This site is an experimental [[TiddlyWiki|http://www.tiddlywiki.com/]] rendering of fragments of the [[IsarMathLib| http://www.nongnu.org/isarmathlib/]] project. IsarMathLib is a library of mathematical proofs  formally verified by the [[Isabelle|http://www.cl.cam.ac.uk/research/hvg/Isabelle/ ]] theorem proving environment. The formalization is based on the [[Zermelo-Fraenkel set theory|http://en.wikipedia.org/wiki/Zermelo%E2%80%93Fraenkel_set_theory ]]. 

The software for translating Isabelle's Isar language to <nowiki>TiddlyWiki</nowiki> markup is at the early alpha stage, so some proofs may be rendered incorrectly. In case of doubts, compare with the Isabelle generated IsarMathLib [[proof document|http://www.nongnu.org/isarmathlib/IsarMathLib/document.pdf]].

+++[Comments|click to leave comment]
<html> <div> <iframe style="width:50%;height:400px" src="http://www.haloscan.com/comments/slawekk/tiddlyformalmath"></iframe> </div> </html>
This document has been  created from a ~TiddlyWiki from tiddlyspot.com.  A ~TiddlyWiki is an electronic notebook that is great for managing todo lists, personal information, and all sorts of things.

 This tiddler is for me, the author of this TiddlyWiki.  Here I can configure privacy and other site settings at my [[control panel|http://formalmath.tiddlyspot.com/controlpanel]] (my control panel username is //formalmath//).
<<tiddler TspotControls>>
See also GettingStarted.

AboutThisSite
 ''theory'' DirectProduct_ZF ''imports'' [[func_ZF]]

 ''begin
'' 
This theory considers the direct product of binary operations. Submitted by Seo Sanghyeon.

!Definition

In group theory the notion of direct product provides a natural way of creating a new group from two given groups.

Given $(G,\cdot)$ and $(H,\circ)$ a new operation $(G\times H, \times )$ is defined as $(g, h) \times (g', h') = (g \cdot g', h \circ h')$.

 ''Definition
'' $ DirectProduct(P,Q,G,H) \equiv  $
$  \{\langle x,\langle P\langle fst(fst(x)),fst(snd(x))\rangle  , Q\langle snd(fst(x)),snd(snd(x))\rangle \rangle \rangle .\ $
$  x \in  (G\times H)\times (G\times H)\}$

We define a context called //direct0// which holds an assumtion that $P, Q$ are binary operations on $G,H$, resp. and denotes $R$ as the direct product of $(G,P)$ and $(H,Q)$.

 ''Locale '' direct0
 ''fixes '' $ P$
 ''fixes '' $ Q$
 ''fixes '' $ G$
 ''fixes '' $ H$
 ''assumes '' Pfun: $ P : G\times G\rightarrow G$
 ''assumes '' Qfun: $ Q : H\times H\rightarrow H$
 ''fixes '' $ R$
 ''defines '' $ R \equiv  DirectProduct(P,Q,G,H)$


The direct product of binary operations is a binary operation.

 ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L1</nowiki>:
 ''   shows '' $ R : (G\times H)\times (G\times H)\rightarrow G\times H$+++[proof ]>
 ''from '' Pfun, Qfun  ''have''  $ \forall x\in (G\times H)\times (G\times H).\ $
$    \langle P\langle fst(fst(x)),fst(snd(x))\rangle ,Q\langle snd(fst(x)),snd(snd(x))\rangle \rangle  \in  G\times H$ 
 ''then ''  ''show''  $ thesis$ ''using''  <nowiki>ZF_fun_from_total</nowiki> ,  +++^[DirectProduct_def | DirectProduct_ZF ]... Definition of <nowiki>DirectProduct</nowiki>:
$ DirectProduct(P,Q,G,H) \equiv  $
$  \{\langle x,\langle P\langle fst(fst(x)),fst(snd(x))\rangle  , Q\langle snd(fst(x)),snd(snd(x))\rangle \rangle \rangle .\ $
$  x \in  (G\times H)\times (G\times H)\}$=== 
 ''qed'' === 

And it has the intended value.

 ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L2</nowiki>:
 ''   shows '' $ \forall x\in (G\times H).\  \forall y\in (G\times H).\  $
$  R\langle x,y\rangle  = \langle P\langle fst(x),fst(y)\rangle ,Q\langle snd(x),snd(y)\rangle \rangle $ ''using''  +++^[DirectProduct_def | DirectProduct_ZF ]... Definition of <nowiki>DirectProduct</nowiki>:
$ DirectProduct(P,Q,G,H) \equiv  $
$  \{\langle x,\langle P\langle fst(fst(x)),fst(snd(x))\rangle  , Q\langle snd(fst(x)),snd(snd(x))\rangle \rangle \rangle .\ $
$  x \in  (G\times H)\times (G\times H)\}$===  ,  +++^[DirectProduct_ZF_1_L1 | DirectProduct_ZF ]...  ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L1</nowiki>:  '' shows '' $ R : (G\times H)\times (G\times H)\rightarrow G\times H$ ===  ,  <nowiki>ZF_fun_from_tot_val</nowiki>

And the value belongs to the set the operation is defined on.

 ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L3</nowiki>:
 ''   shows '' $ \forall x\in (G\times H).\  \forall y\in (G\times H).\  R\langle x,y\rangle  \in  G\times H$ ''using''  +++^[DirectProduct_ZF_1_L1 | DirectProduct_ZF ]...  ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L1</nowiki>:  '' shows '' $ R : (G\times H)\times (G\times H)\rightarrow G\times H$ === 


!Associative and commutative operations

If P and Q are both associative or commutative operations, the direct product of P and Q has the same property.

Direct product of commutative operations is commutative.

 ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_2_L1</nowiki>:
 ''   assumes '' $ P \text{ is commutative on } G$ ''and '' $ Q \text{ is commutative on } H$ ''   shows '' $ R \text{ is commutative on } G\times H$+++[proof ]>
 ''from '' assms  ''have''  $ \forall x\in (G\times H).\  \forall y\in (G\times H).\  R\langle x,y\rangle  = R\langle y,x\rangle $ ''using''  +++^[DirectProduct_ZF_1_L2 | DirectProduct_ZF ]...  ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L2</nowiki>:  '' shows '' $ \forall x\in (G\times H).\  \forall y\in (G\times H).\  $
$  R\langle x,y\rangle  = \langle P\langle fst(x),fst(y)\rangle ,Q\langle snd(x),snd(y)\rangle \rangle $
===  ,  +++^[IsCommutative_def | func_ZF ]... Definition of <nowiki>IsCommutative</nowiki>:
$ f \text{ is commutative on } G \equiv  \forall x\in G.\  \forall y\in G.\  f\langle x,y\rangle  = f\langle y,x\rangle $=== 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[IsCommutative_def | func_ZF ]... Definition of <nowiki>IsCommutative</nowiki>:
$ f \text{ is commutative on } G \equiv  \forall x\in G.\  \forall y\in G.\  f\langle x,y\rangle  = f\langle y,x\rangle $=== 
 ''qed'' === 

Direct product of associative operations is associative.

 ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_2_L2</nowiki>:
 ''   assumes '' $ P \text{ is associative on } G$ ''and '' $ Q \text{ is associative on } H$ ''   shows '' $ R \text{ is associative on } G\times H$+++[proof ]>
 ''have''  $ \forall x\in G\times H.\  \forall y\in G\times H.\  \forall z\in G\times H.\  R\langle R\langle x,y\rangle ,z\rangle  =$
$    \langle P\langle P\langle fst(x),fst(y)\rangle ,fst(z)\rangle ,Q\langle Q\langle snd(x),snd(y)\rangle ,snd(z)\rangle \rangle $ ''using''  +++^[DirectProduct_ZF_1_L2 | DirectProduct_ZF ]...  ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L2</nowiki>:  '' shows '' $ \forall x\in (G\times H).\  \forall y\in (G\times H).\  $
$  R\langle x,y\rangle  = \langle P\langle fst(x),fst(y)\rangle ,Q\langle snd(x),snd(y)\rangle \rangle $
===  ,  +++^[DirectProduct_ZF_1_L3 | DirectProduct_ZF ]...  ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L3</nowiki>:  '' shows '' $ \forall x\in (G\times H).\  \forall y\in (G\times H).\  R\langle x,y\rangle  \in  G\times H$ === 
 ''moreover''   ''have''  $ \forall x\in G\times H.\  \forall y\in G\times H.\  \forall z\in G\times H.\  R\langle x,R\langle y,z\rangle \rangle  =$
$    \langle P\langle fst(x),P\langle fst(y),fst(z)\rangle \rangle ,Q\langle snd(x),Q\langle snd(y),snd(z)\rangle \rangle \rangle $ ''using''  +++^[DirectProduct_ZF_1_L2 | DirectProduct_ZF ]...  ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L2</nowiki>:  '' shows '' $ \forall x\in (G\times H).\  \forall y\in (G\times H).\  $
$  R\langle x,y\rangle  = \langle P\langle fst(x),fst(y)\rangle ,Q\langle snd(x),snd(y)\rangle \rangle $
===  ,  +++^[DirectProduct_ZF_1_L3 | DirectProduct_ZF ]...  ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L3</nowiki>:  '' shows '' $ \forall x\in (G\times H).\  \forall y\in (G\times H).\  R\langle x,y\rangle  \in  G\times H$ === 
 ''ultimately ''  ''have''  $ \forall x\in G\times H.\  \forall y\in G\times H.\  \forall z\in G\times H.\  R\langle R\langle x,y\rangle ,z\rangle  = R\langle x,R\langle y,z\rangle \rangle $ ''using''  <nowiki>assms</nowiki> ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[DirectProduct_ZF_1_L1 | DirectProduct_ZF ]...  ''lemma''   ''(in '' direct0 '') '' <nowiki>DirectProduct_ZF_1_L1</nowiki>:  '' shows '' $ R : (G\times H)\times (G\times H)\rightarrow G\times H$ ===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''qed'' === 

 ''end

'' +++![Comments on DirectProduct_ZF|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/DirectProduct_ZF"></iframe> </div> </html>
=== 
 ''theory'' EquivClass1 ''imports'' [[EquivClass]] [[func_ZF]] [[ZF1]]

 ''begin
'' 
In this theory file we extend the work on equivalence relations done in the standard Isabelle's EquivClass theory. That development is very good and all, but we really would prefer an approach contained within the a standard ZF set theory, without extensions specific to Isabelle. That is why this theory is written.

!Congruent functions and projections on the quotient

Suppose we have a set $X$ with a relation $r\subseteq X\times X$ and a function $f: X\rightarrow X$. The function $f$ can be compatible (congruent) with $r$ in the sense that if two elements $x,y$ are related then the values $f(x), f(x)$ are also related. This is especially useful if $r$ is an equivalence relation as it allows to "project" the function to the quotient space $X/r$ (the set of equivalence classes of $r$) and create a new function $F$ that satifies the formula $F([x]_r) = [f(x)]_r$. When $f$ is congruent with respect to $r$ such definition of the value of $F$ on the equivalence class $[x]_r$ does not depend on which $x$ we choose to represent the class. In this section we also consider binary operations that are congruent with respect to a relation. These are important in algebra - the congruency condition allows to project the operation to obtain the operation on the quotient space.

First we define the notion of function that maps equivalent elements to equivalent values. We use similar names as in the Isabelle's standard //EquivClass// theory to indicate the conceptual correspondence of the notions.

 ''Definition
'' $ Congruent(r,f) \equiv $
$  (\forall x y.\  \langle x,y\rangle  \in  r  \longrightarrow  \langle f(x),f(y)\rangle  \in  r)$

Now we will define the projection of a function onto the quotient space. In standard math the equivalence class of $x$ with respect to relation $r$ is usually denoted $[x]_r$. Here we reuse notation $r\{ x\}$ instead. This means the image of the set $\{ x\}$ with respect to the relation, which, for equivalence relations is exactly its equivalence class if you think about it.

 ''Definition
'' $ ProjFun(A,r,f) \equiv $
$  \{\langle c,\bigcup x\in c.\  r\{f(x)\}\rangle .\  c \in  (A//r)\}$

Elements of equivalence classes belong to the set.

 ''lemma''  <nowiki>EquivClass_1_L1</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ C \in  A//r$ ''and '' A3: $ x\in C$ ''   shows '' $ x\in A$+++[proof ]>
 ''from '' A2  ''have''  $ C \subseteq  \bigcup  (A//r)$ 
 ''with '' A1, A3  ''show''  $ x\in A$ ''using''  <nowiki>Union_quotient</nowiki>
 ''qed'' === 

The image of a subset of $X$ under projection is a subset of $A/r$.

 ''lemma''  <nowiki>EquivClass_1_L1A</nowiki>:
 ''   assumes '' $ A\subseteq X$ ''   shows '' $ \{r\{x\}.\  x\in A\} \subseteq  X//r$ ''using''  <nowiki>prems</nowiki> ,  <nowiki>quotientI</nowiki>

If an element belongs to an equivalence class, then its image under relation is this equivalence class.

 ''lemma''  <nowiki>EquivClass_1_L2</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$,  $ C \in  A//r$ ''and '' A2: $ x\in C$ ''   shows '' $ r\{x\} = C$+++[proof ]>
 ''from '' A1, A2  ''have''  $ x \in  r\{x\}$ ''using''  +++^[EquivClass_1_L1 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L1</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ C \in  A//r$  ''and'' $ x\in C$  '' shows '' $ x\in A$ ===  ,  <nowiki>equiv_class_self</nowiki>
 ''with '' A2  ''have''  I: $ r\{x\}\cap C \neq  0$ 
 ''from '' A1, A2  ''have''  $ r\{x\} \in  A//r$ ''using''  +++^[EquivClass_1_L1 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L1</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ C \in  A//r$  ''and'' $ x\in C$  '' shows '' $ x\in A$ ===  ,  <nowiki>quotientI</nowiki>
 ''with '' A1, I  ''show''  $ thesis$ ''using''  <nowiki>quotient_disj</nowiki>
 ''qed'' === 

Elements that belong to the same equivalence class are equivalent.

 ''lemma''  <nowiki>EquivClass_1_L2A</nowiki>:
 ''   assumes '' $ equiv(A,r)$,  $ C \in  A//r$,  $ x\in C$,  $ y\in C$ ''   shows '' $ \langle x,y\rangle  \in  r$ ''using''  <nowiki>assms</nowiki> ,  +++^[EquivClass_1_L2 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L2</nowiki>:  ''assumes '' $ equiv(A,r)$,   $ C \in  A//r$  ''and'' $ x\in C$  '' shows '' $ r\{x\} = C$ ===  ,  +++^[EquivClass_1_L1 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L1</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ C \in  A//r$  ''and'' $ x\in C$  '' shows '' $ x\in A$ ===  ,  <nowiki>equiv_class_eq_iff</nowiki>

Every $x$ is in the class of $y$, then they are equivalent.

 ''lemma''  <nowiki>EquivClass_1_L2B</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ y\in A$ ''and '' A3: $ x \in  r\{y\}$ ''   shows '' $ \langle x,y\rangle  \in  r$+++[proof ]>
 ''from '' A2  ''have''  $ r\{y\} \in  A//r$ ''using''  <nowiki>quotientI</nowiki>
 ''with '' A1, A3  ''show''  $ thesis$ ''using''  +++^[EquivClass_1_L1 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L1</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ C \in  A//r$  ''and'' $ x\in C$  '' shows '' $ x\in A$ ===  ,  <nowiki>equiv_class_self</nowiki> ,  <nowiki>equiv_class_nondisjoint</nowiki>
 ''qed'' === 

If a function is congruent then the equivalence classes of the values that come from the arguments from the same class are the same.

 ''lemma''  <nowiki>EquivClass_1_L3</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ Congruent(r,f)$ ''and '' A3: $ C \in  A//r$,  $ x\in C$,  $ y\in C$ ''   shows '' $ r\{f(x)\} = r\{f(y)\}$+++[proof ]>
 ''from '' A1, A3  ''have''  $ \langle x,y\rangle  \in  r$ ''using''  +++^[EquivClass_1_L2A | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L2A</nowiki>:  ''assumes '' $ equiv(A,r)$,   $ C \in  A//r$,   $ x\in C$,   $ y\in C$  '' shows '' $ \langle x,y\rangle  \in  r$ === 
 ''with '' A2  ''have''  $ \langle f(x),f(y)\rangle  \in  r$ ''using''  +++^[Congruent_def | EquivClass1 ]... Definition of <nowiki>Congruent</nowiki>:
$ Congruent(r,f) \equiv $
$  (\forall x y.\  \langle x,y\rangle  \in  r  \longrightarrow  \langle f(x),f(y)\rangle  \in  r)$=== 
 ''with '' A1  ''show''  $ thesis$ ''using''  <nowiki>equiv_class_eq</nowiki>
 ''qed'' === 

The values of congruent functions are in the space.

 ''lemma''  <nowiki>EquivClass_1_L4</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ C \in  A//r$,  $ x\in C$ ''and '' A3: $ Congruent(r,f)$ ''   shows '' $ f(x) \in  A$+++[proof ]>
 ''from '' A1, A2  ''have''  $ x\in A$ ''using''  +++^[EquivClass_1_L1 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L1</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ C \in  A//r$  ''and'' $ x\in C$  '' shows '' $ x\in A$ === 
 ''with '' A1  ''have''  $ \langle x,x\rangle  \in  r$ ''using''  <nowiki>equiv_def</nowiki> ,  <nowiki>refl_def</nowiki>
 ''with '' A3  ''have''  $ \langle f(x),f(x)\rangle  \in  r$ ''using''  +++^[Congruent_def | EquivClass1 ]... Definition of <nowiki>Congruent</nowiki>:
$ Congruent(r,f) \equiv $
$  (\forall x y.\  \langle x,y\rangle  \in  r  \longrightarrow  \langle f(x),f(y)\rangle  \in  r)$=== 
 ''with '' A1  ''show''  $ thesis$ ''using''  <nowiki>equiv_type</nowiki>
 ''qed'' === 

Equivalence classes are not empty.

 ''lemma''  <nowiki>EquivClass_1_L5</nowiki>:
 ''   assumes '' A1: $ refl(A,r)$ ''and '' A2: $ C \in  A//r$ ''   shows '' $ C\neq 0$+++[proof ]>
 ''from '' A2  ''obtain '' $ x$ ''where '' I: $ C = r\{x\}$ ''and '' $ x\in A$ ''using''  <nowiki>quotient_def</nowiki>
 ''from '' A1, $ x\in A$  ''have''  $ x \in  r\{x\}$ ''using''  <nowiki>refl_def</nowiki>
 ''with '' I  ''show''  $ thesis$ 
 ''qed'' === 

To avoid using an axiom of choice, we define the projection using the expression $\bigcup _{x\in C} r(\{f(x)\})$. The next lemma shows that for congruent function this is in the quotient space $A/r$.

 ''lemma''  <nowiki>EquivClass_1_L6</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ Congruent(r,f)$ ''and '' A3: $ C \in  A//r$ ''   shows '' $ (\bigcup x\in C.\  r\{f(x)\}) \in  A//r$+++[proof ]>
 ''from '' A1  ''have''  $ refl(A,r)$ ''unfolding''  <nowiki>equiv_def</nowiki>
 ''with '' A3  ''have''  $ C\neq 0$ ''using''  +++^[EquivClass_1_L5 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L5</nowiki>:  ''assumes '' $ refl(A,r)$  ''and'' $ C \in  A//r$  '' shows '' $ C\neq 0$ === 
 ''moreover''   ''from '' A2, A3, A1  ''have''  $ \forall x\in C.\  r\{f(x)\} \in  A//r$ ''using''  +++^[EquivClass_1_L4 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L4</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ C \in  A//r$,   $ x\in C$  ''and'' $ Congruent(r,f)$  '' shows '' $ f(x) \in  A$ ===  ,  <nowiki>quotientI</nowiki>
 ''moreover''   ''from '' A1, A2, A3  ''have''  $ \forall x y.\  x\in C \wedge  y\in C \longrightarrow  r\{f(x)\} = r\{f(y)\}$ ''using''  +++^[EquivClass_1_L3 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L3</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent(r,f)$  ''and'' $ C \in  A//r$,   $ x\in C$,   $ y\in C$  '' shows '' $ r\{f(x)\} = r\{f(y)\}$ === 
 ''ultimately ''  ''show''  $ thesis$ ''   by (rule '' +++^[ZF1_1_L2 | ZF1 ]...  ''lemma''  <nowiki>ZF1_1_L2</nowiki>:  ''assumes '' $ C\neq 0$  ''and'' $ \forall x\in C.\  b(x) \in  A$  ''and'' $ \forall x y.\  x\in C \wedge  y\in C \longrightarrow  b(x) = b(y)$  '' shows '' $ (\bigcup x\in C.\  b(x))\in A$ ===  '')'' 
 ''qed'' === 

Congruent functions can be projected.

 ''lemma''  <nowiki>EquivClass_1_T0</nowiki>:
 ''   assumes '' $ equiv(A,r)$,  $ Congruent(r,f)$ ''   shows '' $ ProjFun(A,r,f) : A//r \rightarrow  A//r$ ''using''  <nowiki>assms</nowiki> ,  +++^[EquivClass_1_L6 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L6</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent(r,f)$  ''and'' $ C \in  A//r$  '' shows '' $ (\bigcup x\in C.\  r\{f(x)\}) \in  A//r$ ===  ,  +++^[ProjFun_def | EquivClass1 ]... Definition of <nowiki>ProjFun</nowiki>:
$ ProjFun(A,r,f) \equiv $
$  \{\langle c,\bigcup x\in c.\  r\{f(x)\}\rangle .\  c \in  (A//r)\}$===  ,  <nowiki>ZF_fun_from_total</nowiki>

We now define congruent functions of two variables (binary funtions). The predicate //Congruent2// corresponds to //congruent2// in Isabelle's standard //EquivClass// theory, but uses ZF-functions rather than meta-functions.

 ''Definition
'' $ Congruent2(r,f) \equiv $
$  (\forall x_1 x_2 y_1 y_2.\  \langle x_1,x_2\rangle  \in  r \wedge  \langle y_1,y_2\rangle  \in  r  \longrightarrow  $
$  \langle f\langle x_1,y_1\rangle , f\langle x_2,y_2\rangle  \rangle  \in  r)$

Next we define the notion of projecting a binary operation to the quotient space. This is a very important concept that allows to define quotient groups, among other things.

 ''Definition
'' $ ProjFun2(A,r,f) \equiv $
$  \{\langle p,\bigcup  z \in  fst(p)\times snd(p).\  r\{f(z)\}\rangle .\  p \in  (A//r)\times (A//r) \}$

The following lemma is a two-variables equivalent of //EquivClass_1_L3//.

 ''lemma''  <nowiki>EquivClass_1_L7</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ Congruent2(r,f)$ ''and '' A3: $ C_1 \in  A//r$,  $ C_2 \in  A//r$ ''and '' A4: $ z_1 \in  C_1\times C_2$,  $ z_2 \in  C_1\times C_2$ ''   shows '' $ r\{f(z_1)\} = r\{f(z_2)\}$+++[proof ]>
 ''from '' A4  ''obtain '' $ x_1$ $ y_1$ $ x_2$ $ y_2$ ''where '' $ x_1\in C_1$ ''and '' $ y_1\in C_2$ ''and '' $ z_1 = \langle x_1,y_1\rangle $ ''and '' $ x_2\in C_1$ ''and '' $ y_2\in C_2$ ''and '' $ z_2 = \langle x_2,y_2\rangle $ 
 ''with '' A1, A3  ''have''  $ \langle x_1,x_2\rangle  \in  r$ ''and '' $ \langle y_1,y_2\rangle  \in  r$ ''using''  +++^[EquivClass_1_L2A | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L2A</nowiki>:  ''assumes '' $ equiv(A,r)$,   $ C \in  A//r$,   $ x\in C$,   $ y\in C$  '' shows '' $ \langle x,y\rangle  \in  r$ === 
 ''with '' A2  ''have''  $ \langle f\langle x_1,y_1\rangle ,f\langle x_2,y_2\rangle \rangle  \in  r$ ''using''  +++^[Congruent2_def | EquivClass1 ]... Definition of <nowiki>Congruent2</nowiki>:
$ Congruent2(r,f) \equiv $
$  (\forall x_1 x_2 y_1 y_2.\  \langle x_1,x_2\rangle  \in  r \wedge  \langle y_1,y_2\rangle  \in  r  \longrightarrow  $
$  \langle f\langle x_1,y_1\rangle , f\langle x_2,y_2\rangle  \rangle  \in  r)$=== 
 ''with '' A1, $ z_1 = \langle x_1,y_1\rangle $, $ z_2 = \langle x_2,y_2\rangle $  ''show''  $ thesis$ ''using''  <nowiki>equiv_class_eq</nowiki>
 ''qed'' === 

The values of congruent functions of two variables are in the space.

 ''lemma''  <nowiki>EquivClass_1_L8</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ C_1 \in  A//r$ ''and '' A3: $ C_2 \in  A//r$ ''and '' A4: $ z \in  C_1\times C_2$ ''and '' A5: $ Congruent2(r,f)$ ''   shows '' $ f(z) \in  A$+++[proof ]>
 ''from '' A4  ''obtain '' $ x$ $ y$ ''where '' $ x\in C_1$ ''and '' $ y\in C_2$ ''and '' $ z = \langle x,y\rangle $ 
 ''with '' A1, A2, A3  ''have''  $ x\in A$ ''and '' $ y\in A$ ''using''  +++^[EquivClass_1_L1 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L1</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ C \in  A//r$  ''and'' $ x\in C$  '' shows '' $ x\in A$ === 
 ''with '' A1, A4  ''have''  $ \langle x,x\rangle  \in  r$ ''and '' $ \langle y,y\rangle  \in  r$ ''using''  <nowiki>equiv_def</nowiki> ,  <nowiki>refl_def</nowiki>
 ''with '' A5  ''have''  $ \langle f\langle x,y\rangle , f\langle x,y\rangle  \rangle  \in  r$ ''using''  +++^[Congruent2_def | EquivClass1 ]... Definition of <nowiki>Congruent2</nowiki>:
$ Congruent2(r,f) \equiv $
$  (\forall x_1 x_2 y_1 y_2.\  \langle x_1,x_2\rangle  \in  r \wedge  \langle y_1,y_2\rangle  \in  r  \longrightarrow  $
$  \langle f\langle x_1,y_1\rangle , f\langle x_2,y_2\rangle  \rangle  \in  r)$=== 
 ''with '' A1, $ z = \langle x,y\rangle $  ''show''  $ thesis$ ''using''  <nowiki>equiv_type</nowiki>
 ''qed'' === 

The values of congruent functions are in the space. Note that although this lemma is intended to be used with functions, we don't need to assume that we $f$ is a function.

 ''lemma''  <nowiki>EquivClass_1_L8A</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ x\in A$,  $ y\in A$ ''and '' A3: $ Congruent2(r,f)$ ''   shows '' $ f\langle x,y\rangle  \in  A$+++[proof ]>
 ''from '' A1, A2  ''have''  $ r\{x\} \in  A//r$,  $ r\{y\} \in  A//r$,  $ \langle x,y\rangle  \in  r\{x\}\times r\{y\}$ ''using''  <nowiki>equiv_class_self</nowiki> ,  <nowiki>quotientI</nowiki>
 ''with '' A1, A3  ''show''  $ thesis$ ''using''  +++^[EquivClass_1_L8 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L8</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ C_1 \in  A//r$  ''and'' $ C_2 \in  A//r$  ''and'' $ z \in  C_1\times C_2$  ''and'' $ Congruent2(r,f)$  '' shows '' $ f(z) \in  A$ === 
 ''qed'' === 

The following lemma is a two-variables equivalent of //EquivClass_1_L6//.

 ''lemma''  <nowiki>EquivClass_1_L9</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ Congruent2(r,f)$ ''and '' A3: $ p \in  (A//r)\times (A//r)$ ''   shows '' $ (\bigcup  z \in  fst(p)\times snd(p).\  r\{f(z)\}) \in  A//r$+++[proof ]>
 ''from '' A3  ''have''  $ fst(p) \in  A//r$ ''and '' $ snd(p) \in  A//r$ 
 ''with '' A1, A2  ''have''  I: $ \forall z \in  fst(p)\times snd(p).\  f(z) \in  A$ ''using''  +++^[EquivClass_1_L8 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L8</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ C_1 \in  A//r$  ''and'' $ C_2 \in  A//r$  ''and'' $ z \in  C_1\times C_2$  ''and'' $ Congruent2(r,f)$  '' shows '' $ f(z) \in  A$ === 
 ''from '' A3, A1  ''have''  $ fst(p)\times snd(p) \neq  0$ ''using''  <nowiki>equiv_def</nowiki> ,  +++^[EquivClass_1_L5 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L5</nowiki>:  ''assumes '' $ refl(A,r)$  ''and'' $ C \in  A//r$  '' shows '' $ C\neq 0$ ===  ,  <nowiki>Sigma_empty_iff</nowiki>
 ''moreover''   ''from '' A1, I  ''have''  $ \forall z \in  fst(p)\times snd(p).\  r\{f(z)\} \in  A//r$ ''using''  <nowiki>quotientI</nowiki>
 ''moreover''   ''from '' A1, A2, $ fst(p) \in  A//r$, $ snd(p) \in  A//r$  ''have''  $ \forall z_1 z_2.\  z_1 \in  fst(p)\times snd(p) \wedge  z_2 \in  fst(p)\times snd(p) \longrightarrow  $
$    r\{f(z_1)\} = r\{f(z_2)\}$ ''using''  +++^[EquivClass_1_L7 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L7</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ C_1 \in  A//r$,   $ C_2 \in  A//r$  ''and'' $ z_1 \in  C_1\times C_2$,   $ z_2 \in  C_1\times C_2$  '' shows '' $ r\{f(z_1)\} = r\{f(z_2)\}$ === 
 ''ultimately ''  ''show''  $ thesis$ ''   by (rule '' +++^[ZF1_1_L2 | ZF1 ]...  ''lemma''  <nowiki>ZF1_1_L2</nowiki>:  ''assumes '' $ C\neq 0$  ''and'' $ \forall x\in C.\  b(x) \in  A$  ''and'' $ \forall x y.\  x\in C \wedge  y\in C \longrightarrow  b(x) = b(y)$  '' shows '' $ (\bigcup x\in C.\  b(x))\in A$ ===  '')'' 
 ''qed'' === 

Congruent functions of two variables can be projected.

 ''theorem''  <nowiki>EquivClass_1_T1</nowiki>:
 ''   assumes '' $ equiv(A,r)$,  $ Congruent2(r,f)$ ''   shows '' $ ProjFun2(A,r,f) : (A//r)\times (A//r) \rightarrow  A//r$ ''using''  <nowiki>assms</nowiki> ,  +++^[EquivClass_1_L9 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L9</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ p \in  (A//r)\times (A//r)$  '' shows '' $ (\bigcup  z \in  fst(p)\times snd(p).\  r\{f(z)\}) \in  A//r$ ===  ,  +++^[ProjFun2_def | EquivClass1 ]... Definition of <nowiki>ProjFun2</nowiki>:
$ ProjFun2(A,r,f) \equiv $
$  \{\langle p,\bigcup  z \in  fst(p)\times snd(p).\  r\{f(z)\}\rangle .\  p \in  (A//r)\times (A//r) \}$===  ,  <nowiki>ZF_fun_from_total</nowiki>

The projection diagram commutes. I wish I knew how to draw this diagram in LaTeX.

 ''lemma''  <nowiki>EquivClass_1_L10</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ Congruent2(r,f)$ ''and '' A3: $ x\in A$,  $ y\in A$ ''   shows '' $ ProjFun2(A,r,f)\langle r\{x\},r\{y\}\rangle  = r\{f\langle x,y\rangle \}$+++[proof ]>
 ''from '' A3, A1  ''have''  $ r\{x\} \times  r\{y\} \neq  0$ ''using''  <nowiki>quotientI</nowiki> ,  <nowiki>equiv_def</nowiki> ,  +++^[EquivClass_1_L5 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L5</nowiki>:  ''assumes '' $ refl(A,r)$  ''and'' $ C \in  A//r$  '' shows '' $ C\neq 0$ ===  ,  <nowiki>Sigma_empty_iff</nowiki>
 ''moreover''   ''have''  $ \forall z \in  r\{x\}\times r\{y\}.\   r\{f(z)\} = r\{f\langle x,y\rangle \}$+++[proof ]>
 ''fix '' $ z$
 ''assume '' A4: $ z \in  r\{x\}\times r\{y\}$
 ''from '' A1, A3  ''have''  $ r\{x\} \in  A//r$,  $ r\{y\} \in  A//r$,  $ \langle x,y\rangle  \in  r\{x\}\times r\{y\}$ ''using''  <nowiki>quotientI</nowiki> ,  <nowiki>equiv_class_self</nowiki>
 ''with '' A1, A2, A4  ''show''  $ r\{f(z)\} = r\{f\langle x,y\rangle \}$ ''using''  +++^[EquivClass_1_L7 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L7</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ C_1 \in  A//r$,   $ C_2 \in  A//r$  ''and'' $ z_1 \in  C_1\times C_2$,   $ z_2 \in  C_1\times C_2$  '' shows '' $ r\{f(z_1)\} = r\{f(z_2)\}$ === 
 ''qed'' === 
 ''ultimately ''  ''have''  $ (\bigcup z \in  r\{x\}\times r\{y\}.\  r\{f(z)\}) =  r\{f\langle x,y\rangle \}$ ''   by (rule '' +++^[ZF1_1_L1 | ZF1 ]...  ''lemma''  <nowiki>ZF1_1_L1</nowiki>:  ''assumes '' $ C\neq 0$  ''and'' $ \forall y\in C.\  b(y) = A$  '' shows '' $ (\bigcup y\in C.\  b(y)) = A$ ===  '')'' 
 ''moreover''   ''have''  $ ProjFun2(A,r,f)\langle r\{x\},r\{y\}\rangle  = (\bigcup z \in  r\{x\}\times r\{y\}.\  r\{f(z)\})$+++[proof ]>
 ''from '' assms  ''have''  $ ProjFun2(A,r,f) : (A//r)\times (A//r) \rightarrow  A//r$,  $ \langle r\{x\},r\{y\}\rangle  \in  (A//r)\times (A//r)$ ''using''  +++^[EquivClass_1_T1 | EquivClass1 ]...  ''theorem''  <nowiki>EquivClass_1_T1</nowiki>:  ''assumes '' $ equiv(A,r)$,   $ Congruent2(r,f)$  '' shows '' $ ProjFun2(A,r,f) : (A//r)\times (A//r) \rightarrow  A//r$ ===  ,  <nowiki>quotientI</nowiki>
 ''then ''  ''show''  $ thesis$ ''using''  +++^[ProjFun2_def | EquivClass1 ]... Definition of <nowiki>ProjFun2</nowiki>:
$ ProjFun2(A,r,f) \equiv $
$  \{\langle p,\bigcup  z \in  fst(p)\times snd(p).\  r\{f(z)\}\rangle .\  p \in  (A//r)\times (A//r) \}$===  ,  <nowiki>ZF_fun_from_tot_val</nowiki>
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 


!Projecting commutative, associative and distributive operations.

In this section we show that if the operations are congruent with respect to an equivalence relation then the projection to the quotient space preserves commutativity, associativity and distributivity.

The projection of commutative operation is commutative.

 ''lemma''  <nowiki>EquivClass_2_L1</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ Congruent2(r,f)$ ''and '' A3: $ f \text{ is commutative on } A$ ''and '' A4: $ c1 \in  A//r$,  $ c2 \in  A//r$ ''   shows '' $ ProjFun2(A,r,f)\langle c1,c2\rangle  = ProjFun2(A,r,f)\langle c2,c1\rangle $+++[proof ]>
 ''from '' A4  ''obtain '' $ x$ $ y$ ''where '' D1: $ c1 = r\{x\}$,  $ c2 = r\{y\}$,  $ x\in A$,  $ y\in A$ ''using''  <nowiki>quotient_def</nowiki>
 ''with '' A1, A2  ''have''  $ ProjFun2(A,r,f)\langle c1,c2\rangle  = r\{f\langle x,y\rangle \}$ ''using''  +++^[EquivClass_1_L10 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L10</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ x\in A$,   $ y\in A$  '' shows '' $ ProjFun2(A,r,f)\langle r\{x\},r\{y\}\rangle  = r\{f\langle x,y\rangle \}$ === 
 ''also''   ''from '' A3, D1  ''have''  $ r\{f\langle x,y\rangle \} = r\{f\langle y,x\rangle \}$ ''using''  +++^[IsCommutative_def | func_ZF ]... Definition of <nowiki>IsCommutative</nowiki>:
$ f \text{ is commutative on } G \equiv  \forall x\in G.\  \forall y\in G.\  f\langle x,y\rangle  = f\langle y,x\rangle $=== 
 ''also''   ''from '' A1, A2, D1  ''have''  $ r\{f\langle y,x\rangle \} = ProjFun2(A,r,f) \langle c2,c1\rangle $ ''using''  +++^[EquivClass_1_L10 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L10</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ x\in A$,   $ y\in A$  '' shows '' $ ProjFun2(A,r,f)\langle r\{x\},r\{y\}\rangle  = r\{f\langle x,y\rangle \}$ === 
 ''finally ''  ''show''  $ thesis$ 
 ''qed'' === 

The projection of commutative operation is commutative.

 ''theorem''  <nowiki>EquivClass_2_T1</nowiki>:
 ''   assumes '' $ equiv(A,r)$ ''and '' $ Congruent2(r,f)$ ''and '' $ f \text{ is commutative on } A$ ''   shows '' $ ProjFun2(A,r,f) \text{ is commutative on } A//r$ ''using''  <nowiki>prems</nowiki> ,  +++^[IsCommutative_def | func_ZF ]... Definition of <nowiki>IsCommutative</nowiki>:
$ f \text{ is commutative on } G \equiv  \forall x\in G.\  \forall y\in G.\  f\langle x,y\rangle  = f\langle y,x\rangle $===  ,  +++^[EquivClass_2_L1 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_2_L1</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ f \text{ is commutative on } A$  ''and'' $ c1 \in  A//r$,   $ c2 \in  A//r$  '' shows '' $ ProjFun2(A,r,f)\langle c1,c2\rangle  = ProjFun2(A,r,f)\langle c2,c1\rangle $ === 

The projection of an associative operation is associative.

 ''lemma''  <nowiki>EquivClass_2_L2</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ Congruent2(r,f)$ ''and '' A3: $ f \text{ is associative on } A$ ''and '' A4: $ c1 \in  A//r$,  $ c2 \in  A//r$,  $ c3 \in  A//r$ ''and '' A5: $ g = ProjFun2(A,r,f)$ ''   shows '' $ g\langle g\langle c1,c2\rangle ,c3\rangle  = g\langle c1,g\langle c2,c3\rangle \rangle $+++[proof ]>
 ''from '' A4  ''obtain '' $ x$ $ y$ $ z$ ''where '' D1: $ c1 = r\{x\}$,  $ c2 = r\{y\}$,  $ c3 = r\{z\}$,  $ x\in A$,  $ y\in A$,  $ z\in A$ ''using''  <nowiki>quotient_def</nowiki>
 ''with '' A3  ''have''  T1: $ f\langle x,y\rangle  \in  A$,  $ f\langle y,z\rangle  \in  A$ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$===  ,  <nowiki>apply_type</nowiki>
 ''with '' A1, A2, D1, A5  ''have''  $ g\langle g\langle c1,c2\rangle ,c3\rangle  =  r\{f\langle f\langle x,y\rangle ,z\rangle \}$ ''using''  +++^[EquivClass_1_L10 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L10</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ x\in A$,   $ y\in A$  '' shows '' $ ProjFun2(A,r,f)\langle r\{x\},r\{y\}\rangle  = r\{f\langle x,y\rangle \}$ === 
 ''also''   ''from '' D1, A3  ''have''  $ \ldots  = r\{f\langle x,f\langle y,z\rangle  \rangle \}$ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''also''   ''from '' T1, A1, A2, D1, A5  ''have''  $ \ldots  = g\langle c1,g\langle c2,c3\rangle \rangle $ ''using''  +++^[EquivClass_1_L10 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L10</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ x\in A$,   $ y\in A$  '' shows '' $ ProjFun2(A,r,f)\langle r\{x\},r\{y\}\rangle  = r\{f\langle x,y\rangle \}$ === 
 ''finally ''  ''show''  $ thesis$ 
 ''qed'' === 

The projection of an associative operation is associative on the quotient.

 ''theorem''  <nowiki>EquivClass_2_T2</nowiki>:
 ''   assumes '' A1: $ equiv(A,r)$ ''and '' A2: $ Congruent2(r,f)$ ''and '' A3: $ f \text{ is associative on } A$ ''   shows '' $ ProjFun2(A,r,f) \text{ is associative on } A//r$+++[proof ]>
 ''let '' $ g = ProjFun2(A,r,f)$
 ''from '' A1, A2  ''have''  $ g \in  (A//r)\times (A//r) \rightarrow  A//r$ ''using''  +++^[EquivClass_1_T1 | EquivClass1 ]...  ''theorem''  <nowiki>EquivClass_1_T1</nowiki>:  ''assumes '' $ equiv(A,r)$,   $ Congruent2(r,f)$  '' shows '' $ ProjFun2(A,r,f) : (A//r)\times (A//r) \rightarrow  A//r$ === 
 ''moreover''   ''from '' A1, A2, A3  ''have''  $ \forall c1 \in  A//r.\ \forall c2 \in  A//r.\ \forall c3 \in  A//r.\ $
$    g\langle g\langle c1,c2\rangle ,c3\rangle  = g\langle c1,g\langle c2,c3\rangle \rangle $ ''using''  +++^[EquivClass_2_L2 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_2_L2</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ f \text{ is associative on } A$  ''and'' $ c1 \in  A//r$,   $ c2 \in  A//r$,   $ c3 \in  A//r$  ''and'' $ g = ProjFun2(A,r,f)$  '' shows '' $ g\langle g\langle c1,c2\rangle ,c3\rangle  = g\langle c1,g\langle c2,c3\rangle \rangle $ === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''qed'' === 

The essential condition to show that distributivity is preserved by projections to quotient spaces, provided both operations are congruent with respect to the equivalence relation.

 ''lemma''  <nowiki>EquivClass_2_L3</nowiki>:
 ''   assumes '' A1: $ IsDistributive(X,A,M)$ ''and '' A2: $ equiv(X,r)$ ''and '' A3: $ Congruent2(r,A)$,  $ Congruent2(r,M)$ ''and '' A4: $ a \in  X//r$,  $ b \in  X//r$,  $ c \in  X//r$ ''and '' A5: $ A_p = ProjFun2(X,r,A)$,  $ M_p = ProjFun2(X,r,M)$ ''   shows '' $ M_p\langle a,A_p\langle b,c\rangle \rangle  = A_p\langle  M_p\langle a,b\rangle ,M_p\langle a,c\rangle \rangle  \wedge  $
$  M_p\langle  A_p\langle b,c\rangle ,a \rangle  = A_p\langle  M_p\langle b,a\rangle , M_p\langle c,a\rangle \rangle $+++[proof ]>
 ''from '' A4  ''obtain '' $ x$ $ y$ $ z$ ''where '' $ x\in X$,  $ y\in X$,  $ z\in X$,  $ a = r\{x\}$,  $ b = r\{y\}$,  $ c = r\{z\}$ ''using''  <nowiki>quotient_def</nowiki>
 ''with '' A1, A2, A3, A5  ''show''  $ M_p\langle a,A_p\langle b,c\rangle \rangle  = A_p\langle  M_p\langle a,b\rangle ,M_p\langle a,c\rangle \rangle $ ''and '' $ M_p\langle  A_p\langle b,c\rangle ,a \rangle  = A_p\langle  M_p\langle b,a\rangle , M_p\langle c,a\rangle \rangle $ ''using''  +++^[EquivClass_1_L8A | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L8A</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ x\in A$,   $ y\in A$  ''and'' $ Congruent2(r,f)$  '' shows '' $ f\langle x,y\rangle  \in  A$ ===  ,  +++^[EquivClass_1_L10 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_1_L10</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ x\in A$,   $ y\in A$  '' shows '' $ ProjFun2(A,r,f)\langle r\{x\},r\{y\}\rangle  = r\{f\langle x,y\rangle \}$ ===  ,  +++^[IsDistributive_def | func_ZF ]... Definition of <nowiki>IsDistributive</nowiki>:
$ IsDistributive(X,A,M) \equiv  (\forall a\in X.\ \forall b\in X.\ \forall c\in X.\ $
$  M\langle a,A\langle b,c\rangle \rangle  = A\langle M\langle a,b\rangle ,M\langle a,c\rangle \rangle  \wedge  $
$  M\langle A\langle b,c\rangle ,a\rangle  = A\langle M\langle b,a\rangle ,M\langle c,a\rangle  \rangle )$=== 
 ''qed'' === 

Distributivity is preserved by projections to quotient spaces, provided both operations are congruent with respect to the equivalence relation.

 ''lemma''  <nowiki>EquivClass_2_L4</nowiki>:
 ''   assumes '' A1: $ IsDistributive(X,A,M)$ ''and '' A2: $ equiv(X,r)$ ''and '' A3: $ Congruent2(r,A)$,  $ Congruent2(r,M)$ ''   shows '' $ IsDistributive(X//r,ProjFun2(X,r,A),ProjFun2(X,r,M))$+++[proof ]>
 ''let '' $ A_p = ProjFun2(X,r,A)$
 ''let '' $ M_p = ProjFun2(X,r,M)$
 ''from '' A1, A2, A3  ''have''  $ \forall a\in X//r.\ \forall b\in X//r.\ \forall c\in X//r.\ $
$   M_p\langle a,A_p\langle b,c\rangle \rangle  = A_p\langle M_p\langle a,b\rangle ,M_p\langle a,c\rangle \rangle  \wedge  $
$   M_p\langle A_p\langle b,c\rangle ,a\rangle  = A_p\langle M_p\langle b,a\rangle ,M_p\langle c,a\rangle \rangle $ ''using''  +++^[EquivClass_2_L3 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_2_L3</nowiki>:  ''assumes '' $ IsDistributive(X,A,M)$  ''and'' $ equiv(X,r)$  ''and'' $ Congruent2(r,A)$,   $ Congruent2(r,M)$  ''and'' $ a \in  X//r$,   $ b \in  X//r$,   $ c \in  X//r$  ''and'' $ A_p = ProjFun2(X,r,A)$,   $ M_p = ProjFun2(X,r,M)$  '' shows '' $ M_p\langle a,A_p\langle b,c\rangle \rangle  = A_p\langle  M_p\langle a,b\rangle ,M_p\langle a,c\rangle \rangle  \wedge  $
$  M_p\langle  A_p\langle b,c\rangle ,a \rangle  = A_p\langle  M_p\langle b,a\rangle , M_p\langle c,a\rangle \rangle $
=== 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[IsDistributive_def | func_ZF ]... Definition of <nowiki>IsDistributive</nowiki>:
$ IsDistributive(X,A,M) \equiv  (\forall a\in X.\ \forall b\in X.\ \forall c\in X.\ $
$  M\langle a,A\langle b,c\rangle \rangle  = A\langle M\langle a,b\rangle ,M\langle a,c\rangle \rangle  \wedge  $
$  M\langle A\langle b,c\rangle ,a\rangle  = A\langle M\langle b,a\rangle ,M\langle c,a\rangle  \rangle )$=== 
 ''qed'' === 


!Saturated sets

In this section we consider sets that are saturated with respect to an equivalence relation. A set $A$ is saturated with respect to a relation $r$ if $A=r^{-1}(r(A))$. For equivalence relations saturated sets are unions of equivalemce classes. This makes them useful as a tool to define subsets of the quoutient space using properties of representants. Namely, we often define a set $B\subseteq X/r$ by saying that $[x]_r \in B$ iff $x\in A$. If $A$ is a saturated set, this definition is consistent in the sense that it does not depend on the choice of $x$ to represent $[x]_r$.

The following defines the notion of a saturated set. Recall that in Isabelle $ r^{-1}(A)$ is the inverse image of $A$ with respect to relation $r$. This definition is not specific to equivalence relations.

 ''Definition
'' $ IsSaturated(r,A) \equiv  A = r^{-1}(r(A))$

For equivalence relations a set is saturated iff it is an image of itself.

 ''lemma''  <nowiki>EquivClass_3_L1</nowiki>:
 ''   assumes '' A1: $ equiv(X,r)$ ''   shows '' $ IsSaturated(r,A) \longleftrightarrow  A = r(A)$+++[proof ]>
 ''assume '' $ IsSaturated(r,A)$
 ''then ''  ''have''  $ A = (converse(r) O r)(A)$ ''using''  +++^[IsSaturated_def | EquivClass1 ]... Definition of <nowiki>IsSaturated</nowiki>:
$ IsSaturated(r,A) \equiv  A = r^{-1}(r(A))$===  ,  <nowiki>vimage_def</nowiki> ,  <nowiki>image_comp</nowiki>
 ''also''   ''from '' A1  ''have''  $ \ldots  = r(A)$ ''using''  <nowiki>equiv_comp_eq</nowiki>
 ''finally ''  ''show''  $ A = r(A)$ 
 ''next '' 
 ''assume '' $ A = r(A)$
 ''with '' A1  ''have''  $ A = (converse(r) O r)(A)$ ''using''  <nowiki>equiv_comp_eq</nowiki>
 ''also''   ''have''  $ \ldots  =  r^{-1}(r(A))$ ''using''  <nowiki>vimage_def</nowiki> ,  <nowiki>image_comp</nowiki>
 ''finally ''  ''have''  $ A =  r^{-1}(r(A))$ 
 ''then ''  ''show''  $ IsSaturated(r,A)$ ''using''  +++^[IsSaturated_def | EquivClass1 ]... Definition of <nowiki>IsSaturated</nowiki>:
$ IsSaturated(r,A) \equiv  A = r^{-1}(r(A))$=== 
 ''qed'' === 

For equivalence relations sets are contained in their images.

 ''lemma''  <nowiki>EquivClass_3_L2</nowiki>:
 ''   assumes '' A1: $ equiv(X,r)$ ''and '' A2: $ A\subseteq X$ ''   shows '' $ A \subseteq  r(A)$+++[proof ]>
 ''fix '' $ a$
 ''assume '' $ a\in A$
 ''with '' A1, A2  ''have''  $ a \in  r\{a\}$ ''using''  <nowiki>equiv_class_self</nowiki>
 ''with '' $ a\in A$  ''show''  $ a \in  r(A)$ 
 ''qed'' === 

The next lemma shows that if "$\sim$" is an equivalence relation and a set $A$ is such that $a\in A$ and $a\sim b$ implies $b\in A$, then $A$ is saturated with respect to the relation.

 ''lemma''  <nowiki>EquivClass_3_L3</nowiki>:
 ''   assumes '' A1: $ equiv(X,r)$ ''and '' A2: $ r \subseteq  X\times X$ ''and '' A3: $ A\subseteq X$ ''and '' A4: $ \forall x\in A.\  \forall y\in X.\  \langle x,y\rangle  \in  r \longrightarrow  y\in A$ ''   shows '' $ IsSaturated(r,A)$+++[proof ]>
 ''from '' A2, A4  ''have''  $ r(A) \subseteq  A$ ''using''  <nowiki>image_iff</nowiki>
 ''moreover''   ''from '' A1, A3  ''have''  $ A \subseteq  r(A)$ ''using''  +++^[EquivClass_3_L2 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_3_L2</nowiki>:  ''assumes '' $ equiv(X,r)$  ''and'' $ A\subseteq X$  '' shows '' $ A \subseteq  r(A)$ === 
 ''ultimately ''  ''have''  $ A = r(A)$ 
 ''with '' A1  ''show''  $ IsSaturated(r,A)$ ''using''  +++^[EquivClass_3_L1 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_3_L1</nowiki>:  ''assumes '' $ equiv(X,r)$  '' shows '' $ IsSaturated(r,A) \longleftrightarrow  A = r(A)$ === 
 ''qed'' === 

If $A\subseteq X$ and $A$ is saturated and $x\sim y$, then $x\in A$ iff $y\in A$. Here we show only one direction.

 ''lemma''  <nowiki>EquivClass_3_L4</nowiki>:
 ''   assumes '' A1: $ equiv(X,r)$ ''and '' A2: $ IsSaturated(r,A)$ ''and '' A3: $ A\subseteq X$ ''and '' A4: $ \langle x,y\rangle  \in  r$ ''and '' A5: $ x\in X$,  $ y\in A$ ''   shows '' $ x\in A$+++[proof ]>
 ''from '' A1, A5  ''have''  $ x \in  r\{x\}$ ''using''  <nowiki>equiv_class_self</nowiki>
 ''with '' A1, A3, A4, A5  ''have''  $ x \in  r(A)$ ''using''  <nowiki>equiv_class_eq</nowiki> ,  <nowiki>equiv_class_self</nowiki>
 ''with '' A1, A2  ''show''  $ x\in A$ ''using''  +++^[EquivClass_3_L1 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_3_L1</nowiki>:  ''assumes '' $ equiv(X,r)$  '' shows '' $ IsSaturated(r,A) \longleftrightarrow  A = r(A)$ === 
 ''qed'' === 

If $A\subseteq X$ and $A$ is saturated and $x\sim y$, then $x\in A$ iff $y\in A$.

 ''lemma''  <nowiki>EquivClass_3_L5</nowiki>:
 ''   assumes '' A1: $ equiv(X,r)$ ''and '' A2: $ IsSaturated(r,A)$ ''and '' A3: $ A\subseteq X$ ''and '' A4: $ x\in X$,  $ y\in X$ ''and '' A5: $ \langle x,y\rangle  \in  r$ ''   shows '' $ x\in A \longleftrightarrow  y\in A$+++[proof ]>
 ''assume '' $ y\in A$
 ''with '' prems  ''show''  $ x\in A$ ''using''  +++^[EquivClass_3_L4 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_3_L4</nowiki>:  ''assumes '' $ equiv(X,r)$  ''and'' $ IsSaturated(r,A)$  ''and'' $ A\subseteq X$  ''and'' $ \langle x,y\rangle  \in  r$  ''and'' $ x\in X$,   $ y\in A$  '' shows '' $ x\in A$ === 
 ''next '' 
 ''assume '' $ x\in A$
 ''from '' A1, A5  ''have''  $ \langle y,x\rangle  \in  r$ ''using''  <nowiki>equiv_is_sym</nowiki>
 ''with '' A1, A2, A3, A4, $ x\in A$  ''show''  $ y\in A$ ''using''  +++^[EquivClass_3_L4 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_3_L4</nowiki>:  ''assumes '' $ equiv(X,r)$  ''and'' $ IsSaturated(r,A)$  ''and'' $ A\subseteq X$  ''and'' $ \langle x,y\rangle  \in  r$  ''and'' $ x\in X$,   $ y\in A$  '' shows '' $ x\in A$ === 
 ''qed'' === 

If $A$ is saturated then $x\in A$ iff its class is in the projection of $A$.

 ''lemma''  <nowiki>EquivClass_3_L6</nowiki>:
 ''   assumes '' A1: $ equiv(X,r)$ ''and '' A2: $ IsSaturated(r,A)$ ''and '' A3: $ A\subseteq X$ ''and '' A4: $ x\in X$ ''and '' A5: $ B = \{r\{x\}.\  x\in A\}$ ''   shows '' $ x\in A \longleftrightarrow  r\{x\} \in  B$+++[proof ]>
 ''assume '' $ x\in A$
 ''with '' A5  ''show''  $ r\{x\} \in  B$ 
 ''next '' 
 ''assume '' $ r\{x\} \in  B$
 ''with '' A5  ''obtain '' $ y$ ''where '' $ y \in  A$ ''and '' $ r\{x\} = r\{y\}$ 
 ''with '' A1, A3  ''have''  $ \langle x,y\rangle  \in  r$ ''using''  <nowiki>eq_equiv_class</nowiki>
 ''with '' A1, A2, A3, A4, $ y \in  A$  ''show''  $ x\in A$ ''using''  +++^[EquivClass_3_L4 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_3_L4</nowiki>:  ''assumes '' $ equiv(X,r)$  ''and'' $ IsSaturated(r,A)$  ''and'' $ A\subseteq X$  ''and'' $ \langle x,y\rangle  \in  r$  ''and'' $ x\in X$,   $ y\in A$  '' shows '' $ x\in A$ === 
 ''qed'' === 

A technical lemma involving a projection of a saturated set and a logical epression with exclusive or. Note that we don't really care what //Xor// is here, this is true for any predicate.

 ''lemma''  <nowiki>EquivClass_3_L7</nowiki>:
 ''   assumes '' $ equiv(X,r)$ ''and '' $ IsSaturated(r,A)$ ''and '' $ A\subseteq X$ ''and '' $ x\in X$,  $ y\in X$ ''and '' $ B = \{r\{x\}.\  x\in A\}$ ''and '' $ (x\in A) Xor (y\in A)$ ''   shows '' $ (r\{x\} \in  B)  Xor (r\{y\} \in  B)$ ''using''  <nowiki>assms</nowiki> ,  +++^[EquivClass_3_L6 | EquivClass1 ]...  ''lemma''  <nowiki>EquivClass_3_L6</nowiki>:  ''assumes '' $ equiv(X,r)$  ''and'' $ IsSaturated(r,A)$  ''and'' $ A\subseteq X$  ''and'' $ x\in X$  ''and'' $ B = \{r\{x\}.\  x\in A\}$  '' shows '' $ x\in A \longleftrightarrow  r\{x\} \in  B$ === 

 ''end

'' +++![Comments on EquivClass1|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/EquivClass1"></iframe> </div> </html>
=== 
 ''theory'' Finite_ZF ''imports'' [[Nat_ZF_IML]] [[Cardinal]]

 ''begin
'' 
Standard Isabelle Finite.thy contains a very useful notion of finite powerset: the set of finite subsets of a given set. The definition, however, is specific to Isabelle and based on the notion of "datatype", obviously not something that belongs to ZF set theory. This theory file devolopes the notion of finite powerset similarly as in Finite.thy, but based on standard library's Cardinal.thy. This theory file is intended to replace IsarMathLib's //Finite1// and //Finite_ZF_1// theories that are currently derived from the "datatype" approach.

!Definition and basic properties of finite powerset

The goal of this section is to prove an induction theorem about finite powersets: if the empty set has some property and this property is preserved by adding a single element of a set, then this property is true for all finite subsets of this set.

We defined the finite powerset $ FinPow(X)$ as those elements of the powerset that are finite.

 ''Definition
'' $ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$

The cardinality of an element of finite powerset is a natural number.

 ''lemma''  <nowiki>card_fin_is_nat</nowiki>:
 ''   assumes '' $ A \in  FinPow(X)$ ''   shows '' $ |A| \in  nat$ ''and '' $ A \approx  |A|$ ''using''  <nowiki>assms</nowiki> ,  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$===  ,  <nowiki>Finite_def</nowiki> ,  <nowiki>cardinal_cong</nowiki> ,  <nowiki>nat_into_Card</nowiki> ,  <nowiki>Card_cardinal_eq</nowiki>

We can decompose the finite powerset into collection of sets of the same natural cardinalities.

 ''lemma''  <nowiki>finpow_decomp</nowiki>:
 ''   shows '' $ FinPow(X) = (\bigcup n \in  nat.\  \{A \in  Pow(X).\  A \approx  n\})$ ''using''  <nowiki>Finite_def</nowiki> ,  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 

Finite powerset is the union of sets of cardinality bounded by natural numbers.

 ''lemma''  <nowiki>finpow_union_card_nat</nowiki>:
 ''   shows '' $ FinPow(X) = (\bigcup n \in  nat.\  \{A \in  Pow(X).\  A \preceq  n\})$+++[proof ]>
 ''have''  $ FinPow(X) \subseteq  (\bigcup n \in  nat.\  \{A \in  Pow(X).\  A \preceq  n\})$ ''using''  +++^[finpow_decomp | Finite_ZF ]...  ''lemma''  <nowiki>finpow_decomp</nowiki>:  '' shows '' $ FinPow(X) = (\bigcup n \in  nat.\  \{A \in  Pow(X).\  A \approx  n\})$ ===  ,  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$===  ,  <nowiki>eqpoll_imp_lepoll</nowiki>
 ''moreover''   ''have''  $ (\bigcup n \in  nat.\  \{A \in  Pow(X).\  A \preceq  n\}) \subseteq  FinPow(X)$ ''using''  <nowiki>lepoll_nat_imp_Finite</nowiki> ,  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

A different form of //finpow_union_card_nat// (see above) - a subset that has not more elements than a given natural number is in the finite powerset.

 ''lemma''  <nowiki>lepoll_nat_in_finpow</nowiki>:
 ''   assumes '' $ n \in  nat$,  $ A \subseteq  X$,  $ A \preceq  n$ ''   shows '' $ A \in  FinPow(X)$ ''using''  <nowiki>assms</nowiki> ,  +++^[finpow_union_card_nat | Finite_ZF ]...  ''lemma''  <nowiki>finpow_union_card_nat</nowiki>:  '' shows '' $ FinPow(X) = (\bigcup n \in  nat.\  \{A \in  Pow(X).\  A \preceq  n\})$ === 

If we remove an element and put it back we get the set back.

 ''lemma''  <nowiki>rem_add_eq</nowiki>:
 ''   assumes '' $ a\in A$ ''   shows '' $ (A-\{a\}) \cup  \{a\} = A$ ''using''  <nowiki>assms</nowiki>

Induction for finite powerset. This is smilar to the standard Isabelle's //Fin_induct//.

 ''theorem''  <nowiki>FinPow_induct</nowiki>:
 ''   assumes '' A1: $ P(0)$ ''and '' A2: $ \forall A \in  FinPow(X).\  P(A) \longrightarrow  (\forall a\in X.\  P(A \cup  \{a\}))$ ''and '' A3: $ B \in  FinPow(X)$ ''   shows '' $ P(B)$+++[proof ]>

 ''{ ''  ''fix '' $ n$
 ''assume '' $ n \in  nat$
 ''moreover''   ''from '' A1  ''have''  I: $ \forall B\in Pow(X).\  B \preceq  0 \longrightarrow  P(B)$ ''using''  <nowiki>lepoll_0_is_0</nowiki>
 ''moreover''   ''have''  $ \forall  k \in  nat.\  $
$      (\forall B \in  Pow(X).\  (B \preceq  k \longrightarrow  P(B))) \longrightarrow  $
$      (\forall B \in  Pow(X).\  (B \preceq  succ(k) \longrightarrow  P(B)))$+++[proof ]>
 ''{ ''  ''fix '' $ k$
 ''assume '' A4: $ k \in  nat$
 ''assume '' A5: $ \forall  B \in  Pow(X).\  (B \preceq  k \longrightarrow  P(B))$
 ''fix '' $ B$
 ''assume '' A6: $ B \in  Pow(X)$,  $ B \preceq  succ(k)$
 ''have''  $ P(B)$+++[proof ]>
 ''have''  $ B = 0 \longrightarrow  P(B)$+++[proof ]>
 ''{ ''  ''assume '' $ B = 0$
 ''then ''  ''have''  $ B \preceq  0$ ''using''  <nowiki>lepoll_0_iff</nowiki>
 ''with '' I, A6  ''have''  $ P(B)$ 
 '' }'' 
 ''thus''  $ B = 0 \longrightarrow  P(B)$
 ''qed'' === 
 ''moreover''   ''have''  $ B\neq 0 \longrightarrow  P(B)$+++[proof ]>
 ''{ ''  ''assume '' $ B \neq  0$
 ''then ''  ''obtain '' $ a$ ''where '' II: $ a\in B$ 
 ''let '' $ A = B - \{a\}$
 ''from '' A6, II  ''have''  $ A \subseteq  X$ ''and '' $ A \preceq  k$ ''using''  <nowiki>Diff_sing_lepoll</nowiki>
 ''with '' A4, A5  ''have''  $ A \in  FinPow(X)$ ''and '' $ P(A)$ ''using''  +++^[lepoll_nat_in_finpow | Finite_ZF ]...  ''lemma''  <nowiki>lepoll_nat_in_finpow</nowiki>:  ''assumes '' $ n \in  nat$,   $ A \subseteq  X$,   $ A \preceq  n$  '' shows '' $ A \in  FinPow(X)$ ===  ,  +++^[finpow_decomp | Finite_ZF ]...  ''lemma''  <nowiki>finpow_decomp</nowiki>:  '' shows '' $ FinPow(X) = (\bigcup n \in  nat.\  \{A \in  Pow(X).\  A \approx  n\})$ === 
 ''with '' A2, A6, II  ''have''  $  P(A \cup  \{a\})$ 
 ''moreover''   ''from '' II  ''have''  $ A \cup  \{a\} = B$ 
 ''ultimately ''  ''have''  $ P(B)$ 
 '' }'' 
 ''thus''  $ B\neq 0 \longrightarrow  P(B)$
 ''qed'' === 
 ''ultimately ''  ''show''  $ P(B)$ 
 ''qed'' === 
 '' }'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''ultimately ''  ''have''  $ \forall B \in  Pow(X).\  (B \preceq  n \longrightarrow  P(B))$ ''   by (rule '' +++^[ind_on_nat | Nat_ZF_IML ]...  ''theorem''  <nowiki>ind_on_nat</nowiki>:  ''assumes '' $ n\in nat$  ''and'' $ P(0)$  ''and'' $ \forall k\in nat.\  P(k)\longrightarrow P(succ(k))$  '' shows '' $ P(n)$ ===  '')'' 
 '' }'' 
 ''then ''  ''have''  $ \forall n \in  nat.\  \forall B \in  Pow(X).\  (B \preceq  n \longrightarrow  P(B))$ 
 ''with '' A3  ''show''  $ P(B)$ ''using''  +++^[finpow_union_card_nat | Finite_ZF ]...  ''lemma''  <nowiki>finpow_union_card_nat</nowiki>:  '' shows '' $ FinPow(X) = (\bigcup n \in  nat.\  \{A \in  Pow(X).\  A \preceq  n\})$ === 
 ''qed'' === 

If a family of sets is closed with respect to taking intersections of two sets then it is closed with respect to taking intersections of any nonempty finite collection.

 ''lemma''  <nowiki>inter_two_inter_fin</nowiki>:
 ''   assumes '' A1: $ \forall V\in T.\  \forall W\in T.\  V \cap  W \in  T$ ''and '' A2: $ N \neq  0$ ''and '' A3: $ N \in  FinPow(T)$ ''   shows '' $ (\bigcap N \in  T)$+++[proof ]>
 ''have''  $ 0 = 0 \vee  (\bigcap 0 \in  T)$ 
 ''moreover''   ''have''  $ \forall M \in  FinPow(T).\  (M = 0 \vee  \bigcap M \in  T) \longrightarrow  $
$    (\forall W \in  T.\  M\cup \{W\} = 0 \vee  \bigcap (M \cup  \{W\}) \in  T)$+++[proof ]>
 ''{ ''  ''fix '' $ M$
 ''assume '' $ M \in  FinPow(T)$
 ''assume '' A4: $ M = 0 \vee  \bigcap M \in  T$
 ''{ ''  ''assume '' $ M = 0$
 ''hence''  $ \forall W \in  T.\  M\cup \{W\} = 0 \vee  \bigcap (M \cup  \{W\}) \in  T$
 '' }'' 
 ''moreover''  
 ''{ ''  ''assume '' $ M \neq  0$
 ''with '' A4  ''have''  $ \bigcap M \in  T$ 
 ''{ ''  ''fix '' $ W$
 ''assume '' $ W \in  T$
 ''from '' $ M \neq  0$  ''have''  $ \bigcap (M \cup  \{W\}) = (\bigcap M) \cap  W$ 
 ''with '' A1, $ \bigcap M \in  T$, $ W \in  T$  ''have''  $ \bigcap (M \cup  \{W\}) \in  T$ 
 '' }'' 
 ''hence''  $ \forall W \in  T.\  M\cup \{W\} = 0 \vee  \bigcap (M \cup  \{W\}) \in  T$
 '' }'' 
 ''ultimately ''  ''have''  $ \forall W \in  T.\  M\cup \{W\} = 0 \vee  \bigcap (M \cup  \{W\}) \in  T$ 
 '' }'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''note '' $ N \in  FinPow(T)$
 ''ultimately ''  ''have''  $ N = 0 \vee  (\bigcap N \in  T)$ ''   by (rule '' +++^[FinPow_induct | Finite_ZF ]...  ''theorem''  <nowiki>FinPow_induct</nowiki>:  ''assumes '' $ P(0)$  ''and'' $ \forall A \in  FinPow(X).\  P(A) \longrightarrow  (\forall a\in X.\  P(A \cup  \{a\}))$  ''and'' $ B \in  FinPow(X)$  '' shows '' $ P(B)$ ===  '')'' 
 ''with '' A2  ''show''  $ (\bigcap N \in  T)$ 
 ''qed'' === 

If a family of sets contains the empty set and is closed with respect to taking unions of two sets then it is closed with respect to taking unions of any finite collection.

 ''lemma''  <nowiki>union_two_union_fin</nowiki>:
 ''   assumes '' A1: $ 0 \in  C$ ''and '' A2: $ \forall A\in C.\  \forall B\in C.\  A\cup B \in  C$ ''and '' A3: $ N \in  FinPow(C)$ ''   shows '' $ \bigcup N \in  C$+++[proof ]>
 ''from '' $ 0 \in  C$  ''have''  $ \bigcup 0 \in  C$ 
 ''moreover''   ''have''  $ \forall M \in  FinPow(C).\  \bigcup M \in  C \longrightarrow  (\forall A\in C.\  \bigcup (M \cup  \{A\}) \in  C)$+++[proof ]>
 ''{ ''  ''fix '' $ M$
 ''assume '' $ M \in  FinPow(C)$
 ''assume '' $ \bigcup M \in  C$
 ''fix '' $ A$
 ''assume '' $ A\in C$
 ''have''  $ \bigcup (M \cup  \{A\}) = (\bigcup M) \cup  A$ 
 ''with '' A2, $ \bigcup M \in  C$, $ A\in C$  ''have''  $ \bigcup (M \cup  \{A\}) \in  C$ 
 '' }'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''note '' $ N \in  FinPow(C)$
 ''ultimately ''  ''show''  $ \bigcup N \in  C$ ''   by (rule '' +++^[FinPow_induct | Finite_ZF ]...  ''theorem''  <nowiki>FinPow_induct</nowiki>:  ''assumes '' $ P(0)$  ''and'' $ \forall A \in  FinPow(X).\  P(A) \longrightarrow  (\forall a\in X.\  P(A \cup  \{a\}))$  ''and'' $ B \in  FinPow(X)$  '' shows '' $ P(B)$ ===  '')'' 
 ''qed'' === 

Empty set is in finite power set.

 ''lemma''  <nowiki>empty_in_finpow</nowiki>:
 ''   shows '' $ 0 \in  FinPow(X)$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 

Singleton is in the finite powerset.

 ''lemma''  <nowiki>singleton_in_finpow</nowiki>:
 ''   assumes '' $ x \in  X$ ''   shows '' $ \{x\} \in  FinPow(X)$ ''using''  <nowiki>assms</nowiki> ,  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 

Union of two finite subsets is a finite subset.

 ''lemma''  <nowiki>union_finpow</nowiki>:
 ''   assumes '' $ A \in  FinPow(X)$ ''and '' $ B \in  FinPow(X)$ ''   shows '' $ A \cup  B \in  FinPow(X)$ ''using''  <nowiki>assms</nowiki> ,  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 

An image of a finite set is finite.

 ''lemma''  <nowiki>fin_image_fin</nowiki>:
 ''   assumes '' $ \forall V\in B.\  K(V)\in C$ ''and '' $ N \in  FinPow(B)$ ''   shows '' $ \{K(V).\  V\in N\} \in  FinPow(C)$+++[proof ]>
 ''have''  $ \{K(V).\  V\in 0\} \in  FinPow(C)$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 
 ''moreover''   ''have''  $ \forall A \in  FinPow(B).\  $
$    \{K(V).\  V\in A\} \in  FinPow(C) \longrightarrow  (\forall a\in B.\  \{K(V).\  V \in  (A \cup  \{a\})\} \in  FinPow(C))$+++[proof ]>
 ''{ ''  ''fix '' $ A$
 ''assume '' $ A \in  FinPow(B)$
 ''assume '' $ \{K(V).\  V\in A\} \in  FinPow(C)$
 ''fix '' $ a$
 ''assume '' $ a\in B$
 ''have''  $ \{K(V).\  V \in  (A \cup  \{a\})\} \in  FinPow(C)$+++[proof ]>
 ''have''  $ \{K(V).\  V \in  (A \cup  \{a\})\} = \{K(V).\  V\in A\} \cup  \{K(a)\}$ 
 ''moreover''   ''note '' $ \{K(V).\  V\in A\} \in  FinPow(C)$
 ''moreover''   ''from '' $ \forall V\in B.\  K(V)\in C$, $ a\in B$  ''have''  $ \{K(a)\} \in   FinPow(C)$ ''using''  +++^[singleton_in_finpow | Finite_ZF ]...  ''lemma''  <nowiki>singleton_in_finpow</nowiki>:  ''assumes '' $ x \in  X$  '' shows '' $ \{x\} \in  FinPow(X)$ === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  +++^[union_finpow | Finite_ZF ]...  ''lemma''  <nowiki>union_finpow</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  ''and'' $ B \in  FinPow(X)$  '' shows '' $ A \cup  B \in  FinPow(X)$ === 
 ''qed'' === 
 '' }'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''note '' $ N \in  FinPow(B)$
 ''ultimately ''  ''show''  $ \{K(V).\  V\in N\} \in  FinPow(C)$ ''   by (rule '' +++^[FinPow_induct | Finite_ZF ]...  ''theorem''  <nowiki>FinPow_induct</nowiki>:  ''assumes '' $ P(0)$  ''and'' $ \forall A \in  FinPow(X).\  P(A) \longrightarrow  (\forall a\in X.\  P(A \cup  \{a\}))$  ''and'' $ B \in  FinPow(X)$  '' shows '' $ P(B)$ ===  '')'' 
 ''qed'' === 

 ''end

'' +++![Comments on Finite_ZF|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Finite_ZF"></iframe> </div> </html>
=== 
Click on the items to the left to browse the IsarMathLib theories. Be patient, your browser may take a couple of seconds to render them.  If you want to edit a local copy of this Wiki you may want to enter your username for signing the edits: <<option txtUserName>>. 
 ''theory'' Group_ZF ''imports'' [[Monoid_ZF]]

 ''begin
'' 
This theory file covers basics of group theory.

!Definition and basic properties of groups

In this section we define the notion of a group and set up the notation for discussing groups. We prove some basic theorems about groups.

To define a group we take a monoid and add a requirement that the right inverse needs to exist for every element of the group.

 ''Definition
'' $ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$

We define the group inverse as the set $\{\langle x,y \rangle \in G\times G: x\cdot y = e \}$, where $e$ is the neutral element of the group. This set (which can be written as $(\cdot)^{-1}\{ e\}$) is a certain relation on the group (carrier). Since, as we show later, for every $x\in G$ there is exactly one $y\in G$ such that $x \cdot y = e$ this relation is in fact a function from $G$ to $G$.

 ''Definition
'' $ GroupInv(G,f) \equiv  \{\langle x,y\rangle  \in  G\times G.\  f\langle x,y\rangle  = TheNeutralElement(G,f)\}$

We will use the miltiplicative notation for groups. The neutral element is denoted $1$.

 ''Locale '' group0
 ''fixes '' $ G$
 ''fixes '' $ P$
 ''assumes '' groupAssum: $ \text{IsAgroup}(G,P)$
 ''fixes '' $ neut$
 ''defines '' $ 1  \equiv  TheNeutralElement(G,P)$
 ''fixes '' $ groper$
 ''defines '' $ a \cdot  b \equiv  P\langle a,b\rangle $
 ''fixes '' $ inv$
 ''defines '' $ x^{-1} \equiv  GroupInv(G,P)(x)$


First we show a lemma that says that we can use theorems proven in the //monoid0// context (locale).

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L1</nowiki>:
 ''   shows '' $ monoid0(G,P)$ ''using''  <nowiki>groupAssum</nowiki> ,  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$===  ,  <nowiki>monoid0_def</nowiki>

In some strange cases Isabelle has difficulties with applying the definition of a group. The next lemma defines a rule to be applied in such cases.

 ''lemma''  <nowiki>definition_of_group</nowiki>:
 ''   assumes '' $ \text{IsAmonoid}(G,f)$ ''and '' $ \forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)$ ''   shows '' $ \text{IsAgroup}(G,f)$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$=== 

A technical lemma that allows to use $1$ as the neutral element of the group without referencing a list of lemmas and definitions.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:
 ''   shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ ''using''  +++^[group0_2_L1 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L1</nowiki>:  '' shows '' $ monoid0(G,P)$ ===  ,  +++^[unit_is_neutral | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>unit_is_neutral</nowiki>:  ''assumes '' $ e = TheNeutralElement(G,f)$  '' shows '' $ e \in  G \wedge  (\forall g\in G.\  e \oplus  g = g \wedge  g \oplus  e = g)$ === 

The group is closed under the group operation. Used all the time, useful to have handy.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group_op_closed</nowiki>:
 ''   assumes '' $ a\in G$,  $ b\in G$ ''   shows '' $ a\cdot b \in  G$ ''using''  <nowiki>assms</nowiki> ,  +++^[group0_2_L1 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L1</nowiki>:  '' shows '' $ monoid0(G,P)$ ===  ,  +++^[group0_1_L1 | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L1</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\oplus b \in  G$ === 

The group operation is associative. This is another technical lemma that allows to shorten the list of referenced lemmas in some proofs.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:
 ''   assumes '' $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ ''using''  <nowiki>groupAssum</nowiki> ,  <nowiki>assms</nowiki> ,  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$===  ,  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$===  ,  +++^[group_op_closed | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_op_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ === 

The group operation maps $G\times G$ into $G$. It is conveniet to have this fact easily accessible in the //group0// context.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assocA</nowiki>:
 ''   shows '' $ P : G\times G\rightarrow G$ ''using''  <nowiki>groupAssum</nowiki> ,  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$===  ,  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 

The definition of a group requires the existence of the right inverse. We show that this is also the left inverse.

 ''theorem''   ''(in '' group0 '') '' <nowiki>group0_2_T1</nowiki>:
 ''   assumes '' A1: $ g\in G$ ''and '' A2: $ b\in G$ ''and '' A3: $ g\cdot b = 1 $ ''   shows '' $ b\cdot g = 1 $+++[proof ]>
 ''from '' A2, groupAssum  ''obtain '' $ c$ ''where '' I: $ c \in  G \wedge  b\cdot c = 1 $ ''using''  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$=== 
 ''then ''  ''have''  $ c\in G$ 
 ''have''  $ 1 \in G$ ''using''  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''with '' A1, A2, I  ''have''  $ b\cdot g =  b\cdot (g\cdot (b\cdot c))$ ''using''  +++^[group_op_closed | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_op_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''also''   ''from '' A1, A2, $ c\in G$  ''have''  $ b\cdot (g\cdot (b\cdot c)) = b\cdot (g\cdot b\cdot c)$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''also''   ''from '' A3, A2, I  ''have''  $ b\cdot (g\cdot b\cdot c)= 1 $ ''using''  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''finally ''  ''show''  $ b\cdot g = 1 $ 
 ''qed'' === 

For every element of a group there is only one inverse.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L4</nowiki>:
 ''   assumes '' A1: $ x\in G$ ''   shows '' $ \exists !y.\  y\in G \wedge  x\cdot y = 1 $+++[proof ]>
 ''from '' A1, groupAssum  ''show''  $ \exists y.\  y\in G \wedge   x\cdot y = 1 $ ''using''  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$=== 
 ''fix '' $ y$ $ n$
 ''assume '' A2: $ y\in G \wedge   x\cdot y = 1 $ ''and '' A3: $ n\in G \wedge  x\cdot n = 1 $
 ''show''  $ y=n$+++[proof ]>
 ''from '' A1, A2  ''have''  T1: $ y\cdot x = 1 $ ''using''  +++^[group0_2_T1 | Group_ZF ]...  ''theorem''   ''(in '' group0 '') '' <nowiki>group0_2_T1</nowiki>:  ''assumes '' $ g\in G$  ''and'' $ b\in G$  ''and'' $ g\cdot b = 1 $  '' shows '' $ b\cdot g = 1 $ === 
 ''from '' A2, A3  ''have''  $ y = y\cdot (x\cdot n)$ ''using''  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''also''   ''from '' A1, A2, A3  ''have''  $ \ldots  = (y\cdot x)\cdot n$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''also''   ''from '' T1, A3  ''have''  $ \ldots  = n$ ''using''  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''finally ''  ''show''  $ y=n$ 
 ''qed'' === 
 ''qed'' === 

The group inverse is a function that maps G into G.

 ''theorem''  <nowiki>group0_2_T2</nowiki>:
 ''   assumes '' A1: $ \text{IsAgroup}(G,f)$ ''   shows '' $ GroupInv(G,f) : G\rightarrow G$+++[proof ]>
 ''have''  $ GroupInv(G,f) \subseteq  G\times G$ ''using''  +++^[GroupInv_def | Group_ZF ]... Definition of <nowiki>GroupInv</nowiki>:
$ GroupInv(G,f) \equiv  \{\langle x,y\rangle  \in  G\times G.\  f\langle x,y\rangle  = TheNeutralElement(G,f)\}$=== 
 ''moreover''   ''from '' A1  ''have''  $ \forall x\in G.\  \exists !y.\  y\in G \wedge  \langle x,y\rangle  \in  GroupInv(G,f)$ ''using''  <nowiki>group0_def</nowiki> ,  +++^[group0_2_L4 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L4</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ \exists !y.\  y\in G \wedge  x\cdot y = 1 $ ===  ,  +++^[GroupInv_def | Group_ZF ]... Definition of <nowiki>GroupInv</nowiki>:
$ GroupInv(G,f) \equiv  \{\langle x,y\rangle  \in  G\times G.\  f\langle x,y\rangle  = TheNeutralElement(G,f)\}$=== 
 ''ultimately ''  ''show''  $ thesis$ ''using''  <nowiki>func1_1_L11</nowiki>
 ''qed'' === 

We can think about the group inverse (the function) as the inverse image of the neutral element. Recall that in Isabelle $ f^{-1}(A)$ denotes the inverse image of the set $A$.

 ''theorem''   ''(in '' group0 '') '' <nowiki>group0_2_T3</nowiki>:
 ''   shows '' $ P^{-1}\{1 \} = GroupInv(G,P)$+++[proof ]>
 ''from '' groupAssum  ''have''  $ P : G\times G \rightarrow  G$ ''using''  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$===  ,  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''then ''  ''show''  $ P^{-1}\{1 \} = GroupInv(G,P)$ ''using''  <nowiki>func1_1_L14</nowiki> ,  +++^[GroupInv_def | Group_ZF ]... Definition of <nowiki>GroupInv</nowiki>:
$ GroupInv(G,f) \equiv  \{\langle x,y\rangle  \in  G\times G.\  f\langle x,y\rangle  = TheNeutralElement(G,f)\}$=== 
 ''qed'' === 

The inverse is in the group.

 ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:
 ''   assumes '' A1: $ x\in G$ ''   shows '' $ x^{-1}\in G$+++[proof ]>
 ''from '' groupAssum  ''have''  $ GroupInv(G,P) : G\rightarrow G$ ''using''  +++^[group0_2_T2 | Group_ZF ]...  ''theorem''  <nowiki>group0_2_T2</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,f)$  '' shows '' $ GroupInv(G,f) : G\rightarrow G$ === 
 ''with '' A1  ''show''  $ thesis$ ''using''  <nowiki>apply_type</nowiki>
 ''qed'' === 

The notation for the inverse means what it is supposed to mean.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:
 ''   assumes '' A1: $ x\in G$ ''   shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $+++[proof ]>
 ''from '' groupAssum  ''have''  $ GroupInv(G,P) : G\rightarrow G$ ''using''  +++^[group0_2_T2 | Group_ZF ]...  ''theorem''  <nowiki>group0_2_T2</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,f)$  '' shows '' $ GroupInv(G,f) : G\rightarrow G$ === 
 ''with '' A1  ''have''  $ \langle x,x^{-1}\rangle  \in   GroupInv(G,P)$ ''using''  <nowiki>apply_Pair</nowiki>
 ''then ''  ''show''  $ x\cdot x^{-1} = 1 $ ''using''  +++^[GroupInv_def | Group_ZF ]... Definition of <nowiki>GroupInv</nowiki>:
$ GroupInv(G,f) \equiv  \{\langle x,y\rangle  \in  G\times G.\  f\langle x,y\rangle  = TheNeutralElement(G,f)\}$=== 
 ''with '' A1  ''show''  $ x^{-1}\cdot x = 1 $ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group0_2_T1 | Group_ZF ]...  ''theorem''   ''(in '' group0 '') '' <nowiki>group0_2_T1</nowiki>:  ''assumes '' $ g\in G$  ''and'' $ b\in G$  ''and'' $ g\cdot b = 1 $  '' shows '' $ b\cdot g = 1 $ === 
 ''qed'' === 

The next two lemmas state that unless we multiply by the neutral element, the result is always different than any of the operands.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L7</nowiki>:
 ''   assumes '' A1: $ a\in G$ ''and '' A2: $ b\in G$ ''and '' A3: $ a\cdot b = a$ ''   shows '' $ b=1 $+++[proof ]>
 ''from '' A3  ''have''  $ a^{-1} \cdot  (a\cdot b) = a^{-1}\cdot a$ 
 ''with '' A1, A2  ''show''  $ thesis$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ ===  ,  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''qed'' === 

See the comment to //group0_2_L7//.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L8</nowiki>:
 ''   assumes '' A1: $ a\in G$ ''and '' A2: $ b\in G$ ''and '' A3: $ a\cdot b = b$ ''   shows '' $ a=1 $+++[proof ]>
 ''from '' A3  ''have''  $ (a\cdot b)\cdot b^{-1}  = b\cdot b^{-1}$ 
 ''with '' A1, A2  ''have''  $ a\cdot (b\cdot b^{-1})  = b\cdot b^{-1}$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''with '' A1, A2  ''show''  $ thesis$ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''qed'' === 

The inverse of the neutral element is the neutral element.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_one</nowiki>:
 ''   shows '' $ 1 ^{-1} = 1 $ ''using''  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ ===  ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L7 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L7</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  ''and'' $ a\cdot b = a$  '' shows '' $ b=1 $ === 

if $a^{-1} = 1$, then $a=1$.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L8A</nowiki>:
 ''   assumes '' A1: $ a\in G$ ''and '' A2: $ a^{-1} = 1 $ ''   shows '' $ a = 1 $+++[proof ]>
 ''from '' A1  ''have''  $ a\cdot a^{-1} = 1 $ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ === 
 ''with '' A1, A2  ''show''  $ a = 1 $ ''using''  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''qed'' === 

If $a$ is not a unit, then its inverse is not a unit either.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L8B</nowiki>:
 ''   assumes '' $ a\in G$ ''and '' $ a \neq  1 $ ''   shows '' $ a^{-1} \neq  1 $ ''using''  <nowiki>assms</nowiki> ,  +++^[group0_2_L8A | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L8A</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ a^{-1} = 1 $  '' shows '' $ a = 1 $ === 

If $a^{-1}$ is not a unit, then a is not a unit either.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L8C</nowiki>:
 ''   assumes '' $ a\in G$ ''and '' $ a^{-1} \neq  1 $ ''   shows '' $ a\neq 1 $ ''using''  <nowiki>assms</nowiki> ,  +++^[group0_2_L8A | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L8A</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ a^{-1} = 1 $  '' shows '' $ a = 1 $ ===  ,  +++^[group_inv_of_one | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_one</nowiki>:  '' shows '' $ 1 ^{-1} = 1 $ === 

If a product of two elements of a group is equal to the neutral element then they are inverses of each other.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L9</nowiki>:
 ''   assumes '' A1: $ a\in G$ ''and '' A2: $ b\in G$ ''and '' A3: $ a\cdot b = 1 $ ''   shows '' $ a = b^{-1}$ ''and '' $ b = a^{-1}$+++[proof ]>
 ''from '' A3  ''have''  $ a\cdot b\cdot b^{-1} = 1 \cdot b^{-1}$ 
 ''with '' A1, A2  ''have''  $ a\cdot (b\cdot b^{-1}) = 1 \cdot b^{-1}$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''with '' A1, A2  ''show''  $ a = b^{-1}$ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''from '' A3  ''have''  $ a^{-1}\cdot (a\cdot b) = a^{-1}\cdot 1 $ 
 ''with '' A1, A2  ''show''  $ b = a^{-1}$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ ===  ,  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''qed'' === 

It happens quite often that we know what is (have a meta-function for) the right inverse in a group. The next lemma shows that the value of the group inverse (function) is equal to the right inverse (meta-function).

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L9A</nowiki>:
 ''   assumes '' A1: $ \forall g\in G.\  b(g) \in  G \wedge  g\cdot b(g) = 1 $ ''   shows '' $ \forall g\in G.\  b(g) = g^{-1}$+++[proof ]>
 ''fix '' $ g$
 ''assume '' $ g\in G$
 ''moreover''   ''from '' A1, $ g\in G$  ''have''  $ b(g) \in  G$ 
 ''moreover''   ''from '' A1, $ g\in G$  ''have''  $ g\cdot b(g) = 1 $ 
 ''ultimately ''  ''show''  $ b(g) = g^{-1}$ ''   by (rule '' +++^[group0_2_L9 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L9</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  ''and'' $ a\cdot b = 1 $  '' shows '' $ a = b^{-1}$  ''and'' $ b = a^{-1}$ ===  '')'' 
 ''qed'' === 

What is the inverse of a product?

 ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_two</nowiki>:
 ''   assumes '' A1: $ a\in G$ ''and '' A2: $ b\in G$ ''   shows '' $  b^{-1}\cdot a^{-1} = (a\cdot b)^{-1}$+++[proof ]>
 ''from '' A1, A2  ''have''  $ b^{-1}\in G$,  $ a^{-1}\in G$,  $ a\cdot b\in G$,  $ b^{-1}\cdot a^{-1} \in  G$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_op_closed | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_op_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ === 
 ''from '' A1, A2, $ b^{-1}\cdot a^{-1} \in  G$  ''have''  $ a\cdot b\cdot (b^{-1}\cdot a^{-1}) = a\cdot (b\cdot (b^{-1}\cdot a^{-1}))$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''moreover''   ''from '' A2, $ b^{-1}\in G$, $ a^{-1}\in G$  ''have''  $ b\cdot (b^{-1}\cdot a^{-1}) = b\cdot b^{-1}\cdot a^{-1}$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''moreover''   ''from '' A2, $ a^{-1}\in G$  ''have''  $ b\cdot b^{-1}\cdot a^{-1} = a^{-1}$ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''ultimately ''  ''have''  $ a\cdot b\cdot (b^{-1}\cdot a^{-1}) = a\cdot a^{-1}$ 
 ''with '' A1  ''have''  $ a\cdot b\cdot (b^{-1}\cdot a^{-1}) = 1 $ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ === 
 ''with '' $ a\cdot b \in  G$, $ b^{-1}\cdot a^{-1} \in  G$  ''show''  $ b^{-1}\cdot a^{-1} = (a\cdot b)^{-1}$ ''using''  +++^[group0_2_L9 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L9</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  ''and'' $ a\cdot b = 1 $  '' shows '' $ a = b^{-1}$  ''and'' $ b = a^{-1}$ === 
 ''qed'' === 

What is the inverse of a product of three elements?

 ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_three</nowiki>:
 ''   assumes '' A1: $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ (a\cdot b\cdot c)^{-1} = c^{-1}\cdot (a\cdot b)^{-1}$,  $ (a\cdot b\cdot c)^{-1} = c^{-1}\cdot (b^{-1}\cdot a^{-1})$,  $ (a\cdot b\cdot c)^{-1} = c^{-1}\cdot b^{-1}\cdot a^{-1}$+++[proof ]>
 ''from '' A1  ''have''  T: $ a\cdot b \in  G$,  $ a^{-1} \in  G$,  $ b^{-1} \in  G$,  $ c^{-1} \in  G$ ''using''  +++^[group_op_closed | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_op_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ ===  ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ === 
 ''with '' A1  ''show''  $ (a\cdot b\cdot c)^{-1} = c^{-1}\cdot (a\cdot b)^{-1}$ ''and '' $ (a\cdot b\cdot c)^{-1} = c^{-1}\cdot (b^{-1}\cdot a^{-1})$ ''using''  +++^[group_inv_of_two | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_two</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  '' shows '' $  b^{-1}\cdot a^{-1} = (a\cdot b)^{-1}$ === 
 ''with '' T  ''show''  $ (a\cdot b\cdot c)^{-1} = c^{-1}\cdot b^{-1}\cdot a^{-1}$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''qed'' === 

The inverse of the inverse is the element.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_inv</nowiki>:
 ''   assumes '' $ a\in G$ ''   shows '' $ a = (a^{-1})^{-1}$ ''using''  <nowiki>assms</nowiki> ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L9 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L9</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  ''and'' $ a\cdot b = 1 $  '' shows '' $ a = b^{-1}$  ''and'' $ b = a^{-1}$ === 

If $a^{-1}\cdot b=1$, then $a=b$.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L11</nowiki>:
 ''   assumes '' A1: $ a\in G$,  $ b\in G$ ''and '' A2: $ a^{-1}\cdot b = 1 $ ''   shows '' $ a=b$+++[proof ]>
 ''from '' A1, A2  ''have''  $ a^{-1} \in  G$,  $ b\in G$,  $ a^{-1}\cdot b = 1 $ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ === 
 ''then ''  ''have''  $ b = (a^{-1})^{-1}$ ''   by (rule '' +++^[group0_2_L9 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L9</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  ''and'' $ a\cdot b = 1 $  '' shows '' $ a = b^{-1}$  ''and'' $ b = a^{-1}$ ===  '')'' 
 ''with '' A1  ''show''  $ a=b$ ''using''  +++^[group_inv_of_inv | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_inv</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ a = (a^{-1})^{-1}$ === 
 ''qed'' === 

If $a\cdot b^{-1}=1$, then $a=b$.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L11A</nowiki>:
 ''   assumes '' A1: $ a\in G$,  $ b\in G$ ''and '' A2: $ a\cdot b^{-1} = 1 $ ''   shows '' $ a=b$+++[proof ]>
 ''from '' A1, A2  ''have''  $ a \in  G$,  $ b^{-1}\in G$,  $ a\cdot b^{-1} = 1 $ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ === 
 ''then ''  ''have''  $ a = (b^{-1})^{-1}$ ''   by (rule '' +++^[group0_2_L9 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L9</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  ''and'' $ a\cdot b = 1 $  '' shows '' $ a = b^{-1}$  ''and'' $ b = a^{-1}$ ===  '')'' 
 ''with '' A1  ''show''  $ a=b$ ''using''  +++^[group_inv_of_inv | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_inv</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ a = (a^{-1})^{-1}$ === 
 ''qed'' === 

If if the inverse of $b$ is different than $a$, then the inverse of $a$ is different than $b$.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L11B</nowiki>:
 ''   assumes '' A1: $ a\in G$ ''and '' A2: $ b^{-1} \neq  a$ ''   shows '' $ a^{-1} \neq  b$+++[proof ]>

 ''{ ''  ''assume '' $ a^{-1} = b$
 ''then ''  ''have''  $ (a^{-1})^{-1} = b^{-1}$ 
 ''with '' A1, A2  ''have''  $ False$ ''using''  +++^[group_inv_of_inv | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_inv</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ a = (a^{-1})^{-1}$ === 
 '' }'' 
 ''then ''  ''show''  $ a^{-1} \neq  b$ 
 ''qed'' === 

What is the inverse of $ab^{-1}$ ?

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L12</nowiki>:
 ''   assumes '' A1: $ a\in G$,  $ b\in G$ ''   shows '' $ (a\cdot b^{-1})^{-1} = b\cdot a^{-1}$,  $ (a^{-1}\cdot b)^{-1} = b^{-1}\cdot a$+++[proof ]>
 ''from '' A1  ''have''  $ (a\cdot b^{-1})^{-1} = (b^{-1})^{-1}\cdot  a^{-1}$ ''and '' $ (a^{-1}\cdot b)^{-1} = b^{-1}\cdot (a^{-1})^{-1}$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_inv_of_two | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_two</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  '' shows '' $  b^{-1}\cdot a^{-1} = (a\cdot b)^{-1}$ === 
 ''with '' A1  ''show''  $ (a\cdot b^{-1})^{-1} = b\cdot a^{-1}$,  $ (a^{-1}\cdot b)^{-1} = b^{-1}\cdot a$ ''using''  +++^[group_inv_of_inv | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_inv</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ a = (a^{-1})^{-1}$ === 
 ''qed'' === 

A couple useful rearrangements with three elements: we can insert a $b\cdot b^{-1}$ between two group elements (another version) and one about a product of an element and inverse of a product, and two others.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L14A</nowiki>:
 ''   assumes '' A1: $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ a\cdot c^{-1}= (a\cdot b^{-1})\cdot (b\cdot c^{-1})$,  $ a^{-1}\cdot c = (a^{-1}\cdot b)\cdot (b^{-1}\cdot c)$,  $ a\cdot (b\cdot c)^{-1} = a\cdot c^{-1}\cdot b^{-1}$,  $ a\cdot (b\cdot c^{-1}) = a\cdot b\cdot c^{-1}$,  $ (a\cdot b^{-1}\cdot c^{-1})^{-1} = c\cdot b\cdot a^{-1}$,  $ a\cdot b\cdot c^{-1}\cdot (c\cdot b^{-1}) = a$,  $ a\cdot (b\cdot c)\cdot c^{-1} = a\cdot b$+++[proof ]>
 ''from '' A1  ''have''  T: $ a^{-1} \in  G$,  $ b^{-1}\in G$,  $ c^{-1}\in G$,  $ a^{-1}\cdot b \in  G$,  $ a\cdot b^{-1} \in  G$,  $ a\cdot b \in  G$,  $ c\cdot b^{-1} \in  G$,  $ b\cdot c \in  G$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_op_closed | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_op_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ === 
 ''from '' A1, T  ''have''  $ a\cdot c^{-1} =  a\cdot (b^{-1}\cdot b)\cdot c^{-1}$,  $ a^{-1}\cdot c =  a^{-1}\cdot (b\cdot b^{-1})\cdot c$ ''using''  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ ===  ,  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ === 
 ''with '' A1, T  ''show''  $ a\cdot c^{-1}= (a\cdot b^{-1})\cdot (b\cdot c^{-1})$,  $ a^{-1}\cdot c = (a^{-1}\cdot b)\cdot (b^{-1}\cdot c)$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''from '' A1  ''have''  $ a\cdot (b\cdot c)^{-1} = a\cdot (c^{-1}\cdot b^{-1})$ ''using''  +++^[group_inv_of_two | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_two</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  '' shows '' $  b^{-1}\cdot a^{-1} = (a\cdot b)^{-1}$ === 
 ''with '' A1, T  ''show''  $ a\cdot (b\cdot c)^{-1} =a\cdot c^{-1}\cdot b^{-1}$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''from '' A1, T  ''show''  $ a\cdot (b\cdot c^{-1}) = a\cdot b\cdot c^{-1}$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''from '' A1, T  ''show''  $ (a\cdot b^{-1}\cdot c^{-1})^{-1} = c\cdot b\cdot a^{-1}$ ''using''  +++^[group_inv_of_three | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_three</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ (a\cdot b\cdot c)^{-1} = c^{-1}\cdot (a\cdot b)^{-1}$,  
$ (a\cdot b\cdot c)^{-1} = c^{-1}\cdot (b^{-1}\cdot a^{-1})$,  
$ (a\cdot b\cdot c)^{-1} = c^{-1}\cdot b^{-1}\cdot a^{-1}$ ===  ,  +++^[group_inv_of_inv | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_inv</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ a = (a^{-1})^{-1}$ === 
 ''from '' T  ''have''  $ a\cdot b\cdot c^{-1}\cdot (c\cdot b^{-1}) = a\cdot b\cdot (c^{-1}\cdot (c\cdot b^{-1}))$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''also''   ''from '' A1, T  ''have''  $ \ldots  =  a\cdot b\cdot b^{-1}$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ ===  ,  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''also''   ''from '' A1, T  ''have''  $ \ldots  = a\cdot (b\cdot b^{-1})$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''also''   ''from '' A1  ''have''  $ \ldots  = a$ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''finally ''  ''show''  $ a\cdot b\cdot c^{-1}\cdot (c\cdot b^{-1}) = a$ 
 ''from '' A1, T  ''have''  $ a\cdot (b\cdot c)\cdot c^{-1} =  a\cdot (b\cdot (c\cdot c^{-1}))$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''also''   ''from '' A1, T  ''have''  $ \ldots  = a\cdot b$ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''finally ''  ''show''  $ a\cdot (b\cdot c)\cdot c^{-1} = a\cdot b$ 
 ''qed'' === 

Another lemma about rearranging a product of four group elements.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L15</nowiki>:
 ''   assumes '' A1: $ a\in G$,  $ b\in G$,  $ c\in G$,  $ d\in G$ ''   shows '' $ (a\cdot b)\cdot (c\cdot d)^{-1} = a\cdot (b\cdot d^{-1})\cdot a^{-1}\cdot (a\cdot c^{-1})$+++[proof ]>
 ''from '' A1  ''have''  T1: $ d^{-1}\in G$,  $ c^{-1}\in G$,  $ a\cdot b\in G$,  $ a\cdot (b\cdot d^{-1})\in G$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_op_closed | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_op_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ === 
 ''with '' A1  ''have''  $ (a\cdot b)\cdot (c\cdot d)^{-1} = (a\cdot b)\cdot (d^{-1}\cdot c^{-1})$ ''using''  +++^[group_inv_of_two | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_two</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  '' shows '' $  b^{-1}\cdot a^{-1} = (a\cdot b)^{-1}$ === 
 ''also''   ''from '' A1, T1  ''have''  $ \ldots  = a\cdot (b\cdot d^{-1})\cdot c^{-1}$ ''using''  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''also''   ''from '' A1, T1  ''have''  $ \ldots  = a\cdot (b\cdot d^{-1})\cdot a^{-1}\cdot (a\cdot c^{-1})$ ''using''  +++^[group0_2_L14A | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L14A</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot c^{-1}= (a\cdot b^{-1})\cdot (b\cdot c^{-1})$,  
$ a^{-1}\cdot c = (a^{-1}\cdot b)\cdot (b^{-1}\cdot c)$,  
$ a\cdot (b\cdot c)^{-1} = a\cdot c^{-1}\cdot b^{-1}$,  
$ a\cdot (b\cdot c^{-1}) = a\cdot b\cdot c^{-1}$,  
$ (a\cdot b^{-1}\cdot c^{-1})^{-1} = c\cdot b\cdot a^{-1}$,  
$ a\cdot b\cdot c^{-1}\cdot (c\cdot b^{-1}) = a$,   $ a\cdot (b\cdot c)\cdot c^{-1} = a\cdot b$ === 
 ''finally ''  ''show''  $ thesis$ 
 ''qed'' === 

We can cancel an element with its inverse that is written next to it.

 ''lemma''   ''(in '' group0 '') '' <nowiki>inv_cancel_two</nowiki>:
 ''   assumes '' A1: $ a\in G$,  $ b\in G$ ''   shows '' $ a\cdot b^{-1}\cdot b = a$,  $ a\cdot b\cdot b^{-1} = a$,  $ a^{-1}\cdot (a\cdot b) = b$,  $ a\cdot (a^{-1}\cdot b) = b$+++[proof ]>
 ''from '' A1  ''have''  $ a\cdot b^{-1}\cdot b = a\cdot (b^{-1}\cdot b)$,  $ a\cdot b\cdot b^{-1} = a\cdot (b\cdot b^{-1})$,  $ a^{-1}\cdot (a\cdot b) = a^{-1}\cdot a\cdot b$,  $ a\cdot (a^{-1}\cdot b) = a\cdot a^{-1}\cdot b$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''with '' A1  ''show''  $ a\cdot b^{-1}\cdot b = a$,  $ a\cdot b\cdot b^{-1} = a$,  $ a^{-1}\cdot (a\cdot b) = b$,  $ a\cdot (a^{-1}\cdot b) = b$ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''qed'' === 

Another lemma about cancelling with two group elements.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L16A</nowiki>:
 ''   assumes '' A1: $ a\in G$,  $ b\in G$ ''   shows '' $ a\cdot (b\cdot a)^{-1} = b^{-1}$+++[proof ]>
 ''from '' A1  ''have''  $ (b\cdot a)^{-1} = a^{-1}\cdot b^{-1}$,  $ b^{-1} \in  G$ ''using''  +++^[group_inv_of_two | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_two</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  '' shows '' $  b^{-1}\cdot a^{-1} = (a\cdot b)^{-1}$ ===  ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ === 
 ''with '' A1  ''show''  $ a\cdot (b\cdot a)^{-1} = b^{-1}$ ''using''  +++^[inv_cancel_two | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inv_cancel_two</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b^{-1}\cdot b = a$,  
$ a\cdot b\cdot b^{-1} = a$,   $ a^{-1}\cdot (a\cdot b) = b$,   $ a\cdot (a^{-1}\cdot b) = b$ === 
 ''qed'' === 

Adding a neutral element to a set that is closed under the group operation results in a set that is closed under the group operation.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L17</nowiki>:
 ''   assumes '' $ H\subseteq G$ ''and '' $ H \text{ is closed under } P$ ''   shows '' $ (H \cup  \{1 \}) \text{ is closed under } P$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 

We can put an element on the other side of an equation.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L18</nowiki>:
 ''   assumes '' A1: $ a\in G$,  $ b\in G$,  $ c\in G$ ''and '' A2: $ c = a\cdot b$ ''   shows '' $ c\cdot b^{-1} = a$,  $ a^{-1}\cdot c = b$+++[proof ]>
 ''from '' A2, A1  ''have''  $ c\cdot b^{-1} =  a\cdot (b\cdot b^{-1})$,  $ a^{-1}\cdot c = (a^{-1}\cdot a)\cdot b$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''moreover''   ''from '' A1  ''have''  $ a\cdot (b\cdot b^{-1}) = a$,  $ (a^{-1}\cdot a)\cdot b = b$ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 
 ''ultimately ''  ''show''  $ c\cdot b^{-1} = a$,  $ a^{-1}\cdot c = b$ 
 ''qed'' === 

Multiplying different group elements by the same factor results in different group elements.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L19</nowiki>:
 ''   assumes '' A1: $ a\in G$,  $ b\in G$,  $ c\in G$ ''and '' A2: $ a\neq b$ ''   shows '' $ a\cdot c \neq  b\cdot c$ ''and '' $ c\cdot a \neq  c\cdot b$+++[proof ]>

 ''{ ''  ''assume '' $ a\cdot c = b\cdot c \vee  c\cdot a =c\cdot b$
 ''then ''  ''have''  $ a\cdot c\cdot c^{-1} = b\cdot c\cdot c^{-1} \vee  c^{-1}\cdot (c\cdot a) = c^{-1}\cdot (c\cdot b)$ 
 ''with '' A1, A2  ''have''  $ False$ ''using''  +++^[inv_cancel_two | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inv_cancel_two</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b^{-1}\cdot b = a$,  
$ a\cdot b\cdot b^{-1} = a$,   $ a^{-1}\cdot (a\cdot b) = b$,   $ a\cdot (a^{-1}\cdot b) = b$ === 
 '' }'' 
 ''then ''  ''show''  $ a\cdot c \neq  b\cdot c$ ''and '' $ c\cdot a \neq  c\cdot b$ 
 ''qed'' === 


!Subgroups

There are two common ways to define subgroups. One requires that the group operation is closed in the subgroup. The second one defines subgroup as a subset of a group which is itself a group under the group operations. We use the second approach because it results in shorter definition.
The rest of this section is devoted to proving the equivalence of these two definitions of the notion of a subgroup.

A pair $(H,P)$ is a subgroup if $H$ forms a group with the operation $P$ restricted to $H\times H$. It may be surprising that we don't require $H$ to be a subset of $G$. This however can be inferred from the definition if the pair $(G,P)$ is a group, see lemma //group0_3_L2//.

 ''Definition
'' $ IsAsubgroup(H,P) \equiv  \text{IsAgroup}(H, restrict(P,H\times H))$

Formally the group operation in a subgroup is different than in the group as they have different domains. Of course we want to use the original operation with the associated notation in the subgroup. The next couple of lemmas will allow for that. The next lemma states that the neutral element of a subgroup is in the subgroup and it is both right and left neutral there. The notation is very ugly because we don't want to introduce a separate notation for the subgroup operation.

 ''lemma''  <nowiki>group0_3_L1</nowiki>:
 ''   assumes '' A1: $ IsAsubgroup(H,f)$ ''and '' A2: $ n = TheNeutralElement(H,restrict(f,H\times H))$ ''   shows '' $ n \in  H$,  $ \forall h\in H.\  restrict(f,H\times H)\langle n,h \rangle  = h$,  $ \forall h\in H.\  restrict(f,H\times H)\langle h,n\rangle  = h$+++[proof ]>
 ''let '' $ b = restrict(f,H\times H)$
 ''let '' $ e = TheNeutralElement(H,restrict(f,H\times H))$
 ''from '' A1  ''have''  $ group0(H,b)$ ''using''  +++^[IsAsubgroup_def | Group_ZF ]... Definition of <nowiki>IsAsubgroup</nowiki>:
$ IsAsubgroup(H,P) \equiv  \text{IsAgroup}(H, restrict(P,H\times H))$===  ,  <nowiki>group0_def</nowiki>
 ''then ''  ''have''  I: $ e \in  H \wedge  (\forall h\in H.\  (b\langle e,h \rangle  = h \wedge  b\langle h,e\rangle  = h))$ ''   by (rule '' +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ ===  '')'' 
 ''with '' A2  ''show''  $ n \in  H$ 
 ''from '' A2, I  ''show''  $ \forall h\in H.\  b\langle n,h\rangle  = h$ ''and '' $ \forall h\in H.\  b\langle h,n\rangle  = h$ 
 ''qed'' === 

A subgroup is contained in the group.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L2</nowiki>:
 ''   assumes '' A1: $ IsAsubgroup(H,P)$ ''   shows '' $ H \subseteq  G$+++[proof ]>
 ''fix '' $ h$
 ''assume '' $ h\in H$
 ''let '' $ b = restrict(P,H\times H)$
 ''let '' $ n = TheNeutralElement(H,restrict(P,H\times H))$
 ''from '' A1  ''have''  $ b \in  H\times H\rightarrow H$ ''using''  +++^[IsAsubgroup_def | Group_ZF ]... Definition of <nowiki>IsAsubgroup</nowiki>:
$ IsAsubgroup(H,P) \equiv  \text{IsAgroup}(H, restrict(P,H\times H))$===  ,  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$===  ,  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''moreover''   ''from '' A1, $ h\in H$  ''have''  $ \langle  n,h\rangle  \in  H\times H$ ''using''  +++^[group0_3_L1 | Group_ZF ]...  ''lemma''  <nowiki>group0_3_L1</nowiki>:  ''assumes '' $ IsAsubgroup(H,f)$  ''and'' $ n = TheNeutralElement(H,restrict(f,H\times H))$  '' shows '' $ n \in  H$,   $ \forall h\in H.\  restrict(f,H\times H)\langle n,h \rangle  = h$,  
$ \forall h\in H.\  restrict(f,H\times H)\langle h,n\rangle  = h$ === 
 ''moreover''   ''from '' A1, $ h\in H$  ''have''  $ h = b\langle n,h \rangle $ ''using''  +++^[group0_3_L1 | Group_ZF ]...  ''lemma''  <nowiki>group0_3_L1</nowiki>:  ''assumes '' $ IsAsubgroup(H,f)$  ''and'' $ n = TheNeutralElement(H,restrict(f,H\times H))$  '' shows '' $ n \in  H$,   $ \forall h\in H.\  restrict(f,H\times H)\langle n,h \rangle  = h$,  
$ \forall h\in H.\  restrict(f,H\times H)\langle h,n\rangle  = h$ === 
 ''ultimately ''  ''have''  $ \langle \langle n,h\rangle ,h\rangle  \in  b$ ''using''  <nowiki>func1_1_L5A</nowiki>
 ''then ''  ''have''  $ \langle \langle n,h\rangle ,h\rangle  \in  P$ ''using''  <nowiki>restrict_subset</nowiki>
 ''moreover''   ''from '' groupAssum  ''have''  $ P:G\times G\rightarrow G$ ''using''  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$===  ,  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''ultimately ''  ''show''  $ h\in G$ ''using''  <nowiki>func1_1_L5</nowiki>
 ''qed'' === 

The group's neutral element (denoted $1$ in the group0 context) is a neutral element for the subgroup with respect to the group action.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L3</nowiki>:
 ''   assumes '' $ IsAsubgroup(H,P)$ ''   shows '' $ \forall h\in H.\  1 \cdot h = h \wedge  h\cdot 1  = h$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>groupAssum</nowiki> ,  +++^[group0_3_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L2</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ H \subseteq  G$ ===  ,  +++^[group0_2_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L2</nowiki>:  '' shows '' $ 1 \in G \wedge  (\forall g\in G.\ (1 \cdot g = g \wedge  g\cdot 1  = g))$ === 

The neutral element of a subgroup is the same as that of the group.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L4</nowiki>:
 ''   assumes '' A1: $ IsAsubgroup(H,P)$ ''   shows '' $ TheNeutralElement(H,restrict(P,H\times H)) = 1 $+++[proof ]>
 ''let '' $ n = TheNeutralElement(H,restrict(P,H\times H))$
 ''from '' A1  ''have''  $ n \in  H$ ''using''  +++^[group0_3_L1 | Group_ZF ]...  ''lemma''  <nowiki>group0_3_L1</nowiki>:  ''assumes '' $ IsAsubgroup(H,f)$  ''and'' $ n = TheNeutralElement(H,restrict(f,H\times H))$  '' shows '' $ n \in  H$,   $ \forall h\in H.\  restrict(f,H\times H)\langle n,h \rangle  = h$,  
$ \forall h\in H.\  restrict(f,H\times H)\langle h,n\rangle  = h$ === 
 ''with '' groupAssum, A1  ''have''  $ n\in G$ ''using''  +++^[group0_3_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L2</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ H \subseteq  G$ === 
 ''with '' A1, $ n \in  H$  ''show''  $ thesis$ ''using''  +++^[group0_3_L1 | Group_ZF ]...  ''lemma''  <nowiki>group0_3_L1</nowiki>:  ''assumes '' $ IsAsubgroup(H,f)$  ''and'' $ n = TheNeutralElement(H,restrict(f,H\times H))$  '' shows '' $ n \in  H$,   $ \forall h\in H.\  restrict(f,H\times H)\langle n,h \rangle  = h$,  
$ \forall h\in H.\  restrict(f,H\times H)\langle h,n\rangle  = h$ ===  ,  <nowiki>restrict_if</nowiki> ,  +++^[group0_2_L7 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L7</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b\in G$  ''and'' $ a\cdot b = a$  '' shows '' $ b=1 $ === 
 ''qed'' === 

The neutral element of the group (denoted $1$ in the group0 context) belongs to every subgroup.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L5</nowiki>:
 ''   assumes '' A1: $ IsAsubgroup(H,P)$ ''   shows '' $ 1 \in H$+++[proof ]>
 ''from '' A1  ''show''  $ 1 \in H$ ''using''  +++^[group0_3_L1 | Group_ZF ]...  ''lemma''  <nowiki>group0_3_L1</nowiki>:  ''assumes '' $ IsAsubgroup(H,f)$  ''and'' $ n = TheNeutralElement(H,restrict(f,H\times H))$  '' shows '' $ n \in  H$,   $ \forall h\in H.\  restrict(f,H\times H)\langle n,h \rangle  = h$,  
$ \forall h\in H.\  restrict(f,H\times H)\langle h,n\rangle  = h$ ===  ,  +++^[group0_3_L4 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L4</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ TheNeutralElement(H,restrict(P,H\times H)) = 1 $ === 
 ''qed'' === 

Subgroups are closed with respect to the group operation.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L6</nowiki>:
 ''   assumes '' A1: $ IsAsubgroup(H,P)$ ''and '' A2: $ a\in H$,  $ b\in H$ ''   shows '' $ a\cdot b \in  H$+++[proof ]>
 ''let '' $ f = restrict(P,H\times H)$
 ''from '' A1  ''have''  $ monoid0(H,f)$ ''using''  +++^[IsAsubgroup_def | Group_ZF ]... Definition of <nowiki>IsAsubgroup</nowiki>:
$ IsAsubgroup(H,P) \equiv  \text{IsAgroup}(H, restrict(P,H\times H))$===  ,  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$===  ,  <nowiki>monoid0_def</nowiki>
 ''with '' A2  ''have''  $ f (\langle a,b\rangle ) \in  H$ ''using''  +++^[group0_1_L1 | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L1</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\oplus b \in  G$ === 
 ''with '' A2  ''show''  $ a\cdot b \in  H$ ''using''  <nowiki>restrict_if</nowiki>
 ''qed'' === 

A preliminary lemma that we need to show that taking the inverse in the subgroup is the same as taking the inverse in the group.

 ''lemma''  <nowiki>group0_3_L7A</nowiki>:
 ''   assumes '' A1: $ \text{IsAgroup}(G,f)$ ''and '' A2: $ IsAsubgroup(H,f)$ ''and '' A3: $ g = restrict(f,H\times H)$ ''   shows '' $ GroupInv(G,f) \cap  H\times H = GroupInv(H,g)$+++[proof ]>
 ''let '' $ e = TheNeutralElement(G,f)$
 ''let '' $ e_1 = TheNeutralElement(H,g)$
 ''from '' A1  ''have''  $ group0(G,f)$ ''using''  <nowiki>group0_def</nowiki>
 ''from '' A2, A3  ''have''  $ group0(H,g)$ ''using''  +++^[IsAsubgroup_def | Group_ZF ]... Definition of <nowiki>IsAsubgroup</nowiki>:
$ IsAsubgroup(H,P) \equiv  \text{IsAgroup}(H, restrict(P,H\times H))$===  ,  <nowiki>group0_def</nowiki>
 ''from '' $ group0(G,f)$, A2, A3  ''have''  $ GroupInv(G,f) = f^{-1}\{e_1\}$ ''using''  +++^[group0_3_L4 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L4</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ TheNeutralElement(H,restrict(P,H\times H)) = 1 $ ===  ,  +++^[group0_2_T3 | Group_ZF ]...  ''theorem''   ''(in '' group0 '') '' <nowiki>group0_2_T3</nowiki>:  '' shows '' $ P^{-1}\{1 \} = GroupInv(G,P)$ === 
 ''moreover''   ''have''  $ g^{-1}\{e_1\} = f^{-1}\{e_1\} \cap  H\times H$+++[proof ]>
 ''from '' A1  ''have''  $ f \in  G\times G\rightarrow G$ ''using''  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$===  ,  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''moreover''   ''from '' A2, $ group0(G,f)$  ''have''  $ H\times H \subseteq  G\times G$ ''using''  +++^[group0_3_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L2</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ H \subseteq  G$ === 
 ''ultimately ''  ''show''  $ g^{-1}\{e_1\} = f^{-1}\{e_1\} \cap  H\times H$ ''using''  <nowiki>A3</nowiki> ,  <nowiki>func1_2_L1</nowiki>
 ''qed'' === 
 ''moreover''   ''from '' A3, $ group0(H,g)$  ''have''  $ GroupInv(H,g) = g^{-1}\{e_1\}$ ''using''  +++^[group0_2_T3 | Group_ZF ]...  ''theorem''   ''(in '' group0 '') '' <nowiki>group0_2_T3</nowiki>:  '' shows '' $ P^{-1}\{1 \} = GroupInv(G,P)$ === 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

Using the lemma above we can show the actual statement: taking the inverse in the subgroup is the same as taking the inverse in the group.

 ''theorem''   ''(in '' group0 '') '' <nowiki>group0_3_T1</nowiki>:
 ''   assumes '' A1: $ IsAsubgroup(H,P)$ ''and '' A2: $ g = restrict(P,H\times H)$ ''   shows '' $ GroupInv(H,g) = restrict(GroupInv(G,P),H)$+++[proof ]>
 ''from '' groupAssum  ''have''  $ GroupInv(G,P) : G\rightarrow G$ ''using''  +++^[group0_2_T2 | Group_ZF ]...  ''theorem''  <nowiki>group0_2_T2</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,f)$  '' shows '' $ GroupInv(G,f) : G\rightarrow G$ === 
 ''moreover''   ''from '' A1, A2  ''have''  $ GroupInv(H,g) : H\rightarrow H$ ''using''  +++^[IsAsubgroup_def | Group_ZF ]... Definition of <nowiki>IsAsubgroup</nowiki>:
$ IsAsubgroup(H,P) \equiv  \text{IsAgroup}(H, restrict(P,H\times H))$===  ,  +++^[group0_2_T2 | Group_ZF ]...  ''theorem''  <nowiki>group0_2_T2</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,f)$  '' shows '' $ GroupInv(G,f) : G\rightarrow G$ === 
 ''moreover''   ''from '' A1  ''have''  $ H \subseteq  G$ ''using''  +++^[group0_3_L2 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L2</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ H \subseteq  G$ === 
 ''moreover''   ''from '' groupAssum, A1, A2  ''have''  $ GroupInv(G,P) \cap  H\times H = GroupInv(H,g)$ ''using''  +++^[group0_3_L7A | Group_ZF ]...  ''lemma''  <nowiki>group0_3_L7A</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,f)$  ''and'' $ IsAsubgroup(H,f)$  ''and'' $ g = restrict(f,H\times H)$  '' shows '' $ GroupInv(G,f) \cap  H\times H = GroupInv(H,g)$ === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  <nowiki>func1_2_L3</nowiki>
 ''qed'' === 

A sligtly weaker, but more convenient in applications, reformulation of the above theorem.

 ''theorem''   ''(in '' group0 '') '' <nowiki>group0_3_T2</nowiki>:
 ''   assumes '' $ IsAsubgroup(H,P)$ ''and '' $ g = restrict(P,H\times H)$ ''   shows '' $ \forall h\in H.\  GroupInv(H,g)(h) = h^{-1}$ ''using''  <nowiki>assms</nowiki> ,  +++^[group0_3_T1 | Group_ZF ]...  ''theorem''   ''(in '' group0 '') '' <nowiki>group0_3_T1</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  ''and'' $ g = restrict(P,H\times H)$  '' shows '' $ GroupInv(H,g) = restrict(GroupInv(G,P),H)$ ===  ,  <nowiki>restrict_if</nowiki>

Subgroups are closed with respect to taking the group inverse.

 ''theorem''   ''(in '' group0 '') '' <nowiki>group0_3_T3A</nowiki>:
 ''   assumes '' A1: $ IsAsubgroup(H,P)$ ''and '' A2: $ h\in H$ ''   shows '' $ h^{-1}\in  H$+++[proof ]>
 ''let '' $ g = restrict(P,H\times H)$
 ''from '' A1  ''have''  $ GroupInv(H,g) \in  H\rightarrow H$ ''using''  +++^[IsAsubgroup_def | Group_ZF ]... Definition of <nowiki>IsAsubgroup</nowiki>:
$ IsAsubgroup(H,P) \equiv  \text{IsAgroup}(H, restrict(P,H\times H))$===  ,  +++^[group0_2_T2 | Group_ZF ]...  ''theorem''  <nowiki>group0_2_T2</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,f)$  '' shows '' $ GroupInv(G,f) : G\rightarrow G$ === 
 ''with '' A2  ''have''  $ GroupInv(H,g)(h) \in  H$ ''using''  <nowiki>apply_type</nowiki>
 ''with '' A1, A2  ''show''  $ h^{-1}\in  H$ ''using''  +++^[group0_3_T2 | Group_ZF ]...  ''theorem''   ''(in '' group0 '') '' <nowiki>group0_3_T2</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  ''and'' $ g = restrict(P,H\times H)$  '' shows '' $ \forall h\in H.\  GroupInv(H,g)(h) = h^{-1}$ === 
 ''qed'' === 

The next theorem states that a nonempty subset of a group $G$ that is closed under the group operation and taking the inverse is a subgroup of the group.

 ''theorem''   ''(in '' group0 '') '' <nowiki>group0_3_T3</nowiki>:
 ''   assumes '' A1: $ H\neq 0$ ''and '' A2: $ H\subseteq G$ ''and '' A3: $ H \text{ is closed under } P$ ''and '' A4: $ \forall x\in H.\  x^{-1} \in  H$ ''   shows '' $ IsAsubgroup(H,P)$+++[proof ]>
 ''let '' $ g = restrict(P,H\times H)$
 ''let '' $ n = TheNeutralElement(H,g)$
 ''from '' A3  ''have''  I: $ \forall x\in H.\ \forall y\in H.\  x\cdot y \in  H$ ''using''  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$=== 
 ''from '' A1  ''obtain '' $ x$ ''where '' $ x\in H$ 
 ''with '' A4, I, A2  ''have''  $ 1 \in H$ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ === 
 ''with '' A3, A2  ''have''  T2: $ \text{IsAmonoid}(H,g)$ ''using''  +++^[group0_2_L1 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L1</nowiki>:  '' shows '' $ monoid0(G,P)$ ===  ,  +++^[group0_1_T1 | Monoid_ZF ]...  ''theorem''   ''(in '' monoid0 '') '' <nowiki>group0_1_T1</nowiki>:  ''assumes '' $ H \text{ is closed under } f$  ''and'' $ H\subseteq G$  ''and'' $ TheNeutralElement(G,f) \in  H$  '' shows '' $ \text{IsAmonoid}(H,restrict(f,H\times H))$ === 
 ''moreover''   ''have''  $ \forall h\in H.\ \exists b\in H.\  g\langle h,b\rangle  = n$+++[proof ]>
 ''fix '' $ h$
 ''assume '' $ h\in H$
 ''with '' A4, A2  ''have''  $ h\cdot h^{-1} = 1 $ ''using''  +++^[group0_2_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_2_L6</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x\cdot x^{-1} = 1  \wedge  x^{-1}\cdot x = 1 $ === 
 ''moreover''   ''from '' groupAssum, A2, A3, $ 1 \in H$  ''have''  $ 1  = n$ ''using''  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$===  ,  +++^[group0_1_L6 | Monoid_ZF ]...  ''lemma''  <nowiki>group0_1_L6</nowiki>:  ''assumes '' $ \text{IsAmonoid}(G,f)$  ''and'' $ H \text{ is closed under } f$  ''and'' $ H\subseteq G$  ''and'' $ TheNeutralElement(G,f) \in  H$  '' shows '' $ TheNeutralElement(H,restrict(f,H\times H)) = TheNeutralElement(G,f)$ === 
 ''moreover''   ''from '' A4, $ h\in H$  ''have''  $ g\langle h,h^{-1}\rangle  = h\cdot h^{-1}$ ''using''  <nowiki>restrict_if</nowiki>
 ''ultimately ''  ''have''  $ g\langle h,h^{-1}\rangle  = n$ 
 ''with '' A4, $ h\in H$  ''show''  $ \exists b\in H.\  g\langle h,b\rangle  = n$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ IsAsubgroup(H,P)$ ''using''  +++^[IsAsubgroup_def | Group_ZF ]... Definition of <nowiki>IsAsubgroup</nowiki>:
$ IsAsubgroup(H,P) \equiv  \text{IsAgroup}(H, restrict(P,H\times H))$===  ,  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$=== 
 ''qed'' === 

Intersection of subgroups is a subgroup.

 ''lemma''  <nowiki>group0_3_L7</nowiki>:
 ''   assumes '' A1: $ \text{IsAgroup}(G,f)$ ''and '' A2: $ IsAsubgroup(H_1,f)$ ''and '' A3: $ IsAsubgroup(H_2,f)$ ''   shows '' $ IsAsubgroup(H_1\cap H_2,restrict(f,H_1\times H_1))$+++[proof ]>
 ''let '' $ e = TheNeutralElement(G,f)$
 ''let '' $ g = restrict(f,H_1\times H_1)$
 ''from '' A1  ''have''  I: $ group0(G,f)$ ''using''  <nowiki>group0_def</nowiki>
 ''from '' A2  ''have''  $ group0(H_1,g)$ ''using''  +++^[IsAsubgroup_def | Group_ZF ]... Definition of <nowiki>IsAsubgroup</nowiki>:
$ IsAsubgroup(H,P) \equiv  \text{IsAgroup}(H, restrict(P,H\times H))$===  ,  <nowiki>group0_def</nowiki>
 ''moreover''   ''have''  $ H_1\cap H_2 \neq  0$+++[proof ]>
 ''from '' A1, A2, A3  ''have''  $ e \in  H_1\cap H_2$ ''using''  <nowiki>group0_def</nowiki> ,  +++^[group0_3_L5 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L5</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ 1 \in H$ === 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''have''  $ H_1\cap H_2 \subseteq  H_1$ 
 ''moreover''   ''from '' A2, A3, I, $ H_1\cap H_2 \subseteq  H_1$  ''have''  $ H_1\cap H_2 \text{ is closed under } g$ ''using''  +++^[group0_3_L6 | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_3_L6</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  ''and'' $ a\in H$,   $ b\in H$  '' shows '' $ a\cdot b \in  H$ ===  ,  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$===  ,  +++^[func_ZF_4_L7 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_4_L7</nowiki>:  ''assumes '' $ A \text{ is closed under } f$,   $ B \text{ is closed under } f$  '' shows '' $ A\cap B \text{ is closed under } f$ ===  ,  +++^[func_ZF_4_L5 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_4_L5</nowiki>:  ''assumes '' $ A \text{ is closed under } f$  ''and'' $ A\subseteq B$  '' shows '' $ A \text{ is closed under } restrict(f,B\times B)$ === 
 ''moreover''   ''from '' A2, A3, I  ''have''  $ \forall x \in  H_1\cap H_2.\  GroupInv(H_1,g)(x) \in  H_1\cap H_2$ ''using''  +++^[group0_3_T2 | Group_ZF ]...  ''theorem''   ''(in '' group0 '') '' <nowiki>group0_3_T2</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  ''and'' $ g = restrict(P,H\times H)$  '' shows '' $ \forall h\in H.\  GroupInv(H,g)(h) = h^{-1}$ ===  ,  +++^[group0_3_T3A | Group_ZF ]...  ''theorem''   ''(in '' group0 '') '' <nowiki>group0_3_T3A</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  ''and'' $ h\in H$  '' shows '' $ h^{-1}\in  H$ === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  +++^[group0_3_T3 | Group_ZF ]...  ''theorem''   ''(in '' group0 '') '' <nowiki>group0_3_T3</nowiki>:  ''assumes '' $ H\neq 0$  ''and'' $ H\subseteq G$  ''and'' $ H \text{ is closed under } P$  ''and'' $ \forall x\in H.\  x^{-1} \in  H$  '' shows '' $ IsAsubgroup(H,P)$ === 
 ''qed'' === 

 ''end

'' +++![Comments on Group_ZF|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Group_ZF"></iframe> </div> </html>
=== 
 ''theory'' Group_ZF_1 ''imports'' [[Group_ZF]]

 ''begin
'' 
In this theory we consider right and left translations and odd functions.

!Translations

In this section we consider translations. Translations are maps $T: G\rightarrow G$ of the form $T_g (a) = g\cdot a$ or $T_g (a) = a\cdot g$. We also consider two-dimensional translations $T_g : G\times G \rightarrow G\times G$, where $T_g(a,b) = (a\cdot g, b\cdot g)$ or $T_g(a,b) = (g\cdot a, g\cdot b)$.

For an element $a\in G$ the right translation is defined a function (set of pairs) such that its value (the second element of a pair) is the value of the group operation on the first element of the pair and $g$. This looks a bit strange in the raw set notation, when we write a function explicitely as a set of pairs and value of the group operation on the pair $\langle a,b \rangle$ as $ P\langle a,b\rangle $ instead of the usual infix $a\cdot b$ or $a + b$.

 ''Definition
'' $ RightTranslation(G,P,g) \equiv  \{\langle  a,b\rangle  \in  G\times G.\  P\langle a,g\rangle  = b\}$

A similar definition of the left translation.

 ''Definition
'' $ LeftTranslation(G,P,g) \equiv  \{\langle a,b\rangle  \in  G\times G.\  P\langle g,a\rangle  = b\}$

Translations map $G$ into $G$. Two dimensional translations map $G\times G$ into itself.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L1</nowiki>:
 ''   assumes '' A1: $ g\in G$ ''   shows '' $ RightTranslation(G,P,g) : G\rightarrow G$,  $ LeftTranslation(G,P,g) : G\rightarrow G$+++[proof ]>
 ''from '' A1  ''have''  $ \forall a\in G.\  a\cdot g \in  G$ ''and '' $ \forall a\in G.\  g\cdot a \in  G$ ''using''  +++^[group_oper_assocA | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assocA</nowiki>:  '' shows '' $ P : G\times G\rightarrow G$ ===  ,  <nowiki>apply_funtype</nowiki>
 ''then ''  ''show''  $ RightTranslation(G,P,g) : G\rightarrow G$,  $ LeftTranslation(G,P,g) : G\rightarrow G$ ''using''  +++^[RightTranslation_def | Group_ZF_1 ]... Definition of <nowiki>RightTranslation</nowiki>:
$ RightTranslation(G,P,g) \equiv  \{\langle  a,b\rangle  \in  G\times G.\  P\langle a,g\rangle  = b\}$===  ,  +++^[LeftTranslation_def | Group_ZF_1 ]... Definition of <nowiki>LeftTranslation</nowiki>:
$ LeftTranslation(G,P,g) \equiv  \{\langle a,b\rangle  \in  G\times G.\  P\langle g,a\rangle  = b\}$===  ,  <nowiki>func1_1_L11A</nowiki>
 ''qed'' === 

The values of the translations are what we expect.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L2</nowiki>:
 ''   assumes '' $ g\in G$,  $ a\in G$ ''   shows '' $ RightTranslation(G,P,g)(a) = a\cdot g$,  $ LeftTranslation(G,P,g)(a) = g\cdot a$ ''using''  <nowiki>assms</nowiki> ,  +++^[group0_5_L1 | Group_ZF_1 ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L1</nowiki>:  ''assumes '' $ g\in G$  '' shows '' $ RightTranslation(G,P,g) : G\rightarrow G$,   $ LeftTranslation(G,P,g) : G\rightarrow G$ ===  ,  +++^[RightTranslation_def | Group_ZF_1 ]... Definition of <nowiki>RightTranslation</nowiki>:
$ RightTranslation(G,P,g) \equiv  \{\langle  a,b\rangle  \in  G\times G.\  P\langle a,g\rangle  = b\}$===  ,  +++^[LeftTranslation_def | Group_ZF_1 ]... Definition of <nowiki>LeftTranslation</nowiki>:
$ LeftTranslation(G,P,g) \equiv  \{\langle a,b\rangle  \in  G\times G.\  P\langle g,a\rangle  = b\}$===  ,  <nowiki>func1_1_L11B</nowiki>

Composition of left translations is a left translation by the product.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L4</nowiki>:
 ''   assumes '' A1: $ g\in G$,  $ h\in G$,  $ a\in G$ ''and '' A2: $ T_g = LeftTranslation(G,P,g)$,  $ T_h = LeftTranslation(G,P,h)$ ''   shows '' $ T_g(T_h(a)) = g\cdot h\cdot a$,  $ T_g(T_h(a)) = LeftTranslation(G,P,g\cdot h)(a)$+++[proof ]>
 ''from '' A1  ''have''  I: $ h\cdot a\in G$,  $ g\cdot h\in G$ ''using''  +++^[group_oper_assocA | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assocA</nowiki>:  '' shows '' $ P : G\times G\rightarrow G$ ===  ,  <nowiki>apply_funtype</nowiki>
 ''with '' A1, A2  ''show''  $ T_g(T_h(a)) = g\cdot h\cdot a$ ''using''  +++^[group0_5_L2 | Group_ZF_1 ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L2</nowiki>:  ''assumes '' $ g\in G$,   $ a\in G$  '' shows '' $ RightTranslation(G,P,g)(a) = a\cdot g$,   $ LeftTranslation(G,P,g)(a) = g\cdot a$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''with '' A1, A2, I  ''show''  $ T_g(T_h(a)) = LeftTranslation(G,P,g\cdot h)(a)$ ''using''  +++^[group0_5_L2 | Group_ZF_1 ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L2</nowiki>:  ''assumes '' $ g\in G$,   $ a\in G$  '' shows '' $ RightTranslation(G,P,g)(a) = a\cdot g$,   $ LeftTranslation(G,P,g)(a) = g\cdot a$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''qed'' === 

Composition of right translations is a right translation by the product.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L5</nowiki>:
 ''   assumes '' A1: $ g\in G$,  $ h\in G$,  $ a\in G$ ''and '' A2: $ T_g = RightTranslation(G,P,g)$,  $ T_h = RightTranslation(G,P,h)$ ''   shows '' $ T_g(T_h(a)) = a\cdot h\cdot g$,  $ T_g(T_h(a)) = RightTranslation(G,P,h\cdot g)(a)$+++[proof ]>
 ''from '' A1  ''have''  I: $ a\cdot h\in G$,  $ h\cdot g \in G$ ''using''  +++^[group_oper_assocA | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assocA</nowiki>:  '' shows '' $ P : G\times G\rightarrow G$ ===  ,  <nowiki>apply_funtype</nowiki>
 ''with '' A1, A2  ''show''  $ T_g(T_h(a)) = a\cdot h\cdot g$ ''using''  +++^[group0_5_L2 | Group_ZF_1 ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L2</nowiki>:  ''assumes '' $ g\in G$,   $ a\in G$  '' shows '' $ RightTranslation(G,P,g)(a) = a\cdot g$,   $ LeftTranslation(G,P,g)(a) = g\cdot a$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''with '' A1, A2, I  ''show''  $ T_g(T_h(a)) = RightTranslation(G,P,h\cdot g)(a)$ ''using''  +++^[group0_5_L2 | Group_ZF_1 ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L2</nowiki>:  ''assumes '' $ g\in G$,   $ a\in G$  '' shows '' $ RightTranslation(G,P,g)(a) = a\cdot g$,   $ LeftTranslation(G,P,g)(a) = g\cdot a$ ===  ,  +++^[group_oper_assoc | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_oper_assoc</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot (b\cdot c) = a\cdot b\cdot c$ === 
 ''qed'' === 

The image of a set under a composition of translations is the same as the image under translation by a product.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L6</nowiki>:
 ''   assumes '' A1: $ g\in G$,  $ h\in G$ ''and '' A2: $ A\subseteq G$ ''and '' A3: $ T_g = RightTranslation(G,P,g)$,  $ T_h = RightTranslation(G,P,h)$ ''   shows '' $ T_g(T_h(A)) = \{a\cdot h\cdot g.\  a\in A\}$+++[proof ]>
 ''from '' A2  ''have''  $ \forall a\in A.\  a\in G$ 
 ''from '' A1, A3  ''have''  $ T_g : G\rightarrow G$,  $ T_h : G\rightarrow G$ ''using''  +++^[group0_5_L1 | Group_ZF_1 ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L1</nowiki>:  ''assumes '' $ g\in G$  '' shows '' $ RightTranslation(G,P,g) : G\rightarrow G$,   $ LeftTranslation(G,P,g) : G\rightarrow G$ === 
 ''with '' assms, $ \forall a\in A.\  a\in G$  ''show''  $ T_g(T_h(A)) = \{a\cdot h\cdot g.\  a\in A\}$ ''using''  <nowiki>func1_1_L15C</nowiki> ,  +++^[group0_5_L5 | Group_ZF_1 ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group0_5_L5</nowiki>:  ''assumes '' $ g\in G$,   $ h\in G$,   $ a\in G$  ''and'' $ T_g = RightTranslation(G,P,g)$,   $ T_h = RightTranslation(G,P,h)$  '' shows '' $ T_g(T_h(a)) = a\cdot h\cdot g$,   $ T_g(T_h(a)) = RightTranslation(G,P,h\cdot g)(a)$ === 
 ''qed'' === 


!Odd functions

This section is about odd functions.

Odd functions are those that commute with the group inverse: $f(a^{-1}) = (f(a))^{-1}.$

 ''Definition
'' $ IsOdd(G,P,f) \equiv  (\forall a\in G.\  f(GroupInv(G,P)(a)) = GroupInv(G,P)(f(a)) )$

Let's see the definition of an odd function in a more readable notation.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_6_L1</nowiki>:
 ''   shows '' $ IsOdd(G,P,p) \longleftrightarrow  ( \forall a\in G.\  p(a^{-1}) = (p(a))^{-1} )$ ''using''  +++^[IsOdd_def | Group_ZF_1 ]... Definition of <nowiki>IsOdd</nowiki>:
$ IsOdd(G,P,f) \equiv  (\forall a\in G.\  f(GroupInv(G,P)(a)) = GroupInv(G,P)(f(a)) )$=== 

We can express the definition of an odd function in two ways.

 ''lemma''   ''(in '' group0 '') '' <nowiki>group0_6_L2</nowiki>:
 ''   assumes '' A1: $ p : G\rightarrow G$ ''   shows '' $ (\forall a\in G.\  p(a^{-1}) = (p(a))^{-1}) \longleftrightarrow  (\forall a\in G.\  (p(a^{-1}))^{-1} = p(a))$+++[proof ]>
 ''assume '' $ \forall a\in G.\  p(a^{-1}) = (p(a))^{-1}$
 ''with '' A1  ''show''  $ \forall a\in G.\  (p(a^{-1}))^{-1} = p(a)$ ''using''  <nowiki>apply_funtype</nowiki> ,  +++^[group_inv_of_inv | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_inv</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ a = (a^{-1})^{-1}$ === 
 ''next '' 
 ''assume '' A2: $ \forall a\in G.\  (p(a^{-1}))^{-1} = p(a)$
 ''{ ''  ''fix '' $ a$
 ''assume '' $ a\in G$
 ''with '' A1, A2  ''have''  $ p(a^{-1}) \in  G$ ''and '' $ ((p(a^{-1}))^{-1})^{-1} =  (p(a))^{-1}$ ''using''  <nowiki>apply_funtype</nowiki> ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ === 
 ''then ''  ''have''  $ p(a^{-1}) = (p(a))^{-1}$ ''using''  +++^[group_inv_of_inv | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_inv_of_inv</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ a = (a^{-1})^{-1}$ === 
 '' }'' 
 ''then ''  ''show''  $ \forall a\in G.\  p(a^{-1}) = (p(a))^{-1}$ 
 ''qed'' === 

 ''end

'' +++![Comments on Group_ZF_1|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Group_ZF_1"></iframe> </div> </html>
=== 
 ''theory'' Group_ZF_1b ''imports'' [[Group_ZF]]

 ''begin
'' 
In a typical textbook a group is defined as a set $G$ with an associative operation such that two conditions hold: A: there is an element $e\in G$ such that for all $g\in G$ we have $e\cdot g = g$ and $g\cdot e =g$. We call this element a "unit" or a "neutral element" of the group.
B: for every $a\in G$ there exists a $b\in G$ such that $a\cdot b = e$, where $e$ is the element of $G$ whose existence is guaranteed by A. The validity of this definition is rather dubious to me, as condition A does not define any specific element $e$ that can be referred to in condition B - it merely states that a set of such units $e$ is not empty. Of course it does work in the end as we can prove that the set of such neutral elements has exactly one element, but still the definition by itself is not valid. You just can't reference a variable bound by a quantifier outside of the scope of that quantifier.
One way around this is to first use condition A to define the notion of a monoid, then prove the uniqueness of $e$ and then use the condition B to define groups. Another way is to write conditions A and B together as follows: $$\exists_{e \in G} \ (\forall_{g \in G} \ e\cdot g = g \wedge g\cdot e = g) \wedge (\forall_{a\in G}\exists_{b\in G}\ a\cdot b = e).$$ This is rather ugly. What I want to talk about is an amusing way to define groups directly without any reference to the neutral elements. Namely, we can define a group as a non-empty set $G$ with an associative operation "$\cdot $" such that
C: for every $a,b\in G$ the equations $a\cdot x = b$ and $y\cdot a = b$ can be solved in $G$.
This theory file aims at proving the equivalence of this alternative definition with the usual definition of the group, as formulated in //Group_ZF.thy//. The informal proofs come from an Aug. 14, 2005 post by buli on the matematyka.org forum.

!An alternative definition of group

First we will define notation for writing about groups.

We will use the multiplicative notation for the group operation. To do this, we define a context (locale) that tells Isabelle to interpret $a\cdot b$ as the value of function $P$ on the pair $\langle a,b \rangle$.

 ''Locale '' group2
 ''fixes '' $ P$
 ''fixes '' $ dot$
 ''defines '' $ a \cdot  b \equiv  P\langle a,b\rangle $


The next theorem states that a set $G$ with an associative operation that satisfies condition C is a group, as defined in IsarMathLib //Group_ZF// theory.

 ''theorem''   ''(in '' group2 '') '' <nowiki>altgroup_is_group</nowiki>:
 ''   assumes '' A1: $ G\neq 0$ ''and '' A2: $ P \text{ is associative on } G$ ''and '' A3: $ \forall a\in G.\ \forall b\in G.\  \exists x\in G.\  a\cdot x = b$ ''and '' A4: $ \forall a\in G.\ \forall b\in G.\  \exists y\in G.\  y\cdot a = b$ ''   shows '' $ \text{IsAgroup}(G,P)$+++[proof ]>
 ''from '' A1  ''obtain '' $ a$ ''where '' $ a\in G$ 
 ''with '' A3  ''obtain '' $ x$ ''where '' $ x\in G$ ''and '' $ a\cdot x = a$ 
 ''from '' A4, $ a\in G$  ''obtain '' $ y$ ''where '' $ y\in G$ ''and '' $ y\cdot a = a$ 
 ''have''  I: $ \forall b\in G.\  b = b\cdot x \wedge  b = y\cdot b$+++[proof ]>
 ''fix '' $ b$
 ''assume '' $ b\in G$
 ''with '' A4, $ a\in G$  ''obtain '' $ y_b$ ''where '' $ y_b\in G$ ''and '' $ y_b\cdot a = b$ 
 ''from '' A3, $ a\in G$, $ b\in G$  ''obtain '' $ x_b$ ''where '' $ x_b\in G$ ''and '' $ a\cdot x_b = b$ 
 ''from '' $ a\cdot x = a$, $ y\cdot a = a$, $ y_b\cdot a = b$, $ a\cdot x_b = b$  ''have''  $ b = y_b\cdot (a\cdot x)$ ''and '' $ b = (y\cdot a)\cdot x_b$ 
 ''moreover''   ''from '' A2, $ a\in G$, $ x\in G$, $ y\in G$, $ x_b\in G$, $ y_b\in G$  ''have''  $ (y\cdot a)\cdot x_b = y\cdot (a\cdot x_b)$,  $ y_b\cdot (a\cdot x) = (y_b\cdot a)\cdot x$ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''moreover''   ''from '' $ y_b\cdot a = b$, $ a\cdot x_b = b$  ''have''  $ (y_b\cdot a)\cdot x = b\cdot x$,  $ y\cdot (a\cdot x_b) = y\cdot b$ 
 ''ultimately ''  ''show''  $ b = b\cdot x \wedge  b = y\cdot b$ 
 ''qed'' === 
 ''moreover''   ''have''  $ x = y$+++[proof ]>
 ''from '' $ x\in G$, I  ''have''  $ x = y\cdot x$ 
 ''also''   ''from '' $ y\in G$, I  ''have''  $ y\cdot x = y$ 
 ''finally ''  ''show''  $ x = y$ 
 ''qed'' === 
 ''ultimately ''  ''have''  $ \forall b\in G.\  b\cdot x = b \wedge  x\cdot b = b$ 
 ''with '' A2, $ x\in G$  ''have''  $ \text{IsAmonoid}(G,P)$ ''using''  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$=== 
 ''with '' A3  ''show''  $ \text{IsAgroup}(G,P)$ ''using''  <nowiki>monoid0_def</nowiki> ,  +++^[unit_is_neutral | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>unit_is_neutral</nowiki>:  ''assumes '' $ e = TheNeutralElement(G,f)$  '' shows '' $ e \in  G \wedge  (\forall g\in G.\  e \oplus  g = g \wedge  g \oplus  e = g)$ ===  ,  +++^[IsAgroup_def | Group_ZF ]... Definition of <nowiki>IsAgroup</nowiki>:
$ \text{IsAgroup}(G,f) \equiv  $
$  (\text{IsAmonoid}(G,f) \wedge  (\forall g\in G.\  \exists b\in G.\  f\langle g,b\rangle  = TheNeutralElement(G,f)))$=== 
 ''qed'' === 

The converse of //altgroup_is_group//: in every (classically defined) group condition C holds. In informal mathematics we can say "Obviously condition C holds in any group." In formalized mathematics the word "obviously" is not in the language. The next theorem is proven in the context called //group0// defined in the theory //Group_ZF.thy//. Similarly to the //group2// that context defines $a\cdot b$ as $P\langle a,b\rangle$ It also defines notation related to the group inverse and adds an assumption that the pair $(G,P)$ is a group to all its theorems. This is why in the next theorem we don't explicitely assume that $(G,P)$ is a group - this assumption is implicit in the context.

 ''theorem''   ''(in '' group0 '') '' <nowiki>group_is_altgroup</nowiki>:
 ''   shows '' $ \forall a\in G.\ \forall b\in G.\  \exists x\in G.\  a\cdot x = b$ ''and '' $ \forall a\in G.\ \forall b\in G.\  \exists y\in G.\  y\cdot a = b$+++[proof ]>

 ''{ ''  ''fix '' $ a$ $ b$
 ''assume '' $ a\in G$,  $ b\in G$
 ''let '' $ x = a^{-1}\cdot  b$
 ''let '' $ y = b\cdot a^{-1}$
 ''from '' $ a\in G$, $ b\in G$  ''have''  $ x \in  G$,  $ y \in  G$ ''and '' $ a\cdot x = b$,  $ y\cdot a = b$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group_op_closed | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>group_op_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ ===  ,  +++^[inv_cancel_two | Group_ZF ]...  ''lemma''   ''(in '' group0 '') '' <nowiki>inv_cancel_two</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b^{-1}\cdot b = a$,  
$ a\cdot b\cdot b^{-1} = a$,   $ a^{-1}\cdot (a\cdot b) = b$,   $ a\cdot (a^{-1}\cdot b) = b$ === 
 ''hence''  $ \exists x\in G.\  a\cdot x = b$ ''and '' $ \exists y\in G.\  y\cdot a = b$
 '' }'' 
 ''thus''  $ \forall a\in G.\ \forall b\in G.\  \exists x\in G.\  a\cdot x = b$ ''and '' $ \forall a\in G.\ \forall b\in G.\  \exists y\in G.\  y\cdot a = b$
 ''qed'' === 

 ''end

'' +++![Comments on Group_ZF_1b|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Group_ZF_1b"></iframe> </div> </html>
=== 
 ''theory'' Introduction ''imports'' [[equalities]]

 ''begin
'' 
This theory does not contain any formalized mathematics used in other theories, but is an introduction to IsarMathLib project.

!How to read IsarMathLib proofs - a tutorial

Isar (the Isabelle's formal proof language) was designed to be similar to the standard language of mathematics. Any person able to read proofs in a typical mathematical paper should be able to read and understand Isar proofs without having to learn a special proof language. However, Isar is a formal proof language and as such it does contain a couple of constructs whose meaning is hard to guess. In this tutorial we will define a notion and prove an example theorem about that notion, explaining Isar syntax along the way. This tutorial may also serve as a style guide for IsarMathLib contributors. Note that this tutorial aims to help in reading the presentation of the Isar language that is used in IsarMathLib proof document and TiddlyWiki rendering on the Tiddly Formal Math site, but does not teach how to write proofs that can be verified by Isabelle. This presentation is different than the source processed by Isabelle (the concept that the source and presentation look different should be familiar to any LaTeX user). To learn how to write Isar proofs one needs to study the source of this tutorial as well.

The first thing that mathematicians typically do is to define notions. In Isar this is done with the //definition// keyword. In our case we define a notion of two sets being disjoint. We will use the infix notation, i.e. the string $ \text{ is disjoint with }$ put between two sets to denote our notion of disjointness. The left side of the $ \equiv $ symbol is the notion being defined, the right side says how we define it. In Isabelle //0// is used to denote both zero (of natural numbers) and the empty set, which is not surprising as those two things are the same in set theory.

 ''Definition
'' $ A \text{ is disjoint with } B \equiv  A \cap  B = 0$

We are ready to prove a theorem. Here we show that the relation of being disjoint is symmetric. We start with one of the keywords ''theorem'', ''lemma'' or ''corollary''. In Isar they are synonymous. Then we provide a name for the theorem. In standard mathematics theorems are numbered. In Isar we can do that too, but it is considered better to give theorems meaningful names. After the ''shows'' keyword we give the statement to show. The $ \longleftrightarrow $ symbol denotes the equivalence in Isabelle/ZF. Here we want to show that "A is disjoint with B iff and only if B is disjoint with A". To prove this fact we show two implications - the first one that $ A \text{ is disjoint with } B$ implies $ B \text{ is disjoint with } A$ and then the converse one. Each of these implications is formulated as a statement to be proved and then proved in a subproof like a mini-theorem. Each subproof uses a proof block to show the implication. Proof blocks are delimited with curly brackets in Isar. Proof block is one of the constructs that does not exist in informal mathematics, so it may be confusing. When reading a proof containing a proof block I suggest to focus first on what is that we are proving in it. This can be done by looking at the first line or two of the block and then at the last statement. In our case the block starts with "assume $ A \text{ is disjoint with } B$ and the last statement is "then have $ B \text{ is disjoint with } A$". It is a typical pattern when someone needs to prove an implication: one assumes the antecedent and then shows that the consequent follows from this assumption. Implications are denoted with the $ \longrightarrow $ symbol in Isabelle. After we prove both implications we collect them using the ''moreover'' construct. The keyword ''ultimately'' indicates that what follows is the conclusion of the statements collected with ''moreover''. The ''show'' keyword is like ''have'', except that it indicates that we have at arrived the claim of the theorem (or a subproof).

 ''theorem''  <nowiki>disjointness_symmetric</nowiki>:
 ''   shows '' $ A \text{ is disjoint with } B \longleftrightarrow  B \text{ is disjoint with } A$+++[proof ]>
 ''have''  $ A \text{ is disjoint with } B \longrightarrow  B \text{ is disjoint with } A$+++[proof ]>
 ''{ ''  ''assume '' $ A \text{ is disjoint with } B$
 ''then ''  ''have''  $ A \cap  B = 0$ ''using''  +++^[AreDisjoint_def | Introduction ]... Definition of <nowiki>AreDisjoint</nowiki>:
$ A \text{ is disjoint with } B \equiv  A \cap  B = 0$=== 
 ''hence''  $ B \cap  A = 0$
 ''then ''  ''have''  $ B \text{ is disjoint with } A$ ''using''  +++^[AreDisjoint_def | Introduction ]... Definition of <nowiki>AreDisjoint</nowiki>:
$ A \text{ is disjoint with } B \equiv  A \cap  B = 0$=== 
 '' }'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''have''  $ B \text{ is disjoint with } A \longrightarrow  A \text{ is disjoint with } B$+++[proof ]>
 ''{ ''  ''assume '' $ B \text{ is disjoint with } A$
 ''then ''  ''have''  $ B \cap  A = 0$ ''using''  +++^[AreDisjoint_def | Introduction ]... Definition of <nowiki>AreDisjoint</nowiki>:
$ A \text{ is disjoint with } B \equiv  A \cap  B = 0$=== 
 ''hence''  $ A \cap  B = 0$
 ''then ''  ''have''  $ A \text{ is disjoint with } B$ ''using''  +++^[AreDisjoint_def | Introduction ]... Definition of <nowiki>AreDisjoint</nowiki>:
$ A \text{ is disjoint with } B \equiv  A \cap  B = 0$=== 
 '' }'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 


!Overview of the project

The //Fol1//, // ZF1// and //Nat_ZF_IML// theory files contain some background material that is needed for the remaining theories. //Order_ZF// reformulates material from standard Isabelle's //Order// theory in terms of non-strict (less-or-equal) order relations. //Order_ZF_1// on the other hand directly continues the //Order// theory file using strict order relations (less and not equal). This is useful for translating theorems from Metamath.
The //func1// theory provides basic facts about functions. //func_ZF// continues this development with more advanced topics that relate to algebraic properties of binary operations, like lifting a binary operation to a function space, associative, commutative and distributive operations and properties of functions related to order relations. The standard Isabelle's //Finite// theory defines the finite powerset of a set as a certain "datatype" (?) with some recursive properties. IsarMathLib's //Finite1// and //Finite_ZF_1// theories develope more facts about this notion. These two theories are obsolete now. They will be gradually replaced by an approach based on set theory rather than tools specific to Isabelle. This approach is presented in //Finite_ZF// theory file. The //EquivClass1// theory file is a reformulation of the material in the standard Isabelle's //EquivClass// theory in the spirit of ZF set theory.
//FiniteSeq_ZF// discusses the notion of finite sequences (a.k.a. lists). //InductiveSeq_ZF// provides the definition and properties of (what is known in basic calculus as) sequences defined by induction, i. e. by a formula of the form $a_0 = x,\ a_{n+1} = f(a_n)$. //Fold_ZF// shows how the familiar from functional programming notion of fold can be interpreted in set theory. //Semigroup_ZF// treats the expressions of the form $a_0\cdot a_1\cdot .. \cdot a_n$, (i.e. products of finite sequences), where "$\cdot$" is an associative binary operation. The //Topology_ZF// series covers basics of general topology: interior, closure, boundary, compact sets, separation axioms and continuous functions.
//Group_ZF//, //Group_ZF_1//, and //Group_ZF_2// provide basic facts of the group theory. //Group_ZF_3// considers the notion of almost homomorphisms that is nedeed for the real numbers construction in //Real_ZF//.
//Ring_ZF// defines rings. //Ring_ZF_1// covers the properties of rings that are specific to the real numbers construction in //Real_ZF//.
//Int_ZF_IML// theory considers the integers as a monoid (multiplication) and an abelian ordered group (addition). In //Int_ZF_1// we show that integers form a commutative ring. //Int_ZF_2// contains some facts about slopes (almost homomorphisms on integers) needed for real numbers construction, used in //Real_ZF_1//. //Field_ZF// and //OrderedField_ZF// contain basic facts about (you guessed it) fields and ordered fields.
The //Real_ZF// and //Real_ZF_1// theories contain the construction of real numbers based on the paper \cite{Arthan2004} by R. D. Arthan (not Cauchy sequences, not Dedekind sections). The heavy lifting is done mostly in //Group_ZF_3//, //Ring_ZF_1// and //Int_ZF_2//. //Real_ZF// contains the part of the construction that can be done starting from generic abelian groups (rather than additive group of integers). This allows to show that real numbers form a ring. //Real_ZF_1// continues the construction using properties specific to the integers and showing that real numbers constructed this way form a complete ordered field. In //Complex_ZF// we construct complex numbers starting from a complete ordered field (a model of real numbers). We also define the notation for writing about complex numbers and prove that the structure of complex numbers constructed there satisfies the axioms of complex numbers used in Metamath. //MMI_prelude// defines the //mmisar0// context in which most theorems translated from Metamath are proven. It also contains a chapter explaining how the translation works. In the //Metamath_interface// theory we prove a theorem that the //mmisar0// context is valid (can be used) in the //complex0// context. All theories using the translated results will import the //Metamath_interface// theory. The //Metamath_sampler// theory provides some examples of using the translated theorems in the //complex0// context. The theories //MMI_logic_and_sets//, //MMI_Complex//, //MMI_Complex_1// and //MMI_Complex_2// contain the theorems imported from the Metamath's set.mm database. As the translated proofs are rather verbose these theories are not printed in this proof document. The full list of translated facts can be found in the //known_theorems.txt// file included in the IsarMathLib distribution. The //MMI_examples// provides some theorems imported from Metamath that are printed in this proof document as examples of how translated proofs look like.

 ''end

'' +++![Comments on Introduction|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Introduction"></iframe> </div> </html>
=== 
/***
|''Name:''|LoadRemoteFileThroughProxy (previous LoadRemoteFileHijack)|
|''Description:''|When the TiddlyWiki file is located on the web (view over http) the content of [[SiteProxy]] tiddler is added in front of the file url. If [[SiteProxy]] does not exist "/proxy/" is added. |
|''Version:''|1.1.0|
|''Date:''|mar 17, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#LoadRemoteFileHijack|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
***/
//{{{
version.extensions.LoadRemoteFileThroughProxy = {
 major: 1, minor: 1, revision: 0, 
 date: new Date("mar 17, 2007"), 
 source: "http://tiddlywiki.bidix.info/#LoadRemoteFileThroughProxy"};

if (!window.bidix) window.bidix = {}; // bidix namespace
if (!bidix.core) bidix.core = {};

bidix.core.loadRemoteFile = loadRemoteFile;
loadRemoteFile = function(url,callback,params)
{
 if ((document.location.toString().substr(0,4) == "http") && (url.substr(0,4) == "http")){ 
  url = store.getTiddlerText("SiteProxy", "/proxy/") + url;
 }
 return bidix.core.loadRemoteFile(url,callback,params);
}
//}}}
AboutThisSite
[[Introduction]]
ZF1
Nat_ZF
[[func_ZF]]
EquivClass1
Finite_ZF
Topology_ZF
Topology_ZF_1
Topology_ZF_1b
Topology_ZF_2
Monoid_ZF
Group_ZF
Group_ZF_1
Group_ZF_1b
DirectProduct_ZF
[[Administration]] 
GettingStarted
 ''theory'' Monoid_ZF ''imports'' [[func_ZF]]

 ''begin
'' 
This theory provides basic facts about monoids.

!Definition and basic properties

In this section we talk about monoids. The notion of a monoid is similar to the notion of a a semigroup group except that we require the existence of a netrual element. It is also similar to the notion of group except that we don't require existence of the inverse.

Monoid is a set $G$ with an associative operation and a neutral element. The operation is a function on $G\times G$ with values in $G$. In the context of ZF set theory this means that it is a set of pairs $\langle x,y \rangle$, where $x\in G\times G$ and $y\in G$. In other words the operation is a certain subset of $(G\times G)\times G$. We express all this by defing a predicate $ \text{IsAmonoid}(G,f)$. Here $G$ is the ''carrier'' of the group and $f$ is the binary operation on it.

 ''Definition
'' $ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$

The next locale called ''monoid0'' defines a context for theorems that concern monoids. In this contex we assume that the pair $(G,f)$ is a monoid. We will use the $ \oplus $ symbol to denote the monoid operation (for no particular reason).

 ''Locale '' monoid0
 ''fixes '' $ G$
 ''fixes '' $ f$
 ''assumes '' monoidAsssum: $ \text{IsAmonoid}(G,f)$
 ''fixes '' $ monoper$
 ''defines '' $ a \oplus  b \equiv  f\langle a,b\rangle $


The result of the monoid operation is in the monoid (carrier).

 ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L1</nowiki>:
 ''   assumes '' $ a\in G$,  $ b\in G$ ''   shows '' $ a\oplus b \in  G$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>monoidAsssum</nowiki> ,  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$===  ,  <nowiki>apply_funtype</nowiki>

There is only one neutral element in monoid.

 ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L2</nowiki>:
 ''   shows '' $ \exists !e.\  e\in G \wedge  (\forall  g\in G.\  ( (e\oplus g = g) \wedge  g\oplus e = g))$+++[proof ]>
 ''fix '' $ e$ $ y$
 ''assume '' $ e \in  G \wedge  (\forall g\in G.\  e \oplus  g = g \wedge  g \oplus  e = g)$ ''and '' $ y \in  G \wedge  (\forall g\in G.\  y \oplus  g = g \wedge  g \oplus  y = g)$
 ''then ''  ''have''  $ y\oplus e = y$,  $ y\oplus e = e$ 
 ''thus''  $ e = y$
 ''next '' 
 ''from '' monoidAsssum  ''show''  $ \exists e.\  e\in  G \wedge  (\forall  g\in G.\  e\oplus g = g \wedge  g\oplus e = g)$ ''using''  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$=== 
 ''qed'' === 

We could put the definition of neutral element anywhere, but it is only usable in conjuction with the above lemma.

 ''Definition
'' $ TheNeutralElement(G,f) \equiv  $
$  ( \text{The } e.\  e\in G \wedge  (\forall  g\in G.\  f\langle e,g\rangle  = g \wedge  f\langle g,e\rangle  = g))$

The neutral element is neutral.

 ''lemma''   ''(in '' monoid0 '') '' <nowiki>unit_is_neutral</nowiki>:
 ''   assumes '' A1: $ e = TheNeutralElement(G,f)$ ''   shows '' $ e \in  G \wedge  (\forall g\in G.\  e \oplus  g = g \wedge  g \oplus  e = g)$+++[proof ]>
 ''let '' $ n = \text{The } b.\  b\in  G \wedge  (\forall  g\in G.\  b\oplus g = g \wedge  g\oplus b = g)$
 ''have''  $ \exists !b.\  b\in  G \wedge  (\forall  g\in G.\  b\oplus g = g \wedge  g\oplus b = g)$ ''using''  +++^[group0_1_L2 | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L2</nowiki>:  '' shows '' $ \exists !e.\  e\in G \wedge  (\forall  g\in G.\  ( (e\oplus g = g) \wedge  g\oplus e = g))$ === 
 ''then ''  ''have''  $ n\in  G \wedge  (\forall  g\in G.\  n\oplus g = g \wedge  g\oplus n = g)$ ''   by (rule '' <nowiki>theI</nowiki> '')'' 
 ''with '' A1  ''show''  $ thesis$ ''using''  +++^[TheNeutralElement_def | Monoid_ZF ]... Definition of <nowiki>TheNeutralElement</nowiki>:
$ TheNeutralElement(G,f) \equiv  $
$  ( \text{The } e.\  e\in G \wedge  (\forall  g\in G.\  f\langle e,g\rangle  = g \wedge  f\langle g,e\rangle  = g))$=== 
 ''qed'' === 

The monoid carrier is not empty.

 ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L3A</nowiki>:
 ''   shows '' $ G\neq 0$+++[proof ]>
 ''have''  $ TheNeutralElement(G,f) \in  G$ ''using''  +++^[unit_is_neutral | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>unit_is_neutral</nowiki>:  ''assumes '' $ e = TheNeutralElement(G,f)$  '' shows '' $ e \in  G \wedge  (\forall g\in G.\  e \oplus  g = g \wedge  g \oplus  e = g)$ === 
 ''thus''  $ thesis$
 ''qed'' === 

The range of the monoid operation is the whole monoid carrier.

 ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L3B</nowiki>:
 ''   shows '' $ range(f) = G$+++[proof ]>
 ''from '' monoidAsssum  ''have''  $ f : G\times G\rightarrow G$ ''using''  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''then ''  ''show''  $ range(f) \subseteq  G$ ''using''  <nowiki>func1_1_L5B</nowiki>
 ''show''  $ G \subseteq  range(f)$+++[proof ]>
 ''fix '' $ g$
 ''assume '' A1: $ g\in G$
 ''let '' $ e = TheNeutralElement(G,f)$
 ''from '' A1  ''have''  $ \langle e,g\rangle  \in  G\times G$,  $ g = f\langle e,g\rangle $ ''using''  +++^[unit_is_neutral | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>unit_is_neutral</nowiki>:  ''assumes '' $ e = TheNeutralElement(G,f)$  '' shows '' $ e \in  G \wedge  (\forall g\in G.\  e \oplus  g = g \wedge  g \oplus  e = g)$ === 
 ''with '' $ f : G\times G\rightarrow G$  ''show''  $ g \in  range(f)$ ''using''  <nowiki>func1_1_L5A</nowiki>
 ''qed'' === 
 ''qed'' === 

In a monoid any neutral element is the neutral element.

 ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L4</nowiki>:
 ''   assumes '' A1: $ e \in  G \wedge  (\forall g\in G.\  e \oplus  g = g \wedge  g \oplus  e = g)$ ''   shows '' $ e = TheNeutralElement(G,f)$+++[proof ]>
 ''let '' $ n = \text{The } b.\  b\in  G \wedge  (\forall  g\in G.\  b\oplus g = g \wedge  g\oplus b = g)$
 ''have''  $ \exists !b.\  b\in  G \wedge  (\forall  g\in G.\  b\oplus g = g \wedge  g\oplus b = g)$ ''using''  +++^[group0_1_L2 | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L2</nowiki>:  '' shows '' $ \exists !e.\  e\in G \wedge  (\forall  g\in G.\  ( (e\oplus g = g) \wedge  g\oplus e = g))$ === 
 ''moreover''   ''note '' A1
 ''ultimately ''  ''have''  $ n = e$ ''   by (rule '' <nowiki>the_equality2</nowiki> '')'' 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[TheNeutralElement_def | Monoid_ZF ]... Definition of <nowiki>TheNeutralElement</nowiki>:
$ TheNeutralElement(G,f) \equiv  $
$  ( \text{The } e.\  e\in G \wedge  (\forall  g\in G.\  f\langle e,g\rangle  = g \wedge  f\langle g,e\rangle  = g))$=== 
 ''qed'' === 

The next lemma shows that if the if we restrict the monoid operation to a subset of $G$ that contains the neutral element, then the neutral element of the monoid operation is also neutral with the restricted operation.

 ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L5</nowiki>:
 ''   assumes '' A1: $ \forall x\in H.\ \forall y\in H.\  x\oplus y \in  H$ ''and '' A2: $ H\subseteq G$ ''and '' A3: $ e = TheNeutralElement(G,f)$ ''and '' A4: $ g = restrict(f,H\times H)$ ''and '' A5: $ e\in H$ ''and '' A6: $ h\in H$ ''   shows '' $ g\langle e,h\rangle  = h \wedge  g\langle h,e\rangle  = h$+++[proof ]>
 ''from '' A4, A6, A5  ''have''  $ g\langle e,h\rangle  = e\oplus h \wedge  g\langle h,e\rangle  = h\oplus e$ ''using''  <nowiki>restrict_if</nowiki>
 ''with '' A3, A4, A6, A2  ''show''  $ g\langle e,h\rangle  = h \wedge  g\langle h,e\rangle  = h$ ''using''  +++^[unit_is_neutral | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>unit_is_neutral</nowiki>:  ''assumes '' $ e = TheNeutralElement(G,f)$  '' shows '' $ e \in  G \wedge  (\forall g\in G.\  e \oplus  g = g \wedge  g \oplus  e = g)$ === 
 ''qed'' === 

The next theorem shows that if the monoid operation is closed on a subset of $G$ then this set is a (sub)monoid (although we do not define this notion). This fact will be useful when we study subgroups.

 ''theorem''   ''(in '' monoid0 '') '' <nowiki>group0_1_T1</nowiki>:
 ''   assumes '' A1: $ H \text{ is closed under } f$ ''and '' A2: $ H\subseteq G$ ''and '' A3: $ TheNeutralElement(G,f) \in  H$ ''   shows '' $ \text{IsAmonoid}(H,restrict(f,H\times H))$+++[proof ]>
 ''let '' $ g = restrict(f,H\times H)$
 ''let '' $ e = TheNeutralElement(G,f)$
 ''from '' monoidAsssum  ''have''  $ f \in  G\times G\rightarrow G$ ''using''  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''moreover''   ''from '' A2  ''have''  $ H\times H \subseteq  G\times G$ 
 ''moreover''   ''from '' A1  ''have''  $ \forall p \in  H\times H.\  f(p) \in  H$ ''using''  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$=== 
 ''ultimately ''  ''have''  $ g \in  H\times H\rightarrow H$ ''using''  <nowiki>func1_2_L4</nowiki>
 ''moreover''   ''have''  $ \forall x\in H.\ \forall y\in H.\ \forall z\in H.\  $
$    g\langle g\langle x,y\rangle  ,z\rangle  = g\langle x,g\langle y,z\rangle \rangle $+++[proof ]>
 ''from '' A1  ''have''  $ \forall x\in H.\ \forall y\in H.\ \forall z\in H.\ $
$      g\langle g\langle x,y\rangle ,z\rangle  = x\oplus y\oplus z$ ''using''  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$===  ,  <nowiki>restrict_if</nowiki>
 ''moreover''   ''have''  $ \forall x\in H.\ \forall y\in H.\ \forall z\in H.\  x\oplus y\oplus z = x\oplus (y\oplus z)$+++[proof ]>
 ''from '' monoidAsssum  ''have''  $ \forall x\in G.\ \forall y\in G.\ \forall z\in G.\  x\oplus y\oplus z = x\oplus (y\oplus z)$ ''using''  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''with '' A2  ''show''  $ thesis$ 
 ''qed'' === 
 ''moreover''   ''from '' A1  ''have''  $ \forall x\in H.\ \forall y\in H.\ \forall z\in H.\  x\oplus (y\oplus z) = g\langle  x,g\langle y,z\rangle  \rangle $ ''using''  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$===  ,  <nowiki>restrict_if</nowiki>
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 
 ''moreover''   ''have''  $ \exists n\in H.\  (\forall h\in H.\  g\langle n,h\rangle  = h \wedge  g\langle h,n\rangle  = h)$+++[proof ]>
 ''from '' A1  ''have''  $ \forall x\in H.\ \forall y\in H.\  x\oplus y \in  H$ ''using''  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$=== 
 ''with '' A2, A3  ''have''  $ \forall  h\in H.\  g\langle e,h\rangle  = h \wedge  g\langle h,e\rangle  = h$ ''using''  +++^[group0_1_L5 | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L5</nowiki>:  ''assumes '' $ \forall x\in H.\ \forall y\in H.\  x\oplus y \in  H$  ''and'' $ H\subseteq G$  ''and'' $ e = TheNeutralElement(G,f)$  ''and'' $ g = restrict(f,H\times H)$  ''and'' $ e\in H$  ''and'' $ h\in H$  '' shows '' $ g\langle e,h\rangle  = h \wedge  g\langle h,e\rangle  = h$ === 
 ''with '' A3  ''show''  $ thesis$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  +++^[IsAmonoid_def | Monoid_ZF ]... Definition of <nowiki>IsAmonoid</nowiki>:
$ \text{IsAmonoid}(G,f) \equiv $
$  f \text{ is associative on } G \wedge  $
$  (\exists e\in G.\  (\forall  g\in G.\  ( (f(\langle e,g\rangle ) = g) \wedge  (f(\langle g,e\rangle ) = g))))$===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''qed'' === 

Under the assumptions of // group0_1_T1// the neutral element of a submonoid is the same as that of the monoid.

 ''lemma''  <nowiki>group0_1_L6</nowiki>:
 ''   assumes '' A1: $ \text{IsAmonoid}(G,f)$ ''and '' A2: $ H \text{ is closed under } f$ ''and '' A3: $ H\subseteq G$ ''and '' A4: $ TheNeutralElement(G,f) \in  H$ ''   shows '' $ TheNeutralElement(H,restrict(f,H\times H)) = TheNeutralElement(G,f)$+++[proof ]>
 ''let '' $ e = TheNeutralElement(G,f)$
 ''let '' $ g = restrict(f,H\times H)$
 ''from '' assms  ''have''  $ monoid0(H,g)$ ''using''  <nowiki>monoid0_def</nowiki> ,  +++^[group0_1_T1 | Monoid_ZF ]...  ''theorem''   ''(in '' monoid0 '') '' <nowiki>group0_1_T1</nowiki>:  ''assumes '' $ H \text{ is closed under } f$  ''and'' $ H\subseteq G$  ''and'' $ TheNeutralElement(G,f) \in  H$  '' shows '' $ \text{IsAmonoid}(H,restrict(f,H\times H))$ === 
 ''moreover''   ''have''  $ e \in  H \wedge  (\forall h\in H.\  g\langle e,h\rangle  = h \wedge  g\langle h,e\rangle  = h)$+++[proof ]>
 ''{ ''  ''fix '' $ h$
 ''assume '' $ h \in  H$
 ''with '' assms  ''have''  $ monoid0(G,f)$,  $ \forall x\in H.\ \forall y\in H.\  f\langle x,y\rangle  \in  H$,  $ H\subseteq G$,  $ e = TheNeutralElement(G,f)$,  $ g = restrict(f,H\times H)$,  $ e \in  H$,  $ h \in  H$ ''using''  <nowiki>monoid0_def</nowiki> ,  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$=== 
 ''then ''  ''have''  $ g\langle e,h\rangle  = h \wedge  g\langle h,e\rangle  = h$ ''   by (rule '' +++^[group0_1_L5 | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L5</nowiki>:  ''assumes '' $ \forall x\in H.\ \forall y\in H.\  x\oplus y \in  H$  ''and'' $ H\subseteq G$  ''and'' $ e = TheNeutralElement(G,f)$  ''and'' $ g = restrict(f,H\times H)$  ''and'' $ e\in H$  ''and'' $ h\in H$  '' shows '' $ g\langle e,h\rangle  = h \wedge  g\langle h,e\rangle  = h$ ===  '')'' 
 '' }'' 
 ''hence''  $ \forall h\in H.\  g\langle e,h\rangle  = h \wedge  g\langle h,e\rangle  = h$
 ''with '' A4  ''show''  $ thesis$ 
 ''qed'' === 
 ''ultimately ''  ''have''  $ e =  TheNeutralElement(H,g)$ ''   by (rule '' +++^[group0_1_L4 | Monoid_ZF ]...  ''lemma''   ''(in '' monoid0 '') '' <nowiki>group0_1_L4</nowiki>:  ''assumes '' $ e \in  G \wedge  (\forall g\in G.\  e \oplus  g = g \wedge  g \oplus  e = g)$  '' shows '' $ e = TheNeutralElement(G,f)$ ===  '')'' 
 ''thus''  $ thesis$
 ''qed'' === 

 ''end

'' +++![Comments on Monoid_ZF|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Monoid_ZF"></iframe> </div> </html>
=== 
Nat_ZF placeholder
/***
|Name|NestedSlidersPlugin|
|Source|http://www.TiddlyTools.com/#NestedSlidersPlugin|
|Version|2.3.2|
|Author|Eric Shulman - ELS Design Studios|
|License|http://www.TiddlyTools.com/#LegalStatements <<br>>and [[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]|
|~CoreVersion|2.1|
|Type|plugin|
|Requires||
|Overrides|Slider.prototype.stop|
|Description|show content in nest-able 'slider' or 'floating' panels, without needing to create separate tiddlers for each panel|

!!!!!Configuration
<<<
Enable animation for slider panels
<<option chkFloatingSlidersAnimate>> allow sliders to animate when opening/closing
>(note: This setting is in //addition// to the general option for enabling/disabling animation effects:
><<option chkAnimate>> enable animations (entire document)
>For slider animation to occur, you must also allow animation in general.

Debugging messages for 'lazy sliders' deferred rendering:
<<option chkDebugLazySliderDefer>> show debugging alert when deferring slider rendering
<<option chkDebugLazySliderRender>> show debugging alert when deferred slider is actually rendered
<<<
!!!!!Usage
<<<
When installed, this plugin adds new wiki syntax for embedding 'slider' panels directly into tiddler content.  Use {{{+++}}} and {{{===}}} to delimit the slider content.  You can also 'nest' these sliders as deep as you like (see complex nesting example below), so that expandable 'tree-like' hierarchical displays can be created.  This is most useful when converting existing in-line text content to create in-line annotations, footnotes, context-sensitive help, or other subordinate information displays.

Additional optional syntax elements let you specify
*default to open
*cookiename
*heading level
*floater (with optional CSS width value)
*transient display (clicking elsewhere closes panel)
*custom class/label/tooltip/accesskey
*alternate label/tooltip (displayed when panel is open)
*panelID (for later use with {{{<<DOM>>}}} macro.  See [[DOMTweaksPlugin]])
*automatic blockquote style on panel
*deferred rendering of panel content
The complete syntax, using all options, is:
//{{{
++++(cookiename)!!!!!^width^*{{class{[label=key|tooltip][altlabel|alttooltip]}}}#panelID:>...
content goes here
===
//}}}
where:
* {{{+++}}} (or {{{++++}}}) and {{{===}}}<br>marks the start and end of the slider definition, respectively.  When the extra {{{+}}} is used, the slider will be open when initially displayed.
* {{{(cookiename)}}}<br>saves the slider opened/closed state, and restores this state whenever the slider is re-rendered.
* {{{!}}} through {{{!!!!!}}}<br>displays the slider label using a formatted headline (Hn) style instead of a button/link style
* {{{^width^}}} (or just {{{^}}})<br>makes the slider 'float' on top of other content rather than shifting that content downward.  'width' must be a valid CSS value (e.g., "30em", "180px", "50%", etc.).  If omitted, the default width is "auto" (i.e., fit to content)
* {{{"*"}}} //(without the quotes)//<br>denotes "transient display": when a click occurs elsewhere in the document, the slider/floating panel will be automatically closed.  This is useful for creating 'pulldown menus' that automatically go away after they are used.  //Note: using SHIFT-click on a slider label will open/close that slider without triggering the automatic closing of any transient slider panels that are currently displayed, permitting ''temporary'' display of several transient panels at once.//
* """{{class{[label=key|tooltip][altlabel|alttooltip]}}}"""<br>uses label/tooltip/accesskey.  """{{class{...}}}""", """=key""", """|tooltip""" and """[altlabel|alttooltip]""" are optional.  'class' is any valid CSS class name, used to style the slider label text.  'key' must be a ''single letter only''.  altlabel/alttooltip specifiy alternative label/tooltip for use when slider/floating panel is displayed.
* {{{#panelID:}}}<br>defines a unique DOM element ID that is assigned to the panel element used to display the slider content.  This ID can then be used later to reposition the panel using the {{{<<DOM move id>>}}} macro (see [[DOMTweaksPlugin]]), or to access/modify the panel element through use of {{{document.getElementById(...)}}}) javascript code in a plugin or inline script.
* {{{">"}}} //(without the quotes)//<br>automatically adds blockquote formatting to slider content
* {{{"..."}}} //(without the quotes)//<br>defers rendering of closed sliders until the first time they are opened.  //Note: deferred rendering may produce unexpected results in some cases.  Use with care.//

//Note: to make slider definitions easier to read and recognize when editing a tiddler, newlines immediately following the {{{+++}}} 'start slider' or preceding the {{{===}}} 'end slider' sequence are automatically supressed so that excess whitespace is eliminated from the output.//
<<<
!!!!!Examples
<<<
simple in-line slider: 
{{{
+++
   content
===
}}}
+++
   content
===
----
use a custom label and tooltip: 
{{{
+++[label|tooltip]
   content
===
}}}
+++[label|tooltip]
   content
===
----
content automatically blockquoted: 
{{{
+++>
   content
===
}}}
+++>
   content
===
----
all options combined //(default open, cookie, heading, sized floater, transient, class, label/tooltip/key, blockquoted, deferred)//
{{{
++++(testcookie)!!!^30em^*{{big{[label=Z|click or press Alt-Z to open]}}}>...
   content
===
}}}
++++(testcookie)!!!^30em^*{{big{[label=Z|click or press Alt-Z to open]}}}>...
   content
===
----
complex nesting example:
{{{
+++[get info...=I|click for information or press Alt-I]
	put some general information here,
	plus a floating panel with more specific info:
	+++^10em^[view details...|click for details]
		put some detail here, which could in turn contain a transient panel,
		perhaps with a +++^25em^*[glossary definition]explaining technical terms===
	===
===
}}}
+++[get info...=I|click for information or press Alt-I]
	put some general information here,
	plus a floating panel with more specific info:
	+++^10em^[view details...|click for details]
		put some detail here, which could in turn contain a transient panel,
		perhaps with a +++^25em^*[glossary definition]explaining technical terms===
	===
===
<<<
!!!!!Installation
<<<
import (or copy/paste) the following tiddlers into your document:
''NestedSlidersPlugin'' (tagged with <<tag systemConfig>>)
<<<
!!!!!Revision History
<<<
''2007.11.14 - 2.3.2'' in onClickNestedSlider(), prevent SHIFT-click events from opening a new, empty browser window by setting "cancelBubble=true" and calling "stopPropagation()".  Note: SHIFT-click is still processed as a normal click (i.e., it toggles the slider panel display).  Also, using SHIFT-click will prevent 'transient' sliders from being automatically closed when another slider is opened, allowing you to *temporarily* display several transient sliders at once.
''2007.07.26 - 2.3.1'' in document.onclick(), propagate return value from hijacked core click handler to consume OR bubble up click as needed.  Fixes "IE click disease", whereby nearly every mouse click causes a page transition.
|please see [[NestedSlidersPluginHistory]] for additional revision details|
''2005.11.03 - 1.0.0'' initial public release
<<<
!!!!!Credits
<<<
This feature was implemented by EricShulman from [[ELS Design Studios|http:/www.elsdesign.com]] with initial research and suggestions from RodneyGomes, GeoffSlocock, and PaulPetterson.
<<<
!!!!!Code
***/
//{{{
version.extensions.nestedSliders = {major: 2, minor: 3, revision: 2, date: new Date(2007,11,14)};
//}}}

//{{{
// options for deferred rendering of sliders that are not initially displayed
if (config.options.chkDebugLazySliderDefer==undefined) config.options.chkDebugLazySliderDefer=false;
if (config.options.chkDebugLazySliderRender==undefined) config.options.chkDebugLazySliderRender=false;
if (config.options.chkFloatingSlidersAnimate==undefined) config.options.chkFloatingSlidersAnimate=false;

// default styles for 'floating' class
setStylesheet(".floatingPanel { position:absolute; z-index:10; padding:0.5em; margin:0em; \
	background-color:#eee; color:#000; border:1px solid #000; text-align:left; }","floatingPanelStylesheet");
//}}}

//{{{
config.formatters.push( {
	name: "nestedSliders",
	match: "\\n?\\+{3}",
	terminator: "\\s*\\={3}\\n?",
	lookahead: "\\n?\\+{3}(\\+)?(\\([^\\)]*\\))?(\\!*)?(\\^(?:[^\\^\\*\\[\\>]*\\^)?)?(\\*)?(?:\\{\\{([\\w]+[\\s\\w]*)\\{)?(\\[[^\\]]*\\])?(\\[[^\\]]*\\])?(?:\\}{3})?(\\#[^:]*\\:)?(\\>)?(\\.\\.\\.)?\\s*",
	handler: function(w)
		{
			lookaheadRegExp = new RegExp(this.lookahead,"mg");
			lookaheadRegExp.lastIndex = w.matchStart;
			var lookaheadMatch = lookaheadRegExp.exec(w.source)
			if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
			{
				// var defopen=lookaheadMatch[1]
				// var cookiename=lookaheadMatch[2]
				// var header=lookaheadMatch[3]
				// var panelwidth=lookaheadMatch[4]
				// var transient=lookaheadMatch[5]
				// var class=lookaheadMatch[6]
				// var label=lookaheadMatch[7]
				// var openlabel=lookaheadMatch[8]
				// var panelID=lookaheadMatch[9]
				// var blockquote=lookaheadMatch[10]
				// var deferred=lookaheadMatch[11]

				// location for rendering button and panel
				var place=w.output;

				// default to closed, no cookie, no accesskey, no alternate text/tip
				var show="none"; var cookie=""; var key="";
				var closedtext=">"; var closedtip="";
				var openedtext="<"; var openedtip="";

				// extra "+", default to open
				if (lookaheadMatch[1]) show="block";

				// cookie, use saved open/closed state
				if (lookaheadMatch[2]) {
					cookie=lookaheadMatch[2].trim().slice(1,-1);
					cookie="chkSlider"+cookie;
					if (config.options[cookie]==undefined)
						{ config.options[cookie] = (show=="block") }
					show=config.options[cookie]?"block":"none";
				}

				// parse label/tooltip/accesskey: [label=X|tooltip]
				if (lookaheadMatch[7]) {
					var parts=lookaheadMatch[7].trim().slice(1,-1).split("|");
					closedtext=parts.shift();
					if (closedtext.substr(closedtext.length-2,1)=="=")	
						{ key=closedtext.substr(closedtext.length-1,1); closedtext=closedtext.slice(0,-2); }
					openedtext=closedtext;
					if (parts.length) closedtip=openedtip=parts.join("|");
					else { closedtip="show "+closedtext; openedtip="hide "+closedtext; }
				}

				// parse alternate label/tooltip: [label|tooltip]
				if (lookaheadMatch[8]) {
					var parts=lookaheadMatch[8].trim().slice(1,-1).split("|");
					openedtext=parts.shift();
					if (parts.length) openedtip=parts.join("|");
					else openedtip="hide "+openedtext;
				}

				var title=show=='block'?openedtext:closedtext;
				var tooltip=show=='block'?openedtip:closedtip;

				// create the button
				if (lookaheadMatch[3]) { // use "Hn" header format instead of button/link
					var lvl=(lookaheadMatch[3].length>6)?6:lookaheadMatch[3].length;
					var btn = createTiddlyElement(createTiddlyElement(place,"h"+lvl,null,null,null),"a",null,lookaheadMatch[6],title);
					btn.onclick=onClickNestedSlider;
					btn.setAttribute("href","javascript:;");
					btn.setAttribute("title",tooltip);
				}
				else
					var btn = createTiddlyButton(place,title,tooltip,onClickNestedSlider,lookaheadMatch[6]);
				btn.innerHTML=title; // enables use of HTML entities in label

				// set extra button attributes
				btn.setAttribute("closedtext",closedtext);
				btn.setAttribute("closedtip",closedtip);
				btn.setAttribute("openedtext",openedtext);
				btn.setAttribute("openedtip",openedtip);
				btn.sliderCookie = cookie; // save the cookiename (if any) in the button object
				btn.defOpen=lookaheadMatch[1]!=null; // save default open/closed state (boolean)
				btn.keyparam=key; // save the access key letter ("" if none)
				if (key.length) {
					btn.setAttribute("accessKey",key); // init access key
					btn.onfocus=function(){this.setAttribute("accessKey",this.keyparam);}; // **reclaim** access key on focus
				}
				btn.onmouseover=function(event) // mouseover on button aligns floater position with button
					{ if (window.adjustSliderPos) window.adjustSliderPos(this.parentNode,this,this.sliderPanel,this.sliderPanel.className); }

				// create slider panel
				var panelClass=lookaheadMatch[4]?"floatingPanel":"sliderPanel";
				var panelID=lookaheadMatch[9]; if (panelID) panelID=panelID.slice(1,-1); // trim off delimiters
				var panel=createTiddlyElement(place,"div",panelID,panelClass,null);
				panel.button = btn; // so the slider panel know which button it belongs to
				btn.sliderPanel=panel; // so the button knows which slider panel it belongs to
				panel.defaultPanelWidth=(lookaheadMatch[4] && lookaheadMatch[4].length>2)?lookaheadMatch[4].slice(1,-1):"";
				panel.setAttribute("transient",lookaheadMatch[5]=="*"?"true":"false");
				panel.style.display = show;
				panel.style.width=panel.defaultPanelWidth;
				panel.onmouseover=function(event) // mouseover on panel aligns floater position with button
					{ if (window.adjustSliderPos) window.adjustSliderPos(this.parentNode,this.button,this,this.className); }

				// render slider (or defer until shown) 
				w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
				if ((show=="block")||!lookaheadMatch[11]) {
					// render now if panel is supposed to be shown or NOT deferred rendering
					w.subWikify(lookaheadMatch[10]?createTiddlyElement(panel,"blockquote"):panel,this.terminator);
					// align floater position with button
					if (window.adjustSliderPos) window.adjustSliderPos(place,btn,panel,panelClass);
				}
				else {
					var src = w.source.substr(w.nextMatch);
					var endpos=findMatchingDelimiter(src,"+++","===");
					panel.setAttribute("raw",src.substr(0,endpos));
					panel.setAttribute("blockquote",lookaheadMatch[10]?"true":"false");
					panel.setAttribute("rendered","false");
					w.nextMatch += endpos+3;
					if (w.source.substr(w.nextMatch,1)=="\n") w.nextMatch++;
					if (config.options.chkDebugLazySliderDefer) alert("deferred '"+title+"':\n\n"+panel.getAttribute("raw"));
				}
			}
		}
	}
)

// TBD: ignore 'quoted' delimiters (e.g., "{{{+++foo===}}}" isn't really a slider)
function findMatchingDelimiter(src,starttext,endtext) {
	var startpos = 0;
	var endpos = src.indexOf(endtext);
	// check for nested delimiters
	while (src.substring(startpos,endpos-1).indexOf(starttext)!=-1) {
		// count number of nested 'starts'
		var startcount=0;
		var temp = src.substring(startpos,endpos-1);
		var pos=temp.indexOf(starttext);
		while (pos!=-1)  { startcount++; pos=temp.indexOf(starttext,pos+starttext.length); }
		// set up to check for additional 'starts' after adjusting endpos
		startpos=endpos+endtext.length;
		// find endpos for corresponding number of matching 'ends'
		while (startcount && endpos!=-1) {
			endpos = src.indexOf(endtext,endpos+endtext.length);
			startcount--;
		}
	}
	return (endpos==-1)?src.length:endpos;
}
//}}}

//{{{
window.onClickNestedSlider=function(e)
{
	if (!e) var e = window.event;
	var theTarget = resolveTarget(e);
	var theLabel = theTarget.firstChild.data;
	var theSlider = theTarget.sliderPanel
	var isOpen = theSlider.style.display!="none";

	// toggle label
	theTarget.innerHTML=isOpen?theTarget.getAttribute("closedText"):theTarget.getAttribute("openedText");
	// toggle tooltip
	theTarget.setAttribute("title",isOpen?theTarget.getAttribute("closedTip"):theTarget.getAttribute("openedTip"));

	// deferred rendering (if needed)
	if (theSlider.getAttribute("rendered")=="false") {
		if (config.options.chkDebugLazySliderRender)
			alert("rendering '"+theLabel+"':\n\n"+theSlider.getAttribute("raw"));
		var place=theSlider;
		if (theSlider.getAttribute("blockquote")=="true")
			place=createTiddlyElement(place,"blockquote");
		wikify(theSlider.getAttribute("raw"),place);
		theSlider.setAttribute("rendered","true");
	}
	// show/hide the slider
	if(config.options.chkAnimate && (theSlider.className!='floatingPanel' || config.options.chkFloatingSlidersAnimate))
		anim.startAnimating(new Slider(theSlider,!isOpen,e.shiftKey || e.altKey,"none"));
	else
		theSlider.style.display = isOpen ? "none" : "block";
	// reset to default width (might have been changed via plugin code)
	theSlider.style.width=theSlider.defaultPanelWidth;
	// align floater panel position with target button
	if (!isOpen && window.adjustSliderPos) window.adjustSliderPos(theSlider.parentNode,theTarget,theSlider,theSlider.className);
	// if showing panel, set focus to first 'focus-able' element in panel
	if (theSlider.style.display!="none") {
		var ctrls=theSlider.getElementsByTagName("*");
		for (var c=0; c<ctrls.length; c++) {
			var t=ctrls[c].tagName.toLowerCase();
			if ((t=="input" && ctrls[c].type!="hidden") || t=="textarea" || t=="select")
				{ ctrls[c].focus(); break; }
		}
	}
	var cookie=theTarget.sliderCookie;
	if (cookie && cookie.length) {
		config.options[cookie]=!isOpen;
		if (config.options[cookie]!=theTarget.defOpen)
			saveOptionCookie(cookie);
		else { // remove cookie if slider is in default display state
			var ex=new Date(); ex.setTime(ex.getTime()-1000);
			document.cookie = cookie+"=novalue; path=/; expires="+ex.toGMTString();
		}
	}
	// prevent SHIFT-CLICK from being processed by browser (opens blank window... yuck!)
	// but allow plain click to bubble up to page background (to dismiss open popup, if any)
	if (e.shiftKey) { e.cancelBubble=true; if (e.stopPropagation) e.stopPropagation(); }
	return false;
}
//}}}

//{{{
// click in document background closes transient panels 
document.nestedSliders_savedOnClick=document.onclick;
document.onclick=function(ev) { if (!ev) var ev=window.event; var target=resolveTarget(ev);
	// call original click handler
	if (document.nestedSliders_savedOnClick)
		var retval=document.nestedSliders_savedOnClick.apply(this,arguments);
	// if click was inside transient panel (or something contained by a transient panel)... leave it alone
	var p=target;
	while (p)
		if ((p.className=="floatingPanel"||p.className=="sliderPanel")&&p.getAttribute("transient")=="true") break;
		else p=p.parentNode;
	if (p) return retval;
	// otherwise, find and close all transient panels...
	var all=document.all?document.all:document.getElementsByTagName("DIV");
	for (var i=0; i<all.length; i++) {
		 // if it is not a transient panel, or the click was on the button that opened this panel, don't close it.
		if (all[i].getAttribute("transient")!="true" || all[i].button==target) continue;
		// otherwise, if the panel is currently visible, close it by clicking it's button
		if (all[i].style.display!="none") window.onClickNestedSlider({target:all[i].button}) 
	}
	return retval;
};
//}}}

//{{{
// adjust floating panel position based on button position
if (window.adjustSliderPos==undefined) window.adjustSliderPos=function(place,btn,panel,panelClass) {
	if (panelClass=="floatingPanel") {
		var left=0;
		var top=btn.offsetHeight; 
		if (place.style.position!="relative") {
			var left=findPosX(btn);
			var top=findPosY(btn)+btn.offsetHeight;
			var p=place; while (p && p.className!='floatingPanel') p=p.parentNode;
			if (p) { left-=findPosX(p); top-=findPosY(p); }
		}
		if (findPosX(btn)+panel.offsetWidth > getWindowWidth())  // adjust position to stay inside right window edge
			left-=findPosX(btn)+panel.offsetWidth-getWindowWidth()+15; // add extra 15px 'fudge factor'
		panel.style.left=left+"px"; panel.style.top=top+"px";
	}
}

function getWindowWidth() {
	if(document.width!=undefined)
		return document.width; // moz (FF)
	if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		return document.documentElement.clientWidth; // IE6
	if(document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		return document.body.clientWidth; // IE4
	if(window.innerWidth!=undefined)
		return window.innerWidth; // IE - general
	return 0; // unknown
}
//}}}

//{{{
// TW2.1 and earlier:
// hijack Slider animation handler 'stop' handler so overflow is visible after animation has completed
Slider.prototype.coreStop = Slider.prototype.stop;
Slider.prototype.stop = function()
	{ this.coreStop.apply(this,arguments); this.element.style.overflow = "visible"; }

// TW2.2+
// hijack Morpher animation handler 'stop' handler so overflow is visible after animation has completed
if (version.major+.1*version.minor+.01*version.revision>=2.2) {
	Morpher.prototype.coreStop = Morpher.prototype.stop;
	Morpher.prototype.stop = function()
		{ this.coreStop.apply(this,arguments); this.element.style.overflow = "visible"; }
}
//}}}
a <nowiki>TiddlyWiki</nowiki> rendering of the [[IsarMathLib| http://www.nongnu.org/isarmathlib/]]  project
Tiddly Formal Math
$a \cdot b = b\cdot a$+++[proof]>
''show'' $a \cdot b = b\cdot a$ ''using'' +++^[commutative_assumption |  in Group_ZF.thy ]
                                                                      $\forall x,y \in G.\  x\cdot y = y \cdot x $  ===

''qed''
===

+++
content
{{indent{ indented slider content }}}
normal slider content
===



{{indent{ text }}} indented +++[proof]>
{{indent{ slider}}} multiline text 
{{indent{ content }}} inside indentation ===

{{indent{ indented, }}} but outside of slider
 
normal text

 ''theory'' Topology_ZF ''imports'' [[ZF1]] [[Finite_ZF]] [[Fol1]]

 ''begin
'' 
This theory file provides basic definitions and properties of topology, open and closed sets, closure and boundary.

!Basic definitions and properties

A typical textbook defines a topology on a set $X$ as a collection $T$ of subsets of $X$ such that $X\in T$, $\emptyset \in T$ and $T$ is closed with respect to arbitrary unions and intersection of two sets. One can notice here that since we always have $\bigcup T = X$, the set on which the topology is defined (the "carrier" of the topology) can always be constructed from the topology itself and is superfluous in the definition. Hence, we define a topology as a collection of sets that contains the empty set and is closed under arbitrary unions and intersections of two sets, without any mention of the set on which the topology is defined. Recall that $ Pow(T)$ is the powerset of $T$, so that if $M\in$$ Pow(T)$ then $M$ is a subset of $T$.

Topology is a collection of sets that contains the empty set and is closed under arbitrary unions and intersections of two sets.

 ''Definition
'' $ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$

We define interior of a set $A$ as the union of all open sets contained in $A$. We use $ Interior(A,T)$ to denote the interior of A.

 ''Definition
'' $ Interior(A,T) \equiv  \bigcup  \{U\in T.\  U \subseteq  A\}$

A set is closed if it is contained in the carrier of topology and its complement is open.

 ''Definition
'' $ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$

To prove various properties of closure we will often use the collection of closed sets that contain a given set $A$. Such collection does not have a separate name in informal math. We will call it $ ClosedCovers(A,T)$.

 ''Definition
'' $ ClosedCovers(A,T) \equiv  \{D \in  Pow(\bigcup T).\  D \text{ is closed in } T \wedge  A\subseteq D\}$

The closure of a set $A$ is defined as the intersection of the collection of closed sets that contain $A$.

 ''Definition
'' $ Closure(A,T) \equiv  \bigcap  ClosedCovers(A,T)$

We also define boundary of a set as the intersection of its closure with the closure of the complement (with respect to the carrier).

 ''Definition
'' $ Boundary(A,T) \equiv  Closure(A,T) \cap  Closure(\bigcup T - A,T)$

A set $K$ is compact if for every collection of open sets that covers $K$ we can choose a finite one that still covers the set. Recall that $ FinPow(M)$ is the collection of finite subsets of $M$ (finite powerset of $M$), defined in IsarMathLib's //Finite_ZF// theory.

 ''Definition
'' $ K \text{ is compact in } T \equiv  (K \subseteq  \bigcup T \wedge  $
$  (\forall  M\in Pow(T).\  K \subseteq  \bigcup M \longrightarrow  (\exists  N \in  FinPow(M).\  K \subseteq  \bigcup N)))$

A basic example of a topology: the powerset of any set is a topology.

 ''lemma''  <nowiki>Pow_is_top</nowiki>:
 ''   shows '' $ Pow(X) \text{ is a topology }$+++[proof ]>
 ''have''  $ 0 \in  Pow(X)$ 
 ''moreover''   ''have''  $ \forall A\in Pow(Pow(X)).\  \bigcup A \in  Pow(X)$ 
 ''moreover''   ''have''  $ \forall U\in Pow(X).\  \forall V\in Pow(X).\  U\cap V \in  Pow(X)$ 
 ''ultimately ''  ''show''  $ Pow(X) \text{ is a topology }$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''qed'' === 

The intersection of any nonempty collection of topologies on a set $X$ is a topology.

 ''lemma''  <nowiki>Inter_tops_is_top</nowiki>:
 ''   assumes '' A1: $ \mathcal{M}  \neq  0$ ''and '' A2: $ \forall T\in \mathcal{M} .\  T \text{ is a topology }$ ''   shows '' $ (\bigcap \mathcal{M} ) \text{ is a topology }$+++[proof ]>
 ''from '' A1, A2  ''have''  $ 0 \in  \bigcap \mathcal{M} $ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''moreover''  
 ''{ ''  ''fix '' $ A$
 ''assume '' $ A\in Pow(\bigcap \mathcal{M} )$
 ''with '' A1  ''have''  $ \forall T\in \mathcal{M} .\  A\in Pow(T)$ 
 ''with '' A1, A2  ''have''  $ \bigcup A \in  \bigcap \mathcal{M} $ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 '' }'' 
 ''then ''  ''have''  $ \forall A.\  A\in Pow(\bigcap \mathcal{M} ) \longrightarrow  \bigcup A \in  \bigcap \mathcal{M} $ 
 ''hence''  $ \forall A\in Pow(\bigcap \mathcal{M} ).\  \bigcup A \in  \bigcap \mathcal{M} $
 ''moreover''  
 ''{ ''  ''fix '' $ U$ $ V$
 ''assume '' $ U \in  \bigcap \mathcal{M} $ ''and '' $ V \in  \bigcap \mathcal{M} $
 ''then ''  ''have''  $ \forall T\in \mathcal{M} .\  U \in  T \wedge  V \in  T$ 
 ''with '' A1, A2  ''have''  $ \forall T\in \mathcal{M} .\  U\cap V \in  T$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 '' }'' 
 ''then ''  ''have''  $ \forall  U \in  \bigcap \mathcal{M} .\  \forall  V \in  \bigcap \mathcal{M} .\  U\cap V \in  \bigcap \mathcal{M} $ 
 ''ultimately ''  ''show''  $ (\bigcap \mathcal{M} ) \text{ is a topology }$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''qed'' === 

We will now introduce some notation. In Isar, this is done by definining a "locale". Locale is kind of a context that holds some assumptions and notation used in all theorems proven in it. In the locale (context) below called //topology0// we assume that $T$ is a topology. The interior of the set $A$ (with respect to the topology in the context) is denoted $ int(A)$. The closure of a set $A\subseteq \bigcup T$ is denoted $ cl(A)$ and the boundary is $ \partial A$.

 ''Locale '' topology0
 ''fixes '' $ T$
 ''assumes '' topSpaceAssum: $ T \text{ is a topology }$
 ''fixes '' $ int$
 ''defines '' $ int(A) \equiv  Interior(A,T)$
 ''fixes '' $ cl$
 ''defines '' $ cl(A) \equiv  Closure(A,T)$
 ''fixes '' $ boundary$
 ''defines '' $ \partial A \equiv  Boundary(A,T)$


Intersection of a finite nonempty collection of open sets is open.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>fin_inter_open_open</nowiki>:
 ''   assumes '' $ N\neq 0$,  $ N \in  FinPow(T)$ ''   shows '' $ \bigcap N \in  T$ ''using''  <nowiki>topSpaceAssum</nowiki> ,  <nowiki>assms</nowiki> ,  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$===  ,  +++^[inter_two_inter_fin | Finite_ZF ]...  ''lemma''  <nowiki>inter_two_inter_fin</nowiki>:  ''assumes '' $ \forall V\in T.\  \forall W\in T.\  V \cap  W \in  T$  ''and'' $ N \neq  0$  ''and'' $ N \in  FinPow(T)$  '' shows '' $ (\bigcap N \in  T)$ === 

Having a topology $T$ and a set $X$ we can define the induced topology as the one consisting of the intersections of $X$ with sets from $T$. The notion of a collection restricted to a set is defined in ZF1.thy.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_1_L4</nowiki>:
 ''   shows '' $ (T \text{ restricted to } X) \text{ is a topology }$+++[proof ]>
 ''let '' $ S = T \text{ restricted to } X$
 ''from '' topSpaceAssum  ''have''  $ 0 \in  S$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$===  ,  +++^[RestrictedTo_def | ZF1 ]... Definition of <nowiki>RestrictedTo</nowiki>:
$ M \text{ restricted to } X \equiv  \{X \cap  A .\  A \in  M\}$=== 
 ''moreover''   ''have''  $ \forall A\in Pow(S).\  \bigcup A \in  S$+++[proof ]>
 ''fix '' $ A$
 ''assume '' A1: $ A\in Pow(S)$
 ''have''  $ \forall V\in A.\  \bigcup  \{U \in  T.\  V = U\cap X\} \in  T$+++[proof ]>
 ''{ ''  ''fix '' $ V$
 ''let '' $ M = \{U \in  T.\  V = U\cap X\}$
 ''have''  $ M \in  Pow(T)$ 
 ''with '' topSpaceAssum  ''have''  $ \bigcup M \in  T$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 '' }'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''hence''  $ \{\bigcup \{U\in T.\  V = U\cap X\}.\ V\in  A\} \subseteq  T$
 ''with '' topSpaceAssum  ''have''  $ (\bigcup V\in A.\  \bigcup \{U\in T.\  V = U\cap X\}) \in  T$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''then ''  ''have''  $ (\bigcup V\in A.\  \bigcup \{U\in T.\  V = U\cap X\})\cap  X \in  S$ ''using''  +++^[RestrictedTo_def | ZF1 ]... Definition of <nowiki>RestrictedTo</nowiki>:
$ M \text{ restricted to } X \equiv  \{X \cap  A .\  A \in  M\}$=== 
 ''moreover''   ''from '' A1  ''have''  $ \forall V\in A.\  \exists U\in T.\  V = U\cap X$ ''using''  +++^[RestrictedTo_def | ZF1 ]... Definition of <nowiki>RestrictedTo</nowiki>:
$ M \text{ restricted to } X \equiv  \{X \cap  A .\  A \in  M\}$=== 
 ''hence''  $ (\bigcup V\in A.\  \bigcup \{U\in T.\  V = U\cap X\})\cap X = \bigcup A$
 ''ultimately ''  ''show''  $ \bigcup A \in  S$ 
 ''qed'' === 
 ''moreover''   ''have''  $ \forall U\in S.\  \forall V\in S.\  U\cap V \in  S$+++[proof ]>
 ''{ ''  ''fix '' $ U$ $ V$
 ''assume '' $ U\in S$,  $ V\in S$
 ''then ''  ''obtain '' $ U_1$ $ V_1$ ''where '' $ U_1 \in  T \wedge  U = U_1\cap X$ ''and '' $ V_1 \in  T \wedge  V = V_1\cap X$ ''using''  +++^[RestrictedTo_def | ZF1 ]... Definition of <nowiki>RestrictedTo</nowiki>:
$ M \text{ restricted to } X \equiv  \{X \cap  A .\  A \in  M\}$=== 
 ''with '' topSpaceAssum  ''have''  $ U_1\cap V_1 \in  T$ ''and '' $ U\cap V = (U_1\cap V_1)\cap X$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''then ''  ''have''  $  U\cap V \in  S$ ''using''  +++^[RestrictedTo_def | ZF1 ]... Definition of <nowiki>RestrictedTo</nowiki>:
$ M \text{ restricted to } X \equiv  \{X \cap  A .\  A \in  M\}$=== 
 '' }'' 
 ''thus''  $ \forall U\in S.\  \forall  V\in S.\  U\cap V \in  S$
 ''qed'' === 
 ''ultimately ''  ''show''  $ S \text{ is a topology }$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''qed'' === 


!Interior of a set

In section we show basic properties of the interior of a set.

Interior of a set $A$ is contained in $A$.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L1</nowiki>:
 ''   shows '' $ int(A) \subseteq  A$ ''using''  +++^[Interior_def | Topology_ZF ]... Definition of <nowiki>Interior</nowiki>:
$ Interior(A,T) \equiv  \bigcup  \{U\in T.\  U \subseteq  A\}$=== 

Interior is open.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L2</nowiki>:
 ''   shows '' $ int(A) \in  T$+++[proof ]>
 ''have''  $ \{U\in T.\  U\subseteq A\} \in  Pow(T)$ 
 ''with '' topSpaceAssum  ''show''  $ int(A) \in  T$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$===  ,  +++^[Interior_def | Topology_ZF ]... Definition of <nowiki>Interior</nowiki>:
$ Interior(A,T) \equiv  \bigcup  \{U\in T.\  U \subseteq  A\}$=== 
 ''qed'' === 

A set is open iff it is equal to its interior.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L3</nowiki>:
 ''   shows '' $ U\in T \longleftrightarrow  int(U) = U$+++[proof ]>
 ''assume '' $ U\in T$
 ''then ''  ''show''  $ int(U) = U$ ''using''  +++^[Interior_def | Topology_ZF ]... Definition of <nowiki>Interior</nowiki>:
$ Interior(A,T) \equiv  \bigcup  \{U\in T.\  U \subseteq  A\}$=== 
 ''next '' 
 ''assume '' A1: $ int(U) = U$
 ''have''  $ int(U) \in  T$ ''using''  +++^[Top_2_L2 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L2</nowiki>:  '' shows '' $ int(A) \in  T$ === 
 ''with '' A1  ''show''  $ U\in T$ 
 ''qed'' === 

Interior of the interior is the interior.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L4</nowiki>:
 ''   shows '' $ int(int(A)) = int(A)$+++[proof ]>
 ''let '' $ U = int(A)$
 ''from '' topSpaceAssum  ''have''  $ U\in T$ ''using''  +++^[Top_2_L2 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L2</nowiki>:  '' shows '' $ int(A) \in  T$ === 
 ''then ''  ''show''  $ int(int(A)) = int(A)$ ''using''  +++^[Top_2_L3 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L3</nowiki>:  '' shows '' $ U\in T \longleftrightarrow  int(U) = U$ === 
 ''qed'' === 

Interior of a bigger set is bigger.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>interior_mono</nowiki>:
 ''   assumes '' A1: $ A\subseteq B$ ''   shows '' $ int(A) \subseteq  int(B)$+++[proof ]>
 ''from '' A1  ''have''  $ \forall  U\in T.\  (U\subseteq A \longrightarrow  U\subseteq B)$ 
 ''then ''  ''show''  $ int(A) \subseteq  int(B)$ ''using''  +++^[Interior_def | Topology_ZF ]... Definition of <nowiki>Interior</nowiki>:
$ Interior(A,T) \equiv  \bigcup  \{U\in T.\  U \subseteq  A\}$=== 
 ''qed'' === 

An open subset of any set is a subset of the interior of that set.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L5</nowiki>:
 ''   assumes '' $ U\subseteq A$ ''and '' $ U\in T$ ''   shows '' $ U \subseteq  int(A)$ ''using''  <nowiki>assms</nowiki> ,  +++^[Interior_def | Topology_ZF ]... Definition of <nowiki>Interior</nowiki>:
$ Interior(A,T) \equiv  \bigcup  \{U\in T.\  U \subseteq  A\}$=== 

If a point of a set has an open neighboorhood contained in the set, then the point belongs to the interior of the set.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L6</nowiki>:
 ''   assumes '' $ \exists U\in T.\  (x\in U \wedge  U\subseteq A)$ ''   shows '' $ x \in  int(A)$ ''using''  <nowiki>assms</nowiki> ,  +++^[Interior_def | Topology_ZF ]... Definition of <nowiki>Interior</nowiki>:
$ Interior(A,T) \equiv  \bigcup  \{U\in T.\  U \subseteq  A\}$=== 

A set is open iff its every point has a an open neighbourhood contained in the set. We will formulate this statement as two lemmas (implication one way and the other way). The lemma below shows that if a set is open then every point has a an open neighbourhood contained in the set.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>open_open_neigh</nowiki>:
 ''   assumes '' A1: $ V\in T$ ''   shows '' $ \forall x\in V.\  \exists U\in T.\  (x\in U \wedge  U\subseteq V)$+++[proof ]>
 ''from '' A1  ''have''  $ \forall x\in V.\  V\in T \wedge  x \in  V \wedge  V \subseteq  V$ 
 ''thus''  $ thesis$
 ''qed'' === 

If every point of a set has a an open neighbourhood contained in the set then the set is open.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>open_neigh_open</nowiki>:
 ''   assumes '' A1: $ \forall x\in V.\  \exists U\in T.\  (x\in U \wedge  U\subseteq V)$ ''   shows '' $ V\in T$+++[proof ]>
 ''from '' A1  ''have''  $ V = int(V)$ ''using''  +++^[Top_2_L1 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L1</nowiki>:  '' shows '' $ int(A) \subseteq  A$ ===  ,  +++^[Top_2_L6 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L6</nowiki>:  ''assumes '' $ \exists U\in T.\  (x\in U \wedge  U\subseteq A)$  '' shows '' $ x \in  int(A)$ === 
 ''then ''  ''show''  $ V\in T$ ''using''  +++^[Top_2_L3 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L3</nowiki>:  '' shows '' $ U\in T \longleftrightarrow  int(U) = U$ === 
 ''qed'' === 


!Closed sets, closure, boundary.

This section is devoted to closed sets and properties of the closure and boundary operators.

The carrier of the space is closed.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L1</nowiki>:
 ''   shows '' $ (\bigcup T) \text{ is closed in } T$+++[proof ]>
 ''have''  $ \bigcup T - \bigcup T = 0$ 
 ''with '' topSpaceAssum  ''have''  $ \bigcup T - \bigcup T \in  T$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''qed'' === 

Empty set is closed.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L2</nowiki>:
 ''   shows '' $ 0 \text{ is closed in } T$ ''using''  <nowiki>topSpaceAssum</nowiki> ,  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$===  ,  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 

The collection of closed covers of a subset of the carrier of topology is never empty. This is good to know, as we want to intersect this collection to get the closure.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L3</nowiki>:
 ''   assumes '' A1: $ A \subseteq  \bigcup T$ ''   shows '' $ ClosedCovers(A,T) \neq  0$+++[proof ]>
 ''from '' A1  ''have''  $ \bigcup T \in  ClosedCovers(A,T)$ ''using''  +++^[ClosedCovers_def | Topology_ZF ]... Definition of <nowiki>ClosedCovers</nowiki>:
$ ClosedCovers(A,T) \equiv  \{D \in  Pow(\bigcup T).\  D \text{ is closed in } T \wedge  A\subseteq D\}$===  ,  +++^[Top_3_L1 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L1</nowiki>:  '' shows '' $ (\bigcup T) \text{ is closed in } T$ === 
 ''thus''  $ thesis$
 ''qed'' === 

Intersection of a nonempty family of closed sets is closed.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L4</nowiki>:
 ''   assumes '' A1: $ K\neq 0$ ''and '' A2: $ \forall D\in K.\  D \text{ is closed in } T$ ''   shows '' $ (\bigcap K) \text{ is closed in } T$+++[proof ]>
 ''from '' A2  ''have''  I: $ \forall D\in K.\  (D \subseteq  \bigcup T \wedge  (\bigcup T - D)\in  T)$ ''using''  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''then ''  ''have''  $ \{\bigcup T - D.\  D\in  K\} \subseteq  T$ 
 ''with '' topSpaceAssum  ''have''  $ (\bigcup  \{\bigcup T - D.\  D\in  K\}) \in  T$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''moreover''   ''from '' A1  ''have''  $ \bigcup  \{\bigcup T - D.\  D\in  K\} = \bigcup T - \bigcap K$ 
 ''moreover''   ''from '' A1, I  ''have''  $ \bigcap K \subseteq  \bigcup T$ 
 ''ultimately ''  ''show''  $ (\bigcap K) \text{ is closed in } T$ ''using''  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''qed'' === 

The union and intersection of two closed sets are closed.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L5</nowiki>:
 ''   assumes '' A1: $ D_1 \text{ is closed in } T$,  $ D_2 \text{ is closed in } T$ ''   shows '' $ (D_1\cap D_2) \text{ is closed in } T$,  $ (D_1\cup D_2) \text{ is closed in } T$+++[proof ]>
 ''have''  $ \{D_1,D_2\} \neq  0$ 
 ''with '' A1  ''have''  $ (\bigcap  \{D_1,D_2\}) \text{ is closed in } T$ ''using''  +++^[Top_3_L4 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L4</nowiki>:  ''assumes '' $ K\neq 0$  ''and'' $ \forall D\in K.\  D \text{ is closed in } T$  '' shows '' $ (\bigcap K) \text{ is closed in } T$ === 
 ''thus''  $ (D_1\cap D_2) \text{ is closed in } T$
 ''from '' topSpaceAssum, A1  ''have''  $ (\bigcup T - D_1) \cap  (\bigcup T - D_2) \in  T$ ''using''  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$===  ,  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''moreover''   ''have''  $ (\bigcup T - D_1) \cap  (\bigcup T - D_2) = \bigcup T - (D_1 \cup  D_2)$ 
 ''moreover''   ''from '' A1  ''have''  $ D_1 \cup  D_2 \subseteq  \bigcup T$ ''using''  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''ultimately ''  ''show''  $ (D_1\cup D_2) \text{ is closed in } T$ ''using''  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''qed'' === 

Finite union of closed sets is closed. To understand the proof recall that $D\in$$ Pow(\bigcup T)$ means that $D$ is a subset of the carrier of the topology.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>fin_union_cl_is_cl</nowiki>:
 ''   assumes '' A1: $ N \in  FinPow(\{D\in Pow(\bigcup T).\  D \text{ is closed in } T\})$ ''   shows '' $ (\bigcup N) \text{ is closed in } T$+++[proof ]>
 ''let '' $ C = \{D\in Pow(\bigcup T).\  D \text{ is closed in } T\}$
 ''have''  $ 0\in C$ ''using''  +++^[Top_3_L2 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L2</nowiki>:  '' shows '' $ 0 \text{ is closed in } T$ === 
 ''moreover''   ''have''  $ \forall A\in C.\  \forall B\in C.\  A\cup B \in  C$ ''using''  +++^[Top_3_L5 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L5</nowiki>:  ''assumes '' $ D_1 \text{ is closed in } T$,   $ D_2 \text{ is closed in } T$  '' shows '' $ (D_1\cap D_2) \text{ is closed in } T$,   $ (D_1\cup D_2) \text{ is closed in } T$ === 
 ''moreover''   ''note '' A1
 ''ultimately ''  ''have''  $ \bigcup N \in  C$ ''   by (rule '' +++^[union_two_union_fin | Finite_ZF ]...  ''lemma''  <nowiki>union_two_union_fin</nowiki>:  ''assumes '' $ 0 \in  C$  ''and'' $ \forall A\in C.\  \forall B\in C.\  A\cup B \in  C$  ''and'' $ N \in  FinPow(C)$  '' shows '' $ \bigcup N \in  C$ ===  '')'' 
 ''thus''  $ (\bigcup N) \text{ is closed in } T$
 ''qed'' === 

Closure of a set is closed.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_is_closed</nowiki>:
 ''   assumes '' $ A \subseteq  \bigcup T$ ''   shows '' $ cl(A) \text{ is closed in } T$ ''using''  <nowiki>assms</nowiki> ,  +++^[Closure_def | Topology_ZF ]... Definition of <nowiki>Closure</nowiki>:
$ Closure(A,T) \equiv  \bigcap  ClosedCovers(A,T)$===  ,  +++^[Top_3_L3 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L3</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ ClosedCovers(A,T) \neq  0$ ===  ,  +++^[ClosedCovers_def | Topology_ZF ]... Definition of <nowiki>ClosedCovers</nowiki>:
$ ClosedCovers(A,T) \equiv  \{D \in  Pow(\bigcup T).\  D \text{ is closed in } T \wedge  A\subseteq D\}$===  ,  +++^[Top_3_L4 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L4</nowiki>:  ''assumes '' $ K\neq 0$  ''and'' $ \forall D\in K.\  D \text{ is closed in } T$  '' shows '' $ (\bigcap K) \text{ is closed in } T$ === 

Closure of a bigger sets is bigger.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>top_closure_mono</nowiki>:
 ''   assumes '' A1: $ A \subseteq  \bigcup T$,  $ B \subseteq  \bigcup T$ ''and '' A2: $ A\subseteq B$ ''   shows '' $ cl(A) \subseteq  cl(B)$+++[proof ]>
 ''from '' A2  ''have''  $ ClosedCovers(B,T)\subseteq  ClosedCovers(A,T)$ ''using''  +++^[ClosedCovers_def | Topology_ZF ]... Definition of <nowiki>ClosedCovers</nowiki>:
$ ClosedCovers(A,T) \equiv  \{D \in  Pow(\bigcup T).\  D \text{ is closed in } T \wedge  A\subseteq D\}$=== 
 ''with '' A1  ''show''  $ thesis$ ''using''  +++^[Top_3_L3 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L3</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ ClosedCovers(A,T) \neq  0$ ===  ,  +++^[Closure_def | Topology_ZF ]... Definition of <nowiki>Closure</nowiki>:
$ Closure(A,T) \equiv  \bigcap  ClosedCovers(A,T)$=== 
 ''qed'' === 

Boundary of a set is closed.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>boundary_closed</nowiki>:
 ''   assumes '' A1: $ A \subseteq  \bigcup T$ ''   shows '' $ \partial A \text{ is closed in } T$+++[proof ]>
 ''from '' A1  ''have''  $ \bigcup T - A \subseteq  \bigcup T$ 
 ''with '' A1  ''show''  $ \partial A \text{ is closed in } T$ ''using''  +++^[cl_is_closed | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_is_closed</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ cl(A) \text{ is closed in } T$ ===  ,  +++^[Top_3_L5 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L5</nowiki>:  ''assumes '' $ D_1 \text{ is closed in } T$,   $ D_2 \text{ is closed in } T$  '' shows '' $ (D_1\cap D_2) \text{ is closed in } T$,   $ (D_1\cup D_2) \text{ is closed in } T$ ===  ,  +++^[Boundary_def | Topology_ZF ]... Definition of <nowiki>Boundary</nowiki>:
$ Boundary(A,T) \equiv  Closure(A,T) \cap  Closure(\bigcup T - A,T)$=== 
 ''qed'' === 

A set is closed iff it is equal to its closure.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L8</nowiki>:
 ''   assumes '' A1: $ A \subseteq  \bigcup T$ ''   shows '' $ A \text{ is closed in } T \longleftrightarrow  cl(A) = A$+++[proof ]>
 ''assume '' $ A \text{ is closed in } T$
 ''with '' A1  ''show''  $ cl(A) = A$ ''using''  +++^[Closure_def | Topology_ZF ]... Definition of <nowiki>Closure</nowiki>:
$ Closure(A,T) \equiv  \bigcap  ClosedCovers(A,T)$===  ,  +++^[ClosedCovers_def | Topology_ZF ]... Definition of <nowiki>ClosedCovers</nowiki>:
$ ClosedCovers(A,T) \equiv  \{D \in  Pow(\bigcup T).\  D \text{ is closed in } T \wedge  A\subseteq D\}$=== 
 ''next '' 
 ''assume '' $ cl(A) = A$
 ''then ''  ''have''  $ \bigcup T - A = \bigcup T - cl(A)$ 
 ''with '' A1  ''show''  $ A \text{ is closed in } T$ ''using''  +++^[cl_is_closed | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_is_closed</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ cl(A) \text{ is closed in } T$ ===  ,  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''qed'' === 

Complement of an open set is closed.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L9</nowiki>:
 ''   assumes '' A1: $ A\in T$ ''   shows '' $ (\bigcup T - A) \text{ is closed in } T$+++[proof ]>
 ''from '' topSpaceAssum, A1  ''have''  $ \bigcup T - (\bigcup T - A) = A$ ''and '' $ \bigcup T - A \subseteq  \bigcup T$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''with '' A1  ''show''  $ (\bigcup T - A) \text{ is closed in } T$ ''using''  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''qed'' === 

A set is contained in its closure.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_contains_set</nowiki>:
 ''   assumes '' $ A \subseteq  \bigcup T$ ''   shows '' $ A \subseteq  cl(A)$ ''using''  <nowiki>assms</nowiki> ,  +++^[Top_3_L1 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L1</nowiki>:  '' shows '' $ (\bigcup T) \text{ is closed in } T$ ===  ,  +++^[ClosedCovers_def | Topology_ZF ]... Definition of <nowiki>ClosedCovers</nowiki>:
$ ClosedCovers(A,T) \equiv  \{D \in  Pow(\bigcup T).\  D \text{ is closed in } T \wedge  A\subseteq D\}$===  ,  +++^[Top_3_L3 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L3</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ ClosedCovers(A,T) \neq  0$ ===  ,  +++^[Closure_def | Topology_ZF ]... Definition of <nowiki>Closure</nowiki>:
$ Closure(A,T) \equiv  \bigcap  ClosedCovers(A,T)$=== 

Closure of a subset of the carrier is a subset of the carrier and closure of the complement is the complement of the interior.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L11</nowiki>:
 ''   assumes '' A1: $ A \subseteq  \bigcup T$ ''   shows '' $ cl(A) \subseteq  \bigcup T$,  $ cl(\bigcup T - A) = \bigcup T - int(A)$+++[proof ]>
 ''from '' A1  ''show''  $ cl(A) \subseteq  \bigcup T$ ''using''  +++^[Top_3_L1 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L1</nowiki>:  '' shows '' $ (\bigcup T) \text{ is closed in } T$ ===  ,  +++^[Closure_def | Topology_ZF ]... Definition of <nowiki>Closure</nowiki>:
$ Closure(A,T) \equiv  \bigcap  ClosedCovers(A,T)$===  ,  +++^[ClosedCovers_def | Topology_ZF ]... Definition of <nowiki>ClosedCovers</nowiki>:
$ ClosedCovers(A,T) \equiv  \{D \in  Pow(\bigcup T).\  D \text{ is closed in } T \wedge  A\subseteq D\}$=== 
 ''from '' A1  ''have''  $ \bigcup T - A \subseteq  \bigcup T - int(A)$ ''using''  +++^[Top_2_L1 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L1</nowiki>:  '' shows '' $ int(A) \subseteq  A$ === 
 ''moreover''   ''have''  I: $ \bigcup T - int(A) \subseteq  \bigcup T$,  $ \bigcup T - A \subseteq  \bigcup T$ 
 ''ultimately ''  ''have''  $ cl(\bigcup T - A) \subseteq  cl(\bigcup T - int(A))$ ''using''  +++^[top_closure_mono | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>top_closure_mono</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$,   $ B \subseteq  \bigcup T$  ''and'' $ A\subseteq B$  '' shows '' $ cl(A) \subseteq  cl(B)$ === 
 ''moreover''   ''from '' I  ''have''  $ (\bigcup T - int(A)) \text{ is closed in } T$ ''using''  +++^[Top_2_L2 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L2</nowiki>:  '' shows '' $ int(A) \in  T$ ===  ,  +++^[Top_3_L9 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L9</nowiki>:  ''assumes '' $ A\in T$  '' shows '' $ (\bigcup T - A) \text{ is closed in } T$ === 
 ''with '' I  ''have''  $ cl((\bigcup T) - int(A)) = \bigcup T - int(A)$ ''using''  +++^[Top_3_L8 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L8</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ A \text{ is closed in } T \longleftrightarrow  cl(A) = A$ === 
 ''ultimately ''  ''have''  $ cl(\bigcup T - A) \subseteq  \bigcup T - int(A)$ 
 ''moreover''   ''from '' I  ''have''  $ \bigcup T - A \subseteq  cl(\bigcup T - A)$ ''using''  +++^[cl_contains_set | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_contains_set</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ A \subseteq  cl(A)$ === 
 ''hence''  $ \bigcup T - cl(\bigcup T - A) \subseteq  A$ ''and '' $ \bigcup T - A \subseteq  \bigcup T$
 ''then ''  ''have''  $ \bigcup T - cl(\bigcup T - A) \subseteq  int(A)$ ''using''  +++^[cl_is_closed | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_is_closed</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ cl(A) \text{ is closed in } T$ ===  ,  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$===  ,  +++^[Top_2_L5 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_2_L5</nowiki>:  ''assumes '' $ U\subseteq A$  ''and'' $ U\in T$  '' shows '' $ U \subseteq  int(A)$ === 
 ''hence''  $ \bigcup T - int(A) \subseteq   cl(\bigcup T - A)$
 ''ultimately ''  ''show''  $ cl(\bigcup T - A) = \bigcup T - int(A)$ 
 ''qed'' === 

Boundary of a set is the closure of the set minus the interior of the set.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L12</nowiki>:
 ''   assumes '' A1: $ A \subseteq  \bigcup T$ ''   shows '' $ \partial A = cl(A) - int(A)$+++[proof ]>
 ''from '' A1  ''have''  $ \partial A = cl(A) \cap  (\bigcup T - int(A))$ ''using''  +++^[Boundary_def | Topology_ZF ]... Definition of <nowiki>Boundary</nowiki>:
$ Boundary(A,T) \equiv  Closure(A,T) \cap  Closure(\bigcup T - A,T)$===  ,  +++^[Top_3_L11 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L11</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ cl(A) \subseteq  \bigcup T$,   $ cl(\bigcup T - A) = \bigcup T - int(A)$ === 
 ''moreover''   ''from '' A1  ''have''  $ cl(A) \cap  (\bigcup T - int(A)) = cl(A) - int(A)$ ''using''  +++^[Top_3_L11 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L11</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ cl(A) \subseteq  \bigcup T$,   $ cl(\bigcup T - A) = \bigcup T - int(A)$ === 
 ''ultimately ''  ''show''  $ \partial A = cl(A) - int(A)$ 
 ''qed'' === 

If a set $A$ is contained in a closed set $B$, then the closure of $A$ is contained in $B$.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L13</nowiki>:
 ''   assumes '' A1: $ B \text{ is closed in } T$,  $ A\subseteq B$ ''   shows '' $ cl(A) \subseteq  B$+++[proof ]>
 ''from '' A1  ''have''  $ B \subseteq  \bigcup T$ ''using''  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''with '' A1  ''show''  $ cl(A) \subseteq  B$ ''using''  +++^[ClosedCovers_def | Topology_ZF ]... Definition of <nowiki>ClosedCovers</nowiki>:
$ ClosedCovers(A,T) \equiv  \{D \in  Pow(\bigcup T).\  D \text{ is closed in } T \wedge  A\subseteq D\}$===  ,  +++^[Closure_def | Topology_ZF ]... Definition of <nowiki>Closure</nowiki>:
$ Closure(A,T) \equiv  \bigcap  ClosedCovers(A,T)$=== 
 ''qed'' === 

If two open sets are disjoint, then we can close one of them and they will still be disjoint.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>open_disj_cl_disj</nowiki>:
 ''   assumes '' A1: $ U\in T$,  $ V\in T$ ''and '' A2: $ U\cap V = 0$ ''   shows '' $ cl(U) \cap  V = 0$+++[proof ]>
 ''from '' topSpaceAssum, A1  ''have''  I: $ U \subseteq  \bigcup T$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''with '' A2  ''have''  $ U \subseteq  \bigcup T - V$ 
 ''moreover''   ''from '' A1  ''have''  $ (\bigcup T - V) \text{ is closed in } T$ ''using''  +++^[Top_3_L9 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L9</nowiki>:  ''assumes '' $ A\in T$  '' shows '' $ (\bigcup T - A) \text{ is closed in } T$ === 
 ''ultimately ''  ''have''  $ cl(U) - (\bigcup T - V) = 0$ ''using''  +++^[Top_3_L13 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L13</nowiki>:  ''assumes '' $ B \text{ is closed in } T$,   $ A\subseteq B$  '' shows '' $ cl(A) \subseteq  B$ === 
 ''moreover''   ''from '' I  ''have''  $ cl(U) \subseteq  \bigcup T$ ''using''  +++^[cl_is_closed | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_is_closed</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ cl(A) \text{ is closed in } T$ ===  ,  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''then ''  ''have''  $ cl(U) -(\bigcup T - V) = cl(U) \cap  V$ 
 ''ultimately ''  ''show''  $ cl(U) \cap  V = 0$ 
 ''qed'' === 

 ''end

'' +++![Comments on Topology_ZF|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Topology_ZF"></iframe> </div> </html>
=== 
 ''theory'' Topology_ZF_1 ''imports'' [[Topology_ZF]] [[Fol1]]

 ''begin
'' 
In this theory file we study separation axioms and the notion of base and subbase. Using the products of open sets as a subbase we define a natural topology on a product of two topological spaces.

!Separation axioms.

Topological spaces cas be classified according to certain properties called "separation axioms". In this section we define what it means that a topological space is $T_0$, $T_1$ or $T_2$.

A topology on $X$ is $T_0$ if for every pair of distinct points of $X$ there is an open set that contains only one of them.

 ''Definition
'' $ T \{is T_0\} \equiv  \forall  x y.\  ((x \in  \bigcup T \wedge  y \in  \bigcup T \wedge   x\neq y) \longrightarrow  $
$  (\exists U\in T.\  (x\in U \wedge  y\notin U) \vee  (y\in U \wedge  x\notin U)))$

A topology is $T_1$ if for every such pair there exist an open set that contains the first point but not the second.

 ''Definition
'' $ T \{is T_1\} \equiv  \forall  x y.\  ((x \in  \bigcup T \wedge  y \in  \bigcup T \wedge   x\neq y) \longrightarrow  $
$  (\exists U\in T.\  (x\in U \wedge  y\notin U)))$

A topology is $T_2$ (Hausdorff) if for every pair of points there exist a pair of disjoint open sets each containing one of the points. This is an important class of topological spaces. In particular, metric spaces are Hausdorff.

 ''Definition
'' $ T \{is T_2\} \equiv  \forall  x y.\  ((x \in  \bigcup T \wedge  y \in  \bigcup T \wedge   x\neq y) \longrightarrow $
$  (\exists U\in T.\  \exists V\in T.\  x\in U \wedge  y\in V \wedge  U\cap V=0))$

If a topology is $T_1$ then it is $T_0$. We don't really assume here that $T$ is a topology on $X$. Instead, we prove the relation between isT0 condition and isT1.

 ''lemma''  <nowiki>T1_is_T0</nowiki>:
 ''   assumes '' A1: $ T \{is T_1\}$ ''   shows '' $ T \{is T_0\}$+++[proof ]>
 ''from '' A1  ''have''  $ \forall  x y.\  x \in  \bigcup T \wedge  y \in  \bigcup T \wedge  x\neq y \longrightarrow  $
$    (\exists U\in T.\  x\in U \wedge  y\notin U)$ ''using''  +++^[isT1_def | Topology_ZF_1 ]... Definition of <nowiki>isT1</nowiki>:
$ T \{is T_1\} \equiv  \forall  x y.\  ((x \in  \bigcup T \wedge  y \in  \bigcup T \wedge   x\neq y) \longrightarrow  $
$  (\exists U\in T.\  (x\in U \wedge  y\notin U)))$=== 
 ''then ''  ''have''  $ \forall  x y.\  x \in  \bigcup T \wedge  y \in  \bigcup T \wedge  x\neq y \longrightarrow  $
$    (\exists U\in T.\  x\in U \wedge  y\notin U \vee  y\in U \wedge  x\notin U)$ 
 ''then ''  ''show''  $ T \{is T_0\}$ ''using''  +++^[isT0_def | Topology_ZF_1 ]... Definition of <nowiki>isT0</nowiki>:
$ T \{is T_0\} \equiv  \forall  x y.\  ((x \in  \bigcup T \wedge  y \in  \bigcup T \wedge   x\neq y) \longrightarrow  $
$  (\exists U\in T.\  (x\in U \wedge  y\notin U) \vee  (y\in U \wedge  x\notin U)))$=== 
 ''qed'' === 

If a topology is $T_2$ then it is $T_1$.

 ''lemma''  <nowiki>T2_is_T1</nowiki>:
 ''   assumes '' A1: $ T \{is T_2\}$ ''   shows '' $ T \{is T_1\}$+++[proof ]>

 ''{ ''  ''fix '' $ x$ $ y$
 ''assume '' $ x \in  \bigcup T$,  $ y \in  \bigcup T$,  $ x\neq y$
 ''with '' A1  ''have''  $ \exists U\in T.\  \exists V\in T.\  x\in U \wedge  y\in V \wedge  U\cap V=0$ ''using''  +++^[isT2_def | Topology_ZF_1 ]... Definition of <nowiki>isT2</nowiki>:
$ T \{is T_2\} \equiv  \forall  x y.\  ((x \in  \bigcup T \wedge  y \in  \bigcup T \wedge   x\neq y) \longrightarrow $
$  (\exists U\in T.\  \exists V\in T.\  x\in U \wedge  y\in V \wedge  U\cap V=0))$=== 
 ''then ''  ''have''  $ \exists U\in T.\  x\in U \wedge  y\notin U$ 
 '' }'' 
 ''then ''  ''have''  $ \forall  x y.\  x \in  \bigcup T \wedge  y \in  \bigcup T \wedge   x\neq y \longrightarrow  $
$      (\exists U\in T.\  x\in U \wedge  y\notin U)$ 
 ''then ''  ''show''  $ T \{is T_1\}$ ''using''  +++^[isT1_def | Topology_ZF_1 ]... Definition of <nowiki>isT1</nowiki>:
$ T \{is T_1\} \equiv  \forall  x y.\  ((x \in  \bigcup T \wedge  y \in  \bigcup T \wedge   x\neq y) \longrightarrow  $
$  (\exists U\in T.\  (x\in U \wedge  y\notin U)))$=== 
 ''qed'' === 

In a $T_0$ space two points that can not be separated by an open set are equal. Proof by contradiction.

 ''lemma''  <nowiki>Top_1_1_L1</nowiki>:
 ''   assumes '' A1: $ T \{is T_0\}$ ''and '' A2: $ x \in  \bigcup T$,  $ y \in  \bigcup T$ ''and '' A3: $ \forall U\in T.\  (x\in U \longleftrightarrow  y\in U)$ ''   shows '' $ x=y$+++[proof ]>

 ''{ ''  ''assume '' $ x\neq y$
 ''with '' A1, A2  ''have''  $ \exists U\in T.\  x\in U \wedge  y\notin U \vee  y\in U \wedge  x\notin U$ ''using''  +++^[isT0_def | Topology_ZF_1 ]... Definition of <nowiki>isT0</nowiki>:
$ T \{is T_0\} \equiv  \forall  x y.\  ((x \in  \bigcup T \wedge  y \in  \bigcup T \wedge   x\neq y) \longrightarrow  $
$  (\exists U\in T.\  (x\in U \wedge  y\notin U) \vee  (y\in U \wedge  x\notin U)))$=== 
 ''with '' A3  ''have''  $ False$ 
 '' }'' 
 ''then ''  ''show''  $ x=y$ 
 ''qed'' === 


!Bases and subbases.

Sometimes it is convenient to talk about topologies in terms of their bases and subbases. These are certain collections of open sets that define the whole topology.

A base of topology is a collection of open sets such that every open set is a union of the sets from the base.

 ''Definition
'' $ B \text{ is a base for } T \equiv  B\subseteq T \wedge  T = \{\bigcup A.\  A\in Pow(B)\}$

A subbase is a collection of open sets such that finite intersection of those sets form a base.

 ''Definition
'' $ B \text{ is a subbase for } T \equiv  $
$  B \subseteq  T \wedge  \{\bigcap A.\  A \in  FinPow(B)\} \text{ is a base for } T$

Below we formulate a condition that we will prove to be necessary and sufficient for a collection $B$ of open sets to form a base. It says that for any two sets $U,V$ from the collection $B$ we can find a point $x\in U\cap V$ with a neighboorhod from $B$ contained in $U\cap V$.

 ''Definition
'' $ B \text{ satisfies the base condition } \equiv  $
$  \forall U V.\  ((U\in B \wedge  V\in B) \longrightarrow  (\forall x \in  U\cap V.\  \exists W\in B.\  x\in W \wedge  W \subseteq  U\cap V))$

Each open set is a union of some sets from the base.

 ''lemma''  <nowiki>Top_1_2_L1</nowiki>:
 ''   assumes '' $ B \text{ is a base for } T$ ''and '' $ U\in T$ ''   shows '' $ \exists A\in Pow(B).\  U = \bigcup A$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsAbaseFor_def | Topology_ZF_1 ]... Definition of <nowiki>IsAbaseFor</nowiki>:
$ B \text{ is a base for } T \equiv  B\subseteq T \wedge  T = \{\bigcup A.\  A\in Pow(B)\}$=== 

A necessary conditionfor a collection of sets to be a base for some topology : every point in the intersection of two sets in the base has a neighboorhood from the base contained in the intersection.

 ''lemma''  <nowiki>Top_1_2_L2</nowiki>:
 ''   assumes '' A1: $ \exists T.\  T \text{ is a topology } \wedge  B \text{ is a base for } T$ ''and '' A2: $ V\in B$,  $ W\in B$ ''   shows '' $ \forall  x \in  V\cap W.\  \exists U\in B.\  x\in U \wedge  U \subseteq  V \cap  W$+++[proof ]>
 ''from '' A1  ''obtain '' $ T$ ''where '' D1: $ T \text{ is a topology }$,  $ B \text{ is a base for } T$ 
 ''then ''  ''have''  $ B \subseteq  T$ ''using''  +++^[IsAbaseFor_def | Topology_ZF_1 ]... Definition of <nowiki>IsAbaseFor</nowiki>:
$ B \text{ is a base for } T \equiv  B\subseteq T \wedge  T = \{\bigcup A.\  A\in Pow(B)\}$=== 
 ''with '' A2  ''have''  $ V\in T$ ''and '' $ W\in T$ ''using''  +++^[IsAbaseFor_def | Topology_ZF_1 ]... Definition of <nowiki>IsAbaseFor</nowiki>:
$ B \text{ is a base for } T \equiv  B\subseteq T \wedge  T = \{\bigcup A.\  A\in Pow(B)\}$=== 
 ''with '' D1  ''have''  $ \exists A\in Pow(B).\  V\cap W = \bigcup A$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$===  ,  +++^[Top_1_2_L1 | Topology_ZF_1 ]...  ''lemma''  <nowiki>Top_1_2_L1</nowiki>:  ''assumes '' $ B \text{ is a base for } T$  ''and'' $ U\in T$  '' shows '' $ \exists A\in Pow(B).\  U = \bigcup A$ === 
 ''then ''  ''obtain '' $ A$ ''where '' $ A \subseteq  B$ ''and '' $ V \cap  W = \bigcup A$ 
 ''then ''  ''show''  $ \forall  x \in  V\cap W.\  \exists U\in B.\  (x\in U \wedge  U \subseteq  V \cap  W)$ 
 ''qed'' === 

We will construct a topology as the collection of unions of (would-be) base. First we prove that if the collection of sets satisfies the condition we want to show to be sufficient, the the intersection belongs to what we will define as topology (am I clear here?). Having this fact ready simplifies the proof of the next lemma. There is not much topology here, just some set theory.

 ''lemma''  <nowiki>Top_1_2_L3</nowiki>:
 ''   assumes '' A1: $ \forall x\in  V\cap W .\  \exists U\in B.\  x\in U \wedge  U \subseteq  V\cap W$ ''   shows '' $ V\cap W \in  \{\bigcup A.\  A\in Pow(B)\}$+++[proof ]>
 ''let '' $ A = \bigcup x\in V\cap W.\  \{U\in B.\  x\in U \wedge  U \subseteq  V\cap W\}$
 ''show''  $ A\in Pow(B)$ 
 ''from '' A1  ''show''  $ V\cap W = \bigcup A$ 
 ''qed'' === 

The next lemma is needed when proving that the would-be topology is closed with respect to taking intersections. We show here that intersection of two sets from this (would-be) topology can be written as union of sets from the topology.

 ''lemma''  <nowiki>Top_1_2_L4</nowiki>:
 ''   assumes '' A1: $ U_1 \in  \{\bigcup A.\  A\in Pow(B)\}$,  $ U_2 \in  \{\bigcup A.\  A\in Pow(B)\}$ ''and '' A2: $ B \text{ satisfies the base condition }$ ''   shows '' $ \exists C.\  C \subseteq  \{\bigcup A.\  A\in Pow(B)\} \wedge  U_1\cap U_2 = \bigcup C$+++[proof ]>
 ''from '' A1, A2  ''obtain '' $ A_1$ $ A_2$ ''where '' D1: $ A_1\in  Pow(B)$,  $ U_1 = \bigcup A_1$,  $ A_2 \in  Pow(B)$,  $ U_2 = \bigcup A_2$ 
 ''let '' $ C = \bigcup U\in A_1.\ \{U\cap V.\  V\in A_2\}$
 ''from '' D1  ''have''  $ (\forall U\in A_1.\  U\in B) \wedge  (\forall V\in A_2.\  V\in B)$ 
 ''with '' A2  ''have''  $ C \subseteq  \{\bigcup A .\  A \in  Pow(B)\}$ ''using''  +++^[Top_1_2_L3 | Topology_ZF_1 ]...  ''lemma''  <nowiki>Top_1_2_L3</nowiki>:  ''assumes '' $ \forall x\in  V\cap W .\  \exists U\in B.\  x\in U \wedge  U \subseteq  V\cap W$  '' shows '' $ V\cap W \in  \{\bigcup A.\  A\in Pow(B)\}$ ===  ,  +++^[SatisfiesBaseCondition_def | Topology_ZF_1 ]... Definition of <nowiki>SatisfiesBaseCondition</nowiki>:
$ B \text{ satisfies the base condition } \equiv  $
$  \forall U V.\  ((U\in B \wedge  V\in B) \longrightarrow  (\forall x \in  U\cap V.\  \exists W\in B.\  x\in W \wedge  W \subseteq  U\cap V))$=== 
 ''moreover''   ''from '' D1  ''have''  $ U_1 \cap  U_2 = \bigcup C$ 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

If $B$ satisfies the base condition, then the collection of unions of sets from $B$ is a topology and $B$ is a base for this topology.

 ''theorem''  <nowiki>Top_1_2_T1</nowiki>:
 ''   assumes '' A1: $ B \text{ satisfies the base condition }$ ''and '' A2: $ T = \{\bigcup A.\  A\in Pow(B)\}$ ''   shows '' $ T \text{ is a topology }$ ''and '' $ B \text{ is a base for } T$+++[proof ]>
 ''show''  $ T \text{ is a topology }$+++[proof ]>
 ''from '' A2  ''have''  $ 0\in T$ 
 ''moreover''   ''have''  I: $ \forall C\in Pow(T).\  \bigcup C \in  T$+++[proof ]>
 ''{ ''  ''fix '' $ C$
 ''assume '' A3: $ C \in  Pow(T)$
 ''let '' $ Q = \bigcup  \{\bigcup \{A\in Pow(B).\  U = \bigcup A\}.\  U\in C\}$
 ''from '' A2, A3  ''have''  $ \forall U\in C.\  \exists A\in Pow(B).\  U = \bigcup A$ 
 ''then ''  ''have''  $ \bigcup Q = \bigcup C$ ''using''  +++^[ZF1_1_L10 | ZF1 ]...  ''lemma''  <nowiki>ZF1_1_L10</nowiki>:  ''assumes '' $ \forall U\in C.\  \exists A\in B.\  U = \bigcup A$  '' shows '' $ \bigcup \bigcup  \{\bigcup \{A\in B.\  U = \bigcup A\}.\  U\in C\} = \bigcup C$ === 
 ''moreover''   ''from '' A2  ''have''  $ \bigcup Q \in  T$ 
 ''ultimately ''  ''have''  $ \bigcup C \in  T$ 
 '' }'' 
 ''thus''  $ \forall C\in Pow(T).\  \bigcup C \in  T$
 ''qed'' === 
 ''moreover''   ''have''  $ \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T$+++[proof ]>
 ''{ ''  ''fix '' $ U$ $ V$
 ''assume '' $ U \in  T$,  $ V \in  T$
 ''with '' A1, A2  ''have''  $ \exists C.\ (C \subseteq  T \wedge  U\cap V = \bigcup C)$ ''using''  +++^[Top_1_2_L4 | Topology_ZF_1 ]...  ''lemma''  <nowiki>Top_1_2_L4</nowiki>:  ''assumes '' $ U_1 \in  \{\bigcup A.\  A\in Pow(B)\}$,   $ U_2 \in  \{\bigcup A.\  A\in Pow(B)\}$  ''and'' $ B \text{ satisfies the base condition }$  '' shows '' $ \exists C.\  C \subseteq  \{\bigcup A.\  A\in Pow(B)\} \wedge  U_1\cap U_2 = \bigcup C$ === 
 ''then ''  ''obtain '' $ C$ ''where '' $ C \subseteq  T$ ''and '' $ U\cap V = \bigcup C$ 
 ''with '' I  ''have''  $ U\cap V \in  T$ 
 '' }'' 
 ''then ''  ''show''  $ \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ T \text{ is a topology }$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''qed'' === 
 ''from '' A2  ''have''  $ B\subseteq T$ 
 ''with '' A2  ''show''  $ B \text{ is a base for } T$ ''using''  +++^[IsAbaseFor_def | Topology_ZF_1 ]... Definition of <nowiki>IsAbaseFor</nowiki>:
$ B \text{ is a base for } T \equiv  B\subseteq T \wedge  T = \{\bigcup A.\  A\in Pow(B)\}$=== 
 ''qed'' === 

The carrier of the base and topology are the same.

 ''lemma''  <nowiki>Top_1_2_L5</nowiki>:
 ''   assumes '' $ B \text{ is a base for } T$ ''   shows '' $ \bigcup T = \bigcup B$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsAbaseFor_def | Topology_ZF_1 ]... Definition of <nowiki>IsAbaseFor</nowiki>:
$ B \text{ is a base for } T \equiv  B\subseteq T \wedge  T = \{\bigcup A.\  A\in Pow(B)\}$=== 


!Product topology

In this section we consider a topology defined on a product of two sets.

Given two topological spaces we can define a topology on the product of the carriers such that the cartesian products of the sets of the topologies are a base for the product topology. Recall that for two collections $S,T$ of sets the product collection is defined (in //ZF1.thy//) as the collections of cartesian products $A\times B$, where $A\in S, B\in T$.

 ''Definition
'' $ ProductTopology(T,S) \equiv  \{\bigcup W.\  W \in  Pow(ProductCollection(T,S))\}$

The product collection satisfies the base condition.

 ''lemma''  <nowiki>Top_1_4_L1</nowiki>:
 ''   assumes '' A1: $ T \text{ is a topology }$,  $ S \text{ is a topology }$ ''and '' A2: $ A \in  ProductCollection(T,S)$,  $ B \in  ProductCollection(T,S)$ ''   shows '' $ \forall x\in (A\cap B).\  \exists W\in ProductCollection(T,S).\  (x\in W \wedge  W \subseteq  A \cap  B)$+++[proof ]>
 ''fix '' $ x$
 ''assume '' A3: $ x \in  A\cap B$
 ''from '' A2  ''obtain '' $ U_1$ $ V_1$ $ U_2$ $ V_2$ ''where '' D1: $ U_1\in T$,  $ V_1\in S$,  $ A=U_1\times V_1$,  $ U_2\in T$,  $ V_2\in S$,  $ B=U_2\times V_2$ ''using''  +++^[ProductCollection_def | ZF1 ]... Definition of <nowiki>ProductCollection</nowiki>:
$ ProductCollection(T,S) \equiv  \bigcup U\in T.\ \{U\times V.\  V\in S\}$=== 
 ''let '' $ W = (U_1\cap U_2) \times  (V_1\cap V_2)$
 ''from '' A1, D1  ''have''  $ U_1\cap U_2 \in  T$ ''and '' $ V_1\cap V_2 \in  S$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''then ''  ''have''  $ W \in  ProductCollection(T,S)$ ''using''  +++^[ProductCollection_def | ZF1 ]... Definition of <nowiki>ProductCollection</nowiki>:
$ ProductCollection(T,S) \equiv  \bigcup U\in T.\ \{U\times V.\  V\in S\}$=== 
 ''moreover''   ''from '' A3, D1  ''have''  $ x\in W$ ''and '' $ W \subseteq  A\cap B$ 
 ''ultimately ''  ''have''  $ \exists W.\  (W \in  ProductCollection(T,S) \wedge  x\in W \wedge  W \subseteq  A\cap B)$ 
 ''thus''  $ \exists W\in ProductCollection(T,S).\  (x\in W \wedge  W \subseteq  A \cap  B)$
 ''qed'' === 

The product topology is indeed a topology on the product.

 ''theorem''  <nowiki>Top_1_4_T1</nowiki>:
 ''   assumes '' A1: $ T \text{ is a topology }$,  $ S \text{ is a topology }$ ''   shows '' $ ProductTopology(T,S) \text{ is a topology }$,  $ ProductCollection(T,S) \text{ is a base for } ProductTopology(T,S)$,  $ \bigcup  ProductTopology(T,S) = \bigcup T \times  \bigcup S$+++[proof ]>
 ''from '' A1  ''show''  $ ProductTopology(T,S) \text{ is a topology }$,  $ ProductCollection(T,S) \text{ is a base for } ProductTopology(T,S)$ ''using''  +++^[Top_1_4_L1 | Topology_ZF_1 ]...  ''lemma''  <nowiki>Top_1_4_L1</nowiki>:  ''assumes '' $ T \text{ is a topology }$,   $ S \text{ is a topology }$  ''and'' $ A \in  ProductCollection(T,S)$,   $ B \in  ProductCollection(T,S)$  '' shows '' $ \forall x\in (A\cap B).\  \exists W\in ProductCollection(T,S).\  (x\in W \wedge  W \subseteq  A \cap  B)$
===  ,  +++^[ProductCollection_def | ZF1 ]... Definition of <nowiki>ProductCollection</nowiki>:
$ ProductCollection(T,S) \equiv  \bigcup U\in T.\ \{U\times V.\  V\in S\}$===  ,  +++^[SatisfiesBaseCondition_def | Topology_ZF_1 ]... Definition of <nowiki>SatisfiesBaseCondition</nowiki>:
$ B \text{ satisfies the base condition } \equiv  $
$  \forall U V.\  ((U\in B \wedge  V\in B) \longrightarrow  (\forall x \in  U\cap V.\  \exists W\in B.\  x\in W \wedge  W \subseteq  U\cap V))$===  ,  +++^[ProductTopology_def | Topology_ZF_1 ]... Definition of <nowiki>ProductTopology</nowiki>:
$ ProductTopology(T,S) \equiv  \{\bigcup W.\  W \in  Pow(ProductCollection(T,S))\}$===  ,  +++^[Top_1_2_T1 | Topology_ZF_1 ]...  ''theorem''  <nowiki>Top_1_2_T1</nowiki>:  ''assumes '' $ B \text{ satisfies the base condition }$  ''and'' $ T = \{\bigcup A.\  A\in Pow(B)\}$  '' shows '' $ T \text{ is a topology }$  ''and'' $ B \text{ is a base for } T$ === 
 ''then ''  ''show''  $ \bigcup  ProductTopology(T,S) = \bigcup T \times  \bigcup S$ ''using''  +++^[Top_1_2_L5 | Topology_ZF_1 ]...  ''lemma''  <nowiki>Top_1_2_L5</nowiki>:  ''assumes '' $ B \text{ is a base for } T$  '' shows '' $ \bigcup T = \bigcup B$ ===  ,  +++^[ZF1_1_L6 | ZF1 ]...  ''lemma''  <nowiki>ZF1_1_L6</nowiki>:  '' shows '' $ \bigcup  ProductCollection(S,T) = \bigcup S \times  \bigcup T$ === 
 ''qed'' === 

 ''end

'' +++![Comments on Topology_ZF_1|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Topology_ZF_1"></iframe> </div> </html>
=== 
 ''theory'' Topology_ZF_1b ''imports'' [[Topology_ZF_1]]

 ''begin
'' 
One of the facts demonstrated in every class on General Topology is that in a $T_2$ (Hausdorff) topological space compact sets are closed. Formalizing the proof of this fact gave me an interesting insight into the role of the Axiom of Choice (AC) in many informal proofs. A typical informal proof of this fact goes like this: we want to show that the complement of $K$ is open. To do this, choose an arbitrary point $y\in K^c$. Since $X$ is $T_2$, for every point $x\in K$ we can find an open set $U_x$ such that $y\notin \overline{U_x}$. Obviously $\{U_x\}_{x\in K}$ covers $K$, so select a finite subcollection that covers $K$, and so on. I had never realized that such reasoning requires the Axiom of Choice. Namely, suppose we have a lemma that states "In $T_2$ spaces, if $x\neq y$, then there is an open set $U$ such that $x\in U$ and $y\notin \overline{U}$" (like our lemma //T2_cl_open_sep// below). This only states that the set of such open sets $U$ is not empty. To get the collection $\{U_x \}_{x\in K}$ in this proof we have to select one such set among many for every $x\in K$ and this is where we use the Axiom of Choice. Probably in 99/100 cases when an informal calculus proof states something like $\forall \varepsilon \exists \delta_\varepsilon \cdots$ the proof uses AC. Most of the time the use of AC in such proofs can be avoided. This is also the case for the fact that in a $T_2$ space compact sets are closed.

!Compact sets are closed - no need for AC

In this section we show that in a $T_2$ topological space compact sets are closed.

First we prove a lemma that in a $T_2$ space two points can be separated by the closure of an open set.

 ''lemma''   ''(in '' topology0 '') '' <nowiki>T2_cl_open_sep</nowiki>:
 ''   assumes '' $ T \{is T_2\}$ ''and '' $ x \in  \bigcup T$,  $ y \in  \bigcup T$,  $ x\neq y$ ''   shows '' $ \exists U\in T.\  (x\in U \wedge  y \notin  cl(U))$+++[proof ]>
 ''from '' assms  ''have''  $ \exists U\in T.\  \exists V\in T.\  x\in U \wedge  y\in V \wedge  U\cap V=0$ ''using''  +++^[isT2_def | Topology_ZF_1 ]... Definition of <nowiki>isT2</nowiki>:
$ T \{is T_2\} \equiv  \forall  x y.\  ((x \in  \bigcup T \wedge  y \in  \bigcup T \wedge   x\neq y) \longrightarrow $
$  (\exists U\in T.\  \exists V\in T.\  x\in U \wedge  y\in V \wedge  U\cap V=0))$=== 
 ''then ''  ''obtain '' $ U$ $ V$ ''where '' $ U\in T$,  $ V\in T$,  $ x\in U$,  $ y\in V$,  $ U\cap V=0$ 
 ''then ''  ''have''  $ U\in T \wedge  x\in U \wedge  y\in  V \wedge  cl(U) \cap  V = 0$ ''using''  +++^[open_disj_cl_disj | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>open_disj_cl_disj</nowiki>:  ''assumes '' $ U\in T$,   $ V\in T$  ''and'' $ U\cap V = 0$  '' shows '' $ cl(U) \cap  V = 0$ === 
 ''thus''  $ \exists U\in T.\  (x\in U \wedge  y \notin  cl(U))$
 ''qed'' === 

AC-free proof that in a Hausdorff space compact sets are closed. To understand the notation recall that in Isabelle/ZF $ Pow(A)$ is the powerset (the set of subsets) of $A$ and $ FinPow(A)$ denotes the set of finite subsets of $A$ in IsarMathLib.

 ''theorem''   ''(in '' topology0 '') '' <nowiki>in_t2_compact_is_cl</nowiki>:
 ''   assumes '' A1: $ T \{is T_2\}$ ''and '' A2: $ K \text{ is compact in } T$ ''   shows '' $ K \text{ is closed in } T$+++[proof ]>
 ''let '' $ X = \bigcup T$
 ''have''  $ \forall y \in  X - K.\  \exists U\in T.\  y\in U \wedge  U \subseteq  X - K$+++[proof ]>
 ''{ ''  ''fix '' $ y$
 ''assume '' $ y \in  X$,  $ y\notin K$
 ''have''  $ \exists U\in T.\  y\in U \wedge  U \subseteq  X - K$+++[proof ]>
 ''let '' $ B = \bigcup x\in K.\  \{V\in T.\  x\in V \wedge  y \notin  cl(V)\}$
 ''have''  I: $ B \in  Pow(T)$,  $ FinPow(B) \subseteq  Pow(B)$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 
 ''from '' $ K \text{ is compact in } T$, $ y \in  X$, $ y\notin K$  ''have''  $ \forall x\in K.\  x \in  X \wedge  y \in  X \wedge  x\neq y$ ''using''  +++^[IsCompact_def | Topology_ZF ]... Definition of <nowiki>IsCompact</nowiki>:
$ K \text{ is compact in } T \equiv  (K \subseteq  \bigcup T \wedge  $
$  (\forall  M\in Pow(T).\  K \subseteq  \bigcup M \longrightarrow  (\exists  N \in  FinPow(M).\  K \subseteq  \bigcup N)))$=== 
 ''with '' $ T \{is T_2\}$  ''have''  $ \forall x\in K.\  \{V\in T.\  x\in V \wedge  y \notin  cl(V)\} \neq  0$ ''using''  +++^[T2_cl_open_sep | Topology_ZF_1b ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>T2_cl_open_sep</nowiki>:  ''assumes '' $ T \{is T_2\}$  ''and'' $ x \in  \bigcup T$,   $ y \in  \bigcup T$,   $ x\neq y$  '' shows '' $ \exists U\in T.\  (x\in U \wedge  y \notin  cl(U))$ === 
 ''hence''  $ K \subseteq  \bigcup B$
 ''with '' $ K \text{ is compact in } T$, I  ''have''  $ \exists N \in  FinPow(B).\  K \subseteq  \bigcup N$ ''using''  +++^[IsCompact_def | Topology_ZF ]... Definition of <nowiki>IsCompact</nowiki>:
$ K \text{ is compact in } T \equiv  (K \subseteq  \bigcup T \wedge  $
$  (\forall  M\in Pow(T).\  K \subseteq  \bigcup M \longrightarrow  (\exists  N \in  FinPow(M).\  K \subseteq  \bigcup N)))$=== 
 ''then ''  ''obtain '' $ N$ ''where '' $ N \in  FinPow(B)$,  $ K \subseteq  \bigcup N$ 
 ''with '' I  ''have''  $ N \subseteq  B$ 
 ''hence''  $ \forall V\in N.\  V\in B$
 ''let '' $ M = \{cl(V).\  V\in N\}$
 ''let '' $ C = \{D \in  Pow(X).\  D \text{ is closed in } T\}$
 ''from '' $ N \in  FinPow(B)$  ''have''  $ \forall V\in B.\  cl(V) \in  C$,  $ N \in  FinPow(B)$ ''using''  +++^[cl_is_closed | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_is_closed</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ cl(A) \text{ is closed in } T$ ===  ,  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''then ''  ''have''  $ M \in  FinPow(C)$ ''   by (rule '' +++^[fin_image_fin | Finite_ZF ]...  ''lemma''  <nowiki>fin_image_fin</nowiki>:  ''assumes '' $ \forall V\in B.\  K(V)\in C$  ''and'' $ N \in  FinPow(B)$  '' shows '' $ \{K(V).\  V\in N\} \in  FinPow(C)$ ===  '')'' 
 ''then ''  ''have''  $ X - \bigcup M \in  T$ ''using''  +++^[fin_union_cl_is_cl | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>fin_union_cl_is_cl</nowiki>:  ''assumes '' $ N \in  FinPow(\{D\in Pow(\bigcup T).\  D \text{ is closed in } T\})$  '' shows '' $ (\bigcup N) \text{ is closed in } T$ ===  ,  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''moreover''   ''from '' $ y \in  X$, $ y\notin K$, $ \forall V\in N.\  V\in B$  ''have''  $ y \in  X - \bigcup M$ 
 ''moreover''   ''have''  $ X - \bigcup M \subseteq  X - K$+++[proof ]>
 ''from '' $ \forall V\in N.\  V\in B$  ''have''  $ \bigcup N \subseteq  \bigcup M$ ''using''  +++^[cl_contains_set | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_contains_set</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ A \subseteq  cl(A)$ === 
 ''with '' $ K \subseteq  \bigcup N$  ''show''  $ X - \bigcup M \subseteq  X - K$ 
 ''qed'' === 
 ''ultimately ''  ''have''  $ \exists U.\  U\in T \wedge  y \in  U \wedge  U \subseteq  X - K$ 
 ''thus''  $ \exists U\in T.\  y\in U \wedge  U \subseteq  X - K$
 ''qed'' === 
 '' }'' 
 ''thus''  $ \forall y \in  X - K.\  \exists U\in T.\  y\in U \wedge  U \subseteq  X - K$
 ''qed'' === 
 ''with '' A2  ''show''  $ K \text{ is closed in } T$ ''using''  +++^[open_neigh_open | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>open_neigh_open</nowiki>:  ''assumes '' $ \forall x\in V.\  \exists U\in T.\  (x\in U \wedge  U\subseteq V)$  '' shows '' $ V\in T$ ===  ,  +++^[IsCompact_def | Topology_ZF ]... Definition of <nowiki>IsCompact</nowiki>:
$ K \text{ is compact in } T \equiv  (K \subseteq  \bigcup T \wedge  $
$  (\forall  M\in Pow(T).\  K \subseteq  \bigcup M \longrightarrow  (\exists  N \in  FinPow(M).\  K \subseteq  \bigcup N)))$===  ,  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$=== 
 ''qed'' === 

 ''end

'' +++![Comments on Topology_ZF_1b|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Topology_ZF_1b"></iframe> </div> </html>
=== 
 ''theory'' Topology_ZF_2 ''imports'' [[Topology_ZF_1]] [[func1]] [[Fol1]]

 ''begin
'' 
This theory continues the series on general topology and covers the definition and basic properties of continuous functions.

!Continuous functions.

In this section we define continuous functions and prove that certain conditions are equivalent to a function being continuous.

In standard math we say that a function is contiuous with respect to two topologies $\tau_1 ,\tau_2 $ if the inverse image of sets from topology $\tau_2$ are in $\tau_1$. Here we define a predicate that is supposed to reflect that definition, with a difference that we don't require in the definition that $\tau_1 ,\tau_2 $ are topologies. This means for example that when we define measurable functions, the definition will be the same.
The notation $ f^{-1}(A)$ means the inverse image of (a set) $A$ with respect to (a function) $f$.

 ''Definition
'' $ IsContinuous(\tau _1,\tau _2,f) \equiv  (\forall U\in \tau _2.\  f^{-1}(U) \in  \tau _1)$

We will work with a pair of topological spaces. The following locale sets up our context that consists of two topologies $\tau_1,\tau_2$ and a continuous function $f: X_1 \rightarrow X_2$, where $X_i$ is defined as $\bigcup\tau_i$ for $i=1,2$. We also define notation $ cl_1(A)$ and $ cl_2(A)$ for closure of a set $A$ in topologies $\tau_1$ and $\tau_2$, respectively.

 ''Locale '' two_top_spaces0
 ''fixes '' $ \tau _1$
 ''assumes '' tau1_is_top: $ \tau _1 \text{ is a topology }$
 ''fixes '' $ \tau _2$
 ''assumes '' tau2_is_top: $ \tau _2 \text{ is a topology }$
 ''fixes '' $ X_1$
 ''defines '' $ X_1 \equiv  \bigcup \tau _1$
 ''fixes '' $ X_2$
 ''defines '' $ X_2 \equiv  \bigcup \tau _2$
 ''fixes '' $ f$
 ''assumes '' fmapAssum: $ f: X_1 \rightarrow  X_2$
 ''fixes '' $ isContinuous$
 ''defines '' $ g \text{ is continuous } \equiv  IsContinuous(\tau _1,\tau _2,g)$
 ''fixes '' $ cl_1$
 ''defines '' $ cl_1(A) \equiv  Closure(A,\tau _1)$
 ''fixes '' $ cl_2$
 ''defines '' $ cl_2(A) \equiv  Closure(A,\tau _2)$


First we show that theorems proven in locale //topology0// are valid when applied to topologies $\tau_1$ and $\tau_2$.

 ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:
 ''   shows '' $ topology0(\tau _1)$ ''and '' $ topology0(\tau _2)$ ''using''  <nowiki>tau1_is_top</nowiki> ,  <nowiki>tau2_is_top</nowiki> ,  <nowiki>topology0_def</nowiki>

For continuous functions the inverse image of a closed set is closed.

 ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>TopZF_2_1_L1</nowiki>:
 ''   assumes '' A1: $ f \text{ is continuous }$ ''and '' A2: $ D \text{ is closed in } \tau _2$ ''   shows '' $ f^{-1}(D) \text{ is closed in } \tau _1$+++[proof ]>
 ''from '' fmapAssum  ''have''  $ f^{-1}(D) \subseteq  X_1$ ''using''  <nowiki>func1_1_L3</nowiki>
 ''moreover''   ''from '' fmapAssum  ''have''  $ f^{-1}(X_2 - D) =  X_1 - f^{-1}(D)$ ''using''  <nowiki>Pi_iff</nowiki> ,  <nowiki>function_vimage_Diff</nowiki> ,  <nowiki>func1_1_L4</nowiki>
 ''ultimately ''  ''have''  $ X_1 - f^{-1}(X_2 - D) = f^{-1}(D)$ 
 ''moreover''   ''from '' A1, A2  ''have''  $ (X_1 - f^{-1}(X_2 - D)) \text{ is closed in } \tau _1$ ''using''  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$===  ,  +++^[IsContinuous_def | Topology_ZF_2 ]... Definition of <nowiki>IsContinuous</nowiki>:
$ IsContinuous(\tau _1,\tau _2,f) \equiv  (\forall U\in \tau _2.\  f^{-1}(U) \in  \tau _1)$===  ,  +++^[topol_cntxs_valid | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:  '' shows '' $ topology0(\tau _1)$  ''and'' $ topology0(\tau _2)$ ===  ,  +++^[Top_3_L9 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L9</nowiki>:  ''assumes '' $ A\in T$  '' shows '' $ (\bigcup T - A) \text{ is closed in } T$ === 
 ''ultimately ''  ''show''  $ f^{-1}(D) \text{ is closed in } \tau _1$ 
 ''qed'' === 

If the inverse image of every closed set is closed, then the image of a closure is contained in the closure of the image.

 ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>Top_ZF_2_1_L2</nowiki>:
 ''   assumes '' A1: $ \forall D.\  ((D \text{ is closed in } \tau _2) \longrightarrow  f^{-1}(D) \text{ is closed in } \tau _1)$ ''and '' A2: $ A \subseteq  X_1$ ''   shows '' $ f(cl_1(A)) \subseteq  cl_2(f(A))$+++[proof ]>
 ''from '' fmapAssum  ''have''  $ f(A) \subseteq  cl_2(f(A))$ ''using''  <nowiki>func1_1_L6</nowiki> ,  +++^[topol_cntxs_valid | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:  '' shows '' $ topology0(\tau _1)$  ''and'' $ topology0(\tau _2)$ ===  ,  +++^[cl_contains_set | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_contains_set</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ A \subseteq  cl(A)$ === 
 ''with '' fmapAssum  ''have''  $ f^{-1}(f(A)) \subseteq  f^{-1}(cl_2(f(A)))$ ''using''  <nowiki>func1_1_L7</nowiki>
 ''moreover''   ''from '' fmapAssum, A2  ''have''  $ A \subseteq  f^{-1}(f(A))$ ''using''  <nowiki>func1_1_L9</nowiki>
 ''ultimately ''  ''have''  $ A \subseteq  f^{-1}(cl_2(f(A)))$ 
 ''with '' fmapAssum, A1  ''have''  $ f(cl_1(A)) \subseteq  f(f^{-1}(cl_2(f(A))))$ ''using''  <nowiki>func1_1_L6</nowiki> ,  <nowiki>func1_1_L8</nowiki> ,  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$===  ,  +++^[topol_cntxs_valid | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:  '' shows '' $ topology0(\tau _1)$  ''and'' $ topology0(\tau _2)$ ===  ,  +++^[cl_is_closed | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_is_closed</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ cl(A) \text{ is closed in } T$ ===  ,  +++^[Top_3_L13 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L13</nowiki>:  ''assumes '' $ B \text{ is closed in } T$,   $ A\subseteq B$  '' shows '' $ cl(A) \subseteq  B$ === 
 ''moreover''   ''from '' fmapAssum  ''have''  $ f(f^{-1}(cl_2(f(A)))) \subseteq  cl_2(f(A))$ ''using''  <nowiki>fun_is_function</nowiki> ,  <nowiki>function_image_vimage</nowiki>
 ''ultimately ''  ''show''  $ f(cl_1(A)) \subseteq  cl_2(f(A))$ 
 ''qed'' === 

If $f\left( \overline{A}\right)\subseteq \overline{f(A)}$ (the image of the closure is contained in the closure of the image), then $\overline{f^{-1}(B)}\subseteq f^{-1}\left( \overline{B} \right)$ (the inverse image of the closure contains the closure of the inverse image).

 ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>Top_ZF_2_1_L3</nowiki>:
 ''   assumes '' A1: $ \forall  A.\  ( A \subseteq  X_1 \longrightarrow  f(cl_1(A)) \subseteq  cl_2(f(A)))$ ''   shows '' $ \forall B.\  ( B \subseteq  X_2 \longrightarrow  cl_1(f^{-1}(B)) \subseteq  f^{-1}(cl_2(B)) )$+++[proof ]>

 ''{ ''  ''fix '' $ B$
 ''assume '' $ B \subseteq  X_2$
 ''from '' fmapAssum, A1  ''have''  $ f(cl_1(f^{-1}(B))) \subseteq  cl_2(f(f^{-1}(B)))$ ''using''  <nowiki>func1_1_L3</nowiki>
 ''moreover''   ''from '' fmapAssum, $ B \subseteq  X_2$  ''have''  $ cl_2(f(f^{-1}(B))) \subseteq  cl_2(B)$ ''using''  <nowiki>fun_is_function</nowiki> ,  <nowiki>function_image_vimage</nowiki> ,  <nowiki>func1_1_L6</nowiki> ,  +++^[topol_cntxs_valid | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:  '' shows '' $ topology0(\tau _1)$  ''and'' $ topology0(\tau _2)$ ===  ,  +++^[top_closure_mono | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>top_closure_mono</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$,   $ B \subseteq  \bigcup T$  ''and'' $ A\subseteq B$  '' shows '' $ cl(A) \subseteq  cl(B)$ === 
 ''ultimately ''  ''have''  $ f^{-1}(f(cl_1(f^{-1}(B)))) \subseteq  f^{-1}(cl_2(B))$ ''using''  <nowiki>fmapAssum</nowiki> ,  <nowiki>fun_is_function</nowiki> ,  <nowiki>func1_1_L7</nowiki>
 ''moreover''   ''from '' fmapAssum, $ B \subseteq  X_2$  ''have''  $ cl_1(f^{-1}(B)) \subseteq  f^{-1}(f(cl_1(f^{-1}(B))))$ ''using''  <nowiki>func1_1_L3</nowiki> ,  <nowiki>func1_1_L9</nowiki> ,  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$===  ,  +++^[topol_cntxs_valid | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:  '' shows '' $ topology0(\tau _1)$  ''and'' $ topology0(\tau _2)$ ===  ,  +++^[cl_is_closed | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_is_closed</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ cl(A) \text{ is closed in } T$ === 
 ''ultimately ''  ''have''  $ cl_1(f^{-1}(B)) \subseteq  f^{-1}(cl_2(B))$ 
 '' }'' 
 ''then ''  ''show''  $ thesis$ 
 ''qed'' === 

If $\overline{f^{-1}(B)}\subseteq f^{-1}\left( \overline{B} \right)$ (the inverse image of a closure contains the closure of the inverse image), then the function is continuous. This lemma closes a series of implications in lemmas // Top_ZF_2_1_L1//, // Top_ZF_2_1_L2// and // Top_ZF_2_1_L3// showing equavalence of four definitions of continuity.

 ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>Top_ZF_2_1_L4</nowiki>:
 ''   assumes '' A1: $ \forall B.\  ( B \subseteq  X_2 \longrightarrow  cl_1(f^{-1}(B)) \subseteq  f^{-1}(cl_2(B)) )$ ''   shows '' $ f \text{ is continuous }$+++[proof ]>

 ''{ ''  ''fix '' $ U$
 ''assume '' $ U \in  \tau _2$
 ''then ''  ''have''  $ (X_2 - U) \text{ is closed in } \tau _2$ ''using''  +++^[topol_cntxs_valid | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:  '' shows '' $ topology0(\tau _1)$  ''and'' $ topology0(\tau _2)$ ===  ,  +++^[Top_3_L9 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L9</nowiki>:  ''assumes '' $ A\in T$  '' shows '' $ (\bigcup T - A) \text{ is closed in } T$ === 
 ''moreover''   ''have''  $ X_2 - U \subseteq  \bigcup \tau _2$ 
 ''ultimately ''  ''have''  $ cl_2(X_2 - U) = X_2 - U$ ''using''  +++^[topol_cntxs_valid | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:  '' shows '' $ topology0(\tau _1)$  ''and'' $ topology0(\tau _2)$ ===  ,  +++^[Top_3_L8 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L8</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ A \text{ is closed in } T \longleftrightarrow  cl(A) = A$ === 
 ''moreover''   ''from '' A1  ''have''  $ cl_1(f^{-1}(X_2 - U)) \subseteq  f^{-1}(cl_2(X_2 - U))$ 
 ''ultimately ''  ''have''  $ cl_1(f^{-1}(X_2 - U)) \subseteq  f^{-1}(X_2 - U)$ 
 ''moreover''   ''from '' fmapAssum  ''have''  $ f^{-1}(X_2 - U) \subseteq  cl_1(f^{-1}(X_2 - U))$ ''using''  <nowiki>func1_1_L3</nowiki> ,  +++^[topol_cntxs_valid | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:  '' shows '' $ topology0(\tau _1)$  ''and'' $ topology0(\tau _2)$ ===  ,  +++^[cl_contains_set | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>cl_contains_set</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ A \subseteq  cl(A)$ === 
 ''ultimately ''  ''have''  $ f^{-1}(X_2 - U) \text{ is closed in } \tau _1$ ''using''  <nowiki>fmapAssum</nowiki> ,  <nowiki>func1_1_L3</nowiki> ,  +++^[topol_cntxs_valid | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:  '' shows '' $ topology0(\tau _1)$  ''and'' $ topology0(\tau _2)$ ===  ,  +++^[Top_3_L8 | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>Top_3_L8</nowiki>:  ''assumes '' $ A \subseteq  \bigcup T$  '' shows '' $ A \text{ is closed in } T \longleftrightarrow  cl(A) = A$ === 
 ''with '' fmapAssum  ''have''  $ f^{-1}(U) \in  \tau _1$ ''using''  <nowiki>fun_is_function</nowiki> ,  <nowiki>function_vimage_Diff</nowiki> ,  <nowiki>func1_1_L4</nowiki> ,  <nowiki>func1_1_L3</nowiki> ,  +++^[IsClosed_def | Topology_ZF ]... Definition of <nowiki>IsClosed</nowiki>:
$ D \text{ is closed in } T \equiv  (D \subseteq  \bigcup T \wedge  \bigcup T - D \in  T)$===  ,  <nowiki>double_complement</nowiki>
 '' }'' 
 ''then ''  ''have''  $ \forall U\in \tau _2.\  f^{-1}(U) \in  \tau _1$ 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[IsContinuous_def | Topology_ZF_2 ]... Definition of <nowiki>IsContinuous</nowiki>:
$ IsContinuous(\tau _1,\tau _2,f) \equiv  (\forall U\in \tau _2.\  f^{-1}(U) \in  \tau _1)$=== 
 ''qed'' === 

Another condition for continuity: it is sufficient to check if the inverse image of every set in a base is open.

 ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>Top_ZF_2_1_L5</nowiki>:
 ''   assumes '' A1: $ B \text{ is a base for } \tau _2$ ''and '' A2: $ \forall U\in B.\  f^{-1}(U) \in  \tau _1$ ''   shows '' $ f \text{ is continuous }$+++[proof ]>

 ''{ ''  ''fix '' $ V$
 ''assume '' A3: $ V \in  \tau _2$
 ''with '' A1  ''obtain '' $ A$ ''where '' $ A \subseteq  B$,  $ V = \bigcup A$ ''using''  +++^[IsAbaseFor_def | Topology_ZF_1 ]... Definition of <nowiki>IsAbaseFor</nowiki>:
$ B \text{ is a base for } T \equiv  B\subseteq T \wedge  T = \{\bigcup A.\  A\in Pow(B)\}$=== 
 ''with '' A2  ''have''  $ \{f^{-1}(U).\  U\in A\} \subseteq  \tau _1$ 
 ''with '' tau1_is_top  ''have''  $ \bigcup  \{f^{-1}(U).\  U\in A\} \in  \tau _1$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''moreover''   ''from '' $ A \subseteq  B$, $ V = \bigcup A$  ''have''  $ f^{-1}(V) = \bigcup \{f^{-1}(U).\  U\in A\}$ 
 ''ultimately ''  ''have''  $ f^{-1}(V) \in   \tau _1$ 
 '' }'' 
 ''then ''  ''show''  $ f \text{ is continuous }$ ''using''  +++^[IsContinuous_def | Topology_ZF_2 ]... Definition of <nowiki>IsContinuous</nowiki>:
$ IsContinuous(\tau _1,\tau _2,f) \equiv  (\forall U\in \tau _2.\  f^{-1}(U) \in  \tau _1)$=== 
 ''qed'' === 

We can strenghten the previous lemma: it is sufficient to check if the inverse image of every set in a subbase is open. The proof is rather awkward, as usual when we deal with general intersections. We have to keep track of the case when the collection is empty.

 ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>Top_ZF_2_1_L6</nowiki>:
 ''   assumes '' A1: $ B \text{ is a subbase for } \tau _2$ ''and '' A2: $ \forall U\in B.\  f^{-1}(U) \in  \tau _1$ ''   shows '' $ f \text{ is continuous }$+++[proof ]>
 ''let '' $ C = \{\bigcap A.\  A \in  FinPow(B)\}$
 ''from '' A1  ''have''  $ C \text{ is a base for } \tau _2$ ''using''  +++^[IsAsubBaseFor_def | Topology_ZF_1 ]... Definition of <nowiki>IsAsubBaseFor</nowiki>:
$ B \text{ is a subbase for } T \equiv  $
$  B \subseteq  T \wedge  \{\bigcap A.\  A \in  FinPow(B)\} \text{ is a base for } T$=== 
 ''moreover''   ''have''  $ \forall U\in C.\  f^{-1}(U) \in  \tau _1$+++[proof ]>
 ''fix '' $ U$
 ''assume '' $ U\in C$
 ''{ ''  ''assume '' $ f^{-1}(U)=0$
 ''with '' tau1_is_top  ''have''  $ f^{-1}(U) \in  \tau _1$ ''using''  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 '' }'' 
 ''moreover''  
 ''{ ''  ''assume '' $ f^{-1}(U)\neq 0$
 ''then ''  ''have''  $ U\neq 0$ ''   by (rule '' <nowiki>func1_1_L13</nowiki> '')'' 
 ''moreover''   ''from '' $ U\in C$  ''obtain '' $ A$ ''where '' $ A \in  FinPow(B)$ ''and '' $ U = \bigcap A$ 
 ''ultimately ''  ''have''  $ \bigcap A\neq 0$ 
 ''then ''  ''have''  $ A\neq 0$ ''   by (rule '' +++^[inter_nempty_nempty | ZF1 ]...  ''lemma''  <nowiki>inter_nempty_nempty</nowiki>:  ''assumes '' $ \bigcap A \neq  0$  '' shows '' $ A\neq 0$ ===  '')'' 
 ''then ''  ''have''  $ \{f^{-1}(W).\  W\in A\} \neq  0$ 
 ''moreover''   ''from '' A2, $ A \in  FinPow(B)$  ''have''  $ \{f^{-1}(W).\  W\in A\} \in  FinPow(\tau _1)$ ''   by (rule '' +++^[fin_image_fin | Finite_ZF ]...  ''lemma''  <nowiki>fin_image_fin</nowiki>:  ''assumes '' $ \forall V\in B.\  K(V)\in C$  ''and'' $ N \in  FinPow(B)$  '' shows '' $ \{K(V).\  V\in N\} \in  FinPow(C)$ ===  '')'' 
 ''ultimately ''  ''have''  $ \bigcap \{f^{-1}(W).\  W\in A\} \in  \tau _1$ ''using''  +++^[topol_cntxs_valid | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>topol_cntxs_valid</nowiki>:  '' shows '' $ topology0(\tau _1)$  ''and'' $ topology0(\tau _2)$ ===  ,  +++^[fin_inter_open_open | Topology_ZF ]...  ''lemma''   ''(in '' topology0 '') '' <nowiki>fin_inter_open_open</nowiki>:  ''assumes '' $ N\neq 0$,   $ N \in  FinPow(T)$  '' shows '' $ \bigcap N \in  T$ === 
 ''moreover''   ''from '' $ A \in  FinPow(B)$  ''have''  $ A \subseteq  B$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 
 ''with '' tau2_is_top, A1  ''have''  $ A \subseteq  Pow(X_2)$ ''using''  +++^[IsAsubBaseFor_def | Topology_ZF_1 ]... Definition of <nowiki>IsAsubBaseFor</nowiki>:
$ B \text{ is a subbase for } T \equiv  $
$  B \subseteq  T \wedge  \{\bigcap A.\  A \in  FinPow(B)\} \text{ is a base for } T$===  ,  +++^[IsATopology_def | Topology_ZF ]... Definition of <nowiki>IsATopology</nowiki>:
$ T \text{ is a topology } \equiv  (0 \in  T) \wedge  ( \forall M \in  Pow(T).\  \bigcup M \in  T ) \wedge  $
$  ( \forall U\in T.\  \forall  V\in T.\  U\cap V \in  T)$=== 
 ''with '' fmapAssum, $ A\neq 0$, $ U = \bigcap A$  ''have''  $ f^{-1}(U) = \bigcap \{f^{-1}(W).\  W\in A\}$ ''using''  <nowiki>func1_1_L12</nowiki>
 ''ultimately ''  ''have''  $ f^{-1}(U) \in  \tau _1$ 
 '' }'' 
 ''ultimately ''  ''show''  $ f^{-1}(U) \in  \tau _1$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ f \text{ is continuous }$ ''using''  +++^[Top_ZF_2_1_L5 | Topology_ZF_2 ]...  ''lemma''   ''(in '' two_top_spaces0 '') '' <nowiki>Top_ZF_2_1_L5</nowiki>:  ''assumes '' $ B \text{ is a base for } \tau _2$  ''and'' $ \forall U\in B.\  f^{-1}(U) \in  \tau _1$  '' shows '' $ f \text{ is continuous }$ === 
 ''qed'' === 

 ''end

'' +++![Comments on Topology_ZF_2|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Topology_ZF_2"></iframe> </div> </html>
=== 
/***
Contains the stuff you need to use Tiddlyspot
Note you must also have UploadPlugin installed
***/
//{{{

// edit this if you are migrating sites or retrofitting an existing TW
config.tiddlyspotSiteId = 'formalmath';

// make it so you can by default see edit controls via http
config.options.chkHttpReadOnly = false;
window.readOnly = false; // make sure of it (for tw 2.2)

// disable autosave in d3
if (window.location.protocol != "file:")
	config.options.chkGTDLazyAutoSave = false;

// tweak shadow tiddlers to add upload button, password entry box etc
with (config.shadowTiddlers) {
	SiteUrl = 'http://'+config.tiddlyspotSiteId+'.tiddlyspot.com';
	SideBarOptions = SideBarOptions.replace(/(<<saveChanges>>)/,"$1<<tiddler TspotSidebar>>");
	OptionsPanel = OptionsPanel.replace(/^/,"<<tiddler TspotOptions>>");
	DefaultTiddlers = DefaultTiddlers.replace(/^/,"WelcomeToTiddlyspot]] ");
	MainMenu = MainMenu.replace(/^/,"[[WelcomeToTiddlyspot]] ");
}

// create some shadow tiddler content
merge(config.shadowTiddlers,{

'WelcomeToTiddlyspot':[
 "This document is a ~TiddlyWiki from tiddlyspot.com.  A ~TiddlyWiki is an electronic notebook that is great for managing todo lists, personal information, and all sorts of things.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //What now?// &nbsp;&nbsp;@@ Before you can save any changes, you need to enter your password in the form below.  Then configure privacy and other site settings at your [[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]] (your control panel username is //" + config.tiddlyspotSiteId + "//).",
 "<<tiddler TspotControls>>",
 "See also GettingStarted.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Working online// &nbsp;&nbsp;@@ You can edit this ~TiddlyWiki right now, and save your changes using the \"save to web\" button in the column on the right.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Working offline// &nbsp;&nbsp;@@ A fully functioning copy of this ~TiddlyWiki can be saved onto your hard drive or USB stick.  You can make changes and save them locally without being connected to the Internet.  When you're ready to sync up again, just click \"upload\" and your ~TiddlyWiki will be saved back to tiddlyspot.com.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Help!// &nbsp;&nbsp;@@ Find out more about ~TiddlyWiki at [[TiddlyWiki.com|http://tiddlywiki.com]].  Also visit [[TiddlyWiki Guides|http://tiddlywikiguides.org]] for documentation on learning and using ~TiddlyWiki. New users are especially welcome on the [[TiddlyWiki mailing list|http://groups.google.com/group/TiddlyWiki]], which is an excellent place to ask questions and get help.  If you have a tiddlyspot related problem email [[tiddlyspot support|mailto:support@tiddlyspot.com]].",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Enjoy :)// &nbsp;&nbsp;@@ We hope you like using your tiddlyspot.com site.  Please email [[feedback@tiddlyspot.com|mailto:feedback@tiddlyspot.com]] with any comments or suggestions."
].join("\n"),

'TspotControls':[
 "| tiddlyspot password:|<<option pasUploadPassword>>|",
 "| site management:|<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . .  " + config.tiddlyspotSiteId + ">>//(requires tiddlyspot password)//<<br>>[[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]], [[download (go offline)|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download]]|",
 "| links:|[[tiddlyspot.com|http://tiddlyspot.com/]], [[FAQs|http://faq.tiddlyspot.com/]], [[announcements|http://announce.tiddlyspot.com/]], [[blog|http://tiddlyspot.com/blog/]], email [[support|mailto:support@tiddlyspot.com]] & [[feedback|mailto:feedback@tiddlyspot.com]], [[donate|http://tiddlyspot.com/?page=donate]]|"
].join("\n"),

'TspotSidebar':[
 "<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . .  " + config.tiddlyspotSiteId + ">><html><a href='http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download' class='button'>download</a></html>"
].join("\n"),

'TspotOptions':[
 "tiddlyspot password:",
 "<<option pasUploadPassword>>",
 ""
].join("\n")

});
//}}}
| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |
| 18/11/2007 10:05:19 | YourName | [[formalmath.html|file:///home/slawek/Desktop/formalmath.html]] | [[store.cgi|http://formalmath.tiddlyspot.com/store.cgi]] | . | [[index.html | http://formalmath.tiddlyspot.com/index.html]] | . |
| 18/11/2007 10:16:58 | YourName | [[/|http://formalmath.tiddlyspot.com/#author:true]] | [[store.cgi|http://formalmath.tiddlyspot.com/store.cgi]] | . | [[index.html | http://formalmath.tiddlyspot.com/index.html]] | . |
| 18/11/2007 10:23:21 | YourName | [[/|http://formalmath.tiddlyspot.com/#author:true]] | [[store.cgi|http://formalmath.tiddlyspot.com/store.cgi]] | . | [[index.html | http://formalmath.tiddlyspot.com/index.html]] | . | ok |
| 18/11/2007 10:43:13 | YourName | [[/|http://formalmath.tiddlyspot.com/#author:true]] | [[store.cgi|http://formalmath.tiddlyspot.com/store.cgi]] | . | [[index.html | http://formalmath.tiddlyspot.com/index.html]] | . |
| 19/01/2008 21:24:36 | YourName | [[/|http://formalmath.tiddlyspot.com/#author:true]] | [[store.cgi|http://formalmath.tiddlyspot.com/store.cgi]] | . | [[index.html | http://formalmath.tiddlyspot.com/index.html]] | . |
| 04/03/2008 21:59:40 | Slawekk | [[formalmath.html|file:///home/slawek/formalized_math/tiddlyMath/formalmath.html]] | [[store.cgi|http://formalmath.tiddlyspot.com/store.cgi]] | . | [[index.html | http://formalmath.tiddlyspot.com/index.html]] | . | ok |
| 08/03/2008 10:36:32 | Slawekk | [[formalmath.html|file:///home/slawek/formalized_math/tiddlyMath/formalmath.html]] | [[store.cgi|http://formalmath.tiddlyspot.com/store.cgi]] | . | [[index.html | http://formalmath.tiddlyspot.com/index.html]] | . | ok |
| 09/03/2008 12:46:27 | Slawekk | [[formalmath.html|file:///home/slawek/formalized_math/tiddlyMath/formalmath.html]] | [[store.cgi|http://formalmath.tiddlyspot.com/store.cgi]] | . | [[index.html | http://formalmath.tiddlyspot.com/index.html]] | . |
| 20/03/2008 19:25:26 | Slawekk | [[formalmath.html|file:///home/slawek/formalized_math/tiddlyMath/formalmath.html]] | [[store.cgi|http://formalmath.tiddlyspot.com/store.cgi]] | . | [[index.html | http://formalmath.tiddlyspot.com/index.html]] | . |
/***
|''Name:''|PasswordOptionPlugin|
|''Description:''|Extends TiddlyWiki options with non encrypted password option.|
|''Version:''|1.0.2|
|''Date:''|Apr 19, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#PasswordOptionPlugin|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0 (Beta 5)|
***/
//{{{
version.extensions.PasswordOptionPlugin = {
	major: 1, minor: 0, revision: 2, 
	date: new Date("Apr 19, 2007"),
	source: 'http://tiddlywiki.bidix.info/#PasswordOptionPlugin',
	author: 'BidiX (BidiX (at) bidix (dot) info',
	license: '[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D]]',
	coreVersion: '2.2.0 (Beta 5)'
};

config.macros.option.passwordCheckboxLabel = "Save this password on this computer";
config.macros.option.passwordInputType = "password"; // password | text
setStylesheet(".pasOptionInput {width: 11em;}\n","passwordInputTypeStyle");

merge(config.macros.option.types, {
	'pas': {
		elementType: "input",
		valueField: "value",
		eventName: "onkeyup",
		className: "pasOptionInput",
		typeValue: config.macros.option.passwordInputType,
		create: function(place,type,opt,className,desc) {
			// password field
			config.macros.option.genericCreate(place,'pas',opt,className,desc);
			// checkbox linked with this password "save this password on this computer"
			config.macros.option.genericCreate(place,'chk','chk'+opt,className,desc);			
			// text savePasswordCheckboxLabel
			place.appendChild(document.createTextNode(config.macros.option.passwordCheckboxLabel));
		},
		onChange: config.macros.option.genericOnChange
	}
});

merge(config.optionHandlers['chk'], {
	get: function(name) {
		// is there an option linked with this chk ?
		var opt = name.substr(3);
		if (config.options[opt]) 
			saveOptionCookie(opt);
		return config.options[name] ? "true" : "false";
	}
});

merge(config.optionHandlers, {
	'pas': {
 		get: function(name) {
			if (config.options["chk"+name]) {
				return encodeCookie(config.options[name].toString());
			} else {
				return "";
			}
		},
		set: function(name,value) {config.options[name] = decodeCookie(value);}
	}
});

// need to reload options to load passwordOptions
loadOptionsCookie();

/*
if (!config.options['pasPassword'])
	config.options['pasPassword'] = '';

merge(config.optionsDesc,{
		pasPassword: "Test password"
	});
*/
//}}}

/***
|''Name:''|UploadPlugin|
|''Description:''|Save to web a TiddlyWiki|
|''Version:''|4.1.0|
|''Date:''|May 5, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#UploadPlugin|
|''Documentation:''|http://tiddlywiki.bidix.info/#UploadPluginDoc|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0 (#3125)|
|''Requires:''|PasswordOptionPlugin|
***/
//{{{
version.extensions.UploadPlugin = {
	major: 4, minor: 1, revision: 0,
	date: new Date("May 5, 2007"),
	source: 'http://tiddlywiki.bidix.info/#UploadPlugin',
	author: 'BidiX (BidiX (at) bidix (dot) info',
	coreVersion: '2.2.0 (#3125)'
};

//
// Environment
//

if (!window.bidix) window.bidix = {}; // bidix namespace
bidix.debugMode = false;	// true to activate both in Plugin and UploadService
	
//
// Upload Macro
//

config.macros.upload = {
// default values
	defaultBackupDir: '',	//no backup
	defaultStoreScript: "store.php",
	defaultToFilename: "index.html",
	defaultUploadDir: ".",
	authenticateUser: true	// UploadService Authenticate User
};
	
config.macros.upload.label = {
	promptOption: "Save and Upload this TiddlyWiki with UploadOptions",
	promptParamMacro: "Save and Upload this TiddlyWiki in %0",
	saveLabel: "save to web", 
	saveToDisk: "save to disk",
	uploadLabel: "upload"	
};

config.macros.upload.messages = {
	noStoreUrl: "No store URL in parmeters or options",
	usernameOrPasswordMissing: "Username or password missing"
};

config.macros.upload.handler = function(place,macroName,params) {
	if (readOnly)
		return;
	var label;
	if (document.location.toString().substr(0,4) == "http") 
		label = this.label.saveLabel;
	else
		label = this.label.uploadLabel;
	var prompt;
	if (params[0]) {
		prompt = this.label.promptParamMacro.toString().format([this.destFile(params[0], 
			(params[1] ? params[1]:bidix.basename(window.location.toString())), params[3])]);
	} else {
		prompt = this.label.promptOption;
	}
	createTiddlyButton(place, label, prompt, function() {config.macros.upload.action(params);}, null, null, this.accessKey);
};

config.macros.upload.action = function(params)
{
		// for missing macro parameter set value from options
		var storeUrl = params[0] ? params[0] : config.options.txtUploadStoreUrl;
		var toFilename = params[1] ? params[1] : config.options.txtUploadFilename;
		var backupDir = params[2] ? params[2] : config.options.txtUploadBackupDir;
		var uploadDir = params[3] ? params[3] : config.options.txtUploadDir;
		var username = params[4] ? params[4] : config.options.txtUploadUserName;
		var password = config.options.pasUploadPassword; // for security reason no password as macro parameter	
		// for still missing parameter set default value
		if ((!storeUrl) && (document.location.toString().substr(0,4) == "http")) 
			storeUrl = bidix.dirname(document.location.toString())+'/'+config.macros.upload.defaultStoreScript;
		if (storeUrl.substr(0,4) != "http")
			storeUrl = bidix.dirname(document.location.toString()) +'/'+ storeUrl;
		if (!toFilename)
			toFilename = bidix.basename(window.location.toString());
		if (!toFilename)
			toFilename = config.macros.upload.defaultToFilename;
		if (!uploadDir)
			uploadDir = config.macros.upload.defaultUploadDir;
		if (!backupDir)
			backupDir = config.macros.upload.defaultBackupDir;
		// report error if still missing
		if (!storeUrl) {
			alert(config.macros.upload.messages.noStoreUrl);
			clearMessage();
			return false;
		}
		if (config.macros.upload.authenticateUser && (!username || !password)) {
			alert(config.macros.upload.messages.usernameOrPasswordMissing);
			clearMessage();
			return false;
		}
		bidix.upload.uploadChanges(false,null,storeUrl, toFilename, uploadDir, backupDir, username, password); 
		return false; 
};

config.macros.upload.destFile = function(storeUrl, toFilename, uploadDir) 
{
	if (!storeUrl)
		return null;
		var dest = bidix.dirname(storeUrl);
		if (uploadDir && uploadDir != '.')
			dest = dest + '/' + uploadDir;
		dest = dest + '/' + toFilename;
	return dest;
};

//
// uploadOptions Macro
//

config.macros.uploadOptions = {
	handler: function(place,macroName,params) {
		var wizard = new Wizard();
		wizard.createWizard(place,this.wizardTitle);
		wizard.addStep(this.step1Title,this.step1Html);
		var markList = wizard.getElement("markList");
		var listWrapper = document.createElement("div");
		markList.parentNode.insertBefore(listWrapper,markList);
		wizard.setValue("listWrapper",listWrapper);
		this.refreshOptions(listWrapper,false);
		var uploadCaption;
		if (document.location.toString().substr(0,4) == "http") 
			uploadCaption = config.macros.upload.label.saveLabel;
		else
			uploadCaption = config.macros.upload.label.uploadLabel;
		
		wizard.setButtons([
				{caption: uploadCaption, tooltip: config.macros.upload.label.promptOption, 
					onClick: config.macros.upload.action},
				{caption: this.cancelButton, tooltip: this.cancelButtonPrompt, onClick: this.onCancel}
				
			]);
	},
	refreshOptions: function(listWrapper) {
		var uploadOpts = [
			"txtUploadUserName",
			"pasUploadPassword",
			"txtUploadStoreUrl",
			"txtUploadDir",
			"txtUploadFilename",
			"txtUploadBackupDir",
			"chkUploadLog",
			"txtUploadLogMaxLine",
			]
		var opts = [];
		for(i=0; i<uploadOpts.length; i++) {
			var opt = {};
			opts.push()
			opt.option = "";
			n = uploadOpts[i];
			opt.name = n;
			opt.lowlight = !config.optionsDesc[n];
			opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
			opts.push(opt);
		}
		var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
		for(n=0; n<opts.length; n++) {
			var type = opts[n].name.substr(0,3);
			var h = config.macros.option.types[type];
			if (h && h.create) {
				h.create(opts[n].colElements['option'],type,opts[n].name,opts[n].name,"no");
			}
		}
		
	},
	onCancel: function(e)
	{
		backstage.switchTab(null);
		return false;
	},
	
	wizardTitle: "Upload with options",
	step1Title: "These options are saved in cookies in your browser",
	step1Html: "<input type='hidden' name='markList'></input><br>",
	cancelButton: "Cancel",
	cancelButtonPrompt: "Cancel prompt",
	listViewTemplate: {
		columns: [
			{name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
			{name: 'Option', field: 'option', title: "Option", type: 'String'},
			{name: 'Name', field: 'name', title: "Name", type: 'String'}
			],
		rowClasses: [
			{className: 'lowlight', field: 'lowlight'} 
			]}
}

//
// upload functions
//

if (!bidix.upload) bidix.upload = {};

if (!bidix.upload.messages) bidix.upload.messages = {
	//from saving
	invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
	backupSaved: "Backup saved",
	backupFailed: "Failed to upload backup file",
	rssSaved: "RSS feed uploaded",
	rssFailed: "Failed to upload RSS feed file",
	emptySaved: "Empty template uploaded",
	emptyFailed: "Failed to upload empty template file",
	mainSaved: "Main TiddlyWiki file uploaded",
	mainFailed: "Failed to upload main TiddlyWiki file. Your changes have not been saved",
	//specific upload
	loadOriginalHttpPostError: "Can't get original file",
	aboutToSaveOnHttpPost: 'About to upload on %0 ...',
	storePhpNotFound: "The store script '%0' was not found."
};

bidix.upload.uploadChanges = function(onlyIfDirty,tiddlers,storeUrl,toFilename,uploadDir,backupDir,username,password)
{
	var callback = function(status,uploadParams,original,url,xhr) {
		if (!status) {
			displayMessage(bidix.upload.messages.loadOriginalHttpPostError);
			return;
		}
		if (bidix.debugMode) 
			alert(original.substr(0,500)+"\n...");
		// Locate the storeArea div's 
		var posDiv = locateStoreArea(original);
		if((posDiv[0] == -1) || (posDiv[1] == -1)) {
			alert(config.messages.invalidFileError.format([localPath]));
			return;
		}
		bidix.upload.uploadRss(uploadParams,original,posDiv);
	};
	
	if(onlyIfDirty && !store.isDirty())
		return;
	clearMessage();
	// save on localdisk ?
	if (document.location.toString().substr(0,4) == "file") {
		var path = document.location.toString();
		var localPath = getLocalPath(path);
		saveChanges();
	}
	// get original
	var uploadParams = Array(storeUrl,toFilename,uploadDir,backupDir,username,password);
	var originalPath = document.location.toString();
	// If url is a directory : add index.html
	if (originalPath.charAt(originalPath.length-1) == "/")
		originalPath = originalPath + "index.html";
	var dest = config.macros.upload.destFile(storeUrl,toFilename,uploadDir);
	var log = new bidix.UploadLog();
	log.startUpload(storeUrl, dest, uploadDir,  backupDir);
	displayMessage(bidix.upload.messages.aboutToSaveOnHttpPost.format([dest]));
	if (bidix.debugMode) 
		alert("about to execute Http - GET on "+originalPath);
	var r = doHttp("GET",originalPath,null,null,null,null,callback,uploadParams,null);
	if (typeof r == "string")
		displayMessage(r);
	return r;
};

bidix.upload.uploadRss = function(uploadParams,original,posDiv) 
{
	var callback = function(status,params,responseText,url,xhr) {
		if(status) {
			var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
			displayMessage(bidix.upload.messages.rssSaved,bidix.dirname(url)+'/'+destfile);
			bidix.upload.uploadMain(params[0],params[1],params[2]);
		} else {
			displayMessage(bidix.upload.messages.rssFailed);			
		}
	};
	// do uploadRss
	if(config.options.chkGenerateAnRssFeed) {
		var rssPath = uploadParams[1].substr(0,uploadParams[1].lastIndexOf(".")) + ".xml";
		var rssUploadParams = Array(uploadParams[0],rssPath,uploadParams[2],'',uploadParams[4],uploadParams[5]);
		bidix.upload.httpUpload(rssUploadParams,convertUnicodeToUTF8(generateRss()),callback,Array(uploadParams,original,posDiv));
	} else {
		bidix.upload.uploadMain(uploadParams,original,posDiv);
	}
};

bidix.upload.uploadMain = function(uploadParams,original,posDiv) 
{
	var callback = function(status,params,responseText,url,xhr) {
		var log = new bidix.UploadLog();
		if(status) {
			// if backupDir specified
			if ((params[3]) && (responseText.indexOf("backupfile:") > -1))  {
				var backupfile = responseText.substring(responseText.indexOf("backupfile:")+11,responseText.indexOf("\n", responseText.indexOf("backupfile:")));
				displayMessage(bidix.upload.messages.backupSaved,bidix.dirname(url)+'/'+backupfile);
			}
			var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
			displayMessage(bidix.upload.messages.mainSaved,bidix.dirname(url)+'/'+destfile);
			store.setDirty(false);
			log.endUpload("ok");
		} else {
			alert(bidix.upload.messages.mainFailed);
			displayMessage(bidix.upload.messages.mainFailed);
			log.endUpload("failed");			
		}
	};
	// do uploadMain
	var revised = bidix.upload.updateOriginal(original,posDiv);
	bidix.upload.httpUpload(uploadParams,revised,callback,uploadParams);
};

bidix.upload.httpUpload = function(uploadParams,data,callback,params)
{
	var localCallback = function(status,params,responseText,url,xhr) {
		url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
		if (xhr.status == httpStatus.NotFound)
			alert(bidix.upload.messages.storePhpNotFound.format([url]));
		if ((bidix.debugMode) || (responseText.indexOf("Debug mode") >= 0 )) {
			alert(responseText);
			if (responseText.indexOf("Debug mode") >= 0 )
				responseText = responseText.substring(responseText.indexOf("\n\n")+2);
		} else if (responseText.charAt(0) != '0') 
			alert(responseText);
		if (responseText.charAt(0) != '0')
			status = null;
		callback(status,params,responseText,url,xhr);
	};
	// do httpUpload
	var boundary = "---------------------------"+"AaB03x";	
	var uploadFormName = "UploadPlugin";
	// compose headers data
	var sheader = "";
	sheader += "--" + boundary + "\r\nContent-disposition: form-data; name=\"";
	sheader += uploadFormName +"\"\r\n\r\n";
	sheader += "backupDir="+uploadParams[3] +
				";user=" + uploadParams[4] +
				";password=" + uploadParams[5] +
				";uploaddir=" + uploadParams[2];
	if (bidix.debugMode)
		sheader += ";debug=1";
	sheader += ";;\r\n"; 
	sheader += "\r\n" + "--" + boundary + "\r\n";
	sheader += "Content-disposition: form-data; name=\"userfile\"; filename=\""+uploadParams[1]+"\"\r\n";
	sheader += "Content-Type: text/html;charset=UTF-8" + "\r\n";
	sheader += "Content-Length: " + data.length + "\r\n\r\n";
	// compose trailer data
	var strailer = new String();
	strailer = "\r\n--" + boundary + "--\r\n";
	data = sheader + data + strailer;
	if (bidix.debugMode) alert("about to execute Http - POST on "+uploadParams[0]+"\n with \n"+data.substr(0,500)+ " ... ");
	var r = doHttp("POST",uploadParams[0],data,"multipart/form-data; boundary="+boundary,uploadParams[4],uploadParams[5],localCallback,params,null);
	if (typeof r == "string")
		displayMessage(r);
	return r;
};

// same as Saving's updateOriginal but without convertUnicodeToUTF8 calls
bidix.upload.updateOriginal = function(original, posDiv)
{
	if (!posDiv)
		posDiv = locateStoreArea(original);
	if((posDiv[0] == -1) || (posDiv[1] == -1)) {
		alert(config.messages.invalidFileError.format([localPath]));
		return;
	}
	var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
				store.allTiddlersAsHtml() + "\n" +
				original.substr(posDiv[1]);
	var newSiteTitle = getPageTitle().htmlEncode();
	revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
	revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
	revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
	revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
	revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
	return revised;
};

//
// UploadLog
// 
// config.options.chkUploadLog :
//		false : no logging
//		true : logging
// config.options.txtUploadLogMaxLine :
//		-1 : no limit
//      0 :  no Log lines but UploadLog is still in place
//		n :  the last n lines are only kept
//		NaN : no limit (-1)

bidix.UploadLog = function() {
	if (!config.options.chkUploadLog) 
		return; // this.tiddler = null
	this.tiddler = store.getTiddler("UploadLog");
	if (!this.tiddler) {
		this.tiddler = new Tiddler();
		this.tiddler.title = "UploadLog";
		this.tiddler.text = "| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |";
		this.tiddler.created = new Date();
		this.tiddler.modifier = config.options.txtUserName;
		this.tiddler.modified = new Date();
		store.addTiddler(this.tiddler);
	}
	return this;
};

bidix.UploadLog.prototype.addText = function(text) {
	if (!this.tiddler)
		return;
	// retrieve maxLine when we need it
	var maxLine = parseInt(config.options.txtUploadLogMaxLine,10);
	if (isNaN(maxLine))
		maxLine = -1;
	// add text
	if (maxLine != 0) 
		this.tiddler.text = this.tiddler.text + text;
	// Trunck to maxLine
	if (maxLine >= 0) {
		var textArray = this.tiddler.text.split('\n');
		if (textArray.length > maxLine + 1)
			textArray.splice(1,textArray.length-1-maxLine);
			this.tiddler.text = textArray.join('\n');		
	}
	// update tiddler fields
	this.tiddler.modifier = config.options.txtUserName;
	this.tiddler.modified = new Date();
	store.addTiddler(this.tiddler);
	// refresh and notifiy for immediate update
	story.refreshTiddler(this.tiddler.title);
	store.notify(this.tiddler.title, true);
};

bidix.UploadLog.prototype.startUpload = function(storeUrl, toFilename, uploadDir,  backupDir) {
	if (!this.tiddler)
		return;
	var now = new Date();
	var text = "\n| ";
	var filename = bidix.basename(document.location.toString());
	if (!filename) filename = '/';
	text += now.formatString("0DD/0MM/YYYY 0hh:0mm:0ss") +" | ";
	text += config.options.txtUserName + " | ";
	text += "[["+filename+"|"+location + "]] |";
	text += " [[" + bidix.basename(storeUrl) + "|" + storeUrl + "]] | ";
	text += uploadDir + " | ";
	text += "[[" + bidix.basename(toFilename) + " | " +toFilename + "]] | ";
	text += backupDir + " |";
	this.addText(text);
};

bidix.UploadLog.prototype.endUpload = function(status) {
	if (!this.tiddler)
		return;
	this.addText(" "+status+" |");
};

//
// Utilities
// 

bidix.checkPlugin = function(plugin, major, minor, revision) {
	var ext = version.extensions[plugin];
	if (!
		(ext  && 
			((ext.major > major) || 
			((ext.major == major) && (ext.minor > minor))  ||
			((ext.major == major) && (ext.minor == minor) && (ext.revision >= revision))))) {
			// write error in PluginManager
			if (pluginInfo)
				pluginInfo.log.push("Requires " + plugin + " " + major + "." + minor + "." + revision);
			eval(plugin); // generate an error : "Error: ReferenceError: xxxx is not defined"
	}
};

bidix.dirname = function(filePath) {
	if (!filePath) 
		return;
	var lastpos;
	if ((lastpos = filePath.lastIndexOf("/")) != -1) {
		return filePath.substring(0, lastpos);
	} else {
		return filePath.substring(0, filePath.lastIndexOf("\\"));
	}
};

bidix.basename = function(filePath) {
	if (!filePath) 
		return;
	var lastpos;
	if ((lastpos = filePath.lastIndexOf("#")) != -1) 
		filePath = filePath.substring(0, lastpos);
	if ((lastpos = filePath.lastIndexOf("/")) != -1) {
		return filePath.substring(lastpos + 1);
	} else
		return filePath.substring(filePath.lastIndexOf("\\")+1);
};

bidix.initOption = function(name,value) {
	if (!config.options[name])
		config.options[name] = value;
};

//
// Initializations
//

// require PasswordOptionPlugin 1.0.1 or better
bidix.checkPlugin("PasswordOptionPlugin", 1, 0, 1);

// styleSheet
setStylesheet('.txtUploadStoreUrl, .txtUploadBackupDir, .txtUploadDir {width: 22em;}',"uploadPluginStyles");

//optionsDesc
merge(config.optionsDesc,{
	txtUploadStoreUrl: "Url of the UploadService script (default: store.php)",
	txtUploadFilename: "Filename of the uploaded file (default: in index.html)",
	txtUploadDir: "Relative Directory where to store the file (default: . (downloadService directory))",
	txtUploadBackupDir: "Relative Directory where to backup the file. If empty no backup. (default: ''(empty))",
	txtUploadUserName: "Upload Username",
	pasUploadPassword: "Upload Password",
	chkUploadLog: "do Logging in UploadLog (default: true)",
	txtUploadLogMaxLine: "Maximum of lines in UploadLog (default: 10)"
});

// Options Initializations
bidix.initOption('txtUploadStoreUrl','');
bidix.initOption('txtUploadFilename','');
bidix.initOption('txtUploadDir','');
bidix.initOption('txtUploadBackupDir','');
bidix.initOption('txtUploadUserName','');
bidix.initOption('pasUploadPassword','');
bidix.initOption('chkUploadLog',true);
bidix.initOption('txtUploadLogMaxLine','10');


/* don't want this for tiddlyspot sites

// Backstage
merge(config.tasks,{
	uploadOptions: {text: "upload", tooltip: "Change UploadOptions and Upload", content: '<<uploadOptions>>'}
});
config.backstageTasks.push("uploadOptions");

*/


//}}}


 ''theory'' ZF1 ''imports'' [[equalities]]

 ''begin
'' 
Standard Isabelle distribution contains lots of facts about basic set theory. This theory file adds some more.

!Lemmas in Zermelo-Fraenkel set theory

Here we put lemmas from the set theory that we could not find in the standard Isabelle distribution.

If all sets of a nonempty collection are the same, then its union is the same.

 ''lemma''  <nowiki>ZF1_1_L1</nowiki>:
 ''   assumes '' $ C\neq 0$ ''and '' $ \forall y\in C.\  b(y) = A$ ''   shows '' $ (\bigcup y\in C.\  b(y)) = A$ ''using''  <nowiki>assms</nowiki>

The union af all values of a constant meta-function belongs to the same set as the constant.

 ''lemma''  <nowiki>ZF1_1_L2</nowiki>:
 ''   assumes '' A1: $ C\neq 0$ ''and '' A2: $ \forall x\in C.\  b(x) \in  A$ ''and '' A3: $ \forall x y.\  x\in C \wedge  y\in C \longrightarrow  b(x) = b(y)$ ''   shows '' $ (\bigcup x\in C.\  b(x))\in A$+++[proof ]>
 ''from '' A1  ''obtain '' $ x$ ''where '' D1: $ x\in C$ 
 ''with '' A3  ''have''  $ \forall y\in C.\  b(y) = b(x)$ 
 ''with '' A1  ''have''  $ (\bigcup y\in C.\  b(y)) = b(x)$ ''using''  +++^[ZF1_1_L1 | ZF1 ]...  ''lemma''  <nowiki>ZF1_1_L1</nowiki>:  ''assumes '' $ C\neq 0$  ''and'' $ \forall y\in C.\  b(y) = A$  '' shows '' $ (\bigcup y\in C.\  b(y)) = A$ === 
 ''with '' D1, A2  ''show''  $ thesis$ 
 ''qed'' === 

If two meta-functions are the same on a cartesian product, then the subsets defined by them are the same. I am surprised Isabelle can not handle this automatically.

 ''lemma''  <nowiki>ZF1_1_L4</nowiki>:
 ''   assumes '' A1: $ \forall x\in X.\ \forall y\in Y.\  a(x,y) = b(x,y)$ ''   shows '' $ \{a(x,y).\  \langle x,y\rangle  \in  X\times Y\} = \{b(x,y).\  \langle x,y\rangle  \in  X\times Y\}$+++[proof ]>
 ''show''  $ \{a(x, y).\  \langle x,y\rangle  \in  X \times  Y\} \subseteq  \{b(x, y).\  \langle x,y\rangle  \in  X \times  Y\}$+++[proof ]>
 ''fix '' $ z$
 ''assume '' $ z \in  \{a(x, y) .\  \langle x,y\rangle  \in  X \times  Y\}$
 ''with '' A1  ''show''  $ z \in  \{b(x,y).\ \langle x,y\rangle  \in  X\times Y\}$ 
 ''qed'' === 
 ''show''  $ \{b(x, y).\  \langle x,y\rangle  \in  X \times  Y\} \subseteq  \{a(x, y).\  \langle x,y\rangle  \in  X \times  Y\}$+++[proof ]>
 ''fix '' $ z$
 ''assume '' $ z \in  \{b(x, y).\  \langle x,y\rangle  \in  X \times  Y\}$
 ''with '' A1  ''show''  $ z \in  \{a(x,y).\ \langle x,y\rangle  \in  X\times Y\}$ 
 ''qed'' === 
 ''qed'' === 

If two meta-functions are the same on a cartesian product, then the subsets defined by them are the same. This is similar to //ZF1_1_L4//, except that the set definition varies over $ p\in X\times Y$ rather than $ \in X\times Y$.

 ''lemma''  <nowiki>ZF1_1_L4A</nowiki>:
 ''   assumes '' A1: $ \forall x\in X.\ \forall y\in Y.\  a() = b(x,y)$ ''   shows '' $ \{a(p).\  p \in  X\times Y\} = \{b(x,y).\  \langle x,y\rangle  \in  X\times Y\}$+++[proof ]>

 ''{ ''  ''fix '' $ z$
 ''assume '' $ z \in  \{a(p).\  p\in X\times Y\}$
 ''then ''  ''obtain '' $ p$ ''where '' D1: $ z=a(p)$,  $ p\in X\times Y$ 
 ''let '' $ x = fst(p)$
 ''let '' $ y = snd(p)$
 ''from '' A1, D1  ''have''  $ z \in  \{b(x,y).\  \langle x,y\rangle  \in  X\times Y\}$ 
 '' }'' 
 ''then ''  ''show''  $ \{a(p).\  p \in  X\times Y\} \subseteq  \{b(x,y).\  \langle x,y\rangle  \in  X\times Y\}$ 
 ''next '' 
 ''{ ''  ''fix '' $ z$
 ''assume '' $ z \in  \{b(x,y).\  \langle x,y\rangle  \in  X\times Y\}$
 ''then ''  ''obtain '' $ x$ $ y$ ''where '' D1: $ \langle x,y\rangle  \in  X\times Y$,  $ z=b(x,y)$ 
 ''let '' $ p = $
 ''from '' A1, D1  ''have''  $ p\in X\times Y$,  $ z = a(p)$ 
 ''then ''  ''have''  $ z \in  \{a(p).\  p \in  X\times Y\}$ 
 '' }'' 
 ''then ''  ''show''  $ \{b(x,y).\  \langle x,y\rangle  \in  X\times Y\} \subseteq  \{a(p).\  p \in  X\times Y\}$ 
 ''qed'' === 

If two meta-functions are the same on a set, then they define the same set by separation.

 ''lemma''  <nowiki>ZF1_1_L4B</nowiki>:
 ''   assumes '' $ \forall x\in X.\  a(x) = b(x)$ ''   shows '' $ \{a(x).\  x\in X\} = \{b(x).\  x\in X\}$ ''using''  <nowiki>assms</nowiki>

A set defined by a constant meta-function is a singleton.

 ''lemma''  <nowiki>ZF1_1_L5</nowiki>:
 ''   assumes '' $ X\neq 0$ ''and '' $ \forall x\in X.\  b(x) = c$ ''   shows '' $ \{b(x).\  x\in X\} = \{c\}$ ''using''  <nowiki>assms</nowiki>

Most of the time, //auto// does this job, but there are strange cases when the next lemma is needed.

 ''lemma''  <nowiki>subset_with_property</nowiki>:
 ''   assumes '' $ Y = \{x\in X.\  b(x)\}$ ''   shows '' $ Y \subseteq  X$ ''using''  <nowiki>assms</nowiki>

We can choose an element from a nonempty set.

 ''lemma''  <nowiki>nonempty_has_element</nowiki>:
 ''   assumes '' $ X\neq 0$ ''   shows '' $ \exists x.\  x\in X$ ''using''  <nowiki>assms</nowiki>

In Isabelle/ZF the intersection of an empty family is empty. This is exactly lemma //Inter_0// from Isabelle's //equalities// theory. We repeat this lemma here as it is very difficult to find. This is one reason we need comments before every theorem: so that we can search for keywords.

 ''lemma''  <nowiki>inter_empty_empty</nowiki>:
 ''   shows '' $ \bigcap 0 = 0$ ''   by (rule '' <nowiki>Inter_0</nowiki> '')'' 

If an intersection of a collection is not empty, then the collection is not empty. We are (ab)using the fact the the intesection of empty collection is defined to be empty.

 ''lemma''  <nowiki>inter_nempty_nempty</nowiki>:
 ''   assumes '' $ \bigcap A \neq  0$ ''   shows '' $ A\neq 0$ ''using''  <nowiki>assms</nowiki>

For two collections $S,T$ of sets we define the product collection as the collections of cartesian products $A\times B$, where $A\in S, B\in T$.

 ''Definition
'' $ ProductCollection(T,S) \equiv  \bigcup U\in T.\ \{U\times V.\  V\in S\}$

The union of the product collection of collections $S,T$ is the cartesian product of $\bigcup S$ and $\bigcup T$.

 ''lemma''  <nowiki>ZF1_1_L6</nowiki>:
 ''   shows '' $ \bigcup  ProductCollection(S,T) = \bigcup S \times  \bigcup T$ ''using''  +++^[ProductCollection_def | ZF1 ]... Definition of <nowiki>ProductCollection</nowiki>:
$ ProductCollection(T,S) \equiv  \bigcup U\in T.\ \{U\times V.\  V\in S\}$=== 

An intersection of subsets is a subset.

 ''lemma''  <nowiki>ZF1_1_L7</nowiki>:
 ''   assumes '' A1: $ I\neq 0$ ''and '' A2: $ \forall i\in I.\  P(i) \subseteq  X$ ''   shows '' $ ( \bigcap i\in I.\  P(i) ) \subseteq  X$+++[proof ]>
 ''from '' A1  ''obtain '' $ i_0$ ''where '' $ i_0 \in  I$ 
 ''with '' A2  ''have''  $ ( \bigcap i\in I.\  P(i) ) \subseteq  P(i_0)$ ''and '' $ P(i_0) \subseteq  X$ 
 ''thus''  $ ( \bigcap i\in I.\  P(i) ) \subseteq  X$
 ''qed'' === 

Isabelle/ZF has a "THE" construct that allows to define an element if there is only one such that is satisfies given predicate. In pure ZF we can express something similar using the indentity proven below.

 ''lemma''  <nowiki>ZF1_1_L8</nowiki>:
 ''   shows '' $ \bigcup  \{x\} = x$ 

Some properties of singletons.

 ''lemma''  <nowiki>ZF1_1_L9</nowiki>:
 ''   assumes '' A1: $ \exists ! x.\  x\in A \wedge  \phi (x)$ ''   shows '' $ \exists a.\  \{x\in A.\  \phi (x)\} = \{a\}$,  $ \bigcup  \{x\in A.\  \phi (x)\} \in  A$,  $ \phi (\bigcup  \{x\in A.\  \phi (x)\})$+++[proof ]>
 ''from '' A1  ''show''  $ \exists a.\  \{x\in A.\  \phi (x)\} = \{a\}$ 
 ''then ''  ''obtain '' $ a$ ''where '' I: $ \{x\in A.\  \phi (x)\} = \{a\}$ 
 ''then ''  ''have''  $ \bigcup  \{x\in A.\  \phi (x)\} = a$ 
 ''moreover''   ''from '' I  ''have''  $ a \in  \{x\in A.\  \phi (x)\}$ 
 ''hence''  $ a\in A$ ''and '' $ \phi (a)$
 ''ultimately ''  ''show''  $ \bigcup  \{x\in A.\  \phi (x)\} \in  A$ ''and '' $ \phi (\bigcup  \{x\in A.\  \phi (x)\})$ 
 ''qed'' === 

Adding an element of a set to that set does not change the set.

 ''lemma''  <nowiki>set_elem_add</nowiki>:
 ''   assumes '' $ x\in X$ ''   shows '' $ X \cup  \{x\} = X$ ''using''  <nowiki>assms</nowiki>

Here we define a restriction of a collection of sets to a given set. In romantic math this is typically denoted $X\cap M$ and means $\{X\cap A : A\in M \} $. Note there is also restrict$(f,A)$ defined for relations in ZF.thy.

 ''Definition
'' $ M \text{ restricted to } X \equiv  \{X \cap  A .\  A \in  M\}$

Next we show a technical identity that is used to prove sufficiency of some condition for a collection of sets to be a base for a topology.

 ''lemma''  <nowiki>ZF1_1_L10</nowiki>:
 ''   assumes '' A1: $ \forall U\in C.\  \exists A\in B.\  U = \bigcup A$ ''   shows '' $ \bigcup \bigcup  \{\bigcup \{A\in B.\  U = \bigcup A\}.\  U\in C\} = \bigcup C$+++[proof ]>
 ''show''  $ \bigcup (\bigcup U\in C.\  \bigcup \{A \in  B .\  U = \bigcup A\}) \subseteq  \bigcup C$ 
 ''show''  $ \bigcup C \subseteq  \bigcup (\bigcup U\in C.\  \bigcup \{A \in  B .\  U = \bigcup A\})$+++[proof ]>
 ''fix '' $ x$
 ''assume '' $ x \in  \bigcup C$
 ''show''  $ x \in  \bigcup (\bigcup U\in C.\  \bigcup \{A \in  B .\  U = \bigcup A\})$+++[proof ]>
 ''from '' $ x \in  \bigcup C$  ''obtain '' $ U$ ''where '' $ U\in C \wedge  x\in U$ 
 ''with '' A1  ''obtain '' $ A$ ''where '' $ A\in B \wedge  U = \bigcup A$ 
 ''from '' $ U\in C \wedge  x\in U$, $ A\in B \wedge  U = \bigcup A$  ''show''  $ x\in  \bigcup (\bigcup U\in C.\  \bigcup \{A \in  B .\  U = \bigcup A\})$ 
 ''qed'' === 
 ''qed'' === 
 ''qed'' === 

 ''end

'' +++![Comments on ZF1|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/ZF1"></iframe> </div> </html>
=== 


 ''theory'' func_ZF ''imports'' [[func1]]

 ''begin
'' 
In this theory we consider properties of functions that are binary operations, that is they map $X\times X$ into $X$.

!Lifting operations to a function space

It happens quite often that we have a binary operation on some set and we need a similar operation that is defined for functions on that set. For example once we know how to add real numbers we also know how to add real-valued functions: for $f,g:X \rightarrow \mathbf{R}$ we define $(f+g)(x) = f(x) + g(x)$. Note that formally the $+$ means something different on the left hand side of this equality than on the right hand side. This section aims at formalizing this process. We will call it "lifting to a function space", if you have a suggestion for a better name, please let me know.

Since we are writing in generic set notation, the definition below is a bit complicated. Here it what it says: Given a set $X$ and another set $f$ (that represents a binary function on $X$) we are defining $f$ lifted to function space over $X$ as the binary function (a set of pairs) on the space $F = X \rightarrow \textrm{range}(f)$ such that the value of this function on pair $\langle a,b \rangle$ of functions on $X$ is another function $c$ on $X$ with values defined by $c(x) = f\langle a(x), b(x)\rangle$.

 ''Definition
'' $ f \text{ lifted to function space over } X \equiv  $
$  \{\langle  p,\{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\}\rangle .\  $
$  p \in  (X\rightarrow range(f))\times (X\rightarrow range(f))\}$

The result of the lift belongs to the function space.

 ''lemma''  <nowiki>func_ZF_1_L1</nowiki>:
 ''   assumes '' A1: $ f : Y\times Y\rightarrow Y$ ''and '' A2: $ p \in (X\rightarrow range(f))\times (X\rightarrow range(f))$ ''   shows '' $ \{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\} : X\rightarrow range(f)$+++[proof ]>
 ''have''  $ \forall x\in X.\  f\langle fst(p)(x),snd(p)(x)\rangle  \in  range(f)$+++[proof ]>
 ''fix '' $ x$
 ''assume '' $ x\in X$
 ''let '' $ p = \langle fst(p)(x),snd(p)(x)\rangle $
 ''from '' A2, $ x\in X$  ''have''  $ fst(p)(x) \in  range(f)$,  $ snd(p)(x) \in  range(f)$ ''using''  <nowiki>apply_type</nowiki>
 ''with '' A1  ''have''  $ p \in  Y\times Y$ ''using''  <nowiki>func1_1_L5B</nowiki>
 ''with '' A1  ''have''  $ \langle p, f(p)\rangle  \in  f$ ''using''  <nowiki>apply_Pair</nowiki>
 ''with '' A1  ''show''  $ f(p) \in  range(f)$ ''using''  <nowiki>rangeI</nowiki>
 ''qed'' === 
 ''then ''  ''show''  $ thesis$ ''using''  <nowiki>ZF_fun_from_total</nowiki>
 ''qed'' === 

The values of the lift are defined by the value of the liftee in a natural way.

 ''lemma''  <nowiki>func_ZF_1_L2</nowiki>:
 ''   assumes '' A1: $ f : Y\times Y\rightarrow Y$ ''and '' A2: $ p \in  (X\rightarrow range(f))\times (X\rightarrow range(f))$ ''and '' A3: $ x\in X$ ''and '' A4: $ P = \{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\}$ ''   shows '' $ P(x) = f\langle fst(p)(x),snd(p)(x)\rangle $+++[proof ]>
 ''from '' A1, A2  ''have''  $ \{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\} : X \rightarrow  range(f)$ ''using''  +++^[func_ZF_1_L1 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_1_L1</nowiki>:  ''assumes '' $ f : Y\times Y\rightarrow Y$  ''and'' $ p \in (X\rightarrow range(f))\times (X\rightarrow range(f))$  '' shows '' $ \{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\} : X\rightarrow range(f)$ === 
 ''with '' A4  ''have''  $ P :  X \rightarrow  range(f)$ 
 ''with '' A3, A4  ''show''  $ P(x) = f\langle fst(p)(x),snd(p)(x)\rangle $ ''using''  <nowiki>ZF_fun_from_tot_val</nowiki>
 ''qed'' === 

Function lifted to a function space results in function space operator.

 ''theorem''  <nowiki>func_ZF_1_L3</nowiki>:
 ''   assumes '' $ f : Y\times Y\rightarrow Y$ ''and '' $ F = f \text{ lifted to function space over } X$ ''   shows '' $ F : (X\rightarrow range(f))\times (X\rightarrow range(f))\rightarrow (X\rightarrow range(f))$ ''using''  <nowiki>prems</nowiki> ,  +++^[Lift2FcnSpce_def | func_ZF ]... Definition of <nowiki>Lift2FcnSpce</nowiki>:
$ f \text{ lifted to function space over } X \equiv  $
$  \{\langle  p,\{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\}\rangle .\  $
$  p \in  (X\rightarrow range(f))\times (X\rightarrow range(f))\}$===  ,  +++^[func_ZF_1_L1 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_1_L1</nowiki>:  ''assumes '' $ f : Y\times Y\rightarrow Y$  ''and'' $ p \in (X\rightarrow range(f))\times (X\rightarrow range(f))$  '' shows '' $ \{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\} : X\rightarrow range(f)$ ===  ,  <nowiki>ZF_fun_from_total</nowiki>

The values of the lift are defined by the values of the liftee in the natural way.

 ''theorem''  <nowiki>func_ZF_1_L4</nowiki>:
 ''   assumes '' A1: $ f : Y\times Y\rightarrow Y$ ''and '' A2: $ F = f \text{ lifted to function space over } X$ ''and '' A3: $ s:X\rightarrow range(f)$,  $ r:X\rightarrow range(f)$ ''and '' A4: $ x\in X$ ''   shows '' $ (F\langle s,r\rangle )(x) = f\langle s(x),r(x)\rangle $+++[proof ]>
 ''let '' $ p = \langle s,r\rangle $
 ''let '' $ P = \{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\}$
 ''from '' A1, A3, A4  ''have''  $ f : Y\times Y\rightarrow Y$,  $ p \in  (X\rightarrow range(f))\times (X\rightarrow range(f))$,  $ x\in X$,  $ P = \{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\}$ 
 ''then ''  ''have''  $ P(x) = f\langle fst(p)(x),snd(p)(x)\rangle $ ''   by (rule '' +++^[func_ZF_1_L2 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_1_L2</nowiki>:  ''assumes '' $ f : Y\times Y\rightarrow Y$  ''and'' $ p \in  (X\rightarrow range(f))\times (X\rightarrow range(f))$  ''and'' $ x\in X$  ''and'' $ P = \{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\}$  '' shows '' $ P(x) = f\langle fst(p)(x),snd(p)(x)\rangle $ ===  '')'' 
 ''hence''  $ P(x) = f\langle s(x),r(x)\rangle $
 ''moreover''   ''have''  $ P = F\langle s,r\rangle $+++[proof ]>
 ''from '' A1, A2  ''have''  $ F : (X\rightarrow range(f))\times (X\rightarrow range(f))\rightarrow (X\rightarrow range(f))$ ''using''  +++^[func_ZF_1_L3 | func_ZF ]...  ''theorem''  <nowiki>func_ZF_1_L3</nowiki>:  ''assumes '' $ f : Y\times Y\rightarrow Y$  ''and'' $ F = f \text{ lifted to function space over } X$  '' shows '' $ F : (X\rightarrow range(f))\times (X\rightarrow range(f))\rightarrow (X\rightarrow range(f))$ === 
 ''moreover''   ''from '' A3  ''have''  $ p \in  (X\rightarrow range(f))\times (X\rightarrow range(f))$ 
 ''moreover''   ''from '' A2  ''have''  $ F = \{\langle p,\{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\}\rangle .\  $
$      p \in  (X\rightarrow range(f))\times (X\rightarrow range(f))\}$ ''using''  +++^[Lift2FcnSpce_def | func_ZF ]... Definition of <nowiki>Lift2FcnSpce</nowiki>:
$ f \text{ lifted to function space over } X \equiv  $
$  \{\langle  p,\{\langle x,f\langle fst(p)(x),snd(p)(x)\rangle \rangle .\  x \in  X\}\rangle .\  $
$  p \in  (X\rightarrow range(f))\times (X\rightarrow range(f))\}$=== 
 ''ultimately ''  ''show''  $ thesis$ ''using''  <nowiki>ZF_fun_from_tot_val</nowiki>
 ''qed'' === 
 ''ultimately ''  ''show''  $ (F\langle s,r\rangle )(x) = f\langle s(x),r(x)\rangle $ 
 ''qed'' === 


!Associative and commutative operations

In this section we define associative and commutative operations and prove that they remain such when we lift them to a function space.

Typically we say that a binary operation "$\cdot $" on a set $G$ is ''associative'' if $(x\cdot y)\cdot z = x\cdot (y\cdot z)$ for all $x,y,z \in G$. Our actual definition below does not use the multiplicative notation so that we can apply it equally to the additive notation $+$ or whatever infix symbol we may want to use. Instead, we use the generic set theory notation and write $P\langle x,y \rangle$ to denote the value of the operation $P$ on a pair $\langle x,y \rangle \in G\times G$.

 ''Definition
'' $ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$

A binary function $f: X\times X \rightarrow Y$ is commutative if $f\langle x,y \rangle = f\langle y,x \rangle$. Note that in the definition of associativity above we talk about binary ''operation'' and here we say use the term binary ''function''. This is not set in stone, but usually the word "operation" is used when the range is a factor of the domain, while the word "function" allows the range to be a completely unrelated set.

 ''Definition
'' $ f \text{ is commutative on } G \equiv  \forall x\in G.\  \forall y\in G.\  f\langle x,y\rangle  = f\langle y,x\rangle $

The lift of a commutative function is commutative.

 ''lemma''  <nowiki>func_ZF_2_L1</nowiki>:
 ''   assumes '' A1: $ f : G\times G\rightarrow G$ ''and '' A2: $ F = f \text{ lifted to function space over } X$ ''and '' A3: $ s : X\rightarrow range(f)$,  $ r : X\rightarrow range(f)$ ''and '' A4: $ f \text{ is commutative on } G$ ''   shows '' $ F\langle s,r\rangle  = F\langle r,s\rangle $+++[proof ]>
 ''from '' A1, A2  ''have''  $ F : (X\rightarrow range(f))\times (X\rightarrow range(f))\rightarrow (X\rightarrow range(f))$ ''using''  +++^[func_ZF_1_L3 | func_ZF ]...  ''theorem''  <nowiki>func_ZF_1_L3</nowiki>:  ''assumes '' $ f : Y\times Y\rightarrow Y$  ''and'' $ F = f \text{ lifted to function space over } X$  '' shows '' $ F : (X\rightarrow range(f))\times (X\rightarrow range(f))\rightarrow (X\rightarrow range(f))$ === 
 ''with '' A3  ''have''  $ F\langle s,r\rangle  : X\rightarrow range(f)$ ''and '' $ F\langle r,s\rangle  : X\rightarrow range(f)$ ''using''  <nowiki>apply_type</nowiki>
 ''moreover''   ''have''  $ \forall x\in X.\  (F\langle s,r\rangle )(x) = (F\langle r,s\rangle )(x)$+++[proof ]>
 ''fix '' $ x$
 ''assume '' $ x\in X$
 ''from '' A1  ''have''  $ range(f)\subseteq G$ ''using''  <nowiki>func1_1_L5B</nowiki>
 ''with '' A3, $ x\in X$  ''have''  $ s(x) \in  G$ ''and '' $ r(x) \in  G$ ''using''  <nowiki>apply_type</nowiki>
 ''with '' A1, A2, A3, A4, $ x\in X$  ''show''  $ (F\langle s,r\rangle )(x) = (F\langle r,s\rangle )(x)$ ''using''  +++^[func_ZF_1_L4 | func_ZF ]...  ''theorem''  <nowiki>func_ZF_1_L4</nowiki>:  ''assumes '' $ f : Y\times Y\rightarrow Y$  ''and'' $ F = f \text{ lifted to function space over } X$  ''and'' $ s:X\rightarrow range(f)$,   $ r:X\rightarrow range(f)$  ''and'' $ x\in X$  '' shows '' $ (F\langle s,r\rangle )(x) = f\langle s(x),r(x)\rangle $ ===  ,  +++^[IsCommutative_def | func_ZF ]... Definition of <nowiki>IsCommutative</nowiki>:
$ f \text{ is commutative on } G \equiv  \forall x\in G.\  \forall y\in G.\  f\langle x,y\rangle  = f\langle y,x\rangle $=== 
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  <nowiki>fun_extension_iff</nowiki>
 ''qed'' === 

The lift of a commutative function is commutative on the function space.

 ''lemma''  <nowiki>func_ZF_2_L2</nowiki>:
 ''   assumes '' $ f : G\times G\rightarrow G$ ''and '' $ f \text{ is commutative on } G$ ''and '' $ F = f \text{ lifted to function space over } X$ ''   shows '' $ F \text{ is commutative on } (X\rightarrow range(f))$ ''using''  <nowiki>prems</nowiki> ,  +++^[IsCommutative_def | func_ZF ]... Definition of <nowiki>IsCommutative</nowiki>:
$ f \text{ is commutative on } G \equiv  \forall x\in G.\  \forall y\in G.\  f\langle x,y\rangle  = f\langle y,x\rangle $===  ,  +++^[func_ZF_2_L1 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_2_L1</nowiki>:  ''assumes '' $ f : G\times G\rightarrow G$  ''and'' $ F = f \text{ lifted to function space over } X$  ''and'' $ s : X\rightarrow range(f)$,   $ r : X\rightarrow range(f)$  ''and'' $ f \text{ is commutative on } G$  '' shows '' $ F\langle s,r\rangle  = F\langle r,s\rangle $ === 

The lift of an associative function is associative.

 ''lemma''  <nowiki>func_ZF_2_L3</nowiki>:
 ''   assumes '' A2: $ F = f \text{ lifted to function space over } X$ ''and '' A3: $ s : X\rightarrow range(f)$,  $ r : X\rightarrow range(f)$,  $ q : X\rightarrow range(f)$ ''and '' A4: $ f \text{ is associative on } G$ ''   shows '' $ F\langle F\langle s,r\rangle ,q\rangle  = F\langle s,F\langle r,q\rangle \rangle $+++[proof ]>
 ''from '' A4, A2  ''have''  $ F : (X\rightarrow range(f))\times (X\rightarrow range(f))\rightarrow (X\rightarrow range(f))$ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$===  ,  +++^[func_ZF_1_L3 | func_ZF ]...  ''theorem''  <nowiki>func_ZF_1_L3</nowiki>:  ''assumes '' $ f : Y\times Y\rightarrow Y$  ''and'' $ F = f \text{ lifted to function space over } X$  '' shows '' $ F : (X\rightarrow range(f))\times (X\rightarrow range(f))\rightarrow (X\rightarrow range(f))$ === 
 ''with '' A3  ''have''  I: $ F\langle s,r\rangle  : X\rightarrow range(f)$,  $ F\langle r,q\rangle  : X\rightarrow range(f)$,  $ F\langle F\langle s,r\rangle ,q\rangle  : X\rightarrow range(f)$,  $ F\langle s,F\langle r,q\rangle \rangle : X\rightarrow range(f)$ ''using''  <nowiki>apply_type</nowiki>
 ''moreover''   ''have''  $ \forall x\in X.\  (F\langle F\langle s,r\rangle ,q\rangle )(x) = (F\langle s,F\langle r,q\rangle \rangle )(x)$+++[proof ]>
 ''fix '' $ x$
 ''assume '' $ x\in X$
 ''from '' A4  ''have''  $ f:G\times G\rightarrow G$ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''then ''  ''have''  $ range(f)\subseteq G$ ''using''  <nowiki>func1_1_L5B</nowiki>
 ''with '' A3, $ x\in X$  ''have''  $ s(x) \in  G$,  $ r(x) \in  G$,  $ q(x) \in  G$ ''using''  <nowiki>apply_type</nowiki>
 ''with '' A2, I, A3, A4, $ x\in X$, $ f:G\times G\rightarrow G$  ''show''  $ (F\langle F\langle s,r\rangle ,q\rangle )(x) = (F\langle s,F\langle r,q\rangle \rangle )(x)$ ''using''  +++^[func_ZF_1_L4 | func_ZF ]...  ''theorem''  <nowiki>func_ZF_1_L4</nowiki>:  ''assumes '' $ f : Y\times Y\rightarrow Y$  ''and'' $ F = f \text{ lifted to function space over } X$  ''and'' $ s:X\rightarrow range(f)$,   $ r:X\rightarrow range(f)$  ''and'' $ x\in X$  '' shows '' $ (F\langle s,r\rangle )(x) = f\langle s(x),r(x)\rangle $ ===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  <nowiki>fun_extension_iff</nowiki>
 ''qed'' === 

The lift of an associative function is associative on the function space.

 ''lemma''  <nowiki>func_ZF_2_L4</nowiki>:
 ''   assumes '' A1: $ f \text{ is associative on } G$ ''and '' A2: $ F = f \text{ lifted to function space over } X$ ''   shows '' $ F \text{ is associative on } (X\rightarrow range(f))$+++[proof ]>
 ''from '' A1, A2  ''have''  $ F : (X\rightarrow range(f))\times (X\rightarrow range(f))\rightarrow (X\rightarrow range(f))$ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$===  ,  +++^[func_ZF_1_L3 | func_ZF ]...  ''theorem''  <nowiki>func_ZF_1_L3</nowiki>:  ''assumes '' $ f : Y\times Y\rightarrow Y$  ''and'' $ F = f \text{ lifted to function space over } X$  '' shows '' $ F : (X\rightarrow range(f))\times (X\rightarrow range(f))\rightarrow (X\rightarrow range(f))$ === 
 ''moreover''   ''from '' A1, A2  ''have''  $ \forall s \in  X\rightarrow range(f).\  \forall  r \in  X\rightarrow range(f).\  \forall q \in  X\rightarrow range(f).\ $
$    F\langle F\langle s,r\rangle ,q\rangle  = F\langle s,F\langle r,q\rangle \rangle $ ''using''  +++^[func_ZF_2_L3 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_2_L3</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  ''and'' $ s : X\rightarrow range(f)$,   $ r : X\rightarrow range(f)$,   $ q : X\rightarrow range(f)$  ''and'' $ f \text{ is associative on } G$  '' shows '' $ F\langle F\langle s,r\rangle ,q\rangle  = F\langle s,F\langle r,q\rangle \rangle $ === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''qed'' === 


!Restricting operations

In this section we consider conditions under which restriction of the operation to a set inherits properties like commutativity and associativity.

The commutativity is inherited when restricting a function to a set.

 ''lemma''  <nowiki>func_ZF_4_L1</nowiki>:
 ''   assumes '' A1: $ f:X\times X\rightarrow Y$ ''and '' A2: $ A\subseteq X$ ''and '' A3: $ f \text{ is commutative on } X$ ''   shows '' $ restrict(f,A\times A) \text{ is commutative on } A$+++[proof ]>

 ''{ ''  ''fix '' $ x$ $ y$
 ''assume '' $ x\in A$ ''and '' $ y\in A$
 ''with '' A2  ''have''  $ x\in X$ ''and '' $ y\in X$ 
 ''with '' A3, $ x\in A$, $ y\in A$  ''have''  $ restrict(f,A\times A)\langle x,y\rangle  = restrict(f,A\times A)\langle y,x\rangle $ ''using''  +++^[IsCommutative_def | func_ZF ]... Definition of <nowiki>IsCommutative</nowiki>:
$ f \text{ is commutative on } G \equiv  \forall x\in G.\  \forall y\in G.\  f\langle x,y\rangle  = f\langle y,x\rangle $===  ,  <nowiki>restrict_if</nowiki>
 '' }'' 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[IsCommutative_def | func_ZF ]... Definition of <nowiki>IsCommutative</nowiki>:
$ f \text{ is commutative on } G \equiv  \forall x\in G.\  \forall y\in G.\  f\langle x,y\rangle  = f\langle y,x\rangle $=== 
 ''qed'' === 

Next we define what it means that a set is closed with respect to an operation.

 ''Definition
'' $ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$

Associative operation restricted to a set that is closed with resp. to this operation is associative.

 ''lemma''  <nowiki>func_ZF_4_L2</nowiki>:
 ''   assumes '' A1: $ f \text{ is associative on } X$ ''and '' A2: $ A\subseteq X$ ''and '' A3: $ A \text{ is closed under } f$ ''and '' A4: $ x\in A$,  $ y\in A$,  $ z\in A$ ''and '' A5: $ g = restrict(f,A\times A)$ ''   shows '' $ g\langle g\langle x,y\rangle ,z\rangle  = g\langle x,g\langle y,z\rangle \rangle $+++[proof ]>
 ''from '' A4, A2  ''have''  I: $ x\in X$,  $ y\in X$,  $ z\in X$ 
 ''from '' A3, A4, A5  ''have''  $ g\langle g\langle x,y\rangle ,z\rangle  = f\langle f\langle x,y\rangle ,z\rangle $,  $ g\langle x,g\langle y,z\rangle \rangle  = f\langle x,f\langle y,z\rangle \rangle $ ''using''  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$===  ,  <nowiki>restrict_if</nowiki>
 ''moreover''   ''from '' A1, I  ''have''  $ f\langle f\langle x,y\rangle ,z\rangle  = f\langle x,f\langle y,z\rangle \rangle $ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

An associative operation restricted to a set that is closed with resp. to this operation is associative on the set.

 ''lemma''  <nowiki>func_ZF_4_L3</nowiki>:
 ''   assumes '' A1: $ f \text{ is associative on } X$ ''and '' A2: $ A\subseteq X$ ''and '' A3: $ A \text{ is closed under } f$ ''   shows '' $ restrict(f,A\times A) \text{ is associative on } A$+++[proof ]>
 ''let '' $ g = restrict(f,A\times A)$
 ''from '' A1  ''have''  $ f:X\times X\rightarrow X$ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''moreover''   ''from '' A2  ''have''  $ A\times A \subseteq  X\times X$ 
 ''moreover''   ''from '' A3  ''have''  $ \forall p \in  A\times A.\  g(p) \in  A$ ''using''  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$===  ,  <nowiki>restrict_if</nowiki>
 ''ultimately ''  ''have''  $ g : A\times A\rightarrow A$ ''using''  <nowiki>func1_2_L4</nowiki>
 ''moreover''   ''from '' A1, A2, A3  ''have''  $ \forall  x \in  A.\  \forall  y \in  A.\  \forall  z \in  A.\ $
$    g\langle g\langle x,y\rangle ,z\rangle  = g\langle  x,g\langle y,z\rangle \rangle $ ''using''  +++^[func_ZF_4_L2 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_4_L2</nowiki>:  ''assumes '' $ f \text{ is associative on } X$  ''and'' $ A\subseteq X$  ''and'' $ A \text{ is closed under } f$  ''and'' $ x\in A$,   $ y\in A$,   $ z\in A$  ''and'' $ g = restrict(f,A\times A)$  '' shows '' $ g\langle g\langle x,y\rangle ,z\rangle  = g\langle x,g\langle y,z\rangle \rangle $ === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''qed'' === 

The essential condition to show that if a set $A$ is closed with respect to an operation, then it is closed under this operation restricted to any superset of $A$.

 ''lemma''  <nowiki>func_ZF_4_L4</nowiki>:
 ''   assumes '' $ A \text{ is closed under } f$ ''and '' $ A\subseteq B$ ''and '' $ x\in A$,  $ y\in A$ ''and '' $ g = restrict(f,B\times B)$ ''   shows '' $ g\langle x,y\rangle  \in  A$ ''using''  <nowiki>prems</nowiki> ,  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$===  ,  <nowiki>restrict</nowiki>

If a set $A$ is closed under an operation, then it is closed under this operation restricted to any superset of $A$.

 ''lemma''  <nowiki>func_ZF_4_L5</nowiki>:
 ''   assumes '' A1: $ A \text{ is closed under } f$ ''and '' A2: $ A\subseteq B$ ''   shows '' $ A \text{ is closed under } restrict(f,B\times B)$+++[proof ]>
 ''let '' $ g = restrict(f,B\times B)$
 ''from '' A1, A2  ''have''  $ \forall x\in A.\  \forall y\in A.\  g\langle x,y\rangle  \in  A$ ''using''  +++^[func_ZF_4_L4 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_4_L4</nowiki>:  ''assumes '' $ A \text{ is closed under } f$  ''and'' $ A\subseteq B$  ''and'' $ x\in A$,   $ y\in A$  ''and'' $ g = restrict(f,B\times B)$  '' shows '' $ g\langle x,y\rangle  \in  A$ === 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$=== 
 ''qed'' === 

The essential condition to show that intersection of sets that are closed with respect to an operation is closed with respect to the operation.

 ''lemma''  <nowiki>func_ZF_4_L6</nowiki>:
 ''   assumes '' $ A \text{ is closed under } f$ ''and '' $ B \text{ is closed under } f$ ''and '' $ x \in  A\cap B$,  $ y\in  A\cap B$ ''   shows '' $ f\langle x,y\rangle  \in  A\cap B$ ''using''  <nowiki>prems</nowiki> ,  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$=== 

Intersection of sets that are closed with respect to an operation is closed under the operation.

 ''lemma''  <nowiki>func_ZF_4_L7</nowiki>:
 ''   assumes '' $ A \text{ is closed under } f$,  $ B \text{ is closed under } f$ ''   shows '' $ A\cap B \text{ is closed under } f$ ''using''  <nowiki>prems</nowiki> ,  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$=== 


!Compositions

For any set $X$ we can consider a binary operation on the set of functions $f:X\rightarrow X$ defined by $C(f,g) = f\circ g$. Composition of functions (or relations) is defined in the standard Isabelle distribution as a higher order function and denoted with the letter //O//. In this section we consider the corresponding two-argument ZF-function (binary operation), that is a subset of $((X\rightarrow X)\times (X\rightarrow X))\times (X\rightarrow X)$.

We define the notion of composition on the set $X$ as the binary operation on the function space $X\rightarrow X$ that takes two functions and creates the their composition.

 ''Definition
'' $ Composition(X) \equiv  $
$  \{\langle p,fst(p) O snd(p)\rangle .\  p \in  (X\rightarrow X)\times (X\rightarrow X)\}$

Composition operation is a function that maps $(X\rightarrow X)\times (X\rightarrow X)$ into $X\rightarrow X$.

 ''lemma''  <nowiki>func_ZF_5_L1</nowiki>:
 ''   shows '' $ Composition(X) : (X\rightarrow X)\times (X\rightarrow X)\rightarrow (X\rightarrow X)$ ''using''  <nowiki>comp_fun</nowiki> ,  +++^[Composition_def | func_ZF ]... Definition of <nowiki>Composition</nowiki>:
$ Composition(X) \equiv  $
$  \{\langle p,fst(p) O snd(p)\rangle .\  p \in  (X\rightarrow X)\times (X\rightarrow X)\}$===  ,  <nowiki>ZF_fun_from_total</nowiki>

The value of the composition operation is the composition of arguments.

 ''lemma''  <nowiki>func_ZF_5_L2</nowiki>:
 ''   assumes '' $ f:X\rightarrow X$ ''and '' $ g:X\rightarrow X$ ''   shows '' $ Composition(X)\langle f,g\rangle  = f O g$+++[proof ]>
 ''from '' assms  ''have''  $ Composition(X) : (X\rightarrow X)\times (X\rightarrow X)\rightarrow (X\rightarrow X)$,  $ \langle f,g\rangle  \in  (X\rightarrow X)\times (X\rightarrow X)$,  $ Composition(X) = \{\langle p,fst(p) O snd(p)\rangle .\  p \in  (X\rightarrow X)\times (X\rightarrow X)\}$ ''using''  +++^[func_ZF_5_L1 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_5_L1</nowiki>:  '' shows '' $ Composition(X) : (X\rightarrow X)\times (X\rightarrow X)\rightarrow (X\rightarrow X)$ ===  ,  +++^[Composition_def | func_ZF ]... Definition of <nowiki>Composition</nowiki>:
$ Composition(X) \equiv  $
$  \{\langle p,fst(p) O snd(p)\rangle .\  p \in  (X\rightarrow X)\times (X\rightarrow X)\}$=== 
 ''then ''  ''show''  $ Composition(X)\langle f,g\rangle  = f O g$ ''using''  <nowiki>ZF_fun_from_tot_val</nowiki>
 ''qed'' === 

What is the falue of a composition on an argument?

 ''lemma''  <nowiki>func_ZF_5_L3</nowiki>:
 ''   assumes '' $ f:X\rightarrow X$ ''and '' $ g:X\rightarrow X$ ''and '' $ x\in X$ ''   shows '' $ (Composition(X)\langle f,g\rangle )(x) = f(g(x))$ ''using''  <nowiki>assms</nowiki> ,  +++^[func_ZF_5_L2 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_5_L2</nowiki>:  ''assumes '' $ f:X\rightarrow X$  ''and'' $ g:X\rightarrow X$  '' shows '' $ Composition(X)\langle f,g\rangle  = f O g$ ===  ,  <nowiki>comp_fun_apply</nowiki>

The essential condition to show that composition is associative.

 ''lemma''  <nowiki>func_ZF_5_L4</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow X$,  $ g:X\rightarrow X$,  $ h:X\rightarrow X$ ''and '' A2: $ C = Composition(X)$ ''   shows '' $ C\langle C\langle f,g\rangle ,h\rangle  = C\langle  f,C\langle g,h\rangle \rangle $+++[proof ]>
 ''from '' A2  ''have''  $ C : ((X\rightarrow X)\times (X\rightarrow X))\rightarrow (X\rightarrow X)$ ''using''  +++^[func_ZF_5_L1 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_5_L1</nowiki>:  '' shows '' $ Composition(X) : (X\rightarrow X)\times (X\rightarrow X)\rightarrow (X\rightarrow X)$ === 
 ''with '' A1  ''have''  I: $ C\langle f,g\rangle  : X\rightarrow X$,  $ C\langle g,h\rangle  : X\rightarrow X$,  $ C\langle C\langle f,g\rangle ,h\rangle  : X\rightarrow X$,  $ C\langle  f,C\langle g,h\rangle \rangle  : X\rightarrow X$ ''using''  <nowiki>apply_funtype</nowiki>
 ''moreover''   ''have''  $ \forall  x \in  X.\  C\langle C\langle f,g\rangle ,h\rangle (x) = C\langle f,C\langle g,h\rangle \rangle (x)$+++[proof ]>
 ''fix '' $ x$
 ''assume '' $ x\in X$
 ''with '' A1, A2, I  ''have''  $ C\langle C\langle f,g\rangle ,h\rangle   (x) = f(g(h(x)))$,  $ C\langle  f,C\langle g,h\rangle \rangle (x) = f(g(h(x)))$ ''using''  +++^[func_ZF_5_L3 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_5_L3</nowiki>:  ''assumes '' $ f:X\rightarrow X$  ''and'' $ g:X\rightarrow X$  ''and'' $ x\in X$  '' shows '' $ (Composition(X)\langle f,g\rangle )(x) = f(g(x))$ ===  ,  <nowiki>apply_funtype</nowiki>
 ''then ''  ''show''  $ C\langle C\langle f,g\rangle ,h\rangle (x) = C\langle  f,C\langle g,h\rangle \rangle (x)$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  <nowiki>fun_extension_iff</nowiki>
 ''qed'' === 

Composition is an associative operation on $X\rightarrow X$ (the space of functions that map $X$ into itself).

 ''lemma''  <nowiki>func_ZF_5_L5</nowiki>:
 ''   shows '' $ Composition(X) \text{ is associative on } (X\rightarrow X)$+++[proof ]>
 ''let '' $ C = Composition(X)$
 ''have''  $ \forall f\in X\rightarrow X.\  \forall g\in X\rightarrow X.\  \forall h\in X\rightarrow X.\ $
$    C\langle C\langle f,g\rangle ,h\rangle  = C\langle f,C\langle g,h\rangle \rangle $ ''using''  +++^[func_ZF_5_L4 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_5_L4</nowiki>:  ''assumes '' $ f:X\rightarrow X$,   $ g:X\rightarrow X$,   $ h:X\rightarrow X$  ''and'' $ C = Composition(X)$  '' shows '' $ C\langle C\langle f,g\rangle ,h\rangle  = C\langle  f,C\langle g,h\rangle \rangle $ === 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[func_ZF_5_L1 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_5_L1</nowiki>:  '' shows '' $ Composition(X) : (X\rightarrow X)\times (X\rightarrow X)\rightarrow (X\rightarrow X)$ ===  ,  +++^[IsAssociative_def | func_ZF ]... Definition of <nowiki>IsAssociative</nowiki>:
$ P \text{ is associative on } G \equiv  P : G\times G\rightarrow G \wedge  $
$  (\forall  x \in  G.\  \forall  y \in  G.\  \forall  z \in  G.\  $
$  ( P(\langle P(\langle x,y\rangle ),z\rangle ) = P( \langle x,P(\langle y,z\rangle )\rangle  )))$=== 
 ''qed'' === 


!Identity function 

In this section we show some additional facts about the identity function defined in the standard Isabelle's //Perm// theory..

Composing a function with identity does not change the function.

 ''lemma''  <nowiki>func_ZF_6_L1A</nowiki>:
 ''   assumes '' A1: $ f : X\rightarrow X$ ''   shows '' $ Composition(X)\langle f,id(X)\rangle  = f$,  $ Composition(X)\langle id(X),f\rangle  = f$+++[proof ]>
 ''have''  $ Composition(X) : (X\rightarrow X)\times (X\rightarrow X)\rightarrow (X\rightarrow X)$ ''using''  +++^[func_ZF_5_L1 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_5_L1</nowiki>:  '' shows '' $ Composition(X) : (X\rightarrow X)\times (X\rightarrow X)\rightarrow (X\rightarrow X)$ === 
 ''with '' A1  ''have''  $ Composition(X)\langle id(X),f\rangle  : X\rightarrow X$,  $ Composition(X)\langle f,id(X)\rangle  : X\rightarrow X$ ''using''  <nowiki>id_type</nowiki> ,  <nowiki>apply_funtype</nowiki>
 ''moreover''   ''note '' A1
 ''moreover''   ''from '' A1  ''have''  $ \forall x\in X.\  (Composition(X)\langle id(X),f\rangle )(x) = f(x)$,  $ \forall x\in X.\  (Composition(X)\langle f,id(X)\rangle )(x) = f(x)$ ''using''  <nowiki>id_type</nowiki> ,  +++^[func_ZF_5_L3 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_5_L3</nowiki>:  ''assumes '' $ f:X\rightarrow X$  ''and'' $ g:X\rightarrow X$  ''and'' $ x\in X$  '' shows '' $ (Composition(X)\langle f,g\rangle )(x) = f(g(x))$ ===  ,  <nowiki>apply_funtype</nowiki> ,  <nowiki>id_conv</nowiki>
 ''ultimately ''  ''show''  $ Composition(X)\langle id(X),f\rangle  = f$,  $ Composition(X)\langle f,id(X)\rangle  = f$ ''using''  <nowiki>fun_extension_iff</nowiki>
 ''qed'' === 


!Distributive operations

In this section we deal with pairs of operations such that one is distributive with respect to the other, that is $a\cdot (b+c) = a\cdot b + a\cdot c$ and $(b+c)\cdot a = b\cdot a + c\cdot a$ . We show that this property is preserved under restriction to a set closed with respect to both operations. In //EquivClass1// theory we show that this property is preserved by projections to the quotient space if both operations are congruent with respect to the equivalence relation.

We define distributivity as a statement about three sets. The first set is the set on which the operations act. The second set is the additive operation (a ZF function) and the third is the multiplicative operation.

 ''Definition
'' $ IsDistributive(X,A,M) \equiv  (\forall a\in X.\ \forall b\in X.\ \forall c\in X.\ $
$  M\langle a,A\langle b,c\rangle \rangle  = A\langle M\langle a,b\rangle ,M\langle a,c\rangle \rangle  \wedge  $
$  M\langle A\langle b,c\rangle ,a\rangle  = A\langle M\langle b,a\rangle ,M\langle c,a\rangle  \rangle )$

The essential condition to show that distributivity is preserved by restrictions to sets that are closed with respect to both operations.

 ''lemma''  <nowiki>func_ZF_7_L1</nowiki>:
 ''   assumes '' A1: $ IsDistributive(X,A,M)$ ''and '' A2: $ Y\subseteq X$ ''and '' A3: $ Y \text{ is closed under } A$,  $ Y \text{ is closed under } M$ ''and '' A4: $ A_r = restrict(A,Y\times Y)$,  $ M_r = restrict(M,Y\times Y)$ ''and '' A5: $ a\in Y$,  $ b\in Y$,  $ c\in Y$ ''   shows '' $ M_r\langle  a,A_r\langle b,c\rangle  \rangle   = A_r\langle  M_r\langle a,b\rangle ,M_r\langle a,c\rangle  \rangle   \wedge  $
$  M_r\langle  A_r\langle b,c\rangle ,a \rangle  = A_r\langle  M_r\langle b,a\rangle , M_r\langle c,a\rangle  \rangle $+++[proof ]>
 ''from '' A3, A5  ''have''  $ A\langle b,c\rangle  \in  Y$,  $ M\langle a,b\rangle  \in  Y$,  $ M\langle a,c\rangle  \in  Y$,  $ M\langle b,a\rangle  \in  Y$,  $ M\langle c,a\rangle  \in  Y$ ''using''  +++^[IsOpClosed_def | func_ZF ]... Definition of <nowiki>IsOpClosed</nowiki>:
$ A \text{ is closed under } f \equiv  \forall x\in A.\  \forall y\in A.\  f\langle x,y\rangle  \in  A$=== 
 ''with '' A5, A4  ''have''  $ A_r\langle b,c\rangle  \in  Y$,  $ M_r\langle a,b\rangle  \in  Y$,  $ M_r\langle a,c\rangle  \in  Y$,  $ M_r\langle b,a\rangle  \in  Y$,  $ M_r\langle c,a\rangle  \in  Y$ ''using''  <nowiki>restrict</nowiki>
 ''with '' A1, A2, A4, A5  ''show''  $ thesis$ ''using''  <nowiki>restrict</nowiki> ,  +++^[IsDistributive_def | func_ZF ]... Definition of <nowiki>IsDistributive</nowiki>:
$ IsDistributive(X,A,M) \equiv  (\forall a\in X.\ \forall b\in X.\ \forall c\in X.\ $
$  M\langle a,A\langle b,c\rangle \rangle  = A\langle M\langle a,b\rangle ,M\langle a,c\rangle \rangle  \wedge  $
$  M\langle A\langle b,c\rangle ,a\rangle  = A\langle M\langle b,a\rangle ,M\langle c,a\rangle  \rangle )$=== 
 ''qed'' === 

Distributivity is preserved by restrictions to sets that are closed with respect to both operations.

 ''lemma''  <nowiki>func_ZF_7_L2</nowiki>:
 ''   assumes '' $ IsDistributive(X,A,M)$ ''and '' $ Y\subseteq X$ ''and '' $ Y \text{ is closed under } A$,  $ Y \text{ is closed under } M$ ''and '' $ A_r = restrict(A,Y\times Y)$,  $ M_r = restrict(M,Y\times Y)$ ''   shows '' $ IsDistributive(Y,A_r,M_r)$+++[proof ]>
 ''from '' assms  ''have''  $ \forall a\in Y.\ \forall b\in Y.\ \forall c\in Y.\  $
$    M_r\langle  a,A_r\langle b,c\rangle  \rangle  = A_r\langle  M_r\langle a,b\rangle ,M_r\langle a,c\rangle  \rangle  \wedge  $
$    M_r\langle  A_r\langle b,c\rangle ,a \rangle  = A_r\langle  M_r\langle b,a\rangle ,M_r\langle c,a\rangle \rangle $ ''using''  +++^[func_ZF_7_L1 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_7_L1</nowiki>:  ''assumes '' $ IsDistributive(X,A,M)$  ''and'' $ Y\subseteq X$  ''and'' $ Y \text{ is closed under } A$,   $ Y \text{ is closed under } M$  ''and'' $ A_r = restrict(A,Y\times Y)$,   $ M_r = restrict(M,Y\times Y)$  ''and'' $ a\in Y$,   $ b\in Y$,   $ c\in Y$  '' shows '' $ M_r\langle  a,A_r\langle b,c\rangle  \rangle   = A_r\langle  M_r\langle a,b\rangle ,M_r\langle a,c\rangle  \rangle   \wedge  $
$  M_r\langle  A_r\langle b,c\rangle ,a \rangle  = A_r\langle  M_r\langle b,a\rangle , M_r\langle c,a\rangle  \rangle $
=== 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[IsDistributive_def | func_ZF ]... Definition of <nowiki>IsDistributive</nowiki>:
$ IsDistributive(X,A,M) \equiv  (\forall a\in X.\ \forall b\in X.\ \forall c\in X.\ $
$  M\langle a,A\langle b,c\rangle \rangle  = A\langle M\langle a,b\rangle ,M\langle a,c\rangle \rangle  \wedge  $
$  M\langle A\langle b,c\rangle ,a\rangle  = A\langle M\langle b,a\rangle ,M\langle c,a\rangle  \rangle )$=== 
 ''qed'' === 

 ''end

'' +++![Comments on func_ZF|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/func_ZF"></iframe> </div> </html>
=== 
// AJAX code adapted from http://timmorgan.org/mini
// This is already loaded by ziddlywiki...
if(typeof(window["ajax"]) == "undefined") {
  ajax = {
      x: function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}},
      gets: function(url){var x=ajax.x();x.open('GET',url,false);x.send(null);return x.responseText}
  }
}

// Load jsMath
jsMath = {
  Setup: {inited: 1},          // don't run jsMath.Setup.Body() yet
  Autoload: {root: new String(document.location).replace(/[^\/]*$/,'jsMath/')}  // URL to jsMath directory, change if necessary
};
var jsMathstr;
try {
  jsMathstr = ajax.gets(jsMath.Autoload.root+"jsMath.js");
} catch(e) {
  alert("jsMath was not found: you must place the 'jsMath' directory in the same place as this file.  "
       +"The error was:\n"+e.name+": "+e.message);
  throw(e);  // abort eval
}
try {
  window.eval(jsMathstr);
} catch(e) {
  alert("jsMath failed to load.  The error was:\n"+e.name + ": " + e.message + " on line " + e.lineNumber);
}
jsMath.Setup.inited=0;  //  allow jsMath.Setup.Body() to run again

// Define wikifers for latex
config.formatterHelpers.mathFormatHelper = function(w) {
    var e = document.createElement(this.element);
    e.className = this.className;
    var endRegExp = new RegExp(this.terminator, "mg");
    endRegExp.lastIndex = w.matchStart+w.matchLength;
    var matched = endRegExp.exec(w.source);
    if(matched) {
        var txt = w.source.substr(w.matchStart+w.matchLength, 
            matched.index-w.matchStart-w.matchLength);
        if(this.keepdelim) {
          txt = w.source.substr(w.matchStart, matched.index+matched[0].length-w.matchStart);
        }
        e.appendChild(document.createTextNode(txt));
        w.output.appendChild(e);
        w.nextMatch = endRegExp.lastIndex;
    }
}

config.formatters.push({
  name: "displayMath1",
  match: "\\\$\\\$",
  terminator: "\\\$\\\$\\n?", // 2.0 compatability
  termRegExp: "\\\$\\\$\\n?",
  element: "div",
  className: "math",
  handler: config.formatterHelpers.mathFormatHelper
});

config.formatters.push({
  name: "inlineMath1",
  match: "\\\$", 
  terminator: "\\\$", // 2.0 compatability
  termRegExp: "\\\$",
  element: "span",
  className: "math",
  handler: config.formatterHelpers.mathFormatHelper
});

var backslashformatters = new Array(0);

backslashformatters.push({
  name: "inlineMath2",
  match: "\\\\\\\(",
  terminator: "\\\\\\\)", // 2.0 compatability
  termRegExp: "\\\\\\\)",
  element: "span",
  className: "math",
  handler: config.formatterHelpers.mathFormatHelper
});

backslashformatters.push({
  name: "displayMath2",
  match: "\\\\\\\[",
  terminator: "\\\\\\\]\\n?", // 2.0 compatability
  termRegExp: "\\\\\\\]\\n?",
  element: "div",
  className: "math",
  handler: config.formatterHelpers.mathFormatHelper
});

backslashformatters.push({
  name: "displayMath3",
  match: "\\\\begin\\{equation\\}",
  terminator: "\\\\end\\{equation\\}\\n?", // 2.0 compatability
  termRegExp: "\\\\end\\{equation\\}\\n?",
  element: "div",
  className: "math",
  handler: config.formatterHelpers.mathFormatHelper
});

// These can be nested.  e.g. \begin{equation} \begin{array}{ccc} \begin{array}{ccc} ...
backslashformatters.push({
  name: "displayMath4",
  match: "\\\\begin\\{eqnarray\\}",
  terminator: "\\\\end\\{eqnarray\\}\\n?", // 2.0 compatability
  termRegExp: "\\\\end\\{eqnarray\\}\\n?",
  element: "div",
  className: "math",
  keepdelim: true,
  handler: config.formatterHelpers.mathFormatHelper
});

// The escape must come between backslash formatters and regular ones.
// So any latex-like \commands must be added to the beginning of
// backslashformatters here.
backslashformatters.push({
    name: "escape",
    match: "\\\\.",
    handler: function(w) {
        w.output.appendChild(document.createTextNode(w.source.substr(w.matchStart+1,1)));
        w.nextMatch = w.matchStart+2;
    }
});

config.formatters=backslashformatters.concat(config.formatters);

window.wikify = function(source,output,highlightRegExp,tiddler)
{
    if(source && source != "") {
        if(version.major == 2 && version.minor > 0) {
            var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);
            wikifier.subWikifyUnterm(output);
        } else {
            var wikifier = new Wikifier(source,formatter,highlightRegExp,tiddler);
            wikifier.subWikify(output,null);
        }
        jsMath.ProcessBeforeShowing();
    }
}