src/HOL/HOL.thy
changeset 52435 6646bb548c6b
parent 52432 c03090937c3b
child 52641 c56b6fa636e8
equal deleted inserted replaced
52434:cbb94074682b 52435:6646bb548c6b
  1828 
  1828 
  1829 subsubsection {* Generic code generator target languages *}
  1829 subsubsection {* Generic code generator target languages *}
  1830 
  1830 
  1831 text {* type @{typ bool} *}
  1831 text {* type @{typ bool} *}
  1832 
  1832 
  1833 code_type bool
  1833 code_printing
  1834   (SML "bool")
  1834   type_constructor bool \<rightharpoonup>
  1835   (OCaml "bool")
  1835     (SML) "bool" and (OCaml) "bool" and (Haskell) "Bool" and (Scala) "Boolean"
  1836   (Haskell "Bool")
  1836 | constant True \<rightharpoonup>
  1837   (Scala "Boolean")
  1837     (SML) "true" and (OCaml) "true" and (Haskell) "True" and (Scala) "true"
  1838 
  1838 | constant False \<rightharpoonup>
  1839 code_const True and False and Not and HOL.conj and HOL.disj and HOL.implies and If 
  1839     (SML) "false" and (OCaml) "false" and (Haskell) "False" and (Scala) "false" 
  1840   (SML "true" and "false" and "not"
       
  1841     and infixl 1 "andalso" and infixl 0 "orelse"
       
  1842     and "!(if (_)/ then (_)/ else true)"
       
  1843     and "!(if (_)/ then (_)/ else (_))")
       
  1844   (OCaml "true" and "false" and "not"
       
  1845     and infixl 3 "&&" and infixl 2 "||"
       
  1846     and "!(if (_)/ then (_)/ else true)"
       
  1847     and "!(if (_)/ then (_)/ else (_))")
       
  1848   (Haskell "True" and "False" and "not"
       
  1849     and infixr 3 "&&" and infixr 2 "||"
       
  1850     and "!(if (_)/ then (_)/ else True)"
       
  1851     and "!(if (_)/ then (_)/ else (_))")
       
  1852   (Scala "true" and "false" and "'! _"
       
  1853     and infixl 3 "&&" and infixl 1 "||"
       
  1854     and "!(if ((_))/ (_)/ else true)"
       
  1855     and "!(if ((_))/ (_)/ else (_))")
       
  1856 
  1840 
  1857 code_reserved SML
  1841 code_reserved SML
  1858   bool true false not
  1842   bool true false
  1859 
  1843 
  1860 code_reserved OCaml
  1844 code_reserved OCaml
  1861   bool not
  1845   bool
  1862 
  1846 
  1863 code_reserved Scala
  1847 code_reserved Scala
  1864   Boolean
  1848   Boolean
  1865 
  1849 
  1866 code_modulename SML Pure HOL
  1850 code_printing
  1867 code_modulename OCaml Pure HOL
  1851   constant Not \<rightharpoonup>
  1868 code_modulename Haskell Pure HOL
  1852     (SML) "not" and (OCaml) "not" and (Haskell) "not" and (Scala) "'! _"
       
  1853 | constant HOL.conj \<rightharpoonup>
       
  1854     (SML) infixl 1 "andalso" and (OCaml) infixl 3 "&&" and (Haskell) infixr 3 "&&" and (Scala) infixl 3 "&&"
       
  1855 | constant HOL.disj \<rightharpoonup>
       
  1856     (SML) infixl 0 "orelse" and (OCaml) infixl 2 "||" and (Haskell) infixl 2 "||" and (Scala) infixl 1 "||"
       
  1857 | constant HOL.implies \<rightharpoonup>
       
  1858     (SML) "!(if (_)/ then (_)/ else true)"
       
  1859     and (OCaml) "!(if (_)/ then (_)/ else true)"
       
  1860     and (Haskell) "!(if (_)/ then (_)/ else True)"
       
  1861     and (Scala) "!(if ((_))/ (_)/ else true)"
       
  1862 | constant If \<rightharpoonup>
       
  1863     (SML) "!(if (_)/ then (_)/ else (_))"
       
  1864     and (OCaml) "!(if (_)/ then (_)/ else (_))"
       
  1865     and (Haskell) "!(if (_)/ then (_)/ else (_))"
       
  1866     and (Scala) "!(if ((_))/ (_)/ else (_))"
       
  1867 
       
  1868 code_reserved SML
       
  1869   not
       
  1870 
       
  1871 code_reserved OCaml
       
  1872   not
       
  1873 
       
  1874 code_identifier
       
  1875   code_module Pure \<rightharpoonup>
       
  1876     (SML) HOL and (OCaml) HOL and (Haskell) HOL and (Scala) HOL
  1869 
  1877 
  1870 text {* using built-in Haskell equality *}
  1878 text {* using built-in Haskell equality *}
  1871 
  1879 
  1872 code_class equal
  1880 code_printing
  1873   (Haskell "Eq")
  1881   type_class equal \<rightharpoonup> (Haskell) "Eq"
  1874 
  1882 | constant HOL.equal \<rightharpoonup> (Haskell) infix 4 "=="
  1875 code_const "HOL.equal"
  1883 | constant HOL.eq \<rightharpoonup> (Haskell) infix 4 "=="
  1876   (Haskell infix 4 "==")
       
  1877 
       
  1878 code_const HOL.eq
       
  1879   (Haskell infix 4 "==")
       
  1880 
  1884 
  1881 text {* undefined *}
  1885 text {* undefined *}
  1882 
  1886 
  1883 code_const undefined
  1887 code_printing
  1884   (SML "!(raise/ Fail/ \"undefined\")")
  1888   constant undefined \<rightharpoonup>
  1885   (OCaml "failwith/ \"undefined\"")
  1889     (SML) "!(raise/ Fail/ \"undefined\")"
  1886   (Haskell "error/ \"undefined\"")
  1890     and (OCaml) "failwith/ \"undefined\""
  1887   (Scala "!sys.error(\"undefined\")")
  1891     and (Haskell) "error/ \"undefined\""
       
  1892     and (Scala) "!sys.error(\"undefined\")"
       
  1893 
  1888 
  1894 
  1889 subsubsection {* Evaluation and normalization by evaluation *}
  1895 subsubsection {* Evaluation and normalization by evaluation *}
  1890 
  1896 
  1891 ML {*
  1897 ML {*
  1892 fun eval_tac ctxt =
  1898 fun eval_tac ctxt =