2014-07-24 23:29:39 +00:00
|
|
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
-- Author: Leonardo de Moura
|
|
|
|
namespace function
|
|
|
|
|
|
|
|
section
|
|
|
|
parameters {A : Type} {B : Type} {C : Type} {D : Type} {E : Type}
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
abbreviation compose (f : B → C) (g : A → B) : A → C :=
|
|
|
|
λx, f (g x)
|
2014-07-24 23:29:39 +00:00
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
abbreviation id (a : A) : A :=
|
|
|
|
a
|
2014-07-24 23:29:39 +00:00
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
abbreviation on_fun (f : B → B → C) (g : A → B) : A → A → C :=
|
|
|
|
λx y, f (g x) (g y)
|
2014-07-24 23:29:39 +00:00
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
abbreviation combine (f : A → B → C) (op : C → D → E) (g : A → B → D) : A → B → E :=
|
|
|
|
λx y, op (f x y) (g x y)
|
2014-07-24 23:29:39 +00:00
|
|
|
end
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
abbreviation const {A : Type} (B : Type) (a : A) : B → A :=
|
|
|
|
λx, a
|
2014-07-28 04:01:59 +00:00
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
abbreviation dcompose {A : Type} {B : A → Type} {C : Π {x : A}, B x → Type} (f : Π {x : A} (y : B x), C y) (g : Πx, B x) : Πx, C (g x) :=
|
|
|
|
λx, f (g x)
|
2014-07-24 23:29:39 +00:00
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
abbreviation flip {A : Type} {B : Type} {C : A → B → Type} (f : Πx y, C x y) : Πy x, C x y :=
|
|
|
|
λy x, f x y
|
2014-07-24 23:29:39 +00:00
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
abbreviation app {A : Type} {B : A → Type} (f : Πx, B x) (x : A) : B x :=
|
|
|
|
f x
|
2014-07-24 23:29:39 +00:00
|
|
|
|
|
|
|
-- Yet another trick to anotate an expression with a type
|
2014-07-29 02:58:57 +00:00
|
|
|
abbreviation is_typeof (A : Type) (a : A) : A :=
|
|
|
|
a
|
2014-07-24 23:29:39 +00:00
|
|
|
|
|
|
|
precedence `∘`:60
|
|
|
|
precedence `∘'`:60
|
|
|
|
precedence `on`:1
|
|
|
|
precedence `$`:1
|
|
|
|
precedence `-[`:1
|
|
|
|
precedence `]-`:1
|
|
|
|
precedence `⟨`:1
|
|
|
|
|
|
|
|
infixr ∘ := compose
|
|
|
|
infixr ∘' := dcompose
|
|
|
|
infixl on := on_fun
|
|
|
|
notation `typeof` t `:` T := is_typeof T t
|
|
|
|
infixr $ := app
|
|
|
|
notation f `-[` op `]-` g := combine f op g
|
|
|
|
-- Trick for using any binary function as infix operator
|
|
|
|
notation a `⟨` f `⟩` b := f a b
|
|
|
|
|
2014-08-07 23:59:08 +00:00
|
|
|
end function
|