LamEx.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Wed, 25 Nov 2009 10:34:03 +0100
changeset 376 e99c0334d8bf
parent 370 09e28d4c19aa
child 378 86fba2c4eeef
permissions -rw-r--r--
lambda_prs and cleaning the existing examples.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
201
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory LamEx
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports Nominal QuotMain
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
atom_decl name
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
243
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
     7
thm abs_fresh(1)
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
     8
201
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
nominal_datatype rlam =
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  rVar "name"
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
| rApp "rlam" "rlam"
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
| rLam "name" "rlam"
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
259
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
    14
print_theorems
201
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
243
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    16
function
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    17
  rfv :: "rlam \<Rightarrow> name set"
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    18
where
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    19
  rfv_var: "rfv (rVar a) = {a}"
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    20
| rfv_app: "rfv (rApp t1 t2) = (rfv t1) \<union> (rfv t2)"
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    21
| rfv_lam: "rfv (rLam a t) = (rfv t) - {a}"
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    22
sorry
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    23
247
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
    24
termination rfv sorry
243
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    25
271
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
    26
inductive
246
6da7d538e5e0 changed the order of rfv and reformulated a3 with rfv
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
    27
  alpha :: "rlam \<Rightarrow> rlam \<Rightarrow> bool" ("_ \<approx> _" [100, 100] 100)
6da7d538e5e0 changed the order of rfv and reformulated a3 with rfv
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
    28
where
6da7d538e5e0 changed the order of rfv and reformulated a3 with rfv
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
    29
  a1: "a = b \<Longrightarrow> (rVar a) \<approx> (rVar b)"
6da7d538e5e0 changed the order of rfv and reformulated a3 with rfv
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
    30
| a2: "\<lbrakk>t1 \<approx> t2; s1 \<approx> s2\<rbrakk> \<Longrightarrow> rApp t1 s1 \<approx> rApp t2 s2"
6da7d538e5e0 changed the order of rfv and reformulated a3 with rfv
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
    31
| a3: "\<lbrakk>t \<approx> ([(a,b)]\<bullet>s); a \<notin> rfv (rLam b t)\<rbrakk> \<Longrightarrow> rLam a t \<approx> rLam b s"
6da7d538e5e0 changed the order of rfv and reformulated a3 with rfv
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
    32
259
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
    33
print_theorems
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
    34
271
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
    35
lemma alpha_refl:
286
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    36
  fixes t::"rlam"
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    37
  shows "t \<approx> t"
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    38
  apply(induct t rule: rlam.induct)
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    39
  apply(simp add: a1)
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    40
  apply(simp add: a2)
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    41
  apply(rule a3)
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    42
  apply(subst pt_swap_bij'')
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    43
  apply(rule pt_name_inst)
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    44
  apply(rule at_name_inst)
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    45
  apply(simp)
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    46
  apply(simp)
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    47
  done
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    48
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    49
lemma alpha_EQUIV:
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    50
  shows "EQUIV alpha"
271
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
    51
sorry
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
    52
201
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
quotient lam = rlam / alpha
286
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    54
  apply(rule alpha_EQUIV)
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
    55
  done
201
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
203
7384115df9fd added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents: 201
diff changeset
    57
print_quotients
7384115df9fd added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents: 201
diff changeset
    58
268
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
    59
quotient_def 
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    60
  Var :: "name \<Rightarrow> lam"
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    61
where
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    62
  "Var \<equiv> rVar"
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    63
268
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
    64
quotient_def 
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    65
  App :: "lam \<Rightarrow> lam \<Rightarrow> lam"
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    66
where
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    67
  "App \<equiv> rApp"
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    68
268
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
    69
quotient_def 
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    70
  Lam :: "name \<Rightarrow> lam \<Rightarrow> lam"
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    71
where
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    72
  "Lam \<equiv> rLam"
201
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
218
df05cd030d2f added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents: 203
diff changeset
    74
thm Var_def
df05cd030d2f added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents: 203
diff changeset
    75
thm App_def
df05cd030d2f added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents: 203
diff changeset
    76
thm Lam_def
df05cd030d2f added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents: 203
diff changeset
    77
268
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
    78
