Nominal/Ex/Lambda.thy
author Christian Urban <urbanc@in.tum.de>
Thu, 19 Apr 2018 13:57:17 +0100
changeset 3245 017e33849f4d
parent 3244 a44479bde681
permissions -rw-r--r--
updated to Isabelle 2016-1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1797
fddb470720f1 renamed ExLam to Lambda and completed the proof of the strong ind principle; tuned paper
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
     1
theory Lambda
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
     2
imports 
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
     3
  "../Nominal2"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
     4
  "~~/src/HOL/Library/Monad_Syntax"
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
begin
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
3219
e5d9b6bca88c updated to new Isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3197
diff changeset
     7
lemma perm_commute: 
e5d9b6bca88c updated to new Isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3197
diff changeset
     8
  "a \<sharp> p \<Longrightarrow> a' \<sharp> p \<Longrightarrow> (a \<rightleftharpoons> a') + p = p + (a \<rightleftharpoons> a')"
e5d9b6bca88c updated to new Isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3197
diff changeset
     9
apply(rule plus_perm_eq)
e5d9b6bca88c updated to new Isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3197
diff changeset
    10
apply(simp add: supp_swap fresh_def)
e5d9b6bca88c updated to new Isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3197
diff changeset
    11
done
2885
1264f2a21ea9 some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
parents: 2868
diff changeset
    12
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
atom_decl name
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
3239
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    15
thm obtain_atom
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    16
3157
de89c95c5377 updated to latest changes (10 April) to quotient package (lift_raw_const only takes dummy theorem TrueI....in the future this will not work anymore)
Christian Urban <urbanc@in.tum.de>
parents: 3134
diff changeset
    17
ML {* trace := true *}
de89c95c5377 updated to latest changes (10 April) to quotient package (lift_raw_const only takes dummy theorem TrueI....in the future this will not work anymore)
Christian Urban <urbanc@in.tum.de>
parents: 3134
diff changeset
    18
2436
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2434
diff changeset
    19
nominal_datatype lam =
1800
78fdc6b36a1c changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents: 1797
diff changeset
    20
  Var "name"
2436
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2434
diff changeset
    21
| App "lam" "lam"
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
    22
| Lam x::"name" l::"lam"  binds x in l ("Lam [_]. _" [100, 100] 100)
2431
331873ebc5cd can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents: 2425
diff changeset
    23
3239
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    24
nominal_datatype environment = 
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    25
   Ni
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    26
 | En name closure environment
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    27
and closure = 
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    28
   Clos "lam" "environment"
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    29
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    30
thm environment_closure.exhaust(1)
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    31
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    32
nominal_function 
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    33
  env_lookup :: "environment => name => closure"
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    34
where
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    35
  "env_lookup Ni x = Clos (Var x) Ni"
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    36
| "env_lookup (En v clos rest) x = (if (v = x) then clos else env_lookup rest x)"
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    37
   apply (auto)
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    38
   apply (simp add: env_lookup_graph_aux_def eqvt_def)
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    39
   by (metis environment_closure.strong_exhaust(1))
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    40
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
    41
3232
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    42
lemma 
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    43
  "Lam [x]. Var x = Lam [y]. Var y"
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    44
proof -
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    45
  obtain c::name where fresh: "atom c \<sharp> (Lam [x]. Var x, Lam [y]. Var y)"
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    46
    by (metis obtain_fresh)
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    47
  have "Lam [x]. Var x = (c \<leftrightarrow> x) \<bullet> Lam [x]. Var x"
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    48
    using fresh by (rule_tac flip_fresh_fresh[symmetric]) (simp_all add: fresh_Pair)
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    49
  also have "... = Lam [c].Var c" by simp
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    50
  also have "... = (c \<leftrightarrow> y) \<bullet> Lam [c]. Var c"
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    51
    using fresh by (rule_tac flip_fresh_fresh[symmetric]) (auto simp add: fresh_Pair)
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    52
  also have "... = Lam [y]. Var y" by simp
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    53
  finally show "Lam [x]. Var x = Lam [y]. Var y" .
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    54
qed
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    55
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    56
definition 
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    57
  Name :: "nat \<Rightarrow> name" 
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    58
where 
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    59
  "Name n = Abs_name (Atom (Sort ''name'' []) n)"
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    60
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    61
definition
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    62
   "Ident2 = Lam [Name 1].(Var (Name 1))"
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    63
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    64
definition 
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    65
   "Ident x = Lam [x].(Var x)"
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    66
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    67
lemma "Ident2 = Ident x"
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    68
unfolding Ident_def Ident2_def
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    69
by simp
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    70
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    71
lemma "Ident x = Ident y"
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    72
unfolding Ident_def
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    73
by simp
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    74
3047
014edadaeb59 Add equivariance for alpha_lam_raw and abs_lam.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3046
diff changeset
    75
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    76
section {* Simple examples from Norrish 2004 *}
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    77
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
    78
nominal_function 
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    79
  is_app :: "lam \<Rightarrow> bool"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    80
where
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    81
  "is_app (Var x) = False"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    82
| "is_app (App t1 t2) = True"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    83
| "is_app (Lam [x]. t) = False"
3232
7bc38b93a1fc some small additions to examples
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3231
diff changeset
    84
thm is_app_graph_def is_app_graph_aux_def
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
    85
apply(simp add: eqvt_def is_app_graph_aux_def)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    86
apply(rule TrueI)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    87
apply(rule_tac y="x" in lam.exhaust)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    88
apply(auto)[3]
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    89
apply(all_trivials)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    90
done
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    91
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
    92
nominal_termination (eqvt) by lexicographic_order
2973
d1038e67923a added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
parents: 2972
diff changeset
    93
2974
b95a2065aa10 generated the partial eqvt-theorem for functions
Christian Urban <urbanc@in.tum.de>
parents: 2973
diff changeset
    94
thm is_app_def
2975
c62e26830420 preliminary version of automatically generation the eqvt-lemmas for functions defined with nominal_primrec
Christian Urban <urbanc@in.tum.de>
parents: 2974
diff changeset
    95
thm is_app.eqvt
2973
d1038e67923a added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
parents: 2972
diff changeset
    96
2975
c62e26830420 preliminary version of automatically generation the eqvt-lemmas for functions defined with nominal_primrec
Christian Urban <urbanc@in.tum.de>
parents: 2974
diff changeset
    97
thm eqvts
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
    98
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
    99
nominal_function 
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   100
  rator :: "lam \<Rightarrow> lam option"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   101
where
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   102
  "rator (Var x) = None"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   103
| "rator (App t1 t2) = Some t1"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   104
| "rator (Lam [x]. t) = None"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   105
apply(simp add: eqvt_def rator_graph_aux_def)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   106
apply(rule TrueI)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   107
apply(rule_tac y="x" in lam.exhaust)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   108
apply(auto)[3]
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   109
apply(simp_all)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   110
done
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   111
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   112
nominal_termination (eqvt) by lexicographic_order
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   113
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   114
nominal_function 
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   115
  rand :: "lam \<Rightarrow> lam option"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   116
where
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   117
  "rand (Var x) = None"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   118
| "rand (App t1 t2) = Some t2"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   119
| "rand (Lam [x]. t) = None"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   120
apply(simp add: eqvt_def rand_graph_aux_def)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   121
apply(rule TrueI)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   122
apply(rule_tac y="x" in lam.exhaust)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   123
apply(auto)[3]
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   124
apply(simp_all)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   125
done
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   126
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   127
nominal_termination (eqvt) by lexicographic_order
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   128
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   129
nominal_function 
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   130
  is_eta_nf :: "lam \<Rightarrow> bool"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   131
where
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   132
  "is_eta_nf (Var x) = True"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   133
| "is_eta_nf (App t1 t2) = (is_eta_nf t1 \<and> is_eta_nf t2)"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   134
| "is_eta_nf (Lam [x]. t) = (is_eta_nf t \<and> 
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   135
                             ((is_app t \<and> rand t = Some (Var x)) \<longrightarrow> atom x \<in> supp (rator t)))"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   136
