Skip to content

Commit 7c5cd63

Browse files
committed
preorders and finite choice
1 parent ba1a7cc commit 7c5cd63

File tree

7 files changed

+173
-8
lines changed

7 files changed

+173
-8
lines changed

IsarMathLib/Cardinal_ZF.thy

+21
Original file line numberDiff line numberDiff line change
@@ -622,4 +622,25 @@ proof -
622622
unfolding ChoiceFunctions_def by auto
623623
qed
624624

625+
text\<open>If a set $X$ is finite and such that for every $x\in X$ we can find
626+
$y\in $ such that the property $P(x,y)$ holds, then there there is a
627+
function $f:X\rightarrow Y$ such that $P(x,f(x))$ holds for every $x\in X$. \<close>
628+
629+
lemma finite_choice_fun: assumes "Finite(X)" "\<forall>x\<in>X. \<exists>y\<in>Y. P(x,y)"
630+
shows "\<exists>f\<in>X\<rightarrow>Y. \<forall>x\<in>X. P(x,f`(x))"
631+
proof -
632+
let ?N = "{\<langle>x,{y\<in>Y. P(x,y)}\<rangle>. x\<in>X}"
633+
let ?\<N> = "(\<lambda>t. ?N`(t))"
634+
from assms(1) obtain n where "n\<in>nat" and "X\<approx>n"
635+
unfolding Finite_def by auto
636+
have I: "\<forall>x\<in>X. ?N`(x) = {y\<in>Y. P(x,y)}" using ZF_fun_from_tot_val2 by simp
637+
with assms(2) \<open>X\<approx>n\<close> have "X\<lesssim>n" and "\<forall>x\<in>X. ?N`(x)\<noteq>\<emptyset>"
638+
using eqpoll_imp_lepoll by auto
639+
with \<open>n\<in>nat\<close> obtain f where "f\<in>Pi(X,?\<N>)" and II: "\<forall>x\<in>X. f`(x)\<in>?N`(x)"
640+
using finite_choice unfolding AxiomCardinalChoiceGen_def by blast
641+
have "Pi(X,?\<N>) = {f\<in>X\<rightarrow>(\<Union>x\<in>X. ?\<N>(x)). \<forall>x\<in>X. f`(x)\<in>?\<N>(x)}"
642+
by (rule pi_fun_space)
643+
with \<open>f\<in>Pi(X,?\<N>)\<close> I II show ?thesis using func1_1_L1A by auto
644+
qed
645+
625646
end

IsarMathLib/FinOrd_ZF.thy

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This file is a part of IsarMathLib -
33
a library of formalized mathematics for Isabelle/Isar.
44
5-
Copyright (C) 2008-2023 Slawomir Kolodynski
5+
Copyright (C) 2008-2025 Slawomir Kolodynski
66
77
This program is free software; Redistribution and use in source and binary forms,
88
with or without modification, are permitted provided that the following conditions are met:
@@ -165,7 +165,7 @@ proof -
165165
with assms(1) show "\<forall>j\<in>n #+ 1. P(j)" and "P(n)"
166166
using succ_add_one(1) by simp_all
167167
qed
168-
168+
169169
subsection\<open>Order isomorphisms of finite sets\<close>
170170

171171
text\<open>In this section we establish that if two linearly
@@ -479,6 +479,4 @@ proof
479479
by auto
480480
qed
481481

482-
483-
484482
end

