297
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 1
theory LFex
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 2
imports Nominal QuotMain
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 3
begin
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 4
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 5
atom_decl name id
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 6
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 7
nominal_datatype kind =
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 8
Type
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 9
| KPi "ty" "name" "kind"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 10
and ty =
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 11
TConst "id"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 12
| TApp "ty" "trm"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 13
| TPi "ty" "name" "ty"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 14
and trm =
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 15
Const "id"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 16
| Var "name"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 17
| App "trm" "trm"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 18
| Lam "ty" "name" "trm"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 19
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 20
function
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 21
fv_kind :: "kind \<Rightarrow> name set"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 22
and fv_ty :: "ty \<Rightarrow> name set"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 23
and fv_trm :: "trm \<Rightarrow> name set"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 24
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 25
"fv_kind (Type) = {}"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 26
| "fv_kind (KPi A x K) = (fv_ty A) \<union> ((fv_kind K) - {x})"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 27
| "fv_ty (TConst i) = {}"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 28
| "fv_ty (TApp A M) = (fv_ty A) \<union> (fv_trm M)"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 29
| "fv_ty (TPi A x B) = (fv_ty A) \<union> ((fv_ty B) - {x})"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 30
| "fv_trm (Const i) = {}"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 31
| "fv_trm (Var x) = {x}"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 32
| "fv_trm (App M N) = (fv_trm M) \<union> (fv_trm N)"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 33
| "fv_trm (Lam A x M) = (fv_ty A) \<union> ((fv_trm M) - {x})"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 34
sorry
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 35
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 36
termination fv_kind sorry
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 37
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 38
inductive
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 39
akind :: "kind \<Rightarrow> kind \<Rightarrow> bool" ("_ \<approx>ki _" [100, 100] 100)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 40
and aty :: "ty \<Rightarrow> ty \<Rightarrow> bool" ("_ \<approx>ty _" [100, 100] 100)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 41
and atrm :: "trm \<Rightarrow> trm \<Rightarrow> bool" ("_ \<approx>tr _" [100, 100] 100)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 42
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 43
a1: "(Type) \<approx>ki (Type)"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 44
| a21: "\<lbrakk>A \<approx>ty A'; K \<approx>ki K'\<rbrakk> \<Longrightarrow> (KPi A x K) \<approx>ki (KPi A' x K')"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 45
| a22: "\<lbrakk>A \<approx>ty A'; K \<approx>ki ([(x,x')]\<bullet>K'); x \<notin> (fv_ty A'); x \<notin> ((fv_kind K') - {x'})\<rbrakk>
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 46
\<Longrightarrow> (KPi A x K) \<approx>ki (KPi A' x' K')"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 47
| a3: "i = j \<Longrightarrow> (TConst i) \<approx>ty (TConst j)"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 48
| a4: "\<lbrakk>A \<approx>ty A'; M \<approx>tr M'\<rbrakk> \<Longrightarrow> (TApp A M) \<approx>ty (TApp A' M')"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 49
| a51: "\<lbrakk>A \<approx>ty A'; B \<approx>ty B'\<rbrakk> \<Longrightarrow> (TPi A x B) \<approx>ty (TPi A' x B')"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 50
| a52: "\<lbrakk>A \<approx>ty A'; B \<approx>ty ([(x,x')]\<bullet>B'); x \<notin> (fv_ty B'); x \<notin> ((fv_ty B') - {x'})\<rbrakk>
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 51
\<Longrightarrow> (TPi A x B) \<approx>ty (TPi A' x' B')"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 52
| a6: "i = j \<Longrightarrow> (Const i) \<approx>trm (Const j)"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 53
| a7: "x = y \<Longrightarrow> (Var x) \<approx>trm (Var y)"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 54
| a8: "\<lbrakk>M \<approx>trm M'; N \<approx>tr N'\<rbrakk> \<Longrightarrow> (App M N) \<approx>tr (App M' N')"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 55
| a91: "\<lbrakk>A \<approx>ty A'; M \<approx>tr M'\<rbrakk> \<Longrightarrow> (Lam A x M) \<approx>tr (Lam A' x M')"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 56
| a92: "\<lbrakk>A \<approx>ty A'; M \<approx>tr ([(x,x')]\<bullet>M'); x \<notin> (fv_ty B'); x \<notin> ((fv_trm M') - {x'})\<rbrakk>
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 57
\<Longrightarrow> (Lam A x M) \<approx>tr (Lam A' x' M')"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 58
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 59
lemma al_refl:
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 60
fixes K::"kind"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 61
and A::"ty"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 62
and M::"trm"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 63
shows "K \<approx>ki K"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 64
and "A \<approx>ty A"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 65
and "M \<approx>tr M"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 66
apply(induct K and A and M rule: kind_ty_trm.inducts)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 67
apply(auto intro: akind_aty_atrm.intros)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 68
done
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 69
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 70
lemma alpha_EQUIVs:
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 71
shows "EQUIV akind"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 72
and "EQUIV aty"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 73
and "EQUIV atrm"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 74
sorry
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 75
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 76
quotient KIND = kind / akind
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 77
by (rule alpha_EQUIVs)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 78
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 79
quotient TY = ty / aty
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 80
and TRM = trm / atrm
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 81
by (auto intro: alpha_EQUIVs)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 82
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 83
print_quotients
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 84
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 85
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 86
TYP :: "KIND"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 87
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 88
"TYP \<equiv> Type"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 89
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 90
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 91
KPI :: "TY \<Rightarrow> name \<Rightarrow> KIND \<Rightarrow> KIND"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 92
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 93
"KPI \<equiv> KPi"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 94
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 95
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 96
TCONST :: "id \<Rightarrow> TY"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 97
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 98
"TCONST \<equiv> TConst"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 99
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 100
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 101
TAPP :: "TY \<Rightarrow> TRM \<Rightarrow> TY"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 102
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 103
"TAPP \<equiv> TApp"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 104
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 105
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 106
TPI :: "TY \<Rightarrow> name \<Rightarrow> TY \<Rightarrow> TY"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 107
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 108
"TPI \<equiv> TPi"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 109
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 110
(* FIXME: does not work with CONST *)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 111
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 112
CONS :: "id \<Rightarrow> TRM"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 113
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 114
"CONS \<equiv> Const"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 115
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 116
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 117
VAR :: "name \<Rightarrow> TRM"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 118
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 119
"VAR \<equiv> Var"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 120
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 121
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 122
APP :: "TRM \<Rightarrow> TRM \<Rightarrow> TRM"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 123
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 124
"APP \<equiv> App"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 125
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 126
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 127
LAM :: "TY \<Rightarrow> name \<Rightarrow> TRM \<Rightarrow> TRM"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 128
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 129
"LAM \<equiv> Lam"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 130
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 131
thm TYP_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 132
thm KPI_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 133
thm TCONST_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 134
thm TAPP_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 135
thm TPI_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 136
thm VAR_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 137
thm CONS_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 138
thm APP_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 139
thm LAM_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 140
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 141
(* FIXME: print out a warning if the type contains a liftet type, like kind \<Rightarrow> name set *)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 142
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 143
FV_kind :: "KIND \<Rightarrow> name set"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 144
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 145
"FV_kind \<equiv> fv_kind"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 146
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 147
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 148
FV_ty :: "TY \<Rightarrow> name set"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 149
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 150
"FV_ty \<equiv> fv_ty"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 151
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 152
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 153
FV_trm :: "TRM \<Rightarrow> name set"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 154
where
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 155
"FV_trm \<equiv> fv_trm"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 156
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 157
thm FV_kind_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 158
thm FV_ty_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 159
thm FV_trm_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 160
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 161
(* FIXME: does not work yet *)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 162
overloading
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 163
perm_kind \<equiv> "perm :: 'x prm \<Rightarrow> KIND \<Rightarrow> KIND" (unchecked)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 164
perm_ty \<equiv> "perm :: 'x prm \<Rightarrow> TY \<Rightarrow> TY" (unchecked)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 165
perm_trm \<equiv> "perm :: 'x prm \<Rightarrow> TRM \<Rightarrow> TRM" (unchecked)
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 166
begin
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 167
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 168
quotient_def
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 169
perm_kind :: "'x prm \<Rightarrow> KIND \<Rightarrow> KIND"
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 170
where
299
+ − 171
"perm_kind \<equiv> (perm::'x prm \<Rightarrow> kind \<Rightarrow> kind)"
+ − 172
+ − 173
quotient_def
+ − 174
perm_ty :: "'x prm \<Rightarrow> TY \<Rightarrow> TY"
+ − 175
where
+ − 176
"perm_ty \<equiv> (perm::'x prm \<Rightarrow> ty \<Rightarrow> ty)"
+ − 177
+ − 178
quotient_def
+ − 179
perm_trm :: "'x prm \<Rightarrow> TRM \<Rightarrow> TRM"
+ − 180
where
+ − 181
"perm_trm \<equiv> (perm::'x prm \<Rightarrow> trm \<Rightarrow> trm)"
+ − 182
301
+ − 183
ML {* val defs =
+ − 184
@{thms TYP_def KPI_def TCONST_def TAPP_def TPI_def VAR_def CONS_def APP_def LAM_def
+ − 185
FV_kind_def FV_ty_def FV_trm_def perm_kind_def perm_ty_def perm_trm_def}
+ − 186
*}
+ − 187
ML {* val consts = lookup_quot_consts defs *}
+ − 188
+ − 189
thm akind_aty_atrm.induct
+ − 190
400
+ − 191
lemma left_ball_regular:
+ − 192
assumes a: "EQUIV R"
+ − 193
shows "(\<And>x. (Q x \<longrightarrow> P x)) \<Longrightarrow> Ball (Respects R) Q \<longrightarrow> All P"
+ − 194
apply (rule LEFT_RES_FORALL_REGULAR)
+ − 195
using Respects_def[of "R"] a EQUIV_REFL_SYM_TRANS[of "R"] REFL_def[of "R"]
+ − 196
apply (simp)
+ − 197
done
+ − 198
+ − 199
lemma right_bex_regular:
+ − 200
assumes a: "EQUIV R"
+ − 201
shows "(\<And>x. (Q x \<longrightarrow> P x)) \<Longrightarrow> Ex Q \<longrightarrow> Bex (Respects R) P"
+ − 202
apply (rule RIGHT_RES_EXISTS_REGULAR)
+ − 203
using Respects_def[of "R"] a EQUIV_REFL_SYM_TRANS[of "R"] REFL_def[of "R"]
+ − 204
apply (simp)
+ − 205
done
+ − 206
+ − 207
lemma ball_respects_refl:
+ − 208
fixes P::"'a \<Rightarrow> bool"
+ − 209
and x::"'a"
+ − 210
assumes a: "EQUIV R2"
+ − 211
shows "(Ball (Respects (R1 ===> R2)) (\<lambda>f. P (f x)) = All (\<lambda>f. P (f x)))"
+ − 212
apply(rule iffI)
+ − 213
apply(rule allI)
+ − 214
apply(drule_tac x="\<lambda>y. f x" in bspec)
+ − 215
apply(simp add: Respects_def IN_RESPECTS)
+ − 216
apply(rule impI)
+ − 217
using a EQUIV_REFL_SYM_TRANS[of "R2"]
+ − 218
apply(simp add: REFL_def)
+ − 219
apply(simp)
+ − 220
apply(simp)
+ − 221
done
+ − 222
394
+ − 223
ML {*
400
+ − 224
fun ball_simproc rel_eqvs ss redex =
+ − 225
let
+ − 226
val ctxt = Simplifier.the_context ss
+ − 227
val thy = ProofContext.theory_of ctxt
394
+ − 228
in
400
+ − 229
case redex of
+ − 230
(ogl as ((Const (@{const_name "Ball"}, _)) $
+ − 231
((Const (@{const_name "Respects"}, _)) $ ((Const (@{const_name "FUN_REL"}, _)) $ R1 $ R2)) $ P1)) =>
+ − 232
(let
+ − 233
val gl = Const (@{const_name "EQUIV"}, dummyT) $ R2;
+ − 234
val glc = HOLogic.mk_Trueprop (Syntax.check_term ctxt gl);
+ − 235
val _ = tracing (Syntax.string_of_term ctxt glc);
+ − 236
val eqv = Goal.prove ctxt [] [] glc (fn _ => equiv_tac rel_eqvs 1);
+ − 237
val thm = (@{thm eq_reflection} OF [@{thm ball_respects_refl} OF [eqv]]);
+ − 238
val R1c = cterm_of @{theory} R1;
+ − 239
val thmi = Drule.instantiate' [] [SOME R1c] thm;
+ − 240
val _ = tracing (Syntax.string_of_term ctxt (prop_of thmi));
+ − 241
val inst = matching_prs thy (term_of (Thm.lhs_of thmi)) ogl
+ − 242
val _ = tracing "AAA";
+ − 243
val thm2 = Drule.eta_contraction_rule (Drule.instantiate inst thmi);
+ − 244
val _ = tracing (Syntax.string_of_term ctxt (prop_of thm2));
+ − 245
in
+ − 246
SOME thm2
+ − 247
end
+ − 248
handle _ => NONE
+ − 249
+ − 250
)
+ − 251
| _ => NONE
394
+ − 252
end
+ − 253
*}
+ − 254
+ − 255
ML {*
400
+ − 256
fun regularize_tac ctxt rel_eqvs =
+ − 257
let
+ − 258
val subs1 = map (fn x => @{thm equiv_res_forall} OF [x]) rel_eqvs;
+ − 259
val subs2 = map (fn x => @{thm equiv_res_exists} OF [x]) rel_eqvs;
+ − 260
val subs = map (fn x => @{thm eq_reflection} OF [x]) (subs1 @ subs2);
+ − 261
val pat = [@{term "Ball (Respects (R1 ===> R2)) P"}];
+ − 262
val thy = ProofContext.theory_of ctxt
+ − 263
val simproc = Simplifier.simproc_i thy "" pat (K (ball_simproc rel_eqvs))
394
+ − 264
in
+ − 265
(ObjectLogic.full_atomize_tac) THEN'
414
+ − 266
(simp_tac (((Simplifier.context ctxt empty_ss) addsimps subs) addsimprocs [simproc])) THEN'
394
+ − 267
REPEAT_ALL_NEW (FIRST' [
400
+ − 268
(rtac @{thm RIGHT_RES_FORALL_REGULAR}),
+ − 269
(rtac @{thm LEFT_RES_EXISTS_REGULAR}),
+ − 270
(rtac @{thm left_ball_regular} THEN' (RANGE [SOLVES' (equiv_tac rel_eqvs)])),
+ − 271
(rtac @{thm right_bex_regular} THEN' (RANGE [SOLVES' (equiv_tac rel_eqvs)])),
+ − 272
(rtac @{thm ball_respects_refl} THEN' (RANGE [SOLVES' (equiv_tac rel_eqvs)])),
+ − 273
(rtac @{thm bex_respects_refl} THEN' (RANGE [SOLVES' (equiv_tac rel_eqvs)])),
+ − 274
(resolve_tac (Inductive.get_monos ctxt)),
+ − 275
rtac @{thm move_forall},
414
+ − 276
rtac @{thm move_exists},
+ − 277
(simp_tac (((Simplifier.context ctxt empty_ss) addsimps subs) addsimprocs [simproc]))
394
+ − 278
])
+ − 279
end
+ − 280
*}
+ − 281
397
+ − 282
393
+ − 283
lemma "\<lbrakk>P1 TYP TYP; \<And>A A' K K' x. \<lbrakk>(A::TY) = A'; P2 A A'; (K::KIND) = K'; P1 K K'\<rbrakk> \<Longrightarrow> P1 (KPI A x K) (KPI A' x K');
+ − 284
\<And>A A' K x x' K'.
+ − 285
\<lbrakk>(A ::TY) = A'; P2 A A'; (K :: KIND) = ([(x, x')] \<bullet> K'); P1 K ([(x, x')] \<bullet> K'); x \<notin> FV_ty A'; x \<notin> FV_kind K' - {x'}\<rbrakk>
+ − 286
\<Longrightarrow> P1 (KPI A x K) (KPI A' x' K');
+ − 287
\<And>i j. i = j \<Longrightarrow> P2 (TCONST i) (TCONST j);
+ − 288
\<And>A A' M M'. \<lbrakk>(A ::TY) = A'; P2 A A'; (M :: TRM) = M'; P3 M M'\<rbrakk> \<Longrightarrow> P2 (TAPP A M) (TAPP A' M');
+ − 289
\<And>A A' B B' x. \<lbrakk>(A ::TY) = A'; P2 A A'; (B ::TY) = B'; P2 B B'\<rbrakk> \<Longrightarrow> P2 (TPI A x B) (TPI A' x B');
+ − 290
\<And>A A' B x x' B'.
+ − 291
\<lbrakk>(A ::TY) = A'; P2 A A'; (B ::TY) = ([(x, x')] \<bullet> B'); P2 B ([(x, x')] \<bullet> B'); x \<notin> FV_ty B'; x \<notin> FV_ty B' - {x'}\<rbrakk>
+ − 292
\<Longrightarrow> P2 (TPI A x B) (TPI A' x' B');
+ − 293
\<And>i j m. i = j \<Longrightarrow> P3 (CONS i) (m (CONS j)); \<And>x y m. x = y \<Longrightarrow> P3 (VAR x) (m (VAR y));
+ − 294
\<And>M m M' N N'. \<lbrakk>(M :: TRM) = m M'; P3 M (m M'); (N :: TRM) = N'; P3 N N'\<rbrakk> \<Longrightarrow> P3 (APP M N) (APP M' N');
+ − 295
\<And>A A' M M' x. \<lbrakk>(A ::TY) = A'; P2 A A'; (M :: TRM) = M'; P3 M M'\<rbrakk> \<Longrightarrow> P3 (LAM A x M) (LAM A' x M');
+ − 296
\<And>A A' M x x' M' B'.
+ − 297
\<lbrakk>(A ::TY) = A'; P2 A A'; (M :: TRM) = ([(x, x')] \<bullet> M'); P3 M ([(x, x')] \<bullet> M'); x \<notin> FV_ty B'; x \<notin> FV_trm M' - {x'}\<rbrakk>
+ − 298
\<Longrightarrow> P3 (LAM A x M) (LAM A' x' M')\<rbrakk>
+ − 299
\<Longrightarrow> ((x1 :: KIND) = x2 \<longrightarrow> P1 x1 x2) \<and>
+ − 300
((x3 ::TY) = x4 \<longrightarrow> P2 x3 x4) \<and> ((x5 :: TRM) = x6 \<longrightarrow> P3 x5 x6)"
+ − 301
apply(tactic {* procedure_tac @{context} @{thm akind_aty_atrm.induct} 1 *})
400
+ − 302
apply(tactic {* regularize_tac @{context} @{thms alpha_EQUIVs} 1 *})
397
+ − 303
prefer 2
414
+ − 304
apply(tactic {* r_mk_comb_tac' @{context} rty quot rel_refl trans2 rsp_thms 1*})
+ − 305
apply (tactic {* clean_tac @{context} quot defs reps_same absrep 1 *})
393
+ − 306
301
+ − 307
ML {*
+ − 308
val rty_qty_rel =
+ − 309
[(@{typ kind}, (@{typ KIND}, @{term akind})),
+ − 310
(@{typ ty}, (@{typ TY}, @{term aty})),
+ − 311
(@{typ trm}, (@{typ TRM}, @{term atrm}))]
+ − 312
*}
+ − 313
+ − 314
print_quotients
+ − 315
394
+ − 316
ML {* val rty = [@{typ }] *}
301
+ − 317
ML {* val defs_sym = flat (map (add_lower_defs @{context}) defs) *}
+ − 318
ML {* val t_a = atomize_thm @{thm akind_aty_atrm.induct} *}
+ − 319
prove {* build_regularize_goal t_a rty rel @{context}
+ − 320
297
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 321
end
299
+ − 322
297
28b264299590
updated to new Isabelle version and added a new example file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
+ − 323
299
+ − 324