Nominal/Ex/TypeSchemes1.thy
author Christian Urban <urbanc@in.tum.de>
Mon, 02 Jan 2012 16:13:16 +0000
changeset 3102 5b5ade6bc889
parent 3100 8779fb01d8b4
child 3103 9a63d90d1752
permissions -rw-r--r--
added definition for generalisation of type schemes (for paper)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
     1
theory TypeSchemes1
2454
9ffee4eb1ae1 renamed NewParser to Nominal2
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
     2
imports "../Nominal2"
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
     5
section {*** Type Schemes defined as two separate nominal datatypes ***}
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
2556
8ed62410236e added a test about subtyping; disabled two tests, because of problem with function package
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
     7
atom_decl name 
8ed62410236e added a test about subtyping; disabled two tests, because of problem with function package
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
     8
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
nominal_datatype ty =
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  Var "name"
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    11
| Fun "ty" "ty" ("_ \<rightarrow> _")
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    12
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    13
nominal_datatype tys =
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    14
  All xs::"name fset" ty::"ty" binds (set+) xs in ty ("All [_]._")
2434
92dc6cfa3a95 automatic lifting
Christian Urban <urbanc@in.tum.de>
parents: 2424
diff changeset
    15
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    16
thm tys.distinct
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    17
thm tys.induct tys.strong_induct
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    18
thm tys.exhaust tys.strong_exhaust
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    19
thm tys.fv_defs
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    20
thm tys.bn_defs
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    21
thm tys.perm_simps
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    22
thm tys.eq_iff
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    23
thm tys.fv_bn_eqvt
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    24
thm tys.size_eqvt
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    25
thm tys.supports
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    26
thm tys.supp
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    27
thm tys.fresh
2885
1264f2a21ea9 some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
parents: 2867
diff changeset
    28
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    29
subsection {* Substitution function for types and type schemes *}
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    30
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    31
type_synonym 
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    32
  Subst = "(name \<times> ty) list"
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    34
fun
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    35
  lookup :: "Subst \<Rightarrow> name \<Rightarrow> ty"
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    36
where
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    37
  "lookup [] Y = Var Y"
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    38
| "lookup ((X, T) # Ts) Y = (if X = Y then T else lookup Ts Y)"
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    39
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    40
lemma lookup_eqvt[eqvt]:
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    41
  shows "(p \<bullet> lookup Ts T) = lookup (p \<bullet> Ts) (p \<bullet> T)"
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    42
apply(induct Ts T rule: lookup.induct)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    43
apply(simp_all)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    44
done
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    45
2981
c8acaded1777 temporary fix
Christian Urban <urbanc@in.tum.de>
parents: 2975
diff changeset
    46
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    47
nominal_primrec
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    48
  subst  :: "Subst \<Rightarrow> ty \<Rightarrow> ty" ("_<_>" [100,60] 120)
2838
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    49
where
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    50
  "\<theta><Var X> = lookup \<theta> X"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    51
| "\<theta><T1 \<rightarrow> T2> = (\<theta><T1>) \<rightarrow> (\<theta><T2>)"
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    52
  unfolding eqvt_def subst_graph_def
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    53
  apply (rule, perm_simp, rule)
2822
23befefc6e73 cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
parents: 2805
diff changeset
    54
  apply(rule TrueI)
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    55
  apply(case_tac x)
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    56
  apply(rule_tac y="b" in ty.exhaust)
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    57
  apply(blast)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    58
  apply(blast)
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    59
  apply(simp_all)
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    60
  done
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
    61
2973
d1038e67923a added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    62
termination (eqvt)
2859
2eeb75cccb8d all tests work again
Christian Urban <urbanc@in.tum.de>
parents: 2850
diff changeset
    63
  by lexicographic_order
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
    64
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    65
lemma supp_fun_app_eqvt:
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    66
  assumes e: "eqvt f"
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    67
  shows "supp (f a b) \<subseteq> supp a \<union> supp b"
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    68
  using supp_fun_app_eqvt[OF e] supp_fun_app
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    69
  by blast
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    70
 
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    71
lemma supp_subst:
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    72
  "supp (subst \<theta> t) \<subseteq> supp \<theta> \<union> supp t"
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    73
  apply (rule supp_fun_app_eqvt)
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    74
  unfolding eqvt_def 
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    75
  by (simp add: permute_fun_def subst.eqvt)
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    76
 
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
    77