IsarMathLib/FinOrd_ZF_1.thy

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
(*
2+
This file is a part of IsarMathLib -
3+
a library of formalized mathematics for Isabelle/Isar.
4+
5+
Copyright (C) 2008-2025 Slawomir Kolodynski
6+
7+
This program is free software; Redistribution and use in source and binary forms,
8+
with or without modification, are permitted provided that the following conditions are met:
9+
10+
1. Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation and/or
14+
other materials provided with the distribution.
15+
3. The name of the author may not be used to endorse or promote products
16+
derived from this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
19+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24+
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
29+
*)
30+
31+
section \<open>Finite choice and order relations\<close>
32+
33+
theory FinOrd_ZF_1 imports FinOrd_ZF Cardinal_ZF
34+
35+
begin
36+
37+
text\<open>In this theory we continue the subject of finite sets and order relation
38+
from \<open>FinOrd_ZF\<close> with some consequences of finite choice for down-directed sets. \<close>
39+
40+
subsection\<open>Finte choice and preorders\<close>
41+
42+
text\<open>In the \<open>Order_ZF\<close> theory we define what it means that a relation $r$ down-directs a set $X$:
43+
each two elements of $X$ have a common lower bound in $X$. If the relation is a preorder
44+
(i.e. is reflexive and transitive) and it down-directs $X$ we say that $X$ is a down-directed
45+
set (by the relation $r$). \<close>
46+
47+
text\<open>The next lemma states that each finite subset of a down-directed set
48+
has a lower bound in $X$.\<close>
49+
50+
lemma fin_dir_set_bounded:
51+
assumes "IsDownDirectedSet(X,r)" and "B\<in>FinPow(X)"
52+
shows "\<exists>x\<in>X.\<forall>t\<in>B. \<langle>x,t\<rangle>\<in>r"
53+
proof -
54+
from assms(1) have "\<exists>x\<in>X.\<forall>t\<in>\<emptyset>. \<langle>x,t\<rangle>\<in>r"
55+
unfolding IsDownDirectedSet_def DownDirects_def by auto
56+
moreover have
57+
"\<forall>A\<in>FinPow(X). (\<exists>x\<in>X.\<forall>t\<in>A. \<langle>x,t\<rangle>\<in>r)\<longrightarrow>(\<forall>a\<in>X. \<exists>m\<in>X.\<forall>t\<in>A\<union>{a}. \<langle>m,t\<rangle>\<in>r)"
58+
proof -
59+
{ fix A assume "A\<in>FinPow(X)" and I: "\<exists>x\<in>X.\<forall>t\<in>A. \<langle>x,t\<rangle>\<in>r"
60+
{ fix a assume "a\<in>X"
61+
from I obtain x where "x\<in>X" and II: "\<forall>t\<in>A. \<langle>x,t\<rangle>\<in>r" by auto
62+
from assms(1) \<open>a\<in>X\<close> \<open>x\<in>X\<close> obtain m where
63+
"m\<in>X" "\<langle>m,a\<rangle>\<in>r" "\<langle>m,x\<rangle>\<in>r"
64+
unfolding IsDownDirectedSet_def DownDirects_def by auto
65+
with assms(1) II have "\<exists>m\<in>X.\<forall>t\<in>A\<union>{a}. \<langle>m,t\<rangle>\<in>r"
66+
unfolding IsDownDirectedSet_def IsPreorder_def trans_def
67+
by blast
68+
} hence "\<forall>a\<in>X. \<exists>x\<in>X.\<forall>t\<in>A\<union>{a}. \<langle>x,t\<rangle>\<in>r" by blast
69+
} thus ?thesis by simp
70+
qed
71+
moreover note assms(2)
72+
ultimately show ?thesis by (rule FinPow_induct)
73+
qed
74+
75+
text\<open>Suppose $Y$ is a set down-directed by a (preorder) relation $r$
76+
and $f,g$ are funtions defined on two finite subsets $A,B$, resp., of $X$, valued in Y
77+
(i.e.$f:A\rightarrow Y$, $f:B\rightarrow Y$ and $A,B$ are finite subsets of $X$).
78+
Then there exist a function $h:A\cup B\rightarrow Y$ that is a lower bound for
79+
$f$ on $A$ and for $g$ on $B$.\<close>
80+
81+
lemma two_fun_low_bound:
82+
assumes "IsDownDirectedSet(Y,r)" "A\<in>FinPow(X)" "B\<in>FinPow(X)" "f:A\<rightarrow>Y" "g:B\<rightarrow>Y"
83+
shows "\<exists>h\<in>A\<union>B\<rightarrow>Y. (\<forall>x\<in>A. \<langle>h`(x),f`(x)\<rangle>\<in>r) \<and> (\<forall>x\<in>B. \<langle>h`(x),g`(x)\<rangle>\<in>r)"
84+
proof -
85+
from assms(2,3) have "Finite(A\<union>B)" using union_finpow
86+
unfolding FinPow_def by simp
87+
{ fix x assume "x\<in>A\<union>B"
88+
from assms(4,5) have "f``{x}\<union>g``{x} \<in> FinPow(Y)"
89+
using image_singleton_fin union_finpow by simp
90+
with assms(1) have "\<exists>y\<in>Y.\<forall>t\<in>(f``{x}\<union>g``{x}). \<langle>y,t\<rangle>\<in>r"
91+
using fin_dir_set_bounded by simp
92+
} hence "\<forall>x\<in>A\<union>B. \<exists>y\<in>Y.\<forall>t\<in>(f``{x}\<union>g``{x}). \<langle>y,t\<rangle>\<in>r" by auto
93+
with \<open>Finite(A\<union>B)\<close> have
94+
"\<exists>h\<in>A\<union>B\<rightarrow>Y. \<forall>x\<in>A\<union>B. \<forall>t\<in>(f``{x}\<union>g``{x}). \<langle>h`(x),t\<rangle>\<in>r"
95+
by (rule finite_choice_fun)
96+
then obtain h where "h\<in>A\<union>B\<rightarrow>Y" and
97+
"\<forall>x\<in>A\<union>B. \<forall>t\<in>(f``{x}\<union>g``{x}). \<langle>h`(x),t\<rangle>\<in>r"
98+
by auto
99+
with assms(4,5) have
100+
"\<forall>x\<in>A. \<langle>h`(x),f`(x)\<rangle>\<in>r" and "\<forall>x\<in>B. \<langle>h`(x),g`(x)\<rangle>\<in>r"
101+
using func_imagedef by simp_all
102+
with \<open>h\<in>A\<union>B\<rightarrow>Y\<close> show ?thesis by auto
103+
qed
104+
105+
end

