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:2px 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.4em;margin-left:1.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
 ''theory'' AbelianGroup_ZF ''imports'' [[Group_ZF]]

 ''begin
'' 
A group is called ``abelian`` if its operation is commutative, i.e. $P\langle a,b \rangle = P\langle a,b \rangle$ for all group elements $a,b$, where $P$ is the group operation. It is customary to use the additive notation for abelian groups, so this condition is typically written as $a+b = b+a$. We will be using multiplicative notation though (in which the commutativity condition of the operation is written as $a\cdot b = b\cdot a$), just to avoid the hassle of changing the notation we used for general groups.

!Rearrangement formulae

This section is not interesting and should not be read. Here we will prove formulas is which right hand side uses the same factors as the left hand side, just in different order. These facts are obvious in informal math sense, but Isabelle prover is not able to derive them automatically, so we have to prove them by hand.

Proving the facts about associative and commutative operations is quite tedious in formalized mathematics. To a human the thing is simple: we can arrange the elements in any order and put parantheses wherever we want, it is all the same. However, formalizing this statement would be rather difficult (I think). The next lemma attempts a quasi-algorithmic approach to this type of problem. To prove that two expressions are equal, we first strip one from parantheses, then rearrange the elements in proper order, then put the parantheses where we want them to be. The algorithm for rearrangement is easy to describe: we keep putting the first element (from the right) that is in the wrong place at the left-most position until we get the proper arrangement. As far removing parantheses is concerned Isabelle does its job automatically.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L2</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$,  $ d\in G$,  $ E\in G$,  $ F\in G$ ''   shows '' $ (a\cdot b)\cdot (c\cdot d)\cdot (E\cdot F) = (a\cdot (d\cdot F))\cdot (b\cdot (c\cdot E))$+++[proof ]>
 ''from '' A2  ''have''  $ (a\cdot b)\cdot (c\cdot d)\cdot (E\cdot F) = a\cdot b\cdot c\cdot d\cdot E\cdot F$ ''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$ ===  ,  +++^[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''   ''have''  $ a\cdot b\cdot c\cdot d\cdot E\cdot F = a\cdot d\cdot F\cdot b\cdot c\cdot E$+++[proof ]>
 ''from '' A1, A2  ''have''  $ a\cdot b\cdot c\cdot d\cdot E\cdot F = F\cdot (a\cdot b\cdot c\cdot d\cdot E)$ ''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 $===  ,  +++^[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$ === 
 ''also''   ''from '' A2  ''have''  $ F\cdot (a\cdot b\cdot c\cdot d\cdot E) = F\cdot a\cdot b\cdot c\cdot d\cdot E$ ''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$ ===  ,  +++^[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  ''have''  $ F\cdot a\cdot b\cdot c\cdot d\cdot E = d\cdot (F\cdot a\cdot b\cdot c)\cdot E$ ''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 $===  ,  +++^[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$ === 
 ''also''   ''from '' A2  ''have''  $ d\cdot (F\cdot a\cdot b\cdot c)\cdot E = d\cdot F\cdot a\cdot b\cdot c\cdot E$ ''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$ ===  ,  +++^[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  ''have''  $  d\cdot F\cdot a\cdot b\cdot c\cdot E = a\cdot (d\cdot F)\cdot b\cdot c\cdot E$ ''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 $===  ,  +++^[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$ === 
 ''also''   ''from '' A2  ''have''  $ a\cdot (d\cdot F)\cdot b\cdot c\cdot E = a\cdot d\cdot F\cdot b\cdot c\cdot E$ ''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$ ===  ,  +++^[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$ === 
 ''finally ''  ''show''  $ thesis$ 
 ''qed'' === 
 ''also''   ''from '' A2  ''have''  $ a\cdot d\cdot F\cdot b\cdot c\cdot E = (a\cdot (d\cdot F))\cdot (b\cdot (c\cdot E))$ ''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$ ===  ,  +++^[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$ === 
 ''finally ''  ''show''  $ thesis$ 
 ''qed'' === 

Another useful rearrangement.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L3</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$ ''and '' A3: $ c\in G$,  $ d\in G$,  $ E\in G$,  $ F\in G$ ''   shows '' $ a\cdot b\cdot ((c\cdot d)^{-1}\cdot (E\cdot F)^{-1}) = (a\cdot (E\cdot c)^{-1})\cdot (b\cdot (F\cdot d)^{-1})$+++[proof ]>
 ''from '' A3  ''have''  T1: $ c^{-1}\in G$,  $ d^{-1}\in G$,  $ E^{-1}\in G$,  $ F^{-1}\in G$,  $ (c\cdot d)^{-1}\in G$,  $ (E\cdot F)^{-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 '' A2, T1  ''have''  $ a\cdot b\cdot ((c\cdot d)^{-1}\cdot (E\cdot F)^{-1}) = a\cdot b\cdot (c\cdot d)^{-1}\cdot (E\cdot F)^{-1}$ ''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$ ===  ,  +++^[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 '' A2, A3  ''have''  $ a\cdot b\cdot (c\cdot d)^{-1}\cdot (E\cdot F)^{-1} = (a\cdot b)\cdot (d^{-1}\cdot c^{-1})\cdot (F^{-1}\cdot E^{-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, A2, T1  ''have''  $ (a\cdot b)\cdot (d^{-1}\cdot c^{-1})\cdot (F^{-1}\cdot E^{-1}) = (a\cdot (c^{-1}\cdot E^{-1}))\cdot (b\cdot (d^{-1}\cdot F^{-1}))$ ''using''  +++^[group0_4_L2 | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L2</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$,   $ d\in G$,   $ E\in G$,   $ F\in G$  '' shows '' $ (a\cdot b)\cdot (c\cdot d)\cdot (E\cdot F) = (a\cdot (d\cdot F))\cdot (b\cdot (c\cdot E))$ === 
 ''also''   ''from '' A2, A3  ''have''  $ (a\cdot (c^{-1}\cdot E^{-1}))\cdot (b\cdot (d^{-1}\cdot F^{-1})) = (a\cdot (E\cdot c)^{-1})\cdot (b\cdot (F\cdot d)^{-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}$ === 
 ''finally ''  ''show''  $ thesis$ 
 ''qed'' === 

Some useful rearrangements for two elements of a group.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$ ''   shows '' $ b^{-1}\cdot a^{-1} = a^{-1}\cdot b^{-1}$,  $ (a\cdot b)^{-1} = a^{-1}\cdot b^{-1}$,  $ (a\cdot b^{-1})^{-1} = a^{-1}\cdot b$+++[proof ]>
 ''from '' A2  ''have''  T1: $ b^{-1}\in G$,  $ 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$ === 
 ''with '' A1  ''show''  $ b^{-1}\cdot a^{-1} = a^{-1}\cdot b^{-1}$ ''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 $=== 
 ''with '' A2  ''show''  $ (a\cdot b)^{-1} = a^{-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}$ === 
 ''from '' A2, T1  ''have''  $ (a\cdot b^{-1})^{-1} = (b^{-1})^{-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 '' A1, A2, T1  ''show''  $ (a\cdot b^{-1})^{-1} = a^{-1}\cdot 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}$ ===  ,  +++^[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'' === 

Another bunch of useful rearrangements with three elements.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4A</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ a\cdot b\cdot c = c\cdot a\cdot b$,  $ a^{-1}\cdot (b^{-1}\cdot c^{-1})^{-1} = (a\cdot (b\cdot c)^{-1})^{-1}$,  $ a\cdot (b\cdot c)^{-1} = a\cdot b^{-1}\cdot c^{-1}$,  $ a\cdot (b\cdot c^{-1})^{-1} = a\cdot b^{-1}\cdot c$,  $ a\cdot b^{-1}\cdot c^{-1} = a\cdot c^{-1}\cdot b^{-1}$+++[proof ]>
 ''from '' A1, A2  ''have''  $ a\cdot b\cdot c = c\cdot (a\cdot b)$ ''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 $===  ,  +++^[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 '' A2  ''show''  $ a\cdot b\cdot c = c\cdot a\cdot b$ ''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$ ===  ,  +++^[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 '' A2  ''have''  T: $ b^{-1}\in G$,  $ c^{-1}\in G$,  $ b^{-1}\cdot c^{-1} \in  G$,  $ a\cdot b \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, A2  ''show''  $ a^{-1}\cdot (b^{-1}\cdot c^{-1})^{-1} = (a\cdot (b\cdot c)^{-1})^{-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}$ ===  ,  +++^[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 $=== 
 ''from '' A1, A2, T  ''have''  $ a\cdot (b\cdot c)^{-1} = a\cdot (b^{-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}$ ===  ,  +++^[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 $=== 
 ''with '' A2, T  ''show''  $ a\cdot (b\cdot c)^{-1} = a\cdot b^{-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$ === 
 ''from '' A1, A2, T  ''have''  $ a\cdot (b\cdot c^{-1})^{-1} = a\cdot (b^{-1}\cdot (c^{-1})^{-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}$ ===  ,  +++^[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 $=== 
 ''with '' A2, T  ''show''  $ a\cdot (b\cdot c^{-1})^{-1} = a\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$ ===  ,  +++^[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 '' A1, A2, T  ''have''  $ a\cdot b^{-1}\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$ ===  ,  +++^[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 $=== 
 ''with '' A2, T  ''show''  $ a\cdot b^{-1}\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$ === 
 ''qed'' === 

Another useful rearrangement.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4B</nowiki>:
 ''   assumes '' $ P \text{ is commutative on } G$ ''and '' $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ a\cdot b^{-1}\cdot (b\cdot c^{-1}) = a\cdot c^{-1}$ ''using''  <nowiki>prems</nowiki> ,  +++^[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$ ===  ,  +++^[group0_4_L4 | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ b^{-1}\cdot a^{-1} = a^{-1}\cdot b^{-1}$,  
$ (a\cdot b)^{-1} = a^{-1}\cdot b^{-1}$,   $ (a\cdot b^{-1})^{-1} = a^{-1}\cdot b$ ===  ,  +++^[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$ ===  ,  +++^[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$ === 

A couple of permutations of order for three alements.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4C</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ a\cdot b\cdot c = c\cdot a\cdot b$,  $ a\cdot b\cdot c = a\cdot (c\cdot b)$,  $ a\cdot b\cdot c = c\cdot (a\cdot b)$,  $ a\cdot b\cdot c = c\cdot b\cdot a$+++[proof ]>
 ''from '' A1, A2  ''show''  I: $ a\cdot b\cdot c = c\cdot a\cdot b$ ''using''  +++^[group0_4_L4A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c = c\cdot a\cdot b$,  
$ a^{-1}\cdot (b^{-1}\cdot c^{-1})^{-1} = (a\cdot (b\cdot c)^{-1})^{-1}$,  
$ a\cdot (b\cdot c)^{-1} = a\cdot b^{-1}\cdot c^{-1}$,  
$ a\cdot (b\cdot c^{-1})^{-1} = a\cdot b^{-1}\cdot c$,  
$ a\cdot b^{-1}\cdot c^{-1} = a\cdot c^{-1}\cdot b^{-1}$ === 
 ''also''   ''from '' A1, A2  ''have''  $ c\cdot a\cdot b = a\cdot c\cdot b$ ''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 '' A2  ''have''  $ a\cdot c\cdot b = a\cdot (c\cdot b)$ ''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$ === 
 ''finally ''  ''show''  $ a\cdot b\cdot c = a\cdot (c\cdot b)$ 
 ''from '' A2, I  ''show''  $ a\cdot b\cdot c = c\cdot (a\cdot b)$ ''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, A2  ''have''  $ c\cdot (a\cdot b) = c\cdot (b\cdot a)$ ''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 '' A2  ''have''  $ c\cdot (b\cdot a) = c\cdot b\cdot a$ ''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$ === 
 ''finally ''  ''show''  $ a\cdot b\cdot c = c\cdot b\cdot a$ 
 ''qed'' === 

Some rearangement with three elements and inverse.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4D</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ a^{-1}\cdot b^{-1}\cdot c = c\cdot a^{-1}\cdot b^{-1}$,  $ b^{-1}\cdot a^{-1}\cdot c = c\cdot a^{-1}\cdot b^{-1}$,  $ (a^{-1}\cdot b\cdot c)^{-1} = a\cdot b^{-1}\cdot c^{-1}$+++[proof ]>
 ''from '' A2  ''have''  T: $ a^{-1} \in  G$,  $ b^{-1} \in  G$,  $ c^{-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$ === 
 ''with '' A1, A2  ''show''  $ a^{-1}\cdot b^{-1}\cdot c = c\cdot a^{-1}\cdot b^{-1}$,  $ b^{-1}\cdot a^{-1}\cdot c = c\cdot a^{-1}\cdot b^{-1}$ ''using''  +++^[group0_4_L4A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c = c\cdot a\cdot b$,  
$ a^{-1}\cdot (b^{-1}\cdot c^{-1})^{-1} = (a\cdot (b\cdot c)^{-1})^{-1}$,  
$ a\cdot (b\cdot c)^{-1} = a\cdot b^{-1}\cdot c^{-1}$,  
$ a\cdot (b\cdot c^{-1})^{-1} = a\cdot b^{-1}\cdot c$,  
$ a\cdot b^{-1}\cdot c^{-1} = a\cdot c^{-1}\cdot b^{-1}$ === 
 ''from '' A1, A2, T  ''show''  $ (a^{-1}\cdot b\cdot c)^{-1} = a\cdot b^{-1}\cdot c^{-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}$ ===  ,  +++^[group0_4_L4C | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4C</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c = c\cdot a\cdot b$,   $ a\cdot b\cdot c = a\cdot (c\cdot b)$,  
$ a\cdot b\cdot c = c\cdot (a\cdot b)$,   $ a\cdot b\cdot c = c\cdot b\cdot a$ === 
 ''qed'' === 

Another rearrangement lemma with three elements and equation.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L5</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$ ''and '' A3: $ c = a\cdot b^{-1}$ ''   shows '' $ a = b\cdot c$+++[proof ]>
 ''from '' A2, A3  ''have''  $ c\cdot (b^{-1})^{-1} = a$ ''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_L18 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L18</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  ''and'' $ c = a\cdot b$  '' shows '' $ c\cdot b^{-1} = a$,   $ a^{-1}\cdot c = b$ === 
 ''with '' A1, A2  ''show''  $ thesis$ ''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}$ ===  ,  +++^[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'' === 

In abelian groups we can cancel an element with its inverse even if separated by another element.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6A</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$ ''   shows '' $ a\cdot b\cdot a^{-1} = b$,  $ a^{-1}\cdot b\cdot a = b$,  $ a^{-1}\cdot (b\cdot a) = b$,  $ a\cdot (b\cdot a^{-1}) = b$+++[proof ]>
 ''from '' A1, A2  ''have''  $ a\cdot b\cdot a^{-1} = 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$ ===  ,  +++^[group0_4_L4A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c = c\cdot a\cdot b$,  
$ a^{-1}\cdot (b^{-1}\cdot c^{-1})^{-1} = (a\cdot (b\cdot c)^{-1})^{-1}$,  
$ a\cdot (b\cdot c)^{-1} = a\cdot b^{-1}\cdot c^{-1}$,  
$ a\cdot (b\cdot c^{-1})^{-1} = a\cdot b^{-1}\cdot c$,  
$ a\cdot b^{-1}\cdot c^{-1} = a\cdot c^{-1}\cdot b^{-1}$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  = 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 a^{-1} = b$ 
 ''from '' A1, A2  ''have''  $ a^{-1}\cdot b\cdot a = 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$ ===  ,  +++^[group0_4_L4A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c = c\cdot a\cdot b$,  
$ a^{-1}\cdot (b^{-1}\cdot c^{-1})^{-1} = (a\cdot (b\cdot c)^{-1})^{-1}$,  
$ a\cdot (b\cdot c)^{-1} = a\cdot b^{-1}\cdot c^{-1}$,  
$ a\cdot (b\cdot c^{-1})^{-1} = a\cdot b^{-1}\cdot c$,  
$ a\cdot b^{-1}\cdot c^{-1} = a\cdot c^{-1}\cdot b^{-1}$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  = 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^{-1}\cdot b\cdot a = b$ 
 ''moreover''   ''from '' A2  ''have''  $ a^{-1}\cdot b\cdot a = a^{-1}\cdot (b\cdot a)$ ''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$ === 
 ''ultimately ''  ''show''  $ a^{-1}\cdot (b\cdot a) = b$ 
 ''from '' A1, A2  ''show''  $ a\cdot (b\cdot a^{-1}) = b$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[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 $===  ,  +++^[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'' === 

Another lemma about cancelling with two elements.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6AA</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$ ''   shows '' $ a\cdot b^{-1}\cdot a^{-1} = b^{-1}$ ''using''  <nowiki>prems</nowiki> ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group0_4_L6A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b\cdot a^{-1} = b$,  
$ a^{-1}\cdot b\cdot a = b$,   $ a^{-1}\cdot (b\cdot a) = b$,   $ a\cdot (b\cdot a^{-1}) = b$ === 

Another lemma about cancelling with two elements.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6AB</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$ ''   shows '' $ a\cdot (a\cdot b)^{-1} = b^{-1}$,  $ a\cdot (b\cdot a^{-1}) = b$+++[proof ]>
 ''from '' A2  ''have''  $ a\cdot (a\cdot b)^{-1} = a\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}$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  = a\cdot b^{-1}\cdot 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$ === 
 ''also''   ''from '' A1, A2  ''have''  $ \ldots  =  b^{-1}$ ''using''  +++^[group0_4_L6AA | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6AA</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b^{-1}\cdot a^{-1} = b^{-1}$ === 
 ''finally ''  ''show''  $ a\cdot (a\cdot b)^{-1} = b^{-1}$ 
 ''from '' A1, A2  ''have''  $ a\cdot (b\cdot a^{-1}) = 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$ ===  ,  +++^[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 '' A2  ''have''  $ \ldots  = 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$ ===  ,  +++^[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 a^{-1}) = b$ 
 ''qed'' === 

Another lemma about cancelling with two elements.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6AC</nowiki>:
 ''   assumes '' $ P \text{ is commutative on } G$ ''and '' $ a\in G$,  $ b\in G$ ''   shows '' $ a\cdot (a\cdot b^{-1})^{-1} = b$ ''using''  <nowiki>prems</nowiki> ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  +++^[group0_4_L6AB | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6AB</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot (a\cdot b)^{-1} = b^{-1}$,   $ a\cdot (b\cdot a^{-1}) = b$ ===  ,  +++^[group_inv_of_inv | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group_inv_of_inv</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ a = (a^{-1})^{-1}$ === 

In abelian groups we can cancel an element with its inverse even if separated by two other elements.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6B</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ a\cdot b\cdot c\cdot a^{-1} = b\cdot c$,  $ a^{-1}\cdot b\cdot c\cdot a = b\cdot c$+++[proof ]>
 ''from '' A2  ''have''  $ a\cdot b\cdot c\cdot a^{-1} = a\cdot (b\cdot c)\cdot a^{-1}$,  $ a^{-1}\cdot b\cdot c\cdot a = a^{-1}\cdot (b\cdot c)\cdot a$ ''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$ ===  ,  +++^[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$ ===  ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ === 
 ''with '' A1, A2  ''show''  $ a\cdot b\cdot c\cdot a^{-1} = b\cdot c$,  $ a^{-1}\cdot b\cdot c\cdot a = 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_4_L6A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b\cdot a^{-1} = b$,  
$ a^{-1}\cdot b\cdot a = b$,   $ a^{-1}\cdot (b\cdot a) = b$,   $ a\cdot (b\cdot a^{-1}) = b$ === 
 ''qed'' === 

In abelian groups we can cancel an element with its inverse even if separated by three other elements.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6C</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$,  $ d\in G$ ''   shows '' $ a\cdot b\cdot c\cdot d\cdot a^{-1} = b\cdot c\cdot d$+++[proof ]>
 ''from '' A2  ''have''  $ a\cdot b\cdot c\cdot d\cdot a^{-1} = a\cdot (b\cdot c\cdot d)\cdot a^{-1}$ ''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$ ===  ,  +++^[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''  +++^[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_4_L6A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b\cdot a^{-1} = b$,  
$ a^{-1}\cdot b\cdot a = b$,   $ a^{-1}\cdot (b\cdot a) = b$,   $ a\cdot (b\cdot a^{-1}) = b$ === 
 ''qed'' === 

Another couple of useful rearrangements of three elements and cancelling.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6D</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ a\cdot b^{-1}\cdot (a\cdot c^{-1})^{-1} = c\cdot b^{-1}$,  $ (a\cdot c)^{-1}\cdot (b\cdot c) = a^{-1}\cdot b$,  $ a\cdot (b\cdot (c\cdot a^{-1}\cdot b^{-1})) = c$,  $ a\cdot b\cdot c^{-1}\cdot (c\cdot a^{-1}) = b$+++[proof ]>
 ''from '' A2  ''have''  T: $ a^{-1} \in  G$,  $ b^{-1} \in  G$,  $ c^{-1} \in  G$,  $ a\cdot b \in  G$,  $ a\cdot b^{-1} \in  G$,  $ c^{-1}\cdot a^{-1} \in  G$,  $ c\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$ === 
 ''with '' A1, A2  ''show''  $ a\cdot b^{-1}\cdot (a\cdot c^{-1})^{-1} = c\cdot b^{-1}$ ''using''  +++^[group0_2_L12 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L12</nowiki>:  ''assumes '' $ 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$ ===  ,  +++^[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_4_L6B | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6B</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c\cdot a^{-1} = b\cdot c$,   $ a^{-1}\cdot b\cdot c\cdot a = b\cdot c$ ===  ,  +++^[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 $=== 
 ''from '' A2, T  ''have''  $ (a\cdot c)^{-1}\cdot (b\cdot c) = c^{-1}\cdot a^{-1}\cdot b\cdot c$ ''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}$ ===  ,  +++^[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, T  ''have''  $ \ldots  = a^{-1}\cdot b$ ''using''  +++^[group0_4_L6B | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6B</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c\cdot a^{-1} = b\cdot c$,   $ a^{-1}\cdot b\cdot c\cdot a = b\cdot c$ === 
 ''finally ''  ''show''  $ (a\cdot c)^{-1}\cdot (b\cdot c) = a^{-1}\cdot b$ 
 ''from '' A1, A2, T  ''show''  $ a\cdot (b\cdot (c\cdot a^{-1}\cdot b^{-1})) = 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$ ===  ,  +++^[group0_4_L6B | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6B</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c\cdot a^{-1} = b\cdot c$,   $ a^{-1}\cdot b\cdot c\cdot a = b\cdot c$ ===  ,  +++^[group0_4_L6A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b\cdot a^{-1} = b$,  
$ a^{-1}\cdot b\cdot a = b$,   $ a^{-1}\cdot (b\cdot a) = b$,   $ a\cdot (b\cdot a^{-1}) = b$ === 
 ''from '' T  ''have''  $ a\cdot b\cdot c^{-1}\cdot (c\cdot a^{-1}) = a\cdot b\cdot (c^{-1}\cdot (c\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$ === 
 ''also''   ''from '' A1, A2, T  ''have''  $ \ldots  = b$ ''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))$ ===  ,  +++^[group0_4_L6A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b\cdot a^{-1} = b$,  
$ a^{-1}\cdot b\cdot a = b$,   $ a^{-1}\cdot (b\cdot a) = b$,   $ a\cdot (b\cdot a^{-1}) = b$ === 
 ''finally ''  ''show''  $ a\cdot b\cdot c^{-1}\cdot (c\cdot a^{-1}) = b$ 
 ''qed'' === 

Another useful rearrangement of three elements and cancelling.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6E</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ a\cdot b\cdot (a\cdot c)^{-1} = b\cdot c^{-1}$+++[proof ]>
 ''from '' A2  ''have''  T: $ b^{-1} \in  G$,  $ c^{-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$ === 
 ''with '' A1, A2  ''have''  $ a\cdot (b^{-1})^{-1}\cdot (a\cdot (c^{-1})^{-1})^{-1} = c^{-1}\cdot (b^{-1})^{-1}$ ''using''  +++^[group0_4_L6D | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6D</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b^{-1}\cdot (a\cdot c^{-1})^{-1} = c\cdot b^{-1}$,  
$ (a\cdot c)^{-1}\cdot (b\cdot c) = a^{-1}\cdot b$,  
$ a\cdot (b\cdot (c\cdot a^{-1}\cdot b^{-1})) = c$,  
$ a\cdot b\cdot c^{-1}\cdot (c\cdot a^{-1}) = b$ === 
 ''with '' A1, A2, T  ''show''  $ a\cdot b\cdot (a\cdot c)^{-1} = b\cdot c^{-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}$ ===  ,  +++^[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'' === 

A rearrangement with two elements and canceelling, special case of //group0_4_L6D// when $c=b^{-1}$.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6F</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$ ''   shows '' $ a\cdot b^{-1}\cdot (a\cdot b)^{-1} = b^{-1}\cdot b^{-1}$+++[proof ]>
 ''from '' A2  ''have''  $ b^{-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$ === 
 ''with '' A1, A2  ''have''  $ a\cdot b^{-1}\cdot (a\cdot (b^{-1})^{-1})^{-1} = b^{-1}\cdot b^{-1}$ ''using''  +++^[group0_4_L6D | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6D</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b^{-1}\cdot (a\cdot c^{-1})^{-1} = c\cdot b^{-1}$,  
$ (a\cdot c)^{-1}\cdot (b\cdot c) = a^{-1}\cdot b$,  
$ a\cdot (b\cdot (c\cdot a^{-1}\cdot b^{-1})) = c$,  
$ a\cdot b\cdot c^{-1}\cdot (c\cdot a^{-1}) = b$ === 
 ''with '' A2  ''show''  $ a\cdot b^{-1}\cdot (a\cdot b)^{-1} = b^{-1}\cdot b^{-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}$ === 
 ''qed'' === 

Some other rearrangements with four elements. The algorithm for proof as in //group0_4_L2// works very well here.

 ''lemma''  ''(in'' group0'')'' <nowiki>rearr_ab_gr_4_elemA</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$,  $ d\in G$ ''   shows '' $ a\cdot b\cdot c\cdot d = a\cdot d\cdot b\cdot c$,  $ a\cdot b\cdot c\cdot d = a\cdot c\cdot (b\cdot d)$+++[proof ]>
 ''from '' A1, A2  ''have''  $ a\cdot b\cdot c\cdot d = d\cdot (a\cdot b\cdot c)$ ''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 $===  ,  +++^[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$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  = d\cdot a\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$ ===  ,  +++^[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  ''have''  $ \ldots  = a\cdot d\cdot b\cdot c$ ''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 $===  ,  +++^[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$ === 
 ''finally ''  ''show''  $ a\cdot b\cdot c\cdot d = a\cdot d\cdot b\cdot c$ 
 ''from '' A1, A2  ''have''  $ a\cdot b\cdot c\cdot d = c\cdot (a\cdot b)\cdot d$ ''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 $===  ,  +++^[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$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  = c\cdot a\cdot b\cdot d$ ''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$ ===  ,  +++^[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  ''have''  $ \ldots  = a\cdot c\cdot b\cdot d$ ''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 $===  ,  +++^[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$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  = a\cdot c\cdot (b\cdot d)$ ''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$ ===  ,  +++^[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$ === 
 ''finally ''  ''show''  $ a\cdot b\cdot c\cdot d = a\cdot c\cdot (b\cdot d)$ 
 ''qed'' === 

Some rearrangements with four elements and inverse that are applications of //rearr_ab_gr_4_elem//

 ''lemma''  ''(in'' group0'')'' <nowiki>rearr_ab_gr_4_elemB</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$,  $ d\in G$ ''   shows '' $ a\cdot b^{-1}\cdot c^{-1}\cdot d^{-1} = a\cdot d^{-1}\cdot b^{-1}\cdot c^{-1}$,  $ a\cdot b\cdot c\cdot d^{-1} = a\cdot d^{-1}\cdot b\cdot c$,  $ a\cdot b\cdot c^{-1}\cdot d^{-1} =  a\cdot c^{-1}\cdot (b\cdot d^{-1})$+++[proof ]>
 ''from '' A2  ''have''  T: $ b^{-1} \in  G$,  $ c^{-1} \in  G$,  $ 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$ === 
 ''with '' A1, A2  ''show''  $ a\cdot b^{-1}\cdot c^{-1}\cdot d^{-1} = a\cdot d^{-1}\cdot b^{-1}\cdot c^{-1}$,  $ a\cdot b\cdot c\cdot d^{-1} = a\cdot d^{-1}\cdot b\cdot c$,  $ a\cdot b\cdot c^{-1}\cdot d^{-1} =  a\cdot c^{-1}\cdot (b\cdot d^{-1})$ ''using''  +++^[rearr_ab_gr_4_elemA | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>rearr_ab_gr_4_elemA</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$,   $ d\in G$  '' shows '' $ a\cdot b\cdot c\cdot d = a\cdot d\cdot b\cdot c$,  
$ a\cdot b\cdot c\cdot d = a\cdot c\cdot (b\cdot d)$ === 
 ''qed'' === 

Some rearrangement lemmas with four elements.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L7</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$,  $ d\in G$ ''   shows '' $ a\cdot b\cdot c\cdot d^{-1} = a\cdot d^{-1}\cdot  b\cdot c$,  $ a\cdot d\cdot (b\cdot d\cdot (c\cdot d))^{-1} = a\cdot (b\cdot c)^{-1}\cdot d^{-1}$,  $ a\cdot (b\cdot c)\cdot d = a\cdot b\cdot d\cdot c$+++[proof ]>
 ''from '' A2  ''have''  T: $ b\cdot c \in  G$,  $ d^{-1} \in  G$,  $ b^{-1}\in G$,  $ c^{-1}\in G$,  $ d^{-1}\cdot b \in  G$,  $ c^{-1}\cdot d \in  G$,  $ (b\cdot c)^{-1} \in  G$,  $ b\cdot d \in  G$,  $ b\cdot d\cdot c \in  G$,  $ (b\cdot d\cdot c)^{-1} \in  G$,  $ a\cdot d \in  G$,  $ b\cdot c \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, A2  ''have''  $ a\cdot b\cdot c\cdot d^{-1} = a\cdot (d^{-1}\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$ ===  ,  +++^[group0_4_L4A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c = c\cdot a\cdot b$,  
$ a^{-1}\cdot (b^{-1}\cdot c^{-1})^{-1} = (a\cdot (b\cdot c)^{-1})^{-1}$,  
$ a\cdot (b\cdot c)^{-1} = a\cdot b^{-1}\cdot c^{-1}$,  
$ a\cdot (b\cdot c^{-1})^{-1} = a\cdot b^{-1}\cdot c$,  
$ a\cdot b^{-1}\cdot c^{-1} = a\cdot c^{-1}\cdot b^{-1}$ === 
 ''also''   ''from '' A2, T  ''have''  $ a\cdot (d^{-1}\cdot b\cdot c) = a\cdot d^{-1}\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$ === 
 ''finally ''  ''show''  $ a\cdot b\cdot c\cdot d^{-1} = a\cdot d^{-1}\cdot  b\cdot c$ 
 ''from '' A2, T  ''have''  $ a\cdot d\cdot (b\cdot d\cdot (c\cdot d))^{-1} = a\cdot d\cdot (d^{-1}\cdot (b\cdot d\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$ ===  ,  +++^[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 '' A2, T  ''have''  $ \ldots  = a\cdot (b\cdot d\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$ ===  ,  +++^[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$ === 
 ''also''   ''from '' A1, A2  ''have''  $ \ldots  =  a\cdot (d\cdot (b\cdot c))^{-1}$ ''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 $===  ,  +++^[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 '' A2, T  ''have''  $ \ldots  = a\cdot ((b\cdot c)^{-1}\cdot d^{-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 '' A2, T  ''have''  $ \ldots  =  a\cdot (b\cdot c)^{-1}\cdot d^{-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$ === 
 ''finally ''  ''show''  $ a\cdot d\cdot (b\cdot d\cdot (c\cdot d))^{-1} = a\cdot (b\cdot c)^{-1}\cdot d^{-1}$ 
 ''from '' A2  ''have''  $ a\cdot (b\cdot c)\cdot d = a\cdot (b\cdot (c\cdot d))$ ''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$ ===  ,  +++^[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  ''have''  $ \ldots  =  a\cdot (b\cdot (d\cdot c))$ ''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 $===  ,  +++^[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$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  =  a\cdot b\cdot d\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$ ===  ,  +++^[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$ === 
 ''finally ''  ''show''  $ a\cdot (b\cdot c)\cdot d = a\cdot b\cdot d\cdot c$ 
 ''qed'' === 

Some other rearrangements with four elements.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L8</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$,  $ d\in G$ ''   shows '' $ a\cdot (b\cdot c)^{-1} = (a\cdot d^{-1}\cdot c^{-1})\cdot (d\cdot b^{-1})$,  $ a\cdot b\cdot (c\cdot d) = c\cdot a\cdot (b\cdot d)$,  $ a\cdot b\cdot (c\cdot d) = a\cdot c\cdot (b\cdot d)$,  $ a\cdot (b\cdot c^{-1})\cdot d = a\cdot b\cdot d\cdot c^{-1}$,  $ (a\cdot b)\cdot (c\cdot d)^{-1}\cdot (b\cdot d^{-1})^{-1} = a\cdot c^{-1}$+++[proof ]>
 ''from '' A2  ''have''  T: $ b\cdot c \in  G$,  $ a\cdot b \in  G$,  $ d^{-1} \in  G$,  $ b^{-1}\in G$,  $ c^{-1}\in G$,  $ d^{-1}\cdot b \in  G$,  $ c^{-1}\cdot d \in  G$,  $ (b\cdot c)^{-1} \in  G$,  $ a\cdot b \in  G$,  $ (c\cdot d)^{-1} \in  G$,  $ (b\cdot d^{-1})^{-1} \in  G$,  $ d\cdot b^{-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$ === 
 ''from '' A2  ''have''  $ a\cdot (b\cdot c)^{-1} = a\cdot c^{-1}\cdot b^{-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$ === 
 ''moreover''   ''from '' A2  ''have''  $ a\cdot c^{-1} = (a\cdot d^{-1})\cdot (d\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$ === 
 ''ultimately ''  ''have''  $ a\cdot (b\cdot c)^{-1} = (a\cdot d^{-1})\cdot (d\cdot c^{-1})\cdot b^{-1}$ 
 ''with '' A1, A2, T  ''have''  $ a\cdot (b\cdot c)^{-1}= a\cdot d^{-1}\cdot (c^{-1}\cdot d)\cdot b^{-1}$ ''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 $=== 
 ''with '' A2, T  ''show''  $ a\cdot (b\cdot c)^{-1} = (a\cdot d^{-1}\cdot c^{-1})\cdot (d\cdot b^{-1})$ ''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$ ===  ,  +++^[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 '' A2, T  ''have''  $ a\cdot b\cdot (c\cdot d) = a\cdot b\cdot c\cdot d$ ''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''   ''have''  $ a\cdot b\cdot c\cdot d = c\cdot a\cdot b\cdot d$+++[proof ]>
 ''from '' A1, A2  ''have''  $ a\cdot b\cdot c\cdot d = c\cdot (a\cdot b)\cdot d$ ''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 $===  ,  +++^[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$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  = c\cdot a\cdot b\cdot d$ ''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$ ===  ,  +++^[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$ === 
 ''finally ''  ''show''  $ thesis$ 
 ''qed'' === 
 ''also''   ''from '' A2  ''have''  $ c\cdot a\cdot b\cdot d =  c\cdot a\cdot (b\cdot d)$ ''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$ ===  ,  +++^[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$ === 
 ''finally ''  ''show''  $ a\cdot b\cdot (c\cdot d) = c\cdot a\cdot (b\cdot d)$ 
 ''with '' A1, A2  ''show''  $ a\cdot b\cdot (c\cdot d) = a\cdot c\cdot (b\cdot d)$ ''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 $=== 
 ''from '' A1, A2, T  ''show''  $ a\cdot (b\cdot c^{-1})\cdot d = a\cdot b\cdot d\cdot c^{-1}$ ''using''  +++^[group0_4_L7 | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L7</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$,   $ d\in G$  '' shows '' $ a\cdot b\cdot c\cdot d^{-1} = a\cdot d^{-1}\cdot  b\cdot c$,  
$ a\cdot d\cdot (b\cdot d\cdot (c\cdot d))^{-1} = a\cdot (b\cdot c)^{-1}\cdot d^{-1}$,  
$ a\cdot (b\cdot c)\cdot d = a\cdot b\cdot d\cdot c$ === 
 ''from '' T  ''have''  $ (a\cdot b)\cdot (c\cdot d)^{-1}\cdot (b\cdot d^{-1})^{-1} = (a\cdot b)\cdot ((c\cdot d)^{-1}\cdot (b\cdot d^{-1})^{-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, A2, T  ''have''  $ \ldots  = (a\cdot b)\cdot (c^{-1}\cdot d^{-1}\cdot (d\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}$ ===  ,  +++^[group0_2_L12 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L12</nowiki>:  ''assumes '' $ 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$ ===  ,  +++^[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 '' T  ''have''  $ \ldots  = (a\cdot b)\cdot (c^{-1}\cdot (d^{-1}\cdot (d\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, A2, T  ''have''  $ \ldots  = a\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$ ===  ,  +++^[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))$ ===  ,  +++^[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 $===  ,  +++^[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$ === 
 ''finally ''  ''show''  $ (a\cdot b)\cdot (c\cdot d)^{-1}\cdot (b\cdot d^{-1})^{-1} = a\cdot c^{-1}$ 
 ''qed'' === 

Some other rearrangements with four elements.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L8A</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$,  $ d\in G$ ''   shows '' $ a\cdot b^{-1}\cdot (c\cdot d^{-1}) = a\cdot c\cdot (b^{-1}\cdot d^{-1})$,  $ a\cdot b^{-1}\cdot (c\cdot d^{-1}) = a\cdot c\cdot b^{-1}\cdot d^{-1}$+++[proof ]>
 ''from '' A2  ''have''  T: $ a\in G$,  $ b^{-1} \in  G$,  $ c\in G$,  $ 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$ === 
 ''with '' A1  ''show''  $ a\cdot b^{-1}\cdot (c\cdot d^{-1}) = a\cdot c\cdot (b^{-1}\cdot d^{-1})$ ''   by (rule '' +++^[group0_4_L8 | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L8</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$,   $ d\in G$  '' shows '' $ a\cdot (b\cdot c)^{-1} = (a\cdot d^{-1}\cdot c^{-1})\cdot (d\cdot b^{-1})$,  
$ a\cdot b\cdot (c\cdot d) = c\cdot a\cdot (b\cdot d)$,  
$ a\cdot b\cdot (c\cdot d) = a\cdot c\cdot (b\cdot d)$,  
$ a\cdot (b\cdot c^{-1})\cdot d = a\cdot b\cdot d\cdot c^{-1}$,  
$ (a\cdot b)\cdot (c\cdot d)^{-1}\cdot (b\cdot d^{-1})^{-1} = a\cdot c^{-1}$ ===  '')'' 
 ''with '' A2, T  ''show''  $ a\cdot b^{-1}\cdot (c\cdot d^{-1}) = a\cdot c\cdot b^{-1}\cdot d^{-1}$ ''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$ ===  ,  +++^[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'' === 

Some rearrangements with an equation.

 ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L9</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$,  $ d\in G$ ''and '' A3: $ a = b\cdot c^{-1}\cdot d^{-1}$ ''   shows '' $ d = b\cdot a^{-1}\cdot c^{-1}$,  $ d = a^{-1}\cdot b\cdot c^{-1}$,  $ b = a\cdot d\cdot c$+++[proof ]>
 ''from '' A2  ''have''  T: $ a^{-1} \in  G$,  $ c^{-1} \in  G$,  $ d^{-1} \in  G$,  $ b\cdot 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 '' A2, A3  ''have''  $ a\cdot (d^{-1})^{-1} =  b\cdot c^{-1}$ ''using''  +++^[group0_2_L18 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L18</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  ''and'' $ c = a\cdot b$  '' shows '' $ c\cdot b^{-1} = a$,   $ a^{-1}\cdot c = b$ === 
 ''with '' A2  ''have''  $ b\cdot c^{-1} = a\cdot d$ ''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}$ === 
 ''with '' A2, T  ''have''  I: $ a^{-1}\cdot (b\cdot c^{-1}) = d$ ''using''  +++^[group0_2_L18 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L18</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$,   $ c\in G$  ''and'' $ c = a\cdot b$  '' shows '' $ c\cdot b^{-1} = a$,   $ a^{-1}\cdot c = b$ === 
 ''with '' A1, A2, T  ''show''  $ d = b\cdot a^{-1}\cdot c^{-1}$,  $ d = a^{-1}\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$ ===  ,  +++^[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 $=== 
 ''from '' A3  ''have''  $ a\cdot d\cdot c = (b\cdot c^{-1}\cdot d^{-1})\cdot d\cdot c$ 
 ''also''   ''from '' A2, T  ''have''  $ \ldots  = b\cdot c^{-1}\cdot (d^{-1}\cdot d)\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 '' A2, T  ''have''  $ \ldots  =  b\cdot c^{-1}\cdot c$ ''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))$ === 
 ''also''   ''from '' A2, T  ''have''  $ \ldots  =  b\cdot (c^{-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$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  = 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 ''  ''have''  $ a\cdot d\cdot c = b$ 
 ''thus''  $ b = a\cdot d\cdot c$
 ''qed'' === 

 ''end

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

The content of this page by Sławomir Kołodyński (other than the standard <nowiki>TiddlyWiki</nowiki> content) is licensed under a [[Creative Commons Attribution 3.0 License | http://creativecommons.org/licenses/by/3.0/us/]].

+++[Comments|click to leave comment]
<html> <div> <iframe style="width:70%;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. Contributed 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
 ''assumes '' Pfun: $ P : G\times G\rightarrow G$
 ''assumes '' Qfun: $ Q : H\times H\rightarrow H$
 ''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''  +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ ===  ,  +++^[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$ ===  ,  +++^[ZF_fun_from_tot_val | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_tot_val</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$  ''and'' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$  '' shows '' $ f(x) = b(x)$ === 

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)\}$===  ,  +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ === 

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 $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) \}$===  ,  +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ === 

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) \}$===  ,  +++^[ZF_fun_from_tot_val | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_tot_val</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$  ''and'' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$  '' shows '' $ f(x) = b(x)$ === 
 ''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 equivalence 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)\circ 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)\circ 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''  +++^[equiv_is_sym | Fol1 ]...  ''lemma''  <nowiki>equiv_is_sym</nowiki>:  ''assumes '' $ equiv(X,r)$  ''and'' $ \langle x,y\rangle  \in  r$  '' shows '' $ \langle y,x\rangle  \in  r$ === 
 ''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) \text{ Xor }  (y\in A)$ ''   shows '' $ (r\{x\} \in  B)  \text{ 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'' Field_ZF ''imports'' [[Ring_ZF]]

 ''begin
'' 
This theory covers basic facts about fields.

!Definition and basic properties

In this section we define what is a field and list the basic properties of fields.

Field is a notrivial commutative ring such that all non-zero elements have an inverse. We define the notion of being a field as a statement about three sets. The first set, denoted //K// is the carrier of the field. The second set, denoted //A// represents the additive operation on //K// (recall that in ZF set theory functions are sets). The third set //M// represents the multiplicative operation on //K//.

 ''Definition
'' $ IsAfield(K,A,M) \equiv  $
$  (IsAring(K,A,M) \wedge  (M \text{ is commutative on } K) \wedge $
$  TheNeutralElement(K,A) \neq  TheNeutralElement(K,M) \wedge  $
$  (\forall a\in K.\  a\neq TheNeutralElement(K,A)\longrightarrow $
$  (\exists b\in K.\  M\langle a,b\rangle  = TheNeutralElement(K,M))))$

The //field0// context extends the //ring0// context adding field-related assumptions and notation related to the multiplicative inverse.

 ''Locale '' field0 = ring0 K +
 ''assumes '' mult_commute: $ M \text{ is commutative on } K$
 ''assumes '' not_triv: $ 0  \neq  1 $
 ''assumes '' inv_exists: $ \forall a\in K.\  a\neq 0  \longrightarrow  (\exists b\in K.\  a\cdot b = 1 )$
 ''defines '' $ K_0 \equiv  K-\{0 \}$
 ''defines '' $ a^{-1} \equiv  GroupInv(K_0,restrict(M,K_0\times K_0))(a)$


The next lemma assures us that we are talking fields in the //field0// context.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L1</nowiki>:
 ''   shows '' $ IsAfield(K,A,M)$ ''using''  <nowiki>ringAssum</nowiki> ,  <nowiki>mult_commute</nowiki> ,  <nowiki>not_triv</nowiki> ,  <nowiki>inv_exists</nowiki> ,  +++^[IsAfield_def | Field_ZF ]... Definition of <nowiki>IsAfield</nowiki>:
$ IsAfield(K,A,M) \equiv  $
$  (IsAring(K,A,M) \wedge  (M \text{ is commutative on } K) \wedge $
$  TheNeutralElement(K,A) \neq  TheNeutralElement(K,M) \wedge  $
$  (\forall a\in K.\  a\neq TheNeutralElement(K,A)\longrightarrow $
$  (\exists b\in K.\  M\langle a,b\rangle  = TheNeutralElement(K,M))))$=== 

We can use theorems proven in the //field0// context whenever we talk about a field.

 ''lemma''  <nowiki>field_field0</nowiki>:
 ''   assumes '' $ IsAfield(K,A,M)$ ''   shows '' $ field0(K,A,M)$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsAfield_def | Field_ZF ]... Definition of <nowiki>IsAfield</nowiki>:
$ IsAfield(K,A,M) \equiv  $
$  (IsAring(K,A,M) \wedge  (M \text{ is commutative on } K) \wedge $
$  TheNeutralElement(K,A) \neq  TheNeutralElement(K,M) \wedge  $
$  (\forall a\in K.\  a\neq TheNeutralElement(K,A)\longrightarrow $
$  (\exists b\in K.\  M\langle a,b\rangle  = TheNeutralElement(K,M))))$===  ,  <nowiki>field0_axioms.intro</nowiki> ,  <nowiki>ring0_def</nowiki> ,  <nowiki>field0_def</nowiki>

Let's have an explicit statement that the multiplication in fields is commutative.

 ''lemma''  ''(in'' field0'')'' <nowiki>field_mult_comm</nowiki>:
 ''   assumes '' $ a\in K$,  $ b\in K$ ''   shows '' $ a\cdot b = b\cdot a$ ''using''  <nowiki>mult_commute</nowiki> ,  <nowiki>assms</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 $=== 

Fields do not have zero divisors.

 ''lemma''  ''(in'' field0'')'' <nowiki>field_has_no_zero_divs</nowiki>:
 ''   shows '' $ HasNoZeroDivs(K,A,M)$+++[proof ]>
++++[{ ]>
 ''fix '' $ a$ $ b$
 ''assume '' A1: $ a\in K$,  $ b\in K$ ''and '' A2: $ a\cdot b = 0 $ ''and '' A3: $ b\neq 0 $
 ''from '' inv_exists, A1, A3  ''obtain '' $ c$ ''where '' I: $ c\in K$ ''and '' II: $ b\cdot c = 1 $ 
 ''from '' A2  ''have''  $ a\cdot b\cdot c = 0 \cdot c$ 
 ''with '' A1, I  ''have''  $ a\cdot (b\cdot c) = 0 $ ''using''  +++^[Ring_ZF_1_L11 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + b + c = a + (b + c)$,   $ a\cdot b\cdot c = a\cdot (b\cdot c)$ ===  ,  +++^[Ring_ZF_1_L6 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L6</nowiki>:  ''assumes '' $ x\in R$  '' shows '' $ 0 \cdot x = 0 $,   $ x\cdot 0  = 0 $ === 
 ''with '' A1, II  ''have''  $ a=0  $ ''using''  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ === 
===  ''}'' 
 ''then ''  ''have''  $ \forall a\in K.\ \forall b\in K.\  a\cdot b = 0  \longrightarrow  a=0  \vee  b=0 $ 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[HasNoZeroDivs_def | Ring_ZF ]... Definition of <nowiki>HasNoZeroDivs</nowiki>:
$ HasNoZeroDivs(R,A,M) \equiv  (\forall a\in R.\  \forall b\in R.\  $
$  M\langle  a,b\rangle  = TheNeutralElement(R,A) \longrightarrow $
$  a = TheNeutralElement(R,A) \vee  b = TheNeutralElement(R,A))$=== 
 ''qed'' === 

$K_0$ (the set of nonzero field elements is closed with respect to multiplication.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L2</nowiki>:
 ''   shows '' $ K_0 \text{ is closed under } M$ ''using''  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ ===  ,  +++^[field_has_no_zero_divs | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>field_has_no_zero_divs</nowiki>:  '' shows '' $ HasNoZeroDivs(K,A,M)$ ===  ,  +++^[Ring_ZF_1_L12 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L12</nowiki>:  ''assumes '' $ HasNoZeroDivs(R,A,M)$  ''and'' $ a\in R$,   $ a\neq 0 $,   $ b\in R$,   $ b\neq 0 $  '' shows '' $ a\cdot b\neq 0 $ ===  ,  +++^[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$=== 

Any nonzero element has a right inverse that is nonzero.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L3</nowiki>:
 ''   assumes '' A1: $ a\in K_0$ ''   shows '' $ \exists b\in K_0.\  a\cdot b = 1 $+++[proof ]>
 ''from '' inv_exists, A1  ''obtain '' $ b$ ''where '' $ b\in K$ ''and '' $ a\cdot b = 1 $ 
 ''with '' not_triv, A1  ''show''  $ \exists b\in K_0.\  a\cdot b = 1 $ ''using''  +++^[Ring_ZF_1_L6 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L6</nowiki>:  ''assumes '' $ x\in R$  '' shows '' $ 0 \cdot x = 0 $,   $ x\cdot 0  = 0 $ === 
 ''qed'' === 

If we remove zero, the field with multiplication becomes a group and we can use all theorems proven in //group0// context.

 ''theorem''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L4</nowiki>:
 ''   shows '' $ \text{IsAgroup}(K_0,restrict(M,K_0\times K_0))$,  $ group0(K_0,restrict(M,K_0\times K_0))$,  $ 1  = TheNeutralElement(K_0,restrict(M,K_0\times K_0))$+++[proof ]>
 ''let '' $ f = restrict(M,K_0\times K_0)$
 ''have''  $ M \text{ is associative on } K$,  $ K_0 \subseteq  K$,  $ K_0 \text{ is closed under } M$ ''using''  +++^[Field_ZF_1_L1 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L1</nowiki>:  '' shows '' $ IsAfield(K,A,M)$ ===  ,  +++^[IsAfield_def | Field_ZF ]... Definition of <nowiki>IsAfield</nowiki>:
$ IsAfield(K,A,M) \equiv  $
$  (IsAring(K,A,M) \wedge  (M \text{ is commutative on } K) \wedge $
$  TheNeutralElement(K,A) \neq  TheNeutralElement(K,M) \wedge  $
$  (\forall a\in K.\  a\neq TheNeutralElement(K,A)\longrightarrow $
$  (\exists b\in K.\  M\langle a,b\rangle  = TheNeutralElement(K,M))))$===  ,  +++^[IsAring_def | Ring_ZF ]... Definition of <nowiki>IsAring</nowiki>:
$ IsAring(R,A,M) \equiv  \text{IsAgroup}(R,A) \wedge  (A \text{ is commutative on } R) \wedge  $
$  \text{IsAmonoid}(R,M) \wedge  IsDistributive(R,A,M)$===  ,  +++^[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))))$===  ,  +++^[Field_ZF_1_L2 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L2</nowiki>:  '' shows '' $ K_0 \text{ is closed under } M$ === 
 ''then ''  ''have''  $ f \text{ is associative on } K_0$ ''using''  +++^[func_ZF_4_L3 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_4_L3</nowiki>:  ''assumes '' $ f \text{ is associative on } X$  ''and'' $ A\subseteq X$  ''and'' $ A \text{ is closed under } f$  '' shows '' $ restrict(f,A\times A) \text{ is associative on } A$ === 
 ''moreover''   ''from '' not_triv  ''have''  I: $ 1 \in K_0 \wedge  (\forall a\in K_0.\  f\langle 1 ,a\rangle  = a \wedge   f\langle a,1 \rangle  = a)$ ''using''  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ === 
 ''then ''  ''have''  $ \exists n\in K_0.\  \forall a\in K_0.\  f\langle n,a\rangle  = a \wedge   f\langle a,n\rangle  = a$ 
 ''ultimately ''  ''have''  II: $ \text{IsAmonoid}(K_0,f)$ ''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))))$=== 
 ''then ''  ''have''  $ monoid0(K_0,f)$ ''using''  <nowiki>monoid0_def</nowiki>
 ''moreover''   ''note '' I
 ''ultimately ''  ''show''  $ 1  = TheNeutralElement(K_0,f)$ ''   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)$ ===  '')'' 
 ''then ''  ''have''  $ \forall a\in K_0.\ \exists b\in K_0.\  f\langle a,b\rangle  =  TheNeutralElement(K_0,f)$ ''using''  +++^[Field_ZF_1_L3 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L3</nowiki>:  ''assumes '' $ a\in K_0$  '' shows '' $ \exists b\in K_0.\  a\cdot b = 1 $ === 
 ''with '' II  ''show''  $ \text{IsAgroup}(K_0,f)$ ''   by (rule '' +++^[definition_of_group | Group_ZF ]...  ''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)$ ===  '')'' 
 ''then ''  ''show''  $ group0(K_0,f)$ ''using''  <nowiki>group0_def</nowiki>
 ''qed'' === 

The inverse of a nonzero field element is nonzero.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L5</nowiki>:
 ''   assumes '' A1: $ a\in K$,  $ a\neq 0 $ ''   shows '' $ a^{-1} \in  K_0$,  $ (a^{-1})^2  \in  K_0$,  $ a^{-1} \in  K$,  $ a^{-1} \neq  0 $+++[proof ]>
 ''from '' A1  ''have''  $ a \in  K_0$ 
 ''then ''  ''show''  $ a^{-1} \in  K_0$ ''using''  +++^[Field_ZF_1_L4 | Field_ZF ]...  ''theorem''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L4</nowiki>:  '' shows '' $ \text{IsAgroup}(K_0,restrict(M,K_0\times K_0))$,  
$ group0(K_0,restrict(M,K_0\times K_0))$,   $ 1  = TheNeutralElement(K_0,restrict(M,K_0\times K_0))$ ===  ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ === 
 ''then ''  ''show''  $ (a^{-1})^2  \in  K_0$,  $ a^{-1} \in  K$,  $ a^{-1} \neq  0 $ ''using''  +++^[Field_ZF_1_L2 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L2</nowiki>:  '' shows '' $ K_0 \text{ is closed under } M$ ===  ,  +++^[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 inverse is really the inverse.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L6</nowiki>:
 ''   assumes '' A1: $ a\in K$,  $ a\neq 0 $ ''   shows '' $ a\cdot a^{-1} = 1 $,  $ a^{-1}\cdot a = 1 $+++[proof ]>
 ''let '' $ f = restrict(M,K_0\times K_0)$
 ''from '' A1  ''have''  $ group0(K_0,f)$,  $ a \in  K_0$ ''using''  +++^[Field_ZF_1_L4 | Field_ZF ]...  ''theorem''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L4</nowiki>:  '' shows '' $ \text{IsAgroup}(K_0,restrict(M,K_0\times K_0))$,  
$ group0(K_0,restrict(M,K_0\times K_0))$,   $ 1  = TheNeutralElement(K_0,restrict(M,K_0\times K_0))$ === 
 ''then ''  ''have''  $ f\langle a,GroupInv(K_0, f)(a)\rangle  = TheNeutralElement(K_0,f) \wedge $
$    f\langle GroupInv(K_0,f)(a),a\rangle  = TheNeutralElement(K_0, f)$ ''   by (rule '' +++^[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  ''show''  $ a\cdot a^{-1} = 1 $,  $ a^{-1}\cdot a = 1 $ ''using''  +++^[Field_ZF_1_L5 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L5</nowiki>:  ''assumes '' $ a\in K$,   $ a\neq 0 $  '' shows '' $ a^{-1} \in  K_0$,   $ (a^{-1})^2  \in  K_0$,   $ a^{-1} \in  K$,   $ a^{-1} \neq  0 $ ===  ,  +++^[Field_ZF_1_L4 | Field_ZF ]...  ''theorem''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L4</nowiki>:  '' shows '' $ \text{IsAgroup}(K_0,restrict(M,K_0\times K_0))$,  
$ group0(K_0,restrict(M,K_0\times K_0))$,   $ 1  = TheNeutralElement(K_0,restrict(M,K_0\times K_0))$ === 
 ''qed'' === 

A lemma with two field elements and cancelling.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L7</nowiki>:
 ''   assumes '' $ a\in K$,  $ b\in K$,  $ b\neq 0 $ ''   shows '' $ a\cdot b\cdot b^{-1} = a$,  $ a\cdot b^{-1}\cdot b = a$ ''using''  <nowiki>assms</nowiki> ,  +++^[Field_ZF_1_L5 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L5</nowiki>:  ''assumes '' $ a\in K$,   $ a\neq 0 $  '' shows '' $ a^{-1} \in  K_0$,   $ (a^{-1})^2  \in  K_0$,   $ a^{-1} \in  K$,   $ a^{-1} \neq  0 $ ===  ,  +++^[Ring_ZF_1_L11 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + b + c = a + (b + c)$,   $ a\cdot b\cdot c = a\cdot (b\cdot c)$ ===  ,  +++^[Field_ZF_1_L6 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L6</nowiki>:  ''assumes '' $ a\in K$,   $ a\neq 0 $  '' shows '' $ a\cdot a^{-1} = 1 $,   $ a^{-1}\cdot a = 1 $ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ === 


!Equations and identities

This section deals with more specialized identities that are true in fields.

$a/(a^2) = a$.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_2_L1</nowiki>:
 ''   assumes '' A1: $ a\in K$,  $ a\neq 0 $ ''   shows '' $ a\cdot (a^{-1})^2  = a^{-1}$+++[proof ]>
 ''have''  $ a\cdot (a^{-1})^2  = a\cdot (a^{-1}\cdot a^{-1})$ 
 ''also''   ''from '' A1  ''have''  $ \ldots  =  (a\cdot a^{-1})\cdot a^{-1}$ ''using''  +++^[Field_ZF_1_L5 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L5</nowiki>:  ''assumes '' $ a\in K$,   $ a\neq 0 $  '' shows '' $ a^{-1} \in  K_0$,   $ (a^{-1})^2  \in  K_0$,   $ a^{-1} \in  K$,   $ a^{-1} \neq  0 $ ===  ,  +++^[Ring_ZF_1_L11 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + b + c = a + (b + c)$,   $ a\cdot b\cdot c = a\cdot (b\cdot c)$ === 
 ''also''   ''from '' A1  ''have''  $ \ldots  = a^{-1}$ ''using''  +++^[Field_ZF_1_L6 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L6</nowiki>:  ''assumes '' $ a\in K$,   $ a\neq 0 $  '' shows '' $ a\cdot a^{-1} = 1 $,   $ a^{-1}\cdot a = 1 $ ===  ,  +++^[Field_ZF_1_L5 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L5</nowiki>:  ''assumes '' $ a\in K$,   $ a\neq 0 $  '' shows '' $ a^{-1} \in  K_0$,   $ (a^{-1})^2  \in  K_0$,   $ a^{-1} \in  K$,   $ a^{-1} \neq  0 $ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ === 
 ''finally ''  ''show''  $ a\cdot (a^{-1})^2  = a^{-1}$ 
 ''qed'' === 

If we multiply two different numbers by a nonzero number, the results will be different.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_2_L2</nowiki>:
 ''   assumes '' $ a\in K$,  $ b\in K$,  $ c\in K$,  $ a\neq b$,  $ c\neq 0 $ ''   shows '' $ a\cdot c^{-1} \neq  b\cdot c^{-1}$ ''using''  <nowiki>assms</nowiki> ,  +++^[field_has_no_zero_divs | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>field_has_no_zero_divs</nowiki>:  '' shows '' $ HasNoZeroDivs(K,A,M)$ ===  ,  +++^[Field_ZF_1_L5 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L5</nowiki>:  ''assumes '' $ a\in K$,   $ a\neq 0 $  '' shows '' $ a^{-1} \in  K_0$,   $ (a^{-1})^2  \in  K_0$,   $ a^{-1} \in  K$,   $ a^{-1} \neq  0 $ ===  ,  +++^[Ring_ZF_1_L12B | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L12B</nowiki>:  ''assumes '' $ HasNoZeroDivs(R,A,M)$,   $ a\in R$,   $ b\in R$,   $ c\in R$,   $ a\neq b$,   $ c\neq 0 $  '' shows '' $ a\cdot c \neq  b\cdot c$ === 

We can put a nonzero factor on the other side of non-identity (is this the best way to call it?) changing it to the inverse.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_2_L3</nowiki>:
 ''   assumes '' A1: $ a\in K$,  $ b\in K$,  $ b\neq 0 $,  $ c\in K$ ''and '' A2: $ a\cdot b \neq  c$ ''   shows '' $ a \neq  c\cdot b^{-1}$+++[proof ]>
 ''from '' A1, A2  ''have''  $ a\cdot b\cdot b^{-1} \neq  c\cdot b^{-1}$ ''using''  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ ===  ,  +++^[Field_ZF_2_L2 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_2_L2</nowiki>:  ''assumes '' $ a\in K$,   $ b\in K$,   $ c\in K$,   $ a\neq b$,   $ c\neq 0 $  '' shows '' $ a\cdot c^{-1} \neq  b\cdot c^{-1}$ === 
 ''with '' A1  ''show''  $ a \neq  c\cdot b^{-1}$ ''using''  +++^[Field_ZF_1_L7 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L7</nowiki>:  ''assumes '' $ a\in K$,   $ b\in K$,   $ b\neq 0 $  '' shows '' $ a\cdot b\cdot b^{-1} = a$,   $ a\cdot b^{-1}\cdot b = a$ === 
 ''qed'' === 

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

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_2_L4</nowiki>:
 ''   assumes '' $ a\in K$,  $ a\neq 0 $ ''and '' $ b^{-1} \neq  a$ ''   shows '' $ a^{-1} \neq  b$ ''using''  <nowiki>assms</nowiki> ,  +++^[Field_ZF_1_L4 | Field_ZF ]...  ''theorem''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L4</nowiki>:  '' shows '' $ \text{IsAgroup}(K_0,restrict(M,K_0\times K_0))$,  
$ group0(K_0,restrict(M,K_0\times K_0))$,   $ 1  = TheNeutralElement(K_0,restrict(M,K_0\times K_0))$ ===  ,  +++^[group0_2_L11B | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L11B</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ b^{-1} \neq  a$  '' shows '' $ a^{-1} \neq  b$ === 

An identity with two field elements, one and an inverse.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_2_L5</nowiki>:
 ''   assumes '' $ a\in K$,  $ b\in K$,  $ b\neq 0 $ ''   shows '' $ (1   +  a\cdot b)\cdot b^{-1} = a  +  b^{-1}$ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ ===  ,  +++^[Field_ZF_1_L5 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L5</nowiki>:  ''assumes '' $ a\in K$,   $ a\neq 0 $  '' shows '' $ a^{-1} \in  K_0$,   $ (a^{-1})^2  \in  K_0$,   $ a^{-1} \in  K$,   $ a^{-1} \neq  0 $ ===  ,  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ ===  ,  +++^[Field_ZF_1_L7 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L7</nowiki>:  ''assumes '' $ a\in K$,   $ b\in K$,   $ b\neq 0 $  '' shows '' $ a\cdot b\cdot b^{-1} = a$,   $ a\cdot b^{-1}\cdot b = a$ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ === 

An identity with three field elements, inverse and cancelling.

 ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_2_L6</nowiki>:
 ''   assumes '' A1: $ a\in K$,  $ b\in K$,  $ b\neq 0 $,  $ c\in K$ ''   shows '' $ a\cdot b\cdot (c\cdot b^{-1}) = a\cdot c$+++[proof ]>
 ''from '' A1  ''have''  T: $ a\cdot b \in  K$,  $ b^{-1} \in  K$ ''using''  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ ===  ,  +++^[Field_ZF_1_L5 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L5</nowiki>:  ''assumes '' $ a\in K$,   $ a\neq 0 $  '' shows '' $ a^{-1} \in  K_0$,   $ (a^{-1})^2  \in  K_0$,   $ a^{-1} \in  K$,   $ a^{-1} \neq  0 $ === 
 ''with '' mult_commute, A1  ''have''  $ a\cdot b\cdot (c\cdot b^{-1}) = a\cdot b\cdot (b^{-1}\cdot c)$ ''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 $=== 
 ''moreover''   ''from '' A1, T  ''have''  $ a\cdot b \in  K$,  $ b^{-1} \in  K$,  $ c\in K$ 
 ''then ''  ''have''  $ a\cdot b\cdot b^{-1}\cdot c = a\cdot b\cdot (b^{-1}\cdot c)$ ''   by (rule '' +++^[Ring_ZF_1_L11 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + b + c = a + (b + c)$,   $ a\cdot b\cdot c = a\cdot (b\cdot c)$ ===  '')'' 
 ''ultimately ''  ''have''  $ a\cdot b\cdot (c\cdot b^{-1}) = a\cdot b\cdot b^{-1}\cdot c$ 
 ''with '' A1  ''show''  $ a\cdot b\cdot (c\cdot b^{-1}) = a\cdot c$ ''using''  +++^[Field_ZF_1_L7 | Field_ZF ]...  ''lemma''  ''(in'' field0'')'' <nowiki>Field_ZF_1_L7</nowiki>:  ''assumes '' $ a\in K$,   $ b\in K$,   $ b\neq 0 $  '' shows '' $ a\cdot b\cdot b^{-1} = a$,   $ a\cdot b^{-1}\cdot b = a$ === 
 ''qed'' === 

 ''end

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

 ''begin
'' 
This theory file contains properties of finite sets related to order relations. Part of this is similar to what is done in //Finite_ZF_1// except that the development is based on the notion of finite powerset defined in //Finite_ZF// rather the one defined in standard Isabelle //Finite// theory.

!Finite vs. bounded sets

The goal of this section is to show that finite sets are bounded and have maxima and minima.

For total and transitive relations nonempty finite set has a maximum.

 ''theorem''  <nowiki>fin_has_max</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ B \in  FinPow(X)$ ''and '' A4: $ B \neq  0$ ''   shows '' $ HasAmaximum(r,B)$+++[proof ]>
 ''have''  $ 0=0 \vee  HasAmaximum(r,0)$ 
 ''moreover''   ''have''  $ \forall A \in  FinPow(X).\  A=0 \vee  HasAmaximum(r,A) \longrightarrow $
$    (\forall x\in X.\  (A \cup  \{x\}) = 0 \vee  HasAmaximum(r,A \cup  \{x\}))$+++[proof ]>
++++[{ ]>
 ''fix '' $ A$
 ''assume '' $ A \in  FinPow(X)$,  $ A = 0 \vee  HasAmaximum(r,A)$
 ''have''  $ \forall x\in X.\  (A \cup  \{x\}) = 0 \vee  HasAmaximum(r,A \cup  \{x\})$+++[proof ]>
++++[{ ]>
 ''fix '' $ x$
 ''assume '' $ x\in X$
 ''note '' $ A = 0 \vee  HasAmaximum(r,A)$
 ''moreover''  ++++[{ ]>
 ''assume '' $ A = 0$
 ''then ''  ''have''  $ A\cup \{x\} = \{x\}$ 
 ''from '' A1  ''have''  $ refl(X,r)$ ''using''  +++^[total_is_refl | Order_ZF ]...  ''lemma''  <nowiki>total_is_refl</nowiki>:  ''assumes '' $ r \text{ is total on } X$  '' shows '' $ refl(X,r)$ === 
 ''with '' $ x\in X$, $ A\cup \{x\} = \{x\}$  ''have''  $ HasAmaximum(r,A\cup \{x\})$ ''using''  +++^[Order_ZF_4_L8 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L8</nowiki>:  ''assumes '' $ refl(X,r)$  ''and'' $ a\in X$  '' shows '' $ HasAmaximum(r,\{a\})$,   $ HasAminimum(r,\{a\})$ === 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ HasAmaximum(r,A)$
 ''with '' A1, A2, $ A \in  FinPow(X)$, $ x\in X$  ''have''  $ HasAmaximum(r,A\cup \{x\})$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$===  ,  +++^[Order_ZF_4_L9 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L9</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ A\subseteq X$  ''and'' $ a\in X$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ HasAmaximum(r,A\cup \{a\})$ === 
===  ''}'' 
 ''ultimately ''  ''have''  $ A \cup  \{x\} = 0 \vee  HasAmaximum(r,A \cup  \{x\})$ 
===  ''}'' 
 ''thus''  $ \forall x\in X.\  (A \cup  \{x\}) = 0 \vee  HasAmaximum(r,A \cup  \{x\})$
 ''qed'' === 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''note '' A3
 ''ultimately ''  ''have''  $ B = 0 \vee   HasAmaximum(r,B)$ ''   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 '' A4  ''show''  $ HasAmaximum(r,B)$ 
 ''qed'' === 

For linearly ordered nonempty finite sets the maximum is in the set and indeed it is the greatest element of the set.

 ''lemma''  <nowiki>linord_max_props</nowiki>:
 ''   assumes '' A1: $ IsLinOrder(X,r)$ ''and '' A2: $ A \in  FinPow(X)$,  $ A \neq  0$ ''   shows '' $ Maximum(r,A) \in  A$,  $ Maximum(r,A) \in  X$,  $ \forall a\in A.\  \langle a,Maximum(r,A)\rangle  \in  r$+++[proof ]>
 ''from '' A1, A2  ''show''  $ Maximum(r,A) \in  A$ ''and '' $ \forall a\in A.\  \langle a,Maximum(r,A)\rangle  \in  r$ ''using''  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[fin_has_max | FinOrd_ZF ]...  ''theorem''  <nowiki>fin_has_max</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ B \in  FinPow(X)$  ''and'' $ B \neq  0$  '' shows '' $ HasAmaximum(r,B)$ ===  ,  +++^[Order_ZF_4_L3 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L3</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ Maximum(r,A) \in  A$,   $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$ === 
 ''with '' A2  ''show''  $ Maximum(r,A) \in  X$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 
 ''qed'' === 


!Order isomorphisms of finite sets

In this section we eastablish that if two linearly ordered finite sets have the same number of elements, then they are order-isomorphic and the isomorphism is unique. This allows us to talk about ''enumeration'' of a linearly ordered finite set. We define the enumeration as the order isomorphism between the number of elements of the set (which is a natural number $n = \{0,1,..,n-1\}$) and the set.

A really weird corner case - empty set is order isomorphic with itself.

 ''lemma''  <nowiki>empty_ord_iso</nowiki>:
 ''   shows '' $ ord\_iso(0,r,0,R) \neq  0$+++[proof ]>
 ''have''  $ 0 \approx  0$ ''using''  <nowiki>eqpoll_refl</nowiki>
 ''then ''  ''obtain '' $ f$ ''where '' $ f \in  bij(0,0)$ ''using''  <nowiki>eqpoll_def</nowiki>
 ''then ''  ''show''  $ thesis$ ''using''  <nowiki>ord_iso_def</nowiki>
 ''qed'' === 

Even weirder than //empty_ord_iso// The order automorphism of the empty set is unique.

 ''lemma''  <nowiki>empty_ord_iso_uniq</nowiki>:
 ''   assumes '' $ f \in  ord\_iso(0,r,0,R)$,  $ g \in  ord\_iso(0,r,0,R)$ ''   shows '' $ f = g$+++[proof ]>
 ''from '' assms  ''have''  $ f : 0 \rightarrow  0$ ''and '' $ g: 0 \rightarrow  0$ ''using''  <nowiki>ord_iso_def</nowiki> ,  <nowiki>bij_def</nowiki> ,  <nowiki>surj_def</nowiki>
 ''moreover''   ''have''  $ \forall x\in 0.\  f(x) = g(x)$ 
 ''ultimately ''  ''show''  $ f = g$ ''   by (rule '' +++^[func_eq | func1 ]...  ''lemma''  <nowiki>func_eq</nowiki>:  ''assumes '' $ f: X\rightarrow Y$,   $ g: X\rightarrow Z$  ''and'' $ \forall x\in X.\  f(x) = g(x)$  '' shows '' $ f = g$ ===  '')'' 
 ''qed'' === 

The empty set is the only order automorphism of itself.

 ''lemma''  <nowiki>empty_ord_iso_empty</nowiki>:
 ''   shows '' $ ord\_iso(0,r,0,R) = \{0\}$+++[proof ]>
 ''have''  $ 0 \in  ord\_iso(0,r,0,R)$+++[proof ]>
 ''have''  $ ord\_iso(0,r,0,R) \neq  0$ ''   by (rule '' +++^[empty_ord_iso | FinOrd_ZF ]...  ''lemma''  <nowiki>empty_ord_iso</nowiki>:  '' shows '' $ ord\_iso(0,r,0,R) \neq  0$ ===  '')'' 
 ''then ''  ''obtain '' $ f$ ''where '' $ f \in  ord\_iso(0,r,0,R)$ 
 ''then ''  ''show''  $ 0 \in  ord\_iso(0,r,0,R)$ ''using''  <nowiki>ord_iso_def</nowiki> ,  <nowiki>bij_def</nowiki> ,  <nowiki>surj_def</nowiki> ,  +++^[fun_subset_prod | func1 ]...  ''lemma''  <nowiki>fun_subset_prod</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f \subseteq  X\times Y$ === 
 ''qed'' === 
 ''then ''  ''show''  $ ord\_iso(0,r,0,R) = \{0\}$ ''using''  +++^[empty_ord_iso_uniq | FinOrd_ZF ]...  ''lemma''  <nowiki>empty_ord_iso_uniq</nowiki>:  ''assumes '' $ f \in  ord\_iso(0,r,0,R)$,   $ g \in  ord\_iso(0,r,0,R)$  '' shows '' $ f = g$ === 
 ''qed'' === 

An induction (or maybe recursion?) scheme for linearly ordered sets. The induction step is that we show that if the property holds when the set is a singleton or for a set with the maximum removed, then it holds for the set. The idea is that since we can build any finite set by adding elements on the right, then if the property holds for the empty set and is invariant with respect to this operation. it must hold for all finite sets.

 ''lemma''  <nowiki>fin_ord_induction</nowiki>:
 ''   assumes '' A1: $ IsLinOrder(X,r)$ ''and '' A2: $ P(0)$ ''and '' A3: $ \forall A \in  FinPow(X).\  A \neq  0 \longrightarrow  (P(A - \{Maximum(r,A)\}) \longrightarrow  P(A))$ ''and '' A4: $ B \in  FinPow(X)$ ''   shows '' $ P(B)$+++[proof ]>
 ''note '' A2
 ''moreover''   ''have''  $ \forall  A \in  FinPow(X).\  A \neq  0 \longrightarrow  (\exists a\in A.\  P(A-\{a\}) \longrightarrow  P(A))$+++[proof ]>
++++[{ ]>
 ''fix '' $ A$
 ''assume '' $ A \in   FinPow(X)$ ''and '' $ A \neq  0$
 ''with '' A1, A3  ''have''  $ \exists a\in A.\  P(A-\{a\}) \longrightarrow  P(A)$ ''using''  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[fin_has_max | FinOrd_ZF ]...  ''theorem''  <nowiki>fin_has_max</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ B \in  FinPow(X)$  ''and'' $ B \neq  0$  '' shows '' $ HasAmaximum(r,B)$ ===  ,  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[Order_ZF_4_L3 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L3</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ Maximum(r,A) \in  A$,   $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$ === 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''note '' A4
 ''ultimately ''  ''show''  $ P(B)$ ''   by (rule '' +++^[FinPow_ind_rem_one | Finite_ZF ]...  ''lemma''  <nowiki>FinPow_ind_rem_one</nowiki>:  ''assumes '' $ P(0)$  ''and'' $ \forall  A \in  FinPow(X).\  A \neq  0 \longrightarrow  (\exists a\in A.\  P(A-\{a\}) \longrightarrow  P(A))$
 ''and'' $ B \in   FinPow(X)$  '' shows '' $ P(B)$ ===  '')'' 
 ''qed'' === 

A sligltly more complicated version of //fin_ord_induction// that allows to prove properties that are not true for the empty set.

 ''lemma''  <nowiki>fin_ord_ind</nowiki>:
 ''   assumes '' A1: $ IsLinOrder(X,r)$ ''and '' A2: $ \forall A \in  FinPow(X).\  $
$  A = 0 \vee  (A = \{Maximum(r,A)\} \vee  P(A - \{Maximum(r,A)\}) \longrightarrow  P(A))$ ''and '' A3: $ B \in   FinPow(X)$ ''and '' A4: $ B\neq 0$ ''   shows '' $ P(B)$+++[proof ]>
++++[{ ]>
 ''fix '' $ A$
 ''assume '' $ A \in   FinPow(X)$ ''and '' $ A \neq  0$
 ''with '' A1, A2  ''have''  $ \exists a\in A.\  A = \{a\} \vee  P(A-\{a\}) \longrightarrow  P(A)$ ''using''  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[fin_has_max | FinOrd_ZF ]...  ''theorem''  <nowiki>fin_has_max</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ B \in  FinPow(X)$  ''and'' $ B \neq  0$  '' shows '' $ HasAmaximum(r,B)$ ===  ,  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[Order_ZF_4_L3 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L3</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ Maximum(r,A) \in  A$,   $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$ === 
===  ''}'' 
 ''then ''  ''have''  $ \forall A \in  FinPow(X).\  $
$      A = 0 \vee  (\exists a\in A.\  A = \{a\} \vee  P(A-\{a\}) \longrightarrow  P(A))$ 
 ''with '' A3, A4  ''show''  $ P(B)$ ''using''  +++^[FinPow_rem_ind | Finite_ZF ]...  ''lemma''  <nowiki>FinPow_rem_ind</nowiki>:  ''assumes '' $ \forall A \in  FinPow(X).\  $
$  A = 0 \vee  (\exists a\in A.\  A = \{a\} \vee  P(A-\{a\}) \longrightarrow  P(A))$
 ''and'' $ A \in   FinPow(X)$  ''and'' $ A\neq 0$  '' shows '' $ P(A)$ === 
 ''qed'' === 

Yet another induction scheme. We build and linearly ordered set by adding elements that are greater than any elements in the set.

 ''lemma''  <nowiki>fin_ind_add_max</nowiki>:
 ''   assumes '' A1: $ IsLinOrder(X,r)$ ''and '' A2: $ P(0)$ ''and '' A3: $ \forall  A \in  FinPow(X).\  $
$  ( \forall  x \in  X-A.\  P(A) \wedge  (\forall a\in A.\  \langle a,x\rangle  \in  r ) \longrightarrow  P(A \cup  \{x\}))$ ''and '' A4: $ B \in  FinPow(X)$ ''   shows '' $ P(B)$+++[proof ]>
 ''note '' A1 A2
 ''moreover''   ''have''  $ \forall C \in  FinPow(X).\  C \neq  0 \longrightarrow  (P(C - \{Maximum(r,C)\}) \longrightarrow  P(C))$+++[proof ]>
++++[{ ]>
 ''fix '' $ C$
 ''assume '' $ C \in  FinPow(X)$ ''and '' $ C \neq  0$
 ''let '' $ x = Maximum(r,C)$
 ''let '' $ A = C - \{x\}$
 ''assume '' $ P(A)$
 ''moreover''   ''from '' $ C \in  FinPow(X)$  ''have''  $ A \in  FinPow(X)$ ''using''  +++^[fin_rem_point_fin | Finite_ZF ]...  ''corollary''  <nowiki>fin_rem_point_fin</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ A - \{a\} \in  FinPow(X)$ === 
 ''moreover''   ''from '' A1, $ C \in  FinPow(X)$, $ C \neq  0$  ''have''  $ x \in  C$ ''and '' $ x \in  X - A$ ''and '' $ \forall a\in A.\  \langle a,x\rangle  \in  r$ ''using''  +++^[linord_max_props | FinOrd_ZF ]...  ''lemma''  <nowiki>linord_max_props</nowiki>:  ''assumes '' $ IsLinOrder(X,r)$  ''and'' $ A \in  FinPow(X)$,   $ A \neq  0$  '' shows '' $ Maximum(r,A) \in  A$,  
$ Maximum(r,A) \in  X$,   $ \forall a\in A.\  \langle a,Maximum(r,A)\rangle  \in  r$ === 
 ''moreover''   ''note '' A3
 ''ultimately ''  ''have''  $ P(A \cup  \{x\})$ 
 ''moreover''   ''from '' $ x \in  C$  ''have''  $ A \cup  \{x\} = C$ 
 ''ultimately ''  ''have''  $ P(C)$ 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''note '' A4
 ''ultimately ''  ''show''  $ P(B)$ ''   by (rule '' +++^[fin_ord_induction | FinOrd_ZF ]...  ''lemma''  <nowiki>fin_ord_induction</nowiki>:  ''assumes '' $ IsLinOrder(X,r)$  ''and'' $ P(0)$  ''and'' $ \forall A \in  FinPow(X).\  A \neq  0 \longrightarrow  (P(A - \{Maximum(r,A)\}) \longrightarrow  P(A))$
 ''and'' $ B \in  FinPow(X)$  '' shows '' $ P(B)$ ===  '')'' 
 ''qed'' === 

The only order automorphism of a linearly ordered finite set is the identity.

 ''theorem''  <nowiki>fin_ord_auto_id</nowiki>:
 ''   assumes '' A1: $ IsLinOrder(X,r)$ ''and '' A2: $ B \in   FinPow(X)$ ''and '' A3: $ B\neq 0$ ''   shows '' $ ord\_iso(B,r,B,r) = \{id(B)\}$+++[proof ]>
 ''note '' A1
 ''moreover''  ++++[{ ]>
 ''fix '' $ A$
 ''assume '' $ A \in   FinPow(X)$,  $ A\neq 0$
 ''let '' $ M = Maximum(r,A)$
 ''let '' $ A_0 = A - \{M\}$
 ''assume '' $ A = \{M\} \vee  ord\_iso(A_0,r,A_0,r) = \{id(A_0)\}$
 ''moreover''  ++++[{ ]>
 ''assume '' $ A = \{M\}$
 ''have''  $ ord\_iso(\{M\},r,\{M\},r) = \{id(\{M\})\}$ ''using''  <nowiki>id_ord_auto_singleton</nowiki>
 ''with '' $ A = \{M\}$  ''have''  $ ord\_iso(A,r,A,r) = \{id(A)\}$ 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ ord\_iso(A_0,r,A_0,r) = \{id(A_0)\}$
 ''have''  $ ord\_iso(A,r,A,r) = \{id(A)\}$+++[proof ]>
 ''show''  $ \{id(A)\} \subseteq  ord\_iso(A,r,A,r)$ ''using''  <nowiki>id_ord_iso</nowiki>
++++[{ ]>
 ''fix '' $ f$
 ''assume '' $ f \in  ord\_iso(A,r,A,r)$
 ''with '' A1, $ A \in   FinPow(X)$, $ A\neq 0$  ''have''  $ restrict(f,A_0) \in  ord\_iso(A_0, r, A-\{f(M)\},r)$ ''using''  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[fin_has_max | FinOrd_ZF ]...  ''theorem''  <nowiki>fin_has_max</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ B \in  FinPow(X)$  ''and'' $ B \neq  0$  '' shows '' $ HasAmaximum(r,B)$ ===  ,  <nowiki>ord_iso_rem_max</nowiki>
 ''with '' A1, $ A \in   FinPow(X)$, $ A\neq 0$, $ f \in  ord\_iso(A,r,A,r)$, $ ord\_iso(A_0,r,A_0,r) = \{id(A_0)\}$  ''have''  $ restrict(f,A_0) = id(A_0)$ ''using''  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[fin_has_max | FinOrd_ZF ]...  ''theorem''  <nowiki>fin_has_max</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ B \in  FinPow(X)$  ''and'' $ B \neq  0$  '' shows '' $ HasAmaximum(r,B)$ ===  ,  <nowiki>max_auto_fixpoint</nowiki>
 ''moreover''   ''from '' A1, $ f \in  ord\_iso(A,r,A,r)$, $ A \in   FinPow(X)$, $ A\neq 0$  ''have''  $ f : A \rightarrow  A$ ''and '' $ M \in  A$ ''and '' $ f(M) = M$ ''using''  <nowiki>ord_iso_def</nowiki> ,  <nowiki>bij_is_fun</nowiki> ,  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[fin_has_max | FinOrd_ZF ]...  ''theorem''  <nowiki>fin_has_max</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ B \in  FinPow(X)$  ''and'' $ B \neq  0$  '' shows '' $ HasAmaximum(r,B)$ ===  ,  +++^[Order_ZF_4_L3 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L3</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ Maximum(r,A) \in  A$,   $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$ ===  ,  <nowiki>max_auto_fixpoint</nowiki>
 ''ultimately ''  ''have''  $ f = id(A)$ ''using''  +++^[id_fixpoint_rem | func_ZF ]...  ''lemma''  <nowiki>id_fixpoint_rem</nowiki>:  ''assumes '' $ f:X\rightarrow X$  ''and'' $ p\in X$  ''and'' $ f(p) = p$  ''and'' $ restrict(f, X-\{p\}) = id(X-\{p\})$  '' shows '' $ f = id(X)$ === 
===  ''}'' 
 ''then ''  ''show''  $ ord\_iso(A,r,A,r) \subseteq  \{id(A)\}$ 
 ''qed'' === 
===  ''}'' 
 ''ultimately ''  ''have''  $ ord\_iso(A,r,A,r) = \{id(A)\}$ 
===  ''}'' 
 ''then ''  ''have''  $ \forall A \in   FinPow(X).\  A = 0 \vee  $
$      (A = \{Maximum(r,A)\} \vee  $
$      ord\_iso(A-\{Maximum(r,A)\},r,A-\{Maximum(r,A)\},r) = $
$      \{id(A-\{Maximum(r,A)\})\} \longrightarrow   ord\_iso(A,r,A,r) = \{id(A)\})$ 
 ''moreover''   ''note '' A2 A3
 ''ultimately ''  ''show''  $ ord\_iso(B,r,B,r) = \{id(B)\}$ ''   by (rule '' +++^[fin_ord_ind | FinOrd_ZF ]...  ''lemma''  <nowiki>fin_ord_ind</nowiki>:  ''assumes '' $ IsLinOrder(X,r)$  ''and'' $ \forall A \in  FinPow(X).\  $
$  A = 0 \vee  (A = \{Maximum(r,A)\} \vee  P(A - \{Maximum(r,A)\}) \longrightarrow  P(A))$
 ''and'' $ B \in   FinPow(X)$  ''and'' $ B\neq 0$  '' shows '' $ P(B)$ ===  '')'' 
 ''qed'' === 

Every two finite linearly ordered sets are order isomorphic. The statement is formulated to make the proof by induction on the size of the set easier, see //fin_ord_iso_ex// for an alternative formulation.

 ''lemma''  <nowiki>fin_order_iso</nowiki>:
 ''   assumes '' A1: $ IsLinOrder(X,r)$,  $ IsLinOrder(Y,R)$ ''and '' A2: $ n \in  nat$ ''   shows '' $ \forall A \in  FinPow(X).\  \forall B \in  FinPow(Y).\ $
$  A \approx  n \wedge  B \approx  n \longrightarrow  ord\_iso(A,r,B,R) \neq  0$+++[proof ]>
 ''note '' A2
 ''moreover''   ''have''  $ \forall A \in  FinPow(X).\  \forall B \in  FinPow(Y).\ $
$    A \approx  0 \wedge  B \approx  0 \longrightarrow  ord\_iso(A,r,B,R) \neq  0$ ''using''  <nowiki>eqpoll_0_is_0</nowiki> ,  +++^[empty_ord_iso | FinOrd_ZF ]...  ''lemma''  <nowiki>empty_ord_iso</nowiki>:  '' shows '' $ ord\_iso(0,r,0,R) \neq  0$ === 
 ''moreover''   ''have''  $ \forall k \in  nat.\ $
$    (\forall A \in  FinPow(X).\  \forall B \in  FinPow(Y).\  $
$    A \approx  k \wedge  B \approx  k \longrightarrow  ord\_iso(A,r,B,R) \neq  0) \longrightarrow $
$    (\forall C \in  FinPow(X).\  \forall D \in  FinPow(Y).\  $
$    C \approx  succ(k) \wedge  D \approx  succ(k) \longrightarrow  ord\_iso(C,r,D,R) \neq  0)$+++[proof ]>
++++[{ ]>
 ''fix '' $ k$
 ''assume '' $ k \in  nat$
 ''assume '' A3: $ \forall A \in  FinPow(X).\  \forall B \in  FinPow(Y).\  $
$	A \approx  k \wedge  B \approx  k \longrightarrow  ord\_iso(A,r,B,R) \neq  0$
 ''have''  $ \forall C \in  FinPow(X).\  \forall D \in  FinPow(Y).\  $
$	C \approx  succ(k) \wedge  D \approx  succ(k) \longrightarrow  ord\_iso(C,r,D,R) \neq  0$+++[proof ]>
++++[{ ]>
 ''fix '' $ C$
 ''assume '' $ C \in  FinPow(X)$
 ''fix '' $ D$
 ''assume '' $ D \in  FinPow(Y)$
 ''assume '' $ C \approx  succ(k)$,  $ D \approx  succ(k)$
 ''then ''  ''have''  $ C \neq  0$ ''and '' $ D\neq  0$ ''using''  <nowiki>eqpoll_succ_imp_not_empty</nowiki>
 ''let '' $ M_C = Maximum(r,C)$
 ''let '' $ M_D = Maximum(R,D)$
 ''let '' $ C_0 = C - \{M_C\}$
 ''let '' $ D_0 = D - \{M_D\}$
 ''from '' $ C \in  FinPow(X)$  ''have''  $ C \subseteq  X$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 
 ''with '' A1  ''have''  $ IsLinOrder(C,r)$ ''using''  +++^[ord_linear_subset | Order_ZF ]...  ''lemma''  <nowiki>ord_linear_subset</nowiki>:  ''assumes '' $ IsLinOrder(X,r)$  ''and'' $ A\subseteq X$  '' shows '' $ IsLinOrder(A,r)$ === 
 ''from '' $ D \in  FinPow(Y)$  ''have''  $ D \subseteq  Y$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 
 ''with '' A1  ''have''  $ IsLinOrder(D,R)$ ''using''  +++^[ord_linear_subset | Order_ZF ]...  ''lemma''  <nowiki>ord_linear_subset</nowiki>:  ''assumes '' $ IsLinOrder(X,r)$  ''and'' $ A\subseteq X$  '' shows '' $ IsLinOrder(A,r)$ === 
 ''from '' A1, $ C \in  FinPow(X)$, $ D \in  FinPow(Y)$, $ C \neq  0$, $ D\neq  0$  ''have''  $ HasAmaximum(r,C)$ ''and '' $ HasAmaximum(R,D)$ ''using''  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[fin_has_max | FinOrd_ZF ]...  ''theorem''  <nowiki>fin_has_max</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ B \in  FinPow(X)$  ''and'' $ B \neq  0$  '' shows '' $ HasAmaximum(r,B)$ === 
 ''with '' A1  ''have''  $ M_C \in  C$ ''and '' $ M_D \in  D$ ''using''  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[Order_ZF_4_L3 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L3</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ Maximum(r,A) \in  A$,   $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$ === 
 ''with '' $ C \approx  succ(k)$, $ D \approx  succ(k)$  ''have''  $ C_0  \approx  k$ ''and '' $ D_0 \approx  k$ ''using''  <nowiki>Diff_sing_eqpoll</nowiki>
 ''from '' $ C \in  FinPow(X)$, $ D \in  FinPow(Y)$  ''have''  $ C_0 \in   FinPow(X)$ ''and '' $ D_0 \in   FinPow(Y)$ ''using''  +++^[fin_rem_point_fin | Finite_ZF ]...  ''corollary''  <nowiki>fin_rem_point_fin</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ A - \{a\} \in  FinPow(X)$ === 
 ''with '' A3, $ C_0  \approx  k$, $ D_0 \approx  k$  ''have''  $ ord\_iso(C_0,r,D_0,R) \neq  0$ 
 ''with '' $ IsLinOrder(C,r)$, $ IsLinOrder(D,R)$, $ HasAmaximum(r,C)$, $ HasAmaximum(R,D)$  ''have''  $ ord\_iso(C,r,D,R) \neq  0$ ''   by (rule '' <nowiki>rem_max_ord_iso</nowiki> '')'' 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ ''   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)$ ===  '')'' 
 ''qed'' === 

Every two finite linearly ordered sets are order isomorphic.

 ''lemma''  <nowiki>fin_ord_iso_ex</nowiki>:
 ''   assumes '' A1: $ IsLinOrder(X,r)$,  $ IsLinOrder(Y,R)$ ''and '' A2: $ A \in  FinPow(X)$,  $ B \in  FinPow(Y)$ ''and '' A3: $ B \approx  A$ ''   shows '' $ ord\_iso(A,r,B,R) \neq  0$+++[proof ]>
 ''from '' A2  ''obtain '' $ n$ ''where '' $ n \in  nat$ ''and '' $ A \approx  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\})$ === 
 ''from '' A3, $ A \approx  n$  ''have''  $ B \approx  n$ ''   by (rule '' <nowiki>eqpoll_trans</nowiki> '')'' 
 ''with '' A1, A2, $ A \approx  n$, $ n \in  nat$  ''show''  $ ord\_iso(A,r,B,R) \neq  0$ ''using''  +++^[fin_order_iso | FinOrd_ZF ]...  ''lemma''  <nowiki>fin_order_iso</nowiki>:  ''assumes '' $ IsLinOrder(X,r)$,   $ IsLinOrder(Y,R)$  ''and'' $ n \in  nat$  '' shows '' $ \forall A \in  FinPow(X).\  \forall B \in  FinPow(Y).\ $
$  A \approx  n \wedge  B \approx  n \longrightarrow  ord\_iso(A,r,B,R) \neq  0$
=== 
 ''qed'' === 

Existence and uniqueness of order isomorphism for two linearly ordered sets with the same number of elements.

 ''theorem''  <nowiki>fin_ord_iso_ex_uniq</nowiki>:
 ''   assumes '' A1: $ IsLinOrder(X,r)$,  $ IsLinOrder(Y,R)$ ''and '' A2: $ A \in  FinPow(X)$,  $ B \in  FinPow(Y)$ ''and '' A3: $ B \approx  A$ ''   shows '' $ \exists !f.\  f \in  ord\_iso(A,r,B,R)$+++[proof ]>
 ''from '' assms  ''show''  $ \exists f.\  f \in  ord\_iso(A,r,B,R)$ ''using''  +++^[fin_ord_iso_ex | FinOrd_ZF ]...  ''lemma''  <nowiki>fin_ord_iso_ex</nowiki>:  ''assumes '' $ IsLinOrder(X,r)$,   $ IsLinOrder(Y,R)$  ''and'' $ A \in  FinPow(X)$,   $ B \in  FinPow(Y)$  ''and'' $ B \approx  A$  '' shows '' $ ord\_iso(A,r,B,R) \neq  0$ === 
 ''fix '' $ f$ $ g$
 ''assume '' A4: $ f \in  ord\_iso(A,r,B,R)$,  $ g \in  ord\_iso(A,r,B,R)$
 ''then ''  ''have''  $ converse(g) \in  ord\_iso(B,R,A,r)$ ''using''  <nowiki>ord_iso_sym</nowiki>
 ''with '' $ f \in  ord\_iso(A,r,B,R)$  ''have''  I: $ converse(g)\circ f \in   ord\_iso(A,r,A,r)$ ''   by (rule '' <nowiki>ord_iso_trans</nowiki> '')'' 
++++[{ ]>
 ''assume '' $ A \neq  0$
 ''with '' A1, A2, I  ''have''  $ converse(g)\circ f = id(A)$ ''using''  +++^[fin_ord_auto_id | FinOrd_ZF ]...  ''theorem''  <nowiki>fin_ord_auto_id</nowiki>:  ''assumes '' $ IsLinOrder(X,r)$  ''and'' $ B \in   FinPow(X)$  ''and'' $ B\neq 0$  '' shows '' $ ord\_iso(B,r,B,r) = \{id(B)\}$ === 
 ''with '' A4  ''have''  $ f = g$ ''using''  <nowiki>ord_iso_def</nowiki> ,  +++^[comp_inv_id_eq_bij | func1 ]...  ''lemma''  <nowiki>comp_inv_id_eq_bij</nowiki>:  ''assumes '' $ a \in  bij(A,B)$,   $ b \in  bij(A,B)$  ''and'' $ converse(b)\circ a = id(A)$  '' shows '' $ a = b$ === 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ A = 0$
 ''then ''  ''have''  $ A \approx  0$ ''using''  <nowiki>eqpoll_0_iff</nowiki>
 ''with '' A3  ''have''  $ B \approx  0$ ''   by (rule '' <nowiki>eqpoll_trans</nowiki> '')'' 
 ''with '' A4, $ A = 0$  ''have''  $ f \in  ord\_iso(0,r,0,R)$ ''and '' $ g \in  ord\_iso(0,r,0,R)$ ''using''  <nowiki>eqpoll_0_iff</nowiki>
 ''then ''  ''have''  $ f = g$ ''   by (rule '' +++^[empty_ord_iso_uniq | FinOrd_ZF ]...  ''lemma''  <nowiki>empty_ord_iso_uniq</nowiki>:  ''assumes '' $ f \in  ord\_iso(0,r,0,R)$,   $ g \in  ord\_iso(0,r,0,R)$  '' shows '' $ f = g$ ===  '')'' 
===  ''}'' 
 ''ultimately ''  ''show''  $ f = g$ ''using''  <nowiki>ord_iso_def</nowiki> ,  +++^[comp_inv_id_eq_bij | func1 ]...  ''lemma''  <nowiki>comp_inv_id_eq_bij</nowiki>:  ''assumes '' $ a \in  bij(A,B)$,   $ b \in  bij(A,B)$  ''and'' $ converse(b)\circ a = id(A)$  '' shows '' $ a = b$ === 
 ''qed'' === 

 ''end

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

 ''begin
'' 
Functions with finite support are those functions valued in a monoid that are equal to the neutral element everywhere except a finite number of points. They form a submonoid of the space of all functions valued in the monoid with the natural pointwise operation (or a subgroup if functions are valued in a group). Polynomials can be viewed as ring valued sequences that have finite support.

!Functions with finite support

In this section we provide the definition and set up notation for formalizing the notion of finitely supported functions.

Support of a function is the subset of its domain where the values are not zero.

 ''Definition
'' $ Supp(f,G,A) \equiv  \{x \in  domain(f).\  f(x) \neq  TheNeutralElement(G,A)\}$

A finitely supported function is such that its support is in the finite powerset of its domain.

 ''Definition
'' $ FinSupp(X,G,A) \equiv  \{f \in  X\rightarrow G.\  Supp(f,G,A) \in  FinPow(X)\}$

We will use the additive notation writing about finitely supported functions. In the //finsupp// context defined below we assume that $(M,A)$ is a monoid and $X$ is some arbitrary set. We denote $ \mathcal{A} $ to be the pointwise operation on $M$-valued functions on $X$ corresponding to the monoid operation $A$, (denoted as $ + $). $ 0 $ is the neutral element of the monoid.

 ''Locale '' finsupp
 ''assumes '' monoidAsssum: $ \text{IsAmonoid}(M,A)$
 ''defines '' $ a  +  b \equiv  A\langle a,b\rangle $
 ''defines '' $ \mathcal{M}  \equiv  FinSupp(X,M,A)$
 ''defines '' $ \mathcal{A}  \equiv  A \text{ lifted to function space over } X$
 ''defines '' $ a \oplus  b \equiv  \mathcal{A} \langle a,b\rangle $
 ''defines '' $ 0  \equiv  TheNeutralElement(M,A)$
 ''defines '' $ supp(f) \equiv  Supp(f,M,A)$


We can use theorems proven in the //monoid0// context.

 ''lemma''  ''(in'' finsupp'')'' <nowiki>monoid0_valid</nowiki>:
 ''   shows '' $ monoid0(M,A)$ ''using''  <nowiki>monoidAsssum</nowiki> ,  <nowiki>monoid0_def</nowiki>


!Finitely supported functions valued in a monoid

We show in //Group_ZF_2// that if $(M,A)$ is a monoid, and $X$ is an arbitrary set, then the space of functions $X\rightarrow M$ with the natural pointwise operation is also a monoid. In this section we show that the set of finitely supported funtions is a a sub-monoid of that monoid.

The sum of monoid valued functions is a monoid valued function.

 ''lemma''  ''(in'' finsupp'')'' <nowiki>lifted_op_closed</nowiki>:
 ''   assumes '' $ f:X \rightarrow M$,  $ g:X \rightarrow M$ ''   shows '' $ f\oplus g : X\rightarrow M$+++[proof ]>
 ''have''  $ \mathcal{A}  : (X\rightarrow M)\times (X\rightarrow M)\rightarrow (X\rightarrow M)$ ''using''  +++^[monoid0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>monoid0_valid</nowiki>:  '' shows '' $ monoid0(M,A)$ ===  ,  +++^[Group_ZF_2_1_L0A | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_L0A</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  '' shows '' $ F : (X\rightarrow G)\times (X\rightarrow G)\rightarrow (X\rightarrow G)$ === 
 ''with '' assms  ''show''  $ f\oplus g : X\rightarrow M$ 
 ''qed'' === 

What is the value of a sum of monoid-valued functions?

 ''lemma''  ''(in'' finsupp'')'' <nowiki>finsupp_sum_val</nowiki>:
 ''   assumes '' $ f:X \rightarrow M$,  $ g:X \rightarrow M$ ''and '' $ x \in  X$ ''   shows '' $ (f\oplus g)(x) = f(x)  +  g(x)$ ''using''  <nowiki>assms</nowiki> ,  +++^[monoid0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>monoid0_valid</nowiki>:  '' shows '' $ monoid0(M,A)$ ===  ,  +++^[lifted_val | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>lifted_val</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  ''and'' $ s:X\rightarrow G$,   $ r:X\rightarrow G$  ''and'' $ x\in X$  '' shows '' $ (F\langle s,r\rangle )(x) = s(x) \oplus  r(x)$ === 

The support of the sum of functions is contained in the union of supports.

 ''lemma''  ''(in'' finsupp'')'' <nowiki>supp_sum_union</nowiki>:
 ''   assumes '' $ f:X \rightarrow M$,  $ g:X \rightarrow M$ ''   shows '' $ supp(f\oplus g) \subseteq  supp(f) \cup  supp(g)$+++[proof ]>
++++[{ ]>
 ''fix '' $ x$
 ''assume '' $ x \in  supp(f\oplus g)$
 ''from '' assms  ''have''  $ f\oplus g : X\rightarrow M$ ''using''  +++^[lifted_op_closed | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>lifted_op_closed</nowiki>:  ''assumes '' $ f:X \rightarrow M$,   $ g:X \rightarrow M$  '' shows '' $ f\oplus g : X\rightarrow M$ === 
 ''with '' assms, $ x \in  supp(f\oplus g)$  ''have''  $ x\in X$ ''and '' $ f(x)  +  g(x) \neq  0 $ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  +++^[Supp_def | FinSupp_ZF ]... Definition of <nowiki>Supp</nowiki>:
$ Supp(f,G,A) \equiv  \{x \in  domain(f).\  f(x) \neq  TheNeutralElement(G,A)\}$===  ,  +++^[finsupp_sum_val | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>finsupp_sum_val</nowiki>:  ''assumes '' $ f:X \rightarrow M$,   $ g:X \rightarrow M$  ''and'' $ x \in  X$  '' shows '' $ (f\oplus g)(x) = f(x)  +  g(x)$ === 
 ''with '' assms  ''have''  $ x \in  (supp(f) \cup  supp(g))$ ''using''  +++^[monoid0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>monoid0_valid</nowiki>:  '' shows '' $ monoid0(M,A)$ ===  ,  +++^[sum_nonzero_elmnt_nonzero | Monoid_ZF ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>sum_nonzero_elmnt_nonzero</nowiki>:  ''assumes '' $ a \oplus  b \neq  TheNeutralElement(G,f)$  '' shows '' $ a \neq  TheNeutralElement(G,f) \vee  b \neq  TheNeutralElement(G,f)$ ===  ,  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  +++^[Supp_def | FinSupp_ZF ]... Definition of <nowiki>Supp</nowiki>:
$ Supp(f,G,A) \equiv  \{x \in  domain(f).\  f(x) \neq  TheNeutralElement(G,A)\}$=== 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 

The sum of finitely supported functions is finitely supported.

 ''lemma''  ''(in'' finsupp'')'' <nowiki>sum_finsupp</nowiki>:
 ''   assumes '' $ f \in  \mathcal{M} $,  $ g \in  \mathcal{M} $ ''   shows '' $ f\oplus g \in \mathcal{M}  $+++[proof ]>
 ''from '' assms  ''have''  I: $ f: X\rightarrow M$,  $ g: X\rightarrow M$ ''and '' $ supp(f) \in  FinPow(X)$,  $ supp(g) \in  FinPow(X)$ ''using''  +++^[FinSupp_def | FinSupp_ZF ]... Definition of <nowiki>FinSupp</nowiki>:
$ FinSupp(X,G,A) \equiv  \{f \in  X\rightarrow G.\  Supp(f,G,A) \in  FinPow(X)\}$=== 
 ''then ''  ''have''  $ supp(f) \cup  supp(g) \in   FinPow(X)$ ''and '' $ supp(f\oplus g) \subseteq  supp(f) \cup  supp(g)$ ''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)$ ===  ,  +++^[supp_sum_union | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>supp_sum_union</nowiki>:  ''assumes '' $ f:X \rightarrow M$,   $ g:X \rightarrow M$  '' shows '' $ supp(f\oplus g) \subseteq  supp(f) \cup  supp(g)$ === 
 ''then ''  ''have''  $ supp(f\oplus g) \in   FinPow(X)$ ''   by (rule '' +++^[subset_finpow | Finite_ZF ]...  ''lemma''  <nowiki>subset_finpow</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  ''and'' $ B \subseteq  A$  '' shows '' $ B \in  FinPow(X)$ ===  '')'' 
 ''with '' I  ''show''  $ f\oplus g \in  \mathcal{M} $ ''using''  +++^[lifted_op_closed | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>lifted_op_closed</nowiki>:  ''assumes '' $ f:X \rightarrow M$,   $ g:X \rightarrow M$  '' shows '' $ f\oplus g : X\rightarrow M$ ===  ,  +++^[FinSupp_def | FinSupp_ZF ]... Definition of <nowiki>FinSupp</nowiki>:
$ FinSupp(X,G,A) \equiv  \{f \in  X\rightarrow G.\  Supp(f,G,A) \in  FinPow(X)\}$=== 
 ''qed'' === 

The neutral element of the lifted (pointwise) operation is the function equal zero everywhere. In the next lemma we show that this is a finitely supported function.

 ''lemma''  ''(in'' finsupp'')'' <nowiki>const_zero_fin_supp</nowiki>:
 ''   shows '' $ TheNeutralElement(X\rightarrow M, \mathcal{A} ) \in  \mathcal{M} $ ''using''  <nowiki>monoidAsssum</nowiki> ,  +++^[Group_ZF_2_1_L2 | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_1_L2</nowiki>:  ''assumes '' $ \text{IsAmonoid}(G,f)$  ''and'' $ F = f \text{ lifted to function space over } X$  ''and'' $ E = ConstantFunction(X,TheNeutralElement(G,f))$  '' shows '' $ E = TheNeutralElement(X\rightarrow G,F)$ ===  ,  +++^[monoid0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>monoid0_valid</nowiki>:  '' shows '' $ monoid0(M,A)$ ===  ,  +++^[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)$ ===  ,  +++^[func1_3_L1 | func1 ]...  ''lemma''  <nowiki>func1_3_L1</nowiki>:  ''assumes '' $ c\in Y$  '' shows '' $ ConstantFunction(X,c) : X\rightarrow Y$ ===  ,  +++^[func1_3_L2 | func1 ]...  ''lemma''  <nowiki>func1_3_L2</nowiki>:  ''assumes '' $ x\in X$  '' shows '' $ ConstantFunction(X,c)(x) = c$ ===  ,  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  +++^[Supp_def | FinSupp_ZF ]... Definition of <nowiki>Supp</nowiki>:
$ Supp(f,G,A) \equiv  \{x \in  domain(f).\  f(x) \neq  TheNeutralElement(G,A)\}$===  ,  +++^[empty_in_finpow | Finite_ZF ]...  ''lemma''  <nowiki>empty_in_finpow</nowiki>:  '' shows '' $ 0 \in  FinPow(X)$ ===  ,  +++^[FinSupp_def | FinSupp_ZF ]... Definition of <nowiki>FinSupp</nowiki>:
$ FinSupp(X,G,A) \equiv  \{f \in  X\rightarrow G.\  Supp(f,G,A) \in  FinPow(X)\}$=== 

Finitely supported functions form a submonoid of all functions with pointwise operation.

 ''theorem''  ''(in'' finsupp'')'' <nowiki>fin_supp_monoid</nowiki>:
 ''   shows '' $ \text{IsAmonoid}(\mathcal{M} ,restrict(\mathcal{A} ,\mathcal{M} \times \mathcal{M} ))$+++[proof ]>
 ''have''  $ monoid0(X\rightarrow M,\mathcal{A} )$ ''using''  +++^[monoid0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>monoid0_valid</nowiki>:  '' shows '' $ monoid0(M,A)$ ===  ,  +++^[Group_ZF_2_1_T1 | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_T1</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  '' shows '' $ \text{IsAmonoid}(X\rightarrow G,F)$ ===  ,  <nowiki>monoid0_def</nowiki>
 ''moreover''   ''have''  $ \mathcal{M}  \text{ is closed under } \mathcal{A} $,  $ \mathcal{M}  \subseteq  (X\rightarrow M)$,  $ TheNeutralElement(X\rightarrow M, \mathcal{A} ) \in  \mathcal{M} $ ''using''  +++^[sum_finsupp | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>sum_finsupp</nowiki>:  ''assumes '' $ f \in  \mathcal{M} $,   $ g \in  \mathcal{M} $  '' shows '' $ f\oplus g \in \mathcal{M}  $ ===  ,  +++^[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$===  ,  +++^[FinSupp_def | FinSupp_ZF ]... Definition of <nowiki>FinSupp</nowiki>:
$ FinSupp(X,G,A) \equiv  \{f \in  X\rightarrow G.\  Supp(f,G,A) \in  FinPow(X)\}$===  ,  +++^[const_zero_fin_supp | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>const_zero_fin_supp</nowiki>:  '' shows '' $ TheNeutralElement(X\rightarrow M, \mathcal{A} ) \in  \mathcal{M} $ === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  +++^[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))$ === 
 ''qed'' === 


!Group valued finitely supported functions

Similarly as in the monoid case the group valued finitely supported functions form a subgroup of all functions valued in that group.

We will reuse the notation defined in the //finsupp// context, just adding an assumption about that the existence of the right inverse with a notation for it.

 ''Locale '' finsupp1 = finsupp  +
 ''assumes '' rinverse: $ \forall x\in M.\  \exists y\in M.\  x  +  y = 0 $
 ''defines '' $ ( - a) \equiv  GroupInv(M,A)(a)$


With this additional assumption $(M,A)$ becomes a group and we can use theorems proven in ine //group0// context.

 ''lemma''  ''(in'' finsupp1'')'' <nowiki>group0_valid</nowiki>:
 ''   shows '' $ \text{IsAgroup}(M,A)$ ''and '' $ group0(M,A)$ ''using''  <nowiki>monoidAsssum</nowiki> ,  <nowiki>rinverse</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>group0_def</nowiki>

Recall from //Group_ZF_2// that the function space of $G$ valued functions is also a group.

 ''lemma''  ''(in'' finsupp1'')'' <nowiki>fungroup0_valid</nowiki>:
 ''   shows '' $ \text{IsAgroup}(X\rightarrow M,\mathcal{A} )$ ''and '' $ group0(X\rightarrow M,\mathcal{A} )$ ''using''  +++^[group0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp1'')'' <nowiki>group0_valid</nowiki>:  '' shows '' $ \text{IsAgroup}(M,A)$  ''and'' $ group0(M,A)$ ===  ,  +++^[Group_ZF_2_1_T2 | Group_ZF_2 ]...  ''theorem''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_T2</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  '' shows '' $ \text{IsAgroup}(X\rightarrow G,F)$ ===  ,  <nowiki>group0_def</nowiki>

A function has the same support as its negative.

 ''lemma''  ''(in'' finsupp1'')'' <nowiki>finsupp_neg</nowiki>:
 ''   assumes '' A1: $ f: X\rightarrow M$ ''   shows '' $ supp(f) = supp(GroupInv(X\rightarrow M,\mathcal{A} )(f))$+++[proof ]>
 ''let '' $ g = GroupInv(X\rightarrow M,\mathcal{A} )(f)$
 ''from '' A1  ''have''  I: $ g : X\rightarrow M$ ''using''  +++^[fungroup0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp1'')'' <nowiki>fungroup0_valid</nowiki>:  '' shows '' $ \text{IsAgroup}(X\rightarrow M,\mathcal{A} )$  ''and'' $ group0(X\rightarrow M,\mathcal{A} )$ ===  ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ === 
 ''have''  $ supp(g) \subseteq  supp(f)$+++[proof ]>
++++[{ ]>
 ''fix '' $ x$
 ''assume '' $ x \in  supp(g)$
 ''with '' I  ''have''  $ x\in X$ ''and '' $ g(x) \neq  0 $ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  +++^[Supp_def | FinSupp_ZF ]... Definition of <nowiki>Supp</nowiki>:
$ Supp(f,G,A) \equiv  \{x \in  domain(f).\  f(x) \neq  TheNeutralElement(G,A)\}$=== 
 ''with '' A1  ''have''  $ x \in  supp(f)$ ''using''  +++^[group0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp1'')'' <nowiki>group0_valid</nowiki>:  '' shows '' $ \text{IsAgroup}(M,A)$  ''and'' $ group0(M,A)$ ===  ,  +++^[lift_gr_inv_val | Group_ZF_2 ]...  ''corollary''  ''(in'' group0'')'' <nowiki>lift_gr_inv_val</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  ''and'' $ s : X\rightarrow G$  ''and'' $ x\in X$  '' shows '' $ (GroupInv(X\rightarrow G,F)(s))(x) = (s(x))^{-1}$ ===  ,  +++^[group0_2_L8C | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L8C</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ a^{-1} \neq  1 $  '' shows '' $ a\neq 1 $ ===  ,  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  +++^[Supp_def | FinSupp_ZF ]... Definition of <nowiki>Supp</nowiki>:
$ Supp(f,G,A) \equiv  \{x \in  domain(f).\  f(x) \neq  TheNeutralElement(G,A)\}$=== 
===  ''}'' 
 ''thus''  $ supp(g) \subseteq  supp(f)$
 ''qed'' === 
 ''moreover''   ''from '' A1, I  ''have''  $ supp(f) \subseteq  supp(g)$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  +++^[Supp_def | FinSupp_ZF ]... Definition of <nowiki>Supp</nowiki>:
$ Supp(f,G,A) \equiv  \{x \in  domain(f).\  f(x) \neq  TheNeutralElement(G,A)\}$===  ,  +++^[group0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp1'')'' <nowiki>group0_valid</nowiki>:  '' shows '' $ \text{IsAgroup}(M,A)$  ''and'' $ group0(M,A)$ ===  ,  +++^[group0_2_L8B | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L8B</nowiki>:  ''assumes '' $ a\in G$  ''and'' $ a \neq  1 $  '' shows '' $ a^{-1} \neq  1 $ ===  ,  +++^[lift_gr_inv_val | Group_ZF_2 ]...  ''corollary''  ''(in'' group0'')'' <nowiki>lift_gr_inv_val</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  ''and'' $ s : X\rightarrow G$  ''and'' $ x\in X$  '' shows '' $ (GroupInv(X\rightarrow G,F)(s))(x) = (s(x))^{-1}$ === 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

The negative of a function with a finite support is a function with a finite support.

 ''lemma''  ''(in'' finsupp1'')'' <nowiki>finsupp_neg_finsupp</nowiki>:
 ''   assumes '' A1: $ f \in  \mathcal{M} $ ''   shows '' $ GroupInv(X\rightarrow M,\mathcal{A} )(f) \in  \mathcal{M} $+++[proof ]>
 ''let '' $ g = GroupInv(X\rightarrow M,\mathcal{A} )(f)$
 ''from '' A1  ''have''  I: $ f: X\rightarrow M$,  $ supp(f) \in  FinPow(X)$ ''using''  +++^[FinSupp_def | FinSupp_ZF ]... Definition of <nowiki>FinSupp</nowiki>:
$ FinSupp(X,G,A) \equiv  \{f \in  X\rightarrow G.\  Supp(f,G,A) \in  FinPow(X)\}$===  ,  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ === 
 ''then ''  ''have''  $ g \in  X\rightarrow M$ ''using''  +++^[fungroup0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp1'')'' <nowiki>fungroup0_valid</nowiki>:  '' shows '' $ \text{IsAgroup}(X\rightarrow M,\mathcal{A} )$  ''and'' $ group0(X\rightarrow M,\mathcal{A} )$ ===  ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ === 
 ''moreover''   ''from '' I  ''have''  $ supp(g) \in  FinPow(X)$ ''using''  +++^[finsupp_neg | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp1'')'' <nowiki>finsupp_neg</nowiki>:  ''assumes '' $ f: X\rightarrow M$  '' shows '' $ supp(f) = supp(GroupInv(X\rightarrow M,\mathcal{A} )(f))$ === 
 ''ultimately ''  ''show''  $ thesis$ ''using''  +++^[FinSupp_def | FinSupp_ZF ]... Definition of <nowiki>FinSupp</nowiki>:
$ FinSupp(X,G,A) \equiv  \{f \in  X\rightarrow G.\  Supp(f,G,A) \in  FinPow(X)\}$=== 
 ''qed'' === 

Finitely supported functions form a subgroup with pointwise addition of group-valued functions.

 ''theorem''  ''(in'' finsupp1'')'' <nowiki>fin_sup_group</nowiki>:
 ''   shows '' $ IsAsubgroup(\mathcal{M} ,\mathcal{A} )$+++[proof ]>
 ''have''  $ \mathcal{M}  \neq  0$ ''and '' $ \mathcal{M}  \subseteq  X\rightarrow M$ ''and '' $ \mathcal{M}  \text{ is closed under } \mathcal{A} $ ''and '' $ \forall f\in \mathcal{M} .\  GroupInv(X\rightarrow M,\mathcal{A} )(f) \in  \mathcal{M} $ ''using''  +++^[const_zero_fin_supp | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>const_zero_fin_supp</nowiki>:  '' shows '' $ TheNeutralElement(X\rightarrow M, \mathcal{A} ) \in  \mathcal{M} $ ===  ,  +++^[FinSupp_def | FinSupp_ZF ]... Definition of <nowiki>FinSupp</nowiki>:
$ FinSupp(X,G,A) \equiv  \{f \in  X\rightarrow G.\  Supp(f,G,A) \in  FinPow(X)\}$===  ,  +++^[sum_finsupp | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp'')'' <nowiki>sum_finsupp</nowiki>:  ''assumes '' $ f \in  \mathcal{M} $,   $ g \in  \mathcal{M} $  '' shows '' $ f\oplus g \in \mathcal{M}  $ ===  ,  +++^[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$===  ,  +++^[finsupp_neg_finsupp | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp1'')'' <nowiki>finsupp_neg_finsupp</nowiki>:  ''assumes '' $ f \in  \mathcal{M} $  '' shows '' $ GroupInv(X\rightarrow M,\mathcal{A} )(f) \in  \mathcal{M} $ === 
 ''then ''  ''show''  $ IsAsubgroup(\mathcal{M} ,\mathcal{A} )$ ''using''  +++^[fungroup0_valid | FinSupp_ZF ]...  ''lemma''  ''(in'' finsupp1'')'' <nowiki>fungroup0_valid</nowiki>:  '' shows '' $ \text{IsAgroup}(X\rightarrow M,\mathcal{A} )$  ''and'' $ group0(X\rightarrow M,\mathcal{A} )$ ===  ,  +++^[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 FinSupp_ZF|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/FinSupp_ZF"></iframe> </div> </html>
=== 
 ''theory'' Finite_ZF ''imports'' [[ZF1]] [[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>

If a set has the same number of elements as $n \in \mathbb{N}$, then its cardinality is $n$. Recall that in set theory a natural number $n$ is a set that has $n$ elements.

 ''lemma''  <nowiki>card_card</nowiki>:
 ''   assumes '' $ A \approx  n$ ''and '' $ n \in  nat$ ''   shows '' $ |A| = n$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>cardinal_cong</nowiki> ,  <nowiki>nat_into_Card</nowiki> ,  <nowiki>Card_cardinal_eq</nowiki>

If we add a point to a finite set, the cardinality increases by one. To understand tye second assertion $| A \cup \{ a\}| = |A| \cup \{ |A|\} $ recall that the cardinality $|A|$ of $A$ is a natural number and for natural numbers we have $n+1 = n \cup \{ n\}$.

 ''lemma''  <nowiki>card_fin_add_one</nowiki>:
 ''   assumes '' A1: $ A \in  FinPow(X)$ ''and '' A2: $ a \in  X-A$ ''   shows '' $ |A \cup  \{a\}| = succ( |A| )$,  $ |A \cup  \{a\}| = |A| \cup  \{|A|\}$+++[proof ]>
 ''from '' A1, A2  ''have''  $ cons(a,A) \approx  cons( |A|, |A| )$ ''using''  +++^[card_fin_is_nat | Finite_ZF ]...  ''lemma''  <nowiki>card_fin_is_nat</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ |A| \in  nat$  ''and'' $ A \approx  |A|$ ===  ,  <nowiki>mem_not_refl</nowiki> ,  <nowiki>cons_eqpoll_cong</nowiki>
 ''moreover''   ''have''  $ cons(a,A) = A \cup  \{a\}$ ''   by (rule '' +++^[consdef | ZF1 ]...  ''lemma''  <nowiki>consdef</nowiki>:  '' shows '' $ cons(a,A) = A \cup  \{a\}$ ===  '')'' 
 ''moreover''   ''have''  $ cons( |A|, |A| ) = |A| \cup  \{|A|\}$ ''   by (rule '' +++^[consdef | ZF1 ]...  ''lemma''  <nowiki>consdef</nowiki>:  '' shows '' $ cons(a,A) = A \cup  \{a\}$ ===  '')'' 
 ''ultimately ''  ''have''  $ A\cup \{a\} \approx  succ( |A| )$ ''using''  +++^[succ_explained | Nat_ZF_IML ]...  ''lemma''  <nowiki>succ_explained</nowiki>:  '' shows '' $ succ(n) = n \cup  \{n\}$ === 
 ''with '' A1  ''show''  $ |A \cup  \{a\}| = succ( |A| )$ ''and '' $ |A \cup  \{a\}| = |A| \cup  \{|A|\}$ ''using''  +++^[card_fin_is_nat | Finite_ZF ]...  ''lemma''  <nowiki>card_fin_is_nat</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ |A| \in  nat$  ''and'' $ A \approx  |A|$ ===  ,  +++^[card_card | Finite_ZF ]...  ''lemma''  <nowiki>card_card</nowiki>:  ''assumes '' $ A \approx  n$  ''and'' $ n \in  nat$  '' shows '' $ |A| = n$ === 
 ''qed'' === 

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\})$ === 

Natural numbers are finite subsets of the set of natural numbers.

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

A finite subset is a finite subset of itself.

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

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'' === 

A subset of a finites subset is a finite subset.

 ''lemma''  <nowiki>subset_finpow</nowiki>:
 ''   assumes '' $ A \in  FinPow(X)$ ''and '' $ B \subseteq  A$ ''   shows '' $ 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)\}$===  ,  <nowiki>subset_Finite</nowiki>

If we subtract anything from a finite set, the resulting set is finite.

 ''lemma''  <nowiki>diff_finpow</nowiki>:
 ''   assumes '' $ A \in  FinPow(X)$ ''   shows '' $ A-B \in  FinPow(X)$ ''using''  <nowiki>assms</nowiki> ,  +++^[subset_finpow | Finite_ZF ]...  ''lemma''  <nowiki>subset_finpow</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  ''and'' $ B \subseteq  A$  '' shows '' $ B \in  FinPow(X)$ === 

If we remove a point from a finites subset, we get a finite subset.

 ''corollary''  <nowiki>fin_rem_point_fin</nowiki>:
 ''   assumes '' $ A \in  FinPow(X)$ ''   shows '' $ A - \{a\} \in  FinPow(X)$ ''using''  <nowiki>assms</nowiki> ,  +++^[diff_finpow | Finite_ZF ]...  ''lemma''  <nowiki>diff_finpow</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ A-B \in  FinPow(X)$ === 

Cardinality of a nonempty finite set is a successsor of some natural number.

 ''lemma''  <nowiki>card_non_empty_succ</nowiki>:
 ''   assumes '' A1: $ A \in  FinPow(X)$ ''and '' A2: $ A \neq  0$ ''   shows '' $ \exists n \in  nat.\  |A| = succ(n)$+++[proof ]>
 ''from '' A2  ''obtain '' $ a$ ''where '' $ a \in  A$ 
 ''let '' $ B = A - \{a\}$
 ''from '' A1, $ a \in  A$  ''have''  $ B \in  FinPow(X)$ ''and '' $ a \in  X - B$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$===  ,  +++^[fin_rem_point_fin | Finite_ZF ]...  ''corollary''  <nowiki>fin_rem_point_fin</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ A - \{a\} \in  FinPow(X)$ === 
 ''then ''  ''have''  $ |B \cup  \{a\}| = succ( |B| )$ ''using''  +++^[card_fin_add_one | Finite_ZF ]...  ''lemma''  <nowiki>card_fin_add_one</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  ''and'' $ a \in  X-A$  '' shows '' $ |A \cup  \{a\}| = succ( |A| )$,   $ |A \cup  \{a\}| = |A| \cup  \{|A|\}$ === 
 ''moreover''   ''from '' $ a \in  A$, $ B \in  FinPow(X)$  ''have''  $ A = B \cup  \{a\}$ ''and '' $ |B| \in  nat$ ''using''  +++^[card_fin_is_nat | Finite_ZF ]...  ''lemma''  <nowiki>card_fin_is_nat</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ |A| \in  nat$  ''and'' $ A \approx  |A|$ === 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

Another variation on the induction theme: If we can show something holds for the empty set and if it holds for all finite sets with at most $k$ elements then it holds for all finite sets with at most $k+1$ elements, the it holds for all finite sets.

 ''theorem''  <nowiki>FinPow_card_ind</nowiki>:
 ''   assumes '' A1: $ P(0)$ ''and '' A2: $ \forall k\in nat.\ $
$  (\forall A \in  FinPow(X).\  A \preceq  k \longrightarrow  P(A)) \longrightarrow $
$  (\forall A \in  FinPow(X).\  A \preceq  succ(k) \longrightarrow  P(A))$ ''and '' A3: $ A \in   FinPow(X)$ ''   shows '' $ P(A)$+++[proof ]>
 ''from '' A3  ''have''  $ |A| \in  nat$ ''and '' $ A \in   FinPow(X)$ ''and '' $ A \preceq  |A|$ ''using''  +++^[card_fin_is_nat | Finite_ZF ]...  ''lemma''  <nowiki>card_fin_is_nat</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ |A| \in  nat$  ''and'' $ A \approx  |A|$ ===  ,  <nowiki>eqpoll_imp_lepoll</nowiki>
 ''moreover''   ''have''  $ \forall n \in  nat.\  (\forall A \in  FinPow(X).\ $
$    A \preceq  n \longrightarrow  P(A))$+++[proof ]>
 ''fix '' $ n$
 ''assume '' $ n \in  nat$
 ''moreover''   ''from '' A1  ''have''  $ \forall A \in  FinPow(X).\  A \preceq  0 \longrightarrow  P(A)$ ''using''  <nowiki>lepoll_0_is_0</nowiki>
 ''moreover''   ''note '' A2
 ''ultimately ''  ''show''  $ \forall A \in  FinPow(X).\  A \preceq  n \longrightarrow  P(A)$ ''   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)$ ===  '')'' 
 ''qed'' === 
 ''ultimately ''  ''show''  $ P(A)$ 
 ''qed'' === 

Another type of induction (or, maybe recursion). The induction step we try to find a point in the set that if we remove it, the fact that the property holds for the smaller set implies that the property holds for the whole set.

 ''lemma''  <nowiki>FinPow_ind_rem_one</nowiki>:
 ''   assumes '' A1: $ P(0)$ ''and '' A2: $ \forall  A \in  FinPow(X).\  A \neq  0 \longrightarrow  (\exists a\in A.\  P(A-\{a\}) \longrightarrow  P(A))$ ''and '' A3: $ B \in   FinPow(X)$ ''   shows '' $ P(B)$+++[proof ]>
 ''note '' A1
 ''moreover''   ''have''  $ \forall k\in nat.\ $
$  (\forall B \in  FinPow(X).\  B \preceq  k \longrightarrow  P(B)) \longrightarrow $
$  (\forall C \in  FinPow(X).\  C \preceq  succ(k) \longrightarrow  P(C))$+++[proof ]>
++++[{ ]>
 ''fix '' $ k$
 ''assume '' $ k \in  nat$
 ''assume '' A4: $ \forall B \in  FinPow(X).\  B \preceq  k \longrightarrow  P(B)$
 ''have''  $ \forall C \in  FinPow(X).\  C \preceq  succ(k) \longrightarrow  P(C)$+++[proof ]>
++++[{ ]>
 ''fix '' $ C$
 ''assume '' $ C \in  FinPow(X)$
 ''assume '' $ C \preceq  succ(k)$
 ''note '' A1
 ''moreover''  ++++[{ ]>
 ''assume '' $ C \neq  0$
 ''with '' A2, $ C \in  FinPow(X)$  ''obtain '' $ a$ ''where '' $ a\in C$ ''and '' $ P(C-\{a\}) \longrightarrow  P(C)$ 
 ''with '' A4, $ C \in  FinPow(X)$, $ C \preceq  succ(k)$  ''have''  $ P(C)$ ''using''  <nowiki>Diff_sing_lepoll</nowiki> ,  +++^[fin_rem_point_fin | Finite_ZF ]...  ''corollary''  <nowiki>fin_rem_point_fin</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ A - \{a\} \in  FinPow(X)$ === 
===  ''}'' 
 ''ultimately ''  ''have''  $ P(C)$ 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''note '' A3
 ''ultimately ''  ''show''  $ P(B)$ ''   by (rule '' +++^[FinPow_card_ind | Finite_ZF ]...  ''theorem''  <nowiki>FinPow_card_ind</nowiki>:  ''assumes '' $ P(0)$  ''and'' $ \forall k\in nat.\ $
$  (\forall A \in  FinPow(X).\  A \preceq  k \longrightarrow  P(A)) \longrightarrow $
$  (\forall A \in  FinPow(X).\  A \preceq  succ(k) \longrightarrow  P(A))$
 ''and'' $ A \in   FinPow(X)$  '' shows '' $ P(A)$ ===  '')'' 
 ''qed'' === 

Yet another induction theorem. This is similar, but slightly more complicated than //FinPow_ind_rem_one//. The difference is in the treatment of the empty set to allow to show properties that are not true for empty set.

 ''lemma''  <nowiki>FinPow_rem_ind</nowiki>:
 ''   assumes '' A1: $ \forall A \in  FinPow(X).\  $
$  A = 0 \vee  (\exists a\in A.\  A = \{a\} \vee  P(A-\{a\}) \longrightarrow  P(A))$ ''and '' A2: $ A \in   FinPow(X)$ ''and '' A3: $ A\neq 0$ ''   shows '' $ P(A)$+++[proof ]>
 ''have''  $ 0 = 0 \vee  P(0)$ 
 ''moreover''   ''have''  $ \forall k\in nat.\ $
$    (\forall B \in  FinPow(X).\  B \preceq  k \longrightarrow  (B=0 \vee  P(B))) \longrightarrow $
$    (\forall A \in  FinPow(X).\  A \preceq  succ(k) \longrightarrow  (A=0 \vee  P(A)))$+++[proof ]>
++++[{ ]>
 ''fix '' $ k$
 ''assume '' $ k \in  nat$
 ''assume '' A4: $ \forall B \in  FinPow(X).\  B \preceq  k \longrightarrow  (B=0 \vee  P(B))$
 ''have''  $ \forall A \in  FinPow(X).\  A \preceq  succ(k) \longrightarrow  (A=0 \vee  P(A))$+++[proof ]>
++++[{ ]>
 ''fix '' $ A$
 ''assume '' $ A \in  FinPow(X)$
 ''assume '' $ A \preceq  succ(k)$,  $ A\neq 0$
 ''from '' A1, $ A \in  FinPow(X)$, $ A\neq 0$  ''obtain '' $ a$ ''where '' $ a\in A$ ''and '' $ A = \{a\} \vee  P(A-\{a\}) \longrightarrow  P(A)$ 
 ''let '' $ B = A-\{a\}$
 ''from '' A4, $ A \in  FinPow(X)$, $ A \preceq  succ(k)$, $ a\in A$  ''have''  $ B = 0 \vee  P(B)$ ''using''  <nowiki>Diff_sing_lepoll</nowiki> ,  +++^[fin_rem_point_fin | Finite_ZF ]...  ''corollary''  <nowiki>fin_rem_point_fin</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ A - \{a\} \in  FinPow(X)$ === 
 ''with '' $ a\in A$, $ A = \{a\} \vee  P(A-\{a\}) \longrightarrow  P(A)$  ''have''  $ P(A)$ 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''note '' A2
 ''ultimately ''  ''have''  $ A=0 \vee  P(A)$ ''   by (rule '' +++^[FinPow_card_ind | Finite_ZF ]...  ''theorem''  <nowiki>FinPow_card_ind</nowiki>:  ''assumes '' $ P(0)$  ''and'' $ \forall k\in nat.\ $
$  (\forall A \in  FinPow(X).\  A \preceq  k \longrightarrow  P(A)) \longrightarrow $
$  (\forall A \in  FinPow(X).\  A \preceq  succ(k) \longrightarrow  P(A))$
 ''and'' $ A \in   FinPow(X)$  '' shows '' $ P(A)$ ===  '')'' 
 ''with '' A3  ''show''  $ P(A)$ 
 ''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)\}$=== 

Union of finite number of finite sets is finite.

 ''lemma''  <nowiki>fin_union_finpow</nowiki>:
 ''   assumes '' $ M \in  FinPow(FinPow(X))$ ''   shows '' $ \bigcup M \in  FinPow(X)$ ''using''  <nowiki>assms</nowiki> ,  +++^[empty_in_finpow | Finite_ZF ]...  ''lemma''  <nowiki>empty_in_finpow</nowiki>:  '' shows '' $ 0 \in  FinPow(X)$ ===  ,  +++^[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)$ ===  ,  +++^[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$ === 

If a set is finite after removing one element, then it is finite.

 ''lemma''  <nowiki>rem_point_fin_fin</nowiki>:
 ''   assumes '' A1: $ x \in  X$ ''and '' A2: $ A - \{x\} \in  FinPow(X)$ ''   shows '' $ A \in  FinPow(X)$+++[proof ]>
 ''from '' assms  ''have''  $ (A - \{x\}) \cup  \{x\} \in  FinPow(X)$ ''using''  +++^[singleton_in_finpow | Finite_ZF ]...  ''lemma''  <nowiki>singleton_in_finpow</nowiki>:  ''assumes '' $ x \in  X$  '' shows '' $ \{x\} \in  FinPow(X)$ ===  ,  +++^[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)$ === 
 ''moreover''   ''have''  $ A \subseteq  (A - \{x\}) \cup  \{x\}$ 
 ''ultimately ''  ''show''  $ A \in  FinPow(X)$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$===  ,  <nowiki>subset_Finite</nowiki>
 ''qed'' === 

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'' === 

Union of a finite indexed family of finite sets is finite.

 ''lemma''  <nowiki>union_fin_list_fin</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ \forall k \in  n.\  N(k) \in  FinPow(X)$ ''   shows '' $ \{N(k).\  k \in  n\} \in   FinPow(FinPow(X))$ ''and '' $ (\bigcup k \in  n.\  N(k)) \in  FinPow(X)$+++[proof ]>
 ''from '' A1  ''have''  $ n \in  FinPow(n)$ ''using''  +++^[nat_finpow_nat | Finite_ZF ]...  ''lemma''  <nowiki>nat_finpow_nat</nowiki>:  ''assumes '' $ n \in  nat$  '' shows '' $ n \in  FinPow(nat)$ ===  ,  +++^[fin_finpow_self | Finite_ZF ]...  ''lemma''  <nowiki>fin_finpow_self</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ A \in  FinPow(A)$ === 
 ''with '' A2  ''show''  $ \{N(k).\  k \in  n\} \in   FinPow(FinPow(X))$ ''   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 ''  ''show''  $ (\bigcup k \in  n.\  N(k)) \in  FinPow(X)$ ''using''  +++^[fin_union_finpow | Finite_ZF ]...  ''lemma''  <nowiki>fin_union_finpow</nowiki>:  ''assumes '' $ M \in  FinPow(FinPow(X))$  '' shows '' $ \bigcup M \in  FinPow(X)$ === 
 ''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>
=== 
 ''theory'' Fol1 ''imports'' [[Trancl]]

 ''begin
'' 
Isabelle/ZF builds on the first order logic. Almost everything one would like to have in this area is covered in the standard Isabelle libraries. The material in this theory provides some lemmas that are missing or allow for a more readable proof style.

!Notions and lemmas in FOL

This section contains mostly shortcuts and workarounds that allow to use more readable coding style.

The next lemma serves as a workaround to problems with applying the definition of transitivity (of a relation) in our coding style (any attempt to do something like //using trans_def// results up Isabelle in an infinite loop).

 ''lemma''  <nowiki>Fol1_L2</nowiki>:
 ''   assumes '' A1: $ \forall  x y z.\  \langle x, y\rangle  \in  r \wedge  \langle y, z\rangle  \in  r \longrightarrow  \langle x, z\rangle  \in  r$ ''   shows '' $ trans(r)$+++[proof ]>
 ''from '' A1  ''have''  $ \forall  x y z.\  \langle x, y\rangle  \in  r \longrightarrow  \langle y, z\rangle  \in  r \longrightarrow  \langle x, z\rangle  \in  r$ ''using''  <nowiki>imp_conj</nowiki>
 ''then ''  ''show''  $ thesis$ ''unfolding''  <nowiki>trans_def</nowiki>
 ''qed'' === 

Another workaround for the problem of Isabelle simplifier looping when the transitivity definition is used.

 ''lemma''  <nowiki>Fol1_L3</nowiki>:
 ''   assumes '' A1: $ trans(r)$ ''and '' A2: $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$ ''   shows '' $ \langle  a,c\rangle  \in  r$+++[proof ]>
 ''from '' A1  ''have''  $ \forall x y z.\  \langle x, y\rangle  \in  r \longrightarrow  \langle y, z\rangle  \in  r \longrightarrow  \langle x, z\rangle  \in  r$ ''unfolding''  <nowiki>trans_def</nowiki>
 ''with '' A2  ''show''  $ thesis$ ''using''  <nowiki>imp_conj</nowiki>
 ''qed'' === 

There is a problem with application of the definition of asymetry for relations. The next lemma is a workaround.

 ''lemma''  <nowiki>Fol1_L4</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ \langle  a,b\rangle  \in  r$,  $ \langle  b,a\rangle  \in  r$ ''   shows '' $ a=b$+++[proof ]>
 ''from '' A1  ''have''  $ \forall  x y.\  \langle  x,y\rangle  \in  r \longrightarrow  \langle  y,x\rangle  \in  r \longrightarrow  x=y$ ''unfolding''  <nowiki>antisym_def</nowiki>
 ''with '' A2  ''show''  $ a=b$ ''using''  <nowiki>imp_conj</nowiki>
 ''qed'' === 

The definition below implements a common idiom that states that (perhaps under some assumptions) exactly one of give three statements is true.

 ''Definition
'' $ Exactly\_1\_of\_3\_holds(p,q,r) \equiv  $
$  (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$

The next lemma allows to prove statements of the form $ Exactly\_1\_of\_3\_holds (p,q,r)$.

 ''lemma''  <nowiki>Fol1_L5</nowiki>:
 ''   assumes '' $ p\vee q\vee r$ ''and '' $ p \longrightarrow  \neg q \wedge  \neg r$ ''and '' $ q \longrightarrow  \neg p \wedge  \neg r$ ''and '' $ r \longrightarrow  \neg p \wedge  \neg q$ ''   shows '' $ Exactly\_1\_of\_3\_holds (p,q,r)$+++[proof ]>
 ''from '' prems  ''have''  $ (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$ 
 ''then ''  ''show''  $ Exactly\_1\_of\_3\_holds (p,q,r)$ ''unfolding''  +++^[Exactly_1_of_3_holds_def | Fol1 ]... Definition of <nowiki>Exactly_1_of_3_holds</nowiki>:
$ Exactly\_1\_of\_3\_holds(p,q,r) \equiv  $
$  (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$=== 
 ''qed'' === 

If exactly one of $p,q,r$ holds and $p$ is not true, then $q$ or $r$.

 ''lemma''  <nowiki>Fol1_L6</nowiki>:
 ''   assumes '' A1: $ \neg p$ ''and '' A2: $ Exactly\_1\_of\_3\_holds (p,q,r)$ ''   shows '' $ q\vee r$+++[proof ]>
 ''from '' A2  ''have''  $ (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$ ''unfolding''  +++^[Exactly_1_of_3_holds_def | Fol1 ]... Definition of <nowiki>Exactly_1_of_3_holds</nowiki>:
$ Exactly\_1\_of\_3\_holds(p,q,r) \equiv  $
$  (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$=== 
 ''hence''  $ p \vee  q \vee  r$
 ''with '' A1  ''show''  $ q \vee  r$ 
 ''qed'' === 

If exactly one of $p,q,r$ holds and $q$ is true, then $r$ can not be true.

 ''lemma''  <nowiki>Fol1_L7</nowiki>:
 ''   assumes '' A1: $ q$ ''and '' A2: $ Exactly\_1\_of\_3\_holds (p,q,r)$ ''   shows '' $ \neg r$+++[proof ]>
 ''from '' A2  ''have''  $ (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$ ''unfolding''  +++^[Exactly_1_of_3_holds_def | Fol1 ]... Definition of <nowiki>Exactly_1_of_3_holds</nowiki>:
$ Exactly\_1\_of\_3\_holds(p,q,r) \equiv  $
$  (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$=== 
 ''with '' A1  ''show''  $ \neg r$ 
 ''qed'' === 

The next lemma demonstrates an elegant form of the $ Exactly\_1\_of\_3\_holds (p,q,r)$ predicate. More on that at www.solcon.nl/mklooster/calc/calc-tri.html .

 ''lemma''  <nowiki>Fol1_L8</nowiki>:
 ''   shows '' $ Exactly\_1\_of\_3\_holds (p,q,r) \longleftrightarrow  (p\longleftrightarrow q\longleftrightarrow r) \wedge  \neg (p\wedge q\wedge r)$+++[proof ]>
 ''assume '' $ Exactly\_1\_of\_3\_holds (p,q,r)$
 ''then ''  ''have''  $ (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$ ''unfolding''  +++^[Exactly_1_of_3_holds_def | Fol1 ]... Definition of <nowiki>Exactly_1_of_3_holds</nowiki>:
$ Exactly\_1\_of\_3\_holds(p,q,r) \equiv  $
$  (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$=== 
 ''thus''  $ (p\longleftrightarrow q\longleftrightarrow r) \wedge  \neg (p\wedge q\wedge r)$
 ''next '' 
 ''assume '' $ (p\longleftrightarrow q\longleftrightarrow r) \wedge  \neg (p\wedge q\wedge r)$
 ''hence''  $ (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$
 ''then ''  ''show''  $ Exactly\_1\_of\_3\_holds (p,q,r)$ ''unfolding''  +++^[Exactly_1_of_3_holds_def | Fol1 ]... Definition of <nowiki>Exactly_1_of_3_holds</nowiki>:
$ Exactly\_1\_of\_3\_holds(p,q,r) \equiv  $
$  (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$=== 
 ''qed'' === 

A property of the //Exactly_1_of_3_holds// predicate.

 ''lemma''  <nowiki>Fol1_L8A</nowiki>:
 ''   assumes '' A1: $ Exactly\_1\_of\_3\_holds (p,q,r)$ ''   shows '' $ p \longleftrightarrow  \neg (q \vee  r)$+++[proof ]>
 ''from '' A1  ''have''  $ (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$ ''unfolding''  +++^[Exactly_1_of_3_holds_def | Fol1 ]... Definition of <nowiki>Exactly_1_of_3_holds</nowiki>:
$ Exactly\_1\_of\_3\_holds(p,q,r) \equiv  $
$  (p\vee q\vee r) \wedge  (p \longrightarrow  \neg q \wedge  \neg r) \wedge  (q \longrightarrow  \neg p \wedge  \neg r) \wedge  (r \longrightarrow  \neg p \wedge  \neg q)$=== 
 ''then ''  ''show''  $ p \longleftrightarrow  \neg (q \vee  r)$ 
 ''qed'' === 

Exclusive or definition. There is one also defined in the standard Isabelle, denoted //xor//, but it relates to boolean values, which are sets. Here we define a logical functor.

 ''Definition
'' $ p \text{ Xor }  q \equiv  (p\vee q) \wedge  \neg (p \wedge  q)$

The "exclusive or" is the same as negation of equivalence.

 ''lemma''  <nowiki>Fol1_L9</nowiki>:
 ''   shows '' $ p \text{ Xor }  q \longleftrightarrow  \neg (p\longleftrightarrow q)$ ''using''  +++^[Xor_def | Fol1 ]... Definition of <nowiki>Xor</nowiki>:
$ p \text{ Xor }  q \equiv  (p\vee q) \wedge  \neg (p \wedge  q)$=== 

Equivalence relations are symmetric.

 ''lemma''  <nowiki>equiv_is_sym</nowiki>:
 ''   assumes '' A1: $ equiv(X,r)$ ''and '' A2: $ \langle x,y\rangle  \in  r$ ''   shows '' $ \langle y,x\rangle  \in  r$+++[proof ]>
 ''from '' A1  ''have''  $ sym(r)$ ''using''  <nowiki>equiv_def</nowiki>
 ''then ''  ''have''  $ \forall x y.\  \langle x,y\rangle  \in  r \longrightarrow  \langle y,x\rangle  \in  r$ ''unfolding''  <nowiki>sym_def</nowiki>
 ''with '' A2  ''show''  $ \langle y,x\rangle  \in  r$ 
 ''qed'' === 

 ''end

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

 ''begin
'' 
Suppose we have a binary operation $P: X\times X \rightarrow X$ written multiplicatively as $P\langle x, y \rangle= x\cdot y$. In informal mathematics we can take a sequence $\{ x_k \}_{k\in 0.. n}$ of elements of $X$ and consider the product $x_0\cdot x_1 \cdot .. \cdot x_n$. To do the same thing in formalized mathematics we have to define precisely what is meant by that "$\cdot .. \cdot$". The definitition we want to use is based on the notion of sequence defined by induction discussed in //InductiveSeq_ZF//. We don't really want to derive the terminology for this from the word "product" as that would tie it conceptually to the multiplicative notation. This would be awkward when we want to reuse the same notions to talk about sums like $x_0 + x_1 + .. + x_n$.
In functional programming there is something called "fold". Namely for a function $f$, initial point $a$ and list $\left[ b, c, d\right]$ the expression $ fold(f, a, [b,c,d])$ is defined to be $ f(f(f(a,b),c),d)$ (in Haskell something like this is called //foldl//). If we write $f$ in multiplicative notation we get $a\cdot b \cdot c\cdot d$, so this is exactly what we need. The notion of folds in functional programming is actually much more general that what we need here (not that I know anything about that). In this theory file we just make a slight generalization and talk about folding a list with a binary operation $f:X\times Y \rightarrow X$ with $X$ not necessarily the same as $Y$.

!Folding in ZF

Suppose we have a binary operation $f : X\times Y \rightarrow X$. Then every $y\in Y$ defines a transformation of $X$ defined by $T_y(x) = f\langle x,y\rangle$. In IsarMathLib such transformation is called as $ Fix2ndVar(f,y)$. Using this notion, given a function $f: X\times Y\rightarrow X$ and a sequence $y = \{y_k\}_{k\in N}$ of elements of $X$ we can get a sequence of transformations of $X$. This is defined in //Seq2TransSeq// below. Then we use that sequence of tranformations to define the sequence of partial folds (called //FoldSeq//) by means of //InductiveSeqVarFN// (defined in //InductiveSeq_ZF// theory) which implements the inductive sequence determined by a starting point and a sequence of transformations. Finally, we define the fold of a sequence as the last element of the sequence of the partial folds.

Definition that specifies how to convert a sequence $a$ of elements of $Y$ into a sequence of transformations of $X$, given a binary operation $f :X\times Y \rightarrow X$.

 ''Definition
'' $ Seq2TrSeq(f,a) \equiv  \{\langle k,Fix2ndVar(f,a(k))\rangle .\  k \in  domain(a)\}$

Definition of a sequence of partial folds.

 ''Definition
'' $ FoldSeq(f,x,a) \equiv  $
$  InductiveSeqVarFN(x,fstdom(f),Seq2TrSeq(f,a),domain(a))$

Definition of a fold.

 ''Definition
'' $ Fold(f,x,a) \equiv  Last(FoldSeq(f,x,a))$

If $X$ is a set with a binary operation $f:X\times Y \rightarrow X$ then $ Seq2TransSeqN(f,a)$ converts a sequence $a$ of elements of $Y$ into the sequence of corresponding transformations of $X$.

 ''lemma''  <nowiki>seq2trans_seq_props</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ f : X\times Y \rightarrow  X$ ''and '' A3: $ a:n\rightarrow Y$ ''and '' A4: $ T = Seq2TrSeq(f,a)$ ''   shows '' $ T : n \rightarrow  (X\rightarrow X)$ ''and '' $ \forall k\in n.\  \forall x\in X.\  (T(k))(x) = f\langle x,a(k)\rangle $+++[proof ]>
 ''from '' $ a:n\rightarrow Y$  ''have''  D: $ domain(a) = n$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ === 
 ''with '' A2, A3, A4  ''show''  $ T : n \rightarrow  (X\rightarrow X)$ ''using''  <nowiki>apply_funtype</nowiki> ,  +++^[fix_2nd_var_fun | func1 ]...  ''lemma''  <nowiki>fix_2nd_var_fun</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  ''and'' $ y\in Y$  '' shows '' $ Fix2ndVar(f,y) : X \rightarrow  Z$ ===  ,  +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ ===  ,  +++^[Seq2TrSeq_def | Fold_ZF ]... Definition of <nowiki>Seq2TrSeq</nowiki>:
$ Seq2TrSeq(f,a) \equiv  \{\langle k,Fix2ndVar(f,a(k))\rangle .\  k \in  domain(a)\}$=== 
 ''with '' A4, D  ''have''  I: $ \forall k \in  n.\  T(k) = Fix2ndVar(f,a(k))$ ''using''  +++^[Seq2TrSeq_def | Fold_ZF ]... Definition of <nowiki>Seq2TrSeq</nowiki>:
$ Seq2TrSeq(f,a) \equiv  \{\langle k,Fix2ndVar(f,a(k))\rangle .\  k \in  domain(a)\}$===  ,  +++^[ZF_fun_from_tot_val0 | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_tot_val0</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$  '' shows '' $ \forall x\in X.\  f(x) = b(x)$ === 
++++[{ ]>
 ''fix '' $ k$ $ fix$ $ x$
 ''assume '' A5: $ k\in n$,  $ x\in X$
 ''with '' A1, A3  ''have''  $ a(k) \in  Y$ ''using''  <nowiki>apply_funtype</nowiki>
 ''with '' A2, A5, I  ''have''  $ (T(k))(x) = f\langle x,a(k)\rangle $ ''using''  +++^[fix_var_val | func1 ]...  ''lemma''  <nowiki>fix_var_val</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  ''and'' $ x\in X$,   $ y\in Y$  '' shows '' $ Fix1stVar(f,x)(y) = f\langle x,y\rangle $,   $ Fix2ndVar(f,y)(x) = f\langle x,y\rangle $ === 
===  ''}'' 
 ''thus''  $ \forall k\in n.\  \forall x\in X.\  (T(k))(x) = f\langle x,a(k)\rangle $
 ''qed'' === 

Basic properties of the sequence of partial folds of a sequence $a = \{y_k\}_{k\in \{0,..,n\} }$.

 ''theorem''  <nowiki>fold_seq_props</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ f : X\times Y \rightarrow  X$ ''and '' A3: $ y:n\rightarrow Y$ ''and '' A4: $ x\in X$ ''and '' A5: $ Y\neq 0$ ''and '' A6: $ F = FoldSeq(f,x,y)$ ''   shows '' $ F: succ(n) \rightarrow  X$,  $ F(0) = x$ ''and '' $ \forall k\in n.\  F(succ(k)) = f\langle F(k), y(k)\rangle $+++[proof ]>
 ''let '' $ T = Seq2TrSeq(f,y)$
 ''from '' A1, A3  ''have''  D: $ domain(y) = n$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ === 
 ''from '' $ f : X\times Y \rightarrow  X$, $ Y\neq 0$  ''have''  I: $ fstdom(f) = X$ ''using''  +++^[fstdomdef | func1 ]...  ''lemma''  <nowiki>fstdomdef</nowiki>:  ''assumes '' $ f: X\times Y \rightarrow  Z$  ''and'' $ Y\neq 0$  '' shows '' $ fstdom(f) = X$ === 
 ''with '' A1, A2, A3, A4, A6, D  ''show''  II: $ F: succ(n) \rightarrow  X$ ''and '' $ F(0) = x$ ''using''  +++^[seq2trans_seq_props | Fold_ZF ]...  ''lemma''  <nowiki>seq2trans_seq_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$  ''and'' $ a:n\rightarrow Y$  ''and'' $ T = Seq2TrSeq(f,a)$  '' shows '' $ T : n \rightarrow  (X\rightarrow X)$  ''and'' $ \forall k\in n.\  \forall x\in X.\  (T(k))(x) = f\langle x,a(k)\rangle $ ===  ,  +++^[FoldSeq_def | Fold_ZF ]... Definition of <nowiki>FoldSeq</nowiki>:
$ FoldSeq(f,x,a) \equiv  $
$  InductiveSeqVarFN(x,fstdom(f),Seq2TrSeq(f,a),domain(a))$===  ,  <nowiki>fin_indseq_var_f_props</nowiki>
 ''from '' A1, A2, A3, A4, A6, I, D  ''have''  $ \forall k\in n.\  F(succ(k)) = T(k)(F(k))$ ''using''  +++^[seq2trans_seq_props | Fold_ZF ]...  ''lemma''  <nowiki>seq2trans_seq_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$  ''and'' $ a:n\rightarrow Y$  ''and'' $ T = Seq2TrSeq(f,a)$  '' shows '' $ T : n \rightarrow  (X\rightarrow X)$  ''and'' $ \forall k\in n.\  \forall x\in X.\  (T(k))(x) = f\langle x,a(k)\rangle $ ===  ,  +++^[FoldSeq_def | Fold_ZF ]... Definition of <nowiki>FoldSeq</nowiki>:
$ FoldSeq(f,x,a) \equiv  $
$  InductiveSeqVarFN(x,fstdom(f),Seq2TrSeq(f,a),domain(a))$===  ,  <nowiki>fin_indseq_var_f_props</nowiki>
 ''moreover''  ++++[{ ]>
 ''fix '' $ k$
 ''assume '' A5: $ k\in n$
 ''hence''  $ k \in  succ(n)$
 ''with '' A1, A2, A3, II, A5  ''have''  $ (T(k))(F(k)) = f\langle F(k),y(k)\rangle $ ''using''  <nowiki>apply_funtype</nowiki> ,  +++^[seq2trans_seq_props | Fold_ZF ]...  ''lemma''  <nowiki>seq2trans_seq_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$  ''and'' $ a:n\rightarrow Y$  ''and'' $ T = Seq2TrSeq(f,a)$  '' shows '' $ T : n \rightarrow  (X\rightarrow X)$  ''and'' $ \forall k\in n.\  \forall x\in X.\  (T(k))(x) = f\langle x,a(k)\rangle $ === 
===  ''}'' 
 ''ultimately ''  ''show''  $ \forall k\in n.\  F(succ(k)) = f\langle F(k), y(k)\rangle $ 
 ''qed'' === 

A consistency condition: if we make the list shorter, then we get a shorter sequence of partial folds with the same values as in the original sequence. This can be proven as a special case of //fin_indseq_var_f_restrict// but a proof using //fold_seq_props// and induction turns out to be shorter.

 ''lemma''  <nowiki>foldseq_restrict</nowiki>:
 ''   assumes '' $ n \in  nat$,  $ k \in  succ(n)$ ''and '' $ i \in  nat$,  $ f : X\times Y \rightarrow  X$,  $ a : n \rightarrow  Y$,  $ b : i \rightarrow  Y$ ''and '' $ n \subseteq  i$,  $ \forall j \in  n.\  b(j) = a(j)$,  $ x \in  X$,  $ Y \neq  0$ ''   shows '' $ FoldSeq(f,x,b)(k) = FoldSeq(f,x,a)(k)$+++[proof ]>
 ''let '' $ P = FoldSeq(f,x,a)$
 ''let '' $ Q = FoldSeq(f,x,b)$
 ''from '' assms  ''have''  $ n \in  nat$,  $ k \in  succ(n)$,  $ Q(0) = P(0)$ ''and '' $ \forall j \in  n.\  Q(j) = P(j) \longrightarrow  Q(succ(j)) = P(succ(j))$ ''using''  +++^[fold_seq_props | Fold_ZF ]...  ''theorem''  <nowiki>fold_seq_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$  ''and'' $ y:n\rightarrow Y$  ''and'' $ x\in X$  ''and'' $ Y\neq 0$  ''and'' $ F = FoldSeq(f,x,y)$  '' shows '' $ F: succ(n) \rightarrow  X$,   $ F(0) = x$  ''and'' $ \forall k\in n.\  F(succ(k)) = f\langle F(k), y(k)\rangle $ === 
 ''then ''  ''show''  $ Q(k) = P(k)$ ''   by (rule '' +++^[fin_nat_ind | Nat_ZF_IML ]...  ''lemma''  <nowiki>fin_nat_ind</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k \in  succ(n)$  ''and'' $ P(0)$  ''and'' $ \forall j\in n.\  P(j)  \longrightarrow  P(succ(j))$  '' shows '' $ P(k)$ ===  '')'' 
 ''qed'' === 

A special case of //foldseq_restrict// when the longer sequence is created from the shorter one by appending one element.

 ''corollary''  <nowiki>fold_seq_append</nowiki>:
 ''   assumes '' $ n \in  nat$,  $ f : X\times Y \rightarrow  X$,  $ a:n \rightarrow  Y$ ''and '' $ x\in X$,  $ k \in  succ(n)$,  $ y\in Y$ ''   shows '' $ FoldSeq(f,x,Append(a,y))(k) = FoldSeq(f,x,a)(k)$+++[proof ]>
 ''let '' $ b = Append(a,y)$
 ''from '' assms  ''have''  $ b : succ(n) \rightarrow  Y$,  $ \forall j \in  n.\  b(j) = a(j)$ ''using''  <nowiki>append_props</nowiki>
 ''with '' assms  ''show''  $ thesis$ ''using''  +++^[foldseq_restrict | Fold_ZF ]...  ''lemma''  <nowiki>foldseq_restrict</nowiki>:  ''assumes '' $ n \in  nat$,   $ k \in  succ(n)$  ''and'' $ i \in  nat$,  
$ f : X\times Y \rightarrow  X$,   $ a : n \rightarrow  Y$,   $ b : i \rightarrow  Y$  ''and'' $ n \subseteq  i$,   $ \forall j \in  n.\  b(j) = a(j)$,   $ x \in  X$,   $ Y \neq  0$  '' shows '' $ FoldSeq(f,x,b)(k) = FoldSeq(f,x,a)(k)$ === 
 ''qed'' === 

What we really will be using is the notion of the fold of a sequence, which we define as the last element of (inductively defined) sequence of partial folds. The next theorem lists some properties of the product of the fold operation.

 ''theorem''  <nowiki>fold_props</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ f : X\times Y \rightarrow  X$,  $ a:n \rightarrow  Y$,  $ x\in X$,  $ Y\neq 0$ ''   shows '' $ Fold(f,x,a) =  FoldSeq(f,x,a)(n)$ ''and '' $ Fold(f,x,a) \in  X$+++[proof ]>
 ''from '' assms  ''have''  $  FoldSeq(f,x,a) : succ(n) \rightarrow  X$ ''using''  +++^[fold_seq_props | Fold_ZF ]...  ''theorem''  <nowiki>fold_seq_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$  ''and'' $ y:n\rightarrow Y$  ''and'' $ x\in X$  ''and'' $ Y\neq 0$  ''and'' $ F = FoldSeq(f,x,y)$  '' shows '' $ F: succ(n) \rightarrow  X$,   $ F(0) = x$  ''and'' $ \forall k\in n.\  F(succ(k)) = f\langle F(k), y(k)\rangle $ === 
 ''with '' A1  ''show''  $ Fold(f,x,a) =  FoldSeq(f,x,a)(n)$ ''and '' $ Fold(f,x,a) \in  X$ ''using''  <nowiki>last_seq_elem</nowiki> ,  <nowiki>apply_funtype</nowiki> ,  +++^[Fold_def | Fold_ZF ]... Definition of <nowiki>Fold</nowiki>:
$ Fold(f,x,a) \equiv  Last(FoldSeq(f,x,a))$=== 
 ''qed'' === 

A corner case: what happens when we fold an empty list?

 ''theorem''  <nowiki>fold_empty</nowiki>:
 ''   assumes '' A1: $ f : X\times Y \rightarrow  X$ ''and '' A2: $ a:0\rightarrow Y$,  $ x\in X$,  $ Y\neq 0$ ''   shows '' $ Fold(f,x,a) = x$+++[proof ]>
 ''let '' $ F = FoldSeq(f,x,a)$
 ''from '' assms  ''have''  I: $ 0 \in  nat$,  $ f : X\times Y \rightarrow  X$,  $ a:0\rightarrow Y$,  $ x\in X$,  $ Y\neq 0$ 
 ''then ''  ''have''  $ Fold(f,x,a) = F(0)$ ''   by (rule '' +++^[fold_props | Fold_ZF ]...  ''theorem''  <nowiki>fold_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$,   $ a:n \rightarrow  Y$,   $ x\in X$,   $ Y\neq 0$  '' shows '' $ Fold(f,x,a) =  FoldSeq(f,x,a)(n)$  ''and'' $ Fold(f,x,a) \in  X$ ===  '')'' 
 ''moreover''   ''from '' I  ''have''  $ 0 \in  nat$,  $ f : X\times Y \rightarrow  X$,  $ a:0\rightarrow Y$,  $ x\in X$,  $ Y\neq 0$ ''and '' $ F = FoldSeq(f,x,a)$ 
 ''then ''  ''have''  $ F(0) = x$ ''   by (rule '' +++^[fold_seq_props | Fold_ZF ]...  ''theorem''  <nowiki>fold_seq_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$  ''and'' $ y:n\rightarrow Y$  ''and'' $ x\in X$  ''and'' $ Y\neq 0$  ''and'' $ F = FoldSeq(f,x,y)$  '' shows '' $ F: succ(n) \rightarrow  X$,   $ F(0) = x$  ''and'' $ \forall k\in n.\  F(succ(k)) = f\langle F(k), y(k)\rangle $ ===  '')'' 
 ''ultimately ''  ''show''  $ Fold(f,x,a) = x$ 
 ''qed'' === 

The next theorem tells us what happens to the fold of a sequence when we add one more element to it.

 ''theorem''  <nowiki>fold_append</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ f : X\times Y \rightarrow  X$ ''and '' A3: $ a:n\rightarrow Y$ ''and '' A4: $ x\in X$ ''and '' A5: $ y\in Y$ ''   shows '' $ FoldSeq(f,x,Append(a,y))(n) = Fold(f,x,a)$ ''and '' $ Fold(f,x,Append(a,y)) = f\langle Fold(f,x,a), y\rangle $+++[proof ]>
 ''let '' $ b = Append(a,y)$
 ''let '' $ P = FoldSeq(f,x,b)$
 ''from '' A5  ''have''  I: $ Y \neq  0$ 
 ''with '' assms  ''show''  thesis1: $ P(n) = Fold(f,x,a)$ ''using''  +++^[fold_seq_append | Fold_ZF ]...  ''corollary''  <nowiki>fold_seq_append</nowiki>:  ''assumes '' $ n \in  nat$,   $ f : X\times Y \rightarrow  X$,   $ a:n \rightarrow  Y$  ''and'' $ x\in X$,   $ k \in  succ(n)$,   $ y\in Y$  '' shows '' $ FoldSeq(f,x,Append(a,y))(k) = FoldSeq(f,x,a)(k)$ ===  ,  +++^[fold_props | Fold_ZF ]...  ''theorem''  <nowiki>fold_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$,   $ a:n \rightarrow  Y$,   $ x\in X$,   $ Y\neq 0$  '' shows '' $ Fold(f,x,a) =  FoldSeq(f,x,a)(n)$  ''and'' $ Fold(f,x,a) \in  X$ === 
 ''from '' assms, I  ''have''  II: $ succ(n) \in  nat$,  $ f : X\times Y \rightarrow  X$,  $ b : succ(n) \rightarrow  Y$,  $ x\in X$,  $ Y \neq  0$,  $ P = FoldSeq(f,x,b)$ ''using''  <nowiki>append_props</nowiki>
 ''then ''  ''have''  $ \forall k \in  succ(n).\  P(succ(k)) =  f\langle P(k), b(k)\rangle $ ''   by (rule '' +++^[fold_seq_props | Fold_ZF ]...  ''theorem''  <nowiki>fold_seq_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$  ''and'' $ y:n\rightarrow Y$  ''and'' $ x\in X$  ''and'' $ Y\neq 0$  ''and'' $ F = FoldSeq(f,x,y)$  '' shows '' $ F: succ(n) \rightarrow  X$,   $ F(0) = x$  ''and'' $ \forall k\in n.\  F(succ(k)) = f\langle F(k), y(k)\rangle $ ===  '')'' 
 ''with '' A3, A5, thesis1  ''have''  $ P(succ(n)) =  f\langle  Fold(f,x,a), y\rangle $ ''using''  <nowiki>append_props</nowiki>
 ''moreover''   ''from '' II  ''have''  $ P : succ(succ(n)) \rightarrow  X$ ''   by (rule '' +++^[fold_seq_props | Fold_ZF ]...  ''theorem''  <nowiki>fold_seq_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$  ''and'' $ y:n\rightarrow Y$  ''and'' $ x\in X$  ''and'' $ Y\neq 0$  ''and'' $ F = FoldSeq(f,x,y)$  '' shows '' $ F: succ(n) \rightarrow  X$,   $ F(0) = x$  ''and'' $ \forall k\in n.\  F(succ(k)) = f\langle F(k), y(k)\rangle $ ===  '')'' 
 ''then ''  ''have''  $ Fold(f,x,b) = P(succ(n))$ ''using''  <nowiki>last_seq_elem</nowiki> ,  +++^[Fold_def | Fold_ZF ]... Definition of <nowiki>Fold</nowiki>:
$ Fold(f,x,a) \equiv  Last(FoldSeq(f,x,a))$=== 
 ''ultimately ''  ''show''  $ Fold(f,x,Append(a,y)) = f\langle Fold(f,x,a), y\rangle $ 
 ''qed'' === 

 ''end

'' +++![Comments on Fold_ZF|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Fold_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
 ''assumes '' groupAssum: $ \text{IsAgroup}(G,P)$
 ''defines '' $ 1  \equiv  TheNeutralElement(G,P)$
 ''defines '' $ a \cdot  b \equiv  P\langle a,b\rangle $
 ''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''  +++^[func1_1_L11 | func1 ]...  ''lemma''  <nowiki>func1_1_L11</nowiki>:  ''assumes '' $ f \subseteq  X\times Y$  ''and'' $ \forall x\in X.\  \exists !y.\  y\in Y \wedge  \langle x,y\rangle  \in  f$  '' shows '' $ f: X\rightarrow Y$ === 
 ''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''  +++^[func1_1_L14 | func1 ]...  ''lemma''  <nowiki>func1_1_L14</nowiki>:  ''assumes '' $ f\in X\rightarrow Y$  '' shows '' $ f^{-1}(\{y\}) = \{x\in X.\  f(x) = y\}$ ===  ,  +++^[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''  +++^[func1_1_L5A | func1 ]...  ''lemma''  <nowiki>func1_1_L5A</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$,   $ y = f(x)$  '' shows '' $ \langle  x,y\rangle  \in  f$,   $ y \in  range(f)$ === 
 ''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''  +++^[func1_1_L5 | func1 ]...  ''lemma''  <nowiki>func1_1_L5</nowiki>:  ''assumes '' $ \langle  x,y\rangle  \in  f$  ''and'' $ f:X\rightarrow Y$  '' shows '' $ x\in X \wedge  y\in Y$ === 
 ''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> ,  +++^[func1_2_L1 | func1 ]...  ''lemma''  <nowiki>func1_2_L1</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ B\subseteq X$  '' shows '' $ restrict(f,B)^{-1}(A) = f^{-1}(A) \cap  B$ === 
 ''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''  +++^[func1_2_L3 | func1 ]...  ''lemma''  <nowiki>func1_2_L3</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ g:A\rightarrow Z$  ''and'' $ A\subseteq X$  ''and'' $ f \cap  A\times Z = g$  '' shows '' $ g = restrict(f,A)$ === 
 ''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\}$===  ,  +++^[func1_1_L11A | func1 ]...  ''lemma''  <nowiki>func1_1_L11A</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x)\in Y$  '' shows '' $ \{\langle  x,y\rangle  \in  X\times Y.\  b(x) = y\} : X\rightarrow Y$ === 
 ''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\}$===  ,  +++^[func1_1_L11B | func1 ]...  ''lemma''  <nowiki>func1_1_L11B</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$  ''and'' $ f = \{\langle  x,y\rangle  \in  X\times Y.\  b(x) = y\}$  '' shows '' $ f(x) = b(x)$ === 

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''  +++^[func1_1_L15C | func1 ]...  ''lemma''  <nowiki>func1_1_L15C</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ g:Y\rightarrow Z$  ''and'' $ A\subseteq X$  '' shows '' $ g(f(A)) =  \{g(f(x)).\  x\in A\}$,   $ g(f(A)) = (g\circ f)(A)$ ===  ,  +++^[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
 ''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'' Group_ZF_2 ''imports'' [[AbelianGroup_ZF]] [[func_ZF]] [[EquivClass1]]

 ''begin
'' 
This theory continues Group\_ZF.thy and considers lifting the group structure to function spaces and projecting the group structure to quotient spaces, in particular the quotient qroup.

!Lifting groups to function spaces

If we have a monoid (group) $G$ than we get a monoid (group) structure on a space of functions valued in in $G$ by defining $(f\cdot g)(x) := f(x)\cdot g(x)$. We call this process ''lifting the monoid (group) to function space''. This section formalizes this lifting.

The lifted operation is an operation on the function space.

 ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_L0A</nowiki>:
 ''   assumes '' A1: $ F = f \text{ lifted to function space over } X$ ''   shows '' $ F : (X\rightarrow G)\times (X\rightarrow G)\rightarrow (X\rightarrow 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  )))$=== 
 ''with '' A1  ''show''  $ thesis$ ''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))$ ===  ,  +++^[group0_1_L3B | Monoid_ZF ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>group0_1_L3B</nowiki>:  '' shows '' $ range(f) = G$ === 
 ''qed'' === 

The result of the lifted operation is in the function space.

 ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_L0</nowiki>:
 ''   assumes '' A1: $ F = f \text{ lifted to function space over } X$ ''and '' A2: $ s:X\rightarrow G$,  $ r:X\rightarrow G$ ''   shows '' $ F\langle  s,r\rangle  : X\rightarrow G$+++[proof ]>
 ''from '' A1  ''have''  $ F : (X\rightarrow G)\times (X\rightarrow G)\rightarrow (X\rightarrow G)$ ''using''  +++^[Group_ZF_2_1_L0A | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_L0A</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  '' shows '' $ F : (X\rightarrow G)\times (X\rightarrow G)\rightarrow (X\rightarrow G)$ === 
 ''with '' A2  ''show''  $ thesis$ ''using''  <nowiki>apply_funtype</nowiki>
 ''qed'' === 

The lifted monoid operation has a neutral element, namely the constant function with the neutral element as the value.

 ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_L1</nowiki>:
 ''   assumes '' A1: $ F = f \text{ lifted to function space over } X$ ''and '' A2: $ E = ConstantFunction(X,TheNeutralElement(G,f))$ ''   shows '' $ E : X\rightarrow G \wedge  (\forall s\in X\rightarrow G.\  F\langle  E,s\rangle  = s \wedge  F\langle  s,E\rangle  = s)$+++[proof ]>
 ''from '' A2  ''show''  T1: $ E : X\rightarrow 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)$ ===  ,  +++^[func1_3_L1 | func1 ]...  ''lemma''  <nowiki>func1_3_L1</nowiki>:  ''assumes '' $ c\in Y$  '' shows '' $ ConstantFunction(X,c) : X\rightarrow Y$ === 
 ''show''  $ \forall s\in X\rightarrow G.\  F\langle  E,s\rangle  = s \wedge  F\langle  s,E\rangle  = s$+++[proof ]>
 ''fix '' $ s$
 ''assume '' A3: $ s:X\rightarrow G$
 ''from '' monoidAsssum  ''have''  T2: $ 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  )))$=== 
 ''from '' A3, A1, T1  ''have''  $ F\langle  E,s\rangle  : X\rightarrow G$,  $ F\langle  s,E\rangle  : X\rightarrow G$,  $ s : X\rightarrow G$ ''using''  +++^[Group_ZF_2_1_L0 | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_L0</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  ''and'' $ s:X\rightarrow G$,   $ r:X\rightarrow G$  '' shows '' $ F\langle  s,r\rangle  : X\rightarrow G$ === 
 ''moreover''   ''from '' T2, A1, T1, A2, A3  ''have''  $ \forall x\in X.\  (F\langle  E,s\rangle )(x) = s(x)$,  $ \forall x\in X.\  (F\langle  s,E\rangle )(x) = s(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 $ ===  ,  +++^[group0_1_L3B | Monoid_ZF ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>group0_1_L3B</nowiki>:  '' shows '' $ range(f) = G$ ===  ,  +++^[func1_3_L2 | func1 ]...  ''lemma''  <nowiki>func1_3_L2</nowiki>:  ''assumes '' $ x\in X$  '' shows '' $ ConstantFunction(X,c)(x) = c$ ===  ,  <nowiki>apply_type</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)$ === 
 ''ultimately ''  ''show''  $ F\langle  E,s\rangle  = s \wedge  F\langle  s,E\rangle  = s$ ''using''  <nowiki>fun_extension_iff</nowiki>
 ''qed'' === 
 ''qed'' === 

Monoids can be lifted to a function space.

 ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_T1</nowiki>:
 ''   assumes '' A1: $ F = f \text{ lifted to function space over } X$ ''   shows '' $ \text{IsAmonoid}(X\rightarrow G,F)$+++[proof ]>
 ''from '' monoidAsssum, A1  ''have''  $ F \text{ is associative on } (X\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))))$===  ,  +++^[func_ZF_2_L4 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_2_L4</nowiki>:  ''assumes '' $ f \text{ is associative on } G$  ''and'' $ F = f \text{ lifted to function space over } X$  '' shows '' $ F \text{ is associative on } (X\rightarrow range(f))$ ===  ,  +++^[group0_1_L3B | Monoid_ZF ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>group0_1_L3B</nowiki>:  '' shows '' $ range(f) = G$ === 
 ''moreover''   ''from '' A1  ''have''  $ \exists  E \in  X\rightarrow G.\  \forall s \in  X\rightarrow G.\  F\langle  E,s\rangle  = s \wedge  F\langle  s,E\rangle  = s$ ''using''  +++^[Group_ZF_2_1_L1 | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_L1</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  ''and'' $ E = ConstantFunction(X,TheNeutralElement(G,f))$  '' shows '' $ E : X\rightarrow G \wedge  (\forall s\in X\rightarrow G.\  F\langle  E,s\rangle  = s \wedge  F\langle  s,E\rangle  = s)$
=== 
 ''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))))$=== 
 ''qed'' === 

The constant function with the neutral element as the value is the neutral element of the lifted monoid.

 ''lemma''  <nowiki>Group_ZF_2_1_L2</nowiki>:
 ''   assumes '' A1: $ \text{IsAmonoid}(G,f)$ ''and '' A2: $ F = f \text{ lifted to function space over } X$ ''and '' A3: $ E = ConstantFunction(X,TheNeutralElement(G,f))$ ''   shows '' $ E = TheNeutralElement(X\rightarrow G,F)$+++[proof ]>
 ''from '' A1, A2  ''have''  T1: $ monoid0(G,f)$ ''and '' T2: $ monoid0(X\rightarrow G,F)$ ''using''  <nowiki>monoid0_def</nowiki> ,  +++^[Group_ZF_2_1_T1 | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_T1</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  '' shows '' $ \text{IsAmonoid}(X\rightarrow G,F)$ === 
 ''from '' T1, A2, A3  ''have''  $ E : X\rightarrow G \wedge  (\forall s\in X\rightarrow G.\  F\langle  E,s\rangle  = s \wedge  F\langle  s,E\rangle  = s)$ ''using''  +++^[Group_ZF_2_1_L1 | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_L1</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  ''and'' $ E = ConstantFunction(X,TheNeutralElement(G,f))$  '' shows '' $ E : X\rightarrow G \wedge  (\forall s\in X\rightarrow G.\  F\langle  E,s\rangle  = s \wedge  F\langle  s,E\rangle  = s)$
=== 
 ''with '' T2  ''show''  $ thesis$ ''using''  +++^[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)$ === 
 ''qed'' === 

The lifted operation acts on the functions in a natural way defined by the monoid operation.

 ''lemma''  ''(in'' monoid0'')'' <nowiki>lifted_val</nowiki>:
 ''   assumes '' $ F = f \text{ lifted to function space over } X$ ''and '' $ s:X\rightarrow G$,  $ r:X\rightarrow G$ ''and '' $ x\in X$ ''   shows '' $ (F\langle s,r\rangle )(x) = s(x) \oplus  r(x)$ ''using''  <nowiki>monoidAsssum</nowiki> ,  <nowiki>assms</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  )))$===  ,  +++^[group0_1_L3B | Monoid_ZF ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>group0_1_L3B</nowiki>:  '' shows '' $ range(f) = G$ ===  ,  +++^[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 $ === 

The lifted operation acts on the functions in a natural way defined by the group operation. This is the same as //lifted_val//, but in the //group0// context.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L3</nowiki>:
 ''   assumes '' $ F = P \text{ lifted to function space over } X$ ''and '' $ s:X\rightarrow G$,  $ r:X\rightarrow G$ ''and '' $ x\in X$ ''   shows '' $ (F\langle s,r\rangle )(x) = s(x)\cdot r(x)$ ''using''  <nowiki>assms</nowiki> ,  +++^[group0_2_L1 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L1</nowiki>:  '' shows '' $ monoid0(G,P)$ ===  ,  +++^[lifted_val | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>lifted_val</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  ''and'' $ s:X\rightarrow G$,   $ r:X\rightarrow G$  ''and'' $ x\in X$  '' shows '' $ (F\langle s,r\rangle )(x) = s(x) \oplus  r(x)$ === 

In the group0 context we can apply theorems proven in monoid0 context to the lifted monoid.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L4</nowiki>:
 ''   assumes '' A1: $ F = P \text{ lifted to function space over } X$ ''   shows '' $ monoid0(X\rightarrow G,F)$+++[proof ]>
 ''from '' A1  ''show''  $ thesis$ ''using''  +++^[group0_2_L1 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L1</nowiki>:  '' shows '' $ monoid0(G,P)$ ===  ,  +++^[Group_ZF_2_1_T1 | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_T1</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  '' shows '' $ \text{IsAmonoid}(X\rightarrow G,F)$ ===  ,  <nowiki>monoid0_def</nowiki>
 ''qed'' === 

The compostion of a function $f:X\rightarrow G$ with the group inverse is a right inverse for the lifted group.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L5</nowiki>:
 ''   assumes '' A1: $ F = P \text{ lifted to function space over } X$ ''and '' A2: $ s : X\rightarrow G$ ''and '' A3: $ i = GroupInv(G,P)\circ s$ ''   shows '' $ i: X\rightarrow G$ ''and '' $ F\langle  s,i\rangle  = TheNeutralElement(X\rightarrow G,F)$+++[proof ]>
 ''let '' $ E = ConstantFunction(X,1 )$
 ''have''  $ E : X\rightarrow 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))$ ===  ,  +++^[func1_3_L1 | func1 ]...  ''lemma''  <nowiki>func1_3_L1</nowiki>:  ''assumes '' $ c\in Y$  '' shows '' $ ConstantFunction(X,c) : X\rightarrow Y$ === 
 ''moreover''   ''from '' groupAssum, A2, A3, A1  ''have''  $ F\langle  s,i\rangle  :  X\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$ ===  ,  <nowiki>comp_fun</nowiki> ,  +++^[Group_ZF_2_1_L4 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L4</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  '' shows '' $ monoid0(X\rightarrow G,F)$ ===  ,  +++^[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$ === 
 ''moreover''   ''from '' groupAssum, A2, A3, A1  ''have''  $ \forall x\in X.\  (F\langle  s,i\rangle )(x) = E(x)$ ''using''  +++^[group0_2_T2 | Group_ZF ]...  ''theorem''  <nowiki>group0_2_T2</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,f)$  '' shows '' $ GroupInv(G,f) : G\rightarrow G$ ===  ,  <nowiki>comp_fun</nowiki> ,  +++^[Group_ZF_2_1_L3 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L3</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  ''and'' $ s:X\rightarrow G$,   $ r:X\rightarrow G$  ''and'' $ x\in X$  '' shows '' $ (F\langle s,r\rangle )(x) = s(x)\cdot r(x)$ ===  ,  <nowiki>comp_fun_apply</nowiki> ,  <nowiki>apply_funtype</nowiki> ,  +++^[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 $ ===  ,  +++^[func1_3_L2 | func1 ]...  ''lemma''  <nowiki>func1_3_L2</nowiki>:  ''assumes '' $ x\in X$  '' shows '' $ ConstantFunction(X,c)(x) = c$ === 
 ''moreover''   ''from '' groupAssum, A1  ''have''  $ E = TheNeutralElement(X\rightarrow G,F)$ ''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)))$===  ,  +++^[Group_ZF_2_1_L2 | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_1_L2</nowiki>:  ''assumes '' $ \text{IsAmonoid}(G,f)$  ''and'' $ F = f \text{ lifted to function space over } X$  ''and'' $ E = ConstantFunction(X,TheNeutralElement(G,f))$  '' shows '' $ E = TheNeutralElement(X\rightarrow G,F)$ === 
 ''ultimately ''  ''show''  $ F\langle  s,i\rangle  = TheNeutralElement(X\rightarrow G,F)$ ''using''  <nowiki>fun_extension_iff</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)))$===  ,  +++^[Group_ZF_2_1_L2 | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_1_L2</nowiki>:  ''assumes '' $ \text{IsAmonoid}(G,f)$  ''and'' $ F = f \text{ lifted to function space over } X$  ''and'' $ E = ConstantFunction(X,TheNeutralElement(G,f))$  '' shows '' $ E = TheNeutralElement(X\rightarrow G,F)$ === 
 ''from '' groupAssum, A2, A3  ''show''  $ i: X\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$ ===  ,  <nowiki>comp_fun</nowiki>
 ''qed'' === 

Groups can be lifted to the function space.

 ''theorem''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_T2</nowiki>:
 ''   assumes '' A1: $ F = P \text{ lifted to function space over } X$ ''   shows '' $ \text{IsAgroup}(X\rightarrow G,F)$+++[proof ]>
 ''from '' A1  ''have''  $ \text{IsAmonoid}(X\rightarrow G,F)$ ''using''  +++^[group0_2_L1 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L1</nowiki>:  '' shows '' $ monoid0(G,P)$ ===  ,  +++^[Group_ZF_2_1_T1 | Group_ZF_2 ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_1_T1</nowiki>:  ''assumes '' $ F = f \text{ lifted to function space over } X$  '' shows '' $ \text{IsAmonoid}(X\rightarrow G,F)$ === 
 ''moreover''   ''have''  $ \forall s\in X\rightarrow G.\  \exists i\in X\rightarrow G.\  F\langle  s,i\rangle  = TheNeutralElement(X\rightarrow G,F)$+++[proof ]>
 ''fix '' $ s$
 ''assume '' A2: $ s : X\rightarrow G$
 ''let '' $ i = GroupInv(G,P)\circ s$
 ''from '' groupAssum, A2  ''have''  $ i:X\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$ ===  ,  <nowiki>comp_fun</nowiki>
 ''moreover''   ''from '' A1, A2  ''have''  $ F\langle  s,i\rangle  = TheNeutralElement(X\rightarrow G,F)$ ''using''  +++^[Group_ZF_2_1_L5 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L5</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  ''and'' $ s : X\rightarrow G$  ''and'' $ i = GroupInv(G,P)\circ s$  '' shows '' $ i: X\rightarrow G$  ''and'' $ F\langle  s,i\rangle  = TheNeutralElement(X\rightarrow G,F)$ === 
 ''ultimately ''  ''show''  $ \exists i\in X\rightarrow G.\  F\langle  s,i\rangle  = TheNeutralElement(X\rightarrow G,F)$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ ''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)))$=== 
 ''qed'' === 

What is the group inverse for the lifted group?

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L6</nowiki>:
 ''   assumes '' A1: $ F = P \text{ lifted to function space over } X$ ''   shows '' $ \forall s\in (X\rightarrow G).\  GroupInv(X\rightarrow G,F)(s) = GroupInv(G,P)\circ s$+++[proof ]>
 ''from '' A1  ''have''  $ group0(X\rightarrow G,F)$ ''using''  <nowiki>group0_def</nowiki> ,  +++^[Group_ZF_2_1_T2 | Group_ZF_2 ]...  ''theorem''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_T2</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  '' shows '' $ \text{IsAgroup}(X\rightarrow G,F)$ === 
 ''moreover''   ''from '' A1  ''have''  $ \forall s\in X\rightarrow G.\  GroupInv(G,P)\circ s : X\rightarrow G \wedge  $
$    F\langle  s,GroupInv(G,P)\circ s\rangle  = TheNeutralElement(X\rightarrow G,F)$ ''using''  +++^[Group_ZF_2_1_L5 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L5</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  ''and'' $ s : X\rightarrow G$  ''and'' $ i = GroupInv(G,P)\circ s$  '' shows '' $ i: X\rightarrow G$  ''and'' $ F\langle  s,i\rangle  = TheNeutralElement(X\rightarrow G,F)$ === 
 ''ultimately ''  ''have''  $ \forall s\in (X\rightarrow G).\   GroupInv(G,P)\circ s = GroupInv(X\rightarrow G,F)(s)$ ''   by (rule '' +++^[group0_2_L9A | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L9A</nowiki>:  ''assumes '' $ \forall g\in G.\  b(g) \in  G \wedge  g\cdot b(g) = 1 $  '' shows '' $ \forall g\in G.\  b(g) = g^{-1}$ ===  '')'' 
 ''thus''  $ thesis$
 ''qed'' === 

What is the value of the group inverse for the lifted group?

 ''corollary''  ''(in'' group0'')'' <nowiki>lift_gr_inv_val</nowiki>:
 ''   assumes '' $ F = P \text{ lifted to function space over } X$ ''and '' $ s : X\rightarrow G$ ''and '' $ x\in X$ ''   shows '' $ (GroupInv(X\rightarrow G,F)(s))(x) = (s(x))^{-1}$ ''using''  <nowiki>groupAssum</nowiki> ,  <nowiki>assms</nowiki> ,  +++^[Group_ZF_2_1_L6 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L6</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  '' shows '' $ \forall s\in (X\rightarrow G).\  GroupInv(X\rightarrow G,F)(s) = GroupInv(G,P)\circ s$ ===  ,  +++^[group0_2_T2 | Group_ZF ]...  ''theorem''  <nowiki>group0_2_T2</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,f)$  '' shows '' $ GroupInv(G,f) : G\rightarrow G$ ===  ,  <nowiki>comp_fun_apply</nowiki>

What is the group inverse in a subgroup of the lifted group?

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L6A</nowiki>:
 ''   assumes '' A1: $ F = P \text{ lifted to function space over } X$ ''and '' A2: $ IsAsubgroup(H,F)$ ''and '' A3: $ g = restrict(F,H\times H)$ ''and '' A4: $ s\in H$ ''   shows '' $ GroupInv(H,g)(s) = GroupInv(G,P)\circ s$+++[proof ]>
 ''from '' A1  ''have''  T1: $ group0(X\rightarrow G,F)$ ''using''  <nowiki>group0_def</nowiki> ,  +++^[Group_ZF_2_1_T2 | Group_ZF_2 ]...  ''theorem''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_T2</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  '' shows '' $ \text{IsAgroup}(X\rightarrow G,F)$ === 
 ''with '' A2, A3, A4  ''have''  $ GroupInv(H,g)(s) = GroupInv(X\rightarrow G,F)(s)$ ''using''  +++^[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</nowiki>
 ''moreover''   ''from '' T1, A1, A2, A4  ''have''  $ GroupInv(X\rightarrow G,F)(s) = GroupInv(G,P)\circ s$ ''using''  +++^[group0_3_L2 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_3_L2</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ H \subseteq  G$ ===  ,  +++^[Group_ZF_2_1_L6 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L6</nowiki>:  ''assumes '' $ F = P \text{ lifted to function space over } X$  '' shows '' $ \forall s\in (X\rightarrow G).\  GroupInv(X\rightarrow G,F)(s) = GroupInv(G,P)\circ s$ === 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

If a group is abelian, then its lift to a function space is also abelian.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_1_L7</nowiki>:
 ''   assumes '' A1: $ F = P \text{ lifted to function space over } X$ ''and '' A2: $ P \text{ is commutative on } G$ ''   shows '' $ F \text{ is commutative on } (X\rightarrow G)$+++[proof ]>
 ''from '' A1, A2  ''have''  $ F \text{ is commutative on } (X\rightarrow range(P))$ ''using''  +++^[group_oper_assocA | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group_oper_assocA</nowiki>:  '' shows '' $ P : G\times G\rightarrow G$ ===  ,  +++^[func_ZF_2_L2 | func_ZF ]...  ''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))$ === 
 ''moreover''   ''from '' groupAssum  ''have''  $ range(P) = G$ ''using''  +++^[group0_2_L1 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L1</nowiki>:  '' shows '' $ monoid0(G,P)$ ===  ,  +++^[group0_1_L3B | Monoid_ZF ]...  ''lemma''  ''(in'' monoid0'')'' <nowiki>group0_1_L3B</nowiki>:  '' shows '' $ range(f) = G$ === 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 


!Equivalence relations on groups

The goal of this section is to establish that (under some conditions) given an equivalence relation on a group or (monoid )we can project the group (monoid) structure on the quotient and obtain another group.

The neutral element class is neutral in the projection.

 ''lemma''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_2_L1</nowiki>:
 ''   assumes '' A1: $ equiv(G,r)$ ''and '' A2: $ Congruent2(r,f)$ ''and '' A3: $ F = ProjFun2(G,r,f)$ ''and '' A4: $ e = TheNeutralElement(G,f)$ ''   shows '' $ r\{e\} \in  G//r \wedge  $
$  (\forall c \in  G//r.\  F\langle  r\{e\},c\rangle  = c \wedge   F\langle  c,r\{e\}\rangle  = c)$+++[proof ]>
 ''from '' A4  ''show''  T1: $ r\{e\} \in  G//r$ ''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)$ ===  ,  <nowiki>quotientI</nowiki>
 ''show''  $ \forall c \in  G//r.\  F\langle  r\{e\},c\rangle  = c \wedge   F\langle  c,r\{e\}\rangle  = c$+++[proof ]>
 ''fix '' $ c$
 ''assume '' A5: $ c \in  G//r$
 ''then ''  ''obtain '' $ g$ ''where '' D1: $ g\in G$,  $ c = r\{g\}$ ''using''  <nowiki>quotient_def</nowiki>
 ''with '' A1, A2, A3, A4, D1  ''show''  $ F\langle  r\{e\},c\rangle  = c \wedge   F\langle  c,r\{e\}\rangle  = c$ ''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)$ ===  ,  +++^[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 \}$ === 
 ''qed'' === 
 ''qed'' === 

The projected structure is a monoid.

 ''theorem''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_2_T1</nowiki>:
 ''   assumes '' A1: $ equiv(G,r)$ ''and '' A2: $ Congruent2(r,f)$ ''and '' A3: $ F = ProjFun2(G,r,f)$ ''   shows '' $ \text{IsAmonoid}(G//r,F)$+++[proof ]>
 ''let '' $ E = r\{TheNeutralElement(G,f)\}$
 ''from '' A1, A2, A3  ''have''  $ E \in  G//r \wedge  (\forall c\in G//r.\  F\langle  E,c\rangle  = c \wedge  F\langle  c,E\rangle  = c)$ ''using''  +++^[Group_ZF_2_2_L1 | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_2_L1</nowiki>:  ''assumes '' $ \text{IsAmonoid}(G,f)$  ''and'' $ equiv(G,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ F = ProjFun2(G,r,f)$  ''and'' $ e = TheNeutralElement(G,f)$  '' shows '' $  r\{e\} = TheNeutralElement(G//r,F)$ === 
 ''hence''  $ \exists E\in G//r.\  \forall  c\in G//r.\  F\langle  E,c\rangle  = c \wedge  F\langle  c,E\rangle  = c$
 ''with '' monoidAsssum, A1, A2, A3  ''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))))$===  ,  +++^[EquivClass_2_T2 | EquivClass1 ]...  ''theorem''  <nowiki>EquivClass_2_T2</nowiki>:  ''assumes '' $ equiv(A,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ f \text{ is associative on } A$  '' shows '' $ ProjFun2(A,r,f) \text{ is associative on } A//r$ === 
 ''qed'' === 

The class of the neutral element is the neutral element of the projected monoid.

 ''lemma''  <nowiki>Group_ZF_2_2_L1</nowiki>:
 ''   assumes '' A1: $ \text{IsAmonoid}(G,f)$ ''and '' A2: $ equiv(G,r)$ ''and '' A3: $ Congruent2(r,f)$ ''and '' A4: $ F = ProjFun2(G,r,f)$ ''and '' A5: $ e = TheNeutralElement(G,f)$ ''   shows '' $  r\{e\} = TheNeutralElement(G//r,F)$+++[proof ]>
 ''from '' A1, A2, A3, A4  ''have''  T1: $ monoid0(G,f)$ ''and '' T2: $ monoid0(G//r,F)$ ''using''  <nowiki>monoid0_def</nowiki> ,  +++^[Group_ZF_2_2_T1 | Group_ZF_2 ]...  ''theorem''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_2_T1</nowiki>:  ''assumes '' $ equiv(G,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ F = ProjFun2(G,r,f)$  '' shows '' $ \text{IsAmonoid}(G//r,F)$ === 
 ''from '' T1, A2, A3, A4, A5  ''have''  $ r\{e\} \in  G//r \wedge  $
$    (\forall c \in  G//r.\  F\langle  r\{e\},c\rangle  = c \wedge   F\langle  c,r\{e\}\rangle  = c)$ ''using''  +++^[Group_ZF_2_2_L1 | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_2_L1</nowiki>:  ''assumes '' $ \text{IsAmonoid}(G,f)$  ''and'' $ equiv(G,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ F = ProjFun2(G,r,f)$  ''and'' $ e = TheNeutralElement(G,f)$  '' shows '' $  r\{e\} = TheNeutralElement(G//r,F)$ === 
 ''with '' T2  ''show''  $ thesis$ ''using''  +++^[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)$ === 
 ''qed'' === 

The projected operation can be defined in terms of the group operation on representants in a natural way.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_2_L2</nowiki>:
 ''   assumes '' A1: $ equiv(G,r)$ ''and '' A2: $ Congruent2(r,P)$ ''and '' A3: $ F = ProjFun2(G,r,P)$ ''and '' A4: $ a\in G$,  $ b\in G$ ''   shows '' $ F\langle  r\{a\},r\{b\}\rangle  = r\{a\cdot b\}$+++[proof ]>
 ''from '' A1, A2, A3, A4  ''show''  $ thesis$ ''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 \}$ === 
 ''qed'' === 

The class of the inverse is a right inverse of the class.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_2_L3</nowiki>:
 ''   assumes '' A1: $ equiv(G,r)$ ''and '' A2: $ Congruent2(r,P)$ ''and '' A3: $ F = ProjFun2(G,r,P)$ ''and '' A4: $ a\in G$ ''   shows '' $ F\langle r\{a\},r\{a^{-1}\}\rangle  = TheNeutralElement(G//r,F)$+++[proof ]>
 ''from '' A1, A2, A3, A4  ''have''  $ F\langle r\{a\},r\{a^{-1}\}\rangle  = r\{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_ZF_2_2_L2 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_2_L2</nowiki>:  ''assumes '' $ equiv(G,r)$  ''and'' $ Congruent2(r,P)$  ''and'' $ F = ProjFun2(G,r,P)$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ F\langle  r\{a\},r\{b\}\rangle  = r\{a\cdot b\}$ ===  ,  +++^[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 '' groupAssum, A1, A2, A3  ''show''  $ thesis$ ''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)))$===  ,  +++^[Group_ZF_2_2_L1 | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_2_L1</nowiki>:  ''assumes '' $ \text{IsAmonoid}(G,f)$  ''and'' $ equiv(G,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ F = ProjFun2(G,r,f)$  ''and'' $ e = TheNeutralElement(G,f)$  '' shows '' $  r\{e\} = TheNeutralElement(G//r,F)$ === 
 ''qed'' === 

The group structure can be projected to the quotient space.

 ''theorem''  ''(in'' group0'')'' <nowiki>Group_ZF_3_T2</nowiki>:
 ''   assumes '' A1: $ equiv(G,r)$ ''and '' A2: $ Congruent2(r,P)$ ''   shows '' $ \text{IsAgroup}(G//r,ProjFun2(G,r,P))$+++[proof ]>
 ''let '' $ F = ProjFun2(G,r,P)$
 ''let '' $ E = TheNeutralElement(G//r,F)$
 ''from '' groupAssum, A1, A2  ''have''  $ \text{IsAmonoid}(G//r,F)$ ''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)))$===  ,  <nowiki>monoid0_def</nowiki> ,  +++^[Group_ZF_2_2_T1 | Group_ZF_2 ]...  ''theorem''  ''(in'' monoid0'')'' <nowiki>Group_ZF_2_2_T1</nowiki>:  ''assumes '' $ equiv(G,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ F = ProjFun2(G,r,f)$  '' shows '' $ \text{IsAmonoid}(G//r,F)$ === 
 ''moreover''   ''have''  $ \forall c\in G//r.\  \exists b\in G//r.\  F\langle  c,b\rangle  = E$+++[proof ]>
 ''fix '' $ c$
 ''assume '' A3: $ c \in  G//r$
 ''then ''  ''obtain '' $ g$ ''where '' D1: $ g\in G$,  $ c = r\{g\}$ ''using''  <nowiki>quotient_def</nowiki>
 ''let '' $ b = r\{g^{-1}\}$
 ''from '' D1  ''have''  $ b \in  G//r$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  <nowiki>quotientI</nowiki>
 ''moreover''   ''from '' A1, A2, D1  ''have''  $ F\langle  c,b\rangle  = E$ ''using''  +++^[Group_ZF_2_2_L3 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_2_L3</nowiki>:  ''assumes '' $ equiv(G,r)$  ''and'' $ Congruent2(r,P)$  ''and'' $ F = ProjFun2(G,r,P)$  ''and'' $ a\in G$  '' shows '' $ F\langle r\{a\},r\{a^{-1}\}\rangle  = TheNeutralElement(G//r,F)$ === 
 ''ultimately ''  ''show''  $ \exists b\in G//r.\  F\langle  c,b\rangle  = E$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ ''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)))$=== 
 ''qed'' === 

The group inverse (in the projected group) of a class is the class of the inverse.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_2_L4</nowiki>:
 ''   assumes '' A1: $ equiv(G,r)$ ''and '' A2: $ Congruent2(r,P)$ ''and '' A3: $ F = ProjFun2(G,r,P)$ ''and '' A4: $ a\in G$ ''   shows '' $ r\{a^{-1}\} = GroupInv(G//r,F)(r\{a\})$+++[proof ]>
 ''from '' A1, A2, A3  ''have''  $ group0(G//r,F)$ ''using''  +++^[Group_ZF_3_T2 | Group_ZF_2 ]...  ''theorem''  ''(in'' group0'')'' <nowiki>Group_ZF_3_T2</nowiki>:  ''assumes '' $ equiv(G,r)$  ''and'' $ Congruent2(r,P)$  '' shows '' $ \text{IsAgroup}(G//r,ProjFun2(G,r,P))$ ===  ,  <nowiki>group0_def</nowiki>
 ''moreover''   ''from '' A4  ''have''  $ r\{a\} \in  G//r$,  $ r\{a^{-1}\} \in  G//r$ ''using''  +++^[inverse_in_group | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ ===  ,  <nowiki>quotientI</nowiki>
 ''moreover''   ''from '' A1, A2, A3, A4  ''have''  $ F\langle r\{a\},r\{a^{-1}\}\rangle  = TheNeutralElement(G//r,F)$ ''using''  +++^[Group_ZF_2_2_L3 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_2_L3</nowiki>:  ''assumes '' $ equiv(G,r)$  ''and'' $ Congruent2(r,P)$  ''and'' $ F = ProjFun2(G,r,P)$  ''and'' $ a\in G$  '' shows '' $ F\langle r\{a\},r\{a^{-1}\}\rangle  = TheNeutralElement(G//r,F)$ === 
 ''ultimately ''  ''show''  $ thesis$ ''   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'' === 


!Normal subgroups and quotient groups

If $H$ is a subgroup of $G$, then for every $a\in G$ we can cosider the sets $\{a\cdot h. h \in H\}$ and $\{ h\cdot a. h \in H\}$ (called a left and right ''coset of H'', resp.) These sets sometimes form a group, called the ''quotient group''. This section discusses the notion of quotient groups.

A normal subgorup $N$ of a group $G$ is such that $aba^{-1}$ belongs to $N$ if $a\in G, b\in N$.

 ''Definition
'' $ IsAnormalSubgroup(G,P,N) \equiv  IsAsubgroup(N,P) \wedge  $
$  (\forall n\in N.\ \forall g\in G.\  P\langle   P\langle   g,n \rangle ,GroupInv(G,P)(g) \rangle  \in  N)$

Having a group and a normal subgroup $N$ we can create another group consisting of eqivalence classes of the relation $a\sim b \equiv a\cdot b^{-1} \in N$. We will refer to this relation as the quotient group relation. The classes of this relation are in fact cosets of subgroup $H$.

 ''Definition
'' $ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$

Next we define the operation in the quotient group as the projection of the group operation on the classses of the quotient group relation.

 ''Definition
'' $ QuotientGroupOp(G,P,H) \equiv  ProjFun2(G,QuotientGroupRel(G,P,H ),P)$

Definition of a normal subgroup in a more readable notation.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L0</nowiki>:
 ''   assumes '' $ IsAnormalSubgroup(G,P,H)$ ''and '' $ g\in G$,  $ n\in H$ ''   shows '' $ g\cdot n\cdot g^{-1} \in  H$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsAnormalSubgroup_def | Group_ZF_2 ]... Definition of <nowiki>IsAnormalSubgroup</nowiki>:
$ IsAnormalSubgroup(G,P,N) \equiv  IsAsubgroup(N,P) \wedge  $
$  (\forall n\in N.\ \forall g\in G.\  P\langle   P\langle   g,n \rangle ,GroupInv(G,P)(g) \rangle  \in  N)$=== 

The quotient group relation is reflexive.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L1</nowiki>:
 ''   assumes '' $ IsAsubgroup(H,P)$ ''   shows '' $ refl(G,QuotientGroupRel(G,P,H))$ ''using''  <nowiki>assms</nowiki> ,  +++^[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_3_L5 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_3_L5</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ 1 \in H$ ===  ,  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$===  ,  <nowiki>refl_def</nowiki>

The quotient group relation is symmetric.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L2</nowiki>:
 ''   assumes '' A1: $ IsAsubgroup(H,P)$ ''   shows '' $ sym(QuotientGroupRel(G,P,H))$+++[proof ]>
++++[{ ]>
 ''fix '' $ a$ $ b$
 ''assume '' A2: $ \langle  a,b\rangle  \in  QuotientGroupRel(G,P,H)$
 ''with '' A1  ''have''  $ (a\cdot b^{-1})^{-1} \in  H$ ''using''  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$===  ,  +++^[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$ === 
 ''moreover''   ''from '' A2  ''have''  $ (a\cdot b^{-1})^{-1} =  b\cdot a^{-1}$ ''using''  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$===  ,  +++^[group0_2_L12 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L12</nowiki>:  ''assumes '' $ 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$ === 
 ''ultimately ''  ''have''  $ b\cdot a^{-1} \in  H$ 
 ''with '' A2  ''have''  $ \langle  b,a\rangle  \in  QuotientGroupRel(G,P,H)$ ''using''  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$=== 
===  ''}'' 
 ''then ''  ''show''  $ thesis$ ''using''  <nowiki>symI</nowiki>
 ''qed'' === 

The quotient group relation is transistive.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L3A</nowiki>:
 ''   assumes '' A1: $ IsAsubgroup(H,P)$ ''and '' A2: $ \langle  a,b\rangle  \in  QuotientGroupRel(G,P,H)$ ''and '' A3: $ \langle  b,c\rangle  \in  QuotientGroupRel(G,P,H)$ ''   shows '' $ \langle  a,c\rangle  \in  QuotientGroupRel(G,P,H)$+++[proof ]>
 ''let '' $ r = QuotientGroupRel(G,P,H)$
 ''from '' A2, A3  ''have''  T1: $ a\in G$,  $ b\in G$,  $ c\in G$ ''using''  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$=== 
 ''from '' A1, A2, A3  ''have''  $ (a\cdot b^{-1})\cdot (b\cdot c^{-1}) \in  H$ ''using''  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$===  ,  +++^[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$ === 
 ''moreover''   ''from '' T1  ''have''  $ a\cdot c^{-1} = (a\cdot b^{-1})\cdot (b\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$ === 
 ''ultimately ''  ''have''  $ a\cdot c^{-1} \in  H$ 
 ''with '' T1  ''show''  $ thesis$ ''using''  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$=== 
 ''qed'' === 

The quotient group relation is an equivalence relation. Note we do not need the subgroup to be normal for this to be true.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L3</nowiki>:
 ''   assumes '' A1: $ IsAsubgroup(H,P)$ ''   shows '' $ equiv(G,QuotientGroupRel(G,P,H))$+++[proof ]>
 ''let '' $ r = QuotientGroupRel(G,P,H)$
 ''from '' A1  ''have''  $ \forall a b c.\  (\langle a, b\rangle  \in  r  \wedge   \langle b, c\rangle  \in  r \longrightarrow  \langle a, c\rangle  \in  r)$ ''using''  +++^[Group_ZF_2_4_L3A | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L3A</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  ''and'' $ \langle  a,b\rangle  \in  QuotientGroupRel(G,P,H)$  ''and'' $ \langle  b,c\rangle  \in  QuotientGroupRel(G,P,H)$  '' shows '' $ \langle  a,c\rangle  \in  QuotientGroupRel(G,P,H)$ === 
 ''then ''  ''have''  $ trans(r)$ ''using''  +++^[Fol1_L2 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L2</nowiki>:  ''assumes '' $ \forall  x y z.\  \langle x, y\rangle  \in  r \wedge  \langle y, z\rangle  \in  r \longrightarrow  \langle x, z\rangle  \in  r$
 '' shows '' $ trans(r)$ === 
 ''with '' A1  ''show''  $ thesis$ ''using''  +++^[Group_ZF_2_4_L1 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L1</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ refl(G,QuotientGroupRel(G,P,H))$ ===  ,  +++^[Group_ZF_2_4_L2 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L2</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ sym(QuotientGroupRel(G,P,H))$ ===  ,  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$===  ,  <nowiki>equiv_def</nowiki>
 ''qed'' === 

The next lemma states the essential condition for congruency of the group operation with respect to the quotient group relation.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L4</nowiki>:
 ''   assumes '' A1: $ IsAnormalSubgroup(G,P,H)$ ''and '' A2: $ \langle a1,a2\rangle  \in  QuotientGroupRel(G,P,H)$ ''and '' A3: $ \langle b1,b2\rangle  \in  QuotientGroupRel(G,P,H)$ ''   shows '' $ \langle a1\cdot b1, a2\cdot b2\rangle  \in  QuotientGroupRel(G,P,H)$+++[proof ]>
 ''from '' A2, A3  ''have''  T1: $ a1\in G$,  $ a2\in G$,  $ b1\in G$,  $ b2\in G$,  $ a1\cdot b1 \in  G$,  $ a2\cdot b2 \in  G$,  $ b1\cdot b2^{-1} \in  H$,  $ a1\cdot a2^{-1} \in  H$ ''using''  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$===  ,  +++^[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$ === 
 ''with '' A1  ''show''  $ thesis$ ''using''  +++^[IsAnormalSubgroup_def | Group_ZF_2 ]... Definition of <nowiki>IsAnormalSubgroup</nowiki>:
$ IsAnormalSubgroup(G,P,N) \equiv  IsAsubgroup(N,P) \wedge  $
$  (\forall n\in N.\ \forall g\in G.\  P\langle   P\langle   g,n \rangle ,GroupInv(G,P)(g) \rangle  \in  N)$===  ,  +++^[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$ ===  ,  +++^[group0_2_L15 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L15</nowiki>:  ''assumes '' $ 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})$ ===  ,  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$=== 
 ''qed'' === 

If the subgroup is normal, the group operation is congruent with respect to the quotient group relation.

 ''lemma''  <nowiki>Group_ZF_2_4_L5A</nowiki>:
 ''   assumes '' $ \text{IsAgroup}(G,P)$ ''and '' $ IsAnormalSubgroup(G,P,H)$ ''   shows '' $ Congruent2(QuotientGroupRel(G,P,H),P)$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>group0_def</nowiki> ,  +++^[Group_ZF_2_4_L4 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L4</nowiki>:  ''assumes '' $ IsAnormalSubgroup(G,P,H)$  ''and'' $ \langle a1,a2\rangle  \in  QuotientGroupRel(G,P,H)$  ''and'' $ \langle b1,b2\rangle  \in  QuotientGroupRel(G,P,H)$  '' shows '' $ \langle a1\cdot b1, a2\cdot b2\rangle  \in  QuotientGroupRel(G,P,H)$ ===  ,  +++^[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)$=== 

The quotient group is indeed a group.

 ''theorem''  <nowiki>Group_ZF_2_4_T1</nowiki>:
 ''   assumes '' $ \text{IsAgroup}(G,P)$ ''and '' $ IsAnormalSubgroup(G,P,H)$ ''   shows '' $ \text{IsAgroup}(G//QuotientGroupRel(G,P,H),QuotientGroupOp(G,P,H))$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>group0_def</nowiki> ,  +++^[Group_ZF_2_4_L3 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L3</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ equiv(G,QuotientGroupRel(G,P,H))$ ===  ,  +++^[IsAnormalSubgroup_def | Group_ZF_2 ]... Definition of <nowiki>IsAnormalSubgroup</nowiki>:
$ IsAnormalSubgroup(G,P,N) \equiv  IsAsubgroup(N,P) \wedge  $
$  (\forall n\in N.\ \forall g\in G.\  P\langle   P\langle   g,n \rangle ,GroupInv(G,P)(g) \rangle  \in  N)$===  ,  +++^[Group_ZF_2_4_L5A | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_4_L5A</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,P)$  ''and'' $ IsAnormalSubgroup(G,P,H)$  '' shows '' $ Congruent2(QuotientGroupRel(G,P,H),P)$ ===  ,  +++^[Group_ZF_3_T2 | Group_ZF_2 ]...  ''theorem''  ''(in'' group0'')'' <nowiki>Group_ZF_3_T2</nowiki>:  ''assumes '' $ equiv(G,r)$  ''and'' $ Congruent2(r,P)$  '' shows '' $ \text{IsAgroup}(G//r,ProjFun2(G,r,P))$ ===  ,  +++^[QuotientGroupOp_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupOp</nowiki>:
$ QuotientGroupOp(G,P,H) \equiv  ProjFun2(G,QuotientGroupRel(G,P,H ),P)$=== 

The class (coset) of the neutral element is the neutral element of the quotient group.

 ''lemma''  <nowiki>Group_ZF_2_4_L5B</nowiki>:
 ''   assumes '' $ \text{IsAgroup}(G,P)$ ''and '' $ IsAnormalSubgroup(G,P,H)$ ''and '' $ r = QuotientGroupRel(G,P,H)$ ''and '' $ e = TheNeutralElement(G,P)$ ''   shows '' $  r\{e\} = TheNeutralElement(G//r,QuotientGroupOp(G,P,H))$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsAnormalSubgroup_def | Group_ZF_2 ]... Definition of <nowiki>IsAnormalSubgroup</nowiki>:
$ IsAnormalSubgroup(G,P,N) \equiv  IsAsubgroup(N,P) \wedge  $
$  (\forall n\in N.\ \forall g\in G.\  P\langle   P\langle   g,n \rangle ,GroupInv(G,P)(g) \rangle  \in  N)$===  ,  <nowiki>group0_def</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)))$===  ,  +++^[Group_ZF_2_4_L3 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L3</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ equiv(G,QuotientGroupRel(G,P,H))$ ===  ,  +++^[Group_ZF_2_4_L5A | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_4_L5A</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,P)$  ''and'' $ IsAnormalSubgroup(G,P,H)$  '' shows '' $ Congruent2(QuotientGroupRel(G,P,H),P)$ ===  ,  +++^[QuotientGroupOp_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupOp</nowiki>:
$ QuotientGroupOp(G,P,H) \equiv  ProjFun2(G,QuotientGroupRel(G,P,H ),P)$===  ,  +++^[Group_ZF_2_2_L1 | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_2_L1</nowiki>:  ''assumes '' $ \text{IsAmonoid}(G,f)$  ''and'' $ equiv(G,r)$  ''and'' $ Congruent2(r,f)$  ''and'' $ F = ProjFun2(G,r,f)$  ''and'' $ e = TheNeutralElement(G,f)$  '' shows '' $  r\{e\} = TheNeutralElement(G//r,F)$ === 

A group element is equivalent to the neutral element iff it is in the subgroup we divide the group by.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L5C</nowiki>:
 ''   assumes '' $ a\in G$ ''   shows '' $ \langle a,1 \rangle  \in  QuotientGroupRel(G,P,H) \longleftrightarrow  a\in H$ ''using''  <nowiki>assms</nowiki> ,  +++^[QuotientGroupRel_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupRel</nowiki>:
$ QuotientGroupRel(G,P,H) \equiv  $
$  \{\langle  a,b\rangle  \in  G\times G.\  P\langle  a, GroupInv(G,P)(b)\rangle  \in  H\}$===  ,  +++^[group_inv_of_one | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group_inv_of_one</nowiki>:  '' shows '' $ 1 ^{-1} = 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))$ === 

A group element is in $H$ iff its class is the neutral element of $G/H$.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L5D</nowiki>:
 ''   assumes '' A1: $ IsAnormalSubgroup(G,P,H)$ ''and '' A2: $ a\in G$ ''and '' A3: $ r = QuotientGroupRel(G,P,H)$ ''and '' A4: $ TheNeutralElement(G//r,QuotientGroupOp(G,P,H)) = e$ ''   shows '' $ r\{a\} = e \longleftrightarrow  \langle a,1 \rangle  \in  r$+++[proof ]>
 ''assume '' $ r\{a\} = e$
 ''with '' groupAssum, assms  ''have''  $ r\{1 \} = r\{a\}$ ''and '' I: $ equiv(G,r)$ ''using''  +++^[Group_ZF_2_4_L5B | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_4_L5B</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,P)$  ''and'' $ IsAnormalSubgroup(G,P,H)$  ''and'' $ r = QuotientGroupRel(G,P,H)$  ''and'' $ e = TheNeutralElement(G,P)$  '' shows '' $  r\{e\} = TheNeutralElement(G//r,QuotientGroupOp(G,P,H))$ ===  ,  +++^[IsAnormalSubgroup_def | Group_ZF_2 ]... Definition of <nowiki>IsAnormalSubgroup</nowiki>:
$ IsAnormalSubgroup(G,P,N) \equiv  IsAsubgroup(N,P) \wedge  $
$  (\forall n\in N.\ \forall g\in G.\  P\langle   P\langle   g,n \rangle ,GroupInv(G,P)(g) \rangle  \in  N)$===  ,  +++^[Group_ZF_2_4_L3 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L3</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ equiv(G,QuotientGroupRel(G,P,H))$ === 
 ''with '' A2  ''have''  $ \langle 1 ,a\rangle  \in  r$ ''using''  <nowiki>eq_equiv_class</nowiki>
 ''with '' I  ''show''  $ \langle a,1 \rangle  \in  r$ ''   by (rule '' +++^[equiv_is_sym | Fol1 ]...  ''lemma''  <nowiki>equiv_is_sym</nowiki>:  ''assumes '' $ equiv(X,r)$  ''and'' $ \langle x,y\rangle  \in  r$  '' shows '' $ \langle y,x\rangle  \in  r$ ===  '')'' 
 ''next '' 
 ''assume '' $ \langle a,1 \rangle  \in  r$
 ''moreover''   ''from '' A1, A3  ''have''  $ equiv(G,r)$ ''using''  +++^[IsAnormalSubgroup_def | Group_ZF_2 ]... Definition of <nowiki>IsAnormalSubgroup</nowiki>:
$ IsAnormalSubgroup(G,P,N) \equiv  IsAsubgroup(N,P) \wedge  $
$  (\forall n\in N.\ \forall g\in G.\  P\langle   P\langle   g,n \rangle ,GroupInv(G,P)(g) \rangle  \in  N)$===  ,  +++^[Group_ZF_2_4_L3 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L3</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ equiv(G,QuotientGroupRel(G,P,H))$ === 
 ''ultimately ''  ''have''  $ r\{a\} = r\{1 \}$ ''using''  <nowiki>equiv_class_eq</nowiki>
 ''with '' groupAssum, A1, A3, A4  ''show''  $ r\{a\} = e$ ''using''  +++^[Group_ZF_2_4_L5B | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_4_L5B</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,P)$  ''and'' $ IsAnormalSubgroup(G,P,H)$  ''and'' $ r = QuotientGroupRel(G,P,H)$  ''and'' $ e = TheNeutralElement(G,P)$  '' shows '' $  r\{e\} = TheNeutralElement(G//r,QuotientGroupOp(G,P,H))$ === 
 ''qed'' === 

The class of $a\in G$ is the neutral element of the quotient $G/H$ iff $a\in H$.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L5E</nowiki>:
 ''   assumes '' $ IsAnormalSubgroup(G,P,H)$ ''and '' $ a\in G$ ''and '' $ r = QuotientGroupRel(G,P,H)$ ''and '' $ TheNeutralElement(G//r,QuotientGroupOp(G,P,H)) = e$ ''   shows '' $ r\{a\} = e \longleftrightarrow  a\in H$ ''using''  <nowiki>assms</nowiki> ,  +++^[Group_ZF_2_4_L5C | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L5C</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ \langle a,1 \rangle  \in  QuotientGroupRel(G,P,H) \longleftrightarrow  a\in H$ ===  ,  +++^[Group_ZF_2_4_L5D | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L5D</nowiki>:  ''assumes '' $ IsAnormalSubgroup(G,P,H)$  ''and'' $ a\in G$  ''and'' $ r = QuotientGroupRel(G,P,H)$  ''and'' $ TheNeutralElement(G//r,QuotientGroupOp(G,P,H)) = e$  '' shows '' $ r\{a\} = e \longleftrightarrow  \langle a,1 \rangle  \in  r$ === 

Essential condition to show that every subgroup of an abelian group is normal.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L5</nowiki>:
 ''   assumes '' A1: $ P \text{ is commutative on } G$ ''and '' A2: $ IsAsubgroup(H,P)$ ''and '' A3: $ g\in G$,  $ h\in H$ ''   shows '' $ g\cdot h\cdot g^{-1} \in  H$+++[proof ]>
 ''from '' A2, A3  ''have''  T1: $ h\in G$,  $ g^{-1} \in  G$ ''using''  +++^[group0_3_L2 | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_3_L2</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ H \subseteq  G$ ===  ,  +++^[inverse_in_group | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>inverse_in_group</nowiki>:  ''assumes '' $ x\in G$  '' shows '' $ x^{-1}\in G$ === 
 ''with '' A3, A1  ''have''  $ g\cdot h\cdot g^{-1} = g^{-1}\cdot g\cdot h$ ''using''  +++^[group0_4_L4A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c = c\cdot a\cdot b$,  
$ a^{-1}\cdot (b^{-1}\cdot c^{-1})^{-1} = (a\cdot (b\cdot c)^{-1})^{-1}$,  
$ a\cdot (b\cdot c)^{-1} = a\cdot b^{-1}\cdot c^{-1}$,  
$ a\cdot (b\cdot c^{-1})^{-1} = a\cdot b^{-1}\cdot c$,  
$ a\cdot b^{-1}\cdot c^{-1} = a\cdot c^{-1}\cdot b^{-1}$ === 
 ''with '' A3, T1  ''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'' === 

Every subgroup of an abelian group is normal. Moreover, the quotient group is also abelian.

 ''lemma''  <nowiki>Group_ZF_2_4_L6</nowiki>:
 ''   assumes '' A1: $ \text{IsAgroup}(G,P)$ ''and '' A2: $ P \text{ is commutative on } G$ ''and '' A3: $ IsAsubgroup(H,P)$ ''   shows '' $ IsAnormalSubgroup(G,P,H)$,  $ QuotientGroupOp(G,P,H) \text{ is commutative on } (G//QuotientGroupRel(G,P,H))$+++[proof ]>
 ''from '' A1, A2, A3  ''show''  T1: $ IsAnormalSubgroup(G,P,H)$ ''using''  <nowiki>group0_def</nowiki> ,  +++^[IsAnormalSubgroup_def | Group_ZF_2 ]... Definition of <nowiki>IsAnormalSubgroup</nowiki>:
$ IsAnormalSubgroup(G,P,N) \equiv  IsAsubgroup(N,P) \wedge  $
$  (\forall n\in N.\ \forall g\in G.\  P\langle   P\langle   g,n \rangle ,GroupInv(G,P)(g) \rangle  \in  N)$===  ,  +++^[Group_ZF_2_4_L5 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L5</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ IsAsubgroup(H,P)$  ''and'' $ g\in G$,   $ h\in H$  '' shows '' $ g\cdot h\cdot g^{-1} \in  H$ === 
 ''let '' $ r = QuotientGroupRel(G,P,H)$
 ''from '' A1, A3, T1  ''have''  $ equiv(G,r)$,  $ Congruent2(r,P)$ ''using''  <nowiki>group0_def</nowiki> ,  +++^[Group_ZF_2_4_L3 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L3</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ equiv(G,QuotientGroupRel(G,P,H))$ ===  ,  +++^[Group_ZF_2_4_L5A | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_4_L5A</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,P)$  ''and'' $ IsAnormalSubgroup(G,P,H)$  '' shows '' $ Congruent2(QuotientGroupRel(G,P,H),P)$ === 
 ''with '' A2  ''show''  $ QuotientGroupOp(G,P,H) \text{ is commutative on } (G//QuotientGroupRel(G,P,H))$ ''using''  +++^[EquivClass_2_T1 | EquivClass1 ]...  ''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$ ===  ,  +++^[QuotientGroupOp_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupOp</nowiki>:
$ QuotientGroupOp(G,P,H) \equiv  ProjFun2(G,QuotientGroupRel(G,P,H ),P)$=== 
 ''qed'' === 

The group inverse (in the quotient group) of a class (coset) is the class of the inverse.

 ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L7</nowiki>:
 ''   assumes '' $ IsAnormalSubgroup(G,P,H)$ ''and '' $ a\in G$ ''and '' $ r = QuotientGroupRel(G,P,H)$ ''and '' $ F = QuotientGroupOp(G,P,H)$ ''   shows '' $ r\{a^{-1}\} = GroupInv(G//r,F)(r\{a\})$ ''using''  <nowiki>groupAssum</nowiki> ,  <nowiki>assms</nowiki> ,  +++^[IsAnormalSubgroup_def | Group_ZF_2 ]... Definition of <nowiki>IsAnormalSubgroup</nowiki>:
$ IsAnormalSubgroup(G,P,N) \equiv  IsAsubgroup(N,P) \wedge  $
$  (\forall n\in N.\ \forall g\in G.\  P\langle   P\langle   g,n \rangle ,GroupInv(G,P)(g) \rangle  \in  N)$===  ,  +++^[Group_ZF_2_4_L3 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_4_L3</nowiki>:  ''assumes '' $ IsAsubgroup(H,P)$  '' shows '' $ equiv(G,QuotientGroupRel(G,P,H))$ ===  ,  +++^[Group_ZF_2_4_L5A | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_4_L5A</nowiki>:  ''assumes '' $ \text{IsAgroup}(G,P)$  ''and'' $ IsAnormalSubgroup(G,P,H)$  '' shows '' $ Congruent2(QuotientGroupRel(G,P,H),P)$ ===  ,  +++^[QuotientGroupOp_def | Group_ZF_2 ]... Definition of <nowiki>QuotientGroupOp</nowiki>:
$ QuotientGroupOp(G,P,H) \equiv  ProjFun2(G,QuotientGroupRel(G,P,H ),P)$===  ,  +++^[Group_ZF_2_2_L4 | Group_ZF_2 ]...  ''lemma''  ''(in'' group0'')'' <nowiki>Group_ZF_2_2_L4</nowiki>:  ''assumes '' $ equiv(G,r)$  ''and'' $ Congruent2(r,P)$  ''and'' $ F = ProjFun2(G,r,P)$  ''and'' $ a\in G$  '' shows '' $ r\{a^{-1}\} = GroupInv(G//r,F)(r\{a\})$ === 


!Function spaces as monoids

On every space of functions $\{f : X\rightarrow X\}$ we can define a natural monoid structure with composition as the operation. This section explores this fact.

The next lemma states that composition has a neutral element, namely the identity function on $X$ (the one that maps $x\in X$ into itself).

 ''lemma''  <nowiki>Group_ZF_2_5_L1</nowiki>:
 ''   assumes '' A1: $ F = Composition(X)$ ''   shows '' $ \exists I\in (X\rightarrow X).\  \forall f\in (X\rightarrow X).\  F\langle  I,f\rangle  = f \wedge  F\langle  f,I\rangle  = f$+++[proof ]>
 ''let '' $ I = id(X)$
 ''from '' A1  ''have''  $ I \in  X\rightarrow X \wedge  (\forall f\in (X\rightarrow X).\  F\langle  I,f\rangle  = f \wedge  F\langle  f,I\rangle  = f)$ ''using''  <nowiki>id_type</nowiki> ,  +++^[func_ZF_6_L1A | func_ZF ]...  ''lemma''  <nowiki>func_ZF_6_L1A</nowiki>:  ''assumes '' $ f : X\rightarrow X$  '' shows '' $ Composition(X)\langle f,id(X)\rangle  = f$,   $ Composition(X)\langle id(X),f\rangle  = f$ === 
 ''thus''  $ thesis$
 ''qed'' === 

The space of functions that map a set $X$ into itsef is a monoid with composition as operation and the identity function as the neutral element.

 ''lemma''  <nowiki>Group_ZF_2_5_L2</nowiki>:
 ''   shows '' $ \text{IsAmonoid}(X\rightarrow X,Composition(X))$,  $ id(X) = TheNeutralElement(X\rightarrow X,Composition(X))$+++[proof ]>
 ''let '' $ I = id(X)$
 ''let '' $ F = Composition(X)$
 ''show''  $ \text{IsAmonoid}(X\rightarrow X,Composition(X))$ ''using''  +++^[func_ZF_5_L5 | func_ZF ]...  ''lemma''  <nowiki>func_ZF_5_L5</nowiki>:  '' shows '' $ Composition(X) \text{ is associative on } (X\rightarrow X)$ ===  ,  +++^[Group_ZF_2_5_L1 | Group_ZF_2 ]...  ''lemma''  <nowiki>Group_ZF_2_5_L1</nowiki>:  ''assumes '' $ F = Composition(X)$  '' shows '' $ \exists I\in (X\rightarrow X).\  \forall f\in (X\rightarrow X).\  F\langle  I,f\rangle  = f \wedge  F\langle  f,I\rangle  = 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))))$=== 
 ''then ''  ''have''  $ monoid0(X\rightarrow X,F)$ ''using''  <nowiki>monoid0_def</nowiki>
 ''moreover''   ''have''  $ I \in  X\rightarrow X \wedge  (\forall f\in (X\rightarrow X).\  F\langle  I,f\rangle  = f \wedge  F\langle  f,I\rangle  = f)$ ''using''  <nowiki>id_type</nowiki> ,  +++^[func_ZF_6_L1A | func_ZF ]...  ''lemma''  <nowiki>func_ZF_6_L1A</nowiki>:  ''assumes '' $ f : X\rightarrow X$  '' shows '' $ Composition(X)\langle f,id(X)\rangle  = f$,   $ Composition(X)\langle id(X),f\rangle  = f$ === 
 ''ultimately ''  ''show''  $ I = TheNeutralElement(X\rightarrow X,F)$ ''using''  +++^[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)$ === 
 ''qed'' === 

 ''end

'' +++![Comments on Group_ZF_2|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Group_ZF_2"></iframe> </div> </html>
=== 
/***
|Name|InlineJavascriptPlugin|
|Source|http://www.TiddlyTools.com/#InlineJavascriptPlugin|
|Documentation|http://www.TiddlyTools.com/#InlineJavascriptPluginInfo|
|Version|1.9.3|
|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||
|Description|Insert Javascript executable code directly into your tiddler content.|
''Call directly into TW core utility routines, define new functions, calculate values, add dynamically-generated TiddlyWiki-formatted output'' into tiddler content, or perform any other programmatic actions each time the tiddler is rendered.
!!!!!Documentation
>see [[InlineJavascriptPluginInfo]]
!!!!!Revisions
<<<
2008.06.11 [1.9.3] added $(...) function as 'shorthand' convenience syntax for document.getElementById()
2008.03.03 [1.9.2] corrected declaration of wikifyPlainText() for 'TW 2.1.x compatibility fallback' (fixes Safari "parse error")
2008.02.23 [1.9.1] in onclick function, use string instead of array for 'bufferedHTML' attribute on link element (fixes IE errors)
2008.02.21 [1.9.0] 'onclick' scripts now allow returned text (or document.write() calls) to be wikified into a span that immediately follows the onclick link.  Also, added default 'return false' handling if no return value provided (prevents HREF from being triggered -- return TRUE to allow HREF to be processed).  Thanks to Xavier Verges for suggestion and preliminary code.
|please see [[InlineJavascriptPluginInfo]] for additional revision details|
2005.11.08 [1.0.0] initial release
<<<
!!!!!Code
***/
//{{{
version.extensions.InlineJavascriptPlugin= {major: 1, minor: 9, revision: 3, date: new Date(2008,6,11)};

config.formatters.push( {
	name: "inlineJavascript",
	match: "\\<script",
	lookahead: "\\<script(?: src=\\\"((?:.|\\n)*?)\\\")?(?: label=\\\"((?:.|\\n)*?)\\\")?(?: title=\\\"((?:.|\\n)*?)\\\")?(?: key=\\\"((?:.|\\n)*?)\\\")?( show)?\\>((?:.|\\n)*?)\\</script\\>",

	handler: function(w) {
		var lookaheadRegExp = new RegExp(this.lookahead,"mg");
		lookaheadRegExp.lastIndex = w.matchStart;
		var lookaheadMatch = lookaheadRegExp.exec(w.source)
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
			var src=lookaheadMatch[1];
			var label=lookaheadMatch[2];
			var tip=lookaheadMatch[3];
			var key=lookaheadMatch[4];
			var show=lookaheadMatch[5];
			var code=lookaheadMatch[6];
			if (src) { // load a script library
				// make script tag, set src, add to body to execute, then remove for cleanup
				var script = document.createElement("script"); script.src = src;
				document.body.appendChild(script); document.body.removeChild(script);
			}
			if (code) { // there is script code
				if (show) // show inline script code in tiddler output
					wikify("{{{\n"+lookaheadMatch[0]+"\n}}}\n",w.output);
				if (label) { // create a link to an 'onclick' script
					// add a link, define click handler, save code in link (pass 'place'), set link attributes
					var link=createTiddlyElement(w.output,"a",null,"tiddlyLinkExisting",wikifyPlainText(label));
					var fixup=code.replace(/document.write\s*\(/gi,'place.bufferedHTML+=(');
					link.code="function _out(place){"+fixup+"\n};_out(this);"
					link.tiddler=w.tiddler;
					link.onclick=function(){
						this.bufferedHTML="";
						try{ var r=eval(this.code);
							if(this.bufferedHTML.length || (typeof(r)==="string")&&r.length)
								var s=this.parentNode.insertBefore(document.createElement("span"),this.nextSibling);
							if(this.bufferedHTML.length)
								s.innerHTML=this.bufferedHTML;
							if((typeof(r)==="string")&&r.length) {
								wikify(r,s,null,this.tiddler);
								return false;
							} else return r!==undefined?r:false;
						} catch(e){alert(e.description||e.toString());return false;}
					};
					link.setAttribute("title",tip||"");
					var URIcode='javascript:void(eval(decodeURIComponent(%22(function(){try{';
					URIcode+=encodeURIComponent(encodeURIComponent(code.replace(/\n/g,' ')));
					URIcode+='}catch(e){alert(e.description||e.toString())}})()%22)))';
					link.setAttribute("href",URIcode);
					link.style.cursor="pointer";
					if (key) link.accessKey=key.substr(0,1); // single character only
				}
				else { // run inline script code
					var fixup=code.replace(/document.write\s*\(/gi,'place.innerHTML+=(');
					var code="function _out(place){"+fixup+"\n};_out(w.output);"
					try { var out=eval(code); } catch(e) { out=e.description?e.description:e.toString(); }
					if (out && out.length) wikify(out,w.output,w.highlightRegExp,w.tiddler);
				}
			}
			w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
		}
	}
} )
//}}}

// // Backward-compatibility for TW2.1.x and earlier
//{{{
if (typeof(wikifyPlainText)=="undefined") window.wikifyPlainText=function(text,limit,tiddler) {
	if(limit > 0) text = text.substr(0,limit);
	var wikifier = new Wikifier(text,formatter,null,tiddler);
	return wikifier.wikifyPlain();
}
//}}}

// // $(...) function: 'shorthand' convenience syntax for document.getElementById()
//{{{
if (typeof($)=="undefined") { // avoid redefinition
function $() {
	var elements=new Array();
	for (var i=0; i<arguments.length; i++) {
		var element=arguments[i];
		if (typeof element=='string') element=document.getElementById(element);
		if (arguments.length==1) return element;
		elements.push(element);
	}
	return elements;
}
}
//}}}
 ''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 arrived at the claim of the theorem (or a subproof).

 ''theorem''  <nowiki>disjointness_symetric</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// and //Order_ZF_1a// reformulate 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. In //NatOrder_ZF// we prove that the usual order on natural numbers is linear.
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. //func_ZF_1// is about 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 develop 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. In //FinOrd_ZF// we talk about ordered finite sets. 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. //Partitions_ZF// is about splitting a set into non-overlapping subsets. This is a common trick in proofs. //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//, //Group_ZF_1b// 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//. In //DirectProduct_ZF// we define direct product of groups and show some its basic properties. The //OrderedGroup_ZF// theory treats ordered groups. This is a suprisingly large theory for such relatively obscure topic.
//Ring_ZF// defines rings. //Ring_ZF_1// covers the properties of rings that are specific to the real numbers construction in //Real_ZF//. The //OrderedRing_ZF// theory looks at the consequences of adding a linear order to the ring algebraic structure.
//Field_ZF// and //OrderedField_ZF// contain basic facts about (you guessed it) fields and ordered fields.
//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//. In the //IntDiv_ZF_IML// theory translates some properties of the integer quotient and reminder functions studied in the standard Isabelle's //IntDiv_ZF// theory to the notation used in IsarMathLib.
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 //Metamath_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
GettingStarted
[[Introduction]]
[[Fol1]]
ZF1
Nat_ZF_IML
[[func1]]
[[func_ZF]]
Fold_ZF
EquivClass1
Finite_ZF
Partitions_ZF
Order_ZF
Order_ZF_1a
FinOrd_ZF
FinSupp_ZF
Topology_ZF
Topology_ZF_1
Topology_ZF_1b
Topology_ZF_2
Semigroup_ZF
Monoid_ZF
Group_ZF
Group_ZF_1
Group_ZF_1b
DirectProduct_ZF
AbelianGroup_ZF
Group_ZF_2
Ring_ZF
Field_ZF
[[Administration]] 
 ''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 semigroup except that we require the existence of a neutral 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
 ''assumes '' monoidAsssum: $ \text{IsAmonoid}(G,f)$
 ''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''  +++^[func1_1_L5B | func1 ]...  ''lemma''  <nowiki>func1_1_L5B</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ range(f) \subseteq  Y$ === 
 ''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''  +++^[func1_1_L5A | func1 ]...  ''lemma''  <nowiki>func1_1_L5A</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$,   $ y = f(x)$  '' shows '' $ \langle  x,y\rangle  \in  f$,   $ y \in  range(f)$ === 
 ''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''  +++^[func1_2_L4 | func1 ]...  ''lemma''  <nowiki>func1_2_L4</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  ''and'' $ \forall x\in A.\  f(x) \in  Z$  '' shows '' $ restrict(f,A) : A\rightarrow Z$ === 
 ''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'' === 

If a sum of two elements is not zero, then at least one has to be nonzero.

 ''lemma''  ''(in'' monoid0'')'' <nowiki>sum_nonzero_elmnt_nonzero</nowiki>:
 ''   assumes '' $ a \oplus  b \neq  TheNeutralElement(G,f)$ ''   shows '' $ a \neq  TheNeutralElement(G,f) \vee  b \neq  TheNeutralElement(G,f)$ ''using''  <nowiki>assms</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)$ === 

 ''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>
=== 
 ''theory'' Nat_ZF_IML ''imports'' [[Arith]]

 ''begin
'' 
The ZF set theory constructs natural numbers from the empty set and the notion of a one-element set. Namely, zero of natural numbers is defined as the empty set. For each natural number $n$ the next natural number is defined as $n\cup \{n\}$. With this definition for every non-zero natural number we get the identity $n = \{0,1,2,..,n-1\}$. It is good to remember that when we see an expression like $f: n \rightarrow X$. Also, with this definition the relation "less or equal than" becomes "$\subseteq$" and the relation "less than" becomes "$\in$".

!Induction

The induction lemmas in the standard Isabelle's Nat.thy file like for example //nat_induct// require the induction step to be a higher order statement (the one that uses the $\Longrightarrow$ sign). I found it difficult to apply from Isar, which is perhaps more of an indication of my Isar skills than anything else. Anyway, here we provide a first order version that is easier to reference in Isar declarative style proofs.

The next theorem is a version of induction on natural numbers that I was thought in school.

 ''theorem''  <nowiki>ind_on_nat</nowiki>:
 ''   assumes '' A1: $ n\in nat$ ''and '' A2: $ P(0)$ ''and '' A3: $ \forall k\in nat.\  P(k)\longrightarrow P(succ(k))$ ''   shows '' $ P(n)$+++[proof ]>
 ''note '' A1 A2
 ''moreover''  ++++[{ ]>
 ''fix '' $ x$
 ''assume '' $ x\in nat$,  $ P(x)$ ''and '' $ \forall k\in nat.\  P(k)\longrightarrow P(succ(k))$
 ''hence''  $ P(succ(x))$
===  ''}'' 
 ''ultimately ''  ''show''  $ P(n)$ ''   by (rule '' <nowiki>nat_induct</nowiki> '')'' 
 ''qed'' === 

A nonzero natural number has a predecessor.

 ''lemma''  <nowiki>Nat_ZF_1_L3</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ n\neq 0$ ''   shows '' $ \exists k\in nat.\  n = succ(k)$+++[proof ]>
 ''from '' A1  ''have''  $ n \in  \{0\} \cup  \{succ(k).\  k\in nat\}$ ''using''  <nowiki>nat_unfold</nowiki>
 ''with '' A2  ''show''  $ thesis$ 
 ''qed'' === 

What is //succ//, anyway?

 ''lemma''  <nowiki>succ_explained</nowiki>:
 ''   shows '' $ succ(n) = n \cup  \{n\}$ ''using''  <nowiki>succ_iff</nowiki>

Empty set is an element of every natural number which is not zero.

 ''lemma''  <nowiki>empty_in_every_succ</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''   shows '' $ 0 \in  succ(n)$+++[proof ]>
 ''note '' A1
 ''moreover''   ''have''  $ 0 \in  succ(0)$ 
 ''moreover''  ++++[{ ]>
 ''fix '' $ k$
 ''assume '' $ k \in  nat$ ''and '' A2: $ 0 \in  succ(k)$
 ''then ''  ''have''  $ succ(k) \subseteq  succ(succ(k))$ 
 ''with '' A2  ''have''  $ 0 \in  succ(succ(k))$ 
===  ''}'' 
 ''then ''  ''have''  $ \forall k \in  nat.\  0 \in  succ(k) \longrightarrow  0 \in  succ(succ(k))$ 
 ''ultimately ''  ''show''  $ 0 \in  succ(n)$ ''   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)$ ===  '')'' 
 ''qed'' === 

If one natural number is less than another then their successors are in the same relation.

 ''lemma''  <nowiki>succ_ineq</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''   shows '' $ \forall i \in  n.\  succ(i) \in  succ(n)$+++[proof ]>
 ''note '' A1
 ''moreover''   ''have''  $ \forall k \in  0.\  succ(k) \in  succ(0)$ 
 ''moreover''  ++++[{ ]>
 ''fix '' $ k$
 ''assume '' A2: $ \forall i\in k.\  succ(i) \in  succ(k)$
++++[{ ]>
 ''fix '' $ i$
 ''assume '' $ i \in  succ(k)$
 ''then ''  ''have''  $ i \in  k \vee  i = k$ 
 ''moreover''  ++++[{ ]>
 ''assume '' $ i\in k$
 ''with '' A2  ''have''  $ succ(i) \in  succ(k)$ 
 ''hence''  $ succ(i) \in  succ(succ(k))$
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ i = k$
 ''then ''  ''have''  $ succ(i) \in  succ(succ(k))$ 
===  ''}'' 
 ''ultimately ''  ''have''  $ succ(i) \in  succ(succ(k))$ 
===  ''}'' 
 ''then ''  ''have''  $ \forall i \in  succ(k).\  succ(i) \in  succ(succ(k))$ 
===  ''}'' 
 ''then ''  ''have''  $ \forall k \in  nat.\  $
$      ( (\forall i\in k.\  succ(i) \in  succ(k)) \longrightarrow  (\forall i \in  succ(k).\  succ(i) \in  succ(succ(k))) )$ 
 ''ultimately ''  ''show''  $ \forall i \in  n.\  succ(i) \in  succ(n)$ ''   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)$ ===  '')'' 
 ''qed'' === 

For natural numbers if $k\subseteq n$ the similar holds for their successors.

 ''lemma''  <nowiki>succ_subset</nowiki>:
 ''   assumes '' A1: $ k \in  nat$,  $ n \in  nat$ ''and '' A2: $ k\subseteq n$ ''   shows '' $ succ(k) \subseteq  succ(n)$+++[proof ]>
 ''from '' A1  ''have''  T: $ Ord(k)$ ''and '' $ Ord(n)$ ''using''  <nowiki>nat_into_Ord</nowiki>
 ''with '' A2  ''have''  $ succ(k) \leq succ(n)$ ''using''  <nowiki>subset_imp_le</nowiki>
 ''then ''  ''show''  $ succ(k) \subseteq  succ(n)$ ''using''  <nowiki>le_imp_subset</nowiki>
 ''qed'' === 

For any two natural numbers one of them is contained in the other.

 ''lemma''  <nowiki>nat_incl_total</nowiki>:
 ''   assumes '' A1: $ i \in  nat$,  $ j \in  nat$ ''   shows '' $ i \subseteq  j \vee  j \subseteq  i$+++[proof ]>
 ''from '' A1  ''have''  T: $ Ord(i)$,  $ Ord(j)$ ''using''  <nowiki>nat_into_Ord</nowiki>
 ''then ''  ''have''  $ i\in j \vee  i=j \vee  j\in i$ ''using''  <nowiki>Ord_linear</nowiki>
 ''moreover''  ++++[{ ]>
 ''assume '' $ i\in j$
 ''with '' T  ''have''  $ i\subseteq j \vee  j\subseteq i$ ''using''  <nowiki>lt_def</nowiki> ,  <nowiki>leI</nowiki> ,  <nowiki>le_imp_subset</nowiki>
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ i=j$
 ''then ''  ''have''  $ i\subseteq j \vee  j\subseteq i$ 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ j\in i$
 ''with '' T  ''have''  $ i\subseteq j \vee  j\subseteq i$ ''using''  <nowiki>lt_def</nowiki> ,  <nowiki>leI</nowiki> ,  <nowiki>le_imp_subset</nowiki>
===  ''}'' 
 ''ultimately ''  ''show''  $ i \subseteq  j \vee  j \subseteq  i$ 
 ''qed'' === 

The set of natural numbers is the union of all successors of natural numbers.

 ''lemma''  <nowiki>nat_union_succ</nowiki>:
 ''   shows '' $ nat = (\bigcup n \in  nat.\  succ(n))$+++[proof ]>
 ''show''  $ nat \subseteq  (\bigcup n \in  nat.\  succ(n))$ 
 ''next '' 
++++[{ ]>
 ''fix '' $ k$
 ''assume '' A2: $ k \in  (\bigcup n \in  nat.\  succ(n))$
 ''then ''  ''obtain '' $ n$ ''where '' T: $ n \in  nat$ ''and '' I: $ k \in  succ(n)$ 
 ''then ''  ''have''  $ k \leq n$ ''using''  <nowiki>nat_into_Ord</nowiki> ,  <nowiki>lt_def</nowiki>
 ''with '' T  ''have''  $ k \in  nat$ ''using''  <nowiki>le_in_nat</nowiki>
===  ''}'' 
 ''then ''  ''show''  $ (\bigcup n \in  nat.\  succ(n)) \subseteq  nat$ 
 ''qed'' === 

Successors of natural numbers are subsets of the set of natural numbers.

 ''lemma''  <nowiki>succnat_subset_nat</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''   shows '' $ succ(n) \subseteq  nat$+++[proof ]>
 ''from '' A1  ''have''  $ succ(n) \subseteq  (\bigcup n \in  nat.\  succ(n))$ 
 ''then ''  ''show''  $ succ(n) \subseteq  nat$ ''using''  +++^[nat_union_succ | Nat_ZF_IML ]...  ''lemma''  <nowiki>nat_union_succ</nowiki>:  '' shows '' $ nat = (\bigcup n \in  nat.\  succ(n))$ === 
 ''qed'' === 

Element of a natural number is a natural number.

 ''lemma''  <nowiki>elem_nat_is_nat</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ k\in n$ ''   shows '' $ k < n$,  $ k \in  nat$,  $ k \leq n$,  $ \langle k,n\rangle  \in  Le$+++[proof ]>
 ''from '' A1, A2  ''show''  $ k < n$ ''using''  <nowiki>nat_into_Ord</nowiki> ,  <nowiki>lt_def</nowiki>
 ''with '' A1  ''show''  $ k \in  nat$ ''using''  <nowiki>lt_nat_in_nat</nowiki>
 ''from '' $ k < n$  ''show''  $ k \leq n$ ''using''  <nowiki>leI</nowiki>
 ''with '' A1, $ k \in  nat$  ''show''  $ \langle k,n\rangle  \in  Le$ ''using''  <nowiki>Le_def</nowiki>
 ''qed'' === 

The set of natural numbers is the union of its elements.

 ''lemma''  <nowiki>nat_union_nat</nowiki>:
 ''   shows '' $ nat = \bigcup  nat$ ''using''  +++^[elem_nat_is_nat | Nat_ZF_IML ]...  ''lemma''  <nowiki>elem_nat_is_nat</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k\in n$  '' shows '' $ k < n$,   $ k \in  nat$,   $ k \leq n$,   $ \langle k,n\rangle  \in  Le$ === 

A natural number is a subset of the set of natural numbers.

 ''lemma''  <nowiki>nat_subset_nat</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''   shows '' $ n \subseteq  nat$+++[proof ]>
 ''from '' A1  ''have''  $ n \subseteq  \bigcup  nat$ 
 ''then ''  ''show''  $ n \subseteq  nat$ ''using''  +++^[nat_union_nat | Nat_ZF_IML ]...  ''lemma''  <nowiki>nat_union_nat</nowiki>:  '' shows '' $ nat = \bigcup  nat$ === 
 ''qed'' === 

Adding a natural numbers does not decrease what we add to.

 ''lemma''  <nowiki>add_nat_le</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ k \in  nat$ ''   shows '' $ n \leq n \ \sharp + k$,  $ n \subseteq  n \ \sharp + k$,  $ n \subseteq  k \ \sharp + n$+++[proof ]>
 ''from '' A1, A2  ''have''  $ n \leq n$,  $ 0 \leq k$,  $ n \in  nat$,  $ k \in  nat$ ''using''  <nowiki>nat_le_refl</nowiki> ,  <nowiki>nat_0_le</nowiki>
 ''then ''  ''have''  $ n \ \sharp + 0 \leq n \ \sharp + k$ ''   by (rule '' <nowiki>add_le_mono</nowiki> '')'' 
 ''with '' A1  ''show''  $ n \leq n \ \sharp + k$ ''using''  <nowiki>add_0_right</nowiki>
 ''then ''  ''show''  $ n \subseteq  n \ \sharp + k$ ''using''  <nowiki>le_imp_subset</nowiki>
 ''then ''  ''show''  $ n \subseteq  k \ \sharp + n$ ''using''  <nowiki>add_commute</nowiki>
 ''qed'' === 

Result of adding an element of $k$ is smaller than of adding $k$.

 ''lemma''  <nowiki>add_lt_mono</nowiki>:
 ''   assumes '' $ k \in  nat$ ''and '' $ j\in k$ ''   shows '' $ (n \ \sharp + j) < (n \ \sharp + k)$,  $ (n \ \sharp + j) \in  (n \ \sharp + k)$+++[proof ]>
 ''from '' assms  ''have''  $ j < k$,  $ k \in  nat$ ''using''  +++^[elem_nat_is_nat | Nat_ZF_IML ]...  ''lemma''  <nowiki>elem_nat_is_nat</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k\in n$  '' shows '' $ k < n$,   $ k \in  nat$,   $ k \leq n$,   $ \langle k,n\rangle  \in  Le$ === 
 ''then ''  ''show''  $ (n \ \sharp + j) < (n \ \sharp + k)$,  $ (n \ \sharp + j) \in  (n \ \sharp + k)$ ''using''  <nowiki>add_lt_mono2</nowiki> ,  <nowiki>ltD</nowiki>
 ''qed'' === 

A technical lemma about a decomposition of a sum of two natural numbers: if a number $i$ is from $m + n$ then it is either from $m$ or can be written as a sum of $m$ and a number from $n$. The proof by induction w.r.t. to $m$ seems to be a bit heavy-handed, but I could not figure out how to do this directly from results from standard Isabelle/ZF.

 ''lemma''  <nowiki>nat_sum_decomp</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ m \in  nat$ ''   shows '' $ \forall i \in  m \ \sharp + n.\  i \in  m \vee  (\exists j \in  n.\  i = m \ \sharp + j)$+++[proof ]>
 ''note '' A1
 ''moreover''   ''from '' A2  ''have''  $ \forall i \in  m \ \sharp + 0.\  i \in  m \vee  (\exists j \in  0.\  i = m \ \sharp + j)$ ''using''  <nowiki>add_0_right</nowiki>
 ''moreover''   ''have''  $ \forall k\in nat.\ $
$    (\forall i \in  m \ \sharp + k.\  i \in  m \vee  (\exists j \in  k.\  i = m \ \sharp + j)) \longrightarrow $
$    (\forall i \in  m \ \sharp + succ(k).\  i \in  m \vee  (\exists j \in  succ(k).\  i = m \ \sharp + j))$+++[proof ]>
++++[{ ]>
 ''fix '' $ k$
 ''assume '' A3: $ k \in  nat$
++++[{ ]>
 ''assume '' A4: $ \forall i \in  m \ \sharp + k.\  i \in  m \vee  (\exists j \in  k.\  i = m \ \sharp + j)$
++++[{ ]>
 ''fix '' $ i$
 ''assume '' $ i \in   m \ \sharp + succ(k)$
 ''then ''  ''have''  $ i \in  m \ \sharp + k \vee  i = m \ \sharp + k$ ''using''  <nowiki>add_succ_right</nowiki>
 ''moreover''   ''from '' A4, A3  ''have''  $ i \in  m \ \sharp + k \longrightarrow  i \in  m \vee  (\exists j \in  succ(k).\  i = m \ \sharp + j)$ 
 ''ultimately ''  ''have''  $ i \in  m \vee  (\exists j \in  succ(k).\  i = m \ \sharp + j)$ 
===  ''}'' 
 ''then ''  ''have''  $ \forall i \in  m \ \sharp + succ(k).\  i \in  m \vee  (\exists j \in  succ(k).\  i = m \ \sharp + j)$ 
===  ''}'' 
 ''then ''  ''have''  $ (\forall i \in  m \ \sharp + k.\  i \in  m \vee  (\exists j \in  k.\  i = m \ \sharp + j)) \longrightarrow $
$	  (\forall i \in  m \ \sharp + succ(k).\  i \in  m \vee  (\exists j \in  succ(k).\  i = m \ \sharp + j))$ 
===  ''}'' 
 ''then ''  ''show''  $ thesis$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ \forall i \in  m \ \sharp + n.\  i \in  m \vee  (\exists j \in  n.\  i = m \ \sharp + j)$ ''   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)$ ===  '')'' 
 ''qed'' === 

A variant of induction useful for finite sequences.

 ''lemma''  <nowiki>fin_nat_ind</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ k \in  succ(n)$ ''and '' A3: $ P(0)$ ''and '' A4: $ \forall j\in n.\  P(j)  \longrightarrow  P(succ(j))$ ''   shows '' $ P(k)$+++[proof ]>
 ''from '' A2  ''have''  $ k \in  n \vee  k=n$ 
 ''with '' A1  ''have''  $ k \in  nat$ ''using''  +++^[elem_nat_is_nat | Nat_ZF_IML ]...  ''lemma''  <nowiki>elem_nat_is_nat</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k\in n$  '' shows '' $ k < n$,   $ k \in  nat$,   $ k \leq n$,   $ \langle k,n\rangle  \in  Le$ === 
 ''moreover''   ''from '' A3  ''have''  $ 0 \in  succ(n) \longrightarrow  P(0)$ 
 ''moreover''   ''from '' A1, A4  ''have''  $ \forall k \in  nat.\  (k \in  succ(n) \longrightarrow  P(k)) \longrightarrow  (succ(k) \in  succ(n) \longrightarrow  P(succ(k)))$ ''using''  <nowiki>nat_into_Ord</nowiki> ,  <nowiki>Ord_succ_mem_iff</nowiki>
 ''ultimately ''  ''have''  $ k \in  succ(n) \longrightarrow  P(k)$ ''   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)$ ===  '')'' 
 ''with '' A2  ''show''  $ P(k)$ 
 ''qed'' === 

Some properties of positive natural numbers.

 ''lemma''  <nowiki>succ_plus</nowiki>:
 ''   assumes '' $ n \in  nat$,  $ k \in  nat$ ''   shows '' $ succ(n \ \sharp + j) \in  nat$,  $ succ(n) \ \sharp + succ(j) = succ(succ(n \ \sharp + j))$ ''using''  <nowiki>assms</nowiki>


!Intervals

In this section we consider intervals of natural numbers i.e. sets of the form $\{n+j : j \in 0..k-1\}$.

The interval is determined by two parameters: starting point and length. Recall that in standard Isabelle's //Arith.thy// the symbol $ \ \sharp +$ is defined as the sum of natural numbers.

 ''Definition
'' $ NatInterval(n,k) \equiv  \{n \ \sharp + j.\  j\in k\}$

Subtracting the beginning af the interval results in a number from the length of the interval.It may sound weird, but note that the length of such interval is a natural number, hence a set.

 ''lemma''  <nowiki>inter_diff_in_len</nowiki>:
 ''   assumes '' A1: $ k \in  nat$ ''and '' A2: $ i \in  NatInterval(n,k)$ ''   shows '' $ i \ \sharp - n \in  k$+++[proof ]>
 ''from '' A2  ''obtain '' $ j$ ''where '' I: $ i = n \ \sharp + j$ ''and '' II: $ j \in  k$ ''using''  +++^[NatInterval_def | Nat_ZF_IML ]... Definition of <nowiki>NatInterval</nowiki>:
$ NatInterval(n,k) \equiv  \{n \ \sharp + j.\  j\in k\}$=== 
 ''from '' A1, II  ''have''  $ j \in  nat$ ''using''  +++^[elem_nat_is_nat | Nat_ZF_IML ]...  ''lemma''  <nowiki>elem_nat_is_nat</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k\in n$  '' shows '' $ k < n$,   $ k \in  nat$,   $ k \leq n$,   $ \langle k,n\rangle  \in  Le$ === 
 ''moreover''   ''from '' I  ''have''  $ i \ \sharp - n = natify(j)$ ''using''  <nowiki>diff_add_inverse</nowiki>
 ''ultimately ''  ''have''  $ i \ \sharp - n = j$ 
 ''with '' II  ''show''  $ thesis$ 
 ''qed'' === 

Intervals don't overlap with their starting point and the union of an interval with its starting point is the sum of the starting point and the length of the interval.

 ''lemma''  <nowiki>length_start_decomp</nowiki>:
 ''   assumes '' A1: $ n \in  nat$,  $ k \in  nat$ ''   shows '' $ n \cap  NatInterval(n,k) = 0$,  $ n \cup  NatInterval(n,k) = n \ \sharp + k$+++[proof ]>
++++[{ ]>
 ''fix '' $ i$
 ''assume '' A2: $ i \in  n$ ''and '' $ i \in  NatInterval(n,k)$
 ''then ''  ''obtain '' $ j$ ''where '' I: $ i = n \ \sharp + j$ ''and '' II: $ j \in  k$ ''using''  +++^[NatInterval_def | Nat_ZF_IML ]... Definition of <nowiki>NatInterval</nowiki>:
$ NatInterval(n,k) \equiv  \{n \ \sharp + j.\  j\in k\}$=== 
 ''from '' A1  ''have''  $ k \in  nat$ ''using''  +++^[elem_nat_is_nat | Nat_ZF_IML ]...  ''lemma''  <nowiki>elem_nat_is_nat</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k\in n$  '' shows '' $ k < n$,   $ k \in  nat$,   $ k \leq n$,   $ \langle k,n\rangle  \in  Le$ === 
 ''with '' II  ''have''  $ j \in  nat$ ''using''  +++^[elem_nat_is_nat | Nat_ZF_IML ]...  ''lemma''  <nowiki>elem_nat_is_nat</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k\in n$  '' shows '' $ k < n$,   $ k \in  nat$,   $ k \leq n$,   $ \langle k,n\rangle  \in  Le$ === 
 ''with '' A1, I  ''have''  $ n \leq i$ ''using''  +++^[add_nat_le | Nat_ZF_IML ]...  ''lemma''  <nowiki>add_nat_le</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k \in  nat$  '' shows '' $ n \leq n \ \sharp + k$,   $ n \subseteq  n \ \sharp + k$,   $ n \subseteq  k \ \sharp + n$ === 
 ''moreover''   ''from '' A1, A2  ''have''  $ i < n$ ''using''  +++^[elem_nat_is_nat | Nat_ZF_IML ]...  ''lemma''  <nowiki>elem_nat_is_nat</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k\in n$  '' shows '' $ k < n$,   $ k \in  nat$,   $ k \leq n$,   $ \langle k,n\rangle  \in  Le$ === 
 ''ultimately ''  ''have''  $ False$ ''using''  <nowiki>le_imp_not_lt</nowiki>
===  ''}'' 
 ''thus''  $ n \cap  NatInterval(n,k) = 0$
 ''from '' A1  ''have''  $ n \subseteq  n \ \sharp + k$ ''using''  +++^[add_nat_le | Nat_ZF_IML ]...  ''lemma''  <nowiki>add_nat_le</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k \in  nat$  '' shows '' $ n \leq n \ \sharp + k$,   $ n \subseteq  n \ \sharp + k$,   $ n \subseteq  k \ \sharp + n$ === 
 ''moreover''  ++++[{ ]>
 ''fix '' $ i$
 ''assume '' $ i \in  NatInterval(n,k)$
 ''then ''  ''obtain '' $ j$ ''where '' III: $ i = n \ \sharp + j$ ''and '' IV: $ j \in  k$ ''using''  +++^[NatInterval_def | Nat_ZF_IML ]... Definition of <nowiki>NatInterval</nowiki>:
$ NatInterval(n,k) \equiv  \{n \ \sharp + j.\  j\in k\}$=== 
 ''with '' A1  ''have''  $ j < k$ ''using''  +++^[elem_nat_is_nat | Nat_ZF_IML ]...  ''lemma''  <nowiki>elem_nat_is_nat</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ k\in n$  '' shows '' $ k < n$,   $ k \in  nat$,   $ k \leq n$,   $ \langle k,n\rangle  \in  Le$ === 
 ''with '' A1, III  ''have''  $ i \in  n \ \sharp + k$ ''using''  <nowiki>add_lt_mono2</nowiki> ,  <nowiki>ltD</nowiki>
===  ''}'' 
 ''ultimately ''  ''have''  $ n \cup  NatInterval(n,k) \subseteq  n \ \sharp + k$ 
 ''moreover''   ''from '' A1  ''have''  $ n \ \sharp + k \subseteq  n \cup  NatInterval(n,k)$ ''using''  +++^[nat_sum_decomp | Nat_ZF_IML ]...  ''lemma''  <nowiki>nat_sum_decomp</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ m \in  nat$  '' shows '' $ \forall i \in  m \ \sharp + n.\  i \in  m \vee  (\exists j \in  n.\  i = m \ \sharp + j)$ ===  ,  +++^[NatInterval_def | Nat_ZF_IML ]... Definition of <nowiki>NatInterval</nowiki>:
$ NatInterval(n,k) \equiv  \{n \ \sharp + j.\  j\in k\}$=== 
 ''ultimately ''  ''show''  $ n \cup  NatInterval(n,k) = n \ \sharp + k$ 
 ''qed'' === 

Sme properties of three adjacent intervals.

 ''lemma''  <nowiki>adjacent_intervals3</nowiki>:
 ''   assumes '' $ n \in  nat$,  $ k \in  nat$,  $ m \in  nat$ ''   shows '' $ n \ \sharp + k \ \sharp + m = (n \ \sharp + k) \cup  NatInterval(n \ \sharp + k,m)$,  $ n \ \sharp + k \ \sharp + m = n \cup  NatInterval(n,k \ \sharp +  m)$,  $ n \ \sharp + k \ \sharp + m = n \cup  NatInterval(n,k) \cup  NatInterval(n \ \sharp + k,m)$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>add_assoc</nowiki> ,  +++^[length_start_decomp | Nat_ZF_IML ]...  ''lemma''  <nowiki>length_start_decomp</nowiki>:  ''assumes '' $ n \in  nat$,   $ k \in  nat$  '' shows '' $ n \cap  NatInterval(n,k) = 0$,   $ n \cup  NatInterval(n,k) = n \ \sharp + k$ === 

 ''end

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

/***
|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"; }
}
//}}}
 ''theory'' Order_ZF ''imports'' [[Fol1]]

 ''begin
'' 
This theory file considers various notion related to order. We redefine the notions of a total order, linear order and partial order to have the same terminology as Wikipedia (I found it very consistent across different areas of math). We also define and study the notions of intervals and bounded sets. We show the inclusion relations between the intervals with endpoints being in certain order. We also show that union of bounded sets are bounded. This allows to show in //Finite_ZF.thy// that finite sets are bounded.

!Definitions

In this section we formulate the definitions related to order relations.

A relation $r$ is ''total'' on a set $X$ if for all elements $a,b$ of $X$ we have $a$ is in relation with $b$ or $b$ is in relation with $a$. An example is the $\leq $ relation on numbers.

 ''Definition
'' $ r \text{ is total on } X \equiv  (\forall a\in X.\ \forall b\in X.\  \langle  a,b\rangle  \in  r \vee  \langle  b,a\rangle  \in  r)$

A relation $r$ is a partial order on $X$ if it is reflexive on $X$ (i.e. $\langle x,x \rangle$ for every $x\in X$), antisymmetric (if $\langle x, y\rangle \in r $ and $\langle y, x\rangle \in r $, then $x=y$) and transitive $\langle x, y\rangle \in r $ and $\langle y, z\rangle \in r $ implies $\langle x, z\rangle \in r $).

 ''Definition
'' $ IsPartOrder(X,r) \equiv  (refl(X,r) \wedge  antisym(r) \wedge  trans(r))$

We define a linear order as a binary relation that is antisymmetric, transitive and total. Note that this terminology is different than the one used the standard Order.thy file.

 ''Definition
'' $ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$

A set is bounded above if there is that is an upper bound for it, i.e. there are some $u$ such that $\langle x, u\rangle \in r$ for all $x\in A$. In addition, the empty set is defined as bounded.

 ''Definition
'' $ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$

We define sets bounded below analogously.

 ''Definition
'' $ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$

A set is bounded if it is bounded below and above.

 ''Definition
'' $ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$

The notation for the definition of an interval may be mysterious for some readers, see lemma //Order_ZF_2_L1// for more intuitive notation.

 ''Definition
'' $ Interval(r,a,b) \equiv  r\{a\} \cap  r^{-1}\{b\}$

We also define the maximum (the greater of) two elemnts in the obvious way.

 ''Definition
'' $ GreaterOf(r,a,b) \equiv  (if \langle  a,b\rangle  \in  r then b else a)$

The definition a a minimum (the smaller of) two elements.

 ''Definition
'' $ SmallerOf(r,a,b) \equiv  (if \langle  a,b\rangle  \in  r then a else b)$

We say that a set has a maximum if it has an element that is not smaller that any other one. We show that under some conditions this element of the set is unique (if exists).

 ''Definition
'' $ HasAmaximum(r,A) \equiv  \exists M\in A.\ \forall x\in A.\  \langle  x,M\rangle  \in  r$

A similar definition what it means that a set has a minimum.

 ''Definition
'' $ HasAminimum(r,A) \equiv  \exists m\in A.\ \forall x\in A.\  \langle  m,x\rangle  \in  r$

Definition of the maximum of a set.

 ''Definition
'' $ Maximum(r,A) \equiv  \text{The } M.\  M\in A \wedge  (\forall x\in A.\  \langle  x,M\rangle  \in  r)$

Definition of a minimum of a set.

 ''Definition
'' $ Minimum(r,A) \equiv  \text{The } m.\  m\in A \wedge  (\forall x\in A.\  \langle  m,x\rangle  \in  r)$

The supremum of a set $A$ is defined as the minimum of the set of upper bounds, i.e. the set $\{u.\forall_{a\in A} \langle a,u\rangle \in r\}=\bigcap_{a\in A} r\{a\}$. Recall that in Isabelle/ZF $ r^{-1}(A)$ denotes the inverse image of the set $A$ by relation $r$ (i.e. $ r^{-1}(A)$=$\{ x: \langle x,y\rangle\in r$ for some $y\in A\}$).

 ''Definition
'' $ Supremum(r,A) \equiv  Minimum(r,\bigcap a\in A.\  r\{a\})$

Infimum is defined analogously.

 ''Definition
'' $ Infimum(r,A) \equiv  Maximum(r,\bigcap a\in A.\  r^{-1}\{a\})$

We define a relation to be complete if every nonempty bounded above set has a supremum.

 ''Definition
'' $ r \text{ is complete } \equiv  $
$  \forall A.\  IsBoundedAbove(A,r) \wedge  A\neq 0 \longrightarrow  HasAminimum(r,\bigcap a\in A.\  r\{a\})$

The essential condition to show that a total relation is reflexive.

 ''lemma''  <nowiki>Order_ZF_1_L1</nowiki>:
 ''   assumes '' $ r \text{ is total on } X$ ''and '' $ a\in X$ ''   shows '' $ \langle a,a\rangle  \in  r$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsTotal_def | Order_ZF ]... Definition of <nowiki>IsTotal</nowiki>:
$ r \text{ is total on } X \equiv  (\forall a\in X.\ \forall b\in X.\  \langle  a,b\rangle  \in  r \vee  \langle  b,a\rangle  \in  r)$=== 

A total relation is reflexive.

 ''lemma''  <nowiki>total_is_refl</nowiki>:
 ''   assumes '' $ r \text{ is total on } X$ ''   shows '' $ refl(X,r)$ ''using''  <nowiki>assms</nowiki> ,  +++^[Order_ZF_1_L1 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_1_L1</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ a\in X$  '' shows '' $ \langle a,a\rangle  \in  r$ ===  ,  <nowiki>refl_def</nowiki>

A linear order is partial order.

 ''lemma''  <nowiki>Order_ZF_1_L2</nowiki>:
 ''   assumes '' $ IsLinOrder(X,r)$ ''   shows '' $ IsPartOrder(X,r)$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[IsPartOrder_def | Order_ZF ]... Definition of <nowiki>IsPartOrder</nowiki>:
$ IsPartOrder(X,r) \equiv  (refl(X,r) \wedge  antisym(r) \wedge  trans(r))$===  ,  <nowiki>refl_def</nowiki> ,  +++^[Order_ZF_1_L1 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_1_L1</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ a\in X$  '' shows '' $ \langle a,a\rangle  \in  r$ === 

Partial order that is total is linear.

 ''lemma''  <nowiki>Order_ZF_1_L3</nowiki>:
 ''   assumes '' $ IsPartOrder(X,r)$ ''and '' $ r \text{ is total on } X$ ''   shows '' $ IsLinOrder(X,r)$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsPartOrder_def | Order_ZF ]... Definition of <nowiki>IsPartOrder</nowiki>:
$ IsPartOrder(X,r) \equiv  (refl(X,r) \wedge  antisym(r) \wedge  trans(r))$===  ,  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$=== 

Relation that is total on a set is total on any subset.

 ''lemma''  <nowiki>Order_ZF_1_L4</nowiki>:
 ''   assumes '' $ r \text{ is total on } X$ ''and '' $ A\subseteq X$ ''   shows '' $ r \text{ is total on } A$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsTotal_def | Order_ZF ]... Definition of <nowiki>IsTotal</nowiki>:
$ r \text{ is total on } X \equiv  (\forall a\in X.\ \forall b\in X.\  \langle  a,b\rangle  \in  r \vee  \langle  b,a\rangle  \in  r)$=== 

A linear relation is linear on any subset.

 ''lemma''  <nowiki>ord_linear_subset</nowiki>:
 ''   assumes '' $ IsLinOrder(X,r)$ ''and '' $ A\subseteq X$ ''   shows '' $ IsLinOrder(A,r)$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[Order_ZF_1_L4 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_1_L4</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ A\subseteq X$  '' shows '' $ r \text{ is total on } A$ === 

If the relation is total, then every set is a union of those elements that are nongreater than a given one and nonsmaller than a given one.

 ''lemma''  <nowiki>Order_ZF_1_L5</nowiki>:
 ''   assumes '' $ r \text{ is total on } X$ ''and '' $ A\subseteq X$ ''and '' $ a\in X$ ''   shows '' $ A = \{x\in A.\  \langle x,a\rangle  \in  r\} \cup  \{x\in A.\  \langle a,x\rangle  \in  r\}$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsTotal_def | Order_ZF ]... Definition of <nowiki>IsTotal</nowiki>:
$ r \text{ is total on } X \equiv  (\forall a\in X.\ \forall b\in X.\  \langle  a,b\rangle  \in  r \vee  \langle  b,a\rangle  \in  r)$=== 

A technical fact about reflexive relations.

 ''lemma''  <nowiki>refl_add_point</nowiki>:
 ''   assumes '' $ refl(X,r)$ ''and '' $ A \subseteq  B \cup  \{x\}$ ''and '' $ B \subseteq  X$ ''and '' $ x \in  X$ ''and '' $ \forall y\in B.\  \langle y,x\rangle  \in  r$ ''   shows '' $ \forall a\in A.\  \langle a,x\rangle  \in  r$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>refl_def</nowiki>


!Intervals

In this section we discuss intervals.

The next lemma explains the notation of the definition of an interval.

 ''lemma''  <nowiki>Order_ZF_2_L1</nowiki>:
 ''   shows '' $ x \in  Interval(r,a,b) \longleftrightarrow  \langle  a,x\rangle  \in  r \wedge  \langle  x,b\rangle  \in  r$ ''using''  +++^[Interval_def | Order_ZF ]... Definition of <nowiki>Interval</nowiki>:
$ Interval(r,a,b) \equiv  r\{a\} \cap  r^{-1}\{b\}$=== 

Since there are some problems with applying the above lemma (seems that simp and auto don't handle equivalence very well), we split //Order_ZF_2_L1// into two lemmas.

 ''lemma''  <nowiki>Order_ZF_2_L1A</nowiki>:
 ''   assumes '' $ x \in  Interval(r,a,b)$ ''   shows '' $ \langle  a,x\rangle  \in  r$,  $ \langle  x,b\rangle  \in  r$ ''using''  <nowiki>assms</nowiki> ,  +++^[Order_ZF_2_L1 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L1</nowiki>:  '' shows '' $ x \in  Interval(r,a,b) \longleftrightarrow  \langle  a,x\rangle  \in  r \wedge  \langle  x,b\rangle  \in  r$
=== 

//Order_ZF_2_L1//, implication from right to left.

 ''lemma''  <nowiki>Order_ZF_2_L1B</nowiki>:
 ''   assumes '' $ \langle  a,x\rangle  \in  r$,  $ \langle  x,b\rangle  \in  r$ ''   shows '' $ x \in  Interval(r,a,b)$ ''using''  <nowiki>assms</nowiki> ,  +++^[Order_ZF_2_L1 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L1</nowiki>:  '' shows '' $ x \in  Interval(r,a,b) \longleftrightarrow  \langle  a,x\rangle  \in  r \wedge  \langle  x,b\rangle  \in  r$
=== 

If the relation is reflexive, the endpoints belong to the interval.

 ''lemma''  <nowiki>Order_ZF_2_L2</nowiki>:
 ''   assumes '' $ refl(X,r)$ ''and '' $ a\in X$,  $ b\in X$ ''and '' $ \langle  a,b\rangle  \in  r$ ''   shows '' $ a \in  Interval(r,a,b)$,  $ b \in  Interval(r,a,b)$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>refl_def</nowiki> ,  +++^[Order_ZF_2_L1 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L1</nowiki>:  '' shows '' $ x \in  Interval(r,a,b) \longleftrightarrow  \langle  a,x\rangle  \in  r \wedge  \langle  x,b\rangle  \in  r$
=== 

Under the assumptions of //Order_ZF_2_L2//, the interval is nonempty.

 ''lemma''  <nowiki>Order_ZF_2_L2A</nowiki>:
 ''   assumes '' $ refl(X,r)$ ''and '' $ a\in X$,  $ b\in X$ ''and '' $ \langle  a,b\rangle  \in  r$ ''   shows '' $ Interval(r,a,b) \neq  0$+++[proof ]>
 ''from '' assms  ''have''  $ a \in  Interval(r,a,b)$ ''using''  +++^[Order_ZF_2_L2 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L2</nowiki>:  ''assumes '' $ refl(X,r)$  ''and'' $ a\in X$,   $ b\in X$  ''and'' $ \langle  a,b\rangle  \in  r$  '' shows '' $ a \in  Interval(r,a,b)$,   $ b \in  Interval(r,a,b)$ === 
 ''then ''  ''show''  $ Interval(r,a,b) \neq  0$ 
 ''qed'' === 

If $a,b,c,d$ are in this order, then $[b,c]\subseteq [a,d]$. We only need trasitivity for this to be true.

 ''lemma''  <nowiki>Order_ZF_2_L3</nowiki>:
 ''   assumes '' A1: $ trans(r)$ ''and '' A2: $ \langle  a,b\rangle \in r$,  $ \langle  b,c\rangle \in r$,  $ \langle  c,d\rangle \in r$ ''   shows '' $ Interval(r,b,c) \subseteq  Interval(r,a,d)$+++[proof ]>
 ''fix '' $ x$
 ''assume '' A3: $ x \in  Interval(r, b, c)$
 ''note '' A1
 ''moreover''   ''from '' A2, A3  ''have''  $ \langle  a,b\rangle  \in  r \wedge  \langle  b,x\rangle  \in  r$ ''using''  +++^[Order_ZF_2_L1A | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L1A</nowiki>:  ''assumes '' $ x \in  Interval(r,a,b)$  '' shows '' $ \langle  a,x\rangle  \in  r$,   $ \langle  x,b\rangle  \in  r$ === 
 ''ultimately ''  ''have''  T1: $ \langle  a,x\rangle  \in  r$ ''   by (rule '' +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ ===  '')'' 
 ''note '' A1
 ''moreover''   ''from '' A2, A3  ''have''  $ \langle  x,c\rangle  \in  r \wedge  \langle  c,d\rangle  \in  r$ ''using''  +++^[Order_ZF_2_L1A | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L1A</nowiki>:  ''assumes '' $ x \in  Interval(r,a,b)$  '' shows '' $ \langle  a,x\rangle  \in  r$,   $ \langle  x,b\rangle  \in  r$ === 
 ''ultimately ''  ''have''  $ \langle  x,d\rangle  \in  r$ ''   by (rule '' +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ ===  '')'' 
 ''with '' T1  ''show''  $ x \in  Interval(r,a,d)$ ''using''  +++^[Order_ZF_2_L1B | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L1B</nowiki>:  ''assumes '' $ \langle  a,x\rangle  \in  r$,   $ \langle  x,b\rangle  \in  r$  '' shows '' $ x \in  Interval(r,a,b)$ === 
 ''qed'' === 

For reflexive and antisymmetric relations the interval with equal endpoints consists only of that endpoint.

 ''lemma''  <nowiki>Order_ZF_2_L4</nowiki>:
 ''   assumes '' A1: $ refl(X,r)$ ''and '' A2: $ antisym(r)$ ''and '' A3: $ a\in X$ ''   shows '' $ Interval(r,a,a) = \{a\}$+++[proof ]>
 ''from '' A1, A3  ''have''  $ \langle  a,a\rangle  \in  r$ ''using''  <nowiki>refl_def</nowiki>
 ''with '' A1, A3  ''show''  $ \{a\} \subseteq  Interval(r,a,a)$ ''using''  +++^[Order_ZF_2_L2 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L2</nowiki>:  ''assumes '' $ refl(X,r)$  ''and'' $ a\in X$,   $ b\in X$  ''and'' $ \langle  a,b\rangle  \in  r$  '' shows '' $ a \in  Interval(r,a,b)$,   $ b \in  Interval(r,a,b)$ === 
 ''from '' A2  ''show''  $ Interval(r,a,a) \subseteq  \{a\}$ ''using''  +++^[Order_ZF_2_L1A | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L1A</nowiki>:  ''assumes '' $ x \in  Interval(r,a,b)$  '' shows '' $ \langle  a,x\rangle  \in  r$,   $ \langle  x,b\rangle  \in  r$ ===  ,  +++^[Fol1_L4 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L4</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ \langle  a,b\rangle  \in  r$,   $ \langle  b,a\rangle  \in  r$  '' shows '' $ a=b$ === 
 ''qed'' === 

For transitive relations the endpoints have to be in the relation for the interval to be nonempty.

 ''lemma''  <nowiki>Order_ZF_2_L5</nowiki>:
 ''   assumes '' A1: $ trans(r)$ ''and '' A2: $ \langle  a,b\rangle  \notin  r$ ''   shows '' $ Interval(r,a,b) = 0$+++[proof ]>
++++[{ ]>
 ''assume '' $ Interval(r,a,b)\neq 0$
 ''then ''  ''obtain '' $ x$ ''where '' $ x \in  Interval(r,a,b)$ 
 ''with '' A1, A2  ''have''  $ False$ ''using''  +++^[Order_ZF_2_L1A | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L1A</nowiki>:  ''assumes '' $ x \in  Interval(r,a,b)$  '' shows '' $ \langle  a,x\rangle  \in  r$,   $ \langle  x,b\rangle  \in  r$ ===  ,  +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ === 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 

If a relation is defined on a set, then intervals are subsets of that set.

 ''lemma''  <nowiki>Order_ZF_2_L6</nowiki>:
 ''   assumes '' A1: $ r \subseteq  X\times X$ ''   shows '' $ Interval(r,a,b) \subseteq  X$ ''using''  <nowiki>assms</nowiki> ,  +++^[Interval_def | Order_ZF ]... Definition of <nowiki>Interval</nowiki>:
$ Interval(r,a,b) \equiv  r\{a\} \cap  r^{-1}\{b\}$=== 


!Bounded sets

In this section we consider properties of bounded sets.

For reflexive relations singletons are bounded.

 ''lemma''  <nowiki>Order_ZF_3_L1</nowiki>:
 ''   assumes '' $ refl(X,r)$ ''and '' $ a\in X$ ''   shows '' $ IsBounded(\{a\},r)$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>refl_def</nowiki> ,  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$===  ,  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$===  ,  +++^[IsBounded_def | Order_ZF ]... Definition of <nowiki>IsBounded</nowiki>:
$ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$=== 

Sets that are bounded above are contained in the domain of the relation.

 ''lemma''  <nowiki>Order_ZF_3_L1A</nowiki>:
 ''   assumes '' $ r \subseteq  X\times X$ ''and '' $ IsBoundedAbove(A,r)$ ''   shows '' $ A\subseteq X$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 

Sets that are bounded below are contained in the domain of the relation.

 ''lemma''  <nowiki>Order_ZF_3_L1B</nowiki>:
 ''   assumes '' $ r \subseteq  X\times X$ ''and '' $ IsBoundedBelow(A,r)$ ''   shows '' $ A\subseteq X$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$=== 

For a total relation, the greater of two elements, as defined above, is indeed greater of any of the two.

 ''lemma''  <nowiki>Order_ZF_3_L2</nowiki>:
 ''   assumes '' $ r \text{ is total on } X$ ''and '' $ x\in X$,  $ y\in X$ ''   shows '' $ \langle x,GreaterOf(r,x,y)\rangle  \in  r$,  $ \langle y,GreaterOf(r,x,y)\rangle  \in  r$,  $ \langle SmallerOf(r,x,y),x\rangle  \in  r$,  $ \langle SmallerOf(r,x,y),y\rangle  \in  r$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsTotal_def | Order_ZF ]... Definition of <nowiki>IsTotal</nowiki>:
$ r \text{ is total on } X \equiv  (\forall a\in X.\ \forall b\in X.\  \langle  a,b\rangle  \in  r \vee  \langle  b,a\rangle  \in  r)$===  ,  +++^[Order_ZF_1_L1 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_1_L1</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ a\in X$  '' shows '' $ \langle a,a\rangle  \in  r$ ===  ,  +++^[GreaterOf_def | Order_ZF ]... Definition of <nowiki>GreaterOf</nowiki>:
$ GreaterOf(r,a,b) \equiv  (if \langle  a,b\rangle  \in  r then b else a)$===  ,  +++^[SmallerOf_def | Order_ZF ]... Definition of <nowiki>SmallerOf</nowiki>:
$ SmallerOf(r,a,b) \equiv  (if \langle  a,b\rangle  \in  r then a else b)$=== 

If $A$ is bounded above by $u$, $B$ is bounded above by $w$, then $A\cup B$ is bounded above by the greater of $u,w$.

 ''lemma''  <nowiki>Order_ZF_3_L2B</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ u\in X$,  $ w\in X$ ''and '' A4: $ \forall x\in A.\  \langle  x,u\rangle  \in  r$,  $ \forall x\in B.\  \langle  x,w\rangle  \in  r$ ''   shows '' $ \forall x\in A\cup B.\  \langle x,GreaterOf(r,u,w)\rangle  \in  r$+++[proof ]>
 ''let '' $ v = GreaterOf(r,u,w)$
 ''from '' A1, A3  ''have''  T1: $ \langle  u,v\rangle  \in  r$ ''and '' T2: $ \langle  w,v\rangle  \in  r$ ''using''  +++^[Order_ZF_3_L2 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L2</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ x\in X$,   $ y\in X$  '' shows '' $ \langle x,GreaterOf(r,x,y)\rangle  \in  r$,   $ \langle y,GreaterOf(r,x,y)\rangle  \in  r$,  
$ \langle SmallerOf(r,x,y),x\rangle  \in  r$,   $ \langle SmallerOf(r,x,y),y\rangle  \in  r$ === 
 ''fix '' $ x$
 ''assume '' A5: $ x\in A\cup B$
 ''show''  $ \langle x,v\rangle  \in  r$+++[proof ]>
++++[{ ]>
 ''assume '' $ x\in A$
 ''with '' A4, T1  ''have''  $ \langle  x,u\rangle  \in  r \wedge  \langle  u,v\rangle  \in  r$ 
 ''with '' A2  ''have''  $ \langle x,v\rangle  \in  r$ ''   by (rule '' +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ ===  '')'' 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ x\notin A$
 ''with '' A5, A4, T2  ''have''  $ \langle  x,w\rangle  \in  r \wedge  \langle  w,v\rangle  \in  r$ 
 ''with '' A2  ''have''  $ \langle x,v\rangle  \in  r$ ''   by (rule '' +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ ===  '')'' 
===  ''}'' 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 
 ''qed'' === 

For total and transitive relation the union of two sets bounded above is bounded above.

 ''lemma''  <nowiki>Order_ZF_3_L3</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ IsBoundedAbove(A,r)$,  $ IsBoundedAbove(B,r)$ ''and '' A4: $ r \subseteq  X\times X$ ''   shows '' $ IsBoundedAbove(A\cup B,r)$+++[proof ]>
++++[{ ]>
 ''assume '' $ A=0 \vee  B=0$
 ''with '' A3  ''have''  $ IsBoundedAbove(A\cup B,r)$ 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ \neg  (A = 0 \vee  B = 0)$
 ''then ''  ''have''  T1: $ A\neq 0$,  $ B\neq 0$ 
 ''with '' A3  ''obtain '' $ u$ $ w$ ''where '' D1: $ \forall x\in A.\  \langle  x,u\rangle  \in  r$,  $ \forall x\in B.\  \langle  x,w\rangle  \in  r$ ''using''  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 
 ''let '' $ U = GreaterOf(r,u,w)$
 ''from '' T1, A4, D1  ''have''  $ u\in X$,  $ w\in X$ 
 ''with '' A1, A2, D1  ''have''  $ \forall x\in A\cup B.\ \langle  x,U\rangle  \in  r$ ''using''  +++^[Order_ZF_3_L2B | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L2B</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ u\in X$,   $ w\in X$  ''and'' $ \forall x\in A.\  \langle  x,u\rangle  \in  r$,   $ \forall x\in B.\  \langle  x,w\rangle  \in  r$  '' shows '' $ \forall x\in A\cup B.\  \langle x,GreaterOf(r,u,w)\rangle  \in  r$ === 
 ''then ''  ''have''  $ IsBoundedAbove(A\cup B,r)$ ''using''  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 
===  ''}'' 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

For total and transitive relations if a set $A$ is bounded above then $A\cup \{a\}$ is bounded above.

 ''lemma''  <nowiki>Order_ZF_3_L4</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ IsBoundedAbove(A,r)$ ''and '' A4: $ a\in X$ ''and '' A5: $ r \subseteq  X\times X$ ''   shows '' $ IsBoundedAbove(A\cup \{a\},r)$+++[proof ]>
 ''from '' A1  ''have''  $ refl(X,r)$ ''using''  +++^[total_is_refl | Order_ZF ]...  ''lemma''  <nowiki>total_is_refl</nowiki>:  ''assumes '' $ r \text{ is total on } X$  '' shows '' $ refl(X,r)$ === 
 ''with '' assms  ''show''  $ thesis$ ''using''  +++^[Order_ZF_3_L1 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L1</nowiki>:  ''assumes '' $ refl(X,r)$  ''and'' $ a\in X$  '' shows '' $ IsBounded(\{a\},r)$ ===  ,  +++^[IsBounded_def | Order_ZF ]... Definition of <nowiki>IsBounded</nowiki>:
$ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$===  ,  +++^[Order_ZF_3_L3 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L3</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ IsBoundedAbove(A,r)$,   $ IsBoundedAbove(B,r)$  ''and'' $ r \subseteq  X\times X$  '' shows '' $ IsBoundedAbove(A\cup B,r)$ === 
 ''qed'' === 

If $A$ is bounded below by $l$, $B$ is bounded below by $m$, then $A\cup B$ is bounded below by the smaller of $u,w$.

 ''lemma''  <nowiki>Order_ZF_3_L5B</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ l\in X$,  $ m\in X$ ''and '' A4: $ \forall x\in A.\  \langle  l,x\rangle  \in  r$,  $ \forall x\in B.\  \langle  m,x\rangle  \in  r$ ''   shows '' $ \forall x\in A\cup B.\  \langle SmallerOf(r,l,m),x\rangle  \in  r$+++[proof ]>
 ''let '' $ k = SmallerOf(r,l,m)$
 ''from '' A1, A3  ''have''  T1: $ \langle  k,l\rangle  \in  r$ ''and '' T2: $ \langle  k,m\rangle  \in  r$ ''using''  +++^[Order_ZF_3_L2 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L2</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ x\in X$,   $ y\in X$  '' shows '' $ \langle x,GreaterOf(r,x,y)\rangle  \in  r$,   $ \langle y,GreaterOf(r,x,y)\rangle  \in  r$,  
$ \langle SmallerOf(r,x,y),x\rangle  \in  r$,   $ \langle SmallerOf(r,x,y),y\rangle  \in  r$ === 
 ''fix '' $ x$
 ''assume '' A5: $ x\in A\cup B$
 ''show''  $ \langle k,x\rangle  \in  r$+++[proof ]>
++++[{ ]>
 ''assume '' $ x\in A$
 ''with '' A4, T1  ''have''  $ \langle  k,l\rangle  \in  r \wedge  \langle  l,x\rangle  \in  r$ 
 ''with '' A2  ''have''  $ \langle k,x\rangle  \in  r$ ''   by (rule '' +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ ===  '')'' 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ x\notin A$
 ''with '' A5, A4, T2  ''have''  $ \langle  k,m\rangle  \in  r \wedge  \langle  m,x\rangle  \in  r$ 
 ''with '' A2  ''have''  $ \langle k,x\rangle  \in  r$ ''   by (rule '' +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ ===  '')'' 
===  ''}'' 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 
 ''qed'' === 

For total and transitive relation the union of two sets bounded below is bounded below.

 ''lemma''  <nowiki>Order_ZF_3_L6</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ IsBoundedBelow(A,r)$,  $ IsBoundedBelow(B,r)$ ''and '' A4: $ r \subseteq  X\times X$ ''   shows '' $ IsBoundedBelow(A\cup B,r)$+++[proof ]>
++++[{ ]>
 ''assume '' $ A=0 \vee  B=0$
 ''with '' A3  ''have''  $ thesis$ 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ \neg  (A = 0 \vee  B = 0)$
 ''then ''  ''have''  T1: $ A\neq 0$,  $ B\neq 0$ 
 ''with '' A3  ''obtain '' $ l$ $ m$ ''where '' D1: $ \forall x\in A.\  \langle  l,x\rangle  \in  r$,  $ \forall x\in B.\  \langle  m,x\rangle  \in  r$ ''using''  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$=== 
 ''let '' $ L = SmallerOf(r,l,m)$
 ''from '' T1, A4, D1  ''have''  T1: $ l\in X$,  $ m\in X$ 
 ''with '' A1, A2, D1  ''have''  $ \forall x\in A\cup B.\ \langle  L,x\rangle  \in  r$ ''using''  +++^[Order_ZF_3_L5B | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L5B</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ l\in X$,   $ m\in X$  ''and'' $ \forall x\in A.\  \langle  l,x\rangle  \in  r$,   $ \forall x\in B.\  \langle  m,x\rangle  \in  r$  '' shows '' $ \forall x\in A\cup B.\  \langle SmallerOf(r,l,m),x\rangle  \in  r$ === 
 ''then ''  ''have''  $ IsBoundedBelow(A\cup B,r)$ ''using''  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$=== 
===  ''}'' 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

For total and transitive relations if a set $A$ is bounded below then $A\cup \{a\}$ is bounded below.

 ''lemma''  <nowiki>Order_ZF_3_L7</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ IsBoundedBelow(A,r)$ ''and '' A4: $ a\in X$ ''and '' A5: $ r \subseteq  X\times X$ ''   shows '' $ IsBoundedBelow(A\cup \{a\},r)$+++[proof ]>
 ''from '' A1  ''have''  $ refl(X,r)$ ''using''  +++^[total_is_refl | Order_ZF ]...  ''lemma''  <nowiki>total_is_refl</nowiki>:  ''assumes '' $ r \text{ is total on } X$  '' shows '' $ refl(X,r)$ === 
 ''with '' assms  ''show''  $ thesis$ ''using''  +++^[Order_ZF_3_L1 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L1</nowiki>:  ''assumes '' $ refl(X,r)$  ''and'' $ a\in X$  '' shows '' $ IsBounded(\{a\},r)$ ===  ,  +++^[IsBounded_def | Order_ZF ]... Definition of <nowiki>IsBounded</nowiki>:
$ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$===  ,  +++^[Order_ZF_3_L6 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L6</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ IsBoundedBelow(A,r)$,   $ IsBoundedBelow(B,r)$  ''and'' $ r \subseteq  X\times X$  '' shows '' $ IsBoundedBelow(A\cup B,r)$ === 
 ''qed'' === 

For total and transitive relations unions of two bounded sets are bounded.

 ''theorem''  <nowiki>Order_ZF_3_T1</nowiki>:
 ''   assumes '' $ r \text{ is total on } X$ ''and '' $ trans(r)$ ''and '' $ IsBounded(A,r)$,  $ IsBounded(B,r)$ ''and '' $ r \subseteq  X\times X$ ''   shows '' $ IsBounded(A\cup B,r)$ ''using''  <nowiki>assms</nowiki> ,  +++^[Order_ZF_3_L3 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L3</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ IsBoundedAbove(A,r)$,   $ IsBoundedAbove(B,r)$  ''and'' $ r \subseteq  X\times X$  '' shows '' $ IsBoundedAbove(A\cup B,r)$ ===  ,  +++^[Order_ZF_3_L6 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L6</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ IsBoundedBelow(A,r)$,   $ IsBoundedBelow(B,r)$  ''and'' $ r \subseteq  X\times X$  '' shows '' $ IsBoundedBelow(A\cup B,r)$ ===  ,  +++^[Order_ZF_3_L7 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L7</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ IsBoundedBelow(A,r)$  ''and'' $ a\in X$  ''and'' $ r \subseteq  X\times X$  '' shows '' $ IsBoundedBelow(A\cup \{a\},r)$ ===  ,  +++^[IsBounded_def | Order_ZF ]... Definition of <nowiki>IsBounded</nowiki>:
$ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$=== 

For total and transitive relations if a set $A$ is bounded then $A\cup \{a\}$ is bounded.

 ''lemma''  <nowiki>Order_ZF_3_L8</nowiki>:
 ''   assumes '' $ r \text{ is total on } X$ ''and '' $ trans(r)$ ''and '' $ IsBounded(A,r)$ ''and '' $ a\in X$ ''and '' $ r \subseteq  X\times X$ ''   shows '' $ IsBounded(A\cup \{a\},r)$ ''using''  <nowiki>assms</nowiki> ,  +++^[total_is_refl | Order_ZF ]...  ''lemma''  <nowiki>total_is_refl</nowiki>:  ''assumes '' $ r \text{ is total on } X$  '' shows '' $ refl(X,r)$ ===  ,  +++^[Order_ZF_3_L1 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L1</nowiki>:  ''assumes '' $ refl(X,r)$  ''and'' $ a\in X$  '' shows '' $ IsBounded(\{a\},r)$ ===  ,  +++^[Order_ZF_3_T1 | Order_ZF ]...  ''theorem''  <nowiki>Order_ZF_3_T1</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ IsBounded(A,r)$,   $ IsBounded(B,r)$  ''and'' $ r \subseteq  X\times X$  '' shows '' $ IsBounded(A\cup B,r)$ === 

A sufficient condition for a set to be bounded below.

 ''lemma''  <nowiki>Order_ZF_3_L9</nowiki>:
 ''   assumes '' A1: $ \forall a\in A.\  \langle l,a\rangle  \in  r$ ''   shows '' $ IsBoundedBelow(A,r)$+++[proof ]>
 ''from '' A1  ''have''  $ \exists l.\  \forall x\in A.\  \langle l,x\rangle  \in  r$ 
 ''then ''  ''show''  $ IsBoundedBelow(A,r)$ ''using''  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$=== 
 ''qed'' === 

A sufficient condition for a set to be bounded above.

 ''lemma''  <nowiki>Order_ZF_3_L10</nowiki>:
 ''   assumes '' A1: $ \forall a\in A.\  \langle a,u\rangle  \in  r$ ''   shows '' $ IsBoundedAbove(A,r)$+++[proof ]>
 ''from '' A1  ''have''  $ \exists u.\  \forall x\in A.\  \langle x,u\rangle  \in  r$ 
 ''then ''  ''show''  $ IsBoundedAbove(A,r)$ ''using''  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 
 ''qed'' === 

Intervals are bounded.

 ''lemma''  <nowiki>Order_ZF_3_L11</nowiki>:
 ''   shows '' $ IsBoundedAbove(Interval(r,a,b),r)$,  $ IsBoundedBelow(Interval(r,a,b),r)$,  $ IsBounded(Interval(r,a,b),r)$+++[proof ]>
++++[{ ]>
 ''fix '' $ x$
 ''assume '' $ x \in  Interval(r,a,b)$
 ''then ''  ''have''  $ \langle  x,b\rangle  \in  r$,  $ \langle  a,x\rangle  \in  r$ ''using''  +++^[Order_ZF_2_L1A | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_2_L1A</nowiki>:  ''assumes '' $ x \in  Interval(r,a,b)$  '' shows '' $ \langle  a,x\rangle  \in  r$,   $ \langle  x,b\rangle  \in  r$ === 
===  ''}'' 
 ''then ''  ''have''  $ \exists u.\  \forall x\in Interval(r,a,b).\  \langle  x,u\rangle  \in  r$,  $ \exists l.\  \forall x\in Interval(r,a,b).\  \langle  l,x\rangle  \in  r$ 
 ''then ''  ''show''  $ IsBoundedAbove(Interval(r,a,b),r)$,  $ IsBoundedBelow(Interval(r,a,b),r)$,  $ IsBounded(Interval(r,a,b),r)$ ''using''  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$===  ,  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$===  ,  +++^[IsBounded_def | Order_ZF ]... Definition of <nowiki>IsBounded</nowiki>:
$ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$=== 
 ''qed'' === 

A subset of a set that is bounded below is bounded below.

 ''lemma''  <nowiki>Order_ZF_3_L12</nowiki>:
 ''   assumes '' A1: $ IsBoundedBelow(A,r)$ ''and '' A2: $ B\subseteq A$ ''   shows '' $ IsBoundedBelow(B,r)$+++[proof ]>
++++[{ ]>
 ''assume '' $ A = 0$
 ''with '' assms  ''have''  $ IsBoundedBelow(B,r)$ ''using''  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$=== 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ A \neq  0$
 ''with '' A1  ''have''  $ \exists l.\  \forall x\in A.\  \langle l,x\rangle  \in  r$ ''using''  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$=== 
 ''with '' A2  ''have''  $ \exists l.\ \forall x\in B.\  \langle l,x\rangle  \in  r$ 
 ''then ''  ''have''  $ IsBoundedBelow(B,r)$ ''using''  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$=== 
===  ''}'' 
 ''ultimately ''  ''show''  $ IsBoundedBelow(B,r)$ 
 ''qed'' === 

A subset of a set that is bounded above is bounded above.

 ''lemma''  <nowiki>Order_ZF_3_L13</nowiki>:
 ''   assumes '' A1: $ IsBoundedAbove(A,r)$ ''and '' A2: $ B\subseteq A$ ''   shows '' $ IsBoundedAbove(B,r)$+++[proof ]>
++++[{ ]>
 ''assume '' $ A = 0$
 ''with '' assms  ''have''  $ IsBoundedAbove(B,r)$ ''using''  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ A \neq  0$
 ''with '' A1  ''have''  $ \exists u.\  \forall x\in A.\  \langle x,u\rangle  \in  r$ ''using''  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 
 ''with '' A2  ''have''  $ \exists u.\ \forall x\in B.\  \langle x,u\rangle  \in  r$ 
 ''then ''  ''have''  $ IsBoundedAbove(B,r)$ ''using''  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 
===  ''}'' 
 ''ultimately ''  ''show''  $ IsBoundedAbove(B,r)$ 
 ''qed'' === 

If for every element of $X$ we can find one in $A$ that is greater, then the $A$ can not be bounded above. Works for relations that are total, transitive and antisymmetric, (i.e. for linear order relations).

 ''lemma''  <nowiki>Order_ZF_3_L14</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ antisym(r)$ ''and '' A4: $ r \subseteq  X\times X$ ''and '' A5: $ X\neq 0$ ''and '' A6: $ \forall x\in X.\  \exists a\in A.\  x\neq a \wedge  \langle x,a\rangle  \in  r$ ''   shows '' $ \neg IsBoundedAbove(A,r)$+++[proof ]>
++++[{ ]>
 ''from '' A5, A6  ''have''  I: $ A\neq 0$ 
 ''moreover''   ''assume '' $ IsBoundedAbove(A,r)$
 ''ultimately ''  ''obtain '' $ u$ ''where '' II: $ \forall x\in A.\  \langle  x,u\rangle  \in  r$ ''using''  +++^[IsBounded_def | Order_ZF ]... Definition of <nowiki>IsBounded</nowiki>:
$ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$===  ,  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 
 ''with '' A4, I  ''have''  $ u\in X$ 
 ''with '' A6  ''obtain '' $ b$ ''where '' $ b\in A$ ''and '' III: $ u\neq b$ ''and '' $ \langle u,b\rangle  \in  r$ 
 ''with '' II  ''have''  $ \langle b,u\rangle  \in  r$,  $ \langle u,b\rangle  \in  r$ 
 ''with '' A3  ''have''  $ b=u$ ''   by (rule '' +++^[Fol1_L4 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L4</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ \langle  a,b\rangle  \in  r$,   $ \langle  b,a\rangle  \in  r$  '' shows '' $ a=b$ ===  '')'' 
 ''with '' III  ''have''  $ False$ 
===  ''}'' 
 ''thus''  $ \neg IsBoundedAbove(A,r)$
 ''qed'' === 

The set of elements in a set $A$ that are nongreater than a given element is bounded above.

 ''lemma''  <nowiki>Order_ZF_3_L15</nowiki>:
 ''   shows '' $ IsBoundedAbove(\{x\in A.\  \langle x,a\rangle  \in  r\},r)$ ''using''  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 

If $A$ is bounded below, then the set of elements in a set $A$ that are nongreater than a given element is bounded.

 ''lemma''  <nowiki>Order_ZF_3_L16</nowiki>:
 ''   assumes '' A1: $ IsBoundedBelow(A,r)$ ''   shows '' $ IsBounded(\{x\in A.\  \langle x,a\rangle  \in  r\},r)$+++[proof ]>
++++[{ ]>
 ''assume '' $ A=0$
 ''then ''  ''have''  $ IsBounded(\{x\in A.\  \langle x,a\rangle  \in  r\},r)$ ''using''  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$===  ,  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$===  ,  +++^[IsBounded_def | Order_ZF ]... Definition of <nowiki>IsBounded</nowiki>:
$ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$=== 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ A\neq 0$
 ''with '' A1  ''obtain '' $ l$ ''where '' I: $ \forall x\in A.\  \langle l,x\rangle  \in  r$ ''using''  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$=== 
 ''then ''  ''have''  $ \forall y\in \{x\in A.\  \langle x,a\rangle  \in  r\}.\  \langle l,y\rangle  \in  r$ 
 ''then ''  ''have''  $ IsBoundedBelow(\{x\in A.\  \langle x,a\rangle  \in  r\},r)$ ''   by (rule '' +++^[Order_ZF_3_L9 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L9</nowiki>:  ''assumes '' $ \forall a\in A.\  \langle l,a\rangle  \in  r$  '' shows '' $ IsBoundedBelow(A,r)$ ===  '')'' 
 ''then ''  ''have''  $ IsBounded(\{x\in A.\  \langle x,a\rangle  \in  r\},r)$ ''using''  +++^[Order_ZF_3_L15 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L15</nowiki>:  '' shows '' $ IsBoundedAbove(\{x\in A.\  \langle x,a\rangle  \in  r\},r)$ ===  ,  +++^[IsBounded_def | Order_ZF ]... Definition of <nowiki>IsBounded</nowiki>:
$ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$=== 
===  ''}'' 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

 ''end

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

 ''begin
'' 
This theory is a continuation of //Order_ZF// and talks about maximuma and minimum of a set, supremum and infimum and strict (not reflexive) versions of order relations.

!Maximum and minimum of a set

In this section we show that maximum and minimum are unique if they exist. We also show that union of sets that have maxima (minima) has a maximum (minimum). We also show that singletons have maximum and minimum. All this allows to show (in //Finite_ZF//) that every finite set has well-defined maximum and minimum.

For antisymmetric relations maximum of a set is unique if it exists.

 ''lemma''  <nowiki>Order_ZF_4_L1</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ HasAmaximum(r,A)$ ''   shows '' $ \exists !M.\  M\in A \wedge  (\forall x\in A.\  \langle  x,M\rangle  \in  r)$+++[proof ]>
 ''from '' A2  ''show''  $ \exists M.\  M \in  A \wedge  (\forall x\in A.\  \langle x, M\rangle  \in  r)$ ''using''  +++^[HasAmaximum_def | Order_ZF ]... Definition of <nowiki>HasAmaximum</nowiki>:
$ HasAmaximum(r,A) \equiv  \exists M\in A.\ \forall x\in A.\  \langle  x,M\rangle  \in  r$=== 
 ''fix '' $ M1$ $ M2$
 ''assume '' A2: $ M1 \in  A \wedge  (\forall x\in A.\  \langle x, M1\rangle  \in  r)$,  $ M2 \in  A \wedge  (\forall x\in A.\  \langle x, M2\rangle  \in  r)$
 ''then ''  ''have''  $ \langle M1,M2\rangle  \in  r$,  $ \langle M2,M1\rangle  \in  r$ 
 ''with '' A1  ''show''  $ M1=M2$ ''   by (rule '' +++^[Fol1_L4 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L4</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ \langle  a,b\rangle  \in  r$,   $ \langle  b,a\rangle  \in  r$  '' shows '' $ a=b$ ===  '')'' 
 ''qed'' === 

For antisymmetric relations minimum of a set is unique if it exists.

 ''lemma''  <nowiki>Order_ZF_4_L2</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ HasAminimum(r,A)$ ''   shows '' $ \exists !m.\  m\in A \wedge  (\forall x\in A.\  \langle  m,x\rangle  \in  r)$+++[proof ]>
 ''from '' A2  ''show''  $ \exists m.\  m \in  A \wedge  (\forall x\in A.\  \langle m, x\rangle  \in  r)$ ''using''  +++^[HasAminimum_def | Order_ZF ]... Definition of <nowiki>HasAminimum</nowiki>:
$ HasAminimum(r,A) \equiv  \exists m\in A.\ \forall x\in A.\  \langle  m,x\rangle  \in  r$=== 
 ''fix '' $ m1$ $ m2$
 ''assume '' A2: $ m1 \in  A \wedge  (\forall x\in A.\  \langle m1, x\rangle  \in  r)$,  $ m2 \in  A \wedge  (\forall x\in A.\  \langle m2, x\rangle  \in  r)$
 ''then ''  ''have''  $ \langle m1,m2\rangle  \in  r$,  $ \langle m2,m1\rangle  \in  r$ 
 ''with '' A1  ''show''  $ m1=m2$ ''   by (rule '' +++^[Fol1_L4 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L4</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ \langle  a,b\rangle  \in  r$,   $ \langle  b,a\rangle  \in  r$  '' shows '' $ a=b$ ===  '')'' 
 ''qed'' === 

Maximum of a set has desired properties.

 ''lemma''  <nowiki>Order_ZF_4_L3</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ HasAmaximum(r,A)$ ''   shows '' $ Maximum(r,A) \in  A$,  $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$+++[proof ]>
 ''let '' $ Max = \text{The } M.\  M\in A \wedge  (\forall x\in A.\  \langle  x,M\rangle  \in  r)$
 ''from '' A1, A2  ''have''  $ \exists !M.\  M\in A \wedge  (\forall x\in A.\  \langle  x,M\rangle  \in  r)$ ''   by (rule '' +++^[Order_ZF_4_L1 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L1</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ \exists !M.\  M\in A \wedge  (\forall x\in A.\  \langle  x,M\rangle  \in  r)$ ===  '')'' 
 ''then ''  ''have''  $ Max \in  A \wedge  (\forall x\in A.\  \langle  x,Max\rangle  \in  r)$ ''   by (rule '' <nowiki>theI</nowiki> '')'' 
 ''then ''  ''show''  $ Maximum(r,A) \in  A$,  $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$ ''using''  +++^[Maximum_def | Order_ZF ]... Definition of <nowiki>Maximum</nowiki>:
$ Maximum(r,A) \equiv  \text{The } M.\  M\in A \wedge  (\forall x\in A.\  \langle  x,M\rangle  \in  r)$=== 
 ''qed'' === 

Minimum of a set has desired properties.

 ''lemma''  <nowiki>Order_ZF_4_L4</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ HasAminimum(r,A)$ ''   shows '' $ Minimum(r,A) \in  A$,  $ \forall x\in A.\  \langle Minimum(r,A),x\rangle  \in  r$+++[proof ]>
 ''let '' $ Min = \text{The } m.\  m\in A \wedge  (\forall x\in A.\  \langle  m,x\rangle  \in  r)$
 ''from '' A1, A2  ''have''  $ \exists !m.\  m\in A \wedge  (\forall x\in A.\  \langle  m,x\rangle  \in  r)$ ''   by (rule '' +++^[Order_ZF_4_L2 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L2</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAminimum(r,A)$  '' shows '' $ \exists !m.\  m\in A \wedge  (\forall x\in A.\  \langle  m,x\rangle  \in  r)$ ===  '')'' 
 ''then ''  ''have''  $ Min \in  A \wedge  (\forall x\in A.\  \langle  Min,x\rangle  \in  r)$ ''   by (rule '' <nowiki>theI</nowiki> '')'' 
 ''then ''  ''show''  $ Minimum(r,A) \in  A$,  $ \forall x\in A.\  \langle Minimum(r,A),x\rangle  \in  r$ ''using''  +++^[Minimum_def | Order_ZF ]... Definition of <nowiki>Minimum</nowiki>:
$ Minimum(r,A) \equiv  \text{The } m.\  m\in A \wedge  (\forall x\in A.\  \langle  m,x\rangle  \in  r)$=== 
 ''qed'' === 

For total and transitive relations a union a of two sets that have maxima has a maximum.

 ''lemma''  <nowiki>Order_ZF_4_L5</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } (A\cup B)$ ''and '' A2: $ trans(r)$ ''and '' A3: $ HasAmaximum(r,A)$,  $ HasAmaximum(r,B)$ ''   shows '' $ HasAmaximum(r,A\cup B)$+++[proof ]>
 ''from '' A3  ''obtain '' $ M$ $ K$ ''where '' D1: $ M\in A \wedge  (\forall x\in A.\  \langle  x,M\rangle  \in  r)$,  $ K\in B \wedge  (\forall x\in B.\  \langle  x,K\rangle  \in  r)$ ''using''  +++^[HasAmaximum_def | Order_ZF ]... Definition of <nowiki>HasAmaximum</nowiki>:
$ HasAmaximum(r,A) \equiv  \exists M\in A.\ \forall x\in A.\  \langle  x,M\rangle  \in  r$=== 
 ''let '' $ L = GreaterOf(r,M,K)$
 ''from '' D1  ''have''  T1: $ M \in  A\cup B$,  $ K \in  A\cup B$,  $ \forall x\in A.\  \langle  x,M\rangle  \in  r$,  $ \forall x\in B.\  \langle  x,K\rangle  \in  r$ 
 ''with '' A1, A2  ''have''  $ \forall x\in A\cup B.\ \langle  x,L\rangle  \in  r$ ''   by (rule '' +++^[Order_ZF_3_L2B | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L2B</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ u\in X$,   $ w\in X$  ''and'' $ \forall x\in A.\  \langle  x,u\rangle  \in  r$,   $ \forall x\in B.\  \langle  x,w\rangle  \in  r$  '' shows '' $ \forall x\in A\cup B.\  \langle x,GreaterOf(r,u,w)\rangle  \in  r$ ===  '')'' 
 ''moreover''   ''from '' T1  ''have''  $ L \in  A\cup B$ ''using''  +++^[GreaterOf_def | Order_ZF ]... Definition of <nowiki>GreaterOf</nowiki>:
$ GreaterOf(r,a,b) \equiv  (if \langle  a,b\rangle  \in  r then b else a)$===  ,  +++^[IsTotal_def | Order_ZF ]... Definition of <nowiki>IsTotal</nowiki>:
$ r \text{ is total on } X \equiv  (\forall a\in X.\ \forall b\in X.\  \langle  a,b\rangle  \in  r \vee  \langle  b,a\rangle  \in  r)$=== 
 ''ultimately ''  ''show''  $ HasAmaximum(r,A\cup B)$ ''using''  +++^[HasAmaximum_def | Order_ZF ]... Definition of <nowiki>HasAmaximum</nowiki>:
$ HasAmaximum(r,A) \equiv  \exists M\in A.\ \forall x\in A.\  \langle  x,M\rangle  \in  r$=== 
 ''qed'' === 

For total and transitive relations A union a of two sets that have minima has a minimum.

 ''lemma''  <nowiki>Order_ZF_4_L6</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } (A\cup B)$ ''and '' A2: $ trans(r)$ ''and '' A3: $ HasAminimum(r,A)$,  $ HasAminimum(r,B)$ ''   shows '' $ HasAminimum(r,A\cup B)$+++[proof ]>
 ''from '' A3  ''obtain '' $ m$ $ k$ ''where '' D1: $ m\in A \wedge  (\forall x\in A.\  \langle  m,x\rangle  \in  r)$,  $ k\in B \wedge  (\forall x\in B.\  \langle  k,x\rangle  \in  r)$ ''using''  +++^[HasAminimum_def | Order_ZF ]... Definition of <nowiki>HasAminimum</nowiki>:
$ HasAminimum(r,A) \equiv  \exists m\in A.\ \forall x\in A.\  \langle  m,x\rangle  \in  r$=== 
 ''let '' $ l = SmallerOf(r,m,k)$
 ''from '' D1  ''have''  T1: $ m \in  A\cup B$,  $ k \in  A\cup B$,  $ \forall x\in A.\  \langle  m,x\rangle  \in  r$,  $ \forall x\in B.\  \langle  k,x\rangle  \in  r$ 
 ''with '' A1, A2  ''have''  $ \forall x\in A\cup B.\ \langle  l,x\rangle  \in  r$ ''   by (rule '' +++^[Order_ZF_3_L5B | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L5B</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ trans(r)$  ''and'' $ l\in X$,   $ m\in X$  ''and'' $ \forall x\in A.\  \langle  l,x\rangle  \in  r$,   $ \forall x\in B.\  \langle  m,x\rangle  \in  r$  '' shows '' $ \forall x\in A\cup B.\  \langle SmallerOf(r,l,m),x\rangle  \in  r$ ===  '')'' 
 ''moreover''   ''from '' T1  ''have''  $ l \in  A\cup B$ ''using''  +++^[SmallerOf_def | Order_ZF ]... Definition of <nowiki>SmallerOf</nowiki>:
$ SmallerOf(r,a,b) \equiv  (if \langle  a,b\rangle  \in  r then a else b)$===  ,  +++^[IsTotal_def | Order_ZF ]... Definition of <nowiki>IsTotal</nowiki>:
$ r \text{ is total on } X \equiv  (\forall a\in X.\ \forall b\in X.\  \langle  a,b\rangle  \in  r \vee  \langle  b,a\rangle  \in  r)$=== 
 ''ultimately ''  ''show''  $ HasAminimum(r,A\cup B)$ ''using''  +++^[HasAminimum_def | Order_ZF ]... Definition of <nowiki>HasAminimum</nowiki>:
$ HasAminimum(r,A) \equiv  \exists m\in A.\ \forall x\in A.\  \langle  m,x\rangle  \in  r$=== 
 ''qed'' === 

Set that has a maximum is bounded above.

 ''lemma''  <nowiki>Order_ZF_4_L7</nowiki>:
 ''   assumes '' $ HasAmaximum(r,A)$ ''   shows '' $ IsBoundedAbove(A,r)$ ''using''  <nowiki>assms</nowiki> ,  +++^[HasAmaximum_def | Order_ZF ]... Definition of <nowiki>HasAmaximum</nowiki>:
$ HasAmaximum(r,A) \equiv  \exists M\in A.\ \forall x\in A.\  \langle  x,M\rangle  \in  r$===  ,  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 

Set that has a minimum is bounded below.

 ''lemma''  <nowiki>Order_ZF_4_L8A</nowiki>:
 ''   assumes '' $ HasAminimum(r,A)$ ''   shows '' $ IsBoundedBelow(A,r)$ ''using''  <nowiki>assms</nowiki> ,  +++^[HasAminimum_def | Order_ZF ]... Definition of <nowiki>HasAminimum</nowiki>:
$ HasAminimum(r,A) \equiv  \exists m\in A.\ \forall x\in A.\  \langle  m,x\rangle  \in  r$===  ,  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$=== 

For reflexive relations singletons have a minimum and maximum.

 ''lemma''  <nowiki>Order_ZF_4_L8</nowiki>:
 ''   assumes '' $ refl(X,r)$ ''and '' $ a\in X$ ''   shows '' $ HasAmaximum(r,\{a\})$,  $ HasAminimum(r,\{a\})$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>refl_def</nowiki> ,  +++^[HasAmaximum_def | Order_ZF ]... Definition of <nowiki>HasAmaximum</nowiki>:
$ HasAmaximum(r,A) \equiv  \exists M\in A.\ \forall x\in A.\  \langle  x,M\rangle  \in  r$===  ,  +++^[HasAminimum_def | Order_ZF ]... Definition of <nowiki>HasAminimum</nowiki>:
$ HasAminimum(r,A) \equiv  \exists m\in A.\ \forall x\in A.\  \langle  m,x\rangle  \in  r$=== 

For total and transitive relations if we add an element to a set that has a maximum, the set still has a maximum.

 ''lemma''  <nowiki>Order_ZF_4_L9</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ A\subseteq X$ ''and '' A4: $ a\in X$ ''and '' A5: $ HasAmaximum(r,A)$ ''   shows '' $ HasAmaximum(r,A\cup \{a\})$+++[proof ]>
 ''from '' A3, A4  ''have''  $ A\cup \{a\} \subseteq  X$ 
 ''with '' A1  ''have''  $ r \text{ is total on } (A\cup \{a\})$ ''using''  +++^[Order_ZF_1_L4 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_1_L4</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ A\subseteq X$  '' shows '' $ r \text{ is total on } A$ === 
 ''moreover''   ''from '' A1, A2, A4, A5  ''have''  $ trans(r)$,  $ HasAmaximum(r,A)$ 
 ''moreover''   ''from '' A1, A4  ''have''  $ HasAmaximum(r,\{a\})$ ''using''  +++^[total_is_refl | Order_ZF ]...  ''lemma''  <nowiki>total_is_refl</nowiki>:  ''assumes '' $ r \text{ is total on } X$  '' shows '' $ refl(X,r)$ ===  ,  +++^[Order_ZF_4_L8 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L8</nowiki>:  ''assumes '' $ refl(X,r)$  ''and'' $ a\in X$  '' shows '' $ HasAmaximum(r,\{a\})$,   $ HasAminimum(r,\{a\})$ === 
 ''ultimately ''  ''show''  $ HasAmaximum(r,A\cup \{a\})$ ''   by (rule '' +++^[Order_ZF_4_L5 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L5</nowiki>:  ''assumes '' $ r \text{ is total on } (A\cup B)$  ''and'' $ trans(r)$  ''and'' $ HasAmaximum(r,A)$,   $ HasAmaximum(r,B)$  '' shows '' $ HasAmaximum(r,A\cup B)$ ===  '')'' 
 ''qed'' === 

For total and transitive relations if we add an element to a set that has a minimum, the set still has a minimum.

 ''lemma''  <nowiki>Order_ZF_4_L10</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ A\subseteq X$ ''and '' A4: $ a\in X$ ''and '' A5: $ HasAminimum(r,A)$ ''   shows '' $ HasAminimum(r,A\cup \{a\})$+++[proof ]>
 ''from '' A3, A4  ''have''  $ A\cup \{a\} \subseteq  X$ 
 ''with '' A1  ''have''  $ r \text{ is total on } (A\cup \{a\})$ ''using''  +++^[Order_ZF_1_L4 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_1_L4</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ A\subseteq X$  '' shows '' $ r \text{ is total on } A$ === 
 ''moreover''   ''from '' A1, A2, A4, A5  ''have''  $ trans(r)$,  $ HasAminimum(r,A)$ 
 ''moreover''   ''from '' A1, A4  ''have''  $ HasAminimum(r,\{a\})$ ''using''  +++^[total_is_refl | Order_ZF ]...  ''lemma''  <nowiki>total_is_refl</nowiki>:  ''assumes '' $ r \text{ is total on } X$  '' shows '' $ refl(X,r)$ ===  ,  +++^[Order_ZF_4_L8 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L8</nowiki>:  ''assumes '' $ refl(X,r)$  ''and'' $ a\in X$  '' shows '' $ HasAmaximum(r,\{a\})$,   $ HasAminimum(r,\{a\})$ === 
 ''ultimately ''  ''show''  $ HasAminimum(r,A\cup \{a\})$ ''   by (rule '' +++^[Order_ZF_4_L6 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L6</nowiki>:  ''assumes '' $ r \text{ is total on } (A\cup B)$  ''and'' $ trans(r)$  ''and'' $ HasAminimum(r,A)$,   $ HasAminimum(r,B)$  '' shows '' $ HasAminimum(r,A\cup B)$ ===  '')'' 
 ''qed'' === 

If the order relation has a property that every nonempty bounded set attains a minimum (for example integers are like that), then every nonempty set bounded below attains a minimum.

 ''lemma''  <nowiki>Order_ZF_4_L11</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ r \subseteq  X\times X$ ''and '' A4: $ \forall A.\  IsBounded(A,r) \wedge  A\neq 0 \longrightarrow  HasAminimum(r,A)$ ''and '' A5: $ B\neq 0$ ''and '' A6: $ IsBoundedBelow(B,r)$ ''   shows '' $ HasAminimum(r,B)$+++[proof ]>
 ''from '' A5  ''obtain '' $ b$ ''where '' T: $ b\in B$ 
 ''let '' $ L = \{x\in B.\  \langle x,b\rangle  \in  r\}$
 ''from '' A3, A6, T  ''have''  T1: $ b\in X$ ''using''  +++^[Order_ZF_3_L1B | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L1B</nowiki>:  ''assumes '' $ r \subseteq  X\times X$  ''and'' $ IsBoundedBelow(A,r)$  '' shows '' $ A\subseteq X$ === 
 ''with '' A1, T  ''have''  T2: $ b \in  L$ ''using''  +++^[total_is_refl | Order_ZF ]...  ''lemma''  <nowiki>total_is_refl</nowiki>:  ''assumes '' $ r \text{ is total on } X$  '' shows '' $ refl(X,r)$ ===  ,  <nowiki>refl_def</nowiki>
 ''then ''  ''have''  $ L \neq  0$ 
 ''moreover''   ''have''  $ IsBounded(L,r)$+++[proof ]>
 ''have''  $ L \subseteq  B$ 
 ''with '' A6  ''have''  $ IsBoundedBelow(L,r)$ ''using''  +++^[Order_ZF_3_L12 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L12</nowiki>:  ''assumes '' $ IsBoundedBelow(A,r)$  ''and'' $ B\subseteq A$  '' shows '' $ IsBoundedBelow(B,r)$ === 
 ''moreover''   ''have''  $ IsBoundedAbove(L,r)$ ''   by (rule '' +++^[Order_ZF_3_L15 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L15</nowiki>:  '' shows '' $ IsBoundedAbove(\{x\in A.\  \langle x,a\rangle  \in  r\},r)$ ===  '')'' 
 ''ultimately ''  ''have''  $ IsBoundedAbove(L,r) \wedge  IsBoundedBelow(L,r)$ 
 ''then ''  ''show''  $ IsBounded(L,r)$ ''using''  +++^[IsBounded_def | Order_ZF ]... Definition of <nowiki>IsBounded</nowiki>:
$ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$=== 
 ''qed'' === 
 ''ultimately ''  ''have''  $ IsBounded(L,r) \wedge  L \neq  0$ 
 ''with '' A4  ''have''  $ HasAminimum(r,L)$ 
 ''then ''  ''obtain '' $ m$ ''where '' I: $ m\in L$ ''and '' II: $ \forall x\in L.\  \langle  m,x\rangle  \in  r$ ''using''  +++^[HasAminimum_def | Order_ZF ]... Definition of <nowiki>HasAminimum</nowiki>:
$ HasAminimum(r,A) \equiv  \exists m\in A.\ \forall x\in A.\  \langle  m,x\rangle  \in  r$=== 
 ''then ''  ''have''  III: $ \langle m,b\rangle  \in  r$ 
 ''from '' I  ''have''  $ m\in B$ 
 ''moreover''   ''have''  $ \forall x\in B.\  \langle m,x\rangle  \in  r$+++[proof ]>
 ''fix '' $ x$
 ''assume '' A7: $ x\in B$
 ''from '' A3, A6  ''have''  $ B\subseteq X$ ''using''  +++^[Order_ZF_3_L1B | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L1B</nowiki>:  ''assumes '' $ r \subseteq  X\times X$  ''and'' $ IsBoundedBelow(A,r)$  '' shows '' $ A\subseteq X$ === 
 ''with '' A1, A7, T1  ''have''  $ x \in   L \cup  \{x\in B.\  \langle b,x\rangle  \in  r\}$ ''using''  +++^[Order_ZF_1_L5 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_1_L5</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ A\subseteq X$  ''and'' $ a\in X$  '' shows '' $ A = \{x\in A.\  \langle x,a\rangle  \in  r\} \cup  \{x\in A.\  \langle a,x\rangle  \in  r\}$ === 
 ''then ''  ''have''  $ x\in L \vee  \langle b,x\rangle  \in  r$ 
 ''moreover''  ++++[{ ]>
 ''assume '' $ x\in L$
 ''with '' II  ''have''  $ \langle m,x\rangle  \in  r$ 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ \langle b,x\rangle  \in  r$
 ''with '' A2, III  ''have''  $ trans(r)$ ''and '' $ \langle m,b\rangle  \in  r \wedge  \langle b,x\rangle  \in  r$ 
 ''then ''  ''have''  $ \langle m,x\rangle  \in  r$ ''   by (rule '' +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ ===  '')'' 
===  ''}'' 
 ''ultimately ''  ''show''  $ \langle m,x\rangle  \in  r$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ HasAminimum(r,B)$ ''using''  +++^[HasAminimum_def | Order_ZF ]... Definition of <nowiki>HasAminimum</nowiki>:
$ HasAminimum(r,A) \equiv  \exists m\in A.\ \forall x\in A.\  \langle  m,x\rangle  \in  r$=== 
 ''qed'' === 

A dual to //Order_ZF_4_L11//: If the order relation has a property that every nonempty bounded set attains a maximum (for example integers are like that), then every nonempty set bounded above attains a maximum.

 ''lemma''  <nowiki>Order_ZF_4_L11A</nowiki>:
 ''   assumes '' A1: $ r \text{ is total on } X$ ''and '' A2: $ trans(r)$ ''and '' A3: $ r \subseteq  X\times X$ ''and '' A4: $ \forall A.\  IsBounded(A,r) \wedge  A\neq 0 \longrightarrow  HasAmaximum(r,A)$ ''and '' A5: $ B\neq 0$ ''and '' A6: $ IsBoundedAbove(B,r)$ ''   shows '' $ HasAmaximum(r,B)$+++[proof ]>
 ''from '' A5  ''obtain '' $ b$ ''where '' T: $ b\in B$ 
 ''let '' $ U = \{x\in B.\  \langle b,x\rangle  \in  r\}$
 ''from '' A3, A6, T  ''have''  T1: $ b\in X$ ''using''  +++^[Order_ZF_3_L1A | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L1A</nowiki>:  ''assumes '' $ r \subseteq  X\times X$  ''and'' $ IsBoundedAbove(A,r)$  '' shows '' $ A\subseteq X$ === 
 ''with '' A1, T  ''have''  T2: $ b \in  U$ ''using''  +++^[total_is_refl | Order_ZF ]...  ''lemma''  <nowiki>total_is_refl</nowiki>:  ''assumes '' $ r \text{ is total on } X$  '' shows '' $ refl(X,r)$ ===  ,  <nowiki>refl_def</nowiki>
 ''then ''  ''have''  $ U \neq  0$ 
 ''moreover''   ''have''  $ IsBounded(U,r)$+++[proof ]>
 ''have''  $ U \subseteq  B$ 
 ''with '' A6  ''have''  $ IsBoundedAbove(U,r)$ ''using''  +++^[Order_ZF_3_L13 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L13</nowiki>:  ''assumes '' $ IsBoundedAbove(A,r)$  ''and'' $ B\subseteq A$  '' shows '' $ IsBoundedAbove(B,r)$ === 
 ''moreover''   ''have''  $ IsBoundedBelow(U,r)$ ''using''  +++^[IsBoundedBelow_def | Order_ZF ]... Definition of <nowiki>IsBoundedBelow</nowiki>:
$ IsBoundedBelow(A,r) \equiv  (A=0 \vee  (\exists l.\  \forall x\in A.\  \langle  l,x\rangle  \in  r))$=== 
 ''ultimately ''  ''have''  $ IsBoundedAbove(U,r) \wedge  IsBoundedBelow(U,r)$ 
 ''then ''  ''show''  $ IsBounded(U,r)$ ''using''  +++^[IsBounded_def | Order_ZF ]... Definition of <nowiki>IsBounded</nowiki>:
$ IsBounded(A,r) \equiv  (IsBoundedAbove(A,r) \wedge  IsBoundedBelow(A,r))$=== 
 ''qed'' === 
 ''ultimately ''  ''have''  $ IsBounded(U,r) \wedge  U \neq  0$ 
 ''with '' A4  ''have''  $ HasAmaximum(r,U)$ 
 ''then ''  ''obtain '' $ m$ ''where '' I: $ m\in U$ ''and '' II: $ \forall x\in U.\  \langle x,m\rangle  \in  r$ ''using''  +++^[HasAmaximum_def | Order_ZF ]... Definition of <nowiki>HasAmaximum</nowiki>:
$ HasAmaximum(r,A) \equiv  \exists M\in A.\ \forall x\in A.\  \langle  x,M\rangle  \in  r$=== 
 ''then ''  ''have''  III: $ \langle b,m\rangle  \in  r$ 
 ''from '' I  ''have''  $ m\in B$ 
 ''moreover''   ''have''  $ \forall x\in B.\  \langle x,m\rangle  \in  r$+++[proof ]>
 ''fix '' $ x$
 ''assume '' A7: $ x\in B$
 ''from '' A3, A6  ''have''  $ B\subseteq X$ ''using''  +++^[Order_ZF_3_L1A | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_3_L1A</nowiki>:  ''assumes '' $ r \subseteq  X\times X$  ''and'' $ IsBoundedAbove(A,r)$  '' shows '' $ A\subseteq X$ === 
 ''with '' A1, A7, T1  ''have''  $ x \in  \{x\in B.\  \langle x,b\rangle  \in  r\} \cup  U$ ''using''  +++^[Order_ZF_1_L5 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_1_L5</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ A\subseteq X$  ''and'' $ a\in X$  '' shows '' $ A = \{x\in A.\  \langle x,a\rangle  \in  r\} \cup  \{x\in A.\  \langle a,x\rangle  \in  r\}$ === 
 ''then ''  ''have''  $ x\in U \vee  \langle x,b\rangle  \in  r$ 
 ''moreover''  ++++[{ ]>
 ''assume '' $ x\in U$
 ''with '' II  ''have''  $ \langle x,m\rangle  \in  r$ 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ \langle x,b\rangle  \in  r$
 ''with '' A2, III  ''have''  $ trans(r)$ ''and '' $ \langle x,b\rangle  \in  r \wedge  \langle b,m\rangle  \in  r$ 
 ''then ''  ''have''  $ \langle x,m\rangle  \in  r$ ''   by (rule '' +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ ===  '')'' 
===  ''}'' 
 ''ultimately ''  ''show''  $ \langle x,m\rangle  \in  r$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ HasAmaximum(r,B)$ ''using''  +++^[HasAmaximum_def | Order_ZF ]... Definition of <nowiki>HasAmaximum</nowiki>:
$ HasAmaximum(r,A) \equiv  \exists M\in A.\ \forall x\in A.\  \langle  x,M\rangle  \in  r$=== 
 ''qed'' === 

If a set has a minimum and $L$ is less or equal than all elements of the set, then $L$ is less or equal than the minimum.

 ''lemma''  <nowiki>Order_ZF_4_L12</nowiki>:
 ''   assumes '' $ antisym(r)$ ''and '' $ HasAminimum(r,A)$ ''and '' $ \forall a\in A.\  \langle L,a\rangle  \in  r$ ''   shows '' $ \langle L,Minimum(r,A)\rangle  \in  r$ ''using''  <nowiki>assms</nowiki> ,  +++^[Order_ZF_4_L4 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L4</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAminimum(r,A)$  '' shows '' $ Minimum(r,A) \in  A$,   $ \forall x\in A.\  \langle Minimum(r,A),x\rangle  \in  r$ === 

If a set has a maximum and all its elements are less or equal than $M$, then the maximum of the set is less or equal than $M$.

 ''lemma''  <nowiki>Order_ZF_4_L13</nowiki>:
 ''   assumes '' $ antisym(r)$ ''and '' $ HasAmaximum(r,A)$ ''and '' $ \forall a\in A.\  \langle a,M\rangle  \in  r$ ''   shows '' $ \langle Maximum(r,A),M\rangle  \in  r$ ''using''  <nowiki>assms</nowiki> ,  +++^[Order_ZF_4_L3 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L3</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ Maximum(r,A) \in  A$,   $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$ === 

If an element belongs to a set and is greater or equal than all elements of that set, then it is the maximum of that set.

 ''lemma''  <nowiki>Order_ZF_4_L14</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ M \in  A$ ''and '' A3: $ \forall a\in A.\  \langle a,M\rangle  \in  r$ ''   shows '' $ Maximum(r,A) = M$+++[proof ]>
 ''from '' A2, A3  ''have''  I: $ HasAmaximum(r,A)$ ''using''  +++^[HasAmaximum_def | Order_ZF ]... Definition of <nowiki>HasAmaximum</nowiki>:
$ HasAmaximum(r,A) \equiv  \exists M\in A.\ \forall x\in A.\  \langle  x,M\rangle  \in  r$=== 
 ''with '' A1  ''have''  $ \exists !M.\  M\in A \wedge  (\forall x\in A.\  \langle x,M\rangle  \in  r)$ ''using''  +++^[Order_ZF_4_L1 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L1</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ \exists !M.\  M\in A \wedge  (\forall x\in A.\  \langle  x,M\rangle  \in  r)$ === 
 ''moreover''   ''from '' A2, A3  ''have''  $ M\in A \wedge  (\forall x\in A.\  \langle x,M\rangle  \in  r)$ 
 ''moreover''   ''from '' A1, I  ''have''  $ Maximum(r,A) \in  A \wedge  (\forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r)$ ''using''  +++^[Order_ZF_4_L3 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L3</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ Maximum(r,A) \in  A$,   $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$ === 
 ''ultimately ''  ''show''  $ Maximum(r,A) = M$ 
 ''qed'' === 

If an element belongs to a set and is less or equal than all elements of that set, then it is the minimum of that set.

 ''lemma''  <nowiki>Order_ZF_4_L15</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ m \in  A$ ''and '' A3: $ \forall a\in A.\  \langle m,a\rangle  \in  r$ ''   shows '' $ Minimum(r,A) = m$+++[proof ]>
 ''from '' A2, A3  ''have''  I: $ HasAminimum(r,A)$ ''using''  +++^[HasAminimum_def | Order_ZF ]... Definition of <nowiki>HasAminimum</nowiki>:
$ HasAminimum(r,A) \equiv  \exists m\in A.\ \forall x\in A.\  \langle  m,x\rangle  \in  r$=== 
 ''with '' A1  ''have''  $ \exists !m.\  m\in A \wedge  (\forall x\in A.\  \langle m,x\rangle  \in  r)$ ''using''  +++^[Order_ZF_4_L2 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L2</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAminimum(r,A)$  '' shows '' $ \exists !m.\  m\in A \wedge  (\forall x\in A.\  \langle  m,x\rangle  \in  r)$ === 
 ''moreover''   ''from '' A2, A3  ''have''  $ m\in A \wedge  (\forall x\in A.\  \langle m,x\rangle  \in  r)$ 
 ''moreover''   ''from '' A1, I  ''have''  $ Minimum(r,A) \in  A \wedge  (\forall x\in A.\  \langle Minimum(r,A),x\rangle  \in  r)$ ''using''  +++^[Order_ZF_4_L4 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L4</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAminimum(r,A)$  '' shows '' $ Minimum(r,A) \in  A$,   $ \forall x\in A.\  \langle Minimum(r,A),x\rangle  \in  r$ === 
 ''ultimately ''  ''show''  $ Minimum(r,A) = m$ 
 ''qed'' === 

If a set does not have a maximum, then for any its element we can find one that is (strictly) greater.

 ''lemma''  <nowiki>Order_ZF_4_L16</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ r \text{ is total on } X$ ''and '' A3: $ A\subseteq X$ ''and '' A4: $ \neg HasAmaximum(r,A)$ ''and '' A5: $ x\in A$ ''   shows '' $ \exists y\in A.\  \langle x,y\rangle  \in  r \wedge  y\neq x$+++[proof ]>
++++[{ ]>
 ''assume '' A6: $ \forall y\in A.\  \langle x,y\rangle  \notin  r \vee  y=x$
 ''have''  $ \forall y\in A.\  \langle y,x\rangle  \in  r$+++[proof ]>
 ''fix '' $ y$
 ''assume '' A7: $ y\in A$
 ''with '' A6  ''have''  $ \langle x,y\rangle  \notin  r \vee  y=x$ 
 ''with '' A2, A3, A5, A7  ''show''  $ \langle y,x\rangle  \in  r$ ''using''  +++^[IsTotal_def | Order_ZF ]... Definition of <nowiki>IsTotal</nowiki>:
$ r \text{ is total on } X \equiv  (\forall a\in X.\ \forall b\in X.\  \langle  a,b\rangle  \in  r \vee  \langle  b,a\rangle  \in  r)$===  ,  +++^[Order_ZF_1_L1 | Order_ZF ]...  ''lemma''  <nowiki>Order_ZF_1_L1</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ a\in X$  '' shows '' $ \langle a,a\rangle  \in  r$ === 
 ''qed'' === 
 ''with '' A5  ''have''  $ \exists x\in A.\ \forall y\in A.\  \langle y,x\rangle  \in  r$ 
 ''with '' A4  ''have''  $ False$ ''using''  +++^[HasAmaximum_def | Order_ZF ]... Definition of <nowiki>HasAmaximum</nowiki>:
$ HasAmaximum(r,A) \equiv  \exists M\in A.\ \forall x\in A.\  \langle  x,M\rangle  \in  r$=== 
===  ''}'' 
 ''then ''  ''show''  $ \exists y\in A.\  \langle x,y\rangle  \in  r \wedge  y\neq x$ 
 ''qed'' === 


!Supremum and Infimum

In this section we consider the notions of supremum and infimum a set.

Elements of the set of upper bounds are indeed upper bounds. Isabelle also thinks it is obvious.

 ''lemma''  <nowiki>Order_ZF_5_L1</nowiki>:
 ''   assumes '' $ u \in  (\bigcap a\in A.\  r\{a\})$ ''and '' $ a\in A$ ''   shows '' $ \langle a,u\rangle  \in  r$ ''using''  <nowiki>assms</nowiki>

Elements of the set of lower bounds are indeed lower bounds. Isabelle also thinks it is obvious.

 ''lemma''  <nowiki>Order_ZF_5_L2</nowiki>:
 ''   assumes '' $ l \in  (\bigcap a\in A.\  r^{-1}\{a\})$ ''and '' $ a\in A$ ''   shows '' $ \langle l,a\rangle  \in  r$ ''using''  <nowiki>assms</nowiki>

If the set of upper bounds has a minimum, then the supremum is less or equal than any upper bound. We can probably do away with the assumption that $A$ is not empty, (ab)using the fact that intersection over an empty family is defined in Isabelle to be empty.

 ''lemma''  <nowiki>Order_ZF_5_L3</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ A\neq 0$ ''and '' A3: $ HasAminimum(r,\bigcap a\in A.\  r\{a\})$ ''and '' A4: $ \forall a\in A.\  \langle a,u\rangle  \in  r$ ''   shows '' $ \langle Supremum(r,A),u\rangle  \in  r$+++[proof ]>
 ''let '' $ U = \bigcap a\in A.\  r\{a\}$
 ''from '' A4  ''have''  $ \forall a\in A.\  u \in  r\{a\}$ ''using''  <nowiki>image_singleton_iff</nowiki>
 ''with '' A2  ''have''  $ u\in U$ 
 ''with '' A1, A3  ''show''  $ \langle Supremum(r,A),u\rangle  \in  r$ ''using''  +++^[Order_ZF_4_L4 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L4</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAminimum(r,A)$  '' shows '' $ Minimum(r,A) \in  A$,   $ \forall x\in A.\  \langle Minimum(r,A),x\rangle  \in  r$ ===  ,  +++^[Supremum_def | Order_ZF ]... Definition of <nowiki>Supremum</nowiki>:
$ Supremum(r,A) \equiv  Minimum(r,\bigcap a\in A.\  r\{a\})$=== 
 ''qed'' === 

Infimum is greater or equal than any lower bound.

 ''lemma''  <nowiki>Order_ZF_5_L4</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ A\neq 0$ ''and '' A3: $ HasAmaximum(r,\bigcap a\in A.\  r^{-1}\{a\})$ ''and '' A4: $ \forall a\in A.\  \langle l,a\rangle  \in  r$ ''   shows '' $ \langle l,Infimum(r,A)\rangle  \in  r$+++[proof ]>
 ''let '' $ L = \bigcap a\in A.\  r^{-1}\{a\}$
 ''from '' A4  ''have''  $ \forall a\in A.\  l \in  r^{-1}\{a\}$ ''using''  <nowiki>vimage_singleton_iff</nowiki>
 ''with '' A2  ''have''  $ l\in L$ 
 ''with '' A1, A3  ''show''  $ \langle l,Infimum(r,A)\rangle  \in  r$ ''using''  +++^[Order_ZF_4_L3 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L3</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ Maximum(r,A) \in  A$,   $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$ ===  ,  +++^[Infimum_def | Order_ZF ]... Definition of <nowiki>Infimum</nowiki>:
$ Infimum(r,A) \equiv  Maximum(r,\bigcap a\in A.\  r^{-1}\{a\})$=== 
 ''qed'' === 

If $z$ is an upper bound for $A$ and is greater or equal than any other upper bound, then $z$ is the supremum of $A$.

 ''lemma''  <nowiki>Order_ZF_5_L5</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ A\neq 0$ ''and '' A3: $ \forall x\in A.\  \langle x,z\rangle  \in  r$ ''and '' A4: $ \forall y.\  (\forall x\in A.\  \langle x,y\rangle  \in  r) \longrightarrow  \langle z,y\rangle  \in  r$ ''   shows '' $ HasAminimum(r,\bigcap a\in A.\  r\{a\})$,  $ z = Supremum(r,A)$+++[proof ]>
 ''let '' $ B = \bigcap a\in A.\  r\{a\}$
 ''from '' A2, A3, A4  ''have''  I: $ z \in  B$,  $ \forall y\in B.\  \langle z,y\rangle  \in  r$ 
 ''then ''  ''show''  $ HasAminimum(r,\bigcap a\in A.\  r\{a\})$ ''using''  +++^[HasAminimum_def | Order_ZF ]... Definition of <nowiki>HasAminimum</nowiki>:
$ HasAminimum(r,A) \equiv  \exists m\in A.\ \forall x\in A.\  \langle  m,x\rangle  \in  r$=== 
 ''from '' A1, I  ''show''  $ z = Supremum(r,A)$ ''using''  +++^[Order_ZF_4_L15 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L15</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ m \in  A$  ''and'' $ \forall a\in A.\  \langle m,a\rangle  \in  r$  '' shows '' $ Minimum(r,A) = m$ ===  ,  +++^[Supremum_def | Order_ZF ]... Definition of <nowiki>Supremum</nowiki>:
$ Supremum(r,A) \equiv  Minimum(r,\bigcap a\in A.\  r\{a\})$=== 
 ''qed'' === 

If a set has a maximum, then the maximum is the supremum.

 ''lemma''  <nowiki>Order_ZF_5_L6</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ A\neq 0$ ''and '' A3: $ HasAmaximum(r,A)$ ''   shows '' $ HasAminimum(r,\bigcap a\in A.\  r\{a\})$,  $ Maximum(r,A) = Supremum(r,A)$+++[proof ]>
 ''let '' $ M = Maximum(r,A)$
 ''from '' A1, A3  ''have''  I: $ M \in  A$ ''and '' II: $ \forall x\in A.\  \langle x,M\rangle  \in  r$ ''using''  +++^[Order_ZF_4_L3 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L3</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAmaximum(r,A)$  '' shows '' $ Maximum(r,A) \in  A$,   $ \forall x\in A.\  \langle x,Maximum(r,A)\rangle  \in  r$ === 
 ''from '' I  ''have''  III: $ \forall y.\  (\forall x\in A.\  \langle x,y\rangle  \in  r) \longrightarrow  \langle M,y\rangle  \in  r$ 
 ''with '' A1, A2, II  ''show''  $ HasAminimum(r,\bigcap a\in A.\  r\{a\})$ ''   by (rule '' +++^[Order_ZF_5_L5 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_5_L5</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ A\neq 0$  ''and'' $ \forall x\in A.\  \langle x,z\rangle  \in  r$  ''and'' $ \forall y.\  (\forall x\in A.\  \langle x,y\rangle  \in  r) \longrightarrow  \langle z,y\rangle  \in  r$
 '' shows '' $ HasAminimum(r,\bigcap a\in A.\  r\{a\})$,   $ z = Supremum(r,A)$ ===  '')'' 
 ''from '' A1, A2, II, III  ''show''  $ M = Supremum(r,A)$ ''   by (rule '' +++^[Order_ZF_5_L5 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_5_L5</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ A\neq 0$  ''and'' $ \forall x\in A.\  \langle x,z\rangle  \in  r$  ''and'' $ \forall y.\  (\forall x\in A.\  \langle x,y\rangle  \in  r) \longrightarrow  \langle z,y\rangle  \in  r$
 '' shows '' $ HasAminimum(r,\bigcap a\in A.\  r\{a\})$,   $ z = Supremum(r,A)$ ===  '')'' 
 ''qed'' === 

Properties of supremum of a set for complete relations.

 ''lemma''  <nowiki>Order_ZF_5_L7</nowiki>:
 ''   assumes '' A1: $ r \subseteq  X\times X$ ''and '' A2: $ antisym(r)$ ''and '' A3: $ r \text{ is complete }$ ''and '' A4: $ A\subseteq X$,  $ A\neq 0$ ''and '' A5: $ \exists x\in X.\  \forall y\in A.\  \langle y,x\rangle  \in  r$ ''   shows '' $ Supremum(r,A) \in  X$,  $ \forall x\in A.\  \langle x,Supremum(r,A)\rangle  \in  r$+++[proof ]>
 ''from '' A5  ''have''  $ IsBoundedAbove(A,r)$ ''using''  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 
 ''with '' A3, A4  ''have''  $ HasAminimum(r,\bigcap a\in A.\  r\{a\})$ ''using''  +++^[IsComplete_def | Order_ZF ]... Definition of <nowiki>IsComplete</nowiki>:
$ r \text{ is complete } \equiv  $
$  \forall A.\  IsBoundedAbove(A,r) \wedge  A\neq 0 \longrightarrow  HasAminimum(r,\bigcap a\in A.\  r\{a\})$=== 
 ''with '' A2  ''have''  $ Minimum(r,\bigcap a\in A.\  r\{a\}) \in  ( \bigcap a\in A.\  r\{a\} )$ ''using''  +++^[Order_ZF_4_L4 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_4_L4</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ HasAminimum(r,A)$  '' shows '' $ Minimum(r,A) \in  A$,   $ \forall x\in A.\  \langle Minimum(r,A),x\rangle  \in  r$ === 
 ''moreover''   ''have''  $ Minimum(r,\bigcap a\in A.\  r\{a\}) = Supremum(r,A)$ ''using''  +++^[Supremum_def | Order_ZF ]... Definition of <nowiki>Supremum</nowiki>:
$ Supremum(r,A) \equiv  Minimum(r,\bigcap a\in A.\  r\{a\})$=== 
 ''ultimately ''  ''have''  I: $ Supremum(r,A) \in   ( \bigcap a\in A.\  r\{a\} )$ 
 ''moreover''   ''from '' A4  ''obtain '' $ a$ ''where '' $ a\in A$ 
 ''ultimately ''  ''have''  $ \langle a,Supremum(r,A)\rangle  \in  r$ ''using''  +++^[Order_ZF_5_L1 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_5_L1</nowiki>:  ''assumes '' $ u \in  (\bigcap a\in A.\  r\{a\})$  ''and'' $ a\in A$  '' shows '' $ \langle a,u\rangle  \in  r$ === 
 ''with '' A1  ''show''  $ Supremum(r,A) \in  X$ 
 ''from '' I  ''show''  $ \forall x\in A.\  \langle x,Supremum(r,A)\rangle  \in  r$ ''using''  +++^[Order_ZF_5_L1 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_5_L1</nowiki>:  ''assumes '' $ u \in  (\bigcap a\in A.\  r\{a\})$  ''and'' $ a\in A$  '' shows '' $ \langle a,u\rangle  \in  r$ === 
 ''qed'' === 

If the relation is a linear order then for any element $y$ smaller than the supremum of a set we can find one element of the set that is greater than $y$.

 ''lemma''  <nowiki>Order_ZF_5_L8</nowiki>:
 ''   assumes '' A1: $ r \subseteq  X\times X$ ''and '' A2: $ IsLinOrder(X,r)$ ''and '' A3: $ r \text{ is complete }$ ''and '' A4: $ A\subseteq X$,  $ A\neq 0$ ''and '' A5: $ \exists x\in X.\  \forall y\in A.\  \langle y,x\rangle  \in  r$ ''and '' A6: $ \langle y,Supremum(r,A)\rangle  \in  r$,  $ y \neq  Supremum(r,A)$ ''   shows '' $ \exists z\in A.\  \langle y,z\rangle  \in  r \wedge  y \neq  z$+++[proof ]>
 ''from '' A2  ''have''  I: $ antisym(r)$ ''and '' II: $ trans(r)$ ''and '' III: $ r \text{ is total on } X$ ''using''  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$=== 
 ''from '' A1, A6  ''have''  T1: $ y\in X$ 
++++[{ ]>
 ''assume '' A7: $ \forall z \in  A.\  \langle y,z\rangle  \notin  r \vee  y=z$
 ''from '' A4, I  ''have''  $ antisym(r)$ ''and '' $ A\neq 0$ 
 ''moreover''   ''have''  $ \forall x\in A.\  \langle x,y\rangle  \in  r$+++[proof ]>
 ''fix '' $ x$
 ''assume '' A8: $ x\in A$
 ''with '' A4  ''have''  T2: $ x\in X$ 
 ''from '' A7, A8  ''have''  $ \langle y,x\rangle  \notin  r \vee  y=x$ 
 ''with '' III, T1, T2  ''show''  $ \langle x,y\rangle  \in  r$ ''using''  +++^[IsTotal_def | Order_ZF ]... Definition of <nowiki>IsTotal</nowiki>:
$ r \text{ is total on } X \equiv  (\forall a\in X.\ \forall b\in X.\  \langle  a,b\rangle  \in  r \vee  \langle  b,a\rangle  \in  r)$===  ,  +++^[total_is_refl | Order_ZF ]...  ''lemma''  <nowiki>total_is_refl</nowiki>:  ''assumes '' $ r \text{ is total on } X$  '' shows '' $ refl(X,r)$ ===  ,  <nowiki>refl_def</nowiki>
 ''qed'' === 
 ''moreover''   ''have''  $ \forall u.\  (\forall x\in A.\  \langle x,u\rangle  \in  r) \longrightarrow  \langle y,u\rangle  \in  r$+++[proof ]>
++++[{ ]>
 ''fix '' $ u$
 ''assume '' A9: $ \forall x\in A.\  \langle x,u\rangle  \in  r$
 ''from '' A4, A5  ''have''  $ IsBoundedAbove(A,r)$ ''and '' $ A\neq 0$ ''using''  +++^[IsBoundedAbove_def | Order_ZF ]... Definition of <nowiki>IsBoundedAbove</nowiki>:
$ IsBoundedAbove(A,r) \equiv  ( A=0 \vee  (\exists u.\  \forall x\in A.\  \langle  x,u\rangle  \in  r))$=== 
 ''with '' A3, A4, A6, I, A9  ''have''  $ \langle y,Supremum(r,A)\rangle  \in  r \wedge  \langle Supremum(r,A),u\rangle  \in  r$ ''using''  +++^[IsComplete_def | Order_ZF ]... Definition of <nowiki>IsComplete</nowiki>:
$ r \text{ is complete } \equiv  $
$  \forall A.\  IsBoundedAbove(A,r) \wedge  A\neq 0 \longrightarrow  HasAminimum(r,\bigcap a\in A.\  r\{a\})$===  ,  +++^[Order_ZF_5_L3 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_5_L3</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ A\neq 0$  ''and'' $ HasAminimum(r,\bigcap a\in A.\  r\{a\})$  ''and'' $ \forall a\in A.\  \langle a,u\rangle  \in  r$  '' shows '' $ \langle Supremum(r,A),u\rangle  \in  r$ === 
 ''with '' II  ''have''  $ \langle y,u\rangle  \in  r$ ''   by (rule '' +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ ===  '')'' 
===  ''}'' 
 ''then ''  ''show''  $ \forall u.\  (\forall x\in A.\  \langle x,u\rangle  \in  r) \longrightarrow  \langle y,u\rangle  \in  r$ 
 ''qed'' === 
 ''ultimately ''  ''have''  $ y = Supremum(r,A)$ ''   by (rule '' +++^[Order_ZF_5_L5 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_5_L5</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ A\neq 0$  ''and'' $ \forall x\in A.\  \langle x,z\rangle  \in  r$  ''and'' $ \forall y.\  (\forall x\in A.\  \langle x,y\rangle  \in  r) \longrightarrow  \langle z,y\rangle  \in  r$
 '' shows '' $ HasAminimum(r,\bigcap a\in A.\  r\{a\})$,   $ z = Supremum(r,A)$ ===  '')'' 
 ''with '' A6  ''have''  $ False$ 
===  ''}'' 
 ''then ''  ''show''  $ \exists z\in A.\  \langle y,z\rangle  \in  r \wedge  y \neq  z$ 
 ''qed'' === 


!Strict versions of order relations

One of the problems with translating formalized mathematics from Metamath to IsarMathLib is that Metamath uses strict orders (of the $<$ type) while in IsarMathLib we mostly use nonstrict orders (of the $\leq$ type). This doesn't really make any difference, but is annoying as we have to prove many theorems twice. In this section we prove some theorems to make it easier to translate the statements about strict orders to statements about the corresponding non-strict order and vice versa.

We define a strict version of a relation by removing the $y=x$ line from the relation.

 ''Definition
'' $ StrictVersion(r) \equiv  r - \{\langle x,x\rangle .\  x \in  domain(r)\}$

A reformulation of the definition of a strict version of an order.

 ''lemma''  <nowiki>def_of_strict_ver</nowiki>:
 ''   shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$ ''using''  +++^[StrictVersion_def | Order_ZF_1a ]... Definition of <nowiki>StrictVersion</nowiki>:
$ StrictVersion(r) \equiv  r - \{\langle x,x\rangle .\  x \in  domain(r)\}$===  ,  <nowiki>domain_def</nowiki>

The next lemma is about the strict version of an antisymmetric relation.

 ''lemma''  <nowiki>strict_of_antisym</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ \langle a,b\rangle  \in  StrictVersion(r)$ ''   shows '' $ \langle b,a\rangle  \notin  StrictVersion(r)$+++[proof ]>
++++[{ ]>
 ''assume '' A3: $ \langle b,a\rangle  \in  StrictVersion(r)$
 ''with '' A2  ''have''  $ \langle a,b\rangle  \in  r$ ''and '' $ \langle b,a\rangle  \in  r$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
=== 
 ''with '' A1  ''have''  $ a=b$ ''   by (rule '' +++^[Fol1_L4 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L4</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ \langle  a,b\rangle  \in  r$,   $ \langle  b,a\rangle  \in  r$  '' shows '' $ a=b$ ===  '')'' 
 ''with '' A2  ''have''  $ False$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
=== 
===  ''}'' 
 ''then ''  ''show''  $ \langle b,a\rangle  \notin  StrictVersion(r)$ 
 ''qed'' === 

The strict version of totality.

 ''lemma''  <nowiki>strict_of_tot</nowiki>:
 ''   assumes '' $ r \text{ is total on } X$ ''and '' $ a\in X$,  $ b\in X$,  $ a\neq b$ ''   shows '' $ \langle a,b\rangle  \in  StrictVersion(r) \vee  \langle b,a\rangle  \in  StrictVersion(r)$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsTotal_def | Order_ZF ]... Definition of <nowiki>IsTotal</nowiki>:
$ r \text{ is total on } X \equiv  (\forall a\in X.\ \forall b\in X.\  \langle  a,b\rangle  \in  r \vee  \langle  b,a\rangle  \in  r)$===  ,  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
=== 

A trichotomy law for the strict version of a total and antisymmetric relation. It is kind of interesting that one does not need the full linear order for this.

 ''lemma''  <nowiki>strict_ans_tot_trich</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ r \text{ is total on } X$ ''and '' A3: $ a\in X$,  $ b\in X$ ''and '' A4: $ s = StrictVersion(r)$ ''   shows '' $ Exactly\_1\_of\_3\_holds(\langle a,b\rangle  \in  s, a=b,\langle b,a\rangle  \in  s)$+++[proof ]>
 ''let '' $ p = \langle a,b\rangle  \in  s$
 ''let '' $ q = a=b$
 ''let '' $ r = \langle b,a\rangle  \in  s$
 ''from '' A2, A3, A4  ''have''  $ p \vee  q \vee  r$ ''using''  +++^[strict_of_tot | Order_ZF_1a ]...  ''lemma''  <nowiki>strict_of_tot</nowiki>:  ''assumes '' $ r \text{ is total on } X$  ''and'' $ a\in X$,   $ b\in X$,   $ a\neq b$  '' shows '' $ \langle a,b\rangle  \in  StrictVersion(r) \vee  \langle b,a\rangle  \in  StrictVersion(r)$ === 
 ''moreover''   ''from '' A1, A4  ''have''  $ p \longrightarrow  \neg q \wedge  \neg r$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
===  ,  +++^[strict_of_antisym | Order_ZF_1a ]...  ''lemma''  <nowiki>strict_of_antisym</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ \langle a,b\rangle  \in  StrictVersion(r)$  '' shows '' $ \langle b,a\rangle  \notin  StrictVersion(r)$ === 
 ''moreover''   ''from '' A4  ''have''  $ q \longrightarrow  \neg p \wedge  \neg r$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
=== 
 ''moreover''   ''from '' A1, A4  ''have''  $ r \longrightarrow  \neg p \wedge  \neg q$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
===  ,  +++^[strict_of_antisym | Order_ZF_1a ]...  ''lemma''  <nowiki>strict_of_antisym</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ \langle a,b\rangle  \in  StrictVersion(r)$  '' shows '' $ \langle b,a\rangle  \notin  StrictVersion(r)$ === 
 ''ultimately ''  ''show''  $ Exactly\_1\_of\_3\_holds(p, q, r)$ ''   by (rule '' +++^[Fol1_L5 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L5</nowiki>:  ''assumes '' $ p\vee q\vee r$  ''and'' $ p \longrightarrow  \neg q \wedge  \neg r$  ''and'' $ q \longrightarrow  \neg p \wedge  \neg r$  ''and'' $ r \longrightarrow  \neg p \wedge  \neg q$  '' shows '' $ Exactly\_1\_of\_3\_holds (p,q,r)$ ===  '')'' 
 ''qed'' === 

A trichotomy law for linear order. This is a special case of //strict_ans_tot_trich//.

 ''corollary''  <nowiki>strict_lin_trich</nowiki>:
 ''   assumes '' A1: $ IsLinOrder(X,r)$ ''and '' A2: $ a\in X$,  $ b\in X$ ''and '' A3: $ s = StrictVersion(r)$ ''   shows '' $ Exactly\_1\_of\_3\_holds(\langle a,b\rangle  \in  s, a=b,\langle b,a\rangle  \in  s)$ ''using''  <nowiki>assms</nowiki> ,  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[strict_ans_tot_trich | Order_ZF_1a ]...  ''lemma''  <nowiki>strict_ans_tot_trich</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ r \text{ is total on } X$  ''and'' $ a\in X$,   $ b\in X$  ''and'' $ s = StrictVersion(r)$  '' shows '' $ Exactly\_1\_of\_3\_holds(\langle a,b\rangle  \in  s, a=b,\langle b,a\rangle  \in  s)$ === 

For an antisymmetric relation if a pair is in relation then the reversed pair is not in the strict version of the relation.

 ''lemma''  <nowiki>geq_impl_not_less</nowiki>:
 ''   assumes '' A1: $ antisym(r)$ ''and '' A2: $ \langle a,b\rangle  \in  r$ ''   shows '' $ \langle b,a\rangle  \notin  StrictVersion(r)$+++[proof ]>
++++[{ ]>
 ''assume '' A3: $ \langle b,a\rangle  \in   StrictVersion(r)$
 ''with '' A2  ''have''  $ \langle a,b\rangle  \in  StrictVersion(r)$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
=== 
 ''with '' A1, A3  ''have''  $ False$ ''using''  +++^[strict_of_antisym | Order_ZF_1a ]...  ''lemma''  <nowiki>strict_of_antisym</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ \langle a,b\rangle  \in  StrictVersion(r)$  '' shows '' $ \langle b,a\rangle  \notin  StrictVersion(r)$ === 
===  ''}'' 
 ''then ''  ''show''  $ \langle b,a\rangle  \notin  StrictVersion(r)$ 
 ''qed'' === 

If an antisymmetric relation is transitive, then the strict version is also transitive, an explicit version //strict_of_transB// below.

 ''lemma''  <nowiki>strict_of_transA</nowiki>:
 ''   assumes '' A1: $ trans(r)$ ''and '' A2: $ antisym(r)$ ''and '' A3: $ s= StrictVersion(r)$ ''and '' A4: $ \langle a,b\rangle  \in  s$,  $ \langle b,c\rangle  \in  s$ ''   shows '' $ \langle a,c\rangle  \in  s$+++[proof ]>
 ''from '' A3, A4  ''have''  I: $ \langle a,b\rangle  \in  r \wedge  \langle b,c\rangle  \in  r$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
=== 
 ''with '' A1  ''have''  $ \langle a,c\rangle  \in  r$ ''   by (rule '' +++^[Fol1_L3 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L3</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ \langle  a,b\rangle  \in  r  \wedge  \langle  b,c\rangle  \in  r$  '' shows '' $ \langle  a,c\rangle  \in  r$ ===  '')'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ a=c$
 ''with '' I  ''have''  $ \langle a,b\rangle  \in  r$ ''and '' $ \langle b,a\rangle  \in  r$ 
 ''with '' A2  ''have''  $ a=b$ ''   by (rule '' +++^[Fol1_L4 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L4</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ \langle  a,b\rangle  \in  r$,   $ \langle  b,a\rangle  \in  r$  '' shows '' $ a=b$ ===  '')'' 
 ''with '' A3, A4  ''have''  $ False$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
=== 
===  ''}'' 
 ''then ''  ''have''  $ a\neq c$ 
 ''ultimately ''  ''have''  $ \langle a,c\rangle  \in  StrictVersion(r)$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
=== 
 ''with '' A3  ''show''  $ thesis$ 
 ''qed'' === 

If an antisymmetric relation is transitive, then the strict version is also transitive.

 ''lemma''  <nowiki>strict_of_transB</nowiki>:
 ''   assumes '' A1: $ trans(r)$ ''and '' A2: $ antisym(r)$ ''   shows '' $ trans(StrictVersion(r))$+++[proof ]>
 ''let '' $ s = StrictVersion(r)$
 ''from '' A1, A2  ''have''  $ \forall  x y z.\  \langle x, y\rangle  \in  s \wedge  \langle y, z\rangle  \in  s \longrightarrow  \langle x, z\rangle  \in  s$ ''using''  +++^[strict_of_transA | Order_ZF_1a ]...  ''lemma''  <nowiki>strict_of_transA</nowiki>:  ''assumes '' $ trans(r)$  ''and'' $ antisym(r)$  ''and'' $ s= StrictVersion(r)$  ''and'' $ \langle a,b\rangle  \in  s$,   $ \langle b,c\rangle  \in  s$  '' shows '' $ \langle a,c\rangle  \in  s$ === 
 ''then ''  ''show''  $ trans(StrictVersion(r))$ ''   by (rule '' +++^[Fol1_L2 | Fol1 ]...  ''lemma''  <nowiki>Fol1_L2</nowiki>:  ''assumes '' $ \forall  x y z.\  \langle x, y\rangle  \in  r \wedge  \langle y, z\rangle  \in  r \longrightarrow  \langle x, z\rangle  \in  r$
 '' shows '' $ trans(r)$ ===  '')'' 
 ''qed'' === 

The next lemma provides a condition that is satisfied by the strict version of a relation if the original relation is a complete linear order.

 ''lemma''  <nowiki>strict_of_compl</nowiki>:
 ''   assumes '' A1: $ r \subseteq  X\times X$ ''and '' A2: $ IsLinOrder(X,r)$ ''and '' A3: $ r \text{ is complete }$ ''and '' A4: $ A\subseteq X$,  $ A\neq 0$ ''and '' A5: $ s = StrictVersion(r)$ ''and '' A6: $ \exists u\in X.\  \forall y\in A.\  \langle y,u\rangle  \in  s$ ''   shows '' $ \exists x\in X.\  ( \forall y\in A.\  \langle x,y\rangle  \notin  s ) \wedge  (\forall y\in X.\  \langle y,x\rangle  \in  s \longrightarrow  (\exists z\in A.\  \langle y,z\rangle  \in  s))$+++[proof ]>
 ''let '' $ x = Supremum(r,A)$
 ''from '' A2  ''have''  I: $ antisym(r)$ ''using''  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$=== 
 ''moreover''   ''from '' A5, A6  ''have''  $ \exists u\in X.\  \forall y\in A.\  \langle y,u\rangle  \in  r$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
=== 
 ''moreover''   ''note '' A1 A3 A4
 ''ultimately ''  ''have''  II: $ x \in  X$,  $ \forall y\in A.\  \langle y,x\rangle  \in  r$ ''using''  +++^[Order_ZF_5_L7 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_5_L7</nowiki>:  ''assumes '' $ r \subseteq  X\times X$  ''and'' $ antisym(r)$  ''and'' $ r \text{ is complete }$  ''and'' $ A\subseteq X$,   $ A\neq 0$  ''and'' $ \exists x\in X.\  \forall y\in A.\  \langle y,x\rangle  \in  r$  '' shows '' $ Supremum(r,A) \in  X$,   $ \forall x\in A.\  \langle x,Supremum(r,A)\rangle  \in  r$ === 
 ''then ''  ''have''  III: $ \exists x\in X.\  \forall y\in A.\  \langle y,x\rangle  \in  r$ 
 ''from '' A5, I, II  ''have''  $ x \in  X$,  $ \forall y\in A.\  \langle x,y\rangle  \notin  s$ ''using''  +++^[geq_impl_not_less | Order_ZF_1a ]...  ''lemma''  <nowiki>geq_impl_not_less</nowiki>:  ''assumes '' $ antisym(r)$  ''and'' $ \langle a,b\rangle  \in  r$  '' shows '' $ \langle b,a\rangle  \notin  StrictVersion(r)$ === 
 ''moreover''   ''from '' A1, A2, A3, A4, A5, III  ''have''  $ \forall y\in X.\  \langle y,x\rangle  \in  s \longrightarrow  (\exists z\in A.\  \langle y,z\rangle  \in  s)$ ''using''  +++^[def_of_strict_ver | Order_ZF_1a ]...  ''lemma''  <nowiki>def_of_strict_ver</nowiki>:  '' shows '' $ \langle x,y\rangle  \in  StrictVersion(r) \longleftrightarrow  \langle x,y\rangle  \in  r \wedge  x\neq y$
===  ,  +++^[Order_ZF_5_L8 | Order_ZF_1a ]...  ''lemma''  <nowiki>Order_ZF_5_L8</nowiki>:  ''assumes '' $ r \subseteq  X\times X$  ''and'' $ IsLinOrder(X,r)$  ''and'' $ r \text{ is complete }$  ''and'' $ A\subseteq X$,   $ A\neq 0$  ''and'' $ \exists x\in X.\  \forall y\in A.\  \langle y,x\rangle  \in  r$  ''and'' $ \langle y,Supremum(r,A)\rangle  \in  r$,   $ y \neq  Supremum(r,A)$  '' shows '' $ \exists z\in A.\  \langle y,z\rangle  \in  r \wedge  y \neq  z$ === 
 ''ultimately ''  ''show''  $ \exists x\in X.\  ( \forall y\in A.\  \langle x,y\rangle  \notin  s ) \wedge  (\forall y\in X.\  \langle y,x\rangle  \in  s \longrightarrow  (\exists z\in A.\  \langle y,z\rangle  \in  s))$ 
 ''qed'' === 

Strict version of a relation on a set is a relation on that set.

 ''lemma''  <nowiki>strict_ver_rel</nowiki>:
 ''   assumes '' A1: $ r \subseteq  A\times A$ ''   shows '' $ StrictVersion(r) \subseteq  A\times A$ ''using''  <nowiki>assms</nowiki> ,  +++^[StrictVersion_def | Order_ZF_1a ]... Definition of <nowiki>StrictVersion</nowiki>:
$ StrictVersion(r) \equiv  r - \{\langle x,x\rangle .\  x \in  domain(r)\}$=== 

 ''end

'' +++![Comments on Order_ZF_1a|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Order_ZF_1a"></iframe> </div> </html>
=== 
<!--{{{-->
<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 style="float:left">
   <span macro="tiddler ToggleRightSidebar"></span>
</div>
<!--}}}-->
 ''theory'' Partitions_ZF ''imports'' [[Finite_ZF]] [[FiniteSeq_ZF]]

 ''begin
'' 
It is a common trick in proofs that we divide a set into non-overlapping subsets. The first case is when we split the set into two nonempty disjoint sets. Here this is modeled as an ordered pair of sets and the set of such divisions of set $X$ is called $ Bisections(X)$. The second variation on this theme is a set-valued function (aren't they all in ZF?) whose values are nonempty and mutually disjoint.

!Bisections

This section is about dividing sets into two non-overlapping subsets.

The set of bisections of a given set $A$ is a set of pairs of nonempty subsets of $A$ that do not overlap and their union is equal to $A$.

 ''Definition
'' $ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$

Properties of bisections.

 ''lemma''  <nowiki>bisec_props</nowiki>:
 ''   assumes '' $ \langle A,B\rangle  \in  Bisections(X)$ ''   shows '' $ A\neq 0$,  $ B\neq 0$,  $ A \subseteq  X$,  $ B \subseteq  X$,  $ A \cap  B = 0$,  $ A \cup  B = X$,  $ X \neq  0$ ''using''  <nowiki>assms</nowiki> ,  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 

Kind of inverse of //bisec_props//: a pair of nonempty disjoint sets form a bisection of their union.

 ''lemma''  <nowiki>is_bisec</nowiki>:
 ''   assumes '' $ A\neq 0$,  $ B\neq 0$,  $ A \cap  B = 0$ ''   shows '' $ \langle A,B\rangle  \in  Bisections(A\cup B)$ ''using''  <nowiki>assms</nowiki> ,  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 

Bisection of $X$ is a pair of subsets of $X$.

 ''lemma''  <nowiki>bisec_is_pair</nowiki>:
 ''   assumes '' $ Q \in  Bisections(X)$ ''   shows '' $ Q = \langle fst(Q), snd(Q)\rangle $ ''using''  <nowiki>assms</nowiki> ,  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 

The set of bisections of the empty set is empty.

 ''lemma''  <nowiki>bisec_empty</nowiki>:
 ''   shows '' $ Bisections(0) = 0$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 

The next lemma shows what can we say about bisections of a set with another element added.

 ''lemma''  <nowiki>bisec_add_point</nowiki>:
 ''   assumes '' A1: $ x \notin  X$ ''and '' A2: $ \langle A,B\rangle  \in  Bisections(X \cup  \{x\})$ ''   shows '' $ (A = \{x\} \vee  B = \{x\}) \vee  (\langle A - \{x\}, B - \{x\}\rangle  \in  Bisections(X))$+++[proof ]>
++++[{ ]>
 ''assume '' $ A \neq  \{x\}$ ''and '' $ B \neq  \{x\}$
 ''with '' A2  ''have''  $ A - \{x\} \neq  0$ ''and '' $ B - \{x\} \neq  0$ ''using''  +++^[singl_diff_empty | ZF1 ]...  ''lemma''  <nowiki>singl_diff_empty</nowiki>:  ''assumes '' $ A - \{x\} = 0$  '' shows '' $ A = 0 \vee  A = \{x\}$ ===  ,  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''moreover''   ''have''  $ (A - \{x\}) \cup  (B - \{x\}) = X$+++[proof ]>
 ''have''  $ (A - \{x\}) \cup  (B - \{x\}) = (A \cup  B) - \{x\}$ 
 ''also''   ''from '' assms  ''have''  $ (A \cup  B) - \{x\} = X$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''finally ''  ''show''  $ thesis$ 
 ''qed'' === 
 ''moreover''   ''from '' A2  ''have''  $ (A - \{x\}) \cap  (B - \{x\}) = 0$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''ultimately ''  ''have''  $ \langle A - \{x\}, B - \{x\}\rangle  \in  Bisections(X)$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 

A continuation of the lemma //bisec_add_point// that refines the case when the pair with removed point bisects the original set.

 ''lemma''  <nowiki>bisec_add_point_case3</nowiki>:
 ''   assumes '' A1: $ \langle A,B\rangle  \in  Bisections(X \cup  \{x\})$ ''and '' A2: $ \langle A - \{x\}, B - \{x\}\rangle  \in  Bisections(X)$ ''   shows '' $ (\langle A, B - \{x\}\rangle  \in  Bisections(X) \wedge  x \in  B) \vee  $
$  (\langle A - \{x\}, B\rangle  \in  Bisections(X) \wedge  x \in  A)$+++[proof ]>
 ''from '' A1  ''have''  $ x \in  A \cup  B$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''hence''  $ x\in A \vee  x\in B$
 ''from '' A1  ''have''  $ A - \{x\} = A \vee  B - \{x\} = B$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''moreover''  ++++[{ ]>
 ''assume '' $ A - \{x\} = A$
 ''with '' A2, $ x \in  A \cup  B$  ''have''  $ \langle A, B - \{x\}\rangle  \in  Bisections(X) \wedge  x \in  B$ ''using''  +++^[singl_diff_eq | ZF1 ]...  ''lemma''  <nowiki>singl_diff_eq</nowiki>:  ''assumes '' $ A - \{x\} = A$  '' shows '' $ x \notin  A$ === 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ B - \{x\} = B$
 ''with '' A2, $ x \in  A \cup  B$  ''have''  $ \langle A - \{x\}, B\rangle  \in  Bisections(X) \wedge  x \in  A$ ''using''  +++^[singl_diff_eq | ZF1 ]...  ''lemma''  <nowiki>singl_diff_eq</nowiki>:  ''assumes '' $ A - \{x\} = A$  '' shows '' $ x \notin  A$ === 
===  ''}'' 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

Another lemma about bisecting a set with an added point.

 ''lemma''  <nowiki>point_set_bisec</nowiki>:
 ''   assumes '' A1: $ x \notin  X$ ''and '' A2: $ \langle \{x\}, A\rangle  \in  Bisections(X \cup  \{x\})$ ''   shows '' $ A = X$ ''and '' $ X \neq  0$+++[proof ]>
 ''from '' A2  ''have''  $ A \subseteq  X$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''moreover''  ++++[{ ]>
 ''fix '' $ a$
 ''assume '' $ a\in X$
 ''with '' A2  ''have''  $ a \in  \{x\} \cup  A$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''with '' A1, $ a\in X$  ''have''  $ a \in  A$ 
===  ''}'' 
 ''ultimately ''  ''show''  $ A = X$ 
 ''with '' A2  ''show''  $ X \neq  0$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''qed'' === 

Yet another lemma about bisecting a set with an added point, very similar to // point_set_bisec// with almost the same proof.

 ''lemma''  <nowiki>set_point_bisec</nowiki>:
 ''   assumes '' A1: $ x \notin  X$ ''and '' A2: $ \langle A, \{x\}\rangle  \in  Bisections(X \cup  \{x\})$ ''   shows '' $ A = X$ ''and '' $ X \neq  0$+++[proof ]>
 ''from '' A2  ''have''  $ A \subseteq  X$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''moreover''  ++++[{ ]>
 ''fix '' $ a$
 ''assume '' $ a\in X$
 ''with '' A2  ''have''  $ a \in  A \cup  \{x\}$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''with '' A1, $ a\in X$  ''have''  $ a \in  A$ 
===  ''}'' 
 ''ultimately ''  ''show''  $ A = X$ 
 ''with '' A2  ''show''  $ X \neq  0$ ''using''  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''qed'' === 

If a pair of sets bisects a finite set, then both elements of the pair are finite.

 ''lemma''  <nowiki>bisect_fin</nowiki>:
 ''   assumes '' A1: $ A \in  FinPow(X)$ ''and '' A2: $ Q \in  Bisections(A)$ ''   shows '' $ fst(Q) \in  FinPow(X)$ ''and '' $ snd(Q) \in  FinPow(X)$+++[proof ]>
 ''from '' A2  ''have''  $ \langle fst(Q), snd(Q)\rangle  \in  Bisections(A)$ ''using''  +++^[bisec_is_pair | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_is_pair</nowiki>:  ''assumes '' $ Q \in  Bisections(X)$  '' shows '' $ Q = \langle fst(Q), snd(Q)\rangle $ === 
 ''then ''  ''have''  $ fst(Q) \subseteq  A$ ''and '' $ snd(Q) \subseteq  A$ ''using''  +++^[bisec_props | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_props</nowiki>:  ''assumes '' $ \langle A,B\rangle  \in  Bisections(X)$  '' shows '' $ A\neq 0$,   $ B\neq 0$,  
$ A \subseteq  X$,   $ B \subseteq  X$,   $ A \cap  B = 0$,   $ A \cup  B = X$,   $ X \neq  0$ === 
 ''with '' A1  ''show''  $ fst(Q) \in  FinPow(X)$ ''and '' $ snd(Q) \in  FinPow(X)$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$===  ,  <nowiki>subset_Finite</nowiki>
 ''qed'' === 


!Partitions

This sections covers the situation when we have an arbitrary number of sets we want to partition into.

We define a notion of a partition as a set valued function such that the values for different arguments are disjoint. The name is derived from the fact that such function "partitions" the union of its arguments. Please let me know if you have a better idea for a name for such notion. We would prefer to say ''is a partition'', but that reserves the letter ''a'' as a keyword(?) which causes problems.

 ''Definition
'' $ P \text{ is partition } \equiv   \forall x \in  domain(P).\  $
$  P(x) \neq  0 \wedge  (\forall y \in  domain(P).\  x\neq y \longrightarrow  P(x) \cap  P(y) = 0)$

A fact about lists of mutually disjoint sets.

 ''lemma''  <nowiki>list_partition</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ a : succ(n) \rightarrow  X$,  $ a \text{ is partition }$ ''   shows '' $ (\bigcup i\in n.\  a(i)) \cap  a(n) = 0$+++[proof ]>
++++[{ ]>
 ''assume '' $ (\bigcup i\in n.\  a(i)) \cap  a(n) \neq  0$
 ''then ''  ''have''  $ \exists x.\  x \in  (\bigcup i\in n.\  a(i)) \cap  a(n)$ ''   by (rule '' +++^[nonempty_has_element | ZF1 ]...  ''lemma''  <nowiki>nonempty_has_element</nowiki>:  ''assumes '' $ X\neq 0$  '' shows '' $ \exists x.\  x\in X$ ===  '')'' 
 ''then ''  ''obtain '' $ x$ ''where '' $ x \in  (\bigcup i\in n.\  a(i))$ ''and '' I: $ x \in  a(n)$ 
 ''then ''  ''obtain '' $ i$ ''where '' $ i \in  n$ ''and '' $ x \in  a(i)$ 
 ''with '' A2, I  ''have''  $ False$ ''using''  <nowiki>mem_imp_not_eq</nowiki> ,  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  +++^[Partition_def | Partitions_ZF ]... Definition of <nowiki>Partition</nowiki>:
$ P \text{ is partition } \equiv   \forall x \in  domain(P).\  $
$  P(x) \neq  0 \wedge  (\forall y \in  domain(P).\  x\neq y \longrightarrow  P(x) \cap  P(y) = 0)$=== 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 

 ''end

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

 ''begin
'' 
This theory file covers basic facts about rings.

!Definition and basic properties

In this section we define what is a ring and list the basic properties of rings.

We say that three sets $(R,A,M)$ form a ring if $(R,A)$ is an abelian group, $(R,M)$ is a monoid and $A$ is distributive with respect to $M$ on $R$. $A$ represents the additive operation on $R$. As such it is a subset of $(R\times R)\times R$ (recall that in ZF set theory functions are sets). Similarly $M$ represents the multiplicative operation on $R$ and is also a subset of $(R\times R)\times R$. We don't require the multiplicative operation to be commutative in the definition of a ring.

 ''Definition
'' $ IsAring(R,A,M) \equiv  \text{IsAgroup}(R,A) \wedge  (A \text{ is commutative on } R) \wedge  $
$  \text{IsAmonoid}(R,M) \wedge  IsDistributive(R,A,M)$

We also define the notion of having no zero divisors. In standard notation the ring has no zero divisors if for all $a,b \in R$ we have $a\cdot b = 0$ implies $a = 0$ or $b = 0$.

 ''Definition
'' $ HasNoZeroDivs(R,A,M) \equiv  (\forall a\in R.\  \forall b\in R.\  $
$  M\langle  a,b\rangle  = TheNeutralElement(R,A) \longrightarrow $
$  a = TheNeutralElement(R,A) \vee  b = TheNeutralElement(R,A))$

Next we define a locale that will be used when considering rings.

 ''Locale '' ring0
 ''assumes '' ringAssum: $ IsAring(R,A,M)$
 ''defines '' $ a + b \equiv  A\langle  a,b\rangle $
 ''defines '' $ ( - a) \equiv  GroupInv(R,A)(a)$
 ''defines '' $ a - b \equiv  a + ( - b)$
 ''defines '' $ a\cdot b \equiv  M\langle  a,b\rangle $
 ''defines '' $ 0  \equiv  TheNeutralElement(R,A)$
 ''defines '' $ 1  \equiv  TheNeutralElement(R,M)$
 ''defines '' $  2  \equiv  1  + 1 $
 ''defines '' $ a^2  \equiv  a\cdot a$


In the //ring0// context we can use theorems proven in some other contexts.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:
 ''   shows '' $ monoid0(R,M)$,  $ group0(R,A)$,  $ A \text{ is commutative on } R$ ''using''  <nowiki>ringAssum</nowiki> ,  +++^[IsAring_def | Ring_ZF ]... Definition of <nowiki>IsAring</nowiki>:
$ IsAring(R,A,M) \equiv  \text{IsAgroup}(R,A) \wedge  (A \text{ is commutative on } R) \wedge  $
$  \text{IsAmonoid}(R,M) \wedge  IsDistributive(R,A,M)$===  ,  <nowiki>group0_def</nowiki> ,  <nowiki>monoid0_def</nowiki>

The additive operation in a ring is distributive with respect to the multiplicative operation.

 ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:
 ''   assumes '' A1: $ a\in R$,  $ b\in R$,  $ c\in R$ ''   shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,  $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ ''using''  <nowiki>ringAssum</nowiki> ,  <nowiki>assms</nowiki> ,  +++^[IsAring_def | Ring_ZF ]... Definition of <nowiki>IsAring</nowiki>:
$ IsAring(R,A,M) \equiv  \text{IsAgroup}(R,A) \wedge  (A \text{ is commutative on } R) \wedge  $
$  \text{IsAmonoid}(R,M) \wedge  IsDistributive(R,A,M)$===  ,  +++^[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 )$=== 

Zero and one of the ring are elements of the ring. The negative of zero is zero.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:
 ''   shows '' $ 0 \in R$,  $ 1 \in R$,  $ ( - 0 ) = 0 $ ''using''  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[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))$ ===  ,  +++^[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)$ ===  ,  +++^[group_inv_of_one | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group_inv_of_one</nowiki>:  '' shows '' $ 1 ^{-1} = 1 $ === 

The next lemma lists some properties of a ring that require one element of a ring.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:
 ''   assumes '' $ a\in R$ ''   shows '' $ ( - a) \in  R$,  $ ( - ( - a)) = a$,  $ a + 0  = a$,  $ 0  + a = a$,  $ a\cdot 1  = a$,  $ 1 \cdot a = a$,  $ a - a = 0 $,  $ a - 0  = a$,  $  2 \cdot a = a + a$,  $ ( - a) + a = 0 $ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[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_inv | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group_inv_of_inv</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ a = (a^{-1})^{-1}$ ===  ,  +++^[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))$ ===  ,  +++^[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)$ ===  ,  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ === 

Properties that require two elements of a ring.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:
 ''   assumes '' A1: $ a\in R$,  $ b\in R$ ''   shows '' $ a + b \in  R$,  $ a - b \in  R$,  $ a\cdot b \in  R$,  $ a + b = b + a$ ''using''  <nowiki>ringAssum</nowiki> ,  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[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$ ===  ,  +++^[IsAring_def | Ring_ZF ]... Definition of <nowiki>IsAring</nowiki>:
$ IsAring(R,A,M) \equiv  \text{IsAgroup}(R,A) \wedge  (A \text{ is commutative on } R) \wedge  $
$  \text{IsAmonoid}(R,M) \wedge  IsDistributive(R,A,M)$===  ,  +++^[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 $=== 

Cancellation of an element on both sides of equality. This is a property of groups, written in the (additive) notation we use for the additive operation in rings.

 ''lemma''  ''(in'' ring0'')'' <nowiki>ring_cancel_add</nowiki>:
 ''   assumes '' A1: $ a\in R$,  $ b\in R$ ''and '' A2: $ a  +  b = a$ ''   shows '' $ b = 0 $ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[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 $ === 

Any element of a ring multiplied by zero is zero.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L6</nowiki>:
 ''   assumes '' A1: $ x\in R$ ''   shows '' $ 0 \cdot x = 0 $,  $ x\cdot 0  = 0 $+++[proof ]>
 ''let '' $ a = x\cdot 1 $
 ''let '' $ b = x\cdot 0 $
 ''let '' $ c = 1 \cdot x$
 ''let '' $ d = 0 \cdot x$
 ''from '' A1  ''have''  $ a  +  b = x\cdot (1   +  0 )$,  $ c  +  d = (1   +  0 )\cdot x$ ''using''  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ === 
 ''moreover''   ''have''  $ x\cdot (1   +  0 ) = a$,  $ (1   +  0 )\cdot x = c$ ''using''  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ === 
 ''ultimately ''  ''have''  $ a  +  b = a$ ''and '' T1: $ c  +  d = c$ 
 ''moreover''   ''from '' A1  ''have''  $ a \in  R$,  $ b \in  R$ ''and '' T2: $ c \in  R$,  $ d \in  R$ ''using''  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ === 
 ''ultimately ''  ''have''  $ b = 0 $ ''using''  +++^[ring_cancel_add | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_cancel_add</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  ''and'' $ a  +  b = a$  '' shows '' $ b = 0 $ === 
 ''moreover''   ''from '' T2, T1  ''have''  $ d = 0 $ ''using''  +++^[ring_cancel_add | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_cancel_add</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  ''and'' $ a  +  b = a$  '' shows '' $ b = 0 $ === 
 ''ultimately ''  ''show''  $ x\cdot 0  = 0 $,  $ 0 \cdot x = 0 $ 
 ''qed'' === 

Negative can be pulled out of a product.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L7</nowiki>:
 ''   assumes '' A1: $ a\in R$,  $ b\in R$ ''   shows '' $ ( - a)\cdot b =  - (a\cdot b)$,  $ a\cdot ( - b) =  - (a\cdot b)$,  $ ( - a)\cdot b = a\cdot ( - b)$+++[proof ]>
 ''from '' A1  ''have''  I: $ a\cdot b \in  R$,  $ ( - a) \in  R$,  $ (( - a)\cdot b) \in  R$,  $ ( - b) \in  R$,  $ a\cdot ( - b) \in  R$ ''using''  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ === 
 ''moreover''   ''have''  $ ( - a)\cdot b  +  a\cdot b = 0 $ ''and '' II: $ a\cdot ( - b)  +  a\cdot b = 0 $+++[proof ]>
 ''from '' A1, I  ''have''  $ ( - a)\cdot b  +  a\cdot b = (( - a) +  a)\cdot b$,  $ a\cdot ( - b)  +  a\cdot b= a\cdot (( - b) + b)$ ''using''  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ === 
 ''moreover''   ''from '' A1  ''have''  $ (( - a) +  a)\cdot b = 0 $,  $ a\cdot (( - b) + b) = 0 $ ''using''  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[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 $ ===  ,  +++^[Ring_ZF_1_L6 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L6</nowiki>:  ''assumes '' $ x\in R$  '' shows '' $ 0 \cdot x = 0 $,   $ x\cdot 0  = 0 $ === 
 ''ultimately ''  ''show''  $ ( - a)\cdot b  +  a\cdot b = 0 $,  $ a\cdot ( - b)  +  a\cdot b = 0 $ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ ( - a)\cdot b =  - (a\cdot b)$ ''using''  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[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}$ === 
 ''moreover''   ''from '' I, II  ''show''  $ a\cdot ( - b) =  - (a\cdot b)$ ''using''  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[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}$ === 
 ''ultimately ''  ''show''  $ ( - a)\cdot b = a\cdot ( - b)$ 
 ''qed'' === 

Minus times minus is plus.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L7A</nowiki>:
 ''   assumes '' $ a\in R$,  $ b\in R$ ''   shows '' $ ( - a)\cdot ( - b) = a\cdot b$ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L7 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L7</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ ( - a)\cdot b =  - (a\cdot b)$,  
$ a\cdot ( - b) =  - (a\cdot b)$,   $ ( - a)\cdot b = a\cdot ( - b)$ ===  ,  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ === 

Subtraction is distributive with respect to multiplication.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L8</nowiki>:
 ''   assumes '' $ a\in R$,  $ b\in R$,  $ c\in R$ ''   shows '' $ a\cdot (b - c) = a\cdot b  -  a\cdot c$,  $ (b - c)\cdot a = b\cdot a  -  c\cdot a$ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ ===  ,  +++^[Ring_ZF_1_L7 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L7</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ ( - a)\cdot b =  - (a\cdot b)$,  
$ a\cdot ( - b) =  - (a\cdot b)$,   $ ( - a)\cdot b = a\cdot ( - b)$ ===  ,  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ === 

Other basic properties involving two elements of a ring.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L9</nowiki>:
 ''   assumes '' $ a\in R$,  $ b\in R$ ''   shows '' $ ( - b) - a = ( - a) - b$,  $ ( - (a + b)) = ( - a) - b$,  $ ( - (a - b)) = (( - a) + b)$,  $ a - ( - b) = a + b$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>ringAssum</nowiki> ,  +++^[IsAring_def | Ring_ZF ]... Definition of <nowiki>IsAring</nowiki>:
$ IsAring(R,A,M) \equiv  \text{IsAgroup}(R,A) \wedge  (A \text{ is commutative on } R) \wedge  $
$  \text{IsAmonoid}(R,M) \wedge  IsDistributive(R,A,M)$===  ,  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[group0_4_L4 | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ b^{-1}\cdot a^{-1} = a^{-1}\cdot b^{-1}$,  
$ (a\cdot b)^{-1} = a^{-1}\cdot b^{-1}$,   $ (a\cdot b^{-1})^{-1} = a^{-1}\cdot b$ ===  ,  +++^[group_inv_of_inv | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group_inv_of_inv</nowiki>:  ''assumes '' $ a\in G$  '' shows '' $ a = (a^{-1})^{-1}$ === 

If the difference of two element is zero, then those elements are equal.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L9A</nowiki>:
 ''   assumes '' A1: $ a\in R$,  $ b\in R$ ''and '' A2: $ a - b = 0 $ ''   shows '' $ a=b$+++[proof ]>
 ''from '' A1, A2  ''have''  $ group0(R,A)$,  $ a\in R$,  $ b\in R$,  $ A\langle a,GroupInv(R,A)(b)\rangle  = TheNeutralElement(R,A)$ ''using''  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ === 
 ''then ''  ''show''  $ a=b$ ''   by (rule '' +++^[group0_2_L11A | Group_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_2_L11A</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  ''and'' $ a\cdot b^{-1} = 1 $  '' shows '' $ a=b$ ===  '')'' 
 ''qed'' === 

Other basic properties involving three elements of a ring.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L10</nowiki>:
 ''   assumes '' $ a\in R$,  $ b\in R$,  $ c\in R$ ''   shows '' $ a + (b + c) = a + b + c$,  $ a - (b + c) = a - b - c$,  $ a - (b - c) = a - b + c$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>ringAssum</nowiki> ,  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[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$ ===  ,  +++^[IsAring_def | Ring_ZF ]... Definition of <nowiki>IsAring</nowiki>:
$ IsAring(R,A,M) \equiv  \text{IsAgroup}(R,A) \wedge  (A \text{ is commutative on } R) \wedge  $
$  \text{IsAmonoid}(R,M) \wedge  IsDistributive(R,A,M)$===  ,  +++^[group0_4_L4A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L4A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c = c\cdot a\cdot b$,  
$ a^{-1}\cdot (b^{-1}\cdot c^{-1})^{-1} = (a\cdot (b\cdot c)^{-1})^{-1}$,  
$ a\cdot (b\cdot c)^{-1} = a\cdot b^{-1}\cdot c^{-1}$,  
$ a\cdot (b\cdot c^{-1})^{-1} = a\cdot b^{-1}\cdot c$,  
$ a\cdot b^{-1}\cdot c^{-1} = a\cdot c^{-1}\cdot b^{-1}$ === 

Another property with three elements.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L10A</nowiki>:
 ''   assumes '' A1: $ a\in R$,  $ b\in R$,  $ c\in R$ ''   shows '' $ a + (b - c) = a + b - c$ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L10 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L10</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + (b + c) = a + b + c$,   $ a - (b + c) = a - b - c$,   $ a - (b - c) = a - b + c$ === 

Associativity of addition and multiplication.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:
 ''   assumes '' $ a\in R$,  $ b\in R$,  $ c\in R$ ''   shows '' $ a + b + c = a + (b + c)$,  $ a\cdot b\cdot c = a\cdot (b\cdot c)$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>ringAssum</nowiki> ,  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[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$ ===  ,  +++^[IsAring_def | Ring_ZF ]... Definition of <nowiki>IsAring</nowiki>:
$ IsAring(R,A,M) \equiv  \text{IsAgroup}(R,A) \wedge  (A \text{ is commutative on } R) \wedge  $
$  \text{IsAmonoid}(R,M) \wedge  IsDistributive(R,A,M)$===  ,  +++^[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  )))$=== 

An interpretation of what it means that a ring has no zero divisors.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L12</nowiki>:
 ''   assumes '' $ HasNoZeroDivs(R,A,M)$ ''and '' $ a\in R$,  $ a\neq 0 $,  $ b\in R$,  $ b\neq 0 $ ''   shows '' $ a\cdot b\neq 0 $ ''using''  <nowiki>assms</nowiki> ,  +++^[HasNoZeroDivs_def | Ring_ZF ]... Definition of <nowiki>HasNoZeroDivs</nowiki>:
$ HasNoZeroDivs(R,A,M) \equiv  (\forall a\in R.\  \forall b\in R.\  $
$  M\langle  a,b\rangle  = TheNeutralElement(R,A) \longrightarrow $
$  a = TheNeutralElement(R,A) \vee  b = TheNeutralElement(R,A))$=== 

In rings with no zero divisors we can cancel nonzero factors.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L12A</nowiki>:
 ''   assumes '' A1: $ HasNoZeroDivs(R,A,M)$ ''and '' A2: $ a\in R$,  $ b\in R$,  $ c\in R$ ''and '' A3: $ a\cdot c = b\cdot c$ ''and '' A4: $ c\neq 0 $ ''   shows '' $ a=b$+++[proof ]>
 ''from '' A2  ''have''  T: $ a\cdot c \in  R$,  $ a - b \in  R$ ''using''  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ === 
 ''with '' A1, A2, A3  ''have''  $ a - b = 0  \vee  c=0 $ ''using''  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L8 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L8</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b - c) = a\cdot b  -  a\cdot c$,   $ (b - c)\cdot a = b\cdot a  -  c\cdot a$ ===  ,  +++^[HasNoZeroDivs_def | Ring_ZF ]... Definition of <nowiki>HasNoZeroDivs</nowiki>:
$ HasNoZeroDivs(R,A,M) \equiv  (\forall a\in R.\  \forall b\in R.\  $
$  M\langle  a,b\rangle  = TheNeutralElement(R,A) \longrightarrow $
$  a = TheNeutralElement(R,A) \vee  b = TheNeutralElement(R,A))$=== 
 ''with '' A2, A4  ''have''  $ a\in R$,  $ b\in R$,  $ a - b = 0 $ 
 ''then ''  ''show''  $ a=b$ ''   by (rule '' +++^[Ring_ZF_1_L9A | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L9A</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  ''and'' $ a - b = 0 $  '' shows '' $ a=b$ ===  '')'' 
 ''qed'' === 

In rings with no zero divisors if two elements are different, then after multiplying by a nonzero element they are still different.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L12B</nowiki>:
 ''   assumes '' A1: $ HasNoZeroDivs(R,A,M)$,  $ a\in R$,  $ b\in R$,  $ c\in R$,  $ a\neq b$,  $ c\neq 0 $ ''   shows '' $ a\cdot c \neq  b\cdot c$ ''using''  <nowiki>A1</nowiki> ,  +++^[Ring_ZF_1_L12A | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L12A</nowiki>:  ''assumes '' $ HasNoZeroDivs(R,A,M)$  ''and'' $ a\in R$,   $ b\in R$,   $ c\in R$  ''and'' $ a\cdot c = b\cdot c$  ''and'' $ c\neq 0 $  '' shows '' $ a=b$ === 

In rings with no zero divisors multiplying a nonzero element by a nonone element changes the value.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L12C</nowiki>:
 ''   assumes '' A1: $ HasNoZeroDivs(R,A,M)$ ''and '' A2: $ a\in R$,  $ b\in R$ ''and '' A3: $ 0 \neq a$,  $ 1 \neq b$ ''   shows '' $ a \neq  a\cdot b$+++[proof ]>
++++[{ ]>
 ''assume '' $ a = a\cdot b$
 ''with '' A1, A2  ''have''  $ a = 0  \vee  b - 1  = 0 $ ''using''  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[Ring_ZF_1_L8 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L8</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b - c) = a\cdot b  -  a\cdot c$,   $ (b - c)\cdot a = b\cdot a  -  c\cdot a$ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ ===  ,  +++^[HasNoZeroDivs_def | Ring_ZF ]... Definition of <nowiki>HasNoZeroDivs</nowiki>:
$ HasNoZeroDivs(R,A,M) \equiv  (\forall a\in R.\  \forall b\in R.\  $
$  M\langle  a,b\rangle  = TheNeutralElement(R,A) \longrightarrow $
$  a = TheNeutralElement(R,A) \vee  b = TheNeutralElement(R,A))$=== 
 ''with '' A2, A3  ''have''  $ False$ ''using''  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[Ring_ZF_1_L9A | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L9A</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  ''and'' $ a - b = 0 $  '' shows '' $ a=b$ === 
===  ''}'' 
 ''then ''  ''show''  $ a \neq  a\cdot b$ 
 ''qed'' === 

If a square is nonzero, then the element is nonzero.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L13</nowiki>:
 ''   assumes '' $ a\in R$ ''and '' $ a^2  \neq  0 $ ''   shows '' $ a\neq 0 $ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[Ring_ZF_1_L6 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L6</nowiki>:  ''assumes '' $ x\in R$  '' shows '' $ 0 \cdot x = 0 $,   $ x\cdot 0  = 0 $ === 

Square of an element and its opposite are the same.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L14</nowiki>:
 ''   assumes '' $ a\in R$ ''   shows '' $ ( - a)^2  = ((a)^2 )$ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L7A | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L7A</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ ( - a)\cdot ( - b) = a\cdot b$ === 

Adding zero to a set that is closed under addition results in a set that is also closed under addition. This is a property of groups.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L15</nowiki>:
 ''   assumes '' $ H \subseteq  R$ ''and '' $ H \text{ is closed under } A$ ''   shows '' $ (H \cup  \{0 \}) \text{ is closed under } A$ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[group0_2_L17 | Group_ZF ]...  ''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$ === 

Adding zero to a set that is closed under multiplication results in a set that is also closed under multiplication.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L16</nowiki>:
 ''   assumes '' A1: $ H \subseteq  R$ ''and '' A2: $ H \text{ is closed under } M$ ''   shows '' $ (H \cup  \{0 \}) \text{ is closed under } M$ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[Ring_ZF_1_L6 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L6</nowiki>:  ''assumes '' $ x\in R$  '' shows '' $ 0 \cdot x = 0 $,   $ x\cdot 0  = 0 $ ===  ,  +++^[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$=== 

The ring is trivial iff $0=1$.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L17</nowiki>:
 ''   shows '' $ R = \{0 \} \longleftrightarrow  0 =1 $+++[proof ]>
 ''assume '' $ R = \{0 \}$
 ''then ''  ''show''  $ 0 =1 $ ''using''  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ === 
 ''next '' 
 ''assume '' A1: $ 0  = 1 $
 ''then ''  ''have''  $ R \subseteq  \{0 \}$ ''using''  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L6 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L6</nowiki>:  ''assumes '' $ x\in R$  '' shows '' $ 0 \cdot x = 0 $,   $ x\cdot 0  = 0 $ === 
 ''moreover''   ''have''  $ \{0 \} \subseteq  R$ ''using''  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ === 
 ''ultimately ''  ''show''  $ R = \{0 \}$ 
 ''qed'' === 

The sets $\{m\cdot x. x\in R\}$ and $\{-m\cdot x. x\in R\}$ are the same.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L18</nowiki>:
 ''   assumes '' A1: $ m\in R$ ''   shows '' $ \{m\cdot x.\  x\in R\} = \{( - m)\cdot x.\  x\in R\}$+++[proof ]>
++++[{ ]>
 ''fix '' $ a$
 ''assume '' $ a \in  \{m\cdot x.\  x\in R\}$
 ''then ''  ''obtain '' $ x$ ''where '' $ x\in R$ ''and '' $ a = m\cdot x$ 
 ''with '' A1  ''have''  $ ( - x) \in  R$ ''and '' $ a = ( - m)\cdot ( - x)$ ''using''  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L7A | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L7A</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ ( - a)\cdot ( - b) = a\cdot b$ === 
 ''then ''  ''have''  $ a \in  \{( - m)\cdot x.\  x\in R\}$ 
===  ''}'' 
 ''then ''  ''show''  $ \{m\cdot x.\  x\in R\} \subseteq  \{( - m)\cdot x.\  x\in R\}$ 
 ''next '' 
++++[{ ]>
 ''fix '' $ a$
 ''assume '' $ a \in  \{( - m)\cdot x.\  x\in R\}$
 ''then ''  ''obtain '' $ x$ ''where '' $ x\in R$ ''and '' $ a = ( - m)\cdot x$ 
 ''with '' A1  ''have''  $ ( - x) \in  R$ ''and '' $ a = m\cdot ( - x)$ ''using''  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L7 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L7</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ ( - a)\cdot b =  - (a\cdot b)$,  
$ a\cdot ( - b) =  - (a\cdot b)$,   $ ( - a)\cdot b = a\cdot ( - b)$ === 
 ''then ''  ''have''  $ a \in  \{m\cdot x.\  x\in R\}$ 
===  ''}'' 
 ''then ''  ''show''  $ \{( - m)\cdot x.\  x\in R\} \subseteq  \{m\cdot x.\  x\in R\}$ 
 ''qed'' === 


!Rearrangement lemmas

In happens quite often that we want to show a fact like $(a+b)c+d = (ac+d-e)+(bc+e)$in rings. This is trivial in romantic math and probably there is a way to make it trivial in formalized math. However, I don't know any other way than to tediously prove each such rearrangement when it is needed. This section collects facts of this type.

Rearrangements with two elements of a ring.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_2_L1</nowiki>:
 ''   assumes '' $ a\in R$,  $ b\in R$ ''   shows '' $ a + b\cdot a = (b + 1 )\cdot a$ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ === 

Rearrangements with two elements and cancelling.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_2_L1A</nowiki>:
 ''   assumes '' $ a\in R$,  $ b\in R$ ''   shows '' $ a - b + b = a$,  $ a + b - a = b$,  $ ( - a) + b + a = b$,  $ ( - a) + (b + a) = b$,  $ a + (b - a) = b$ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[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$ ===  ,  +++^[group0_4_L6A | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L6A</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b\cdot a^{-1} = b$,  
$ a^{-1}\cdot b\cdot a = b$,   $ a^{-1}\cdot (b\cdot a) = b$,   $ a\cdot (b\cdot a^{-1}) = b$ === 

In commutative rings $a-(b+1)c = (a-d-c)+(d-bc)$. For unknown reasons we have to use the raw set notation in the proof, otherwise all methods fail.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_2_L2</nowiki>:
 ''   assumes '' A1: $ a\in R$,  $ b\in R$,  $ c\in R$,  $ d\in R$ ''   shows '' $ a - (b + 1 )\cdot c = (a - d - c) + (d - b\cdot c)$+++[proof ]>
 ''let '' $ B = b\cdot c$
 ''from '' ringAssum  ''have''  $ A \text{ is commutative on } R$ ''using''  +++^[IsAring_def | Ring_ZF ]... Definition of <nowiki>IsAring</nowiki>:
$ IsAring(R,A,M) \equiv  \text{IsAgroup}(R,A) \wedge  (A \text{ is commutative on } R) \wedge  $
$  \text{IsAmonoid}(R,M) \wedge  IsDistributive(R,A,M)$=== 
 ''moreover''   ''from '' A1  ''have''  $ a\in R$,  $ B \in  R$,  $ c\in R$,  $ d\in R$ ''using''  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ === 
 ''ultimately ''  ''have''  $ A\langle a, GroupInv(R,A)(A\langle B, c\rangle )\rangle  =$
$    A\langle A\langle A\langle a, GroupInv(R, A)(d)\rangle ,GroupInv(R, A)(c)\rangle ,$
$    A\langle d,GroupInv(R, A)(B)\rangle \rangle $ ''using''  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[group0_4_L8 | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L8</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$,   $ d\in G$  '' shows '' $ a\cdot (b\cdot c)^{-1} = (a\cdot d^{-1}\cdot c^{-1})\cdot (d\cdot b^{-1})$,  
$ a\cdot b\cdot (c\cdot d) = c\cdot a\cdot (b\cdot d)$,  
$ a\cdot b\cdot (c\cdot d) = a\cdot c\cdot (b\cdot d)$,  
$ a\cdot (b\cdot c^{-1})\cdot d = a\cdot b\cdot d\cdot c^{-1}$,  
$ (a\cdot b)\cdot (c\cdot d)^{-1}\cdot (b\cdot d^{-1})^{-1} = a\cdot c^{-1}$ === 
 ''with '' A1  ''show''  $ thesis$ ''using''  +++^[Ring_ZF_1_L2 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L2</nowiki>:  '' shows '' $ 0 \in R$,   $ 1 \in R$,   $ ( - 0 ) = 0 $ ===  ,  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ === 
 ''qed'' === 

Rerrangement about adding linear functions.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_2_L3</nowiki>:
 ''   assumes '' A1: $ a\in R$,  $ b\in R$,  $ c\in R$,  $ d\in R$,  $ x\in R$ ''   shows '' $ (a\cdot x  +  b)  +  (c\cdot x  +  d) = (a + c)\cdot x  +  (b + d)$+++[proof ]>
 ''from '' A1  ''have''  $ group0(R,A)$,  $ A \text{ is commutative on } R$,  $ a\cdot x \in  R$,  $ b\in R$,  $ c\cdot x \in  R$,  $ d\in R$ ''using''  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ === 
 ''then ''  ''have''  $ A\langle A\langle  a\cdot x,b\rangle ,A\langle  c\cdot x,d\rangle \rangle  = A\langle A\langle  a\cdot x,c\cdot x\rangle ,A\langle  b,d\rangle \rangle $ ''   by (rule '' +++^[group0_4_L8 | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>group0_4_L8</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$,   $ d\in G$  '' shows '' $ a\cdot (b\cdot c)^{-1} = (a\cdot d^{-1}\cdot c^{-1})\cdot (d\cdot b^{-1})$,  
$ a\cdot b\cdot (c\cdot d) = c\cdot a\cdot (b\cdot d)$,  
$ a\cdot b\cdot (c\cdot d) = a\cdot c\cdot (b\cdot d)$,  
$ a\cdot (b\cdot c^{-1})\cdot d = a\cdot b\cdot d\cdot c^{-1}$,  
$ (a\cdot b)\cdot (c\cdot d)^{-1}\cdot (b\cdot d^{-1})^{-1} = a\cdot c^{-1}$ ===  '')'' 
 ''with '' A1  ''show''  $ (a\cdot x  +  b)  +  (c\cdot x  +  d) = (a + c)\cdot x  +  (b + d)$ ''using''  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ === 
 ''qed'' === 

Rearrangement with three elements

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_2_L4</nowiki>:
 ''   assumes '' $ M \text{ is commutative on } R$ ''and '' $ a\in R$,  $ b\in R$,  $ c\in R$ ''   shows '' $ a\cdot (b\cdot c) = a\cdot c\cdot b$ ''using''  <nowiki>assms</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 $===  ,  +++^[Ring_ZF_1_L11 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + b + c = a + (b + c)$,   $ a\cdot b\cdot c = a\cdot (b\cdot c)$ === 

Some other rearrangements with three elements.

 ''lemma''  ''(in'' ring0'')'' <nowiki>ring_rearr_3_elemA</nowiki>:
 ''   assumes '' A1: $ M \text{ is commutative on } R$ ''and '' A2: $ a\in R$,  $ b\in R$,  $ c\in R$ ''   shows '' $ a\cdot (a\cdot c)  -  b\cdot ( - b\cdot c) = (a\cdot a  +  b\cdot b)\cdot c$,  $ a\cdot ( - b\cdot c)  +  b\cdot (a\cdot c) = 0 $+++[proof ]>
 ''from '' A2  ''have''  T: $ b\cdot c \in  R$,  $ a\cdot a \in  R$,  $ b\cdot b \in  R$,  $ b\cdot (b\cdot c) \in  R$,  $ a\cdot (b\cdot c) \in  R$ ''using''  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ === 
 ''with '' A2  ''show''  $ a\cdot (a\cdot c)  -  b\cdot ( - b\cdot c) = (a\cdot a  +  b\cdot b)\cdot c$ ''using''  +++^[Ring_ZF_1_L7 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L7</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ ( - a)\cdot b =  - (a\cdot b)$,  
$ a\cdot ( - b) =  - (a\cdot b)$,   $ ( - a)\cdot b = a\cdot ( - b)$ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ ===  ,  +++^[Ring_ZF_1_L11 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + b + c = a + (b + c)$,   $ a\cdot b\cdot c = a\cdot (b\cdot c)$ ===  ,  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ === 
 ''from '' A2, T  ''have''  $ a\cdot ( - b\cdot c)  +  b\cdot (a\cdot c) = ( - a\cdot (b\cdot c))  +  b\cdot a\cdot c$ ''using''  +++^[Ring_ZF_1_L7 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L7</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ ( - a)\cdot b =  - (a\cdot b)$,  
$ a\cdot ( - b) =  - (a\cdot b)$,   $ ( - a)\cdot b = a\cdot ( - b)$ ===  ,  +++^[Ring_ZF_1_L11 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + b + c = a + (b + c)$,   $ a\cdot b\cdot c = a\cdot (b\cdot c)$ === 
 ''also''   ''from '' A1, A2, T  ''have''  $ \ldots  = 0 $ ''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 $===  ,  +++^[Ring_ZF_1_L11 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + b + c = a + (b + c)$,   $ a\cdot b\cdot c = a\cdot (b\cdot c)$ ===  ,  +++^[Ring_ZF_1_L3 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L3</nowiki>:  ''assumes '' $ a\in R$  '' shows '' $ ( - a) \in  R$,   $ ( - ( - a)) = a$,   $ a + 0  = a$,   $ 0  + a = a$,   $ a\cdot 1  = a$,  
$ 1 \cdot a = a$,   $ a - a = 0 $,   $ a - 0  = a$,   $  2 \cdot a = a + a$,   $ ( - a) + a = 0 $ === 
 ''finally ''  ''show''  $ a\cdot ( - b\cdot c)  +  b\cdot (a\cdot c) = 0 $ 
 ''qed'' === 

Some rearrangements with four elements. Properties of abelian groups.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_2_L5</nowiki>:
 ''   assumes '' $ a\in R$,  $ b\in R$,  $ c\in R$,  $ d\in R$ ''   shows '' $ a  -  b  -  c  -  d = a  -  d  -  b  -  c$,  $ a  +  b  +  c  -  d = a  -  d  +  b  +  c$,  $ a  +  b  -  c  -  d = a  -  c  +  (b  -  d)$,  $ a  +  b  +  c  +  d = a  +  c  +  (b  +  d)$ ''using''  <nowiki>assms</nowiki> ,  +++^[Ring_ZF_1_L1 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L1</nowiki>:  '' shows '' $ monoid0(R,M)$,   $ group0(R,A)$,   $ A \text{ is commutative on } R$ ===  ,  +++^[rearr_ab_gr_4_elemB | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>rearr_ab_gr_4_elemB</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$,   $ d\in G$  '' shows '' $ a\cdot b^{-1}\cdot c^{-1}\cdot d^{-1} = a\cdot d^{-1}\cdot b^{-1}\cdot c^{-1}$,  
$ a\cdot b\cdot c\cdot d^{-1} = a\cdot d^{-1}\cdot b\cdot c$,  
$ a\cdot b\cdot c^{-1}\cdot d^{-1} =  a\cdot c^{-1}\cdot (b\cdot d^{-1})$ ===  ,  +++^[rearr_ab_gr_4_elemA | AbelianGroup_ZF ]...  ''lemma''  ''(in'' group0'')'' <nowiki>rearr_ab_gr_4_elemA</nowiki>:  ''assumes '' $ P \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$,   $ d\in G$  '' shows '' $ a\cdot b\cdot c\cdot d = a\cdot d\cdot b\cdot c$,  
$ a\cdot b\cdot c\cdot d = a\cdot c\cdot (b\cdot d)$ === 

Two big rearranegements with six elements, useful for proving properties of complex addition and multiplication.

 ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_2_L6</nowiki>:
 ''   assumes '' A1: $ a\in R$,  $ b\in R$,  $ c\in R$,  $ d\in R$,  $ e\in R$,  $ f\in R$ ''   shows '' $ a\cdot (c\cdot e  -  d\cdot f)  -  b\cdot (c\cdot f  +  d\cdot e) =$
$  (a\cdot c  -  b\cdot d)\cdot e  -  (a\cdot d  +  b\cdot c)\cdot f$,  $ a\cdot (c\cdot f  +  d\cdot e)  +  b\cdot (c\cdot e  -  d\cdot f) =$
$  (a\cdot c  -  b\cdot d)\cdot f  +  (a\cdot d  +  b\cdot c)\cdot e$,  $ a\cdot (c + e)  -  b\cdot (d + f) = a\cdot c  -  b\cdot d  +  (a\cdot e  -  b\cdot f)$,  $ a\cdot (d + f)  +  b\cdot (c + e) = a\cdot d  +  b\cdot c  +  (a\cdot f  +  b\cdot e)$+++[proof ]>
 ''from '' A1  ''have''  T: $ c\cdot e \in  R$,  $ d\cdot f \in  R$,  $ c\cdot f \in  R$,  $ d\cdot e \in  R$,  $ a\cdot c \in  R$,  $ b\cdot d \in  R$,  $ a\cdot d \in  R$,  $ b\cdot c \in  R$,  $ b\cdot f \in  R$,  $ a\cdot e \in  R$,  $ b\cdot e \in  R$,  $ a\cdot f \in  R$,  $ a\cdot c\cdot e \in  R$,  $ a\cdot d\cdot f \in  R$,  $ b\cdot c\cdot f \in  R$,  $ b\cdot d\cdot e \in  R$,  $ b\cdot c\cdot e \in  R$,  $ b\cdot d\cdot f \in  R$,  $ a\cdot c\cdot f \in  R$,  $ a\cdot d\cdot e \in  R$,  $ a\cdot c\cdot e  -  a\cdot d\cdot f \in  R$,  $ a\cdot c\cdot e  -  b\cdot d\cdot e \in  R$,  $ a\cdot c\cdot f  +  a\cdot d\cdot e \in  R$,  $ a\cdot c\cdot f  -  b\cdot d\cdot f \in  R$,  $ a\cdot c  +  a\cdot e \in  R$,  $ a\cdot d  +  a\cdot f \in  R$ ''using''  +++^[Ring_ZF_1_L4 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L4</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$  '' shows '' $ a + b \in  R$,   $ a - b \in  R$,   $ a\cdot b \in  R$,   $ a + b = b + a$ === 
 ''with '' A1  ''show''  $ a\cdot (c\cdot e  -  d\cdot f)  -  b\cdot (c\cdot f  +  d\cdot e) =$
$    (a\cdot c  -  b\cdot d)\cdot e  -  (a\cdot d  +  b\cdot c)\cdot f$ ''using''  +++^[Ring_ZF_1_L8 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L8</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b - c) = a\cdot b  -  a\cdot c$,   $ (b - c)\cdot a = b\cdot a  -  c\cdot a$ ===  ,  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ ===  ,  +++^[Ring_ZF_1_L11 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + b + c = a + (b + c)$,   $ a\cdot b\cdot c = a\cdot (b\cdot c)$ ===  ,  +++^[Ring_ZF_1_L10 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L10</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + (b + c) = a + b + c$,   $ a - (b + c) = a - b - c$,   $ a - (b - c) = a - b + c$ ===  ,  +++^[Ring_ZF_2_L5 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_2_L5</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$,   $ d\in R$  '' shows '' $ a  -  b  -  c  -  d = a  -  d  -  b  -  c$,   $ a  +  b  +  c  -  d = a  -  d  +  b  +  c$,  
$ a  +  b  -  c  -  d = a  -  c  +  (b  -  d)$,   $ a  +  b  +  c  +  d = a  +  c  +  (b  +  d)$ === 
 ''from '' A1, T  ''show''  $ a\cdot (c\cdot f  +  d\cdot e)  +  b\cdot (c\cdot e  -  d\cdot f) =$
$    (a\cdot c  -  b\cdot d)\cdot f  +  (a\cdot d  +  b\cdot c)\cdot e$ ''using''  +++^[Ring_ZF_1_L8 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L8</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b - c) = a\cdot b  -  a\cdot c$,   $ (b - c)\cdot a = b\cdot a  -  c\cdot a$ ===  ,  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ ===  ,  +++^[Ring_ZF_1_L11 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L11</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + b + c = a + (b + c)$,   $ a\cdot b\cdot c = a\cdot (b\cdot c)$ ===  ,  +++^[Ring_ZF_1_L10A | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L10A</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + (b - c) = a + b - c$ ===  ,  +++^[Ring_ZF_2_L5 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_2_L5</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$,   $ d\in R$  '' shows '' $ a  -  b  -  c  -  d = a  -  d  -  b  -  c$,   $ a  +  b  +  c  -  d = a  -  d  +  b  +  c$,  
$ a  +  b  -  c  -  d = a  -  c  +  (b  -  d)$,   $ a  +  b  +  c  +  d = a  +  c  +  (b  +  d)$ ===  ,  +++^[Ring_ZF_1_L10 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L10</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + (b + c) = a + b + c$,   $ a - (b + c) = a - b - c$,   $ a - (b - c) = a - b + c$ === 
 ''from '' A1, T  ''show''  $ a\cdot (c + e)  -  b\cdot (d + f) = a\cdot c  -  b\cdot d  +  (a\cdot e  -  b\cdot f)$,  $ a\cdot (d + f)  +  b\cdot (c + e) = a\cdot d  +  b\cdot c  +  (a\cdot f  +  b\cdot e)$ ''using''  +++^[ring_oper_distr | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>ring_oper_distr</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a\cdot (b + c) = a\cdot b  +  a\cdot c$,   $ (b + c)\cdot a = b\cdot a  +  c\cdot a$ ===  ,  +++^[Ring_ZF_1_L10 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_1_L10</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$  '' shows '' $ a + (b + c) = a + b + c$,   $ a - (b + c) = a - b - c$,   $ a - (b - c) = a - b + c$ ===  ,  +++^[Ring_ZF_2_L5 | Ring_ZF ]...  ''lemma''  ''(in'' ring0'')'' <nowiki>Ring_ZF_2_L5</nowiki>:  ''assumes '' $ a\in R$,   $ b\in R$,   $ c\in R$,   $ d\in R$  '' shows '' $ a  -  b  -  c  -  d = a  -  d  -  b  -  c$,   $ a  +  b  +  c  -  d = a  -  d  +  b  +  c$,  
$ a  +  b  -  c  -  d = a  -  c  +  (b  -  d)$,   $ a  +  b  +  c  +  d = a  +  c  +  (b  +  d)$ === 
 ''qed'' === 

 ''end

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

 ''begin
'' 
It seems that the minimal setup needed to talk about a product of a sequence is a set with a binary operation. Such object is called "magma". However, interesting properties show up when the binary operation is associative and such alebraic structure is called a semigroup. In this theory file we define and study sequences of partial products of sequences of magma and semigroup elements.

!Products of sequences of semigroup elements

Semigroup is a a magma in which the binary operation is associative. In this section we mostly study the products of sequences of elements of semigroup. The goal is to establish the fact that taking the product of a sequence is distributive with respect to concatenation of sequences, i.e for two sequences $a,b$ of the semigroup elements we have $\prod (a\sqcup b) = (\prod a)\cdot (\prod b)$, where "$a \sqcup b$" is concatenation of $a$ and $b$ ($a$$ ++$$b$ in Haskell notation). Less formally, we want to show that we can discard parantheses in expressions of the form $(a_0\cdot a_1\cdot .. \cdot a_n)\cdot (b_0\cdot .. \cdot b_k)$.

First we define a notion similar to //Fold//, except that that the initial element of the fold is given by the first element of sequence. By analogy with Haskell fold we call that //Fold1//

 ''Definition
'' $ Fold1(f,a) \equiv  Fold(f,a(0),Tail(a))$

The definition of the //semigr0// context below introduces notation for writing about finite sequences and semigroup products. In the context we fix the carrier and denote it $G$. The binary operation on $G$ is called $f$. All theorems proven in the context //semigr0// will implicitly assume that $f$ is an associative operation on $G$. We will use multiplicative notation for the semigroup operation. The product of a sequence $a$ is denoted $\prod a$. We will write $a\hookleftarrow x$ for the result of appending an element $x$ to the finite sequence (list) $a$. This is a bit nonstandard, but I don't have a better idea for the "append" notation. Finally, $a\sqcup b$ will denote the concatenation of the lists $a$ and $b$.

 ''Locale '' semigr0
 ''assumes '' assoc_assum: $ f \text{ is associative on } G$
 ''defines '' $ x \cdot  y \equiv  f\langle x,y\rangle $
 ''defines '' $ \prod  a \equiv  Fold1(f,a)$
 ''defines '' $ a \hookleftarrow  x \equiv  Append(a,x)$
 ''defines '' $ a \sqcup  b \equiv  Concat(a,b)$


The next lemma shows our assumption on the associativity of the semigroup operation in the notation defined in in the //semigr0// context.

 ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_assoc</nowiki>:
 ''   assumes '' $ x \in  G$,  $ y \in  G$,  $ z \in  G$ ''   shows '' $ x\cdot y\cdot z = x\cdot (y\cdot z)$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>assoc_assum</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  )))$=== 

In the way we define associativity the assumption that $f$ is associative on $G$ also implies that it is a binary operation on $X$.

 ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_binop</nowiki>:
 ''   shows '' $ f : G\times G \rightarrow  G$ ''using''  <nowiki>assoc_assum</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  )))$=== 

Semigroup operation is closed.

 ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_closed</nowiki>:
 ''   assumes '' $ a\in G$,  $ b\in G$ ''   shows '' $ a\cdot b \in  G$ ''using''  <nowiki>assms</nowiki> ,  +++^[semigr_binop | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_binop</nowiki>:  '' shows '' $ f : G\times G \rightarrow  G$ ===  ,  <nowiki>apply_funtype</nowiki>

Lemma //append_1elem// written in the notation used in the //semigr0// context.

 ''lemma''  ''(in'' semigr0'')'' <nowiki>append_1elem_nice</nowiki>:
 ''   assumes '' $ n \in  nat$ ''and '' $ a: n \rightarrow  X$ ''and '' $ b : 1 \rightarrow  X$ ''   shows '' $ a \sqcup  b = a \hookleftarrow  b(0)$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>append_1elem</nowiki>

Lemma //concat_init_last_elem// rewritten in the notation used in the //semigr0// context.

 ''lemma''  ''(in'' semigr0'')'' <nowiki>concat_init_last</nowiki>:
 ''   assumes '' $ n \in  nat$,  $ k \in  nat$ ''and '' $ a: n \rightarrow  X$ ''and '' $ b : succ(k) \rightarrow  X$ ''   shows '' $ (a \sqcup  Init(b)) \hookleftarrow  b(k) = a \sqcup  b$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>concat_init_last_elem</nowiki>

The product of semigroup (actually, magma -- we don't need associativity for this) elements is in the semigroup.

 ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_type</nowiki>:
 ''   assumes '' $ n \in  nat$ ''and '' $ a : succ(n) \rightarrow  G$ ''   shows '' $ (\prod  a) \in  G$+++[proof ]>
 ''from '' assms  ''have''  $ succ(n) \in  nat$,  $ f : G\times G \rightarrow  G$,  $ Tail(a) : n \rightarrow  G$ ''using''  +++^[semigr_binop | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_binop</nowiki>:  '' shows '' $ f : G\times G \rightarrow  G$ ===  ,  <nowiki>tail_props</nowiki>
 ''moreover''   ''from '' assms  ''have''  $ a(0) \in  G$ ''and '' $ G \neq  0$ ''using''  +++^[empty_in_every_succ | Nat_ZF_IML ]...  ''lemma''  <nowiki>empty_in_every_succ</nowiki>:  ''assumes '' $ n \in  nat$  '' shows '' $ 0 \in  succ(n)$ ===  ,  <nowiki>apply_funtype</nowiki>
 ''ultimately ''  ''show''  $ (\prod  a) \in  G$ ''using''  +++^[Fold1_def | Semigroup_ZF ]... Definition of <nowiki>Fold1</nowiki>:
$ Fold1(f,a) \equiv  Fold(f,a(0),Tail(a))$===  ,  +++^[fold_props | Fold_ZF ]...  ''theorem''  <nowiki>fold_props</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$,   $ a:n \rightarrow  Y$,   $ x\in X$,   $ Y\neq 0$  '' shows '' $ Fold(f,x,a) =  FoldSeq(f,x,a)(n)$  ''and'' $ Fold(f,x,a) \in  X$ === 
 ''qed'' === 

What is the product of one element list?

 ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_of_1elem</nowiki>:
 ''   assumes '' A1: $ a: 1 \rightarrow  G$ ''   shows '' $ (\prod  a) = a(0)$+++[proof ]>
 ''have''  $ f : G\times G \rightarrow  G$ ''using''  +++^[semigr_binop | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_binop</nowiki>:  '' shows '' $ f : G\times G \rightarrow  G$ === 
 ''moreover''   ''from '' A1  ''have''  $ Tail(a) : 0 \rightarrow  G$ ''using''  <nowiki>tail_props</nowiki>
 ''moreover''   ''from '' A1  ''have''  $ a(0) \in  G$ ''and '' $ G \neq  0$ ''using''  <nowiki>apply_funtype</nowiki>
 ''ultimately ''  ''show''  $ (\prod  a) =  a(0)$ ''using''  +++^[fold_empty | Fold_ZF ]...  ''theorem''  <nowiki>fold_empty</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  X$  ''and'' $ a:0\rightarrow Y$,   $ x\in X$,   $ Y\neq 0$  '' shows '' $ Fold(f,x,a) = x$ ===  ,  +++^[Fold1_def | Semigroup_ZF ]... Definition of <nowiki>Fold1</nowiki>:
$ Fold1(f,a) \equiv  Fold(f,a(0),Tail(a))$=== 
 ''qed'' === 

What happens to the product of a list when we append an element to the list?

 ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_append</nowiki>:
 ''   assumes '' A1: $ n \in  nat$ ''and '' A2: $ a : succ(n) \rightarrow  G$ ''and '' A3: $ x\in G$ ''   shows '' $ (\prod  a\hookleftarrow x) = (\prod  a) \cdot  x$+++[proof ]>
 ''from '' A1, A2  ''have''  I: $ Tail(a) : n \rightarrow  G$,  $ a(0) \in  G$ ''using''  <nowiki>tail_props</nowiki> ,  +++^[empty_in_every_succ | Nat_ZF_IML ]...  ''lemma''  <nowiki>empty_in_every_succ</nowiki>:  ''assumes '' $ n \in  nat$  '' shows '' $ 0 \in  succ(n)$ ===  ,  <nowiki>apply_funtype</nowiki>
 ''from '' assms  ''have''  $ (\prod  a\hookleftarrow x) = Fold(f,a(0),Tail(a)\hookleftarrow x)$ ''using''  <nowiki>head_of_append</nowiki> ,  <nowiki>tail_append_commute</nowiki> ,  +++^[Fold1_def | Semigroup_ZF ]... Definition of <nowiki>Fold1</nowiki>:
$ Fold1(f,a) \equiv  Fold(f,a(0),Tail(a))$=== 
 ''also''   ''from '' A1, A3, I  ''have''  $ \ldots  = (\prod  a) \cdot  x$ ''using''  +++^[semigr_binop | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_binop</nowiki>:  '' shows '' $ f : G\times G \rightarrow  G$ ===  ,  +++^[fold_append | Fold_ZF ]...  ''theorem''  <nowiki>fold_append</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ f : X\times Y \rightarrow  X$  ''and'' $ a:n\rightarrow Y$  ''and'' $ x\in X$  ''and'' $ y\in Y$  '' shows '' $ FoldSeq(f,x,Append(a,y))(n) = Fold(f,x,a)$  ''and'' $ Fold(f,x,Append(a,y)) = f\langle Fold(f,x,a), y\rangle $ ===  ,  +++^[Fold1_def | Semigroup_ZF ]... Definition of <nowiki>Fold1</nowiki>:
$ Fold1(f,a) \equiv  Fold(f,a(0),Tail(a))$=== 
 ''finally ''  ''show''  $ thesis$ 
 ''qed'' === 

The main theorem of the section: taking the product of a sequence is distributive with respect to concatenation of sequences. The proof is by induction on the length of the second list.

 ''theorem''  ''(in'' semigr0'')'' <nowiki>prod_conc_distr</nowiki>:
 ''   assumes '' A1: $ n \in  nat$,  $ k \in  nat$ ''and '' A2: $ a : succ(n) \rightarrow  G$,  $ b: succ(k) \rightarrow  G$ ''   shows '' $ (\prod  a) \cdot  (\prod  b) = \prod  (a \sqcup  b)$+++[proof ]>
 ''from '' A1  ''have''  $ k \in  nat$ 
 ''moreover''   ''have''  $ \forall b \in  succ(0) \rightarrow  G.\  (\prod  a) \cdot  (\prod  b) = \prod  (a \sqcup  b)$+++[proof ]>
++++[{ ]>
 ''fix '' $ b$
 ''assume '' A3: $ b : succ(0) \rightarrow  G$
 ''with '' A1, A2  ''have''  $ succ(n) \in  nat$,  $ a : succ(n) \rightarrow  G$,  $ b : 1 \rightarrow  G$ 
 ''then ''  ''have''  $ a \sqcup  b = a \hookleftarrow  b(0)$ ''   by (rule '' +++^[append_1elem_nice | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>append_1elem_nice</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a: n \rightarrow  X$  ''and'' $ b : 1 \rightarrow  X$  '' shows '' $ a \sqcup  b = a \hookleftarrow  b(0)$ ===  '')'' 
 ''with '' A1, A2, A3  ''have''  $ (\prod  a) \cdot  (\prod  b) = \prod  (a \sqcup  b)$ ''using''  <nowiki>apply_funtype</nowiki> ,  +++^[prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_append</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a : succ(n) \rightarrow  G$  ''and'' $ x\in G$  '' shows '' $ (\prod  a\hookleftarrow x) = (\prod  a) \cdot  x$ ===  ,  +++^[semigr_binop | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_binop</nowiki>:  '' shows '' $ f : G\times G \rightarrow  G$ ===  ,  +++^[prod_of_1elem | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_of_1elem</nowiki>:  ''assumes '' $ a: 1 \rightarrow  G$  '' shows '' $ (\prod  a) = a(0)$ === 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''have''  $ \forall j \in  nat.\  $
$    (\forall b \in  succ(j) \rightarrow  G.\  (\prod  a) \cdot  (\prod  b) = \prod  (a \sqcup  b)) \longrightarrow $
$    (\forall b \in  succ(succ(j)) \rightarrow  G.\  (\prod  a) \cdot  (\prod  b) = \prod  (a \sqcup  b))$+++[proof ]>
++++[{ ]>
 ''fix '' $ j$
 ''assume '' A4: $ j \in  nat$ ''and '' A5: $ (\forall b \in  succ(j) \rightarrow  G.\  (\prod  a) \cdot  (\prod  b) = \prod  (a \sqcup  b))$
++++[{ ]>
 ''fix '' $ b$
 ''assume '' A6: $ b : succ(succ(j)) \rightarrow  G$
 ''let '' $ c = Init(b)$
 ''from '' A4, A6  ''have''  T: $ b(succ(j)) \in  G$ ''and '' I: $ c : succ(j) \rightarrow  G$ ''and '' II: $ b = c\hookleftarrow b(succ(j))$ ''using''  <nowiki>apply_funtype</nowiki> ,  <nowiki>init_props</nowiki>
 ''from '' A1, A2, A4, A6  ''have''  $ succ(n) \in  nat$,  $ succ(j) \in  nat$,  $ a : succ(n) \rightarrow  G$,  $ b : succ(succ(j)) \rightarrow  G$ 
 ''then ''  ''have''  III: $ (a \sqcup  c) \hookleftarrow  b(succ(j)) = a \sqcup  b$ ''   by (rule '' +++^[concat_init_last | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>concat_init_last</nowiki>:  ''assumes '' $ n \in  nat$,   $ k \in  nat$  ''and'' $ a: n \rightarrow  X$  ''and'' $ b : succ(k) \rightarrow  X$  '' shows '' $ (a \sqcup  Init(b)) \hookleftarrow  b(k) = a \sqcup  b$ ===  '')'' 
 ''from '' A4, I, T  ''have''  $ (\prod  c\hookleftarrow b(succ(j))) = (\prod  c) \cdot  b(succ(j))$ ''   by (rule '' +++^[prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_append</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a : succ(n) \rightarrow  G$  ''and'' $ x\in G$  '' shows '' $ (\prod  a\hookleftarrow x) = (\prod  a) \cdot  x$ ===  '')'' 
 ''with '' II  ''have''  $ (\prod  a) \cdot  (\prod  b) = (\prod  a) \cdot  ((\prod  c) \cdot  b(succ(j)))$ 
 ''moreover''   ''from '' A1, A2, A4, T, I  ''have''  $ (\prod  a) \in  G$,  $ (\prod  c) \in  G$,  $ b(succ(j)) \in  G$ ''using''  +++^[prod_type | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_type</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a : succ(n) \rightarrow  G$  '' shows '' $ (\prod  a) \in  G$ === 
 ''ultimately ''  ''have''  $ (\prod  a) \cdot  (\prod  b) =  ((\prod  a) \cdot  (\prod  c)) \cdot  b(succ(j))$ ''using''  +++^[semigr_assoc | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_assoc</nowiki>:  ''assumes '' $ x \in  G$,   $ y \in  G$,   $ z \in  G$  '' shows '' $ x\cdot y\cdot z = x\cdot (y\cdot z)$ === 
 ''with '' A5, I  ''have''  $ (\prod  a) \cdot  (\prod  b) = (\prod  (a \sqcup  c))\cdot b(succ(j))$ 
 ''moreover''   ''from '' A1, A2, A4, I  ''have''  T1: $ succ(n) \in  nat$,  $ succ(j) \in  nat$ ''and '' $ a : succ(n) \rightarrow  G$,  $ c : succ(j) \rightarrow  G$ 
 ''then ''  ''have''  $ Concat(a,c): succ(n) \ \sharp + succ(j) \rightarrow  G$ ''   by (rule '' <nowiki>concat_props</nowiki> '')'' 
 ''with '' A1, A4, T  ''have''  $ succ(n \ \sharp + j) \in  nat$,  $ a \sqcup  c : succ(succ(n \ \sharp +j)) \rightarrow  G$,  $ b(succ(j)) \in  G$ ''using''  +++^[succ_plus | Nat_ZF_IML ]...  ''lemma''  <nowiki>succ_plus</nowiki>:  ''assumes '' $ n \in  nat$,   $ k \in  nat$  '' shows '' $ succ(n \ \sharp + j) \in  nat$,   $ succ(n) \ \sharp + succ(j) = succ(succ(n \ \sharp + j))$ === 
 ''then ''  ''have''  $ (\prod  (a \sqcup  c)\hookleftarrow b(succ(j))) = (\prod  (a \sqcup  c))\cdot b(succ(j))$ ''   by (rule '' +++^[prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_append</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a : succ(n) \rightarrow  G$  ''and'' $ x\in G$  '' shows '' $ (\prod  a\hookleftarrow x) = (\prod  a) \cdot  x$ ===  '')'' 
 ''with '' III  ''have''  $ (\prod  (a \sqcup  c))\cdot b(succ(j)) =  \prod  (a \sqcup  b)$ 
 ''ultimately ''  ''have''  $ (\prod  a) \cdot  (\prod  b) = \prod  (a \sqcup  b)$ 
===  ''}'' 
 ''hence''  $ (\forall b \in  succ(succ(j)) \rightarrow  G.\  (\prod  a) \cdot  (\prod  b) = \prod  (a \sqcup  b))$
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''ultimately ''  ''have''  $ \forall b \in  succ(k) \rightarrow  G.\  (\prod  a) \cdot  (\prod  b) = \prod  (a \sqcup  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)$ ===  '')'' 
 ''with '' A2  ''show''  $ (\prod  a) \cdot  (\prod  b) = \prod  (a \sqcup  b)$ 
 ''qed'' === 


!Products over sets of indices

In this section we study the properties of expressions of the form $\prod_{i\in \Lambda} a_i = a_{i_0}\cdot a_{i_1} \cdot .. \cdot a_{i-1}$, i.e. what we denote as $ \prod (\Lambda ,a)$. $\Lambda$ here is a finite subset of some set $X$ and $a$ is a function defined on $X$ with values in the semigroup $G$.

Suppose $a: X \rightarrow G$ is an indexed family of elements of a semigroup $G$ and $\Lambda = \{i_0, i_1, .. , i_{n-1}\} \subseteq \mathbb{N}$ is a finite set of indices. We want to define $\prod_{i\in \Lambda} a_i = a_{i_0}\cdot a_{i_1} \cdot .. \cdot a_{i-1}$. To do that we use the notion of //Enumeration// defined in the //Enumeration_ZF// theory file that takes a set of indices and lists them in increasing order, thus converting it to list. Then we use the //Fold1// to multiply the resulting list. Recall that in Isabelle/ZF the capital letter ''O'' denotes the composition of two functions (or relations).

 ''Definition
'' $ SetFold(f,a,\Lambda ,r) = Fold1(f,a\circ Enumeration(\Lambda ,r))$

For a finite subset $\Lambda$ of a linearly ordered set $X$ we will write $\sigma (\Lambda )$ to denote the enumeration of the elements of $\Lambda$, i.e. the only order isomorphism $|\Lambda | \rightarrow \Lambda$, where $|\Lambda | \in \mathbb{N}$ is the number of elements of $\Lambda $. We also define notation for taking a product over a set of indices of some sequence of semigroup elements. The product of semigroup elements over some set $\Lambda \subseteq X$ of indices of a sequence $a: X \rightarrow G$ (i.e. $\prod_{i\in \Lambda} a_i$) is denoted $ \prod (\Lambda ,a)$. In the //semigr1// context we assume that $a$ is a function defined on some linearly ordered set $X$ with values in the semigroup $G$.

 ''Locale '' semigr1 = semigr0  +
 ''assumes '' linord: $ IsLinOrder(X,r)$
 ''assumes '' a_is_fun: $ a : X \rightarrow  G$
 ''defines '' $ \sigma (A) \equiv  Enumeration(A,r)$
 ''defines '' $ \prod (\Lambda ,b) \equiv  SetFold(f,b,\Lambda ,r)$


We can use the //enums// locale in the //semigr0// context.

 ''lemma''  ''(in'' semigr1'')'' <nowiki>enums_valid_in_semigr1</nowiki>:
 ''   shows '' $ enums(X,r)$ ''using''  <nowiki>linord</nowiki> ,  <nowiki>enums_def</nowiki>

Definition of product over a set expressed in notation of the //semigr0// locale.

 ''lemma''  ''(in'' semigr1'')'' <nowiki>setproddef</nowiki>:
 ''   shows '' $ \prod (\Lambda ,a) = \prod  (a\circ \sigma (\Lambda ))$ ''using''  +++^[SetFold_def | Semigroup_ZF ]... Definition of <nowiki>SetFold</nowiki>:
$ SetFold(f,a,\Lambda ,r) = Fold1(f,a\circ Enumeration(\Lambda ,r))$=== 

A composition of enumeration of a nonempty finite subset of $\mathbb{N}$ with a sequence of elements of $G$ is a nonempty list of elements of $G$. This implies that a product over set of a finite set of indices belongs to the (carrier of) semigroup.

 ''lemma''  ''(in'' semigr1'')'' <nowiki>setprod_type</nowiki>:
 ''   assumes '' A1: $ \Lambda  \in  FinPow(X)$ ''and '' A2: $ \Lambda \neq 0$ ''   shows '' $ \exists n \in  nat .\  |\Lambda | = succ(n) \wedge  a\circ \sigma (\Lambda ) : succ(n) \rightarrow  G$ ''and '' $ \prod (\Lambda ,a) \in  G$+++[proof ]>
 ''from '' assms  ''obtain '' $ n$ ''where '' $ n \in  nat$ ''and '' $ |\Lambda | = succ(n)$ ''using''  +++^[card_non_empty_succ | Finite_ZF ]...  ''lemma''  <nowiki>card_non_empty_succ</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  ''and'' $ A \neq  0$  '' shows '' $ \exists n \in  nat.\  |A| = succ(n)$ === 
 ''from '' A1  ''have''  $ \sigma (\Lambda ) : |\Lambda | \rightarrow  \Lambda $ ''using''  +++^[enums_valid_in_semigr1 | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>enums_valid_in_semigr1</nowiki>:  '' shows '' $ enums(X,r)$ ===  ,  <nowiki>enums.enum_props</nowiki>
 ''with '' A1  ''have''  $ a\circ \sigma (\Lambda ): |\Lambda | \rightarrow  G$ ''using''  <nowiki>a_is_fun</nowiki> ,  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$===  ,  +++^[comp_fun_subset | func1 ]...  ''lemma''  <nowiki>comp_fun_subset</nowiki>:  ''assumes '' $ g:A\rightarrow B$  ''and'' $ f:C\rightarrow D$  ''and'' $ B \subseteq  C$  '' shows '' $ f\circ g : A \rightarrow  D$ === 
 ''with '' $ n \in  nat$, and, $ |\Lambda | = succ(n)$  ''show''  $ \exists n \in  nat .\  |\Lambda | = succ(n) \wedge  a\circ \sigma (\Lambda ) : succ(n) \rightarrow  G$ 
 ''from '' $ n \in  nat$, $ |\Lambda | = succ(n)$, $ a\circ \sigma (\Lambda ): |\Lambda | \rightarrow  G$  ''show''  $ \prod (\Lambda ,a) \in  G$ ''using''  +++^[prod_type | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_type</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a : succ(n) \rightarrow  G$  '' shows '' $ (\prod  a) \in  G$ ===  ,  +++^[setproddef | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>setproddef</nowiki>:  '' shows '' $ \prod (\Lambda ,a) = \prod  (a\circ \sigma (\Lambda ))$ === 
 ''qed'' === 

The //enum_append// lemma from the //Enemeration// theory specialized for natural numbers.

 ''lemma''  ''(in'' semigr1'')'' <nowiki>semigr1_enum_append</nowiki>:
 ''   assumes '' $ \Lambda  \in  FinPow(X)$ ''and '' $ n \in  X - \Lambda $ ''and '' $ \forall k\in \Lambda .\  \langle k,n\rangle  \in  r$ ''   shows '' $ \sigma (\Lambda  \cup  \{n\}) = \sigma (\Lambda )\hookleftarrow  n$ ''using''  <nowiki>assms</nowiki> ,  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$===  ,  +++^[enums_valid_in_semigr1 | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>enums_valid_in_semigr1</nowiki>:  '' shows '' $ enums(X,r)$ ===  ,  <nowiki>enums.enum_append</nowiki>

What is product over a singleton?

 ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_prod_singleton</nowiki>:
 ''   assumes '' A1: $ x \in  X$ ''   shows '' $ \prod (\{x\},a) = a(x)$+++[proof ]>
 ''from '' A1  ''have''  $ \sigma (\{x\}): 1 \rightarrow  X$ ''and '' $ \sigma (\{x\})(0) = x$ ''using''  +++^[enums_valid_in_semigr1 | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>enums_valid_in_semigr1</nowiki>:  '' shows '' $ enums(X,r)$ ===  ,  <nowiki>enums.enum_singleton</nowiki>
 ''then ''  ''show''  $ \prod (\{x\},a) = a(x)$ ''using''  <nowiki>a_is_fun</nowiki> ,  <nowiki>comp_fun</nowiki> ,  +++^[setproddef | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>setproddef</nowiki>:  '' shows '' $ \prod (\Lambda ,a) = \prod  (a\circ \sigma (\Lambda ))$ ===  ,  +++^[prod_of_1elem | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_of_1elem</nowiki>:  ''assumes '' $ a: 1 \rightarrow  G$  '' shows '' $ (\prod  a) = a(0)$ ===  ,  <nowiki>comp_fun_apply</nowiki>
 ''qed'' === 

A generalization of //prod_append// to the products over sets of indices.

 ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_prod_append</nowiki>:
 ''   assumes '' A1: $ \Lambda  \in  FinPow(X)$ ''and '' A2: $ \Lambda  \neq  0$ ''and '' A3: $ n \in  X -  \Lambda $ ''and '' A4: $ \forall k\in \Lambda .\  \langle k,n\rangle  \in  r$ ''   shows '' $ \prod (\Lambda  \cup  \{n\}, a) = (\prod (\Lambda ,a)) \cdot  a(n)$+++[proof ]>
 ''have''  $ \prod (\Lambda  \cup  \{n\}, a) =  \prod  (a\circ \sigma (\Lambda  \cup  \{n\}))$ ''using''  +++^[setproddef | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>setproddef</nowiki>:  '' shows '' $ \prod (\Lambda ,a) = \prod  (a\circ \sigma (\Lambda ))$ === 
 ''also''   ''from '' A1, A3, A4  ''have''  $ \ldots  = \prod  (a\circ (\sigma (\Lambda )\hookleftarrow  n))$ ''using''  +++^[semigr1_enum_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>semigr1_enum_append</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ n \in  X - \Lambda $  ''and'' $ \forall k\in \Lambda .\  \langle k,n\rangle  \in  r$  '' shows '' $ \sigma (\Lambda  \cup  \{n\}) = \sigma (\Lambda )\hookleftarrow  n$ === 
 ''also''   ''have''  $ \ldots  = \prod  ((a\circ \sigma (\Lambda ))\hookleftarrow  a(n))$+++[proof ]>
 ''from '' A1, A3  ''have''  $ |\Lambda | \in  nat$ ''and '' $ \sigma (\Lambda ) : |\Lambda | \rightarrow  X$ ''and '' $ n \in  X$ ''using''  +++^[card_fin_is_nat | Finite_ZF ]...  ''lemma''  <nowiki>card_fin_is_nat</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ |A| \in  nat$  ''and'' $ A \approx  |A|$ ===  ,  +++^[enums_valid_in_semigr1 | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>enums_valid_in_semigr1</nowiki>:  '' shows '' $ enums(X,r)$ ===  ,  <nowiki>enums.enum_fun</nowiki>
 ''then ''  ''show''  $ thesis$ ''using''  <nowiki>a_is_fun</nowiki> ,  <nowiki>list_compose_append</nowiki>
 ''qed'' === 
 ''also''   ''from '' assms  ''have''  $ \ldots  = (\prod  (a\circ \sigma (\Lambda )))\cdot a(n)$ ''using''  <nowiki>a_is_fun</nowiki> ,  +++^[setprod_type | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>setprod_type</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda \neq 0$  '' shows '' $ \exists n \in  nat .\  |\Lambda | = succ(n) \wedge  a\circ \sigma (\Lambda ) : succ(n) \rightarrow  G$
 ''and'' $ \prod (\Lambda ,a) \in  G$ ===  ,  <nowiki>apply_funtype</nowiki> ,  +++^[prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_append</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a : succ(n) \rightarrow  G$  ''and'' $ x\in G$  '' shows '' $ (\prod  a\hookleftarrow x) = (\prod  a) \cdot  x$ === 
 ''also''   ''have''  $ \ldots  = (\prod (\Lambda ,a)) \cdot  a(n)$ ''using''  +++^[SetFold_def | Semigroup_ZF ]... Definition of <nowiki>SetFold</nowiki>:
$ SetFold(f,a,\Lambda ,r) = Fold1(f,a\circ Enumeration(\Lambda ,r))$=== 
 ''finally ''  ''show''  $ \prod (\Lambda  \cup  \{n\}, a) = (\prod (\Lambda ,a)) \cdot  a(n)$ 
 ''qed'' === 

Very similar to //gen_prod_append//: a relation between a product over a set of indices and the product over the set with the maximum removed.

 ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_product_rem_point</nowiki>:
 ''   assumes '' A1: $ A \in  FinPow(X)$ ''and '' A2: $ n \in  A$ ''and '' A4: $ A - \{n\} \neq  0$ ''and '' A3: $ \forall k\in A.\  \langle k, n\rangle  \in  r$ ''   shows '' $ (\prod (A - \{n\},a)) \cdot  a(n) = \prod (A, a)$+++[proof ]>
 ''let '' $ \Lambda  = A - \{n\}$
 ''from '' A1, A2  ''have''  $ \Lambda  \in  FinPow(X)$ ''and '' $ n \in  X -  \Lambda $ ''using''  +++^[fin_rem_point_fin | Finite_ZF ]...  ''corollary''  <nowiki>fin_rem_point_fin</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  '' shows '' $ A - \{a\} \in  FinPow(X)$ ===  ,  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 
 ''with '' A3, A4  ''have''  $ \prod (\Lambda  \cup  \{n\}, a) = (\prod (\Lambda ,a)) \cdot  a(n)$ ''using''  <nowiki>a_is_fun</nowiki> ,  +++^[gen_prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_prod_append</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda  \neq  0$  ''and'' $ n \in  X -  \Lambda $  ''and'' $ \forall k\in \Lambda .\  \langle k,n\rangle  \in  r$  '' shows '' $ \prod (\Lambda  \cup  \{n\}, a) = (\prod (\Lambda ,a)) \cdot  a(n)$ === 
 ''with '' A2  ''show''  $ thesis$ ''using''  +++^[rem_add_eq | Finite_ZF ]...  ''lemma''  <nowiki>rem_add_eq</nowiki>:  ''assumes '' $ a\in A$  '' shows '' $ (A-\{a\}) \cup  \{a\} = A$ === 
 ''qed'' === 


!Commutative semigroups

Commutative semigroups are those whose operation is commutative, i.e. $\cdot b = b\cdot a$. This implies that for any permutation $s : n \rightarrow n$ we have $\prod_{j=0}^n a_j = \prod_{j=0}^n a_{s (j)}$, or, closer to the notation we are using in the //semigr0// context, $\prod a = \prod (a \circ s )$. Maybe one day we will be able to prove this, but for now the goal is to prove something simpler: that if the semigroup operation is commutative taking the product of a sequence is distributive with respect to the operation: $\prod_{j=0}^n (a_j\cdot b_j) = \left(\prod_{j=0}^n a_j)\right) \left(\prod_{j=0}^n b_j)\right)$. Many of the rearrangements (namely those that don't use the inverse) proven in the //AbelianGroup_ZF// theory hold in fact in semigroups. Some of them will be reproven in this section.

A rearrangement with 3 elements.

 ''lemma''  ''(in'' semigr0'')'' <nowiki>rearr3elems</nowiki>:
 ''   assumes '' $ f \text{ is commutative on } G$ ''and '' $ a\in G$,  $ b\in G$,  $ c\in G$ ''   shows '' $ a\cdot b\cdot c = a\cdot c\cdot b$ ''using''  <nowiki>assms</nowiki> ,  +++^[semigr_assoc | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_assoc</nowiki>:  ''assumes '' $ x \in  G$,   $ y \in  G$,   $ z \in  G$  '' shows '' $ x\cdot y\cdot z = x\cdot (y\cdot z)$ ===  ,  +++^[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 $=== 

A rearrangement of four elements.

 ''lemma''  ''(in'' semigr0'')'' <nowiki>rearr4elems</nowiki>:
 ''   assumes '' A1: $ f \text{ is commutative on } G$ ''and '' A2: $ a\in G$,  $ b\in G$,  $ c\in G$,  $ d\in G$ ''   shows '' $ a\cdot b\cdot (c\cdot d) = a\cdot c\cdot (b\cdot d)$+++[proof ]>
 ''from '' A2  ''have''  $ a\cdot b\cdot (c\cdot d) = a\cdot b\cdot c\cdot d$ ''using''  +++^[semigr_closed | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ ===  ,  +++^[semigr_assoc | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_assoc</nowiki>:  ''assumes '' $ x \in  G$,   $ y \in  G$,   $ z \in  G$  '' shows '' $ x\cdot y\cdot z = x\cdot (y\cdot z)$ === 
 ''also''   ''have''  $ a\cdot b\cdot c\cdot d =  a\cdot c\cdot (b\cdot d)$+++[proof ]>
 ''from '' A1, A2  ''have''  $ a\cdot b\cdot c\cdot d = c\cdot (a\cdot b)\cdot d$ ''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 $===  ,  +++^[semigr_closed | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  =  c\cdot a\cdot b\cdot d$ ''using''  +++^[semigr_closed | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ ===  ,  +++^[semigr_assoc | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_assoc</nowiki>:  ''assumes '' $ x \in  G$,   $ y \in  G$,   $ z \in  G$  '' shows '' $ x\cdot y\cdot z = x\cdot (y\cdot z)$ === 
 ''also''   ''from '' A1, A2  ''have''  $ \ldots  = a\cdot c\cdot b\cdot d$ ''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 $===  ,  +++^[semigr_closed | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ === 
 ''also''   ''from '' A2  ''have''  $ \ldots  = a\cdot c\cdot (b\cdot d)$ ''using''  +++^[semigr_closed | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_closed</nowiki>:  ''assumes '' $ a\in G$,   $ b\in G$  '' shows '' $ a\cdot b \in  G$ ===  ,  +++^[semigr_assoc | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_assoc</nowiki>:  ''assumes '' $ x \in  G$,   $ y \in  G$,   $ z \in  G$  '' shows '' $ x\cdot y\cdot z = x\cdot (y\cdot z)$ === 
 ''finally ''  ''show''  $ a\cdot b\cdot c\cdot d =  a\cdot c\cdot (b\cdot d)$ 
 ''qed'' === 
 ''finally ''  ''show''  $ a\cdot b\cdot (c\cdot d) = a\cdot c\cdot (b\cdot d)$ 
 ''qed'' === 

We start with a version of //prod_append// that will shorten a bit the proof of the main theorem.

 ''lemma''  ''(in'' semigr0'')'' <nowiki>shorter_seq</nowiki>:
 ''   assumes '' A1: $ k \in  nat$ ''and '' A2: $ a \in  succ(succ(k)) \rightarrow  G$ ''   shows '' $ (\prod  a) = (\prod  Init(a)) \cdot  a(succ(k))$+++[proof ]>
 ''let '' $ x = Init(a)$
 ''from '' assms  ''have''  $ a(succ(k)) \in  G$ ''and '' $ x : succ(k) \rightarrow  G$ ''using''  <nowiki>apply_funtype</nowiki> ,  <nowiki>init_props</nowiki>
 ''with '' A1  ''have''  $ (\prod  x\hookleftarrow a(succ(k))) = (\prod  x) \cdot  a(succ(k))$ ''using''  +++^[prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_append</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a : succ(n) \rightarrow  G$  ''and'' $ x\in G$  '' shows '' $ (\prod  a\hookleftarrow x) = (\prod  a) \cdot  x$ === 
 ''with '' assms  ''show''  $ thesis$ ''using''  <nowiki>init_props</nowiki>
 ''qed'' === 

A lemma useful in the induction step of the main theorem.

 ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_distr_ind_step</nowiki>:
 ''   assumes '' A1: $ k \in  nat$ ''and '' A2: $ a : succ(succ(k)) \rightarrow  G$ ''and '' A3: $ b : succ(succ(k)) \rightarrow  G$ ''and '' A4: $ c : succ(succ(k)) \rightarrow  G$ ''and '' A5: $ \forall j\in succ(succ(k)).\  c(j) = a(j) \cdot  b(j)$ ''   shows '' $ Init(a) : succ(k) \rightarrow  G$,  $ Init(b) : succ(k) \rightarrow  G$,  $ Init(c) : succ(k) \rightarrow  G$,  $ \forall j\in succ(k).\  Init(c)(j) = Init(a)(j) \cdot  Init(b)(j)$+++[proof ]>
 ''from '' A1, A2, A3, A4  ''show''  $ Init(a) : succ(k) \rightarrow  G$,  $ Init(b) : succ(k) \rightarrow  G$,  $ Init(c) : succ(k) \rightarrow  G$ ''using''  <nowiki>init_props</nowiki>
 ''from '' A1  ''have''  T: $ succ(k) \in  nat$ 
 ''from '' T, A2  ''have''  $ \forall j\in succ(k).\  Init(a)(j) = a(j)$ ''   by (rule '' <nowiki>init_props</nowiki> '')'' 
 ''moreover''   ''from '' T, A3  ''have''  $ \forall j\in succ(k).\  Init(b)(j) = b(j)$ ''   by (rule '' <nowiki>init_props</nowiki> '')'' 
 ''moreover''   ''from '' T, A4  ''have''  $ \forall j\in succ(k).\  Init(c)(j) = c(j)$ ''   by (rule '' <nowiki>init_props</nowiki> '')'' 
 ''moreover''   ''from '' A5  ''have''  $ \forall j\in succ(k).\  c(j) = a(j) \cdot  b(j)$ 
 ''ultimately ''  ''show''  $ \forall j\in succ(k).\  Init(c)(j) = Init(a)(j) \cdot  Init(b)(j)$ 
 ''qed'' === 

For commutative operations taking the product of a sequence is distributive with respect to the operation. This version will probably not be used in applications, it is formulated in a way that is easier to prove by induction. For a more convenient formulation see //prod_comm_distrib//. The proof by induction on the length of the sequence.

 ''theorem''  ''(in'' semigr0'')'' <nowiki>prod_comm_distr</nowiki>:
 ''   assumes '' A1: $ f \text{ is commutative on } G$ ''and '' A2: $ n\in nat$ ''   shows '' $ \forall  a b c.\  $
$  (a : succ(n)\rightarrow G \wedge  b : succ(n)\rightarrow G \wedge  c : succ(n)\rightarrow G \wedge  $
$  (\forall j\in succ(n).\  c(j) = a(j) \cdot  b(j))) \longrightarrow $
$  (\prod  c) = (\prod  a) \cdot  (\prod  b)$+++[proof ]>
 ''note '' A2
 ''moreover''   ''have''  $ \forall  a b c.\  $
$    (a : succ(0)\rightarrow G \wedge  b : succ(0)\rightarrow G \wedge  c : succ(0)\rightarrow G \wedge  $
$    (\forall j\in succ(0).\  c(j) = a(j) \cdot  b(j))) \longrightarrow $
$    (\prod  c) = (\prod  a) \cdot  (\prod  b)$+++[proof ]>
++++[{ ]>
 ''fix '' $ a$ $ b$ $ c$
 ''assume '' $ a : succ(0)\rightarrow G \wedge  b : succ(0)\rightarrow G \wedge  c : succ(0)\rightarrow G \wedge  $
$	(\forall j\in succ(0).\  c(j) = a(j) \cdot  b(j))$
 ''then ''  ''have''  I: $ a : 1\rightarrow G$,  $ b : 1\rightarrow G$,  $ c : 1\rightarrow G$ ''and '' II: $ c(0) = a(0) \cdot  b(0)$ 
 ''from '' I  ''have''  $ (\prod  a) = a(0)$ ''and '' $ (\prod  b) = b(0)$ ''and '' $ (\prod  c) = c(0)$ ''using''  +++^[prod_of_1elem | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_of_1elem</nowiki>:  ''assumes '' $ a: 1 \rightarrow  G$  '' shows '' $ (\prod  a) = a(0)$ === 
 ''with '' II  ''have''  $ (\prod  c) = (\prod  a) \cdot  (\prod  b)$ 
===  ''}'' 
 ''then ''  ''show''  $ thesis$ ''using''  +++^[Fold1_def | Semigroup_ZF ]... Definition of <nowiki>Fold1</nowiki>:
$ Fold1(f,a) \equiv  Fold(f,a(0),Tail(a))$=== 
 ''qed'' === 
 ''moreover''   ''have''  $ \forall k \in  nat.\  $
$    (\forall  a b c.\  $
$    (a : succ(k)\rightarrow G \wedge  b : succ(k)\rightarrow G \wedge  c : succ(k)\rightarrow G \wedge  $
$    (\forall j\in succ(k).\  c(j) = a(j) \cdot  b(j))) \longrightarrow $
$    (\prod  c) = (\prod  a) \cdot  (\prod  b)) \longrightarrow $
$    (\forall  a b c.\  $
$    (a : succ(succ(k))\rightarrow G \wedge  b : succ(succ(k))\rightarrow G \wedge  c : succ(succ(k))\rightarrow G \wedge  $
$    (\forall j\in succ(succ(k)).\  c(j) = a(j) \cdot  b(j))) \longrightarrow $
$    (\prod  c) = (\prod  a) \cdot  (\prod  b))$+++[proof ]>
 ''fix '' $ k$
 ''assume '' $ k \in  nat$
 ''show''  $ (\forall a b c.\ $
$      a \in  succ(k) \rightarrow  G \wedge $
$      b \in  succ(k) \rightarrow  G \wedge  c \in  succ(k) \rightarrow  G \wedge  $
$      (\forall j\in succ(k).\  c(j) = a(j) \cdot  b(j)) \longrightarrow $
$      (\prod  c) = (\prod  a) \cdot  (\prod  b)) \longrightarrow $
$      (\forall a b c.\ $
$      a \in  succ(succ(k)) \rightarrow  G \wedge $
$      b \in  succ(succ(k)) \rightarrow  G \wedge $
$      c \in  succ(succ(k)) \rightarrow  G \wedge  $
$      (\forall j\in succ(succ(k)).\  c(j) = a(j) \cdot  b(j)) \longrightarrow $
$      (\prod  c) = (\prod  a) \cdot  (\prod  b))$+++[proof ]>
 ''assume '' A3: $ \forall a b c.\ $
$	a \in  succ(k) \rightarrow  G \wedge $
$	b \in  succ(k) \rightarrow  G \wedge  c \in  succ(k) \rightarrow  G \wedge  $
$	(\forall j\in succ(k).\  c(j) = a(j) \cdot  b(j)) \longrightarrow $
$	(\prod  c) = (\prod  a) \cdot  (\prod  b)$
 ''show''  $ \forall a b c.\ $
$	a \in  succ(succ(k)) \rightarrow  G \wedge $
$	b \in  succ(succ(k)) \rightarrow  G \wedge $
$	c \in  succ(succ(k)) \rightarrow  G \wedge  $
$	(\forall j\in succ(succ(k)).\  c(j) = a(j) \cdot  b(j)) \longrightarrow $
$	(\prod  c) = (\prod  a) \cdot  (\prod  b)$+++[proof ]>
++++[{ ]>
 ''fix '' $ a$ $ b$ $ c$
 ''assume '' $ a \in  succ(succ(k)) \rightarrow  G \wedge $
$	    b \in  succ(succ(k)) \rightarrow  G \wedge $
$	    c \in  succ(succ(k)) \rightarrow  G \wedge  $
$	    (\forall j\in succ(succ(k)).\  c(j) = a(j) \cdot  b(j))$
 ''with '' $ k \in  nat$  ''have''  I: $ a : succ(succ(k)) \rightarrow  G$,  $ b : succ(succ(k)) \rightarrow  G$,  $ c : succ(succ(k)) \rightarrow  G$ ''and '' II: $ \forall j\in succ(succ(k)).\  c(j) = a(j) \cdot  b(j)$ 
 ''let '' $ x = Init(a)$
 ''let '' $ y = Init(b)$
 ''let '' $ z = Init(c)$
 ''from '' $ k \in  nat$, I  ''have''  III: $ (\prod  a) = (\prod  x) \cdot  a(succ(k))$,  $ (\prod  b) = (\prod  y) \cdot  b(succ(k))$ ''and '' IV: $ (\prod  c) = (\prod  z) \cdot  c(succ(k))$ ''using''  +++^[shorter_seq | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>shorter_seq</nowiki>:  ''assumes '' $ k \in  nat$  ''and'' $ a \in  succ(succ(k)) \rightarrow  G$  '' shows '' $ (\prod  a) = (\prod  Init(a)) \cdot  a(succ(k))$ === 
 ''moreover''   ''from '' $ k \in  nat$, I, II  ''have''  $ x : succ(k) \rightarrow  G$,  $ y : succ(k) \rightarrow  G$,  $ z : succ(k) \rightarrow  G$ ''and '' $ \forall j\in succ(k).\  z(j) = x(j) \cdot  y(j)$ ''using''  +++^[prod_distr_ind_step | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_distr_ind_step</nowiki>:  ''assumes '' $ k \in  nat$  ''and'' $ a : succ(succ(k)) \rightarrow  G$  ''and'' $ b : succ(succ(k)) \rightarrow  G$  ''and'' $ c : succ(succ(k)) \rightarrow  G$  ''and'' $ \forall j\in succ(succ(k)).\  c(j) = a(j) \cdot  b(j)$  '' shows '' $ Init(a) : succ(k) \rightarrow  G$,  
$ Init(b) : succ(k) \rightarrow  G$,   $ Init(c) : succ(k) \rightarrow  G$,  
$ \forall j\in succ(k).\  Init(c)(j) = Init(a)(j) \cdot  Init(b)(j)$ === 
 ''with '' A3, II, IV  ''have''  $ (\prod  c) = (\prod  x)\cdot (\prod  y)\cdot (a(succ(k)) \cdot  b(succ(k)))$ 
 ''moreover''   ''from '' A1, $ k \in  nat$, I, III  ''have''  $ (\prod  x)\cdot (\prod  y)\cdot (a(succ(k)) \cdot  b(succ(k)))=$
$	    (\prod  a) \cdot  (\prod  b)$ ''using''  <nowiki>init_props</nowiki> ,  +++^[prod_type | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_type</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a : succ(n) \rightarrow  G$  '' shows '' $ (\prod  a) \in  G$ ===  ,  <nowiki>apply_funtype</nowiki> ,  +++^[rearr4elems | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>rearr4elems</nowiki>:  ''assumes '' $ f \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$,   $ d\in G$  '' shows '' $ a\cdot b\cdot (c\cdot d) = a\cdot c\cdot (b\cdot d)$ === 
 ''ultimately ''  ''have''  $ (\prod  c) = (\prod  a) \cdot  (\prod  b)$ 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''qed'' === 
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ ''   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)$ ===  '')'' 
 ''qed'' === 

A reformulation of //prod_comm_distr// that is more convenient in applications.

 ''theorem''  ''(in'' semigr0'')'' <nowiki>prod_comm_distrib</nowiki>:
 ''   assumes '' $ f \text{ is commutative on } G$ ''and '' $ n\in nat$ ''and '' $ a : succ(n)\rightarrow G$,  $ b : succ(n)\rightarrow G$,  $ c : succ(n)\rightarrow G$ ''and '' $ \forall j\in succ(n).\  c(j) = a(j) \cdot  b(j)$ ''   shows '' $ (\prod  c) = (\prod  a) \cdot  (\prod  b)$ ''using''  <nowiki>assms</nowiki> ,  +++^[prod_comm_distr | Semigroup_ZF ]...  ''theorem''  ''(in'' semigr0'')'' <nowiki>prod_comm_distr</nowiki>:  ''assumes '' $ f \text{ is commutative on } G$  ''and'' $ n\in nat$  '' shows '' $ \forall  a b c.\  $
$  (a : succ(n)\rightarrow G \wedge  b : succ(n)\rightarrow G \wedge  c : succ(n)\rightarrow G \wedge  $
$  (\forall j\in succ(n).\  c(j) = a(j) \cdot  b(j))) \longrightarrow $
$  (\prod  c) = (\prod  a) \cdot  (\prod  b)$
=== 

A product of two products over disjoint sets of indices is the product over the union.

 ''lemma''  ''(in'' semigr1'')'' <nowiki>prod_bisect</nowiki>:
 ''   assumes '' A1: $ f \text{ is commutative on } G$ ''and '' A2: $ \Lambda  \in  FinPow(X)$ ''   shows '' $ \forall P \in   Bisections(\Lambda ).\  \prod (\Lambda ,a) = (\prod (fst(P),a))\cdot (\prod (snd(P),a))$+++[proof ]>
 ''have''  $ IsLinOrder(X,r)$ ''using''  <nowiki>linord</nowiki>
 ''moreover''   ''have''  $ \forall P \in   Bisections(0).\  \prod (0,a) = (\prod (fst(P),a))\cdot (\prod (snd(P),a))$ ''using''  +++^[bisec_empty | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_empty</nowiki>:  '' shows '' $ Bisections(0) = 0$ === 
 ''moreover''   ''have''  $ \forall  A \in  FinPow(X).\  $
$    ( \forall  n \in  X - A.\  $
$    (\forall P \in   Bisections(A).\  \prod (A,a) = (\prod (fst(P),a))\cdot (\prod (snd(P),a))) $
$    \wedge  (\forall k\in A.\  \langle k,n\rangle  \in  r ) \longrightarrow  $
$    (\forall Q \in   Bisections(A \cup  \{n\}).\  $
$    \prod (A \cup  \{n\},a) = (\prod (fst(Q),a))\cdot (\prod (snd(Q),a))))$+++[proof ]>
++++[{ ]>
 ''fix '' $ A$
 ''assume '' $ A \in  FinPow(X)$
 ''fix '' $ n$
 ''assume '' $ n \in  X - A$
 ''have''  $ ( \forall P \in  Bisections(A).\  $
$	\prod (A,a) = (\prod (fst(P),a))\cdot (\prod (snd(P),a))) $
$	\wedge  (\forall k\in A.\  \langle k,n\rangle  \in  r )  \longrightarrow  $
$	(\forall Q \in   Bisections(A \cup  \{n\}).\  $
$	\prod (A \cup  \{n\},a) = (\prod (fst(Q),a))\cdot (\prod (snd(Q),a)))$+++[proof ]>
++++[{ ]>
 ''assume '' I: $ \forall P \in  Bisections(A).\  \prod (A,a) = (\prod (fst(P),a))\cdot (\prod (snd(P),a))$ ''and '' II: $ \forall k\in A.\  \langle k,n\rangle  \in  r$
 ''have''  $ \forall Q \in   Bisections(A \cup  \{n\}).\  $
$	    \prod (A \cup  \{n\},a) = (\prod (fst(Q),a))\cdot (\prod (snd(Q),a))$+++[proof ]>
++++[{ ]>
 ''fix '' $ Q$
 ''assume '' $ Q \in   Bisections(A \cup  \{n\})$
 ''let '' $ Q_0 = fst(Q)$
 ''let '' $ Q_1 = snd(Q)$
 ''from '' $ A \in  FinPow(X)$, $ n \in  X - A$  ''have''  $ A \cup  \{n\} \in  FinPow(X)$ ''using''  +++^[singleton_in_finpow | Finite_ZF ]...  ''lemma''  <nowiki>singleton_in_finpow</nowiki>:  ''assumes '' $ x \in  X$  '' shows '' $ \{x\} \in  FinPow(X)$ ===  ,  +++^[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)$ === 
 ''with '' $ Q \in   Bisections(A \cup  \{n\})$  ''have''  $ Q_0 \in  FinPow(X)$,  $ Q_0 \neq  0$ ''and '' $ Q_1 \in  FinPow(X)$,  $ Q_1 \neq  0$ ''using''  +++^[bisect_fin | Partitions_ZF ]...  ''lemma''  <nowiki>bisect_fin</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  ''and'' $ Q \in  Bisections(A)$  '' shows '' $ fst(Q) \in  FinPow(X)$  ''and'' $ snd(Q) \in  FinPow(X)$ ===  ,  +++^[bisec_is_pair | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_is_pair</nowiki>:  ''assumes '' $ Q \in  Bisections(X)$  '' shows '' $ Q = \langle fst(Q), snd(Q)\rangle $ ===  ,  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''then ''  ''have''  $ \prod (Q_0,a) \in  G$ ''and '' $ \prod (Q_1,a) \in  G$ ''using''  <nowiki>a_is_fun</nowiki> ,  +++^[setprod_type | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>setprod_type</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda \neq 0$  '' shows '' $ \exists n \in  nat .\  |\Lambda | = succ(n) \wedge  a\circ \sigma (\Lambda ) : succ(n) \rightarrow  G$
 ''and'' $ \prod (\Lambda ,a) \in  G$ === 
 ''from '' $ Q \in  Bisections(A \cup  \{n\})$, $ A \in  FinPow(X)$, $ n \in  X-A$  ''have''  $ refl(X,r)$,  $ Q_0 \subseteq  A \cup  \{n\}$,  $ Q_1 \subseteq  A \cup  \{n\}$,  $ A \subseteq  X$ ''and '' $ n \in  X$ ''using''  <nowiki>linord</nowiki> ,  +++^[IsLinOrder_def | Order_ZF ]... Definition of <nowiki>IsLinOrder</nowiki>:
$ IsLinOrder(X,r) \equiv  ( antisym(r) \wedge  trans(r) \wedge  (r \text{ is total on } X))$===  ,  +++^[total_is_refl | Order_ZF ]...  ''lemma''  <nowiki>total_is_refl</nowiki>:  ''assumes '' $ r \text{ is total on } X$  '' shows '' $ refl(X,r)$ ===  ,  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$===  ,  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$=== 
 ''from '' $ refl(X,r)$, $ Q_0 \subseteq  A \cup  \{n\}$, $ A \subseteq  X$, $ n \in  X$, II  ''have''  III: $ \forall k \in  Q_0.\  \langle k, n\rangle  \in  r$ ''   by (rule '' +++^[refl_add_point | Order_ZF ]...  ''lemma''  <nowiki>refl_add_point</nowiki>:  ''assumes '' $ refl(X,r)$  ''and'' $ A \subseteq  B \cup  \{x\}$  ''and'' $ B \subseteq  X$  ''and'' $ x \in  X$  ''and'' $ \forall y\in B.\  \langle y,x\rangle  \in  r$  '' shows '' $ \forall a\in A.\  \langle a,x\rangle  \in  r$ ===  '')'' 
 ''from '' $ refl(X,r)$, $ Q_1 \subseteq  A \cup  \{n\}$, $ A \subseteq  X$, $ n \in  X$, II  ''have''  IV: $ \forall k \in  Q_1.\  \langle k, n\rangle  \in  r$ ''   by (rule '' +++^[refl_add_point | Order_ZF ]...  ''lemma''  <nowiki>refl_add_point</nowiki>:  ''assumes '' $ refl(X,r)$  ''and'' $ A \subseteq  B \cup  \{x\}$  ''and'' $ B \subseteq  X$  ''and'' $ x \in  X$  ''and'' $ \forall y\in B.\  \langle y,x\rangle  \in  r$  '' shows '' $ \forall a\in A.\  \langle a,x\rangle  \in  r$ ===  '')'' 
 ''from '' $ n \in  X - A$, $ Q \in   Bisections(A \cup  \{n\})$  ''have''  $ Q_0 = \{n\} \vee  Q_1 = \{n\} \vee  \langle Q_0 - \{n\},Q_1-\{n\}\rangle  \in   Bisections(A)$ ''using''  +++^[bisec_is_pair | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_is_pair</nowiki>:  ''assumes '' $ Q \in  Bisections(X)$  '' shows '' $ Q = \langle fst(Q), snd(Q)\rangle $ ===  ,  +++^[bisec_add_point | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_add_point</nowiki>:  ''assumes '' $ x \notin  X$  ''and'' $ \langle A,B\rangle  \in  Bisections(X \cup  \{x\})$  '' shows '' $ (A = \{x\} \vee  B = \{x\}) \vee  (\langle A - \{x\}, B - \{x\}\rangle  \in  Bisections(X))$ === 
 ''moreover''  ++++[{ ]>
 ''assume '' $ Q_1 = \{n\}$
 ''from '' $ n \in  X - A$  ''have''  $ n \notin  A$ 
 ''moreover''   ''from '' $ Q \in   Bisections(A \cup  \{n\})$  ''have''  $ \langle Q_0,Q_1 \rangle  \in   Bisections(A \cup  \{n\})$ ''using''  +++^[bisec_is_pair | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_is_pair</nowiki>:  ''assumes '' $ Q \in  Bisections(X)$  '' shows '' $ Q = \langle fst(Q), snd(Q)\rangle $ === 
 ''with '' $ Q_1 = \{n\}$  ''have''  $ \langle Q_0, \{n\}\rangle  \in   Bisections(A \cup  \{n\})$ 
 ''ultimately ''  ''have''  $ Q_0 = A$ ''and '' $ A \neq  0$ ''using''  +++^[set_point_bisec | Partitions_ZF ]...  ''lemma''  <nowiki>set_point_bisec</nowiki>:  ''assumes '' $ x \notin  X$  ''and'' $ \langle A, \{x\}\rangle  \in  Bisections(X \cup  \{x\})$  '' shows '' $ A = X$  ''and'' $ X \neq  0$ === 
 ''with '' $ A \in  FinPow(X)$, $ n \in  X - A$, II, $ Q_1 = \{n\}$  ''have''  $ \prod (A \cup  \{n\},a) = (\prod (Q_0,a))\cdot \prod (Q_1,a)$ ''using''  <nowiki>a_is_fun</nowiki> ,  +++^[gen_prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_prod_append</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda  \neq  0$  ''and'' $ n \in  X -  \Lambda $  ''and'' $ \forall k\in \Lambda .\  \langle k,n\rangle  \in  r$  '' shows '' $ \prod (\Lambda  \cup  \{n\}, a) = (\prod (\Lambda ,a)) \cdot  a(n)$ ===  ,  +++^[gen_prod_singleton | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_prod_singleton</nowiki>:  ''assumes '' $ x \in  X$  '' shows '' $ \prod (\{x\},a) = a(x)$ === 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ Q_0 = \{n\}$
 ''from '' $ n \in  X - A$  ''have''  $ n \in  X$ 
 ''then ''  ''have''  $ \{n\} \in  FinPow(X)$ ''and '' $ \{n\} \neq  0$ ''using''  +++^[singleton_in_finpow | Finite_ZF ]...  ''lemma''  <nowiki>singleton_in_finpow</nowiki>:  ''assumes '' $ x \in  X$  '' shows '' $ \{x\} \in  FinPow(X)$ === 
 ''from '' $ n \in  X - A$  ''have''  $ n \notin  A$ 
 ''moreover''   ''from '' $ Q \in  Bisections(A \cup  \{n\})$  ''have''  $ \langle Q_0, Q_1\rangle  \in   Bisections(A \cup  \{n\})$ ''using''  +++^[bisec_is_pair | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_is_pair</nowiki>:  ''assumes '' $ Q \in  Bisections(X)$  '' shows '' $ Q = \langle fst(Q), snd(Q)\rangle $ === 
 ''with '' $ Q_0 = \{n\}$  ''have''  $ \langle \{n\}, Q_1\rangle  \in   Bisections(A \cup  \{n\})$ 
 ''ultimately ''  ''have''  $ Q_1 = A$ ''and '' $ A \neq  0$ ''using''  +++^[point_set_bisec | Partitions_ZF ]...  ''lemma''  <nowiki>point_set_bisec</nowiki>:  ''assumes '' $ x \notin  X$  ''and'' $ \langle \{x\}, A\rangle  \in  Bisections(X \cup  \{x\})$  '' shows '' $ A = X$  ''and'' $ X \neq  0$ === 
 ''with '' A1, $ A \in  FinPow(X)$, $ n \in  X - A$, II, $ \{n\} \in  FinPow(X)$, $ \{n\} \neq  0$, $ Q_0 = \{n\}$  ''have''  $ \prod (A \cup  \{n\},a) = (\prod (Q_0,a))\cdot (\prod (Q_1,a))$ ''using''  <nowiki>a_is_fun</nowiki> ,  +++^[gen_prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_prod_append</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda  \neq  0$  ''and'' $ n \in  X -  \Lambda $  ''and'' $ \forall k\in \Lambda .\  \langle k,n\rangle  \in  r$  '' shows '' $ \prod (\Lambda  \cup  \{n\}, a) = (\prod (\Lambda ,a)) \cdot  a(n)$ ===  ,  +++^[gen_prod_singleton | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_prod_singleton</nowiki>:  ''assumes '' $ x \in  X$  '' shows '' $ \prod (\{x\},a) = a(x)$ ===  ,  +++^[setprod_type | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>setprod_type</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda \neq 0$  '' shows '' $ \exists n \in  nat .\  |\Lambda | = succ(n) \wedge  a\circ \sigma (\Lambda ) : succ(n) \rightarrow  G$
 ''and'' $ \prod (\Lambda ,a) \in  G$ ===  ,  +++^[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 $=== 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' A4: $ \langle Q_0 - \{n\},Q_1 - \{n\}\rangle  \in   Bisections(A)$
 ''with '' $ A \in  FinPow(X)$  ''have''  $ Q_0 - \{n\} \in  FinPow(X)$,  $ Q_0 - \{n\} \neq  0$ ''and '' $ Q_1 - \{n\} \in  FinPow(X)$,  $ Q_1 - \{n\} \neq  0$ ''using''  +++^[FinPow_def | Finite_ZF ]... Definition of <nowiki>FinPow</nowiki>:
$ FinPow(X) \equiv  \{A \in  Pow(X).\  Finite(A)\}$===  ,  +++^[Bisections_def | Partitions_ZF ]... Definition of <nowiki>Bisections</nowiki>:
$ Bisections(X) = \{p \in  Pow(X)\times Pow(X).\  $
$  fst(p)\neq 0 \wedge  snd(p)\neq 0 \wedge  fst(p)\cap snd(p) = 0 \wedge  fst(p)\cup snd(p) = X\}$=== 
 ''with '' $ n \in  X - A$  ''have''  $ \prod (Q_0 - \{n\},a) \in  G$,  $ \prod (Q_1 - \{n\},a) \in  G$ ''and '' T: $ a(n) \in  G$ ''using''  <nowiki>a_is_fun</nowiki> ,  +++^[setprod_type | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>setprod_type</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda \neq 0$  '' shows '' $ \exists n \in  nat .\  |\Lambda | = succ(n) \wedge  a\circ \sigma (\Lambda ) : succ(n) \rightarrow  G$
 ''and'' $ \prod (\Lambda ,a) \in  G$ ===  ,  <nowiki>apply_funtype</nowiki>
 ''from '' $ Q \in  Bisections(A \cup  \{n\})$, A4  ''have''  $ (\langle Q_0, Q_1 - \{n\}\rangle  \in  Bisections(A) \wedge  n \in  Q_1) \vee  $
$		  (\langle Q_0 - \{n\}, Q_1\rangle  \in  Bisections(A) \wedge  n \in  Q_0) $ ''using''  +++^[bisec_is_pair | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_is_pair</nowiki>:  ''assumes '' $ Q \in  Bisections(X)$  '' shows '' $ Q = \langle fst(Q), snd(Q)\rangle $ ===  ,  +++^[bisec_add_point_case3 | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_add_point_case3</nowiki>:  ''assumes '' $ \langle A,B\rangle  \in  Bisections(X \cup  \{x\})$  ''and'' $ \langle A - \{x\}, B - \{x\}\rangle  \in  Bisections(X)$  '' shows '' $ (\langle A, B - \{x\}\rangle  \in  Bisections(X) \wedge  x \in  B) \vee  $
$  (\langle A - \{x\}, B\rangle  \in  Bisections(X) \wedge  x \in  A)$
=== 
 ''moreover''  ++++[{ ]>
 ''assume '' $ \langle Q_0, Q_1 - \{n\}\rangle  \in  Bisections(A)$ ''and '' $ n \in  Q_1$
 ''then ''  ''have''  $ A \neq  0$ ''using''  +++^[bisec_props | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_props</nowiki>:  ''assumes '' $ \langle A,B\rangle  \in  Bisections(X)$  '' shows '' $ A\neq 0$,   $ B\neq 0$,  
$ A \subseteq  X$,   $ B \subseteq  X$,   $ A \cap  B = 0$,   $ A \cup  B = X$,   $ X \neq  0$ === 
 ''with '' A2, $ A \in  FinPow(X)$, $ n \in  X - A$, I, II, T, IV, $ \langle Q_0, Q_1 - \{n\}\rangle  \in  Bisections(A)$, $ \prod (Q_0,a) \in  G$, $ \prod (Q_1 - \{n\},a) \in  G$, $ Q_1 \in  FinPow(X)$, $ n \in  Q_1$, $ Q_1 - \{n\} \neq  0$  ''have''  $ \prod (A \cup  \{n\},a) = (\prod (Q_0,a))\cdot (\prod (Q_1,a))$ ''using''  +++^[gen_prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_prod_append</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda  \neq  0$  ''and'' $ n \in  X -  \Lambda $  ''and'' $ \forall k\in \Lambda .\  \langle k,n\rangle  \in  r$  '' shows '' $ \prod (\Lambda  \cup  \{n\}, a) = (\prod (\Lambda ,a)) \cdot  a(n)$ ===  ,  +++^[semigr_assoc | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>semigr_assoc</nowiki>:  ''assumes '' $ x \in  G$,   $ y \in  G$,   $ z \in  G$  '' shows '' $ x\cdot y\cdot z = x\cdot (y\cdot z)$ ===  ,  +++^[gen_product_rem_point | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_product_rem_point</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  ''and'' $ n \in  A$  ''and'' $ A - \{n\} \neq  0$  ''and'' $ \forall k\in A.\  \langle k, n\rangle  \in  r$  '' shows '' $ (\prod (A - \{n\},a)) \cdot  a(n) = \prod (A, a)$ === 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ \langle Q_0 - \{n\}, Q_1\rangle  \in  Bisections(A)$ ''and '' $ n \in  Q_0$
 ''then ''  ''have''  $ A \neq  0$ ''using''  +++^[bisec_props | Partitions_ZF ]...  ''lemma''  <nowiki>bisec_props</nowiki>:  ''assumes '' $ \langle A,B\rangle  \in  Bisections(X)$  '' shows '' $ A\neq 0$,   $ B\neq 0$,  
$ A \subseteq  X$,   $ B \subseteq  X$,   $ A \cap  B = 0$,   $ A \cup  B = X$,   $ X \neq  0$ === 
 ''with '' A1, A2, $ A \in  FinPow(X)$, $ n \in  X - A$, I, II, III, T, $ \langle Q_0 - \{n\}, Q_1\rangle \in Bisections(A)$, $ \prod (Q_0 - \{n\},a)\in G$, $ \prod (Q_1,a) \in  G$, $ Q_0 \in  FinPow(X)$, $ n \in  Q_0$, $ Q_0-\{n\}\neq 0$  ''have''  $ \prod (A \cup  \{n\},a) = (\prod (Q_0,a))\cdot (\prod (Q_1,a))$ ''using''  +++^[gen_prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_prod_append</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda  \neq  0$  ''and'' $ n \in  X -  \Lambda $  ''and'' $ \forall k\in \Lambda .\  \langle k,n\rangle  \in  r$  '' shows '' $ \prod (\Lambda  \cup  \{n\}, a) = (\prod (\Lambda ,a)) \cdot  a(n)$ ===  ,  +++^[rearr3elems | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>rearr3elems</nowiki>:  ''assumes '' $ f \text{ is commutative on } G$  ''and'' $ a\in G$,   $ b\in G$,   $ c\in G$  '' shows '' $ a\cdot b\cdot c = a\cdot c\cdot b$ ===  ,  +++^[gen_product_rem_point | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>gen_product_rem_point</nowiki>:  ''assumes '' $ A \in  FinPow(X)$  ''and'' $ n \in  A$  ''and'' $ A - \{n\} \neq  0$  ''and'' $ \forall k\in A.\  \langle k, n\rangle  \in  r$  '' shows '' $ (\prod (A - \{n\},a)) \cdot  a(n) = \prod (A, a)$ === 
===  ''}'' 
 ''ultimately ''  ''have''  $ \prod (A \cup  \{n\},a) = (\prod (Q_0,a))\cdot (\prod (Q_1,a))$ 
===  ''}'' 
 ''ultimately ''  ''have''  $ \prod (A \cup  \{n\},a) = (\prod (Q_0,a))\cdot (\prod (Q_1,a))$ 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''moreover''   ''note '' A2
 ''ultimately ''  ''show''  $ thesis$ ''   by (rule '' +++^[fin_ind_add_max | FinOrd_ZF ]...  ''lemma''  <nowiki>fin_ind_add_max</nowiki>:  ''assumes '' $ IsLinOrder(X,r)$  ''and'' $ P(0)$  ''and'' $ \forall  A \in  FinPow(X).\  $
$  ( \forall  x \in  X-A.\  P(A) \wedge  (\forall a\in A.\  \langle a,x\rangle  \in  r ) \longrightarrow  P(A \cup  \{x\}))$
 ''and'' $ B \in  FinPow(X)$  '' shows '' $ P(B)$ ===  '')'' 
 ''qed'' === 

A better looking reformulation of //prod_bisect//.

 ''theorem''  ''(in'' semigr1'')'' <nowiki>prod_disjoint</nowiki>:
 ''   assumes '' A1: $ f \text{ is commutative on } G$ ''and '' A2: $ A \in  FinPow(X)$,  $ A \neq  0$ ''and '' A3: $ B \in  FinPow(X)$,  $ B \neq  0$ ''and '' A4: $ A \cap  B = 0$ ''   shows '' $ \prod (A\cup B,a) = (\prod (A,a))\cdot (\prod (B,a))$+++[proof ]>
 ''from '' A2, A3, A4  ''have''  $ \langle A,B\rangle  \in  Bisections(A\cup B)$ ''using''  +++^[is_bisec | Partitions_ZF ]...  ''lemma''  <nowiki>is_bisec</nowiki>:  ''assumes '' $ A\neq 0$,   $ B\neq 0$,   $ A \cap  B = 0$  '' shows '' $ \langle A,B\rangle  \in  Bisections(A\cup B)$ === 
 ''with '' A1, A2, A3  ''show''  $ thesis$ ''using''  <nowiki>a_is_fun</nowiki> ,  +++^[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)$ ===  ,  +++^[prod_bisect | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>prod_bisect</nowiki>:  ''assumes '' $ f \text{ is commutative on } G$  ''and'' $ \Lambda  \in  FinPow(X)$  '' shows '' $ \forall P \in   Bisections(\Lambda ).\  \prod (\Lambda ,a) = (\prod (fst(P),a))\cdot (\prod (snd(P),a))$
=== 
 ''qed'' === 

A generalization of //prod_disjoint//.

 ''lemma''  ''(in'' semigr1'')'' <nowiki>prod_list_of_lists</nowiki>:
 ''   assumes '' A1: $ f \text{ is commutative on } G$ ''and '' A2: $ n \in  nat$ ''   shows '' $ \forall M \in  succ(n) \rightarrow  FinPow(X).\  $
$  M \text{ is partition } \longrightarrow  $
$  (\prod  \{\langle i,\prod (M(i),a)\rangle .\  i \in  succ(n)\}) = $
$  (\prod (\bigcup i \in  succ(n).\  M(i),a))$+++[proof ]>
 ''note '' A2
 ''moreover''   ''have''  $ \forall M \in  succ(0) \rightarrow  FinPow(X).\  $
$    M \text{ is partition } \longrightarrow  $
$    (\prod  \{\langle i,\prod (M(i),a)\rangle .\  i \in  succ(0)\}) = (\prod (\bigcup i \in  succ(0).\  M(i),a))$ ''using''  <nowiki>a_is_fun</nowiki> ,  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  +++^[Partition_def | Partitions_ZF ]... Definition of <nowiki>Partition</nowiki>:
$ P \text{ is partition } \equiv   \forall x \in  domain(P).\  $
$  P(x) \neq  0 \wedge  (\forall y \in  domain(P).\  x\neq y \longrightarrow  P(x) \cap  P(y) = 0)$===  ,  <nowiki>apply_funtype</nowiki> ,  +++^[setprod_type | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>setprod_type</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda \neq 0$  '' shows '' $ \exists n \in  nat .\  |\Lambda | = succ(n) \wedge  a\circ \sigma (\Lambda ) : succ(n) \rightarrow  G$
 ''and'' $ \prod (\Lambda ,a) \in  G$ ===  ,  <nowiki>list_len1_singleton</nowiki> ,  +++^[prod_of_1elem | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_of_1elem</nowiki>:  ''assumes '' $ a: 1 \rightarrow  G$  '' shows '' $ (\prod  a) = a(0)$ === 
 ''moreover''   ''have''  $ \forall k \in  nat.\  $
$    (\forall M \in  succ(k) \rightarrow  FinPow(X).\  $
$    M \text{ is partition } \longrightarrow  $
$    (\prod  \{\langle i,\prod (M(i),a)\rangle .\  i \in  succ(k)\}) = $
$    (\prod (\bigcup i \in  succ(k).\  M(i),a))) \longrightarrow $
$    (\forall M \in  succ(succ(k)) \rightarrow  FinPow(X).\  $
$    M \text{ is partition } \longrightarrow  $
$    (\prod  \{\langle i,\prod (M(i),a)\rangle .\  i \in  succ(succ(k))\}) = $
$    (\prod (\bigcup i \in  succ(succ(k)).\  M(i),a)))$+++[proof ]>
++++[{ ]>
 ''fix '' $ k$
 ''assume '' $ k \in  nat$
 ''assume '' A3: $ \forall M \in  succ(k) \rightarrow  FinPow(X).\  $
$	M \text{ is partition } \longrightarrow  $
$	(\prod  \{\langle i,\prod (M(i),a)\rangle .\  i \in  succ(k)\}) = $
$	(\prod (\bigcup i \in  succ(k).\  M(i),a))$
 ''have''  $ (\forall N \in  succ(succ(k)) \rightarrow  FinPow(X).\  $
$	N \text{ is partition } \longrightarrow  $
$	(\prod  \{\langle i,\prod (N(i),a)\rangle .\  i \in  succ(succ(k))\}) = $
$	(\prod (\bigcup i \in  succ(succ(k)).\  N(i),a)))$+++[proof ]>
++++[{ ]>
 ''fix '' $ N$
 ''assume '' A4: $ N : succ(succ(k)) \rightarrow  FinPow(X)$
 ''assume '' A5: $ N \text{ is partition }$
 ''with '' A4  ''have''  I: $ \forall i \in  succ(succ(k)).\  N(i) \neq  0$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  +++^[Partition_def | Partitions_ZF ]... Definition of <nowiki>Partition</nowiki>:
$ P \text{ is partition } \equiv   \forall x \in  domain(P).\  $
$  P(x) \neq  0 \wedge  (\forall y \in  domain(P).\  x\neq y \longrightarrow  P(x) \cap  P(y) = 0)$=== 
 ''let '' $ b = \{\langle i,\prod (N(i),a)\rangle .\  i \in  succ(succ(k))\}$
 ''let '' $ c = \{\langle i,\prod (N(i),a)\rangle .\  i \in  succ(k)\}$
 ''have''  II: $ \forall i \in  succ(succ(k)).\  \prod (N(i),a) \in  G$+++[proof ]>
 ''fix '' $ i$
 ''assume '' $ i \in  succ(succ(k))$
 ''with '' A4, I  ''have''  $ N(i) \in  FinPow(X)$ ''and '' $ N(i) \neq  0$ ''using''  <nowiki>apply_funtype</nowiki>
 ''then ''  ''show''  $ \prod (N(i),a) \in  G$ ''using''  +++^[setprod_type | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>setprod_type</nowiki>:  ''assumes '' $ \Lambda  \in  FinPow(X)$  ''and'' $ \Lambda \neq 0$  '' shows '' $ \exists n \in  nat .\  |\Lambda | = succ(n) \wedge  a\circ \sigma (\Lambda ) : succ(n) \rightarrow  G$
 ''and'' $ \prod (\Lambda ,a) \in  G$ === 
 ''qed'' === 
 ''hence''  $ \forall i \in  succ(k).\   \prod (N(i),a) \in  G$
 ''then ''  ''have''  $ c : succ(k) \rightarrow  G$ ''   by (rule '' +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ ===  '')'' 
 ''have''  $ b = \{\langle i,\prod (N(i),a)\rangle .\  i \in  succ(succ(k))\}$ 
 ''with '' II  ''have''  $ b = Append(c,\prod (N(succ(k)),a))$ ''   by (rule '' <nowiki>set_list_append</nowiki> '')'' 
 ''with '' II, $ k \in  nat$, $ c : succ(k) \rightarrow  G$  ''have''  $ (\prod  b) = (\prod  c)\cdot (\prod (N(succ(k)),a))$ ''using''  +++^[prod_append | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr0'')'' <nowiki>prod_append</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a : succ(n) \rightarrow  G$  ''and'' $ x\in G$  '' shows '' $ (\prod  a\hookleftarrow x) = (\prod  a) \cdot  x$ === 
 ''also''   ''have''  $ \ldots  =  (\prod (\bigcup i \in  succ(k).\  N(i),a))\cdot (\prod (N(succ(k)),a))$+++[proof ]>
 ''let '' $ M = restrict(N,succ(k))$
 ''have''  $ succ(k) \subseteq  succ(succ(k))$ 
 ''with '' $ N : succ(succ(k)) \rightarrow  FinPow(X)$  ''have''  $ M : succ(k) \rightarrow  FinPow(X)$ ''and '' III: $ \forall i \in  succ(k).\  M(i) = N(i)$ ''using''  <nowiki>restrict_type2</nowiki> ,  <nowiki>restrict</nowiki> ,  <nowiki>apply_funtype</nowiki>
 ''with '' A5, $ M : succ(k) \rightarrow  FinPow(X)$  ''have''  $ M \text{ is partition }$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  +++^[Partition_def | Partitions_ZF ]... Definition of <nowiki>Partition</nowiki>:
$ P \text{ is partition } \equiv   \forall x \in  domain(P).\  $
$  P(x) \neq  0 \wedge  (\forall y \in  domain(P).\  x\neq y \longrightarrow  P(x) \cap  P(y) = 0)$=== 
 ''with '' A3, $ M : succ(k) \rightarrow  FinPow(X)$  ''have''  $ (\prod  \{\langle i,\prod (M(i),a)\rangle .\  i \in  succ(k)\}) = $
$	      (\prod (\bigcup i \in  succ(k).\  M(i),a))$ 
 ''with '' III  ''show''  $ thesis$ 
 ''qed'' === 
 ''also''   ''have''  $ \ldots  = (\prod (\bigcup i \in  succ(succ(k)).\  N(i),a))$+++[proof ]>
 ''let '' $ A = \bigcup i \in  succ(k).\  N(i)$
 ''let '' $ B = N(succ(k))$
 ''from '' A4, $ k \in  nat$  ''have''  $ succ(k) \in  nat$ ''and '' $ \forall i \in  succ(k).\  N(i) \in  FinPow(X)$ ''using''  <nowiki>apply_funtype</nowiki>
 ''then ''  ''have''  $ A \in  FinPow(X)$ ''   by (rule '' +++^[union_fin_list_fin | Finite_ZF ]...  ''lemma''  <nowiki>union_fin_list_fin</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ \forall k \in  n.\  N(k) \in  FinPow(X)$  '' shows '' $ \{N(k).\  k \in  n\} \in   FinPow(FinPow(X))$  ''and'' $ (\bigcup k \in  n.\  N(k)) \in  FinPow(X)$ ===  '')'' 
 ''moreover''   ''from '' I  ''have''  $ A \neq  0$ 
 ''moreover''   ''from '' A4, I  ''have''  $ N(succ(k)) \in  FinPow(X)$ ''and '' $ N(succ(k)) \neq  0$ ''using''  <nowiki>apply_funtype</nowiki>
 ''moreover''   ''from '' $ succ(k) \in  nat$, A4, A5  ''have''  $ A \cap  B = 0$ ''   by (rule '' +++^[list_partition | Partitions_ZF ]...  ''lemma''  <nowiki>list_partition</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ a : succ(n) \rightarrow  X$,   $ a \text{ is partition }$  '' shows '' $ (\bigcup i\in n.\  a(i)) \cap  a(n) = 0$ ===  '')'' 
 ''moreover''   ''note '' A1
 ''ultimately ''  ''have''  $ \prod (A\cup B,a) = (\prod (A,a))\cdot (\prod (B,a))$ ''using''  +++^[prod_disjoint | Semigroup_ZF ]...  ''theorem''  ''(in'' semigr1'')'' <nowiki>prod_disjoint</nowiki>:  ''assumes '' $ f \text{ is commutative on } G$  ''and'' $ A \in  FinPow(X)$,   $ A \neq  0$  ''and'' $ B \in  FinPow(X)$,   $ B \neq  0$  ''and'' $ A \cap  B = 0$  '' shows '' $ \prod (A\cup B,a) = (\prod (A,a))\cdot (\prod (B,a))$ === 
 ''moreover''   ''have''  $ A \cup  B = (\bigcup i \in  succ(succ(k)).\  N(i))$ 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 
 ''finally ''  ''have''  $ (\prod  \{\langle i,\prod (N(i),a)\rangle .\  i \in  succ(succ(k))\}) = $
$	    (\prod (\bigcup i \in  succ(succ(k)).\  N(i),a))$ 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ ''   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)$ ===  '')'' 
 ''qed'' === 

A more convenient reformulation of //prod_list_of_lists//.

 ''theorem''  ''(in'' semigr1'')'' <nowiki>prod_list_of_sets</nowiki>:
 ''   assumes '' A1: $ f \text{ is commutative on } G$ ''and '' A2: $ n \in  nat$,  $ n \neq  0$ ''and '' A3: $ M : n \rightarrow  FinPow(X)$,  $ M \text{ is partition }$ ''   shows '' $ (\prod  \{\langle i,\prod (M(i),a)\rangle .\  i \in  n\}) = (\prod (\bigcup i \in  n.\  M(i),a))$+++[proof ]>
 ''from '' A2  ''obtain '' $ k$ ''where '' $ k \in  nat$ ''and '' $ n = succ(k)$ ''using''  +++^[Nat_ZF_1_L3 | Nat_ZF_IML ]...  ''lemma''  <nowiki>Nat_ZF_1_L3</nowiki>:  ''assumes '' $ n \in  nat$  ''and'' $ n\neq 0$  '' shows '' $ \exists k\in nat.\  n = succ(k)$ === 
 ''with '' A1, A3  ''show''  $ thesis$ ''using''  +++^[prod_list_of_lists | Semigroup_ZF ]...  ''lemma''  ''(in'' semigr1'')'' <nowiki>prod_list_of_lists</nowiki>:  ''assumes '' $ f \text{ is commutative on } G$  ''and'' $ n \in  nat$  '' shows '' $ \forall M \in  succ(n) \rightarrow  FinPow(X).\  $
$  M \text{ is partition } \longrightarrow  $
$  (\prod  \{\langle i,\prod (M(i),a)\rangle .\  i \in  succ(n)\}) = $
$  (\prod (\bigcup i \in  succ(n).\  M(i),a))$
=== 
 ''qed'' === 

 ''end

'' +++![Comments on Semigroup_ZF|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/Semigroup_ZF"></iframe> </div> </html>
=== 
<<search>><<closeAll>><<permaview>><<newTiddler>><<saveChanges>><<tiddler TspotSidebar>><<slider chkSliderOptionsPanel OptionsPanel "options »" "Change TiddlyWiki advanced options">>
a <nowiki>TiddlyWiki</nowiki> rendering of the [[IsarMathLib| http://www.nongnu.org/isarmathlib/]]  project
Tiddly Formal Math
blockquote { margin-right:0; }
$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''
===

++++[{]> 
fix x assume $x\in A$
show $x \in B$
===
} thus $A \subseteq B$



/%
|Name|ToggleRightSidebar|
|Source|http://www.TiddlyTools.com/#ToggleRightSidebar|
|Version|2.0.0|
|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|script|
|Requires|InlineJavascriptPlugin|
|Overrides||
|Description|show/hide right sidebar (MainMenu)|

Usage: <<tiddler ToggleRightSidebar with: "label">>

Config settings:
	config.options.chkShowRightSidebar (true)
	config.options.txtToggleRightSideBarLabelShow (â—„)
	config.options.txtToggleRightSideBarLabelHide (â–º)

%/<script label="$1" title="show/hide right sidebar content">
	var co=config.options;
	if (co.chkShowRightSidebar=='undefined') co.chkShowRightSidebar=true;
	co.chkShowRightSidebar=!co.chkShowRightSidebar;
	var sb=document.getElementById('sidebar'); if (!sb) return;
	sb.style.display=co.chkShowRightSidebar?'block':'none';
	document.getElementById('displayArea').style.marginRight=co.chkShowRightSidebar?'':'1em';
	saveOptionCookie('chkShowRightSidebar');
	var labelShow=co.txtToggleRightSideBarLabelShow||'&#x25C4;';
	var labelHide=co.txtToggleRightSideBarLabelHide||'&#x25BA;';
	if (typeof(place)!='undefined' && '$1'=='$'+'1') {
		place.innerHTML=co.chkShowRightSidebar?labelHide:labelShow;
		place.title=(co.chkShowRightSidebar?'hide':'show')+' right sidebar';
	}
	var sm=document.getElementById('storyMenu'); if (sm) config.refreshers.content(sm);
</script><script>
	var co=config.options;
	if (co.chkShowRightSidebar=='undefined') co.chkShowRightSidebar=true;
	var sb=document.getElementById('sidebar'); if (!sb) return;
	sb.style.display=co.chkShowRightSidebar?'block':'none';
	document.getElementById('displayArea').style.marginRight=co.chkShowRightSidebar?'':'1em';
	if ('$1'=='$'+'1') {
		var labelShow=co.txtToggleRightSideBarLabelShow||'&#x25C4;';
		var labelHide=co.txtToggleRightSideBarLabelHide||'&#x25BA;';
		place.lastChild.innerHTML=co.chkShowRightSidebar?labelHide:labelShow;
		place.lastChild.title=(co.chkShowRightSidebar?'hide':'show')+' right sidebar';
	}
</script>
 ''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
 ''assumes '' topSpaceAssum: $ T \text{ is a topology }$
 ''defines '' $ int(A) \equiv  Interior(A,T)$
 ''defines '' $ cl(A) \equiv  Closure(A,T)$
 ''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
 ''assumes '' tau1_is_top: $ \tau _1 \text{ is a topology }$
 ''assumes '' tau2_is_top: $ \tau _2 \text{ is a topology }$
 ''defines '' $ X_1 \equiv  \bigcup \tau _1$
 ''defines '' $ X_2 \equiv  \bigcup \tau _2$
 ''assumes '' fmapAssum: $ f: X_1 \rightarrow  X_2$
 ''defines '' $ g \text{ is continuous } \equiv  IsContinuous(\tau _1,\tau _2,g)$
 ''defines '' $ cl_1(A) \equiv  Closure(A,\tau _1)$
 ''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''  +++^[func1_1_L3 | func1 ]...  ''lemma''  <nowiki>func1_1_L3</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(D) \subseteq  X$ === 
 ''moreover''   ''from '' fmapAssum  ''have''  $ f^{-1}(X_2 - D) =  X_1 - f^{-1}(D)$ ''using''  <nowiki>Pi_iff</nowiki> ,  <nowiki>function_vimage_Diff</nowiki> ,  +++^[func1_1_L4 | func1 ]...  ''lemma''  <nowiki>func1_1_L4</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(Y) = X$ === 
 ''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''  +++^[func1_1_L6 | func1 ]...  ''lemma''  <nowiki>func1_1_L6</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f(B) \subseteq  range(f)$,   $ f(B) \subseteq  Y$ ===  ,  +++^[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''  +++^[func1_1_L7 | func1 ]...  ''lemma''  <nowiki>func1_1_L7</nowiki>:  ''assumes '' $ A\subseteq B$  ''and'' $ function(f)$  '' shows '' $ f^{-1}(A)\subseteq  f^{-1}(B)$ === 
 ''moreover''   ''from '' fmapAssum, A2  ''have''  $ A \subseteq  f^{-1}(f(A))$ ''using''  +++^[func1_1_L9 | func1 ]...  ''lemma''  <nowiki>func1_1_L9</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ A \subseteq  f^{-1}(f(A))$ === 
 ''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''  +++^[func1_1_L6 | func1 ]...  ''lemma''  <nowiki>func1_1_L6</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f(B) \subseteq  range(f)$,   $ f(B) \subseteq  Y$ ===  ,  +++^[func1_1_L8 | func1 ]...  ''lemma''  <nowiki>func1_1_L8</nowiki>:  ''assumes '' $ A\subseteq B$  '' shows '' $ f(A)\subseteq  f(B)$ ===  ,  +++^[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''  +++^[func1_1_L3 | func1 ]...  ''lemma''  <nowiki>func1_1_L3</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(D) \subseteq  X$ === 
 ''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> ,  +++^[func1_1_L6 | func1 ]...  ''lemma''  <nowiki>func1_1_L6</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f(B) \subseteq  range(f)$,   $ f(B) \subseteq  Y$ ===  ,  +++^[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> ,  +++^[func1_1_L7 | func1 ]...  ''lemma''  <nowiki>func1_1_L7</nowiki>:  ''assumes '' $ A\subseteq B$  ''and'' $ function(f)$  '' shows '' $ f^{-1}(A)\subseteq  f^{-1}(B)$ === 
 ''moreover''   ''from '' fmapAssum, $ B \subseteq  X_2$  ''have''  $ cl_1(f^{-1}(B)) \subseteq  f^{-1}(f(cl_1(f^{-1}(B))))$ ''using''  +++^[func1_1_L3 | func1 ]...  ''lemma''  <nowiki>func1_1_L3</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(D) \subseteq  X$ ===  ,  +++^[func1_1_L9 | func1 ]...  ''lemma''  <nowiki>func1_1_L9</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ A \subseteq  f^{-1}(f(A))$ ===  ,  +++^[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''  +++^[func1_1_L3 | func1 ]...  ''lemma''  <nowiki>func1_1_L3</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(D) \subseteq  X$ ===  ,  +++^[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> ,  +++^[func1_1_L3 | func1 ]...  ''lemma''  <nowiki>func1_1_L3</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(D) \subseteq  X$ ===  ,  +++^[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> ,  +++^[func1_1_L4 | func1 ]...  ''lemma''  <nowiki>func1_1_L4</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(Y) = X$ ===  ,  +++^[func1_1_L3 | func1 ]...  ''lemma''  <nowiki>func1_1_L3</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(D) \subseteq  X$ ===  ,  +++^[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 '' +++^[func1_1_L13 | func1 ]...  ''lemma''  <nowiki>func1_1_L13</nowiki>:  ''assumes '' $ f^{-1}(A) \neq  0$  '' shows '' $ A\neq 0$ ===  '')'' 
 ''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''  +++^[func1_1_L12 | func1 ]...  ''lemma''  <nowiki>func1_1_L12</nowiki>:  ''assumes '' $ B\subseteq Pow(Y)$  ''and'' $ B\neq 0$  ''and'' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(\bigcap B) = (\bigcap U\in B.\  f^{-1}(U))$ === 
 ''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]] | . |
| 28/12/2008 17:36:56 | 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 $ \langle x,y\rangle \in X\times Y$.

 ''lemma''  <nowiki>ZF1_1_L4A</nowiki>:
 ''   assumes '' A1: $ \forall x\in X.\ \forall y\in Y.\  a(\langle  x,y\rangle ) = 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 = \langle  x,y\rangle $
 ''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'' === 

A simple version of // ZF1_1_L9//.

 ''corollary''  <nowiki>sigleton_extract</nowiki>:
 ''   assumes '' $ \exists ! x.\  x\in A$ ''   shows '' $ (\bigcup  A) \in  A$+++[proof ]>
 ''from '' assms  ''have''  $ \exists ! x.\  x\in A \wedge  True$ 
 ''then ''  ''have''  $ \bigcup  \{x\in A.\  True\} \in  A$ ''   by (rule '' +++^[ZF1_1_L9 | ZF1 ]...  ''lemma''  <nowiki>ZF1_1_L9</nowiki>:  ''assumes '' $ \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)\})$ ===  '')'' 
 ''thus''  $ (\bigcup  A) \in  A$
 ''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'' === 

Standard Isabelle uses a notion of $ cons(A,a)$ that can be thought of as $A\cup \{a\}$.

 ''lemma''  <nowiki>consdef</nowiki>:
 ''   shows '' $ cons(a,A) = A \cup  \{a\}$ ''using''  <nowiki>cons_def</nowiki>

If a difference between a set and a sigleton is empty, then the set is empty or it is equal to the sigleton.

 ''lemma''  <nowiki>singl_diff_empty</nowiki>:
 ''   assumes '' $ A - \{x\} = 0$ ''   shows '' $ A = 0 \vee  A = \{x\}$ ''using''  <nowiki>assms</nowiki>

If a difference between a set and a sigleton is the set, then the only element of the singleton is not in the set.

 ''lemma''  <nowiki>singl_diff_eq</nowiki>:
 ''   assumes '' A1: $ A - \{x\} = A$ ''   shows '' $ x \notin  A$+++[proof ]>
 ''have''  $ x \notin  A - \{x\}$ 
 ''with '' A1  ''show''  $ x \notin  A$ 
 ''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'' func1 ''imports'' [[func]] [[Fol1]] [[ZF1]]

 ''begin
'' 
This theory covers basic properties of function spaces. A set of functions with domain $X$ and values in the set $Y$ is denoted in Isabelle as $X\rightarrow Y$. It just happens that the colon ":" is a synonym of the set membership symbol $\in$ in Isabelle/ZF so we can write $f:X\rightarrow Y$ instead of $fin X\rightarrow Y$. This is the only case that we use the colon instead of the regular set membership symbol.

!Properties of functions, function spaces and (inverse) images.

Functions in ZF are sets of pairs. This means that if $f: X\rightarrow Y $ then $f\subseteq X\times Y$. This section is mostly about consequences of this understanding of the notion of function.

We define the notion of function that preserves a collection here. Given two collection of sets a function preserves the collections if the inverse image of sets in one collection belongs to the second one. This notion does not have a name in romantic math. It is used to define continuous functions in //Topology_ZF_2// theory. We define it here so that we can use it for other purposes, like defining measurable functions. Recall that $ f^{-1}(A)$ means the inverse image of the set $A$.

 ''Definition
'' $ PresColl(f,S,T) \equiv  \forall  A\in T.\  f^{-1}(A)\in S$

A definition that allows to get the first factor of the domain of a binary function $f: X\times Y \rightarrow Z$.

 ''Definition
'' $ fstdom(f) \equiv  domain(domain(f))$

If a function maps $A$ into another set, then $A$ is the domain of the function.

 ''lemma''  <nowiki>func1_1_L1</nowiki>:
 ''   assumes '' $ f:A\rightarrow C$ ''   shows '' $ domain(f) = A$ ''using''  <nowiki>prems</nowiki> ,  <nowiki>domain_of_fun</nowiki>

A lemma explains what //fstdom// is for.

 ''lemma''  <nowiki>fstdomdef</nowiki>:
 ''   assumes '' A1: $ f: X\times Y \rightarrow  Z$ ''and '' A2: $ Y\neq 0$ ''   shows '' $ fstdom(f) = X$+++[proof ]>
 ''from '' A1  ''have''  $ domain(f) = X\times Y$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ === 
 ''with '' A2  ''show''  $ fstdom(f) = X$ ''unfolding''  +++^[fstdom_def | func1 ]... Definition of <nowiki>fstdom</nowiki>:
$ fstdom(f) \equiv  domain(domain(f))$=== 
 ''qed'' === 

A first-order version of //Pi_type//.

 ''lemma''  <nowiki>func1_1_L1A</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ \forall x\in X.\  f(x) \in  Z$ ''   shows '' $ f:X\rightarrow Z$+++[proof ]>
++++[{ ]>
 ''fix '' $ x$
 ''assume '' $ x\in X$
 ''with '' A2  ''have''  $ f(x) \in  Z$ 
===  ''}'' 
 ''with '' A1  ''show''  $ f:X\rightarrow Z$ ''   by (rule '' <nowiki>Pi_type</nowiki> '')'' 
 ''qed'' === 

A variant of //func1_1_L1A//.

 ''lemma''  <nowiki>func1_1_L1B</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ Y\subseteq Z$ ''   shows '' $ f:X\rightarrow Z$+++[proof ]>
 ''from '' A1, A2  ''have''  $ \forall x\in X.\  f(x) \in  Z$ ''using''  <nowiki>apply_funtype</nowiki>
 ''with '' A1  ''show''  $ f:X\rightarrow Z$ ''using''  +++^[func1_1_L1A | func1 ]...  ''lemma''  <nowiki>func1_1_L1A</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ \forall x\in X.\  f(x) \in  Z$  '' shows '' $ f:X\rightarrow Z$ === 
 ''qed'' === 

There is a value for each argument.

 ''lemma''  <nowiki>func1_1_L2</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$,  $ x\in X$ ''   shows '' $ \exists y\in Y.\  \langle  x,y\rangle  \in  f$+++[proof ]>
 ''from '' A1  ''have''  $ f(x) \in  Y$ ''using''  <nowiki>apply_type</nowiki>
 ''moreover''   ''from '' A1  ''have''  $ \langle  x,f(x)\rangle \in  f$ ''using''  <nowiki>apply_Pair</nowiki>
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

Inverse image of any set is contained in the domain.

 ''lemma''  <nowiki>func1_1_L3</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''   shows '' $ f^{-1}(D) \subseteq  X$+++[proof ]>
 ''have''  $ \forall x.\  x\in f^{-1}(D) \longrightarrow  x\in domain(f)$ ''using''  <nowiki>vimage_iff</nowiki> ,  <nowiki>domain_iff</nowiki>
 ''with '' A1  ''have''  $ \forall x.\  (x \in  f^{-1}(D)) \longrightarrow  (x\in X)$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ === 
 ''then ''  ''show''  $ thesis$ 
 ''qed'' === 

The inverse image of the range is the domain.

 ''lemma''  <nowiki>func1_1_L4</nowiki>:
 ''   assumes '' $ f:X\rightarrow Y$ ''   shows '' $ f^{-1}(Y) = X$ ''using''  <nowiki>prems</nowiki> ,  +++^[func1_1_L3 | func1 ]...  ''lemma''  <nowiki>func1_1_L3</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(D) \subseteq  X$ ===  ,  +++^[func1_1_L2 | func1 ]...  ''lemma''  <nowiki>func1_1_L2</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$  '' shows '' $ \exists y\in Y.\  \langle  x,y\rangle  \in  f$ ===  ,  <nowiki>vimage_iff</nowiki>

The arguments belongs to the domain and values to the range.

 ''lemma''  <nowiki>func1_1_L5</nowiki>:
 ''   assumes '' A1: $ \langle  x,y\rangle  \in  f$ ''and '' A2: $ f:X\rightarrow Y$ ''   shows '' $ x\in X \wedge  y\in Y$+++[proof ]>
 ''from '' A1, A2  ''show''  $ x\in X$ ''using''  <nowiki>apply_iff</nowiki>
 ''with '' A2  ''have''  $ f(x)\in  Y$ ''using''  <nowiki>apply_type</nowiki>
 ''with '' A1, A2  ''show''  $ y\in Y$ ''using''  <nowiki>apply_iff</nowiki>
 ''qed'' === 

Function is a subset of cartesian product.

 ''lemma''  <nowiki>fun_subset_prod</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''   shows '' $ f \subseteq  X\times Y$+++[proof ]>
 ''fix '' $ p$
 ''assume '' $ p \in  f$
 ''with '' A1  ''have''  $ \exists x\in X.\  p = \langle x, f(x)\rangle $ ''using''  <nowiki>Pi_memberD</nowiki>
 ''then ''  ''obtain '' $ x$ ''where '' I: $ p = \langle x, f(x)\rangle $ 
 ''with '' A1, $ p \in  f$  ''have''  $ x\in X \wedge  f(x) \in  Y$ ''using''  +++^[func1_1_L5 | func1 ]...  ''lemma''  <nowiki>func1_1_L5</nowiki>:  ''assumes '' $ \langle  x,y\rangle  \in  f$  ''and'' $ f:X\rightarrow Y$  '' shows '' $ x\in X \wedge  y\in Y$ === 
 ''with '' I  ''show''  $ p \in  X\times Y$ 
 ''qed'' === 

The (argument, value) pair belongs to the graph of the function.

 ''lemma''  <nowiki>func1_1_L5A</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$,  $ x\in X$,  $ y = f(x)$ ''   shows '' $ \langle  x,y\rangle  \in  f$,  $ y \in  range(f)$+++[proof ]>
 ''from '' A1  ''show''  $ \langle  x,y\rangle  \in  f$ ''using''  <nowiki>apply_Pair</nowiki>
 ''then ''  ''show''  $ y \in  range(f)$ ''using''  <nowiki>rangeI</nowiki>
 ''qed'' === 

The range of function thet maps $X$ into $Y$ is contained in $Y$.

 ''lemma''  <nowiki>func1_1_L5B</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''   shows '' $ range(f) \subseteq  Y$+++[proof ]>
 ''fix '' $ y$
 ''assume '' $ y \in  range(f)$
 ''then ''  ''obtain '' $ x$ ''where '' $ \langle  x,y\rangle  \in  f$ ''using''  <nowiki>range_def</nowiki> ,  <nowiki>converse_def</nowiki> ,  <nowiki>domain_def</nowiki>
 ''with '' A1  ''show''  $ y\in Y$ ''using''  +++^[func1_1_L5 | func1 ]...  ''lemma''  <nowiki>func1_1_L5</nowiki>:  ''assumes '' $ \langle  x,y\rangle  \in  f$  ''and'' $ f:X\rightarrow Y$  '' shows '' $ x\in X \wedge  y\in Y$ === 
 ''qed'' === 

The image of any set is contained in the range.

 ''lemma''  <nowiki>func1_1_L6</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''   shows '' $ f(B) \subseteq  range(f)$,  $ f(B) \subseteq  Y$+++[proof ]>
 ''show''  $ f(B) \subseteq  range(f)$ ''using''  <nowiki>image_iff</nowiki> ,  <nowiki>rangeI</nowiki>
 ''with '' A1  ''show''  $ f(B) \subseteq  Y$ ''using''  +++^[func1_1_L5B | func1 ]...  ''lemma''  <nowiki>func1_1_L5B</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ range(f) \subseteq  Y$ === 
 ''qed'' === 

The inverse image of any set is contained in the domain.

 ''lemma''  <nowiki>func1_1_L6A</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''   shows '' $ f^{-1}(A)\subseteq X$+++[proof ]>
 ''fix '' $ x$
 ''assume '' A2: $ x\in f^{-1}(A)$
 ''then ''  ''obtain '' $ y$ ''where '' $ \langle  x,y\rangle  \in  f$ ''using''  <nowiki>vimage_iff</nowiki>
 ''with '' A1  ''show''  $ x\in X$ ''using''  +++^[func1_1_L5 | func1 ]...  ''lemma''  <nowiki>func1_1_L5</nowiki>:  ''assumes '' $ \langle  x,y\rangle  \in  f$  ''and'' $ f:X\rightarrow Y$  '' shows '' $ x\in X \wedge  y\in Y$ === 
 ''qed'' === 

Inverse image of a greater set is greater.

 ''lemma''  <nowiki>func1_1_L7</nowiki>:
 ''   assumes '' $ A\subseteq B$ ''and '' $ function(f)$ ''   shows '' $ f^{-1}(A)\subseteq  f^{-1}(B)$ ''using''  <nowiki>prems</nowiki> ,  <nowiki>function_vimage_Diff</nowiki>

Image of a greater set is greater.

 ''lemma''  <nowiki>func1_1_L8</nowiki>:
 ''   assumes '' A1: $ A\subseteq B$ ''   shows '' $ f(A)\subseteq  f(B)$ ''using''  <nowiki>prems</nowiki> ,  <nowiki>image_Un</nowiki>

A set is contained in the the inverse image of its image. There is similar theorem in //equalities.thy// (//function_image_vimage//) which shows that the image of inverse image of a set is contained in the set.

 ''lemma''  <nowiki>func1_1_L9</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ A\subseteq X$ ''   shows '' $ A \subseteq  f^{-1}(f(A))$+++[proof ]>
 ''from '' A1, A2  ''have''  $ \forall x\in A.\  \langle  x,f(x)\rangle  \in  f$ ''using''  <nowiki>apply_Pair</nowiki>
 ''then ''  ''show''  $ thesis$ ''using''  <nowiki>image_iff</nowiki>
 ''qed'' === 

A technical lemma needed to make the //func1_1_L11// proof more clear.

 ''lemma''  <nowiki>func1_1_L10</nowiki>:
 ''   assumes '' A1: $ f \subseteq  X\times Y$ ''and '' A2: $ \exists !y.\  (y\in Y \wedge  \langle x,y\rangle  \in  f)$ ''   shows '' $ \exists !y.\  \langle  x,y\rangle  \in  f$+++[proof ]>
 ''from '' A2  ''show''  $ \exists y.\  \langle x, y\rangle  \in  f$ 
 ''fix '' $ y$ $ n$
 ''assume '' $ \langle x,y\rangle  \in  f$ ''and '' $ \langle x,n\rangle  \in  f$
 ''with '' A1, A2  ''show''  $ y=n$ 
 ''qed'' === 

If $f\subseteq X\times Y$ and for every $x\in X$ there is exactly one $y\in Y$ such that $(x,y)\in f$ then $f$ maps $X$ to $Y$.

 ''lemma''  <nowiki>func1_1_L11</nowiki>:
 ''   assumes '' $ f \subseteq  X\times Y$ ''and '' $ \forall x\in X.\  \exists !y.\  y\in Y \wedge  \langle x,y\rangle  \in  f$ ''   shows '' $ f: X\rightarrow Y$ ''using''  <nowiki>prems</nowiki> ,  +++^[func1_1_L10 | func1 ]...  ''lemma''  <nowiki>func1_1_L10</nowiki>:  ''assumes '' $ f \subseteq  X\times Y$  ''and'' $ \exists !y.\  (y\in Y \wedge  \langle x,y\rangle  \in  f)$  '' shows '' $ \exists !y.\  \langle  x,y\rangle  \in  f$ ===  ,  <nowiki>Pi_iff_old</nowiki>

A set defined by a lambda-type expression is a fuction. There is a similar lemma in func.thy, but I had problems with lamda expressions syntax so I could not apply it. This lemma is a workaround this. Besides, lambda expressions are not readable.

 ''lemma''  <nowiki>func1_1_L11A</nowiki>:
 ''   assumes '' A1: $ \forall x\in X.\  b(x)\in Y$ ''   shows '' $ \{\langle  x,y\rangle  \in  X\times Y.\  b(x) = y\} : X\rightarrow Y$+++[proof ]>
 ''let '' $ f = \{\langle  x,y\rangle  \in  X\times Y.\  b(x) = y\}$
 ''have''  $ f \subseteq  X\times Y$ 
 ''moreover''   ''have''  $ \forall x\in X.\  \exists !y.\  y\in Y \wedge  \langle  x,y\rangle  \in  f$+++[proof ]>
 ''fix '' $ x$
 ''assume '' A2: $ x\in X$
 ''show''  $ \exists !y.\  y\in Y \wedge  \langle x, y\rangle  \in  \{\langle x,y\rangle  \in  X\times Y .\  b(x) = y\}$+++[proof ]>
 ''from '' A2, A1  ''show''  $ \exists y.\  y\in Y \wedge  \langle x, y\rangle  \in  \{\langle x,y\rangle  \in  X\times Y .\  b(x) = y\}$ 
 ''next '' 
 ''fix '' $ y$ $ y1$
 ''assume '' $ y\in Y \wedge  \langle x, y\rangle  \in  \{\langle x,y\rangle  \in  X\times Y .\  b(x) = y\}$ ''and '' $ y1\in Y \wedge  \langle x, y1\rangle  \in  \{\langle x,y\rangle  \in  X\times Y .\  b(x) = y\}$
 ''then ''  ''show''  $ y = y1$ 
 ''qed'' === 
 ''qed'' === 
 ''ultimately ''  ''show''  $ \{\langle  x,y\rangle  \in  X\times Y.\  b(x) = y\} : X\rightarrow Y$ ''using''  +++^[func1_1_L11 | func1 ]...  ''lemma''  <nowiki>func1_1_L11</nowiki>:  ''assumes '' $ f \subseteq  X\times Y$  ''and'' $ \forall x\in X.\  \exists !y.\  y\in Y \wedge  \langle x,y\rangle  \in  f$  '' shows '' $ f: X\rightarrow Y$ === 
 ''qed'' === 

The next lemma will replace //func1_1_L11A// one day.

 ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:
 ''   assumes '' A1: $ \forall x\in X.\  b(x) \in  Y$ ''   shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$+++[proof ]>
 ''let '' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$
++++[{ ]>
 ''fix '' $ x$
 ''assume '' A2: $ x\in X$
 ''have''  $ \exists !y.\  y\in Y \wedge  \langle x, y\rangle  \in  f$+++[proof ]>
 ''from '' A1, A2  ''show''  $ \exists y.\  y\in Y \wedge  \langle x, y\rangle  \in  f$ 
 ''next '' 
 ''fix '' $ y$ $ y1$
 ''assume '' $ y\in Y \wedge  \langle x, y\rangle  \in  f$ ''and '' $ y1\in Y \wedge  \langle x, y1\rangle  \in  f$
 ''then ''  ''show''  $ y = y1$ 
 ''qed'' === 
===  ''}'' 
 ''then ''  ''have''  $ \forall x\in X.\  \exists !y.\  y\in Y \wedge  \langle  x,y\rangle  \in  f$ 
 ''moreover''   ''from '' A1  ''have''  $ f \subseteq  X\times Y$ 
 ''ultimately ''  ''show''  $ thesis$ ''using''  +++^[func1_1_L11 | func1 ]...  ''lemma''  <nowiki>func1_1_L11</nowiki>:  ''assumes '' $ f \subseteq  X\times Y$  ''and'' $ \forall x\in X.\  \exists !y.\  y\in Y \wedge  \langle x,y\rangle  \in  f$  '' shows '' $ f: X\rightarrow Y$ === 
 ''qed'' === 

The value of a function defined by a meta-function is this meta-function.

 ''lemma''  <nowiki>func1_1_L11B</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$,  $ x\in X$ ''and '' A2: $ f = \{\langle  x,y\rangle  \in  X\times Y.\  b(x) = y\}$ ''   shows '' $ f(x) = b(x)$+++[proof ]>
 ''from '' A1  ''have''  $ \langle  x,f(x)\rangle  \in  f$ ''using''  <nowiki>apply_iff</nowiki>
 ''with '' A2  ''show''  $ thesis$ 
 ''qed'' === 

The next lemma will replace //func1_1_L11B// one day.

 ''lemma''  <nowiki>ZF_fun_from_tot_val</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$,  $ x\in X$ ''and '' A2: $ f = \{\langle x,b(x)\rangle .\  x\in X\}$ ''   shows '' $ f(x) = b(x)$+++[proof ]>
 ''from '' A1  ''have''  $ \langle  x,f(x)\rangle  \in  f$ ''using''  <nowiki>apply_iff</nowiki>
 ''with '' A2  ''show''  $ thesis$ 
 ''qed'' === 

Identical meaning as // ZF_fun_from_tot_val//, but phrased a bit differently.

 ''lemma''  <nowiki>ZF_fun_from_tot_val0</nowiki>:
 ''   assumes '' $ f:X\rightarrow Y$ ''and '' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$ ''   shows '' $ \forall x\in X.\  f(x) = b(x)$ ''using''  <nowiki>prems</nowiki> ,  +++^[ZF_fun_from_tot_val | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_tot_val</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$  ''and'' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$  '' shows '' $ f(x) = b(x)$ === 

We can extend a function by specifying its values on a set disjoint with the domain.

 ''lemma''  <nowiki>func1_1_L11C</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ \forall x\in A.\  b(x)\in B$ ''and '' A3: $ X\cap A = 0$ ''and '' Dg: $ g = f \cup  \{\langle x,b(x)\rangle .\  x\in A\}$ ''   shows '' $ g : X\cup A \rightarrow  Y\cup B$,  $ \forall x\in X.\  g(x) = f(x)$,  $ \forall x\in A.\  g(x) = b(x)$+++[proof ]>
 ''let '' $ h = \{\langle x,b(x)\rangle .\  x\in A\}$
 ''from '' A1, A2, A3  ''have''  I: $ f:X\rightarrow Y$,  $ h : A\rightarrow B$,  $ X\cap A = 0$ ''using''  +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ === 
 ''then ''  ''have''  $ f\cup h : X\cup A \rightarrow  Y\cup B$ ''   by (rule '' <nowiki>fun_disjoint_Un</nowiki> '')'' 
 ''with '' Dg  ''show''  $ g : X\cup A \rightarrow  Y\cup B$ 
++++[{ ]>
 ''fix '' $ x$
 ''assume '' A4: $ x\in A$
 ''with '' A1, A3  ''have''  $ (f\cup h)(x) = h(x)$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ ===  ,  <nowiki>fun_disjoint_apply2</nowiki>
 ''moreover''   ''from '' I, A4  ''have''  $ h(x) = b(x)$ ''using''  +++^[ZF_fun_from_tot_val | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_tot_val</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$  ''and'' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$  '' shows '' $ f(x) = b(x)$ === 
 ''ultimately ''  ''have''  $ (f\cup h)(x) = b(x)$ 
===  ''}'' 
 ''with '' Dg  ''show''  $ \forall x\in A.\  g(x) = b(x)$ 
++++[{ ]>
 ''fix '' $ x$
 ''assume '' A5: $ x\in X$
 ''with '' A3, I  ''have''  $ x \notin  domain(h)$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ === 
 ''then ''  ''have''  $ (f\cup h)(x) = f(x)$ ''using''  <nowiki>fun_disjoint_apply1</nowiki>
===  ''}'' 
 ''with '' Dg  ''show''  $ \forall x\in X.\  g(x) = f(x)$ 
 ''qed'' === 

We can extend a function by specifying its value at a point that does not belong to the domain.

 ''lemma''  <nowiki>func1_1_L11D</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ a\notin X$ ''and '' Dg: $ g = f \cup  \{\langle a,b\rangle \}$ ''   shows '' $ g : X\cup \{a\} \rightarrow  Y\cup \{b\}$,  $ \forall x\in X.\  g(x) = f(x)$,  $ g(a) = b$+++[proof ]>
 ''let '' $ h = \{\langle a,b\rangle \}$
 ''from '' A1, A2, Dg  ''have''  I: $ f:X\rightarrow Y$,  $ \forall x\in \{a\}.\  b\in \{b\}$,  $ X\cap \{a\} = 0$,  $ g = f \cup  \{\langle x,b\rangle .\  x\in \{a\}\}$ 
 ''then ''  ''show''  $ g : X\cup \{a\} \rightarrow  Y\cup \{b\}$ ''   by (rule '' +++^[func1_1_L11C | func1 ]...  ''lemma''  <nowiki>func1_1_L11C</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ \forall x\in A.\  b(x)\in B$  ''and'' $ X\cap A = 0$  ''and'' $ g = f \cup  \{\langle x,b(x)\rangle .\  x\in A\}$  '' shows '' $ g : X\cup A \rightarrow  Y\cup B$,  
$ \forall x\in X.\  g(x) = f(x)$,   $ \forall x\in A.\  g(x) = b(x)$ ===  '')'' 
 ''from '' I  ''show''  $ \forall x\in X.\  g(x) = f(x)$ ''   by (rule '' +++^[func1_1_L11C | func1 ]...  ''lemma''  <nowiki>func1_1_L11C</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ \forall x\in A.\  b(x)\in B$  ''and'' $ X\cap A = 0$  ''and'' $ g = f \cup  \{\langle x,b(x)\rangle .\  x\in A\}$  '' shows '' $ g : X\cup A \rightarrow  Y\cup B$,  
$ \forall x\in X.\  g(x) = f(x)$,   $ \forall x\in A.\  g(x) = b(x)$ ===  '')'' 
 ''from '' I  ''have''  $ \forall x\in \{a\}.\  g(x) = b$ ''   by (rule '' +++^[func1_1_L11C | func1 ]...  ''lemma''  <nowiki>func1_1_L11C</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ \forall x\in A.\  b(x)\in B$  ''and'' $ X\cap A = 0$  ''and'' $ g = f \cup  \{\langle x,b(x)\rangle .\  x\in A\}$  '' shows '' $ g : X\cup A \rightarrow  Y\cup B$,  
$ \forall x\in X.\  g(x) = f(x)$,   $ \forall x\in A.\  g(x) = b(x)$ ===  '')'' 
 ''then ''  ''show''  $ g(a) = b$ 
 ''qed'' === 

A technical lemma about extending a function both by defining on a set disjoint with the domain and on a point that does not belong to any of those sets.

 ''lemma''  <nowiki>func1_1_L11E</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ \forall x\in A.\  b(x)\in B$ ''and '' A3: $ X\cap A = 0$ ''and '' A4: $ a\notin  X\cup A$ ''and '' Dg: $ g = f \cup  \{\langle x,b(x)\rangle .\  x\in A\} \cup  \{\langle a,c\rangle \}$ ''   shows '' $ g : X\cup A\cup \{a\} \rightarrow  Y\cup B\cup \{c\}$,  $ \forall x\in X.\  g(x) = f(x)$,  $ \forall x\in A.\  g(x) = b(x)$,  $ g(a) = c$+++[proof ]>
 ''let '' $ h = f \cup  \{\langle x,b(x)\rangle .\  x\in A\}$
 ''from '' prems  ''show''  $ g : X\cup A\cup \{a\} \rightarrow  Y\cup B\cup \{c\}$ ''using''  +++^[func1_1_L11C | func1 ]...  ''lemma''  <nowiki>func1_1_L11C</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ \forall x\in A.\  b(x)\in B$  ''and'' $ X\cap A = 0$  ''and'' $ g = f \cup  \{\langle x,b(x)\rangle .\  x\in A\}$  '' shows '' $ g : X\cup A \rightarrow  Y\cup B$,  
$ \forall x\in X.\  g(x) = f(x)$,   $ \forall x\in A.\  g(x) = b(x)$ ===  ,  +++^[func1_1_L11D | func1 ]...  ''lemma''  <nowiki>func1_1_L11D</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ a\notin X$  ''and'' $ g = f \cup  \{\langle a,b\rangle \}$  '' shows '' $ g : X\cup \{a\} \rightarrow  Y\cup \{b\}$,   $ \forall x\in X.\  g(x) = f(x)$,   $ g(a) = b$ === 
 ''from '' A1, A2, A3  ''have''  I: $ f:X\rightarrow Y$,  $ \forall x\in A.\  b(x)\in B$,  $ X\cap A = 0$,  $ h = f \cup  \{\langle x,b(x)\rangle .\  x\in A\}$ 
 ''from '' prems  ''have''  II: $ h : X\cup A \rightarrow  Y\cup B$,  $ a\notin  X\cup A$,  $ g = h \cup  \{\langle a,c\rangle \}$ ''using''  +++^[func1_1_L11C | func1 ]...  ''lemma''  <nowiki>func1_1_L11C</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ \forall x\in A.\  b(x)\in B$  ''and'' $ X\cap A = 0$  ''and'' $ g = f \cup  \{\langle x,b(x)\rangle .\  x\in A\}$  '' shows '' $ g : X\cup A \rightarrow  Y\cup B$,  
$ \forall x\in X.\  g(x) = f(x)$,   $ \forall x\in A.\  g(x) = b(x)$ === 
 ''then ''  ''have''  III: $ \forall x\in X\cup A.\  g(x) = h(x)$ ''   by (rule '' +++^[func1_1_L11D | func1 ]...  ''lemma''  <nowiki>func1_1_L11D</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ a\notin X$  ''and'' $ g = f \cup  \{\langle a,b\rangle \}$  '' shows '' $ g : X\cup \{a\} \rightarrow  Y\cup \{b\}$,   $ \forall x\in X.\  g(x) = f(x)$,   $ g(a) = b$ ===  '')'' 
 ''moreover''   ''from '' I  ''have''  $ \forall x\in X.\  h(x) = f(x)$ ''   by (rule '' +++^[func1_1_L11C | func1 ]...  ''lemma''  <nowiki>func1_1_L11C</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ \forall x\in A.\  b(x)\in B$  ''and'' $ X\cap A = 0$  ''and'' $ g = f \cup  \{\langle x,b(x)\rangle .\  x\in A\}$  '' shows '' $ g : X\cup A \rightarrow  Y\cup B$,  
$ \forall x\in X.\  g(x) = f(x)$,   $ \forall x\in A.\  g(x) = b(x)$ ===  '')'' 
 ''ultimately ''  ''show''  $ \forall x\in X.\  g(x) = f(x)$ 
 ''from '' I  ''have''  $ \forall x\in A.\  h(x) = b(x)$ ''   by (rule '' +++^[func1_1_L11C | func1 ]...  ''lemma''  <nowiki>func1_1_L11C</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ \forall x\in A.\  b(x)\in B$  ''and'' $ X\cap A = 0$  ''and'' $ g = f \cup  \{\langle x,b(x)\rangle .\  x\in A\}$  '' shows '' $ g : X\cup A \rightarrow  Y\cup B$,  
$ \forall x\in X.\  g(x) = f(x)$,   $ \forall x\in A.\  g(x) = b(x)$ ===  '')'' 
 ''with '' III  ''show''  $ \forall x\in A.\  g(x) = b(x)$ 
 ''from '' II  ''show''  $ g(a) = c$ ''   by (rule '' +++^[func1_1_L11D | func1 ]...  ''lemma''  <nowiki>func1_1_L11D</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ a\notin X$  ''and'' $ g = f \cup  \{\langle a,b\rangle \}$  '' shows '' $ g : X\cup \{a\} \rightarrow  Y\cup \{b\}$,   $ \forall x\in X.\  g(x) = f(x)$,   $ g(a) = b$ ===  '')'' 
 ''qed'' === 

The inverse image of an intersection of a nonempty collection of sets is the intersection of the inverse images. This generalizes //function_vimage_Int// which is proven for the case of two sets.

 ''lemma''  <nowiki>func1_1_L12</nowiki>:
 ''   assumes '' A1: $ B\subseteq Pow(Y)$ ''and '' A2: $ B\neq 0$ ''and '' A3: $ f:X\rightarrow Y$ ''   shows '' $ f^{-1}(\bigcap B) = (\bigcap U\in B.\  f^{-1}(U))$+++[proof ]>
 ''from '' A2  ''show''  $ f^{-1}(\bigcap B) \subseteq  (\bigcap U\in B.\  f^{-1}(U))$ 
 ''show''  $ (\bigcap U\in B.\  f^{-1}(U)) \subseteq  f^{-1}(\bigcap B)$+++[proof ]>
 ''fix '' $ x$
 ''assume '' A4: $ x \in  (\bigcap U\in B.\  f^{-1}(U))$
 ''from '' A3  ''have''  $ \forall U\in B.\  f^{-1}(U) \subseteq  X$ ''using''  +++^[func1_1_L6A | func1 ]...  ''lemma''  <nowiki>func1_1_L6A</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(A)\subseteq X$ === 
 ''with '' A4  ''have''  $ \forall U\in B.\  x\in X$ 
 ''with '' A2  ''have''  $ x\in X$ 
 ''with '' A3  ''have''  $ \exists !y.\  \langle  x,y\rangle  \in  f$ ''using''  <nowiki>Pi_iff_old</nowiki>
 ''with '' A2, A4  ''show''  $ x \in  f^{-1}(\bigcap B)$ ''using''  <nowiki>vimage_iff</nowiki>
 ''qed'' === 
 ''qed'' === 

If the inverse image of a set is not empty, then the set is not empty. Proof by contradiction.

 ''lemma''  <nowiki>func1_1_L13</nowiki>:
 ''   assumes '' A1: $ f^{-1}(A) \neq  0$ ''   shows '' $ A\neq 0$ ''using''  <nowiki>assms</nowiki>

If the image of a set is not empty, then the set is not empty. Proof by contradiction.

 ''lemma''  <nowiki>func1_1_L13A</nowiki>:
 ''   assumes '' A1: $ f(A)\neq 0$ ''   shows '' $ A\neq 0$ ''using''  <nowiki>assms</nowiki>

What is the inverse image of a singleton?

 ''lemma''  <nowiki>func1_1_L14</nowiki>:
 ''   assumes '' $ f\in X\rightarrow Y$ ''   shows '' $ f^{-1}(\{y\}) = \{x\in X.\  f(x) = y\}$ ''using''  <nowiki>prems</nowiki> ,  +++^[func1_1_L6A | func1 ]...  ''lemma''  <nowiki>func1_1_L6A</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(A)\subseteq X$ ===  ,  <nowiki>vimage_singleton_iff</nowiki> ,  <nowiki>apply_iff</nowiki>

A lemma that can be used instead //fun_extension_iff// to show that two functions are equal

 ''lemma''  <nowiki>func_eq</nowiki>:
 ''   assumes '' $ f: X\rightarrow Y$,  $ g: X\rightarrow Z$ ''and '' $ \forall x\in X.\  f(x) = g(x)$ ''   shows '' $ f = g$ ''using''  <nowiki>prems</nowiki> ,  <nowiki>fun_extension_iff</nowiki>

Function defined on a singleton is a single pair.

 ''lemma''  <nowiki>func_singleton_pair</nowiki>:
 ''   assumes '' A1: $ f : \{a\}\rightarrow X$ ''   shows '' $ f = \{\langle a, f(a)\rangle \}$+++[proof ]>
 ''let '' $ g = \{\langle a, f(a)\rangle \}$
 ''note '' A1
 ''moreover''   ''have''  $ g : \{a\} \rightarrow  \{f(a)\}$ ''using''  <nowiki>singleton_fun</nowiki>
 ''moreover''   ''have''  $ \forall x \in  \{a\}.\  f(x) = g(x)$ ''using''  <nowiki>singleton_apply</nowiki>
 ''ultimately ''  ''show''  $ f = g$ ''   by (rule '' +++^[func_eq | func1 ]...  ''lemma''  <nowiki>func_eq</nowiki>:  ''assumes '' $ f: X\rightarrow Y$,   $ g: X\rightarrow Z$  ''and'' $ \forall x\in X.\  f(x) = g(x)$  '' shows '' $ f = g$ ===  '')'' 
 ''qed'' === 

A single pair is a function on a singleton. This is similar to //singleton_fun// from standard Isabelle/ZF.

 ''lemma''  <nowiki>pair_func_singleton</nowiki>:
 ''   assumes '' A1: $ y \in  Y$ ''   shows '' $ \{\langle x,y\rangle \} : \{x\} \rightarrow  Y$+++[proof ]>
 ''have''  $ \{\langle x,y\rangle \} : \{x\} \rightarrow  \{y\}$ ''using''  <nowiki>singleton_fun</nowiki>
 ''moreover''   ''from '' A1  ''have''  $ \{y\} \subseteq  Y$ 
 ''ultimately ''  ''show''  $ \{\langle x,y\rangle \} : \{x\} \rightarrow  Y$ ''   by (rule '' +++^[func1_1_L1B | func1 ]...  ''lemma''  <nowiki>func1_1_L1B</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ Y\subseteq Z$  '' shows '' $ f:X\rightarrow Z$ ===  '')'' 
 ''qed'' === 

The value of a pair on the first element is the second one.

 ''lemma''  <nowiki>pair_val</nowiki>:
 ''   shows '' $ \{\langle x,y\rangle \}(x) = y$ ''using''  <nowiki>singleton_fun</nowiki> ,  <nowiki>apply_equality</nowiki>

A more familiar definition of inverse image.

 ''lemma''  <nowiki>func1_1_L15</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''   shows '' $ f^{-1}(A) = \{x\in X.\  f(x) \in  A\}$+++[proof ]>
 ''have''  $ f^{-1}(A) = (\bigcup y\in A .\  f^{-1}\{y\})$ ''   by (rule '' <nowiki>vimage_eq_UN</nowiki> '')'' 
 ''with '' A1  ''show''  $ thesis$ ''using''  +++^[func1_1_L14 | func1 ]...  ''lemma''  <nowiki>func1_1_L14</nowiki>:  ''assumes '' $ f\in X\rightarrow Y$  '' shows '' $ f^{-1}(\{y\}) = \{x\in X.\  f(x) = y\}$ === 
 ''qed'' === 

A more familiar definition of image.

 ''lemma''  <nowiki>func_imagedef</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ A\subseteq X$ ''   shows '' $ f(A) = \{f(x).\  x \in  A\}$+++[proof ]>
 ''from '' A1  ''show''  $ f(A) \subseteq  \{f(x).\  x \in  A\}$ ''using''  <nowiki>image_iff</nowiki> ,  <nowiki>apply_iff</nowiki>
 ''show''  $ \{f(x).\  x \in  A\} \subseteq  f(A)$+++[proof ]>
 ''fix '' $ y$
 ''assume '' $ y \in  \{f(x).\  x \in  A\}$
 ''then ''  ''obtain '' $ x$ ''where '' $ x\in A \wedge  y = f(x)$ 
 ''with '' A1, A2  ''show''  $ y \in  f(A)$ ''using''  <nowiki>apply_iff</nowiki> ,  <nowiki>image_iff</nowiki>
 ''qed'' === 
 ''qed'' === 

What is the image of a singleton?

 ''lemma''  <nowiki>singleton_image</nowiki>:
 ''   assumes '' $ f\in X\rightarrow Y$ ''and '' $ x\in X$ ''   shows '' $ f\{x\}= \{f(x)\}$ ''using''  <nowiki>assms</nowiki> ,  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 

If an element of the domain of a function belongs to a set, then its value belongs to the imgage of that set.

 ''lemma''  <nowiki>func1_1_L15D</nowiki>:
 ''   assumes '' $ f:X\rightarrow Y$,  $ x\in A$,  $ A\subseteq X$ ''   shows '' $ f(x) \in  f(A)$ ''using''  <nowiki>assms</nowiki> ,  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 

Range is the image of the domain. Isabelle/ZF defines $ range(f)$ as $ domain(converse(f))$, and that's why we have something to prove here.

 ''lemma''  <nowiki>range_image_domain</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''   shows '' $ f(X) = range(f)$+++[proof ]>
 ''show''  $ f(X) \subseteq  range(f)$ ''using''  <nowiki>image_def</nowiki>
++++[{ ]>
 ''fix '' $ y$
 ''assume '' $ y \in  range(f)$
 ''then ''  ''obtain '' $ x$ ''where '' $ \langle y,x\rangle  \in  converse(f)$ 
 ''with '' A1  ''have''  $ x\in X$ ''using''  +++^[func1_1_L5 | func1 ]...  ''lemma''  <nowiki>func1_1_L5</nowiki>:  ''assumes '' $ \langle  x,y\rangle  \in  f$  ''and'' $ f:X\rightarrow Y$  '' shows '' $ x\in X \wedge  y\in Y$ === 
 ''with '' A1  ''have''  $ f(x) \in  f(X)$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''with '' A1, $ \langle y,x\rangle  \in  converse(f)$  ''have''  $ y \in  f(X)$ ''using''  <nowiki>apply_equality</nowiki>
===  ''}'' 
 ''then ''  ''show''  $ range(f) \subseteq  f(X)$ 
 ''qed'' === 

The difference of images is contained in the image of difference.

 ''lemma''  <nowiki>diff_image_diff</nowiki>:
 ''   assumes '' A1: $ f: X\rightarrow Y$ ''and '' A2: $ A\subseteq X$ ''   shows '' $ f(X) - f(A) \subseteq  f(X-A)$+++[proof ]>
 ''fix '' $ y$
 ''assume '' $ y \in  f(X) - f(A)$
 ''hence''  $ y \in  f(X)$ ''and '' I: $ y \notin  f(A)$
 ''with '' A1  ''obtain '' $ x$ ''where '' $ x\in X$ ''and '' II: $ y = f(x)$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''with '' A1, A2, I  ''have''  $ x\notin A$ ''using''  +++^[func1_1_L15D | func1 ]...  ''lemma''  <nowiki>func1_1_L15D</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in A$,   $ A\subseteq X$  '' shows '' $ f(x) \in  f(A)$ === 
 ''with '' $ x\in X$  ''have''  $ x \in  X-A$,  $ X-A \subseteq  X$ 
 ''with '' A1, II  ''show''  $ y \in  f(X-A)$ ''using''  +++^[func1_1_L15D | func1 ]...  ''lemma''  <nowiki>func1_1_L15D</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in A$,   $ A\subseteq X$  '' shows '' $ f(x) \in  f(A)$ === 
 ''qed'' === 

The image of an intersection is contained in the intersection of the images.

 ''lemma''  <nowiki>image_of_Inter</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ I\neq 0$ ''and '' A3: $ \forall i\in I.\  P(i) \subseteq  X$ ''   shows '' $ f(\bigcap i\in I.\  P(i)) \subseteq  ( \bigcap i\in I.\  f(P(i)) )$+++[proof ]>
 ''fix '' $ y$
 ''assume '' A4: $ y \in  f(\bigcap i\in I.\  P(i))$
 ''from '' A1, A2, A3  ''have''  $ f(\bigcap i\in I.\  P(i)) = \{f(x).\  x \in  ( \bigcap i\in I.\  P(i) )\}$ ''using''  +++^[ZF1_1_L7 | ZF1 ]...  ''lemma''  <nowiki>ZF1_1_L7</nowiki>:  ''assumes '' $ I\neq 0$  ''and'' $ \forall i\in I.\  P(i) \subseteq  X$  '' shows '' $ ( \bigcap i\in I.\  P(i) ) \subseteq  X$ ===  ,  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''with '' A4  ''obtain '' $ x$ ''where '' $ x \in  ( \bigcap i\in I.\  P(i) )$ ''and '' $ y = f(x)$ 
 ''with '' A1, A2, A3  ''show''  $ y \in  ( \bigcap i\in I.\  f(P(i)) )$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''qed'' === 

The image of a nonempty subset of domain is nonempty.

 ''lemma''  <nowiki>func1_1_L15A</nowiki>:
 ''   assumes '' A1: $ f: X\rightarrow Y$ ''and '' A2: $ A\subseteq X$ ''and '' A3: $ A\neq 0$ ''   shows '' $ f(A) \neq  0$+++[proof ]>
 ''from '' A3  ''obtain '' $ x$ ''where '' $ x\in A$ 
 ''with '' A1, A2  ''have''  $ f(x) \in  f(A)$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''then ''  ''show''  $ f(A) \neq  0$ 
 ''qed'' === 

The next lemma allows to prove statements about the values in the domain of a function given a statement about values in the range.

 ''lemma''  <nowiki>func1_1_L15B</nowiki>:
 ''   assumes '' $ f:X\rightarrow Y$ ''and '' $ A\subseteq X$ ''and '' $ \forall y\in f(A).\  P(y)$ ''   shows '' $ \forall x\in A.\  P(f(x))$ ''using''  <nowiki>prems</nowiki> ,  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 

An image of an image is the image of a composition.

 ''lemma''  <nowiki>func1_1_L15C</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ g:Y\rightarrow Z$ ''and '' A3: $ A\subseteq X$ ''   shows '' $ g(f(A)) =  \{g(f(x)).\  x\in A\}$,  $ g(f(A)) = (g\circ f)(A)$+++[proof ]>
 ''from '' A1, A3  ''have''  $ \{f(x).\  x\in A\} \subseteq  Y$ ''using''  <nowiki>apply_funtype</nowiki>
 ''with '' A2  ''have''  $ g\{f(x).\  x\in A\} = \{g(f(x)).\  x\in A\}$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''with '' A1, A3  ''show''  I: $ g(f(A)) =  \{g(f(x)).\  x\in A\}$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''from '' A1, A3  ''have''  $ \forall x\in A.\  (g\circ f)(x) = g(f(x))$ ''using''  <nowiki>comp_fun_apply</nowiki>
 ''with '' I  ''have''  $ g(f(A)) = \{(g\circ f)(x).\  x\in A\}$ 
 ''moreover''   ''from '' A1, A2, A3  ''have''  $ (g\circ f)(A) = \{(g\circ f)(x).\  x\in A\}$ ''using''  <nowiki>comp_fun</nowiki> ,  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''ultimately ''  ''show''  $ g(f(A)) = (g\circ f)(A)$ 
 ''qed'' === 

What is the image of a set defined by a meta-fuction?

 ''lemma''  <nowiki>func1_1_L17</nowiki>:
 ''   assumes '' A1: $ f \in  X\rightarrow Y$ ''and '' A2: $ \forall x\in A.\  b(x) \in  X$ ''   shows '' $ f(\{b(x).\  x\in A\}) = \{f(b(x)).\  x\in A\}$+++[proof ]>
 ''from '' A2  ''have''  $ \{b(x).\  x\in A\} \subseteq  X$ 
 ''with '' A1  ''show''  $ thesis$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''qed'' === 

What are the values of composition of three functions?

 ''lemma''  <nowiki>func1_1_L18</nowiki>:
 ''   assumes '' A1: $ f:A\rightarrow B$,  $ g:B\rightarrow C$,  $ h:C\rightarrow D$ ''and '' A2: $ x\in A$ ''   shows '' $ (h\circ g\circ f)(x) \in  D$,  $ (h\circ g\circ f)(x) = h(g(f(x)))$+++[proof ]>
 ''from '' A1  ''have''  $ (h\circ g\circ f) : A\rightarrow D$ ''using''  <nowiki>comp_fun</nowiki>
 ''with '' A2  ''show''  $ (h\circ g\circ f)(x) \in  D$ ''using''  <nowiki>apply_funtype</nowiki>
 ''from '' A1, A2  ''have''  $ (h\circ g\circ f)(x) = h( (g\circ f)(x))$ ''using''  <nowiki>comp_fun</nowiki> ,  <nowiki>comp_fun_apply</nowiki>
 ''with '' A1, A2  ''show''  $ (h\circ g\circ f)(x) = h(g(f(x)))$ ''using''  <nowiki>comp_fun_apply</nowiki>
 ''qed'' === 

A composition of functions is a function. This is a slight generaization of standard Isabelle's //comp_fun//

 ''lemma''  <nowiki>comp_fun_subset</nowiki>:
 ''   assumes '' A1: $ g:A\rightarrow B$ ''and '' A2: $ f:C\rightarrow D$ ''and '' A3: $ B \subseteq  C$ ''   shows '' $ f\circ g : A \rightarrow  D$+++[proof ]>
 ''from '' A1, A3  ''have''  $ g:A\rightarrow C$ ''   by (rule '' +++^[func1_1_L1B | func1 ]...  ''lemma''  <nowiki>func1_1_L1B</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ Y\subseteq Z$  '' shows '' $ f:X\rightarrow Z$ ===  '')'' 
 ''with '' A2  ''show''  $ f\circ g : A \rightarrow  D$ ''using''  <nowiki>comp_fun</nowiki>
 ''qed'' === 

A lemma about a value of a function that is a union of some collection of functions.

 ''lemma''  <nowiki>fun_Union_apply</nowiki>:
 ''   assumes '' A1: $ \bigcup F : X\rightarrow Y$ ''and '' A2: $ f\in F$ ''and '' A3: $ f:A\rightarrow B$ ''and '' A4: $ x\in A$ ''   shows '' $ (\bigcup F)(x) = f(x)$+++[proof ]>
 ''from '' A3, A4  ''have''  $ \langle x, f(x)\rangle  \in  f$ ''using''  <nowiki>apply_Pair</nowiki>
 ''with '' A2  ''have''  $ \langle x, f(x)\rangle  \in  \bigcup F$ 
 ''with '' A1  ''show''  $ (\bigcup F)(x) = f(x)$ ''using''  <nowiki>apply_equality</nowiki>
 ''qed'' === 


!Functions restricted to a set

Standard Isabelle/ZF defines the notion $ restrict(f,A)$ of to mean a function (or relation) $f$ restricted to a set. This means that if $f$ is a function defined on $X$ and $A$ is a subset of $X$ then $ restrict(f,A)$ is a function whith the same values as $f$, but whose domain is $A$.

What is the inverse image of a set under a restricted fuction?

 ''lemma''  <nowiki>func1_2_L1</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ B\subseteq X$ ''   shows '' $ restrict(f,B)^{-1}(A) = f^{-1}(A) \cap  B$+++[proof ]>
 ''let '' $ g = restrict(f,B)$
 ''from '' A1, A2  ''have''  $ g:B\rightarrow Y$ ''using''  <nowiki>restrict_type2</nowiki>
 ''with '' A2, A1  ''show''  $ g^{-1}(A) = f^{-1}(A) \cap  B$ ''using''  +++^[func1_1_L15 | func1 ]...  ''lemma''  <nowiki>func1_1_L15</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f^{-1}(A) = \{x\in X.\  f(x) \in  A\}$ ===  ,  <nowiki>restrict_if</nowiki>
 ''qed'' === 

A criterion for when one function is a restriction of another. The lemma below provides a result useful in the actual proof of the criterion and applications.

 ''lemma''  <nowiki>func1_2_L2</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ g \in  A\rightarrow Z$ ''and '' A3: $ A\subseteq X$ ''and '' A4: $ f \cap  A\times Z = g$ ''   shows '' $ \forall x\in A.\  g(x) = f(x)$+++[proof ]>
 ''fix '' $ x$
 ''assume '' $ x\in A$
 ''with '' A2  ''have''  $ \langle  x,g(x)\rangle  \in  g$ ''using''  <nowiki>apply_Pair</nowiki>
 ''with '' A4, A1  ''show''  $ g(x) = f(x)$ ''using''  <nowiki>apply_iff</nowiki>
 ''qed'' === 

Here is the actual criterion.

 ''lemma''  <nowiki>func1_2_L3</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ g:A\rightarrow Z$ ''and '' A3: $ A\subseteq X$ ''and '' A4: $ f \cap  A\times Z = g$ ''   shows '' $ g = restrict(f,A)$+++[proof ]>
 ''from '' A4  ''show''  $ g \subseteq  restrict(f, A)$ ''using''  <nowiki>restrict_iff</nowiki>
 ''show''  $ restrict(f, A) \subseteq  g$+++[proof ]>
 ''fix '' $ z$
 ''assume '' A5: $ z \in  restrict(f,A)$
 ''then ''  ''obtain '' $ x$ $ y$ ''where '' D1: $ z\in f \wedge  x\in A  \wedge  z = \langle x,y\rangle $ ''using''  <nowiki>restrict_iff</nowiki>
 ''with '' A1  ''have''  $ y = f(x)$ ''using''  <nowiki>apply_iff</nowiki>
 ''with '' A1, A2, A3, A4, D1  ''have''  $ y = g(x)$ ''using''  +++^[func1_2_L2 | func1 ]...  ''lemma''  <nowiki>func1_2_L2</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ g \in  A\rightarrow Z$  ''and'' $ A\subseteq X$  ''and'' $ f \cap  A\times Z = g$  '' shows '' $ \forall x\in A.\  g(x) = f(x)$ === 
 ''with '' A2, D1  ''show''  $ z\in g$ ''using''  <nowiki>apply_Pair</nowiki>
 ''qed'' === 
 ''qed'' === 

Which function space a restricted function belongs to?

 ''lemma''  <nowiki>func1_2_L4</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow Y$ ''and '' A2: $ A\subseteq X$ ''and '' A3: $ \forall x\in A.\  f(x) \in  Z$ ''   shows '' $ restrict(f,A) : A\rightarrow Z$+++[proof ]>
 ''let '' $ g = restrict(f,A)$
 ''from '' A1, A2  ''have''  $ g : A\rightarrow Y$ ''using''  <nowiki>restrict_type2</nowiki>
 ''moreover''  ++++[{ ]>
 ''fix '' $ x$
 ''assume '' $ x\in A$
 ''with '' A1, A3  ''have''  $ g(x) \in  Z$ ''using''  <nowiki>restrict</nowiki>
===  ''}'' 
 ''ultimately ''  ''show''  $ thesis$ ''   by (rule '' <nowiki>Pi_type</nowiki> '')'' 
 ''qed'' === 


!Constant functions

Constant functions are trivial, but stille we need to prove some properties to shorten proofs.

We define constant($=c$) functions on a set $X$ in a natural way as ConstantFunction$(X,c)$.

 ''Definition
'' $ ConstantFunction(X,c) \equiv  X\times \{c\}$

Constant function belongs to the function space.

 ''lemma''  <nowiki>func1_3_L1</nowiki>:
 ''   assumes '' A1: $ c\in Y$ ''   shows '' $ ConstantFunction(X,c) : X\rightarrow Y$+++[proof ]>
 ''from '' A1  ''have''  $ X\times \{c\} = \{\langle  x,y\rangle  \in  X\times Y.\  c = y\}$ 
 ''with '' A1  ''show''  $ thesis$ ''using''  +++^[func1_1_L11A | func1 ]...  ''lemma''  <nowiki>func1_1_L11A</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x)\in Y$  '' shows '' $ \{\langle  x,y\rangle  \in  X\times Y.\  b(x) = y\} : X\rightarrow Y$ ===  ,  +++^[ConstantFunction_def | func1 ]... Definition of <nowiki>ConstantFunction</nowiki>:
$ ConstantFunction(X,c) \equiv  X\times \{c\}$=== 
 ''qed'' === 

Constant function is equal to the constant on its domain.

 ''lemma''  <nowiki>func1_3_L2</nowiki>:
 ''   assumes '' A1: $ x\in X$ ''   shows '' $ ConstantFunction(X,c)(x) = c$+++[proof ]>
 ''have''  $ ConstantFunction(X,c) \in  X\rightarrow \{c\}$ ''using''  +++^[func1_3_L1 | func1 ]...  ''lemma''  <nowiki>func1_3_L1</nowiki>:  ''assumes '' $ c\in Y$  '' shows '' $ ConstantFunction(X,c) : X\rightarrow Y$ === 
 ''moreover''   ''from '' A1  ''have''  $ \langle  x,c\rangle  \in  ConstantFunction(X,c)$ ''using''  +++^[ConstantFunction_def | func1 ]... Definition of <nowiki>ConstantFunction</nowiki>:
$ ConstantFunction(X,c) \equiv  X\times \{c\}$=== 
 ''ultimately ''  ''show''  $ thesis$ ''using''  <nowiki>apply_iff</nowiki>
 ''qed'' === 


!Injections, surjections, bijections etc.

In this section we prove the properties of the spaces of injections, surjections and bijections that we can't find in the standard Isabelle's //Perm.thy//.

For injections the image a difference of two sets is the difference of images

 ''lemma''  <nowiki>inj_image_dif</nowiki>:
 ''   assumes '' A1: $ f \in  inj(A,B)$ ''and '' A2: $ C \subseteq  A$ ''   shows '' $ f(A-C) = f(A) - f(C)$+++[proof ]>
 ''show''  $ f(A - C) \subseteq  f(A) - f(C)$+++[proof ]>
 ''fix '' $ y$
 ''assume '' A3: $ y \in  f(A - C)$
 ''from '' A1  ''have''  $ f:A\rightarrow B$ ''using''  <nowiki>inj_def</nowiki>
 ''moreover''   ''have''  $ A-C \subseteq  A$ 
 ''ultimately ''  ''have''  $ f(A-C) = \{f(x).\  x \in  A-C\}$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''with '' A3  ''obtain '' $ x$ ''where '' I: $ f(x) = y$ ''and '' $ x \in  A-C$ 
 ''hence''  $ x\in A$
 ''with '' $ f:A\rightarrow B$, I  ''have''  $ y \in  f(A)$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''moreover''   ''have''  $ y \notin   f(C)$+++[proof ]>
++++[{ ]>
 ''assume '' $ y \in  f(C)$
 ''with '' A2, $ f:A\rightarrow B$  ''obtain '' $ x_0$ ''where '' II: $ f(x_0) = y$ ''and '' $ x_0 \in  C$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''with '' A1, A2, I, $ x\in A$  ''have''  $ f \in  inj(A,B)$,  $ f(x) = f(x_0)$,  $ x\in A$,  $ x_0 \in  A$ 
 ''then ''  ''have''  $ x = x_0$ ''   by (rule '' <nowiki>inj_apply_equality</nowiki> '')'' 
 ''with '' $ x \in  A-C$, $ x_0 \in  C$  ''have''  $ False$ 
===  ''}'' 
 ''thus''  $ thesis$
 ''qed'' === 
 ''ultimately ''  ''show''  $ y \in  f(A) - f(C)$ 
 ''qed'' === 
 ''from '' A1, A2  ''show''  $ f(A) - f(C) \subseteq  f(A-C)$ ''using''  <nowiki>inj_def</nowiki> ,  +++^[diff_image_diff | func1 ]...  ''lemma''  <nowiki>diff_image_diff</nowiki>:  ''assumes '' $ f: X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(X) - f(A) \subseteq  f(X-A)$ === 
 ''qed'' === 

For surjection from $A$ to $B$ the image of the domain is $B$.

 ''lemma''  <nowiki>surj_range_image_domain</nowiki>:
 ''   assumes '' A1: $ f \in  surj(A,B)$ ''   shows '' $ f(A) = B$+++[proof ]>
 ''from '' A1  ''have''  $ f(A) = range(f)$ ''using''  <nowiki>surj_def</nowiki> ,  +++^[range_image_domain | func1 ]...  ''lemma''  <nowiki>range_image_domain</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f(X) = range(f)$ === 
 ''with '' A1  ''show''  $ f(A) = B$ ''using''  <nowiki>surj_range</nowiki>
 ''qed'' === 

Restriction of an bijection to a set without a point is a a bijection.

 ''lemma''  <nowiki>bij_restrict_rem</nowiki>:
 ''   assumes '' A1: $ f \in  bij(A,B)$ ''and '' A2: $ a\in A$ ''   shows '' $ restrict(f, A-\{a\}) \in  bij(A-\{a\}, B-\{f(a)\})$+++[proof ]>
 ''let '' $ C = A-\{a\}$
 ''from '' A1  ''have''  $ f \in  inj(A,B)$,  $ C \subseteq  A$ ''using''  <nowiki>bij_def</nowiki>
 ''then ''  ''have''  $ restrict(f,C) \in  bij(C, f(C))$ ''using''  <nowiki>restrict_bij</nowiki>
 ''moreover''   ''have''  $ f(C) =  B-\{f(a)\}$+++[proof ]>
 ''from '' A2, $ f \in  inj(A,B)$  ''have''  $ f(C) = f(A) - f\{a\}$ ''using''  +++^[inj_image_dif | func1 ]...  ''lemma''  <nowiki>inj_image_dif</nowiki>:  ''assumes '' $ f \in  inj(A,B)$  ''and'' $ C \subseteq  A$  '' shows '' $ f(A-C) = f(A) - f(C)$ === 
 ''moreover''   ''from '' A1  ''have''  $ f(A) = B$ ''using''  <nowiki>bij_def</nowiki> ,  +++^[surj_range_image_domain | func1 ]...  ''lemma''  <nowiki>surj_range_image_domain</nowiki>:  ''assumes '' $ f \in  surj(A,B)$  '' shows '' $ f(A) = B$ === 
 ''moreover''   ''from '' A1, A2  ''have''  $ f\{a\} = \{f(a)\}$ ''using''  <nowiki>bij_is_fun</nowiki> ,  +++^[singleton_image | func1 ]...  ''lemma''  <nowiki>singleton_image</nowiki>:  ''assumes '' $ f\in X\rightarrow Y$  ''and'' $ x\in X$  '' shows '' $ f\{x\}= \{f(x)\}$ === 
 ''ultimately ''  ''show''  $ f(C) =  B-\{f(a)\}$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

The domain of a bijection between $X$ and $Y$ is $X$.

 ''lemma''  <nowiki>domain_of_bij</nowiki>:
 ''   assumes '' A1: $ f \in  bij(X,Y)$ ''   shows '' $ domain(f) = X$+++[proof ]>
 ''from '' A1  ''have''  $ f:X\rightarrow Y$ ''using''  <nowiki>bij_is_fun</nowiki>
 ''then ''  ''show''  $ domain(f) = X$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ === 
 ''qed'' === 

The value of the inverse of an injection on a point of the image of a set belongs to that set.

 ''lemma''  <nowiki>inj_inv_back_in_set</nowiki>:
 ''   assumes '' A1: $ f \in  inj(A,B)$ ''and '' A2: $ C\subseteq A$ ''and '' A3: $ y \in  f(C)$ ''   shows '' $ converse(f)(y) \in  C$,  $ f(converse(f)(y)) = y$+++[proof ]>
 ''from '' A1  ''have''  I: $ f:A\rightarrow B$ ''using''  <nowiki>inj_is_fun</nowiki>
 ''with '' A2, A3  ''obtain '' $ x$ ''where '' II: $ x\in C$,  $ y = f(x)$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
 ''with '' A1, A2  ''show''  $ converse(f)(y) \in  C$ ''using''  <nowiki>left_inverse</nowiki>
 ''from '' A1, A2, I, II  ''show''  $ f(converse(f)(y)) = y$ ''using''  +++^[func1_1_L5A | func1 ]...  ''lemma''  <nowiki>func1_1_L5A</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$,   $ y = f(x)$  '' shows '' $ \langle  x,y\rangle  \in  f$,   $ y \in  range(f)$ ===  ,  <nowiki>right_inverse</nowiki>
 ''qed'' === 

For injections if a value at a point belongs to the image of a set, then the point belongs to the set.

 ''lemma''  <nowiki>inj_point_of_image</nowiki>:
 ''   assumes '' A1: $ f \in  inj(A,B)$ ''and '' A2: $ C\subseteq A$ ''and '' A3: $ x\in A$ ''and '' A4: $ f(x) \in  f(C)$ ''   shows '' $ x \in  C$+++[proof ]>
 ''from '' A1, A2, A4  ''have''  $ converse(f)(f(x)) \in  C$ ''using''  +++^[inj_inv_back_in_set | func1 ]...  ''lemma''  <nowiki>inj_inv_back_in_set</nowiki>:  ''assumes '' $ f \in  inj(A,B)$  ''and'' $ C\subseteq A$  ''and'' $ y \in  f(C)$  '' shows '' $ converse(f)(y) \in  C$,   $ f(converse(f)(y)) = y$ === 
 ''moreover''   ''from '' A1, A3  ''have''  $ converse(f)(f(x)) = x$ ''using''  <nowiki>left_inverse_eq</nowiki>
 ''ultimately ''  ''show''  $ x \in  C$ 
 ''qed'' === 

For injections the image of intersection is the intersection of images.

 ''lemma''  <nowiki>inj_image_of_Inter</nowiki>:
 ''   assumes '' A1: $ f \in  inj(A,B)$ ''and '' A2: $ I\neq 0$ ''and '' A3: $ \forall i\in I.\  P(i) \subseteq  A$ ''   shows '' $ f(\bigcap i\in I.\  P(i)) = ( \bigcap i\in I.\  f(P(i)) )$+++[proof ]>
 ''from '' A1, A2, A3  ''show''  $ f(\bigcap i\in I.\  P(i)) \subseteq  ( \bigcap i\in I.\  f(P(i)) )$ ''using''  <nowiki>inj_is_fun</nowiki> ,  +++^[image_of_Inter | func1 ]...  ''lemma''  <nowiki>image_of_Inter</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ I\neq 0$  ''and'' $ \forall i\in I.\  P(i) \subseteq  X$  '' shows '' $ f(\bigcap i\in I.\  P(i)) \subseteq  ( \bigcap i\in I.\  f(P(i)) )$ === 
 ''from '' A1, A2, A3  ''have''  $ f:A\rightarrow B$ ''and '' $ ( \bigcap i\in I.\  P(i) ) \subseteq  A$ ''using''  <nowiki>inj_is_fun</nowiki> ,  +++^[ZF1_1_L7 | ZF1 ]...  ''lemma''  <nowiki>ZF1_1_L7</nowiki>:  ''assumes '' $ I\neq 0$  ''and'' $ \forall i\in I.\  P(i) \subseteq  X$  '' shows '' $ ( \bigcap i\in I.\  P(i) ) \subseteq  X$ === 
 ''then ''  ''have''  I: $ f(\bigcap i\in I.\  P(i)) = \{ f(x).\  x \in  ( \bigcap i\in I.\  P(i) ) \}$ ''using''  +++^[func_imagedef | func1 ]...  ''lemma''  <nowiki>func_imagedef</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  '' shows '' $ f(A) = \{f(x).\  x \in  A\}$ === 
++++[{ ]>
 ''fix '' $ y$
 ''assume '' A4: $ y \in  ( \bigcap i\in I.\  f(P(i)) )$
 ''let '' $ x = converse(f)(y)$
 ''from '' A2  ''obtain '' $ i_0$ ''where '' $ i_0 \in  I$ 
 ''with '' A1, A4  ''have''  II: $ y \in  range(f)$ ''using''  <nowiki>inj_is_fun</nowiki> ,  +++^[func1_1_L6 | func1 ]...  ''lemma''  <nowiki>func1_1_L6</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f(B) \subseteq  range(f)$,   $ f(B) \subseteq  Y$ === 
 ''with '' A1  ''have''  III: $ f(x) = y$ ''using''  <nowiki>right_inverse</nowiki>
 ''from '' A1, II  ''have''  IV: $ x \in  A$ ''using''  <nowiki>inj_converse_fun</nowiki> ,  <nowiki>apply_funtype</nowiki>
++++[{ ]>
 ''fix '' $ i$
 ''assume '' $ i\in I$
 ''with '' A3, A4, III  ''have''  $ P(i) \subseteq  A$ ''and '' $ f(x) \in   f(P(i))$ 
 ''with '' A1, IV  ''have''  $ x \in  P(i)$ ''using''  +++^[inj_point_of_image | func1 ]...  ''lemma''  <nowiki>inj_point_of_image</nowiki>:  ''assumes '' $ f \in  inj(A,B)$  ''and'' $ C\subseteq A$  ''and'' $ x\in A$  ''and'' $ f(x) \in  f(C)$  '' shows '' $ x \in  C$ === 
===  ''}'' 
 ''then ''  ''have''  $ \forall i\in I.\  x \in  P(i)$ 
 ''with '' A2, I  ''have''  $ f(x) \in  f( \bigcap i\in I.\  P(i) )$ 
 ''with '' III  ''have''  $ y \in   f( \bigcap i\in I.\  P(i) )$ 
===  ''}'' 
 ''then ''  ''show''  $ ( \bigcap i\in I.\  f(P(i)) ) \subseteq   f( \bigcap i\in I.\  P(i) )$ 
 ''qed'' === 

A lemma about extending a surjection by one point.

 ''lemma''  <nowiki>surj_extend_point</nowiki>:
 ''   assumes '' A1: $ f \in  surj(X,Y)$ ''and '' A2: $ a\notin X$ ''and '' A3: $ g = f \cup  \{\langle a,b\rangle \}$ ''   shows '' $ g \in  surj(X\cup \{a\},Y\cup \{b\})$+++[proof ]>
 ''from '' A1, A2, A3  ''have''  $ g : X\cup \{a\} \rightarrow  Y\cup \{b\}$ ''using''  <nowiki>surj_def</nowiki> ,  +++^[func1_1_L11D | func1 ]...  ''lemma''  <nowiki>func1_1_L11D</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ a\notin X$  ''and'' $ g = f \cup  \{\langle a,b\rangle \}$  '' shows '' $ g : X\cup \{a\} \rightarrow  Y\cup \{b\}$,   $ \forall x\in X.\  g(x) = f(x)$,   $ g(a) = b$ === 
 ''moreover''   ''have''  $ \forall y \in  Y\cup \{b\}.\  \exists x \in  X\cup \{a\}.\  y = g(x)$+++[proof ]>
 ''fix '' $ y$
 ''assume '' $ y \in   Y \cup  \{b\}$
 ''then ''  ''have''  $ y \in  Y \vee  y = b$ 
 ''moreover''  ++++[{ ]>
 ''assume '' $ y \in  Y$
 ''with '' A1  ''obtain '' $ x$ ''where '' $ x\in X$ ''and '' $ y = f(x)$ ''using''  <nowiki>surj_def</nowiki>
 ''with '' A1, A2, A3  ''have''  $ x \in   X\cup \{a\}$ ''and '' $ y = g(x)$ ''using''  <nowiki>surj_def</nowiki> ,  +++^[func1_1_L11D | func1 ]...  ''lemma''  <nowiki>func1_1_L11D</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ a\notin X$  ''and'' $ g = f \cup  \{\langle a,b\rangle \}$  '' shows '' $ g : X\cup \{a\} \rightarrow  Y\cup \{b\}$,   $ \forall x\in X.\  g(x) = f(x)$,   $ g(a) = b$ === 
 ''then ''  ''have''  $ \exists x \in  X\cup \{a\}.\  y = g(x)$ 
===  ''}'' 
 ''moreover''  ++++[{ ]>
 ''assume '' $ y = b$
 ''with '' A1, A2, A3  ''have''  $ y = g(a)$ ''using''  <nowiki>surj_def</nowiki> ,  +++^[func1_1_L11D | func1 ]...  ''lemma''  <nowiki>func1_1_L11D</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ a\notin X$  ''and'' $ g = f \cup  \{\langle a,b\rangle \}$  '' shows '' $ g : X\cup \{a\} \rightarrow  Y\cup \{b\}$,   $ \forall x\in X.\  g(x) = f(x)$,   $ g(a) = b$ === 
 ''then ''  ''have''  $ \exists x \in  X\cup \{a\}.\  y = g(x)$ 
===  ''}'' 
 ''ultimately ''  ''show''  $ \exists x \in  X\cup \{a\}.\  y = g(x)$ 
 ''qed'' === 
 ''ultimately ''  ''show''  $ g \in  surj(X\cup \{a\},Y\cup \{b\})$ ''using''  <nowiki>surj_def</nowiki>
 ''qed'' === 

A lemma about extending an injection by one point. Essentially the same as standard Isabelle's //inj_extend//.

 ''lemma''  <nowiki>inj_extend_point</nowiki>:
 ''   assumes '' $ f \in  inj(X,Y)$,  $ a\notin X$,  $ b\notin Y$ ''   shows '' $ (f \cup  \{\langle a,b\rangle \}) \in  inj(X\cup \{a\},Y\cup \{b\})$+++[proof ]>
 ''from '' assms  ''have''  $ cons(\langle a,b\rangle ,f) \in  inj(cons(a, X), cons(b, Y))$ ''using''  <nowiki>assms</nowiki> ,  <nowiki>inj_extend</nowiki>
 ''moreover''   ''have''  $ cons(\langle a,b\rangle ,f) = f \cup  \{\langle a,b\rangle \}$ ''and '' $ cons(a, X) = X\cup \{a\}$ ''and '' $ cons(b, Y) = Y\cup \{b\}$ 
 ''ultimately ''  ''show''  $ thesis$ 
 ''qed'' === 

A lemma about extending a bijection by one point.

 ''lemma''  <nowiki>bij_extend_point</nowiki>:
 ''   assumes '' $ f \in  bij(X,Y)$,  $ a\notin X$,  $ b\notin Y$ ''   shows '' $ (f \cup  \{\langle a,b\rangle \}) \in  bij(X\cup \{a\},Y\cup \{b\})$ ''using''  <nowiki>assms</nowiki> ,  +++^[surj_extend_point | func1 ]...  ''lemma''  <nowiki>surj_extend_point</nowiki>:  ''assumes '' $ f \in  surj(X,Y)$  ''and'' $ a\notin X$  ''and'' $ g = f \cup  \{\langle a,b\rangle \}$  '' shows '' $ g \in  surj(X\cup \{a\},Y\cup \{b\})$ ===  ,  +++^[inj_extend_point | func1 ]...  ''lemma''  <nowiki>inj_extend_point</nowiki>:  ''assumes '' $ f \in  inj(X,Y)$,   $ a\notin X$,   $ b\notin Y$  '' shows '' $ (f \cup  \{\langle a,b\rangle \}) \in  inj(X\cup \{a\},Y\cup \{b\})$ ===  ,  <nowiki>bij_def</nowiki>

A quite general form of the $a^{-1}b = 1$ implies $a=b$ law.

 ''lemma''  <nowiki>comp_inv_id_eq</nowiki>:
 ''   assumes '' A1: $ converse(b)\circ a = id(A)$ ''and '' A2: $ a \subseteq  A\times B$,  $ b \in  surj(A,B)$ ''   shows '' $ a = b$+++[proof ]>
 ''from '' A1  ''have''  $ (b\circ converse(b))\circ a = b\circ id(A)$ ''using''  <nowiki>comp_assoc</nowiki>
 ''with '' A2  ''have''  $ id(B)\circ a = b\circ id(A)$ ''using''  <nowiki>right_comp_inverse</nowiki>
 ''moreover''   ''from '' A2  ''have''  $ a \subseteq  A\times B$ ''and '' $ b \subseteq  A\times B$ ''using''  <nowiki>surj_def</nowiki> ,  +++^[fun_subset_prod | func1 ]...  ''lemma''  <nowiki>fun_subset_prod</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f \subseteq  X\times Y$ === 
 ''then ''  ''have''  $ id(B)\circ a = a$ ''and '' $ b\circ id(A) = b$ ''using''  <nowiki>left_comp_id</nowiki> ,  <nowiki>right_comp_id</nowiki>
 ''ultimately ''  ''show''  $ a = b$ 
 ''qed'' === 

A special case of //comp_inv_id_eq// - the $a^{-1}b = 1$ implies $a=b$ law for bijections.

 ''lemma''  <nowiki>comp_inv_id_eq_bij</nowiki>:
 ''   assumes '' A1: $ a \in  bij(A,B)$,  $ b \in  bij(A,B)$ ''and '' A2: $ converse(b)\circ a = id(A)$ ''   shows '' $ a = b$+++[proof ]>
 ''from '' A1  ''have''  $ a \subseteq  A\times B$ ''and '' $ b \in  surj(A,B)$ ''using''  <nowiki>bij_def</nowiki> ,  <nowiki>surj_def</nowiki> ,  +++^[fun_subset_prod | func1 ]...  ''lemma''  <nowiki>fun_subset_prod</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ f \subseteq  X\times Y$ === 
 ''with '' A2  ''show''  $ a = b$ ''   by (rule '' +++^[comp_inv_id_eq | func1 ]...  ''lemma''  <nowiki>comp_inv_id_eq</nowiki>:  ''assumes '' $ converse(b)\circ a = id(A)$  ''and'' $ a \subseteq  A\times B$,   $ b \in  surj(A,B)$  '' shows '' $ a = b$ ===  '')'' 
 ''qed'' === 


!Fixing variables in functions

For every function of two variables we can define families of functions of one variable by fixing the other variable. This section establishes basic definitions and results for this concept.

If we fix an $x\in X$ we obtain a function on $Y$. Note that if $ domain(f)$ is $X\times Y$, $ range(domain(f))$ extracts $Y$ from $X\times Y$.

 ''Definition
'' $ Fix1stVar(f,x) \equiv  \{\langle y,f\langle x,y\rangle \rangle .\  y \in  range(domain(f))\}$

For every $y\in Y$ we can fix the second variable in a binary function $f: X\times Y \rightarrow Z$ to get a function on $X$.

 ''Definition
'' $ Fix2ndVar(f,y) \equiv  \{\langle x,f\langle x,y\rangle \rangle .\  x \in  domain(domain(f))\}$

We defined //Fix1stVar// and //Fix2ndVar// so that the domain of the function is not listed in the arguments, but is recovered from the function. The next lemma is a technical fact that makes it easier to use this definition.

 ''lemma''  <nowiki>fix_var_fun_domain</nowiki>:
 ''   assumes '' A1: $ f : X\times Y \rightarrow  Z$ ''   shows '' $ x\in X \longrightarrow  Fix1stVar(f,x) = \{\langle y,f\langle x,y\rangle \rangle .\  y \in  Y\}$,  $ y\in Y \longrightarrow  Fix2ndVar(f,y) = \{\langle x,f\langle x,y\rangle \rangle .\  x \in  X\}$+++[proof ]>
 ''from '' A1  ''have''  I: $ domain(f) = X\times Y$ ''using''  +++^[func1_1_L1 | func1 ]...  ''lemma''  <nowiki>func1_1_L1</nowiki>:  ''assumes '' $ f:A\rightarrow C$  '' shows '' $ domain(f) = A$ === 
++++[{ ]>
 ''assume '' $ x\in X$
 ''with '' I  ''have''  $ range(domain(f)) = Y$ 
 ''then ''  ''have''  $ Fix1stVar(f,x) = \{\langle y,f\langle x,y\rangle \rangle .\  y \in  Y\}$ ''using''  +++^[Fix1stVar_def | func1 ]... Definition of <nowiki>Fix1stVar</nowiki>:
$ Fix1stVar(f,x) \equiv  \{\langle y,f\langle x,y\rangle \rangle .\  y \in  range(domain(f))\}$=== 
===  ''}'' 
 ''then ''  ''show''  $ x\in X \longrightarrow  Fix1stVar(f,x) = \{\langle y,f\langle x,y\rangle \rangle .\  y \in  Y\}$ 
++++[{ ]>
 ''assume '' $ y\in Y$
 ''with '' I  ''have''  $ domain(domain(f)) = X$ 
 ''then ''  ''have''  $ Fix2ndVar(f,y) = \{\langle x,f\langle x,y\rangle \rangle .\  x \in  X\}$ ''using''  +++^[Fix2ndVar_def | func1 ]... Definition of <nowiki>Fix2ndVar</nowiki>:
$ Fix2ndVar(f,y) \equiv  \{\langle x,f\langle x,y\rangle \rangle .\  x \in  domain(domain(f))\}$=== 
===  ''}'' 
 ''then ''  ''show''  $ y\in Y \longrightarrow  Fix2ndVar(f,y) = \{\langle x,f\langle x,y\rangle \rangle .\  x \in  X\}$ 
 ''qed'' === 

If we fix the first variable, we get a function of the second variable.

 ''lemma''  <nowiki>fix_1st_var_fun</nowiki>:
 ''   assumes '' A1: $ f : X\times Y \rightarrow  Z$ ''and '' A2: $ x\in X$ ''   shows '' $ Fix1stVar(f,x) : Y \rightarrow  Z$+++[proof ]>
 ''from '' A1, A2  ''have''  $ \forall y\in Y.\  f\langle x,y\rangle  \in  Z$ ''using''  <nowiki>apply_funtype</nowiki>
 ''then ''  ''have''  $ \{\langle y,f\langle x,y\rangle \rangle .\  y \in  Y\} :  Y \rightarrow  Z$ ''using''  +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ === 
 ''with '' A1, A2  ''show''  $ Fix1stVar(f,x) : Y \rightarrow  Z$ ''using''  +++^[fix_var_fun_domain | func1 ]...  ''lemma''  <nowiki>fix_var_fun_domain</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  '' shows '' $ x\in X \longrightarrow  Fix1stVar(f,x) = \{\langle y,f\langle x,y\rangle \rangle .\  y \in  Y\}$,  
$ y\in Y \longrightarrow  Fix2ndVar(f,y) = \{\langle x,f\langle x,y\rangle \rangle .\  x \in  X\}$ === 
 ''qed'' === 

If we fix the second variable, we get a function of the first variable.

 ''lemma''  <nowiki>fix_2nd_var_fun</nowiki>:
 ''   assumes '' A1: $ f : X\times Y \rightarrow  Z$ ''and '' A2: $ y\in Y$ ''   shows '' $ Fix2ndVar(f,y) : X \rightarrow  Z$+++[proof ]>
 ''from '' A1, A2  ''have''  $ \forall x\in X.\  f\langle x,y\rangle  \in  Z$ ''using''  <nowiki>apply_funtype</nowiki>
 ''then ''  ''have''  $ \{\langle x,f\langle x,y\rangle \rangle .\  x \in  X\} :  X \rightarrow  Z$ ''using''  +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ === 
 ''with '' A1, A2  ''show''  $ Fix2ndVar(f,y) : X \rightarrow  Z$ ''using''  +++^[fix_var_fun_domain | func1 ]...  ''lemma''  <nowiki>fix_var_fun_domain</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  '' shows '' $ x\in X \longrightarrow  Fix1stVar(f,x) = \{\langle y,f\langle x,y\rangle \rangle .\  y \in  Y\}$,  
$ y\in Y \longrightarrow  Fix2ndVar(f,y) = \{\langle x,f\langle x,y\rangle \rangle .\  x \in  X\}$ === 
 ''qed'' === 

What is the value of $ Fix1stVar(f,x)$ at $y\in Y$ and the value of $ Fix2ndVar(f,y)$ at $x\in X$"?

 ''lemma''  <nowiki>fix_var_val</nowiki>:
 ''   assumes '' A1: $ f : X\times Y \rightarrow  Z$ ''and '' A2: $ x\in X$,  $ y\in Y$ ''   shows '' $ Fix1stVar(f,x)(y) = f\langle x,y\rangle $,  $ Fix2ndVar(f,y)(x) = f\langle x,y\rangle $+++[proof ]>
 ''let '' $ f_1 = \{\langle y,f\langle x,y\rangle \rangle .\  y \in  Y\}$
 ''let '' $ f_2 = \{\langle x,f\langle x,y\rangle \rangle .\  x \in  X\}$
 ''from '' A1, A2  ''have''  I: $ Fix1stVar(f,x) = f_1$,  $ Fix2ndVar(f,y) = f_2$ ''using''  +++^[fix_var_fun_domain | func1 ]...  ''lemma''  <nowiki>fix_var_fun_domain</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  '' shows '' $ x\in X \longrightarrow  Fix1stVar(f,x) = \{\langle y,f\langle x,y\rangle \rangle .\  y \in  Y\}$,  
$ y\in Y \longrightarrow  Fix2ndVar(f,y) = \{\langle x,f\langle x,y\rangle \rangle .\  x \in  X\}$ === 
 ''moreover''   ''from '' A1, A2  ''have''  $ Fix1stVar(f,x) : Y \rightarrow  Z$,  $ Fix2ndVar(f,y) : X \rightarrow  Z$ ''using''  +++^[fix_1st_var_fun | func1 ]...  ''lemma''  <nowiki>fix_1st_var_fun</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  ''and'' $ x\in X$  '' shows '' $ Fix1stVar(f,x) : Y \rightarrow  Z$ ===  ,  +++^[fix_2nd_var_fun | func1 ]...  ''lemma''  <nowiki>fix_2nd_var_fun</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  ''and'' $ y\in Y$  '' shows '' $ Fix2ndVar(f,y) : X \rightarrow  Z$ === 
 ''ultimately ''  ''have''  $ f_1 : Y \rightarrow  Z$ ''and '' $ f_2 : X \rightarrow  Z$ 
 ''with '' A2  ''have''  $ f_1(y) = f\langle x,y\rangle $ ''and '' $ f_2(x) = f\langle x,y\rangle $ ''using''  +++^[ZF_fun_from_tot_val | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_tot_val</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$  ''and'' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$  '' shows '' $ f(x) = b(x)$ === 
 ''with '' I  ''show''  $ Fix1stVar(f,x)(y) = f\langle x,y\rangle $,  $ Fix2ndVar(f,y)(x) = f\langle x,y\rangle $ 
 ''qed'' === 

Fixing the second variable commutes with restrictig the domain.

 ''lemma''  <nowiki>fix_2nd_var_restr_comm</nowiki>:
 ''   assumes '' A1: $ f : X\times Y \rightarrow  Z$ ''and '' A2: $ y\in Y$ ''and '' A3: $ X_1 \subseteq  X$ ''   shows '' $ Fix2ndVar(restrict(f,X_1\times Y),y) = restrict(Fix2ndVar(f,y),X_1)$+++[proof ]>
 ''let '' $ g = Fix2ndVar(restrict(f,X_1\times Y),y)$
 ''let '' $ h = restrict(Fix2ndVar(f,y),X_1)$
 ''from '' A3  ''have''  I: $ X_1\times Y \subseteq  X\times Y$ 
 ''with '' A1  ''have''  II: $ restrict(f,X_1\times Y) : X_1\times Y \rightarrow  Z$ ''using''  <nowiki>restrict_type2</nowiki>
 ''with '' A2  ''have''  $ g : X_1 \rightarrow  Z$ ''using''  +++^[fix_2nd_var_fun | func1 ]...  ''lemma''  <nowiki>fix_2nd_var_fun</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  ''and'' $ y\in Y$  '' shows '' $ Fix2ndVar(f,y) : X \rightarrow  Z$ === 
 ''moreover''   ''from '' A1, A2  ''have''  III: $ Fix2ndVar(f,y) : X \rightarrow  Z$ ''using''  +++^[fix_2nd_var_fun | func1 ]...  ''lemma''  <nowiki>fix_2nd_var_fun</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  ''and'' $ y\in Y$  '' shows '' $ Fix2ndVar(f,y) : X \rightarrow  Z$ === 
 ''with '' A3  ''have''  $ h : X_1 \rightarrow  Z$ ''using''  <nowiki>restrict_type2</nowiki>
 ''moreover''  ++++[{ ]>
 ''fix '' $ z$
 ''assume '' A4: $ z \in  X_1$
 ''with '' A2, I, II  ''have''  $ g(z) = f\langle z,y\rangle $ ''using''  <nowiki>restrict</nowiki> ,  +++^[fix_var_val | func1 ]...  ''lemma''  <nowiki>fix_var_val</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  ''and'' $ x\in X$,   $ y\in Y$  '' shows '' $ Fix1stVar(f,x)(y) = f\langle x,y\rangle $,   $ Fix2ndVar(f,y)(x) = f\langle x,y\rangle $ === 
 ''also''   ''from '' A1, A2, A3, A4  ''have''  $ f\langle z,y\rangle  = h(z)$ ''using''  <nowiki>restrict</nowiki> ,  +++^[fix_var_val | func1 ]...  ''lemma''  <nowiki>fix_var_val</nowiki>:  ''assumes '' $ f : X\times Y \rightarrow  Z$  ''and'' $ x\in X$,   $ y\in Y$  '' shows '' $ Fix1stVar(f,x)(y) = f\langle x,y\rangle $,   $ Fix2ndVar(f,y)(x) = f\langle x,y\rangle $ === 
 ''finally ''  ''have''  $ g(z) = h(z)$ 
===  ''}'' 
 ''then ''  ''have''  $ \forall z \in  X_1.\  g(z) = h(z)$ 
 ''ultimately ''  ''show''  $ g = h$ ''   by (rule '' +++^[func_eq | func1 ]...  ''lemma''  <nowiki>func_eq</nowiki>:  ''assumes '' $ f: X\rightarrow Y$,   $ g: X\rightarrow Z$  ''and'' $ \forall x\in X.\  f(x) = g(x)$  '' shows '' $ f = g$ ===  '')'' 
 ''qed'' === 

 ''end

'' +++![Comments on func1|click to add comment] <html> <div> <iframe style="width:60%;height:500px" src="http://www.haloscan.com/comments/slawekk/func1"></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''  +++^[func1_1_L5B | func1 ]...  ''lemma''  <nowiki>func1_1_L5B</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ range(f) \subseteq  Y$ === 
 ''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''  +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ === 
 ''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''  +++^[ZF_fun_from_tot_val | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_tot_val</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$  ''and'' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$  '' shows '' $ f(x) = b(x)$ === 
 ''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)$ ===  ,  +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ === 

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''  +++^[ZF_fun_from_tot_val | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_tot_val</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$  ''and'' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$  '' shows '' $ f(x) = b(x)$ === 
 ''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''  +++^[func1_1_L5B | func1 ]...  ''lemma''  <nowiki>func1_1_L5B</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ range(f) \subseteq  Y$ === 
 ''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''  +++^[func1_1_L5B | func1 ]...  ''lemma''  <nowiki>func1_1_L5B</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  '' shows '' $ range(f) \subseteq  Y$ === 
 ''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''  +++^[func1_2_L4 | func1 ]...  ''lemma''  <nowiki>func1_2_L4</nowiki>:  ''assumes '' $ f:X\rightarrow Y$  ''and'' $ A\subseteq X$  ''and'' $ \forall x\in A.\  f(x) \in  Z$  '' shows '' $ restrict(f,A) : A\rightarrow Z$ === 
 ''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)\circ 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)\circ snd(p)\rangle .\  p \in  (X\rightarrow X)\times (X\rightarrow X)\}$===  ,  +++^[ZF_fun_from_total | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_total</nowiki>:  ''assumes '' $ \forall x\in X.\  b(x) \in  Y$  '' shows '' $ \{\langle x,b(x)\rangle .\  x\in X\} : X\rightarrow Y$ === 

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\circ 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)\circ 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)\circ snd(p)\rangle .\  p \in  (X\rightarrow X)\times (X\rightarrow X)\}$=== 
 ''then ''  ''show''  $ Composition(X)\langle f,g\rangle  = f\circ g$ ''using''  +++^[ZF_fun_from_tot_val | func1 ]...  ''lemma''  <nowiki>ZF_fun_from_tot_val</nowiki>:  ''assumes '' $ f:X\rightarrow Y$,   $ x\in X$  ''and'' $ f = \{\langle x,b(x)\rangle .\  x\in X\}$  '' shows '' $ f(x) = b(x)$ === 
 ''qed'' === 

What is the value 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\circ 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'' === 

A trivial fact:identity is the only function from a singleton to itself.

 ''lemma''  <nowiki>singleton_fun_id</nowiki>:
 ''   shows '' $ (\{x\} \rightarrow  \{x\}) = \{id(\{x\})\}$+++[proof ]>
 ''show''  $ \{id(\{x\})\} \subseteq  (\{x\} \rightarrow  \{x\})$ ''using''  <nowiki>id_def</nowiki>
++++[{ ]>
 ''let '' $ g = id(\{x\})$
 ''fix '' $ f$
 ''assume '' $ f : \{x\} \rightarrow  \{x\}$
 ''then ''  ''have''  $ f : \{x\} \rightarrow  \{x\}$ ''and '' $ g : \{x\} \rightarrow  \{x\}$ ''using''  <nowiki>id_def</nowiki>
 ''moreover''   ''from '' $ f : \{x\} \rightarrow  \{x\}$  ''have''  $ \forall x \in  \{x\}.\  f(x) = g(x)$ ''using''  <nowiki>apply_funtype</nowiki> ,  <nowiki>id_def</nowiki>
 ''ultimately ''  ''have''  $ f = g$ ''   by (rule '' +++^[func_eq | func1 ]...  ''lemma''  <nowiki>func_eq</nowiki>:  ''assumes '' $ f: X\rightarrow Y$,   $ g: X\rightarrow Z$  ''and'' $ \forall x\in X.\  f(x) = g(x)$  '' shows '' $ f = g$ ===  '')'' 
===  ''}'' 
 ''then ''  ''show''  $ (\{x\} \rightarrow  \{x\}) \subseteq  \{id(\{x\})\}$ 
 ''qed'' === 

Another trivial fact: identity is the only bijection of a singleton with itself.

 ''lemma''  <nowiki>single_bij_id</nowiki>:
 ''   shows '' $ bij(\{x\},\{x\}) = \{id(\{x\})\}$+++[proof ]>
 ''show''  $ \{id(\{x\})\} \subseteq  bij(\{x\},\{x\})$ ''using''  <nowiki>id_bij</nowiki>
++++[{ ]>
 ''fix '' $ f$
 ''assume '' $ f \in  bij(\{x\},\{x\})$
 ''then ''  ''have''  $ f : \{x\} \rightarrow  \{x\}$ ''using''  <nowiki>bij_is_fun</nowiki>
 ''then ''  ''have''  $ f \in  \{id(\{x\})\}$ ''using''  +++^[singleton_fun_id | func_ZF ]...  ''lemma''  <nowiki>singleton_fun_id</nowiki>:  '' shows '' $ (\{x\} \rightarrow  \{x\}) = \{id(\{x\})\}$ === 
===  ''}'' 
 ''then ''  ''show''  $ bij(\{x\},\{x\}) \subseteq  \{id(\{x\})\}$ 
 ''qed'' === 

A kind of induction for the identity: if a function $f$ is the identity on a set with a fixpoint of $f$ removed, then it is the indentity on the whole set.

 ''lemma''  <nowiki>id_fixpoint_rem</nowiki>:
 ''   assumes '' A1: $ f:X\rightarrow X$ ''and '' A2: $ p\in X$ ''and '' A3: $ f(p) = p$ ''and '' A4: $ restrict(f, X-\{p\}) = id(X-\{p\})$ ''   shows '' $ f = id(X)$+++[proof ]>
 ''from '' A1  ''have''  $ f: X\rightarrow X$ ''and '' $ id(X) : X\rightarrow X$ ''using''  <nowiki>id_def</nowiki>
 ''moreover''  ++++[{ ]>
 ''fix '' $ x$
 ''assume '' $ x\in X$
++++[{ ]>
 ''assume '' $ x \in  X-\{p\}$
 ''then ''  ''have''  $ f(x) = restrict(f, X-\{p\})(x)$ ''using''  <nowiki>restrict</nowiki>
 ''with '' A4, $ x \in  X-\{p\}$  ''have''  $ f(x) = x$ ''using''  <nowiki>id_def</nowiki>
===  ''}'' 
 ''with '' A2, A3, $ x\in X$  ''have''  $ f(x) = x$ 
===  ''}'' 
 ''then ''  ''have''  $ \forall x\in X.\  f(x) = id(X)(x)$ ''using''  <nowiki>id_def</nowiki>
 ''ultimately ''  ''show''  $ f = id(X)$ ''   by (rule '' +++^[func_eq | func1 ]...  ''lemma''  <nowiki>func_eq</nowiki>:  ''assumes '' $ f: X\rightarrow Y$,   $ g: X\rightarrow Z$  ''and'' $ \forall x\in X.\  f(x) = g(x)$  '' shows '' $ f = g$ ===  '')'' 
 ''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();
    }
}