module Language.Lean.Decl
( Env(..)
, Decl
, axiom
, constant
, definition
, definitionWith
, theorem
, theoremWith
, declName
, declUnivParams
, declType
, DeclView(..)
, declView
, CertDecl
, check
) where
import Foreign
import Foreign.C
import System.IO.Unsafe (unsafePerformIO)
import Language.Lean.List
import Language.Lean.Internal.Decl
import Language.Lean.Internal.Exception
import Language.Lean.Internal.Exception.Unsafe
import Language.Lean.Internal.Expr
import Language.Lean.Internal.Name
axiom :: Name
-> List Name
-> Expr
-> Decl
axiom nm params tp = tryGetLeanValue $ lean_decl_mk_axiom nm params tp
lean_decl_mk_axiom :: (Name) -> (ListName) -> (Expr) -> (OutDeclPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_mk_axiom a1 a2 a3 a4 a5 =
(withName) a1 $ \a1' ->
(withListName) a2 $ \a2' ->
(withExpr) a3 $ \a3' ->
let {a4' = id a4} in
let {a5' = id a5} in
lean_decl_mk_axiom'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = toBool res} in
return (res')
constant :: Name
-> List Name
-> Expr
-> Decl
constant nm params tp = tryGetLeanValue $ lean_decl_mk_const nm params tp
lean_decl_mk_const :: (Name) -> (ListName) -> (Expr) -> (OutDeclPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_mk_const a1 a2 a3 a4 a5 =
(withName) a1 $ \a1' ->
(withListName) a2 $ \a2' ->
(withExpr) a3 $ \a3' ->
let {a4' = id a4} in
let {a5' = id a5} in
lean_decl_mk_const'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = toBool res} in
return (res')
definition :: Name
-> List Name
-> Expr
-> Expr
-> Word32
-> Bool
-> Decl
definition nm params tp v h o = tryGetLeanValue $ lean_decl_mk_def nm params tp v h o
lean_decl_mk_def :: (Name) -> (ListName) -> (Expr) -> (Expr) -> (Word32) -> (Bool) -> (OutDeclPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_mk_def a1 a2 a3 a4 a5 a6 a7 a8 =
(withName) a1 $ \a1' ->
(withListName) a2 $ \a2' ->
(withExpr) a3 $ \a3' ->
(withExpr) a4 $ \a4' ->
let {a5' = fromIntegral a5} in
let {a6' = fromBool a6} in
let {a7' = id a7} in
let {a8' = id a8} in
lean_decl_mk_def'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
let {res' = toBool res} in
return (res')
definitionWith :: Env
-> Name
-> List Name
-> Expr
-> Expr
-> Bool
-> Decl
definitionWith e nm params tp v o =
tryGetLeanValue $ lean_decl_mk_def_with e nm params tp v o
lean_decl_mk_def_with :: (Env) -> (Name) -> (ListName) -> (Expr) -> (Expr) -> (Bool) -> (OutDeclPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_mk_def_with a1 a2 a3 a4 a5 a6 a7 a8 =
(withEnv) a1 $ \a1' ->
(withName) a2 $ \a2' ->
(withListName) a3 $ \a3' ->
(withExpr) a4 $ \a4' ->
(withExpr) a5 $ \a5' ->
let {a6' = fromBool a6} in
let {a7' = id a7} in
let {a8' = id a8} in
lean_decl_mk_def_with'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
let {res' = toBool res} in
return (res')
theorem :: Name
-> List Name
-> Expr
-> Expr
-> Word32
-> Decl
theorem nm params tp v h = tryGetLeanValue $ lean_decl_mk_thm nm params tp v h
lean_decl_mk_thm :: (Name) -> (ListName) -> (Expr) -> (Expr) -> (Word32) -> (OutDeclPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_mk_thm a1 a2 a3 a4 a5 a6 a7 =
(withName) a1 $ \a1' ->
(withListName) a2 $ \a2' ->
(withExpr) a3 $ \a3' ->
(withExpr) a4 $ \a4' ->
let {a5' = fromIntegral a5} in
let {a6' = id a6} in
let {a7' = id a7} in
lean_decl_mk_thm'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
let {res' = toBool res} in
return (res')
theoremWith :: Env
-> Name
-> List Name
-> Expr
-> Expr
-> Decl
theoremWith e nm params tp v = tryGetLeanValue $ lean_decl_mk_thm_with e nm params tp v
lean_decl_mk_thm_with :: (Env) -> (Name) -> (ListName) -> (Expr) -> (Expr) -> (OutDeclPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_mk_thm_with a1 a2 a3 a4 a5 a6 a7 =
(withEnv) a1 $ \a1' ->
(withName) a2 $ \a2' ->
(withListName) a3 $ \a3' ->
(withExpr) a4 $ \a4' ->
(withExpr) a5 $ \a5' ->
let {a6' = id a6} in
let {a7' = id a7} in
lean_decl_mk_thm_with'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
let {res' = toBool res} in
return (res')
declName :: Decl -> Name
declName d = tryGetLeanValue $ lean_decl_get_name d
lean_decl_get_name :: (Decl) -> (OutNamePtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_get_name a1 a2 a3 =
(withDecl) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_decl_get_name'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
declUnivParams :: Decl -> List Name
declUnivParams d = tryGetLeanValue $ lean_decl_get_univ_params d
lean_decl_get_univ_params :: (Decl) -> (OutListNamePtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_get_univ_params a1 a2 a3 =
(withDecl) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_decl_get_univ_params'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
declType :: Decl -> Expr
declType d = tryGetLeanValue $ lean_decl_get_type d
lean_decl_get_type :: (Decl) -> (OutExprPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_get_type a1 a2 a3 =
(withDecl) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_decl_get_type'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
data DeclView
= Constant
| Axiom
| Definition Expr Word32 Bool
| Theorem Expr Word32
deriving (Eq, Show)
declView :: Decl -> DeclView
declView x =
case lean_decl_get_kind x of
LEAN_DECL_CONST -> Constant
LEAN_DECL_AXIOM -> Axiom
LEAN_DECL_DEF ->
Definition (tryGetLeanValue $ lean_decl_get_value x)
(tryGetLeanValue $ lean_decl_get_height x)
(tryGetLeanValue $ lean_decl_get_conv_opt x)
LEAN_DECL_THM ->
Theorem (tryGetLeanValue $ lean_decl_get_value x)
(tryGetLeanValue $ lean_decl_get_height x)
data DeclKind = LEAN_DECL_CONST
| LEAN_DECL_AXIOM
| LEAN_DECL_DEF
| LEAN_DECL_THM
deriving (Enum,Eq)
lean_decl_get_kind :: (Decl) -> (DeclKind)
lean_decl_get_kind a1 =
unsafePerformIO $
(withDecl) a1 $ \a1' ->
let {res = lean_decl_get_kind'_ a1'} in
let {res' = (toEnum . fromIntegral) res} in
return (res')
lean_decl_get_value :: (Decl) -> (OutExprPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_get_value a1 a2 a3 =
(withDecl) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_decl_get_value'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
lean_decl_get_height :: (Decl) -> (Ptr CUInt) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_get_height a1 a2 a3 =
(withDecl) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_decl_get_height'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
lean_decl_get_conv_opt :: (Decl) -> (Ptr CInt) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_get_conv_opt a1 a2 a3 =
(withDecl) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_decl_get_conv_opt'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
check :: Env -> Decl -> CertDecl
check e d = tryGetLeanValue $ lean_decl_check e d
lean_decl_check :: (Env) -> (Decl) -> (OutCertDeclPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_decl_check a1 a2 a3 a4 =
(withEnv) a1 $ \a1' ->
(withDecl) a2 $ \a2' ->
let {a3' = id a3} in
let {a4' = id a4} in
lean_decl_check'_ a1' a2' a3' a4' >>= \res ->
let {res' = toBool res} in
return (res')
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_mk_axiom"
lean_decl_mk_axiom'_ :: ((NamePtr) -> ((ListNamePtr) -> ((ExprPtr) -> ((OutDeclPtr) -> ((OutExceptionPtr) -> (IO CInt))))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_mk_const"
lean_decl_mk_const'_ :: ((NamePtr) -> ((ListNamePtr) -> ((ExprPtr) -> ((OutDeclPtr) -> ((OutExceptionPtr) -> (IO CInt))))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_mk_def"
lean_decl_mk_def'_ :: ((NamePtr) -> ((ListNamePtr) -> ((ExprPtr) -> ((ExprPtr) -> (CUInt -> (CInt -> ((OutDeclPtr) -> ((OutExceptionPtr) -> (IO CInt)))))))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_mk_def_with"
lean_decl_mk_def_with'_ :: ((EnvPtr) -> ((NamePtr) -> ((ListNamePtr) -> ((ExprPtr) -> ((ExprPtr) -> (CInt -> ((OutDeclPtr) -> ((OutExceptionPtr) -> (IO CInt)))))))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_mk_thm"
lean_decl_mk_thm'_ :: ((NamePtr) -> ((ListNamePtr) -> ((ExprPtr) -> ((ExprPtr) -> (CUInt -> ((OutDeclPtr) -> ((OutExceptionPtr) -> (IO CInt))))))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_mk_thm_with"
lean_decl_mk_thm_with'_ :: ((EnvPtr) -> ((NamePtr) -> ((ListNamePtr) -> ((ExprPtr) -> ((ExprPtr) -> ((OutDeclPtr) -> ((OutExceptionPtr) -> (IO CInt))))))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_get_name"
lean_decl_get_name'_ :: ((DeclPtr) -> ((OutNamePtr) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_get_univ_params"
lean_decl_get_univ_params'_ :: ((DeclPtr) -> ((OutListNamePtr) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_get_type"
lean_decl_get_type'_ :: ((DeclPtr) -> ((OutExprPtr) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_get_kind"
lean_decl_get_kind'_ :: ((DeclPtr) -> CInt)
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_get_value"
lean_decl_get_value'_ :: ((DeclPtr) -> ((OutExprPtr) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_get_height"
lean_decl_get_height'_ :: ((DeclPtr) -> ((Ptr CUInt) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_get_conv_opt"
lean_decl_get_conv_opt'_ :: ((DeclPtr) -> ((Ptr CInt) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall unsafe "Language/Lean/Decl.chs.h lean_decl_check"
lean_decl_check'_ :: ((EnvPtr) -> ((DeclPtr) -> ((OutCertDeclPtr) -> ((OutExceptionPtr) -> (IO CInt)))))