1 (* Title: "BaseDefinitions/BaseDefinitions.thy"
2 Author: Walther Neuper 190823
3 (c) due to copyright terms
5 Know_Store holds Theory_Data (problems, methods, etc) and requires respective definitions.
7 theory BaseDefinitions imports Know_Store
10 subsection \<open>Power re-defined for a specific type\<close>
12 definition even_real :: "real \<Rightarrow> bool"
13 where "even_real x \<longleftrightarrow> \<bar>x\<bar> \<in> \<nat> \<and> even (inv real \<bar>x\<bar>)"
14 definition odd_real :: "real \<Rightarrow> bool"
15 where "odd_real x \<longleftrightarrow> \<bar>x\<bar> \<in> \<nat> \<and> odd (inv real \<bar>x\<bar>)"
17 definition realpow :: "real \<Rightarrow> real \<Rightarrow> real" (infixr "\<up>" 80)
19 (if x \<ge> 0 then x powr n
20 else if n \<ge> 0 \<and> even_real n then (- x) powr n
21 else if n \<ge> 0 \<and> odd_real n then - ((- x) powr n)
22 else if n < 0 \<and> even_real n then 1 / (- x) powr (- n)
23 else if n < 0 \<and> odd_real n then - 1 / ((- x) powr (- n))
26 lemma realpow_simps [simp]:
29 "numeral m \<up> numeral n = (numeral m ^ numeral n :: real)"
30 "x > 0 \<Longrightarrow> x \<up> 0 = 1"
31 "x \<ge> 0 \<Longrightarrow> x \<up> 1 = x"
32 "x \<ge> 0 \<Longrightarrow> x \<up> numeral n = x ^ numeral n"
33 "x > 0 \<Longrightarrow> x \<up> - numeral n = 1 / (x ^ numeral n)"
34 by (simp_all add: realpow_def powr_neg_numeral)
39 "inv real (numeral n) = numeral n"
40 by (simp_all add: inv_f_eq)
42 lemma realpow_uminus_simps [simp]:
45 "x \<up> (- 1) = 1 / x"
46 "(- numeral m) \<up> 0 = 1"
47 "(- numeral m) \<up> 1 = - numeral m"
48 "even (numeral n :: nat) \<Longrightarrow> (- 1) \<up> (numeral n) = 1"
49 "odd (numeral n :: nat) \<Longrightarrow> (- 1) \<up> (numeral n) = - 1"
50 "even (numeral n :: nat) \<Longrightarrow> (- 1) \<up> (- numeral n) = 1"
51 "odd (numeral n :: nat) \<Longrightarrow> (- 1) \<up> (- numeral n) = - 1"
52 "odd (numeral n :: nat) \<Longrightarrow> (- numeral m) \<up> (numeral n) = - (numeral m ^ numeral n)"
53 "even (numeral n :: nat) \<Longrightarrow> (- numeral m) \<up> (numeral n) = numeral m ^ numeral n"
54 "even (numeral n :: nat) \<Longrightarrow> (- numeral m) \<up> (- numeral n) = 1 / (numeral m ^ numeral n)"
55 "odd (numeral n :: nat) \<Longrightarrow> (- numeral m) \<up> (- numeral n) = - 1 / (numeral m ^ numeral n)"
56 apply (simp_all add: realpow_def even_real_def odd_real_def inv_real_eq)
57 by (simp add: powr_minus_divide)
60 ML_file substitution.sml
62 ML_file environment.sml