src/ZF/Induct/ListN.thy
author nipkow
Wed, 31 Jul 2024 10:36:28 +0200
changeset 80628 161286c9d426
parent 76987 4c275405faae
permissions -rw-r--r--
tuned names
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
     1
(*  Title:      ZF/Induct/ListN.thy
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     3
    Copyright   1994  University of Cambridge
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
     4
*)
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     5
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
     6
section \<open>Lists of n elements\<close>
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     7
65449
c82e63b11b8b clarified main ZF.thy / ZFC.thy, and avoid name clash with global HOL/Main.thy;
wenzelm
parents: 61798
diff changeset
     8
theory ListN imports ZF begin
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     9
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    10
text \<open>
61798
27f3c10b0b50 isabelle update_cartouches -c -t;
wenzelm
parents: 60770
diff changeset
    11
  Inductive definition of lists of \<open>n\<close> elements; see
76987
4c275405faae isabelle update -u cite;
wenzelm
parents: 76217
diff changeset
    12
  \<^cite>\<open>"paulin-tlca"\<close>.
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    13
\<close>
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    14
76215
a642599ffdea More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents: 76214
diff changeset
    15
consts listn :: "i\<Rightarrow>i"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    16
inductive
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    17
  domains "listn(A)" \<subseteq> "nat \<times> list(A)"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    18
  intros
76215
a642599ffdea More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents: 76214
diff changeset
    19
    NilI: "\<langle>0,Nil\<rangle> \<in> listn(A)"
a642599ffdea More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents: 76214
diff changeset
    20
    ConsI: "\<lbrakk>a \<in> A; \<langle>n,l\<rangle> \<in> listn(A)\<rbrakk> \<Longrightarrow> <succ(n), Cons(a,l)> \<in> listn(A)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    21
  type_intros nat_typechecks list.intros
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    22
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    23
76213
e44d86131648 Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 65449
diff changeset
    24
lemma list_into_listn: "l \<in> list(A) \<Longrightarrow> <length(l),l> \<in> listn(A)"
18415
eb68dc98bda2 improved proofs;
wenzelm
parents: 16417
diff changeset
    25
  by (induct set: list) (simp_all add: listn.intros)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    26
76215
a642599ffdea More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents: 76214
diff changeset
    27
lemma listn_iff: "\<langle>n,l\<rangle> \<in> listn(A) \<longleftrightarrow> l \<in> list(A) \<and> length(l)=n"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    28
  apply (rule iffI)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    29
   apply (erule listn.induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    30
    apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    31
  apply (blast intro: list_into_listn)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    32
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    33
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    34
lemma listn_image_eq: "listn(A)``{n} = {l \<in> list(A). length(l)=n}"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    35
  apply (rule equality_iffI)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    36
  apply (simp add: listn_iff separation image_singleton_iff)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    37
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    38
76213
e44d86131648 Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents: 65449
diff changeset
    39
lemma listn_mono: "A \<subseteq> B \<Longrightarrow> listn(A) \<subseteq> listn(B)"
76217
8655344f1cf6 More obsolete "unfold" calls
paulson <lp15@cam.ac.uk>
parents: 76215
diff changeset
    40
    unfolding listn.defs
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    41
  apply (rule lfp_mono)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    42
    apply (rule listn.bnd_mono)+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    43
  apply (assumption | rule univ_mono Sigma_mono list_mono basic_monos)+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    44
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    45
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    46
lemma listn_append:
76215
a642599ffdea More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents: 76214
diff changeset
    47
    "\<lbrakk>\<langle>n,l\<rangle> \<in> listn(A); <n',l'> \<in> listn(A)\<rbrakk> \<Longrightarrow> <n#+n', l@l'> \<in> listn(A)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    48
  apply (erule listn.induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    49
   apply (frule listn.dom_subset [THEN subsetD])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    50
   apply (simp_all add: listn.intros)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    51
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    52
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    53
inductive_cases
76215
a642599ffdea More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents: 76214
diff changeset
    54
      Nil_listn_case: "\<langle>i,Nil\<rangle> \<in> listn(A)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    55
  and Cons_listn_case: "<i,Cons(x,l)> \<in> listn(A)"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    56
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    57
inductive_cases
76215
a642599ffdea More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents: 76214
diff changeset
    58
      zero_listn_case: "\<langle>0,l\<rangle> \<in> listn(A)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    59
  and succ_listn_case: "<succ(i),l> \<in> listn(A)"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    60
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    61
end