Nominal/Ex/TypeSchemes.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Thu, 09 Jun 2011 15:03:58 +0900
changeset 2840 177a32a4f289
parent 2839 bcf48a1cb24b
child 2843 1ae3c9b2d557
permissions -rw-r--r--
Minor simplification
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory TypeSchemes
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
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
section {*** Type Schemes ***}
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
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
     7
thm Set.set_mp Set.subsetD
2709
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
     8
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
     9
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
    10
2486
b4ea19604b0b cleaned up two examples
Christian Urban <urbanc@in.tum.de>
parents: 2480
diff changeset
    11
(* defined as a single nominal datatype *)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
nominal_datatype ty =
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  Var "name"
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
| Fun "ty" "ty"
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
and tys =
2714
908750991c2f Experiments with substitution on set+
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2711
diff changeset
    17
  All xs::"name fset" ty::"ty" bind (set+) xs in ty
2434
92dc6cfa3a95 automatic lifting
Christian Urban <urbanc@in.tum.de>
parents: 2424
diff changeset
    18
2468
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
    19
thm ty_tys.distinct
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
    20
thm ty_tys.induct
2617
e44551d067e6 properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
    21
thm ty_tys.inducts
e44551d067e6 properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
    22
thm ty_tys.exhaust ty_tys.strong_exhaust
2468
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
    23
thm ty_tys.fv_defs
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
    24
thm ty_tys.bn_defs
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
    25
thm ty_tys.perm_simps
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
    26
thm ty_tys.eq_iff
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
    27
thm ty_tys.fv_bn_eqvt
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
    28
thm ty_tys.size_eqvt
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
    29
thm ty_tys.supports
2493
2e174807c891 added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents: 2486
diff changeset
    30
thm ty_tys.supp
2494
11133eb76f61 added Foo1 to explore a contrived example
Christian Urban <urbanc@in.tum.de>
parents: 2493
diff changeset
    31
thm ty_tys.fresh
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    33
fun
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    34
  lookup :: "(name \<times> ty) list \<Rightarrow> name \<Rightarrow> ty"
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    35
where
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    36
  "lookup [] Y = Var Y"
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    37
| "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
    38
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    39
lemma lookup_eqvt[eqvt]:
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    40
  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
    41
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
    42
apply(simp_all)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    43
done
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
    44
2709
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    45
lemma test:
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    46
  assumes a: "f x = Inl y"
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    47
  shows "(p \<bullet> (Sum_Type.Projl (f x))) = Sum_Type.Projl ((p \<bullet> f) (p \<bullet> x))"
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    48
using a 
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    49
apply(frule_tac p="p" in permute_boolI)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    50
apply(simp (no_asm_use) only: eqvts)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    51
apply(subst (asm) permute_fun_app_eq)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    52
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    53
apply(simp)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    54
done
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    55
2710
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
    56
lemma test2:
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
    57
  assumes a: "f x = Inl y"
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
    58
  shows "(p \<bullet> (Sum_Type.Projl (f x))) = Sum_Type.Projl (p \<bullet> (f x))"
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
    59
using a 
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
    60
apply(frule_tac p="p" in permute_boolI)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
    61
apply(simp (no_asm_use) only: eqvts)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
    62
apply(subst (asm) permute_fun_app_eq)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
    63
back
2709
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    64
apply(simp)
2710
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
    65
done
2709
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
    66
2727
c10b56d226ce further experiments with typeschemes subst
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2722
diff changeset
    67
lemma helper:
c10b56d226ce further experiments with typeschemes subst
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2722
diff changeset
    68
  assumes "A - C = A - D"
c10b56d226ce further experiments with typeschemes subst
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2722
diff changeset
    69
  and "B - C = B - D"
c10b56d226ce further experiments with typeschemes subst
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2722
diff changeset
    70
  and "E \<subseteq> A \<union> B"
c10b56d226ce further experiments with typeschemes subst
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2722
diff changeset
    71
  shows "E - C = E - D"
c10b56d226ce further experiments with typeschemes subst
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2722
diff changeset
    72
