П
Size: a a a
П
G
gо
G
H
gо
AN
gо
gо
p
{- declare the function that expected that first argument applies the rule x > 15 -}
foo: (x: Int) -> Int where x > 15
{- declare proof that if
f x y and f y z then f x z. Proof is a special type that creates new proof in the scope of proofs -}
Transitive: (x: a) -> (y: a) -> (z: a) -> (f: a -> a -> bool) -> Proof (f x z) where f x y && f y z
{- there are no way to proof this by the compiler. Programmer must proof this by himself. If function does not satisfied the theorem, program may have undefined behaviour. -}
proof (>) is Transitive
bar: IO ()
bar = do
x <- readLine
{- check that rule x > 20 applies. Into first branch of if clause will be put proof x > 20 -}
if x > 20 then do
{- compiler cannot proof that if x > 20 then x > 15, but we can do this by applying transitive rule. We already checks that x > 20, compiler can check that 20 > 15 by evaluating this expression, so we can apply transitive rule and put proof that x > 15 into the scope. -}
apply Transitive x 20 15 (>)
{- compiler checks that in the scope available proof that x > 15 -}
foo x
gо
p
p
H
p
p
H
p
gо