quotient_def 
243
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    79
  fv :: "lam \<Rightarrow> name set"
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    80
where
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    81
  "fv \<equiv> rfv"
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    82
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    83
thm fv_def
22715cab3995 added fv-function
Christian Urban <urbanc@in.tum.de>
parents: 240
diff changeset
    84
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    85
(* definition of overloaded permutation function *)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    86
(* for the lifted type lam                       *)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    87
overloading
268
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
    88
  perm_lam \<equiv> "perm :: 'x prm \<Rightarrow> lam \<Rightarrow> lam"   (unchecked)
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    89
begin
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    90
268
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
    91
quotient_def 
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    92
  perm_lam :: "'x prm \<Rightarrow> lam \<Rightarrow> lam"
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    93
where
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    94
  "perm_lam \<equiv> (perm::'x prm \<Rightarrow> rlam \<Rightarrow> rlam)"
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    95
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    96
end
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
    97
238
e9cc3a3aa5d1 Tried manually lifting real_alpha
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 237
diff changeset
    98
(*quotient_def (for lam)
e9cc3a3aa5d1 Tried manually lifting real_alpha
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 237
diff changeset
    99
  abs_fun_lam :: "'x prm \<Rightarrow> lam \<Rightarrow> lam"
e9cc3a3aa5d1 Tried manually lifting real_alpha
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 237
diff changeset
   100
where
e9cc3a3aa5d1 Tried manually lifting real_alpha
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 237
diff changeset
   101
  "perm_lam \<equiv> (perm::'x prm \<Rightarrow> rlam \<Rightarrow> rlam)"*)
e9cc3a3aa5d1 Tried manually lifting real_alpha
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 237
diff changeset
   102
e9cc3a3aa5d1 Tried manually lifting real_alpha
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 237
diff changeset
   103
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   104
thm perm_lam_def
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   105
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   106
(* lemmas that need to lift *)
234
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   107
lemma pi_var_com:
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   108
  fixes pi::"'x prm"
234
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   109
  shows "(pi\<bullet>rVar a) \<approx> rVar (pi\<bullet>a)"
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   110
  sorry
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   111
234
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   112
lemma pi_app_com:
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   113
  fixes pi::"'x prm"
234
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   114
  shows "(pi\<bullet>rApp t1 t2) \<approx> rApp (pi\<bullet>t1) (pi\<bullet>t2)"
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   115
  sorry
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   116
234
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   117
lemma pi_lam_com:
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   118
  fixes pi::"'x prm"
234
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   119
  shows "(pi\<bullet>rLam a t) \<approx> rLam (pi\<bullet>a) (pi\<bullet>t)"
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   120
  sorry
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   121
201
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
lemma real_alpha:
242
47de63a883c2 The proper real_alpha
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 240
diff changeset
   123
  assumes "t = [(a,b)]\<bullet>s" "a\<sharp>[b].s"
201
1ac36993cc71 added an example about lambda-terms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
  shows "Lam a t = Lam b s"
217
9cc87d02190a First experiments with Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 203
diff changeset
   125
sorry
9cc87d02190a First experiments with Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 203
diff changeset
   126
286
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
   127
lemma perm_rsp: 
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
   128
  "(op = ===> alpha ===> alpha) op \<bullet> op \<bullet>"
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   129
  apply(auto)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   130
  (* this is propably true if some type conditions are imposed ;o) *)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   131
  sorry
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   132
286
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
   133
lemma fresh_rsp: 
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
   134
  "(op = ===> alpha ===> op =) fresh fresh" 
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   135
  apply(auto)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   136
  (* this is probably only true if some type conditions are imposed *)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   137
  sorry
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   138
234
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   139
lemma rVar_rsp: "(op = ===> alpha) rVar rVar"
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   140
  apply(auto)
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   141
  apply(rule a1)
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   142
  apply(simp)
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   143
  done
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   144
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   145
lemma rApp_rsp: "(alpha ===> alpha ===> alpha) rApp rApp"
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   146
  apply(auto)
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   147
  apply(rule a2)
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   148
  apply (assumption)
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   149
  apply (assumption)
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   150
  done
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   151
811f17de4031 Lifting of the 3 lemmas in LamEx
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 233
diff changeset
   152
lemma rLam_rsp: "(op = ===> alpha ===> alpha) rLam rLam"
229
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   153
  apply(auto)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   154
  apply(rule a3)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   155
  apply(rule_tac t="[(x,x)]\<bullet>y" and s="y" in subst)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   156
  apply(rule sym)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   157
  apply(rule trans)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   158
  apply(rule pt_name3)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   159
  apply(rule at_ds1[OF at_name_inst])
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   160
  apply(simp add: pt_name1)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   161
  apply(assumption)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   162
  apply(simp add: abs_fresh)
