separated Isac documentation (~~/doc-isac) from Isabelle documentation (~~/src/Doc)
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*}
41 subsection {*example 1 -- ADD*}
44 val (thy, ro, er) = (@{theory}, tless_true, eval_rls);
47 val thm = @{thm "complex_add"};
48 val t = str2term "Complex 1 2 + Complex 3 4";
49 val SOME _ = rewrite_ thy ro er true thm t;
50 val SOME (t', _) = rewrite_ thy ro er true thm t;
51 "Complex (1 + 3) (2 + 4)" = term2str t';
57 subsection {*example 2 -- ADD, MULT*}
60 val Simplify_complex = append_rls "Simplify_complex" e_rls
61 [ Thm ("complex_add",num_str @{thm complex_add}),
62 Thm ("complex_mult",num_str @{thm complex_mult}),
69 val t = str2term "(Complex 1 2 * (Complex 3 4 + Complex 5 (6::real)))";
70 term2str t = "Complex 1 2 * (Complex 3 4 + Complex 5 6)";
77 val SOME (t, _) = rewrite_set_ thy true Simplify_complex t;
79 term2str t = "Complex -12 26";
84 subsection {*example 3*}
86 val Simplify_complex = append_rls "Simplify_complex" e_rls
87 [ Thm ("complex_mult",num_str @{thm complex_mult}),
88 Thm ("complex_inverse",num_str @{thm complex_inverse}),
93 val t = str2term "inverse (Complex (2::real) (4::real))";
94 term2str t = "inverse Complex (2) (4)";
98 trace_rewrite := true;
99 val SOME (t, _) = rewrite_set_ thy true Simplify_complex t;
100 trace_rewrite := false;
101 term2str t = "Complex -12 26";
108 trace_rewrite := true;
109 trace_rewrite := false;