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