using assms
c10b56d226ce further experiments with typeschemes subst
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2722
diff changeset
    73
by blast
c10b56d226ce further experiments with typeschemes subst
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2722
diff changeset
    74
2833
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
    75
definition "MYUNDEFINED \<equiv> undefined"
2838
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    76
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    77
--"The following is accepted by 'function' but not by 'nominal_primrec'"
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    78
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
    79
function (default "sum_case (\<lambda>x. Inl undefined) (\<lambda>x. Inr undefined)")
2838
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    80
    subst  :: "(name \<times> ty) list \<Rightarrow> ty \<Rightarrow> ty"
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    81
and substs :: "(name \<times> ty) list \<Rightarrow> tys \<Rightarrow> tys"
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    82
where
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    83
  "subst \<theta> (Var X) = lookup \<theta> X"
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    84
| "subst \<theta> (Fun T1 T2) = Fun (subst \<theta> T1) (subst \<theta> T2)"
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    85
| "fset (map_fset atom xs) \<sharp>* \<theta> \<Longrightarrow> substs \<theta> (All xs T) = All xs (subst \<theta> 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
    86
thm subst_substs_graph_def
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
    87
thm subst_substs_sumC_def
2838
36544bac1659 More experiments with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2836
diff changeset
    88
oops
2833
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
    89
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
    90
lemma Abs_res_fcb:
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
    91
  fixes xs ys :: "('a :: at_base) set"
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
    92
    and S T :: "'b :: fs"
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
    93
  assumes e: "(Abs_res (atom ` xs) T) = (Abs_res (atom ` ys) S)"
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
    94
    and f1: "\<And>x. x \<in> atom ` xs \<Longrightarrow> x \<in> supp T \<Longrightarrow> x \<sharp> f xs T"
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
    95
    and f2: "\<And>x. supp T - atom ` xs = supp S - atom ` ys \<Longrightarrow> x \<in> atom ` ys \<Longrightarrow> x \<in> supp S \<Longrightarrow> x \<sharp> f xs T"
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
    96
    and eqv: "\<And>p. p \<bullet> T = S \<Longrightarrow> supp p \<subseteq> atom ` xs \<inter> supp T \<union> atom ` ys \<inter> supp S
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
    97
               \<Longrightarrow> p \<bullet> (atom ` xs \<inter> supp T) = atom ` ys \<inter> supp S \<Longrightarrow> p \<bullet> (f xs T) = f ys S"
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
    98
  shows "f xs T = f ys S"
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
    99
  using e apply -
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
   100
  apply (subst (asm) Abs_eq_res_set)
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
   101
  apply (subst (asm) Abs_eq_iff2)
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
   102
  apply (simp add: alphas)
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
   103
  apply (elim exE conjE)
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
   104
  apply(rule trans)
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
   105
  apply (rule_tac p="p" in supp_perm_eq[symmetric])
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
   106
  apply(rule fresh_star_supp_conv)
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
   107
  apply(drule fresh_star_perm_set_conv)
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
   108
  apply (rule finite_Diff)
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
   109
  apply (rule finite_supp)
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 (subgoal_tac "(atom ` xs \<inter> supp T \<union> atom ` ys \<inter> supp S) \<sharp>* f xs T")
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 (metis Un_absorb2 fresh_star_Un)
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
   112
  apply (subst fresh_star_Un)
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
   113
  apply (rule conjI)
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 (simp add: fresh_star_def f1)
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 (subgoal_tac "supp T - atom ` xs = supp S - atom ` ys")
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
   116
  apply (simp add: fresh_star_def f2)
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 blast
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: eqv)
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
   119
  done
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
   120
2836
1233af5cea95 Issue with 'default'
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2835
diff changeset
   121
