src/HOL/HOL.thy
changeset 28513 b0b30fd6c264
parent 28400 89904cfd41c3
child 28562 4e74209f113e
equal deleted inserted replaced
28512:f29fecd6ddaa 28513:b0b30fd6c264
    59 
    59 
    60 consts
    60 consts
    61   Not           :: "bool => bool"                   ("~ _" [40] 40)
    61   Not           :: "bool => bool"                   ("~ _" [40] 40)
    62   True          :: bool
    62   True          :: bool
    63   False         :: bool
    63   False         :: bool
    64   arbitrary     :: 'a
       
    65 
    64 
    66   The           :: "('a => bool) => 'a"
    65   The           :: "('a => bool) => 'a"
    67   All           :: "('a => bool) => bool"           (binder "ALL " 10)
    66   All           :: "('a => bool) => bool"           (binder "ALL " 10)
    68   Ex            :: "('a => bool) => bool"           (binder "EX " 10)
    67   Ex            :: "('a => bool) => bool"           (binder "EX " 10)
    69   Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
    68   Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
   162 
   161 
   163 
   162 
   164 subsubsection {* Axioms and basic definitions *}
   163 subsubsection {* Axioms and basic definitions *}
   165 
   164 
   166 axioms
   165 axioms
   167   eq_reflection:  "(x=y) ==> (x==y)"
       
   168 
       
   169   refl:           "t = (t::'a)"
   166   refl:           "t = (t::'a)"
   170 
   167   subst:          "s = t \<Longrightarrow> P s \<Longrightarrow> P t"
   171   ext:            "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
   168   ext:            "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
   172     -- {*Extensionality is built into the meta-logic, and this rule expresses
   169     -- {*Extensionality is built into the meta-logic, and this rule expresses
   173          a related property.  It is an eta-expanded version of the traditional
   170          a related property.  It is an eta-expanded version of the traditional
   174          rule, and similar to the ABS rule of HOL*}
   171          rule, and similar to the ABS rule of HOL*}
   175 
   172 
   199 
   196 
   200 finalconsts
   197 finalconsts
   201   "op ="
   198   "op ="
   202   "op -->"
   199   "op -->"
   203   The
   200   The
   204   arbitrary
       
   205 
   201 
   206 axiomatization
   202 axiomatization
   207   undefined :: 'a
   203   undefined :: 'a
   208 
   204 
   209 axiomatization where
   205 consts
   210   undefined_fun: "undefined x = undefined"
   206   arbitrary :: 'a
       
   207 
       
   208 finalconsts
       
   209   arbitrary
   211 
   210 
   212 
   211 
   213 subsubsection {* Generic classes and algebraic operations *}
   212 subsubsection {* Generic classes and algebraic operations *}
   214 
   213 
   215 class default = type +
   214 class default = type +
   301 
   300 
   302 
   301 
   303 subsection {* Fundamental rules *}
   302 subsection {* Fundamental rules *}
   304 
   303 
   305 subsubsection {* Equality *}
   304 subsubsection {* Equality *}
   306 
       
   307 text {* Thanks to Stephan Merz *}
       
   308 lemma subst:
       
   309   assumes eq: "s = t" and p: "P s"
       
   310   shows "P t"
       
   311 proof -
       
   312   from eq have meta: "s \<equiv> t"
       
   313     by (rule eq_reflection)
       
   314   from p show ?thesis
       
   315     by (unfold meta)
       
   316 qed
       
   317 
   305 
   318 lemma sym: "s = t ==> t = s"
   306 lemma sym: "s = t ==> t = s"
   319   by (erule subst) (rule refl)
   307   by (erule subst) (rule refl)
   320 
   308 
   321 lemma ssubst: "t = s ==> P s ==> P t"
   309 lemma ssubst: "t = s ==> P s ==> P t"
   818 
   806 
   819 use "hologic.ML"
   807 use "hologic.ML"
   820 
   808 
   821 
   809 
   822 subsubsection {* Atomizing meta-level connectives *}
   810 subsubsection {* Atomizing meta-level connectives *}
       
   811 
       
   812 axiomatization where
       
   813   eq_reflection: "x = y \<Longrightarrow> x \<equiv> y" (*admissible axiom*)
   823 
   814 
   824 lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)"
   815 lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)"
   825 proof
   816 proof
   826   assume "!!x. P x"
   817   assume "!!x. P x"
   827   then show "ALL x. P x" ..
   818   then show "ALL x. P x" ..
  1679 *}
  1670 *}
  1680 
  1671 
  1681 
  1672 
  1682 subsection {* Code generator basics -- see further theory @{text "Code_Setup"} *}
  1673 subsection {* Code generator basics -- see further theory @{text "Code_Setup"} *}
  1683 
  1674 
       
  1675 text {* Equality *}
       
  1676 
       
  1677 class eq = type +
       
  1678   fixes eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
       
  1679   assumes eq_equals: "eq x y \<longleftrightarrow> x = y"
       
  1680 begin
       
  1681 
       
  1682 lemma eq: "eq = (op =)"
       
  1683   by (rule ext eq_equals)+
       
  1684 
       
  1685 lemma eq_refl: "eq x x \<longleftrightarrow> True"
       
  1686   unfolding eq by rule+
       
  1687 
       
  1688 end
       
  1689 
  1684 text {* Module setup *}
  1690 text {* Module setup *}
  1685 
  1691 
  1686 use "~~/src/HOL/Tools/recfun_codegen.ML"
  1692 use "~~/src/HOL/Tools/recfun_codegen.ML"
  1687 
  1693 
  1688 setup {*
  1694 setup {*
  1691   #> Code_Haskell.setup
  1697   #> Code_Haskell.setup
  1692   #> Nbe.setup
  1698   #> Nbe.setup
  1693   #> Codegen.setup
  1699   #> Codegen.setup
  1694   #> RecfunCodegen.setup
  1700   #> RecfunCodegen.setup
  1695 *}
  1701 *}
  1696 
       
  1697 
       
  1698 text {* Equality *}
       
  1699 
       
  1700 class eq = type +
       
  1701   fixes eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
       
  1702   assumes eq_equals: "eq x y \<longleftrightarrow> x = y"
       
  1703 begin
       
  1704 
       
  1705 lemma eq: "eq = (op =)"
       
  1706   by (rule ext eq_equals)+
       
  1707 
       
  1708 lemma eq_refl: "eq x x \<longleftrightarrow> True"
       
  1709   unfolding eq by rule+
       
  1710 
       
  1711 end
       
  1712 
  1702 
  1713 
  1703 
  1714 subsection {* Legacy tactics and ML bindings *}
  1704 subsection {* Legacy tactics and ML bindings *}
  1715 
  1705 
  1716 ML {*
  1706 ML {*