Quot/Examples/IntEx.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 08 Dec 2009 11:17:56 +0100
changeset 617 ca37f4b6457c
parent 606 38aa6b67a80b
child 618 8dfae5d97387
permissions -rw-r--r--
An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory IntEx
600
5d932e7a856c List moved after QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 597
diff changeset
     2
imports "../QuotList"
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
fun
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
  intrel :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool" (infix "\<approx>" 50)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  "intrel (x, y) (u, v) = (x + v = u + y)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
quotient my_int = "nat \<times> nat" / intrel
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
  apply(unfold equivp_def)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
  apply(auto simp add: mem_def expand_fun_eq)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
  done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
thm quotient_equiv
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
thm quotient_thm
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
thm my_int_equivp
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
print_theorems
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
print_quotients
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
quotient_def 
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  ZERO::"my_int"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
  "ZERO \<equiv> (0::nat, 0::nat)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
ML {* print_qconstinfo @{context} *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
term ZERO
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
thm ZERO_def
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
ML {* prop_of @{thm ZERO_def} *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
ML {* separate *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
quotient_def 
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
  ONE::"my_int"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
  "ONE \<equiv> (1::nat, 0::nat)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
ML {* print_qconstinfo @{context} *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
term ONE
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
thm ONE_def
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
fun
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
  my_plus :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> (nat \<times> nat)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
  "my_plus (x, y) (u, v) = (x + u, y + v)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
quotient_def 
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  PLUS::"my_int \<Rightarrow> my_int \<Rightarrow> my_int"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  "PLUS \<equiv> my_plus"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
term my_plus
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
term PLUS
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
thm PLUS_def
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
fun
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
  my_neg :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
  "my_neg (x, y) = (y, x)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
quotient_def 
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
  NEG::"my_int \<Rightarrow> my_int"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  "NEG \<equiv> my_neg"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
term NEG
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
thm NEG_def
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
definition
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
  MINUS :: "my_int \<Rightarrow> my_int \<Rightarrow> my_int"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
  "MINUS z w = PLUS z (NEG w)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
fun
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
  my_mult :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> (nat \<times> nat)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
  "my_mult (x, y) (u, v) = (x*u + y*v, x*v + y*u)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
quotient_def 
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
  MULT::"my_int \<Rightarrow> my_int \<Rightarrow> my_int"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
  "MULT \<equiv> my_mult"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
term MULT
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
thm MULT_def
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
(* NOT SURE WETHER THIS DEFINITION IS CORRECT *)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
fun
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
  my_le :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
  "my_le (x, y) (u, v) = (x+v \<le> u+y)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
quotient_def 
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
  LE :: "my_int \<Rightarrow> my_int \<Rightarrow> bool"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
  "LE \<equiv> my_le"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
term LE
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
thm LE_def
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
definition
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
  LESS :: "my_int \<Rightarrow> my_int \<Rightarrow> bool"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
  "LESS z w = (LE z w \<and> z \<noteq> w)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
term LESS
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
thm LESS_def
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
definition
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
  ABS :: "my_int \<Rightarrow> my_int"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
  "ABS i = (if (LESS i ZERO) then (NEG i) else i)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
definition
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
  SIGN :: "my_int \<Rightarrow> my_int"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
where
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
 "SIGN i = (if i = ZERO then ZERO else if (LESS ZERO i) then ONE else (NEG ONE))"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
ML {* print_qconstinfo @{context} *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
lemma plus_sym_pre:
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
  shows "my_plus a b \<approx> my_plus b a"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
  apply(cases a)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
  apply(cases b)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
  apply(auto)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
  done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
lemma plus_rsp[quotient_rsp]:
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
  shows "(intrel ===> intrel ===> intrel) my_plus my_plus"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
by (simp)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
ML {* val qty = @{typ "my_int"} *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "my_int"; *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
ML {* fun lift_tac_intex lthy t = lift_tac lthy t *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
ML {* fun inj_repabs_tac_intex lthy = inj_repabs_tac lthy [rel_refl] [trans2] *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
ML {* fun all_inj_repabs_tac_intex lthy = all_inj_repabs_tac lthy [rel_refl] [trans2] *}
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
lemma test1: "my_plus a b = my_plus a b"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
apply(rule refl)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
lemma "PLUS a b = PLUS a b"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
apply(tactic {* procedure_tac @{context} @{thm test1} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
apply(tactic {* regularize_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
apply(tactic {* clean_tac @{context} 1 *}) 
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
thm lambda_prs
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
lemma test2: "my_plus a = my_plus a"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
apply(rule refl)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
lemma "PLUS a = PLUS a"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
apply(tactic {* procedure_tac @{context} @{thm test2} 1 *})
606
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   167
apply(rule impI)
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
apply(rule ballI)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
apply(rule apply_rsp[OF Quotient_my_int plus_rsp])
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
apply(simp only: in_respects)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
apply(tactic {* clean_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
lemma test3: "my_plus = my_plus"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
apply(rule refl)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
lemma "PLUS = PLUS"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   180
apply(tactic {* procedure_tac @{context} @{thm test3} 1 *})
606
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   181
apply(rule impI)
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   182
apply(rule plus_rsp)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
apply(tactic {* clean_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   186
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
lemma "PLUS a b = PLUS b a"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
apply(tactic {* procedure_tac @{context} @{thm plus_sym_pre} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
apply(tactic {* regularize_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
apply(tactic {* clean_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
lemma plus_assoc_pre:
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
  shows "my_plus (my_plus i j) k \<approx> my_plus i (my_plus j k)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
  apply (cases i)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
  apply (cases j)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
  apply (cases k)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
  apply (simp)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
  done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
lemma plus_assoc: "PLUS (PLUS x xa) xb = PLUS x (PLUS xa xb)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
apply(tactic {* procedure_tac @{context} @{thm plus_assoc_pre} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   205
apply(tactic {* regularize_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
apply(tactic {* clean_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   209
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   210
lemma ho_tst: "foldl my_plus x [] = x"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   211
apply simp
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   212
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   213
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   214
lemma "foldl PLUS x [] = x"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
apply(tactic {* procedure_tac @{context} @{thm ho_tst} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
apply(tactic {* regularize_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   217
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   218
apply(tactic {* clean_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   219
apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] nil_prs[OF Quotient_my_int])
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   220
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   221
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   222
lemma ho_tst2: "foldl my_plus x (h # t) \<approx> my_plus h (foldl my_plus x t)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   223
sorry
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   224
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   225
lemma "foldl PLUS x (h # t) = PLUS h (foldl PLUS x t)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   226
apply(tactic {* procedure_tac @{context} @{thm ho_tst2} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   227
apply(tactic {* regularize_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   228
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   229
apply(tactic {* clean_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   230
apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] cons_prs[OF Quotient_my_int])
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   231
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   232
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   233
lemma ho_tst3: "foldl f (s::nat \<times> nat) ([]::(nat \<times> nat) list) = s"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   234
by simp
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   235
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   236
lemma "foldl f (x::my_int) ([]::my_int list) = x"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   237
apply(tactic {* procedure_tac @{context} @{thm ho_tst3} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   238
apply(tactic {* regularize_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   239
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   240
(* TODO: does not work when this is added *)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   241
(* apply(tactic {* lambda_prs_tac @{context} 1 *})*)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   242
apply(tactic {* clean_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   243
apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] nil_prs[OF Quotient_my_int])
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   244
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   245
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   246
lemma lam_tst: "(\<lambda>x. (x, x)) y = (y, (y :: nat \<times> nat))"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   247
by simp
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   248
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   249
lemma "(\<lambda>x. (x, x)) (y::my_int) = (y, y)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   250
apply(tactic {* procedure_tac @{context} @{thm lam_tst} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   251
apply(tactic {* regularize_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   252
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   253
apply(tactic {* clean_tac @{context} 1 *})
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   254
apply(simp add: pair_prs)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   255
done
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   256
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   257
lemma lam_tst2: "(\<lambda>(y :: nat \<times> nat). y) = (\<lambda>(x :: nat \<times> nat). x)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   258
by simp
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   259
605
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   260
(* test about lifting identity equations *)
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   261
605
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   262
ML {*
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   263
(* helper code from QuotMain *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   264
val pat_ball = @{term "Ball (Respects (R1 ===> R2)) P"}
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   265
val pat_bex  = @{term "Bex (Respects (R1 ===> R2)) P"}
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   266
val simproc = Simplifier.simproc_i @{theory} "" [pat_ball, pat_bex] (K (ball_bex_range_simproc))
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   267
val simpset = (mk_minimal_ss @{context}) 
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   268
                       addsimps @{thms ball_reg_eqv bex_reg_eqv babs_reg_eqv}
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   269
                       addsimprocs [simproc] addSolver equiv_solver
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   270
*}
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   271
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   272
(* What regularising does *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   273
(*========================*)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   274
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   275
(* 0. preliminary simplification step *)
606
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   276
thm ball_reg_eqv bex_reg_eqv (* of no use: babs_reg_eqv *)
605
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   277
    ball_reg_eqv_range bex_reg_eqv_range
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   278
(* 1. first two rtacs *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   279
thm ball_reg_right bex_reg_left
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   280
(* 2. monos *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   281
(* 3. commutation rules *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   282
thm ball_all_comm bex_ex_comm
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   283
(* 4. then rel-equality *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   284
thm eq_imp_rel
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   285
(* 5. then simplification like 0 *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   286
(* finally jump to 1 *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   287
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   288
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   289
(* What cleaning does *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   290
(*====================*)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   291
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   292
(* 1. conversion *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   293
thm lambda_prs
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   294
(* 2. simplification with *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   295
thm all_prs ex_prs
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   296
(* 3. Simplification with *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   297
thm fun_map.simps id_simps Quotient_abs_rep Quotient_rel_rep
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   298
(* 4. Test for refl *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   299
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   300
lemma
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   301
  shows "equivp (op \<approx>)"
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   302
  and   "equivp ((op \<approx>) ===> (op \<approx>))"
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   303
apply -
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   304
apply(tactic {* equiv_tac @{context} 1 *})
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   305
apply(tactic {* equiv_tac @{context} 1 *})?
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   306
oops
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 603
diff changeset
   307
606
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   308
lemma lam_tst3a: "(\<lambda>(y :: nat \<times> nat). y) = (\<lambda>(x :: nat \<times> nat). x)"
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   309
by auto
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   310
617
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   311
lemma lam_tst3a_clean: "(op \<approx> ===> op \<approx>)
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   312
     ((ABS_my_int ---> REP_my_int) ((REP_my_int ---> ABS_my_int) (Babs (Respects op \<approx>) (
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   313
       ((ABS_my_int ---> REP_my_int) ((REP_my_int ---> ABS_my_int) (\<lambda>y. REP_my_int (ABS_my_int y))))))))
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   314
     ((ABS_my_int ---> REP_my_int) ((REP_my_int ---> ABS_my_int) (Babs (Respects op \<approx>) (
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   315
       ((ABS_my_int ---> REP_my_int) ((REP_my_int ---> ABS_my_int) (\<lambda>y. REP_my_int (ABS_my_int y))))))))
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   316
      = ((\<lambda>(y::my_int). y) = (\<lambda>x. x))"
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   317
apply(subst babs_prs[OF Quotient_my_int Quotient_my_int])
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   318
apply(subst babs_prs[OF Quotient_my_int Quotient_my_int])
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   319
apply(subst lambda_prs[OF Quotient_my_int Quotient_my_int])
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   320
apply(subst lambda_prs[OF Quotient_my_int Quotient_my_int])
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   321
apply(subst Quotient_rel_rep[OF fun_quotient[OF Quotient_my_int Quotient_my_int]])
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   322
apply(rule refl)
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   323
done
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   324
606
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   325
lemma "(\<lambda>(y :: my_int). y) = (\<lambda>(x :: my_int). x)"
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   326
apply(tactic {* procedure_tac @{context} @{thm lam_tst3a} 1 *})
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   327
defer
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   328
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
602
e56eeb9fedb3 make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 600
diff changeset
   329
apply(tactic {* clean_tac  @{context} 1 *})
606
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   330
apply(subst babs_rsp)
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   331
apply(tactic {* clean_tac  @{context} 1 *})
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   332
apply(simp)
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   333
apply(tactic {* regularize_tac @{context} 1*})?
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   334
apply(subst babs_reg_eqv)
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   335
apply(tactic {* equiv_tac @{context} 1*})
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   336
apply(subst babs_reg_eqv)
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   337
apply(tactic {* equiv_tac @{context} 1*})
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   338
sorry
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   339
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   340
lemma lam_tst3b: "(\<lambda>(y :: nat \<times> nat \<Rightarrow> nat \<times> nat). y) = (\<lambda>(x :: nat \<times> nat \<Rightarrow> nat \<times> nat). x)"
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   341
by auto
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   342
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   343
lemma "(\<lambda>(y :: my_int => my_int). y) = (\<lambda>(x :: my_int => my_int). x)"
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   344
apply(tactic {* procedure_tac @{context} @{thm lam_tst3b} 1 *})
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   345
defer
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   346
apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   347
apply(tactic {* clean_tac  @{context} 1 *})
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   348
apply(subst babs_rsp)
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   349
apply(tactic {* clean_tac  @{context} 1 *})
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   350
apply(simp)
38aa6b67a80b clarified the function examples
Christian Urban <urbanc@in.tum.de>
parents: 605
diff changeset
   351
apply(tactic {* regularize_tac @{context} 1*})?
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   352
sorry
601
81f40b8bde7b added "end" to each example theory
Christian Urban <urbanc@in.tum.de>
parents: 600
diff changeset
   353
617
ca37f4b6457c An example of working cleaning for lambda lifting. Still not sure why Babs helps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 606
diff changeset
   354
end