Skip to content

Commit 1e971a2

Browse files
author
Andrei Popescu
committed
more
1 parent f71e899 commit 1e971a2

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

thys/POPLmark/POPLmark_1A.thy

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ declare ty.intros[intro]
88

99
lemma well_scoped:
1010
assumes "\<Gamma> \<turnstile> S <: T"
11-
shows "S closed_in \<Gamma>" "T closed_in \<Gamma>"
11+
shows "FFVars_sftypeP S \<subseteq> dom \<Gamma>" "FFVars_sftypeP T \<subseteq> dom \<Gamma>"
1212
using assms proof (induction \<Gamma> S T rule: ty.induct)
1313
case (SA_Trans_TVar x U \<Gamma> T) {
1414
case 1 then show ?case using SA_Trans_TVar
@@ -17,11 +17,12 @@ next
1717
case 2 then show ?case using SA_Trans_TVar by simp
1818
} qed auto
1919

20+
declare SA_Refl_TVar[intro!]
2021

21-
lemma ty_refl: "\<lbrakk>wf \<Gamma> ; T closed_in \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> T <: T"
22+
lemma ty_refl: "\<lbrakk>wf \<Gamma> ; FFVars_sftypeP T \<subseteq> dom \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> T <: T"
2223
proof (binder_induction T arbitrary: \<Gamma> avoiding: "dom \<Gamma>" rule: sftypeP.strong_induct)
2324
case (TVr x \<Gamma>)
24-
then show ?case by blast
25+
then show ?case by (simp add: SA_Refl_TVar)
2526
qed (auto simp: Diff_single_insert SA_All wf_Cons)
2627

2728
lemma ty_permute: "\<lbrakk> \<Gamma> \<turnstile> S <: T ; wf \<Delta> ; set \<Gamma> = set \<Delta> \<rbrakk> \<Longrightarrow> \<Delta> \<turnstile> S <: T"
@@ -43,7 +44,7 @@ proof (induction \<Delta> rule: wf.induct)
4344
using wf_Cons by auto
4445
qed auto
4546

46-
lemma weaken_closed: "\<lbrakk> S closed_in \<Gamma> ; \<Gamma> \<bottom> \<Delta> \<rbrakk> \<Longrightarrow> S closed_in \<Gamma>,,\<Delta>"
47+
lemma weaken_closed: "\<lbrakk> FFVars_sftypeP S \<subseteq> dom \<Gamma> ; \<Gamma> \<bottom> \<Delta> \<rbrakk> \<Longrightarrow> FFVars_sftypeP S \<subseteq> dom (\<Gamma>,,\<Delta>)"
4748
by auto
4849

4950
lemma wf_concat_disjoint: "wf (\<Gamma>,, \<Delta>) \<Longrightarrow> \<Gamma> \<bottom> \<Delta>"
@@ -53,7 +54,7 @@ proof (induction \<Delta>)
5354
by (smt (verit, del_insts) Un_iff append_Cons disjoint_iff fst_conv image_iff inf.idem insertE list.inject list.simps(15) set_append set_empty2 wf.cases)
5455
qed simp
5556

56-
lemma wf_insert: "\<lbrakk> wf (\<Gamma>,,\<Delta>); x \<notin> dom \<Gamma> ; x \<notin> dom \<Delta> ; T closed_in \<Gamma> \<rbrakk> \<Longrightarrow> wf (\<Gamma>,,x<:T,,\<Delta>)"
57+
lemma wf_insert: "\<lbrakk> wf (\<Gamma>,,\<Delta>); x \<notin> dom \<Gamma> ; x \<notin> dom \<Delta> ; FFVars_sftypeP T \<subseteq> dom \<Gamma> \<rbrakk> \<Longrightarrow> wf (\<Gamma>,,x<:T,,\<Delta>)"
5758
by (induction \<Delta>) auto
5859

