diff --git a/language-ats.cabal b/language-ats.cabal
--- a/language-ats.cabal
+++ b/language-ats.cabal
@@ -1,6 +1,6 @@
 cabal-version: 1.18
 name: language-ats
-version: 1.3.0.0
+version: 1.5.0.0
 license: BSD3
 license-file: LICENSE
 copyright: Copyright: (c) 2018 Vanessa McHale
@@ -16,6 +16,8 @@
     test/data/*.dats
     test/data/*.sats
     test/data/*.out
+    test/data/stdlib/*.sats
+    test/data/stdlib/*.out
 extra-doc-files: README.md
 
 source-repository head
diff --git a/src/Language/ATS/Lexer.x b/src/Language/ATS/Lexer.x
--- a/src/Language/ATS/Lexer.x
+++ b/src/Language/ATS/Lexer.x
@@ -83,8 +83,8 @@
 @signature = ":<" @inner_signature_mult ">" | ":"
 @func_type = "->" | "-<" @inner_signature_mult ">"
 
-@at_brace = \@ ($white | @block_comment)* \{
-@at_tuple = \@ ($white | @block_comment)* \(
+@at_brace = \@ (@block_comment)* \{
+@at_tuple = \@ (@block_comment)* \(
 
 @box_tuple = \' ($white | @block_comment)* \(
 @box_record = \' ($white | @block_comment)* \{
diff --git a/src/Language/ATS/Parser.y b/src/Language/ATS/Parser.y
--- a/src/Language/ATS/Parser.y
+++ b/src/Language/ATS/Parser.y
@@ -63,6 +63,7 @@
 %nonassoc mutateEq
 %nonassoc maybeProof
 %nonassoc prfTransform
+%nonassoc raise
 
 %token
     fun { Keyword $$ KwFun }
@@ -253,7 +254,7 @@
 alt(p,q) : p { $1 }
          | q { $1 }
 
-ATS : Declarations { ATS $1 }
+ATS : Declarations { ATS (reverse $1) }
 
 -- | Parse declarations in a list
 Declarations : { [] } 
@@ -290,18 +291,19 @@
      | Existential { Ex $1 Nothing }
      | Universal Type { ForA $1 $2 }
      | Type at StaticExpression { AtExpr $2 $1 $3 }
-     | at Type { AtType $1 $2 }
+     | at lsqbracket Type rsqbracket lsqbracket StaticExpression rsqbracket { ArrayType $1 $3 $6 }
      | atbrace Records rbrace { AnonymousRecord $1 $2 }
-     | openParen TypeIn vbar Type closeParen { ProofType $1 $2 $4 }
+     | openParen TypeIn vbar TypeIn closeParen { ProofType $1 $2 $4 }
      | identifierSpace identifier { Dependent (Unqualified $ to_string $1) [Named (Unqualified $ to_string $2)] }
      | openParen TypeIn closeParen { Tuple $1 (toList $2) }
      | openParen TypeIn closeParen lineComment { Tuple $1 (toList $2) }
      | boxTuple TypeIn closeParen { BoxTuple $1 $2 }
      | boxTuple TypeIn closeParen lineComment { BoxTuple $1 $2 }
      | openParen Type closeParen { ParenType $1 $2 }
-     | openParen TypeIn rbrace {% left $ Expected $3 ")" "}" }
-     | doubleParens { NoneType $1 }
+     | addr { AddrType $1 }
+     | doubleParens { Tuple $1 mempty }
      | Type where IdentifierOr SortArgs eq Type { WhereType $2 $1 $3 $4 $6 }
+     | openParen TypeIn rbrace {% left $ Expected $3 ")" "}" }
      | dollar {% left $ Expected $1 "Type" "$" }
      | identifierSpace identifier openParen {% left $ Expected (token_posn $2) "Static integer expression" (to_string $2) }
      | Type identifierSpace {% left $ Expected (token_posn $2) "," (to_string $2) }
@@ -321,7 +323,7 @@
         | exclamation IdentifierOr colon {% left $ OneOf $3 [",", ")"] ":" }
 
 Arg : TypeArg { $1 }
-    | StaticExpression { Arg (Second (ConcreteType $1)) }
+    | StaticExpression { Arg (Second (ConcreteType $1)) } -- TODO: have some sort of stop showing bound variables that we can use to disambiguate types vs. static expressions?
 
 -- | Parse a literal
 Literal : uintLit { UintLit $1 }
@@ -352,6 +354,7 @@
         | at Pattern { AtPattern $1 $2 }
         | identifier Universals Pattern { UniversalPattern (token_posn $1) (to_string $1) $2 $3 }
         | identifierSpace Universals Pattern { UniversalPattern (token_posn $1) (to_string $1) $2 $3 }
+        | Pattern customOperator Pattern { BinPattern (token_posn $2) (SpecialInfix (token_posn $2) (to_string $2)) $1 $3 }
         | Pattern as Pattern { As $2 $1 $3 }
         | Existential Pattern { ExistentialPattern $1 $2 }
         | minus {% left $ Expected $1 "Pattern" "-" }
@@ -441,6 +444,8 @@
 StaticExpression : Name { StaticVal $1 }
                  | StaticExpression BinOp StaticExpression { StaticBinary $2 $1 $3 }
                  | intLit { StaticInt $1 }
+                 | hexLit { StaticHex $1 }
+                 | string { SString $1 }
                  | doubleParens { StaticVoid $1 }
                  | sif StaticExpression then StaticExpression else StaticExpression { Sif $2 $4 $6 }
                  | identifierSpace { StaticVal (Unqualified $ to_string $1) }
@@ -450,9 +455,11 @@
                  | StaticExpression semicolon StaticExpression { SPrecede $1 $3 }
                  | UnOp StaticExpression { SUnary $1 $2 }
                  | identifierSpace doubleParens { SCall (Unqualified $ to_string $1) [] }
+                 | identifier doubleParens { SCall (Unqualified $ to_string $1) [] }
                  | let StaticDecls comment_after(in) end { SLet $1 $2 Nothing }
                  | let StaticDecls in StaticExpression end { SLet $1 $2 (Just $4) }
                  | openParen StaticExpression closeParen { $2 }
+                 | openParen lineComment StaticExpression closeParen { $3 }
                  | case StaticExpression of StaticCase { SCase $1 $2 $4 }
 
 -- | Parse an expression that can be called without parentheses
@@ -556,8 +563,8 @@
 
 Implicits : lspecial TypeIn rbracket { [toList $2] }
           | Implicits lspecial TypeIn rbracket { toList $3 : $1 }
-          | doubleBrackets { [[Named (Unqualified "")]] }
-          | Implicits doubleBrackets { [Named (Unqualified "")] : $1 }
+          | doubleBrackets { [[]] }
+          | Implicits doubleBrackets { [] : $1 }
           | lbracket TypeIn rbracket { [toList $2] }
           | Implicits lspecial TypeIn rbracket { toList $3 : $1 }
           
@@ -594,13 +601,13 @@
      | dollar {% left $ Expected $1 "Name" "$" }
 
 -- | Parse a list of values in a record
-RecordVal : IdentifierOr eq Expression { [($1, $3)] }
-          | RecordVal comma IdentifierOr eq Expression { ($3, $5) : $1 }
+RecordVal : IdentifierOr eq Expression { ($1, $3) :| [] }
+          | RecordVal comma IdentifierOr eq Expression { ($3, $5) :| toList $1 }
           | IdentifierOr eq comma {% left $ Expected $3 "Expression" "," }
 
 -- | Parse a list of types in a record
-Records : IdentifierOr eq Type { [($1, $3)] }
-        | Records comma IdentifierOr eq Type { ($3, $5) : $1 }
+Records : IdentifierOr eq Type { ($1, $3) :| [] }
+        | Records comma IdentifierOr eq Type { ($3, $5) :| toList $1 }
 
 IdentifiersIn : comma_sep(IdentifierOr) { toList $1 }
 
@@ -615,11 +622,11 @@
         | vbar Universals IdentifierOr openParen StaticExpressionsIn closeParen OfType { Leaf $2 $3 $5 $7 } -- FIXME could also be e.g. '0' (static expression)
 
 -- | Parse all constructors of a sum type
-Leaves : SumLeaf { [$1] }
-       | Leaves SumLeaf { $2 : $1 }
-       | Universals identifierSpace of Type { [Leaf $1 (to_string $2) [] (Just $4)] }
-       | Universals identifier { [Leaf $1 (to_string $2) [] Nothing] }
-       | Universals identifier openParen StaticExpressionsIn closeParen OfType { [Leaf $1 (to_string $2) $4 $6] }
+Leaves : SumLeaf { $1 :| [] }
+       | Leaves SumLeaf { $2 :| toList $1 }
+       | Universals identifierSpace of Type { Leaf $1 (to_string $2) [] (Just $4) :| [] }
+       | Universals identifier { Leaf $1 (to_string $2) [] Nothing :| [] }
+       | Universals identifier openParen StaticExpressionsIn closeParen OfType { Leaf $1 (to_string $2) $4 $6 :| [] }
        | dollar {% left $ Expected $1 "|" "$" }
 
 PreUniversals : { [] }
@@ -701,7 +708,7 @@
         | { Nothing }
 
 -- | Parse a type signature and optional function body
-PreFunction : FunName openParen Args closeParen OptType OptExpression { (PreF $1 (fmap fst $5) [] [] (Just $3) (fmap snd $5) Nothing $6) }
+PreFunction : FunName openParen Args closeParen OptType OptExpression { PreF $1 (fmap fst $5) [] [] (Just $3) (fmap snd $5) Nothing $6 }
             | FunName Universals OptTermetric OptType OptExpression { PreF $1 (fmap fst $4) [] $2 Nothing (fmap snd $4) $3 $5 }
             | FunName Universals OptTermetric doubleParens OptType OptExpression { PreF $1 (fmap fst $5) [] $2 (Just []) (fmap snd $5) $3 $6 }
             | FunName Universals OptTermetric openParen Args closeParen OptType OptExpression { PreF $1 (fmap fst $7) [] $2 (Just $5) (fmap snd $7) $3 $8 }
@@ -720,13 +727,15 @@
         | sortdef IdentifierOr eq Sort { SortDef $1 $2 (Left $4) }
         | sortdef IdentifierOr eq Universal { SortDef $1 $2 (Right $4) }
 
-StaticDef : eq Type { Right $2 }
+StaticDef : eq Type { Right (Nothing, $2) }
           | eq StaticExpression MaybeAnnot { Left ($2, $3) }
+          | colon Type eq StaticExpression { Right (Just $2, ConcreteType $4) } -- FIXME wrong wrong bad!!
 
 MaybeAnnot : colon Sort { Just $2 }
            | { Nothing }
 
 AndStadef : stadef IdentifierOr SortArgs StaticDef { Stadef $2 $3 $4 }
+          | stadef IdentifierOr lineComment SortArgs StaticDef { Stadef $2 $4 $5 }
           | stadef Operator SortArgs StaticDef { Stadef $2 $3 $4 }
           | AndStadef and IdentifierOr SortArgs StaticDef { AndD $1 (Stadef $3 $4 $5) }
           | AndStadef and Operator SortArgs StaticDef { AndD $1 (Stadef $3 $4 $5) }
@@ -871,8 +880,8 @@
              | vbar Universals Sort of Sort { DataSortLeaf $2 $3 (Just $5) }
              | DataSortLeaf Comment { $1 }
 
-DataSortLeaves : DataSortLeaf { [$1] }
-               | DataSortLeaves DataSortLeaf { $2 : $1 }
+DataSortLeaves : DataSortLeaf { $1 :| [] }
+               | DataSortLeaves DataSortLeaf { $2 :| toList $1 }
 
 CommentContents : commentContents { Comment $1 }
                 | CommentContents commentContents { over comment (<> $2) $1 }
@@ -889,6 +898,10 @@
 Load : staload { (True, $1) }
      | dynload { (False, $1) }
 
+MacroArgs : doubleParens { Just [] }
+          | openParen IdentifiersIn closeParen { Just $2 }
+          | { Nothing }
+
 -- | Parse a declaration
 Declaration : include string { Include $2 }
             | define { Define $1 }
@@ -898,10 +911,8 @@
             | define identifierSpace intLit { Define ($1 ++ " " ++ to_string $2 ++ " " ++ show $3) }
             | cblock { CBlock $1 }
             | datasort identifierSpace eq DataSortLeaves { DataSort $1 (to_string $2) $4 }
-            | macdef IdentifierOr doubleParens eq Expression { MacDecl $1 $2 [] $5 }
-            | macdef customOperator doubleParens eq Expression { MacDecl $1 (to_string $2) [] $5 }
-            | macdef IdentifierOr openParen IdentifiersIn closeParen eq Expression { MacDecl $1 $2 $4 $7 }
-            | macdef customOperator openParen IdentifiersIn closeParen eq Expression { MacDecl $1 (to_string $2) $4 $7 }
+            | macdef IdentifierOr MacroArgs eq Expression { MacDecl $1 $2 $3 $5 }
+            | macdef customOperator MacroArgs eq Expression { MacDecl $1 (to_string $2) $3 $5 }
             | lineComment { Comment (to_string $1) }
             | Comment { $1 }
             | Load underscore eq string { Load (fst $1) (get_staload $ snd $1) (Just "_") $4 }
diff --git a/src/Language/ATS/PrettyPrint.hs b/src/Language/ATS/PrettyPrint.hs
--- a/src/Language/ATS/PrettyPrint.hs
+++ b/src/Language/ATS/PrettyPrint.hs
@@ -14,7 +14,7 @@
 
 import           Control.Composition          hiding ((&))
 import           Data.Bool                    (bool)
-import           Data.Foldable                (toList)
+import           Data.Foldable                (fold, toList)
 import           Data.Functor.Foldable        (cata)
 import           Data.List                    (isPrefixOf)
 import           Data.List.NonEmpty           (NonEmpty (..))
@@ -177,9 +177,9 @@
         a (BoxTupleExF _ es)           = "'(" <> mconcat (punctuate ", " (toList $ NE.reverse es)) <> ")"
         a (WhileF _ e e')              = "while" <> parens e <> e'
         a (ForF _ e e')                = "for" <> parens e <> e'
-        a (WhileStarF _ us t as e e' Nothing)   = "while*" <> prettyUsNil us <> prettyTermetric (Just t) <> prettyArgs as <+> "=>" <$> indent 4 e <$> indent 4 e'
-        a (WhileStarF _ us t as e e' (Just ty)) = "while*" <> prettyUsNil us <> prettyTermetric (Just t) <> prettyArgs as <+> ":" <+> prettyArgs ty <+> "=>" <$> indent 4 e <$> indent 4 e'
-        a (ForStarF _ us t as e e')    = "for*" <> prettyUsNil us <> prettyTermetric (Just t) <> prettyArgs as <+> "=>" <$> indent 4 e <$> indent 4 e'
+        a (WhileStarF _ us t as e e' Nothing)   = "while*" <> prettyUsStarNil us <> prettyTermetric t <> prettyArgs as <+> "=>" <$> indent 4 e <$> indent 4 e'
+        a (WhileStarF _ us t as e e' (Just ty)) = "while*" <> prettyUsStarNil us <> prettyTermetric t <> prettyArgs as <+> ":" <+> prettyArgs ty <+> "=>" <$> indent 4 e <$> indent 4 e'
+        a (ForStarF _ us t as e e')    = "for*" <> prettyUsStarNil us <> prettyTermetric t <> prettyArgs as <+> "=>" <$> indent 4 e <$> indent 4 e'
         a (ActionsF (ATS [d]))         = "{" <+> pretty d <+> "}"
         a (ActionsF as)                = "{" <$> indent 2 (pretty as) <$> "}"
         a UnderscoreLitF{}             = "_"
@@ -195,7 +195,7 @@
         a (MacroVarF _ s) = ",(" <> text s <> ")"
         a BinListF{} = undefined -- Shouldn't happen
 
-        prettyImplicits = mconcat . fmap (prettyArgsU "<" ">") . reverse
+        prettyImplicits = fold . fmap (prettyArgsU "<" ">") . reverse
 
         prettyIfCase []              = mempty
         prettyIfCase [(s, l, t)]     = "|" <+> s <+> pretty l <+> t
@@ -229,6 +229,7 @@
         a (UniversalPatternF _ n us p) = text n <> prettyArgsU "" "" us <> p
         a (ExistentialPatternF e p)    = pretty e <> p
         a (AsF _ p p')                 = p <+> "as" <+> p'
+        a (BinPatternF _ op p p')      = p <+> pretty op <+> p'
 
 argHelper :: Eq a => (Doc -> Doc -> Doc) -> Arg a -> Doc
 argHelper _ (Arg (First s))   = pretty s
@@ -260,6 +261,7 @@
             | squish op = se <> pretty op <> se'
             | otherwise = se <+> pretty op <+> se'
         a (StaticIntF i)            = pretty i
+        a (StaticHexF h)            = text h
         a StaticVoidF{}             = "()"
         a (SifF e e' e'')           = "sif" <+> e <+> "then" <$> indent 2 e' <$> "else" <$> indent 2 e''
         a (SCallF n cs)             = pretty n <> parens (mconcat (punctuate "," . fmap pretty $ cs))
@@ -269,6 +271,7 @@
             ("let" <$> indent 2 (pretty e) <$> endLet e')
             ("let" <+> pretty e <$> endLet e')
         a (SCaseF ad e sls) = "case" <> pretty ad <+> e <+> "of" <$> indent 2 (prettyCases sls)
+        a (SStringF s)      = text s
 
 instance Eq a => Pretty (Sort a) where
     pretty = cata a where
@@ -298,9 +301,9 @@
         a (FromVTF t)                      = t <> "?!"
         a (MaybeValF t)                    = t <> "?"
         a (AtExprF _ t t')                 = t <+> "@" <+> pretty t'
-        a (AtTypeF _ t)                    = "@" <> t
-        a (ProofTypeF _ t t')              = parens (pre' `op` "|" <+> t')
-            where pre' = prettyArgsG mempty mempty (toList t)
+        a (ArrayTypeF _ t n)               = "@[" <> t <> "][" <> pretty n <> "]"
+        a (ProofTypeF _ t t')              = parens (pre' `op` "|" <+> prettyArgsG mempty mempty t')
+            where pre' = prettyArgsG mempty mempty t
                   op = bool (<+>) (<>) ('\n' `elem` showFast pre')
         a (ConcreteTypeF e)                = pretty e
         a (TupleF _ ts)                    = parens (mconcat (punctuate ", " (fmap pretty (reverse ts))))
@@ -308,11 +311,11 @@
         a (RefTypeF t)                     = "&" <> t
         a (FunctionTypeF s t t')           = t <+> string s <+> t'
         a (ViewLiteralF c)                 = "view" <> pretty c
-        a NoneTypeF{}                      = "()"
         a ImplicitTypeF{}                  = ".."
         a (AnonymousRecordF _ rs)          = prettyRecord rs
         a (ParenTypeF _ t)                 = parens t
         a (WhereTypeF _ t i sa t')         = t <#> indent 2 ("where" </> pretty i <+> prettySortArgs sa <+> "=" <+> pretty t')
+        a AddrTypeF{}                      = "addr"
 
 gan :: Eq a => Maybe (Sort a) -> Doc
 gan (Just t) = " : " <> pretty t <> " "
@@ -337,7 +340,7 @@
     pretty (Universal bs ty es) = lbrace <+> mconcat (punctuate ", " (fmap pretty bs)) <> gan ty <> "|" <+> mconcat (punctuate "; " (fmap pretty es)) <+> rbrace
 
 instance Eq a => Pretty (ATS a) where
-    pretty (ATS xs) = concatSame (reverse xs)
+    pretty (ATS xs) = concatSame xs
 
 prettyOr :: (Pretty a, Eq a) => [[a]] -> Doc
 prettyOr [] = mempty
@@ -405,10 +408,10 @@
 showFast :: Doc -> String
 showFast d = displayS (renderCompact d) mempty
 
-prettyRecord :: (Pretty a) => [(String, a)] -> Doc
+prettyRecord :: (Pretty a) => NonEmpty (String, a) -> Doc
 prettyRecord es
-    | any ((>40) . length . showFast . pretty) es = prettyRecordF True es
-    | otherwise                                   = lineAlt (prettyRecordF True es) (prettyRecordS True es)
+    | any ((>40) . length . showFast . pretty) es = prettyRecordF True (toList es)
+    | otherwise                                   = lineAlt (prettyRecordF True (toList es)) (prettyRecordS True (toList es))
 
 prettyRecordS :: (Pretty a) => Bool -> [(String, a)] -> Doc
 prettyRecordS _ []             = mempty
@@ -428,6 +431,10 @@
 prettyUsNil [] = space
 prettyUsNil us = space <> foldMap pretty us <> space
 
+prettyUsStarNil :: Eq a => [Universal a] -> Doc
+prettyUsStarNil [] = space
+prettyUsStarNil us = space <> foldMap pretty us
+
 prettyOf :: (Pretty a) => Maybe a -> Doc
 prettyOf Nothing  = mempty
 prettyOf (Just x) = space <> "of" <+> pretty x
@@ -470,32 +477,30 @@
 prettyBody c1 c2 [d] = c1 <> d <> c2
 prettyBody c1 c2 ds  = (c1 <>) . align . indent (-1) . cat . (<> pure c2) $ ds
 
-prettyArgsG' :: Doc -> Doc -> Doc -> [Doc] -> Doc
-prettyArgsG' c3 c1 c2 = prettyBody c1 c2 . prettyHelper c3 . reverse
-
-prettyArgsList :: Doc -> Doc -> Doc -> [Doc] -> Doc
-prettyArgsList c3 c1 c2 = prettyBody c1 c2 . va . prettyHelper c3
+prettyArgsG' :: Foldable t => Doc -> Doc -> Doc -> t Doc -> Doc
+prettyArgsG' c3 c1 c2 = prettyBody c1 c2 . prettyHelper c3 . reverse . toList
 
-va :: [Doc] -> [Doc]
-va = (& _tail.traverse %~ group)
+prettyArgsList :: Foldable t => Doc -> Doc -> Doc -> t Doc -> Doc
+prettyArgsList c3 c1 c2 = prettyBody c1 c2 . va . prettyHelper c3 . toList
+    where va = (& _tail.traverse %~ group)
 
-prettyArgsG :: Doc -> Doc -> [Doc] -> Doc
+prettyArgsG :: Foldable t => Doc -> Doc -> t Doc -> Doc
 prettyArgsG = prettyArgsG' ", "
 
-prettyArgsU :: (Pretty a) => Doc -> Doc -> [a] -> Doc
+prettyArgsU :: (Pretty a, Foldable f, Functor f) => Doc -> Doc -> f a -> Doc
 prettyArgsU = prettyArgs' ","
 
-prettyArgs' :: (Pretty a) => Doc -> Doc -> Doc -> [a] -> Doc
+prettyArgs' :: (Pretty a, Functor f, Foldable f) => Doc -> Doc -> Doc -> f a -> Doc
 prettyArgs' = fmap pretty -.*** prettyArgsG'
 
-prettyArgs :: (Pretty a) => [a] -> Doc
+prettyArgs :: (Pretty a, Foldable f, Functor f) => f a -> Doc
 prettyArgs = prettyArgs' ", " "(" ")"
 
 prettyArgsNil :: Eq a => Maybe [Arg a] -> Doc
 prettyArgsNil Nothing   = mempty
 prettyArgsNil (Just as) = prettyArgs' ", " "(" ")" as
 
-fancyU :: Eq a => [Universal a] -> Doc
+fancyU :: Pretty a => [a] -> Doc
 fancyU = foldMap pretty
 
 (<#>) :: Doc -> Doc -> Doc
@@ -512,25 +517,23 @@
 prettySig :: (Pretty a) => Maybe String -> Maybe a -> Doc
 prettySig = prettySigG space space
 
-prettyTermetric :: Pretty a => Maybe a -> Doc
-prettyTermetric (Just t) = softline <> ".<" <> pretty t <> ">." <> softline
-prettyTermetric Nothing  = mempty
+prettyTermetric :: Pretty a => a -> Doc
+prettyTermetric t = softline <> ".<" <> pretty t <> ">." <> softline
 
+prettyMTermetric :: Pretty a => Maybe a -> Doc
+prettyMTermetric = maybe mempty prettyTermetric
+
 -- FIXME figure out a nicer algorithm for when/how to split lines.
 instance Eq a => Pretty (PreFunction a) where
     pretty (PreF i si [] [] as rt Nothing (Just e)) = pretty i <> prettyArgsNil as <> prettySig si rt <> "=" <$> indent 2 (pretty e)
-    pretty (PreF i si [] us as rt t (Just e)) = pretty i </> fancyU us <> prettyTermetric t <> prettyArgsNil as <> prettySig si rt <> "=" <$> indent 2 (pretty e)
+    pretty (PreF i si [] us as rt t (Just e)) = pretty i </> fancyU us <> prettyMTermetric t <> prettyArgsNil as <> prettySig si rt <> "=" <$> indent 2 (pretty e)
     pretty (PreF i si pus [] as rt Nothing (Just e)) = fancyU pus </> pretty i <> prettyArgsNil as <> prettySig si rt <> "=" <$> indent 2 (pretty e)
-    pretty (PreF i si pus us as rt t (Just e)) = fancyU pus </> pretty i </> fancyU us <> prettyTermetric t <> prettyArgsNil as <> prettySig si rt <> "=" <$> indent 2 (pretty e)
+    pretty (PreF i si pus us as rt t (Just e)) = fancyU pus </> pretty i </> fancyU us <> prettyMTermetric t <> prettyArgsNil as <> prettySig si rt <> "=" <$> indent 2 (pretty e)
     pretty (PreF i si [] [] as rt Nothing Nothing) = pretty i <> prettyArgsNil as <> prettySigNull si rt
     pretty (PreF i si [] us Nothing rt Nothing Nothing) = pretty i </> fancyU us <> prettySigNull si rt
     pretty (PreF i si [] us as rt Nothing Nothing) = pretty i </> fancyU us </> prettyArgsNil as <> prettySigNull si rt
-    pretty (PreF i si pus [] as rt t Nothing) = fancyU pus </> pretty i <> prettyTermetric t </> prettyArgsNil as <> prettySigNull si rt
-    pretty (PreF i si pus us as rt t Nothing) = fancyU pus </> pretty i <> prettyTermetric t </> fancyU us </> prettyArgsNil as <> prettySigNull si rt
-
-instance Eq a => Pretty (DataPropLeaf a) where
-    pretty (DataPropLeaf us e Nothing)   = "|" <+> foldMap pretty (reverse us) <+> pretty e
-    pretty (DataPropLeaf us e (Just e')) = "|" <+> foldMap pretty (reverse us) <+> pretty e <+> "of" <+> pretty e'
+    pretty (PreF i si pus [] as rt t Nothing) = fancyU pus </> pretty i <> prettyMTermetric t </> prettyArgsNil as <> prettySigNull si rt
+    pretty (PreF i si pus us as rt t Nothing) = fancyU pus </> pretty i <> prettyMTermetric t </> fancyU us </> prettyArgsNil as <> prettySigNull si rt
 
 prettyFix :: (Pretty a) => Either a String -> Doc
 prettyFix (Left i)  = pretty i
@@ -551,8 +554,7 @@
 valSig = prettySigG mempty mempty (Just mempty)
 
 prettySortArgs :: (Pretty a) => Maybe [a] -> Doc
-prettySortArgs Nothing   = mempty
-prettySortArgs (Just as) = prettyArgs' ", " "(" ")" as
+prettySortArgs = maybe mempty (prettyArgs' ", " "(" ")")
 
 maybeT :: Pretty a => Maybe a -> Doc
 maybeT (Just x) = ":" <+> pretty x
@@ -563,10 +565,10 @@
     pretty (AbsType _ s as t)               = "abstype" <+> text s <> prettySortArgs as <> prettyMaybeType t
     pretty (AbsViewType _ s as Nothing)     = "absvtype" <+> text s <> prettySortArgs as
     pretty (AbsViewType _ s as (Just t))    = "absvtype" <+> text s <> prettySortArgs as <+> "=" <+> pretty t
-    pretty (SumViewType s as ls)            = "datavtype" <+> text s <> prettySortArgs as <+> "=" <$> prettyLeaf ls
-    pretty (DataView _ s as ls)             = "dataview" <+> text s <> prettySortArgs as <+> "=" <$> prettyLeaf ls
-    pretty (SumType s as ls)                = "datatype" <+> text s <> prettySortArgs as <+> "=" <$> prettyLeaf ls
-    pretty (DataSort _ s ls)                = "datasort" <+> text s <+> "=" <$> prettyDSL ls
+    pretty (SumViewType s as ls)            = "datavtype" <+> text s <> prettySortArgs as <+> "=" <$> prettyLeaf (toList ls)
+    pretty (DataView _ s as ls)             = "dataview" <+> text s <> prettySortArgs as <+> "=" <$> prettyLeaf (toList ls)
+    pretty (SumType s as ls)                = "datatype" <+> text s <> prettySortArgs as <+> "=" <$> prettyLeaf (toList ls)
+    pretty (DataSort _ s ls)                = "datasort" <+> text s <+> "=" <$> prettyDSL (toList ls)
     pretty (Impl as i)                      = "implement" <+> prettyArgsNil as <> pretty i
     pretty (ProofImpl as i)                 = "primplmnt" <+> prettyArgsNil as <> pretty i
     pretty (PrVal p (Just e) Nothing)       = "prval" <+> pretty p <+> "=" <+> pretty e
@@ -582,7 +584,7 @@
     pretty (Var t p Nothing (Just e))       = "var" <+> pretty p <> valSig t <+> "with" <+> pretty e
     pretty (Var t p (Just e) Nothing)       = "var" <+> pretty p <> valSig t <+> "=" <+> pretty e
     pretty (Var t p Nothing Nothing)        = "var" <+> pretty p <> valSig t
-    pretty (Var _ _ _ Just{})               = undefined
+    pretty (Var _ _ _ Just{})               = undefined -- TODO figure out what this is supposed to be
     pretty (Include s)                      = "#include" <+> pretty s
     pretty (Load sta b Nothing s)           = bool "" "#" b <> bool "dyn" "sta" sta <> "load" <+> pretty s
     pretty (Load sta b (Just q) s)          = bool "" "#" b <> bool "dyn" "sta" sta <> "load" <+> pretty q <+> "=" <+> pretty s
@@ -616,13 +618,15 @@
     pretty (Stacst _ n t (Just e))          = "stacst" </> pretty n <+> ":" </> pretty t <+> "=" </> pretty e
     pretty (PropDef _ s as@Just{} t)        = "propdef" </> text s <+> prettyArgsNil as <+> "=" </> pretty t
     pretty (PropDef _ s Nothing t)          = "propdef" </> text s <+> "=" </> pretty t
-    pretty (Local _ (ATS ds) (ATS []))      = "local" <$> indent 2 (pretty (ATS $ reverse ds)) <$> "in end"
+    pretty (Local _ (ATS ds) (ATS []))      = "local" <$> indent 2 (pretty (ATS ds)) <$> "in end"
     pretty (Local _ d d')                   = "local" <$> indent 2 (pretty d) <$> "in" <$> indent 2 (pretty d') <$> "end"
     pretty (FixityDecl f ss)                = pretty f <+> hsep (fmap text ss)
     pretty (StaVal us i t)                  = "val" </> mconcat (fmap pretty us) <+> text i <+> ":" <+> pretty t
-    pretty (Stadef i as (Right t))          = "stadef" <+> text i <+> prettySortArgs as <+> "=" <+> pretty t
+    pretty (Stadef i as (Right (Nothing, t))) = "stadef" <+> text i <+> prettySortArgs as <+> "=" <+> pretty t
+    pretty (Stadef i as (Right (Just ty, t))) = "stadef" <+> text i <+> prettySortArgs as <+> ":" <+> pretty ty <+> "=" <+> pretty t
     pretty (Stadef i as (Left (se, mt)))    = "stadef" <+> text i <+> prettySortArgs as <+> "=" <+> pretty se <> maybeT mt
-    pretty (AndD d (Stadef i as (Right t))) = pretty d <+> "and" <+> text i <+> prettySortArgs as <+> "=" <+> pretty t
+    pretty (AndD d (Stadef i as (Right (Nothing, t)))) = pretty d <+> "and" <+> text i <+> prettySortArgs as <+> "=" <+> pretty t
+    pretty (AndD d (Stadef i as (Right (Just ty, t)))) = pretty d <+> "and" <+> text i <+> prettySortArgs as <+> ":" <+> pretty ty <+> "=" <+> pretty t
     pretty (AndD d (Stadef i as (Left (se, mt)))) = pretty d <+> "and" <+> text i <+> prettySortArgs as <+> "=" <+> pretty se <> maybeT mt
     pretty (AbsView _ i as t)               = "absview" <+> text i <> prettySortArgs as <> prettyMaybeType t
     pretty (AbsVT0p _ i as t)               = "absvt@ype" <+> text i <> prettySortArgs as <> prettyMaybeType t
@@ -632,7 +636,8 @@
     pretty (TKind _ n s)                    = pretty n <+> "=" <+> text s
     pretty (SortDef _ s t)                  = "sortdef" <+> text s <+> "=" <+> either pretty pretty t
     pretty (AndD d (SortDef _ i t))         = pretty d <+> "and" <+> text i <+> "=" <+> either pretty pretty t
-    pretty (MacDecl _ n is e)               = "macdef" <+> text n <> "(" <> mconcat (punctuate ", " (fmap text is)) <> ") =" <+> pretty e
+    pretty (MacDecl _ n (Just is) e)        = "macdef" <+> text n <> "(" <> mconcat (punctuate ", " (fmap text is)) <> ") =" <+> pretty e
+    pretty (MacDecl _ n Nothing e)          = "macdef" <+> text n <+> "=" <+> pretty e
     pretty (ExtVar _ s e)                   = "extvar" <+> text s <+> "=" <+> pretty e
     pretty (AbsImpl _ n as e)               = "absimpl" </> pretty n <> prettySortArgs as <+> "=" </> pretty e
     pretty AndD{}                           = undefined -- probably not valid syntax if we get to this point
diff --git a/src/Language/ATS/Types.hs b/src/Language/ATS/Types.hs
--- a/src/Language/ATS/Types.hs
+++ b/src/Language/ATS/Types.hs
@@ -90,12 +90,12 @@
                    | AndDecl { andT :: Maybe (Type a), andPat :: Pattern a, _andExpr :: Expression a }
                    | Include String
                    | Load { static :: Bool, withOctothorpe :: Bool, qualName :: Maybe String, fileName :: String }
-                   | Stadef String (SortArgs a) (Either (StaticExpression a, Maybe (Sort a)) (Type a))
+                   | Stadef String (SortArgs a) (Either (StaticExpression a, Maybe (Sort a)) (Maybe (Type a), Type a))
                    | CBlock String
                    | TypeDef a String (SortArgs a) (Type a) (Maybe (Sort a))
                    | ViewTypeDef a String (SortArgs a) (Type a)
-                   | SumType { typeName :: String, typeArgs :: SortArgs a, _leaves :: [Leaf a] }
-                   | SumViewType { typeName :: String, typeArgs :: SortArgs a, _leaves :: [Leaf a] }
+                   | SumType { typeName :: String, typeArgs :: SortArgs a, _leaves :: NonEmpty (Leaf a) }
+                   | SumViewType { typeName :: String, typeArgs :: SortArgs a, _leaves :: NonEmpty (Leaf a) }
                    | AbsType a String (SortArgs a) (Maybe (Type a))
                    | AbsViewType a String (SortArgs a) (Maybe (Type a))
                    | AbsView a String (SortArgs a) (Maybe (Type a))
@@ -106,7 +106,7 @@
                    | OverloadIdent a String (Name a) (Maybe Int)
                    | Comment { _comment :: String }
                    | DataProp { pos :: a, propName :: String, propArgs :: SortArgs a, _propLeaves :: [DataPropLeaf a] }
-                   | DataView a String (SortArgs a) [Leaf a]
+                   | DataView a String (SortArgs a) (NonEmpty (Leaf a))
                    | Extern a (Declaration a)
                    | Define String
                    | SortDef a String (Either (Sort a) (Universal a))
@@ -119,8 +119,8 @@
                    | Stacst a (Name a) (Type a) (Maybe (StaticExpression a))
                    | PropDef a String (Args a) (Type a)
                    | FixityDecl (Fixity a) [String]
-                   | MacDecl a String [String] (Expression a)
-                   | DataSort a String [DataSortLeaf a]
+                   | MacDecl a String (Maybe [String]) (Expression a)
+                   | DataSort a String (NonEmpty (DataSortLeaf a))
                    | Exception String (Type a)
                    | ExtVar a String (Expression a)
                    | AbsImpl a (Name a) (SortArgs a) (Type a)
@@ -144,18 +144,18 @@
             | FromVT (Type a) -- | @a?!@
             | MaybeVal (Type a) -- | @a?@
             | AtExpr a (Type a) (StaticExpression a)
-            | AtType a (Type a)
-            | ProofType a (NonEmpty (Type a)) (Type a) -- Aka (prf | val)
+            | ArrayType a (Type a) (StaticExpression a)
+            | ProofType a (NonEmpty (Type a)) (NonEmpty (Type a)) -- Aka (prf | val)
             | ConcreteType (StaticExpression a)
             | RefType (Type a)
             | ViewType a (Type a)
             | FunctionType String (Type a) (Type a)
-            | NoneType a
             | ImplicitType a
             | ViewLiteral Addendum
-            | AnonymousRecord a [(String, Type a)]
+            | AnonymousRecord a (NonEmpty (String, Type a))
             | ParenType a (Type a)
             | WhereType a (Type a) String (SortArgs a) (Type a)
+            | AddrType a -- ^ @addr@
             deriving (Show, Eq, Generic, NFData)
 
 data TypeF a x = TupleF a [x]
@@ -169,18 +169,18 @@
                | FromVTF x
                | MaybeValF x
                | AtExprF a x (StaticExpression a)
-               | AtTypeF a x
-               | ProofTypeF a (NonEmpty x) x
+               | ArrayTypeF a x (StaticExpression a)
+               | ProofTypeF a (NonEmpty x) (NonEmpty x)
                | ConcreteTypeF (StaticExpression a)
                | RefTypeF x
                | ViewTypeF a x
                | FunctionTypeF String x x
-               | NoneTypeF a
                | ImplicitTypeF a
                | ViewLiteralF Addendum
-               | AnonymousRecordF a [(String, x)]
+               | AnonymousRecordF a (NonEmpty (String, x))
                | ParenTypeF a x
                | WhereTypeF a x String (SortArgs a) x
+               | AddrTypeF a
                deriving (Functor)
 
 type instance Base (Type a) = TypeF a
@@ -197,18 +197,18 @@
     project (FromVT ty)                = FromVTF ty
     project (MaybeVal ty)              = MaybeValF ty
     project (AtExpr l ty se)           = AtExprF l ty se
-    project (AtType l ty)              = AtTypeF l ty
+    project (ArrayType l ty n)         = ArrayTypeF l ty n
     project (ProofType l tys ty')      = ProofTypeF l tys ty'
     project (ConcreteType se)          = ConcreteTypeF se
     project (RefType ty)               = RefTypeF ty
     project (ViewType l ty)            = ViewTypeF l ty
     project (FunctionType s ty ty')    = FunctionTypeF s ty ty'
-    project (NoneType l)               = NoneTypeF l
     project (ImplicitType l)           = ImplicitTypeF l
     project (ViewLiteral a)            = ViewLiteralF a
     project (AnonymousRecord l stys)   = AnonymousRecordF l stys
     project (ParenType l ty)           = ParenTypeF l ty
     project (WhereType l ty s sas ty') = WhereTypeF l ty s sas ty'
+    project (AddrType l)               = AddrTypeF l
 
 -- | A type for @=>@, @=\<cloref1>@, etc.
 data LambdaType a = Plain a
@@ -239,6 +239,7 @@
                | UniversalPattern a String [Universal a] (Pattern a)
                | ExistentialPattern (Existential a) (Pattern a)
                | As a (Pattern a) (Pattern a)
+               | BinPattern a (BinOp a) (Pattern a) (Pattern a) -- ^ For use with e.g. @::@.
                deriving (Show, Eq, Generic, NFData)
 
 data PatternF a x = WildcardF a
@@ -254,6 +255,7 @@
                   | UniversalPatternF a String [Universal a] x
                   | ExistentialPatternF (Existential a) x
                   | AsF a x x
+                  | BinPatternF a (BinOp a) x x
                   deriving (Functor)
 
 type instance Base (Pattern a) = PatternF a
@@ -272,6 +274,7 @@
     project (UniversalPattern x s us p) = UniversalPatternF x s us p
     project (ExistentialPattern e x)    = ExistentialPatternF e x
     project (As x p p')                 = AsF x p p'
+    project (BinPattern a op p p')      = BinPatternF a op p p'
 
 data Paired a b = Both a b
                 | First a
@@ -361,6 +364,7 @@
 data StaticExpression a = StaticVal (Name a)
                         | StaticBinary (BinOp a) (StaticExpression a) (StaticExpression a)
                         | StaticInt Int
+                        | StaticHex String
                         | SPrecede (StaticExpression a) (StaticExpression a)
                         | StaticVoid a
                         | Sif { scond :: StaticExpression a, whenTrue :: StaticExpression a, selseExpr :: StaticExpression a } -- Static if (for proofs)
@@ -368,11 +372,13 @@
                         | SUnary (UnOp a) (StaticExpression a)
                         | SLet a [Declaration a] (Maybe (StaticExpression a))
                         | SCase Addendum (StaticExpression a) [(Pattern a, LambdaType a, StaticExpression a)]
+                        | SString String -- ^ @ext#@
                         deriving (Show, Eq, Generic, NFData)
 
 data StaticExpressionF a x = StaticValF (Name a)
                            | StaticBinaryF (BinOp a) x x
                            | StaticIntF Int
+                           | StaticHexF String
                            | SPrecedeF x x
                            | StaticVoidF a
                            | SifF x x x
@@ -380,6 +386,7 @@
                            | SUnaryF (UnOp a) x
                            | SLetF a [Declaration a] (Maybe x)
                            | SCaseF Addendum x [(Pattern a, LambdaType a, x)]
+                           | SStringF String
                            deriving (Functor)
 
 type instance Base (StaticExpression a) = StaticExpressionF a
@@ -387,6 +394,7 @@
 instance Recursive (StaticExpression a) where
     project (StaticVal n)         = StaticValF n
     project (StaticBinary b x x') = StaticBinaryF b x x'
+    project (StaticHex h)         = StaticHexF h
     project (StaticInt i)         = StaticIntF i
     project (SPrecede x x')       = SPrecedeF x x'
     project (StaticVoid x)        = StaticVoidF x
@@ -395,6 +403,7 @@
     project (SUnary u x)          = SUnaryF u x
     project (SLet x ds e)         = SLetF x ds e
     project (SCase a x ples)      = SCaseF a x ples
+    project (SString s)           = SStringF s
 
 -- | A (possibly effectful) expression.
 data Expression a = Let a (ATS a) (Maybe (Expression a))
@@ -434,7 +443,7 @@
                          , val   :: Expression a
                          , _arms :: [(Pattern a, LambdaType a, Expression a)] -- ^ Each (('Pattern' a), ('Expression' a)) pair corresponds to a branch of the 'case' statement
                          }
-                  | RecordValue a [(String, Expression a)] (Maybe (Type a))
+                  | RecordValue a (NonEmpty (String, Expression a)) (Maybe (Type a))
                   | Precede (Expression a) (Expression a)
                   | ProofExpr a (NonEmpty (Expression a)) (Expression a)
                   | TypeSignature (Expression a) (Type a)
@@ -479,7 +488,7 @@
                      | UnaryF (UnOp a) x
                      | IfCaseF a [(x, LambdaType a, x)]
                      | CaseF a Addendum x [(Pattern a, LambdaType a, x)]
-                     | RecordValueF a [(String, x)] (Maybe (Type a))
+                     | RecordValueF a (NonEmpty (String, x)) (Maybe (Type a))
                      | PrecedeF x x
                      | ProofExprF a (NonEmpty x) x
                      | TypeSignatureF x (Type a)
diff --git a/src/Language/ATS/Types/Lens.hs b/src/Language/ATS/Types/Lens.hs
--- a/src/Language/ATS/Types/Lens.hs
+++ b/src/Language/ATS/Types/Lens.hs
@@ -20,6 +20,7 @@
                                , comment
                                ) where
 
+import           Data.List.NonEmpty (NonEmpty)
 import           Language.ATS.Types
 import           Lens.Micro
 
@@ -83,7 +84,7 @@
 propLeaves f (DataProp l n as pl) = DataProp l n as <$> f pl
 propLeaves _ x                    = pure x
 
-leaves :: Traversal' (Declaration a) [Leaf a]
+leaves :: Traversal' (Declaration a) (NonEmpty (Leaf a))
 leaves f (SumType t as l)     = SumType t as <$> f l
 leaves f (SumViewType t as l) = SumViewType t as <$> f l
 leaves _ x                    = pure x
diff --git a/test/data/fib-thm.dats b/test/data/fib-thm.dats
--- a/test/data/fib-thm.dats
+++ b/test/data/fib-thm.dats
@@ -10,7 +10,9 @@
 dataprop fib_p(int, int) =
   | fib_p_bas0(0, 0) of ()
   | fib_p_bas1(1, 1) of ()
-  | {n:nat}{ r0, r1 : int } fib_p_ind2(n + 2, r0 + r1) of (fib_p(n, r0), fib_p(n + 1, r1))
+  | {n:nat}{ r0, r1 : int } fib_p_ind2(n + 2, r0 + r1) of (fib_p( n
+                                                                , r0
+                                                                ), fib_p(n + 1, r1))
 
 stacst fib_b : (int, int) -> bool
 
@@ -21,12 +23,14 @@
 praxi fib_b_bas1() : [fib_b(1,1)] unit_p
 
 extern
-praxi fib_b_ind2 {n:nat}{ r0, r1 : int }  : [fib_b(n,r0) && fib_b(n+1,r1) ->> fib_b(n+2,r0+r1)] unit_p
+praxi fib_b_ind2 {n:nat}{ r0, r1 : int } :
+  [fib_b(n,r0) && fib_b(n+1,r1) ->> fib_b(n+2,r0+r1)] unit_p
 
 fun f_fib_p {n:nat}(n : int(n)) : [r:int] (fib_p(n, r) | int(r)) =
   let
-    fun loop { i : nat | i < n }{ r0, r1 : int }(pf0 : fib_p(i, r0), pf1 : fib_p(i+1, r1)
-                                                | i : int(i), r0 : int(r0), r1 : int(r1)) :
+    fun loop { i : nat | i < n }{ r0, r1 : int }( pf0 : fib_p(i, r0)
+                                                 , pf1 : fib_p(i+1, r1)
+                                                  | i : int(i), r0 : int(r0), r1 : int(r1)) :
       [r:int] (fib_p(n, r) | int(r)) =
       if i + 1 < n then
         loop(pf1, fib_p_ind2(pf0, pf1) | i + 1, r1, r0 + r1)
@@ -48,3 +52,4 @@
   in
     println!(i)
   end
+
diff --git a/test/data/levenshtein.out b/test/data/levenshtein.out
--- a/test/data/levenshtein.out
+++ b/test/data/levenshtein.out
@@ -17,11 +17,11 @@
         }
     
     val () = loop1(sz2i(s1_l))
-    val () = while* {i:nat}  .<i>. (i : int(i)) =>
+    val () = while* {i:nat} .<i>. (i : int(i)) =>
         (i > 0)
         (column[i] := i ; i := i - 1)
     val () = while(i > 0)(column[i] := i ; i := i - 1)
-    val () = for* { i : nat | i <= m }  .<i>. (i : int(i)) =>
+    val () = for* { i : nat | i <= m } .<i>. (i : int(i)) =>
         (i := sz2i(s1_l) ; i > 0 ; i := i - 1)
         (column[i] := i)
     
diff --git a/test/data/levenshtein2.out b/test/data/levenshtein2.out
--- a/test/data/levenshtein2.out
+++ b/test/data/levenshtein2.out
@@ -32,13 +32,13 @@
         prvar pf1 = pf_arr
         
         //
-        val () = while* { i : nat | i <= m }  .<m-i>. ( i : int(i)
-                                                      , p : ptr(larr+i*sizeof(int))
-                                                      , pf0 : array_v(int, larr, i)
-                                                      , pf1 : array_v(int?, larr+i*sizeof(int), m-i)
-                                                      ) : ( pf0 : array_v(int, larr, m)
-                                                          , pf1 : array_v(int?, larr+i*sizeof(int), 0)
-                                                          ) =>
+        val () = while* { i : nat | i <= m } .<m-i>. ( i : int(i)
+                                                     , p : ptr(larr+i*sizeof(int))
+                                                     , pf0 : array_v(int, larr, i)
+                                                     , pf1 : array_v(int?, larr+i*sizeof(int), m-i)
+                                                     ) : ( pf0 : array_v(int, larr, m)
+                                                         , pf1 : array_v(int?, larr+i*sizeof(int), 0)
+                                                         ) =>
             (i < sz2i(s1_l))
             {
               //
diff --git a/test/data/stdlib/arith_prf.out b/test/data/stdlib/arith_prf.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/arith_prf.out
@@ -0,0 +1,276 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/arith_prf.atxt
+** Time of generation: Thu Jan 11 11:00:02 2018
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: September, 2011 *)
+(* ****** ****** *)
+
+#if(0)
+//
+// It is available in [basic_dyn.sats]
+//
+dataprop
+MUL_prop
+(
+  int, int, int
+) = // MUL_prop
+  | {n:int}
+    MULbas (0, n, 0)
+  | {m:nat}{n:int}{p:int}
+    MULind (m+1, n, p+n) of MUL_prop (m, n, p)
+  | {m:pos}{n:int}{p:int}
+    MULneg (~(m), n, ~(p)) of MUL_prop (m, n, p)
+//
+propdef MUL = MUL_prop
+//
+#endif
+(* ****** ****** *)
+praxi mul_make : { m, n : int } () -<prf> MUL(m, n, m*n)
+
+praxi mul_elim :
+  { m, n : int } {p:int} MUL(m, n, p) -<prf> [p == m*n] void
+
+(* ****** ****** *)
+//
+prfun mul_istot { m, n : int } () :<prf> [p:int] MUL(m, n, p)
+
+//
+prfun mul_isfun { m, n : int }{ p1, p2 : int } ( MUL(m,n,p1)
+                                               , MUL(m,n,p2)
+                                               ) :<prf> [p1 == p2] void
+
+// endfun
+prfun mul_isfun2 { m, n : int }{ p1, p2 : int } ( MUL(m,n,p1)
+                                                , MUL(m,n,p2)
+                                                ) :<prf> EQINT(p1, p2)
+
+//
+(* ****** ****** *)
+//
+// HX: (m+i)*n = m*n+i*n
+//
+praxi mul_add_const {i:int}{ m, n : int }{p:int} (pf : MUL(m, n, p)) 
+  :<prf> MUL(m+i, n, p+i*n)
+
+// end of [mul_add_const]
+//
+(* ****** ****** *)
+//
+// HX: (ax+b)*(cy+d) = ac*xy + ad*x + bc*y + bd
+//
+praxi mul_expand_linear
+{ a, b : int }{ c, d : int }{ x, y : int }{xy:int} (pf : MUL(x, y, xy)) 
+  :<prf> MUL(a*x+b, c*y+d, a*c*xy+a*d*x+b*c*y+b*d)
+
+// end of [mul_expand_linear]
+(* ****** ****** *)
+//
+// HX: (a1x1+a2x2+b)*(c1y1+c2y2+d) = ...
+//
+praxi mul_expand2_linear
+{ a1, a2, b : int }{ c1, c2, d : int }{ x1, x2 : int }{ y1, y2 : int }{ x1y1, x1y2, x2y1, x2y2 : int }
+(MUL(x1,y1,x1y1), MUL(x1,y2,x1y2), MUL(x2,y1,x2y1), MUL(x2,y2,x2y2)) 
+  :<prf>
+  MUL_prop(a1*x1+a2*x2+b, c1*y1+c2*y2+d, a1*c1*x1y1+a1*c2*x1y2+a2*c1*x2y1+a2*c2*x2y2+a1*d*x1+a2*d*x2+b*c1*y1+b*c2*y2+b*d)
+
+(* end of [mul_expand2_linear] *)
+(* ****** ****** *)
+//
+prfun mul_gte_gte_gte :
+  { m, n : int | m >= 0; n >= 0 } () -<prf> [m*n >= 0] void
+
+prfun mul_lte_gte_lte :
+  { m, n : int | m <= 0; n >= 0 } () -<prf> [m*n <= 0] void
+
+prfun mul_gte_lte_lte :
+  { m, n : int | m >= 0; n <= 0 } () -<prf> [m*n <= 0] void
+
+prfun mul_lte_lte_gte :
+  { m, n : int | m <= 0; n <= 0 } () -<prf> [m*n >= 0] void
+
+//
+(* ****** ****** *)
+//
+prfun mul_nat_nat_nat :
+  { m, n : nat } {p:int} MUL(m, n, p) -<prf> [p >= 0] void
+
+prfun mul_pos_pos_pos :
+  { m, n : pos } {p:int} MUL(m, n, p) -<prf> [p >= m+n-1] void
+
+//
+(* ****** ****** *)
+//
+prfun mul_negate { m, n : int }{p:int} (pf : MUL(m, n, p)) :<prf>
+  MUL(~m, n, ~p)
+
+prfun mul_negate2 { m, n : int }{p:int} (pf : MUL(m, n, p)) :<prf>
+  MUL(m, ~n, ~p)
+
+//
+(* ****** ****** *)
+//
+// HX: m*n = n*m
+//
+prfun mul_commute { m, n : int }{p:int} (pf : MUL(m, n, p)) :<prf>
+  MUL(n, m, p)
+
+prfun mul_is_commutative { m, n : int }{ p, q : int }
+(pf1 : MUL(m, n, p), pf2 : MUL(n, m, q)) : [p == q] void
+
+//
+(* ****** ****** *)
+//
+// HX: m*(n1+n2) = m*n1+m*n2
+//
+prfun mul_distribute {m:int}{ n1, n2 : int }{ p1, p2 : int }
+(pf1 : MUL(m, n1, p1), pf2 : MUL(m, n2, p2)) :<prf> MUL(m, n1+n2, p1+p2)
+
+//
+// HX: (m1+m2)*n = m1*n + m2*n
+//
+prfun mul_distribute2 { m1, m2 : int }{n:int}{ p1, p2 : int }
+(pf1 : MUL(m1, n, p1), pf2 : MUL(m2, n, p2)) :<prf> MUL(m1+m2, n, p1+p2)
+
+//
+(* ****** ****** *)
+prfun mul_is_associative
+{ x, y, z : int }{ xy, yz : int }{ xy_z, x_yz : int }
+( pf1 : MUL(x, y, xy)
+, pf2 : MUL(y, z, yz)
+, pf3 : MUL(xy, z, xy_z)
+, pf4 : MUL(x, yz, x_yz)
+) :<prf> [xy_z == x_yz] void
+
+(* ****** ****** *)
+//
+praxi div_istot { x, y : int | x >= 0; y > 0 } () : DIV(x, y, x / y)
+
+//
+praxi divmod_istot { x, y : int | x >= 0; y > 0 } () :
+  [ q, r : nat | r < y ] DIVMOD(x, y, q, r)
+
+//
+(* ****** ****** *)
+praxi divmod_isfun
+{ x, y : int | x >= 0; y > 0 }{ q1, q2 : int }{ r1, r2 : int }
+(pf1 : DIVMOD(x, y, q1, r1), pf2 : DIVMOD(x, y, q2, r2)) :
+  [q1 == q2; r1 == r2] void
+
+// end of [divmod_isfun]
+(* ****** ****** *)
+praxi divmod_elim { x, y : int | x >= 0; y > 0 }{ q, r : int }
+(pf : DIVMOD(x, y, q, r)) :
+  [ qy : nat | 0 <= r; r < y; x == qy+r ] MUL(q, y, qy)
+
+praxi divmod_mul_elim { x, y : int | x >= 0; y > 0 }{ q, r : int }
+(pf : DIVMOD(x, y, q, r)) :
+  [0 <= q; 0 <= r; r < y; q == ndiv_int_int(x,y); x == q*y+r] void
+
+// end of [divmod_mul_elim]
+(* ****** ****** *)
+//
+dataprop EXP2(int, int) =
+  | EXP2bas((0, 1))
+  | {n:nat}{p:nat} EXP2ind((n + 1, 2 * p)) of EXP2((n, p))
+
+prfun lemma_exp2_param :
+  {n:int} {p:int} EXP2(n, p) -<prf> [n >= 0; p >= 1] void
+
+// end of [lemma_exp2_param]
+//
+prfun exp2_istot {n:nat} () : [p:nat] EXP2(n, p)
+
+prfun exp2_isfun {n:nat}{ p1, p2 : int } ( pf1 : EXP2(n, p1)
+                                         , pf2 : EXP2(n, p2)
+                                         ) : [p1 == p2] void
+
+// end of [exp2_isfun]
+//
+// HX: proven in [arith_prf.dats]
+//
+prfun exp2_ispos {n:nat}{p:int} (pf : EXP2(n, p)) : [p >= 1] void
+
+// end of [exp2_ispos]
+//
+// HX: proven in [arith_prf.dats]
+//
+prfun exp2_is_mono { n1, n2 : nat | n1 <= n2 }{ p1, p2 : int }
+(pf1 : EXP2(n1, p1), pf2 : EXP2(n2, p2)) : [p1 <= p2] void
+
+// end of [exp2_is_mono]
+//
+// HX: proven in [arith_prf.dats]
+//
+prfun exp2_muladd { n1, n2 : nat | n1 <= n2 }{ p1, p2 : int }{p:int}
+(pf1 : EXP2(n1, p1), pf2 : EXP2(n2, p2), pf3 : MUL(p1, p2, p)) :
+  EXP2(n1+n2, p)
+
+// end of [exp2_muladd]
+//
+(* ****** ****** *)
+absprop EXP (int, int, int)
+
+praxi lemma_exp_param {b:int}{n:int}{p:int} (pf : EXP(b, n, p)) :
+  [n >= 0] void
+
+// end of [lemma_exp_param]
+praxi exp_istot {b:int}{n:nat} () : [p:nat] EXP(b, n, p)
+
+praxi exp_isfun {b:int}{n:int}{ p1, p2 : int } ( pf1 : EXP(b, n, p1)
+                                               , pf2 : EXP(b, n, p2)
+                                               ) : [p1 == p2] void
+
+// end of [exp_isfun]
+praxi exp_elim_0 {n:pos}{p:int} (pf : EXP(0, n, p)) : [p == 0] void
+
+praxi exp_elim_1 {n:int}{p:int} (pf : EXP(1, n, p)) : [p == 1] void
+
+praxi exp_elim_2 {n:int}{p:int} (pf : EXP(2, n, p)) : EXP2(n, p)
+
+praxi exp_elim_b_0 {b:int}{p:int} (pf : EXP(b, 0, p)) : [p == 1] void
+
+praxi exp_elim_b_1 {b:int}{p:int} (pf : EXP(b, 1, p)) : [p == b] void
+
+praxi exp_elim_b_2 {b:int}{p:int} (pf : EXP(b, 2, p)) : MUL(b, b, p)
+
+praxi exp_muladd {b:int}{ n1, n2 : int }{ p1, p2 : int }{p:int}
+(pf1 : EXP(b, n1, p1), pf2 : EXP(b, n2, p2)) : EXP(b, n1+n2, p1*p2)
+
+// end of [exp_muladd]
+praxi exp_expmul {b:int}{ n1, n2 : int }{bn1:int}{bn1n2:int}
+(pf1 : EXP(b, n1, bn1), pf2 : EXP(bn1, n2, bn1n2)) :
+  EXP(b, n1*n2, bn1n2)
+
+// end of [exp_muladd]
+(* ****** ****** *)
+(* end of [arith_prf.sats] *)
diff --git a/test/data/stdlib/arith_prf.sats b/test/data/stdlib/arith_prf.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/arith_prf.sats
@@ -0,0 +1,309 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/arith_prf.atxt
+** Time of generation: Thu Jan 11 11:00:02 2018
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: September, 2011 *)
+
+(* ****** ****** *)
+
+#if(0)
+//
+// It is available in [basic_dyn.sats]
+//
+dataprop
+MUL_prop
+(
+  int, int, int
+) = // MUL_prop
+  | {n:int}
+    MULbas (0, n, 0)
+  | {m:nat}{n:int}{p:int}
+    MULind (m+1, n, p+n) of MUL_prop (m, n, p)
+  | {m:pos}{n:int}{p:int}
+    MULneg (~(m), n, ~(p)) of MUL_prop (m, n, p)
+//
+propdef MUL = MUL_prop
+//
+#endif
+
+(* ****** ****** *)
+
+praxi
+mul_make : {m,n:int} () -<prf> MUL (m, n, m*n)
+praxi
+mul_elim : {m,n:int} {p:int} MUL (m, n, p) -<prf> [p == m*n] void
+
+(* ****** ****** *)
+//
+prfun
+mul_istot{m,n:int}():<prf> [p:int] MUL(m, n, p)
+//
+prfun
+mul_isfun
+{m,n:int}{p1,p2:int}
+(
+  MUL(m, n, p1), MUL(m, n, p2)
+) :<prf> [p1==p2] void // endfun
+prfun
+mul_isfun2{m,n:int}{p1,p2:int}
+  (MUL(m, n, p1), MUL(m, n, p2)):<prf> EQINT(p1, p2)
+//
+(* ****** ****** *)
+//
+// HX: (m+i)*n = m*n+i*n
+//
+praxi
+mul_add_const
+  {i:int}{m,n:int}{p:int}
+  (pf: MUL (m, n, p)):<prf> MUL(m+i, n, p+i*n)
+// end of [mul_add_const]
+//
+(* ****** ****** *)
+//
+// HX: (ax+b)*(cy+d) = ac*xy + ad*x + bc*y + bd
+//
+praxi
+mul_expand_linear // a,b,c,d: constants!
+  {a,b:int}
+  {c,d:int}
+  {x,y:int}{xy:int}
+(
+  pf: MUL(x, y, xy)
+) :<prf> MUL(a*x+b, c*y+d, a*c*xy+a*d*x+b*c*y+b*d)
+// end of [mul_expand_linear]
+
+(* ****** ****** *)
+//
+// HX: (a1x1+a2x2+b)*(c1y1+c2y2+d) = ...
+//
+praxi
+mul_expand2_linear // a1,b1,c1,a2,b2,c2: constants!
+  {a1,a2,b:int}
+  {c1,c2,d:int}
+  {x1,x2:int}{y1,y2:int}
+  {x1y1,x1y2,x2y1,x2y2:int}
+(
+  MUL(x1, y1, x1y1), MUL(x1, y2, x1y2)
+, MUL(x2, y1, x2y1), MUL(x2, y2, x2y2)
+) :<prf>
+MUL_prop (
+  a1*x1+a2*x2+b
+, c1*y1+c2*y2+d
+, a1*c1*x1y1 + a1*c2*x1y2 +
+  a2*c1*x2y1 + a2*c2*x2y2 +
+  a1*d*x1 + a2*d*x2 + b*c1*y1 + b*c2*y2 + b*d
+) (* end of [mul_expand2_linear] *)
+
+(* ****** ****** *)
+//
+prfun
+mul_gte_gte_gte
+  : {m,n:int | m >= 0; n >= 0} () -<prf> [m*n >= 0] void
+prfun
+mul_lte_gte_lte
+  : {m,n:int | m <= 0; n >= 0} () -<prf> [m*n <= 0] void
+prfun
+mul_gte_lte_lte
+  : {m,n:int | m >= 0; n <= 0} () -<prf> [m*n <= 0] void
+prfun
+mul_lte_lte_gte
+  : {m,n:int | m <= 0; n <= 0} () -<prf> [m*n >= 0] void
+//
+(* ****** ****** *)
+//
+prfun
+mul_nat_nat_nat :
+  {m,n:nat} {p:int} MUL(m, n, p) -<prf> [p >= 0] void
+prfun
+mul_pos_pos_pos :
+  {m,n:pos} {p:int} MUL(m, n, p) -<prf> [p >= m+n-1] void
+//
+(* ****** ****** *)
+//
+prfun mul_negate
+  {m,n:int}{p:int}(pf: MUL(m, n, p)):<prf> MUL(~m, n, ~p)
+prfun mul_negate2
+  {m,n:int}{p:int}(pf: MUL(m, n, p)):<prf> MUL(m, ~n, ~p)
+//
+(* ****** ****** *)
+//
+// HX: m*n = n*m
+//
+prfun mul_commute
+  {m,n:int}{p:int}(pf: MUL(m, n, p)):<prf> MUL(n, m, p)
+prfun mul_is_commutative
+  {m,n:int}{p,q:int}(pf1: MUL(m, n, p), pf2: MUL(n, m, q)): [p==q] void
+//
+(* ****** ****** *)
+//
+// HX: m*(n1+n2) = m*n1+m*n2
+//
+prfun
+mul_distribute
+  {m:int}{n1,n2:int}{p1,p2:int}
+  (pf1: MUL(m, n1, p1), pf2: MUL(m, n2, p2)):<prf> MUL(m, n1+n2, p1+p2)
+//
+// HX: (m1+m2)*n = m1*n + m2*n
+//
+prfun
+mul_distribute2
+  {m1,m2:int}{n:int}{p1,p2:int}
+  (pf1: MUL(m1, n, p1), pf2: MUL(m2, n, p2)):<prf> MUL(m1+m2, n, p1+p2)
+//
+(* ****** ****** *)
+
+prfun
+mul_is_associative
+  {x,y,z:int}
+  {xy,yz:int}
+  {xy_z,x_yz:int} (
+  pf1: MUL (x, y, xy), pf2: MUL (y, z, yz)
+, pf3: MUL (xy, z, xy_z), pf4: MUL (x, yz, x_yz)
+) :<prf> [xy_z==x_yz] void
+
+(* ****** ****** *)
+//
+praxi
+div_istot
+  {x,y:int | x >= 0; y > 0} (): DIV(x, y, x/y)
+//
+praxi
+divmod_istot
+{ x,y:int
+| x >= 0; y > 0
+} ((*void*)): [q,r:nat | r < y] DIVMOD(x, y, q, r)
+//
+(* ****** ****** *)
+
+praxi
+divmod_isfun
+  {x,y:int | x >= 0; y > 0}
+  {q1,q2:int} {r1,r2:int} (
+  pf1: DIVMOD (x, y, q1, r1)
+, pf2: DIVMOD (x, y, q2, r2)
+) : [q1==q2;r1==r2] void // end of [divmod_isfun]
+
+(* ****** ****** *)
+
+praxi
+divmod_elim
+  {x,y:int | x >= 0; y > 0}
+  {q,r:int}
+(
+  pf: DIVMOD (x, y, q, r)
+) : [qy:nat | 0 <= r; r < y; x==qy+r] MUL (q, y, qy)
+
+praxi
+divmod_mul_elim
+  {x,y:int | x >= 0; y > 0}
+  {q,r:int}
+  (pf: DIVMOD (x, y, q, r))
+: [0 <= q; 0 <= r; r < y; q==ndiv_int_int(x, y); x==q*y+r] void
+// end of [divmod_mul_elim]
+
+(* ****** ****** *)
+//
+dataprop
+EXP2 (int, int) =
+  | EXP2bas (0, 1)
+  | {n:nat}{p:nat}
+    EXP2ind (n+1, 2*p) of EXP2 (n, p)
+// end of [EXP2]
+//
+prfun lemma_exp2_param :
+  {n:int}{p:int} EXP2 (n, p) -<prf> [n>=0;p>=1] void
+// end of [lemma_exp2_param]
+//
+prfun exp2_istot {n:nat} (): [p:nat] EXP2 (n, p)
+prfun exp2_isfun {n:nat} {p1,p2:int}
+  (pf1: EXP2 (n, p1), pf2: EXP2 (n, p2)): [p1==p2] void
+// end of [exp2_isfun]
+//
+// HX: proven in [arith_prf.dats]
+//
+prfun exp2_ispos
+  {n:nat} {p:int} (pf: EXP2 (n, p)): [p >= 1] void
+// end of [exp2_ispos]
+//
+// HX: proven in [arith_prf.dats]
+//
+prfun exp2_is_mono
+  {n1,n2:nat | n1 <= n2} {p1,p2:int}
+  (pf1: EXP2 (n1, p1), pf2: EXP2 (n2, p2)): [p1 <= p2] void
+// end of [exp2_is_mono]
+//
+// HX: proven in [arith_prf.dats]
+//
+prfun exp2_muladd
+  {n1,n2:nat | n1 <= n2} {p1,p2:int} {p:int} (
+  pf1: EXP2 (n1, p1), pf2: EXP2 (n2, p2), pf3: MUL (p1, p2, p)
+) : EXP2 (n1+n2, p) // end of [exp2_muladd]
+//
+(* ****** ****** *)
+
+absprop EXP (int(*base*), int(*power*), int(*res*))
+
+praxi lemma_exp_param
+  {b:int}{n:int}{p:int} (pf: EXP (b, n, p)): [n >= 0] void
+// end of [lemma_exp_param]
+
+praxi exp_istot {b:int}{n:nat} (): [p:nat] EXP (b, n, p)
+praxi exp_isfun {b:int}{n:int}{p1,p2:int}
+  (pf1: EXP (b, n, p1), pf2: EXP (b, n, p2)): [p1==p2] void
+// end of [exp_isfun]
+
+praxi exp_elim_0 {n:pos}{p:int} (pf: EXP (0, n, p)): [p==0] void
+praxi exp_elim_1 {n:int}{p:int} (pf: EXP (1, n, p)): [p==1] void
+praxi exp_elim_2 {n:int}{p:int} (pf: EXP (2, n, p)): EXP2 (n, p)
+praxi exp_elim_b_0 {b:int}{p:int} (pf: EXP (b, 0, p)): [p==1] void
+praxi exp_elim_b_1 {b:int}{p:int} (pf: EXP (b, 1, p)): [p==b] void
+praxi exp_elim_b_2 {b:int}{p:int} (pf: EXP (b, 2, p)): MUL (b, b, p)
+
+praxi exp_muladd
+  {b:int}{n1,n2:int}{p1,p2:int}{p:int} (
+  pf1: EXP (b, n1, p1), pf2: EXP (b, n2, p2)
+) : EXP (b, n1+n2, p1*p2) // end of [exp_muladd]
+
+praxi exp_expmul
+  {b:int}{n1,n2:int}{bn1:int}{bn1n2:int} (
+  pf1: EXP (b, n1, bn1), pf2: EXP (bn1, n2, bn1n2)
+) : EXP (b, n1*n2, bn1n2) // end of [exp_muladd]
+
+(* ****** ****** *)
+
+(* end of [arith_prf.sats] *)
diff --git a/test/data/stdlib/array.out b/test/data/stdlib/array.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/array.out
@@ -0,0 +1,594 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2013 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/array.atxt
+** Time of generation: Mon Jun  4 01:42:39 2018
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: Feburary, 2012 *)
+(* ****** ****** *)
+vtypedef RD(a: vt0p) = a
+
+// for commenting: read-only
+#define NSH (x) x // for commenting: no sharing
+#define SHR (x) x // for commenting: it is shared
+
+(* ****** ****** *)
+sortdef t0p = t@ype
+
+sortdef vtp = vtype
+
+sortdef vt0p = vt@ype
+
+(* ****** ****** *)
+(*
+//
+// HX: [array_v] can also be defined as follows:
+//
+dataview
+array_v
+(
+  a:vt@ype+, addr, int
+) = // HX: for arry view
+  | {l:addr}
+    array_v_nil (a, l, 0)
+  | {l:addr}{n:int}
+    array_v_cons (a, l, n+1) of (a @ l, array_v (a, l+sizeof a, n))
+// end of [array_v]
+*)
+(* ****** ****** *)
+dataview arrayopt_v(a: vt@ype+, addr, int, bool) =
+  | {l:addr}{n:int} arrayopt_v_some(a, l, n, true) of array_v(a, l, n)
+  | {l:addr}{n:int} arrayopt_v_none(a, l, n, false) of array_v(a?, l, n)
+
+// end of [arrayopt_v]
+(* ****** ****** *)
+//
+exception ArraySubscriptExn of ()
+
+//
+(*
+fun
+ArraySubscriptExn():<> exn = "mac#%ArraySubscriptExn_make"
+fun
+isArraySubscriptExn(x: !exn):<> bool = "mac#%isArraySubscriptExn"
+//
+macdef
+ifArraySubscriptExn
+  {tres}(exn, body) =
+(
+let val x = ,(exn) in
+(
+//
+if
+isArraySubscriptExn(x)
+then (
+  let prval () = __vfree_exn (x) in ,(body) end
+) else $raise (x)
+//
+) : tres // end of [if]
+end (* end of [let] *)
+) // end of [ifArraySubscriptExn]
+*)
+//
+(* ****** ****** *)
+//
+praxi lemma_array_param {a:vt0p}{l:addr}{n:int} (A : &(@[INV(a)][n])) :
+  [n >= 0] void
+
+// end of [lemma_array_param]
+//
+praxi lemma_array_v_param {a:vt0p}{l:addr}{n:int}
+(pf : !array_v(INV(a), l, n)) : [n >= 0] void
+
+// end of [lemma_array_v_param]
+//
+(* ****** ****** *)
+//
+praxi array_v_nil : {a:vt0p} {l:addr} () -<prf> array_v(a, l, 0)
+
+//
+praxi array_v_unnil : {a:vt0p} {l:addr} array_v(a, l, 0) -<prf> void
+
+//
+prfun array_v_unnil_nil :
+  { a1, a2 : vt0p } {l:addr} array_v(a1, l, 0) -<prf> array_v(a2, l, 0)
+
+// end of [array_v_unnil_nil]
+//
+(* ****** ****** *)
+//
+praxi array_v_cons :
+  {a:vt0p} {l:addr} {n:int} (a @ l, array_v(INV(a), l+sizeof(a), n)) -<prf> array_v(a, l, n+1)
+
+//
+praxi array_v_uncons :
+  {a:vt0p} {l:addr} { n : int | n > 0 } array_v(INV(a), l, n) -<prf> (a @ l, array_v(a, l+sizeof(a), n-1))
+
+(* ****** ****** *)
+prfun array_v_sing {a:vt0p}{l:addr} (pf : INV(a) @ l) : array_v(a, l, 1)
+
+prfun array_v_unsing {a:vt0p}{l:addr} (pf : array_v(INV(a), l, 1)) :
+  a @ l
+
+(* ****** ****** *)
+//
+fun {a:vt0p} array_getref_at {n:int} ( A : &RD(@[INV(a)][n])
+                                     , i : sizeLt(n)
+                                     ) :<> cPtr1(a)
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p}{tk:tk} array_get_at_gint {n:int} ( A : &RD(@[INV(a)][n])
+                                             , i : g1intLt(tk, n)
+                                             ) :<> a
+
+//
+fun {a:t0p}{tk:tk} array_get_at_guint {n:int} ( A : &RD(@[INV(a)][n])
+                                              , i : g1uintLt(tk, n)
+                                              ) :<> a
+
+//
+overload [] with array_get_at_gint of 0
+
+overload [] with array_get_at_guint of 0
+
+//
+symintr array_get_at
+
+overload array_get_at with array_get_at_gint of 0
+
+overload array_get_at with array_get_at_guint of 0
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p}{tk:tk} array_set_at_gint {n:int} ( A : &(@[INV(a)][n])
+                                             , i : g1intLt(tk, n)
+                                             , x : a
+                                             ) :<!wrt> void
+
+//
+fun {a:t0p}{tk:tk} array_set_at_guint {n:int} ( A : &(@[INV(a)][n])
+                                              , i : g1uintLt(tk, n)
+                                              , x : a
+                                              ) :<!wrt> void
+
+//
+overload [] with array_set_at_gint of 0
+
+overload [] with array_set_at_guint of 0
+
+//
+symintr array_set_at
+
+overload array_set_at with array_set_at_gint of 0
+
+overload array_set_at with array_set_at_guint of 0
+
+//
+(* ****** ****** *)
+fun {a:vt0p}{tk:tk} array_exch_at_gint {n:int} ( A : &(@[INV(a)][n])
+                                               , i : g1intLt(tk, n)
+                                               , x : &a >> _
+                                               ) :<!wrt> void
+
+fun {a:vt0p}{tk:tk} array_exch_at_guint {n:int} ( A : &(@[INV(a)][n])
+                                                , i : g1uintLt(tk, n)
+                                                , x : &a >> _
+                                                ) :<!wrt> void
+
+symintr array_exch_at
+
+overload array_exch_at with array_exch_at_gint of 0
+
+overload array_exch_at with array_exch_at_guint of 0
+
+(* ****** ****** *)
+fun {a:vt0p} array_subreverse
+{n:int}{ i, j : int | 0 <= i; i <= j; j <= n } ( A : &(@[INV(a)][n])
+                                               , i : size_t(i)
+                                               , j : size_t(j)
+                                               ) :<!wrt> void
+
+// end of [array_subreverse]
+(* ****** ****** *)
+fun {a:vt0p} array_interchange {n:int} ( A : &(@[INV(a)][n])
+                                       , i : sizeLt(n)
+                                       , j : sizeLt(n)
+                                       ) :<!wrt> void
+
+// end of [array_interchange]
+(* ****** ****** *)
+fun {a:vt0p} array_subcirculate {n:int} ( A : &(@[INV(a)][n])
+                                        , i : sizeLt(n)
+                                        , j : sizeLt(n)
+                                        ) :<!wrt> void
+
+// end of [array_subcirculate]
+(* ****** ****** *)
+fun {a:vt0p} array_ptr_takeout {l:addr}{n:int}{ i : nat | i < n }
+(array_v(INV(a),l,n) | ptr(l), size_t(i)) : ( a @ l+i*sizeof(a)
+                                            , a @ l+i*sizeof(a) -<lin,prf> array_v(a, l, n)
+                                            | ptr(l+i*sizeof(a)))
+
+(* end of [array_ptr_takeout] *)
+(* ****** ****** *)
+fun {a:vt0p} array_ptr_alloc {n:int} (asz : size_t(n)) :<!wrt>
+  [l:agz] (array_v(a?, l, n), mfree_gc_v(l)| ptr(l))
+
+(* end of [array_ptr_alloc] *)
+fun array_ptr_free {a:vt0p}{l:addr}{n:int} ( array_v(a?, l, n)
+                                           , mfree_gc_v(l)
+                                            | ptr(l)) :<!wrt> void
+
+// end-of-function
+(* ****** ****** *)
+//
+fun fprint_array$sep(out : FILEref) : void
+
+//
+fun {a:vt0p} fprint_array_int {n:int} ( out : FILEref
+                                      , A : &RD(@[INV(a)][n])
+                                      , n : int(n)
+                                      ) : void
+
+// end of [fprint_array_int]
+fun {a:vt0p} fprint_array_size {n:int} ( out : FILEref
+                                       , A : &RD(@[INV(a)][n])
+                                       , n : size_t(n)
+                                       ) : void
+
+// end of [fprint_array_size]
+//
+symintr fprint_array
+
+overload fprint_array with fprint_array_int
+
+overload fprint_array with fprint_array_size
+
+//
+fun {a:vt0p} fprint_array_sep {n:int} ( out : FILEref
+                                      , A : &RD(@[INV(a)][n])
+                                      , n : size_t(n)
+                                      , sep : NSH(string)
+                                      ) : void
+
+// end of [fprint_array_sep]
+//
+(* ****** ****** *)
+overload fprint with fprint_array
+
+overload fprint with fprint_array_sep
+
+(* ****** ****** *)
+fun {a:vt0p} array_copy {n:int} ( to : &(@[a?][n]) >> @[a][n]
+                                , from : &RD(@[INV(a)][n]) >> @[a?!][n]
+                                , n : size_t(n)
+                                ) :<!wrt> void
+
+// end of [array_copy]
+(* ****** ****** *)
+//
+fun {a:t0p} array_copy_from_list {n:int} ( A : &(@[a?][n]) >> @[a][n]
+                                         , xs : list(INV(a), n)
+                                         ) :<!wrt> void
+
+// end of [array_copy_from_list]
+//
+fun {a:vt0p} array_copy_from_list_vt {n:int}
+(A : &(@[a?][n]) >> @[a][n], xs : list_vt(INV(a), n)) :<!wrt> void
+
+// end of [array_copy_from_list_vt]
+//
+(* ****** ****** *)
+fun {a:vt0p} array_copy_to_list_vt {n:int}
+(A : &RD(@[INV(a)][n]) >> @[a?!][n], n : size_t(n)) :<!wrt>
+  list_vt(a, n)
+
+// endfun
+macdef array2list = array_copy_to_list_vt
+
+(* ****** ****** *)
+//
+fun {a:vt0p} array_tabulate$fopr (i : size_t) : (a)
+
+//
+fun {a:vt0p} array_ptr_tabulate {n:int} (asz : size_t(n)) :
+  [l:addr] (array_v(a, l, n), mfree_gc_v(l)| ptr(l))
+
+// end of [arrayptr_tabulate]
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} array_foreach {n:int} ( A : &(@[INV(a)][n]) >> @[a][n]
+                                   , asz : size_t(n)
+                                   ) : sizeLte(n)
+
+// end of [array_foreach]
+//
+fun {a:vt0p}{env:vt0p} array_foreach_env {n:int}
+(A : &(@[INV(a)][n]) >> @[a][n], asz : size_t(n), env : &(env) >> _) :
+  sizeLte(n)
+
+// end of [array_foreach_env]
+//
+fun {a:vt0p}{env:vt0p} array_foreach$cont (x : &a, env : &env) : bool
+
+fun {a:vt0p}{env:vt0p} array_foreach$fwork ( x : &a >> _
+                                           , env : &(env) >> _
+                                           ) : void
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} array_foreach_funenv {v:view}{vt:vtype}{n:int}{fe:eff}
+(pf : !v
+| A0 : &(@[INV(a)][n]) >> @[a][n], asz : size_t(n), f0 : (!v | &a >> _, !vt) -<fun,fe> void, env : !vt) 
+  :<fe> void
+
+// end of [array_foreach_funenv]
+//
+fun array_foreach_funenv_tsz
+{a:vt0p}{v:view}{vt:vtype}{n:int}{fe:eff}( pf : !v
+                                         | A0 : &(@[INV(a)][n]) >> @[a][n]
+                                         , asz : size_t(n)
+                                         , tsz : sizeof_t(a)
+                                         , f0 : (!v | &a >> _, !vt) -<fun,fe> void
+                                         , env : !vt
+                                         ) :<fe> void =
+  "ext#%"
+
+// end of [array_foreach_funenv_tsz]
+//
+(* ****** ****** *)
+fun { a1, a2 : vt0p } array_foreach2 {n:int}
+( A1 : &(@[INV(a1)][n]) >> @[a1][n]
+, A2 : &(@[INV(a2)][n]) >> @[a2][n]
+, asz : size_t(n)
+) : sizeLte(n)
+
+// end of [array_foreach2]
+//
+fun { a1, a2 : vt0p }{env:vt0p} array_foreach2_env {n:int}
+( A1 : &(@[INV(a1)][n]) >> @[a1][n]
+, A2 : &(@[INV(a2)][n]) >> @[a2][n]
+, asz : size_t(n)
+, env : &(env) >> env
+) : sizeLte(n)
+
+// end of [array_foreach2_env]
+//
+fun { a1, a2 : vt0p }{env:vt0p} array_foreach2$cont ( x1 : &a1
+                                                    , x2 : &a2
+                                                    , env : &env
+                                                    ) : bool
+
+fun { a1, a2 : vt0p }{env:vt0p} array_foreach2$fwork ( x1 : &a1 >> _
+                                                     , x2 : &a2 >> _
+                                                     , env : &(env) >> _
+                                                     ) : void
+
+//
+(* ****** ****** *)
+fun {a:vt0p} array_iforeach {n:int} ( A0 : &(@[INV(a)][n]) >> @[a][n]
+                                    , asz : size_t(n)
+                                    ) : sizeLte(n)
+
+// end of [array_iforeach]
+//
+fun {a:vt0p}{env:vt0p} array_iforeach_env {n:int}
+(A0 : &(@[INV(a)][n]) >> @[a][n], asz : size_t(n), env : &(env) >> _) :
+  sizeLte(n)
+
+// end of [array_iforeach_env]
+//
+fun {a:vt0p}{env:vt0p} array_iforeach$cont ( i : size_t
+                                           , x : &a
+                                           , env : &env
+                                           ) : bool
+
+fun {a:vt0p}{env:vt0p} array_iforeach$fwork ( i : size_t
+                                            , x : &(a) >> _
+                                            , env : &(env) >> _
+                                            ) : void
+
+//
+(* ****** ****** *)
+fun {a:vt0p} array_rforeach {n:int} ( A : &(@[INV(a)][n]) >> @[a][n]
+                                    , asz : size_t(n)
+                                    ) : sizeLte(n)
+
+// end of [array_rforeach]
+//
+fun {a:vt0p}{env:vt0p} array_rforeach_env {n:int}
+(A0 : &(@[INV(a)][n]) >> @[a][n], asz : size_t(n), env : &(env) >> _) :
+  sizeLte(n)
+
+// end of [array_rforeach_env]
+//
+fun {a:vt0p}{env:vt0p} array_rforeach$cont (x : &a, env : &env) : bool
+
+fun {a:vt0p}{env:vt0p} array_rforeach$fwork ( x : &a >> _
+                                            , env : &(env) >> _
+                                            ) : void
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} array_initize {n:int} ( A : &(@[a?][n]) >> @[a][n]
+                                   , asz : size_t(n)
+                                   ) : void
+
+// end of [array_initize]
+//
+fun {a:vt0p} array_initize$init (i : size_t, x : &a? >> a) : void
+
+//
+(* ****** ****** *)
+fun {a:t0p} array_initize_elt {n:int} ( A : &(@[a?][n]) >> @[a][n]
+                                      , asz : size_t(n)
+                                      , elt : (a)
+                                      ) :<!wrt> void
+
+// end of [array_initize_elt]
+(* ****** ****** *)
+fun {a:t0p} array_initize_list {n:int} ( A : &(@[a?][n]) >> @[a][n]
+                                       , asz : int(n)
+                                       , xs : list(INV(a), n)
+                                       ) :<!wrt> void
+
+// end of [array_initize_list]
+fun {a:t0p} array_initize_rlist {n:int} ( A : &(@[a?][n]) >> @[a][n]
+                                        , asz : int(n)
+                                        , xs : list(INV(a), n)
+                                        ) :<!wrt> void
+
+// end of [array_initize_rlist]
+(* ****** ****** *)
+fun {a:vt0p} array_initize_list_vt {n:int} ( A : &(@[a?][n]) >> @[a][n]
+                                           , asz : int(n)
+                                           , xs : list_vt(INV(a), n)
+                                           ) :<!wrt> void
+
+// end of [array_initize_list_vt]
+fun {a:vt0p} array_initize_rlist_vt {n:int} ( A : &(@[a?][n]) >> @[a][n]
+                                            , asz : int(n)
+                                            , xs : list_vt(INV(a), n)
+                                            ) :<!wrt> void
+
+// end of [array_initize_rlist_vt]
+(* ****** ****** *)
+//
+fun {a:vt0p} array_uninitize {n:int} ( A0 : &(@[INV(a)][n]) >> @[a?][n]
+                                     , asz : size_t(n)
+                                     ) : void
+
+// end of [array_uninitize]
+//
+fun {a:vt0p} array_uninitize$clear (i : size_t, x : &a >> a?) : void
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} array_bsearch$ford (x : &RD(a)) :<> int
+
+//
+fun {a:vt0p} array_bsearch {n:int} (A : &RD(@[a][n]), n : size_t(n)) :<>
+  sizeLte(n)
+
+//
+fun {a:vt0p} array_bsearch_fun {n:int} ( A0 : &RD(@[a][n])
+                                       , asz : size_t(n)
+                                       , key : &RD(a)
+                                       , cmp : cmpref(a)
+                                       ) :<> sizeLte(n)
+
+// end of [array_bsearch_fun]
+//
+(* ****** ****** *)
+//
+(*
+** HX: this one is based on [bsearch] in [stdlib]
+*)
+fun {a:vt0p} array_bsearch_stdlib {n:int} ( A0 : &RD(@[a][n])
+                                          , asz : size_t(n)
+                                          , key : &RD(a)
+                                          , cmp : cmpref(a)
+                                          ) :<> Ptr0
+
+(* found/~found : ~null/null *)
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} array_quicksort {n:int} ( A : &(@[INV(a)][n]) >> @[a][n]
+                                     , n : size_t(n)
+                                     ) :<!wrt> void
+
+// end-of-function
+fun {a:vt0p} array_quicksort$cmp (x1 : &RD(a), x2 : &RD(a)) :<> int
+
+(*sgn*)
+//
+(* ****** ****** *)
+(*
+** HX: this one is based on [qsort] in [stdlib]
+*)
+fun {a:vt0p} array_quicksort_stdlib {n:int}
+(A : &(@[INV(a)][n]) >> @[a][n], n : size_t(n), cmp : cmpref(a)) :<!wrt>
+  void
+
+// end of [array_quicksort_stdlib]
+(* ****** ****** *)
+//
+fun {a:vt0p}{b:vt0p} array_mapto {n:int} ( A : &array(INV(a), n)
+                                         , B : &array(b?, n) >> array(b, n)
+                                         , n : size_t(n)
+                                         ) : void
+
+// end of [array_mapto]
+//
+fun {a:vt0p}{b:vt0p} array_mapto$fwork (x : &a, y : &b? >> b) : void
+
+//
+(* ****** ****** *)
+//
+fun { a, b : vt0p }{c:vt0p} array_map2to {n:int} ( A : &array(INV(a), n)
+                                                 , B : &array(INV(b), n)
+                                                 , C : &array(c?, n) >> array(c, n)
+                                                 , n : size_t(n)
+                                                 ) : void
+
+// end of [array_map2to]
+//
+fun { a, b : vt0p }{c:vt0p} array_map2to$fwork ( x : &a
+                                               , y : &b
+                                               , z : &c? >> c
+                                               ) : void
+
+//
+(* ****** ****** *)
+//
+(*
+HX-2016:
+Fisher–Yates shuffle
+*)
+//
+fun {a:vt0p} array_permute {n:int} ( A : &(@[INV(a)][n]) >> @[a][n]
+                                   , n : size_t(n)
+                                   ) : void
+
+//
+fun array_permute$randint { n : int | n > 0 } (size_t(n)) : sizeLt(n)
+
+//
+(* ****** ****** *)
+(* end of [array.sats] *)
diff --git a/test/data/stdlib/array.sats b/test/data/stdlib/array.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/array.sats
@@ -0,0 +1,684 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2013 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/array.atxt
+** Time of generation: Mon Jun  4 01:42:39 2018
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: Feburary, 2012 *)
+
+(* ****** ****** *)
+
+vtypedef
+RD(a:vt0p) = a // for commenting: read-only
+#define NSH (x) x // for commenting: no sharing
+#define SHR (x) x // for commenting: it is shared
+
+(* ****** ****** *)
+
+sortdef t0p = t@ype
+sortdef vtp = viewtype
+sortdef vt0p = viewt@ype
+
+(* ****** ****** *)
+
+(*
+//
+// HX: [array_v] can also be defined as follows:
+//
+dataview
+array_v
+(
+  a:vt@ype+, addr, int
+) = // HX: for arry view
+  | {l:addr}
+    array_v_nil (a, l, 0)
+  | {l:addr}{n:int}
+    array_v_cons (a, l, n+1) of (a @ l, array_v (a, l+sizeof a, n))
+// end of [array_v]
+*)
+
+(* ****** ****** *)
+
+dataview
+arrayopt_v
+(
+  a:vt@ype+, addr, int, bool
+) = // HX: for optional array view
+  | {l:addr}{n:int}
+    arrayopt_v_some (a, l, n, true) of array_v (a, l, n)
+  | {l:addr}{n:int}
+    arrayopt_v_none (a, l, n, false) of array_v (a?, l, n)
+// end of [arrayopt_v]
+
+(* ****** ****** *)
+//
+exception
+ArraySubscriptExn of ()
+//
+(*
+fun
+ArraySubscriptExn():<> exn = "mac#%ArraySubscriptExn_make"
+fun
+isArraySubscriptExn(x: !exn):<> bool = "mac#%isArraySubscriptExn"
+//
+macdef
+ifArraySubscriptExn
+  {tres}(exn, body) =
+(
+let val x = ,(exn) in
+(
+//
+if
+isArraySubscriptExn(x)
+then (
+  let prval () = __vfree_exn (x) in ,(body) end
+) else $raise (x)
+//
+) : tres // end of [if]
+end (* end of [let] *)
+) // end of [ifArraySubscriptExn]
+*)
+//
+(* ****** ****** *)
+//
+praxi
+lemma_array_param
+  {a:vt0p}{l:addr}{n:int}
+  (A: &(@[INV(a)][n])): [n >= 0] void
+// end of [lemma_array_param]
+//
+praxi
+lemma_array_v_param
+  {a:vt0p}{l:addr}{n:int}
+  (pf: !array_v (INV(a), l, n)): [n >= 0] void
+// end of [lemma_array_v_param]
+//
+(* ****** ****** *)
+//
+praxi
+array_v_nil :
+  {a:vt0p}{l:addr} () -<prf> array_v (a, l, 0)
+//
+praxi
+array_v_unnil :
+  {a:vt0p}{l:addr} array_v (a, l, 0) -<prf> void
+//
+prfun
+array_v_unnil_nil :
+  {a1,a2:vt0p}{l:addr} array_v (a1, l, 0) -<prf> array_v (a2, l, 0)
+// end of [array_v_unnil_nil]
+//
+(* ****** ****** *)
+//
+praxi
+array_v_cons :
+{a:vt0p}{l:addr}{n:int}
+(a @ l, array_v (INV(a), l+sizeof(a), n)) -<prf> array_v (a, l, n+1)
+//
+praxi
+array_v_uncons :
+{a:vt0p}{l:addr}{n:int | n > 0}
+array_v (INV(a), l, n) -<prf> (a @ l, array_v (a, l+sizeof(a), n-1))
+//
+(* ****** ****** *)
+
+prfun
+array_v_sing
+  {a:vt0p}{l:addr} (pf: INV(a) @ l): array_v (a, l, 1)
+prfun
+array_v_unsing
+  {a:vt0p}{l:addr} (pf: array_v (INV(a), l, 1)): a @ l
+
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+array_getref_at
+  {n:int} (A: &RD(@[INV(a)][n]), i: sizeLt n):<> cPtr1(a)
+//
+(* ****** ****** *)
+//
+fun{
+a:t0p}{tk:tk
+} array_get_at_gint
+  {n:int}
+  (A: &RD(@[INV(a)][n]), i: g1intLt(tk, n)):<> a
+//
+fun{
+a:t0p}{tk:tk
+} array_get_at_guint
+  {n:int}
+  (A: &RD(@[INV(a)][n]), i: g1uintLt(tk, n)):<> a
+//
+overload [] with array_get_at_gint of 0
+overload [] with array_get_at_guint of 0
+//
+symintr array_get_at
+overload array_get_at with array_get_at_gint of 0
+overload array_get_at with array_get_at_guint of 0
+//
+(* ****** ****** *)
+//
+fun{
+a:t0p}{tk:tk
+} array_set_at_gint
+  {n:int}
+  (A: &(@[INV(a)][n]), i: g1intLt(tk, n), x: a):<!wrt> void
+//
+fun{
+a:t0p}{tk:tk
+} array_set_at_guint
+  {n:int}
+  (A: &(@[INV(a)][n]), i: g1uintLt(tk, n), x: a):<!wrt> void
+//
+overload [] with array_set_at_gint of 0
+overload [] with array_set_at_guint of 0
+//
+symintr array_set_at
+overload array_set_at with array_set_at_gint of 0
+overload array_set_at with array_set_at_guint of 0
+//
+(* ****** ****** *)
+
+fun{
+a:vt0p}{tk:tk
+} array_exch_at_gint{n:int}
+(
+  A: &(@[INV(a)][n]), i: g1intLt (tk, n), x: &a >> _
+) :<!wrt> void
+fun{
+a:vt0p}{tk:tk
+} array_exch_at_guint{n:int}
+(
+  A: &(@[INV(a)][n]), i: g1uintLt (tk, n), x: &a >> _
+) :<!wrt> void
+
+symintr array_exch_at
+overload array_exch_at with array_exch_at_gint of 0
+overload array_exch_at with array_exch_at_guint of 0
+
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+array_subreverse
+ {n:int}
+ {i,j:int |
+  0 <= i; i <= j; j <= n}
+(
+  A: &(@[INV(a)][n]), i: size_t(i), j: size_t(j)
+) :<!wrt> void // end of [array_subreverse]
+
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+array_interchange
+  {n:int}
+(
+  A: &(@[INV(a)][n]), i: sizeLt (n), j: sizeLt (n)
+) :<!wrt> void // end of [array_interchange]
+
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+array_subcirculate
+  {n:int}
+(
+  A: &(@[INV(a)][n]), i: sizeLt (n), j: sizeLt (n)
+) :<!wrt> void // end of [array_subcirculate]
+
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+array_ptr_takeout
+  {l:addr}{n:int}{i:nat | i < n}
+(
+  array_v (INV(a), l, n) | ptr l, size_t i
+) : (
+  a @ (l+i*sizeof(a))
+, a @ (l+i*sizeof(a)) -<lin,prf> array_v (a, l, n)
+| ptr (l+i*sizeof(a))
+) (* end of [array_ptr_takeout] *)
+
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+array_ptr_alloc
+  {n:int}
+(
+  asz: size_t n
+) :<!wrt> [l:agz]
+(
+  array_v (a?, l, n), mfree_gc_v (l) | ptr l
+) (* end of [array_ptr_alloc] *)
+
+fun
+{(*void*)}
+array_ptr_free
+  {a:vt0p}{l:addr}{n:int}
+(
+  array_v (a?, l, n), mfree_gc_v (l) | ptr l
+) :<!wrt> void // end-of-function
+
+(* ****** ****** *)
+//
+fun
+{(*void*)}
+fprint_array$sep (out: FILEref): void
+//
+fun{a:vt0p}
+fprint_array_int{n:int}
+(
+  out: FILEref, A: &RD(@[INV(a)][n]), n: int(n)
+) : void // end of [fprint_array_int]
+fun{a:vt0p}
+fprint_array_size{n:int}
+(
+  out: FILEref, A: &RD(@[INV(a)][n]), n: size_t(n)
+) : void // end of [fprint_array_size]
+//
+symintr fprint_array
+overload fprint_array with fprint_array_int
+overload fprint_array with fprint_array_size
+//
+fun
+{a:vt0p}
+fprint_array_sep{n:int}
+(
+  out: FILEref
+, A: &RD(@[INV(a)][n]), n: size_t n, sep: NSH(string)
+) : void // end of [fprint_array_sep]
+//
+(* ****** ****** *)
+
+overload fprint with fprint_array
+overload fprint with fprint_array_sep
+
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+array_copy{n:int}
+(
+  to: &(@[a?][n]) >> @[a][n]
+, from: &RD(@[INV(a)][n]) >> @[a?!][n]
+, n: size_t (n)
+) :<!wrt> void // end of [array_copy]
+
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+array_copy_from_list{n:int}
+(
+  A: &(@[a?][n]) >> @[a][n], xs: list (INV(a), n)
+) :<!wrt> void // end of [array_copy_from_list]
+//
+fun
+{a:vt0p}
+array_copy_from_list_vt{n:int}
+(
+  A: &(@[a?][n]) >> @[a][n], xs: list_vt (INV(a), n)
+) :<!wrt> void // end of [array_copy_from_list_vt]
+//
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+array_copy_to_list_vt{n:int}
+(
+  A: &RD(@[INV(a)][n]) >> @[a?!][n], n: size_t n
+) :<!wrt> list_vt (a, n) // endfun
+
+macdef array2list = array_copy_to_list_vt
+
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+array_tabulate$fopr(i: size_t): (a)
+//
+fun
+{a:vt0p}
+array_ptr_tabulate
+  {n:int}
+(
+  asz: size_t(n)
+) : [l:addr] (array_v(a, l, n), mfree_gc_v(l) | ptr(l))
+// end of [arrayptr_tabulate]
+//
+(* ****** ****** *)
+//
+fun{
+a:vt0p
+} array_foreach{n:int}
+(
+  A: &(@[INV(a)][n]) >> @[a][n], asz: size_t(n)
+) : sizeLte(n) // end of [array_foreach]
+//
+fun{
+a:vt0p}{env:vt0p
+} array_foreach_env{n:int}
+(
+  A: &(@[INV(a)][n]) >> @[a][n], asz: size_t(n), env: &(env) >> _
+) : sizeLte(n) // end of [array_foreach_env]
+//
+fun{
+a:vt0p}{env:vt0p
+} array_foreach$cont (x: &a, env: &env): bool
+fun{
+a:vt0p}{env:vt0p
+} array_foreach$fwork (x: &a >> _, env: &(env) >> _): void
+//
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+array_foreach_funenv
+  {v:view}
+  {vt:vtype}
+  {n:int}
+  {fe:eff}
+(
+  pf: !v
+| A0: &(@[INV(a)][n]) >> @[a][n], asz: size_t(n)
+, f0: (!v | &a >> _, !vt) -<fun,fe> void, env: !vt
+) :<fe> void
+// end of [array_foreach_funenv]
+//
+fun
+array_foreach_funenv_tsz
+  {a:vt0p}
+  {v:view}
+  {vt:vtype}
+  {n:int}
+  {fe:eff}
+(
+  pf: !v
+| A0: &(@[INV(a)][n]) >> @[a][n]
+, asz: size_t(n), tsz: sizeof_t(a)
+, f0: (!v | &a >> _, !vt) -<fun,fe> void, env: !vt
+) :<fe> void = "ext#%"
+// end of [array_foreach_funenv_tsz]
+//
+(* ****** ****** *)
+
+fun{
+a1,a2:vt0p
+} array_foreach2
+  {n:int}
+(
+  A1: &(@[INV(a1)][n]) >> @[a1][n]
+, A2: &(@[INV(a2)][n]) >> @[a2][n]
+, asz: size_t (n)
+) : sizeLte(n) // end of [array_foreach2]
+//
+fun{
+a1,a2:vt0p}{env:vt0p
+} array_foreach2_env
+  {n:int}
+(
+  A1: &(@[INV(a1)][n]) >> @[a1][n]
+, A2: &(@[INV(a2)][n]) >> @[a2][n]
+, asz:size_t (n)
+, env: &(env) >> env
+) : sizeLte(n) // end of [array_foreach2_env]
+//
+fun{
+a1,a2:vt0p}{env:vt0p
+} array_foreach2$cont
+  (x1: &a1, x2: &a2, env: &env): bool
+fun{
+a1,a2:vt0p}{env:vt0p
+} array_foreach2$fwork
+  (x1: &a1 >> _, x2: &a2 >> _, env: &(env) >> _): void
+//
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+array_iforeach
+  {n:int}
+(
+A0: &(@[INV(a)][n]) >> @[a][n], asz: size_t(n)
+) : sizeLte(n) // end of [array_iforeach]
+//
+fun{
+a:vt0p}{env:vt0p
+} array_iforeach_env
+  {n:int}
+(
+A0: &(@[INV(a)][n]) >> @[a][n], asz: size_t(n), env: &(env) >> _
+) : sizeLte(n) // end of [array_iforeach_env]
+//
+fun{
+a:vt0p}{env:vt0p
+} array_iforeach$cont(i: size_t, x: &a, env: &env): bool
+fun{
+a:vt0p}{env:vt0p
+} array_iforeach$fwork(i: size_t, x: &(a) >> _, env: &(env) >> _): void
+//
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+array_rforeach{n:int}
+(
+  A: &(@[INV(a)][n]) >> @[a][n], asz: size_t(n)
+) : sizeLte(n) // end of [array_rforeach]
+//
+fun{
+a:vt0p}{env:vt0p
+} array_rforeach_env{n:int}
+(
+A0: &(@[INV(a)][n]) >> @[a][n], asz: size_t(n), env: &(env) >> _
+) : sizeLte(n) // end of [array_rforeach_env]
+//
+fun{
+a:vt0p}{env:vt0p
+} array_rforeach$cont(x: &a, env: &env): bool
+fun{
+a:vt0p}{env:vt0p
+} array_rforeach$fwork(x: &a >> _, env: &(env) >> _): void
+//
+(* ****** ****** *)
+//
+fun{a:vt0p}
+array_initize{n:int}
+(
+  A: &(@[a?][n]) >> @[a][n], asz: size_t(n)
+) : void // end of [array_initize]
+//
+fun{a:vt0p}
+array_initize$init (i: size_t, x: &a? >> a): void
+//
+(* ****** ****** *)
+
+fun{a:t0p}
+array_initize_elt{n:int}
+(
+  A: &(@[a?][n]) >> @[a][n], asz: size_t n, elt: (a)
+) :<!wrt> void // end of [array_initize_elt]
+
+(* ****** ****** *)
+
+fun{a:t0p}
+array_initize_list{n:int}
+(
+  A: &(@[a?][n]) >> @[a][n], asz: int n, xs: list(INV(a), n)
+) :<!wrt> void // end of [array_initize_list]
+fun{a:t0p}
+array_initize_rlist{n:int}
+(
+  A: &(@[a?][n]) >> @[a][n], asz: int n, xs: list(INV(a), n)
+) :<!wrt> void // end of [array_initize_rlist]
+
+(* ****** ****** *)
+
+fun{a:vt0p}
+array_initize_list_vt{n:int}
+(
+  A: &(@[a?][n]) >> @[a][n], asz: int n, xs: list_vt(INV(a), n)
+) :<!wrt> void // end of [array_initize_list_vt]
+fun{a:vt0p}
+array_initize_rlist_vt{n:int}
+(
+  A: &(@[a?][n]) >> @[a][n], asz: int n, xs: list_vt(INV(a), n)
+) :<!wrt> void // end of [array_initize_rlist_vt]
+
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+array_uninitize
+  {n:int}
+(
+A0: &(@[INV(a)][n]) >> @[a?][n], asz: size_t(n)
+) : void // end of [array_uninitize]
+//
+fun{a:vt0p}
+array_uninitize$clear(i: size_t, x: &a >> a?): void
+//
+(* ****** ****** *)
+//
+fun{a:vt0p}
+array_bsearch$ford (x: &RD(a)):<> int
+//
+fun
+{a:vt0p}
+array_bsearch
+  {n:int}
+  (A: &RD(@[a][n]), n: size_t(n)):<> sizeLte(n)
+//
+fun
+{a:vt0p}
+array_bsearch_fun
+  {n:int}
+(
+A0: &RD(@[a][n]), asz: size_t(n), key: &RD(a), cmp: cmpref(a)
+//
+) :<> sizeLte(n) // end of [array_bsearch_fun]
+//
+(* ****** ****** *)
+//
+(*
+** HX: this one is based on [bsearch] in [stdlib]
+*)
+fun
+{a:vt0p}
+array_bsearch_stdlib
+  {n:int}
+(
+A0: &RD(@[a][n]), asz: size_t(n), key: &RD(a), cmp: cmpref(a)
+) :<> Ptr0 (* found/~found : ~null/null *)
+//
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+array_quicksort
+  {n:int}
+(
+  A: &(@[INV(a)][n]) >> @[a][n], n: size_t n
+) :<!wrt> void // end-of-function
+fun{a:vt0p}
+array_quicksort$cmp(x1: &RD(a), x2: &RD(a)):<> int(*sgn*)
+//
+(* ****** ****** *)
+
+(*
+** HX: this one is based on [qsort] in [stdlib]
+*)
+fun
+{a:vt0p}
+array_quicksort_stdlib
+  {n:int}
+(
+  A: &(@[INV(a)][n]) >> @[a][n], n: size_t(n), cmp: cmpref(a)
+) :<!wrt> void // end of [array_quicksort_stdlib]
+
+(* ****** ****** *)
+//
+fun{
+a:vt0p}{b:vt0p
+} array_mapto{n:int}
+(
+  A: &array(INV(a), n)
+, B: &array(b?, n) >> array (b, n)
+, n: size_t (n)
+) : void // end of [array_mapto]
+//
+fun{
+a:vt0p}{b:vt0p
+} array_mapto$fwork(x: &a, y: &b? >> b): void
+//
+(* ****** ****** *)
+//
+fun{
+a,b:vt0p}{c:vt0p
+} array_map2to{n:int}
+(
+  A: &array(INV(a), n)
+, B: &array(INV(b), n)
+, C: &array(c?, n) >> array (c, n)
+, n: size_t (n)
+) : void // end of [array_map2to]
+//
+fun{
+a,b:vt0p}{c:vt0p
+} array_map2to$fwork(x: &a, y: &b, z: &c? >> c): void
+//
+(* ****** ****** *)
+//
+(*
+HX-2016:
+Fisher–Yates shuffle
+*)
+//
+fun{a:vt0p}
+array_permute{n:int}
+  (A: &(@[INV(a)][n]) >> @[a][n], n: size_t(n)): void
+//
+fun{(*void*)}
+array_permute$randint{n:int | n > 0}(size_t(n)): sizeLt(n)
+//
+(* ****** ****** *)
+
+(* end of [array.sats] *)
diff --git a/test/data/stdlib/arrayref.out b/test/data/stdlib/arrayref.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/arrayref.out
@@ -0,0 +1,587 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/arrayref.atxt
+** Time of generation: Thu Jan 11 11:00:09 2018
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: February, 2012 *)
+(* ****** ****** *)
+#define NSH (x) x // for commenting: no sharing
+#define SHR (x) x // for commenting: it is shared
+
+(* ****** ****** *)
+sortdef tk = tkind
+
+(* ****** ****** *)
+sortdef t0p = t@ype and vt0p = vt@ype
+
+(* ****** ****** *)
+//
+// arrayref:
+// reference to an array without size attached 
+//
+(* ****** ****** *)
+
+#if(0)
+//
+// HX-2013-06:
+// it is declared in [basic_dyn.sats]
+//
+abstype
+arrayref_vt0ype_int_type
+  (a: vt@ype(*elt*), n: int(*size*)) = ptr
+stadef arrayref = arrayref_vt0ype_int_type
+#endif
+(* ****** ****** *)
+//
+praxi lemma_arrayref_param {a:vt0p}{n:int} (A0 : arrayref(a, n)) :
+  [n >= 0] void
+
+//
+(* ****** ****** *)
+//
+castfn arrayref2ptr {a:vt0p}{n:int} (A : arrayref(a, n)) :<> Ptr0
+
+//
+(* ****** ****** *)
+//
+(*
+**
+** HX-2012-06:
+**
+** this function essentially passes the proof of
+** array-view to GC (leaks it if GC is unavailable)
+*)
+//
+castfn arrayptr_refize {a:vt0p}{l:addr}{n:int}
+(A0 : arrayptr(INV(a), l, n)) :<!wrt> arrayref(a, n)
+
+//
+castfn arrayref_get_viewptr {a:vt0p}{n:int} (A0 : arrayref(a, n)) :<>
+  [l:addr] (vbox(array_v(a,l,n)) | ptr(l))
+
+(* end of [arrayref_get_viewptr] *)
+//
+(* ****** ****** *)
+//
+fun arrayref_make_arrpsz {a:vt0p}{n:int}(arrpsz(INV(a),n)) :<!wrt>
+  arrayref(a, n) =
+  "mac#%"
+
+//
+symintr arrayref
+
+//
+overload arrayref with arrayref_make_arrpsz
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} arrayref_make_elt {n:int} (asz : size_t(n), x0 : a) :<!wrt>
+  arrayref(a, n)
+
+// end of [arrayref_make_elt]
+//
+(* ****** ****** *)
+//
+fun arrayref_make_intrange { l, r : int | l <= r } ( l : int(l)
+                                                   , r : int(r)
+                                                   ) :<!wrt> arrayref(int, r-l)
+
+// end of [arrayref_make_intrange]
+//
+(* ****** ****** *)
+//
+fun {a:t0p} arrayref_make_list {n:int} ( asz : int(n)
+                                       , xs : list(INV(a), n)
+                                       ) :<!wrt> arrayref(a, n)
+
+// end of [arrayref_make_list]
+//
+fun {a:t0p} arrayref_make_rlist {n:int} ( asz : int(n)
+                                        , xs : list(INV(a), n)
+                                        ) :<!wrt> arrayref(a, n)
+
+// end of [arrayref_make_rlist]
+//
+(* ****** ****** *)
+//
+// HX-2014-02:
+// [A] must survive [arrayref_tail(A)]
+// in order to support proper garbage-collection
+//
+fun {a:t0p} arrayref_head {n:pos} (A : arrayref(a, n)) :<!ref> (a)
+
+// A[0]
+fun {a:t0p} arrayref_tail {n:pos} (A : arrayref(a, n)) :<!ref>
+  arrayref(a, n-1)
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p}{tk:tk} arrayref_get_at_gint {n:int}{ i : nat | i < n }
+(A0 : arrayref(a, n), i : g1int(tk, i)) :<!ref> (a)
+
+// arrayref_get_at_gint
+//
+fun {a:t0p}{tk:tk} arrayref_get_at_guint {n:int}{ i : nat | i < n }
+(A0 : arrayref(a, n), i : g1uint(tk, i)) :<!ref> (a)
+
+// arrayref_get_at_guint
+//
+symintr arrayref_get_at
+
+//
+overload arrayref_get_at with arrayref_get_at_gint of 0
+
+overload arrayref_get_at with arrayref_get_at_guint of 0
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p}{tk:tk} arrayref_set_at_gint {n:int}{ i : nat | i < n }
+(A : arrayref(a, n), i : g1int(tk, i), x : a) :<!refwrt> void
+
+// end of [arrayref_set_at_gint]
+//
+fun {a:t0p}{tk:tk} arrayref_set_at_guint {n:int}{ i : nat | i < n }
+(A : arrayref(a, n), i : g1uint(tk, i), x : a) :<!refwrt> void
+
+// end of [arrayref_set_at_guint]
+//
+symintr arrayref_set_at
+
+//
+overload arrayref_set_at with arrayref_set_at_gint of 0
+
+overload arrayref_set_at with arrayref_set_at_guint of 0
+
+//
+(* ****** ****** *)
+fun {a:vt0p}{tk:tk} arrayref_exch_at_gint {n:int}{ i : nat | i < n }
+(A0 : arrayref(a, n), i : g1int(tk, i), x : &a >> _) :<!refwrt> void
+
+// arrayref_exch_at_gint
+fun {a:vt0p}{tk:tk} arrayref_exch_at_guint {n:int}{ i : nat | i < n }
+(A0 : arrayref(a, n), i : g1uint(tk, i), x : &a >> _) :<!refwrt> void
+
+// arrayref_exch_at_guint
+//
+symintr arrayref_exch_at
+
+//
+overload arrayref_exch_at with arrayref_exch_at_gint of 0
+
+overload arrayref_exch_at with arrayref_exch_at_guint of 0
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} arrayref_interchange {n:int} ( A : arrayref(a, n)
+                                          , i : sizeLt(n)
+                                          , j : sizeLt(n)
+                                          ) :<!refwrt> void
+
+// end-of-function
+//
+(* ****** ****** *)
+fun {a:vt0p} arrayref_subcirculate {n:int} ( A : arrayref(a, n)
+                                           , i : sizeLt(n)
+                                           , j : sizeLt(n)
+                                           ) :<!refwrt> void
+
+// end-of-function
+(* ****** ****** *)
+(*
+fun{}
+fprint_array$sep
+  (out: FILEref): void
+*)
+fun {a:vt0p} fprint_arrayref {n:int} ( FILEref
+                                     , arrayref(a,n)
+                                     , asz : size_t(n)
+                                     ) : void
+
+// end of [fprint_arrayref]
+fun {a:vt0p} fprint_arrayref_sep {n:int} ( FILEref
+                                         , arrayref(a,n)
+                                         , asz : size_t(n)
+                                         , sep : NSH(string)
+                                         ) : void
+
+// end of [fprint_arrayref_sep]
+(* ****** ****** *)
+fun {a:t0p} arrayref_copy {n:int} (A : arrayref(a, n), n : size_t(n)) :
+  arrayptr(a, n)
+
+// end of [arrayref_copy]
+(* ****** ****** *)
+//
+(*
+fun{a:vt0p}
+array_tabulate$fopr(index: size_t): (a)
+*)
+fun {a:vt0p} arrayref_tabulate {n:int} (asz : size_t(n)) :
+  arrayref(a, n)
+
+//
+(* ****** ****** *)
+(*
+fun
+{a:vt0p}
+{env:vt0p}
+array_foreach$cont
+  (x: &a, env: &env): void
+fun
+{a:vt0p}
+{env:vt0p}
+array_foreach$fwork
+  (x: &a >> a, env: &(env) >> _): void
+*)
+fun {a:vt0p} arrayref_foreach {n:int} ( A0 : arrayref(a, n)
+                                      , asz : size_t(n)
+                                      ) : sizeLte(n)
+
+// end of [arrayref_foreach]
+fun {a:vt0p}{env:vt0p} arrayref_foreach_env {n:int}
+(A0 : arrayref(a, n), asz : size_t(n), env : &env >> _) : sizeLte(n)
+
+// end of [arrayref_foreach_env]
+(* ****** ****** *)
+(*
+fun
+{a:vt0p}
+{env:vt0p}
+array_iforeach$cont
+  (i: size_t, x: &a, env: &env): void
+fun
+{a:vt0p}
+{env:vt0p}
+array_iforeach$fwork
+  (i: size_t, x: &a >> a, env: &(env) >> _): void
+*)
+fun {a:vt0p} arrayref_iforeach {n:int} ( A : arrayref(a, n)
+                                       , asz : size_t(n)
+                                       ) : sizeLte(n)
+
+// end of [arrayref_iforeach]
+fun {a:vt0p}{env:vt0p} arrayref_iforeach_env {n:int}
+(A : arrayref(a, n), asz : size_t(n), env : &(env) >> _) : sizeLte(n)
+
+// end of [arrayref_iforeach_env]
+(* ****** ****** *)
+(*
+fun{a:vt0p}{env:vt0p}
+array_rforeach$cont (x: &a, env: &env): void
+fun{a:vt0p}{env:vt0p}
+array_rforeach$fwork (x: &a >> a, env: &(env) >> _): void
+*)
+fun {a:vt0p} arrayref_rforeach {n:int} ( A : arrayref(a, n)
+                                       , asz : size_t(n)
+                                       ) : sizeLte(n)
+
+// end of [arrayref_rforeach]
+fun {a:vt0p}{env:vt0p} arrayref_rforeach_env {n:int}
+(A : arrayref(a, n), asz : size_t(n), env : &(env) >> env) : sizeLte(n)
+
+// end of [arrayref_rforeach_env]
+(* ****** ****** *)
+//
+// HX-2017-02-19:
+// Using [gcompare_ref_ref] to check
+//
+fun {a:vt0p} arrayref_is_ordered {n:int} ( A : arrayref(a, n)
+                                         , asz : size_t(n)
+                                         ) : bool
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} arrayref_quicksort {n:int} ( A : arrayref(a, n)
+                                        , asz : size_t(n)
+                                        ) : void
+
+//
+fun {a:vt0p} arrayref_quicksort_stdlib {n:int} ( A : arrayref(a, n)
+                                               , asz : size_t(n)
+                                               , cmp : cmpref(a)
+                                               ) : void
+
+//
+(* ****** ****** *)
+(*
+//
+// HX: see below
+//
+fun
+{a:t0p}
+streamize_arrayref_elt
+  {n:int}
+  (A: arrayref(a, n), asz: size_t(n)):<!wrt> stream_vt(a)
+*)
+(* ****** ****** *)
+//
+// arrszref:
+// reference to an array with its size attached
+//
+(* ****** ****** *)
+
+#if(0)
+//
+// HX-2013-06:
+// it is declared in [basic_dyn.sats]
+//
+abstype
+arrszref_vt0ype_type (a: vt@ype) = ptr
+stadef arrszref = arrszref_vt0ype_type
+//
+#endif
+(* ****** ****** *)
+symintr arrszref
+
+(* ****** ****** *)
+fun arrszref_make_arrpsz {a:vt0p}{n:int} (arrpsz(INV(a),n)) :<!wrt>
+  arrszref(a)
+
+//
+overload arrszref with arrszref_make_arrpsz
+
+//
+(* ****** ****** *)
+fun arrszref_make_arrayref {a:vt0p}{n:int} ( A : SHR(arrayref(a,n))
+                                           , n : size_t(n)
+                                           ) :<!wrt> arrszref(a)
+
+// end of [arrszref_make_arrayref]
+(* ****** ****** *)
+fun {} arrszref_get_ref {a:vt0p} (A : arrszref(a)) :<> Ptr1
+
+fun {} arrszref_get_size {a:vt0p} (A : arrszref(a)) :<> size_t
+
+(* ****** ****** *)
+//
+fun arrszref_get_refsize {a:vt0p} ( A : arrszref(a)
+                                  , asz : &size_t? >> size_t(n)
+                                  ) :<!wrt> #[n:nat] arrayref(a, n)
+
+// end-of-fun
+//
+(* ****** ****** *)
+fun {a:t0p} arrszref_make_elt (asz : size_t, x : a) :<!wrt> arrszref(a)
+
+// end of [arrszref_make_elt]
+(* ****** ****** *)
+fun {a:t0p} arrszref_make_list (xs : List(INV(a))) :<!wrt> arrszref(a)
+
+// end of [arrszref_make_list]
+fun {a:t0p} arrszref_make_rlist (xs : List(INV(a))) :<!wrt> arrszref(a)
+
+// end of [arrszref_make_rlist]
+(* ****** ****** *)
+(*
+fun{}
+fprint_array$sep(out: FILEref): void
+*)
+fun {a:vt0p} fprint_arrszref (out : FILEref, A : arrszref(a)) : void
+
+// end of [fprint_arrszref]
+fun {a:vt0p} fprint_arrszref_sep ( out : FILEref
+                                 , A : arrszref(a)
+                                 , sep : NSH(string)
+                                 ) : void
+
+// end of [fprint_arrszref_sep]
+(* ****** ****** *)
+//
+fun {a:t0p} arrszref_get_at_size (A : arrszref(a), i : size_t) 
+  :<!exnref> a
+
+//
+fun {a:t0p}{tk:tk} arrszref_get_at_gint ( A : arrszref(a)
+                                        , i : g0int(tk)
+                                        ) :<!exnref> a
+
+//
+fun {a:t0p}{tk:tk} arrszref_get_at_guint ( A : arrszref(a)
+                                         , i : g0uint(tk)
+                                         ) :<!exnref> a
+
+//
+symintr arrszref_get_at
+
+overload arrszref_get_at with arrszref_get_at_gint of 0
+
+overload arrszref_get_at with arrszref_get_at_guint of 0
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} arrszref_set_at_size (A : arrszref(a), i : size_t, x : a) 
+  :<!exnrefwrt> void
+
+//
+fun {a:t0p}{tk:tk} arrszref_set_at_gint ( A : arrszref(a)
+                                        , i : g0int(tk)
+                                        , x : a
+                                        ) :<!exnrefwrt> void
+
+//
+fun {a:t0p}{tk:tk} arrszref_set_at_guint ( A : arrszref(a)
+                                         , i : g0uint(tk)
+                                         , x : a
+                                         ) :<!exnrefwrt> void
+
+//
+symintr arrszref_set_at
+
+//
+overload arrszref_set_at with arrszref_set_at_gint of 0
+
+overload arrszref_set_at with arrszref_set_at_guint of 0
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} arrszref_exch_at_size ( A0 : arrszref(a)
+                                   , i : size_t
+                                   , x : &a >> _
+                                   ) :<!exnrefwrt> void
+
+//
+fun {a:vt0p}{tk:tk} arrszref_exch_at_gint ( A0 : arrszref(a)
+                                          , i : g0int(tk)
+                                          , x : &a >> _
+                                          ) :<!exnrefwrt> void
+
+// end-of-function
+//
+fun {a:vt0p}{tk:tk} arrszref_exch_at_guint ( A0 : arrszref(a)
+                                           , i : g0uint(tk)
+                                           , x : &a >> _
+                                           ) :<!exnrefwrt> void
+
+// end-of-function
+//
+symintr arrszref_exch_at
+
+//
+overload arrszref_exch_at with arrszref_exch_at_gint of 0
+
+overload arrszref_exch_at with arrszref_exch_at_guint of 0
+
+(* ****** ****** *)
+//
+fun {a:vt0p} arrszref_interchange ( A : arrszref(a)
+                                  , i : size_t
+                                  , j : size_t
+                                  ) :<!exnrefwrt> void
+
+// end of [arrszref_interchange]
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} arrszref_subcirculate ( A : arrszref(a)
+                                   , i : size_t
+                                   , j : size_t
+                                   ) :<!exnrefwrt> void
+
+// end of [arrszref_subcirculate]
+//
+(* ****** ****** *)
+//
+(*
+fun{a:vt0p}
+array_tabulate$fopr(size_t): (a)
+*)
+fun {a:vt0p} arrszref_tabulate (asz : size_t) : arrszref(a)
+
+//
+(* ****** ****** *)
+//
+// HX: for streamization of arrays
+//
+(* ****** ****** *)
+//
+fun {a:t0p} streamize_arrszref_elt (ASZ : arrszref(a)) : stream_vt(a)
+
+fun {a:t0p} streamize_arrayref_elt {n:int} ( A : arrayref(a, n)
+                                           , n : size_t(n)
+                                           ) : stream_vt(a)
+
+//
+(* ****** ****** *)
+//
+// overloading for certain symbols
+//
+(* ****** ****** *)
+//
+overload [] with arrayref_get_at_gint of 0
+
+overload [] with arrayref_set_at_gint of 0
+
+overload [] with arrszref_get_at_gint of 0
+
+overload [] with arrszref_set_at_gint of 0
+
+//
+overload [] with arrayref_get_at_guint of 0
+
+overload [] with arrayref_set_at_guint of 0
+
+overload [] with arrszref_get_at_guint of 0
+
+overload [] with arrszref_set_at_guint of 0
+
+//
+(* ****** ****** *)
+overload .head with arrayref_head
+
+overload .tail with arrayref_tail
+
+(* ****** ****** *)
+overload size with arrszref_get_size
+
+overload .size with arrszref_get_size
+
+(* ****** ****** *)
+overload fprint with fprint_arrayref
+
+overload fprint with fprint_arrayref_sep
+
+overload fprint with fprint_arrszref
+
+overload fprint with fprint_arrszref_sep
+
+(* ****** ****** *)
+overload ptrcast with arrayref2ptr
+
+(* ****** ****** *)
+(* end of [arrayref.sats] *)
diff --git a/test/data/stdlib/arrayref.sats b/test/data/stdlib/arrayref.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/arrayref.sats
@@ -0,0 +1,676 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/arrayref.atxt
+** Time of generation: Thu Jan 11 11:00:09 2018
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: February, 2012 *)
+
+(* ****** ****** *)
+
+#define NSH (x) x // for commenting: no sharing
+#define SHR (x) x // for commenting: it is shared
+
+(* ****** ****** *)
+
+sortdef tk = tkind
+
+(* ****** ****** *)
+
+sortdef t0p = t@ype and vt0p = viewt@ype
+
+(* ****** ****** *)
+//
+// arrayref:
+// reference to an array without size attached 
+//
+(* ****** ****** *)
+
+#if(0)
+//
+// HX-2013-06:
+// it is declared in [basic_dyn.sats]
+//
+abstype
+arrayref_vt0ype_int_type
+  (a: vt@ype(*elt*), n: int(*size*)) = ptr
+stadef arrayref = arrayref_vt0ype_int_type
+#endif
+
+(* ****** ****** *)
+//
+praxi
+lemma_arrayref_param
+  {a:vt0p}{n:int}
+  (A0: arrayref(a, n)): [n >= 0] void
+//
+(* ****** ****** *)
+//
+castfn
+arrayref2ptr
+  {a:vt0p}{n:int}(A: arrayref(a, n)):<> Ptr0
+//
+(* ****** ****** *)
+//
+(*
+**
+** HX-2012-06:
+**
+** this function essentially passes the proof of
+** array-view to GC (leaks it if GC is unavailable)
+*)
+//
+castfn
+arrayptr_refize
+  {a:vt0p}
+  {l:addr}{n:int}
+(
+  A0:
+  arrayptr(INV(a), l, n)
+) :<!wrt> arrayref(a, n)
+//
+castfn
+arrayref_get_viewptr
+  {a:vt0p}{n:int}
+(
+  A0: arrayref(a, n)
+) :<>
+[
+  l:addr
+] (
+  vbox(array_v(a, l, n)) | ptr(l)
+) (* end of [arrayref_get_viewptr] *)
+//
+(* ****** ****** *)
+//
+fun
+arrayref_make_arrpsz
+  {a:vt0p}{n:int}
+(
+  arrpsz(INV(a), n)
+) :<!wrt> arrayref(a, n) = "mac#%"
+//
+symintr arrayref
+//
+overload
+arrayref with arrayref_make_arrpsz
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+arrayref_make_elt
+  {n:int}
+(
+  asz: size_t(n), x0: a
+) :<!wrt> arrayref(a, n)
+// end of [arrayref_make_elt]
+//
+(* ****** ****** *)
+//
+fun{}
+arrayref_make_intrange
+  {l,r:int | l <= r}
+(
+  l: int l, r: int r
+) :<!wrt> arrayref(int, r-l)
+// end of [arrayref_make_intrange]
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+arrayref_make_list
+  {n:int}
+(
+  asz: int n, xs: list(INV(a), n)
+) :<!wrt> arrayref(a, n)
+// end of [arrayref_make_list]
+//
+fun
+{a:t0p}
+arrayref_make_rlist
+  {n:int}
+(
+  asz: int n, xs: list(INV(a), n)
+) :<!wrt> arrayref(a, n)
+// end of [arrayref_make_rlist]
+//
+(* ****** ****** *)
+//
+// HX-2014-02:
+// [A] must survive [arrayref_tail(A)]
+// in order to support proper garbage-collection
+//
+fun
+{a:t0p}
+arrayref_head
+  {n:pos} (A: arrayref(a, n)):<!ref> (a) // A[0]
+fun
+{a:t0p}
+arrayref_tail
+  {n:pos} (A: arrayref(a, n)):<!ref> arrayref(a, n-1)
+//
+(* ****** ****** *)
+//
+fun{
+a:t0p}{tk:tk
+} arrayref_get_at_gint
+  {n:int}{i:nat | i < n}
+(
+A0: arrayref(a, n), i: g1int(tk, i)
+) :<!ref> (a) // arrayref_get_at_gint
+//
+fun{
+a:t0p}{tk:tk
+} arrayref_get_at_guint
+  {n:int}{i:nat | i < n}
+(
+A0: arrayref(a, n), i: g1uint(tk, i)
+) :<!ref> (a) // arrayref_get_at_guint
+//
+symintr
+arrayref_get_at
+//
+overload
+arrayref_get_at with arrayref_get_at_gint of 0
+overload
+arrayref_get_at with arrayref_get_at_guint of 0
+//
+(* ****** ****** *)
+//
+fun{
+a:t0p}{tk:tk
+} arrayref_set_at_gint
+  {n:int}{i:nat | i < n} (
+  A: arrayref(a, n), i: g1int(tk, i), x: a
+) :<!refwrt> void // end of [arrayref_set_at_gint]
+//
+fun{
+a:t0p}{tk:tk
+} arrayref_set_at_guint
+  {n:int}{i:nat | i < n} (
+  A: arrayref(a, n), i: g1uint(tk, i), x: a
+) :<!refwrt> void // end of [arrayref_set_at_guint]
+//
+symintr
+arrayref_set_at
+//
+overload
+arrayref_set_at with arrayref_set_at_gint of 0
+overload
+arrayref_set_at with arrayref_set_at_guint of 0
+//
+(* ****** ****** *)
+
+fun{
+a:vt0p}{tk:tk
+} arrayref_exch_at_gint
+  {n:int}{i:nat | i < n}
+(
+A0: arrayref(a, n), i: g1int(tk, i), x: &a >> _
+) :<!refwrt> void // arrayref_exch_at_gint
+
+fun{
+a:vt0p}{tk:tk
+} arrayref_exch_at_guint
+  {n:int}{i:nat | i < n}
+(
+A0: arrayref(a, n), i: g1uint(tk, i), x: &a >> _
+) :<!refwrt> void // arrayref_exch_at_guint
+//
+symintr
+arrayref_exch_at
+//
+overload
+arrayref_exch_at with arrayref_exch_at_gint of 0
+overload
+arrayref_exch_at with arrayref_exch_at_guint of 0
+//
+(* ****** ****** *)
+//
+fun{a:vt0p}
+arrayref_interchange
+  {n:int}
+(
+  A: arrayref(a, n), i: sizeLt(n), j: sizeLt(n)
+) :<!refwrt> void // end-of-function
+//
+(* ****** ****** *)
+
+fun{a:vt0p}
+arrayref_subcirculate
+  {n:int}
+(
+  A: arrayref(a, n), i: sizeLt(n), j: sizeLt(n)
+) :<!refwrt> void // end-of-function
+
+(* ****** ****** *)
+
+(*
+fun{}
+fprint_array$sep
+  (out: FILEref): void
+*)
+fun{a:vt0p}
+fprint_arrayref
+  {n:int}
+(
+  FILEref
+, arrayref(a, n), asz: size_t(n)
+) : void // end of [fprint_arrayref]
+fun{a:vt0p}
+fprint_arrayref_sep
+  {n:int}
+( FILEref
+, arrayref(a, n), asz: size_t(n), sep: NSH(string)
+) : void // end of [fprint_arrayref_sep]
+
+(* ****** ****** *)
+
+fun{a:t0p}
+arrayref_copy{n:int}
+  (A: arrayref(a, n), n: size_t(n)): arrayptr(a, n)
+// end of [arrayref_copy]
+
+(* ****** ****** *)
+//
+(*
+fun{a:vt0p}
+array_tabulate$fopr(index: size_t): (a)
+*)
+fun{a:vt0p}
+arrayref_tabulate
+  {n:int}(asz: size_t(n)): arrayref(a, n)
+//
+(* ****** ****** *)
+
+(*
+fun
+{a:vt0p}
+{env:vt0p}
+array_foreach$cont
+  (x: &a, env: &env): void
+fun
+{a:vt0p}
+{env:vt0p}
+array_foreach$fwork
+  (x: &a >> a, env: &(env) >> _): void
+*)
+fun
+{a:vt0p}
+arrayref_foreach{n:int}
+(
+A0: arrayref(a, n), asz: size_t(n)
+) : sizeLte(n) // end of [arrayref_foreach]
+fun
+{a:vt0p}
+{env:vt0p}
+arrayref_foreach_env{n:int}
+(
+A0: arrayref(a, n), asz: size_t(n), env: &env >> _
+) : sizeLte(n) // end of [arrayref_foreach_env]
+
+(* ****** ****** *)
+
+(*
+fun
+{a:vt0p}
+{env:vt0p}
+array_iforeach$cont
+  (i: size_t, x: &a, env: &env): void
+fun
+{a:vt0p}
+{env:vt0p}
+array_iforeach$fwork
+  (i: size_t, x: &a >> a, env: &(env) >> _): void
+*)
+fun
+{a:vt0p}
+arrayref_iforeach{n:int}
+(
+  A: arrayref(a, n), asz: size_t(n)
+) : sizeLte(n) // end of [arrayref_iforeach]
+fun
+{a:vt0p}
+{env:vt0p}
+arrayref_iforeach_env{n:int}
+(
+  A: arrayref(a, n), asz: size_t(n), env: &(env) >> _
+) : sizeLte(n) // end of [arrayref_iforeach_env]
+
+(* ****** ****** *)
+
+(*
+fun{a:vt0p}{env:vt0p}
+array_rforeach$cont (x: &a, env: &env): void
+fun{a:vt0p}{env:vt0p}
+array_rforeach$fwork (x: &a >> a, env: &(env) >> _): void
+*)
+fun{
+a:vt0p
+} arrayref_rforeach{n:int}
+(
+  A: arrayref(a, n), asz: size_t(n)
+) : sizeLte(n) // end of [arrayref_rforeach]
+fun{
+a:vt0p}{env:vt0p
+} arrayref_rforeach_env{n:int}
+(
+  A: arrayref(a, n), asz: size_t(n), env: &(env)>>env
+) : sizeLte(n) // end of [arrayref_rforeach_env]
+
+(* ****** ****** *)
+//
+// HX-2017-02-19:
+// Using [gcompare_ref_ref] to check
+//
+fun
+{a:vt0p}
+arrayref_is_ordered
+  {n:int}(A: arrayref(a, n), asz: size_t(n)): bool
+//
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+arrayref_quicksort
+  {n:int}(A: arrayref(a, n), asz: size_t(n)): void
+//
+fun
+{a:vt0p}
+arrayref_quicksort_stdlib
+  {n:int}
+  (A: arrayref(a, n), asz: size_t(n), cmp: cmpref(a)): void
+//
+(* ****** ****** *)
+(*
+//
+// HX: see below
+//
+fun
+{a:t0p}
+streamize_arrayref_elt
+  {n:int}
+  (A: arrayref(a, n), asz: size_t(n)):<!wrt> stream_vt(a)
+*)
+(* ****** ****** *)
+//
+// arrszref:
+// reference to an array with its size attached
+//
+(* ****** ****** *)
+
+#if(0)
+//
+// HX-2013-06:
+// it is declared in [basic_dyn.sats]
+//
+abstype
+arrszref_vt0ype_type (a: vt@ype) = ptr
+stadef arrszref = arrszref_vt0ype_type
+//
+#endif
+
+(* ****** ****** *)
+
+symintr arrszref
+
+(* ****** ****** *)
+
+fun{}
+arrszref_make_arrpsz
+  {a:vt0p}{n:int}
+  (arrpsz (INV(a), n)):<!wrt> arrszref(a)
+//
+overload arrszref with arrszref_make_arrpsz
+//
+(* ****** ****** *)
+
+fun{}
+arrszref_make_arrayref
+  {a:vt0p}{n:int}
+  (A: SHR(arrayref(a, n)), n: size_t(n)):<!wrt> arrszref(a)
+// end of [arrszref_make_arrayref]
+
+(* ****** ****** *)
+
+fun{
+} arrszref_get_ref{a:vt0p} (A: arrszref(a)):<> Ptr1
+fun{
+} arrszref_get_size{a:vt0p} (A: arrszref(a)):<> size_t
+
+(* ****** ****** *)
+//
+fun{}
+arrszref_get_refsize{a:vt0p}
+(
+  A: arrszref(a), asz: &size_t? >> size_t(n)
+) :<!wrt> #[n:nat] arrayref(a, n) // end-of-fun
+//
+(* ****** ****** *)
+
+fun{a:t0p}
+arrszref_make_elt(asz: size_t, x: a):<!wrt> arrszref(a)
+// end of [arrszref_make_elt]
+
+(* ****** ****** *)
+
+fun{a:t0p}
+arrszref_make_list(xs: List(INV(a))):<!wrt> arrszref(a)
+// end of [arrszref_make_list]
+
+fun{a:t0p}
+arrszref_make_rlist(xs: List(INV(a))):<!wrt> arrszref(a)
+// end of [arrszref_make_rlist]
+
+(* ****** ****** *)
+
+(*
+fun{}
+fprint_array$sep(out: FILEref): void
+*)
+fun{a:vt0p}
+fprint_arrszref
+  (out: FILEref, A: arrszref(a)): void
+// end of [fprint_arrszref]
+fun{a:vt0p}
+fprint_arrszref_sep
+(
+  out: FILEref, A: arrszref(a), sep: NSH(string)
+) : void // end of [fprint_arrszref_sep]
+
+(* ****** ****** *)
+//
+fun{a:t0p}
+arrszref_get_at_size
+  (A: arrszref(a), i: size_t):<!exnref> a
+//
+fun{
+a:t0p}{tk:tk
+} arrszref_get_at_gint
+  (A: arrszref(a), i: g0int(tk)):<!exnref> a
+//
+fun{
+a:t0p}{tk:tk
+} arrszref_get_at_guint
+  (A: arrszref(a), i: g0uint(tk)):<!exnref> a
+//
+symintr
+arrszref_get_at
+overload
+arrszref_get_at with arrszref_get_at_gint of 0
+overload
+arrszref_get_at with arrszref_get_at_guint of 0
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+arrszref_set_at_size
+  (A: arrszref(a), i: size_t, x: a):<!exnrefwrt> void
+//
+fun{
+a:t0p}{tk:tk
+} arrszref_set_at_gint
+  (A: arrszref(a), i: g0int(tk), x: a):<!exnrefwrt> void
+//
+fun{
+a:t0p}{tk:tk
+} arrszref_set_at_guint
+  (A: arrszref(a), i: g0uint(tk), x: a):<!exnrefwrt> void
+//
+symintr
+arrszref_set_at
+//
+overload
+arrszref_set_at with arrszref_set_at_gint of 0
+overload
+arrszref_set_at with arrszref_set_at_guint of 0
+//
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+arrszref_exch_at_size
+(
+A0: arrszref(a), i: size_t, x: &a >> _
+) :<!exnrefwrt> void
+//
+fun{
+a:vt0p
+}{tk:tk}
+arrszref_exch_at_gint
+(
+A0: arrszref(a), i: g0int(tk), x: &a >> _
+) :<!exnrefwrt> void // end-of-function
+//
+fun{
+a:vt0p
+}{tk:tk}
+arrszref_exch_at_guint
+(
+A0: arrszref(a), i: g0uint(tk), x: &a >> _
+) :<!exnrefwrt> void // end-of-function
+//
+symintr
+arrszref_exch_at
+//
+overload
+arrszref_exch_at with arrszref_exch_at_gint of 0
+overload
+arrszref_exch_at with arrszref_exch_at_guint of 0
+
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+arrszref_interchange
+  (A: arrszref(a), i: size_t, j: size_t):<!exnrefwrt> void
+// end of [arrszref_interchange]
+//
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+arrszref_subcirculate
+  (A: arrszref(a), i: size_t, j: size_t):<!exnrefwrt> void
+// end of [arrszref_subcirculate]
+//
+(* ****** ****** *)
+//
+(*
+fun{a:vt0p}
+array_tabulate$fopr(size_t): (a)
+*)
+fun{a:vt0p}
+arrszref_tabulate(asz: size_t): arrszref(a)
+//
+(* ****** ****** *)
+//
+// HX: for streamization of arrays
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+streamize_arrszref_elt
+  (ASZ: arrszref(a)): stream_vt(a)
+fun
+{a:t0p}
+streamize_arrayref_elt
+  {n:int}(A: arrayref(a, n), n: size_t(n)): stream_vt(a)
+//
+(* ****** ****** *)
+//
+// overloading for certain symbols
+//
+(* ****** ****** *)
+//
+overload [] with arrayref_get_at_gint of 0
+overload [] with arrayref_set_at_gint of 0
+overload [] with arrszref_get_at_gint of 0
+overload [] with arrszref_set_at_gint of 0
+//
+overload [] with arrayref_get_at_guint of 0
+overload [] with arrayref_set_at_guint of 0
+overload [] with arrszref_get_at_guint of 0
+overload [] with arrszref_set_at_guint of 0
+//
+(* ****** ****** *)
+
+overload .head with arrayref_head
+overload .tail with arrayref_tail
+
+(* ****** ****** *)
+
+overload size with arrszref_get_size
+overload .size with arrszref_get_size
+
+(* ****** ****** *)
+
+overload fprint with fprint_arrayref
+overload fprint with fprint_arrayref_sep
+overload fprint with fprint_arrszref
+overload fprint with fprint_arrszref_sep
+
+(* ****** ****** *)
+
+overload ptrcast with arrayref2ptr
+
+(* ****** ****** *)
+
+(* end of [arrayref.sats] *)
diff --git a/test/data/stdlib/basics_dyn.out b/test/data/stdlib/basics_dyn.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/basics_dyn.out
@@ -0,0 +1,884 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2013 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+//
+// Author of the file:
+// Hongwei Xi (gmhwxiATgmailDOTcom)
+// Start Time: September, 2011
+//
+(* ****** ****** *)
+#include "prelude/params.hats"
+
+(* ****** ****** *)
+//
+fun patsopt_version() : string =
+  "ext#%"
+
+//
+(* ****** ****** *)
+
+#if VERBOSE_PRELUDE #then
+#print "Loading [basics_dyn.sats] starts!\n"
+#endif // end of [VERBOSE_PRELUDE]
+(* ****** ****** *)
+//
+sortdef t0p = t@ype and vt0p = vt@ype
+
+//
+(* ****** ****** *)
+datatype TYPE(a: vt@ype) =
+  | TYPE(a) of ()
+
+(* ****** ****** *)
+//
+// HX-2012: In $ATSHOME/ccomp/runtime:
+// atsbool_true/atsbool_false are mapped to 1/0
+// this mapping is fixed and should never be changed!
+//
+#define true true_bool // shorthand
+#define false false_bool // shorthand
+
+//
+val true_bool: bool(true) = "mac#atsbool_true"
+
+// = 1
+val false_bool: bool(false) = "mac#atsbool_false"
+
+// = 0
+//
+(* ****** ****** *)
+//
+// HX: [false] implies all
+//
+prfun false_elim { X : prop | false } () : X
+
+//
+(* ****** ****** *)
+//
+typedef compopr_type(a: t@ype) = (a, a) -<fun0> bool
+typedef compare_type(a: t@ype) = (a, a) -<fun0> int
+
+(*-/0/+*)
+//
+(* ****** ****** *)
+//
+praxi lemma_subcls_reflexive {c:cls} () : [c <= c] void
+
+//
+praxi lemma_subcls_transitive { c1, c2, c3 : cls | c1 <= c2; c2 <= c3 }
+() : [c1 <= c3] void
+
+//
+(* ****** ****** *)
+//
+praxi praxi_int {i:int} () : int(i)
+
+//
+dataprop MUL_prop(int, int, int) =
+  | {n:int} MULbas((0, n, 0))
+  | {m:nat}{n:int}{p:int} MULind((m + 1, n, p + n)) of MUL_prop((m, n, p))
+  | {m:pos}{n:int}{p:int} MULneg((~(m), n, ~(p))) of MUL_prop((m, n, p))
+
+propdef MUL (m : int, n : int, mn : int) = MUL_prop(m, n, mn)
+
+//
+(* ****** ****** *)
+//
+// HX-2010-12-30: 
+//
+absprop DIVMOD (x : int, y : int, q : int, r : int)
+
+// end of [DIVMOD]
+//
+propdef DIV (x : int, y : int, q : int) = [r:int] DIVMOD(x, y, q, r)
+
+propdef MOD (x : int, y : int, r : int) = [q:int] DIVMOD(x, y, q, r)
+
+//
+(* ****** ****** *)
+dataprop EQINT(int, int) =
+  | {x:int} EQINT(x, x)
+
+prfun eqint_make { x, y : int | x == y } () : EQINT(x, y)
+
+//
+prfun eqint_make_gint {tk:tk}{x:int} (x : g1int(tk, x)) :
+  [y:int] EQINT(x, y)
+
+prfun eqint_make_guint {tk:tk}{x:int} (x : g1uint(tk, x)) :
+  [y:int] EQINT(x, y)
+
+//
+(* ****** ****** *)
+praxi praxi_ptr {l:addr} () : ptr(l)
+
+praxi praxi_bool {b:bool} () : bool(b)
+
+(* ****** ****** *)
+dataprop EQADDR(addr, addr) =
+  | {x:addr} EQADDR(x, x)
+
+prfun eqaddr_make { x, y : addr | x == y } () : EQADDR(x, y)
+
+//
+prfun eqaddr_make_ptr {x:addr} (x : ptr(x)) : [y:addr] EQADDR(x, y)
+
+//
+(* ****** ****** *)
+dataprop EQBOOL(bool, bool) =
+  | {x:bool} EQBOOL(x, x)
+
+prfun eqbool_make { x, y : bool | x == y } () : EQBOOL(x, y)
+
+//
+prfun eqbool_make_bool {x:bool} (x : bool(x)) : [y:bool] EQBOOL(x, y)
+
+//
+(* ****** ****** *)
+//
+dataprop EQTYPE(vt@ype, vt@ype) =
+  | {a:vt@ype} EQTYPE((a, a))
+
+(* ****** ****** *)
+prfun prop_verify { b : bool | b } () :<prf> void
+
+prfun prop_verify_and_add { b : bool | b } () :<prf> [b] void
+
+(* ****** ****** *)
+prfun pridentity_v {v:view} (x : !INV(v)) : void
+
+prfun pridentity_vt {vt:vt@ype} (x : !INV(vt)) : void
+
+(* ****** ****** *)
+castfn viewptr_match {a:vt0ype}{ l1, l2 : addr | l1 == l2 }
+(pf : INV(a) @ l1 | p : ptr(l2)) :<>
+  [ l : addr | l == l1 ] (a @ l | ptr(l))
+
+// end of [viewptr_match]
+(* ****** ****** *)
+//
+val {a:vt0ype} sizeof : size_t(sizeof(a))
+
+//
+praxi lemma_sizeof {a:vt0ype} () : [sizeof(a) >= 0] void
+
+//
+(* ****** ****** *)
+praxi topize {a:t0ype} (x : !INV(a) >> a?) : void
+
+(* ****** ****** *)
+castfn dataget {a:vt0ype} (x : !INV(a) >> a) : a?!
+
+(* ****** ****** *)
+//
+// HX: returning the pf to GC
+//
+praxi mfree_gc_v_elim {l:addr} (pf : mfree_gc_v(l)) :<prf> void
+
+// end of [mfree_gc_v_elim]
+(* ****** ****** *)
+praxi mfree_gcngc_v_nullify {l:addr} ( pf1 : mfree_gc_v(l)
+                                     , pf1 : mfree_ngc_v(l)
+                                     ) : void
+
+// end of [mfree_gcngc_nullify_v]
+(* ****** ****** *)
+//
+fun cloptr_free {a:t0p}(pclo : cloptr(a)) :<!wrt> void =
+  "mac#%"
+
+//
+overload free with cloptr_free of 0
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} lazy_force (lazyval : lazy(INV(a))) :<!laz> (a)
+
+//
+fun {a:vt0p} lazy_vt_force (lazyval : lazy_vt(INV(a))) :<!all> (a)
+
+//
+(*
+//
+// HX-2016-08:
+// this is assumed internally!
+//
+overload ! with lazy_force of 0
+overload ! with lazy_vt_force of 0
+*)
+//
+(* ****** ****** *)
+//
+// HX-2013:
+// macro implemented in [pats_ccomp_instrset]
+//
+fun lazy_vt_free {a:vt0p}(lazyval : lazy_vt(a)) :<!wrt> void =
+  "mac#%"
+
+//
+overload ~ with lazy_vt_free of 0
+
+overload free with lazy_vt_free of 0
+
+//
+(* ****** ****** *)
+//
+// HX-2014:
+// macro implemented in [pats_ccomp_instrset]
+//
+fun lazy2cloref {a:t0p}(lazy(a)) : () -<cloref1> (a) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+(*
+// HX-2012-05-23: this seems TOO complicated!
+(*
+** HX-2012-03: handling read-only views and vtypes
+*)
+castfn
+read_getval // copy out a non-linear value
+  {a:t@ype}{s:int}{n:int} (x: !READ (a, s, n)):<> a
+// end of [read_getval]
+
+praxi
+read_takeout{v:view}
+  (pf: !v >> READOUT (v, s)): #[s:int] READ (v, s, 0)
+// end of [read_takeout]
+praxi
+read_addback // HX: there is no need to check
+  {v1:view}{v2:view}{s:int} // if v1 and v2 match
+  (pf1: !READOUT (v1, s) >> v1, pf2: READ (v2, s, 0)): void
+// end of [read0_addback]
+
+praxi
+read_split
+  {v:view}{s:int}{n:int}
+  (pf: !READ (v, s, n) >> READ (v, s, n+1)): READ (v, s, 0)
+// end of [read_split]
+praxi
+read_unsplit // HX: there is no need to check
+  {v1:view}{v2:view}{s:int}{n1,n2:int} // if v1 and v2 match
+  (pf1: READ (v1, s, n1), pf2: READ (v2, s, n2)): READ (v1, s, n1+n2-1)
+// end of [read_unsplit]
+*)
+(* ****** ****** *)
+//
+castfn stamp_t {a:t@ype} (x : INV(a)) :<> stamped_t(a)
+
+// end of [stamp_t]
+castfn stamp_vt {a:vt@ype} (x : INV(a)) :<> stamped_vt(a)
+
+// end of [stamp_vt]
+//
+(* ****** ****** *)
+//
+castfn unstamp_t {a:t@ype}{x:int} (x : stamped_t(INV(a), x)) :<> a
+
+// end of [unstamp_t]
+castfn unstamp_vt {a:vt@ype}{x:int} (x : stamped_vt(INV(a), x)) :<> a
+
+// end of [unstamp_vt]
+//
+(* ****** ****** *)
+//
+castfn stamped_t2vt {a:t@ype}{x:int} (x : stamped_t(INV(a), x)) :<>
+  stamped_vt(a, x)
+
+// end of [stamped_t2vt]
+//
+castfn stamped_vt2t {a:t@ype}{x:int} (x : stamped_vt(INV(a), x)) :<>
+  stamped_t(a, x)
+
+// end of [stamped_vt2t]
+//
+fun {a:t@ype} stamped_vt2t_ref {x:int} (x : &stamped_vt(INV(a), x)) :<>
+  stamped_t(a, x)
+
+//
+(* ****** ****** *)
+//
+praxi vcopyenv_v_decode {v:view} (x : vcopyenv_v(v)) : vtakeout0(v)
+
+castfn vcopyenv_vt_decode {vt:vt0p} (x : vcopyenv_vt(vt)) :
+  vttakeout0(vt)
+
+//
+overload decode with vcopyenv_v_decode
+
+overload decode with vcopyenv_vt_decode
+
+//
+(* ****** ****** *)
+//
+// HX: the_null_ptr = (void*)0
+//
+val the_null_ptr: ptr(null) = "mac#the_atsptr_null"
+
+//
+(* ****** ****** *)
+//
+praxi lemma_addr_param {l:addr} () : [l >= null] void
+
+//
+(* ****** ****** *)
+praxi lemma_string_param {n:int} (x : string(n)) : [n >= 0] void
+
+// end of [lemma_string_param]
+praxi lemma_stropt_param {n:int} (x : stropt(n)) : [n >= ~1] void
+
+// end of [lemma_stropt_param]
+(* ****** ****** *)
+//
+dataprop SGN(int, int) =
+  | SGNzero((0, 0))
+  | {i:neg} SGNneg((i, ~1))
+  | {i:pos} SGNpos((i, 1))
+
+(* ****** ****** *)
+//
+// HX-2012-06:
+// indication of the failure of
+exception AssertExn of ()
+
+// an assertion
+//
+(* ****** ****** *)
+//
+// HX-2012-06:
+// indication of something expected
+exception NotFoundExn of ()
+
+// to be found but not
+//
+(* ****** ****** *)
+//
+exception GenerallyExn of (string)
+
+// for unspecified causes
+(*
+exception GenerallyExn2 of (string, ptr(*data*)) // for unspecified causes
+*)
+//
+(* ****** ****** *)
+//
+// HX-2012-07:
+// indication of a function argument being
+exception IllegalArgExn of (string)
+
+// out of its domain
+//
+(* ****** ****** *)
+praxi __vfree_exn(x : exn) :<> void
+
+// for freeing nullary exception-con
+(* ****** ****** *)
+//
+datatype unit =
+  | unit of ()
+
+dataprop unit_p =
+  | unit_p of ()
+
+dataview unit_v =
+  | unit_v of ()
+
+datavtype unit_vt =
+  | unit_vt of ()
+
+//
+prfun unit_v_elim(pf : unit_v) : void
+
+//
+(* ****** ****** *)
+//
+abstype boxed_t0ype_type(a: t@ype+) = unit
+absvtype boxed_vt0ype_vtype(a: vt@ype+) = unit
+
+//
+vtypedef boxed(a: vt@ype) = boxed_vt0ype_vtype(a)
+vtypedef boxed_vt(a: vt@ype) = boxed_vt0ype_vtype(a)
+
+//
+typedef boxed(a: t@ype) = boxed_t0ype_type(a)
+typedef boxed_t(a: t@ype) = boxed_t0ype_type(a)
+
+//
+fun {a:type} box  : (INV(a)) -> boxed_t(a)
+
+fun {a:type} unbox  : boxed_t(INV(a)) -> (a)
+
+fun {a:vtype} box_vt  : (INV(a)) -> boxed_vt(a)
+
+fun {a:vtype} unbox_vt  : boxed_vt(INV(a)) -> (a)
+
+//
+(* ****** ****** *)
+//
+stadef array (a: vt@ype, n: int) = @[a][n]
+
+//
+viewdef array_v(a: vt@ype, l: addr, n: int) = @[a][n] @ l
+
+//
+absvtype arrayptr_vt0ype_addr_int_vtype( a: vt0ype+
+                                       , l: addr
+                                       , n: int
+                                       ) = ptr(l)
+
+stadef arrayptr  = arrayptr_vt0ype_addr_int_vtype
+
+vtypedef arrayptr(a: vt0p, n: int) = [l:addr] arrayptr(a, l, n)
+
+//
+abstype arrayref_vt0ype_int_type(a: vt@ype, n: int) = ptr
+
+stadef arrayref  = arrayref_vt0ype_int_type
+
+//
+abstype arrszref_vt0ype_type(a: vt@ype) = ptr
+
+typedef arrszref(a: vt0p) = arrszref_vt0ype_type(a)
+
+//
+(* ****** ****** *)
+//
+datatype list_t0ype_int_type(a: t@ype+, int) =
+  | list_nil(a, 0) of ()
+  | { n : int | n >= 0 } list_cons( a
+                                  , n+1
+                                  ) of (a, list_t0ype_int_type(a, n))
+
+stadef list  = list_t0ype_int_type
+
+typedef List(a: t0p) = [n:int] list(a, n)
+typedef List0(a: t0p) = [ n : int | n >= 0 ] list(a, n)
+typedef List1(a: t0p) = [ n : int | n >= 1 ] list(a, n)
+typedef listLt(a: t0p, n: int) = [ k : nat | k < n ] list(a, k)
+typedef listLte(a: t0p, n: int) = [ k : nat | k <= n ] list(a, k)
+typedef listGt(a: t0p, n: int) = [ k : int | k > n ] list(a, k)
+typedef listGte(a: t0p, n: int) = [ k : int | k >= n ] list(a, k)
+typedef listBtw( a: t0p
+               , m: int
+               , n: int
+               ) = [ k : int | m <= k; k < n ] list(a, k)
+typedef listBtwe( a: t0p
+                , m: int
+                , n: int
+                ) = [ k : int | m <= k; k <= n ] list(a, k)
+
+//
+(* ****** ****** *)
+//
+datavtype list_vt0ype_int_vtype(a: vt@ype+, int) =
+  | list_vt_nil(a, 0) of ()
+  | { n : int | n >= 0 } list_vt_cons( a
+                                     , n+1
+                                     ) of (a, list_vt0ype_int_vtype(a, n))
+
+stadef list_vt  = list_vt0ype_int_vtype
+
+vtypedef List_vt(a: vt0p) = [n:int] list_vt(a, n)
+vtypedef List0_vt(a: vt0p) = [ n : int | n >= 0 ] list_vt(a, n)
+vtypedef List1_vt(a: vt0p) = [ n : int | n >= 1 ] list_vt(a, n)
+vtypedef listLt_vt(a: vt0p, n: int) = [ k : nat | k < n ] list_vt(a, k)
+vtypedef listLte_vt(a: vt0p, n: int) =
+  [ k : nat | k <= n ] list_vt(a, k)
+vtypedef listGt_vt(a: vt0p, n: int) = [ k : int | k > n ] list_vt(a, k)
+vtypedef listGte_vt(a: vt0p, n: int) =
+  [ k : int | k >= n ] list_vt(a, k)
+vtypedef listBtw_vt(a: vt0p, m: int, n: int) =
+  [ k : int | m <= k; k < n ] list_vt(a, k)
+vtypedef listBtwe_vt(a: vt0p, m: int, n: int) =
+  [ k : int | m <= k; k <= n ] list_vt(a, k)
+
+//
+(* ****** ****** *)
+//
+datatype stream_con(a: t@ype+) =
+  | stream_nil of ()
+  | stream_cons of (a, stream(a))   where
+                                    stream (a: t@ype) = lazy(stream_con(a))
+
+//
+datavtype stream_vt_con(a: vt@ype+) =
+  | stream_vt_nil of ()
+  | stream_vt_cons of (a, stream_vt(a))   where
+                                          stream_vt (a: vt@ype) = lazy_vt(stream_vt_con(a))
+
+//
+(* ****** ****** *)
+//
+datatype option_t0ype_bool_type(a: t@ype+, bool) =
+  | Some(a, true) of (INV(a))
+  | None(a, false)
+
+// end of [datatype]
+stadef option  = option_t0ype_bool_type
+
+typedef Option(a: t0p) = [b:bool] option(a, b)
+
+//
+datavtype option_vt0ype_bool_vtype(a: vt@ype+, bool) =
+  | Some_vt(a, true) of (INV(a))
+  | None_vt(a, false)
+
+// end of [option_vt0ype_bool_vtype]
+stadef option_vt  = option_vt0ype_bool_vtype
+
+vtypedef Option_vt(a: vt0p) = [b:bool] option_vt(a, b)
+
+//
+(* ****** ****** *)
+//
+praxi opt_some {a:vt0p} (x : !INV(a) >> opt(a, true)) :<prf> void
+
+praxi opt_unsome {a:vt0p} (x : !opt(INV(a), true) >> a) :<prf> void
+
+//
+fun {a:vt0p} opt_unsome_get (x : &opt(INV(a), true) >> a?) : (a)
+
+//
+praxi opt_none {a:vt0p} (x : !(a?) >> opt(a, false)) :<prf> void
+
+praxi opt_unnone {a:vt0p} (x : !opt(INV(a), false) >> a?) :<prf> void
+
+//
+praxi opt_clear {a:t0p}{b:bool} (x : !opt(INV(a), b) >> a?) :<prf> void
+
+//
+(* ****** ****** *)
+//
+dataprop or_prop_prop_int_prop(a0: prop+, a1: prop+, int) =
+  | POR_l(a0, a1, 0) of (INV(a0))
+  | POR_r(a0, a1, 1) of (INV(a1))
+
+dataview or_view_view_int_view(a0: view+, a1: view+, int) =
+  | VOR_l(a0, a1, 0) of (INV(a0))
+  | VOR_r(a0, a1, 1) of (INV(a1))
+
+//
+stadef por  = or_prop_prop_int_prop
+stadef vor  = or_view_view_int_view
+
+//
+dataprop option_prop_bool_prop(a: prop+, bool) =
+  | Some_p((a, true)) of (INV(a))
+  | None_p((a, false))
+
+stadef option_p  = option_prop_bool_prop
+
+//
+dataview option_view_bool_view(a: view+, bool) =
+  | Some_v(a, true) of (INV(a))
+  | None_v(a, false)
+
+// end of [option_view_bool_view]
+stadef option_v  = option_view_bool_view
+
+//
+(* ****** ****** *)
+//
+absvt@ype arrayopt(a: vt0p, n: int, b: bool) = array(a, n)
+
+//
+praxi arrayopt_some {a:vt0p}{n:int}
+(A : &array(a, n) >> arrayopt(a, n, true)) : void
+
+praxi arrayopt_none {a:vt0p}{n:int}
+(A : &array(a?, n) >> arrayopt(a, n, false)) : void
+
+praxi arrayopt_unsome {a:vt0p}{n:int}
+(A : &arrayopt(a, n, true) >> array(a, n)) : void
+
+praxi arrayopt_unnone {a:vt0p}{n:int}
+(A : &arrayopt(a, n, false) >> array(a?, n)) : void
+
+//
+(* ****** ****** *)
+absvtype argv_int_vtype(n: int) = ptr
+
+stadef argv  = argv_int_vtype
+
+(*
+[argv_takeout_strarr] is declared in prelude/SATS/extern.sats
+[argv_takeout_parrnull] is declared in prelude/SATS/extern.sats
+*)
+(* ****** ****** *)
+praxi lemma_argv_param {n:int} (argv : !argv(n)) : [n >= 0] void
+
+// end of [praxi]
+(* ****** ****** *)
+//
+fun argv_get_at {n:int}(argv : !argv(n), i : natLt(n)) :<> string =
+  "mac#%"
+
+fun argv_set_at {n:int}(argv : !argv(n), i : natLt(n), x : string) 
+  :<!wrt> void =
+  "mac#%"
+
+//
+overload [] with argv_get_at
+
+overload [] with argv_set_at
+
+//
+(* ****** ****** *)
+//
+fun listize_argc_argv {n:int} (argc : int(n), argv : !argv(n)) :
+  list_vt(string, n)
+
+//
+(* ****** ****** *)
+//
+symintr main0
+
+//
+fun main_void_0() : void =
+  "ext#mainats_void_0"
+
+fun main_argc_argv_0 { n : int | n >= 1 }( argc : int(n)
+                                         , argv : !argv(n)
+                                         ) : void =
+  "ext#mainats_argc_argv_0"
+
+//
+overload main0 with main_void_0
+
+overload main0 with main_argc_argv_0
+
+//
+(* ****** ****** *)
+//
+symintr main
+
+//
+fun main_void_int() : int =
+  "ext#mainats_void_int"
+
+fun main_argc_argv_int { n : int | n >= 1 }( argc : int(n)
+                                           , argv : !argv(n)
+                                           ) : int =
+  "ext#mainats_argc_argv_int"
+
+fun main_argc_argv_envp_int { n : int | n >= 1 }( argc : int(n)
+                                                , argv : !argv(n)
+                                                , envp : ptr
+                                                ) : int =
+  "ext#mainats_argc_argv_envp_int"
+
+//
+overload main with main_void_int
+
+overload main with main_argc_argv_int
+
+overload main with main_argc_argv_envp_int
+
+//
+(* ****** ****** *)
+//
+fun exit(ecode : int) :<!exn> {a:t0p} (a) =
+  "mac#%"
+
+fun exit_errmsg(ecode : int, msg : string) :<!exn> {a:t0p} (a) =
+  "mac#%"
+
+//
+(*
+fun exit_fprintf{ts:types}
+(
+  ecode: int, out: FILEref, fmt: printf_c ts, args: ts
+) :<!exn> {a:vt0p}(a) = "mac#%" // end of [exit_fprintf]
+*)
+//
+(* *****p* ****** *)
+//
+fun exit_void(ecode : int) :<!exn> void =
+  "mac#%"
+
+fun exit_errmsg_void(ecode : int, msg : string) :<!exn> void =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun assert_bool0(x : bool) :<!exn> void =
+  "mac#%"
+
+fun assert_bool1 {b:bool}(x : bool(b)) :<!exn> [b] void =
+  "mac#%"
+
+//
+overload assert with assert_bool0 of 0
+
+overload assert with assert_bool1 of 10
+
+//
+(* ****** ****** *)
+//
+fun assertexn_bool0(x : bool) :<!exn> void
+
+fun assertexn_bool1 {b:bool} (x : bool(b)) :<!exn> [b] void
+
+//
+symintr assertexn
+
+overload assertexn with assertexn_bool0 of 0
+
+overload assertexn with assertexn_bool1 of 10
+
+//
+(* ****** ****** *)
+//
+fun assert_errmsg_bool0(x : bool, msg : string) :<!exn> void =
+  "mac#%"
+
+fun assert_errmsg_bool1 {b:bool}(x : bool(b), msg : string) :<!exn>
+  [b] void =
+  "mac#%"
+
+//
+symintr assert_errmsg
+
+overload assert_errmsg with assert_errmsg_bool0 of 0
+
+overload assert_errmsg with assert_errmsg_bool1 of 10
+
+//
+(* ****** ****** *)
+//
+fun assert_errmsg2_bool0(x : bool, msg1 : string, msg2 : string) :<!exn>
+  void =
+  "mac#%"
+
+fun assert_errmsg2_bool1 {b:bool}( x : bool(b)
+                                 , msg1 : string
+                                 , msg2 : string
+                                 ) :<!exn> [b] void =
+  "mac#%"
+
+//
+symintr assert_errmsg2
+
+overload assert_errmsg2 with assert_errmsg2_bool0 of 0
+
+overload assert_errmsg2 with assert_errmsg2_bool1 of 10
+
+//
+(* ****** ****** *)
+//
+datasort file_mode =
+  | file_mode_r
+  | file_mode_w
+  | file_mode_rw
+
+// end of [file_mode]
+//
+(* ****** ****** *)
+local
+  //
+  stadef r () = file_mode_r()
+  stadef w () = file_mode_w()
+  stadef rw () = file_mode_rw()
+  
+  //
+in
+  (* in-of-local *)
+  (* ****** ****** *)
+  abstype file_mode(file_mode) = string
+  
+  typedef file_mode = [fm:file_mode] file_mode(fm)
+  
+  (* ****** ****** *)
+  sortdef fmode = file_mode
+  
+  typedef fmode(fm: fmode) = file_mode(fm)
+  typedef fmode = file_mode
+  
+  (* ****** ****** *)
+  dataprop file_mode_lte(fmode, fmode) =
+    | {m:fmode} file_mode_lte_refl((m, m))
+    | { m1, m2, m3 : fmode } file_mode_lte_tran((m1, m3)) of (file_mode_lte( m1
+                                                                           , m2
+                                                                           ), file_mode_lte(m2, m3))
+    | {m:fmode} file_mode_lte_rw_r(rw(), r()) of ()
+    | {m:fmode} file_mode_lte_rw_w(rw(), w()) of ()
+  
+  (* ****** ****** *)
+  //
+  prval file_mode_lte_r_r : file_mode_lte(r(), r())
+  
+  // impled in [filebas_prf.dats]
+  prval file_mode_lte_w_w : file_mode_lte(w(), w())
+  
+  // impled in [filebas_prf.dats]
+  prval file_mode_lte_rw_rw : file_mode_lte(rw(), rw())
+  
+  // impled in [filebas_prf.dats]
+  //
+  (* ****** ****** *)
+end
+
+// end of [local]
+(* ****** ****** *)
+abstype FILEref_type = ptr
+
+typedef FILEref = FILEref_type
+
+(* ****** ****** *)
+//
+typedef print_type(a: t0p) = (a) -> void
+typedef prerr_type(a: t0p) = (a) -> void
+typedef fprint_type(a: t0p) = (FILEref, a) -> void
+
+//
+typedef print_vtype(a: vt0p) = (!a) -> void
+typedef prerr_vtype(a: vt0p) = (!a) -> void
+typedef fprint_vtype(a: vt0p) = (FILEref, !a) -> void
+
+//
+(* ****** ****** *)
+(*
+fun print_void(x: void): void = "mac#%"
+*)
+(* ****** ****** *)
+fun print_newline() : void =
+  "mac#%"
+
+fun prerr_newline() : void =
+  "mac#%"
+
+fun fprint_newline(out : FILEref) : void =
+  "mac#%"
+
+(* ****** ****** *)
+
+#if VERBOSE_PRELUDE #then
+#print "Loading [basics_dyn.sats] finishes!\n"
+#endif // end of [VERBOSE_PRELUDE]
+(* ****** ****** *)
+(* end of [basics_dyn.sats] *)
diff --git a/test/data/stdlib/basics_dyn.sats b/test/data/stdlib/basics_dyn.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/basics_dyn.sats
@@ -0,0 +1,918 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2013 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+//
+// Author of the file:
+// Hongwei Xi (gmhwxiATgmailDOTcom)
+// Start Time: September, 2011
+//
+(* ****** ****** *)
+
+#include "prelude/params.hats"
+
+(* ****** ****** *)
+//
+fun
+patsopt_version(): string = "ext#%"
+//
+(* ****** ****** *)
+
+#if VERBOSE_PRELUDE #then
+#print "Loading [basics_dyn.sats] starts!\n"
+#endif // end of [VERBOSE_PRELUDE]
+
+(* ****** ****** *)
+//
+sortdef t0p = t@ype and vt0p = vt@ype
+//
+(* ****** ****** *)
+
+datatype TYPE(a:vt@ype) = TYPE(a) of ()
+
+(* ****** ****** *)
+//
+// HX-2012: In $ATSHOME/ccomp/runtime:
+// atsbool_true/atsbool_false are mapped to 1/0
+// this mapping is fixed and should never be changed!
+//
+#define true true_bool // shorthand
+#define false false_bool // shorthand
+//
+val true_bool : bool(true)  = "mac#atsbool_true" // = 1
+val false_bool : bool(false) = "mac#atsbool_false" // = 0
+//
+(* ****** ****** *)
+//
+// HX: [false] implies all
+//
+prfun false_elim{X:prop | false} ((*void*)): X
+//
+(* ****** ****** *)
+//
+typedef
+compopr_type(a: t@ype) = (a, a) -<fun0> bool
+typedef
+compare_type(a: t@ype) = (a, a) -<fun0> int(*-/0/+*)
+//
+(* ****** ****** *)
+//
+praxi
+lemma_subcls_reflexive
+  {c:cls}((*void*)): [c <= c] void
+//
+praxi
+lemma_subcls_transitive
+  {c1,c2,c3:cls | c1 <= c2; c2 <= c3}(): [c1 <= c3] void
+//
+(* ****** ****** *)
+//
+praxi
+praxi_int{i:int} ((*void*)): int(i)
+//
+dataprop
+MUL_prop
+(
+  int, int, int
+) = // MUL_prop
+  | {n:int}
+    MULbas (0, n, 0)
+  | {m:nat}{n:int}{p:int}
+    MULind (m+1, n, p+n) of MUL_prop (m, n, p)
+  | {m:pos}{n:int}{p:int}
+    MULneg (~(m), n, ~(p)) of MUL_prop (m, n, p)
+//
+propdef MUL(m:int, n:int, mn:int) = MUL_prop(m, n, mn)
+//
+(* ****** ****** *)
+//
+// HX-2010-12-30: 
+//
+absprop
+DIVMOD (
+  x:int, y: int, q: int, r: int // x = q * y + r
+) // end of [DIVMOD]
+//
+propdef DIV (x:int, y:int, q:int) = [r:int] DIVMOD(x, y, q, r)
+propdef MOD (x:int, y:int, r:int) = [q:int] DIVMOD(x, y, q, r)
+//
+(* ****** ****** *)
+
+dataprop
+EQINT(int, int) = {x:int} EQINT(x, x)
+//
+prfun
+eqint_make{x,y:int | x == y}(): EQINT(x, y)
+//
+prfun
+eqint_make_gint
+  {tk:tk}{x:int}(x: g1int(tk, x)): [y:int] EQINT(x, y)
+prfun
+eqint_make_guint
+  {tk:tk}{x:int}(x: g1uint(tk, x)): [y:int] EQINT(x, y)
+//
+(* ****** ****** *)
+
+praxi praxi_ptr{l:addr} ((*void*)): ptr(l)
+praxi praxi_bool{b:bool} ((*void*)): bool(b)
+
+(* ****** ****** *)
+
+dataprop
+EQADDR(addr, addr) = {x:addr} EQADDR(x, x)
+//
+prfun
+eqaddr_make{x,y:addr | x == y}(): EQADDR(x, y)
+//
+prfun
+eqaddr_make_ptr{x:addr}(x: ptr(x)): [y:addr] EQADDR(x, y)
+//
+(* ****** ****** *)
+
+dataprop
+EQBOOL(bool, bool) = {x:bool} EQBOOL(x, x)
+//
+prfun
+eqbool_make{x,y:bool | x == y}(): EQBOOL(x, y)
+//
+prfun
+eqbool_make_bool{x:bool}(x: bool(x)): [y:bool] EQBOOL(x, y)
+//
+(* ****** ****** *)
+//
+dataprop
+EQTYPE(vt@ype, vt@ype) = {a:vt@ype} EQTYPE (a, a)
+//
+(* ****** ****** *)
+
+prfun
+prop_verify{b:bool | b} ():<prf> void
+prfun
+prop_verify_and_add{b:bool | b} ():<prf> [b] void
+
+(* ****** ****** *)
+
+prfun pridentity_v{v:view} (x: !INV(v)): void
+prfun pridentity_vt{vt:viewt@ype} (x: !INV(vt)): void
+
+(* ****** ****** *)
+
+castfn
+viewptr_match
+{a:vt0ype}{l1,l2:addr|l1==l2}
+(
+  pf: INV(a) @ l1 | p: ptr(l2)
+) :<> [l:addr | l==l1] (a @ l | ptr(l))
+// end of [viewptr_match]
+
+(* ****** ****** *)
+//
+val{
+a:vt0ype
+} sizeof : size_t(sizeof(a))
+//
+praxi
+lemma_sizeof
+  {a:vt0ype}((*void*)): [sizeof(a) >= 0] void
+//
+(* ****** ****** *)
+
+praxi topize{a:t0ype} (x: !INV(a) >> a?): void
+
+(* ****** ****** *)
+
+castfn dataget{a:vt0ype} (x: !INV(a) >> a): a?!
+
+(* ****** ****** *)
+//
+// HX: returning the pf to GC
+//
+praxi
+mfree_gc_v_elim
+  {l:addr} (pf: mfree_gc_v l):<prf> void
+// end of [mfree_gc_v_elim]
+
+(* ****** ****** *)
+
+praxi
+mfree_gcngc_v_nullify
+  {l:addr} (
+  pf1: mfree_gc_v(l), pf1: mfree_ngc_v(l)
+) : void // end of [mfree_gcngc_nullify_v]
+
+(* ****** ****** *)
+//
+fun
+cloptr_free
+  {a:t0p}
+  (pclo: cloptr(a)):<!wrt> void = "mac#%"
+//
+overload free with cloptr_free of 0
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+lazy_force(lazyval: lazy(INV(a))):<!laz> (a)
+//
+fun
+{a:vt0p}
+lazy_vt_force(lazyval: lazy_vt(INV(a))):<!all> (a)
+//
+(*
+//
+// HX-2016-08:
+// this is assumed internally!
+//
+overload ! with lazy_force of 0
+overload ! with lazy_vt_force of 0
+*)
+//
+(* ****** ****** *)
+//
+// HX-2013:
+// macro implemented in [pats_ccomp_instrset]
+//
+fun
+lazy_vt_free
+  {a:vt0p}
+  (lazyval: lazy_vt(a)):<!wrt> void = "mac#%"
+//
+overload ~ with lazy_vt_free of 0
+overload free with lazy_vt_free of 0
+//
+(* ****** ****** *)
+//
+// HX-2014:
+// macro implemented in [pats_ccomp_instrset]
+//
+fun
+lazy2cloref
+  {a:t0p}
+  (lazy(a)): ((*void*)) -<cloref1> (a) = "mac#%"
+//
+(* ****** ****** *)
+
+(*
+// HX-2012-05-23: this seems TOO complicated!
+(*
+** HX-2012-03: handling read-only views and vtypes
+*)
+castfn
+read_getval // copy out a non-linear value
+  {a:t@ype}{s:int}{n:int} (x: !READ (a, s, n)):<> a
+// end of [read_getval]
+
+praxi
+read_takeout{v:view}
+  (pf: !v >> READOUT (v, s)): #[s:int] READ (v, s, 0)
+// end of [read_takeout]
+praxi
+read_addback // HX: there is no need to check
+  {v1:view}{v2:view}{s:int} // if v1 and v2 match
+  (pf1: !READOUT (v1, s) >> v1, pf2: READ (v2, s, 0)): void
+// end of [read0_addback]
+
+praxi
+read_split
+  {v:view}{s:int}{n:int}
+  (pf: !READ (v, s, n) >> READ (v, s, n+1)): READ (v, s, 0)
+// end of [read_split]
+praxi
+read_unsplit // HX: there is no need to check
+  {v1:view}{v2:view}{s:int}{n1,n2:int} // if v1 and v2 match
+  (pf1: READ (v1, s, n1), pf2: READ (v2, s, n2)): READ (v1, s, n1+n2-1)
+// end of [read_unsplit]
+*)
+(* ****** ****** *)
+//
+castfn
+stamp_t
+  {a:t@ype}(x: INV(a)):<> stamped_t(a)
+// end of [stamp_t]
+castfn
+stamp_vt
+  {a:vt@ype}(x: INV(a)):<> stamped_vt(a)
+// end of [stamp_vt]
+//
+(* ****** ****** *)
+//
+castfn
+unstamp_t
+  {a:t@ype}{x:int}(x: stamped_t(INV(a), x)):<> a
+// end of [unstamp_t]
+castfn
+unstamp_vt
+  {a:vt@ype}{x:int}(x: stamped_vt(INV(a), x)):<> a
+// end of [unstamp_vt]
+//
+(* ****** ****** *)
+//
+castfn
+stamped_t2vt
+  {a:t@ype}{x:int}
+  (x: stamped_t(INV(a), x)):<> stamped_vt(a, x)
+// end of [stamped_t2vt]
+//
+castfn
+stamped_vt2t
+  {a:t@ype}{x:int}
+  (x: stamped_vt(INV(a), x)):<> stamped_t(a, x)
+// end of [stamped_vt2t]
+//
+fun{a:t@ype}
+stamped_vt2t_ref{x:int}
+  (x: &stamped_vt(INV(a), x)):<> stamped_t(a, x)
+//
+(* ****** ****** *)
+//
+praxi
+vcopyenv_v_decode
+  {v:view}(x: vcopyenv_v(v)): vtakeout0(v)
+castfn
+vcopyenv_vt_decode
+  {vt:vt0p}(x: vcopyenv_vt(vt)): vttakeout0(vt)
+//
+overload decode with vcopyenv_v_decode
+overload decode with vcopyenv_vt_decode
+//
+(* ****** ****** *)
+//
+// HX: the_null_ptr = (void*)0
+//
+val
+the_null_ptr
+  : ptr(null) = "mac#the_atsptr_null"
+//
+(* ****** ****** *)
+//
+praxi
+lemma_addr_param
+  {l:addr}((*void*)): [l >= null] void
+//
+(* ****** ****** *)
+
+praxi
+lemma_string_param
+  {n:int} (x: string(n)): [n >= 0] void
+// end of [lemma_string_param]
+praxi
+lemma_stropt_param
+  {n:int} (x: stropt(n)): [n >= ~1] void
+// end of [lemma_stropt_param]
+
+(* ****** ****** *)
+//
+dataprop
+SGN (int, int) =
+  | SGNzero (0, 0)
+  | {i:neg} SGNneg (i, ~1) | {i:pos} SGNpos (i,  1)
+// end of [SGN] // end of [dataprop]
+//
+(* ****** ****** *)
+//
+// HX-2012-06:
+// indication of the failure of
+exception AssertExn of () // an assertion
+//
+(* ****** ****** *)
+//
+// HX-2012-06:
+// indication of something expected
+exception NotFoundExn of () // to be found but not
+//
+(* ****** ****** *)
+//
+exception GenerallyExn of (string) // for unspecified causes
+(*
+exception GenerallyExn2 of (string, ptr(*data*)) // for unspecified causes
+*)
+//
+(* ****** ****** *)
+//
+// HX-2012-07:
+// indication of a function argument being
+exception IllegalArgExn of (string) // out of its domain
+//
+(* ****** ****** *)
+
+praxi __vfree_exn (x: exn):<> void // for freeing nullary exception-con
+
+(* ****** ****** *)
+//
+datatype unit = unit of ()
+dataprop unit_p = unit_p of ()
+dataview unit_v = unit_v of ()
+datavtype unit_vt = unit_vt of ()
+//
+prfun unit_v_elim (pf: unit_v): void
+//
+(* ****** ****** *)
+//
+abstype
+boxed_t0ype_type(a:t@ype+) = unit
+absvtype
+boxed_vt0ype_vtype(a:vt@ype+) = unit
+//
+vtypedef
+boxed(a:vt@ype) = boxed_vt0ype_vtype(a)
+vtypedef
+boxed_vt(a:vt@ype) = boxed_vt0ype_vtype(a)
+//
+typedef boxed(a:t@ype) = boxed_t0ype_type(a)
+typedef boxed_t(a:t@ype) = boxed_t0ype_type(a)
+//
+fun{a:type} box: (INV(a)) -> boxed_t(a)
+fun{a:type} unbox: boxed_t(INV(a)) -> (a)
+fun{a:vtype} box_vt: (INV(a)) -> boxed_vt(a)
+fun{a:vtype} unbox_vt: boxed_vt(INV(a)) -> (a)
+//
+(* ****** ****** *)
+//
+stadef
+array(a:vt@ype, n:int) = @[a][n]
+//
+viewdef
+array_v
+  (a:vt@ype, l:addr, n:int) = @[a][n] @ l
+//
+absvtype
+arrayptr_vt0ype_addr_int_vtype
+  (a:vt0ype+, l:addr, n:int(*size*)) = ptr(l)
+stadef
+arrayptr = arrayptr_vt0ype_addr_int_vtype
+vtypedef
+arrayptr
+  (a:vt0p, n:int) = [l:addr] arrayptr(a, l, n)
+//
+abstype
+arrayref_vt0ype_int_type
+  (a:vt@ype(*elt*), n:int(*size*)) = ptr
+stadef arrayref = arrayref_vt0ype_int_type
+//
+abstype
+arrszref_vt0ype_type(a: vt@ype) = ptr
+typedef arrszref(a:vt0p) = arrszref_vt0ype_type(a)
+//
+(* ****** ****** *)
+//
+datatype
+// t@ype+: covariant
+list_t0ype_int_type
+  (a:t@ype+, int) =
+  | list_nil(a, 0) of ()
+  | {n:int | n >= 0}
+    list_cons(a, n+1) of (a, list_t0ype_int_type(a, n))
+// end of [datatype]
+stadef list = list_t0ype_int_type
+typedef
+List(a:t0p) = [n:int] list(a, n)
+typedef
+List0(a:t0p) = [n:int | n >= 0] list(a, n)
+typedef
+List1(a:t0p) = [n:int | n >= 1] list(a, n)
+typedef listLt
+  (a:t0p, n:int) = [k:nat | k < n] list(a, k)
+typedef listLte
+  (a:t0p, n:int) = [k:nat | k <= n] list(a, k)
+typedef listGt
+  (a:t0p, n:int) = [k:int | k > n] list(a, k)
+typedef listGte
+  (a:t0p, n:int) = [k:int | k >= n] list(a, k)
+typedef listBtw
+  (a:t0p, m:int, n:int) = [k:int | m <= k; k < n] list(a, k)
+typedef listBtwe
+  (a:t0p, m:int, n:int) = [k:int | m <= k; k <= n] list(a, k)
+//
+(* ****** ****** *)
+//
+datavtype
+// vt@ype+: covariant
+list_vt0ype_int_vtype
+  (a:vt@ype+, int) =
+  | list_vt_nil(a, 0) of ()
+  | {n:int | n >= 0}
+    list_vt_cons(a, n+1) of (a, list_vt0ype_int_vtype(a, n))
+// end of [list_vt0ype_int_vtype]
+stadef list_vt = list_vt0ype_int_vtype
+vtypedef
+List_vt(a:vt0p) = [n:int] list_vt(a, n)
+vtypedef
+List0_vt(a:vt0p) = [n:int | n >= 0] list_vt(a, n)
+vtypedef
+List1_vt(a:vt0p) = [n:int | n >= 1] list_vt(a, n)
+vtypedef listLt_vt
+  (a:vt0p, n:int) = [k:nat | k < n] list_vt(a, k)
+vtypedef listLte_vt
+  (a:vt0p, n:int) = [k:nat | k <= n] list_vt(a, k)
+vtypedef listGt_vt
+  (a:vt0p, n:int) = [k:int | k > n] list_vt(a, k)
+vtypedef listGte_vt
+  (a:vt0p, n:int) = [k:int | k >= n] list_vt(a, k)
+vtypedef listBtw_vt
+  (a:vt0p, m:int, n:int) = [k:int | m <= k; k < n] list_vt(a, k)
+vtypedef listBtwe_vt
+  (a:vt0p, m:int, n:int) = [k:int | m <= k; k <= n] list_vt(a, k)
+//
+(* ****** ****** *)
+//
+datatype
+stream_con(a:t@ype+) =
+  | stream_nil of ((*void*))
+  | stream_cons of (a, stream(a))
+//
+where stream (a:t@ype) = lazy (stream_con(a))
+//
+datavtype
+stream_vt_con
+  (a:vt@ype+) =
+  | stream_vt_nil of ((*void*))
+  | stream_vt_cons of (a, stream_vt(a))
+//
+where
+stream_vt(a:vt@ype) = lazy_vt(stream_vt_con(a))
+//
+(* ****** ****** *)
+//
+datatype
+// t@ype+: covariant
+option_t0ype_bool_type
+(
+  a:t@ype+, bool
+) = // option_t0ype_bool_type
+  | Some(a, true) of (INV(a)) | None(a, false)
+// end of [datatype]
+stadef option = option_t0ype_bool_type
+typedef Option(a:t0p) = [b:bool] option(a, b)
+//
+datavtype
+// vt@ype+: covariant
+option_vt0ype_bool_vtype
+(
+  a:vt@ype+, bool
+) = // option_vt0ype_bool_vtype
+  | Some_vt(a, true) of (INV(a)) | None_vt(a, false)
+// end of [option_vt0ype_bool_vtype]
+stadef option_vt = option_vt0ype_bool_vtype
+vtypedef Option_vt(a:vt0p) = [b:bool] option_vt(a, b)
+//
+(* ****** ****** *)
+//
+praxi
+opt_some{a:vt0p}
+  (x: !INV(a) >> opt(a, true)):<prf> void
+praxi
+opt_unsome{a:vt0p}
+  (x: !opt(INV(a), true) >> a):<prf> void
+//
+fun{a:vt0p}
+opt_unsome_get(x: &opt(INV(a), true) >> a?): (a)
+//
+praxi
+opt_none{a:vt0p}
+  (x: !(a?) >> opt(a, false)):<prf> void
+praxi
+opt_unnone{a:vt0p}
+  (x: !opt(INV(a), false) >> a?):<prf> void
+//
+praxi
+opt_clear{a:t0p}
+  {b:bool}(x: !opt(INV(a), b) >> a?):<prf> void
+//
+(* ****** ****** *)
+//
+dataprop
+or_prop_prop_int_prop
+(
+  a0: prop+, a1: prop+, int
+) = // or_prop_prop_int_prop
+  | POR_l(a0, a1, 0) of (INV(a0))
+  | POR_r(a0, a1, 1) of (INV(a1))
+dataview
+or_view_view_int_view
+(
+  a0: view+, a1: view+, int
+) = // or_view_view_int_view
+  | VOR_l(a0, a1, 0) of (INV(a0))
+  | VOR_r(a0, a1, 1) of (INV(a1))
+//
+stadef por = or_prop_prop_int_prop
+stadef vor = or_view_view_int_view
+//
+dataprop
+option_prop_bool_prop
+(
+  a:prop+, bool
+) = // option_prop_bool_prop
+  | Some_p (a, true) of (INV(a)) | None_p (a, false)
+// end of [option_prop_bool_prop]
+stadef option_p = option_prop_bool_prop
+//
+dataview
+option_view_bool_view
+  (a:view+, bool) =
+  | Some_v (a, true) of (INV(a)) | None_v (a, false)
+// end of [option_view_bool_view]
+stadef option_v = option_view_bool_view
+//
+(* ****** ****** *)
+//
+absvt@ype
+arrayopt(a:vt0p, n:int, b:bool) = array(a, n)
+//
+praxi
+arrayopt_some
+  {a:vt0p}{n:int}
+  (A: &array(a, n) >> arrayopt(a, n, true)): void
+praxi
+arrayopt_none
+  {a:vt0p}{n:int}
+  (A: &array(a?, n) >> arrayopt(a, n, false)): void
+praxi
+arrayopt_unsome
+  {a:vt0p}{n:int}
+  (A: &arrayopt(a, n, true) >> array(a, n)): void
+praxi
+arrayopt_unnone
+  {a:vt0p}{n:int}
+  (A: &arrayopt(a, n, false) >> array(a?, n)): void
+//
+(* ****** ****** *)
+
+absvtype
+argv_int_vtype (n:int) = ptr
+stadef argv = argv_int_vtype
+
+(*
+[argv_takeout_strarr] is declared in prelude/SATS/extern.sats
+[argv_takeout_parrnull] is declared in prelude/SATS/extern.sats
+*)
+
+(* ****** ****** *)
+
+praxi
+lemma_argv_param
+  {n:int}(argv: !argv(n)): [n >= 0] void
+// end of [praxi]
+
+(* ****** ****** *)
+//
+fun
+argv_get_at{n:int}
+  (argv: !argv(n), i: natLt(n)):<> string = "mac#%"
+fun
+argv_set_at{n:int}
+  (argv: !argv(n), i: natLt(n), x: string):<!wrt> void = "mac#%"
+//
+overload [] with argv_get_at
+overload [] with argv_set_at
+//
+(* ****** ****** *)
+//
+fun{}
+listize_argc_argv
+  {n:int}
+  (argc: int(n), argv: !argv(n)): list_vt(string, n)
+//
+(* ****** ****** *)
+//
+symintr main0
+//
+fun
+main_void_0
+(
+  (*void*)
+) : void = "ext#mainats_void_0"
+fun
+main_argc_argv_0
+  {n:int | n >= 1}
+  (argc: int n, argv: !argv(n)): void = "ext#mainats_argc_argv_0"
+//
+overload main0 with main_void_0
+overload main0 with main_argc_argv_0
+//
+(* ****** ****** *)
+//
+symintr main
+//
+fun
+main_void_int
+(
+  (*void*)
+) : int = "ext#mainats_void_int"
+fun
+main_argc_argv_int
+  {n:int | n >= 1}
+  (argc: int n, argv: !argv(n)): int = "ext#mainats_argc_argv_int"
+fun
+main_argc_argv_envp_int
+  {n:int | n >= 1}
+  (argc: int n, argv: !argv n, envp: ptr): int = "ext#mainats_argc_argv_envp_int"
+//
+overload main with main_void_int
+overload main with main_argc_argv_int
+overload main with main_argc_argv_envp_int
+//
+(* ****** ****** *)
+//
+fun
+exit(ecode: int):<!exn> {a:t0p}(a) = "mac#%"
+fun
+exit_errmsg
+  (ecode: int, msg: string):<!exn> {a:t0p}(a) = "mac#%"
+//
+(*
+fun exit_fprintf{ts:types}
+(
+  ecode: int, out: FILEref, fmt: printf_c ts, args: ts
+) :<!exn> {a:vt0p}(a) = "mac#%" // end of [exit_fprintf]
+*)
+//
+(* *****p* ****** *)
+//
+fun
+exit_void
+  (ecode: int):<!exn> void = "mac#%"
+fun
+exit_errmsg_void
+  (ecode: int, msg: string):<!exn> void = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+assert_bool0
+  (x: bool):<!exn> void = "mac#%"
+fun
+assert_bool1
+  {b:bool} (x: bool (b)):<!exn> [b] void = "mac#%"
+//
+overload assert with assert_bool0 of 0
+overload assert with assert_bool1 of 10
+//
+(* ****** ****** *)
+//
+fun{}
+assertexn_bool0 (x: bool):<!exn> void
+fun{}
+assertexn_bool1 {b:bool} (x: bool (b)):<!exn> [b] void
+//
+symintr assertexn
+overload assertexn with assertexn_bool0 of 0
+overload assertexn with assertexn_bool1 of 10
+//
+(* ****** ****** *)
+//
+fun
+assert_errmsg_bool0
+  (x: bool, msg: string):<!exn> void = "mac#%"
+fun
+assert_errmsg_bool1
+  {b:bool} (x: bool b, msg: string):<!exn> [b] void = "mac#%"
+//
+symintr assert_errmsg
+overload assert_errmsg with assert_errmsg_bool0 of 0
+overload assert_errmsg with assert_errmsg_bool1 of 10
+//
+(* ****** ****** *)
+//
+fun
+assert_errmsg2_bool0
+  (x: bool, msg1: string, msg2: string):<!exn> void = "mac#%"
+fun
+assert_errmsg2_bool1{b:bool}
+  (x: bool b, msg1: string, msg2: string):<!exn> [b] void = "mac#%"
+//
+symintr assert_errmsg2
+overload assert_errmsg2 with assert_errmsg2_bool0 of 0
+overload assert_errmsg2 with assert_errmsg2_bool1 of 10
+//
+(* ****** ****** *)
+//
+datasort
+file_mode =
+  | file_mode_r (* read *)
+  | file_mode_w (* write *)
+  | file_mode_rw (* read and write *)
+// end of [file_mode]
+//
+(* ****** ****** *)
+
+local
+//
+stadef r() = file_mode_r()
+stadef w() = file_mode_w()
+stadef rw() = file_mode_rw()
+//
+in (* in-of-local *)
+
+(* ****** ****** *)
+
+abstype
+file_mode (file_mode) = string
+typedef
+file_mode = [fm:file_mode] file_mode (fm)
+
+(* ****** ****** *)
+
+sortdef fmode = file_mode
+typedef fmode (fm:fmode) = file_mode (fm)
+typedef fmode = file_mode
+
+(* ****** ****** *)
+
+dataprop
+file_mode_lte
+  (fmode, fmode) =
+//
+  | {m:fmode} file_mode_lte_refl (m, m)
+//
+  | {m1,m2,m3:fmode}
+    file_mode_lte_tran (m1, m3) of
+    (file_mode_lte(m1, m2), file_mode_lte(m2, m3))
+//
+  | {m:fmode} file_mode_lte_rw_r(rw(), r()) of ()
+  | {m:fmode} file_mode_lte_rw_w(rw(), w()) of ()
+// end of [file_mode_lte]
+
+(* ****** ****** *)
+//
+prval
+file_mode_lte_r_r
+  : file_mode_lte(r(), r()) // impled in [filebas_prf.dats]
+prval
+file_mode_lte_w_w
+  : file_mode_lte(w(), w()) // impled in [filebas_prf.dats]
+prval
+file_mode_lte_rw_rw
+  : file_mode_lte(rw(), rw()) // impled in [filebas_prf.dats]
+//
+(* ****** ****** *)
+
+end // end of [local]
+
+(* ****** ****** *)
+
+abstype FILEref_type = ptr
+typedef FILEref = FILEref_type
+
+(* ****** ****** *)
+//
+typedef
+print_type(a: t0p) = (a) -> void
+typedef
+prerr_type(a: t0p) = (a) -> void
+typedef
+fprint_type(a: t0p) = (FILEref, a) -> void
+//
+typedef
+print_vtype(a: vt0p) = (!a) -> void
+typedef
+prerr_vtype(a: vt0p) = (!a) -> void
+typedef
+fprint_vtype(a: vt0p) = (FILEref, !a) -> void
+//
+(* ****** ****** *)
+
+(*
+fun print_void(x: void): void = "mac#%"
+*)
+
+(* ****** ****** *)
+
+fun print_newline((*void*)): void = "mac#%"
+fun prerr_newline((*void*)): void = "mac#%"
+fun fprint_newline(out: FILEref): void = "mac#%"
+
+(* ****** ****** *)
+
+#if VERBOSE_PRELUDE #then
+#print "Loading [basics_dyn.sats] finishes!\n"
+#endif // end of [VERBOSE_PRELUDE]
+
+(* ****** ****** *)
+
+(* end of [basics_dyn.sats] *)
diff --git a/test/data/stdlib/basics_gen.out b/test/data/stdlib/basics_gen.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/basics_gen.out
@@ -0,0 +1,148 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2013 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+//
+// Author of the file:
+// Hongwei Xi (gmhwxiATgmailDOTcom)
+// Start Time: July, 2012
+//
+(* ****** ****** *)
+#include "prelude/params.hats"
+
+(* ****** ****** *)
+
+#if VERBOSE_PRELUDE #then
+#print "Loading [basics_gen.sats] starts!\n"
+#endif // end of [VERBOSE_PRELUDE]
+(* ****** ****** *)
+//
+fun {a:t0p} gidentity (x : INV(a)) :<> a
+
+//
+fun {a:vt0p} gidentity_vt (x : INV(a)) :<> a
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} gcopy_val (x : !INV(a)) :<!wrt> a
+
+//
+fun {a:vt0p} gcopy_ref (x : &INV(a)) :<!wrt> a
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} gfree_val (x : INV(a)) :<!wrt> void
+
+//
+(*
+fun
+{a:vt0p}
+gfree_ref (x: &INV(a) >> a?):<!wrt> void
+*)
+//
+(* ****** ****** *)
+fun {a:vt0p} ginit_ref (x : &a? >> a) :<!wrt> void
+
+(* ****** ****** *)
+fun {a:vt0p} gclear_ref (x : &a >> a?) :<!wrt> void
+
+(* ****** ****** *)
+//
+fun {a:t0p} gequal_val_val (x : a, y : a) :<> bool
+
+//
+fun {a:vt0p} gequal_ref_ref (x : &INV(a), y : &a) :<> bool
+
+//
+(* ****** ****** *)
+fun {a:t0p} tostring_val (x : a) :<> string
+
+fun {a:vt0p} tostring_ref (x : &INV(a)) :<> string
+
+(* ****** ****** *)
+fun {a:t0p} tostrptr_val (x : a) :<!wrt> Strptr1
+
+fun {a:vt0p} tostrptr_ref (x : &INV(a)) :<!wrt> Strptr1
+
+(* ****** ****** *)
+(*
+//
+fun{a:t0p}
+print_val (x: a): void // = fprint_val (stdout_ref, x)
+fun{a:t0p}
+prerr_val (x: a): void // = fprint_val (stderr_ref, x)
+//
+fun{a:vt0p}
+print_ref (x: &INV(a)): void // = fprint_ref (stdout_ref, x)
+fun{a:vt0p}
+prerr_ref (x: &INV(a)): void // = fprint_ref (stderr_ref, x)
+//
+*)
+(* ****** ****** *)
+//
+fun {a:t0p} fprint_val (out : FILEref, x : a) : void
+
+fun {a:vt0p} fprint_ref (out : FILEref, x : &INV(a)) : void
+
+//
+(* ****** ****** *)
+//
+fun {src:vt0p}{elt:vt0p} streamize_val (source : src) : stream_vt(elt)
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} print_stamped_t (stamped_t(a)) : void
+
+fun {a:t0p} prerr_stamped_t (stamped_t(a)) : void
+
+fun {a:t0p} fprint_stamped_t (out : FILEref, x : stamped_t(a)) : void
+
+(*
+//
+// HX-2017-12-09:
+// This one does not seem to be so useful
+//
+fun
+{a:vt0p}
+fprint_stamped_vt(out: FILEref, x: &stamped_vt(a)): void
+*)
+//
+overload print with print_stamped_t
+
+overload prerr with prerr_stamped_t
+
+overload fprint with fprint_stamped_t
+
+//
+(* ****** ****** *)
+
+#if VERBOSE_PRELUDE #then
+#print "Loading [basics_gen.sats] finishes!\n"
+#endif // end of [VERBOSE_PRELUDE]
+(* ****** ****** *)
+(* end of [basics_gen.sats] *)
diff --git a/test/data/stdlib/basics_gen.sats b/test/data/stdlib/basics_gen.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/basics_gen.sats
@@ -0,0 +1,175 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2013 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+//
+// Author of the file:
+// Hongwei Xi (gmhwxiATgmailDOTcom)
+// Start Time: July, 2012
+//
+(* ****** ****** *)
+
+#include "prelude/params.hats"
+
+(* ****** ****** *)
+
+#if VERBOSE_PRELUDE #then
+#print "Loading [basics_gen.sats] starts!\n"
+#endif // end of [VERBOSE_PRELUDE]
+
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+gidentity (x: INV(a)):<> a
+//
+fun
+{a:vt0p}
+gidentity_vt (x: INV(a)):<> a
+//
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+gcopy_val (x: !INV(a)):<!wrt> a
+//
+fun
+{a:vt0p}
+gcopy_ref (x: &INV(a)):<!wrt> a
+//
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+gfree_val (x: INV(a)):<!wrt> void
+//
+(*
+fun
+{a:vt0p}
+gfree_ref (x: &INV(a) >> a?):<!wrt> void
+*)
+//
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+ginit_ref (x: &a? >> a):<!wrt> void
+
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+gclear_ref (x: &a >> a?):<!wrt> void
+
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+gequal_val_val (x: a, y: a):<> bool
+//
+fun
+{a:vt0p}
+gequal_ref_ref (x: &INV(a), y: &a):<> bool
+//
+(* ****** ****** *)
+
+fun{a:t0p}
+tostring_val (x: a):<> string
+fun{a:vt0p}
+tostring_ref (x: &INV(a)):<> string
+
+(* ****** ****** *)
+
+fun{a:t0p}
+tostrptr_val (x: a):<!wrt> Strptr1
+fun{a:vt0p}
+tostrptr_ref (x: &INV(a)):<!wrt> Strptr1
+
+(* ****** ****** *)
+
+(*
+//
+fun{a:t0p}
+print_val (x: a): void // = fprint_val (stdout_ref, x)
+fun{a:t0p}
+prerr_val (x: a): void // = fprint_val (stderr_ref, x)
+//
+fun{a:vt0p}
+print_ref (x: &INV(a)): void // = fprint_ref (stdout_ref, x)
+fun{a:vt0p}
+prerr_ref (x: &INV(a)): void // = fprint_ref (stderr_ref, x)
+//
+*)
+
+(* ****** ****** *)
+//
+fun{a:t0p}
+fprint_val(out: FILEref, x: a): void
+fun{a:vt0p}
+fprint_ref(out: FILEref, x: &INV(a)): void
+//
+(* ****** ****** *)
+//
+fun
+{src:vt0p}
+{elt:vt0p}
+streamize_val(source: src): stream_vt(elt)
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+print_stamped_t(stamped_t(a)): void
+fun
+{a:t0p}
+prerr_stamped_t(stamped_t(a)): void
+fun
+{a:t0p}
+fprint_stamped_t(out: FILEref, x: stamped_t(a)): void
+(*
+//
+// HX-2017-12-09:
+// This one does not seem to be so useful
+//
+fun
+{a:vt0p}
+fprint_stamped_vt(out: FILEref, x: &stamped_vt(a)): void
+*)
+//
+overload print with print_stamped_t
+overload prerr with prerr_stamped_t
+overload fprint with fprint_stamped_t
+//
+(* ****** ****** *)
+
+#if VERBOSE_PRELUDE #then
+#print "Loading [basics_gen.sats] finishes!\n"
+#endif // end of [VERBOSE_PRELUDE]
+
+(* ****** ****** *)
+
+(* end of [basics_gen.sats] *)
diff --git a/test/data/stdlib/bool.out b/test/data/stdlib/bool.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/bool.out
@@ -0,0 +1,63 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/DATS/CODEGEN/bool.atxt
+** Time of generation: Thu Jan 11 11:00:12 2018
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: Feburary, 2012 *)
+(* ****** ****** *)
+#define ATS_DYNLOADFLAG 0 // no dynloading at run-time
+
+(* ****** ****** *)
+(*
+//
+// HX: see CATS/bool.cats
+//
+implement
+bool2string
+  (b) = if b then "true" else "false"
+// end of [bool2string]
+*)
+(* ****** ****** *)
+(*
+//
+// HX: see CATS/bool.cats
+//
+implement
+fprint_bool (out, x) =
+  fprint_string (out, bool2string (x))
+// end of [fprint_bool]
+*)
+implement fprint_val<bool> =
+  fprint_bool
+
+(* ****** ****** *)
+(* end of [bool.dats] *)
diff --git a/test/data/stdlib/checkast.out b/test/data/stdlib/checkast.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/checkast.out
@@ -0,0 +1,123 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/checkast.atxt
+** Time of generation: Thu Jan 11 11:00:06 2018
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: December, 2013 *)
+(* ****** ****** *)
+#define ATS_PACKNAME"ATSLIB.prelude.checkast"
+
+(* ****** ****** *)
+sortdef t0p = t@ype and vt0p = vt@ype
+
+(* ****** ****** *)
+//
+fun checkast_charNZ(c : char, msg : RD(string)) : charNZ
+
+//
+(* ****** ****** *)
+fun {tk:tk} checkast_gintLt {i:int} ( x : g0int(tk)
+                                    , i : int(i)
+                                    , msg : RD(string)
+                                    ) : g1intLt(tk, i)
+
+fun {tk:tk} checkast_gintLte {i:int} ( x : g0int(tk)
+                                     , i : int(i)
+                                     , msg : RD(string)
+                                     ) : g1intLte(tk, i)
+
+fun {tk:tk} checkast_gintGt {i:int} ( x : g0int(tk)
+                                    , i : int(i)
+                                    , msg : RD(string)
+                                    ) : g1intGt(tk, i)
+
+fun {tk:tk} checkast_gintGte {i:int} ( x : g0int(tk)
+                                     , i : int(i)
+                                     , msg : RD(string)
+                                     ) : g1intGte(tk, i)
+
+fun {tk:tk} checkast_gintBtw { i, j : int } ( x : g0int(tk)
+                                            , i : int(i)
+                                            , j : int(j)
+                                            , msg : RD(string)
+                                            ) : g1intBtw(tk, i, j)
+
+fun {tk:tk} checkast_gintBtwe { i, j : int } ( x : g0int(tk)
+                                             , i : int(i)
+                                             , j : int(j)
+                                             , msg : RD(string)
+                                             ) : g1intBtwe(tk, i, j)
+
+(* ****** ****** *)
+macdef ckastloc_charNZ(x) = checkast_charNZ(,(x), $mylocation)
+
+(* ****** ****** *)
+macdef ckastloc_gintLt(i, x) = checkast_gintLt(,(x), ,(i), $mylocation)
+
+macdef ckastloc_gintLte(i, x) = checkast_gintLte( ,(x)
+                                                , ,(i)
+                                                , $mylocation
+                                                )
+
+macdef ckastloc_gintGt(i, x) = checkast_gintGt(,(x), ,(i), $mylocation)
+
+macdef ckastloc_gintGte(i, x) = checkast_gintGte( ,(x)
+                                                , ,(i)
+                                                , $mylocation
+                                                )
+
+macdef ckastloc_gintBtw(j, i, x) = checkast_gintBtw( ,(x)
+                                                   , ,(i)
+                                                   , ,(j)
+                                                   , $mylocation
+                                                   )
+
+macdef ckastloc_gintBtwe(j, i, x) = checkast_gintBtwe( ,(x)
+                                                     , ,(i)
+                                                     , ,(j)
+                                                     , $mylocation
+                                                     )
+
+(* ****** ****** *)
+fun checkast_Ptr1(x : ptr, msg : RD(string)) : Ptr1
+
+(* ****** ****** *)
+macdef ckastloc_Ptr1(x) = checkast_Ptr1(,(x), $mylocation)
+
+(* ****** ****** *)
+fun checkast_Strptr1(x : Strptr0, msg : RD(string)) : Strptr1
+
+(* ****** ****** *)
+macdef ckastloc_Strptr1(x) = checkast_Strptr1(,(x), $mylocation)
+
+(* ****** ****** *)
+(* end of [checkast.sats] *)
diff --git a/test/data/stdlib/checkast.sats b/test/data/stdlib/checkast.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/checkast.sats
@@ -0,0 +1,120 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/checkast.atxt
+** Time of generation: Thu Jan 11 11:00:06 2018
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: December, 2013 *)
+
+(* ****** ****** *)
+
+#define
+ATS_PACKNAME "ATSLIB.prelude.checkast"
+
+(* ****** ****** *)
+
+sortdef t0p = t@ype and vt0p = viewt@ype
+
+(* ****** ****** *)
+//
+fun{}
+checkast_charNZ
+  (c: char, msg: RD(string)): charNZ
+//
+(* ****** ****** *)
+
+fun{tk:tk}
+checkast_gintLt{i:int}
+  (x: g0int(tk), i: int i, msg: RD(string)): g1intLt(tk, i)
+fun{tk:tk}
+checkast_gintLte{i:int}
+  (x: g0int(tk), i: int i, msg: RD(string)): g1intLte(tk, i)
+fun{tk:tk}
+checkast_gintGt{i:int}
+  (x: g0int(tk), i: int i, msg: RD(string)): g1intGt(tk, i)
+fun{tk:tk}
+checkast_gintGte{i:int}
+  (x: g0int(tk), i: int i, msg: RD(string)): g1intGte(tk, i)
+fun{tk:tk}
+checkast_gintBtw{i,j:int}
+  (x: g0int(tk), i: int i, j: int j, msg: RD(string)): g1intBtw(tk, i, j)
+fun{tk:tk}
+checkast_gintBtwe{i,j:int}
+  (x: g0int(tk), i: int i, j: int j, msg: RD(string)): g1intBtwe(tk, i, j)
+
+(* ****** ****** *)
+
+macdef
+ckastloc_charNZ(x) = checkast_charNZ(,(x), $mylocation)
+
+(* ****** ****** *)
+
+macdef
+ckastloc_gintLt(x, i) = checkast_gintLt(,(x), ,(i), $mylocation)
+macdef
+ckastloc_gintLte(x, i) = checkast_gintLte(,(x), ,(i), $mylocation)
+macdef
+ckastloc_gintGt(x, i) = checkast_gintGt(,(x), ,(i), $mylocation)
+macdef
+ckastloc_gintGte(x, i) = checkast_gintGte(,(x), ,(i), $mylocation)
+macdef
+ckastloc_gintBtw(x, i, j) = checkast_gintBtw(,(x), ,(i), ,(j), $mylocation)
+macdef
+ckastloc_gintBtwe(x, i, j) = checkast_gintBtwe(,(x), ,(i), ,(j), $mylocation)
+
+(* ****** ****** *)
+
+fun{}
+checkast_Ptr1(x: ptr, msg: RD(string)): Ptr1
+
+(* ****** ****** *)
+
+macdef
+ckastloc_Ptr1(x) = checkast_Ptr1(,(x), $mylocation)
+
+(* ****** ****** *)
+
+fun{}
+checkast_Strptr1(x: Strptr0, msg: RD(string)): Strptr1
+
+(* ****** ****** *)
+
+macdef
+ckastloc_Strptr1(x) = checkast_Strptr1(,(x), $mylocation)
+
+(* ****** ****** *)
+
+(* end of [checkast.sats] *)
diff --git a/test/data/stdlib/filebas.out b/test/data/stdlib/filebas.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/filebas.out
@@ -0,0 +1,360 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/filebas.atxt
+** Time of generation: Thu Jan 11 11:00:06 2018
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: February, 2012 *)
+(* ****** ****** *)
+sortdef t0p = t@ype and vt0p = vt@ype
+
+(* ****** ****** *)
+#define NSH (x) x // for commenting: no sharing
+#define SHR (x) x // for commenting: it is shared
+
+(* ****** ****** *)
+val stdin_ref: FILEref = "mac#%FILE_stdin"
+val stdout_ref: FILEref = "mac#%FILE_stdout"
+val stderr_ref: FILEref = "mac#%FILE_stderr"
+
+(* ****** ****** *)
+fun dirsep_get() :<> charNZ
+
+fun dirsep_gets() :<> string
+
+fun dirname_self() :<> string
+
+fun dirname_parent() :<> string
+
+(* ****** ****** *)
+fun filename_get_ext(name : string) :<> vStrptr0
+
+fun filename_test_ext(name : string, ext : string) :<> bool
+
+(* ****** ****** *)
+fun filename_get_base(name : string) :<> vStrptr1
+
+fun filename_test_base(name : string, base : string) :<> bool
+
+(* ****** ****** *)
+//
+val file_mode_r: file_mode(file_mode_r()) = "mac#%"
+
+// = "r"
+val file_mode_rr: file_mode(file_mode_rw()) = "mac#%"
+
+// = "r+"
+//
+val file_mode_w: file_mode(file_mode_w()) = "mac#%"
+
+// = "w"
+val file_mode_ww: file_mode(file_mode_rw()) = "mac#%"
+
+// = "w+"
+//
+val file_mode_a: file_mode(file_mode_rw()) = "mac#%"
+
+// = "a"
+val file_mode_aa: file_mode(file_mode_rw()) = "mac#%"
+
+// = "a+"
+//
+(* ****** ****** *)
+//
+(*
+** HX: [stat] is called
+*)
+fun test_file_exists(path : NSH(string)) : bool =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+// HX-2011-02-16:
+// [stat] is called to obtain the mode of a given file
+// for [f] to be applied to it.
+//
+fun test_file_mode(path : NSH(string)) : int
+
+//
+fun test_file_mode$pred(mode : uint) : bool
+
+//
+fun test_file_mode_fun(path : NSH(string), f : uint -> bool) : int =
+  "mac#%"
+
+//
+// HX: [stat] is called // ~1/0/1: error/false/true
+//
+fun test_file_isblk(path : NSH(string)) : int =
+  "mac#%"
+
+fun test_file_ischr(path : NSH(string)) : int =
+  "mac#%"
+
+fun test_file_isdir(path : NSH(string)) : int =
+  "mac#%"
+
+fun test_file_isfifo(path : NSH(string)) : int =
+  "mac#%"
+
+fun test_file_isreg(path : NSH(string)) : int =
+  "mac#%"
+
+//
+// HX: [lstat] is called // ~1/0/1: error/false/true
+//
+fun test_file_islnk(path : NSH(string)) : int =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun fileref_open_exn(path : NSH(string), file_mode) : FILEref =
+  "mac#%"
+
+// end of [fileref_open_exn]
+//
+fun fileref_open_opt(path : NSH(string), file_mode) : Option_vt(FILEref)
+
+// end of [fileref_open_opt]
+//
+(* ****** ****** *)
+//
+fun fileref_close(fil : FILEref) : void =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun fileref_flush(fil : FILEref) : void =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+// HX: error indication: EOF
+//
+fun fileref_getc(input : FILEref) : int =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+// HX: no error reporting
+//
+fun fileref_putc_int(out : FILEref, c : int) : void =
+  "mac#%"
+
+//
+fun fileref_putc_char(out : FILEref, c : char) : void =
+  "mac#%"
+
+//
+symintr fileref_putc
+
+overload fileref_putc with fileref_putc_int
+
+overload fileref_putc with fileref_putc_char
+
+//
+(* ****** ****** *)
+//
+// HX: no error reporting
+//
+fun fileref_puts(out : FILEref, NSH(string)) : void =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun fileref_is_eof(inp : FILEref) : bool =
+  "mac#%"
+
+//
+macdef fileref_isnot_eof(inp) = ~fileref_is_eof(,(inp))
+
+//
+(* ****** ****** *)
+typedef fileref_load_type(a: t@ype) = (FILEref, &a? >> opt(a, b)) -<fun1> #[b:bool] bool(b)
+
+// end of [fileref_load_type]
+//
+fun {a:t0p} fileref_load  : fileref_load_type(a)
+
+//
+fun fileref_load_int : fileref_load_type(int) =
+  "mac#%"
+
+fun fileref_load_lint : fileref_load_type(lint) =
+  "mac#%"
+
+fun fileref_load_uint : fileref_load_type(uint) =
+  "mac#%"
+
+fun fileref_load_ulint : fileref_load_type(ulint) =
+  "mac#%"
+
+//
+fun fileref_load_float : fileref_load_type(float) =
+  "mac#%"
+
+fun fileref_load_double : fileref_load_type(double) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+fun {a:t0p} fileref_get_optval (inp : FILEref) : Option_vt(a)
+
+// end of [fileref_get_optval]
+fun {a:t0p} fileref_get_exnmsg (inp : FILEref, msg : NSH(string)) : a
+
+// end of [fileref_get_exnmsg]
+macdef fileref_get_exnloc(inp) = fileref_get_exnmsg(,(inp), $mylocation)
+
+// end of [fileref_get_exnloc]
+(* ****** ****** *)
+typedef charlst = List0(char)
+
+vtypedef charlst_vt = List0_vt(char)
+
+(* ****** ****** *)
+//
+fun fileref_get_line_charlst(inp : FILEref) : charlst_vt
+
+//
+(* ****** ****** *)
+//
+(*
+** HX: only for files of "tiny" size
+*)
+fun fileref_get_lines_charlstlst(inp : FILEref) : List0_vt(charlst_vt)
+
+//
+(* ****** ****** *)
+//
+(*
+** HX: for handling files of "tiny" size
+*)
+fun fileref_get_file_charlst(inp : FILEref) : List0_vt(char)
+
+fun fileref_get2_file_charlst(inp : FILEref, n : int) : List0_vt(char)
+
+//
+(* ****** ****** *)
+//
+//
+fun fileref_put_string(out : FILEref, cs : NSH(string)) : void
+
+fun fileref_put_charlst(inp : FILEref, cs : NSH(List(char))) : void
+
+//
+(* ****** ****** *)
+//
+//
+// HX-2013-05:
+// these functions are based on [fgets];
+// they should only be applied to files containing
+// no occurrences of the NUL character ('\000').
+//
+fun fileref_get_line_string(inp : FILEref) : Strptr1
+
+//
+fun fileref_get_line_string_main( inp : FILEref
+                                , nchar : &int? >> int(n)
+                                ) : #[n:nat] strnptr(n)
+
+// end-of-function
+fun fileref_get_line_string$bufsize() : intGte(1)
+
+//
+fun fileref_get_lines_stringlst(inp : FILEref) : List0_vt(Strptr1)
+
+//
+(* ****** ****** *)
+//
+fun fileref_get_file_string(inp : FILEref) : Strptr1
+
+fun fileref_get_file_string$bufsize() : intGte(1)
+
+//
+(* ****** ****** *)
+//
+fun fileref_get_word(inp : FILEref) : Strptr0
+
+fun fileref_get_word$isalpha(c0 : charNZ) : bool
+
+//
+(* ****** ****** *)
+//
+fun fileref_foreach(inp : FILEref) : void
+
+fun {env:vt0p} fileref_foreach_env (inp : FILEref, env : &(env) >> _) :
+  void
+
+//
+fun fileref_foreach$bufsize() : sizeGte(1)
+
+fun {env:vt0p} fileref_foreach$fwork (c : char, env : &(env) >> _) :
+  void
+
+fun {env:vt0p} fileref_foreach$fworkv {n:int} ( arrayref(char,n)
+                                              , size_t(n)
+                                              , &(env) >> _
+                                              ) : void
+
+//
+(* ****** ****** *)
+//
+fun streamize_fileref_char(inp : FILEref) : stream_vt(char)
+
+fun streamize_fileref_line(inp : FILEref) : stream_vt(Strptr1)
+
+//
+(* ****** ****** *)
+//
+absvtype FILEptr1_vtype = ptr
+
+vtypedef FILEptr1 = FILEptr1_vtype
+
+//
+fun streamize_fileptr_char(inp : FILEptr1) : stream_vt(char)
+
+fun streamize_fileptr_line(inp : FILEptr1) : stream_vt(Strptr1)
+
+//
+(* ****** ****** *)
+//
+fun streamize_dirname_fname(dir : NSH(string)) : stream_vt(Strptr1)
+
+//
+(* ****** ****** *)
+(* end of [filebas.sats] *)
diff --git a/test/data/stdlib/filebas.sats b/test/data/stdlib/filebas.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/filebas.sats
@@ -0,0 +1,358 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/filebas.atxt
+** Time of generation: Thu Jan 11 11:00:06 2018
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: February, 2012 *)
+
+(* ****** ****** *)
+
+sortdef t0p = t@ype and vt0p = viewt@ype
+
+(* ****** ****** *)
+
+#define NSH (x) x // for commenting: no sharing
+#define SHR (x) x // for commenting: it is shared
+
+(* ****** ****** *)
+
+val stdin_ref : FILEref = "mac#%FILE_stdin"
+val stdout_ref : FILEref = "mac#%FILE_stdout"
+val stderr_ref : FILEref = "mac#%FILE_stderr"
+
+(* ****** ****** *)
+
+fun{} dirsep_get ():<> charNZ
+fun{} dirsep_gets ():<> string
+fun{} dirname_self ():<> string
+fun{} dirname_parent ():<> string
+
+(* ****** ****** *)
+
+fun{}
+filename_get_ext(name: string):<> vStrptr0
+fun{}
+filename_test_ext(name: string, ext: string):<> bool
+
+(* ****** ****** *)
+
+fun{}
+filename_get_base (name: string):<> vStrptr1
+fun{}
+filename_test_base (name: string, base: string):<> bool
+
+(* ****** ****** *)
+//
+val file_mode_r
+  : file_mode(file_mode_r()) = "mac#%" // = "r"
+val file_mode_rr
+  : file_mode(file_mode_rw()) = "mac#%" // = "r+"
+//
+val file_mode_w
+  : file_mode(file_mode_w()) = "mac#%" // = "w"
+val file_mode_ww
+  : file_mode(file_mode_rw()) = "mac#%" // = "w+"
+//
+val file_mode_a
+  : file_mode(file_mode_rw()) = "mac#%" // = "a"
+val file_mode_aa
+  : file_mode(file_mode_rw()) = "mac#%" // = "a+"
+//
+(* ****** ****** *)
+//
+(*
+** HX: [stat] is called
+*)
+fun
+test_file_exists
+  (path: NSH(string)): bool = "mac#%"
+//
+(* ****** ****** *)
+//
+// HX-2011-02-16:
+// [stat] is called to obtain the mode of a given file
+// for [f] to be applied to it.
+//
+fun{}
+test_file_mode
+  (path: NSH(string)): int
+//
+fun{}
+test_file_mode$pred (mode: uint): bool
+//
+fun
+test_file_mode_fun
+  (path: NSH(string), f: uint -> bool): int = "mac#%"
+//
+// HX: [stat] is called // ~1/0/1: error/false/true
+//
+fun
+test_file_isblk(path: NSH(string)): int = "mac#%"
+fun
+test_file_ischr(path: NSH(string)): int = "mac#%"
+fun
+test_file_isdir(path: NSH(string)): int = "mac#%"
+fun
+test_file_isfifo(path: NSH(string)): int = "mac#%"
+fun
+test_file_isreg(path: NSH(string)): int = "mac#%"
+//
+// HX: [lstat] is called // ~1/0/1: error/false/true
+//
+fun
+test_file_islnk(path: NSH(string)): int = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+fileref_open_exn
+  (path: NSH(string), file_mode): FILEref = "mac#%"
+// end of [fileref_open_exn]
+//
+fun{}
+fileref_open_opt
+  (path: NSH(string), file_mode): Option_vt(FILEref)
+// end of [fileref_open_opt]
+//
+(* ****** ****** *)
+//
+fun
+fileref_close(fil: FILEref): void = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+fileref_flush(fil: FILEref): void = "mac#%"
+//
+(* ****** ****** *)
+//
+// HX: error indication: EOF
+//
+fun
+fileref_getc(input: FILEref): int = "mac#%"
+//
+(* ****** ****** *)
+//
+// HX: no error reporting
+//
+fun
+fileref_putc_int
+  (out: FILEref, c: int): void = "mac#%"
+//
+fun
+fileref_putc_char
+  (out: FILEref, c: char): void = "mac#%"
+//
+symintr fileref_putc
+overload fileref_putc with fileref_putc_int
+overload fileref_putc with fileref_putc_char
+//
+(* ****** ****** *)
+//
+// HX: no error reporting
+//
+fun
+fileref_puts
+  (out: FILEref, NSH(string)): void = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+fileref_is_eof(inp: FILEref): bool = "mac#%"
+//
+macdef
+fileref_isnot_eof(inp) = ~fileref_is_eof(,(inp))
+//
+(* ****** ****** *)
+
+typedef
+fileref_load_type(a:t@ype) =
+  (FILEref, &a? >> opt(a, b)) -<fun1> #[b:bool] bool(b)
+// end of [fileref_load_type]
+//
+fun{a:t0p}
+fileref_load : fileref_load_type (a)
+//
+fun
+fileref_load_int : fileref_load_type(int) = "mac#%"
+fun
+fileref_load_lint : fileref_load_type(lint) = "mac#%"
+fun
+fileref_load_uint : fileref_load_type(uint) = "mac#%"
+fun
+fileref_load_ulint : fileref_load_type(ulint) = "mac#%"
+//
+fun
+fileref_load_float : fileref_load_type(float) = "mac#%"
+fun
+fileref_load_double : fileref_load_type(double) = "mac#%"
+//
+(* ****** ****** *)
+
+fun{a:t0p}
+fileref_get_optval
+  (inp: FILEref): Option_vt(a)
+// end of [fileref_get_optval]
+
+fun{
+a:t0p
+} fileref_get_exnmsg
+  (inp: FILEref, msg: NSH(string)): a
+// end of [fileref_get_exnmsg]
+
+macdef
+fileref_get_exnloc
+  (inp) = fileref_get_exnmsg(,(inp), $mylocation)
+// end of [fileref_get_exnloc]
+
+(* ****** ****** *)
+
+typedef charlst = List0(char)
+vtypedef charlst_vt = List0_vt(char)
+
+(* ****** ****** *)
+//
+fun
+fileref_get_line_charlst(inp: FILEref): charlst_vt
+//
+(* ****** ****** *)
+//
+(*
+** HX: only for files of "tiny" size
+*)
+fun
+fileref_get_lines_charlstlst(inp: FILEref): List0_vt(charlst_vt)
+//
+(* ****** ****** *)
+//
+(*
+** HX: for handling files of "tiny" size
+*)
+fun
+fileref_get_file_charlst(inp: FILEref): List0_vt(char)
+fun
+fileref_get2_file_charlst(inp: FILEref, n: int): List0_vt(char)
+//
+(* ****** ****** *)
+//
+//
+fun
+fileref_put_string
+  (out: FILEref, cs: NSH(string)): void
+fun
+fileref_put_charlst
+  (inp: FILEref, cs: NSH(List(char))): void
+//
+(* ****** ****** *)
+//
+//
+// HX-2013-05:
+// these functions are based on [fgets];
+// they should only be applied to files containing
+// no occurrences of the NUL character ('\000').
+//
+fun{}
+fileref_get_line_string(inp: FILEref): Strptr1
+//
+fun{}
+fileref_get_line_string_main
+(
+  inp: FILEref, nchar: &int? >> int(n)
+) : #[n:nat] strnptr(n) // end-of-function
+fun{}
+fileref_get_line_string$bufsize((*void*)): intGte(1)
+//
+fun{}
+fileref_get_lines_stringlst(inp: FILEref): List0_vt(Strptr1)
+//
+(* ****** ****** *)
+//
+fun{}
+fileref_get_file_string(inp: FILEref): Strptr1
+fun{}
+fileref_get_file_string$bufsize((*void*)): intGte(1)
+//
+(* ****** ****** *)
+//
+fun{}
+fileref_get_word(inp: FILEref): Strptr0
+fun{}
+fileref_get_word$isalpha(c0: charNZ): bool
+//
+(* ****** ****** *)
+//
+fun{}
+fileref_foreach(inp: FILEref): void
+fun{
+env:vt0p
+} fileref_foreach_env(inp: FILEref, env: &(env) >> _): void
+//
+fun{}
+fileref_foreach$bufsize((*void*)): sizeGte(1)
+fun{
+env:vt0p
+} fileref_foreach$fwork(c: char, env: &(env) >> _): void
+fun{
+env:vt0p
+} fileref_foreach$fworkv
+  {n:int} (arrayref(char, n), size_t(n), &(env) >> _): void
+//
+(* ****** ****** *)
+//
+fun{}
+streamize_fileref_char(inp: FILEref): stream_vt(char)
+fun{}
+streamize_fileref_line(inp: FILEref): stream_vt(Strptr1)
+//
+(* ****** ****** *)
+//
+absvtype FILEptr1_vtype = ptr
+vtypedef FILEptr1 = FILEptr1_vtype
+//
+fun{}
+streamize_fileptr_char(inp: FILEptr1): stream_vt(char)
+fun{}
+streamize_fileptr_line(inp: FILEptr1): stream_vt(Strptr1)
+//
+(* ****** ****** *)
+//
+fun{}
+streamize_dirname_fname(dir: NSH(string)): stream_vt(Strptr1)
+//
+(* ****** ****** *)
+
+(* end of [filebas.sats] *)
diff --git a/test/data/stdlib/gnumber.out b/test/data/stdlib/gnumber.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/gnumber.out
@@ -0,0 +1,128 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/gnumber.atxt
+** Time of generation: Thu Jan 11 11:00:07 2018
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: September, 2011 *)
+(* ****** ****** *)
+(* Author: Brandon Barker *)
+(* Authoremail: brandon.barker AT gmail DOT com *)
+(* Start time: July, 2013 *)
+(* ****** ****** *)
+//
+// HX: for unindexed gnumber types
+//
+(* ****** ****** *)
+sortdef tk = tkind
+
+(* ****** ****** *)
+typedef SHR(a: type) = a
+
+// for commenting purpose
+typedef NSH(a: type) = a
+
+// for commenting purpose
+(* ****** ****** *)
+abstype fprecision_prop(a1: t0p, a2: t0p)
+
+propdef fprecision (a1 : t0p, a2 : t0p) = fprecision_prop(a1, a2)
+
+praxi fprecision_float() : fprecision(float, float)
+
+praxi fprecision_double() : fprecision(double, double)
+
+praxi fprecision_ldouble() : fprecision(ldouble, ldouble)
+
+(* ****** ****** *)
+//
+// HX: generic number operations
+//
+(* ****** ****** *)
+//
+//
+fun {a:t0p} gnumber_int (x : int) :<> a
+
+fun {a:t0p} gnumber_double (x : double) :<> a
+
+//
+(* ****** ****** *)
+fun {a:t0p} gabs_val (x : a) :<> a
+
+fun {a:t0p} gneg_val (x : a) :<> a
+
+fun {a:t0p} gsucc_val (x : a) :<> a
+
+fun {a:t0p} gpred_val (x : a) :<> a
+
+fun {a:t0p} grecip_val (x : a) :<!exn> a
+
+(* ****** ****** *)
+fun {a:t0p} gadd_val_val (x : a, y : a) :<> a
+
+fun {a:t0p} gsub_val_val (x : a, y : a) :<> a
+
+fun {a:t0p} gmul_val_val (x : a, y : a) :<> a
+
+fun {a:t0p} gdiv_val_val (x : a, y : a) :<!exn> a
+
+fun {a:t0p} gmod_val_val (x : a, y : a) :<!exn> a
+
+(* ****** ****** *)
+//
+fun {a:t0p} gadd_val_int (x : a, y : int) :<> a
+
+fun {a:t0p} gsub_val_int (x : a, y : int) :<> a
+
+//
+fun {a:t0p} gmul_int_val (x : int, y : a) :<> a
+
+fun {a:t0p} gmul_val_int (x : a, y : int) :<> a
+
+//
+fun {a:t0p} gdiv_int_val (x : int, y : a) :<!exn> a
+
+fun {a:t0p} gdiv_val_int (x : a, y : int) :<!exn> a
+
+fun {a:t0p} gmod_val_int (x : a, y : int) :<!exn> a
+
+//
+(* ****** ****** *)
+fun {a:t0p} gsqrt_val (x : a) :<!exn> a
+
+(* ****** ****** *)
+fun {a:t0p} gconjugate_val (x : a) :<> a
+
+(* ****** ****** *)
+fun {a:t0p} gpow_int_val (n : intGte(0), x : a) :<> a
+
+(* ****** ****** *)
+(* end of [gnumber.sats] *)
diff --git a/test/data/stdlib/gnumber.sats b/test/data/stdlib/gnumber.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/gnumber.sats
@@ -0,0 +1,127 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/gnumber.atxt
+** Time of generation: Thu Jan 11 11:00:07 2018
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: September, 2011 *)
+
+(* ****** ****** *)
+
+(* Author: Brandon Barker *)
+(* Authoremail: brandon.barker AT gmail DOT com *)
+(* Start time: July, 2013 *)
+
+(* ****** ****** *)
+//
+// HX: for unindexed gnumber types
+//
+(* ****** ****** *)
+
+sortdef tk = tkind
+
+(* ****** ****** *)
+
+typedef SHR(a:type) = a // for commenting purpose
+typedef NSH(a:type) = a // for commenting purpose
+
+(* ****** ****** *)
+
+abstype
+fprecision_prop (a1:t0p, a2:t0p)
+propdef
+fprecision (a1:t0p, a2:t0p) = fprecision_prop (a1, a2)
+praxi
+fprecision_float (): fprecision (float, float)
+praxi
+fprecision_double (): fprecision (double, double)
+praxi
+fprecision_ldouble (): fprecision (ldouble, ldouble)
+
+(* ****** ****** *)
+//
+// HX: generic number operations
+//
+(* ****** ****** *)
+//
+
+//
+fun{a:t0p} gnumber_int (x: int):<> a
+fun{a:t0p} gnumber_double (x: double):<> a
+//
+(* ****** ****** *)
+
+fun{a:t0p} gabs_val (x: a):<> a
+fun{a:t0p} gneg_val (x: a):<> a
+fun{a:t0p} gsucc_val (x: a):<> a
+fun{a:t0p} gpred_val (x: a):<> a
+fun{a:t0p} grecip_val (x: a):<!exn> a
+
+(* ****** ****** *)
+
+fun{a:t0p} gadd_val_val (x: a, y: a):<> a
+fun{a:t0p} gsub_val_val (x: a, y: a):<> a
+fun{a:t0p} gmul_val_val (x: a, y: a):<> a
+fun{a:t0p} gdiv_val_val (x: a, y: a):<!exn> a
+fun{a:t0p} gmod_val_val (x: a, y: a):<!exn> a
+
+(* ****** ****** *)
+//
+fun{a:t0p} gadd_val_int (x: a, y: int):<> a
+fun{a:t0p} gsub_val_int (x: a, y: int):<> a
+//
+fun{a:t0p} gmul_int_val (x: int, y: a):<> a
+fun{a:t0p} gmul_val_int (x: a, y: int):<> a
+//
+fun{a:t0p} gdiv_int_val (x: int, y: a):<!exn> a
+fun{a:t0p} gdiv_val_int (x: a, y: int):<!exn> a
+fun{a:t0p} gmod_val_int (x: a, y: int):<!exn> a
+//
+(* ****** ****** *)
+
+fun{a:t0p} gsqrt_val (x: a):<!exn> a
+
+(* ****** ****** *)
+
+fun{a:t0p} gconjugate_val (x: a):<> a
+
+(* ****** ****** *)
+
+fun{a:t0p} gpow_int_val (n: intGte(0), x: a):<> a
+
+(* ****** ****** *)
+
+(* end of [gnumber.sats] *)
diff --git a/test/data/stdlib/gorder.out b/test/data/stdlib/gorder.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/gorder.out
@@ -0,0 +1,139 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/gorder.atxt
+** Time of generation: Thu Jan 11 11:00:06 2018
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: September, 2011 *)
+(* ****** ****** *)
+typedef SHR(a: type) = a
+
+// for commenting purpose
+typedef NSH(a: type) = a
+
+// for commenting purpose
+(* ****** ****** *)
+//
+// HX: generic ordering ops
+//
+(* ****** ****** *)
+//
+fun {a:t0p} gisltz_val (x : a) :<> bool
+
+fun {a:t0p} gisltez_val (x : a) :<> bool
+
+//
+fun {a:t0p} gisgtz_val (x : a) :<> bool
+
+fun {a:t0p} gisgtez_val (x : a) :<> bool
+
+//
+fun {a:t0p} giseqz_val (x : a) :<> bool
+
+fun {a:t0p} gisneqz_val (x : a) :<> bool
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} glt_val_val (x : a, y : a) :<> bool
+
+fun {a:t0p} glte_val_val (x : a, y : a) :<> bool
+
+//
+fun {a:t0p} ggt_val_val (x : a, y : a) :<> bool
+
+fun {a:t0p} ggte_val_val (x : a, y : a) :<> bool
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} glt_val_int (x : a, y : int) :<> bool
+
+fun {a:t0p} glte_val_int (x : a, y : int) :<> bool
+
+//
+fun {a:t0p} ggt_val_int (x : a, y : int) :<> bool
+
+fun {a:t0p} ggte_val_int (x : a, y : int) :<> bool
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} geq_val_val (x : a, y : a) :<> bool
+
+fun {a:t0p} gneq_val_val (x : a, y : a) :<> bool
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} geq_val_int (x : a, y : int) :<> bool
+
+fun {a:t0p} gneq_val_int (x : a, y : int) :<> bool
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} gcompare_val_val (x : a, y : a) :<> int
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} gmax_val_val (x : a, y : a) :<> (a)
+
+fun {a:t0p} gmin_val_val (x : a, y : a) :<> (a)
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} glt_ref_ref (x : &INV(a), y : &a) :<> bool
+
+fun {a:vt0p} glte_ref_ref (x : &INV(a), y : &a) :<> bool
+
+//
+fun {a:vt0p} ggt_ref_ref (x : &INV(a), y : &a) :<> bool
+
+fun {a:vt0p} ggte_ref_ref (x : &INV(a), y : &a) :<> bool
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} geq_ref_ref (x : &INV(a), y : &a) :<> bool
+
+fun {a:vt0p} gneq_ref_ref (x : &INV(a), y : &a) :<> bool
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} gcompare_ref_ref (x : &INV(a), y : &a) :<> int
+
+//
+(* ****** ****** *)
+(* end of [gorder.sats] *)
diff --git a/test/data/stdlib/gorder.sats b/test/data/stdlib/gorder.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/gorder.sats
@@ -0,0 +1,172 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/gorder.atxt
+** Time of generation: Thu Jan 11 11:00:06 2018
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: September, 2011 *)
+
+(* ****** ****** *)
+
+typedef SHR(a:type) = a // for commenting purpose
+typedef NSH(a:type) = a // for commenting purpose
+
+(* ****** ****** *)
+//
+// HX: generic ordering ops
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+gisltz_val (x: a):<> bool
+fun
+{a:t0p}
+gisltez_val (x: a):<> bool
+//
+fun
+{a:t0p}
+gisgtz_val (x: a):<> bool
+fun
+{a:t0p}
+gisgtez_val (x: a):<> bool
+//
+fun
+{a:t0p}
+giseqz_val (x: a):<> bool
+fun
+{a:t0p}
+gisneqz_val (x: a):<> bool
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+glt_val_val (x: a, y: a):<> bool
+fun
+{a:t0p}
+glte_val_val (x: a, y: a):<> bool
+//
+fun
+{a:t0p}
+ggt_val_val (x: a, y: a):<> bool
+fun
+{a:t0p}
+ggte_val_val (x: a, y: a):<> bool
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+glt_val_int (x: a, y: int):<> bool
+fun
+{a:t0p}
+glte_val_int (x: a, y: int):<> bool
+//
+fun
+{a:t0p}
+ggt_val_int (x: a, y: int):<> bool
+fun
+{a:t0p}
+ggte_val_int (x: a, y: int):<> bool
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+geq_val_val (x: a, y: a):<> bool
+fun
+{a:t0p}
+gneq_val_val (x: a, y: a):<> bool
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+geq_val_int (x: a, y: int):<> bool
+fun
+{a:t0p}
+gneq_val_int (x: a, y: int):<> bool
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+gcompare_val_val (x: a, y: a):<> int
+//
+(* ****** ****** *)
+//
+fun
+{a:t0p}
+gmax_val_val (x: a, y: a):<> (a)
+fun
+{a:t0p}
+gmin_val_val (x: a, y: a):<> (a)
+//
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+glt_ref_ref (x: &INV(a), y: &a):<> bool
+fun
+{a:vt0p}
+glte_ref_ref (x: &INV(a), y: &a):<> bool
+//
+fun
+{a:vt0p}
+ggt_ref_ref (x: &INV(a), y: &a):<> bool
+fun
+{a:vt0p}
+ggte_ref_ref (x: &INV(a), y: &a):<> bool
+//
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+geq_ref_ref (x: &INV(a), y: &a):<> bool
+fun
+{a:vt0p}
+gneq_ref_ref (x: &INV(a), y: &a):<> bool
+//
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+gcompare_ref_ref (x: &INV(a), y: &a):<> int
+//
+(* ****** ****** *)
+
+(* end of [gorder.sats] *)
diff --git a/test/data/stdlib/integer_fixed.out b/test/data/stdlib/integer_fixed.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/integer_fixed.out
@@ -0,0 +1,1436 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: January, 2013 *)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/integer_fixed.atxt
+** Time of generation: Thu Jan 11 11:00:05 2018
+*)
+(* ****** ****** *)
+//
+// HX: for unindexed integer types
+//
+(* ****** ****** *)
+sortdef tk = tkind
+
+(* ****** ****** *)
+//
+stadef int8knd  = int8_kind
+stadef int16knd  = int16_kind
+stadef int32knd  = int32_kind
+stadef int64knd  = int64_kind
+
+//
+stadef uint8knd  = uint8_kind
+stadef uint16knd  = uint16_kind
+stadef uint32knd  = uint32_kind
+stadef uint64knd  = uint64_kind
+
+//
+(* ****** ****** *)
+//
+fun g0int2int_int8_int(x : int8) :<> int =
+  "mac#%"
+
+fun g0int2int_int16_int(x : int16) :<> int =
+  "mac#%"
+
+fun g0int2int_int32_int(x : int32) :<> int =
+  "mac#%"
+
+fun g0int2int_int64_int(x : int64) :<> int =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0int_neg_int8(x : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_abs_int8(x : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_succ_int8(x : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_pred_int8(x : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_half_int8(x : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_asl_int8(x : int8, n : intGte(0)) :<> int8 =
+  "mac#%"
+
+fun g0int_asr_int8(x : int8, n : intGte(0)) :<> int8 =
+  "mac#%"
+
+fun g0int_add_int8(x : int8, y : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_sub_int8(x : int8, y : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_mul_int8(x : int8, y : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_div_int8(x : int8, y : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_mod_int8(x : int8, y : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_lt_int8(x : int8, y : int8) :<> bool =
+  "mac#%"
+
+fun g0int_lte_int8(x : int8, y : int8) :<> bool =
+  "mac#%"
+
+fun g0int_gt_int8(x : int8, y : int8) :<> bool =
+  "mac#%"
+
+fun g0int_gte_int8(x : int8, y : int8) :<> bool =
+  "mac#%"
+
+fun g0int_eq_int8(x : int8, y : int8) :<> bool =
+  "mac#%"
+
+fun g0int_neq_int8(x : int8, y : int8) :<> bool =
+  "mac#%"
+
+fun g0int_compare_int8(x : int8, y : int8) :<> int =
+  "mac#%"
+
+fun g0int_max_int8(x : int8, y : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_min_int8(x : int8, y : int8) :<> int8 =
+  "mac#%"
+
+fun g0int_isltz_int8(x : int8) :<> bool =
+  "mac#%"
+
+fun g0int_isltez_int8(x : int8) :<> bool =
+  "mac#%"
+
+fun g0int_isgtz_int8(x : int8) :<> bool =
+  "mac#%"
+
+fun g0int_isgtez_int8(x : int8) :<> bool =
+  "mac#%"
+
+fun g0int_iseqz_int8(x : int8) :<> bool =
+  "mac#%"
+
+fun g0int_isneqz_int8(x : int8) :<> bool =
+  "mac#%"
+
+//
+fun g0int_neg_int16(x : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_abs_int16(x : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_succ_int16(x : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_pred_int16(x : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_half_int16(x : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_asl_int16(x : int16, n : intGte(0)) :<> int16 =
+  "mac#%"
+
+fun g0int_asr_int16(x : int16, n : intGte(0)) :<> int16 =
+  "mac#%"
+
+fun g0int_add_int16(x : int16, y : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_sub_int16(x : int16, y : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_mul_int16(x : int16, y : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_div_int16(x : int16, y : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_mod_int16(x : int16, y : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_lt_int16(x : int16, y : int16) :<> bool =
+  "mac#%"
+
+fun g0int_lte_int16(x : int16, y : int16) :<> bool =
+  "mac#%"
+
+fun g0int_gt_int16(x : int16, y : int16) :<> bool =
+  "mac#%"
+
+fun g0int_gte_int16(x : int16, y : int16) :<> bool =
+  "mac#%"
+
+fun g0int_eq_int16(x : int16, y : int16) :<> bool =
+  "mac#%"
+
+fun g0int_neq_int16(x : int16, y : int16) :<> bool =
+  "mac#%"
+
+fun g0int_compare_int16(x : int16, y : int16) :<> int =
+  "mac#%"
+
+fun g0int_max_int16(x : int16, y : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_min_int16(x : int16, y : int16) :<> int16 =
+  "mac#%"
+
+fun g0int_isltz_int16(x : int16) :<> bool =
+  "mac#%"
+
+fun g0int_isltez_int16(x : int16) :<> bool =
+  "mac#%"
+
+fun g0int_isgtz_int16(x : int16) :<> bool =
+  "mac#%"
+
+fun g0int_isgtez_int16(x : int16) :<> bool =
+  "mac#%"
+
+fun g0int_iseqz_int16(x : int16) :<> bool =
+  "mac#%"
+
+fun g0int_isneqz_int16(x : int16) :<> bool =
+  "mac#%"
+
+//
+fun g0int_neg_int32(x : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_abs_int32(x : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_succ_int32(x : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_pred_int32(x : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_half_int32(x : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_asl_int32(x : int32, n : intGte(0)) :<> int32 =
+  "mac#%"
+
+fun g0int_asr_int32(x : int32, n : intGte(0)) :<> int32 =
+  "mac#%"
+
+fun g0int_add_int32(x : int32, y : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_sub_int32(x : int32, y : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_mul_int32(x : int32, y : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_div_int32(x : int32, y : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_mod_int32(x : int32, y : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_lt_int32(x : int32, y : int32) :<> bool =
+  "mac#%"
+
+fun g0int_lte_int32(x : int32, y : int32) :<> bool =
+  "mac#%"
+
+fun g0int_gt_int32(x : int32, y : int32) :<> bool =
+  "mac#%"
+
+fun g0int_gte_int32(x : int32, y : int32) :<> bool =
+  "mac#%"
+
+fun g0int_eq_int32(x : int32, y : int32) :<> bool =
+  "mac#%"
+
+fun g0int_neq_int32(x : int32, y : int32) :<> bool =
+  "mac#%"
+
+fun g0int_compare_int32(x : int32, y : int32) :<> int =
+  "mac#%"
+
+fun g0int_max_int32(x : int32, y : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_min_int32(x : int32, y : int32) :<> int32 =
+  "mac#%"
+
+fun g0int_isltz_int32(x : int32) :<> bool =
+  "mac#%"
+
+fun g0int_isltez_int32(x : int32) :<> bool =
+  "mac#%"
+
+fun g0int_isgtz_int32(x : int32) :<> bool =
+  "mac#%"
+
+fun g0int_isgtez_int32(x : int32) :<> bool =
+  "mac#%"
+
+fun g0int_iseqz_int32(x : int32) :<> bool =
+  "mac#%"
+
+fun g0int_isneqz_int32(x : int32) :<> bool =
+  "mac#%"
+
+//
+fun g0int_neg_int64(x : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_abs_int64(x : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_succ_int64(x : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_pred_int64(x : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_half_int64(x : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_asl_int64(x : int64, n : intGte(0)) :<> int64 =
+  "mac#%"
+
+fun g0int_asr_int64(x : int64, n : intGte(0)) :<> int64 =
+  "mac#%"
+
+fun g0int_add_int64(x : int64, y : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_sub_int64(x : int64, y : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_mul_int64(x : int64, y : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_div_int64(x : int64, y : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_mod_int64(x : int64, y : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_lt_int64(x : int64, y : int64) :<> bool =
+  "mac#%"
+
+fun g0int_lte_int64(x : int64, y : int64) :<> bool =
+  "mac#%"
+
+fun g0int_gt_int64(x : int64, y : int64) :<> bool =
+  "mac#%"
+
+fun g0int_gte_int64(x : int64, y : int64) :<> bool =
+  "mac#%"
+
+fun g0int_eq_int64(x : int64, y : int64) :<> bool =
+  "mac#%"
+
+fun g0int_neq_int64(x : int64, y : int64) :<> bool =
+  "mac#%"
+
+fun g0int_compare_int64(x : int64, y : int64) :<> int =
+  "mac#%"
+
+fun g0int_max_int64(x : int64, y : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_min_int64(x : int64, y : int64) :<> int64 =
+  "mac#%"
+
+fun g0int_isltz_int64(x : int64) :<> bool =
+  "mac#%"
+
+fun g0int_isltez_int64(x : int64) :<> bool =
+  "mac#%"
+
+fun g0int_isgtz_int64(x : int64) :<> bool =
+  "mac#%"
+
+fun g0int_isgtez_int64(x : int64) :<> bool =
+  "mac#%"
+
+fun g0int_iseqz_int64(x : int64) :<> bool =
+  "mac#%"
+
+fun g0int_isneqz_int64(x : int64) :<> bool =
+  "mac#%"
+
+//
+(* ****** ****** *)
+fun print_int8(int8) : void =
+  "mac#%"
+
+fun prerr_int8(int8) : void =
+  "mac#%"
+
+fun fprint_int8 : fprint_type(int8) =
+  "mac#%"
+
+overload print with print_int8
+
+overload prerr with prerr_int8
+
+overload fprint with fprint_int8
+
+fun print_int16(int16) : void =
+  "mac#%"
+
+fun prerr_int16(int16) : void =
+  "mac#%"
+
+fun fprint_int16 : fprint_type(int16) =
+  "mac#%"
+
+overload print with print_int16
+
+overload prerr with prerr_int16
+
+overload fprint with fprint_int16
+
+fun print_int32(int32) : void =
+  "mac#%"
+
+fun prerr_int32(int32) : void =
+  "mac#%"
+
+fun fprint_int32 : fprint_type(int32) =
+  "mac#%"
+
+overload print with print_int32
+
+overload prerr with prerr_int32
+
+overload fprint with fprint_int32
+
+fun print_int64(int64) : void =
+  "mac#%"
+
+fun prerr_int64(int64) : void =
+  "mac#%"
+
+fun fprint_int64 : fprint_type(int64) =
+  "mac#%"
+
+overload print with print_int64
+
+overload prerr with prerr_int64
+
+overload fprint with fprint_int64
+
+(* ****** ****** *)
+//
+fun g0int2uint_int8_uint(x : int8) :<> uint =
+  "mac#%"
+
+fun g0int2uint_int16_uint(x : int16) :<> uint =
+  "mac#%"
+
+fun g0int2uint_int32_uint(x : int32) :<> uint =
+  "mac#%"
+
+fun g0int2uint_int64_uint(x : int64) :<> uint =
+  "mac#%"
+
+//
+fun g0uint2int_uint8_int(x : uint8) :<> int =
+  "mac#%"
+
+fun g0uint2int_uint16_int(x : uint16) :<> int =
+  "mac#%"
+
+fun g0uint2int_uint32_int(x : uint32) :<> int =
+  "mac#%"
+
+fun g0uint2int_uint64_int(x : uint64) :<> int =
+  "mac#%"
+
+//
+fun g0uint2uint_uint8_uint(x : uint8) :<> uint =
+  "mac#%"
+
+fun g0uint2uint_uint16_uint(x : uint16) :<> uint =
+  "mac#%"
+
+fun g0uint2uint_uint32_uint(x : uint32) :<> uint =
+  "mac#%"
+
+fun g0uint2uint_uint64_uint(x : uint64) :<> uint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0uint_succ_uint8(x : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_pred_uint8(x : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_half_uint8(x : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_add_uint8(x : uint8, y : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_sub_uint8(x : uint8, y : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_mul_uint8(x : uint8, y : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_div_uint8(x : uint8, y : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_mod_uint8(x : uint8, y : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_lsl_uint8(x : uint8, n : intGte(0)) :<> uint8 =
+  "mac#%"
+
+fun g0uint_lsr_uint8(x : uint8, n : intGte(0)) :<> uint8 =
+  "mac#%"
+
+fun g0uint_lnot_uint8(x : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_lor_uint8(x : uint8, y : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_lxor_uint8(x : uint8, y : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_land_uint8(x : uint8, y : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_lt_uint8(x : uint8, y : uint8) :<> bool =
+  "mac#%"
+
+fun g0uint_lte_uint8(x : uint8, y : uint8) :<> bool =
+  "mac#%"
+
+fun g0uint_gt_uint8(x : uint8, y : uint8) :<> bool =
+  "mac#%"
+
+fun g0uint_gte_uint8(x : uint8, y : uint8) :<> bool =
+  "mac#%"
+
+fun g0uint_eq_uint8(x : uint8, y : uint8) :<> bool =
+  "mac#%"
+
+fun g0uint_neq_uint8(x : uint8, y : uint8) :<> bool =
+  "mac#%"
+
+fun g0uint_compare_uint8(x : uint8, y : uint8) :<> int =
+  "mac#%"
+
+fun g0uint_max_uint8(x : uint8, y : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_min_uint8(x : uint8, y : uint8) :<> uint8 =
+  "mac#%"
+
+fun g0uint_isgtz_uint8(x : uint8) :<> bool =
+  "mac#%"
+
+fun g0uint_iseqz_uint8(x : uint8) :<> bool =
+  "mac#%"
+
+fun g0uint_isneqz_uint8(x : uint8) :<> bool =
+  "mac#%"
+
+//
+fun g0uint_succ_uint16(x : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_pred_uint16(x : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_half_uint16(x : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_add_uint16(x : uint16, y : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_sub_uint16(x : uint16, y : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_mul_uint16(x : uint16, y : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_div_uint16(x : uint16, y : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_mod_uint16(x : uint16, y : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_lsl_uint16(x : uint16, n : intGte(0)) :<> uint16 =
+  "mac#%"
+
+fun g0uint_lsr_uint16(x : uint16, n : intGte(0)) :<> uint16 =
+  "mac#%"
+
+fun g0uint_lnot_uint16(x : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_lor_uint16(x : uint16, y : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_lxor_uint16(x : uint16, y : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_land_uint16(x : uint16, y : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_lt_uint16(x : uint16, y : uint16) :<> bool =
+  "mac#%"
+
+fun g0uint_lte_uint16(x : uint16, y : uint16) :<> bool =
+  "mac#%"
+
+fun g0uint_gt_uint16(x : uint16, y : uint16) :<> bool =
+  "mac#%"
+
+fun g0uint_gte_uint16(x : uint16, y : uint16) :<> bool =
+  "mac#%"
+
+fun g0uint_eq_uint16(x : uint16, y : uint16) :<> bool =
+  "mac#%"
+
+fun g0uint_neq_uint16(x : uint16, y : uint16) :<> bool =
+  "mac#%"
+
+fun g0uint_compare_uint16(x : uint16, y : uint16) :<> int =
+  "mac#%"
+
+fun g0uint_max_uint16(x : uint16, y : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_min_uint16(x : uint16, y : uint16) :<> uint16 =
+  "mac#%"
+
+fun g0uint_isgtz_uint16(x : uint16) :<> bool =
+  "mac#%"
+
+fun g0uint_iseqz_uint16(x : uint16) :<> bool =
+  "mac#%"
+
+fun g0uint_isneqz_uint16(x : uint16) :<> bool =
+  "mac#%"
+
+//
+fun g0uint_succ_uint32(x : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_pred_uint32(x : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_half_uint32(x : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_add_uint32(x : uint32, y : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_sub_uint32(x : uint32, y : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_mul_uint32(x : uint32, y : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_div_uint32(x : uint32, y : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_mod_uint32(x : uint32, y : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_lsl_uint32(x : uint32, n : intGte(0)) :<> uint32 =
+  "mac#%"
+
+fun g0uint_lsr_uint32(x : uint32, n : intGte(0)) :<> uint32 =
+  "mac#%"
+
+fun g0uint_lnot_uint32(x : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_lor_uint32(x : uint32, y : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_lxor_uint32(x : uint32, y : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_land_uint32(x : uint32, y : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_lt_uint32(x : uint32, y : uint32) :<> bool =
+  "mac#%"
+
+fun g0uint_lte_uint32(x : uint32, y : uint32) :<> bool =
+  "mac#%"
+
+fun g0uint_gt_uint32(x : uint32, y : uint32) :<> bool =
+  "mac#%"
+
+fun g0uint_gte_uint32(x : uint32, y : uint32) :<> bool =
+  "mac#%"
+
+fun g0uint_eq_uint32(x : uint32, y : uint32) :<> bool =
+  "mac#%"
+
+fun g0uint_neq_uint32(x : uint32, y : uint32) :<> bool =
+  "mac#%"
+
+fun g0uint_compare_uint32(x : uint32, y : uint32) :<> int =
+  "mac#%"
+
+fun g0uint_max_uint32(x : uint32, y : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_min_uint32(x : uint32, y : uint32) :<> uint32 =
+  "mac#%"
+
+fun g0uint_isgtz_uint32(x : uint32) :<> bool =
+  "mac#%"
+
+fun g0uint_iseqz_uint32(x : uint32) :<> bool =
+  "mac#%"
+
+fun g0uint_isneqz_uint32(x : uint32) :<> bool =
+  "mac#%"
+
+//
+fun g0uint_succ_uint64(x : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_pred_uint64(x : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_half_uint64(x : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_add_uint64(x : uint64, y : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_sub_uint64(x : uint64, y : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_mul_uint64(x : uint64, y : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_div_uint64(x : uint64, y : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_mod_uint64(x : uint64, y : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_lsl_uint64(x : uint64, n : intGte(0)) :<> uint64 =
+  "mac#%"
+
+fun g0uint_lsr_uint64(x : uint64, n : intGte(0)) :<> uint64 =
+  "mac#%"
+
+fun g0uint_lnot_uint64(x : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_lor_uint64(x : uint64, y : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_lxor_uint64(x : uint64, y : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_land_uint64(x : uint64, y : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_lt_uint64(x : uint64, y : uint64) :<> bool =
+  "mac#%"
+
+fun g0uint_lte_uint64(x : uint64, y : uint64) :<> bool =
+  "mac#%"
+
+fun g0uint_gt_uint64(x : uint64, y : uint64) :<> bool =
+  "mac#%"
+
+fun g0uint_gte_uint64(x : uint64, y : uint64) :<> bool =
+  "mac#%"
+
+fun g0uint_eq_uint64(x : uint64, y : uint64) :<> bool =
+  "mac#%"
+
+fun g0uint_neq_uint64(x : uint64, y : uint64) :<> bool =
+  "mac#%"
+
+fun g0uint_compare_uint64(x : uint64, y : uint64) :<> int =
+  "mac#%"
+
+fun g0uint_max_uint64(x : uint64, y : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_min_uint64(x : uint64, y : uint64) :<> uint64 =
+  "mac#%"
+
+fun g0uint_isgtz_uint64(x : uint64) :<> bool =
+  "mac#%"
+
+fun g0uint_iseqz_uint64(x : uint64) :<> bool =
+  "mac#%"
+
+fun g0uint_isneqz_uint64(x : uint64) :<> bool =
+  "mac#%"
+
+//
+(* ****** ****** *)
+fun print_uint8(uint8) : void =
+  "mac#%"
+
+fun prerr_uint8(uint8) : void =
+  "mac#%"
+
+fun fprint_uint8 : fprint_type(uint8) =
+  "mac#%"
+
+overload print with print_uint8
+
+overload prerr with prerr_uint8
+
+overload fprint with fprint_uint8
+
+fun print_uint16(uint16) : void =
+  "mac#%"
+
+fun prerr_uint16(uint16) : void =
+  "mac#%"
+
+fun fprint_uint16 : fprint_type(uint16) =
+  "mac#%"
+
+overload print with print_uint16
+
+overload prerr with prerr_uint16
+
+overload fprint with fprint_uint16
+
+fun print_uint32(uint32) : void =
+  "mac#%"
+
+fun prerr_uint32(uint32) : void =
+  "mac#%"
+
+fun fprint_uint32 : fprint_type(uint32) =
+  "mac#%"
+
+overload print with print_uint32
+
+overload prerr with prerr_uint32
+
+overload fprint with fprint_uint32
+
+fun print_uint64(uint64) : void =
+  "mac#%"
+
+fun prerr_uint64(uint64) : void =
+  "mac#%"
+
+fun fprint_uint64 : fprint_type(uint64) =
+  "mac#%"
+
+overload print with print_uint64
+
+overload prerr with prerr_uint64
+
+overload fprint with fprint_uint64
+
+(* ****** ****** *)
+//
+fun g1int_neg_int8 : g1int_neg_type(int8knd) =
+  "mac#%"
+
+fun g1int_abs_int8 : g1int_abs_type(int8knd) =
+  "mac#%"
+
+fun g1int_succ_int8 : g1int_succ_type(int8knd) =
+  "mac#%"
+
+fun g1int_pred_int8 : g1int_pred_type(int8knd) =
+  "mac#%"
+
+fun g1int_half_int8 : g1int_half_type(int8knd) =
+  "mac#%"
+
+fun g1int_add_int8 : g1int_add_type(int8knd) =
+  "mac#%"
+
+fun g1int_sub_int8 : g1int_sub_type(int8knd) =
+  "mac#%"
+
+fun g1int_mul_int8 : g1int_mul_type(int8knd) =
+  "mac#%"
+
+fun g1int_div_int8 : g1int_div_type(int8knd) =
+  "mac#%"
+
+fun g1int_nmod_int8 : g1int_nmod_type(int8knd) =
+  "mac#%"
+
+fun g1int_lt_int8 : g1int_lt_type(int8knd) =
+  "mac#%"
+
+fun g1int_lte_int8 : g1int_lte_type(int8knd) =
+  "mac#%"
+
+fun g1int_gt_int8 : g1int_gt_type(int8knd) =
+  "mac#%"
+
+fun g1int_gte_int8 : g1int_gte_type(int8knd) =
+  "mac#%"
+
+fun g1int_eq_int8 : g1int_eq_type(int8knd) =
+  "mac#%"
+
+fun g1int_neq_int8 : g1int_neq_type(int8knd) =
+  "mac#%"
+
+fun g1int_compare_int8 : g1int_compare_type(int8knd) =
+  "mac#%"
+
+fun g1int_max_int8 : g1int_max_type(int8knd) =
+  "mac#%"
+
+fun g1int_min_int8 : g1int_min_type(int8knd) =
+  "mac#%"
+
+fun g1int_isltz_int8 : g1int_isltz_type(int8knd) =
+  "mac#%"
+
+fun g1int_isltez_int8 : g1int_isltez_type(int8knd) =
+  "mac#%"
+
+fun g1int_isgtz_int8 : g1int_isgtz_type(int8knd) =
+  "mac#%"
+
+fun g1int_isgtez_int8 : g1int_isgtez_type(int8knd) =
+  "mac#%"
+
+fun g1int_iseqz_int8 : g1int_iseqz_type(int8knd) =
+  "mac#%"
+
+fun g1int_isneqz_int8 : g1int_isneqz_type(int8knd) =
+  "mac#%"
+
+//
+fun g1int_neg_int16 : g1int_neg_type(int16knd) =
+  "mac#%"
+
+fun g1int_abs_int16 : g1int_abs_type(int16knd) =
+  "mac#%"
+
+fun g1int_succ_int16 : g1int_succ_type(int16knd) =
+  "mac#%"
+
+fun g1int_pred_int16 : g1int_pred_type(int16knd) =
+  "mac#%"
+
+fun g1int_half_int16 : g1int_half_type(int16knd) =
+  "mac#%"
+
+fun g1int_add_int16 : g1int_add_type(int16knd) =
+  "mac#%"
+
+fun g1int_sub_int16 : g1int_sub_type(int16knd) =
+  "mac#%"
+
+fun g1int_mul_int16 : g1int_mul_type(int16knd) =
+  "mac#%"
+
+fun g1int_div_int16 : g1int_div_type(int16knd) =
+  "mac#%"
+
+fun g1int_nmod_int16 : g1int_nmod_type(int16knd) =
+  "mac#%"
+
+fun g1int_lt_int16 : g1int_lt_type(int16knd) =
+  "mac#%"
+
+fun g1int_lte_int16 : g1int_lte_type(int16knd) =
+  "mac#%"
+
+fun g1int_gt_int16 : g1int_gt_type(int16knd) =
+  "mac#%"
+
+fun g1int_gte_int16 : g1int_gte_type(int16knd) =
+  "mac#%"
+
+fun g1int_eq_int16 : g1int_eq_type(int16knd) =
+  "mac#%"
+
+fun g1int_neq_int16 : g1int_neq_type(int16knd) =
+  "mac#%"
+
+fun g1int_compare_int16 : g1int_compare_type(int16knd) =
+  "mac#%"
+
+fun g1int_max_int16 : g1int_max_type(int16knd) =
+  "mac#%"
+
+fun g1int_min_int16 : g1int_min_type(int16knd) =
+  "mac#%"
+
+fun g1int_isltz_int16 : g1int_isltz_type(int16knd) =
+  "mac#%"
+
+fun g1int_isltez_int16 : g1int_isltez_type(int16knd) =
+  "mac#%"
+
+fun g1int_isgtz_int16 : g1int_isgtz_type(int16knd) =
+  "mac#%"
+
+fun g1int_isgtez_int16 : g1int_isgtez_type(int16knd) =
+  "mac#%"
+
+fun g1int_iseqz_int16 : g1int_iseqz_type(int16knd) =
+  "mac#%"
+
+fun g1int_isneqz_int16 : g1int_isneqz_type(int16knd) =
+  "mac#%"
+
+//
+fun g1int_neg_int32 : g1int_neg_type(int32knd) =
+  "mac#%"
+
+fun g1int_abs_int32 : g1int_abs_type(int32knd) =
+  "mac#%"
+
+fun g1int_succ_int32 : g1int_succ_type(int32knd) =
+  "mac#%"
+
+fun g1int_pred_int32 : g1int_pred_type(int32knd) =
+  "mac#%"
+
+fun g1int_half_int32 : g1int_half_type(int32knd) =
+  "mac#%"
+
+fun g1int_add_int32 : g1int_add_type(int32knd) =
+  "mac#%"
+
+fun g1int_sub_int32 : g1int_sub_type(int32knd) =
+  "mac#%"
+
+fun g1int_mul_int32 : g1int_mul_type(int32knd) =
+  "mac#%"
+
+fun g1int_div_int32 : g1int_div_type(int32knd) =
+  "mac#%"
+
+fun g1int_nmod_int32 : g1int_nmod_type(int32knd) =
+  "mac#%"
+
+fun g1int_lt_int32 : g1int_lt_type(int32knd) =
+  "mac#%"
+
+fun g1int_lte_int32 : g1int_lte_type(int32knd) =
+  "mac#%"
+
+fun g1int_gt_int32 : g1int_gt_type(int32knd) =
+  "mac#%"
+
+fun g1int_gte_int32 : g1int_gte_type(int32knd) =
+  "mac#%"
+
+fun g1int_eq_int32 : g1int_eq_type(int32knd) =
+  "mac#%"
+
+fun g1int_neq_int32 : g1int_neq_type(int32knd) =
+  "mac#%"
+
+fun g1int_compare_int32 : g1int_compare_type(int32knd) =
+  "mac#%"
+
+fun g1int_max_int32 : g1int_max_type(int32knd) =
+  "mac#%"
+
+fun g1int_min_int32 : g1int_min_type(int32knd) =
+  "mac#%"
+
+fun g1int_isltz_int32 : g1int_isltz_type(int32knd) =
+  "mac#%"
+
+fun g1int_isltez_int32 : g1int_isltez_type(int32knd) =
+  "mac#%"
+
+fun g1int_isgtz_int32 : g1int_isgtz_type(int32knd) =
+  "mac#%"
+
+fun g1int_isgtez_int32 : g1int_isgtez_type(int32knd) =
+  "mac#%"
+
+fun g1int_iseqz_int32 : g1int_iseqz_type(int32knd) =
+  "mac#%"
+
+fun g1int_isneqz_int32 : g1int_isneqz_type(int32knd) =
+  "mac#%"
+
+//
+fun g1int_neg_int64 : g1int_neg_type(int64knd) =
+  "mac#%"
+
+fun g1int_abs_int64 : g1int_abs_type(int64knd) =
+  "mac#%"
+
+fun g1int_succ_int64 : g1int_succ_type(int64knd) =
+  "mac#%"
+
+fun g1int_pred_int64 : g1int_pred_type(int64knd) =
+  "mac#%"
+
+fun g1int_half_int64 : g1int_half_type(int64knd) =
+  "mac#%"
+
+fun g1int_add_int64 : g1int_add_type(int64knd) =
+  "mac#%"
+
+fun g1int_sub_int64 : g1int_sub_type(int64knd) =
+  "mac#%"
+
+fun g1int_mul_int64 : g1int_mul_type(int64knd) =
+  "mac#%"
+
+fun g1int_div_int64 : g1int_div_type(int64knd) =
+  "mac#%"
+
+fun g1int_nmod_int64 : g1int_nmod_type(int64knd) =
+  "mac#%"
+
+fun g1int_lt_int64 : g1int_lt_type(int64knd) =
+  "mac#%"
+
+fun g1int_lte_int64 : g1int_lte_type(int64knd) =
+  "mac#%"
+
+fun g1int_gt_int64 : g1int_gt_type(int64knd) =
+  "mac#%"
+
+fun g1int_gte_int64 : g1int_gte_type(int64knd) =
+  "mac#%"
+
+fun g1int_eq_int64 : g1int_eq_type(int64knd) =
+  "mac#%"
+
+fun g1int_neq_int64 : g1int_neq_type(int64knd) =
+  "mac#%"
+
+fun g1int_compare_int64 : g1int_compare_type(int64knd) =
+  "mac#%"
+
+fun g1int_max_int64 : g1int_max_type(int64knd) =
+  "mac#%"
+
+fun g1int_min_int64 : g1int_min_type(int64knd) =
+  "mac#%"
+
+fun g1int_isltz_int64 : g1int_isltz_type(int64knd) =
+  "mac#%"
+
+fun g1int_isltez_int64 : g1int_isltez_type(int64knd) =
+  "mac#%"
+
+fun g1int_isgtz_int64 : g1int_isgtz_type(int64knd) =
+  "mac#%"
+
+fun g1int_isgtez_int64 : g1int_isgtez_type(int64knd) =
+  "mac#%"
+
+fun g1int_iseqz_int64 : g1int_iseqz_type(int64knd) =
+  "mac#%"
+
+fun g1int_isneqz_int64 : g1int_isneqz_type(int64knd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1uint_succ_uint8 : g1uint_succ_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_pred_uint8 : g1uint_pred_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_half_uint8 : g1uint_half_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_add_uint8 : g1uint_add_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_sub_uint8 : g1uint_sub_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_mul_uint8 : g1uint_mul_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_div_uint8 : g1uint_div_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_mod_uint8 : g1uint_mod_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_lt_uint8 : g1uint_lt_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_lte_uint8 : g1uint_lte_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_gt_uint8 : g1uint_gt_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_gte_uint8 : g1uint_gte_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_eq_uint8 : g1uint_eq_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_neq_uint8 : g1uint_neq_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_compare_uint8 : g1uint_compare_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_max_uint8 : g1uint_max_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_min_uint8 : g1uint_min_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_isgtz_uint8 : g1uint_isgtz_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_iseqz_uint8 : g1uint_iseqz_type(uint8knd) =
+  "mac#%"
+
+fun g1uint_isneqz_uint8 : g1uint_isneqz_type(uint8knd) =
+  "mac#%"
+
+//
+fun g1uint_succ_uint16 : g1uint_succ_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_pred_uint16 : g1uint_pred_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_half_uint16 : g1uint_half_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_add_uint16 : g1uint_add_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_sub_uint16 : g1uint_sub_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_mul_uint16 : g1uint_mul_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_div_uint16 : g1uint_div_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_mod_uint16 : g1uint_mod_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_lt_uint16 : g1uint_lt_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_lte_uint16 : g1uint_lte_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_gt_uint16 : g1uint_gt_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_gte_uint16 : g1uint_gte_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_eq_uint16 : g1uint_eq_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_neq_uint16 : g1uint_neq_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_compare_uint16 : g1uint_compare_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_max_uint16 : g1uint_max_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_min_uint16 : g1uint_min_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_isgtz_uint16 : g1uint_isgtz_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_iseqz_uint16 : g1uint_iseqz_type(uint16knd) =
+  "mac#%"
+
+fun g1uint_isneqz_uint16 : g1uint_isneqz_type(uint16knd) =
+  "mac#%"
+
+//
+fun g1uint_succ_uint32 : g1uint_succ_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_pred_uint32 : g1uint_pred_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_half_uint32 : g1uint_half_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_add_uint32 : g1uint_add_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_sub_uint32 : g1uint_sub_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_mul_uint32 : g1uint_mul_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_div_uint32 : g1uint_div_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_mod_uint32 : g1uint_mod_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_lt_uint32 : g1uint_lt_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_lte_uint32 : g1uint_lte_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_gt_uint32 : g1uint_gt_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_gte_uint32 : g1uint_gte_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_eq_uint32 : g1uint_eq_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_neq_uint32 : g1uint_neq_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_compare_uint32 : g1uint_compare_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_max_uint32 : g1uint_max_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_min_uint32 : g1uint_min_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_isgtz_uint32 : g1uint_isgtz_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_iseqz_uint32 : g1uint_iseqz_type(uint32knd) =
+  "mac#%"
+
+fun g1uint_isneqz_uint32 : g1uint_isneqz_type(uint32knd) =
+  "mac#%"
+
+//
+fun g1uint_succ_uint64 : g1uint_succ_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_pred_uint64 : g1uint_pred_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_half_uint64 : g1uint_half_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_add_uint64 : g1uint_add_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_sub_uint64 : g1uint_sub_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_mul_uint64 : g1uint_mul_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_div_uint64 : g1uint_div_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_mod_uint64 : g1uint_mod_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_lt_uint64 : g1uint_lt_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_lte_uint64 : g1uint_lte_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_gt_uint64 : g1uint_gt_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_gte_uint64 : g1uint_gte_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_eq_uint64 : g1uint_eq_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_neq_uint64 : g1uint_neq_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_compare_uint64 : g1uint_compare_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_max_uint64 : g1uint_max_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_min_uint64 : g1uint_min_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_isgtz_uint64 : g1uint_isgtz_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_iseqz_uint64 : g1uint_iseqz_type(uint64knd) =
+  "mac#%"
+
+fun g1uint_isneqz_uint64 : g1uint_isneqz_type(uint64knd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+(* end of [integer_fixed.sats] *)
diff --git a/test/data/stdlib/integer_fixed.sats b/test/data/stdlib/integer_fixed.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/integer_fixed.sats
@@ -0,0 +1,566 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: January, 2013 *)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/integer_fixed.atxt
+** Time of generation: Thu Jan 11 11:00:05 2018
+*)
+
+(* ****** ****** *)
+//
+// HX: for unindexed integer types
+//
+(* ****** ****** *)
+
+sortdef tk = tkind
+
+(* ****** ****** *)
+//
+stadef int8knd = int8_kind
+stadef int16knd = int16_kind
+stadef int32knd = int32_kind
+stadef int64knd = int64_kind
+//
+stadef uint8knd = uint8_kind
+stadef uint16knd = uint16_kind
+stadef uint32knd = uint32_kind
+stadef uint64knd = uint64_kind
+//
+(* ****** ****** *)
+//
+fun g0int2int_int8_int (x: int8):<> int = "mac#%"
+fun g0int2int_int16_int (x: int16):<> int = "mac#%"
+fun g0int2int_int32_int (x: int32):<> int = "mac#%"
+fun g0int2int_int64_int (x: int64):<> int = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0int_neg_int8 (x: int8):<> int8 = "mac#%"
+fun g0int_abs_int8 (x: int8):<> int8 = "mac#%"
+fun g0int_succ_int8 (x: int8):<> int8 = "mac#%"
+fun g0int_pred_int8 (x: int8):<> int8 = "mac#%"
+fun g0int_half_int8 (x: int8):<> int8 = "mac#%"
+fun g0int_asl_int8 (x: int8, n: intGte(0)):<> int8 = "mac#%"
+fun g0int_asr_int8 (x: int8, n: intGte(0)):<> int8 = "mac#%"
+fun g0int_add_int8 (x: int8, y: int8):<> int8 = "mac#%"
+fun g0int_sub_int8 (x: int8, y: int8):<> int8 = "mac#%"
+fun g0int_mul_int8 (x: int8, y: int8):<> int8 = "mac#%"
+fun g0int_div_int8 (x: int8, y: int8):<> int8 = "mac#%"
+fun g0int_mod_int8 (x: int8, y: int8):<> int8 = "mac#%"
+fun g0int_lt_int8 (x: int8, y: int8):<> bool = "mac#%"
+fun g0int_lte_int8 (x: int8, y: int8):<> bool = "mac#%"
+fun g0int_gt_int8 (x: int8, y: int8):<> bool = "mac#%"
+fun g0int_gte_int8 (x: int8, y: int8):<> bool = "mac#%"
+fun g0int_eq_int8 (x: int8, y: int8):<> bool = "mac#%"
+fun g0int_neq_int8 (x: int8, y: int8):<> bool = "mac#%"
+fun g0int_compare_int8 (x: int8, y: int8):<> int = "mac#%"
+fun g0int_max_int8 (x: int8, y: int8):<> int8 = "mac#%"
+fun g0int_min_int8 (x: int8, y: int8):<> int8 = "mac#%"
+fun g0int_isltz_int8 (x: int8):<> bool = "mac#%"
+fun g0int_isltez_int8 (x: int8):<> bool = "mac#%"
+fun g0int_isgtz_int8 (x: int8):<> bool = "mac#%"
+fun g0int_isgtez_int8 (x: int8):<> bool = "mac#%"
+fun g0int_iseqz_int8 (x: int8):<> bool = "mac#%"
+fun g0int_isneqz_int8 (x: int8):<> bool = "mac#%"
+//
+fun g0int_neg_int16 (x: int16):<> int16 = "mac#%"
+fun g0int_abs_int16 (x: int16):<> int16 = "mac#%"
+fun g0int_succ_int16 (x: int16):<> int16 = "mac#%"
+fun g0int_pred_int16 (x: int16):<> int16 = "mac#%"
+fun g0int_half_int16 (x: int16):<> int16 = "mac#%"
+fun g0int_asl_int16 (x: int16, n: intGte(0)):<> int16 = "mac#%"
+fun g0int_asr_int16 (x: int16, n: intGte(0)):<> int16 = "mac#%"
+fun g0int_add_int16 (x: int16, y: int16):<> int16 = "mac#%"
+fun g0int_sub_int16 (x: int16, y: int16):<> int16 = "mac#%"
+fun g0int_mul_int16 (x: int16, y: int16):<> int16 = "mac#%"
+fun g0int_div_int16 (x: int16, y: int16):<> int16 = "mac#%"
+fun g0int_mod_int16 (x: int16, y: int16):<> int16 = "mac#%"
+fun g0int_lt_int16 (x: int16, y: int16):<> bool = "mac#%"
+fun g0int_lte_int16 (x: int16, y: int16):<> bool = "mac#%"
+fun g0int_gt_int16 (x: int16, y: int16):<> bool = "mac#%"
+fun g0int_gte_int16 (x: int16, y: int16):<> bool = "mac#%"
+fun g0int_eq_int16 (x: int16, y: int16):<> bool = "mac#%"
+fun g0int_neq_int16 (x: int16, y: int16):<> bool = "mac#%"
+fun g0int_compare_int16 (x: int16, y: int16):<> int = "mac#%"
+fun g0int_max_int16 (x: int16, y: int16):<> int16 = "mac#%"
+fun g0int_min_int16 (x: int16, y: int16):<> int16 = "mac#%"
+fun g0int_isltz_int16 (x: int16):<> bool = "mac#%"
+fun g0int_isltez_int16 (x: int16):<> bool = "mac#%"
+fun g0int_isgtz_int16 (x: int16):<> bool = "mac#%"
+fun g0int_isgtez_int16 (x: int16):<> bool = "mac#%"
+fun g0int_iseqz_int16 (x: int16):<> bool = "mac#%"
+fun g0int_isneqz_int16 (x: int16):<> bool = "mac#%"
+//
+fun g0int_neg_int32 (x: int32):<> int32 = "mac#%"
+fun g0int_abs_int32 (x: int32):<> int32 = "mac#%"
+fun g0int_succ_int32 (x: int32):<> int32 = "mac#%"
+fun g0int_pred_int32 (x: int32):<> int32 = "mac#%"
+fun g0int_half_int32 (x: int32):<> int32 = "mac#%"
+fun g0int_asl_int32 (x: int32, n: intGte(0)):<> int32 = "mac#%"
+fun g0int_asr_int32 (x: int32, n: intGte(0)):<> int32 = "mac#%"
+fun g0int_add_int32 (x: int32, y: int32):<> int32 = "mac#%"
+fun g0int_sub_int32 (x: int32, y: int32):<> int32 = "mac#%"
+fun g0int_mul_int32 (x: int32, y: int32):<> int32 = "mac#%"
+fun g0int_div_int32 (x: int32, y: int32):<> int32 = "mac#%"
+fun g0int_mod_int32 (x: int32, y: int32):<> int32 = "mac#%"
+fun g0int_lt_int32 (x: int32, y: int32):<> bool = "mac#%"
+fun g0int_lte_int32 (x: int32, y: int32):<> bool = "mac#%"
+fun g0int_gt_int32 (x: int32, y: int32):<> bool = "mac#%"
+fun g0int_gte_int32 (x: int32, y: int32):<> bool = "mac#%"
+fun g0int_eq_int32 (x: int32, y: int32):<> bool = "mac#%"
+fun g0int_neq_int32 (x: int32, y: int32):<> bool = "mac#%"
+fun g0int_compare_int32 (x: int32, y: int32):<> int = "mac#%"
+fun g0int_max_int32 (x: int32, y: int32):<> int32 = "mac#%"
+fun g0int_min_int32 (x: int32, y: int32):<> int32 = "mac#%"
+fun g0int_isltz_int32 (x: int32):<> bool = "mac#%"
+fun g0int_isltez_int32 (x: int32):<> bool = "mac#%"
+fun g0int_isgtz_int32 (x: int32):<> bool = "mac#%"
+fun g0int_isgtez_int32 (x: int32):<> bool = "mac#%"
+fun g0int_iseqz_int32 (x: int32):<> bool = "mac#%"
+fun g0int_isneqz_int32 (x: int32):<> bool = "mac#%"
+//
+fun g0int_neg_int64 (x: int64):<> int64 = "mac#%"
+fun g0int_abs_int64 (x: int64):<> int64 = "mac#%"
+fun g0int_succ_int64 (x: int64):<> int64 = "mac#%"
+fun g0int_pred_int64 (x: int64):<> int64 = "mac#%"
+fun g0int_half_int64 (x: int64):<> int64 = "mac#%"
+fun g0int_asl_int64 (x: int64, n: intGte(0)):<> int64 = "mac#%"
+fun g0int_asr_int64 (x: int64, n: intGte(0)):<> int64 = "mac#%"
+fun g0int_add_int64 (x: int64, y: int64):<> int64 = "mac#%"
+fun g0int_sub_int64 (x: int64, y: int64):<> int64 = "mac#%"
+fun g0int_mul_int64 (x: int64, y: int64):<> int64 = "mac#%"
+fun g0int_div_int64 (x: int64, y: int64):<> int64 = "mac#%"
+fun g0int_mod_int64 (x: int64, y: int64):<> int64 = "mac#%"
+fun g0int_lt_int64 (x: int64, y: int64):<> bool = "mac#%"
+fun g0int_lte_int64 (x: int64, y: int64):<> bool = "mac#%"
+fun g0int_gt_int64 (x: int64, y: int64):<> bool = "mac#%"
+fun g0int_gte_int64 (x: int64, y: int64):<> bool = "mac#%"
+fun g0int_eq_int64 (x: int64, y: int64):<> bool = "mac#%"
+fun g0int_neq_int64 (x: int64, y: int64):<> bool = "mac#%"
+fun g0int_compare_int64 (x: int64, y: int64):<> int = "mac#%"
+fun g0int_max_int64 (x: int64, y: int64):<> int64 = "mac#%"
+fun g0int_min_int64 (x: int64, y: int64):<> int64 = "mac#%"
+fun g0int_isltz_int64 (x: int64):<> bool = "mac#%"
+fun g0int_isltez_int64 (x: int64):<> bool = "mac#%"
+fun g0int_isgtz_int64 (x: int64):<> bool = "mac#%"
+fun g0int_isgtez_int64 (x: int64):<> bool = "mac#%"
+fun g0int_iseqz_int64 (x: int64):<> bool = "mac#%"
+fun g0int_isneqz_int64 (x: int64):<> bool = "mac#%"
+//
+(* ****** ****** *)
+
+fun print_int8 (int8): void = "mac#%"
+fun prerr_int8 (int8): void = "mac#%"
+fun fprint_int8 : fprint_type (int8) = "mac#%"
+overload print with print_int8
+overload prerr with prerr_int8
+overload fprint with fprint_int8
+
+fun print_int16 (int16): void = "mac#%"
+fun prerr_int16 (int16): void = "mac#%"
+fun fprint_int16 : fprint_type (int16) = "mac#%"
+overload print with print_int16
+overload prerr with prerr_int16
+overload fprint with fprint_int16
+
+fun print_int32 (int32): void = "mac#%"
+fun prerr_int32 (int32): void = "mac#%"
+fun fprint_int32 : fprint_type (int32) = "mac#%"
+overload print with print_int32
+overload prerr with prerr_int32
+overload fprint with fprint_int32
+
+fun print_int64 (int64): void = "mac#%"
+fun prerr_int64 (int64): void = "mac#%"
+fun fprint_int64 : fprint_type (int64) = "mac#%"
+overload print with print_int64
+overload prerr with prerr_int64
+overload fprint with fprint_int64
+
+
+(* ****** ****** *)
+//
+fun g0int2uint_int8_uint (x: int8):<> uint = "mac#%"
+fun g0int2uint_int16_uint (x: int16):<> uint = "mac#%"
+fun g0int2uint_int32_uint (x: int32):<> uint = "mac#%"
+fun g0int2uint_int64_uint (x: int64):<> uint = "mac#%"
+//
+fun g0uint2int_uint8_int (x: uint8):<> int = "mac#%"
+fun g0uint2int_uint16_int (x: uint16):<> int = "mac#%"
+fun g0uint2int_uint32_int (x: uint32):<> int = "mac#%"
+fun g0uint2int_uint64_int (x: uint64):<> int = "mac#%"
+//
+fun g0uint2uint_uint8_uint (x: uint8):<> uint = "mac#%"
+fun g0uint2uint_uint16_uint (x: uint16):<> uint = "mac#%"
+fun g0uint2uint_uint32_uint (x: uint32):<> uint = "mac#%"
+fun g0uint2uint_uint64_uint (x: uint64):<> uint = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0uint_succ_uint8 (x: uint8):<> uint8 = "mac#%"
+fun g0uint_pred_uint8 (x: uint8):<> uint8 = "mac#%"
+fun g0uint_half_uint8 (x: uint8):<> uint8 = "mac#%"
+fun g0uint_add_uint8 (x: uint8, y: uint8):<> uint8 = "mac#%"
+fun g0uint_sub_uint8 (x: uint8, y: uint8):<> uint8 = "mac#%"
+fun g0uint_mul_uint8 (x: uint8, y: uint8):<> uint8 = "mac#%"
+fun g0uint_div_uint8 (x: uint8, y: uint8):<> uint8 = "mac#%"
+fun g0uint_mod_uint8 (x: uint8, y: uint8):<> uint8 = "mac#%"
+fun g0uint_lsl_uint8 (x: uint8, n: intGte(0)):<> uint8 = "mac#%"
+fun g0uint_lsr_uint8 (x: uint8, n: intGte(0)):<> uint8 = "mac#%"
+fun g0uint_lnot_uint8 (x: uint8):<> uint8 = "mac#%"
+fun g0uint_lor_uint8 (x: uint8, y: uint8):<> uint8 = "mac#%"
+fun g0uint_lxor_uint8 (x: uint8, y: uint8):<> uint8 = "mac#%"
+fun g0uint_land_uint8 (x: uint8, y: uint8):<> uint8 = "mac#%"
+fun g0uint_lt_uint8 (x: uint8, y: uint8):<> bool = "mac#%"
+fun g0uint_lte_uint8 (x: uint8, y: uint8):<> bool = "mac#%"
+fun g0uint_gt_uint8 (x: uint8, y: uint8):<> bool = "mac#%"
+fun g0uint_gte_uint8 (x: uint8, y: uint8):<> bool = "mac#%"
+fun g0uint_eq_uint8 (x: uint8, y: uint8):<> bool = "mac#%"
+fun g0uint_neq_uint8 (x: uint8, y: uint8):<> bool = "mac#%"
+fun g0uint_compare_uint8 (x: uint8, y: uint8):<> int = "mac#%"
+fun g0uint_max_uint8 (x: uint8, y: uint8):<> uint8 = "mac#%"
+fun g0uint_min_uint8 (x: uint8, y: uint8):<> uint8 = "mac#%"
+fun g0uint_isgtz_uint8 (x: uint8):<> bool = "mac#%"
+fun g0uint_iseqz_uint8 (x: uint8):<> bool = "mac#%"
+fun g0uint_isneqz_uint8 (x: uint8):<> bool = "mac#%"
+//
+fun g0uint_succ_uint16 (x: uint16):<> uint16 = "mac#%"
+fun g0uint_pred_uint16 (x: uint16):<> uint16 = "mac#%"
+fun g0uint_half_uint16 (x: uint16):<> uint16 = "mac#%"
+fun g0uint_add_uint16 (x: uint16, y: uint16):<> uint16 = "mac#%"
+fun g0uint_sub_uint16 (x: uint16, y: uint16):<> uint16 = "mac#%"
+fun g0uint_mul_uint16 (x: uint16, y: uint16):<> uint16 = "mac#%"
+fun g0uint_div_uint16 (x: uint16, y: uint16):<> uint16 = "mac#%"
+fun g0uint_mod_uint16 (x: uint16, y: uint16):<> uint16 = "mac#%"
+fun g0uint_lsl_uint16 (x: uint16, n: intGte(0)):<> uint16 = "mac#%"
+fun g0uint_lsr_uint16 (x: uint16, n: intGte(0)):<> uint16 = "mac#%"
+fun g0uint_lnot_uint16 (x: uint16):<> uint16 = "mac#%"
+fun g0uint_lor_uint16 (x: uint16, y: uint16):<> uint16 = "mac#%"
+fun g0uint_lxor_uint16 (x: uint16, y: uint16):<> uint16 = "mac#%"
+fun g0uint_land_uint16 (x: uint16, y: uint16):<> uint16 = "mac#%"
+fun g0uint_lt_uint16 (x: uint16, y: uint16):<> bool = "mac#%"
+fun g0uint_lte_uint16 (x: uint16, y: uint16):<> bool = "mac#%"
+fun g0uint_gt_uint16 (x: uint16, y: uint16):<> bool = "mac#%"
+fun g0uint_gte_uint16 (x: uint16, y: uint16):<> bool = "mac#%"
+fun g0uint_eq_uint16 (x: uint16, y: uint16):<> bool = "mac#%"
+fun g0uint_neq_uint16 (x: uint16, y: uint16):<> bool = "mac#%"
+fun g0uint_compare_uint16 (x: uint16, y: uint16):<> int = "mac#%"
+fun g0uint_max_uint16 (x: uint16, y: uint16):<> uint16 = "mac#%"
+fun g0uint_min_uint16 (x: uint16, y: uint16):<> uint16 = "mac#%"
+fun g0uint_isgtz_uint16 (x: uint16):<> bool = "mac#%"
+fun g0uint_iseqz_uint16 (x: uint16):<> bool = "mac#%"
+fun g0uint_isneqz_uint16 (x: uint16):<> bool = "mac#%"
+//
+fun g0uint_succ_uint32 (x: uint32):<> uint32 = "mac#%"
+fun g0uint_pred_uint32 (x: uint32):<> uint32 = "mac#%"
+fun g0uint_half_uint32 (x: uint32):<> uint32 = "mac#%"
+fun g0uint_add_uint32 (x: uint32, y: uint32):<> uint32 = "mac#%"
+fun g0uint_sub_uint32 (x: uint32, y: uint32):<> uint32 = "mac#%"
+fun g0uint_mul_uint32 (x: uint32, y: uint32):<> uint32 = "mac#%"
+fun g0uint_div_uint32 (x: uint32, y: uint32):<> uint32 = "mac#%"
+fun g0uint_mod_uint32 (x: uint32, y: uint32):<> uint32 = "mac#%"
+fun g0uint_lsl_uint32 (x: uint32, n: intGte(0)):<> uint32 = "mac#%"
+fun g0uint_lsr_uint32 (x: uint32, n: intGte(0)):<> uint32 = "mac#%"
+fun g0uint_lnot_uint32 (x: uint32):<> uint32 = "mac#%"
+fun g0uint_lor_uint32 (x: uint32, y: uint32):<> uint32 = "mac#%"
+fun g0uint_lxor_uint32 (x: uint32, y: uint32):<> uint32 = "mac#%"
+fun g0uint_land_uint32 (x: uint32, y: uint32):<> uint32 = "mac#%"
+fun g0uint_lt_uint32 (x: uint32, y: uint32):<> bool = "mac#%"
+fun g0uint_lte_uint32 (x: uint32, y: uint32):<> bool = "mac#%"
+fun g0uint_gt_uint32 (x: uint32, y: uint32):<> bool = "mac#%"
+fun g0uint_gte_uint32 (x: uint32, y: uint32):<> bool = "mac#%"
+fun g0uint_eq_uint32 (x: uint32, y: uint32):<> bool = "mac#%"
+fun g0uint_neq_uint32 (x: uint32, y: uint32):<> bool = "mac#%"
+fun g0uint_compare_uint32 (x: uint32, y: uint32):<> int = "mac#%"
+fun g0uint_max_uint32 (x: uint32, y: uint32):<> uint32 = "mac#%"
+fun g0uint_min_uint32 (x: uint32, y: uint32):<> uint32 = "mac#%"
+fun g0uint_isgtz_uint32 (x: uint32):<> bool = "mac#%"
+fun g0uint_iseqz_uint32 (x: uint32):<> bool = "mac#%"
+fun g0uint_isneqz_uint32 (x: uint32):<> bool = "mac#%"
+//
+fun g0uint_succ_uint64 (x: uint64):<> uint64 = "mac#%"
+fun g0uint_pred_uint64 (x: uint64):<> uint64 = "mac#%"
+fun g0uint_half_uint64 (x: uint64):<> uint64 = "mac#%"
+fun g0uint_add_uint64 (x: uint64, y: uint64):<> uint64 = "mac#%"
+fun g0uint_sub_uint64 (x: uint64, y: uint64):<> uint64 = "mac#%"
+fun g0uint_mul_uint64 (x: uint64, y: uint64):<> uint64 = "mac#%"
+fun g0uint_div_uint64 (x: uint64, y: uint64):<> uint64 = "mac#%"
+fun g0uint_mod_uint64 (x: uint64, y: uint64):<> uint64 = "mac#%"
+fun g0uint_lsl_uint64 (x: uint64, n: intGte(0)):<> uint64 = "mac#%"
+fun g0uint_lsr_uint64 (x: uint64, n: intGte(0)):<> uint64 = "mac#%"
+fun g0uint_lnot_uint64 (x: uint64):<> uint64 = "mac#%"
+fun g0uint_lor_uint64 (x: uint64, y: uint64):<> uint64 = "mac#%"
+fun g0uint_lxor_uint64 (x: uint64, y: uint64):<> uint64 = "mac#%"
+fun g0uint_land_uint64 (x: uint64, y: uint64):<> uint64 = "mac#%"
+fun g0uint_lt_uint64 (x: uint64, y: uint64):<> bool = "mac#%"
+fun g0uint_lte_uint64 (x: uint64, y: uint64):<> bool = "mac#%"
+fun g0uint_gt_uint64 (x: uint64, y: uint64):<> bool = "mac#%"
+fun g0uint_gte_uint64 (x: uint64, y: uint64):<> bool = "mac#%"
+fun g0uint_eq_uint64 (x: uint64, y: uint64):<> bool = "mac#%"
+fun g0uint_neq_uint64 (x: uint64, y: uint64):<> bool = "mac#%"
+fun g0uint_compare_uint64 (x: uint64, y: uint64):<> int = "mac#%"
+fun g0uint_max_uint64 (x: uint64, y: uint64):<> uint64 = "mac#%"
+fun g0uint_min_uint64 (x: uint64, y: uint64):<> uint64 = "mac#%"
+fun g0uint_isgtz_uint64 (x: uint64):<> bool = "mac#%"
+fun g0uint_iseqz_uint64 (x: uint64):<> bool = "mac#%"
+fun g0uint_isneqz_uint64 (x: uint64):<> bool = "mac#%"
+//
+(* ****** ****** *)
+
+fun print_uint8 (uint8): void = "mac#%"
+fun prerr_uint8 (uint8): void = "mac#%"
+fun fprint_uint8 : fprint_type (uint8) = "mac#%"
+overload print with print_uint8
+overload prerr with prerr_uint8
+overload fprint with fprint_uint8
+
+fun print_uint16 (uint16): void = "mac#%"
+fun prerr_uint16 (uint16): void = "mac#%"
+fun fprint_uint16 : fprint_type (uint16) = "mac#%"
+overload print with print_uint16
+overload prerr with prerr_uint16
+overload fprint with fprint_uint16
+
+fun print_uint32 (uint32): void = "mac#%"
+fun prerr_uint32 (uint32): void = "mac#%"
+fun fprint_uint32 : fprint_type (uint32) = "mac#%"
+overload print with print_uint32
+overload prerr with prerr_uint32
+overload fprint with fprint_uint32
+
+fun print_uint64 (uint64): void = "mac#%"
+fun prerr_uint64 (uint64): void = "mac#%"
+fun fprint_uint64 : fprint_type (uint64) = "mac#%"
+overload print with print_uint64
+overload prerr with prerr_uint64
+overload fprint with fprint_uint64
+
+
+(* ****** ****** *)
+//
+fun g1int_neg_int8 : g1int_neg_type (int8knd) = "mac#%"
+fun g1int_abs_int8 : g1int_abs_type (int8knd) = "mac#%"
+fun g1int_succ_int8 : g1int_succ_type (int8knd) = "mac#%"
+fun g1int_pred_int8 : g1int_pred_type (int8knd) = "mac#%"
+fun g1int_half_int8 : g1int_half_type (int8knd) = "mac#%"
+fun g1int_add_int8 : g1int_add_type (int8knd) = "mac#%"
+fun g1int_sub_int8 : g1int_sub_type (int8knd) = "mac#%"
+fun g1int_mul_int8 : g1int_mul_type (int8knd) = "mac#%"
+fun g1int_div_int8 : g1int_div_type (int8knd) = "mac#%"
+fun g1int_nmod_int8 : g1int_nmod_type (int8knd) = "mac#%"
+fun g1int_lt_int8 : g1int_lt_type (int8knd) = "mac#%"
+fun g1int_lte_int8 : g1int_lte_type (int8knd) = "mac#%"
+fun g1int_gt_int8 : g1int_gt_type (int8knd) = "mac#%"
+fun g1int_gte_int8 : g1int_gte_type (int8knd) = "mac#%"
+fun g1int_eq_int8 : g1int_eq_type (int8knd) = "mac#%"
+fun g1int_neq_int8 : g1int_neq_type (int8knd) = "mac#%"
+fun g1int_compare_int8 : g1int_compare_type (int8knd) = "mac#%"
+fun g1int_max_int8 : g1int_max_type (int8knd) = "mac#%"
+fun g1int_min_int8 : g1int_min_type (int8knd) = "mac#%"
+fun g1int_isltz_int8 : g1int_isltz_type (int8knd) = "mac#%"
+fun g1int_isltez_int8 : g1int_isltez_type (int8knd) = "mac#%"
+fun g1int_isgtz_int8 : g1int_isgtz_type (int8knd) = "mac#%"
+fun g1int_isgtez_int8 : g1int_isgtez_type (int8knd) = "mac#%"
+fun g1int_iseqz_int8 : g1int_iseqz_type (int8knd) = "mac#%"
+fun g1int_isneqz_int8 : g1int_isneqz_type (int8knd) = "mac#%"
+//
+fun g1int_neg_int16 : g1int_neg_type (int16knd) = "mac#%"
+fun g1int_abs_int16 : g1int_abs_type (int16knd) = "mac#%"
+fun g1int_succ_int16 : g1int_succ_type (int16knd) = "mac#%"
+fun g1int_pred_int16 : g1int_pred_type (int16knd) = "mac#%"
+fun g1int_half_int16 : g1int_half_type (int16knd) = "mac#%"
+fun g1int_add_int16 : g1int_add_type (int16knd) = "mac#%"
+fun g1int_sub_int16 : g1int_sub_type (int16knd) = "mac#%"
+fun g1int_mul_int16 : g1int_mul_type (int16knd) = "mac#%"
+fun g1int_div_int16 : g1int_div_type (int16knd) = "mac#%"
+fun g1int_nmod_int16 : g1int_nmod_type (int16knd) = "mac#%"
+fun g1int_lt_int16 : g1int_lt_type (int16knd) = "mac#%"
+fun g1int_lte_int16 : g1int_lte_type (int16knd) = "mac#%"
+fun g1int_gt_int16 : g1int_gt_type (int16knd) = "mac#%"
+fun g1int_gte_int16 : g1int_gte_type (int16knd) = "mac#%"
+fun g1int_eq_int16 : g1int_eq_type (int16knd) = "mac#%"
+fun g1int_neq_int16 : g1int_neq_type (int16knd) = "mac#%"
+fun g1int_compare_int16 : g1int_compare_type (int16knd) = "mac#%"
+fun g1int_max_int16 : g1int_max_type (int16knd) = "mac#%"
+fun g1int_min_int16 : g1int_min_type (int16knd) = "mac#%"
+fun g1int_isltz_int16 : g1int_isltz_type (int16knd) = "mac#%"
+fun g1int_isltez_int16 : g1int_isltez_type (int16knd) = "mac#%"
+fun g1int_isgtz_int16 : g1int_isgtz_type (int16knd) = "mac#%"
+fun g1int_isgtez_int16 : g1int_isgtez_type (int16knd) = "mac#%"
+fun g1int_iseqz_int16 : g1int_iseqz_type (int16knd) = "mac#%"
+fun g1int_isneqz_int16 : g1int_isneqz_type (int16knd) = "mac#%"
+//
+fun g1int_neg_int32 : g1int_neg_type (int32knd) = "mac#%"
+fun g1int_abs_int32 : g1int_abs_type (int32knd) = "mac#%"
+fun g1int_succ_int32 : g1int_succ_type (int32knd) = "mac#%"
+fun g1int_pred_int32 : g1int_pred_type (int32knd) = "mac#%"
+fun g1int_half_int32 : g1int_half_type (int32knd) = "mac#%"
+fun g1int_add_int32 : g1int_add_type (int32knd) = "mac#%"
+fun g1int_sub_int32 : g1int_sub_type (int32knd) = "mac#%"
+fun g1int_mul_int32 : g1int_mul_type (int32knd) = "mac#%"
+fun g1int_div_int32 : g1int_div_type (int32knd) = "mac#%"
+fun g1int_nmod_int32 : g1int_nmod_type (int32knd) = "mac#%"
+fun g1int_lt_int32 : g1int_lt_type (int32knd) = "mac#%"
+fun g1int_lte_int32 : g1int_lte_type (int32knd) = "mac#%"
+fun g1int_gt_int32 : g1int_gt_type (int32knd) = "mac#%"
+fun g1int_gte_int32 : g1int_gte_type (int32knd) = "mac#%"
+fun g1int_eq_int32 : g1int_eq_type (int32knd) = "mac#%"
+fun g1int_neq_int32 : g1int_neq_type (int32knd) = "mac#%"
+fun g1int_compare_int32 : g1int_compare_type (int32knd) = "mac#%"
+fun g1int_max_int32 : g1int_max_type (int32knd) = "mac#%"
+fun g1int_min_int32 : g1int_min_type (int32knd) = "mac#%"
+fun g1int_isltz_int32 : g1int_isltz_type (int32knd) = "mac#%"
+fun g1int_isltez_int32 : g1int_isltez_type (int32knd) = "mac#%"
+fun g1int_isgtz_int32 : g1int_isgtz_type (int32knd) = "mac#%"
+fun g1int_isgtez_int32 : g1int_isgtez_type (int32knd) = "mac#%"
+fun g1int_iseqz_int32 : g1int_iseqz_type (int32knd) = "mac#%"
+fun g1int_isneqz_int32 : g1int_isneqz_type (int32knd) = "mac#%"
+//
+fun g1int_neg_int64 : g1int_neg_type (int64knd) = "mac#%"
+fun g1int_abs_int64 : g1int_abs_type (int64knd) = "mac#%"
+fun g1int_succ_int64 : g1int_succ_type (int64knd) = "mac#%"
+fun g1int_pred_int64 : g1int_pred_type (int64knd) = "mac#%"
+fun g1int_half_int64 : g1int_half_type (int64knd) = "mac#%"
+fun g1int_add_int64 : g1int_add_type (int64knd) = "mac#%"
+fun g1int_sub_int64 : g1int_sub_type (int64knd) = "mac#%"
+fun g1int_mul_int64 : g1int_mul_type (int64knd) = "mac#%"
+fun g1int_div_int64 : g1int_div_type (int64knd) = "mac#%"
+fun g1int_nmod_int64 : g1int_nmod_type (int64knd) = "mac#%"
+fun g1int_lt_int64 : g1int_lt_type (int64knd) = "mac#%"
+fun g1int_lte_int64 : g1int_lte_type (int64knd) = "mac#%"
+fun g1int_gt_int64 : g1int_gt_type (int64knd) = "mac#%"
+fun g1int_gte_int64 : g1int_gte_type (int64knd) = "mac#%"
+fun g1int_eq_int64 : g1int_eq_type (int64knd) = "mac#%"
+fun g1int_neq_int64 : g1int_neq_type (int64knd) = "mac#%"
+fun g1int_compare_int64 : g1int_compare_type (int64knd) = "mac#%"
+fun g1int_max_int64 : g1int_max_type (int64knd) = "mac#%"
+fun g1int_min_int64 : g1int_min_type (int64knd) = "mac#%"
+fun g1int_isltz_int64 : g1int_isltz_type (int64knd) = "mac#%"
+fun g1int_isltez_int64 : g1int_isltez_type (int64knd) = "mac#%"
+fun g1int_isgtz_int64 : g1int_isgtz_type (int64knd) = "mac#%"
+fun g1int_isgtez_int64 : g1int_isgtez_type (int64knd) = "mac#%"
+fun g1int_iseqz_int64 : g1int_iseqz_type (int64knd) = "mac#%"
+fun g1int_isneqz_int64 : g1int_isneqz_type (int64knd) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g1uint_succ_uint8 : g1uint_succ_type (uint8knd) = "mac#%"
+fun g1uint_pred_uint8 : g1uint_pred_type (uint8knd) = "mac#%"
+fun g1uint_half_uint8 : g1uint_half_type (uint8knd) = "mac#%"
+fun g1uint_add_uint8 : g1uint_add_type (uint8knd) = "mac#%"
+fun g1uint_sub_uint8 : g1uint_sub_type (uint8knd) = "mac#%"
+fun g1uint_mul_uint8 : g1uint_mul_type (uint8knd) = "mac#%"
+fun g1uint_div_uint8 : g1uint_div_type (uint8knd) = "mac#%"
+fun g1uint_mod_uint8 : g1uint_mod_type (uint8knd) = "mac#%"
+fun g1uint_lt_uint8 : g1uint_lt_type (uint8knd) = "mac#%"
+fun g1uint_lte_uint8 : g1uint_lte_type (uint8knd) = "mac#%"
+fun g1uint_gt_uint8 : g1uint_gt_type (uint8knd) = "mac#%"
+fun g1uint_gte_uint8 : g1uint_gte_type (uint8knd) = "mac#%"
+fun g1uint_eq_uint8 : g1uint_eq_type (uint8knd) = "mac#%"
+fun g1uint_neq_uint8 : g1uint_neq_type (uint8knd) = "mac#%"
+fun g1uint_compare_uint8 : g1uint_compare_type (uint8knd) = "mac#%"
+fun g1uint_max_uint8 : g1uint_max_type (uint8knd) = "mac#%"
+fun g1uint_min_uint8 : g1uint_min_type (uint8knd) = "mac#%"
+fun g1uint_isgtz_uint8 : g1uint_isgtz_type (uint8knd) = "mac#%"
+fun g1uint_iseqz_uint8 : g1uint_iseqz_type (uint8knd) = "mac#%"
+fun g1uint_isneqz_uint8 : g1uint_isneqz_type (uint8knd) = "mac#%"
+//
+fun g1uint_succ_uint16 : g1uint_succ_type (uint16knd) = "mac#%"
+fun g1uint_pred_uint16 : g1uint_pred_type (uint16knd) = "mac#%"
+fun g1uint_half_uint16 : g1uint_half_type (uint16knd) = "mac#%"
+fun g1uint_add_uint16 : g1uint_add_type (uint16knd) = "mac#%"
+fun g1uint_sub_uint16 : g1uint_sub_type (uint16knd) = "mac#%"
+fun g1uint_mul_uint16 : g1uint_mul_type (uint16knd) = "mac#%"
+fun g1uint_div_uint16 : g1uint_div_type (uint16knd) = "mac#%"
+fun g1uint_mod_uint16 : g1uint_mod_type (uint16knd) = "mac#%"
+fun g1uint_lt_uint16 : g1uint_lt_type (uint16knd) = "mac#%"
+fun g1uint_lte_uint16 : g1uint_lte_type (uint16knd) = "mac#%"
+fun g1uint_gt_uint16 : g1uint_gt_type (uint16knd) = "mac#%"
+fun g1uint_gte_uint16 : g1uint_gte_type (uint16knd) = "mac#%"
+fun g1uint_eq_uint16 : g1uint_eq_type (uint16knd) = "mac#%"
+fun g1uint_neq_uint16 : g1uint_neq_type (uint16knd) = "mac#%"
+fun g1uint_compare_uint16 : g1uint_compare_type (uint16knd) = "mac#%"
+fun g1uint_max_uint16 : g1uint_max_type (uint16knd) = "mac#%"
+fun g1uint_min_uint16 : g1uint_min_type (uint16knd) = "mac#%"
+fun g1uint_isgtz_uint16 : g1uint_isgtz_type (uint16knd) = "mac#%"
+fun g1uint_iseqz_uint16 : g1uint_iseqz_type (uint16knd) = "mac#%"
+fun g1uint_isneqz_uint16 : g1uint_isneqz_type (uint16knd) = "mac#%"
+//
+fun g1uint_succ_uint32 : g1uint_succ_type (uint32knd) = "mac#%"
+fun g1uint_pred_uint32 : g1uint_pred_type (uint32knd) = "mac#%"
+fun g1uint_half_uint32 : g1uint_half_type (uint32knd) = "mac#%"
+fun g1uint_add_uint32 : g1uint_add_type (uint32knd) = "mac#%"
+fun g1uint_sub_uint32 : g1uint_sub_type (uint32knd) = "mac#%"
+fun g1uint_mul_uint32 : g1uint_mul_type (uint32knd) = "mac#%"
+fun g1uint_div_uint32 : g1uint_div_type (uint32knd) = "mac#%"
+fun g1uint_mod_uint32 : g1uint_mod_type (uint32knd) = "mac#%"
+fun g1uint_lt_uint32 : g1uint_lt_type (uint32knd) = "mac#%"
+fun g1uint_lte_uint32 : g1uint_lte_type (uint32knd) = "mac#%"
+fun g1uint_gt_uint32 : g1uint_gt_type (uint32knd) = "mac#%"
+fun g1uint_gte_uint32 : g1uint_gte_type (uint32knd) = "mac#%"
+fun g1uint_eq_uint32 : g1uint_eq_type (uint32knd) = "mac#%"
+fun g1uint_neq_uint32 : g1uint_neq_type (uint32knd) = "mac#%"
+fun g1uint_compare_uint32 : g1uint_compare_type (uint32knd) = "mac#%"
+fun g1uint_max_uint32 : g1uint_max_type (uint32knd) = "mac#%"
+fun g1uint_min_uint32 : g1uint_min_type (uint32knd) = "mac#%"
+fun g1uint_isgtz_uint32 : g1uint_isgtz_type (uint32knd) = "mac#%"
+fun g1uint_iseqz_uint32 : g1uint_iseqz_type (uint32knd) = "mac#%"
+fun g1uint_isneqz_uint32 : g1uint_isneqz_type (uint32knd) = "mac#%"
+//
+fun g1uint_succ_uint64 : g1uint_succ_type (uint64knd) = "mac#%"
+fun g1uint_pred_uint64 : g1uint_pred_type (uint64knd) = "mac#%"
+fun g1uint_half_uint64 : g1uint_half_type (uint64knd) = "mac#%"
+fun g1uint_add_uint64 : g1uint_add_type (uint64knd) = "mac#%"
+fun g1uint_sub_uint64 : g1uint_sub_type (uint64knd) = "mac#%"
+fun g1uint_mul_uint64 : g1uint_mul_type (uint64knd) = "mac#%"
+fun g1uint_div_uint64 : g1uint_div_type (uint64knd) = "mac#%"
+fun g1uint_mod_uint64 : g1uint_mod_type (uint64knd) = "mac#%"
+fun g1uint_lt_uint64 : g1uint_lt_type (uint64knd) = "mac#%"
+fun g1uint_lte_uint64 : g1uint_lte_type (uint64knd) = "mac#%"
+fun g1uint_gt_uint64 : g1uint_gt_type (uint64knd) = "mac#%"
+fun g1uint_gte_uint64 : g1uint_gte_type (uint64knd) = "mac#%"
+fun g1uint_eq_uint64 : g1uint_eq_type (uint64knd) = "mac#%"
+fun g1uint_neq_uint64 : g1uint_neq_type (uint64knd) = "mac#%"
+fun g1uint_compare_uint64 : g1uint_compare_type (uint64knd) = "mac#%"
+fun g1uint_max_uint64 : g1uint_max_type (uint64knd) = "mac#%"
+fun g1uint_min_uint64 : g1uint_min_type (uint64knd) = "mac#%"
+fun g1uint_isgtz_uint64 : g1uint_isgtz_type (uint64knd) = "mac#%"
+fun g1uint_iseqz_uint64 : g1uint_iseqz_type (uint64knd) = "mac#%"
+fun g1uint_isneqz_uint64 : g1uint_isneqz_type (uint64knd) = "mac#%"
+//
+(* ****** ****** *)
+
+(* end of [integer_fixed.sats] *)
diff --git a/test/data/stdlib/integer_long.out b/test/data/stdlib/integer_long.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/integer_long.out
@@ -0,0 +1,919 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: January, 2013 *)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/integer_long.atxt
+** Time of generation: Thu Jan 11 11:00:02 2018
+*)
+(* ****** ****** *)
+sortdef tk = tkind
+
+(* ****** ****** *)
+//
+stadef lintknd  = lint_kind
+stadef ulintknd  = ulint_kind
+
+//
+stadef llintknd  = llint_kind
+stadef ullintknd  = ullint_kind
+
+//
+(* ****** ****** *)
+//
+fun g0int2int_int_lint(int) :<> lint =
+  "mac#%"
+
+fun g0uint2int_uint_lint(uint) :<> lint =
+  "mac#%"
+
+//
+fun g0int2uint_int_ulint(int) :<> ulint =
+  "mac#%"
+
+fun g0uint2uint_uint_ulint(uint) :<> ulint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0int2int_lint_int(lint) :<> int =
+  "mac#%"
+
+fun g0int2int_lint_lint(lint) :<> lint =
+  "mac#%"
+
+fun g0int2int_lint_llint(lint) :<> llint =
+  "mac#%"
+
+//
+fun g0int2uint_lint_uint(lint) :<> uint =
+  "mac#%"
+
+fun g0int2uint_lint_ulint(lint) :<> ulint =
+  "mac#%"
+
+fun g0int2uint_lint_ullint(lint) :<> ullint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0uint2int_ulint_int(ulint) :<> int =
+  "mac#%"
+
+fun g0uint2int_ulint_lint(ulint) :<> lint =
+  "mac#%"
+
+fun g0uint2int_ulint_llint(ulint) :<> llint =
+  "mac#%"
+
+//
+fun g0uint2uint_ulint_uint(ulint) :<> uint =
+  "mac#%"
+
+fun g0uint2uint_ulint_ulint(ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint2uint_ulint_ullint(ulint) :<> ullint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0int2int_int_llint(int) :<> llint =
+  "mac#%"
+
+fun g0uint2int_uint_llint(uint) :<> llint =
+  "mac#%"
+
+//
+fun g0int2uint_int_ullint(int) :<> ullint =
+  "mac#%"
+
+fun g0uint2uint_uint_ullint(uint) :<> ullint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0int2int_llint_int(llint) :<> int =
+  "mac#%"
+
+fun g0int2int_llint_lint(llint) :<> lint =
+  "mac#%"
+
+fun g0int2int_llint_llint(llint) :<> llint =
+  "mac#%"
+
+//
+fun g0int2uint_llint_uint(llint) :<> uint =
+  "mac#%"
+
+fun g0int2uint_llint_ulint(llint) :<> ulint =
+  "mac#%"
+
+fun g0int2uint_llint_ullint(llint) :<> ullint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0uint2int_ullint_int(ullint) :<> int =
+  "mac#%"
+
+fun g0uint2int_ullint_lint(ullint) :<> lint =
+  "mac#%"
+
+fun g0uint2int_ullint_llint(ullint) :<> llint =
+  "mac#%"
+
+//
+fun g0uint2uint_ullint_uint(ullint) :<> uint =
+  "mac#%"
+
+fun g0uint2uint_ullint_ulint(ullint) :<> ulint =
+  "mac#%"
+
+fun g0uint2uint_ullint_ullint(ullint) :<> ullint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0int2string_lint(i0 : lint) :<!wrt> Strptr1 =
+  "mac#%"
+
+fun g0int2string_llint(i0 : llint) :<!wrt> Strptr1 =
+  "mac#%"
+
+//
+fun g0uint2string_ulint(u0 : ulint) :<!wrt> Strptr1 =
+  "mac#%"
+
+fun g0uint2string_ullint(u0 : ullint) :<!wrt> Strptr1 =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0string2int_lint(rep : NSH(string)) :<> lint =
+  "mac#%"
+
+fun g0string2int_llint(rep : NSH(string)) :<> llint =
+  "mac#%"
+
+//
+fun g0string2uint_ulint(rep : NSH(string)) :<> ulint =
+  "mac#%"
+
+fun g0string2uint_ullint(rep : NSH(string)) :<> ullint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun print_lint(lint) : void =
+  "mac#%"
+
+fun prerr_lint(lint) : void =
+  "mac#%"
+
+fun fprint_lint : fprint_type(lint) =
+  "mac#%"
+
+overload print with print_lint
+
+overload prerr with prerr_lint
+
+overload fprint with fprint_lint
+
+//
+fun print_ulint(ulint) : void =
+  "mac#%"
+
+fun prerr_ulint(ulint) : void =
+  "mac#%"
+
+fun fprint_ulint : fprint_type(ulint) =
+  "mac#%"
+
+overload print with print_ulint
+
+overload prerr with prerr_ulint
+
+overload fprint with fprint_ulint
+
+//
+fun print_llint(llint) : void =
+  "mac#%"
+
+fun prerr_llint(llint) : void =
+  "mac#%"
+
+fun fprint_llint : fprint_type(llint) =
+  "mac#%"
+
+overload print with print_llint
+
+overload prerr with prerr_llint
+
+overload fprint with fprint_llint
+
+//
+fun print_ullint(ullint) : void =
+  "mac#%"
+
+fun prerr_ullint(ullint) : void =
+  "mac#%"
+
+fun fprint_ullint : fprint_type(ullint) =
+  "mac#%"
+
+overload print with print_ullint
+
+overload prerr with prerr_ullint
+
+overload fprint with fprint_ullint
+
+//
+(* ****** ****** *)
+//
+fun g0int_neg_lint(x : lint) :<> lint =
+  "mac#%"
+
+fun g0int_abs_lint(x : lint) :<> lint =
+  "mac#%"
+
+fun g0int_succ_lint(x : lint) :<> lint =
+  "mac#%"
+
+fun g0int_pred_lint(x : lint) :<> lint =
+  "mac#%"
+
+fun g0int_half_lint(x : lint) :<> lint =
+  "mac#%"
+
+fun g0int_asl_lint(x : lint, n : intGte(0)) :<> lint =
+  "mac#%"
+
+fun g0int_asr_lint(x : lint, n : intGte(0)) :<> lint =
+  "mac#%"
+
+fun g0int_add_lint(x : lint, y : lint) :<> lint =
+  "mac#%"
+
+fun g0int_sub_lint(x : lint, y : lint) :<> lint =
+  "mac#%"
+
+fun g0int_mul_lint(x : lint, y : lint) :<> lint =
+  "mac#%"
+
+fun g0int_div_lint(x : lint, y : lint) :<> lint =
+  "mac#%"
+
+fun g0int_mod_lint(x : lint, y : lint) :<> lint =
+  "mac#%"
+
+fun g0int_lt_lint(x : lint, y : lint) :<> bool =
+  "mac#%"
+
+fun g0int_lte_lint(x : lint, y : lint) :<> bool =
+  "mac#%"
+
+fun g0int_gt_lint(x : lint, y : lint) :<> bool =
+  "mac#%"
+
+fun g0int_gte_lint(x : lint, y : lint) :<> bool =
+  "mac#%"
+
+fun g0int_eq_lint(x : lint, y : lint) :<> bool =
+  "mac#%"
+
+fun g0int_neq_lint(x : lint, y : lint) :<> bool =
+  "mac#%"
+
+fun g0int_compare_lint(x : lint, y : lint) :<> int =
+  "mac#%"
+
+fun g0int_max_lint(x : lint, y : lint) :<> lint =
+  "mac#%"
+
+fun g0int_min_lint(x : lint, y : lint) :<> lint =
+  "mac#%"
+
+fun g0int_isltz_lint(x : lint) :<> bool =
+  "mac#%"
+
+fun g0int_isltez_lint(x : lint) :<> bool =
+  "mac#%"
+
+fun g0int_isgtz_lint(x : lint) :<> bool =
+  "mac#%"
+
+fun g0int_isgtez_lint(x : lint) :<> bool =
+  "mac#%"
+
+fun g0int_iseqz_lint(x : lint) :<> bool =
+  "mac#%"
+
+fun g0int_isneqz_lint(x : lint) :<> bool =
+  "mac#%"
+
+//
+fun g0uint_succ_ulint(x : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_pred_ulint(x : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_half_ulint(x : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_add_ulint(x : ulint, y : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_sub_ulint(x : ulint, y : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_mul_ulint(x : ulint, y : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_div_ulint(x : ulint, y : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_mod_ulint(x : ulint, y : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_lsl_ulint(x : ulint, n : intGte(0)) :<> ulint =
+  "mac#%"
+
+fun g0uint_lsr_ulint(x : ulint, n : intGte(0)) :<> ulint =
+  "mac#%"
+
+fun g0uint_lnot_ulint(x : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_lor_ulint(x : ulint, y : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_lxor_ulint(x : ulint, y : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_land_ulint(x : ulint, y : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_lt_ulint(x : ulint, y : ulint) :<> bool =
+  "mac#%"
+
+fun g0uint_lte_ulint(x : ulint, y : ulint) :<> bool =
+  "mac#%"
+
+fun g0uint_gt_ulint(x : ulint, y : ulint) :<> bool =
+  "mac#%"
+
+fun g0uint_gte_ulint(x : ulint, y : ulint) :<> bool =
+  "mac#%"
+
+fun g0uint_eq_ulint(x : ulint, y : ulint) :<> bool =
+  "mac#%"
+
+fun g0uint_neq_ulint(x : ulint, y : ulint) :<> bool =
+  "mac#%"
+
+fun g0uint_compare_ulint(x : ulint, y : ulint) :<> int =
+  "mac#%"
+
+fun g0uint_max_ulint(x : ulint, y : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_min_ulint(x : ulint, y : ulint) :<> ulint =
+  "mac#%"
+
+fun g0uint_isgtz_ulint(x : ulint) :<> bool =
+  "mac#%"
+
+fun g0uint_iseqz_ulint(x : ulint) :<> bool =
+  "mac#%"
+
+fun g0uint_isneqz_ulint(x : ulint) :<> bool =
+  "mac#%"
+
+//
+fun g0int_neg_llint(x : llint) :<> llint =
+  "mac#%"
+
+fun g0int_abs_llint(x : llint) :<> llint =
+  "mac#%"
+
+fun g0int_succ_llint(x : llint) :<> llint =
+  "mac#%"
+
+fun g0int_pred_llint(x : llint) :<> llint =
+  "mac#%"
+
+fun g0int_half_llint(x : llint) :<> llint =
+  "mac#%"
+
+fun g0int_asl_llint(x : llint, n : intGte(0)) :<> llint =
+  "mac#%"
+
+fun g0int_asr_llint(x : llint, n : intGte(0)) :<> llint =
+  "mac#%"
+
+fun g0int_add_llint(x : llint, y : llint) :<> llint =
+  "mac#%"
+
+fun g0int_sub_llint(x : llint, y : llint) :<> llint =
+  "mac#%"
+
+fun g0int_mul_llint(x : llint, y : llint) :<> llint =
+  "mac#%"
+
+fun g0int_div_llint(x : llint, y : llint) :<> llint =
+  "mac#%"
+
+fun g0int_mod_llint(x : llint, y : llint) :<> llint =
+  "mac#%"
+
+fun g0int_lt_llint(x : llint, y : llint) :<> bool =
+  "mac#%"
+
+fun g0int_lte_llint(x : llint, y : llint) :<> bool =
+  "mac#%"
+
+fun g0int_gt_llint(x : llint, y : llint) :<> bool =
+  "mac#%"
+
+fun g0int_gte_llint(x : llint, y : llint) :<> bool =
+  "mac#%"
+
+fun g0int_eq_llint(x : llint, y : llint) :<> bool =
+  "mac#%"
+
+fun g0int_neq_llint(x : llint, y : llint) :<> bool =
+  "mac#%"
+
+fun g0int_compare_llint(x : llint, y : llint) :<> int =
+  "mac#%"
+
+fun g0int_max_llint(x : llint, y : llint) :<> llint =
+  "mac#%"
+
+fun g0int_min_llint(x : llint, y : llint) :<> llint =
+  "mac#%"
+
+fun g0int_isltz_llint(x : llint) :<> bool =
+  "mac#%"
+
+fun g0int_isltez_llint(x : llint) :<> bool =
+  "mac#%"
+
+fun g0int_isgtz_llint(x : llint) :<> bool =
+  "mac#%"
+
+fun g0int_isgtez_llint(x : llint) :<> bool =
+  "mac#%"
+
+fun g0int_iseqz_llint(x : llint) :<> bool =
+  "mac#%"
+
+fun g0int_isneqz_llint(x : llint) :<> bool =
+  "mac#%"
+
+//
+fun g0uint_succ_ullint(x : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_pred_ullint(x : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_half_ullint(x : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_add_ullint(x : ullint, y : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_sub_ullint(x : ullint, y : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_mul_ullint(x : ullint, y : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_div_ullint(x : ullint, y : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_mod_ullint(x : ullint, y : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_lsl_ullint(x : ullint, n : intGte(0)) :<> ullint =
+  "mac#%"
+
+fun g0uint_lsr_ullint(x : ullint, n : intGte(0)) :<> ullint =
+  "mac#%"
+
+fun g0uint_lnot_ullint(x : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_lor_ullint(x : ullint, y : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_lxor_ullint(x : ullint, y : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_land_ullint(x : ullint, y : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_lt_ullint(x : ullint, y : ullint) :<> bool =
+  "mac#%"
+
+fun g0uint_lte_ullint(x : ullint, y : ullint) :<> bool =
+  "mac#%"
+
+fun g0uint_gt_ullint(x : ullint, y : ullint) :<> bool =
+  "mac#%"
+
+fun g0uint_gte_ullint(x : ullint, y : ullint) :<> bool =
+  "mac#%"
+
+fun g0uint_eq_ullint(x : ullint, y : ullint) :<> bool =
+  "mac#%"
+
+fun g0uint_neq_ullint(x : ullint, y : ullint) :<> bool =
+  "mac#%"
+
+fun g0uint_compare_ullint(x : ullint, y : ullint) :<> int =
+  "mac#%"
+
+fun g0uint_max_ullint(x : ullint, y : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_min_ullint(x : ullint, y : ullint) :<> ullint =
+  "mac#%"
+
+fun g0uint_isgtz_ullint(x : ullint) :<> bool =
+  "mac#%"
+
+fun g0uint_iseqz_ullint(x : ullint) :<> bool =
+  "mac#%"
+
+fun g0uint_isneqz_ullint(x : ullint) :<> bool =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1int_neg_lint : g1int_neg_type(lintknd) =
+  "mac#%"
+
+fun g1int_abs_lint : g1int_abs_type(lintknd) =
+  "mac#%"
+
+fun g1int_succ_lint : g1int_succ_type(lintknd) =
+  "mac#%"
+
+fun g1int_pred_lint : g1int_pred_type(lintknd) =
+  "mac#%"
+
+fun g1int_half_lint : g1int_half_type(lintknd) =
+  "mac#%"
+
+fun g1int_add_lint : g1int_add_type(lintknd) =
+  "mac#%"
+
+fun g1int_sub_lint : g1int_sub_type(lintknd) =
+  "mac#%"
+
+fun g1int_mul_lint : g1int_mul_type(lintknd) =
+  "mac#%"
+
+fun g1int_div_lint : g1int_div_type(lintknd) =
+  "mac#%"
+
+fun g1int_nmod_lint : g1int_nmod_type(lintknd) =
+  "mac#%"
+
+fun g1int_lt_lint : g1int_lt_type(lintknd) =
+  "mac#%"
+
+fun g1int_lte_lint : g1int_lte_type(lintknd) =
+  "mac#%"
+
+fun g1int_gt_lint : g1int_gt_type(lintknd) =
+  "mac#%"
+
+fun g1int_gte_lint : g1int_gte_type(lintknd) =
+  "mac#%"
+
+fun g1int_eq_lint : g1int_eq_type(lintknd) =
+  "mac#%"
+
+fun g1int_neq_lint : g1int_neq_type(lintknd) =
+  "mac#%"
+
+fun g1int_compare_lint : g1int_compare_type(lintknd) =
+  "mac#%"
+
+fun g1int_max_lint : g1int_max_type(lintknd) =
+  "mac#%"
+
+fun g1int_min_lint : g1int_min_type(lintknd) =
+  "mac#%"
+
+fun g1int_isltz_lint : g1int_isltz_type(lintknd) =
+  "mac#%"
+
+fun g1int_isltez_lint : g1int_isltez_type(lintknd) =
+  "mac#%"
+
+fun g1int_isgtz_lint : g1int_isgtz_type(lintknd) =
+  "mac#%"
+
+fun g1int_isgtez_lint : g1int_isgtez_type(lintknd) =
+  "mac#%"
+
+fun g1int_iseqz_lint : g1int_iseqz_type(lintknd) =
+  "mac#%"
+
+fun g1int_isneqz_lint : g1int_isneqz_type(lintknd) =
+  "mac#%"
+
+//
+fun g1uint_succ_ulint : g1uint_succ_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_pred_ulint : g1uint_pred_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_half_ulint : g1uint_half_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_add_ulint : g1uint_add_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_sub_ulint : g1uint_sub_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_mul_ulint : g1uint_mul_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_div_ulint : g1uint_div_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_mod_ulint : g1uint_mod_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_lt_ulint : g1uint_lt_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_lte_ulint : g1uint_lte_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_gt_ulint : g1uint_gt_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_gte_ulint : g1uint_gte_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_eq_ulint : g1uint_eq_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_neq_ulint : g1uint_neq_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_compare_ulint : g1uint_compare_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_max_ulint : g1uint_max_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_min_ulint : g1uint_min_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_isgtz_ulint : g1uint_isgtz_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_iseqz_ulint : g1uint_iseqz_type(ulintknd) =
+  "mac#%"
+
+fun g1uint_isneqz_ulint : g1uint_isneqz_type(ulintknd) =
+  "mac#%"
+
+//
+fun g1int_neg_llint : g1int_neg_type(llintknd) =
+  "mac#%"
+
+fun g1int_abs_llint : g1int_abs_type(llintknd) =
+  "mac#%"
+
+fun g1int_succ_llint : g1int_succ_type(llintknd) =
+  "mac#%"
+
+fun g1int_pred_llint : g1int_pred_type(llintknd) =
+  "mac#%"
+
+fun g1int_half_llint : g1int_half_type(llintknd) =
+  "mac#%"
+
+fun g1int_add_llint : g1int_add_type(llintknd) =
+  "mac#%"
+
+fun g1int_sub_llint : g1int_sub_type(llintknd) =
+  "mac#%"
+
+fun g1int_mul_llint : g1int_mul_type(llintknd) =
+  "mac#%"
+
+fun g1int_div_llint : g1int_div_type(llintknd) =
+  "mac#%"
+
+fun g1int_nmod_llint : g1int_nmod_type(llintknd) =
+  "mac#%"
+
+fun g1int_lt_llint : g1int_lt_type(llintknd) =
+  "mac#%"
+
+fun g1int_lte_llint : g1int_lte_type(llintknd) =
+  "mac#%"
+
+fun g1int_gt_llint : g1int_gt_type(llintknd) =
+  "mac#%"
+
+fun g1int_gte_llint : g1int_gte_type(llintknd) =
+  "mac#%"
+
+fun g1int_eq_llint : g1int_eq_type(llintknd) =
+  "mac#%"
+
+fun g1int_neq_llint : g1int_neq_type(llintknd) =
+  "mac#%"
+
+fun g1int_compare_llint : g1int_compare_type(llintknd) =
+  "mac#%"
+
+fun g1int_max_llint : g1int_max_type(llintknd) =
+  "mac#%"
+
+fun g1int_min_llint : g1int_min_type(llintknd) =
+  "mac#%"
+
+fun g1int_isltz_llint : g1int_isltz_type(llintknd) =
+  "mac#%"
+
+fun g1int_isltez_llint : g1int_isltez_type(llintknd) =
+  "mac#%"
+
+fun g1int_isgtz_llint : g1int_isgtz_type(llintknd) =
+  "mac#%"
+
+fun g1int_isgtez_llint : g1int_isgtez_type(llintknd) =
+  "mac#%"
+
+fun g1int_iseqz_llint : g1int_iseqz_type(llintknd) =
+  "mac#%"
+
+fun g1int_isneqz_llint : g1int_isneqz_type(llintknd) =
+  "mac#%"
+
+//
+fun g1uint_succ_ullint : g1uint_succ_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_pred_ullint : g1uint_pred_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_half_ullint : g1uint_half_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_add_ullint : g1uint_add_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_sub_ullint : g1uint_sub_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_mul_ullint : g1uint_mul_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_div_ullint : g1uint_div_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_mod_ullint : g1uint_mod_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_lt_ullint : g1uint_lt_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_lte_ullint : g1uint_lte_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_gt_ullint : g1uint_gt_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_gte_ullint : g1uint_gte_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_eq_ullint : g1uint_eq_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_neq_ullint : g1uint_neq_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_compare_ullint : g1uint_compare_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_max_ullint : g1uint_max_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_min_ullint : g1uint_min_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_isgtz_ullint : g1uint_isgtz_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_iseqz_ullint : g1uint_iseqz_type(ullintknd) =
+  "mac#%"
+
+fun g1uint_isneqz_ullint : g1uint_isneqz_type(ullintknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1int2int_int_lint : g1int2int_type(intknd, lintknd) =
+  "mac#%"
+
+fun g1int2int_int_llint : g1int2int_type(intknd, llintknd) =
+  "mac#%"
+
+//
+fun g1int2int_lint_lint : g1int2int_type(lintknd, lintknd) =
+  "mac#%"
+
+fun g1int2int_lint_llint : g1int2int_type(lintknd, llintknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1int2uint_int_ulint : g1int2uint_type(intknd, ulintknd) =
+  "mac#%"
+
+fun g1int2uint_int_ullint : g1int2uint_type(intknd, ullintknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1uint2int_uint_lint : g1uint2int_type(uintknd, lintknd) =
+  "mac#%"
+
+fun g1uint2int_uint_llint : g1uint2int_type(uintknd, llintknd) =
+  "mac#%"
+
+//
+fun g1uint2uint_uint_ulint : g1uint2uint_type(uintknd, ulintknd) =
+  "mac#%"
+
+fun g1uint2uint_uint_ullint : g1uint2uint_type(uintknd, ullintknd) =
+  "mac#%"
+
+//
+fun g1uint2uint_ulint_uint : g1uint2uint_type(uintknd, uintknd) =
+  "mac#%"
+
+fun g1uint2uint_ulint_ulint : g1uint2uint_type(uintknd, ulintknd) =
+  "mac#%"
+
+fun g1uint2uint_ulint_ullint : g1uint2uint_type(uintknd, ullintknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+(* end of [integer_long.sats] *)
diff --git a/test/data/stdlib/integer_long.sats b/test/data/stdlib/integer_long.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/integer_long.sats
@@ -0,0 +1,425 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: January, 2013 *)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/integer_long.atxt
+** Time of generation: Thu Jan 11 11:00:02 2018
+*)
+
+(* ****** ****** *)
+
+sortdef tk = tkind
+
+(* ****** ****** *)
+//
+stadef lintknd = lint_kind
+stadef ulintknd = ulint_kind
+//
+stadef llintknd = llint_kind
+stadef ullintknd = ullint_kind
+//
+(* ****** ****** *)
+//
+fun g0int2int_int_lint(int):<> lint = "mac#%"
+fun g0uint2int_uint_lint(uint):<> lint = "mac#%"
+//
+fun g0int2uint_int_ulint(int):<> ulint = "mac#%"
+fun g0uint2uint_uint_ulint(uint):<> ulint = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0int2int_lint_int(lint):<> int = "mac#%"
+fun g0int2int_lint_lint(lint):<> lint = "mac#%"
+fun g0int2int_lint_llint(lint):<> llint = "mac#%"
+//
+fun g0int2uint_lint_uint(lint):<> uint = "mac#%"
+fun g0int2uint_lint_ulint(lint):<> ulint = "mac#%"
+fun g0int2uint_lint_ullint(lint):<> ullint = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0uint2int_ulint_int(ulint):<> int = "mac#%"
+fun g0uint2int_ulint_lint(ulint):<> lint = "mac#%"
+fun g0uint2int_ulint_llint(ulint):<> llint = "mac#%"
+//
+fun g0uint2uint_ulint_uint(ulint):<> uint = "mac#%"
+fun g0uint2uint_ulint_ulint(ulint):<> ulint = "mac#%"
+fun g0uint2uint_ulint_ullint(ulint):<> ullint = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0int2int_int_llint(int):<> llint = "mac#%"
+fun g0uint2int_uint_llint(uint):<> llint = "mac#%"
+//
+fun g0int2uint_int_ullint(int):<> ullint = "mac#%"
+fun g0uint2uint_uint_ullint(uint):<> ullint = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0int2int_llint_int(llint):<> int = "mac#%"
+fun g0int2int_llint_lint(llint):<> lint = "mac#%"
+fun g0int2int_llint_llint(llint):<> llint = "mac#%"
+//
+fun g0int2uint_llint_uint(llint):<> uint = "mac#%"
+fun g0int2uint_llint_ulint(llint):<> ulint = "mac#%"
+fun g0int2uint_llint_ullint(llint):<> ullint = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0uint2int_ullint_int(ullint):<> int = "mac#%"
+fun g0uint2int_ullint_lint(ullint):<> lint = "mac#%"
+fun g0uint2int_ullint_llint(ullint):<> llint = "mac#%"
+//
+fun g0uint2uint_ullint_uint(ullint):<> uint = "mac#%"
+fun g0uint2uint_ullint_ulint(ullint):<> ulint = "mac#%"
+fun g0uint2uint_ullint_ullint(ullint):<> ullint = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+g0int2string_lint(i0: lint):<!wrt> Strptr1 = "mac#%"
+fun
+g0int2string_llint(i0: llint):<!wrt> Strptr1 = "mac#%"
+//
+fun
+g0uint2string_ulint(u0: ulint):<!wrt> Strptr1 = "mac#%"
+fun
+g0uint2string_ullint(u0: ullint):<!wrt> Strptr1 = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+g0string2int_lint(rep: NSH(string)):<> lint = "mac#%"
+fun
+g0string2int_llint(rep: NSH(string)):<> llint = "mac#%"
+//
+fun
+g0string2uint_ulint(rep: NSH(string)):<> ulint = "mac#%"
+fun
+g0string2uint_ullint(rep: NSH(string)):<> ullint = "mac#%"
+//
+(* ****** ****** *)
+//
+fun print_lint (lint): void = "mac#%"
+fun prerr_lint (lint): void = "mac#%"
+fun fprint_lint : fprint_type (lint) = "mac#%"
+overload print with print_lint
+overload prerr with prerr_lint
+overload fprint with fprint_lint
+//
+fun print_ulint (ulint): void = "mac#%"
+fun prerr_ulint (ulint): void = "mac#%"
+fun fprint_ulint : fprint_type (ulint) = "mac#%"
+overload print with print_ulint
+overload prerr with prerr_ulint
+overload fprint with fprint_ulint
+//
+fun print_llint (llint): void = "mac#%"
+fun prerr_llint (llint): void = "mac#%"
+fun fprint_llint : fprint_type (llint) = "mac#%"
+overload print with print_llint
+overload prerr with prerr_llint
+overload fprint with fprint_llint
+//
+fun print_ullint (ullint): void = "mac#%"
+fun prerr_ullint (ullint): void = "mac#%"
+fun fprint_ullint : fprint_type (ullint) = "mac#%"
+overload print with print_ullint
+overload prerr with prerr_ullint
+overload fprint with fprint_ullint
+//
+(* ****** ****** *)
+//
+fun g0int_neg_lint (x: lint):<> lint = "mac#%"
+fun g0int_abs_lint (x: lint):<> lint = "mac#%"
+fun g0int_succ_lint (x: lint):<> lint = "mac#%"
+fun g0int_pred_lint (x: lint):<> lint = "mac#%"
+fun g0int_half_lint (x: lint):<> lint = "mac#%"
+fun g0int_asl_lint (x: lint, n: intGte(0)):<> lint = "mac#%"
+fun g0int_asr_lint (x: lint, n: intGte(0)):<> lint = "mac#%"
+fun g0int_add_lint (x: lint, y: lint):<> lint = "mac#%"
+fun g0int_sub_lint (x: lint, y: lint):<> lint = "mac#%"
+fun g0int_mul_lint (x: lint, y: lint):<> lint = "mac#%"
+fun g0int_div_lint (x: lint, y: lint):<> lint = "mac#%"
+fun g0int_mod_lint (x: lint, y: lint):<> lint = "mac#%"
+fun g0int_lt_lint (x: lint, y: lint):<> bool = "mac#%"
+fun g0int_lte_lint (x: lint, y: lint):<> bool = "mac#%"
+fun g0int_gt_lint (x: lint, y: lint):<> bool = "mac#%"
+fun g0int_gte_lint (x: lint, y: lint):<> bool = "mac#%"
+fun g0int_eq_lint (x: lint, y: lint):<> bool = "mac#%"
+fun g0int_neq_lint (x: lint, y: lint):<> bool = "mac#%"
+fun g0int_compare_lint (x: lint, y: lint):<> int = "mac#%"
+fun g0int_max_lint (x: lint, y: lint):<> lint = "mac#%"
+fun g0int_min_lint (x: lint, y: lint):<> lint = "mac#%"
+fun g0int_isltz_lint (x: lint):<> bool = "mac#%"
+fun g0int_isltez_lint (x: lint):<> bool = "mac#%"
+fun g0int_isgtz_lint (x: lint):<> bool = "mac#%"
+fun g0int_isgtez_lint (x: lint):<> bool = "mac#%"
+fun g0int_iseqz_lint (x: lint):<> bool = "mac#%"
+fun g0int_isneqz_lint (x: lint):<> bool = "mac#%"
+//
+fun g0uint_succ_ulint (x: ulint):<> ulint = "mac#%"
+fun g0uint_pred_ulint (x: ulint):<> ulint = "mac#%"
+fun g0uint_half_ulint (x: ulint):<> ulint = "mac#%"
+fun g0uint_add_ulint (x: ulint, y: ulint):<> ulint = "mac#%"
+fun g0uint_sub_ulint (x: ulint, y: ulint):<> ulint = "mac#%"
+fun g0uint_mul_ulint (x: ulint, y: ulint):<> ulint = "mac#%"
+fun g0uint_div_ulint (x: ulint, y: ulint):<> ulint = "mac#%"
+fun g0uint_mod_ulint (x: ulint, y: ulint):<> ulint = "mac#%"
+fun g0uint_lsl_ulint (x: ulint, n: intGte(0)):<> ulint = "mac#%"
+fun g0uint_lsr_ulint (x: ulint, n: intGte(0)):<> ulint = "mac#%"
+fun g0uint_lnot_ulint (x: ulint):<> ulint = "mac#%"
+fun g0uint_lor_ulint (x: ulint, y: ulint):<> ulint = "mac#%"
+fun g0uint_lxor_ulint (x: ulint, y: ulint):<> ulint = "mac#%"
+fun g0uint_land_ulint (x: ulint, y: ulint):<> ulint = "mac#%"
+fun g0uint_lt_ulint (x: ulint, y: ulint):<> bool = "mac#%"
+fun g0uint_lte_ulint (x: ulint, y: ulint):<> bool = "mac#%"
+fun g0uint_gt_ulint (x: ulint, y: ulint):<> bool = "mac#%"
+fun g0uint_gte_ulint (x: ulint, y: ulint):<> bool = "mac#%"
+fun g0uint_eq_ulint (x: ulint, y: ulint):<> bool = "mac#%"
+fun g0uint_neq_ulint (x: ulint, y: ulint):<> bool = "mac#%"
+fun g0uint_compare_ulint (x: ulint, y: ulint):<> int = "mac#%"
+fun g0uint_max_ulint (x: ulint, y: ulint):<> ulint = "mac#%"
+fun g0uint_min_ulint (x: ulint, y: ulint):<> ulint = "mac#%"
+fun g0uint_isgtz_ulint (x: ulint):<> bool = "mac#%"
+fun g0uint_iseqz_ulint (x: ulint):<> bool = "mac#%"
+fun g0uint_isneqz_ulint (x: ulint):<> bool = "mac#%"
+//
+fun g0int_neg_llint (x: llint):<> llint = "mac#%"
+fun g0int_abs_llint (x: llint):<> llint = "mac#%"
+fun g0int_succ_llint (x: llint):<> llint = "mac#%"
+fun g0int_pred_llint (x: llint):<> llint = "mac#%"
+fun g0int_half_llint (x: llint):<> llint = "mac#%"
+fun g0int_asl_llint (x: llint, n: intGte(0)):<> llint = "mac#%"
+fun g0int_asr_llint (x: llint, n: intGte(0)):<> llint = "mac#%"
+fun g0int_add_llint (x: llint, y: llint):<> llint = "mac#%"
+fun g0int_sub_llint (x: llint, y: llint):<> llint = "mac#%"
+fun g0int_mul_llint (x: llint, y: llint):<> llint = "mac#%"
+fun g0int_div_llint (x: llint, y: llint):<> llint = "mac#%"
+fun g0int_mod_llint (x: llint, y: llint):<> llint = "mac#%"
+fun g0int_lt_llint (x: llint, y: llint):<> bool = "mac#%"
+fun g0int_lte_llint (x: llint, y: llint):<> bool = "mac#%"
+fun g0int_gt_llint (x: llint, y: llint):<> bool = "mac#%"
+fun g0int_gte_llint (x: llint, y: llint):<> bool = "mac#%"
+fun g0int_eq_llint (x: llint, y: llint):<> bool = "mac#%"
+fun g0int_neq_llint (x: llint, y: llint):<> bool = "mac#%"
+fun g0int_compare_llint (x: llint, y: llint):<> int = "mac#%"
+fun g0int_max_llint (x: llint, y: llint):<> llint = "mac#%"
+fun g0int_min_llint (x: llint, y: llint):<> llint = "mac#%"
+fun g0int_isltz_llint (x: llint):<> bool = "mac#%"
+fun g0int_isltez_llint (x: llint):<> bool = "mac#%"
+fun g0int_isgtz_llint (x: llint):<> bool = "mac#%"
+fun g0int_isgtez_llint (x: llint):<> bool = "mac#%"
+fun g0int_iseqz_llint (x: llint):<> bool = "mac#%"
+fun g0int_isneqz_llint (x: llint):<> bool = "mac#%"
+//
+fun g0uint_succ_ullint (x: ullint):<> ullint = "mac#%"
+fun g0uint_pred_ullint (x: ullint):<> ullint = "mac#%"
+fun g0uint_half_ullint (x: ullint):<> ullint = "mac#%"
+fun g0uint_add_ullint (x: ullint, y: ullint):<> ullint = "mac#%"
+fun g0uint_sub_ullint (x: ullint, y: ullint):<> ullint = "mac#%"
+fun g0uint_mul_ullint (x: ullint, y: ullint):<> ullint = "mac#%"
+fun g0uint_div_ullint (x: ullint, y: ullint):<> ullint = "mac#%"
+fun g0uint_mod_ullint (x: ullint, y: ullint):<> ullint = "mac#%"
+fun g0uint_lsl_ullint (x: ullint, n: intGte(0)):<> ullint = "mac#%"
+fun g0uint_lsr_ullint (x: ullint, n: intGte(0)):<> ullint = "mac#%"
+fun g0uint_lnot_ullint (x: ullint):<> ullint = "mac#%"
+fun g0uint_lor_ullint (x: ullint, y: ullint):<> ullint = "mac#%"
+fun g0uint_lxor_ullint (x: ullint, y: ullint):<> ullint = "mac#%"
+fun g0uint_land_ullint (x: ullint, y: ullint):<> ullint = "mac#%"
+fun g0uint_lt_ullint (x: ullint, y: ullint):<> bool = "mac#%"
+fun g0uint_lte_ullint (x: ullint, y: ullint):<> bool = "mac#%"
+fun g0uint_gt_ullint (x: ullint, y: ullint):<> bool = "mac#%"
+fun g0uint_gte_ullint (x: ullint, y: ullint):<> bool = "mac#%"
+fun g0uint_eq_ullint (x: ullint, y: ullint):<> bool = "mac#%"
+fun g0uint_neq_ullint (x: ullint, y: ullint):<> bool = "mac#%"
+fun g0uint_compare_ullint (x: ullint, y: ullint):<> int = "mac#%"
+fun g0uint_max_ullint (x: ullint, y: ullint):<> ullint = "mac#%"
+fun g0uint_min_ullint (x: ullint, y: ullint):<> ullint = "mac#%"
+fun g0uint_isgtz_ullint (x: ullint):<> bool = "mac#%"
+fun g0uint_iseqz_ullint (x: ullint):<> bool = "mac#%"
+fun g0uint_isneqz_ullint (x: ullint):<> bool = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g1int_neg_lint : g1int_neg_type (lintknd) = "mac#%"
+fun g1int_abs_lint : g1int_abs_type (lintknd) = "mac#%"
+fun g1int_succ_lint : g1int_succ_type (lintknd) = "mac#%"
+fun g1int_pred_lint : g1int_pred_type (lintknd) = "mac#%"
+fun g1int_half_lint : g1int_half_type (lintknd) = "mac#%"
+fun g1int_add_lint : g1int_add_type (lintknd) = "mac#%"
+fun g1int_sub_lint : g1int_sub_type (lintknd) = "mac#%"
+fun g1int_mul_lint : g1int_mul_type (lintknd) = "mac#%"
+fun g1int_div_lint : g1int_div_type (lintknd) = "mac#%"
+fun g1int_nmod_lint : g1int_nmod_type (lintknd) = "mac#%"
+fun g1int_lt_lint : g1int_lt_type (lintknd) = "mac#%"
+fun g1int_lte_lint : g1int_lte_type (lintknd) = "mac#%"
+fun g1int_gt_lint : g1int_gt_type (lintknd) = "mac#%"
+fun g1int_gte_lint : g1int_gte_type (lintknd) = "mac#%"
+fun g1int_eq_lint : g1int_eq_type (lintknd) = "mac#%"
+fun g1int_neq_lint : g1int_neq_type (lintknd) = "mac#%"
+fun g1int_compare_lint : g1int_compare_type (lintknd) = "mac#%"
+fun g1int_max_lint : g1int_max_type (lintknd) = "mac#%"
+fun g1int_min_lint : g1int_min_type (lintknd) = "mac#%"
+fun g1int_isltz_lint : g1int_isltz_type (lintknd) = "mac#%"
+fun g1int_isltez_lint : g1int_isltez_type (lintknd) = "mac#%"
+fun g1int_isgtz_lint : g1int_isgtz_type (lintknd) = "mac#%"
+fun g1int_isgtez_lint : g1int_isgtez_type (lintknd) = "mac#%"
+fun g1int_iseqz_lint : g1int_iseqz_type (lintknd) = "mac#%"
+fun g1int_isneqz_lint : g1int_isneqz_type (lintknd) = "mac#%"
+//
+fun g1uint_succ_ulint : g1uint_succ_type (ulintknd) = "mac#%"
+fun g1uint_pred_ulint : g1uint_pred_type (ulintknd) = "mac#%"
+fun g1uint_half_ulint : g1uint_half_type (ulintknd) = "mac#%"
+fun g1uint_add_ulint : g1uint_add_type (ulintknd) = "mac#%"
+fun g1uint_sub_ulint : g1uint_sub_type (ulintknd) = "mac#%"
+fun g1uint_mul_ulint : g1uint_mul_type (ulintknd) = "mac#%"
+fun g1uint_div_ulint : g1uint_div_type (ulintknd) = "mac#%"
+fun g1uint_mod_ulint : g1uint_mod_type (ulintknd) = "mac#%"
+fun g1uint_lt_ulint : g1uint_lt_type (ulintknd) = "mac#%"
+fun g1uint_lte_ulint : g1uint_lte_type (ulintknd) = "mac#%"
+fun g1uint_gt_ulint : g1uint_gt_type (ulintknd) = "mac#%"
+fun g1uint_gte_ulint : g1uint_gte_type (ulintknd) = "mac#%"
+fun g1uint_eq_ulint : g1uint_eq_type (ulintknd) = "mac#%"
+fun g1uint_neq_ulint : g1uint_neq_type (ulintknd) = "mac#%"
+fun g1uint_compare_ulint : g1uint_compare_type (ulintknd) = "mac#%"
+fun g1uint_max_ulint : g1uint_max_type (ulintknd) = "mac#%"
+fun g1uint_min_ulint : g1uint_min_type (ulintknd) = "mac#%"
+fun g1uint_isgtz_ulint : g1uint_isgtz_type (ulintknd) = "mac#%"
+fun g1uint_iseqz_ulint : g1uint_iseqz_type (ulintknd) = "mac#%"
+fun g1uint_isneqz_ulint : g1uint_isneqz_type (ulintknd) = "mac#%"
+//
+fun g1int_neg_llint : g1int_neg_type (llintknd) = "mac#%"
+fun g1int_abs_llint : g1int_abs_type (llintknd) = "mac#%"
+fun g1int_succ_llint : g1int_succ_type (llintknd) = "mac#%"
+fun g1int_pred_llint : g1int_pred_type (llintknd) = "mac#%"
+fun g1int_half_llint : g1int_half_type (llintknd) = "mac#%"
+fun g1int_add_llint : g1int_add_type (llintknd) = "mac#%"
+fun g1int_sub_llint : g1int_sub_type (llintknd) = "mac#%"
+fun g1int_mul_llint : g1int_mul_type (llintknd) = "mac#%"
+fun g1int_div_llint : g1int_div_type (llintknd) = "mac#%"
+fun g1int_nmod_llint : g1int_nmod_type (llintknd) = "mac#%"
+fun g1int_lt_llint : g1int_lt_type (llintknd) = "mac#%"
+fun g1int_lte_llint : g1int_lte_type (llintknd) = "mac#%"
+fun g1int_gt_llint : g1int_gt_type (llintknd) = "mac#%"
+fun g1int_gte_llint : g1int_gte_type (llintknd) = "mac#%"
+fun g1int_eq_llint : g1int_eq_type (llintknd) = "mac#%"
+fun g1int_neq_llint : g1int_neq_type (llintknd) = "mac#%"
+fun g1int_compare_llint : g1int_compare_type (llintknd) = "mac#%"
+fun g1int_max_llint : g1int_max_type (llintknd) = "mac#%"
+fun g1int_min_llint : g1int_min_type (llintknd) = "mac#%"
+fun g1int_isltz_llint : g1int_isltz_type (llintknd) = "mac#%"
+fun g1int_isltez_llint : g1int_isltez_type (llintknd) = "mac#%"
+fun g1int_isgtz_llint : g1int_isgtz_type (llintknd) = "mac#%"
+fun g1int_isgtez_llint : g1int_isgtez_type (llintknd) = "mac#%"
+fun g1int_iseqz_llint : g1int_iseqz_type (llintknd) = "mac#%"
+fun g1int_isneqz_llint : g1int_isneqz_type (llintknd) = "mac#%"
+//
+fun g1uint_succ_ullint : g1uint_succ_type (ullintknd) = "mac#%"
+fun g1uint_pred_ullint : g1uint_pred_type (ullintknd) = "mac#%"
+fun g1uint_half_ullint : g1uint_half_type (ullintknd) = "mac#%"
+fun g1uint_add_ullint : g1uint_add_type (ullintknd) = "mac#%"
+fun g1uint_sub_ullint : g1uint_sub_type (ullintknd) = "mac#%"
+fun g1uint_mul_ullint : g1uint_mul_type (ullintknd) = "mac#%"
+fun g1uint_div_ullint : g1uint_div_type (ullintknd) = "mac#%"
+fun g1uint_mod_ullint : g1uint_mod_type (ullintknd) = "mac#%"
+fun g1uint_lt_ullint : g1uint_lt_type (ullintknd) = "mac#%"
+fun g1uint_lte_ullint : g1uint_lte_type (ullintknd) = "mac#%"
+fun g1uint_gt_ullint : g1uint_gt_type (ullintknd) = "mac#%"
+fun g1uint_gte_ullint : g1uint_gte_type (ullintknd) = "mac#%"
+fun g1uint_eq_ullint : g1uint_eq_type (ullintknd) = "mac#%"
+fun g1uint_neq_ullint : g1uint_neq_type (ullintknd) = "mac#%"
+fun g1uint_compare_ullint : g1uint_compare_type (ullintknd) = "mac#%"
+fun g1uint_max_ullint : g1uint_max_type (ullintknd) = "mac#%"
+fun g1uint_min_ullint : g1uint_min_type (ullintknd) = "mac#%"
+fun g1uint_isgtz_ullint : g1uint_isgtz_type (ullintknd) = "mac#%"
+fun g1uint_iseqz_ullint : g1uint_iseqz_type (ullintknd) = "mac#%"
+fun g1uint_isneqz_ullint : g1uint_isneqz_type (ullintknd) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+g1int2int_int_lint:
+g1int2int_type(intknd, lintknd) = "mac#%"
+fun
+g1int2int_int_llint:
+g1int2int_type(intknd, llintknd) = "mac#%"
+//
+fun
+g1int2int_lint_lint:
+g1int2int_type(lintknd, lintknd) = "mac#%"
+fun
+g1int2int_lint_llint:
+g1int2int_type(lintknd, llintknd) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+g1int2uint_int_ulint:
+g1int2uint_type(intknd, ulintknd) = "mac#%"
+fun
+g1int2uint_int_ullint:
+g1int2uint_type(intknd, ullintknd) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+g1uint2int_uint_lint:
+g1uint2int_type(uintknd, lintknd) = "mac#%"
+fun
+g1uint2int_uint_llint:
+g1uint2int_type(uintknd, llintknd) = "mac#%"
+//
+fun
+g1uint2uint_uint_ulint:
+g1uint2uint_type(uintknd, ulintknd) = "mac#%"
+fun
+g1uint2uint_uint_ullint:
+g1uint2uint_type(uintknd, ullintknd) = "mac#%"
+//
+fun
+g1uint2uint_ulint_uint:
+g1uint2uint_type(uintknd, uintknd) = "mac#%"
+fun
+g1uint2uint_ulint_ulint:
+g1uint2uint_type(uintknd, ulintknd) = "mac#%"
+fun
+g1uint2uint_ulint_ullint:
+g1uint2uint_type(uintknd, ullintknd) = "mac#%"
+//
+(* ****** ****** *)
+
+(* end of [integer_long.sats] *)
diff --git a/test/data/stdlib/integer_ptr.out b/test/data/stdlib/integer_ptr.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/integer_ptr.out
@@ -0,0 +1,446 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: January, 2013 *)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/integer_ptr.atxt
+** Time of generation: Thu Jan 11 11:00:04 2018
+*)
+(* ****** ****** *)
+//
+// HX: for unindexed integer types
+//
+(* ****** ****** *)
+sortdef tk = tkind
+
+(* ****** ****** *)
+typedef SHR(a: t@ype) = a
+
+// for commenting purpose
+typedef NSH(a: t@ype) = a
+
+// for commenting purpose
+(* ****** ****** *)
+//
+stadef intptrknd  = intptr_kind
+stadef uintptrknd  = uintptr_kind
+
+//
+(* ****** ****** *)
+//
+fun g0int2int_int_intptr(int) :<> intptr =
+  "mac#%"
+
+fun g1int2int_int_intptr {i:int}(int(i)) :<> intptr(i) =
+  "mac#%"
+
+fun g0int2int_lint_intptr(lint) :<> intptr =
+  "mac#%"
+
+fun g1int2int_lint_intptr {i:int}(lint(i)) :<> intptr(i) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0int2uint_int_uintptr(int) :<> uintptr =
+  "mac#%"
+
+fun g1int2uint_int_uintptr {i:nat}(int(i)) :<> uintptr(i) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0uint2uint_uint_uintptr(uint) :<> uintptr =
+  "mac#%"
+
+fun g1uint2uint_uint_uintptr {u:int}(uint(u)) :<> uintptr(u) =
+  "mac#%"
+
+fun g0uint2uint_ulint_uintptr(ulint) :<> uintptr =
+  "mac#%"
+
+fun g1uint2uint_ulint_uintptr {u:int}(ulint(u)) :<> uintptr(u) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0int_neg_intptr(x : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_abs_intptr(x : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_succ_intptr(x : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_pred_intptr(x : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_half_intptr(x : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_asl_intptr(x : intptr, n : intGte(0)) :<> intptr =
+  "mac#%"
+
+fun g0int_asr_intptr(x : intptr, n : intGte(0)) :<> intptr =
+  "mac#%"
+
+fun g0int_add_intptr(x : intptr, y : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_sub_intptr(x : intptr, y : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_mul_intptr(x : intptr, y : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_div_intptr(x : intptr, y : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_mod_intptr(x : intptr, y : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_lt_intptr(x : intptr, y : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_lte_intptr(x : intptr, y : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_gt_intptr(x : intptr, y : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_gte_intptr(x : intptr, y : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_eq_intptr(x : intptr, y : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_neq_intptr(x : intptr, y : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_compare_intptr(x : intptr, y : intptr) :<> int =
+  "mac#%"
+
+fun g0int_max_intptr(x : intptr, y : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_min_intptr(x : intptr, y : intptr) :<> intptr =
+  "mac#%"
+
+fun g0int_isltz_intptr(x : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_isltez_intptr(x : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_isgtz_intptr(x : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_isgtez_intptr(x : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_iseqz_intptr(x : intptr) :<> bool =
+  "mac#%"
+
+fun g0int_isneqz_intptr(x : intptr) :<> bool =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun print_intptr(intptr) : void =
+  "mac#%"
+
+fun prerr_intptr(intptr) : void =
+  "mac#%"
+
+fun fprint_intptr : fprint_type(intptr) =
+  "mac#%"
+
+overload print with print_intptr
+
+overload prerr with prerr_intptr
+
+overload fprint with fprint_intptr
+
+//
+(* ****** ****** *)
+//
+fun g0uint_succ_uintptr(x : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_pred_uintptr(x : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_half_uintptr(x : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_add_uintptr(x : uintptr, y : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_sub_uintptr(x : uintptr, y : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_mul_uintptr(x : uintptr, y : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_div_uintptr(x : uintptr, y : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_mod_uintptr(x : uintptr, y : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_lsl_uintptr(x : uintptr, n : intGte(0)) :<> uintptr =
+  "mac#%"
+
+fun g0uint_lsr_uintptr(x : uintptr, n : intGte(0)) :<> uintptr =
+  "mac#%"
+
+fun g0uint_lnot_uintptr(x : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_lor_uintptr(x : uintptr, y : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_lxor_uintptr(x : uintptr, y : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_land_uintptr(x : uintptr, y : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_lt_uintptr(x : uintptr, y : uintptr) :<> bool =
+  "mac#%"
+
+fun g0uint_lte_uintptr(x : uintptr, y : uintptr) :<> bool =
+  "mac#%"
+
+fun g0uint_gt_uintptr(x : uintptr, y : uintptr) :<> bool =
+  "mac#%"
+
+fun g0uint_gte_uintptr(x : uintptr, y : uintptr) :<> bool =
+  "mac#%"
+
+fun g0uint_eq_uintptr(x : uintptr, y : uintptr) :<> bool =
+  "mac#%"
+
+fun g0uint_neq_uintptr(x : uintptr, y : uintptr) :<> bool =
+  "mac#%"
+
+fun g0uint_compare_uintptr(x : uintptr, y : uintptr) :<> int =
+  "mac#%"
+
+fun g0uint_max_uintptr(x : uintptr, y : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_min_uintptr(x : uintptr, y : uintptr) :<> uintptr =
+  "mac#%"
+
+fun g0uint_isgtz_uintptr(x : uintptr) :<> bool =
+  "mac#%"
+
+fun g0uint_iseqz_uintptr(x : uintptr) :<> bool =
+  "mac#%"
+
+fun g0uint_isneqz_uintptr(x : uintptr) :<> bool =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun print_uintptr(uintptr) : void =
+  "mac#%"
+
+fun prerr_uintptr(uintptr) : void =
+  "mac#%"
+
+fun fprint_uintptr : fprint_type(uintptr) =
+  "mac#%"
+
+overload print with print_uintptr
+
+overload prerr with prerr_uintptr
+
+overload fprint with fprint_uintptr
+
+//
+(* ****** ****** *)
+//
+fun g1int_neg_intptr : g1int_neg_type(intptrknd) =
+  "mac#%"
+
+fun g1int_abs_intptr : g1int_abs_type(intptrknd) =
+  "mac#%"
+
+fun g1int_succ_intptr : g1int_succ_type(intptrknd) =
+  "mac#%"
+
+fun g1int_pred_intptr : g1int_pred_type(intptrknd) =
+  "mac#%"
+
+fun g1int_half_intptr : g1int_half_type(intptrknd) =
+  "mac#%"
+
+fun g1int_add_intptr : g1int_add_type(intptrknd) =
+  "mac#%"
+
+fun g1int_sub_intptr : g1int_sub_type(intptrknd) =
+  "mac#%"
+
+fun g1int_mul_intptr : g1int_mul_type(intptrknd) =
+  "mac#%"
+
+fun g1int_div_intptr : g1int_div_type(intptrknd) =
+  "mac#%"
+
+fun g1int_nmod_intptr : g1int_nmod_type(intptrknd) =
+  "mac#%"
+
+fun g1int_lt_intptr : g1int_lt_type(intptrknd) =
+  "mac#%"
+
+fun g1int_lte_intptr : g1int_lte_type(intptrknd) =
+  "mac#%"
+
+fun g1int_gt_intptr : g1int_gt_type(intptrknd) =
+  "mac#%"
+
+fun g1int_gte_intptr : g1int_gte_type(intptrknd) =
+  "mac#%"
+
+fun g1int_eq_intptr : g1int_eq_type(intptrknd) =
+  "mac#%"
+
+fun g1int_neq_intptr : g1int_neq_type(intptrknd) =
+  "mac#%"
+
+fun g1int_compare_intptr : g1int_compare_type(intptrknd) =
+  "mac#%"
+
+fun g1int_max_intptr : g1int_max_type(intptrknd) =
+  "mac#%"
+
+fun g1int_min_intptr : g1int_min_type(intptrknd) =
+  "mac#%"
+
+fun g1int_isltz_intptr : g1int_isltz_type(intptrknd) =
+  "mac#%"
+
+fun g1int_isltez_intptr : g1int_isltez_type(intptrknd) =
+  "mac#%"
+
+fun g1int_isgtz_intptr : g1int_isgtz_type(intptrknd) =
+  "mac#%"
+
+fun g1int_isgtez_intptr : g1int_isgtez_type(intptrknd) =
+  "mac#%"
+
+fun g1int_iseqz_intptr : g1int_iseqz_type(intptrknd) =
+  "mac#%"
+
+fun g1int_isneqz_intptr : g1int_isneqz_type(intptrknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1uint_succ_uintptr : g1uint_succ_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_pred_uintptr : g1uint_pred_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_half_uintptr : g1uint_half_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_add_uintptr : g1uint_add_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_sub_uintptr : g1uint_sub_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_mul_uintptr : g1uint_mul_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_div_uintptr : g1uint_div_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_mod_uintptr : g1uint_mod_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_lt_uintptr : g1uint_lt_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_lte_uintptr : g1uint_lte_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_gt_uintptr : g1uint_gt_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_gte_uintptr : g1uint_gte_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_eq_uintptr : g1uint_eq_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_neq_uintptr : g1uint_neq_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_compare_uintptr : g1uint_compare_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_max_uintptr : g1uint_max_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_min_uintptr : g1uint_min_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_isgtz_uintptr : g1uint_isgtz_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_iseqz_uintptr : g1uint_iseqz_type(uintptrknd) =
+  "mac#%"
+
+fun g1uint_isneqz_uintptr : g1uint_isneqz_type(uintptrknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+macdef i2ptr(x) = g1int2int_int_intptr((,(x)))
+
+//
+macdef u2ptr(x) = g1uint2uint_uint_uintptr((,(x)))
+
+//
+(* ****** ****** *)
+(* end of [integer_ptr.sats] *)
diff --git a/test/data/stdlib/integer_ptr.sats b/test/data/stdlib/integer_ptr.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/integer_ptr.sats
@@ -0,0 +1,215 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: January, 2013 *)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/integer_ptr.atxt
+** Time of generation: Thu Jan 11 11:00:04 2018
+*)
+
+(* ****** ****** *)
+//
+// HX: for unindexed integer types
+//
+(* ****** ****** *)
+
+sortdef tk = tkind
+
+(* ****** ****** *)
+
+typedef SHR(a:t@ype) = a // for commenting purpose
+typedef NSH(a:t@ype) = a // for commenting purpose
+
+(* ****** ****** *)
+//
+stadef intptrknd = intptr_kind
+stadef uintptrknd = uintptr_kind
+//
+(* ****** ****** *)
+//
+fun g0int2int_int_intptr(int):<> intptr = "mac#%"
+fun g1int2int_int_intptr{i:int}(int(i)):<> intptr(i) = "mac#%"
+fun g0int2int_lint_intptr(lint):<> intptr = "mac#%"
+fun g1int2int_lint_intptr{i:int}(lint(i)):<> intptr(i) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0int2uint_int_uintptr(int):<> uintptr = "mac#%"
+fun g1int2uint_int_uintptr{i:nat}(int(i)):<> uintptr(i) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0uint2uint_uint_uintptr(uint):<> uintptr = "mac#%"
+fun g1uint2uint_uint_uintptr{u:int}(uint(u)):<> uintptr(u) = "mac#%"
+fun g0uint2uint_ulint_uintptr(ulint):<> uintptr = "mac#%"
+fun g1uint2uint_ulint_uintptr{u:int}(ulint(u)):<> uintptr(u) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0int_neg_intptr (x: intptr):<> intptr = "mac#%"
+fun g0int_abs_intptr (x: intptr):<> intptr = "mac#%"
+fun g0int_succ_intptr (x: intptr):<> intptr = "mac#%"
+fun g0int_pred_intptr (x: intptr):<> intptr = "mac#%"
+fun g0int_half_intptr (x: intptr):<> intptr = "mac#%"
+fun g0int_asl_intptr (x: intptr, n: intGte(0)):<> intptr = "mac#%"
+fun g0int_asr_intptr (x: intptr, n: intGte(0)):<> intptr = "mac#%"
+fun g0int_add_intptr (x: intptr, y: intptr):<> intptr = "mac#%"
+fun g0int_sub_intptr (x: intptr, y: intptr):<> intptr = "mac#%"
+fun g0int_mul_intptr (x: intptr, y: intptr):<> intptr = "mac#%"
+fun g0int_div_intptr (x: intptr, y: intptr):<> intptr = "mac#%"
+fun g0int_mod_intptr (x: intptr, y: intptr):<> intptr = "mac#%"
+fun g0int_lt_intptr (x: intptr, y: intptr):<> bool = "mac#%"
+fun g0int_lte_intptr (x: intptr, y: intptr):<> bool = "mac#%"
+fun g0int_gt_intptr (x: intptr, y: intptr):<> bool = "mac#%"
+fun g0int_gte_intptr (x: intptr, y: intptr):<> bool = "mac#%"
+fun g0int_eq_intptr (x: intptr, y: intptr):<> bool = "mac#%"
+fun g0int_neq_intptr (x: intptr, y: intptr):<> bool = "mac#%"
+fun g0int_compare_intptr (x: intptr, y: intptr):<> int = "mac#%"
+fun g0int_max_intptr (x: intptr, y: intptr):<> intptr = "mac#%"
+fun g0int_min_intptr (x: intptr, y: intptr):<> intptr = "mac#%"
+fun g0int_isltz_intptr (x: intptr):<> bool = "mac#%"
+fun g0int_isltez_intptr (x: intptr):<> bool = "mac#%"
+fun g0int_isgtz_intptr (x: intptr):<> bool = "mac#%"
+fun g0int_isgtez_intptr (x: intptr):<> bool = "mac#%"
+fun g0int_iseqz_intptr (x: intptr):<> bool = "mac#%"
+fun g0int_isneqz_intptr (x: intptr):<> bool = "mac#%"
+//
+(* ****** ****** *)
+//
+fun print_intptr (intptr): void = "mac#%"
+fun prerr_intptr (intptr): void = "mac#%"
+fun fprint_intptr : fprint_type (intptr) = "mac#%"
+overload print with print_intptr
+overload prerr with prerr_intptr
+overload fprint with fprint_intptr
+//
+(* ****** ****** *)
+//
+fun g0uint_succ_uintptr (x: uintptr):<> uintptr = "mac#%"
+fun g0uint_pred_uintptr (x: uintptr):<> uintptr = "mac#%"
+fun g0uint_half_uintptr (x: uintptr):<> uintptr = "mac#%"
+fun g0uint_add_uintptr (x: uintptr, y: uintptr):<> uintptr = "mac#%"
+fun g0uint_sub_uintptr (x: uintptr, y: uintptr):<> uintptr = "mac#%"
+fun g0uint_mul_uintptr (x: uintptr, y: uintptr):<> uintptr = "mac#%"
+fun g0uint_div_uintptr (x: uintptr, y: uintptr):<> uintptr = "mac#%"
+fun g0uint_mod_uintptr (x: uintptr, y: uintptr):<> uintptr = "mac#%"
+fun g0uint_lsl_uintptr (x: uintptr, n: intGte(0)):<> uintptr = "mac#%"
+fun g0uint_lsr_uintptr (x: uintptr, n: intGte(0)):<> uintptr = "mac#%"
+fun g0uint_lnot_uintptr (x: uintptr):<> uintptr = "mac#%"
+fun g0uint_lor_uintptr (x: uintptr, y: uintptr):<> uintptr = "mac#%"
+fun g0uint_lxor_uintptr (x: uintptr, y: uintptr):<> uintptr = "mac#%"
+fun g0uint_land_uintptr (x: uintptr, y: uintptr):<> uintptr = "mac#%"
+fun g0uint_lt_uintptr (x: uintptr, y: uintptr):<> bool = "mac#%"
+fun g0uint_lte_uintptr (x: uintptr, y: uintptr):<> bool = "mac#%"
+fun g0uint_gt_uintptr (x: uintptr, y: uintptr):<> bool = "mac#%"
+fun g0uint_gte_uintptr (x: uintptr, y: uintptr):<> bool = "mac#%"
+fun g0uint_eq_uintptr (x: uintptr, y: uintptr):<> bool = "mac#%"
+fun g0uint_neq_uintptr (x: uintptr, y: uintptr):<> bool = "mac#%"
+fun g0uint_compare_uintptr (x: uintptr, y: uintptr):<> int = "mac#%"
+fun g0uint_max_uintptr (x: uintptr, y: uintptr):<> uintptr = "mac#%"
+fun g0uint_min_uintptr (x: uintptr, y: uintptr):<> uintptr = "mac#%"
+fun g0uint_isgtz_uintptr (x: uintptr):<> bool = "mac#%"
+fun g0uint_iseqz_uintptr (x: uintptr):<> bool = "mac#%"
+fun g0uint_isneqz_uintptr (x: uintptr):<> bool = "mac#%"
+//
+(* ****** ****** *)
+//
+fun print_uintptr (uintptr): void = "mac#%"
+fun prerr_uintptr (uintptr): void = "mac#%"
+fun fprint_uintptr : fprint_type (uintptr) = "mac#%"
+overload print with print_uintptr
+overload prerr with prerr_uintptr
+overload fprint with fprint_uintptr
+//
+(* ****** ****** *)
+//
+fun g1int_neg_intptr : g1int_neg_type (intptrknd) = "mac#%"
+fun g1int_abs_intptr : g1int_abs_type (intptrknd) = "mac#%"
+fun g1int_succ_intptr : g1int_succ_type (intptrknd) = "mac#%"
+fun g1int_pred_intptr : g1int_pred_type (intptrknd) = "mac#%"
+fun g1int_half_intptr : g1int_half_type (intptrknd) = "mac#%"
+fun g1int_add_intptr : g1int_add_type (intptrknd) = "mac#%"
+fun g1int_sub_intptr : g1int_sub_type (intptrknd) = "mac#%"
+fun g1int_mul_intptr : g1int_mul_type (intptrknd) = "mac#%"
+fun g1int_div_intptr : g1int_div_type (intptrknd) = "mac#%"
+fun g1int_nmod_intptr : g1int_nmod_type (intptrknd) = "mac#%"
+fun g1int_lt_intptr : g1int_lt_type (intptrknd) = "mac#%"
+fun g1int_lte_intptr : g1int_lte_type (intptrknd) = "mac#%"
+fun g1int_gt_intptr : g1int_gt_type (intptrknd) = "mac#%"
+fun g1int_gte_intptr : g1int_gte_type (intptrknd) = "mac#%"
+fun g1int_eq_intptr : g1int_eq_type (intptrknd) = "mac#%"
+fun g1int_neq_intptr : g1int_neq_type (intptrknd) = "mac#%"
+fun g1int_compare_intptr : g1int_compare_type (intptrknd) = "mac#%"
+fun g1int_max_intptr : g1int_max_type (intptrknd) = "mac#%"
+fun g1int_min_intptr : g1int_min_type (intptrknd) = "mac#%"
+fun g1int_isltz_intptr : g1int_isltz_type (intptrknd) = "mac#%"
+fun g1int_isltez_intptr : g1int_isltez_type (intptrknd) = "mac#%"
+fun g1int_isgtz_intptr : g1int_isgtz_type (intptrknd) = "mac#%"
+fun g1int_isgtez_intptr : g1int_isgtez_type (intptrknd) = "mac#%"
+fun g1int_iseqz_intptr : g1int_iseqz_type (intptrknd) = "mac#%"
+fun g1int_isneqz_intptr : g1int_isneqz_type (intptrknd) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g1uint_succ_uintptr : g1uint_succ_type (uintptrknd) = "mac#%"
+fun g1uint_pred_uintptr : g1uint_pred_type (uintptrknd) = "mac#%"
+fun g1uint_half_uintptr : g1uint_half_type (uintptrknd) = "mac#%"
+fun g1uint_add_uintptr : g1uint_add_type (uintptrknd) = "mac#%"
+fun g1uint_sub_uintptr : g1uint_sub_type (uintptrknd) = "mac#%"
+fun g1uint_mul_uintptr : g1uint_mul_type (uintptrknd) = "mac#%"
+fun g1uint_div_uintptr : g1uint_div_type (uintptrknd) = "mac#%"
+fun g1uint_mod_uintptr : g1uint_mod_type (uintptrknd) = "mac#%"
+fun g1uint_lt_uintptr : g1uint_lt_type (uintptrknd) = "mac#%"
+fun g1uint_lte_uintptr : g1uint_lte_type (uintptrknd) = "mac#%"
+fun g1uint_gt_uintptr : g1uint_gt_type (uintptrknd) = "mac#%"
+fun g1uint_gte_uintptr : g1uint_gte_type (uintptrknd) = "mac#%"
+fun g1uint_eq_uintptr : g1uint_eq_type (uintptrknd) = "mac#%"
+fun g1uint_neq_uintptr : g1uint_neq_type (uintptrknd) = "mac#%"
+fun g1uint_compare_uintptr : g1uint_compare_type (uintptrknd) = "mac#%"
+fun g1uint_max_uintptr : g1uint_max_type (uintptrknd) = "mac#%"
+fun g1uint_min_uintptr : g1uint_min_type (uintptrknd) = "mac#%"
+fun g1uint_isgtz_uintptr : g1uint_isgtz_type (uintptrknd) = "mac#%"
+fun g1uint_iseqz_uintptr : g1uint_iseqz_type (uintptrknd) = "mac#%"
+fun g1uint_isneqz_uintptr : g1uint_isneqz_type (uintptrknd) = "mac#%"
+//
+(* ****** ****** *)
+//
+macdef i2ptr (x) = g1int2int_int_intptr (,(x))
+//
+macdef u2ptr (x) = g1uint2uint_uint_uintptr (,(x))
+//
+(* ****** ****** *)
+
+(* end of [integer_ptr.sats] *)
diff --git a/test/data/stdlib/integer_short.out b/test/data/stdlib/integer_short.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/integer_short.out
@@ -0,0 +1,420 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: January, 2013 *)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/integer_short.atxt
+** Time of generation: Thu Jan 11 11:00:03 2018
+*)
+(* ****** ****** *)
+sortdef tk = tkind
+
+(* ****** ****** *)
+//
+stadef sintknd  = sint_kind
+stadef usintknd  = usint_kind
+
+//
+(* ****** ****** *)
+//
+fun g0int2int_int_sint(int) :<> sint =
+  "mac#%"
+
+fun g0uint2int_uint_sint(uint) :<> sint =
+  "mac#%"
+
+//
+fun g0int2uint_int_usint(int) :<> usint =
+  "mac#%"
+
+fun g0uint2uint_uint_usint(uint) :<> usint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+fun g0int2uint_sint_usint(sint) :<> usint =
+  "mac#%"
+
+fun g0uint2int_usint_sint(usint) :<> sint =
+  "mac#%"
+
+(* ****** ****** *)
+//
+fun g0int2int_sint_int(sint) :<> int =
+  "mac#%"
+
+fun g0int2uint_sint_uint(sint) :<> uint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0uint2int_usint_int(usint) :<> int =
+  "mac#%"
+
+fun g0uint2uint_usint_uint(usint) :<> uint =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun print_sint(sint) : void =
+  "mac#%"
+
+fun prerr_sint(sint) : void =
+  "mac#%"
+
+fun fprint_sint : fprint_type(sint) =
+  "mac#%"
+
+overload print with print_sint
+
+overload prerr with prerr_sint
+
+overload fprint with fprint_sint
+
+fun print_usint(usint) : void =
+  "mac#%"
+
+fun prerr_usint(usint) : void =
+  "mac#%"
+
+fun fprint_usint : fprint_type(usint) =
+  "mac#%"
+
+overload print with print_usint
+
+overload prerr with prerr_usint
+
+overload fprint with fprint_usint
+
+//
+(* ****** ****** *)
+//
+fun g0int_neg_sint(x : sint) :<> sint =
+  "mac#%"
+
+fun g0int_abs_sint(x : sint) :<> sint =
+  "mac#%"
+
+fun g0int_succ_sint(x : sint) :<> sint =
+  "mac#%"
+
+fun g0int_pred_sint(x : sint) :<> sint =
+  "mac#%"
+
+fun g0int_half_sint(x : sint) :<> sint =
+  "mac#%"
+
+fun g0int_asl_sint(x : sint, n : intGte(0)) :<> sint =
+  "mac#%"
+
+fun g0int_asr_sint(x : sint, n : intGte(0)) :<> sint =
+  "mac#%"
+
+fun g0int_add_sint(x : sint, y : sint) :<> sint =
+  "mac#%"
+
+fun g0int_sub_sint(x : sint, y : sint) :<> sint =
+  "mac#%"
+
+fun g0int_mul_sint(x : sint, y : sint) :<> sint =
+  "mac#%"
+
+fun g0int_div_sint(x : sint, y : sint) :<> sint =
+  "mac#%"
+
+fun g0int_mod_sint(x : sint, y : sint) :<> sint =
+  "mac#%"
+
+fun g0int_lt_sint(x : sint, y : sint) :<> bool =
+  "mac#%"
+
+fun g0int_lte_sint(x : sint, y : sint) :<> bool =
+  "mac#%"
+
+fun g0int_gt_sint(x : sint, y : sint) :<> bool =
+  "mac#%"
+
+fun g0int_gte_sint(x : sint, y : sint) :<> bool =
+  "mac#%"
+
+fun g0int_eq_sint(x : sint, y : sint) :<> bool =
+  "mac#%"
+
+fun g0int_neq_sint(x : sint, y : sint) :<> bool =
+  "mac#%"
+
+fun g0int_compare_sint(x : sint, y : sint) :<> int =
+  "mac#%"
+
+fun g0int_max_sint(x : sint, y : sint) :<> sint =
+  "mac#%"
+
+fun g0int_min_sint(x : sint, y : sint) :<> sint =
+  "mac#%"
+
+fun g0int_isltz_sint(x : sint) :<> bool =
+  "mac#%"
+
+fun g0int_isltez_sint(x : sint) :<> bool =
+  "mac#%"
+
+fun g0int_isgtz_sint(x : sint) :<> bool =
+  "mac#%"
+
+fun g0int_isgtez_sint(x : sint) :<> bool =
+  "mac#%"
+
+fun g0int_iseqz_sint(x : sint) :<> bool =
+  "mac#%"
+
+fun g0int_isneqz_sint(x : sint) :<> bool =
+  "mac#%"
+
+fun g0uint_succ_usint(x : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_pred_usint(x : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_half_usint(x : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_add_usint(x : usint, y : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_sub_usint(x : usint, y : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_mul_usint(x : usint, y : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_div_usint(x : usint, y : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_mod_usint(x : usint, y : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_lsl_usint(x : usint, n : intGte(0)) :<> usint =
+  "mac#%"
+
+fun g0uint_lsr_usint(x : usint, n : intGte(0)) :<> usint =
+  "mac#%"
+
+fun g0uint_lnot_usint(x : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_lor_usint(x : usint, y : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_lxor_usint(x : usint, y : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_land_usint(x : usint, y : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_lt_usint(x : usint, y : usint) :<> bool =
+  "mac#%"
+
+fun g0uint_lte_usint(x : usint, y : usint) :<> bool =
+  "mac#%"
+
+fun g0uint_gt_usint(x : usint, y : usint) :<> bool =
+  "mac#%"
+
+fun g0uint_gte_usint(x : usint, y : usint) :<> bool =
+  "mac#%"
+
+fun g0uint_eq_usint(x : usint, y : usint) :<> bool =
+  "mac#%"
+
+fun g0uint_neq_usint(x : usint, y : usint) :<> bool =
+  "mac#%"
+
+fun g0uint_compare_usint(x : usint, y : usint) :<> int =
+  "mac#%"
+
+fun g0uint_max_usint(x : usint, y : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_min_usint(x : usint, y : usint) :<> usint =
+  "mac#%"
+
+fun g0uint_isgtz_usint(x : usint) :<> bool =
+  "mac#%"
+
+fun g0uint_iseqz_usint(x : usint) :<> bool =
+  "mac#%"
+
+fun g0uint_isneqz_usint(x : usint) :<> bool =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1int_neg_sint : g1int_neg_type(sintknd) =
+  "mac#%"
+
+fun g1int_abs_sint : g1int_abs_type(sintknd) =
+  "mac#%"
+
+fun g1int_succ_sint : g1int_succ_type(sintknd) =
+  "mac#%"
+
+fun g1int_pred_sint : g1int_pred_type(sintknd) =
+  "mac#%"
+
+fun g1int_half_sint : g1int_half_type(sintknd) =
+  "mac#%"
+
+fun g1int_add_sint : g1int_add_type(sintknd) =
+  "mac#%"
+
+fun g1int_sub_sint : g1int_sub_type(sintknd) =
+  "mac#%"
+
+fun g1int_mul_sint : g1int_mul_type(sintknd) =
+  "mac#%"
+
+fun g1int_div_sint : g1int_div_type(sintknd) =
+  "mac#%"
+
+fun g1int_nmod_sint : g1int_nmod_type(sintknd) =
+  "mac#%"
+
+fun g1int_lt_sint : g1int_lt_type(sintknd) =
+  "mac#%"
+
+fun g1int_lte_sint : g1int_lte_type(sintknd) =
+  "mac#%"
+
+fun g1int_gt_sint : g1int_gt_type(sintknd) =
+  "mac#%"
+
+fun g1int_gte_sint : g1int_gte_type(sintknd) =
+  "mac#%"
+
+fun g1int_eq_sint : g1int_eq_type(sintknd) =
+  "mac#%"
+
+fun g1int_neq_sint : g1int_neq_type(sintknd) =
+  "mac#%"
+
+fun g1int_compare_sint : g1int_compare_type(sintknd) =
+  "mac#%"
+
+fun g1int_max_sint : g1int_max_type(sintknd) =
+  "mac#%"
+
+fun g1int_min_sint : g1int_min_type(sintknd) =
+  "mac#%"
+
+fun g1int_isltz_sint : g1int_isltz_type(sintknd) =
+  "mac#%"
+
+fun g1int_isltez_sint : g1int_isltez_type(sintknd) =
+  "mac#%"
+
+fun g1int_isgtz_sint : g1int_isgtz_type(sintknd) =
+  "mac#%"
+
+fun g1int_isgtez_sint : g1int_isgtez_type(sintknd) =
+  "mac#%"
+
+fun g1int_iseqz_sint : g1int_iseqz_type(sintknd) =
+  "mac#%"
+
+fun g1int_isneqz_sint : g1int_isneqz_type(sintknd) =
+  "mac#%"
+
+fun g1uint_succ_usint : g1uint_succ_type(usintknd) =
+  "mac#%"
+
+fun g1uint_pred_usint : g1uint_pred_type(usintknd) =
+  "mac#%"
+
+fun g1uint_half_usint : g1uint_half_type(usintknd) =
+  "mac#%"
+
+fun g1uint_add_usint : g1uint_add_type(usintknd) =
+  "mac#%"
+
+fun g1uint_sub_usint : g1uint_sub_type(usintknd) =
+  "mac#%"
+
+fun g1uint_mul_usint : g1uint_mul_type(usintknd) =
+  "mac#%"
+
+fun g1uint_div_usint : g1uint_div_type(usintknd) =
+  "mac#%"
+
+fun g1uint_mod_usint : g1uint_mod_type(usintknd) =
+  "mac#%"
+
+fun g1uint_lt_usint : g1uint_lt_type(usintknd) =
+  "mac#%"
+
+fun g1uint_lte_usint : g1uint_lte_type(usintknd) =
+  "mac#%"
+
+fun g1uint_gt_usint : g1uint_gt_type(usintknd) =
+  "mac#%"
+
+fun g1uint_gte_usint : g1uint_gte_type(usintknd) =
+  "mac#%"
+
+fun g1uint_eq_usint : g1uint_eq_type(usintknd) =
+  "mac#%"
+
+fun g1uint_neq_usint : g1uint_neq_type(usintknd) =
+  "mac#%"
+
+fun g1uint_compare_usint : g1uint_compare_type(usintknd) =
+  "mac#%"
+
+fun g1uint_max_usint : g1uint_max_type(usintknd) =
+  "mac#%"
+
+fun g1uint_min_usint : g1uint_min_type(usintknd) =
+  "mac#%"
+
+fun g1uint_isgtz_usint : g1uint_isgtz_type(usintknd) =
+  "mac#%"
+
+fun g1uint_iseqz_usint : g1uint_iseqz_type(usintknd) =
+  "mac#%"
+
+fun g1uint_isneqz_usint : g1uint_isneqz_type(usintknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+(* end of [integer_short.sats] *)
diff --git a/test/data/stdlib/integer_short.sats b/test/data/stdlib/integer_short.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/integer_short.sats
@@ -0,0 +1,195 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: January, 2013 *)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/integer_short.atxt
+** Time of generation: Thu Jan 11 11:00:03 2018
+*)
+
+(* ****** ****** *)
+
+sortdef tk = tkind
+
+(* ****** ****** *)
+//
+stadef sintknd = sint_kind
+stadef usintknd = usint_kind
+//
+(* ****** ****** *)
+//
+fun g0int2int_int_sint(int):<> sint = "mac#%"
+fun g0uint2int_uint_sint(uint):<> sint = "mac#%"
+//
+fun g0int2uint_int_usint(int):<> usint = "mac#%"
+fun g0uint2uint_uint_usint(uint):<> usint = "mac#%"
+//
+(* ****** ****** *)
+
+fun g0int2uint_sint_usint(sint):<> usint = "mac#%"
+fun g0uint2int_usint_sint(usint):<> sint = "mac#%"
+
+(* ****** ****** *)
+//
+fun g0int2int_sint_int(sint):<> int = "mac#%"
+fun g0int2uint_sint_uint(sint):<> uint = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0uint2int_usint_int(usint):<> int = "mac#%"
+fun g0uint2uint_usint_uint(usint):<> uint = "mac#%"
+//
+(* ****** ****** *)
+//
+fun print_sint (sint): void = "mac#%"
+fun prerr_sint (sint): void = "mac#%"
+fun fprint_sint : fprint_type (sint) = "mac#%"
+overload print with print_sint
+overload prerr with prerr_sint
+overload fprint with fprint_sint
+fun print_usint (usint): void = "mac#%"
+fun prerr_usint (usint): void = "mac#%"
+fun fprint_usint : fprint_type (usint) = "mac#%"
+overload print with print_usint
+overload prerr with prerr_usint
+overload fprint with fprint_usint
+//
+(* ****** ****** *)
+//
+fun g0int_neg_sint (x: sint):<> sint = "mac#%"
+fun g0int_abs_sint (x: sint):<> sint = "mac#%"
+fun g0int_succ_sint (x: sint):<> sint = "mac#%"
+fun g0int_pred_sint (x: sint):<> sint = "mac#%"
+fun g0int_half_sint (x: sint):<> sint = "mac#%"
+fun g0int_asl_sint (x: sint, n: intGte(0)):<> sint = "mac#%"
+fun g0int_asr_sint (x: sint, n: intGte(0)):<> sint = "mac#%"
+fun g0int_add_sint (x: sint, y: sint):<> sint = "mac#%"
+fun g0int_sub_sint (x: sint, y: sint):<> sint = "mac#%"
+fun g0int_mul_sint (x: sint, y: sint):<> sint = "mac#%"
+fun g0int_div_sint (x: sint, y: sint):<> sint = "mac#%"
+fun g0int_mod_sint (x: sint, y: sint):<> sint = "mac#%"
+fun g0int_lt_sint (x: sint, y: sint):<> bool = "mac#%"
+fun g0int_lte_sint (x: sint, y: sint):<> bool = "mac#%"
+fun g0int_gt_sint (x: sint, y: sint):<> bool = "mac#%"
+fun g0int_gte_sint (x: sint, y: sint):<> bool = "mac#%"
+fun g0int_eq_sint (x: sint, y: sint):<> bool = "mac#%"
+fun g0int_neq_sint (x: sint, y: sint):<> bool = "mac#%"
+fun g0int_compare_sint (x: sint, y: sint):<> int = "mac#%"
+fun g0int_max_sint (x: sint, y: sint):<> sint = "mac#%"
+fun g0int_min_sint (x: sint, y: sint):<> sint = "mac#%"
+fun g0int_isltz_sint (x: sint):<> bool = "mac#%"
+fun g0int_isltez_sint (x: sint):<> bool = "mac#%"
+fun g0int_isgtz_sint (x: sint):<> bool = "mac#%"
+fun g0int_isgtez_sint (x: sint):<> bool = "mac#%"
+fun g0int_iseqz_sint (x: sint):<> bool = "mac#%"
+fun g0int_isneqz_sint (x: sint):<> bool = "mac#%"
+fun g0uint_succ_usint (x: usint):<> usint = "mac#%"
+fun g0uint_pred_usint (x: usint):<> usint = "mac#%"
+fun g0uint_half_usint (x: usint):<> usint = "mac#%"
+fun g0uint_add_usint (x: usint, y: usint):<> usint = "mac#%"
+fun g0uint_sub_usint (x: usint, y: usint):<> usint = "mac#%"
+fun g0uint_mul_usint (x: usint, y: usint):<> usint = "mac#%"
+fun g0uint_div_usint (x: usint, y: usint):<> usint = "mac#%"
+fun g0uint_mod_usint (x: usint, y: usint):<> usint = "mac#%"
+fun g0uint_lsl_usint (x: usint, n: intGte(0)):<> usint = "mac#%"
+fun g0uint_lsr_usint (x: usint, n: intGte(0)):<> usint = "mac#%"
+fun g0uint_lnot_usint (x: usint):<> usint = "mac#%"
+fun g0uint_lor_usint (x: usint, y: usint):<> usint = "mac#%"
+fun g0uint_lxor_usint (x: usint, y: usint):<> usint = "mac#%"
+fun g0uint_land_usint (x: usint, y: usint):<> usint = "mac#%"
+fun g0uint_lt_usint (x: usint, y: usint):<> bool = "mac#%"
+fun g0uint_lte_usint (x: usint, y: usint):<> bool = "mac#%"
+fun g0uint_gt_usint (x: usint, y: usint):<> bool = "mac#%"
+fun g0uint_gte_usint (x: usint, y: usint):<> bool = "mac#%"
+fun g0uint_eq_usint (x: usint, y: usint):<> bool = "mac#%"
+fun g0uint_neq_usint (x: usint, y: usint):<> bool = "mac#%"
+fun g0uint_compare_usint (x: usint, y: usint):<> int = "mac#%"
+fun g0uint_max_usint (x: usint, y: usint):<> usint = "mac#%"
+fun g0uint_min_usint (x: usint, y: usint):<> usint = "mac#%"
+fun g0uint_isgtz_usint (x: usint):<> bool = "mac#%"
+fun g0uint_iseqz_usint (x: usint):<> bool = "mac#%"
+fun g0uint_isneqz_usint (x: usint):<> bool = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g1int_neg_sint : g1int_neg_type (sintknd) = "mac#%"
+fun g1int_abs_sint : g1int_abs_type (sintknd) = "mac#%"
+fun g1int_succ_sint : g1int_succ_type (sintknd) = "mac#%"
+fun g1int_pred_sint : g1int_pred_type (sintknd) = "mac#%"
+fun g1int_half_sint : g1int_half_type (sintknd) = "mac#%"
+fun g1int_add_sint : g1int_add_type (sintknd) = "mac#%"
+fun g1int_sub_sint : g1int_sub_type (sintknd) = "mac#%"
+fun g1int_mul_sint : g1int_mul_type (sintknd) = "mac#%"
+fun g1int_div_sint : g1int_div_type (sintknd) = "mac#%"
+fun g1int_nmod_sint : g1int_nmod_type (sintknd) = "mac#%"
+fun g1int_lt_sint : g1int_lt_type (sintknd) = "mac#%"
+fun g1int_lte_sint : g1int_lte_type (sintknd) = "mac#%"
+fun g1int_gt_sint : g1int_gt_type (sintknd) = "mac#%"
+fun g1int_gte_sint : g1int_gte_type (sintknd) = "mac#%"
+fun g1int_eq_sint : g1int_eq_type (sintknd) = "mac#%"
+fun g1int_neq_sint : g1int_neq_type (sintknd) = "mac#%"
+fun g1int_compare_sint : g1int_compare_type (sintknd) = "mac#%"
+fun g1int_max_sint : g1int_max_type (sintknd) = "mac#%"
+fun g1int_min_sint : g1int_min_type (sintknd) = "mac#%"
+fun g1int_isltz_sint : g1int_isltz_type (sintknd) = "mac#%"
+fun g1int_isltez_sint : g1int_isltez_type (sintknd) = "mac#%"
+fun g1int_isgtz_sint : g1int_isgtz_type (sintknd) = "mac#%"
+fun g1int_isgtez_sint : g1int_isgtez_type (sintknd) = "mac#%"
+fun g1int_iseqz_sint : g1int_iseqz_type (sintknd) = "mac#%"
+fun g1int_isneqz_sint : g1int_isneqz_type (sintknd) = "mac#%"
+fun g1uint_succ_usint : g1uint_succ_type (usintknd) = "mac#%"
+fun g1uint_pred_usint : g1uint_pred_type (usintknd) = "mac#%"
+fun g1uint_half_usint : g1uint_half_type (usintknd) = "mac#%"
+fun g1uint_add_usint : g1uint_add_type (usintknd) = "mac#%"
+fun g1uint_sub_usint : g1uint_sub_type (usintknd) = "mac#%"
+fun g1uint_mul_usint : g1uint_mul_type (usintknd) = "mac#%"
+fun g1uint_div_usint : g1uint_div_type (usintknd) = "mac#%"
+fun g1uint_mod_usint : g1uint_mod_type (usintknd) = "mac#%"
+fun g1uint_lt_usint : g1uint_lt_type (usintknd) = "mac#%"
+fun g1uint_lte_usint : g1uint_lte_type (usintknd) = "mac#%"
+fun g1uint_gt_usint : g1uint_gt_type (usintknd) = "mac#%"
+fun g1uint_gte_usint : g1uint_gte_type (usintknd) = "mac#%"
+fun g1uint_eq_usint : g1uint_eq_type (usintknd) = "mac#%"
+fun g1uint_neq_usint : g1uint_neq_type (usintknd) = "mac#%"
+fun g1uint_compare_usint : g1uint_compare_type (usintknd) = "mac#%"
+fun g1uint_max_usint : g1uint_max_type (usintknd) = "mac#%"
+fun g1uint_min_usint : g1uint_min_type (usintknd) = "mac#%"
+fun g1uint_isgtz_usint : g1uint_isgtz_type (usintknd) = "mac#%"
+fun g1uint_iseqz_usint : g1uint_iseqz_type (usintknd) = "mac#%"
+fun g1uint_isneqz_usint : g1uint_isneqz_type (usintknd) = "mac#%"
+//
+(* ****** ****** *)
+
+(* end of [integer_short.sats] *)
diff --git a/test/data/stdlib/integer_size.out b/test/data/stdlib/integer_size.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/integer_size.out
@@ -0,0 +1,569 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: January, 2013 *)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/integer_size.atxt
+** Time of generation: Thu Jan 11 11:00:03 2018
+*)
+(* ****** ****** *)
+sortdef tk = tkind
+
+(* ****** ****** *)
+//
+stadef sizeknd  = size_kind
+stadef ssizeknd  = ssize_kind
+
+//
+(* ****** ****** *)
+//
+fun g0int2uint_int_size(int) :<> size_t =
+  "mac#%"
+
+fun g0uint2uint_uint_size(uint) :<> size_t =
+  "mac#%"
+
+//
+fun g0int2int_int_ssize(int) :<> ssize_t =
+  "mac#%"
+
+fun g0uint2int_uint_ssize(uint) :<> ssize_t =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0int2uint_lint_size(lint) :<> size_t =
+  "mac#%"
+
+fun g0uint2uint_ulint_size(ulint) :<> size_t =
+  "mac#%"
+
+//
+fun g0int2int_lint_ssize(lint) :<> ssize_t =
+  "mac#%"
+
+fun g0uint2int_ulint_ssize(ulint) :<> ssize_t =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0uint2int_size_int(size_t) :<> int =
+  "mac#%"
+
+fun g0uint2int_size_lint(size_t) :<> lint =
+  "mac#%"
+
+fun g0uint2int_size_llint(size_t) :<> llint =
+  "mac#%"
+
+//
+fun g0uint2int_size_ssize(size_t) :<> ssize_t =
+  "mac#%"
+
+//
+fun g0uint2uint_size_uint(size_t) :<> uint =
+  "mac#%"
+
+fun g0uint2uint_size_ulint(size_t) :<> ulint =
+  "mac#%"
+
+fun g0uint2uint_size_ullint(size_t) :<> ullint =
+  "mac#%"
+
+//
+fun g0uint2uint_size_size(sz : size_t) :<> size_t =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0int2int_ssize_int(ssize_t) :<> int =
+  "mac#%"
+
+fun g0int2int_ssize_lint(ssize_t) :<> lint =
+  "mac#%"
+
+fun g0int2int_ssize_llint(ssize_t) :<> llint =
+  "mac#%"
+
+//
+fun g0int2int_ssize_ssize(ssize_t) :<> ssize_t =
+  "mac#%"
+
+//
+fun g0int2uint_ssize_uint(ssize_t) :<> uint =
+  "mac#%"
+
+fun g0int2uint_ssize_ulint(ssize_t) :<> ulint =
+  "mac#%"
+
+fun g0int2uint_ssize_ullint(ssize_t) :<> ullint =
+  "mac#%"
+
+//
+fun g0int2uint_ssize_size(ssz : ssize_t) :<> size_t =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g0uint2string_size(sz : size_t) :<!wrt> Strptr1 =
+  "mac#%"
+
+fun g0string2uint_size(rep : NSH(string)) :<> size_t =
+  "mac#%"
+
+//
+fun g0int2string_ssize(ssz : ssize_t) :<!wrt> Strptr1 =
+  "mac#%"
+
+fun g0string2int_ssize(rep : NSH(string)) :<> ssize_t =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun print_size(size_t) : void =
+  "mac#%"
+
+fun prerr_size(size_t) : void =
+  "mac#%"
+
+fun fprint_size : fprint_type(size_t) =
+  "mac#%"
+
+overload print with print_size
+
+overload prerr with prerr_size
+
+overload fprint with fprint_size
+
+//
+fun print_ssize(ssize_t) : void =
+  "mac#%"
+
+fun prerr_ssize(ssize_t) : void =
+  "mac#%"
+
+fun fprint_ssize : fprint_type(ssize_t) =
+  "mac#%"
+
+overload print with print_ssize
+
+overload prerr with prerr_ssize
+
+overload fprint with fprint_ssize
+
+//
+(* ****** ****** *)
+//
+fun g0uint_succ_size(x : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_pred_size(x : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_half_size(x : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_add_size(x : size_t, y : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_sub_size(x : size_t, y : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_mul_size(x : size_t, y : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_div_size(x : size_t, y : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_mod_size(x : size_t, y : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_lsl_size(x : size_t, n : intGte(0)) :<> size_t =
+  "mac#%"
+
+fun g0uint_lsr_size(x : size_t, n : intGte(0)) :<> size_t =
+  "mac#%"
+
+fun g0uint_lnot_size(x : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_lor_size(x : size_t, y : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_lxor_size(x : size_t, y : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_land_size(x : size_t, y : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_lt_size(x : size_t, y : size_t) :<> bool =
+  "mac#%"
+
+fun g0uint_lte_size(x : size_t, y : size_t) :<> bool =
+  "mac#%"
+
+fun g0uint_gt_size(x : size_t, y : size_t) :<> bool =
+  "mac#%"
+
+fun g0uint_gte_size(x : size_t, y : size_t) :<> bool =
+  "mac#%"
+
+fun g0uint_eq_size(x : size_t, y : size_t) :<> bool =
+  "mac#%"
+
+fun g0uint_neq_size(x : size_t, y : size_t) :<> bool =
+  "mac#%"
+
+fun g0uint_compare_size(x : size_t, y : size_t) :<> int =
+  "mac#%"
+
+fun g0uint_max_size(x : size_t, y : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_min_size(x : size_t, y : size_t) :<> size_t =
+  "mac#%"
+
+fun g0uint_isgtz_size(x : size_t) :<> bool =
+  "mac#%"
+
+fun g0uint_iseqz_size(x : size_t) :<> bool =
+  "mac#%"
+
+fun g0uint_isneqz_size(x : size_t) :<> bool =
+  "mac#%"
+
+//
+fun g0int_neg_ssize(x : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_abs_ssize(x : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_succ_ssize(x : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_pred_ssize(x : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_half_ssize(x : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_asl_ssize(x : ssize_t, n : intGte(0)) :<> ssize_t =
+  "mac#%"
+
+fun g0int_asr_ssize(x : ssize_t, n : intGte(0)) :<> ssize_t =
+  "mac#%"
+
+fun g0int_add_ssize(x : ssize_t, y : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_sub_ssize(x : ssize_t, y : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_mul_ssize(x : ssize_t, y : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_div_ssize(x : ssize_t, y : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_mod_ssize(x : ssize_t, y : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_lt_ssize(x : ssize_t, y : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_lte_ssize(x : ssize_t, y : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_gt_ssize(x : ssize_t, y : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_gte_ssize(x : ssize_t, y : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_eq_ssize(x : ssize_t, y : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_neq_ssize(x : ssize_t, y : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_compare_ssize(x : ssize_t, y : ssize_t) :<> int =
+  "mac#%"
+
+fun g0int_max_ssize(x : ssize_t, y : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_min_ssize(x : ssize_t, y : ssize_t) :<> ssize_t =
+  "mac#%"
+
+fun g0int_isltz_ssize(x : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_isltez_ssize(x : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_isgtz_ssize(x : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_isgtez_ssize(x : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_iseqz_ssize(x : ssize_t) :<> bool =
+  "mac#%"
+
+fun g0int_isneqz_ssize(x : ssize_t) :<> bool =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1int2uint_int_size : g1int2uint_type(intknd, sizeknd) =
+  "mac#%"
+
+fun g1uint2uint_uint_size : g1uint2uint_type(uintknd, sizeknd) =
+  "mac#%"
+
+//
+fun g1int2int_int_ssize : g1int2int_type(intknd, ssizeknd) =
+  "mac#%"
+
+fun g1uint2int_uint_ssize : g1uint2int_type(uintknd, ssizeknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1uint2int_size_int : g1uint2int_type(sizeknd, intknd) =
+  "mac#%"
+
+fun g1uint2uint_size_uint : g1uint2uint_type(sizeknd, uintknd) =
+  "mac#%"
+
+//
+fun g1uint2uint_size_size : g1uint2uint_type(sizeknd, sizeknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1int2int_ssize_int : g1int2int_type(ssizeknd, intknd) =
+  "mac#%"
+
+fun g1int2uint_ssize_uint : g1int2uint_type(ssizeknd, uintknd) =
+  "mac#%"
+
+//
+fun g1int2int_ssize_ssize : g1int2int_type(ssizeknd, ssizeknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1uint2int_size_ssize : g1uint2int_type(sizeknd, ssizeknd) =
+  "mac#%"
+
+fun g1int2uint_ssize_size : g1int2uint_type(ssizeknd, sizeknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+fun g1uint_succ_size : g1uint_succ_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_pred_size : g1uint_pred_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_half_size : g1uint_half_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_add_size : g1uint_add_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_sub_size : g1uint_sub_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_mul_size : g1uint_mul_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_div_size : g1uint_div_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_mod_size : g1uint_mod_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_lt_size : g1uint_lt_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_lte_size : g1uint_lte_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_gt_size : g1uint_gt_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_gte_size : g1uint_gte_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_eq_size : g1uint_eq_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_neq_size : g1uint_neq_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_compare_size : g1uint_compare_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_max_size : g1uint_max_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_min_size : g1uint_min_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_isgtz_size : g1uint_isgtz_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_iseqz_size : g1uint_iseqz_type(sizeknd) =
+  "mac#%"
+
+fun g1uint_isneqz_size : g1uint_isneqz_type(sizeknd) =
+  "mac#%"
+
+//
+fun g1int_neg_ssize : g1int_neg_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_abs_ssize : g1int_abs_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_succ_ssize : g1int_succ_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_pred_ssize : g1int_pred_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_half_ssize : g1int_half_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_add_ssize : g1int_add_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_sub_ssize : g1int_sub_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_mul_ssize : g1int_mul_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_div_ssize : g1int_div_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_nmod_ssize : g1int_nmod_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_lt_ssize : g1int_lt_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_lte_ssize : g1int_lte_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_gt_ssize : g1int_gt_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_gte_ssize : g1int_gte_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_eq_ssize : g1int_eq_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_neq_ssize : g1int_neq_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_compare_ssize : g1int_compare_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_max_ssize : g1int_max_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_min_ssize : g1int_min_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_isltz_ssize : g1int_isltz_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_isltez_ssize : g1int_isltez_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_isgtz_ssize : g1int_isgtz_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_isgtez_ssize : g1int_isgtez_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_iseqz_ssize : g1int_iseqz_type(ssizeknd) =
+  "mac#%"
+
+fun g1int_isneqz_ssize : g1int_isneqz_type(ssizeknd) =
+  "mac#%"
+
+//
+(* ****** ****** *)
+//
+macdef i2sz(x) = g1int2uint_int_size(,(x))
+
+macdef u2sz(x) = g1uint2uint_uint_size(,(x))
+
+//
+macdef i2ssz(x) = g1int2int_int_ssize(,(x))
+
+macdef u2ssz(x) = g1uint2int_uint_ssize(,(x))
+
+//
+(* ****** ****** *)
+//
+symintr sz2i
+
+overload sz2i with g0uint2int_size_int of 0
+
+overload sz2i with g1uint2int_size_int of 10
+
+//
+symintr sz2u
+
+overload sz2u with g0uint2uint_size_uint of 0
+
+overload sz2u with g1uint2uint_size_uint of 10
+
+//
+(* ****** ****** *)
+(* end of [integer_size.sats] *)
diff --git a/test/data/stdlib/integer_size.sats b/test/data/stdlib/integer_size.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/integer_size.sats
@@ -0,0 +1,296 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: gmhwxiATgmailDOTcom *)
+(* Start time: January, 2013 *)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/integer_size.atxt
+** Time of generation: Thu Jan 11 11:00:03 2018
+*)
+
+(* ****** ****** *)
+
+sortdef tk = tkind
+
+(* ****** ****** *)
+//
+stadef sizeknd = size_kind
+stadef ssizeknd = ssize_kind
+//
+(* ****** ****** *)
+//
+fun g0int2uint_int_size(int):<> size_t = "mac#%"
+fun g0uint2uint_uint_size(uint):<> size_t = "mac#%"
+//
+fun g0int2int_int_ssize(int):<> ssize_t = "mac#%"
+fun g0uint2int_uint_ssize(uint):<> ssize_t = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0int2uint_lint_size(lint):<> size_t = "mac#%"
+fun g0uint2uint_ulint_size(ulint):<> size_t = "mac#%"
+//
+fun g0int2int_lint_ssize(lint):<> ssize_t = "mac#%"
+fun g0uint2int_ulint_ssize(ulint):<> ssize_t = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0uint2int_size_int(size_t):<> int = "mac#%"
+fun g0uint2int_size_lint(size_t):<> lint = "mac#%"
+fun g0uint2int_size_llint(size_t):<> llint = "mac#%"
+//
+fun g0uint2int_size_ssize(size_t):<> ssize_t = "mac#%"
+//
+fun g0uint2uint_size_uint(size_t):<> uint = "mac#%"
+fun g0uint2uint_size_ulint(size_t):<> ulint = "mac#%"
+fun g0uint2uint_size_ullint(size_t):<> ullint = "mac#%"
+//
+fun g0uint2uint_size_size(sz: size_t):<> size_t = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0int2int_ssize_int(ssize_t):<> int = "mac#%"
+fun g0int2int_ssize_lint(ssize_t):<> lint = "mac#%"
+fun g0int2int_ssize_llint(ssize_t):<> llint = "mac#%"
+//
+fun g0int2int_ssize_ssize(ssize_t):<> ssize_t = "mac#%"
+//
+fun g0int2uint_ssize_uint(ssize_t):<> uint = "mac#%"
+fun g0int2uint_ssize_ulint(ssize_t):<> ulint = "mac#%"
+fun g0int2uint_ssize_ullint(ssize_t):<> ullint = "mac#%"
+//
+fun g0int2uint_ssize_size(ssz: ssize_t):<> size_t = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g0uint2string_size(sz: size_t):<!wrt> Strptr1 = "mac#%"
+fun g0string2uint_size(rep: NSH(string)):<> size_t = "mac#%"
+//
+fun g0int2string_ssize(ssz: ssize_t):<!wrt> Strptr1 = "mac#%"
+fun g0string2int_ssize(rep: NSH(string)):<> ssize_t = "mac#%"
+//
+(* ****** ****** *)
+//
+fun print_size (size_t): void = "mac#%"
+fun prerr_size (size_t): void = "mac#%"
+fun fprint_size : fprint_type (size_t) = "mac#%"
+overload print with print_size
+overload prerr with prerr_size
+overload fprint with fprint_size
+//
+fun print_ssize (ssize_t): void = "mac#%"
+fun prerr_ssize (ssize_t): void = "mac#%"
+fun fprint_ssize : fprint_type (ssize_t) = "mac#%"
+overload print with print_ssize
+overload prerr with prerr_ssize
+overload fprint with fprint_ssize
+//
+(* ****** ****** *)
+//
+fun g0uint_succ_size (x: size_t):<> size_t = "mac#%"
+fun g0uint_pred_size (x: size_t):<> size_t = "mac#%"
+fun g0uint_half_size (x: size_t):<> size_t = "mac#%"
+fun g0uint_add_size (x: size_t, y: size_t):<> size_t = "mac#%"
+fun g0uint_sub_size (x: size_t, y: size_t):<> size_t = "mac#%"
+fun g0uint_mul_size (x: size_t, y: size_t):<> size_t = "mac#%"
+fun g0uint_div_size (x: size_t, y: size_t):<> size_t = "mac#%"
+fun g0uint_mod_size (x: size_t, y: size_t):<> size_t = "mac#%"
+fun g0uint_lsl_size (x: size_t, n: intGte(0)):<> size_t = "mac#%"
+fun g0uint_lsr_size (x: size_t, n: intGte(0)):<> size_t = "mac#%"
+fun g0uint_lnot_size (x: size_t):<> size_t = "mac#%"
+fun g0uint_lor_size (x: size_t, y: size_t):<> size_t = "mac#%"
+fun g0uint_lxor_size (x: size_t, y: size_t):<> size_t = "mac#%"
+fun g0uint_land_size (x: size_t, y: size_t):<> size_t = "mac#%"
+fun g0uint_lt_size (x: size_t, y: size_t):<> bool = "mac#%"
+fun g0uint_lte_size (x: size_t, y: size_t):<> bool = "mac#%"
+fun g0uint_gt_size (x: size_t, y: size_t):<> bool = "mac#%"
+fun g0uint_gte_size (x: size_t, y: size_t):<> bool = "mac#%"
+fun g0uint_eq_size (x: size_t, y: size_t):<> bool = "mac#%"
+fun g0uint_neq_size (x: size_t, y: size_t):<> bool = "mac#%"
+fun g0uint_compare_size (x: size_t, y: size_t):<> int = "mac#%"
+fun g0uint_max_size (x: size_t, y: size_t):<> size_t = "mac#%"
+fun g0uint_min_size (x: size_t, y: size_t):<> size_t = "mac#%"
+fun g0uint_isgtz_size (x: size_t):<> bool = "mac#%"
+fun g0uint_iseqz_size (x: size_t):<> bool = "mac#%"
+fun g0uint_isneqz_size (x: size_t):<> bool = "mac#%"
+//
+fun g0int_neg_ssize (x: ssize_t):<> ssize_t = "mac#%"
+fun g0int_abs_ssize (x: ssize_t):<> ssize_t = "mac#%"
+fun g0int_succ_ssize (x: ssize_t):<> ssize_t = "mac#%"
+fun g0int_pred_ssize (x: ssize_t):<> ssize_t = "mac#%"
+fun g0int_half_ssize (x: ssize_t):<> ssize_t = "mac#%"
+fun g0int_asl_ssize (x: ssize_t, n: intGte(0)):<> ssize_t = "mac#%"
+fun g0int_asr_ssize (x: ssize_t, n: intGte(0)):<> ssize_t = "mac#%"
+fun g0int_add_ssize (x: ssize_t, y: ssize_t):<> ssize_t = "mac#%"
+fun g0int_sub_ssize (x: ssize_t, y: ssize_t):<> ssize_t = "mac#%"
+fun g0int_mul_ssize (x: ssize_t, y: ssize_t):<> ssize_t = "mac#%"
+fun g0int_div_ssize (x: ssize_t, y: ssize_t):<> ssize_t = "mac#%"
+fun g0int_mod_ssize (x: ssize_t, y: ssize_t):<> ssize_t = "mac#%"
+fun g0int_lt_ssize (x: ssize_t, y: ssize_t):<> bool = "mac#%"
+fun g0int_lte_ssize (x: ssize_t, y: ssize_t):<> bool = "mac#%"
+fun g0int_gt_ssize (x: ssize_t, y: ssize_t):<> bool = "mac#%"
+fun g0int_gte_ssize (x: ssize_t, y: ssize_t):<> bool = "mac#%"
+fun g0int_eq_ssize (x: ssize_t, y: ssize_t):<> bool = "mac#%"
+fun g0int_neq_ssize (x: ssize_t, y: ssize_t):<> bool = "mac#%"
+fun g0int_compare_ssize (x: ssize_t, y: ssize_t):<> int = "mac#%"
+fun g0int_max_ssize (x: ssize_t, y: ssize_t):<> ssize_t = "mac#%"
+fun g0int_min_ssize (x: ssize_t, y: ssize_t):<> ssize_t = "mac#%"
+fun g0int_isltz_ssize (x: ssize_t):<> bool = "mac#%"
+fun g0int_isltez_ssize (x: ssize_t):<> bool = "mac#%"
+fun g0int_isgtz_ssize (x: ssize_t):<> bool = "mac#%"
+fun g0int_isgtez_ssize (x: ssize_t):<> bool = "mac#%"
+fun g0int_iseqz_ssize (x: ssize_t):<> bool = "mac#%"
+fun g0int_isneqz_ssize (x: ssize_t):<> bool = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+g1int2uint_int_size:
+g1int2uint_type(intknd, sizeknd) = "mac#%"
+fun
+g1uint2uint_uint_size:
+g1uint2uint_type(uintknd, sizeknd) = "mac#%"
+//
+fun
+g1int2int_int_ssize:
+g1int2int_type(intknd, ssizeknd) = "mac#%"
+fun
+g1uint2int_uint_ssize:
+g1uint2int_type(uintknd, ssizeknd) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+g1uint2int_size_int:
+g1uint2int_type(sizeknd, intknd) = "mac#%"
+fun
+g1uint2uint_size_uint:
+g1uint2uint_type(sizeknd, uintknd) = "mac#%"
+//
+fun
+g1uint2uint_size_size:
+g1uint2uint_type(sizeknd, sizeknd) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+g1int2int_ssize_int:
+g1int2int_type(ssizeknd, intknd) = "mac#%"
+fun
+g1int2uint_ssize_uint:
+g1int2uint_type(ssizeknd, uintknd) = "mac#%"
+//
+fun
+g1int2int_ssize_ssize:
+g1int2int_type(ssizeknd, ssizeknd) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun
+g1uint2int_size_ssize:
+g1uint2int_type(sizeknd, ssizeknd) = "mac#%"
+fun
+g1int2uint_ssize_size:
+g1int2uint_type(ssizeknd, sizeknd) = "mac#%"
+//
+(* ****** ****** *)
+//
+fun g1uint_succ_size : g1uint_succ_type (sizeknd) = "mac#%"
+fun g1uint_pred_size : g1uint_pred_type (sizeknd) = "mac#%"
+fun g1uint_half_size : g1uint_half_type (sizeknd) = "mac#%"
+fun g1uint_add_size : g1uint_add_type (sizeknd) = "mac#%"
+fun g1uint_sub_size : g1uint_sub_type (sizeknd) = "mac#%"
+fun g1uint_mul_size : g1uint_mul_type (sizeknd) = "mac#%"
+fun g1uint_div_size : g1uint_div_type (sizeknd) = "mac#%"
+fun g1uint_mod_size : g1uint_mod_type (sizeknd) = "mac#%"
+fun g1uint_lt_size : g1uint_lt_type (sizeknd) = "mac#%"
+fun g1uint_lte_size : g1uint_lte_type (sizeknd) = "mac#%"
+fun g1uint_gt_size : g1uint_gt_type (sizeknd) = "mac#%"
+fun g1uint_gte_size : g1uint_gte_type (sizeknd) = "mac#%"
+fun g1uint_eq_size : g1uint_eq_type (sizeknd) = "mac#%"
+fun g1uint_neq_size : g1uint_neq_type (sizeknd) = "mac#%"
+fun g1uint_compare_size : g1uint_compare_type (sizeknd) = "mac#%"
+fun g1uint_max_size : g1uint_max_type (sizeknd) = "mac#%"
+fun g1uint_min_size : g1uint_min_type (sizeknd) = "mac#%"
+fun g1uint_isgtz_size : g1uint_isgtz_type (sizeknd) = "mac#%"
+fun g1uint_iseqz_size : g1uint_iseqz_type (sizeknd) = "mac#%"
+fun g1uint_isneqz_size : g1uint_isneqz_type (sizeknd) = "mac#%"
+//
+fun g1int_neg_ssize : g1int_neg_type (ssizeknd) = "mac#%"
+fun g1int_abs_ssize : g1int_abs_type (ssizeknd) = "mac#%"
+fun g1int_succ_ssize : g1int_succ_type (ssizeknd) = "mac#%"
+fun g1int_pred_ssize : g1int_pred_type (ssizeknd) = "mac#%"
+fun g1int_half_ssize : g1int_half_type (ssizeknd) = "mac#%"
+fun g1int_add_ssize : g1int_add_type (ssizeknd) = "mac#%"
+fun g1int_sub_ssize : g1int_sub_type (ssizeknd) = "mac#%"
+fun g1int_mul_ssize : g1int_mul_type (ssizeknd) = "mac#%"
+fun g1int_div_ssize : g1int_div_type (ssizeknd) = "mac#%"
+fun g1int_nmod_ssize : g1int_nmod_type (ssizeknd) = "mac#%"
+fun g1int_lt_ssize : g1int_lt_type (ssizeknd) = "mac#%"
+fun g1int_lte_ssize : g1int_lte_type (ssizeknd) = "mac#%"
+fun g1int_gt_ssize : g1int_gt_type (ssizeknd) = "mac#%"
+fun g1int_gte_ssize : g1int_gte_type (ssizeknd) = "mac#%"
+fun g1int_eq_ssize : g1int_eq_type (ssizeknd) = "mac#%"
+fun g1int_neq_ssize : g1int_neq_type (ssizeknd) = "mac#%"
+fun g1int_compare_ssize : g1int_compare_type (ssizeknd) = "mac#%"
+fun g1int_max_ssize : g1int_max_type (ssizeknd) = "mac#%"
+fun g1int_min_ssize : g1int_min_type (ssizeknd) = "mac#%"
+fun g1int_isltz_ssize : g1int_isltz_type (ssizeknd) = "mac#%"
+fun g1int_isltez_ssize : g1int_isltez_type (ssizeknd) = "mac#%"
+fun g1int_isgtz_ssize : g1int_isgtz_type (ssizeknd) = "mac#%"
+fun g1int_isgtez_ssize : g1int_isgtez_type (ssizeknd) = "mac#%"
+fun g1int_iseqz_ssize : g1int_iseqz_type (ssizeknd) = "mac#%"
+fun g1int_isneqz_ssize : g1int_isneqz_type (ssizeknd) = "mac#%"
+//
+(* ****** ****** *)
+//
+macdef i2sz(x) = g1int2uint_int_size(,(x))
+macdef u2sz(x) = g1uint2uint_uint_size(,(x))
+//
+macdef i2ssz(x) = g1int2int_int_ssize(,(x))
+macdef u2ssz(x) = g1uint2int_uint_ssize(,(x))
+//
+(* ****** ****** *)
+//
+symintr sz2i
+overload sz2i with g0uint2int_size_int of 0
+overload sz2i with g1uint2int_size_int of 10
+//
+symintr sz2u
+overload sz2u with g0uint2uint_size_uint of 0
+overload sz2u with g1uint2uint_size_uint of 10
+//
+(* ****** ****** *)
+
+(* end of [integer_size.sats] *)
diff --git a/test/data/stdlib/intrange.out b/test/data/stdlib/intrange.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/intrange.out
@@ -0,0 +1,109 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: June, 2012 *)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/intrange.atxt
+** Time of generation: Thu Jan 11 11:00:06 2018
+*)
+(* ****** ****** *)
+//
+// HX-2013-04:
+// intrange (l, r) is for integers i satisfying l <= i < r
+//
+(* ****** ****** *)
+//
+fun intrange_forall(l : int, r : int) : bool
+
+fun intrange_forall$pred(i : int) :<> bool
+
+//
+(* ****** ****** *)
+//
+fun intrange_foreach(l : int, r : int) : (int)
+
+fun {env:vt0p} intrange_foreach_env ( l : int
+                                    , r : int
+                                    , env : &(env) >> _
+                                    ) : int
+
+//
+fun {env:vt0p} intrange_foreach$cont (i : int, env : &env) : bool
+
+fun {env:vt0p} intrange_foreach$fwork (i : int, env : &(env) >> _) :
+  void
+
+//
+(* ****** ****** *)
+//
+fun intrange_rforeach(l : int, r : int) : (int)
+
+fun {env:vt0p} intrange_rforeach_env ( l : int
+                                     , r : int
+                                     , env : &(env) >> _
+                                     ) : int
+
+//
+fun {env:vt0p} intrange_rforeach$cont (i : int, env : &env) : bool
+
+fun {env:vt0p} intrange_rforeach$fwork (i : int, env : &(env) >> _) :
+  void
+
+//
+(* ****** ****** *)
+//
+fun intrange2_foreach(l1 : int, r1 : int, l2 : int, r2 : int) : void
+
+//
+fun {env:vt0p} intrange2_foreach_env ( l1 : int
+                                     , r1 : int
+                                     , l2 : int
+                                     , r2 : int
+                                     , env : &(env) >> _
+                                     ) : void
+
+//
+fun {env:vt0p} intrange2_foreach$fwork ( i : int
+                                       , j : int
+                                       , env : &env >> _
+                                       ) : void
+
+//
+(* ****** ****** *)
+//
+fun streamize_intrange_l(m : int) : stream_vt(int)
+
+fun streamize_intrange_0r(n : int) : stream_vt(int)
+
+fun streamize_intrange_lr(m : int, n : int) : stream_vt(int)
+
+//
+(* ****** ****** *)
+(* end of [intrange.sats] *)
diff --git a/test/data/stdlib/intrange.sats b/test/data/stdlib/intrange.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/intrange.sats
@@ -0,0 +1,106 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: June, 2012 *)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/intrange.atxt
+** Time of generation: Thu Jan 11 11:00:06 2018
+*)
+
+(* ****** ****** *)
+//
+// HX-2013-04:
+// intrange (l, r) is for integers i satisfying l <= i < r
+//
+(* ****** ****** *)
+//
+fun{}
+intrange_forall
+  (l: int, r: int): bool
+fun{}
+intrange_forall$pred(i: int):<> bool
+//
+(* ****** ****** *)
+//
+fun{}
+intrange_foreach
+  (l: int, r: int): (int)
+fun{env:vt0p}
+intrange_foreach_env
+  (l: int, r: int, env: &(env) >> _): int
+//
+fun{env:vt0p}
+intrange_foreach$cont(i: int, env: &env): bool
+fun{env:vt0p}
+intrange_foreach$fwork(i: int, env: &(env) >> _): void
+//
+(* ****** ****** *)
+//
+fun{}
+intrange_rforeach
+  (l: int, r: int): (int)
+fun{env:vt0p}
+intrange_rforeach_env
+  (l: int, r: int, env: &(env) >> _): int
+//
+fun{env:vt0p}
+intrange_rforeach$cont(i: int, env: &env): bool
+fun{env:vt0p}
+intrange_rforeach$fwork(i: int, env: &(env) >> _): void
+//
+(* ****** ****** *)
+//
+fun{}
+intrange2_foreach
+  (l1: int, r1: int, l2: int, r2: int): void
+//
+fun{env:vt0p}
+intrange2_foreach_env
+  (l1: int, r1: int, l2: int, r2: int, env: &(env) >> _): void
+//
+fun{env:vt0p}
+intrange2_foreach$fwork (i: int, j: int, env: &env >> _): void
+//
+(* ****** ****** *)
+//
+fun{}
+streamize_intrange_l(m: int): stream_vt(int)
+fun{}
+streamize_intrange_0r(n: int): stream_vt(int)
+fun{}
+streamize_intrange_lr(m: int, n: int): stream_vt(int)
+//
+(* ****** ****** *)
+
+(* end of [intrange.sats] *)
diff --git a/test/data/stdlib/option_vt.out b/test/data/stdlib/option_vt.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/option_vt.out
@@ -0,0 +1,107 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/option_vt.atxt
+** Time of generation: Thu Jan 11 11:00:08 2018
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: February, 2012 *)
+(* ****** ****** *)
+sortdef vt0p = vt@ype
+
+(* ****** ****** *)
+
+#if(0)
+//
+// HX: these decls are available in [basic_dyn.sats]
+//
+stadef option_vt = option_vt0ype_bool_vtype
+vtypedef Option_vt (a:vt0p) = [b:bool] option_vt (a, b)
+//
+#endif
+(* ****** ****** *)
+fun {a:vt0p} option_vt_some (x : a) :<!wrt> option_vt(a, true)
+
+fun {a:vt0p} option_vt_none () :<!wrt> option_vt(a, false)
+
+(* ****** ****** *)
+fun {a:vt0p} option_vt_make_opt {b:bool} ( b : bool(b)
+                                         , x : &opt(INV(a), b) >> a?
+                                         ) :<!wrt> option_vt(a, b)
+
+// end-of-fun
+(* ****** ****** *)
+fun option_vt_is_some {a:vt0p}{b:bool} (opt : !option_vt(INV(a), b)) :<>
+  bool(b)
+
+// end of [option_vt_is_some]
+fun option_vt_is_none {a:vt0p}{b:bool} (opt : !option_vt(INV(a), b)) :<>
+  bool(~b)
+
+// end of [option_vt_is_none]
+(* ****** ****** *)
+//
+fun {a:vt0p} option_vt_unsome (opt : option_vt(INV(a), true)) :<!wrt>
+  (a)
+
+//
+fun {a:vt0p} option_vt_unnone (opt : option_vt(INV(a), false)) :<!wrt>
+  void
+
+//
+(* ****** ****** *)
+//
+fun {a:t0p} option_vt_free (opt : Option_vt(INV(a))) :<!wrt> void
+
+fun {a:t0p} option2bool_vt {b:bool} (opt : option_vt(INV(a), b)) :<!wrt>
+  bool(b)
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} fprint_option_vt {b:bool} ( out : FILEref
+                                       , opt : !option_vt(INV(a), b)
+                                       ) : void
+
+//
+overload fprint with fprint_option_vt
+
+//
+(* ****** ****** *)
+//
+// overloading for certain symbols
+//
+(* ****** ****** *)
+overload iseqz with option_vt_is_none
+
+overload isneqz with option_vt_is_some
+
+(* ****** ****** *)
+(* end of [option_vt.sats] *)
diff --git a/test/data/stdlib/option_vt.sats b/test/data/stdlib/option_vt.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/option_vt.sats
@@ -0,0 +1,129 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/option_vt.atxt
+** Time of generation: Thu Jan 11 11:00:08 2018
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: February, 2012 *)
+
+(* ****** ****** *)
+
+sortdef vt0p = viewt@ype
+
+(* ****** ****** *)
+
+#if(0)
+//
+// HX: these decls are available in [basic_dyn.sats]
+//
+stadef option_vt = option_vt0ype_bool_vtype
+vtypedef Option_vt (a:vt0p) = [b:bool] option_vt (a, b)
+//
+#endif
+
+(* ****** ****** *)
+
+fun{a:vt0p}
+option_vt_some (x: a):<!wrt> option_vt (a, true)
+fun{a:vt0p}
+option_vt_none ((*void*)):<!wrt> option_vt (a, false)
+
+(* ****** ****** *)
+
+fun{
+a:vt0p
+} option_vt_make_opt
+  {b:bool}
+(
+  b: bool(b)
+, x: &opt (INV(a), b) >> a?
+) :<!wrt> option_vt(a, b) // end-of-fun
+
+(* ****** ****** *)
+
+fun{}
+option_vt_is_some
+  {a:vt0p}{b:bool}
+  (opt: !option_vt(INV(a), b)):<> bool(b)
+// end of [option_vt_is_some]
+fun{}
+option_vt_is_none
+  {a:vt0p}{b:bool}
+  (opt: !option_vt(INV(a), b)):<> bool(~b)
+// end of [option_vt_is_none]
+
+(* ****** ****** *)
+//
+fun
+{a:vt0p}
+option_vt_unsome
+(opt: option_vt(INV(a), true)):<!wrt> (a)
+//
+fun
+{a:vt0p}
+option_vt_unnone
+(opt: option_vt(INV(a), false)):<!wrt> void
+//
+(* ****** ****** *)
+//
+fun{a:t0p}
+option_vt_free
+  (opt: Option_vt(INV(a))):<!wrt> void
+fun{a:t0p}
+option2bool_vt
+  {b:bool}
+  (opt: option_vt(INV(a), b)):<!wrt> bool(b)
+//
+(* ****** ****** *)
+//
+fun{a:vt0p}
+fprint_option_vt{b:bool}
+(out: FILEref, opt: !option_vt(INV(a), b)): void
+//
+overload fprint with fprint_option_vt
+//
+(* ****** ****** *)
+//
+// overloading for certain symbols
+//
+(* ****** ****** *)
+
+overload iseqz with option_vt_is_none
+overload isneqz with option_vt_is_some
+
+(* ****** ****** *)
+
+(* end of [option_vt.sats] *)
diff --git a/test/data/stdlib/unsafe.out b/test/data/stdlib/unsafe.out
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/unsafe.out
@@ -0,0 +1,332 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+(* ****** ****** *)
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/unsafe.atxt
+** Time of generation: Thu Jan 11 11:00:05 2018
+*)
+(* ****** ****** *)
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: April, 2012 *)
+(* ****** ****** *)
+#define ATS_PACKNAME"ATSLIB.prelude.unsafe"
+
+(* ****** ****** *)
+sortdef t0p = t@ype and vt0p = vt@ype
+
+(* ****** ****** *)
+//
+praxi prop_assert {b:bool} () : [b] void
+
+//
+praxi proof_assert {proof:prop} () : proof
+
+//
+praxi eqint_assert { i1, i2 : int } () : EQINT(i1, i2)
+
+praxi eqaddr_assert { l1, l2 : addr } () : EQADDR(l1, l2)
+
+praxi eqbool_assert { b1, b2 : bool } () : EQBOOL(b1, b2)
+
+//
+(* ****** ****** *)
+//
+castfn cast {to:t0p}{from:t0p} (x : INV(from)) :<> to
+
+//
+(* ****** ****** *)
+//
+castfn castvwtp0 {to:vt0p}{from:vt0p} (x : INV(from)) :<> to
+
+//
+// HX:
+// [castvwtp1] is mostly used in a situation
+// where a linear value is passed as a read-only value;
+// for instance, casting [strptr] to [string] is often
+// done for treating a linear string as a nonlinear one
+// temporarily.
+//
+castfn castvwtp1 {to:vt0p}{from:vt0p} (x : !INV(from) >> from) :<> to
+
+//
+(* ****** ****** *)
+//
+castfn cast2ptr {a:type} (x : INV(a)) :<> ptr
+
+castfn cast2Ptr0 {a:type} (x : INV(a)) :<> Ptr0
+
+castfn cast2Ptr1 {a:type} (x : INV(a)) :<> Ptr1
+
+//
+castfn cast2int {a:t0p} (x : INV(a)) :<> int
+
+castfn cast2uint {a:t0p} (x : INV(a)) :<> uint
+
+//
+castfn cast2lint {a:t0p} (x : INV(a)) :<> lint
+
+castfn cast2ulint {a:t0p} (x : INV(a)) :<> ulint
+
+//
+castfn cast2llint {a:t0p} (x : INV(a)) :<> llint
+
+castfn cast2ullint {a:t0p} (x : INV(a)) :<> ullint
+
+//
+castfn cast2size {a:t0p} (x : INV(a)) :<> size_t
+
+castfn cast2ssize {a:t0p} (x : INV(a)) :<> ssize_t
+
+//
+castfn cast2sint {a:t0p} (x : INV(a)) :<> sint
+
+castfn cast2usint {a:t0p} (x : INV(a)) :<> usint
+
+//
+castfn cast2intptr {a:t0p} (x : INV(a)) :<> intptr
+
+castfn cast2uintptr {a:t0p} (x : INV(a)) :<> uintptr
+
+//
+(* ****** ****** *)
+praxi cast2void {a:vt0p} (x : INV(a)) :<prf> void
+
+(* ****** ****** *)
+//
+praxi castview0 {to:view}{from:view} (pf : from) :<prf> to
+
+praxi castview1 {to:view}{from:view} (pf : !INV(from)) :<prf> to
+
+//
+(* ****** ****** *)
+//
+praxi castview2void {to:view}{from:view} (x : !INV(from) >> to) :<prf>
+  void
+
+praxi castvwtp2void {to:vt0p}{from:vt0p} (x : !INV(from) >> to) :<prf>
+  void
+
+//
+praxi castview2void_at {to:vt0p}{from:vt0p}{l:addr}
+(x : !INV(from @ l) >> to @ l) :<prf> void
+
+//
+(* ****** ****** *)
+fun int2ptr(i : int) : ptr
+
+and ptr2int(p : ptr) : int
+
+(* ****** ****** *)
+//
+// HX: these are popular ones:
+//
+castfn list_vt2t {a:t0p}{n:int} (xs : !list_vt(INV(a), n)) :<>
+  list(a, n)
+
+// end of [list_vt2t]
+castfn arrayptr2ref {a:vt0p}{n:int} (x : !arrayptr(INV(a), n)) :<>
+  arrayref(a, n)
+
+// end of [arrayptr2ref]
+castfn strptr2string {l:agz} (x : !strptr(l)) :<> String0
+
+castfn strptr2stropt {l:addr} (x : !strptr(l)) :<> Stropt0
+
+castfn strnptr2string {l:addr}{n:nat} (x : !strnptr(l, n)) :<> string(n)
+
+(* ****** ****** *)
+//
+// HX: only if you know what you are doing ...
+//
+symintr ptr_vtake
+
+//
+castfn ptr0_vtake {a:vt0p} (p0 : ptr) :<> [l:addr] ( a @ l
+                                                   , a @ l -<lin,prf> void
+                                                   | ptr(l))
+
+castfn ptr1_vtake {a:vt0p}{l:addr} (p0 : ptr(l)) :<> ( a @ l
+                                                     , a @ l -<lin,prf> void
+                                                     | ptr(l))
+
+//
+overload ptr_vtake with ptr0_vtake of 0
+
+overload ptr_vtake with ptr1_vtake of 10
+
+//
+(* ****** ****** *)
+castfn ref_vtake {a:vt0p}{l:addr} (ref : ref(a)) :<> [l:addr] ( a @ l
+                                                              , a @ l -<lin,prf> void
+                                                              | ptr(l))
+
+// end of [ref_vtake]
+(* ****** ****** *)
+praxi vtakeout_void {v:view} (pf : !v) : vtakeout0(v)
+
+castfn vttakeout_void {a:vt0p} (x0 : !a) :<> vttakeout0(a)
+
+(* ****** ****** *)
+//
+// HX: only if you know what you are doing ...
+//
+fun {a:vt0p} ptr0_get (p : ptr) :<> (a)
+
+fun {a:vt0p} ptr1_get (p : Ptr1) :<> (a)
+
+//
+fun {a:vt0p} ptr0_set (p : ptr, x : INV(a)) :<!wrt> void
+
+fun {a:vt0p} ptr1_set (p : Ptr1, x : INV(a)) :<!wrt> void
+
+//
+fun {a:vt0p} ptr0_exch (p : ptr, x : &INV(a) >> a) :<!wrt> void
+
+fun {a:vt0p} ptr1_exch (p : Ptr1, x : &INV(a) >> a) :<!wrt> void
+
+//
+fun {a:vt0p} ptr0_intch (p1 : ptr, p2 : ptr) :<!wrt> void
+
+fun {a:vt0p} ptr1_intch (p1 : Ptr1, p2 : Ptr1) :<!wrt> void
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} ptr0_getinc (p : &ptr >> _) : (a)
+
+fun {a:vt0p} ptr1_getinc {l:addr} (p : &ptr(l) >> ptr(l+sizeof(a))) :
+  (a)
+
+//
+fun {a:vt0p} ptr0_setinc (p : &ptr >> _, x : a) : void
+
+fun {a:vt0p} ptr1_setinc {l:addr} ( p : &ptr(l) >> ptr(l+sizeof(a))
+                                  , x : a
+                                  ) : void
+
+//
+(* ****** ****** *)
+//
+fun {a:vt0p} ptr0_get_at_int (p : ptr, i : int) :<> a
+
+fun {a:vt0p} ptr0_set_at_int (p : ptr, i : int, x : a) :<!wrt> void
+
+//
+fun {a:vt0p} ptr0_get_at_size (p : ptr, i : size_t) :<> a
+
+fun {a:vt0p} ptr0_set_at_size (p : ptr, i : size_t, x : a) :<!wrt> void
+
+//
+symintr ptr0_get_at
+
+symintr ptr0_set_at
+
+//
+overload ptr0_get_at with ptr0_get_at_int
+
+overload ptr0_set_at with ptr0_set_at_int
+
+overload ptr0_get_at with ptr0_get_at_size
+
+overload ptr0_set_at with ptr0_set_at_size
+
+//
+(* ****** ****** *)
+//
+// HX-2012-06:
+// generic ops on numbers: +=, -=, *=, /=, %=
+//
+fun {a:t0p} ptr0_addby (p : ptr, x : a) :<!wrt> void
+
+// !p += x
+fun {a:t0p} ptr1_addby (p : Ptr1, x : a) :<!wrt> void
+
+// !p += x
+//
+fun {a:t0p} ptr0_subby (p : ptr, x : a) :<!wrt> void
+
+// !p -= x
+fun {a:t0p} ptr1_subby (p : Ptr1, x : a) :<!wrt> void
+
+// !p -= x
+//
+fun {a:t0p} ptr0_mulby (p : ptr, x : a) :<!wrt> void
+
+// !p *= x
+fun {a:t0p} ptr1_mulby (p : Ptr1, x : a) :<!wrt> void
+
+// !p *= x
+//
+fun {a:t0p} ptr0_divby (p : ptr, x : a) :<!exnwrt> void
+
+// !p /= x
+fun {a:t0p} ptr1_divby (p : Ptr1, x : a) :<!exnwrt> void
+
+// !p /= x
+//
+fun {a:t0p} ptr0_modby (p : ptr, x : a) :<!exnwrt> void
+
+// !p %= x
+fun {a:t0p} ptr1_modby (p : Ptr1, x : a) :<!exnwrt> void
+
+// !p %= x
+//
+(* ****** ****** *)
+fun {a:vt0p} ptr1_list_next (p : Ptr1) : Ptr0
+
+// HX: &(p->next)
+(* ****** ****** *)
+//
+// HX: only if you know what you are doing ...
+//
+castfn ptr2cptr {a:vt0p}{l:addr} (p : ptr(l)) :<> cptr(a, l)
+
+//
+(* ****** ****** *)
+//
+castfn cptr_vtake {a:vt0p}{l:agz} (cp : cptr(INV(a), l)) :<> ( a @ l
+                                                             , a @ l -<lin,prf> void
+                                                             | ptr(l))
+
+// end of [cptr_vtake]
+//
+fun {a:vt0p} cptr_get (cp : cPtr1(INV(a))) :<> a
+
+fun {a:vt0p} cptr_set (cp : cPtr1(INV(a)), x : a) :<!wrt> void
+
+fun {a:vt0p} cptr_exch (cp : cPtr1(INV(a)), xr : &a >> a) :<!wrt> void
+
+//
+(*
+overload .get with cptr_get
+overload .set with cptr_set
+overload .exch with cptr_exch
+*)
+//
+(* ****** ****** *)
+(* end of [unsafe.sats] *)
diff --git a/test/data/stdlib/unsafe.sats b/test/data/stdlib/unsafe.sats
new file mode 100644
--- /dev/null
+++ b/test/data/stdlib/unsafe.sats
@@ -0,0 +1,314 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                         Applied Type System                         *)
+(*                                                                     *)
+(***********************************************************************)
+
+(*
+** ATS/Postiats - Unleashing the Potential of Types!
+** Copyright (C) 2010-2015 Hongwei Xi, ATS Trustful Software, Inc.
+** All rights reserved
+**
+** ATS is free software;  you can  redistribute it and/or modify it under
+** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
+** Free Software Foundation; either version 3, or (at  your  option)  any
+** later version.
+**
+** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
+** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
+** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
+** for more details.
+**
+** You  should  have  received  a  copy of the GNU General Public License
+** along  with  ATS;  see the  file COPYING.  If not, please write to the
+** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
+** 02110-1301, USA.
+*)
+
+(* ****** ****** *)
+
+(*
+** Source:
+** $PATSHOME/prelude/SATS/CODEGEN/unsafe.atxt
+** Time of generation: Thu Jan 11 11:00:05 2018
+*)
+
+(* ****** ****** *)
+
+(* Author: Hongwei Xi *)
+(* Authoremail: hwxi AT cs DOT bu DOT edu *)
+(* Start time: April, 2012 *)
+
+(* ****** ****** *)
+
+#define
+ATS_PACKNAME "ATSLIB.prelude.unsafe"
+
+(* ****** ****** *)
+
+sortdef t0p = t@ype and vt0p = viewt@ype
+
+(* ****** ****** *)
+//
+praxi
+prop_assert{b:bool}((*void*)): [b] void
+//
+praxi
+proof_assert{proof:prop}((*void*)): proof
+//
+praxi
+eqint_assert{i1,i2:int}((*void*)): EQINT(i1,i2)
+praxi
+eqaddr_assert{l1,l2:addr}((*void*)): EQADDR(l1,l2)
+praxi
+eqbool_assert{b1,b2:bool}((*void*)): EQBOOL(b1,b2)
+//
+(* ****** ****** *)
+//
+castfn
+cast{to:t0p}{from:t0p} (x: INV(from)):<> to
+//
+(* ****** ****** *)
+//
+castfn
+castvwtp0
+  {to:vt0p}{from:vt0p} (x: INV(from)):<> to
+//
+// HX:
+// [castvwtp1] is mostly used in a situation
+// where a linear value is passed as a read-only value;
+// for instance, casting [strptr] to [string] is often
+// done for treating a linear string as a nonlinear one
+// temporarily.
+//
+castfn
+castvwtp1
+  {to:vt0p}{from:vt0p} (x: !INV(from)>>from):<> to
+//
+(* ****** ****** *)
+//
+castfn cast2ptr {a:type} (x: INV(a)):<> ptr
+castfn cast2Ptr0 {a:type} (x: INV(a)):<> Ptr0
+castfn cast2Ptr1 {a:type} (x: INV(a)):<> Ptr1
+//
+castfn cast2int {a:t0p} (x: INV(a)):<> int
+castfn cast2uint {a:t0p} (x: INV(a)):<> uint
+//
+castfn cast2lint {a:t0p} (x: INV(a)):<> lint
+castfn cast2ulint {a:t0p} (x: INV(a)):<> ulint
+//
+castfn cast2llint {a:t0p} (x: INV(a)):<> llint
+castfn cast2ullint {a:t0p} (x: INV(a)):<> ullint
+//
+castfn cast2size {a:t0p} (x: INV(a)):<> size_t
+castfn cast2ssize {a:t0p} (x: INV(a)):<> ssize_t
+//
+castfn cast2sint {a:t0p} (x: INV(a)):<> sint
+castfn cast2usint {a:t0p} (x: INV(a)):<> usint
+//
+castfn cast2intptr {a:t0p} (x: INV(a)):<> intptr
+castfn cast2uintptr {a:t0p} (x: INV(a)):<> uintptr
+//
+(* ****** ****** *)
+
+praxi cast2void{a:vt0p}(x: INV(a)):<prf> void
+
+(* ****** ****** *)
+//
+praxi castview0 {to:view}{from:view} (pf: from):<prf> to
+praxi castview1 {to:view}{from:view} (pf: !INV(from)):<prf> to
+//
+(* ****** ****** *)
+//
+praxi
+castview2void
+  {to:view}{from:view}(x: !INV(from) >> to):<prf> void
+praxi
+castvwtp2void
+  {to:vt0p}{from:vt0p}(x: !INV(from) >> to):<prf> void
+//
+praxi
+castview2void_at
+  {to:vt0p}{from:vt0p}{l:addr}(x: !INV(from@l) >> to@l):<prf> void
+//
+(* ****** ****** *)
+
+fun{} int2ptr (i: int): ptr and ptr2int (p: ptr): int
+
+(* ****** ****** *)
+//
+// HX: these are popular ones:
+//
+castfn list_vt2t
+  {a:t0p}{n:int} (xs: !list_vt(INV(a), n)):<> list(a, n)
+// end of [list_vt2t]
+
+castfn arrayptr2ref
+  {a:vt0p}{n:int} (x: !arrayptr (INV(a), n)):<> arrayref(a, n)
+// end of [arrayptr2ref]
+
+castfn strptr2string{l:agz}(x: !strptr(l)):<> String0
+castfn strptr2stropt{l:addr}(x: !strptr(l)):<> Stropt0
+castfn strnptr2string{l:addr}{n:nat}(x: !strnptr(l, n)):<> string(n)
+
+(* ****** ****** *)
+//
+// HX: only if you know what you are doing ...
+//
+symintr ptr_vtake
+//
+castfn
+ptr0_vtake
+  {a:vt0p}
+(
+  p0: ptr
+) :<> [l:addr] (a@l, a@l -<lin,prf> void | ptr(l))
+castfn
+ptr1_vtake
+  {a:vt0p}{l:addr}
+  (p0: ptr(l)):<> (a@l, a@l -<lin,prf> void | ptr(l))
+//
+overload ptr_vtake with ptr0_vtake of 0
+overload ptr_vtake with ptr1_vtake of 10
+//
+(* ****** ****** *)
+
+castfn
+ref_vtake
+{a:vt0p}
+{l:addr}
+(
+  ref: ref(a)
+) :<>
+[
+  l:addr
+] (a@l, a@l -<lin,prf> void | ptr(l))
+// end of [ref_vtake]
+
+(* ****** ****** *)
+
+praxi
+vtakeout_void{v:view}(pf: !v): vtakeout0(v)
+castfn
+vttakeout_void{a:vt0p}(x0: !a):<> vttakeout0(a)
+
+(* ****** ****** *)
+//
+// HX: only if you know what you are doing ...
+//
+fun{a:vt0p} ptr0_get(p: ptr):<> (a)
+fun{a:vt0p} ptr1_get(p: Ptr1):<> (a)
+//
+fun{a:vt0p} ptr0_set(p: ptr, x: INV(a)):<!wrt> void
+fun{a:vt0p} ptr1_set(p: Ptr1, x: INV(a)):<!wrt> void
+//
+fun{a:vt0p} ptr0_exch(p: ptr, x: &INV(a) >> a):<!wrt> void
+fun{a:vt0p} ptr1_exch(p: Ptr1, x: &INV(a) >> a):<!wrt> void
+//
+fun{a:vt0p} ptr0_intch(p1: ptr, p2: ptr):<!wrt> void
+fun{a:vt0p} ptr1_intch(p1: Ptr1, p2: Ptr1):<!wrt> void
+//
+(* ****** ****** *)
+//
+fun{a:vt0p}
+ptr0_getinc(p: &ptr >> _): (a)
+fun{a:vt0p}
+ptr1_getinc{l:addr}(p: &ptr(l) >> ptr(l+sizeof(a))): (a)
+//
+fun{a:vt0p}
+ptr0_setinc(p: &ptr >> _, x: a): void
+fun{a:vt0p}
+ptr1_setinc{l:addr}(p: &ptr(l) >> ptr(l+sizeof(a)), x: a): void
+//
+(* ****** ****** *)
+//
+fun{a:vt0p}
+ptr0_get_at_int(p: ptr, i: int):<> a
+fun{a:vt0p}
+ptr0_set_at_int(p: ptr, i: int, x: a):<!wrt> void
+//
+fun{a:vt0p}
+ptr0_get_at_size(p: ptr, i: size_t):<> a
+fun{a:vt0p}
+ptr0_set_at_size(p: ptr, i: size_t, x: a):<!wrt> void
+//
+symintr ptr0_get_at
+symintr ptr0_set_at
+//
+overload ptr0_get_at with ptr0_get_at_int
+overload ptr0_set_at with ptr0_set_at_int
+overload ptr0_get_at with ptr0_get_at_size
+overload ptr0_set_at with ptr0_set_at_size
+//
+(* ****** ****** *)
+//
+// HX-2012-06:
+// generic ops on numbers: +=, -=, *=, /=, %=
+//
+fun{a:t0p}
+ptr0_addby(p: ptr, x: a):<!wrt> void // !p += x
+fun{a:t0p}
+ptr1_addby(p: Ptr1, x: a):<!wrt> void // !p += x
+//
+fun{a:t0p}
+ptr0_subby(p: ptr, x: a):<!wrt> void // !p -= x
+fun{a:t0p}
+ptr1_subby(p: Ptr1, x: a):<!wrt> void // !p -= x
+//
+fun{a:t0p}
+ptr0_mulby(p: ptr, x: a):<!wrt> void // !p *= x
+fun{a:t0p}
+ptr1_mulby(p: Ptr1, x: a):<!wrt> void // !p *= x
+//
+fun{a:t0p}
+ptr0_divby(p: ptr, x: a):<!exnwrt> void // !p /= x
+fun{a:t0p}
+ptr1_divby(p: Ptr1, x: a):<!exnwrt> void // !p /= x
+//
+fun{a:t0p}
+ptr0_modby(p: ptr, x: a):<!exnwrt> void // !p %= x
+fun{a:t0p}
+ptr1_modby(p: Ptr1, x: a):<!exnwrt> void // !p %= x
+//
+(* ****** ****** *)
+
+fun
+{a:vt0p}
+ptr1_list_next(p: Ptr1): Ptr0 // HX: &(p->next)
+
+(* ****** ****** *)
+//
+// HX: only if you know what you are doing ...
+//
+castfn
+ptr2cptr{a:vt0p}{l:addr}(p: ptr(l)):<> cptr(a, l)
+//
+(* ****** ****** *)
+//
+castfn
+cptr_vtake
+  {a:vt0p}{l:agz}
+(
+  cp: cptr(INV(a), l)
+) :<> (a@l, a@l -<lin,prf> void | ptr l)
+// end of [cptr_vtake]
+//
+fun
+{a:vt0p}
+cptr_get(cp: cPtr1(INV(a))):<> a
+fun
+{a:vt0p}
+cptr_set(cp: cPtr1(INV(a)), x: a):<!wrt> void
+fun
+{a:vt0p}
+cptr_exch(cp: cPtr1(INV(a)), xr: &a >> a):<!wrt> void
+//
+(*
+overload .get with cptr_get
+overload .set with cptr_set
+overload .exch with cptr_exch
+*)
+//
+(* ****** ****** *)
+
+(* end of [unsafe.sats] *)
