src/HOL/Import/HOLLightCompat.thy
author bulwahn
Thu, 07 Jul 2011 23:33:14 +0200
changeset 43704 47b0be18ccbe
parent 41589 bbd861837ebc
child 43787 5be84619e4d4
permissions -rw-r--r--
floor and ceiling definitions are not code equations -- this enables trivial evaluation of floor and ceiling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17322
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
     1
(*  Title:      HOL/Import/HOLLightCompat.thy
41589
bbd861837ebc tuned headers;
wenzelm
parents: 35416
diff changeset
     2
    Author:     Steven Obua and Sebastian Skalberg, TU Muenchen
17322
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
     3
*)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
     4
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
     5
theory HOLLightCompat imports HOL4Setup HOL4Compat Divides Primes Real begin
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
     6
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
     7
lemma light_imp_def: "(t1 --> t2) = ((t1 & t2) = t1)"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
     8
  by auto;
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
     9
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    10
lemma comb_rule: "[| P1 = P2 ; Q1 = Q2 |] ==> P1 Q1 = P2 Q2"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    11
  by simp
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    12
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    13
lemma light_and_def: "(t1 & t2) = ((%f. f t1 t2::bool) = (%f. f True True))"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    14
proof auto
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    15
  assume a: "(%f. f t1 t2::bool) = (%f. f True True)"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    16
  have b: "(%(x::bool) (y::bool). x) = (%x y. x)" ..
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    17
  with a
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    18
  have "t1 = True"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    19
    by (rule comb_rule)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    20
  thus t1
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    21
    by simp
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    22
next
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    23
  assume a: "(%f. f t1 t2::bool) = (%f. f True True)"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    24
  have b: "(%(x::bool) (y::bool). y) = (%x y. y)" ..
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    25
  with a
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    26
  have "t2 = True"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    27
    by (rule comb_rule)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    28
  thus t2
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    29
    by simp
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    30
qed
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    31
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 19064
diff changeset
    32
definition Pred :: "nat \<Rightarrow> nat" where
17322
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    33
   "Pred n \<equiv> n - (Suc 0)"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    34
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    35
lemma Pred_altdef: "Pred = (SOME PRE. PRE 0 = 0 & (ALL n. PRE (Suc n) = n))"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    36
  apply (rule some_equality[symmetric])
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    37
  apply (simp add: Pred_def)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    38
  apply (rule ext)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    39
  apply (induct_tac x)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    40
  apply (auto simp add: Pred_def)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    41
  done
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    42
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    43
lemma NUMERAL_rew[hol4rew]: "NUMERAL x = x" by (simp add: NUMERAL_def)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    44
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    45
lemma REP_ABS_PAIR: "\<forall> x y. Rep_Prod (Abs_Prod (Pair_Rep x y)) = Pair_Rep x y"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    46
  apply (subst Abs_Prod_inverse)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    47
  apply (auto simp add: Prod_def)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    48
  done
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    49
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    50
lemma fst_altdef: "fst = (%p. SOME x. EX y. p = (x, y))"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    51
  apply (rule ext, rule someI2)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    52
  apply (auto intro: fst_conv[symmetric])
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    53
  done
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    54
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    55
lemma snd_altdef: "snd = (%p. SOME x. EX y. p = (y, x))"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    56
  apply (rule ext, rule someI2)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    57
  apply (auto intro: snd_conv[symmetric])
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    58
  done
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    59
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    60
lemma add_altdef: "op + = (SOME add. (ALL n. add 0 n = n) & (ALL m n. add (Suc m) n = Suc (add m n)))"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    61
  apply (rule some_equality[symmetric])
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    62
  apply auto
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    63
  apply (rule ext)+
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    64
  apply (induct_tac x)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    65
  apply auto
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    66
  done
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    67
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    68
lemma mult_altdef: "op * = (SOME mult. (ALL n. mult 0 n = 0) & (ALL m n. mult (Suc m) n = mult m n + n))"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    69
  apply (rule some_equality[symmetric])
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    70
  apply auto
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    71
  apply (rule ext)+
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    72
  apply (induct_tac x)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    73
  apply auto
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    74
  done
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    75
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    76
lemma sub_altdef: "op - = (SOME sub. (ALL m. sub m 0 = m) & (ALL m n. sub m (Suc n) = Pred (sub m n)))"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    77
  apply (simp add: Pred_def)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    78
  apply (rule some_equality[symmetric])
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    79
  apply auto
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    80
  apply (rule ext)+
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    81
  apply (induct_tac xa)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    82
  apply auto
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    83
  done
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    84
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 19064
diff changeset
    85
definition NUMERAL_BIT0 :: "nat \<Rightarrow> nat" where
17322
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    86
  "NUMERAL_BIT0 n \<equiv> n + n"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    87
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    88
lemma NUMERAL_BIT1_altdef: "NUMERAL_BIT1 n = Suc (n + n)"
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    89
  by (simp add: NUMERAL_BIT1_def)
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    90
19064
bf19cc5a7899 fixed bugs, added caching
obua
parents: 17322
diff changeset
    91
consts
bf19cc5a7899 fixed bugs, added caching
obua
parents: 17322
diff changeset
    92
  sumlift :: "('a \<Rightarrow> 'c) \<Rightarrow> ('b \<Rightarrow> 'c) \<Rightarrow> (('a + 'b) \<Rightarrow> 'c)"
17322
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
    93
19064
bf19cc5a7899 fixed bugs, added caching
obua
parents: 17322
diff changeset
    94
primrec
bf19cc5a7899 fixed bugs, added caching
obua
parents: 17322
diff changeset
    95
  "sumlift f g (Inl a) = f a"
bf19cc5a7899 fixed bugs, added caching
obua
parents: 17322
diff changeset
    96
  "sumlift f g (Inr b) = g b"
bf19cc5a7899 fixed bugs, added caching
obua
parents: 17322
diff changeset
    97
  
bf19cc5a7899 fixed bugs, added caching
obua
parents: 17322
diff changeset
    98
lemma sum_Recursion: "\<exists> f. (\<forall> a. f (Inl a) = Inl' a) \<and> (\<forall> b. f (Inr b) = Inr' b)"
bf19cc5a7899 fixed bugs, added caching
obua
parents: 17322
diff changeset
    99
  apply (rule exI[where x="sumlift Inl' Inr'"])
bf19cc5a7899 fixed bugs, added caching
obua
parents: 17322
diff changeset
   100
  apply auto
bf19cc5a7899 fixed bugs, added caching
obua
parents: 17322
diff changeset
   101
  done
17322
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
   102
781abf7011e6 Added HOLLight support to importer.
obua
parents:
diff changeset
   103
end