5960
lemma ty_weakening:
@@ -64,7 +65,8 @@ using assms proof (binder_induction \<Gamma> S T avoiding: "dom \<Delta>" \<Gamm
6465
then show ?case using ty.SA_Top weaken_closed wf_concat_disjoint by presburger
6566
next
6667
case (SA_Refl_TVar \<Gamma> x)
67-
then show ?case using ty.SA_Refl_TVar weaken_closed wf_concat_disjoint by presburger
68+
then show ?case using ty.SA_Refl_TVar weaken_closed wf_concat_disjoint
69+
by (meson ty_refl well_scoped(1))
6870
next
6971
case (SA_All \<Gamma> T\<^sub>1 S\<^sub>1 x S\<^sub>2 T\<^sub>2)
7072
have 1: "wf (\<Gamma>,, x <: T\<^sub>1,, \<Delta>)"
@@ -74,7 +76,7 @@ next
7476
show ?case using ty_permute[OF _ 2] 1 SA_All by auto
7577
qed auto
7678

77-
corollary ty_weakening_extend: "\<lbrakk> \<Gamma> \<turnstile> S <: T ; X \<notin> dom \<Gamma> ; Q closed_in \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma>,,X<:Q \<turnstile> S <: T"
79+
corollary ty_weakening_extend: "\<lbrakk> \<Gamma> \<turnstile> S <: T ; X \<notin> dom \<Gamma> ; FFVars_sftypeP Q \<subseteq> dom \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma>,,X<:Q \<turnstile> S <: T"
7880
using ty_weakening[of _ _ _ "[(X, Q)]"] by (metis append_Cons append_Nil wf_Cons wf_context)
7981

8082
lemma wf_concatD: "wf (\<Gamma>,, \<Delta>) \<Longrightarrow> wf \<Gamma>"
@@ -87,7 +89,7 @@ proof (induction \<Delta>)
8789
by (metis Pair_inject append_Nil fst_conv image_eqI set_ConsD wf_ConsE)
8890
qed auto
8991

90-
lemma narrow_wf: "\<lbrakk> wf ((\<Gamma> ,, X <: Q),, \<Delta>) ; R closed_in \<Gamma> \<rbrakk> \<Longrightarrow> wf ((\<Gamma>,, X <: R),, \<Delta>)"
92+
lemma narrow_wf: "\<lbrakk> wf ((\<Gamma> ,, X <: Q),, \<Delta>) ; FFVars_sftypeP R \<subseteq> dom \<Gamma> \<rbrakk> \<Longrightarrow> wf ((\<Gamma>,, X <: R),, \<Delta>)"
9193
proof (induction \<Delta>)
9294
case (Cons a \<Delta>)
9395
then have "wf (\<Gamma>,, X <: R,, \<Delta>)" by auto
@@ -99,7 +101,7 @@ qed auto
99101

100102
lemma SA_AllE1[consumes 2, case_names SA_Trans_TVar SA_All]:
101103
assumes "\<Gamma> \<turnstile> \<forall>X<:S\<^sub>1. S\<^sub>2 <: T" "X \<notin> dom \<Gamma>"
102-
and Top: "\<And>\<Gamma>. \<lbrakk>wf \<Gamma>; \<forall>X<:S\<^sub>1. S\<^sub>2 closed_in \<Gamma> \<rbrakk> \<Longrightarrow> R \<Gamma> (\<forall>X<:S\<^sub>1. S\<^sub>2) Top"
104+
and Top: "\<And>\<Gamma>. \<lbrakk>wf \<Gamma>; FFVars_sftypeP (\<forall>X<:S\<^sub>1. S\<^sub>2) \<subseteq> dom \<Gamma> \<rbrakk> \<Longrightarrow> R \<Gamma> (\<forall>X<:S\<^sub>1. S\<^sub>2) Top"
103105
and Forall: "\<And>\<Gamma> T\<^sub>1 T\<^sub>2. \<lbrakk> \<Gamma> \<turnstile> T\<^sub>1 <: S\<^sub>1 ; \<Gamma>,, X<:T\<^sub>1 \<turnstile> S\<^sub>2 <: T\<^sub>2 \<rbrakk> \<Longrightarrow> R \<Gamma> (\<forall>X<:S\<^sub>1. S\<^sub>2) (\<forall>X<:T\<^sub>1 . T\<^sub>2)"
104106
shows "R \<Gamma> (\<forall>X<:S\<^sub>1. S\<^sub>2) T"
105107
using assms(1,2) proof (binder_induction \<Gamma> "\<forall>X<:S\<^sub>1. S\<^sub>2" T avoiding: \<Gamma> "\<forall>X<:S\<^sub>1. S\<^sub>2" T rule: ty.strong_induct)
@@ -173,7 +175,7 @@ proof -
173175
have
174176
ty_trans: "\<lbrakk> \<Gamma> \<turnstile> S <: Q ; \<Gamma> \<turnstile> Q <: T \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> S <: T"
175177
and ty_narrow: "\<lbrakk> (\<Gamma>,, X <: Q),, \<Delta> \<turnstile> M <: N ; \<Gamma> \<turnstile> R <: Q ; wf (\<Gamma>,, X <: R,, \<Delta>) ;
176-
M closed_in (\<Gamma>,, X <: R,, \<Delta>) ; N closed_in (\<Gamma>,, X <: R,, \<Delta>) \<rbrakk> \<Longrightarrow> (\<Gamma>,, X <: R),, \<Delta> \<turnstile> M <: N"
178+
FFVars_sftypeP M \<subseteq> dom (\<Gamma>,, X <: R,, \<Delta>) ; FFVars_sftypeP N \<subseteq> dom (\<Gamma>,, X <: R,, \<Delta>) \<rbrakk> \<Longrightarrow> (\<Gamma>,, X <: R),, \<Delta> \<turnstile> M <: N"
177179
proof (binder_induction Q arbitrary: \<Gamma> \<Delta> S T M N X R avoiding: X "dom \<Gamma>" "dom \<Delta>" rule: sftypeP.strong_induct)
178180
case (TVr Y \<Gamma> \<Delta> S T M N X R)
179181
{
@@ -190,15 +192,15 @@ proof -
190192
proof (cases "X = Z")
191193
case True
192194
then have u: "U = TVr Y" using SA_Trans_TVar(1,2) context_determ wf_context by blast
193-
have "TVr Y closed_in (\<Gamma>,, Z <: R,, \<Delta>')" using SA_Trans_TVar(2) True u well_scoped(1) by fastforce
195+
have "FFVars_sftypeP (TVr Y) \<subseteq> dom (\<Gamma>,, Z <: R,, \<Delta>')" using SA_Trans_TVar(2) True u well_scoped(1) by fastforce
194196
then have "\<Gamma>,, Z <: R ,, \<Delta>' \<turnstile> TVr Y <: T" using SA_Trans_TVar True u by auto
195197
moreover have "\<Gamma>,, Z <: R,, \<Delta>' \<turnstile> R <: TVr Y" using ty_weakening[OF ty_weakening_extend[OF SA_Trans_TVar(4)]]
196198
by (metis SA_Trans_TVar(5) True wf_ConsE wf_concatD)
197199
ultimately have "\<Gamma>,, Z <: R,, \<Delta>' \<turnstile> R <: T" using ty_trans by blast
198200
then show ?thesis unfolding True u using ty.SA_Trans_TVar by auto
199201
next
200202
case False
201-
have x: "U closed_in (\<Gamma>,, X <: R,, \<Delta>')" using SA_Trans_TVar(2) well_scoped(1) by fastforce
203+
have x: "FFVars_sftypeP (U) \<subseteq> dom (\<Gamma>,, X <: R,, \<Delta>')" using SA_Trans_TVar(2) well_scoped(1) by fastforce
202204
show ?thesis
203205
apply (rule ty.SA_Trans_TVar)
204206
using SA_Trans_TVar False x by auto
@@ -234,7 +236,7 @@ proof -
234236
then show ?thesis unfolding True u using ty.SA_Trans_TVar by auto
235237
next
236238
case False
237-
have x: "U closed_in (\<Gamma>,, X <: R,, \<Delta>')" using SA_Trans_TVar(2) well_scoped(1) by fastforce
239+
have x: "FFVars_sftypeP (U) \<subseteq> dom (\<Gamma>,, X <: R,, \<Delta>')" using SA_Trans_TVar(2) well_scoped(1) by fastforce
238240
show ?thesis
239241
apply (rule ty.SA_Trans_TVar)
240242
using SA_Trans_TVar False x by auto
@@ -279,15 +281,15 @@ proof -
279281
proof (cases "X = Z")
280282
case True
281283
then have u: "U = (Q\<^sub>1 \<rightarrow> Q\<^sub>2)" using SA_Trans_TVar(1,2) context_determ wf_context by blast
282-
have "(Q\<^sub>1 \<rightarrow> Q\<^sub>2) closed_in (\<Gamma>,, Z <: R,, \<Delta>')" using SA_Trans_TVar(2) True u well_scoped(1) by fastforce
284+
have "FFVars_sftypeP (Q\<^sub>1 \<rightarrow> Q\<^sub>2) \<subseteq> dom (\<Gamma>,, Z <: R,, \<Delta>')" using SA_Trans_TVar(2) True u well_scoped(1) by fastforce
283285
then have "\<Gamma>,, Z <: R,, \<Delta>' \<turnstile> (Q\<^sub>1 \<rightarrow> Q\<^sub>2) <: T" using SA_Trans_TVar True u by auto
284286
moreover have "\<Gamma>,, Z <: R,, \<Delta>' \<turnstile> R <: (Q\<^sub>1 \<rightarrow> Q\<^sub>2)" using ty_weakening[OF ty_weakening_extend[OF SA_Trans_TVar(4)]]
285287
by (metis SA_Trans_TVar(5) True wf_ConsE wf_concatD)
286288
ultimately have "\<Gamma>,, Z <: R,, \<Delta>' \<turnstile> R <: T" using ty_trans by blast
287289
then show ?thesis unfolding True u using ty.SA_Trans_TVar by auto
288290
next
289291
case False
290-
have x: "U closed_in (\<Gamma>,, X <: R,, \<Delta>')" using SA_Trans_TVar(2) well_scoped(1) by fastforce
292+
have x: "FFVars_sftypeP U \<subseteq> dom (\<Gamma>,, X <: R,, \<Delta>')" using SA_Trans_TVar(2) well_scoped(1) by fastforce
291293
show ?thesis
292294
apply (rule ty.SA_Trans_TVar)
293295
using SA_Trans_TVar False x by auto
@@ -340,7 +342,7 @@ proof -
340342
proof (cases "Y = Z")
341343
case True
342344
then have u: "U = \<forall> X <: Q\<^sub>1 . Q\<^sub>2" using SA_Trans_TVar(1,2) context_determ wf_context by blast
343-
have "\<forall> X <: Q\<^sub>1 . Q\<^sub>2 closed_in \<Gamma>,, Z <: R,, \<Delta>'" using SA_Trans_TVar(2) True u well_scoped(1) by fastforce
345+
have "FFVars_sftypeP (\<forall> X <: Q\<^sub>1 . Q\<^sub>2) \<subseteq> dom (\<Gamma>,, Z <: R,, \<Delta>')" using SA_Trans_TVar(2) True u well_scoped(1) by fastforce
344346
then have "\<Gamma>,, Z <: R,, \<Delta>' \<turnstile> \<forall> X <: Q\<^sub>1 . Q\<^sub>2 <: T" using SA_Trans_TVar True u by auto
345347
moreover have "\<Gamma>,, Z <: R,, \<Delta>' \<turnstile> R <: \<forall> X <: Q\<^sub>1 . Q\<^sub>2" using ty_weakening[OF ty_weakening_extend[OF SA_Trans_TVar(4)]]
346348
by (metis SA_Trans_TVar(5) True wf_ConsE wf_concatD)

thys/POPLmark/SystemFSub.thy

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ theory SystemFSub
33
imports "SystemFSub_Types"
44
begin
55

6+
67
abbreviation in_context :: "var \<Rightarrow> sftype \<Rightarrow> \<Gamma>\<^sub>\<tau> \<Rightarrow> bool" ("_ <: _ \<in> _" [55,55,55] 60) where
78
"x <: t \<in> \<Gamma> \<equiv> (x, t) \<in> set \<Gamma>"
9+
810
abbreviation well_scoped :: "sftype \<Rightarrow> \<Gamma>\<^sub>\<tau> \<Rightarrow> bool" ("_ closed'_in _" [55, 55] 60) where
911
"well_scoped S \<Gamma> \<equiv> FFVars_sftypeP S \<subseteq> dom \<Gamma>"
1012

13+
1114
inductive wf :: "\<Gamma>\<^sub>\<tau> \<Rightarrow> bool" where
1215
wf_Nil[intro]: "wf []"
13-
| wf_Cons[intro!]: "\<lbrakk> x \<notin> dom \<Gamma> ; T closed_in \<Gamma> ; wf \<Gamma>\<rbrakk> \<Longrightarrow> wf (\<Gamma>,,x<:T)"
16+
| wf_Cons[intro!]: "\<lbrakk> x \<notin> dom \<Gamma> ; FFVars_sftypeP T \<subseteq> dom \<Gamma> ; wf \<Gamma>\<rbrakk> \<Longrightarrow> wf (\<Gamma>,,x<:T)"
1417

1518
inductive_cases
1619
wfE[elim]: "wf \<Gamma>"
@@ -29,7 +32,7 @@ lemma extend_eqvt:
2932

3033
lemma closed_in_eqvt:
3134
assumes "bij f" "|supp f| <o |UNIV::var set|"
32-
shows "S closed_in \<Gamma> \<Longrightarrow> rrename_sftypeP f S closed_in map_context f \<Gamma>"
35+
shows "FFVars_sftypeP S \<subseteq> dom \<Gamma> \<Longrightarrow> FFVars_sftypeP (rrename_sftypeP f S) \<subseteq> dom (map_context f \<Gamma>)"
3336
using assms by (auto simp: sftypeP.FFVars_rrenames)
3437

3538
lemma wf_eqvt:
@@ -74,8 +77,8 @@ qed
7477
(* *)
7578

7679
inductive ty :: "\<Gamma>\<^sub>\<tau> \<Rightarrow> sftype \<Rightarrow> sftype \<Rightarrow> bool" ("_ \<turnstile> _ <: _" [55,55,55] 60) where
77-
SA_Top: "\<lbrakk>wf \<Gamma>; S closed_in \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> S <: Top"
78-
| SA_Refl_TVar: "\<lbrakk>wf \<Gamma>; TVr x closed_in \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> TVr x <: TVr x"
80+
SA_Top: "\<lbrakk>wf \<Gamma>; FFVars_sftypeP S \<subseteq> dom \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> S <: Top"
81+
| SA_Refl_TVar: "\<lbrakk>wf \<Gamma>; FFVars_sftypeP (TVr x) \<subseteq> dom \<Gamma> \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> TVr x <: TVr x"
7982
| SA_Trans_TVar: "\<lbrakk> X<:U \<in> \<Gamma> ; \<Gamma> \<turnstile> U <: T \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> TVr X <: T"
8083
| SA_Arrow: "\<lbrakk> \<Gamma> \<turnstile> T\<^sub>1 <: S\<^sub>1 ; \<Gamma> \<turnstile> S\<^sub>2 <: T\<^sub>2 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> S\<^sub>1 \<rightarrow> S\<^sub>2 <: T\<^sub>1 \<rightarrow> T\<^sub>2"
8184
| SA_All: "\<lbrakk> \<Gamma> \<turnstile> T\<^sub>1 <: S\<^sub>1 ; \<Gamma>,, X<:T\<^sub>1 \<turnstile> S\<^sub>2 <: T\<^sub>2 \<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> \<forall>X<:S\<^sub>1. S\<^sub>2 <: \<forall>X<:T\<^sub>1 .T\<^sub>2"

0 commit comments

Comments
 (0)