# HG changeset patch # User haftmann # Date 1278655870 -7200 # Node ID 89e16802b6cc187b24339fafaa0c282a190cb223 # Parent 82e0fe8b07ebea37fa43fdd290046a02b5824f40 nicer xsymbol syntax for fcomp and scomp diff -r 82e0fe8b07eb -r 89e16802b6cc src/HOL/Fun.thy --- a/src/HOL/Fun.thy Thu Jul 08 17:23:05 2010 +0200 +++ b/src/HOL/Fun.thy Fri Jul 09 08:11:10 2010 +0200 @@ -95,26 +95,26 @@ subsection {* The Forward Composition Operator @{text fcomp} *} definition - fcomp :: "('a \ 'b) \ ('b \ 'c) \ 'a \ 'c" (infixl "o>" 60) + fcomp :: "('a \ 'b) \ ('b \ 'c) \ 'a \ 'c" (infixl "\>" 60) where - "f o> g = (\x. g (f x))" + "f \> g = (\x. g (f x))" -lemma fcomp_apply: "(f o> g) x = g (f x)" +lemma fcomp_apply [simp]: "(f \> g) x = g (f x)" by (simp add: fcomp_def) -lemma fcomp_assoc: "(f o> g) o> h = f o> (g o> h)" +lemma fcomp_assoc: "(f \> g) \> h = f \> (g \> h)" by (simp add: fcomp_def) -lemma id_fcomp [simp]: "id o> g = g" +lemma id_fcomp [simp]: "id \> g = g" by (simp add: fcomp_def) -lemma fcomp_id [simp]: "f o> id = f" +lemma fcomp_id [simp]: "f \> id = f" by (simp add: fcomp_def) code_const fcomp (Eval infixl 1 "#>") -no_notation fcomp (infixl "o>" 60) +no_notation fcomp (infixl "\>" 60) subsection {* Injectivity and Surjectivity *} diff -r 82e0fe8b07eb -r 89e16802b6cc src/HOL/Library/Fset.thy --- a/src/HOL/Library/Fset.thy Thu Jul 08 17:23:05 2010 +0200 +++ b/src/HOL/Library/Fset.thy Fri Jul 09 08:11:10 2010 +0200 @@ -69,21 +69,21 @@ \ 'a fset \ (unit \ Code_Evaluation.term)" where [code_unfold]: "setify xs = Code_Evaluation.valtermify Set {\} xs" -notation fcomp (infixl "o>" 60) -notation scomp (infixl "o\" 60) +notation fcomp (infixl "\>" 60) +notation scomp (infixl "\\" 60) instantiation fset :: (random) random begin definition - "Quickcheck.random i = Quickcheck.random i o\ (\xs. Pair (setify xs))" + "Quickcheck.random i = Quickcheck.random i \\ (\xs. Pair (setify xs))" instance .. end -no_notation fcomp (infixl "o>" 60) -no_notation scomp (infixl "o\" 60) +no_notation fcomp (infixl "\>" 60) +no_notation scomp (infixl "\\" 60) subsection {* Lattice instantiation *} diff -r 82e0fe8b07eb -r 89e16802b6cc src/HOL/Library/Multiset.thy --- a/src/HOL/Library/Multiset.thy Thu Jul 08 17:23:05 2010 +0200 +++ b/src/HOL/Library/Multiset.thy Fri Jul 09 08:11:10 2010 +0200 @@ -954,21 +954,21 @@ \ 'a multiset \ (unit \ Code_Evaluation.term)" where [code_unfold]: "bagify xs = Code_Evaluation.valtermify Bag {\} xs" -notation fcomp (infixl "o>" 60) -notation scomp (infixl "o\" 60) +notation fcomp (infixl "\>" 60) +notation scomp (infixl "\\" 60) instantiation multiset :: (random) random begin definition - "Quickcheck.random i = Quickcheck.random i o\ (\xs. Pair (bagify xs))" + "Quickcheck.random i = Quickcheck.random i \\ (\xs. Pair (bagify xs))" instance .. end -no_notation fcomp (infixl "o>" 60) -no_notation scomp (infixl "o\" 60) +no_notation fcomp (infixl "\>" 60) +no_notation scomp (infixl "\\" 60) hide_const (open) bagify diff -r 82e0fe8b07eb -r 89e16802b6cc src/HOL/Library/State_Monad.thy --- a/src/HOL/Library/State_Monad.thy Thu Jul 08 17:23:05 2010 +0200 +++ b/src/HOL/Library/State_Monad.thy Fri Jul 09 08:11:10 2010 +0200 @@ -55,23 +55,23 @@ we use a set of monad combinators: *} -notation fcomp (infixl "o>" 60) -notation (xsymbols) fcomp (infixl "o>" 60) +notation fcomp (infixl "\>" 60) +notation (xsymbols) fcomp (infixl "\>" 60) notation scomp (infixl "o->" 60) -notation (xsymbols) scomp (infixl "o\" 60) +notation (xsymbols) scomp (infixl "\\" 60) abbreviation (input) "return \ Pair" text {* Given two transformations @{term f} and @{term g}, they - may be directly composed using the @{term "op o>"} combinator, - forming a forward composition: @{prop "(f o> g) s = f (g s)"}. + may be directly composed using the @{term "op \>"} combinator, + forming a forward composition: @{prop "(f \> g) s = f (g s)"}. After any yielding transformation, we bind the side result immediately using a lambda abstraction. This - is the purpose of the @{term "op o\"} combinator: - @{prop "(f o\ (\x. g)) s = (let (x, s') = f s in g s')"}. + is the purpose of the @{term "op \\"} combinator: + @{prop "(f \\ (\x. g)) s = (let (x, s') = f s in g s')"}. For queries, the existing @{term "Let"} is appropriate. @@ -141,8 +141,8 @@ translations "_do f" => "f" - "_scomp x f g" => "f o\ (\x. g)" - "_fcomp f g" => "f o> g" + "_scomp x f g" => "f \\ (\x. g)" + "_fcomp f g" => "f \> g" "_let x t f" => "CONST Let t (\x. f)" "_done f" => "f" diff -r 82e0fe8b07eb -r 89e16802b6cc src/HOL/Product_Type.thy --- a/src/HOL/Product_Type.thy Thu Jul 08 17:23:05 2010 +0200 +++ b/src/HOL/Product_Type.thy Fri Jul 09 08:11:10 2010 +0200 @@ -791,37 +791,37 @@ The composition-uncurry combinator. *} -notation fcomp (infixl "o>" 60) +notation fcomp (infixl "\>" 60) -definition scomp :: "('a \ 'b \ 'c) \ ('b \ 'c \ 'd) \ 'a \ 'd" (infixl "o\" 60) where - "f o\ g = (\x. split g (f x))" +definition scomp :: "('a \ 'b \ 'c) \ ('b \ 'c \ 'd) \ 'a \ 'd" (infixl "\\" 60) where + "f \\ g = (\x. prod_case g (f x))" lemma scomp_unfold: "scomp = (\f g x. g (fst (f x)) (snd (f x)))" - by (simp add: expand_fun_eq scomp_def split_def) + by (simp add: expand_fun_eq scomp_def prod_case_unfold) -lemma scomp_apply: "(f o\ g) x = split g (f x)" - by (simp add: scomp_unfold split_def) +lemma scomp_apply [simp]: "(f \\ g) x = prod_case g (f x)" + by (simp add: scomp_unfold prod_case_unfold) -lemma Pair_scomp: "Pair x o\ f = f x" +lemma Pair_scomp: "Pair x \\ f = f x" by (simp add: expand_fun_eq scomp_apply) -lemma scomp_Pair: "x o\ Pair = x" +lemma scomp_Pair: "x \\ Pair = x" by (simp add: expand_fun_eq scomp_apply) -lemma scomp_scomp: "(f o\ g) o\ h = f o\ (\x. g x o\ h)" +lemma scomp_scomp: "(f \\ g) \\ h = f \\ (\x. g x \\ h)" by (simp add: expand_fun_eq scomp_unfold) -lemma scomp_fcomp: "(f o\ g) o> h = f o\ (\x. g x o> h)" +lemma scomp_fcomp: "(f \\ g) \> h = f \\ (\x. g x \> h)" by (simp add: expand_fun_eq scomp_unfold fcomp_def) -lemma fcomp_scomp: "(f o> g) o\ h = f o> (g o\ h)" +lemma fcomp_scomp: "(f \> g) \\ h = f \> (g \\ h)" by (simp add: expand_fun_eq scomp_unfold fcomp_apply) code_const scomp (Eval infixl 3 "#->") -no_notation fcomp (infixl "o>" 60) -no_notation scomp (infixl "o\" 60) +no_notation fcomp (infixl "\>" 60) +no_notation scomp (infixl "\\" 60) text {* @{term prod_fun} --- action of the product functor upon diff -r 82e0fe8b07eb -r 89e16802b6cc src/HOL/Quickcheck.thy --- a/src/HOL/Quickcheck.thy Thu Jul 08 17:23:05 2010 +0200 +++ b/src/HOL/Quickcheck.thy Fri Jul 09 08:11:10 2010 +0200 @@ -7,8 +7,8 @@ uses ("Tools/quickcheck_generators.ML") begin -notation fcomp (infixl "o>" 60) -notation scomp (infixl "o\" 60) +notation fcomp (infixl "\>" 60) +notation scomp (infixl "\\" 60) subsection {* The @{text random} class *} @@ -23,7 +23,7 @@ begin definition - "random i = Random.range 2 o\ + "random i = Random.range 2 \\ (\k. Pair (if k = 0 then Code_Evaluation.valtermify False else Code_Evaluation.valtermify True))" instance .. @@ -44,7 +44,7 @@ begin definition - "random _ = Random.select chars o\ (\c. Pair (c, \u. Code_Evaluation.term_of c))" + "random _ = Random.select chars \\ (\c. Pair (c, \u. Code_Evaluation.term_of c))" instance .. @@ -64,7 +64,7 @@ begin definition random_nat :: "code_numeral \ Random.seed \ (nat \ (unit \ Code_Evaluation.term)) \ Random.seed" where - "random_nat i = Random.range (i + 1) o\ (\k. Pair ( + "random_nat i = Random.range (i + 1) \\ (\k. Pair ( let n = Code_Numeral.nat_of k in (n, \_. Code_Evaluation.term_of n)))" @@ -76,7 +76,7 @@ begin definition - "random i = Random.range (2 * i + 1) o\ (\k. Pair ( + "random i = Random.range (2 * i + 1) \\ (\k. Pair ( let j = (if k \ i then Code_Numeral.int_of (k - i) else - Code_Numeral.int_of (i - k)) in (j, \_. Code_Evaluation.term_of j)))" @@ -110,7 +110,7 @@ text {* Towards type copies and datatypes *} definition collapse :: "('a \ ('a \ 'b \ 'a) \ 'a) \ 'a \ 'b \ 'a" where - "collapse f = (f o\ id)" + "collapse f = (f \\ id)" definition beyond :: "code_numeral \ code_numeral \ code_numeral" where "beyond k l = (if l > k then l else 0)" @@ -139,8 +139,8 @@ code_reserved Quickcheck Quickcheck_Generators -no_notation fcomp (infixl "o>" 60) -no_notation scomp (infixl "o\" 60) +no_notation fcomp (infixl "\>" 60) +no_notation scomp (infixl "\\" 60) subsection {* The Random-Predicate Monad *} diff -r 82e0fe8b07eb -r 89e16802b6cc src/HOL/Random.thy --- a/src/HOL/Random.thy Thu Jul 08 17:23:05 2010 +0200 +++ b/src/HOL/Random.thy Fri Jul 09 08:11:10 2010 +0200 @@ -7,8 +7,8 @@ imports Code_Numeral List begin -notation fcomp (infixl "o>" 60) -notation scomp (infixl "o\" 60) +notation fcomp (infixl "\>" 60) +notation scomp (infixl "\\" 60) subsection {* Auxiliary functions *} @@ -48,12 +48,12 @@ subsection {* Base selectors *} fun iterate :: "code_numeral \ ('b \ 'a \ 'b \ 'a) \ 'b \ 'a \ 'b \ 'a" where - "iterate k f x = (if k = 0 then Pair x else f x o\ iterate (k - 1) f)" + "iterate k f x = (if k = 0 then Pair x else f x \\ iterate (k - 1) f)" definition range :: "code_numeral \ seed \ code_numeral \ seed" where "range k = iterate (log 2147483561 k) - (\l. next o\ (\v. Pair (v + l * 2147483561))) 1 - o\ (\v. Pair (v mod k))" + (\l. next \\ (\v. Pair (v + l * 2147483561))) 1 + \\ (\v. Pair (v mod k))" lemma range: "k > 0 \ fst (range k s) < k" @@ -61,7 +61,7 @@ definition select :: "'a list \ seed \ 'a \ seed" where "select xs = range (Code_Numeral.of_nat (length xs)) - o\ (\k. Pair (nth xs (Code_Numeral.nat_of k)))" + \\ (\k. Pair (nth xs (Code_Numeral.nat_of k)))" lemma select: assumes "xs \ []" @@ -97,7 +97,7 @@ definition select_weight :: "(code_numeral \ 'a) list \ seed \ 'a \ seed" where "select_weight xs = range (listsum (map fst xs)) - o\ (\k. Pair (pick xs k))" + \\ (\k. Pair (pick xs k))" lemma select_weight_member: assumes "0 < listsum (map fst xs)" @@ -184,8 +184,8 @@ iterate range select pick select_weight hide_fact (open) range_def -no_notation fcomp (infixl "o>" 60) -no_notation scomp (infixl "o\" 60) +no_notation fcomp (infixl "\>" 60) +no_notation scomp (infixl "\\" 60) end diff -r 82e0fe8b07eb -r 89e16802b6cc src/HOL/Rat.thy --- a/src/HOL/Rat.thy Thu Jul 08 17:23:05 2010 +0200 +++ b/src/HOL/Rat.thy Fri Jul 09 08:11:10 2010 +0200 @@ -1114,14 +1114,14 @@ valterm_fract :: "int \ (unit \ Code_Evaluation.term) \ int \ (unit \ Code_Evaluation.term) \ rat \ (unit \ Code_Evaluation.term)" where [code_unfold]: "valterm_fract k l = Code_Evaluation.valtermify Fract {\} k {\} l" -notation fcomp (infixl "o>" 60) -notation scomp (infixl "o\" 60) +notation fcomp (infixl "\>" 60) +notation scomp (infixl "\\" 60) instantiation rat :: random begin definition - "Quickcheck.random i = Quickcheck.random i o\ (\num. Random.range i o\ (\denom. Pair ( + "Quickcheck.random i = Quickcheck.random i \\ (\num. Random.range i \\ (\denom. Pair ( let j = Code_Numeral.int_of (denom + 1) in valterm_fract num (j, \u. Code_Evaluation.term_of j))))" @@ -1129,8 +1129,8 @@ end -no_notation fcomp (infixl "o>" 60) -no_notation scomp (infixl "o\" 60) +no_notation fcomp (infixl "\>" 60) +no_notation scomp (infixl "\\" 60) text {* Setup for SML code generator *} diff -r 82e0fe8b07eb -r 89e16802b6cc src/HOL/RealDef.thy --- a/src/HOL/RealDef.thy Thu Jul 08 17:23:05 2010 +0200 +++ b/src/HOL/RealDef.thy Fri Jul 09 08:11:10 2010 +0200 @@ -1743,21 +1743,21 @@ valterm_ratreal :: "rat \ (unit \ Code_Evaluation.term) \ real \ (unit \ Code_Evaluation.term)" where [code_unfold]: "valterm_ratreal k = Code_Evaluation.valtermify Ratreal {\} k" -notation fcomp (infixl "o>" 60) -notation scomp (infixl "o\" 60) +notation fcomp (infixl "\>" 60) +notation scomp (infixl "\\" 60) instantiation real :: random begin definition - "Quickcheck.random i = Quickcheck.random i o\ (\r. Pair (valterm_ratreal r))" + "Quickcheck.random i = Quickcheck.random i \\ (\r. Pair (valterm_ratreal r))" instance .. end -no_notation fcomp (infixl "o>" 60) -no_notation scomp (infixl "o\" 60) +no_notation fcomp (infixl "\>" 60) +no_notation scomp (infixl "\\" 60) text {* Setup for SML code generator *} diff -r 82e0fe8b07eb -r 89e16802b6cc src/HOL/Word/Word.thy --- a/src/HOL/Word/Word.thy Thu Jul 08 17:23:05 2010 +0200 +++ b/src/HOL/Word/Word.thy Fri Jul 09 08:11:10 2010 +0200 @@ -26,14 +26,14 @@ code_datatype word_of_int -notation fcomp (infixl "o>" 60) -notation scomp (infixl "o\" 60) +notation fcomp (infixl "\>" 60) +notation scomp (infixl "\\" 60) instantiation word :: ("{len0, typerep}") random begin definition - "random_word i = Random.range (max i (2 ^ len_of TYPE('a))) o\ (\k. Pair ( + "random_word i = Random.range (max i (2 ^ len_of TYPE('a))) \\ (\k. Pair ( let j = word_of_int (Code_Numeral.int_of k) :: 'a word in (j, \_::unit. Code_Evaluation.term_of j)))" @@ -41,8 +41,8 @@ end -no_notation fcomp (infixl "o>" 60) -no_notation scomp (infixl "o\" 60) +no_notation fcomp (infixl "\>" 60) +no_notation scomp (infixl "\\" 60) subsection {* Type conversions and casting *}