13f985a93dbc fixed the definition of alpha; this *breaks* some of the experiments
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
   163
  done
217
9cc87d02190a First experiments with Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 203
diff changeset
   164
247
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   165
lemma rfv_rsp: "(alpha ===> op =) rfv rfv"
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   166
  sorry
217
9cc87d02190a First experiments with Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 203
diff changeset
   167
285
8ebdef196fd5 Infrastructure for polymorphic types
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 273
diff changeset
   168
lemma rvar_inject: "rVar a \<approx> rVar b = (a = b)"
8ebdef196fd5 Infrastructure for polymorphic types
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 273
diff changeset
   169
apply (auto)
8ebdef196fd5 Infrastructure for polymorphic types
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 273
diff changeset
   170
apply (erule alpha.cases)
8ebdef196fd5 Infrastructure for polymorphic types
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 273
diff changeset
   171
apply (simp_all add: rlam.inject alpha_refl)
8ebdef196fd5 Infrastructure for polymorphic types
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 273
diff changeset
   172
done
8ebdef196fd5 Infrastructure for polymorphic types
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 273
diff changeset
   173
217
9cc87d02190a First experiments with Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 203
diff changeset
   174
ML {* val qty = @{typ "lam"} *}
247
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   175
ML {* val defs = @{thms Var_def App_def Lam_def perm_lam_def fv_def} *}
271
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   176
ML {* val rsp_thms = @{thms perm_rsp fresh_rsp rVar_rsp rApp_rsp rLam_rsp rfv_rsp} @
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   177
  @{thms ho_all_prs ho_ex_prs} *}
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   178
240
6cff34032a00 Cleaning also in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 238
diff changeset
   179
ML {* fun lift_thm_lam lthy t = lift_thm lthy qty "lam" rsp_thms defs t *}
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   180
ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *}
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   181
ML {* val consts = lookup_quot_consts defs *}
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   182
ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "lam" *}
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   183
ML {* fun lift_tac_lam lthy t = lift_tac lthy t rel_eqv rel_refl rty quot trans2 rsp_thms reps_same defs *}
237
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   184
376
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   185
lemma pi_var: "(pi\<Colon>('x \<times> 'x) list) \<bullet> Var a = Var (pi \<bullet> a)"
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   186
apply (tactic {* lift_tac_lam @{context} @{thm pi_var_com} 1 *})
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   187
done
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   188
376
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   189
lemma pi_app: "(pi\<Colon>('x \<times> 'x) list) \<bullet> App (x\<Colon>lam) (xa\<Colon>lam) = App (pi \<bullet> x) (pi \<bullet> xa)"
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   190
apply (tactic {* lift_tac_lam @{context} @{thm pi_app_com} 1 *})
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   191
done
376
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   192
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   193
lemma pi_lam: "(pi\<Colon>('x \<times> 'x) list) \<bullet> Lam (a\<Colon>name) (x\<Colon>lam) = Lam (pi \<bullet> a) (pi \<bullet> x)"
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   194
apply (tactic {* lift_tac_lam @{context} @{thm pi_lam_com} 1 *})
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   195
done
249
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   196
376
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   197
lemma fv_var: "fv (Var (a\<Colon>name)) = {a}"
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   198
apply (tactic {* lift_tac_lam @{context} @{thm rfv_var} 1 *})
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   199
done
376
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   200
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   201
lemma fv_app: "fv (App (x\<Colon>lam) (xa\<Colon>lam)) = fv x \<union> fv xa"
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   202
apply (tactic {* lift_tac_lam @{context} @{thm rfv_app} 1 *})
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   203
done
249
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   204
376
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   205
lemma fv_lam: "fv (Lam (a\<Colon>name) (x\<Colon>lam)) = fv x - {a}"
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   206
apply (tactic {* lift_tac_lam @{context} @{thm rfv_lam} 1 *})
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   207
done
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   208
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   209
lemma a1: "(a\<Colon>name) = (b\<Colon>name) \<Longrightarrow> Var a = Var b"
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   210
apply (tactic {* lift_tac_lam @{context} @{thm a1} 1 *})
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   211
done
376
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   212
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   213
lemma a2: "\<lbrakk>(x\<Colon>lam) = (xa\<Colon>lam); (xb\<Colon>lam) = (xc\<Colon>lam)\<rbrakk> \<Longrightarrow> App x xb = App xa xc"
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   214
apply (tactic {* lift_tac_lam @{context} @{thm a2} 1 *})
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   215
done
376
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   216
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   217
lemma a3: "\<lbrakk>(x\<Colon>lam) = [(a\<Colon>name, b\<Colon>name)] \<bullet> (xa\<Colon>lam); a \<notin> fv (Lam b x)\<rbrakk> \<Longrightarrow> Lam a x = Lam b xa"
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   218
apply (tactic {* lift_tac_lam @{context} @{thm a3} 1 *})
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   219
done
286
Christian Urban <urbanc@in.tum.de>
parents: 285
diff changeset
   220
