intermed. updated test + Test_Z_Transform.thy etc
1 theory Test_Complex imports Isac begin
3 section {*terms and operations*}
5 print_depth 999; @{term "Complex 1 (2::real)"};
8 @{term "Complex 1 2 + Complex 3 4"};
9 print_depth 999; str2term "Complex 1 2 + Complex 3 4"; print_depth 999;
12 @{term "Complex 1 2 * Complex 3 4"};
13 @{term "Complex 1 2 - Complex 3 4"};
14 @{term "Complex 1 2 / Complex 3 4"};
15 (*@{term "Complex 1 2 ^ Complex 3 4"};
16 Type unification failed: Clash of types "complex" and "nat"
17 Operator: op ^ (Complex 1 2) :: nat \<Rightarrow> complex
18 Operand: Complex 3 4 :: complex*)
21 term2str @{term "Complex 1 2 + Complex 3 4"};
22 term2str @{term "Complex 1 2 / Complex 3 4"};
26 val a = @{term "Complex 1 2"};
28 val a = str2term "Complex 1 2";
32 val b = @{term "Complex 3 4"};
33 val b = str2term "Complex 3 4";
34 (*a + (b::complex); ERROR: term + term*)
37 section {*use the operations for simplification*}
38 subsection {*example 1*}
41 val (thy, ro, er) = (@{theory}, tless_true, eval_rls);
44 val thm = @{thm "complex_add"};
45 val t = str2term "Complex 1 2 + Complex 3 4";
46 val SOME _ = rewrite_ thy ro er true thm t;
47 val SOME (t', _) = rewrite_ thy ro er true thm t;
48 "Complex (1 + 3) (2 + 4)" = term2str t';
51 subsection {*example 2*}
53 val Simplify_complex = append_rls "Simplify_complex" e_rls
54 [ Thm ("complex_add",num_str @{thm complex_add}),
55 Thm ("complex_mult",num_str @{thm complex_mult}),
60 val t = str2term "(Complex 1 2 * (Complex 3 4 + Complex 5 (6::real)))";
61 term2str t = "Complex 1 2 * (Complex 3 4 + Complex 5 6)";
65 trace_rewrite := true;
66 val SOME (t, _) = rewrite_set_ thy true Simplify_complex t;
67 trace_rewrite := false;
68 term2str t = "Complex -12 26";
75 trace_rewrite := true;
76 trace_rewrite := false;