src/HOL/SetInterval.thy
changeset 15048 11b4dce71d73
parent 15047 fa62de5862b9
child 15052 cc562a263609
     1.1 --- a/src/HOL/SetInterval.thy	Thu Jul 15 15:32:32 2004 +0200
     1.2 +++ b/src/HOL/SetInterval.thy	Thu Jul 15 15:39:40 2004 +0200
     1.3 @@ -50,6 +50,11 @@
     1.4    "{m..n(}" => "{m..<n}"
     1.5    "{)m..n}" => "{m<..n}"
     1.6  
     1.7 +
     1.8 +text{* A note of warning when using @{term"{..<n}"} on type @{typ
     1.9 +nat}: it is equivalent to @{term"{0::nat..<n}"} but some lemmas involving
    1.10 +@{term"{m..<n}"} may not exist for in @{term"{..<n}"}-form as well. *}
    1.11 +
    1.12  syntax
    1.13    "@UNION_le"   :: "nat => nat => 'b set => 'b set"       ("(3UN _<=_./ _)" 10)
    1.14    "@UNION_less" :: "nat => nat => 'b set => 'b set"       ("(3UN _<_./ _)" 10)
    1.15 @@ -533,27 +538,32 @@
    1.16  subsection {* Summation indexed over intervals *}
    1.17  
    1.18  text{* We introduce the obvious syntax @{text"\<Sum>x=a..b. e"} for
    1.19 -@{term"\<Sum>x\<in>{a..b}. e"}. *}
    1.20 +@{term"\<Sum>x\<in>{a..b}. e"}, @{text"\<Sum>x=a..<b. e"} for
    1.21 +@{term"\<Sum>x\<in>{a..<b}. e"}, and @{text"\<Sum>x<b. e"} for @{term"\<Sum>x\<in>{..<b}. e"}.
    1.22 +
    1.23 +Note that for uniformity on @{typ nat} it is better to use
    1.24 +@{text"\<Sum>x=0..<n. e"} rather than @{text"\<Sum>x<n. e"}: @{text setsum} may
    1.25 +not provide all lemmas available for @{term"{m..<n}"} also in the
    1.26 +special form for @{term"{..<n}"}. *}
    1.27  
    1.28  syntax
    1.29    "_from_to_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(SUM _ = _.._./ _)" [0,0,0,10] 10)
    1.30 +  "_from_upto_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(SUM _ = _..<_./ _)" [0,0,0,10] 10)
    1.31 +  "_upto_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(SUM _<_./ _)" [0,0,10] 10)
    1.32  syntax (xsymbols)
    1.33    "_from_to_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sum>_ = _.._./ _)" [0,0,0,10] 10)
    1.34 +  "_from_upto_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sum>_ = _..<_./ _)" [0,0,0,10] 10)
    1.35 +  "_upto_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sum>_<_./ _)" [0,0,10] 10)
    1.36  syntax (HTML output)
    1.37    "_from_to_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sum>_ = _.._./ _)" [0,0,0,10] 10)
    1.38 -
    1.39 -translations "\<Sum>x=a..b. t" == "setsum (%x. t) {a..b}"
    1.40 -
    1.41 -
    1.42 -subsection {* Summation up to *}
    1.43 +  "_from_upto_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sum>_ = _..<_./ _)" [0,0,0,10] 10)
    1.44 +  "_upto_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sum>_<_./ _)" [0,0,10] 10)
    1.45  
    1.46 -text{* Legacy, only used in HoareParallel and Isar-Examples. Really
    1.47 -needed? Probably better to replace it with above syntax. *}
    1.48 +translations
    1.49 +  "\<Sum>x=a..b. t" == "setsum (%x. t) {a..b}"
    1.50 +  "\<Sum>x=a..<b. t" == "setsum (%x. t) {a..<b}"
    1.51 +  "\<Sum>i<n. t" == "setsum (\<lambda>i. t) {..<n}"
    1.52  
    1.53 -syntax
    1.54 -  "_Summation" :: "idt => 'a => 'b => 'b"    ("\<Sum>_<_. _" [0, 51, 10] 10)
    1.55 -translations
    1.56 -  "\<Sum>i < n. b" == "setsum (\<lambda>i. b) {..<n}"
    1.57  
    1.58  lemma Summation_Suc[simp]: "(\<Sum>i < Suc n. b i) = b n + (\<Sum>i < n. b i)"
    1.59  by (simp add:lessThan_Suc)