252
e30997c88050 Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 251
diff changeset
   221
ML {* val alpha_cases = lift_thm_lam @{context} @{thm alpha.cases} *}
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   222
lemma "\<lbrakk>(x\<Colon>lam) = (xa\<Colon>lam); \<And>(a\<Colon>name) b\<Colon>name. \<lbrakk>x = Var a; xa = Var b; a = b\<rbrakk> \<Longrightarrow> P\<Colon>bool;
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   223
     \<And>(x\<Colon>lam) (xa\<Colon>lam) (xb\<Colon>lam) xc\<Colon>lam. \<lbrakk>x = App x xb; xa = App xa xc; x = xa; xb = xc\<rbrakk> \<Longrightarrow> P;
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   224
     \<And>(x\<Colon>lam) (a\<Colon>name) (b\<Colon>name) xa\<Colon>lam. \<lbrakk>x = Lam a x; xa = Lam b xa; x = [(a, b)] \<bullet> xa; a \<notin> fv (Lam b x)\<rbrakk> \<Longrightarrow> P\<rbrakk>
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   225
    \<Longrightarrow> P"
376
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   226
apply (tactic {* procedure_tac @{thm alpha.cases} @{context} 1 *})
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   227
sorry
271
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   228
ML {* val alpha_induct = lift_thm_lam @{context} @{thm alpha.induct} *}
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   229
lemma "\<lbrakk>(qx\<Colon>lam) = (qxa\<Colon>lam); \<And>(a\<Colon>name) b\<Colon>name. a = b \<Longrightarrow> (qxb\<Colon>lam \<Rightarrow> lam \<Rightarrow> bool) (Var a) (Var b);
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   230
     \<And>(x\<Colon>lam) (xa\<Colon>lam) (xb\<Colon>lam) xc\<Colon>lam. \<lbrakk>x = xa; qxb x xa; xb = xc; qxb xb xc\<rbrakk> \<Longrightarrow> qxb (App x xb) (App xa xc);
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   231
     \<And>(x\<Colon>lam) (a\<Colon>name) (b\<Colon>name) xa\<Colon>lam.
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   232
        \<lbrakk>x = [(a, b)] \<bullet> xa; qxb x ([(a, b)] \<bullet> xa); a \<notin> fv (Lam b x)\<rbrakk> \<Longrightarrow> qxb (Lam a x) (Lam b xa)\<rbrakk>
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   233
    \<Longrightarrow> qxb qx qxa"
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   234
(* apply (tactic {* lift_tac_lam @{context} @{thm alpha.induct} 1 *}) *)
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   235
sorry
252
e30997c88050 Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 251
diff changeset
   236
376
e99c0334d8bf lambda_prs and cleaning the existing examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 370
diff changeset
   237
lemma var_inject: "(Var a = Var b) = (a = b)"
370
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   238
apply (tactic {* lift_tac_lam @{context} @{thm rvar_inject} 1 *})
09e28d4c19aa Lambda & SOLVED' for new quotient_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 292
diff changeset
   239
done
285
8ebdef196fd5 Infrastructure for polymorphic types
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 273
diff changeset
   240
249
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   241
lemma var_supp:
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   242
  shows "supp (Var a) = ((supp a)::name set)"
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   243
  apply(simp add: supp_def)
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   244
  apply(simp add: pi_var)
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   245
  apply(simp add: var_inject)
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   246
  done
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   247
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   248
lemma var_fresh:
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   249
  fixes a::"name"
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   250
  shows "(a\<sharp>(Var b)) = (a\<sharp>b)"
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   251
  apply(simp add: fresh_def)
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   252
  apply(simp add: var_supp)
7dec34d12328 added some facts about fresh and support of lam
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
   253
  done