IsarMathLib/Finite_ZF.thy

+32-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This file is a part of IsarMathLib -
33
a library of formalized mathematics for Isabelle/Isar.
44
5-
Copyright (C) 2008 - 2019 Slawomir Kolodynski
5+
Copyright (C) 2008 - 2025 Slawomir Kolodynski
66
77
This program is free software Redistribution and use in source and binary forms,
88
with or without modification, are permitted provided that the following conditions are met:
@@ -28,7 +28,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

2929
section \<open>Finite sets - introduction\<close>
3030

31-
theory Finite_ZF imports ZF1 Nat_ZF_IML ZF.Cardinal
31+
theory Finite_ZF imports ZF1 Nat_ZF_IML ZF.Cardinal func1
3232

3333
begin
3434

@@ -156,8 +156,12 @@ text\<open>A finite subset is a finite subset of itself.\<close>
156156
lemma fin_finpow_self: assumes "A \<in> FinPow(X)" shows "A \<in> FinPow(A)"
157157
using assms FinPow_def by auto
158158

159-
text\<open>If we remove an element and put it back we get the set back.
160-
\<close>
159+
text\<open>A set is finite iff it is in its finite powerset.\<close>
160+
161+
lemma fin_finpow_iff: shows "Finite(A) \<longleftrightarrow> A \<in> FinPow(A)"
162+
unfolding FinPow_def by simp
163+
164+
text\<open>If we remove an element and put it back we get the set back.\<close>
161165

162166
lemma rem_add_eq: assumes "a\<in>A" shows "(A-{a}) \<union> {a} = A"
163167
using assms by auto
@@ -518,6 +522,30 @@ proof -
518522
by (rule FinPow_induct)
519523
qed
520524

525+
text\<open>If a set $X$ is finite then the set $\{ K(x). x\in X\}$ is also finite.
526+
Its basically standard Isalelle/ZF \<open>Finite_RepFun\<close> in nicer notation.\<close>
527+
528+
lemma fin_rep_fin: assumes "Finite(X)" shows "Finite({K(x). x\<in>X})"
529+
using assms Finite_RepFun by simp
530+
531+
text\<open>The image of a singleton by any function is finite. It's of course either
532+
empty or has exactly one element, but showing that it's a finite subset of the codomain
533+
is good enough for us. \<close>
534+
535+
lemma image_singleton_fin: assumes "f:X\<rightarrow>Y" shows "f``{x} \<in> FinPow(Y)"
536+
proof -
537+
{ assume "x\<in>X"
538+
with assms have "f``{x} \<in> FinPow(Y)"
539+
using singleton_image singleton_in_finpow by simp
540+
}
541+
moreover
542+
{ assume "x\<notin>X"
543+
with assms have "f``{x} \<in> FinPow(Y)"
544+
using arg_not_in_domain(1) empty_in_finpow by simp
545+
}
546+
ultimately show ?thesis by auto
547+
qed
548+
521549
text\<open>Union of a finite indexed family of finite sets is finite.\<close>
522550

523551
lemma union_fin_list_fin:

IsarMathLib/ROOT

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ session "IsarMathLib" = "ZF" +
1717
Finite1
1818
Finite_ZF_1
1919
FinOrd_ZF
20+
FinOrd_ZF_1
2021
EquivClass1
2122
FiniteSeq_ZF
2223
Finite_State_Machines_ZF

IsarMathLib/func1.thy

+11
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,17 @@ proof -
427427
} thus ?thesis by auto
428428
qed
429429

430+
text\<open>If $x$ is not in the domain of the function then both the image of the singleton $\{x \}$
431+
and the value of the function are empty. The second of the assertions is also proven
432+
by standard Isabelle/ZF \<open>apply_0\<close> lemma in the \<open>func\<close> theory.\<close>
433+
434+
lemma arg_not_in_domain: assumes "f:X\<rightarrow>Y" and "x\<notin>X"
435+
shows "f``{x} = \<emptyset>" and "f`(x) = \<emptyset>"
436+
proof -
437+
from assms show "f``{x} = \<emptyset>" using func1_1_L1 by blast
438+
then show "f`(x) = \<emptyset>" unfolding apply_def by simp
439+
qed
440+
430441
text\<open>We can extend a function by specifying its values on a set
431442
disjoint with the domain.\<close>
432443

isar2html2.0/theories.conf

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ func_ZF_1
1212
Cardinal_ZF
1313
NatOrder_ZF
1414
FinOrd_ZF
15+
FinOrd_ZF_1
1516
FiniteSeq_ZF
1617
InductiveSeq_ZF
1718
Fold_ZF

0 commit comments

Comments
 (0)