nominal_primrec
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    78
  substs :: "(name \<times> ty) list \<Rightarrow> tys \<Rightarrow> tys" ("_<_>" [100,60] 120)
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
    79
where
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    80
  "fset (map_fset atom Xs) \<sharp>* \<theta> \<Longrightarrow> \<theta><All [Xs].T> = All [Xs].(\<theta><T>)"
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    81
  unfolding eqvt_def substs_graph_def
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
    82
  apply (rule, perm_simp, rule)
2822
23befefc6e73 cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
parents: 2805
diff changeset
    83
  apply auto[2]
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
    84
  apply (rule_tac y="b" and c="a" in tys.strong_exhaust)
2982
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    85
  apply auto[1]
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    86
  apply(simp)
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    87
  apply(erule conjE)
2830
297cff1d1048 FCB for res binding and simplified proof of subst for type schemes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
    88
  apply (erule Abs_res_fcb)
297cff1d1048 FCB for res binding and simplified proof of subst for type schemes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
    89
  apply (simp add: Abs_fresh_iff)
2982
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    90
  apply(simp add: fresh_def)
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    91
  apply(simp add: supp_Abs)
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    92
  apply(rule impI)
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    93
  apply(subgoal_tac "x \<notin> supp \<theta>")
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    94
  prefer 2
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    95
  apply(auto simp add: fresh_star_def fresh_def)[1]
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
    96
  apply(subgoal_tac "x \<in> supp T")
2982
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    97
  using supp_subst
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    98
  apply(blast)
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
    99
  using supp_subst
4a00077c008f completed the eqvt-proofs for functions; they are stored under the name function_name.eqvt and added to the eqvt-list
Christian Urban <urbanc@in.tum.de>
parents: 2981
diff changeset
   100
  apply(blast)
2832
76db0b854bf6 Simpler proof of TypeSchemes/substs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2831
diff changeset
   101
  apply clarify
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
   102
  apply (simp add: subst.eqvt)
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   103
  apply (subst Abs_eq_iff)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   104
  apply (rule_tac x="0::perm" in exI)
2832
76db0b854bf6 Simpler proof of TypeSchemes/substs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2831
diff changeset
   105
  apply (subgoal_tac "p \<bullet> \<theta>' = \<theta>'")
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   106
  apply (simp add: alphas fresh_star_zero)
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   107
  apply (subgoal_tac "\<And>x. x \<in> supp (subst \<theta>' (p \<bullet> T)) \<Longrightarrow> x \<in> p \<bullet> atom ` fset Xs \<longleftrightarrow> x \<in> atom ` fset Xsa")
2804
db0ed02eba6e Remove SMT
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2801
diff changeset
   108
  apply blast
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   109
  apply (subgoal_tac "x \<in> supp(p \<bullet> \<theta>', p \<bullet> T)")
2839
bcf48a1cb24b abs_res_fcb will be enough to finish the multiple-recursive proof, if we have a working 'default'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2838
diff changeset
   110
  apply (simp add: supp_Pair eqvts eqvts_raw)
bcf48a1cb24b abs_res_fcb will be enough to finish the multiple-recursive proof, if we have a working 'default'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2838
diff changeset
   111
  apply auto[1]
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   112
  apply (subgoal_tac "(atom ` fset (p \<bullet> Xs)) \<sharp>* \<theta>'")
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   113
  apply (simp add: fresh_star_def fresh_def)
2839
bcf48a1cb24b abs_res_fcb will be enough to finish the multiple-recursive proof, if we have a working 'default'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2838
diff changeset
   114
  apply(drule_tac p1="p" in iffD2[OF fresh_star_permute_iff])
bcf48a1cb24b abs_res_fcb will be enough to finish the multiple-recursive proof, if we have a working 'default'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2838
diff changeset
   115
  apply (simp add: eqvts eqvts_raw)
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   116
  apply (simp add: fresh_star_def fresh_def)
