src/HOL/Induct/Sexp.thy
changeset 21404 eb85850d3eb7
parent 20820 58693343905f
child 23746 a455e69c31cc
equal deleted inserted replaced
21403:dd58f13a8eb4 21404:eb85850d3eb7
     9 
     9 
    10 theory Sexp imports Main begin
    10 theory Sexp imports Main begin
    11 
    11 
    12 types
    12 types
    13   'a item = "'a Datatype.item"
    13   'a item = "'a Datatype.item"
    14 abbreviation
    14 abbreviation "Leaf == Datatype.Leaf"
    15   "Leaf == Datatype.Leaf"
    15 abbreviation "Numb == Datatype.Numb"
    16   "Numb == Datatype.Numb"
       
    17 
    16 
    18 consts
    17 consts
    19   sexp      :: "'a item set"
    18   sexp      :: "'a item set"
    20 
    19 
    21 inductive sexp
    20 inductive sexp
    24     NumbI:  "Numb(i) \<in> sexp"
    23     NumbI:  "Numb(i) \<in> sexp"
    25     SconsI: "[| M \<in> sexp;  N \<in> sexp |] ==> Scons M N \<in> sexp"
    24     SconsI: "[| M \<in> sexp;  N \<in> sexp |] ==> Scons M N \<in> sexp"
    26 
    25 
    27 definition
    26 definition
    28   sexp_case :: "['a=>'b, nat=>'b, ['a item, 'a item]=>'b, 
    27   sexp_case :: "['a=>'b, nat=>'b, ['a item, 'a item]=>'b, 
    29                 'a item] => 'b"
    28                 'a item] => 'b" where
    30   "sexp_case c d e M = (THE z. (EX x.   M=Leaf(x) & z=c(x))  
    29   "sexp_case c d e M = (THE z. (EX x.   M=Leaf(x) & z=c(x))  
    31                              | (EX k.   M=Numb(k) & z=d(k))  
    30                              | (EX k.   M=Numb(k) & z=d(k))  
    32                              | (EX N1 N2. M = Scons N1 N2  & z=e N1 N2))"
    31                              | (EX N1 N2. M = Scons N1 N2  & z=e N1 N2))"
    33 
    32 
    34   pred_sexp :: "('a item * 'a item)set"
    33 definition
       
    34   pred_sexp :: "('a item * 'a item)set" where
    35      "pred_sexp = (\<Union>M \<in> sexp. \<Union>N \<in> sexp. {(M, Scons M N), (N, Scons M N)})"
    35      "pred_sexp = (\<Union>M \<in> sexp. \<Union>N \<in> sexp. {(M, Scons M N), (N, Scons M N)})"
    36 
    36 
       
    37 definition
    37   sexp_rec  :: "['a item, 'a=>'b, nat=>'b,      
    38   sexp_rec  :: "['a item, 'a=>'b, nat=>'b,      
    38                 ['a item, 'a item, 'b, 'b]=>'b] => 'b"
    39                 ['a item, 'a item, 'b, 'b]=>'b] => 'b" where
    39    "sexp_rec M c d e = wfrec pred_sexp
    40    "sexp_rec M c d e = wfrec pred_sexp
    40              (%g. sexp_case c d (%N1 N2. e N1 N2 (g N1) (g N2))) M"
    41              (%g. sexp_case c d (%N1 N2. e N1 N2 (g N1) (g N2))) M"
    41 
    42 
    42 
    43 
    43 (** sexp_case **)
    44 (** sexp_case **)