apply(simp add: eqvt_def is_eta_nf_graph_aux_def)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   137
apply(rule TrueI)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   138
apply(rule_tac y="x" in lam.exhaust)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   139
apply(auto)[3]
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   140
using [[simproc del: alpha_lst]]
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   141
apply(simp_all)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   142
apply(erule_tac c="()" in Abs_lst1_fcb2')
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   143
apply(simp_all add: pure_fresh fresh_star_def)[3]
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   144
apply(simp add: eqvt_at_def conj_eqvt)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   145
apply(simp add: eqvt_at_def conj_eqvt)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   146
done
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   147
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   148
nominal_termination (eqvt) by lexicographic_order
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   149
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   150
nominal_datatype path = Left | Right | In
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   151
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   152
section {* Paths to a free variables *} 
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   153
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   154
instance path :: pure
3245
017e33849f4d updated to Isabelle 2016-1
Christian Urban <urbanc@in.tum.de>
parents: 3244
diff changeset
   155
apply(standard)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   156
apply(induct_tac "x::path" rule: path.induct)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   157
apply(simp_all)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   158
done
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   159
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   160
nominal_function 
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   161
  var_pos :: "name \<Rightarrow> lam \<Rightarrow> (path list) set"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   162
where
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   163
  "var_pos y (Var x) = (if y = x then {[]} else {})"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   164
| "var_pos y (App t1 t2) = (Cons Left ` (var_pos y t1)) \<union> (Cons Right ` (var_pos y t2))"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   165
| "atom x \<sharp> y \<Longrightarrow> var_pos y (Lam [x]. t) = (Cons In ` (var_pos y t))"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   166
apply(simp add: eqvt_def var_pos_graph_aux_def)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   167
apply(rule TrueI)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   168
apply(case_tac x)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   169
apply(rule_tac y="b" and c="a" in lam.strong_exhaust)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   170
apply(auto simp add: fresh_star_def)[3]
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   171
using [[simproc del: alpha_lst]]
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   172
apply(simp_all)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   173
apply(erule conjE)+
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   174
apply(erule_tac Abs_lst1_fcb2)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   175
apply(simp add: pure_fresh)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   176
apply(simp add: fresh_star_def)
3183
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   177
apply(simp only: eqvt_at_def)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   178
apply(perm_simp)
3183
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   179
apply(simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   180
apply(simp add: perm_supp_eq)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   181
apply(simp only: eqvt_at_def)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   182
apply(perm_simp)
3183
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   183
apply(simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   184
apply(simp add: perm_supp_eq)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   185
done
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   186
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   187
nominal_termination (eqvt) by lexicographic_order
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   188
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   189
lemma var_pos1:
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   190
  assumes "atom y \<notin> supp t"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   191
  shows "var_pos y t = {}"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   192
using assms
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   193
apply(induct t rule: var_pos.induct)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   194
apply(simp_all add: lam.supp supp_at_base fresh_at_base)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   195
done
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   196
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   197
lemma var_pos2:
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   198
  shows "var_pos y (Lam [y].t) = {}"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   199
apply(rule var_pos1)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   200
apply(simp add: lam.supp)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   201
done
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   202
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   203
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   204
text {* strange substitution operation *}
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   205
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   206
nominal_function
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   207
  subst' :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam"  ("_ [_ ::== _]" [90, 90, 90] 90)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   208
where
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   209
  "(Var x)[y ::== s] = (if x = y then s else (Var x))"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   210
| "(App t1 t2)[y ::== s] = App (t1[y ::== s]) (t2[y ::== s])"
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   211
| "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::== s] = Lam [x].(t[y ::== (App (Var y) s)])"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   212
  apply(simp add: eqvt_def subst'_graph_aux_def)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   213
  apply(rule TrueI)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   214
  apply(case_tac x)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   215
  apply(rule_tac y="a" and c="(b, c)" in lam.strong_exhaust)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   216
  apply(auto simp add: fresh_star_def)[3]
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   217
  using [[simproc del: alpha_lst]]
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   218
  apply(simp_all)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   219
  apply(erule conjE)+
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   220
  apply (erule_tac c="(ya,sa)" in Abs_lst1_fcb2)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   221
  apply(simp_all add: Abs_fresh_iff)
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   222
  apply(simp add: fresh_star_def fresh_Pair)
3183
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   223
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   224
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   225
  apply(simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   226
  apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   227
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   228
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   229
  apply(simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   230
  apply(simp add: fresh_star_Pair perm_supp_eq)
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   231
done
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   232
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   233
nominal_termination (eqvt) by lexicographic_order
2951
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   234
d75b3d8529e7 added some relatively simple examples from paper by Norrish
Christian Urban <urbanc@in.tum.de>
parents: 2950
diff changeset
   235
2868
2b8e387d2dfc got rid of the boolean flag in the raw_equivariance function
Christian Urban <urbanc@in.tum.de>
parents: 2860
diff changeset
   236
section {* free name function *}
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   237
3239
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
   238
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
   239
lemma fresh_removeAll_name:
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
   240
  fixes x::"name"
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
   241
    and xs:: "name list"
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
   242
  shows "atom x \<sharp> (removeAll y xs) \<longleftrightarrow> (atom x \<sharp> xs \<or> x = y)"
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
   243
  apply (induct xs)
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
   244
  apply(auto simp add: fresh_def supp_Nil supp_Cons supp_at_base)
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
   245
  done
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
   246
67370521c09c updated for Isabelle 2015
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3236
diff changeset
   247
2860
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   248
text {* first returns an atom list *}
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   249
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   250
nominal_function 
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   251
  frees_lst :: "lam \<Rightarrow> atom list"
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   252
where
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   253
  "frees_lst (Var x) = [atom x]"
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   254
| "frees_lst (App t1 t2) = frees_lst t1 @ frees_lst t2"
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   255
| "frees_lst (Lam [x]. t) = removeAll (atom x) (frees_lst t)"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   256
apply(simp add: eqvt_def frees_lst_graph_aux_def)
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   257
apply(rule TrueI)
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   258
apply(rule_tac y="x" in lam.exhaust)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   259
using [[simproc del: alpha_lst]]
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   260
apply(auto)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   261
apply (erule_tac c="()" in Abs_lst1_fcb2)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   262
apply(simp add: supp_removeAll fresh_def)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   263
apply(simp add: fresh_star_def fresh_Unit)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   264
apply(simp add: eqvt_at_def removeAll_eqvt atom_eqvt)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   265
apply(simp add: eqvt_at_def removeAll_eqvt atom_eqvt)
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   266
done
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   267
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   268
nominal_termination (eqvt) by lexicographic_order
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   269
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   270
text {* a small test lemma *}
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   271
lemma shows "supp t = set (frees_lst t)"
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   272
  by (induct t rule: frees_lst.induct) (simp_all add: lam.supp supp_at_base)
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   273
2860
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   274
text {* second returns an atom set - therefore needs an invariant *}
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   275
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   276
nominal_function (invariant "\<lambda>x (y::atom set). finite y")
2821
c7d4bd9e89e0 fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
parents: 2819
diff changeset
   277
  frees_set :: "lam \<Rightarrow> atom set"
c7d4bd9e89e0 fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
parents: 2819
diff changeset
   278
where
c7d4bd9e89e0 fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
parents: 2819
diff changeset
   279
  "frees_set (Var x) = {atom x}"
c7d4bd9e89e0 fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
parents: 2819
diff changeset
   280
| "frees_set (App t1 t2) = frees_set t1 \<union> frees_set t2"
c7d4bd9e89e0 fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
parents: 2819
diff changeset
   281
| "frees_set (Lam [x]. t) = (frees_set t) - {atom x}"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   282
  apply(simp add: eqvt_def frees_set_graph_aux_def)
2845
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   283
  apply(erule frees_set_graph.induct)
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   284
  apply(auto)[9]
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   285
  apply(rule_tac y="x" in lam.exhaust)
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   286
  apply(auto)[3]
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   287
  using [[simproc del: alpha_lst]]
2845
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   288
  apply(simp)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   289
  apply(erule_tac c="()" in Abs_lst1_fcb2)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   290
  apply(simp add: fresh_minus_atom_set)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   291
  apply(simp add: fresh_star_def fresh_Unit)
3183
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   292
  apply(simp add: Diff_eqvt eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   293
  apply(simp add: Diff_eqvt eqvt_at_def)
2845
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   294
  done
2821
c7d4bd9e89e0 fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
parents: 2819
diff changeset
   295
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   296
nominal_termination (eqvt) 
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   297
  by lexicographic_order
2821
c7d4bd9e89e0 fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
parents: 2819
diff changeset
   298
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: 2821
diff changeset
   299
lemma "frees_set t = supp t"
2845
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   300
  by (induct rule: frees_set.induct) (simp_all add: lam.supp supp_at_base)
2821
c7d4bd9e89e0 fixed problem with earlier commit about nominal_function_common; added facility for specifying an invariant - added a definition of frees_set which need a finiteness invariant
Christian Urban <urbanc@in.tum.de>
parents: 2819
diff changeset
   301
2868
2b8e387d2dfc got rid of the boolean flag in the raw_equivariance function
Christian Urban <urbanc@in.tum.de>
parents: 2860
diff changeset
   302
section {* height function *}
2431
331873ebc5cd can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
parents: 2425
diff changeset
   303
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   304
nominal_function
2678
494b859bfc16 defined height as a function that returns an integer
Christian Urban <urbanc@in.tum.de>
parents: 2675
diff changeset
   305
  height :: "lam \<Rightarrow> int"
2666
324a5d1289a3 added a few examples of functions to Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2664
diff changeset
   306
where
2678
494b859bfc16 defined height as a function that returns an integer
Christian Urban <urbanc@in.tum.de>
parents: 2675
diff changeset
   307
  "height (Var x) = 1"
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   308
| "height (App t1 t2) = max (height t1) (height t2) + 1"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   309
| "height (Lam [x].t) = height t + 1"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   310
  apply(simp add: eqvt_def height_graph_aux_def)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   311
  apply(rule TrueI)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   312
  apply(rule_tac y="x" in lam.exhaust)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   313
  using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   314
  apply(auto)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   315
  apply (erule_tac c="()" in Abs_lst1_fcb2)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   316
  apply(simp_all add: fresh_def pure_supp eqvt_at_def fresh_star_def)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   317
  done
2666
324a5d1289a3 added a few examples of functions to Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2664
diff changeset
   318
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   319
nominal_termination (eqvt)
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   320
  by lexicographic_order
2666
324a5d1289a3 added a few examples of functions to Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2664
diff changeset
   321
  
2707
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2685
diff changeset
   322
thm height.simps
747ebf2f066d made eqvt-proof explicit in the function definitions
Christian Urban <urbanc@in.tum.de>
parents: 2685
diff changeset
   323
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   324
  
2868
2b8e387d2dfc got rid of the boolean flag in the raw_equivariance function
Christian Urban <urbanc@in.tum.de>
parents: 2860
diff changeset
   325
section {* capture-avoiding substitution *}
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   326
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   327
nominal_function
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   328
  subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam"  ("_ [_ ::= _]" [90, 90, 90] 90)
2675
68ccf847507d defined properly substitution
Christian Urban <urbanc@in.tum.de>
parents: 2669
diff changeset
   329
where
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   330
  "(Var x)[y ::= s] = (if x = y then s else (Var x))"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   331
| "(App t1 t2)[y ::= s] = App (t1[y ::= s]) (t2[y ::= s])"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   332
| "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::= s] = Lam [x].(t[y ::= s])"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   333
  apply(simp add: eqvt_def subst_graph_aux_def)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   334
  apply(rule TrueI)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   335
  using [[simproc del: alpha_lst]]
3085
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3065
diff changeset
   336
  apply(auto)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   337
  apply(rule_tac y="a" and c="(aa, b)" in lam.strong_exhaust)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   338
  apply(blast)+
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   339
  using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   340
  apply(simp_all add: fresh_star_def fresh_Pair_elim)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   341
  apply (erule_tac c="(ya,sa)" in Abs_lst1_fcb2)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   342
  apply(simp_all add: Abs_fresh_iff)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   343
  apply(simp add: fresh_star_def fresh_Pair)
3183
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   344
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   345
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   346
  apply(simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   347
  apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   348
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   349
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   350
  apply(simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   351
  apply(simp add: fresh_star_Pair perm_supp_eq)
2675
68ccf847507d defined properly substitution
Christian Urban <urbanc@in.tum.de>
parents: 2669
diff changeset
   352
done
68ccf847507d defined properly substitution
Christian Urban <urbanc@in.tum.de>
parents: 2669
diff changeset
   353
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   354
nominal_termination (eqvt)
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   355
  by lexicographic_order
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   356
2975
c62e26830420 preliminary version of automatically generation the eqvt-lemmas for functions defined with nominal_primrec
Christian Urban <urbanc@in.tum.de>
parents: 2974
diff changeset
   357
thm subst.eqvt
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   358
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   359
lemma forget:
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   360
  shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
2845
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   361
  by (nominal_induct t avoiding: x s rule: lam.strong_induct)
3181
ca162f0a7957 added to the simplifier nominal_datatype.fresh lemmas
Christian Urban <urbanc@in.tum.de>
parents: 3174
diff changeset
   362
     (auto simp add: fresh_at_base)
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   363
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   364
text {* same lemma but with subst.induction *}
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   365
lemma forget2:
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   366
  shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   367
  apply(induct t x s rule: subst.induct)
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   368
  using [[simproc del: alpha_lst]]
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   369
  apply(auto simp add:  flip_fresh_fresh fresh_Pair fresh_at_base)
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   370
  done
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   371
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   372
lemma fresh_fact:
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   373
  fixes z::"name"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   374
  assumes a: "atom z \<sharp> s"
2845
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   375
      and b: "z = y \<or> atom z \<sharp> t"
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   376
  shows "atom z \<sharp> t[y ::= s]"
2845
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   377
  using a b
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   378
  by (nominal_induct t avoiding: z y s rule: lam.strong_induct)
3181
ca162f0a7957 added to the simplifier nominal_datatype.fresh lemmas
Christian Urban <urbanc@in.tum.de>
parents: 3174
diff changeset
   379
      (auto simp add:  fresh_at_base)
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   380
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   381
lemma substitution_lemma:  
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   382
  assumes a: "x \<noteq> y" "atom x \<sharp> u"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   383
  shows "t[x ::= s][y ::= u] = t[y ::= u][x ::= s[y ::= u]]"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   384
using a 
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   385
by (nominal_induct t avoiding: x y s u rule: lam.strong_induct)
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   386
   (auto simp add: fresh_fact forget)
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   387
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   388
lemma subst_rename: 
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   389
  assumes a: "atom y \<sharp> t"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   390
  shows "t[x ::= s] = ((y \<leftrightarrow> x) \<bullet>t)[y ::= s]"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   391
using a 
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   392
apply (nominal_induct t avoiding: x y s rule: lam.strong_induct)
3181
ca162f0a7957 added to the simplifier nominal_datatype.fresh lemmas
Christian Urban <urbanc@in.tum.de>
parents: 3174
diff changeset
   393
apply (auto simp add:  fresh_at_base)
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   394
done
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   395
2767
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   396
lemma height_ge_one:
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   397
  shows "1 \<le> (height e)"
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   398
by (induct e rule: lam.induct) (simp_all)
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   399
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   400
theorem height_subst:
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   401
  shows "height (e[x::=e']) \<le> ((height e) - 1) + (height e')"
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   402
proof (nominal_induct e avoiding: x e' rule: lam.strong_induct)
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   403
  case (Var y)
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   404
  have "1 \<le> height e'" by (rule height_ge_one)
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   405
  then show "height (Var y[x::=e']) \<le> height (Var y) - 1 + height e'" by simp
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   406
next
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   407
  case (Lam y e1)
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   408
  hence ih: "height (e1[x::=e']) \<le> ((height e1) - 1) + (height e')" by simp
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   409
  moreover
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   410
  have vc: "atom y\<sharp>x" "atom y\<sharp>e'" by fact+ (* usual variable convention *)
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   411
  ultimately show "height ((Lam [y]. e1)[x::=e']) \<le> height (Lam [y]. e1) - 1 + height e'" by simp
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   412
next
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   413
  case (App e1 e2)
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   414
  hence ih1: "height (e1[x::=e']) \<le> ((height e1) - 1) + (height e')"
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   415
    and ih2: "height (e2[x::=e']) \<le> ((height e2) - 1) + (height e')" by simp_all
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   416
  then show "height ((App e1 e2)[x::=e']) \<le> height (App e1 e2) - 1 + height e'"  by simp
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   417
qed
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   418
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   419
subsection {* single-step beta-reduction *}
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   420
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   421
inductive 
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   422
  beta :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>b _" [80,80] 80)
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   423
where
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   424
  b1[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> App t1 s \<longrightarrow>b App t2 s"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   425
| b2[intro]: "s1 \<longrightarrow>b s2 \<Longrightarrow> App t s1 \<longrightarrow>b App t s2"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   426
| b3[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> Lam [x]. t1 \<longrightarrow>b Lam [x]. t2"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   427
| b4[intro]: "atom x \<sharp> s \<Longrightarrow> App (Lam [x]. t) s \<longrightarrow>b t[x ::= s]"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   428
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   429
equivariance beta
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   430
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   431
nominal_inductive beta
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   432
  avoids b4: "x"
3181
ca162f0a7957 added to the simplifier nominal_datatype.fresh lemmas
Christian Urban <urbanc@in.tum.de>
parents: 3174
diff changeset
   433
  by (simp_all add: fresh_star_def fresh_Pair  fresh_fact)
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   434
3219
e5d9b6bca88c updated to new Isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3197
diff changeset
   435
thm beta.strong_induct
e5d9b6bca88c updated to new Isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3197
diff changeset
   436
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   437
text {* One-Reduction *}
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   438
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   439
inductive 
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   440
  One :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>1 _" [80,80] 80)
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   441
where
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   442
  o1[intro]: "Var x \<longrightarrow>1 Var x"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   443
| o2[intro]: "\<lbrakk>t1 \<longrightarrow>1 t2; s1 \<longrightarrow>1 s2\<rbrakk> \<Longrightarrow> App t1 s1 \<longrightarrow>1 App t2 s2"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   444
| o3[intro]: "t1 \<longrightarrow>1 t2 \<Longrightarrow> Lam [x].t1 \<longrightarrow>1 Lam [x].t2"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   445
| o4[intro]: "\<lbrakk>atom x \<sharp> (s1, s2); t1 \<longrightarrow>1 t2; s1 \<longrightarrow>1 s2\<rbrakk> \<Longrightarrow> App (Lam [x].t1) s1 \<longrightarrow>1 t2[x ::= s2]"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   446
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   447
equivariance One
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   448
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   449
nominal_inductive One 
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   450
  avoids o3: "x"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   451
      |  o4: "x"
3181
ca162f0a7957 added to the simplifier nominal_datatype.fresh lemmas
Christian Urban <urbanc@in.tum.de>
parents: 3174
diff changeset
   452
  by (simp_all add: fresh_star_def fresh_Pair  fresh_fact)
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   453
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   454
lemma One_refl:
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   455
  shows "t \<longrightarrow>1 t"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   456
by (nominal_induct t rule: lam.strong_induct) (auto)
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   457
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   458
lemma One_subst: 
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   459
  assumes a: "t1 \<longrightarrow>1 t2" "s1 \<longrightarrow>1 s2"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   460
  shows "t1[x ::= s1] \<longrightarrow>1 t2[x ::= s2]" 
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   461
using a 
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   462
apply(nominal_induct t1 t2 avoiding: s1 s2 x rule: One.strong_induct)
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   463
apply(auto simp add: substitution_lemma fresh_at_base fresh_fact fresh_Pair)
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   464
done
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   465
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   466
lemma better_o4_intro:
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   467
  assumes a: "t1 \<longrightarrow>1 t2" "s1 \<longrightarrow>1 s2"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   468
  shows "App (Lam [x]. t1) s1 \<longrightarrow>1 t2[ x ::= s2]"
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   469
proof -
2685
1df873b63cb2 added obtain_fresh lemma; tuned Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2683
diff changeset
   470
  obtain y::"name" where fs: "atom y \<sharp> (x, t1, s1, t2, s2)" by (rule obtain_fresh)
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   471
  have "App (Lam [x]. t1) s1 = App (Lam [y]. ((y \<leftrightarrow> x) \<bullet> t1)) s1" using fs
3085
25d813c5042d Port CR_Takahashi from Nominal1, no more "sorry" in BetaCR.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3065
diff changeset
   472
    by (auto simp add: Abs1_eq_iff' flip_def fresh_Pair fresh_at_base)
2683
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   473
  also have "\<dots> \<longrightarrow>1 ((y \<leftrightarrow> x) \<bullet> t2)[y ::= s2]" using fs a by (auto simp add: One.eqvt)
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   474
  also have "\<dots> = t2[x ::= s2]" using fs by (simp add: subst_rename[symmetric])
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   475
  finally show "App (Lam [x].t1) s1 \<longrightarrow>1 t2[x ::= s2]" by simp
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   476
qed
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   477
42c0d011a177 ported some of the old proofs to serve as testcases
Christian Urban <urbanc@in.tum.de>
parents: 2678
diff changeset
   478
section {* Locally Nameless Terms *}
2678
494b859bfc16 defined height as a function that returns an integer
Christian Urban <urbanc@in.tum.de>
parents: 2675
diff changeset
   479
2669
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   480
nominal_datatype ln = 
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   481
  LNBnd nat
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   482
| LNVar name
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   483
| LNApp ln ln
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   484
| LNLam ln
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   485
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   486
fun
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   487
  lookup :: "name list \<Rightarrow> nat \<Rightarrow> name \<Rightarrow> ln" 
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   488
where
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   489
  "lookup [] n x = LNVar x"
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   490
| "lookup (y # ys) n x = (if x = y then LNBnd n else (lookup ys (n + 1) x))"
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   491
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: 2821
diff changeset
   492
lemma supp_lookup:
2824
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   493
  shows "supp (lookup xs n x) \<subseteq> {atom x}"
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: 2821
diff changeset
   494
  apply(induct arbitrary: n rule: lookup.induct)
2824
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   495
  apply(simp add: ln.supp supp_at_base)
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: 2821
diff changeset
   496
  apply(simp add: ln.supp pure_supp)
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: 2821
diff changeset
   497
  done
2824
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   498
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   499
lemma supp_lookup_in:
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   500
  shows "x \<in> set xs \<Longrightarrow> supp (lookup xs n x) = {}"
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   501
  by (induct arbitrary: n rule: lookup.induct)(auto simp add: ln.supp pure_supp)
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   502
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   503
lemma supp_lookup_notin:
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   504
  shows "x \<notin> set xs \<Longrightarrow> supp (lookup xs n x) = {atom x}"
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   505
  by (induct arbitrary: n rule: lookup.induct) (auto simp add: ln.supp pure_supp supp_at_base)
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: 2821
diff changeset
   506
2829
0acb0b8f4106 Simplify ln-trans proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2828
diff changeset
   507
lemma supp_lookup_fresh:
0acb0b8f4106 Simplify ln-trans proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2828
diff changeset
   508
  shows "atom ` set xs \<sharp>* lookup xs n x"
0acb0b8f4106 Simplify ln-trans proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2828
diff changeset
   509
  by (case_tac "x \<in> set xs") (auto simp add: fresh_star_def fresh_def supp_lookup_in supp_lookup_notin)
0acb0b8f4106 Simplify ln-trans proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2828
diff changeset
   510
0acb0b8f4106 Simplify ln-trans proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2828
diff changeset
   511
lemma lookup_eqvt[eqvt]:
2669
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   512
  shows "(p \<bullet> lookup xs n x) = lookup (p \<bullet> xs) (p \<bullet> n) (p \<bullet> x)"
2767
94f6f70e3067 New way of forward elimination of Abs1_eq and simplifications of the function obligation proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2765
diff changeset
   513
  by (induct xs arbitrary: n) (simp_all add: permute_pure)
2669
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   514
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   515
text {* Function that translates lambda-terms into locally nameless terms *}
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   516
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   517
nominal_function (invariant "\<lambda>(_, xs) y. atom ` set xs \<sharp>* y")
2669
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   518
  trans :: "lam \<Rightarrow> name list \<Rightarrow> ln"
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   519
where
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   520
  "trans (Var x) xs = lookup xs 0 x"
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   521
| "trans (App t1 t2) xs = LNApp (trans t1 xs) (trans t2 xs)"
2685
1df873b63cb2 added obtain_fresh lemma; tuned Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2683
diff changeset
   522
| "atom x \<sharp> xs \<Longrightarrow> trans (Lam [x]. t) xs = LNLam (trans t (x # xs))"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   523
  apply (simp add: eqvt_def trans_graph_aux_def)
2824
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   524
  apply (erule trans_graph.induct)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   525
  apply (auto simp add: ln.fresh)[3]
2829
0acb0b8f4106 Simplify ln-trans proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2828
diff changeset
   526
  apply (simp add: supp_lookup_fresh)
2824
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   527
  apply (simp add: fresh_star_def ln.fresh)
44d937e8ae78 Proof of trans with invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2822
diff changeset
   528
  apply (simp add: ln.fresh fresh_star_def)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   529
  apply(auto)[1]
2829
0acb0b8f4106 Simplify ln-trans proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2828
diff changeset
   530
  apply (rule_tac y="a" and c="b" in lam.strong_exhaust)
0acb0b8f4106 Simplify ln-trans proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2828
diff changeset
   531
  apply (auto simp add: fresh_star_def)[3]
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   532
  using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   533
  apply(simp_all)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   534
  apply(erule conjE)+
2948
b0b2adafb6d2 made the tests go through again
Christian Urban <urbanc@in.tum.de>
parents: 2945
diff changeset
   535
  apply (erule_tac c="xsa" in Abs_lst1_fcb2')
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   536
  apply (simp add: fresh_star_def)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   537
  apply (simp add: fresh_star_def)
3183
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   538
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   539
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   540
  apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   541
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   542
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   543
  apply(simp add: fresh_star_Pair perm_supp_eq)
2829
0acb0b8f4106 Simplify ln-trans proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2828
diff changeset
   544
  done
2669
1d1772a89026 the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
parents: 2667
diff changeset
   545
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   546
nominal_termination (eqvt)
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   547
  by lexicographic_order
2827
394664816e24 defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
parents: 2826
diff changeset
   548
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   549
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   550
text {* count the occurences of lambdas in a term *}
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   551
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   552
nominal_function
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   553
  cntlams :: "lam  \<Rightarrow> nat"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   554
where
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   555
  "cntlams (Var x) = 0"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   556
| "cntlams (App t1 t2) = (cntlams t1) + (cntlams t2)"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   557
| "cntlams (Lam [x]. t) = Suc (cntlams t)"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   558
  apply(simp add: eqvt_def cntlams_graph_aux_def)
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   559
  apply(rule TrueI)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   560
  apply(rule_tac y="x" in lam.exhaust)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   561
  apply(auto)[3]
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   562
  apply(all_trivials)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   563
  apply(simp)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   564
  using [[simproc del: alpha_lst]]
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   565
  apply(simp)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   566
  apply(erule_tac c="()" in Abs_lst1_fcb2')
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   567
  apply(simp add: pure_fresh)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   568
  apply(simp add: fresh_star_def pure_fresh)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   569
  apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   570
  apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   571
  done
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   572
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   573
nominal_termination (eqvt)
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   574
  by lexicographic_order
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   575
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   576
2860
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   577
text {* count the bound-variable occurences in a lambda-term *}
2827
394664816e24 defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
parents: 2826
diff changeset
   578
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   579
nominal_function
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   580
  cntbvs :: "lam \<Rightarrow> name list \<Rightarrow> nat"
2827
394664816e24 defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
parents: 2826
diff changeset
   581
where
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   582
  "cntbvs (Var x) xs = (if x \<in> set xs then 1 else 0)"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   583
| "cntbvs (App t1 t2) xs = (cntbvs t1 xs) + (cntbvs t2 xs)"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   584
| "atom x \<sharp> xs \<Longrightarrow> cntbvs (Lam [x]. t) xs = cntbvs t (x # xs)"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   585
  apply(simp add: eqvt_def cntbvs_graph_aux_def)
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   586
  apply(rule TrueI)
2828
81276d5c7438 cbvs can be easily defined without an invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2827
diff changeset
   587
  apply(case_tac x)
81276d5c7438 cbvs can be easily defined without an invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2827
diff changeset
   588
  apply(rule_tac y="a" and c="b" in lam.strong_exhaust)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   589
  apply(auto simp add: fresh_star_def)[3]
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   590
  apply(all_trivials)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   591
  apply(simp)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   592
  apply(simp)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   593
  using [[simproc del: alpha_lst]]
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   594
  apply(simp)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   595
  apply(erule conjE)
2912
3c363a5070a5 copied all work to Lambda.thy; had to derive a special version of fcb1 for concrete atom
Christian Urban <urbanc@in.tum.de>
parents: 2902
diff changeset
   596
  apply(erule Abs_lst1_fcb2')
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   597
  apply(simp add: pure_fresh fresh_star_def)
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   598
  apply(simp add: fresh_star_def)
3183
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   599
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   600
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   601
  apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   602
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   603
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   604
  apply(simp add: fresh_star_Pair perm_supp_eq)
2828
81276d5c7438 cbvs can be easily defined without an invariant
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2827
diff changeset
   605
  done
2827
394664816e24 defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
parents: 2826
diff changeset
   606
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   607
nominal_termination (eqvt)
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   608
  by lexicographic_order
2827
394664816e24 defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
parents: 2826
diff changeset
   609
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   610
section {* De Bruijn Terms *}
2827
394664816e24 defined the "count-bound-variables-occurences" function which has an accumulator like trans
Christian Urban <urbanc@in.tum.de>
parents: 2826
diff changeset
   611
2667
e3f8673085b1 added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
parents: 2666
diff changeset
   612
nominal_datatype db = 
e3f8673085b1 added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
parents: 2666
diff changeset
   613
  DBVar nat
e3f8673085b1 added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
parents: 2666
diff changeset
   614
| DBApp db db
e3f8673085b1 added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
parents: 2666
diff changeset
   615
| DBLam db
e3f8673085b1 added a translation function from lambda-terms to deBruijn terms (equivariance fails at the moment)
Christian Urban <urbanc@in.tum.de>
parents: 2666
diff changeset
   616
2792
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   617
instance db :: pure
3245
017e33849f4d updated to Isabelle 2016-1
Christian Urban <urbanc@in.tum.de>
parents: 3244
diff changeset
   618
  apply standard
2792
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   619
  apply (induct_tac x rule: db.induct)
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   620
  apply (simp_all add: permute_pure)
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   621
  done
2795
929bd2dd1ab2 DeBruijn translation in a simplifier friendly way
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2794
diff changeset
   622
929bd2dd1ab2 DeBruijn translation in a simplifier friendly way
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2794
diff changeset
   623
lemma fresh_at_list: "atom x \<sharp> xs \<longleftrightarrow> x \<notin> set xs"
929bd2dd1ab2 DeBruijn translation in a simplifier friendly way
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2794
diff changeset
   624
  unfolding fresh_def supp_set[symmetric]
2845
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   625
  by (induct xs) (auto simp add: supp_of_finite_insert supp_at_base supp_set_empty)
2795
929bd2dd1ab2 DeBruijn translation in a simplifier friendly way
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2794
diff changeset
   626
2800
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   627
fun
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   628
  vindex :: "name list \<Rightarrow> name \<Rightarrow> nat \<Rightarrow> db option" 
2792
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   629
where
2800
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   630
  "vindex [] v n = None"
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   631
| "vindex (h # t) v n = (if v = h then (Some (DBVar n)) else (vindex t v (Suc n)))"
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   632
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   633
lemma vindex_eqvt[eqvt]:
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   634
  "(p \<bullet> vindex l v n) = vindex (p \<bullet> l) (p \<bullet> v) (p \<bullet> n)"
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   635
  by (induct l arbitrary: n) (simp_all add: permute_pure)
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   636
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   637
nominal_function
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: 2821
diff changeset
   638
  transdb :: "lam \<Rightarrow> name list \<Rightarrow> db option"
2800
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   639
where
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: 2821
diff changeset
   640
  "transdb (Var x) l = vindex l x 0"
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   641
| "transdb (App t1 t2) xs = 
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   642
      Option.bind (transdb t1 xs) (\<lambda>d1. Option.bind (transdb t2 xs) (\<lambda>d2. Some (DBApp d1 d2)))"
3229
b52e8651591f updated to Isabelle changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3219
diff changeset
   643
| "x \<notin> set xs \<Longrightarrow> transdb (Lam [x].t) xs = Option.map_option DBLam (transdb t (x # xs))"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   644
  apply(simp add: eqvt_def transdb_graph_aux_def)
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: 2821
diff changeset
   645
  apply(rule TrueI)
2792
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   646
  apply (case_tac x)
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   647
  apply (rule_tac y="a" and c="b" in lam.strong_exhaust)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   648
  apply (auto simp add: fresh_star_def fresh_at_list)[3]
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   649
  using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   650
  apply(simp_all)
2942
fac8895b109a Express trans_db with Option.map and Option.bind. Possibly mbind is a copy of bind?
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2941
diff changeset
   651
  apply(elim conjE)
2912
3c363a5070a5 copied all work to Lambda.thy; had to derive a special version of fcb1 for concrete atom
Christian Urban <urbanc@in.tum.de>
parents: 2902
diff changeset
   652
  apply (erule_tac c="xsa" in Abs_lst1_fcb2')
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   653
  apply (simp add: pure_fresh)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   654
  apply(simp add: fresh_star_def fresh_at_list)
3183
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   655
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   656
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   657
  apply(simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   658
  apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   659
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   660
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   661
  apply(simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   662
  apply(simp add: fresh_star_Pair perm_supp_eq)
2792
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   663
  done
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   664
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   665
nominal_termination (eqvt)
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   666
  by lexicographic_order
2792
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   667
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: 2821
diff changeset
   668
lemma transdb_eqvt[eqvt]:
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: 2821
diff changeset
   669
  "p \<bullet> transdb t l = transdb (p \<bullet>t) (p \<bullet>l)"
2942
fac8895b109a Express trans_db with Option.map and Option.bind. Possibly mbind is a copy of bind?
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2941
diff changeset
   670
  apply (nominal_induct t avoiding: l rule: lam.strong_induct)
2800
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   671
  apply (simp add: vindex_eqvt)
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   672
  apply (simp_all add: permute_pure)
2797
6750964a69bf equivariance of db_trans
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2796
diff changeset
   673
  apply (simp add: fresh_at_list)
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: 2821
diff changeset
   674
  apply (subst transdb.simps)
2797
6750964a69bf equivariance of db_trans
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2796
diff changeset
   675
  apply (simp add: fresh_at_list[symmetric])
2800
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   676
  apply (drule_tac x="name # l" in meta_spec)
6e518b436740 DB translation using index; easier to reason about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2799
diff changeset
   677
  apply auto
2797
6750964a69bf equivariance of db_trans
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2796
diff changeset
   678
  done
6750964a69bf equivariance of db_trans
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2796
diff changeset
   679
2792
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   680
lemma db_trans_test:
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   681
  assumes a: "y \<noteq> x"
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   682
  shows "transdb (Lam [x]. Lam [y]. App (Var x) (Var y)) [] = 
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   683
  Some (DBLam (DBLam (DBApp (DBVar 1) (DBVar 0))))"
2795
929bd2dd1ab2 DeBruijn translation in a simplifier friendly way
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2794
diff changeset
   684
  using a by simp
2792
c4ed08a7454a Defined translation from nominal to de-Bruijn; with a freshness condition for the lambda case.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2791
diff changeset
   685
2841
f8d660de0cf7 Eval can be defined with additional freshness
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2840
diff changeset
   686
lemma supp_subst:
2972
84afb941df53 moved eqvt for Option.map
Christian Urban <urbanc@in.tum.de>
parents: 2951
diff changeset
   687
  shows "supp (t[x ::= s]) \<subseteq> (supp t - {atom x}) \<union> supp s"
84afb941df53 moved eqvt for Option.map
Christian Urban <urbanc@in.tum.de>
parents: 2951
diff changeset
   688
  by (induct t x s rule: subst.induct) (auto simp add: lam.supp supp_at_base)
2841
f8d660de0cf7 Eval can be defined with additional freshness
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2840
diff changeset
   689
f8d660de0cf7 Eval can be defined with additional freshness
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2840
diff changeset
   690
lemma var_fresh_subst:
f8d660de0cf7 Eval can be defined with additional freshness
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2840
diff changeset
   691
  "atom x \<sharp> s \<Longrightarrow> atom x \<sharp> (t[x ::= s])"
3181
ca162f0a7957 added to the simplifier nominal_datatype.fresh lemmas
Christian Urban <urbanc@in.tum.de>
parents: 3174
diff changeset
   692
  by (induct t x s rule: subst.induct) (auto simp add: lam.supp  fresh_at_base)
2841
f8d660de0cf7 Eval can be defined with additional freshness
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2840
diff changeset
   693
2834
Christian Urban <urbanc@in.tum.de>
parents: 2827
diff changeset
   694
(* function that evaluates a lambda term *)
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   695
nominal_function
2834
Christian Urban <urbanc@in.tum.de>
parents: 2827
diff changeset
   696
   eval :: "lam \<Rightarrow> lam" and
2860
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   697
   apply_subst :: "lam \<Rightarrow> lam \<Rightarrow> lam"
2834
Christian Urban <urbanc@in.tum.de>
parents: 2827
diff changeset
   698
where
Christian Urban <urbanc@in.tum.de>
parents: 2827
diff changeset
   699
  "eval (Var x) = Var x"
Christian Urban <urbanc@in.tum.de>
parents: 2827
diff changeset
   700
| "eval (Lam [x].t) = Lam [x].(eval t)"
2860
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   701
| "eval (App t1 t2) = apply_subst (eval t1) (eval t2)"
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   702
| "apply_subst (Var x) t2 = App (Var x) t2"
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   703
| "apply_subst (App t0 t1) t2 = App (App t0 t1) t2"
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   704
| "atom x \<sharp> t2 \<Longrightarrow> apply_subst (Lam [x].t1) t2 = eval (t1[x::= t2])"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   705
  apply(simp add: eval_apply_subst_graph_aux_def eqvt_def)
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   706
  apply(rule TrueI)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   707
  apply (case_tac x)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   708
  apply (case_tac a rule: lam.exhaust)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   709
  using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   710
  apply simp_all[3]
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   711
  apply (case_tac b)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   712
  apply (rule_tac y="a" and c="ba" in lam.strong_exhaust)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   713
  apply simp_all[3]
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   714
  apply (simp add: Abs1_eq_iff fresh_star_def)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   715
  using [[simproc del: alpha_lst]]
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   716
  apply(simp_all)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   717
  apply(erule_tac c="()" in Abs_lst1_fcb2)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   718
  apply (simp add: Abs_fresh_iff)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   719
  apply(simp add: fresh_star_def fresh_Unit)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   720
  apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   721
  apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   722
  apply(erule conjE)
2912
3c363a5070a5 copied all work to Lambda.thy; had to derive a special version of fcb1 for concrete atom
Christian Urban <urbanc@in.tum.de>
parents: 2902
diff changeset
   723
  apply(erule_tac c="t2a" in Abs_lst1_fcb2')
2902
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   724
  apply (erule fresh_eqvt_at)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   725
  apply (simp add: finite_supp)
9c3f6a4d95d4 another change to the fcb2; this is needed in order to get all proofs through in Lambda.thy
Christian Urban <urbanc@in.tum.de>
parents: 2891
diff changeset
   726
  apply (simp add: fresh_Inl var_fresh_subst)
2912
3c363a5070a5 copied all work to Lambda.thy; had to derive a special version of fcb1 for concrete atom
Christian Urban <urbanc@in.tum.de>
parents: 2902
diff changeset
   727
  apply(simp add: fresh_star_def)
3183
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   728
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   729
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   730
  apply(simp add: fresh_star_Pair perm_supp_eq)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   731
  apply(simp only: eqvt_at_def)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   732
  apply(perm_simp)
313e6f2cdd89 added permutation simplification to the simplifier; this makes the simplifier more powerful, but it potentially loops more often
Christian Urban <urbanc@in.tum.de>
parents: 3181
diff changeset
   733
  apply(simp add: fresh_star_Pair perm_supp_eq)
2860
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   734
done
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   735
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   736
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   737
(* a small test
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   738
nominal_termination (eqvt) sorry
2845
a99f488a96bb Optimized proofs and removed some garbage.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2843
diff changeset
   739
2860
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   740
lemma 
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   741
  assumes "x \<noteq> y"
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   742
  shows "eval (App (Lam [x].App (Var x) (Var x)) (Var y)) = App (Var y) (Var y)"
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   743
using assms
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   744
apply(simp add: lam.supp fresh_def supp_at_base)
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   745
done
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   746
*)
25a7f421a3ba added a test that every function must be of pt-sort
Christian Urban <urbanc@in.tum.de>
parents: 2858
diff changeset
   747
2852
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   748
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   749
text {* TODO: eqvt_at for the other side *}
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   750
nominal_function q where
2852
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   751
  "atom c \<sharp> (x, M) \<Longrightarrow> q (Lam [x]. M) (N :: lam) = Lam [x]. (Lam [c]. (App M (q (Var c) N)))"
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   752
| "q (Var x) N = Var x"
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   753
| "q (App l r) N = App l r"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   754
apply(simp add: eqvt_def q_graph_aux_def)
2852
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   755
apply (rule TrueI)
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   756
apply (case_tac x)
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   757
apply (rule_tac y="a" in lam.exhaust)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   758
using [[simproc del: alpha_lst]]
2852
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   759
apply simp_all
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   760
apply (rule_tac x="(name, lam)" and ?'a="name" in obtain_fresh)
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   761
apply blast
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   762
apply clarify
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   763
apply (rule_tac x="(x, xa, M, Ma, c, ca, Na)" and ?'a="name" in obtain_fresh)
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   764
apply (subgoal_tac "eqvt_at q_sumC (Var ca, Na)") --"Could come from nominal_function?"
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   765
apply (subgoal_tac "Lam [c]. App M (q_sumC (Var c, Na)) = Lam [a]. App M (q_sumC (Var a, Na))")
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   766
apply (subgoal_tac "Lam [ca]. App Ma (q_sumC (Var ca, Na)) = Lam [a]. App Ma (q_sumC (Var a, Na))")
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   767
apply (simp only:)
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   768
apply (erule Abs_lst1_fcb)
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   769
oops
f884760ac6e2 Some TODOs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2846
diff changeset
   770
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   771
text {* Working Examples *}
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   772
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   773
nominal_function
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   774
  map_term :: "(lam \<Rightarrow> lam) \<Rightarrow> lam \<Rightarrow> lam"
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   775
where
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   776
  "eqvt f \<Longrightarrow> map_term f (Var x) = f (Var x)"
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   777
| "eqvt f \<Longrightarrow> map_term f (App t1 t2) = App (f t1) (f t2)"
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   778
| "eqvt f \<Longrightarrow> map_term f (Lam [x].t) = Lam [x].(f t)"
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   779
| "\<not>eqvt f \<Longrightarrow> map_term f t = t"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   780
  apply (simp add: eqvt_def map_term_graph_aux_def)
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   781
  apply(rule TrueI)
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   782
  apply (case_tac x, case_tac "eqvt a", case_tac b rule: lam.exhaust)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   783
  using [[simproc del: alpha_lst]]
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   784
  apply auto
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   785
  apply (erule Abs_lst1_fcb)
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   786
  apply (simp_all add: Abs_fresh_iff fresh_fun_eqvt_app)
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   787
  apply (simp add: eqvt_def permute_fun_app_eq)
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   788
  done
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   789
3236
e2da10806a34 changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3235
diff changeset
   790
nominal_termination (eqvt)
2858
de6b601c8d3d added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
parents: 2852
diff changeset
   791
  by lexicographic_order
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   792
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   793
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   794
(*
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   795
abbreviation
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   796
  mbind :: "'a option => ('a => 'b option) => 'b option"  ("_ \<guillemotright>= _" [65,65] 65) 
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   797
where  
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   798
  "c \<guillemotright>= f \<equiv> case c of None => None | (Some v) => f v"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   799
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   800
lemma mbind_eqvt:
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   801
  fixes c::"'a::pt option"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   802
  shows "(p \<bullet> (c \<guillemotright>= f)) = ((p \<bullet> c) \<guillemotright>= (p \<bullet> f))"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   803
apply(cases c)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   804
apply(simp_all)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   805
apply(perm_simp)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   806
apply(rule refl)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   807
done
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   808
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   809
lemma mbind_eqvt_raw[eqvt_raw]:
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   810
  shows "(p \<bullet> option_case) \<equiv> option_case"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   811
apply(rule eq_reflection)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   812
apply(rule ext)+
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   813
apply(case_tac xb)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   814
apply(simp_all)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   815
apply(rule_tac p="-p" in permute_boolE)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   816
apply(perm_simp add: permute_minus_cancel)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   817
apply(simp)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   818
apply(rule_tac p="-p" in permute_boolE)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   819
apply(perm_simp add: permute_minus_cancel)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   820
apply(simp)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   821
done
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   822
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   823
fun
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   824
  index :: "atom list \<Rightarrow> nat \<Rightarrow> atom \<Rightarrow> nat option" 
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   825
where
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   826
  "index [] n x = None"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   827
| "index (y # ys) n x = (if x = y then (Some n) else (index ys (n + 1) x))"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   828
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   829
lemma [eqvt]:
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   830
  shows "(p \<bullet> index xs n x) = index (p \<bullet> xs) (p \<bullet> n) (p \<bullet> x)"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   831
apply(induct xs arbitrary: n)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   832
apply(simp_all add: permute_pure)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   833
done
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   834
*)
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   835
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   836
(*
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   837
nominal_function
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   838
  trans2 :: "lam \<Rightarrow> atom list \<Rightarrow> db option"
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   839
where
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   840
  "trans2 (Var x) xs = (index xs 0 (atom x) \<guillemotright>= (\<lambda>n::nat. Some (DBVar n)))"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   841
| "trans2 (App t1 t2) xs = 
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   842
     ((trans2 t1 xs) \<guillemotright>= (\<lambda>db1::db. (trans2 t2 xs) \<guillemotright>= (\<lambda>db2::db. Some (DBApp db1 db2))))"
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   843
| "trans2 (Lam [x].t) xs = (trans2 t (atom x # xs) \<guillemotright>= (\<lambda>db::db. Some (DBLam db)))"
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   844
oops
2950
0911cb7bf696 changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
parents: 2948
diff changeset
   845
*)
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   846
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   847
nominal_function
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   848
  CPS :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   849
where
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   850
  "CPS (Var x) k = Var x"
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   851
| "CPS (App M N) k = CPS M (\<lambda>m. CPS N (\<lambda>n. n))"
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   852
oops
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   853
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   854
consts b :: name
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   855
nominal_function
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   856
  Z :: "lam \<Rightarrow> (lam \<Rightarrow> lam) \<Rightarrow> lam"
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   857
where
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   858
  "Z (App M N) k = Z M (%m. (Z N (%n.(App m n))))"
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   859
| "Z (App M N) k = Z M (%m. (Z N (%n.(App (App m n) (Abs b (k (Var b)))))))"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   860
apply(simp add: eqvt_def Z_graph_aux_def)
2846
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   861
apply (rule, perm_simp, rule)
1d43d30e44c9 Move working examples before non-working ones
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2845
diff changeset
   862
oops
2789
32979078bfe9 functions involving if and case do not throw exceptions anymore; but eqvt_at assumption has now a precondition
Christian Urban <urbanc@in.tum.de>
parents: 2787
diff changeset
   863
2937
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   864
lemma test:
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   865
  assumes "t = s"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   866
  and "supp p \<sharp>* t" "supp p \<sharp>* x"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   867
  and "(p \<bullet> t) = s \<Longrightarrow> (p \<bullet> x) = y"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   868
  shows "x = y"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   869
using assms by (simp add: perm_supp_eq)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   870
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   871
lemma test2:
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   872
  assumes "cs \<subseteq> as \<union> bs"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   873
  and "as \<sharp>* x" "bs \<sharp>* x"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   874
  shows "cs \<sharp>* x"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   875
using assms
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   876
by (auto simp add: fresh_star_def) 
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   877
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   878
lemma test3:
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   879
  assumes "cs \<subseteq> as"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   880
  and "as \<sharp>* x"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   881
  shows "cs \<sharp>* x"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   882
using assms
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   883
by (auto simp add: fresh_star_def) 
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   884
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   885
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   886
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   887
nominal_function  (invariant "\<lambda>(_, _, xs) y. atom ` fst ` set xs \<sharp>* y \<and> atom ` snd ` set xs \<sharp>* y")
2937
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   888
  aux :: "lam \<Rightarrow> lam \<Rightarrow> (name \<times> name) list \<Rightarrow> bool"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   889
where
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   890
  "aux (Var x) (Var y) xs = ((x, y) \<in> set xs)"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   891
| "aux (App t1 t2) (App s1 s2) xs = (aux t1 s1 xs \<and> aux t2 s2 xs)"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   892
| "aux (Var x) (App t1 t2) xs = False"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   893
| "aux (Var x) (Lam [y].t) xs = False"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   894
| "aux (App t1 t2) (Var x) xs = False"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   895
| "aux (App t1 t2) (Lam [x].t) xs = False"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   896
| "aux (Lam [x].t) (Var y) xs = False"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   897
| "aux (Lam [x].t) (App t1 t2) xs = False"
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   898
| "\<lbrakk>{atom x} \<sharp>* (s, xs); {atom y} \<sharp>* (t, xs); x \<noteq> y\<rbrakk> \<Longrightarrow> 
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   899
       aux (Lam [x].t) (Lam [y].s) xs = aux t s ((x, y) # xs)"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   900
  apply (simp add: eqvt_def aux_graph_aux_def)
2937
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   901
  apply(erule aux_graph.induct)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   902
  apply(simp_all add: fresh_star_def pure_fresh)[9]
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   903
  apply(case_tac x)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   904
  apply(simp)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   905
  apply(rule_tac y="a" and c="(b, c)" in lam.strong_exhaust)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   906
  apply(simp)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   907
  apply(rule_tac y="b" and c="c" in lam.strong_exhaust)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   908
  apply(metis)+
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   909
  apply(simp)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   910
  apply(rule_tac y="b" and c="c" in lam.strong_exhaust)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   911
  apply(metis)+
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   912
  apply(simp)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   913
  apply(rule_tac y="b" and c="(lam, c, name)" in lam.strong_exhaust)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   914
  apply(metis)+
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   915
  apply(simp)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   916
  apply(drule_tac x="name" in meta_spec)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   917
  apply(drule_tac x="lama" in meta_spec)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   918
  apply(drule_tac x="c" in meta_spec)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   919
  apply(drule_tac x="namea" in meta_spec)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   920
  apply(drule_tac x="lam" in meta_spec)
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   921
  apply(simp add: fresh_star_Pair)
3181
ca162f0a7957 added to the simplifier nominal_datatype.fresh lemmas
Christian Urban <urbanc@in.tum.de>
parents: 3174
diff changeset
   922
  apply(simp add: fresh_star_def fresh_at_base )
2937
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   923
  apply(auto)[1]
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   924
  apply(simp_all)[44]
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   925
  apply(simp del: Product_Type.prod.inject)  
2948
b0b2adafb6d2 made the tests go through again
Christian Urban <urbanc@in.tum.de>
parents: 2945
diff changeset
   926
  oops
2937
a56d422e17f6 added an example that recurses over two arguments; the interesting proof-obligation is not yet done
Christian Urban <urbanc@in.tum.de>
parents: 2912
diff changeset
   927
2941
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   928
lemma abs_same_binder:
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   929
  fixes t ta s sa :: "_ :: fs"
3191
0440bc1a2438 streamlined definition of alpha-equivalence for single binders (used flip instead of swap)
Christian Urban <urbanc@in.tum.de>
parents: 3183
diff changeset
   930
  and x y::"'a::at"
2941
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   931
  shows "[[atom x]]lst. t = [[atom y]]lst. ta \<and> [[atom x]]lst. s = [[atom y]]lst. sa
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   932
     \<longleftrightarrow> [[atom x]]lst. (t, s) = [[atom y]]lst. (ta, sa)"
3245
017e33849f4d updated to Isabelle 2016-1
Christian Urban <urbanc@in.tum.de>
parents: 3244
diff changeset
   933
  by (cases "atom x = atom y") (auto simp add: Abs1_eq_iff fresh_Pair)
2941
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   934
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   935
nominal_function
2941
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   936
  aux2 :: "lam \<Rightarrow> lam \<Rightarrow> bool"
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   937
where
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   938
  "aux2 (Var x) (Var y) = (x = y)"
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   939
| "aux2 (App t1 t2) (App s1 s2) = (aux2 t1 s1 \<and> aux2 t2 s2)"
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   940
| "aux2 (Var x) (App t1 t2) = False"
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   941
| "aux2 (Var x) (Lam [y].t) = False"
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   942
| "aux2 (App t1 t2) (Var x) = False"
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   943
| "aux2 (App t1 t2) (Lam [x].t) = False"
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   944
| "aux2 (Lam [x].t) (Var y) = False"
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   945
| "aux2 (Lam [x].t) (App t1 t2) = False"
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   946
| "x = y \<Longrightarrow> aux2 (Lam [x].t) (Lam [y].s) = aux2 t s"
3197
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   947
  apply(simp add: eqvt_def aux2_graph_aux_def)
25d11b449e92 definition of an auxiliary graph in nominal-primrec definitions
Christian Urban <urbanc@in.tum.de>
parents: 3192
diff changeset
   948
  apply(rule TrueI)
2941
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   949
  apply(case_tac x)
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   950
  apply(rule_tac y="a" and c="b" in lam.strong_exhaust)
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   951
  apply(rule_tac y="b" in lam.exhaust)
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   952
  apply(auto)[3]
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   953
  apply(rule_tac y="b" in lam.exhaust)
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   954
  apply(auto)[3]
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   955
  apply(rule_tac y="b" and c="(name, lam)" in lam.strong_exhaust)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   956
  using [[simproc del: alpha_lst]]
2941
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   957
  apply(auto)[3]
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   958
  apply(drule_tac x="name" in meta_spec)
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   959
  apply(drule_tac x="name" in meta_spec)
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   960
  apply(drule_tac x="lam" in meta_spec)
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   961
  apply(drule_tac x="(name \<leftrightarrow> namea) \<bullet> lama" in meta_spec)
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   962
  using [[simproc del: alpha_lst]]
3181
ca162f0a7957 added to the simplifier nominal_datatype.fresh lemmas
Christian Urban <urbanc@in.tum.de>
parents: 3174
diff changeset
   963
  apply(simp add: Abs1_eq_iff fresh_star_def fresh_Pair_elim fresh_at_base flip_def)
2941
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   964
  apply (metis Nominal2_Base.swap_commute fresh_permute_iff sort_of_atom_eq swap_atom_simps(2))
3192
14c7d7e29c44 added a simproc for alpha-equivalence to the simplifier
Christian Urban <urbanc@in.tum.de>
parents: 3191
diff changeset
   965
  using [[simproc del: alpha_lst]]
2941
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   966
  apply simp_all
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   967
  apply (simp add: abs_same_binder)
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   968
  apply (erule_tac c="()" in Abs_lst1_fcb2)
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   969
  apply (simp_all add: pure_fresh fresh_star_def eqvt_at_def)
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   970
  done
40991ebcda12 Define a version of aux only for same binders. Completeness is fine.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2940
diff changeset
   971
2940
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   972
text {* tests of functions containing if and case *}
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   973
3191
0440bc1a2438 streamlined definition of alpha-equivalence for single binders (used flip instead of swap)
Christian Urban <urbanc@in.tum.de>
parents: 3183
diff changeset
   974
(*
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   975
nominal_function  
2940
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   976
  A :: "lam => lam"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   977
where  
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   978
  "A (App M N) = (if (True \<or> P M) then (A M) else (A N))"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   979
| "A (Var x) = (Var x)" 
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   980
| "A (App M N) = (if True then M else A N)"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   981
oops
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   982
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   983
nominal_function  
2940
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   984
  C :: "lam => lam"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   985
where  
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   986
  "C (App M N) = (case (True \<or> P M) of True \<Rightarrow> (A M) | False \<Rightarrow> (A N))"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   987
| "C (Var x) = (Var x)" 
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   988
| "C (App M N) = (if True then M else C N)"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   989
oops
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   990
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   991
nominal_function  
2940
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   992
  A :: "lam => lam"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   993
where  
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   994
  "A (Lam [x].M) = (Lam [x].M)"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   995
| "A (Var x) = (Var x)"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   996
| "A (App M N) = (if True then M else A N)"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   997
oops
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
   998
3235
5ebd327ffb96 changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 3232
diff changeset
   999
nominal_function  
2940
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
  1000
  B :: "lam => lam"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
  1001
where  
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
  1002
  "B (Lam [x].M) = (Lam [x].M)"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
  1003
| "B (Var x) = (Var x)"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
  1004
| "B (App M N) = (if True then M else (B N))"
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
  1005
unfolding eqvt_def
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
  1006
unfolding B_graph_def
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
  1007
apply(perm_simp)
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
  1008
apply(rule allI)
cc0605102f95 Move If / Let with 'True' to the end of Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2937
diff changeset
  1009
apply(rule refl)
3134
301b74fcd614 updated to new Isabelle (declared keywords)
Christian Urban <urbanc@in.tum.de>
parents: 3085
diff changeset
  1010
oops
3191
0440bc1a2438 streamlined definition of alpha-equivalence for single binders (used flip instead of swap)
Christian Urban <urbanc@in.tum.de>
parents: 3183
diff changeset
  1011
*)
1594
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1012
end
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1013
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1014
892fcdb96c96 Move LamEx out of Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1015