Tutorial/Tutorial6.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 15 Jul 2011 22:48:37 +0100
changeset 2967 d7e8b9b78e28
parent 2702 de3e4b121c22
child 3132 87eca760dcba
permissions -rw-r--r--
some improvements to the NBE example
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2702
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory Tutorial6
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports "../Nominal/Nominal2"
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
section {* Type Schemes *}
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
text {*
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
  Nominal2 can deal also with more complicated binding
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  structures; for example the finite set of binders found
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
  in type schemes.
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
*}
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
atom_decl name
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
nominal_datatype ty =
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
  Var "name"
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
| Fun "ty" "ty" (infixr "\<rightarrow>" 100)
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
and tys =
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
  All as::"name fset" ty::"ty" bind (set+) as in ty ("All _. _" [100, 100] 100)
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
text {* Some alpha-equivalences *}
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
lemma
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
  shows "All {|a, b|}. (Var a) \<rightarrow> (Var b) = All {|b, a|}. (Var a) \<rightarrow> (Var b)"
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
  unfolding ty_tys.eq_iff Abs_eq_iff alphas fresh_star_def
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
  by (auto simp add: ty_tys.eq_iff ty_tys.supp supp_at_base fresh_star_def intro: permute_zero)
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
lemma
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
  shows "All {|a, b|}. (Var a) \<rightarrow> (Var b) = All {|a, b|}. (Var b) \<rightarrow> (Var a)"
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
  unfolding ty_tys.eq_iff Abs_eq_iff alphas fresh_star_def
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
  by (auto simp add: ty_tys.eq_iff ty_tys.supp supp_at_base fresh_star_def swap_atom)
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
     (metis permute_flip_at)
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
  
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
lemma
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
  shows "All {|a, b, c|}. (Var a) \<rightarrow> (Var b) = All {|a, b|}. (Var a) \<rightarrow> (Var b)"
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
  unfolding ty_tys.eq_iff Abs_eq_iff alphas fresh_star_def
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
  by (auto simp add: ty_tys.eq_iff ty_tys.supp supp_at_base fresh_star_def intro: permute_zero)
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
  
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
lemma
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
  assumes a: "a \<noteq> b"
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  shows "All {|a, b|}. (Var a) \<rightarrow> (Var b) \<noteq> All {|c|}. (Var c) \<rightarrow> (Var c)"
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  using a
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  unfolding ty_tys.eq_iff Abs_eq_iff alphas fresh_star_def
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
  by (auto simp add: ty_tys.eq_iff ty_tys.supp supp_at_base fresh_star_def)
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
de3e4b121c22 added Tutorial6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
end