src/ZF/Induct/ListN.thy
author wenzelm
Mon, 07 Dec 2015 10:23:50 +0100
changeset 61798 27f3c10b0b50
parent 60770 240563fbf41d
child 65449 c82e63b11b8b
permissions -rw-r--r--
isabelle update_cartouches -c -t;
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
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 12610
diff changeset
     8
theory ListN imports Main 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
58623
2db1df2c8467 more bibtex entries;
wenzelm
parents: 46822
diff changeset
    12
  @{cite "paulin-tlca"}.
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    13
\<close>
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    14
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    15
consts listn :: "i=>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
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    19
    NilI: "<0,Nil> \<in> listn(A)"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    20
    ConsI: "[| a \<in> A; <n,l> \<in> listn(A) |] ==> <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
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    24
lemma list_into_listn: "l \<in> list(A) ==> <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
46822
95f1e700b712 mathematical symbols for Isabelle/ZF example theories
paulson
parents: 35762
diff changeset
    27
lemma listn_iff: "<n,l> \<in> listn(A) \<longleftrightarrow> l \<in> list(A) & 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
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    39
lemma listn_mono: "A \<subseteq> B ==> listn(A) \<subseteq> listn(B)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    40
  apply (unfold listn.defs)
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:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    47
    "[| <n,l> \<in> listn(A); <n',l'> \<in> listn(A) |] ==> <n#+n', l@l'> \<in> listn(A)"
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
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    54
      Nil_listn_case: "<i,Nil> \<in> listn(A)"
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
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    58
      zero_listn_case: "<0,l> \<in> listn(A)"
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