test/Tools/isac/ADDTESTS/Test_Units.thy
author wneuper <Walther.Neuper@jku.at>
Wed, 11 Jan 2023 11:38:01 +0100
changeset 60650 06ec8abfd3bc
parent 59592 99c8d2ff63eb
permissions -rw-r--r--
eliminate use of Thy_Info 12: TermC partially
     1 theory Test_Units imports Isac.Isac_Knowledge
     2 begin
     3 
     4 subsection \<open>Variant 1: \<close>
     5 
     6 consts 
     7   SI1m :: "real => real" ("_ SI1m" (*99*))
     8   SI1cm :: "real => real" ("_ SI1cm" (*99*))
     9 term "a SI1m"
    10 term "123 SI1m"
    11 (*term "45.67 SI1m" -- \<open>"4567 / 10\<^sup>2 SI1m" :: "real"\<close>  Undefined document antiquotation: "sup"\<^here> *)
    12 (*term "100 * a SI1m"
    13     Ambiguous input          ?! WE NEED PARENTHESES EVEN WITH: SI1m :: "real => real" ("_ SI1m" 99)
    14     2 terms are type correct:
    15       ((100 * a) SI1m)
    16       (100 * (a SI1m))
    17 *)
    18 axiomatization where
    19   SI1m__cm : "a SI1m = 100 * (a SI1cm)" and
    20   SI1cm__m : "a SI1cm = 0.01 * (a SI1m)" and
    21 
    22   multr_SI1m : "((a SI1m) * b) = ((a * b) SI1m)" and
    23   multl_SI1m : "(b * (a SI1m)) = ((a * b) SI1m)" and
    24   multr_SI1cm : "((a SI1cm) * b) = ((a * b) SI1cm)" and
    25   multl_SI1cm : "(a * (b SI1cm)) = ((a * b) SI1cm)" and
    26 
    27   add_SI1m : "((a SI1m) + (b SI1m)) = ((a + b) SI1m)" and
    28   add_SI1cm : "((a SI1cm) + (b SI1cm)) = ((a + b) SI1cm)"
    29 
    30 ML \<open>
    31 Thm.prop_of @{thm SI1m__cm};
    32 TermC.atom_trace @{context} (Thm.prop_of @{thm SI1m__cm});
    33 \<close>
    34 
    35 (*--------------------- broken Isabelle2015->17 -------------
    36 theorem ad_hoc_1: "((2 SI1m) * 3) = (600 SI1cm)"
    37 proof -
    38   have "(2 SI1m) * 3 = 100 * (2 SI1cm) * 3"
    39     by (simp only: SI1m__cm)
    40   also have "... = ((100 * 2) SI1cm) * 3"
    41     by (simp only: multl_SI1cm)
    42   also have "... = (((100 * 2) * 3) SI1cm)"
    43     by (simp only: multr_SI1cm)
    44   also have "... = (600 SI1cm)"
    45     by simp 
    46   finally show ?thesis .
    47 qed
    48 ----------------------- broken Isabelle2015->17 ------------*)
    49  
    50 subsection \<open>Variant 2: \<close>
    51 
    52 typedef SI2m = "UNIV :: real set" ..
    53 typedef SI2cm = "UNIV :: real set" ..
    54 
    55 setup_lifting type_definition_SI2m
    56 setup_lifting type_definition_SI2cm
    57 
    58 consts
    59   SI2m'_'_cm :: "SI2m => SI2cm" ("_ SI2m'_'_cm" (*99*))
    60   SI2cm'_'_m :: "SI2cm => SI2m" ("_ SI2cm'_'_m" (*99*))
    61 
    62 term "a :: SI2m"
    63 (*term "123 :: SI2m"  
    64     Type unification failed: No type arity SI2m :: numeral*)
    65 (*term "45.67 :: SI2m"  
    66     Type unification failed: No type arity SI2m :: numeral*)
    67 term "(a :: SI2cm) SI2cm__m"
    68 
    69 (*
    70 instantiation SI2m :: (times) times
    71 begin
    72 
    73 lift_definition times_SI2m .......
    74 
    75 end
    76 
    77 term "(100 * (a :: SI2cm))"
    78 
    79 axiomatization where
    80   SI2m__cm : "(a :: SI2m) = ((100 * (a :: SI2cm)) SI2cm__m)"
    81 *)
    82 
    83 end