nominal_primrec (default "\<lambda>(x :: (name \<times> ty) list \<times> ty + (name \<times> ty) list \<times> tys). MYUNDEFINED :: ty + tys")
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   122
    subst  :: "(name \<times> ty) list \<Rightarrow> ty \<Rightarrow> ty"
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   123
and substs :: "(name \<times> ty) list \<Rightarrow> tys \<Rightarrow> tys"
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   124
where
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   125
  "subst \<theta> (Var X) = lookup \<theta> X"
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   126
| "subst \<theta> (Fun T1 T2) = Fun (subst \<theta> T1) (subst \<theta> T2)"
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   127
| "fset (map_fset atom xs) \<sharp>* \<theta> \<Longrightarrow> substs \<theta> (All xs T) = All xs (subst \<theta> T)"
2833
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   128
thm subst_substs_graph_def
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   129
thm subst_substs_sumC_def
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   130
oops
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   131
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   132
nominal_primrec 
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   133
    subst  :: "(name \<times> ty) list \<Rightarrow> ty \<Rightarrow> ty"
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   134
and substs :: "(name \<times> ty) list \<Rightarrow> tys \<Rightarrow> tys"
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   135
where
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   136
  "subst \<theta> (Var X) = lookup \<theta> X"
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   137
| "subst \<theta> (Fun T1 T2) = Fun (subst \<theta> T1) (subst \<theta> T2)"
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   138
| "fset (map_fset atom xs) \<sharp>* \<theta> \<Longrightarrow> substs \<theta> (All xs T) = All xs (subst \<theta> T)"
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   139
thm subst_substs_graph_def
3503432262dc using the option "default" the function package allows one to give an explicit default value
Christian Urban <urbanc@in.tum.de>
parents: 2822
diff changeset
   140
thm subst_substs_sumC_def
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   141
apply(subgoal_tac "\<And>p x r. subst_substs_graph x r \<Longrightarrow> subst_substs_graph (p \<bullet> x) (p \<bullet> r)")
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   142
apply(simp add: eqvt_def)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   143
apply(rule allI)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   144
apply(simp add: permute_fun_def permute_bool_def)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   145
apply(rule ext)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   146
apply(rule ext)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   147
apply(rule iffI)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   148
apply(drule_tac x="p" in meta_spec)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   149
apply(drule_tac x="- p \<bullet> x" in meta_spec)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   150
apply(drule_tac x="- p \<bullet> xa" in meta_spec)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   151
apply(simp)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   152
apply(drule_tac x="-p" in meta_spec)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   153
apply(drule_tac x="x" in meta_spec)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   154
apply(drule_tac x="xa" in meta_spec)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   155
apply(simp)
2710
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   156
--"Eqvt One way"
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   157
apply(erule subst_substs_graph.induct)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   158
apply(perm_simp)
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   159
apply(rule subst_substs_graph.intros)
2709
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   160
apply(erule subst_substs_graph.cases)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   161
apply(simp (no_asm_use) only: eqvts)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   162
apply(subst test)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   163
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   164
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   165
apply(rotate_tac 1)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   166
apply(erule subst_substs_graph.cases)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   167
apply(subst test)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   168
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   169
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   170
apply(perm_simp)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   171
apply(rule subst_substs_graph.intros)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   172
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   173
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   174
apply(subst test)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   175
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   176
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   177
apply(perm_simp)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   178
apply(rule subst_substs_graph.intros)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   179
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   180
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   181
apply(simp)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   182
--"A"
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   183
apply(simp (no_asm_use) only: eqvts)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   184
apply(subst test)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   185
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   186
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   187
apply(rotate_tac 1)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   188
apply(erule subst_substs_graph.cases)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   189
apply(subst test)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   190
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   191
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   192
apply(perm_simp)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   193
apply(rule subst_substs_graph.intros)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   194
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   195
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   196
apply(subst test)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   197
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   198
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   199
apply(perm_simp)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   200
apply(rule subst_substs_graph.intros)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   201
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   202
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   203
apply(simp)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   204
--"A"
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   205
apply(simp)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   206
apply(erule subst_substs_graph.cases)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   207
apply(simp (no_asm_use) only: eqvts)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   208
apply(subst test)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   209
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   210
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   211
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   212
apply(rule subst_substs_graph.intros)
2710
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   213
apply (simp add: eqvts)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   214
apply (subgoal_tac "(p \<bullet> (atom ` fset xs)) \<sharp>* (p \<bullet> \<theta>)")
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   215
apply (simp add: image_eqvt eqvts_raw eqvts)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   216
apply (simp add: fresh_star_permute_iff)
2709
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   217
apply(perm_simp)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   218
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   219
apply(simp (no_asm_use) only: eqvts)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   220
apply(subst test)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   221
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   222
back
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   223
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   224
apply(rule subst_substs_graph.intros)
2710
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   225
apply (simp add: eqvts)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   226
apply (subgoal_tac "(p \<bullet> (atom ` fset xs)) \<sharp>* (p \<bullet> \<theta>)")
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   227
apply (simp add: image_eqvt eqvts_raw eqvts)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   228
apply (simp add: fresh_star_permute_iff)
2709
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   229
apply(perm_simp)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   230
apply(assumption)
eb4a2f4078ae some experiments
Christian Urban <urbanc@in.tum.de>
parents: 2707
diff changeset
   231
