equal
deleted
inserted
replaced
60 (N n1, N n2) \<Rightarrow> N(n1+n2) | |
60 (N n1, N n2) \<Rightarrow> N(n1+n2) | |
61 (a1',a2') \<Rightarrow> Plus a1' a2')" |
61 (a1',a2') \<Rightarrow> Plus a1' a2')" |
62 |
62 |
63 theorem aval_asimp_const[simp]: |
63 theorem aval_asimp_const[simp]: |
64 "aval (asimp_const a) s = aval a s" |
64 "aval (asimp_const a) s = aval a s" |
65 apply(induct a) |
65 apply(induction a) |
66 apply (auto split: aexp.split) |
66 apply (auto split: aexp.split) |
67 done |
67 done |
68 |
68 |
69 text{* Now we also eliminate all occurrences 0 in additions. The standard |
69 text{* Now we also eliminate all occurrences 0 in additions. The standard |
70 method: optimized versions of the constructors: *} |
70 method: optimized versions of the constructors: *} |
75 "plus a (N i) = (if i=0 then a else Plus a (N i))" | |
75 "plus a (N i) = (if i=0 then a else Plus a (N i))" | |
76 "plus a1 a2 = Plus a1 a2" |
76 "plus a1 a2 = Plus a1 a2" |
77 |
77 |
78 lemma aval_plus[simp]: |
78 lemma aval_plus[simp]: |
79 "aval (plus a1 a2) s = aval a1 s + aval a2 s" |
79 "aval (plus a1 a2) s = aval a1 s + aval a2 s" |
80 apply(induct a1 a2 rule: plus.induct) |
80 apply(induction a1 a2 rule: plus.induct) |
81 apply simp_all (* just for a change from auto *) |
81 apply simp_all (* just for a change from auto *) |
82 done |
82 done |
83 |
83 |
84 fun asimp :: "aexp \<Rightarrow> aexp" where |
84 fun asimp :: "aexp \<Rightarrow> aexp" where |
85 "asimp (N n) = N n" | |
85 "asimp (N n) = N n" | |
92 |
92 |
93 value "asimp (Plus (Plus (N 0) (N 0)) (Plus (V ''x'') (N 0)))" |
93 value "asimp (Plus (Plus (N 0) (N 0)) (Plus (V ''x'') (N 0)))" |
94 |
94 |
95 theorem aval_asimp[simp]: |
95 theorem aval_asimp[simp]: |
96 "aval (asimp a) s = aval a s" |
96 "aval (asimp a) s = aval a s" |
97 apply(induct a) |
97 apply(induction a) |
98 apply simp_all |
98 apply simp_all |
99 done |
99 done |
100 |
100 |
101 end |
101 end |