src/HOL/Import/HOL4Setup.thy
author skalberg
Fri Apr 02 17:37:45 2004 +0200 (2004-04-02)
changeset 14516 a183dec876ab
child 14620 1be590fd2422
permissions -rw-r--r--
Added HOL proof importer.
skalberg@14516
     1
theory HOL4Setup = MakeEqual
skalberg@14516
     2
  files ("proof_kernel.ML") ("replay.ML") ("hol4rews.ML") ("import_package.ML"):
skalberg@14516
     3
skalberg@14516
     4
section {* General Setup *}
skalberg@14516
     5
skalberg@14516
     6
lemma eq_imp: "P = Q \<Longrightarrow> P \<longrightarrow> Q"
skalberg@14516
     7
  by auto
skalberg@14516
     8
skalberg@14516
     9
lemma HOLallI: "(!! bogus. P bogus) \<Longrightarrow> (ALL bogus. P bogus)"
skalberg@14516
    10
proof -
skalberg@14516
    11
  assume "!! bogus. P bogus"
skalberg@14516
    12
  thus "ALL x. P x"
skalberg@14516
    13
    ..
skalberg@14516
    14
qed
skalberg@14516
    15
skalberg@14516
    16
consts
skalberg@14516
    17
  ONE_ONE :: "('a => 'b) => bool"
skalberg@14516
    18
  ONTO    :: "('a => 'b) => bool"
skalberg@14516
    19
skalberg@14516
    20
defs
skalberg@14516
    21
  ONE_ONE_DEF: "ONE_ONE f == ALL x y. f x = f y --> x = y"
skalberg@14516
    22
  ONTO_DEF   : "ONTO f == ALL y. EX x. y = f x"
skalberg@14516
    23
skalberg@14516
    24
lemma ONE_ONE_rew: "ONE_ONE f = inj_on f UNIV"
skalberg@14516
    25
  by (simp add: ONE_ONE_DEF inj_on_def)
skalberg@14516
    26
skalberg@14516
    27
lemma INFINITY_AX: "EX (f::ind \<Rightarrow> ind). (inj f & ~(ONTO f))"
skalberg@14516
    28
proof (rule exI,safe)
skalberg@14516
    29
  show "inj Suc_Rep"
skalberg@14516
    30
    by (rule inj_Suc_Rep)
skalberg@14516
    31
next
skalberg@14516
    32
  assume "ONTO Suc_Rep"
skalberg@14516
    33
  hence "ALL y. EX x. y = Suc_Rep x"
skalberg@14516
    34
    by (simp add: ONTO_DEF surj_def)
skalberg@14516
    35
  hence "EX x. Zero_Rep = Suc_Rep x"
skalberg@14516
    36
    by (rule spec)
skalberg@14516
    37
  thus False
skalberg@14516
    38
  proof (rule exE)
skalberg@14516
    39
    fix x
skalberg@14516
    40
    assume "Zero_Rep = Suc_Rep x"
skalberg@14516
    41
    hence "Suc_Rep x = Zero_Rep"
skalberg@14516
    42
      ..
skalberg@14516
    43
    with Suc_Rep_not_Zero_Rep
skalberg@14516
    44
    show False
skalberg@14516
    45
      ..
skalberg@14516
    46
  qed
skalberg@14516
    47
qed
skalberg@14516
    48
skalberg@14516
    49
lemma EXISTS_DEF: "Ex P = P (Eps P)"
skalberg@14516
    50
proof (rule iffI)
skalberg@14516
    51
  assume "Ex P"
skalberg@14516
    52
  thus "P (Eps P)"
skalberg@14516
    53
    ..
skalberg@14516
    54
next
skalberg@14516
    55
  assume "P (Eps P)"
skalberg@14516
    56
  thus "Ex P"
skalberg@14516
    57
    ..
skalberg@14516
    58
qed
skalberg@14516
    59
skalberg@14516
    60
consts
skalberg@14516
    61
  TYPE_DEFINITION :: "('a => bool) => ('b => 'a) => bool"
skalberg@14516
    62
skalberg@14516
    63
defs
skalberg@14516
    64
  TYPE_DEFINITION: "TYPE_DEFINITION p rep == ((ALL x y. (rep x = rep y) --> (x = y)) & (ALL x. (p x = (EX y. x = rep y))))"
skalberg@14516
    65
skalberg@14516
    66
lemma ex_imp_nonempty: "Ex P ==> EX x. x : (Collect P)"
skalberg@14516
    67
  by simp
skalberg@14516
    68
skalberg@14516
    69
lemma light_ex_imp_nonempty: "P t ==> EX x. x : (Collect P)"
skalberg@14516
    70
proof -
skalberg@14516
    71
  assume "P t"
skalberg@14516
    72
  hence "EX x. P x"
skalberg@14516
    73
    ..
skalberg@14516
    74
  thus ?thesis
skalberg@14516
    75
    by (rule ex_imp_nonempty)
skalberg@14516
    76
qed
skalberg@14516
    77
skalberg@14516
    78
