thys/UF_Rec.thy
changeset 249 6e7244ae43b8
parent 248 aea02b5a58d2
child 250 745547bdc1c7
equal deleted inserted replaced
248:aea02b5a58d2 249:6e7244ae43b8
    93 fun Scan :: "nat \<Rightarrow> nat"
    93 fun Scan :: "nat \<Rightarrow> nat"
    94   where
    94   where
    95   "Scan r = r mod 2"
    95   "Scan r = r mod 2"
    96 
    96 
    97 definition 
    97 definition 
    98   "rec_scan = CN rec_rem [Id 1 0, constn 2]"
    98   "rec_scan = CN rec_mod [Id 1 0, constn 2]"
    99 
    99 
   100 lemma scan_lemma [simp]: 
   100 lemma scan_lemma [simp]: 
   101   "rec_eval rec_scan [r] = r mod 2"
   101   "rec_eval rec_scan [r] = r mod 2"
   102 by(simp add: rec_scan_def)
   102 by(simp add: rec_scan_def)
   103 
   103 
   122     "rec_newleft =
   122     "rec_newleft =
   123        (let cond1 = CN rec_disj [CN rec_eq [Id 3 2, Z], CN rec_eq [Id 3 2, constn 1]] in
   123        (let cond1 = CN rec_disj [CN rec_eq [Id 3 2, Z], CN rec_eq [Id 3 2, constn 1]] in
   124         let cond2 = CN rec_eq [Id 3 2, constn 2] in
   124         let cond2 = CN rec_eq [Id 3 2, constn 2] in
   125         let cond3 = CN rec_eq [Id 3 2, constn 3] in
   125         let cond3 = CN rec_eq [Id 3 2, constn 3] in
   126         let case3 = CN rec_add [CN rec_mult [constn 2, Id 3 0], 
   126         let case3 = CN rec_add [CN rec_mult [constn 2, Id 3 0], 
   127                                 CN rec_rem [Id 3 1, constn 2]] in
   127                                 CN rec_mod [Id 3 1, constn 2]] in
   128         CN rec_if [cond1, Id 3 0, 
   128         CN rec_if [cond1, Id 3 0, 
   129           CN rec_if [cond2, CN rec_quo [Id 3 0, constn 2],
   129           CN rec_if [cond2, CN rec_quo [Id 3 0, constn 2],
   130             CN rec_if [cond3, case3, Id 3 0]]])"
   130             CN rec_if [cond3, case3, Id 3 0]]])"
   131 
   131 
   132 definition
   132 definition
   133     "rec_newright =
   133     "rec_newright =
   134        (let condn = \<lambda>n. CN rec_eq [Id 3 2, constn n] in
   134        (let condn = \<lambda>n. CN rec_eq [Id 3 2, constn n] in
   135         let case0 = CN rec_minus [Id 3 1, CN rec_scan [Id 3 1]] in
   135         let case0 = CN rec_minus [Id 3 1, CN rec_scan [Id 3 1]] in
   136         let case1 = CN rec_minus [CN rec_add [Id 3 1, constn 1], CN rec_scan [Id 3 1]] in
   136         let case1 = CN rec_minus [CN rec_add [Id 3 1, constn 1], CN rec_scan [Id 3 1]] in
   137         let case2 = CN rec_add [CN rec_mult [constn 2, Id 3 1],                     
   137         let case2 = CN rec_add [CN rec_mult [constn 2, Id 3 1],                     
   138                                 CN rec_rem [Id 3 0, constn 2]] in
   138                                 CN rec_mod [Id 3 0, constn 2]] in
   139         let case3 = CN rec_quo [Id 2 1, constn 2] in
   139         let case3 = CN rec_quo [Id 2 1, constn 2] in
   140         CN rec_if [condn 0, case0, 
   140         CN rec_if [condn 0, case0, 
   141           CN rec_if [condn 1, case1,
   141           CN rec_if [condn 1, case1,
   142             CN rec_if [condn 2, case2,
   142             CN rec_if [condn 2, case2,
   143               CN rec_if [condn 3, case3, Id 3 1]]]])"
   143               CN rec_if [condn 3, case3, Id 3 1]]]])"