src/Doc/Datatypes/Datatypes.thy
changeset 62328 532ad8de5d61
parent 62327 112eefe85ff0
child 62330 7d0c92d5dd80
equal deleted inserted replaced
62327:112eefe85ff0 62328:532ad8de5d61
   357     no_notation
   357     no_notation
   358       Nil ("[]") and
   358       Nil ("[]") and
   359       Cons (infixr "#" 65)
   359       Cons (infixr "#" 65)
   360 
   360 
   361     hide_type list
   361     hide_type list
   362     hide_const Nil Cons case_list hd tl set map list_all2 rec_list size_list pred_list
   362     hide_const Nil Cons case_list hd tl set map list_all2 rec_list size_list list_all
   363 
   363 
   364     context early
   364     context early
   365     begin
   365     begin
   366 (*>*)
   366 (*>*)
   367     datatype (set: 'a) list =
   367     datatype (set: 'a) list =
   368       null: Nil
   368       null: Nil
   369     | Cons (hd: 'a) (tl: "'a list")
   369     | Cons (hd: 'a) (tl: "'a list")
   370     for
   370     for
   371       map: map
   371       map: map
   372       rel: list_all2
   372       rel: list_all2
       
   373       pred: list_all
   373     where
   374     where
   374       "tl Nil = Nil"
   375       "tl Nil = Nil"
   375 
   376 
   376 text \<open>
   377 text \<open>
   377 \noindent
   378 \noindent
   437       null: Nil ("[]")
   438       null: Nil ("[]")
   438     | Cons (hd: 'a) (tl: "'a list") (infixr "#" 65)
   439     | Cons (hd: 'a) (tl: "'a list") (infixr "#" 65)
   439     for
   440     for
   440       map: map
   441       map: map
   441       rel: list_all2
   442       rel: list_all2
       
   443       pred: list_all
   442 
   444 
   443 text \<open>
   445 text \<open>
   444 \noindent
   446 \noindent
   445 Incidentally, this is how the traditional syntax can be set up:
   447 Incidentally, this is how the traditional syntax can be set up:
   446 \<close>
   448 \<close>
  2887 @{term "zs :: ('a \<times> 'b) list"}.
  2889 @{term "zs :: ('a \<times> 'b) list"}.
  2888 \<close>
  2890 \<close>
  2889 
  2891 
  2890     lift_bnf (*<*)(no_warn_wits) (*>*)'a nonempty_list
  2892     lift_bnf (*<*)(no_warn_wits) (*>*)'a nonempty_list
  2891     proof -
  2893     proof -
  2892       fix f and xs :: "'a list"
  2894       fix f(*<*):: "'a \<Rightarrow> 'c"(*>*) and xs :: "'a list"
  2893       assume "xs \<in> {xs. xs \<noteq> []}"
  2895       assume "xs \<in> {xs. xs \<noteq> []}"
  2894       then show "map f xs \<in> {xs. xs \<noteq> []}"
  2896       then show "map f xs \<in> {xs. xs \<noteq> []}"
  2895         by (cases xs(*<*) rule: list.exhaust(*>*)) auto
  2897         by (cases xs(*<*) rule: list.exhaust(*>*)) auto
  2896     next
  2898     next
  2897       fix zs :: "('a \<times> 'b) list"
  2899       fix zs :: "('a \<times> 'b) list"