2839
bcf48a1cb24b abs_res_fcb will be enough to finish the multiple-recursive proof, if we have a working 'default'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2838
diff changeset
   117
  apply (drule subsetD[OF supp_subst])
bcf48a1cb24b abs_res_fcb will be enough to finish the multiple-recursive proof, if we have a working 'default'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2838
diff changeset
   118
  apply (simp add: supp_Pair)
2832
76db0b854bf6 Simpler proof of TypeSchemes/substs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2831
diff changeset
   119
  apply (rule perm_supp_eq)
76db0b854bf6 Simpler proof of TypeSchemes/substs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2831
diff changeset
   120
  apply (simp add: fresh_def fresh_star_def)
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   121
  apply blast
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   122
  done
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   123
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   124
text {* Some Tests about Alpha-Equality *}
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
lemma
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   127
  shows "All [{|a, b|}].((Var a) \<rightarrow> (Var b)) = All [{|b, a|}]. ((Var a) \<rightarrow> (Var b))"
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
   128
  apply(simp add: Abs_eq_iff)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
  apply(rule_tac x="0::perm" in exI)
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
   130
  apply(simp add: alphas fresh_star_def ty.supp supp_at_base)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
  done
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
lemma
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   134
  shows "All [{|a, b|}].((Var a) \<rightarrow> (Var b)) = All [{|a, b|}].((Var b) \<rightarrow> (Var a))"
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
   135
  apply(simp add: Abs_eq_iff)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
  apply(rule_tac x="(atom a \<rightleftharpoons> atom b)" in exI)
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
   137
  apply(simp add: alphas fresh_star_def supp_at_base ty.supp)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
  done
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
lemma
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   141
  shows "All [{|a, b, c|}].((Var a) \<rightarrow> (Var b)) = All [{|a, b|}].((Var a) \<rightarrow> (Var b))"
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
   142
  apply(simp add: Abs_eq_iff)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
  apply(rule_tac x="0::perm" in exI)
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
   144
  apply(simp add: alphas fresh_star_def ty.supp supp_at_base)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
done
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
lemma
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
  assumes a: "a \<noteq> b"
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   149
  shows "\<not>(All [{|a, b|}].((Var a) \<rightarrow> (Var b)) = All [{|c|}].((Var c) \<rightarrow> (Var c)))"
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
  using a
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
   151
  apply(simp add: Abs_eq_iff)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
  apply(clarify)
3100
8779fb01d8b4 separated the two versions of type schemes into two files
Christian Urban <urbanc@in.tum.de>
parents: 2982
diff changeset
   153
  apply(simp add: alphas fresh_star_def ty.supp supp_at_base)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
  apply auto
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
  done
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
2566
a59d8e1e3a17 moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents: 2556
diff changeset
   157
3102
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   158
text {* HERE *}
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   159
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   160
fun 
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   161
  compose::"Subst \<Rightarrow> Subst \<Rightarrow> Subst" ("_ \<circ> _" [100,100] 100)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   162
where
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   163
  "\<theta>\<^isub>1 \<circ> [] = \<theta>\<^isub>1"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   164
| "\<theta>\<^isub>1 \<circ> ((X,T)#\<theta>\<^isub>2) = (X,\<theta>\<^isub>1<T>)#(\<theta>\<^isub>1 \<circ> \<theta>\<^isub>2)"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   165
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   166
lemma compose_eqvt:
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   167
  fixes  \<theta>1 \<theta>2::"Subst"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   168
  shows "(p \<bullet> (\<theta>1 \<circ> \<theta>2)) = ((p \<bullet> \<theta>1) \<circ> (p \<bullet> \<theta>2))"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   169
apply(induct \<theta>2) 
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   170
apply(auto simp add: subst.eqvt)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   171
done
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   172
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   173
lemma compose_ty:
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   174
  fixes  \<theta>1 :: "Subst"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   175
  and    \<theta>2 :: "Subst"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   176
  and    T :: "ty"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   177
  shows "\<theta>1<\<theta>2<T>> = (\<theta>1\<circ>\<theta>2)<T>"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   178