247
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   254
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   255
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   256
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   257
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   258
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   259
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   260
271
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   261
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   262
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   263
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   264
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   265
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   266
(* Construction Site code *)
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   267
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   268
ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *}
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   269
ML {* val consts = lookup_quot_consts defs *}
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   270
ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "lam" *}
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   271
292
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   272
ML {* val t_a = atomize_thm @{thm alpha.cases} *}
253
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   273
(* prove {* build_regularize_goal t_a rty rel @{context}  *}
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   274
ML_prf {*  fun tac ctxt =
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   275
     (FIRST' [
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   276
      rtac rel_refl,
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   277
      atac,
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   278
      rtac @{thm universal_twice},
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   279
      (rtac @{thm impI} THEN' atac),
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   280
      rtac @{thm implication_twice},
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   281
      EqSubst.eqsubst_tac ctxt [0]
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   282
        [(@{thm equiv_res_forall} OF [rel_eqv]),
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   283
         (@{thm equiv_res_exists} OF [rel_eqv])],
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   284
      (rtac @{thm impI} THEN' (asm_full_simp_tac (Simplifier.context ctxt HOL_ss)) THEN' rtac rel_refl),
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   285
      (rtac @{thm RIGHT_RES_FORALL_REGULAR})
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   286
     ]);
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   287
 *}
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   288
  apply (tactic {* tac @{context} 1 *}) *)
251
c770f36f9459 Regularization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 249
diff changeset
   289
ML {* val t_r = regularize t_a rty rel rel_eqv rel_refl @{context} *}
259
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   290
292
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   291
ML {*
257
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   292
  val rt = build_repabs_term @{context} t_r consts rty qty
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   293
  val rg = Logic.mk_equals ((Thm.prop_of t_r), rt);
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   294
*}
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   295
prove rg
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   296
apply(atomize(full))
292
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   297
(*ML_prf {*
257
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   298
fun r_mk_comb_tac ctxt rty quot_thm reflex_thm trans_thm rsp_thms =
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   299
  (FIRST' [
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   300
    rtac trans_thm,
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   301
    LAMBDA_RES_TAC ctxt,
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   302
    res_forall_rsp_tac ctxt,
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   303
    res_exists_rsp_tac ctxt,
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   304
    (
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   305
     (simp_tac ((Simplifier.context ctxt HOL_ss) addsimps rsp_thms))
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   306
     THEN_ALL_NEW (fn _ => no_tac)
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   307
    ),
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   308
    (instantiate_tac @{thm REP_ABS_RSP(1)} ctxt THEN' (RANGE [quotient_tac quot_thm])),
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   309
    rtac refl,
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   310
    (APPLY_RSP_TAC rty ctxt THEN' (RANGE [quotient_tac quot_thm, quotient_tac quot_thm])),
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   311
    Cong_Tac.cong_tac @{thm cong},
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   312
    rtac @{thm ext},
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   313
    rtac reflex_thm,
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   314
    atac,
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   315
    (
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   316
     (simp_tac ((Simplifier.context ctxt HOL_ss) addsimps @{thms FUN_REL.simps}))
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   317
     THEN_ALL_NEW (fn _ => no_tac)
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   318
    ),
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   319
    WEAK_LAMBDA_RES_TAC ctxt
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   320
    ]);
292
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   321
*}*)
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   322
ML_prf {*
257
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   323
  fun r_mk_comb_tac_lam lthy = r_mk_comb_tac lthy rty quot rel_refl trans2 rsp_thms
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   324
*}
292
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   325
apply (tactic {* (r_mk_comb_tac_lam @{context}) 1 *})
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   326
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   327
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   328
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   329
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   330
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   331
257
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   332
apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_lam @{context}) 1 *})
292
bd76f0398aa9 More functionality for lifting list.cases and list.recs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 286
diff changeset
   333
257
68bd5c2a1b96 Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   334
251
c770f36f9459 Regularization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 249
diff changeset
   335
ML {* val t_t = repabs @{context} t_r consts rty qty quot rel_refl trans2 rsp_thms *}
253
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   336
ML {* val abs = findabs rty (prop_of (atomize_thm @{thm alpha.induct})) *}
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   337
ML {* val aps = findaps rty (prop_of (atomize_thm @{thm alpha.induct})) *}
267
3764566c1151 Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 265
diff changeset
   338
