src/Doc/Tutorial/Sets/Relations.thy
author wenzelm
Wed, 12 Mar 2025 11:39:00 +0100
changeset 82265 4b875a4c83b0
parent 67406 23307fd33906
permissions -rw-r--r--
update for release;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 12489
diff changeset
     1
theory Relations imports Main begin
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     2
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     3
(*Id is only used in UNITY*)
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     4
(*refl, antisym,trans,univalent,\<dots> ho hum*)
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     5
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
     6
text\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
     7
@{thm[display] Id_def[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
     8
\rulename{Id_def}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
     9
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    10
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    11
text\<open>
47508
85c6268b4071 updated rel_comp ~> relcomp (cf. e1b761c216ac);
wenzelm
parents: 42637
diff changeset
    12
@{thm[display] relcomp_unfold[no_vars]}
85c6268b4071 updated rel_comp ~> relcomp (cf. e1b761c216ac);
wenzelm
parents: 42637
diff changeset
    13
\rulename{relcomp_unfold}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    14
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    15
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    16
text\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    17
@{thm[display] R_O_Id[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    18
\rulename{R_O_Id}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    19
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    20
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    21
text\<open>
47508
85c6268b4071 updated rel_comp ~> relcomp (cf. e1b761c216ac);
wenzelm
parents: 42637
diff changeset
    22
@{thm[display] relcomp_mono[no_vars]}
85c6268b4071 updated rel_comp ~> relcomp (cf. e1b761c216ac);
wenzelm
parents: 42637
diff changeset
    23
\rulename{relcomp_mono}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    24
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    25
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    26
text\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    27
@{thm[display] converse_iff[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    28
\rulename{converse_iff}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    29
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    30
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    31
text\<open>
47508
85c6268b4071 updated rel_comp ~> relcomp (cf. e1b761c216ac);
wenzelm
parents: 42637
diff changeset
    32
@{thm[display] converse_relcomp[no_vars]}
85c6268b4071 updated rel_comp ~> relcomp (cf. e1b761c216ac);
wenzelm
parents: 42637
diff changeset
    33
\rulename{converse_relcomp}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    34
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    35
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    36
text\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    37
@{thm[display] Image_iff[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    38
\rulename{Image_iff}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    39
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    40
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    41
text\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    42
@{thm[display] Image_UN[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    43
\rulename{Image_UN}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    44
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    45
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    46
text\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    47
@{thm[display] Domain_iff[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    48
\rulename{Domain_iff}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    49
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    50
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    51
text\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    52
@{thm[display] Range_iff[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    53
\rulename{Range_iff}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    54
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    55
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    56
text\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    57
@{thm[display] relpow.simps[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    58
\rulename{relpow.simps}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    59
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    60
@{thm[display] rtrancl_refl[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    61
\rulename{rtrancl_refl}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    62
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    63
@{thm[display] r_into_rtrancl[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    64
\rulename{r_into_rtrancl}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    65
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    66
@{thm[display] rtrancl_trans[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    67
\rulename{rtrancl_trans}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    68
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    69
@{thm[display] rtrancl_induct[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    70
\rulename{rtrancl_induct}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    71
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    72
@{thm[display] rtrancl_idemp[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    73
\rulename{rtrancl_idemp}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    74
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    75
@{thm[display] r_into_trancl[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    76
\rulename{r_into_trancl}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    77
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    78
@{thm[display] trancl_trans[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    79
\rulename{trancl_trans}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    80
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    81
@{thm[display] trancl_into_rtrancl[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    82
\rulename{trancl_into_rtrancl}
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    83
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    84
@{thm[display] trancl_converse[no_vars]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    85
\rulename{trancl_converse}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    86
\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    87
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    88
text\<open>Relations.  transitive closure\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    89
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10864
diff changeset
    90
lemma rtrancl_converseD: "(x,y) \<in> (r\<inverse>)\<^sup>* \<Longrightarrow> (y,x) \<in> r\<^sup>*"
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    91
apply (erule rtrancl_induct)
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    92
txt\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    93
@{subgoals[display,indent=0,margin=65]}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
    94
\<close>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    95
 apply (rule rtrancl_refl)
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10864
diff changeset
    96
apply (blast intro: rtrancl_trans)
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
    97
done
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    98
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
    99
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10864
diff changeset
   100
lemma rtrancl_converseI: "(y,x) \<in> r\<^sup>* \<Longrightarrow> (x,y) \<in> (r\<inverse>)\<^sup>*"
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   101
apply (erule rtrancl_induct)
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   102
 apply (rule rtrancl_refl)
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10864
diff changeset
   103
apply (blast intro: rtrancl_trans)
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   104
done
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   105
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10864
diff changeset
   106
lemma rtrancl_converse: "(r\<inverse>)\<^sup>* = (r\<^sup>*)\<inverse>"
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   107
by (auto intro: rtrancl_converseI dest: rtrancl_converseD)
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   108
11080
22855d091249 various revisions in response to comments from Tobias
paulson
parents: 10864
diff changeset
   109
lemma rtrancl_converse: "(r\<inverse>)\<^sup>* = (r\<^sup>*)\<inverse>"
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   110
apply (intro equalityI subsetI)
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   111
txt\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   112
after intro rules
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   113
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   114
@{subgoals[display,indent=0,margin=65]}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   115
\<close>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   116
apply clarify
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   117
txt\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   118
after splitting
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   119
@{subgoals[display,indent=0,margin=65]}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   120
\<close>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   121
oops
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   122
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   123
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   124
lemma "(\<forall>u v. (u,v) \<in> A \<longrightarrow> u=v) \<Longrightarrow> A \<subseteq> Id"
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   125
apply (rule subsetI)
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   126
txt\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   127
@{subgoals[display,indent=0,margin=65]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   128
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   129
after subsetI
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   130
\<close>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   131
apply clarify
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   132
txt\<open>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   133
@{subgoals[display,indent=0,margin=65]}
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   134
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   135
subgoals after clarify
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   136
\<close>
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   137
by blast
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   138
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   139
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   140
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   141
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   142
text\<open>rejects\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   143
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   144
lemma "(a \<in> {z. P z} \<union> {y. Q y}) = P a \<or> Q a"
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   145
apply (blast)
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   146
done
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   147
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 58860
diff changeset
   148
text\<open>Pow, Inter too little used\<close>
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   149
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   150
lemma "(A \<subset> B) = (A \<subseteq> B \<and> A \<noteq> B)"
26806
40b411ec05aa Adapted to encoding of sets as predicates
berghofe
parents: 16417
diff changeset
   151
apply (simp add: psubset_eq)
10864
f0b0a125ae4b revisions corresponding to the new version of sets.tex
paulson
parents: 10341
diff changeset
   152
done
10294
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   153
2ec9c808a8a7 the Sets chapter and theories
paulson
parents:
diff changeset
   154
end