proof (induct T rule: ty.induct)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   179
  case (Var X) 
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   180
  have "\<theta>1<lookup \<theta>2 X> = lookup (\<theta>1\<circ>\<theta>2) X" 
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   181
    by (induct \<theta>2) (auto)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   182
  then show ?case by simp
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   183
next
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   184
  case (Fun T1 T2)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   185
  then show ?case by simp
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   186
qed
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   187
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   188
fun
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   189
  dom :: "Subst \<Rightarrow> name fset"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   190
where
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   191
  "dom [] = {||}"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   192
| "dom ((X,T)#\<theta>) = {|X|} |\<union>| dom \<theta>"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   193
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   194
lemma dom_eqvt[eqvt]:
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   195
  shows "(p \<bullet> dom \<theta>) = dom (p \<bullet> \<theta>)"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   196
apply(induct \<theta> rule: dom.induct)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   197
apply(simp_all)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   198
done
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   199
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   200
nominal_primrec
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   201
  ftv  :: "ty \<Rightarrow> name fset"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   202
where
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   203
  "ftv (Var X) = {|X|}"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   204
| "ftv (T1 \<rightarrow> T2) = (ftv T1) |\<union>| (ftv T2)"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   205
  unfolding eqvt_def ftv_graph_def
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   206
  apply (rule, perm_simp, rule)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   207
  apply(auto)[2]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   208
  apply(rule_tac y="x" in ty.exhaust)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   209
  apply(blast)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   210
  apply(blast)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   211
  apply(simp_all)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   212
  done
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   213
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   214
termination (eqvt)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   215
  by lexicographic_order
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   216
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   217
lemma s1:
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   218
  fixes T::"ty"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   219
  shows "(X \<leftrightarrow> Y) \<bullet> T = [(X, Var Y),(Y, Var X)]<T>"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   220
apply(induct T rule: ty.induct)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   221
apply(simp_all)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   222
done
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   223
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   224
lemma s2:
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   225
  fixes T::"ty"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   226
  shows "[]<T> = T"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   227
apply(induct T rule: ty.induct)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   228
apply(simp_all)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   229
done
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   230
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   231
lemma perm_struct_induct_name[case_names pure zero swap]:
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   232
  assumes pure: "supp p \<subseteq> atom ` (UNIV::name set)"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   233
  and     zero: "P 0"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   234
  and     swap: "\<And>p a b::name. \<lbrakk>P p; a \<noteq> b\<rbrakk> \<Longrightarrow> P ((a \<leftrightarrow> b) + p)"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   235
  shows "P p"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   236
apply(rule_tac S="supp p \<inter> atom ` (UNIV::name set)" in perm_struct_induct)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   237
using pure
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   238
apply(auto)[1]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   239
apply(rule zero)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   240
apply(auto)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   241
apply(simp add: flip_def[symmetric])
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   242
apply(rule swap)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   243
apply(auto)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   244
done
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   245
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   246
lemma s3:
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   247
  fixes T::"ty"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   248
  assumes "supp p \<subseteq> atom ` (UNIV::name set)"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   249
  shows "\<exists>\<theta>. p \<bullet> T = \<theta><T>"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   250
apply(induct p rule: perm_struct_induct_name)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   251
apply(rule assms)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   252
apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   253
apply(rule_tac x="[]" in exI)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   254
apply(simp add: s2)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   255
apply(clarify)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   256
apply(simp) 
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   257
apply(rule_tac x="[(a, Var b),(b, Var a)] \<circ> \<theta>" in exI)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   258
apply(simp add: compose_ty[symmetric])
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   259
apply(simp add: s1)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   260
done
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   261
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   262
lemma s4:
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   263
  fixes x::"'a::fs"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   264
  assumes "supp x \<subseteq> atom ` (UNIV::name set)"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   265
  shows "\<exists>q. p \<bullet> x = q \<bullet> x \<and> supp q \<subseteq> atom ` (UNIV::name set)"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   266