ML {* val (alls, exs) = findallex rty qty (prop_of (atomize_thm @{thm alpha.induct})) *}
3764566c1151 Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 265
diff changeset
   339
ML {* val allthms = map (make_allex_prs_thm @{context} quot @{thm FORALL_PRS} ) alls *}
3764566c1151 Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 265
diff changeset
   340
ML {* val exthms = map (make_allex_prs_thm @{context} quot @{thm EXISTS_PRS} ) exs *}
3764566c1151 Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 265
diff changeset
   341
ML {* val t_a = MetaSimplifier.rewrite_rule allthms t_t *}
265
5f3b364d4765 Preparing infrastructure for general FORALL_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 259
diff changeset
   342
ML {* val simp_app_prs_thms = map (make_simp_prs_thm @{context} quot @{thm APP_PRS}) aps *}
5f3b364d4765 Preparing infrastructure for general FORALL_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 259
diff changeset
   343
ML {* val simp_lam_prs_thms = map (make_simp_prs_thm @{context} quot @{thm LAMBDA_PRS}) abs *}
267
3764566c1151 Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 265
diff changeset
   344
ML {* val t_l = repeat_eqsubst_thm @{context} (simp_lam_prs_thms) t_a *}
3764566c1151 Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 265
diff changeset
   345
ML {* val t_l1 = repeat_eqsubst_thm @{context} simp_app_prs_thms t_l *}
252
e30997c88050 Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 251
diff changeset
   346
ML {* val defs_sym = add_lower_defs @{context} defs; *}
259
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   347
ML {* val defs_sym_eq = map (fn x => eq_reflection OF [x]) defs_sym *}
267
3764566c1151 Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 265
diff changeset
   348
ML {* val t_d0 = MetaSimplifier.rewrite_rule defs_sym_eq t_l1 *}
259
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   349
ML {* val t_d = repeat_eqsubst_thm @{context} defs_sym t_d0 *}
252
e30997c88050 Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 251
diff changeset
   350
ML {* val t_r = MetaSimplifier.rewrite_rule [reps_same] t_d *}
253
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   351
ML {* val t_r1 = repeat_eqsubst_thm @{context} @{thms fun_map.simps} t_r *}
259
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   352
ML {* val t_r2 = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_lam.thm10} t_r1 *}
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   353
ML {* val t_r3 = MetaSimplifier.rewrite_rule @{thms eq_reflection[OF id_apply]} t_r2 *}
253
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   354
ML {* val alpha_induct = ObjectLogic.rulify t_r3 *}
247
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   355
271
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   356
(*local_setup {*
253
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   357
  Quotient.note (@{binding "alpha_induct"}, alpha_induct) #> snd
271
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   358
*}*)
247
e83a6e452843 Lemmas about fv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 246
diff changeset
   359
259
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   360
thm alpha_induct
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   361
thm alpha.induct
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   362
271
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   363
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   364
259
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   365
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   366
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   367
22c199522bef Optimization
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 258
diff changeset
   368
271
1b57f99737fe Alpha.induct now lifts automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 270
diff changeset
   369
237
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   370
fun
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   371
  option_map::"('a \<Rightarrow> 'b) \<Rightarrow> ('a noption) \<Rightarrow> ('b noption)"
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   372
where
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   373
  "option_map f (nSome x) = nSome (f x)"
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   374
| "option_map f nNone = nNone"
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   375
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   376
fun
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   377
  option_rel
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   378
where
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   379
  "option_rel r (nSome x) (nSome y) = r x y"
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   380
| "option_rel r _ _ = False"
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   381
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   382
declare [[map noption = (option_map, option_rel)]]
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   383
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   384
lemma OPT_QUOTIENT:
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   385
  assumes q: "QUOTIENT R Abs Rep"
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   386
  shows "QUOTIENT (option_rel R) (option_map Abs) (option_map Rep)"
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   387
  apply (unfold QUOTIENT_def)
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   388
  apply (auto)
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   389
  using q
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   390
  apply (unfold QUOTIENT_def)
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   391
  apply (case_tac "a :: 'b noption")
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   392
  apply (simp)
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   393
  apply (simp)
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   394
  apply (case_tac "a :: 'b noption")
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   395
  apply (simp only: option_map.simps)
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   396
  apply (subst option_rel.simps)
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   397
  (* Simp starts hanging so don't know how to continue *)
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   398
  sorry
80f1df49b940 More tests in Lam
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 234
diff changeset
   399