author | Walther Neuper <neuper@ist.tugraz.at> |
Fri, 22 Jul 2011 12:10:13 +0200 | |
branch | decompose-isar |
changeset 42164 | dc2fe21d2183 |
parent 42160 | 924503e4371c |
child 42185 | 332a0653d4c9 |
permissions | -rw-r--r-- |
neuper@42164 | 1 |
theory Test_Complex imports Isac begin |
neuper@42164 | 2 |
|
neuper@42164 | 3 |
section {*terms and operations*} |
neuper@42160 | 4 |
ML {* |
neuper@42164 | 5 |
print_depth 999; @{term "Complex 1 (2::real)"}; |
neuper@42160 | 6 |
*} |
neuper@42160 | 7 |
ML {* |
neuper@42160 | 8 |
@{term "Complex 1 2 + Complex 3 4"}; |
neuper@42160 | 9 |
@{term "Complex 1 2 * Complex 3 4"}; |
neuper@42160 | 10 |
@{term "Complex 1 2 - Complex 3 4"}; |
neuper@42160 | 11 |
@{term "Complex 1 2 / Complex 3 4"}; |
neuper@42164 | 12 |
(*@{term "Complex 1 2 ^ Complex 3 4"}; |
neuper@42164 | 13 |
Type unification failed: Clash of types "complex" and "nat" |
neuper@42164 | 14 |
Operator: op ^ (Complex 1 2) :: nat \<Rightarrow> complex |
neuper@42164 | 15 |
Operand: Complex 3 4 :: complex*) |
neuper@42160 | 16 |
*} |
neuper@42160 | 17 |
ML {* |
neuper@42164 | 18 |
term2str @{term "Complex 1 2 + Complex 3 4"}; |
neuper@42164 | 19 |
term2str @{term "Complex 1 2 / Complex 3 4"}; |
neuper@42164 | 20 |
*} |
neuper@42164 | 21 |
|
neuper@42164 | 22 |
ML {* |
neuper@42160 | 23 |
val a = @{term "Complex 1 2"}; |
neuper@42160 | 24 |
val b = @{term "Complex 3 4"}; |
neuper@42160 | 25 |
(*a + (b::complex); ERROR: term + term*) |
neuper@42160 | 26 |
*} |
neuper@42164 | 27 |
|
neuper@42164 | 28 |
section {*use the operations for simplification*} |
neuper@42164 | 29 |
subsection {*example 1*} |
neuper@42160 | 30 |
ML {* |
neuper@42164 | 31 |
print_depth 1; |
neuper@42164 | 32 |
val (thy, ro, er) = (@{theory}, tless_true, eval_rls); |
neuper@42160 | 33 |
*} |
neuper@42160 | 34 |
ML {* |
neuper@42164 | 35 |
val thm = @{thm "complex_add"}; |
neuper@42164 | 36 |
val t = @{term "Complex 1 2 + Complex 3 4"}; |
neuper@42164 | 37 |
val SOME _ = rewrite_ thy ro er true thm t; |
neuper@42164 | 38 |
val SOME (t', _) = rewrite_ thy ro er true thm t; |
neuper@42164 | 39 |
"Complex (1 + 3) (2 + 4)" = term2str t'; |
neuper@42164 | 40 |
*} |
neuper@42164 | 41 |
|
neuper@42164 | 42 |
subsection {*example 2*} |
neuper@42164 | 43 |
ML {* |
neuper@42164 | 44 |
val Simplify_complex = append_rls "Simplify_complex" norm_Poly |
neuper@42164 | 45 |
[ Thm ("complex_add",num_str @{thm complex_add}), |
neuper@42164 | 46 |
Thm ("complex_mult",num_str @{thm complex_mult}) |
neuper@42164 | 47 |
]; |
neuper@42164 | 48 |
*} |
neuper@42164 | 49 |
ML {* |
neuper@42164 | 50 |
val t = @{term "0 * (Complex 1 2 * (Complex 3 4 + Complex 5 (6::real)))"}; |
neuper@42164 | 51 |
*} |
neuper@42164 | 52 |
ML {* |
neuper@42164 | 53 |
val SOME (t, _) = rewrite_set_ thy true Simplify_complex t; |
neuper@42164 | 54 |
*} |
neuper@42164 | 55 |
ML {* |
neuper@42164 | 56 |
term2str t |
neuper@42164 | 57 |
*} |
neuper@42164 | 58 |
ML {* |
neuper@42160 | 59 |
*} |
neuper@42160 | 60 |
|
neuper@42160 | 61 |
end |
neuper@42160 | 62 |