
neuper@42164: theory Test_Complex imports Isac begin
neuper@42164: 
neuper@42164: section {*terms and operations*}
neuper@42160: ML {*
neuper@42164: print_depth 999; @{term "Complex 1 (2::real)"};
neuper@42160: *}
neuper@42160: ML {*
neuper@42160: @{term "Complex 1 2 + Complex 3 4"};
neuper@42160: @{term "Complex 1 2 * Complex 3 4"};
neuper@42160: @{term "Complex 1 2 - Complex 3 4"};
neuper@42160: @{term "Complex 1 2 / Complex 3 4"};
neuper@42164: (*@{term "Complex 1 2 ^ Complex 3 4"};
neuper@42164:   Type unification failed: Clash of types "complex" and "nat"
neuper@42164:   Operator:  op ^ (Complex 1 2) :: nat \<Rightarrow> complex
neuper@42164:   Operand:   Complex 3 4 :: complex*)
neuper@42160: *}
neuper@42160: ML {*
neuper@42164: term2str @{term "Complex 1 2 + Complex 3 4"};
neuper@42164: term2str @{term "Complex 1 2 / Complex 3 4"};
neuper@42164: *}
neuper@42164: 
neuper@42164: ML {*
neuper@42160: val a = @{term "Complex 1 2"};
neuper@42160: val b = @{term "Complex 3 4"};
neuper@42160: (*a + (b::complex); ERROR: term + term*)
neuper@42160: *}
neuper@42164: 
neuper@42164: section {*use the operations for simplification*}
neuper@42164: subsection {*example 1*}
neuper@42160: ML {*
neuper@42164: print_depth 1;
neuper@42164: val (thy, ro, er) = (@{theory}, tless_true, eval_rls);
neuper@42160: *}
neuper@42160: ML {*
neuper@42164: val thm = @{thm "complex_add"};
neuper@42164: val t = @{term "Complex 1 2 + Complex 3 4"};
neuper@42164: val SOME _ = rewrite_ thy ro er true thm t;
neuper@42164: val SOME (t', _) = rewrite_ thy ro er true thm t;
neuper@42164: "Complex (1 + 3) (2 + 4)" = term2str t';
neuper@42164: *}
neuper@42164: 
neuper@42164: subsection {*example 2*}
neuper@42164: ML {*
neuper@42164: val Simplify_complex = append_rls "Simplify_complex" norm_Poly
neuper@42164:   [ Thm  ("complex_add",num_str @{thm complex_add}),
neuper@42164: 		    Thm  ("complex_mult",num_str @{thm complex_mult})
neuper@42164: 		  ];
neuper@42164: *}
neuper@42164: ML {*
neuper@42164: val t = @{term "0 * (Complex 1 2 * (Complex 3 4 + Complex 5 (6::real)))"};
neuper@42164: *}
neuper@42164: ML {*
neuper@42164: val SOME (t, _) = rewrite_set_ thy true Simplify_complex t;
neuper@42164: *}
neuper@42164: ML {*
neuper@42164: term2str t
neuper@42164: *}
neuper@42164: ML {*
neuper@42160: *}
neuper@42160: 
neuper@42160: end
neuper@42160: 




