module Language.Lean.Inductive
(
InductiveType
, inductiveType
, inductiveTypeName
, inductiveTypeType
, inductiveTypeConstructors
, recursorName
, InductiveDecl
, inductiveDecl
, inductiveDeclUnivParams
, inductiveDeclNumParams
, inductiveDeclTypes
, addInductiveDecl
, lookupInductiveDecl
, lookupConstructorInductiveTypeName
, lookupRecursorInductiveTypeName
, lookupInductiveTypeNumIndices
, lookupInductiveTypeNumMinorPremises
, inductiveTypeHasDepElim
) where
import Foreign
import Foreign.C
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.Inductive
import Language.Lean.Internal.Name
inductiveType :: Name
-> Expr
-> List Expr
-> InductiveType
inductiveType n t cs = tryGetLeanValue $ lean_inductive_type_mk n t cs
lean_inductive_type_mk :: (Name) -> (Expr) -> (ListExpr) -> (OutInductiveTypePtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_inductive_type_mk a1 a2 a3 a4 a5 =
(withName) a1 $ \a1' ->
(withExpr) a2 $ \a2' ->
(withListExpr) a3 $ \a3' ->
let {a4' = id a4} in
let {a5' = id a5} in
lean_inductive_type_mk'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = toBool res} in
return (res')
inductiveTypeName :: InductiveType -> Name
inductiveTypeName tp = tryGetLeanValue $ lean_inductive_type_get_name tp
lean_inductive_type_get_name :: (InductiveType) -> (OutNamePtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_inductive_type_get_name a1 a2 a3 =
(withInductiveType) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_inductive_type_get_name'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
inductiveTypeType :: InductiveType -> Expr
inductiveTypeType tp = tryGetLeanValue $ lean_inductive_type_get_type tp
lean_inductive_type_get_type :: (InductiveType) -> (OutExprPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_inductive_type_get_type a1 a2 a3 =
(withInductiveType) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_inductive_type_get_type'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
inductiveTypeConstructors :: InductiveType -> List Expr
inductiveTypeConstructors tp = tryGetLeanValue $ lean_inductive_type_get_constructors tp
lean_inductive_type_get_constructors :: (InductiveType) -> (OutListExprPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_inductive_type_get_constructors a1 a2 a3 =
(withInductiveType) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_inductive_type_get_constructors'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
recursorName :: Name -> Name
recursorName n = tryGetLeanValue $ lean_get_recursor_name n
lean_get_recursor_name :: (Name) -> (OutNamePtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_get_recursor_name a1 a2 a3 =
(withName) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_get_recursor_name'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
inductiveDecl :: List Name
-> Word32
-> List InductiveType
-> InductiveDecl
inductiveDecl ps n types = tryGetLeanValue $ lean_inductive_decl_mk ps n types
lean_inductive_decl_mk :: (ListName) -> (Word32) -> (ListInductiveType) -> (OutInductiveDeclPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_inductive_decl_mk a1 a2 a3 a4 a5 =
(withListName) a1 $ \a1' ->
let {a2' = fromIntegral a2} in
(withListInductiveType) a3 $ \a3' ->
let {a4' = id a4} in
let {a5' = id a5} in
lean_inductive_decl_mk'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = toBool res} in
return (res')
inductiveDeclUnivParams :: InductiveDecl -> List Name
inductiveDeclUnivParams d = tryGetLeanValue $ lean_inductive_decl_get_univ_params d
lean_inductive_decl_get_univ_params :: (InductiveDecl) -> (OutListNamePtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_inductive_decl_get_univ_params a1 a2 a3 =
(withInductiveDecl) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_inductive_decl_get_univ_params'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
inductiveDeclNumParams :: InductiveDecl -> Word32
inductiveDeclNumParams d = tryGetLeanValue $ lean_inductive_decl_get_num_params d
lean_inductive_decl_get_num_params :: (InductiveDecl) -> (Ptr CUInt) -> (OutExceptionPtr) -> IO ((Bool))
lean_inductive_decl_get_num_params a1 a2 a3 =
(withInductiveDecl) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_inductive_decl_get_num_params'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
inductiveDeclTypes :: InductiveDecl -> List InductiveType
inductiveDeclTypes d = tryGetLeanValue $ lean_inductive_decl_get_types d
lean_inductive_decl_get_types :: (InductiveDecl) -> (OutListInductiveTypePtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_inductive_decl_get_types a1 a2 a3 =
(withInductiveDecl) a1 $ \a1' ->
let {a2' = id a2} in
let {a3' = id a3} in
lean_inductive_decl_get_types'_ a1' a2' a3' >>= \res ->
let {res' = toBool res} in
return (res')
addInductiveDecl :: InductiveDecl -> Env -> Env
addInductiveDecl d e = tryGetLeanValue $ lean_env_add_inductive e d
lean_env_add_inductive :: (Env) -> (InductiveDecl) -> (OutEnvPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_env_add_inductive a1 a2 a3 a4 =
(withEnv) a1 $ \a1' ->
(withInductiveDecl) a2 $ \a2' ->
let {a3' = id a3} in
let {a4' = id a4} in
lean_env_add_inductive'_ a1' a2' a3' a4' >>= \res ->
let {res' = toBool res} in
return (res')
lookupInductiveDecl :: Env -> Name -> Maybe InductiveDecl
lookupInductiveDecl e nm = tryGetLeanMaybeValue $ lean_env_is_inductive_type e nm
lean_env_is_inductive_type :: (Env) -> (Name) -> (OutInductiveDeclPtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_env_is_inductive_type a1 a2 a3 a4 =
(withEnv) a1 $ \a1' ->
(withName) a2 $ \a2' ->
let {a3' = id a3} in
let {a4' = id a4} in
lean_env_is_inductive_type'_ a1' a2' a3' a4' >>= \res ->
let {res' = toBool res} in
return (res')
lookupConstructorInductiveTypeName :: Env -> Name -> Maybe Name
lookupConstructorInductiveTypeName e nm =
tryGetLeanMaybeValue $ lean_env_is_constructor e nm
lean_env_is_constructor :: (Env) -> (Name) -> (OutNamePtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_env_is_constructor a1 a2 a3 a4 =
(withEnv) a1 $ \a1' ->
(withName) a2 $ \a2' ->
let {a3' = id a3} in
let {a4' = id a4} in
lean_env_is_constructor'_ a1' a2' a3' a4' >>= \res ->
let {res' = toBool res} in
return (res')
lookupRecursorInductiveTypeName :: Env -> Name -> Maybe Name
lookupRecursorInductiveTypeName e nm = tryGetLeanMaybeValue $ lean_env_is_recursor e nm
lean_env_is_recursor :: (Env) -> (Name) -> (OutNamePtr) -> (OutExceptionPtr) -> IO ((Bool))
lean_env_is_recursor a1 a2 a3 a4 =
(withEnv) a1 $ \a1' ->
(withName) a2 $ \a2' ->
let {a3' = id a3} in
let {a4' = id a4} in
lean_env_is_recursor'_ a1' a2' a3' a4' >>= \res ->
let {res' = toBool res} in
return (res')
lookupInductiveTypeNumIndices :: Env -> Name -> Maybe Word32
lookupInductiveTypeNumIndices e nm =
tryGetLeanMaybeValue $ lean_env_get_inductive_type_num_indices e nm
lean_env_get_inductive_type_num_indices :: (Env) -> (Name) -> (Ptr CUInt) -> (OutExceptionPtr) -> IO ((Bool))
lean_env_get_inductive_type_num_indices a1 a2 a3 a4 =
(withEnv) a1 $ \a1' ->
(withName) a2 $ \a2' ->
let {a3' = id a3} in
let {a4' = id a4} in
lean_env_get_inductive_type_num_indices'_ a1' a2' a3' a4' >>= \res ->
let {res' = toBool res} in
return (res')
lookupInductiveTypeNumMinorPremises :: Env -> Name -> Maybe Word32
lookupInductiveTypeNumMinorPremises e nm =
tryGetLeanMaybeValue $ lean_env_get_inductive_type_num_minor_premises e nm
lean_env_get_inductive_type_num_minor_premises :: (Env) -> (Name) -> (Ptr CUInt) -> (OutExceptionPtr) -> IO ((Bool))
lean_env_get_inductive_type_num_minor_premises a1 a2 a3 a4 =
(withEnv) a1 $ \a1' ->
(withName) a2 $ \a2' ->
let {a3' = id a3} in
let {a4' = id a4} in
lean_env_get_inductive_type_num_minor_premises'_ a1' a2' a3' a4' >>= \res ->
let {res' = toBool res} in
return (res')
inductiveTypeHasDepElim :: Env -> Name -> Bool
inductiveTypeHasDepElim e nm =
tryGetLeanValue $ lean_env_get_inductive_type_has_dep_elim e nm
lean_env_get_inductive_type_has_dep_elim :: (Env) -> (Name) -> (Ptr CInt) -> (OutExceptionPtr) -> IO ((Bool))
lean_env_get_inductive_type_has_dep_elim a1 a2 a3 a4 =
(withEnv) a1 $ \a1' ->
(withName) a2 $ \a2' ->
let {a3' = id a3} in
let {a4' = id a4} in
lean_env_get_inductive_type_has_dep_elim'_ a1' a2' a3' a4' >>= \res ->
let {res' = toBool res} in
return (res')
foreign import ccall unsafe "Language/Lean/Inductive.chs.h lean_inductive_type_mk"
lean_inductive_type_mk'_ :: ((NamePtr) -> ((ExprPtr) -> ((ListExprPtr) -> ((OutInductiveTypePtr) -> ((OutExceptionPtr) -> (IO CInt))))))
foreign import ccall unsafe "Language/Lean/Inductive.chs.h lean_inductive_type_get_name"
lean_inductive_type_get_name'_ :: ((InductiveTypePtr) -> ((OutNamePtr) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall unsafe "Language/Lean/Inductive.chs.h lean_inductive_type_get_type"
lean_inductive_type_get_type'_ :: ((InductiveTypePtr) -> ((OutExprPtr) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall unsafe "Language/Lean/Inductive.chs.h lean_inductive_type_get_constructors"
lean_inductive_type_get_constructors'_ :: ((InductiveTypePtr) -> ((OutListExprPtr) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall unsafe "Language/Lean/Inductive.chs.h lean_get_recursor_name"
lean_get_recursor_name'_ :: ((NamePtr) -> ((OutNamePtr) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall unsafe "Language/Lean/Inductive.chs.h lean_inductive_decl_mk"
lean_inductive_decl_mk'_ :: ((ListNamePtr) -> (CUInt -> ((ListInductiveTypePtr) -> ((OutInductiveDeclPtr) -> ((OutExceptionPtr) -> (IO CInt))))))
foreign import ccall safe "Language/Lean/Inductive.chs.h lean_inductive_decl_get_univ_params"
lean_inductive_decl_get_univ_params'_ :: ((InductiveDeclPtr) -> ((OutListNamePtr) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall safe "Language/Lean/Inductive.chs.h lean_inductive_decl_get_num_params"
lean_inductive_decl_get_num_params'_ :: ((InductiveDeclPtr) -> ((Ptr CUInt) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall safe "Language/Lean/Inductive.chs.h lean_inductive_decl_get_types"
lean_inductive_decl_get_types'_ :: ((InductiveDeclPtr) -> ((OutListInductiveTypePtr) -> ((OutExceptionPtr) -> (IO CInt))))
foreign import ccall safe "Language/Lean/Inductive.chs.h lean_env_add_inductive"
lean_env_add_inductive'_ :: ((EnvPtr) -> ((InductiveDeclPtr) -> ((OutEnvPtr) -> ((OutExceptionPtr) -> (IO CInt)))))
foreign import ccall safe "Language/Lean/Inductive.chs.h lean_env_is_inductive_type"
lean_env_is_inductive_type'_ :: ((EnvPtr) -> ((NamePtr) -> ((OutInductiveDeclPtr) -> ((OutExceptionPtr) -> (IO CInt)))))
foreign import ccall safe "Language/Lean/Inductive.chs.h lean_env_is_constructor"
lean_env_is_constructor'_ :: ((EnvPtr) -> ((NamePtr) -> ((OutNamePtr) -> ((OutExceptionPtr) -> (IO CInt)))))
foreign import ccall safe "Language/Lean/Inductive.chs.h lean_env_is_recursor"
lean_env_is_recursor'_ :: ((EnvPtr) -> ((NamePtr) -> ((OutNamePtr) -> ((OutExceptionPtr) -> (IO CInt)))))
foreign import ccall safe "Language/Lean/Inductive.chs.h lean_env_get_inductive_type_num_indices"
lean_env_get_inductive_type_num_indices'_ :: ((EnvPtr) -> ((NamePtr) -> ((Ptr CUInt) -> ((OutExceptionPtr) -> (IO CInt)))))
foreign import ccall safe "Language/Lean/Inductive.chs.h lean_env_get_inductive_type_num_minor_premises"
lean_env_get_inductive_type_num_minor_premises'_ :: ((EnvPtr) -> ((NamePtr) -> ((Ptr CUInt) -> ((OutExceptionPtr) -> (IO CInt)))))
foreign import ccall safe "Language/Lean/Inductive.chs.h lean_env_get_inductive_type_has_dep_elim"
lean_env_get_inductive_type_has_dep_elim'_ :: ((EnvPtr) -> ((NamePtr) -> ((Ptr CInt) -> ((OutExceptionPtr) -> (IO CInt)))))