lean2/tests/lean/revapp.lean
Leonardo de Moura 4ba097a141 feat(frontends/lean): use lowercase commands, replace 'endscope' and 'endnamespace' with 'end'
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-05 13:06:36 -08:00

30 lines
781 B
Text

import Int.
definition revapp {A : (Type U)} {B : A -> (Type U)} (a : A) (f : Pi (x : A), B x) : (B a) := f a.
infixl 100 |> : revapp
eval 10 |> (fun x, x + 1)
|> (fun x, x + 2)
|> (fun x, 2 * x)
|> (fun x, 3 - x)
|> (fun x, x + 2)
definition revcomp {A B C: (Type U)} (f : A -> B) (g : B -> C) : A -> C :=
fun x, g (f x)
infixl 100 #> : revcomp
eval (fun x, x + 1) #>
(fun x, 2 * x * x) #>
(fun x, 10 + x)
definition simple := (fun x, x + 1) #>
(fun x, 2 * x * x) #>
(fun x, 10 + x)
check simple
eval simple 10
definition simple2 := (fun x : Int, x + 1) #>
(fun x, 2 * x * x) #>
(fun x, 10 + x)
check simple2
eval simple2 (-10)