Unused.thy
author Christian Urban <urbanc@in.tum.de>
Mon, 23 Nov 2009 13:24:12 +0100
changeset 334 5a7024be9083
parent 303 991b0e53f9dc
child 685 b12f0321dfb0
permissions -rw-r--r--
code review with Cezary
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
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
  fun dest_cbinop t =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
      val (t2, rhs) = Thm.dest_comb t;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
      val (bop, lhs) = Thm.dest_comb t2;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
      (bop, (lhs, rhs))
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
  fun dest_ceq t =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
      val (bop, pair) = dest_cbinop t;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
      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
    19
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
      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
    21
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
  fun split_binop_conv t =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
      val (lhs, rhs) = dest_ceq t;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
      val (bop, _) = dest_cbinop lhs;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
      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
    30
      val [cmT, crT] = Thm.dest_ctyp cr2;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
      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
    33
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
  fun split_arg_conv t =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
      val (lhs, rhs) = dest_ceq t;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
      val (lop, larg) = Thm.dest_comb lhs;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
      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
    43
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
      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
    45
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
  fun split_binop_tac n thm =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
      val concl = Thm.cprem_of thm n;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
      val (_, cconcl) = Thm.dest_comb concl;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
      val rewr = split_binop_conv cconcl;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
      rtac rewr n thm
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
      handle CTERM _ => Seq.empty
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
*}
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
ML {*
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
  fun split_arg_tac n thm =
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
    let
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
      val concl = Thm.cprem_of thm n;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
      val (_, cconcl) = Thm.dest_comb concl;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
      val rewr = split_arg_conv cconcl;
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
    in
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
      rtac rewr n thm
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
    end
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
      handle CTERM _ => Seq.empty
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
*}
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
lemma trueprop_cong:
303
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
    75
  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
    76
  by auto
226
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    77
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    78
lemma list_induct_hol4:
303
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
    79
  fixes P :: "'a list \<Rightarrow> bool"
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
    80
  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
    81
  shows "\<forall>l. (P l)"
226
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    82
  using a
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    83
  apply (rule_tac allI)
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    84
  apply (induct_tac "l")
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    85
  apply (simp)
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    86
  apply (metis)
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    87
  done
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    88
301
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
    89
ML {*
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
    90
val no_vars = Thm.rule_attribute (fn context => fn th =>
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
    91
  let
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
    92
    val ctxt = Variable.set_body false (Context.proof_of context);
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
    93
    val ((_, [th']), _) = Variable.import true [th] ctxt;
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
    94
  in th' end);
40bb0c4718a6 Cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 226
diff changeset
    95
*}
303
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
    96
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
    97
(*lemma equality_twice:
991b0e53f9dc More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 301
diff changeset
    98
  "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
    99
by auto*)