apply(simp)
2710
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   232
--"Eqvt done"
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
   233
apply(rule TrueI)
2710
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   234
apply (case_tac x)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   235
apply simp apply clarify 
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   236
apply (rule_tac y="b" in ty_tys.exhaust(1))
2787
1a6593bc494d added eq_iff and distinct lemmas of nominal datatypes to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 2728
diff changeset
   237
apply (auto)[1]
1a6593bc494d added eq_iff and distinct lemmas of nominal datatypes to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 2728
diff changeset
   238
apply (auto)[1]
2710
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   239
apply simp apply clarify 
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   240
apply (rule_tac ya="b" and c="a" in ty_tys.strong_exhaust(2))
2787
1a6593bc494d added eq_iff and distinct lemmas of nominal datatypes to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 2728
diff changeset
   241
apply (auto)[1]
1a6593bc494d added eq_iff and distinct lemmas of nominal datatypes to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 2728
diff changeset
   242
apply (auto)[5]
2710
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   243
--"LAST GOAL"
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   244
apply (simp add: meta_eq_to_obj_eq[OF subst_def, symmetric, unfolded fun_eq_iff])
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   245
apply (subgoal_tac "eqvt_at (\<lambda>(l, r). subst l r) (\<theta>', T)")
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   246
apply (thin_tac "eqvt_at subst_substs_sumC (Inl (\<theta>', 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
   247
prefer 2
2710
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   248
apply (simp add: eqvt_at_def subst_def)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   249
apply rule
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   250
apply (subgoal_tac "\<And>x. subst_substs_sumC (Inl (x)) = Inl (?y x)")
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   251
apply (subst test2)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   252
apply (drule_tac x="(\<theta>', T)" in meta_spec)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   253
apply assumption
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   254
apply simp
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   255
--"We require that for Inl it returns Inl. It doesn't work for undefined, but it does work for the following"
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   256
 apply (subgoal_tac "\<And>y. \<exists>z. (\<lambda>x. THE_default (sum_case (\<lambda>x. Inl undefined) (\<lambda>x. Inr undefined) x) (subst_substs_graph x)) (Inl y) = (Inl z)")
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   257
prefer 2
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   258
apply (simp add: THE_default_def)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   259
apply (case_tac "Ex1 (subst_substs_graph (Inl y))")
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   260
prefer 2
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   261
apply simp
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   262
apply (simp add: the1_equality)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   263
apply auto[1]
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   264
apply (erule_tac x="x" in allE)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   265
apply simp
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   266
apply(cases rule: subst_substs_graph.cases)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   267
apply assumption
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   268
apply (rule_tac x="lookup \<theta> X" in exI)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   269
apply clarify
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   270
apply (rule the1_equality)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   271
apply metis apply assumption
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   272
apply (rule_tac x="(Fun (Sum_Type.Projl (subst_substs_sum (Inl (\<theta>, T1))))
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   273
                  (Sum_Type.Projl (subst_substs_sum (Inl (\<theta>, T2)))))" in exI)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   274
apply clarify
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   275
apply (rule the1_equality)
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   276
apply metis apply assumption
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   277
apply clarify
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   278
--"This is exactly the assumption for the properly defined function"
7eebe0d5d298 Experiments with functions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2709
diff changeset
   279
defer
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
   280
apply clarify
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
   281
  apply (frule supp_eqvt_at)
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
   282
  apply (simp add: finite_supp)
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
   283
  apply (erule Abs_res_fcb)
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
   284
  apply (simp add: Abs_fresh_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
   285
  apply (simp add: Abs_fresh_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
   286
  apply auto[1]
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
   287
  apply (simp add: fresh_def fresh_star_def)
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
   288
  apply (erule contra_subsetD)
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
   289
  apply (simp add: supp_Pair)
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
   290
  apply blast
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
   291
  apply clarify
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
   292
  apply (simp)
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
   293
  apply (simp add: eqvt_at_def)
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
   294
  apply (subst Abs_eq_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
   295
  apply (rule_tac x="0::perm" in exI)
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
   296
  apply (subgoal_tac "p \<bullet> \<theta>' = \<theta>'")
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
   297
  apply (simp add: alphas fresh_star_zero)
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
   298
  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")
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
   299
  apply blast
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
   300
  apply (subgoal_tac "x \<in> supp(p \<bullet> \<theta>', p \<bullet> T)")
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
   301
  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
   302
  apply auto[1]
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
   303
  apply (subgoal_tac "(atom ` fset (p \<bullet> xs)) \<sharp>* \<theta>'")
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
   304
  apply (simp add: fresh_star_def fresh_def)
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
   305
  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
   306
  apply (simp add: 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
   307
  apply (simp add: fresh_star_def fresh_def)
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
   308
  apply (simp (no_asm) only: supp_eqvt[symmetric] Pair_eqvt[symmetric])
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
   309
  apply (subgoal_tac "p \<bullet> supp (subst \<theta>' T) \<subseteq> p \<bullet> supp (\<theta>', T)")
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
   310
  apply (erule subsetD)
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
   311
  apply (simp add: supp_eqvt)
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
   312
  apply (metis le_eqvt permute_boolI)
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
   313
  apply (rule perm_supp_eq)
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
   314
  apply (simp add: fresh_def fresh_star_def)
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
   315
  apply blast
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
   316
  oops
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   317
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   318
section {* defined as two separate nominal datatypes *}
2486
b4ea19604b0b cleaned up two examples
Christian Urban <urbanc@in.tum.de>
parents: 2480
diff changeset
   319
2308
387fcbd33820 fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents: 2181
diff changeset
   320
nominal_datatype ty2 =
387fcbd33820 fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents: 2181
diff changeset
   321
  Var2 "name"
387fcbd33820 fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents: 2181
diff changeset
   322
| Fun2 "ty2" "ty2"
387fcbd33820 fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents: 2181
diff changeset
   323
387fcbd33820 fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents: 2181
diff changeset
   324
nominal_datatype tys2 =
2634
3ce1089cdbf3 changed res keyword to set+ for restrictions; comment by a referee
Christian Urban <urbanc@in.tum.de>
parents: 2630
diff changeset
   325
  All2 xs::"name fset" ty::"ty2" bind (set+) xs in ty
2337
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents: 2308
diff changeset
   326
2468
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
   327
thm tys2.distinct
2630
8268b277d240 automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2622
diff changeset
   328
thm tys2.induct tys2.strong_induct
2617
e44551d067e6 properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
parents: 2611
diff changeset
   329
thm tys2.exhaust tys2.strong_exhaust
2468
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
   330
thm tys2.fv_defs
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
   331
thm tys2.bn_defs
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
   332
thm tys2.perm_simps
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
   333
thm tys2.eq_iff
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
   334
thm tys2.fv_bn_eqvt
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
   335
thm tys2.size_eqvt
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
   336
thm tys2.supports
2493
2e174807c891 added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents: 2486
diff changeset
   337
thm tys2.supp
2494
11133eb76f61 added Foo1 to explore a contrived example
Christian Urban <urbanc@in.tum.de>
parents: 2493
diff changeset
   338
thm tys2.fresh
2468
7b1470b55936 moved a proof to Abs
Christian Urban <urbanc@in.tum.de>
parents: 2454
diff changeset
   339
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   340
fun
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   341
  lookup2 :: "(name \<times> ty2) list \<Rightarrow> name \<Rightarrow> ty2"
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   342
where
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   343
  "lookup2 [] Y = Var2 Y"
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   344
| "lookup2 ((X, T) # Ts) Y = (if X = Y then T else lookup2 Ts Y)"
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
   345
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   346
lemma lookup2_eqvt[eqvt]:
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   347
  shows "(p \<bullet> lookup2 Ts T) = lookup2 (p \<bullet> Ts) (p \<bullet> T)"
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   348
  by (induct Ts T rule: lookup2.induct) simp_all
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   349
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   350
nominal_primrec
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   351
  subst  :: "(name \<times> ty2) list \<Rightarrow> ty2 \<Rightarrow> ty2"
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   352
where
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2676
diff changeset
   353
  "subst \<theta> (Var2 X) = lookup2 \<theta> X"
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   354
| "subst \<theta> (Fun2 T1 T2) = Fun2 (subst \<theta> T1) (subst \<theta> T2)"
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   355
  unfolding eqvt_def subst_graph_def
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   356
  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
   357
  apply(rule TrueI)
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   358
  apply(case_tac x)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   359
  apply(rule_tac y="b" in ty2.exhaust)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   360
  apply(blast)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   361
  apply(blast)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   362
  apply(simp_all add: ty2.distinct)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   363
  done
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   364
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   365
termination
2830
297cff1d1048 FCB for res binding and simplified proof of subst for type schemes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   366
  by (relation "measure (size o snd)") (simp_all add: ty2.size)
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   367
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   368
lemma subst_eqvt[eqvt]:
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   369
  shows "(p \<bullet> subst \<theta> T) = subst (p \<bullet> \<theta>) (p \<bullet> T)"
2830
297cff1d1048 FCB for res binding and simplified proof of subst for type schemes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   370
  by (induct \<theta> T rule: subst.induct) (simp_all add: lookup2_eqvt)
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   371
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   372
lemma supp_fun_app2_eqvt:
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   373
  assumes e: "eqvt f"
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   374
  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
   375
  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
   376
  by blast
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   377
 
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   378
lemma supp_subst:
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   379
  "supp (subst \<theta> t) \<subseteq> supp \<theta> \<union> supp t"
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   380
  apply (rule supp_fun_app2_eqvt)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   381
  unfolding eqvt_def by (simp add: eqvts_raw)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   382
 
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   383
lemma fresh_star_inter1:
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   384
  "xs \<sharp>* z \<Longrightarrow> (xs \<inter> ys) \<sharp>* z"
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   385
  unfolding fresh_star_def by blast
2830
297cff1d1048 FCB for res binding and simplified proof of subst for type schemes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   386
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   387
nominal_primrec
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   388
  substs :: "(name \<times> ty2) list \<Rightarrow> tys2 \<Rightarrow> tys2"
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   389
where
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   390
  "fset (map_fset atom xs) \<sharp>* \<theta> \<Longrightarrow> substs \<theta> (All2 xs t) = All2 xs (subst \<theta> t)"
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   391
  unfolding eqvt_def substs_graph_def
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   392
  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
   393
  apply auto[2]
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   394
  apply (rule_tac y="b" and c="a" in tys2.strong_exhaust)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   395
  apply auto
2830
297cff1d1048 FCB for res binding and simplified proof of subst for type schemes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   396
  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
   397
  apply (simp add: Abs_fresh_iff)
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   398
  apply (simp add: Abs_fresh_iff)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   399
  apply auto[1]
2830
297cff1d1048 FCB for res binding and simplified proof of subst for type schemes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   400
  apply (simp add: fresh_def fresh_star_def)
2832
76db0b854bf6 Simpler proof of TypeSchemes/substs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2831
diff changeset
   401
  apply (rule contra_subsetD[OF  supp_subst])
2801
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   402
  apply simp
2830
297cff1d1048 FCB for res binding and simplified proof of subst for type schemes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   403
  apply blast
2832
76db0b854bf6 Simpler proof of TypeSchemes/substs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2831
diff changeset
   404
  apply clarify
2830
297cff1d1048 FCB for res binding and simplified proof of subst for type schemes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   405
  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
   406
  apply (subst Abs_eq_iff)
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   407
  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
   408
  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
   409
  apply (simp add: alphas fresh_star_zero)
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
   410
  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
   411
  apply blast
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
   412
  apply (subgoal_tac "x \<in> supp(p \<bullet> \<theta>', p \<bullet> t)")
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
   413
  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
   414
  apply auto[1]
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
   415
  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
   416
  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
   417
  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
   418
  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
   419
  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
   420
  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
   421
  apply (simp add: supp_Pair)
2832
76db0b854bf6 Simpler proof of TypeSchemes/substs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2831
diff changeset
   422
  apply (rule perm_supp_eq)
76db0b854bf6 Simpler proof of TypeSchemes/substs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2831
diff changeset
   423
  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
   424
  apply blast
5ecb857e9de7 proved subst for All constructor in type schemes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2787
diff changeset
   425
  done
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   426
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   427
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   428
text {* Some Tests about Alpha-Equality *}
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   429
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   430
lemma
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   431
  shows "All {|a, b|} (Fun (Var a) (Var b)) = All {|b, a|} (Fun (Var a) (Var b))"
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   432
  apply(simp add: ty_tys.eq_iff Abs_eq_iff)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   433
  apply(rule_tac x="0::perm" in exI)
2676
028d5511c15f some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents: 2634
diff changeset
   434
  apply(simp add: alphas fresh_star_def ty_tys.supp supp_at_base)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   435
  done
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   436
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   437
lemma
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   438
  shows "All {|a, b|} (Fun (Var a) (Var b)) = All {|a, b|} (Fun (Var b) (Var a))"
2566
a59d8e1e3a17 moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents: 2556
diff changeset
   439
  apply(simp add: ty_tys.eq_iff Abs_eq_iff)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   440
  apply(rule_tac x="(atom a \<rightleftharpoons> atom b)" in exI)
2566
a59d8e1e3a17 moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents: 2556
diff changeset
   441
  apply(simp add: alphas fresh_star_def supp_at_base ty_tys.supp)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   442
  done
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   443
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   444
lemma
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   445
  shows "All {|a, b, c|} (Fun (Var a) (Var b)) = All {|a, b|} (Fun (Var a) (Var b))"
2566
a59d8e1e3a17 moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents: 2556
diff changeset
   446
  apply(simp add: ty_tys.eq_iff Abs_eq_iff)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   447
  apply(rule_tac x="0::perm" in exI)
2566
a59d8e1e3a17 moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents: 2556
diff changeset
   448
  apply(simp add: alphas fresh_star_def ty_tys.supp supp_at_base)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   449
done
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   450
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   451
lemma
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   452
  assumes a: "a \<noteq> b"
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   453
  shows "\<not>(All {|a, b|} (Fun (Var a) (Var b)) = All {|c|} (Fun (Var c) (Var c)))"
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   454
  using a
2566
a59d8e1e3a17 moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents: 2556
diff changeset
   455
  apply(simp add: ty_tys.eq_iff Abs_eq_iff)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   456
  apply(clarify)
2566
a59d8e1e3a17 moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents: 2556
diff changeset
   457
  apply(simp add: alphas fresh_star_def ty_tys.eq_iff ty_tys.supp supp_at_base)
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   458
  apply auto
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   459
  done
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   460
2566
a59d8e1e3a17 moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents: 2556
diff changeset
   461
1795
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   462
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   463
e39453c8b186 tuned type-schemes example
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   464
end