lemma light_imp_as: "[| Q --> P; P --> Q |] ==> P = Q"
skalberg@14516
    79
  by blast
skalberg@14516
    80
skalberg@14516
    81
lemma typedef_hol2hol4:
skalberg@14516
    82
  assumes a: "type_definition (Rep::'a=>'b) Abs (Collect P)"
skalberg@14516
    83
  shows "EX rep. TYPE_DEFINITION P (rep::'a=>'b)"
skalberg@14516
    84
proof -
skalberg@14516
    85
  from a
skalberg@14516
    86
  have td: "(ALL x. P (Rep x)) & (ALL x. Abs (Rep x) = x) & (ALL y. P y \<longrightarrow> Rep (Abs y) = y)"
skalberg@14516
    87
    by (simp add: type_definition_def)
skalberg@14516
    88
  have ed: "TYPE_DEFINITION P Rep"
skalberg@14516
    89
  proof (auto simp add: TYPE_DEFINITION)
skalberg@14516
    90
    fix x y
skalberg@14516
    91
    assume "Rep x = Rep y"
skalberg@14516
    92
    from td have "x = Abs (Rep x)"
skalberg@14516
    93
      by auto
skalberg@14516
    94
    also have "Abs (Rep x) = Abs (Rep y)"
skalberg@14516
    95
      by (simp add: prems)
skalberg@14516
    96
    also from td have "Abs (Rep y) = y"
skalberg@14516
    97
      by auto
skalberg@14516
    98
    finally show "x = y" .
skalberg@14516
    99
  next
skalberg@14516
   100
    fix x
skalberg@14516
   101
    assume "P x"
skalberg@14516
   102
    with td
skalberg@14516
   103
    have "Rep (Abs x) = x"
skalberg@14516
   104
      by auto
skalberg@14516
   105
    hence "x = Rep (Abs x)"
skalberg@14516
   106
      ..
skalberg@14516
   107
    thus "EX y. x = Rep y"
skalberg@14516
   108
      ..
skalberg@14516
   109
  next
skalberg@14516
   110
    fix y
skalberg@14516
   111
    from td
skalberg@14516
   112
    show "P (Rep y)"
skalberg@14516
   113
      by auto
skalberg@14516
   114
  qed
skalberg@14516
   115
  show ?thesis
skalberg@14516
   116
    apply (rule exI [of _ Rep])
skalberg@14516
   117
    apply (rule ed)
skalberg@14516
   118
    .
skalberg@14516
   119
qed
skalberg@14516
   120
skalberg@14516
   121
lemma typedef_hol2hollight:
skalberg@14516
   122
  assumes a: "type_definition (Rep::'a=>'b) Abs (Collect P)"
skalberg@14516
   123
  shows "(Abs (Rep a) = a) & (P r = (Rep (Abs r) = r))"
skalberg@14516
   124
proof
skalberg@14516
   125
  from a
skalberg@14516
   126
  show "Abs (Rep a) = a"
skalberg@14516
   127
    by (rule type_definition.Rep_inverse)
skalberg@14516
   128
next
skalberg@14516
   129
  show "P r = (Rep (Abs r) = r)"
skalberg@14516
   130
  proof
skalberg@14516
   131
    assume "P r"
skalberg@14516
   132
    hence "r \<in> (Collect P)"
skalberg@14516
   133
      by simp
skalberg@14516
   134
    with a
skalberg@14516
   135
    show "Rep (Abs r) = r"
skalberg@14516
   136
      by (rule type_definition.Abs_inverse)
skalberg@14516
   137
  next
skalberg@14516
   138
    assume ra: "Rep (Abs r) = r"
skalberg@14516
   139
    from a
skalberg@14516
   140
    have "Rep (Abs r) \<in> (Collect P)"
skalberg@14516
   141
      by (rule type_definition.Rep)
skalberg@14516
   142
    thus "P r"
skalberg@14516
   143
      by (simp add: ra)
skalberg@14516
   144
  qed
skalberg@14516
   145
qed
skalberg@14516
   146
skalberg@14516
   147
lemma termspec_help: "[| Ex P ; c == Eps P |] ==> P c"
skalberg@14516
   148
  apply simp
skalberg@14516
   149
  apply (rule someI_ex)
skalberg@14516
   150
  .
skalberg@14516
   151
skalberg@14516
   152
lemma typedef_helper: "EX x. P x \<Longrightarrow> EX x. x \<in> (Collect P)"
skalberg@14516
   153
  by simp
skalberg@14516
   154
skalberg@14516
   155
use "hol4rews.ML"
skalberg@14516
   156
skalberg@14516
   157
setup hol4_setup
skalberg@14516
   158
parse_ast_translation smarter_trueprop_parsing
skalberg@14516
   159
skalberg@14516
   160
use "proof_kernel.ML"
skalberg@14516
   161
use "replay.ML"
skalberg@14516
   162
use "import_package.ML"
skalberg@14516
   163
skalberg@14516
   164
setup ImportPackage.setup
skalberg@14516
   165
skalberg@14516
   166
end