src/HOL/HOL.thy
changeset 24219 e558fe311376
parent 24166 7b28dc69bdbb
child 24280 c9867bdf2424
equal deleted inserted replaced
24218:fbf1646b267c 24219:e558fe311376
   181 axioms
   181 axioms
   182   iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
   182   iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
   183   True_or_False:  "(P=True) | (P=False)"
   183   True_or_False:  "(P=True) | (P=False)"
   184 
   184 
   185 defs
   185 defs
   186   Let_def [code func]: "Let s f == f(s)"
   186   Let_def:      "Let s f == f(s)"
   187   if_def:       "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)"
   187   if_def:       "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)"
   188 
   188 
   189 finalconsts
   189 finalconsts
   190   "op ="
   190   "op ="
   191   "op -->"
   191   "op -->"
  1699 *} "solve goal by evaluation"
  1699 *} "solve goal by evaluation"
  1700 
  1700 
  1701 
  1701 
  1702 subsubsection {* Generic code generator setup *}
  1702 subsubsection {* Generic code generator setup *}
  1703 
  1703 
       
  1704 setup "CodeName.setup #> CodeTarget.setup"
       
  1705 
  1704 text {* operational equality for code generation *}
  1706 text {* operational equality for code generation *}
  1705 
  1707 
  1706 class eq (attach "op =") = type
  1708 class eq (attach "op =") = type
  1707 
  1709 
  1708 
  1710 
  1734 lemma [code func]:
  1736 lemma [code func]:
  1735   shows "(\<not> True) = False"
  1737   shows "(\<not> True) = False"
  1736     and "(\<not> False) = True" by (rule HOL.simp_thms)+
  1738     and "(\<not> False) = True" by (rule HOL.simp_thms)+
  1737 
  1739 
  1738 lemmas [code] = imp_conv_disj
  1740 lemmas [code] = imp_conv_disj
  1739 
       
  1740 lemmas [code func] = if_True if_False
       
  1741 
  1741 
  1742 instance bool :: eq ..
  1742 instance bool :: eq ..
  1743 
  1743 
  1744 lemma [code func]:
  1744 lemma [code func]:
  1745   shows "True = P \<longleftrightarrow> P"
  1745   shows "True = P \<longleftrightarrow> P"
  1794   (Haskell "error/ \"undefined\"")
  1794   (Haskell "error/ \"undefined\"")
  1795 
  1795 
  1796 
  1796 
  1797 text {* Let and If *}
  1797 text {* Let and If *}
  1798 
  1798 
       
  1799 lemmas [code func] = Let_def if_True if_False
       
  1800 
  1799 setup {*
  1801 setup {*
  1800   CodegenPackage.add_appconst (@{const_name Let}, CodegenPackage.appgen_let)
  1802   CodePackage.add_appconst (@{const_name Let}, CodePackage.appgen_let)
  1801   #> CodegenPackage.add_appconst (@{const_name If}, CodegenPackage.appgen_if)
  1803   #> CodePackage.add_appconst (@{const_name If}, CodePackage.appgen_if)
  1802 *}
  1804 *}
  1803 
  1805 
       
  1806 
  1804 subsubsection {* Evaluation oracle *}
  1807 subsubsection {* Evaluation oracle *}
  1805 
  1808 
  1806 oracle eval_oracle ("term") = {* fn thy => fn t => 
  1809 oracle eval_oracle ("term") = {* fn thy => fn t => 
  1807   if CodegenPackage.satisfies thy (HOLogic.dest_Trueprop t) [] 
  1810   if CodePackage.satisfies thy (HOLogic.dest_Trueprop t) [] 
  1808   then t
  1811   then t
  1809   else HOLogic.Trueprop $ HOLogic.true_const (*dummy*)
  1812   else HOLogic.Trueprop $ HOLogic.true_const (*dummy*)
  1810 *}
  1813 *}
  1811 
  1814 
  1812 method_setup eval = {*
  1815 method_setup eval = {*