apply(induct p rule: perm_simple_struct_induct)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   267
apply(rule_tac x="0" in exI)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   268
apply(auto)[1]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   269
apply(simp add: supp_zero_perm)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   270
apply(auto)[1]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   271
apply(case_tac "supp (a \<rightleftharpoons> b) \<subseteq> range atom")
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   272
apply(rule_tac x="(a \<rightleftharpoons> b) + q" in exI)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   273
apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   274
apply(rule subset_trans)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   275
apply(rule supp_plus_perm)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   276
apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   277
apply(rule_tac x="q" in exI)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   278
apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   279
apply(rule swap_fresh_fresh)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   280
apply(simp add: fresh_permute_left)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   281
apply(subst perm_supp_eq)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   282
apply(simp add: supp_swap)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   283
apply(simp add: supp_minus_perm)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   284
apply(simp add: fresh_star_def fresh_def)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   285
apply(simp add: supp_atom)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   286
apply(auto)[1]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   287
apply (metis atom_eqvt image_iff rangeI subsetD swap_atom_simps(2))
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   288
apply(simp add: supp_swap)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   289
using assms
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   290
apply(simp add: fresh_def)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   291
apply(auto)[1]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   292
apply (metis atom_eqvt image_iff rangeI subsetD swap_atom_simps(2))
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   293
apply(simp add: fresh_permute_left)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   294
apply(subst perm_supp_eq)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   295
apply(simp add: supp_swap)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   296
apply(simp add: supp_minus_perm)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   297
apply(simp add: fresh_star_def fresh_def)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   298
apply(simp add: supp_atom)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   299
apply(auto)[1]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   300
apply (metis atom_eqvt image_iff rangeI subsetD swap_atom_simps(2))
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   301
apply(simp add: supp_swap)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   302
using assms
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   303
apply(simp add: fresh_def)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   304
apply(auto)[1]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   305
apply (metis atom_eqvt image_iff rangeI subsetD swap_atom_simps(2))
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   306
done
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   307
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   308
lemma s5:
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   309
  fixes T::"ty"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   310
  shows "supp T \<subseteq> atom ` (UNIV::name set)"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   311
apply(induct T rule: ty.induct)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   312
apply(auto simp add: ty.supp supp_at_base)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   313
done
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   314
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   315
function
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   316
  generalises :: "ty \<Rightarrow> tys \<Rightarrow> bool" ("_ \<prec>\<prec> _")
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   317
where
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   318
  "T \<prec>\<prec> All [Xs].T' \<longleftrightarrow> (\<exists>\<theta>. \<theta><T'> = T)"
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   319
  apply auto[1]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   320
  apply (rule_tac y="b" in tys.exhaust)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   321
  apply auto[1]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   322
  apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   323
  apply(clarify)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   324
  apply(rule iffI)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   325
  apply(clarify)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   326
  apply(drule sym)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   327
  apply(simp add: Abs_eq_iff2)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   328
  apply(simp add: alphas)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   329
  apply(clarify)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   330
  using s4[OF s5]
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   331
  apply -
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   332
  apply(drule_tac x="p" in meta_spec)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   333
  apply(drule_tac x="T'a" in meta_spec)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   334
  apply(clarify)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   335
  apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   336
  using s3
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   337
  apply -
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   338
  apply(drule_tac x="q" in meta_spec)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   339
  apply(drule_tac x="T'a" in meta_spec)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   340
  apply(drule meta_mp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   341
  apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   342
  apply(clarify)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   343
  apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   344
  apply(rule_tac x="\<theta> \<circ> \<theta>'" in exI)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   345
  apply(simp add: compose_ty)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   346
  apply(auto)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   347
  apply(simp add: Abs_eq_iff2)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   348
  apply(simp add: alphas)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   349
  apply(clarify)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   350
  apply(drule_tac x="p" in meta_spec)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   351
  apply(drule_tac x="T'" in meta_spec)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   352
  apply(clarify)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   353
  apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   354
  apply(drule_tac x="q" in meta_spec)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   355
  apply(drule_tac x="T'" in meta_spec)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   356
  apply(drule meta_mp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   357
  apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   358
  apply(clarify)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   359
  apply(simp)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   360
  apply(rule_tac x="\<theta> \<circ> \<theta>'" in exI)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   361
  apply(simp add: compose_ty)
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   362
  done
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   363
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   364
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   365
5b5ade6bc889 added definition for generalisation of type schemes (for paper)
Christian Urban <urbanc@in.tum.de>
parents: 3100
diff changeset
   366
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   367
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   368
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   369
end