Unused.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 03 Nov 2009 18:09:59 +0100
changeset 272 ddd2f209d0d2
parent 226 2a28e7ef3048
child 301 40bb0c4718a6
permissions -rw-r--r--
Playing with alpha_refl.
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:
4f93c5a026d2 Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
  shows "(a ≡ b) ⟹ (Trueprop a ≡ Trueprop b)"
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:
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    79
  fixes P :: "'a list ⇒ bool"
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    80
  assumes a: "((P []) ∧ (∀t. (P t) ⟶ (∀h. (P (h # t)))))"
2a28e7ef3048 cleaned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 101
diff changeset
    81
  shows "∀l. (P l)"
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