From 3fa136ec72e4d80775af64f60704c483b3263fd4 Mon Sep 17 00:00:00 2001 From: Simon Foster Date: Tue, 25 Feb 2020 15:42:42 +0000 Subject: [PATCH] A few additional properties and proofs --- src/SI/SI_Accepted.thy | 3 +++ src/SI/SI_Dimensions.thy | 15 ++++++++------- src/SI/SI_Imperial.thy | 30 +++++++++++++++++++++++++----- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/SI/SI_Accepted.thy b/src/SI/SI_Accepted.thy index 92c502e..4946f8f 100644 --- a/src/SI/SI_Accepted.thy +++ b/src/SI/SI_Accepted.thy @@ -25,4 +25,7 @@ subsection \ Examples \ lemma "watt \<^bold>\ hour \\<^sub>Q 3600 \ joule" by (si_calc) +lemma "25 \ meter \<^bold>/ second = 90 \ (kilo \ meter) \<^bold>/ hour" + by (si_calc) + end \ No newline at end of file diff --git a/src/SI/SI_Dimensions.thy b/src/SI/SI_Dimensions.thy index c35c58c..99cbd3b 100644 --- a/src/SI/SI_Dimensions.thy +++ b/src/SI/SI_Dimensions.thy @@ -252,12 +252,12 @@ lemma base_units [simp]: subsubsection \ Higher SI Type Constructors: Inner Product and Inverse \ text\On the class of SI-types (in which we have already inserted the base SI types), -the definitions of the type constructors for inner product and inverse is straight) forward.\ +the definitions of the type constructors for inner product and inverse is straight forward.\ typedef ('a::dim_type, 'b::dim_type) DimTimes (infixl "\" 69) = "UNIV :: unit set" .. setup_lifting type_definition_DimTimes -text \ We can prove that multiplication of two SI types yields an SI type. \ +text \ We can prove that multiplication of two dimension types yields a dimension type. \ instantiation DimTimes :: (dim_type, dim_type) dim_type begin @@ -266,7 +266,8 @@ begin instance by (intro_classes, simp_all add: dim_ty_sem_DimTimes_def, (transfer, simp)+) end -text \ Similarly, we define division of two SI types and prove that SI types are closed under this. \ +text \ Similarly, we define inversion of dimension types and prove that dimension types are + closed under this. \ typedef 'a DimInv ("(_\<^sup>-\<^sup>1)" [999] 999) = "UNIV :: unit set" .. setup_lifting type_definition_DimInv @@ -277,12 +278,14 @@ begin instance by (intro_classes, simp_all add: dim_ty_sem_DimInv_def, (transfer, simp)+) end - subsection \ Syntactic Support for dim-type expressions. \ -text\A number of type-synonyms allow for more compact notation: \ +text \ A division is expressed, as usual, by multiplication with an inverted dimension. \ + type_synonym ('a, 'b) DimDiv = "'a \ ('b\<^sup>-\<^sup>1)" (infixl "'/" 69) +text \ A number of further type-synonyms allow for more compact notation: \ + type_synonym 'a DimSquare = "'a \ 'a" ("(_)\<^sup>2" [999] 999) type_synonym 'a DimCube = "'a \ 'a \ 'a" ("(_)\<^sup>3" [999] 999) type_synonym 'a DimQuart = "'a \ 'a \ 'a \ 'a" ("(_)\<^sup>4" [999] 999) @@ -294,8 +297,6 @@ translations (type) "'a\<^sup>-\<^sup>2" <= (type) "('a\<^sup>2)\<^sup>-\<^sup>1 translations (type) "'a\<^sup>-\<^sup>3" <= (type) "('a\<^sup>3)\<^sup>-\<^sup>1" translations (type) "'a\<^sup>-\<^sup>4" <= (type) "('a\<^sup>4)\<^sup>-\<^sup>1" -(* Need to add DimQuart to the print translation *) - print_translation \ [(@{type_syntax DimTimes}, fn ctx => fn [a, b] => diff --git a/src/SI/SI_Imperial.thy b/src/SI/SI_Imperial.thy index 3fe0ef9..fca8011 100644 --- a/src/SI/SI_Imperial.thy +++ b/src/SI/SI_Imperial.thy @@ -6,19 +6,39 @@ begin subsection \ Definition \ -definition degrees_farenheit :: "'a::field_char_0 \ 'a[\]" ("_\F" [999] 999) +default_sort field_char_0 + +definition degrees_farenheit :: "'a \ 'a[\]" ("_\F" [999] 999) where [si_eq]: "degrees_farenheit x = (x + 459.67)\5/9 \ kelvin" -definition [si_def, si_eq]: "pint = 0.56826125 \ litre" +definition pint :: "'a[Volume]" where +[si_def, si_eq]: "pint = 0.56826125 \ litre" -definition [si_def, si_eq]: "inch = 25.5 \ milli \ meter" +definition inch :: "'a[L]" where +[si_def, si_eq]: "inch = 25.5 \ milli \ meter" -definition [si_def, si_eq]: "foot = 0.3048 \ meter" +definition foot :: "'a[L]" where +[si_def, si_eq]: "foot = 0.3048 \ meter" -definition [si_def, si_eq]: "yard = 0.9144 \ meter" +definition yard :: "'a[L]" where +[si_def, si_eq]: "yard = 0.9144 \ meter" + +definition mile :: "'a[L]" where +[si_def, si_eq]: "mile = 1609.344 \ meter" + +default_sort type subsection \ Properties \ +lemma miles_to_yards: "mile = 1760 \ yard" + by si_simp + +lemma miles_to_feet: "mile = 5280 \ foot" + by si_simp + +lemma mph_to_kmh: "1 \ (mile \<^bold>/ hour) = 1.609344 \ ((kilo \ meter) \<^bold>/ hour)" + by si_simp + lemma celcius_to_farenheit: "(T::rat)\C = ((T - 32) \ 5/9)\F" oops