2016-03-24 10 views
2

が言うにcompositon操作(。)の結合法則を証明するには? それを証明する方法は? と構成操作は、ハスケルのちょうど基本的な操作です、 または私たち自身で1つを得ることができますか?もしそうなら、それを達成する方法?次のように、組成演算子を自分で定義することができはどのように、</p> <pre><code>f :: a -> b g :: b -> c h :: c -> d </code></pre> <p>ハスケル

+0

http://math.stackexchange.com/questions/523906/show-that-function-compositions-are-associative – Amadan

+0

'comp fgx = f(gx)'で '' f''''''は '' 'fg'と同じです。 – Amadan

+1

[(ソース)(https://hackage.haskell.org/package/base-4.8.2.0/docs/src/GHC.Base.html#。)」の横にある[[ソース](https://hackage.haskell.org/package/base-4.8.2.0/docs/src/GHC.Base.html#。) 。] '](https://hackage.haskell.org/package/base-4.8.2.0/docs/Prelude.html#v :.)をご覧ください。 –

答えて

4

(.) :: (b -> c) -> (a -> b) -> a -> c 
g . f = \x -> g (f x) 

を、関連性を証明するために:

lhs = h . (g . f) 
    = \x -> h ((g . f) x)   -- substitution 
    = \x -> h ((\y -> g (f y)) x) -- substitution 
    = \x -> h (g (f x))   -- beta reduction 

rhs = (h . g) . f 
    = \x -> (h . g) (f x)   -- substitution 
    = \x -> (\y -> h (g y)) (f x) -- substitution 
    = \x -> h (g (f x))   -- beta reduction 

、我々はlhs = rhsを持っています。 QED。

+0

ありがとう〜@アディットMシャー – ren

関連する問題

 関連する問題