Skip to content
JensGMPublic

About

Refinement types for python

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Typhon

Refinement types for python

Example

from typhon import prove
from typhon.theories.numeric import Real
from typhon.theories.maybe import Maybe, Just, Nothing

@prove
def divide(a : Real, b : Real) -> Real | (lambda v: v == a / b):
    return a / b

divide.prove() # -> CounterExample

@prove
def divide(a : Real, b : Real) -> Maybe[Real] | (
    lambda v: v == (Just(a / b) if b != 0 else Nothing[Real])
):
    if b != 0:
        v = a / b
        return Just(v)
    else:
        return Nothing[Real]

divide.prove() # -> OK

About

Refinement types for python

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages