Attic/Unused.thy
author Christian Urban <urbanc@in.tum.de>
Mon, 27 Sep 2010 04:56:28 -0400
changeset 2490 320775fa47ca
parent 1024 b3deb964ad26
child 2871 b58073719b06
permissions -rw-r--r--
some experiments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
226
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
     1
(*notation ( output) "prop" ("#_" [1000] 1000) *)
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
     2
notation ( output) "Trueprop" ("#_" [1000] 1000)
101
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
1024
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
     4
function(sequential)
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
     5
    akind :: "kind \<Rightarrow> kind \<Rightarrow> bool" ("_ \<approx>ki _" [100, 100] 100)
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
     6
and aty   :: "ty \<Rightarrow> ty \<Rightarrow> bool"     ("_ \<approx>ty _" [100, 100] 100)
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
     7
and atrm  :: "trm \<Rightarrow> trm \<Rightarrow> bool"   ("_ \<approx>tr _" [100, 100] 100)
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
     8
where
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
     9
  a1: "(Type) \<approx>ki (Type) = True"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    10
| a2: "(KPi A x K) \<approx>ki (KPi A' x' K') = (A \<approx>ty A' \<and> (\<exists>pi. (rfv_kind K - {atom x} = rfv_kind K' - {atom x'} \<and> (rfv_kind K - {atom x})\<sharp>* pi \<and> (pi \<bullet> K) \<approx>ki K' \<and> (pi \<bullet> x) = x')))"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    11
| "_ \<approx>ki _ = False"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    12
| a3: "(TConst i) \<approx>ty (TConst j) = (i = j)"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    13
| a4: "(TApp A M) \<approx>ty (TApp A' M') = (A \<approx>ty A' \<and> M \<approx>tr M')"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    14
| a5: "(TPi A x B) \<approx>ty (TPi A' x' B') = ((A \<approx>ty A') \<and> (\<exists>pi. rfv_ty B - {atom x} = rfv_ty B' - {atom x'} \<and> (rfv_ty B - {atom x})\<sharp>* pi \<and> (pi \<bullet> B) \<approx>ty B' \<and> (pi \<bullet> x) = x'))"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    15
| "_ \<approx>ty _ = False"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    16
| a6: "(Const i) \<approx>tr (Const j) = (i = j)"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    17
| a7: "(Var x) \<approx>tr (Var y) = (x = y)"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    18
| a8: "(App M N) \<approx>tr (App M' N') = (M \<approx>tr M' \<and> N \<approx>tr N')"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    19
| a9: "(Lam A x M) \<approx>tr (Lam A' x' M') = (A \<approx>ty A' \<and> (\<exists>pi. rfv_trm M - {atom x} = rfv_trm M' - {atom x'} \<and> (rfv_trm M - {atom x})\<sharp>* pi \<and> (pi \<bullet> M) \<approx>tr M' \<and> (pi \<bullet> x) = x'))"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    20
| "_ \<approx>tr _ = False"
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    21
apply (pat_completeness)
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    22
apply simp_all
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    23
done
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    24
termination
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    25
by (size_change)
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    26
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    27
b3deb964ad26 Some equivariance machinery that comes useful in LF.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 980
diff changeset
    28
806
43336511993f Readded 'regularize_to_injection' which I believe will be needed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 685
diff changeset
    29
lemma regularize_to_injection:
43336511993f Readded 'regularize_to_injection' which I believe will be needed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 685
diff changeset
    30
  shows "(QUOT_TRUE l \<Longrightarrow> y) \<Longrightarrow> (l = r) \<longrightarrow> y"
43336511993f Readded 'regularize_to_injection' which I believe will be needed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 685
diff changeset
    31
  by(auto simp add: QUOT_TRUE_def)
43336511993f Readded 'regularize_to_injection' which I believe will be needed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 685
diff changeset
    32
912
aa960d16570f Lifted Peter's Sigma lemma with Ex1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 870
diff changeset
    33
syntax
980
9d35c6145dd2 Renamed Bexeq to Bex1_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 948
diff changeset
    34
  "Bex1_rel" :: "id \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" ("(3\<exists>!!_\<in>_./ _)" [0, 0, 10] 10)
912
aa960d16570f Lifted Peter's Sigma lemma with Ex1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 870
diff changeset
    35
translations
980
9d35c6145dd2 Renamed Bexeq to Bex1_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 948
diff changeset
    36
  "\<exists>!!x\<in>A. P"  == "Bex1_rel A (%x. P)"
806
43336511993f Readded 'regularize_to_injection' which I believe will be needed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 685
diff changeset
    37
43336511993f Readded 'regularize_to_injection' which I believe will be needed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 685
diff changeset
    38
870
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    39
(* Atomize infrastructure *)
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    40
(* FIXME/TODO: is this really needed? *)
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    41
(*
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    42
lemma atomize_eqv:
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    43
  shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)"
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    44
proof
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    45
  assume "A \<equiv> B"
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    46
  then show "Trueprop A \<equiv> Trueprop B" by unfold
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    47
next
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    48
  assume *: "Trueprop A \<equiv> Trueprop B"
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    49
  have "A = B"
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    50
  proof (cases A)
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    51
    case True
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    52
    have "A" by fact
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    53
    then show "A = B" using * by simp
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    54
  next
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    55
    case False
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    56
    have "\<not>A" by fact
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    57
    then show "A = B" using * by auto
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    58
  qed
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    59
  then show "A \<equiv> B" by (rule eq_reflection)
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    60
qed
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    61
*)
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 806
diff changeset
    62
806
43336511993f Readded 'regularize_to_injection' which I believe will be needed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 685
diff changeset
    63
101
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
  fun dest_cbinop t =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
      val (t2, rhs) = Thm.dest_comb t;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
      val (bop, lhs) = Thm.dest_comb t2;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
      (bop, (lhs, rhs))
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
  fun dest_ceq t =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
      val (bop, pair) = dest_cbinop t;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
      val (bop_s, _) = Term.dest_Const (Thm.term_of bop);
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
      if bop_s = "op =" then pair else (raise CTERM ("Not an equality", [t]))
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
  fun split_binop_conv t =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
      val (lhs, rhs) = dest_ceq t;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
      val (bop, _) = dest_cbinop lhs;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
      val [clT, cr2] = bop |> Thm.ctyp_of_term |> Thm.dest_ctyp;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
      val [cmT, crT] = Thm.dest_ctyp cr2;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    92
      Drule.instantiate' [SOME clT, SOME cmT, SOME crT] [NONE, NONE, NONE, NONE, SOME bop] @{thm arg_cong2}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    93
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    96
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
  fun split_arg_conv t =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
      val (lhs, rhs) = dest_ceq t;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
      val (lop, larg) = Thm.dest_comb lhs;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
      val [caT, crT] = lop |> Thm.ctyp_of_term |> Thm.dest_ctyp;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
      Drule.instantiate' [SOME caT, SOME crT] [NONE, NONE, SOME lop] @{thm arg_cong}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
  fun split_binop_tac n thm =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   110
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
      val concl = Thm.cprem_of thm n;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   112
      val (_, cconcl) = Thm.dest_comb concl;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
      val rewr = split_binop_conv cconcl;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   115
      rtac rewr n thm
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   116
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   117
      handle CTERM _ => Seq.empty
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   118
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   119
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   121
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   122
  fun split_arg_tac n thm =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   124
      val concl = Thm.cprem_of thm n;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   125
      val (_, cconcl) = Thm.dest_comb concl;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   126
      val rewr = split_arg_conv cconcl;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   127
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   128
      rtac rewr n thm
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   129
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   130
      handle CTERM _ => Seq.empty
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   132
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   133
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
lemma trueprop_cong:
303
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
   135
  shows "(a \<equiv> b) \<Longrightarrow> (Trueprop a \<equiv> Trueprop b)"
101
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   136
  by auto
226
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   137
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   138
lemma list_induct_hol4:
303
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
   139
  fixes P :: "'a list \<Rightarrow> bool"
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
   140
  assumes a: "((P []) \<and> (\<forall>t. (P t) \<longrightarrow> (\<forall>h. (P (h # t)))))"
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
   141
  shows "\<forall>l. (P l)"
226
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   142
  using a
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   143
  apply (rule_tac allI)
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   144
  apply (induct_tac "l")
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   145
  apply (simp)
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   146
  apply (metis)
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   147
  done
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
   148
301
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
   149
ML {*
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
   150
val no_vars = Thm.rule_attribute (fn context => fn th =>
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
   151
  let
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
   152
    val ctxt = Variable.set_body false (Context.proof_of context);
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
   153
    val ((_, [th']), _) = Variable.import true [th] ctxt;
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
   154
  in th' end);
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
   155
*}
303
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
   156
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
   157
(*lemma equality_twice:
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
   158
  "a = c \<Longrightarrow> b = d \<Longrightarrow> (a = b \<longrightarrow> c = d)"
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
   159
by auto*)
685
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   160
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   161
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   162
(*interpretation code *)
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   163
(*val bindd = ((Binding.make ("", Position.none)), ([]: Attrib.src list))
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   164
  val ((_, [eqn1pre]), lthy5) = Variable.import true [ABS_def] lthy4;
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   165
  val eqn1i = Thm.prop_of (symmetric eqn1pre)
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   166
  val ((_, [eqn2pre]), lthy6) = Variable.import true [REP_def] lthy5;
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   167
  val eqn2i = Thm.prop_of (symmetric eqn2pre)
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   168
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   169
  val exp_morphism = ProofContext.export_morphism lthy6 (ProofContext.init (ProofContext.theory_of lthy6));
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   170
  val exp_term = Morphism.term exp_morphism;
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   171
  val exp = Morphism.thm exp_morphism;
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   172
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   173
  val mthd = Method.SIMPLE_METHOD ((rtac quot_thm 1) THEN
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   174
    ALLGOALS (simp_tac (HOL_basic_ss addsimps [(symmetric (exp ABS_def)), (symmetric (exp REP_def))])))
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   175
  val mthdt = Method.Basic (fn _ => mthd)
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   176
  val bymt = Proof.global_terminal_proof (mthdt, NONE)
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   177
  val exp_i = [(@{const_name QUOT_TYPE}, ((("QUOT_TYPE_I_" ^ (Binding.name_of qty_name)), true),
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   178
    Expression.Named [("R", rel), ("Abs", abs), ("Rep", rep) ]))]*)
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   179
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   180
(*||> Local_Theory.theory (fn thy =>
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   181
      let
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   182
        val global_eqns = map exp_term [eqn2i, eqn1i];
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   183
        (* Not sure if the following context should not be used *)
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   184
        val (global_eqns2, lthy7) = Variable.import_terms true global_eqns lthy6;
b12f0321dfb0 moved the interpretation code into Unused.thy
Christian Urban <urbanc@in.tum.de>
parents: 303
diff changeset
   185
        val global_eqns3 = map (fn t => (bindd, t)) global_eqns2;
806
43336511993f Readded 'regularize_to_injection' which I believe will be needed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 685
diff changeset
   186
      in ProofContext.theory_of (bymt (Expression.interpretation (exp_i, []) global_eqns3 thy)) end)*)