| Copyright | (c) Levent Erkok |
|---|---|
| License | BSD3 |
| Maintainer | erkokl@gmail.com |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Documentation.SBV.Examples.ADT.Types
Description
An encoding of the simple type-checking via constraints, following https://microsoft.github.io/z3guide/docs/theories/Datatypes/#using-datatypes-for-solving-type-constraints
Synopsis
- data M
- data T
- cv2M :: String -> [CV] -> M
- _undefiner_M :: a
- type SM = SBV M
- sVar :: SBV [Char] -> SBV M
- sLam :: SBV [Char] -> SBV M -> SBV M
- sApp :: SBV M -> SBV M -> SBV M
- isVar :: SBV M -> SBool
- isLam :: SBV M -> SBool
- isApp :: SBV M -> SBool
- getVar_1 :: SBV M -> SBV [Char]
- svar :: SBV M -> SBV [Char]
- getLam_1 :: SBV M -> SBV [Char]
- sbound :: SBV M -> SBV [Char]
- getLam_2 :: SBV M -> SBV M
- sbody :: SBV M -> SBV M
- getApp_1 :: SBV M -> SBV M
- sfn :: SBV M -> SBV M
- getApp_2 :: SBV M -> SBV M
- sarg :: SBV M -> SBV M
- sCaseM :: Mergeable result => SBV M -> (SBV [Char] -> result) -> (SBV [Char] -> SBV M -> result) -> (SBV M -> SBV M -> result) -> result
- cv2T :: String -> [CV] -> T
- _undefiner_T :: a
- type ST = SBV T
- sTInt :: SBV T
- sTStr :: SBV T
- sTArr :: SBV T -> SBV T -> SBV T
- isTInt :: SBV T -> SBool
- isTStr :: SBV T -> SBool
- isTArr :: SBV T -> SBool
- getTArr_1 :: SBV T -> SBV T
- sdom :: SBV T -> SBV T
- getTArr_2 :: SBV T -> SBV T
- srng :: SBV T -> SBV T
- sCaseT :: Mergeable result => SBV T -> result -> result -> (SBV T -> SBV T -> result) -> result
- env :: SString -> ST
- typeOf :: SM -> ST
- tc :: SM -> ST -> SBool
- wellTyped :: SM -> SBool
- idWF :: IO SatResult
- intFuncAppString :: IO SatResult
- selfAppNotWellTyped :: IO SatResult
Documentation
Simple encoding of untyped lambda terms
Instances
Types.
Instances
_undefiner_M :: a Source #
Autogenerated definition to avoid unused-variable warnings from GHC.
sCaseM :: Mergeable result => SBV M -> (SBV [Char] -> result) -> (SBV [Char] -> SBV M -> result) -> (SBV M -> SBV M -> result) -> result Source #
Case analyzer for the type M.
_undefiner_T :: a Source #
Autogenerated definition to avoid unused-variable warnings from GHC.
sCaseT :: Mergeable result => SBV T -> result -> result -> (SBV T -> SBV T -> result) -> result Source #
Case analyzer for the type T.
Instead of modeling environments for mapping variables to their types, we'll simply use an uninterpreted function. Note that this also implies we consider all terms to be given so that variables do not shadow each other; i.e., all variables are unique. This is a simplification, but it is not without justification: One can always alpha-rename bound variables so all bound variables are unique.
wellTyped :: SM -> SBool Source #
Well typedness: If what the typeOf function returns type-checks the term,
then a term is well-typed.
Make sure the identity function can be typed.
>>>idWFSatisfiable. Model: env :: String -> T env _ = TStr typeOf :: M -> T typeOf _ = TArr TStr TStr
The model is rather uninteresting, but it shows that identity can have the type String to String, where all variables are mapped to Strings.
intFuncAppString :: IO SatResult Source #
Check that if we apply a function that takes n integer to a string is not well-typed.
>>>intFuncAppStringUnsatisfiable
As expected, the solver says that there's no way to type-check such an expression.
selfAppNotWellTyped :: IO SatResult Source #
Make sure self-application cannot be typed.
>>>selfAppNotWellTypedUnsatisfiable
We get unsatisfiable, indicating there's no way to come up with an environment that will
successfully assign a type to the term x -> x x.