Nominal/Ex/NoneExamples.thy
author Christian Urban <urbanc@in.tum.de>
Sun, 29 Aug 2010 12:14:40 +0800
changeset 2452 39f8d405d7a2
parent 2436 3885dc2669f9
child 2454 9ffee4eb1ae1
permissions -rw-r--r--
updated todos
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2083
9568f9f31822 tuned file names for examples
Christian Urban <urbanc@in.tum.de>
parents: 2082
diff changeset
     1
theory NoneExamples
2082
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
     2
imports "../NewParser"
1589
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
begin
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
atom_decl name
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
2436
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
     7
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
     8
text {* 
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
     9
  "Weirdo" example from Peter Sewell's bestiary. 
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    10
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    11
  This example is not covered by our binding 
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    12
  specification.
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    13
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    14
*}
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    15
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    16
nominal_datatype weird =
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    17
  Foo_var "name"
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    18
| Foo_pair "weird" "weird" 
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    19
| Foo x::"name" y::"name" p1::"weird" p2::"weird" p3::"weird"
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    20
    bind x in p1 p2, 
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    21
    bind y in p2 p3
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    22
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    23
(* e1 occurs in two bodies *)
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    24
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    25
nominal_datatype exp =
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    26
  Var name
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    27
| Pair exp exp
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    28
| LetRec x::name p::pat e1::exp e2::exp  bind x in e1 e2, bind "bp p" in e1
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    29
and pat =
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    30
  PVar name
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    31
| PUnit
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    32
| PPair pat pat
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    33
binder
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    34
  bp :: "pat \<Rightarrow> atom list"
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    35
where
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    36
  "bp (PVar x) = [atom x]"
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    37
| "bp (PUnit) = []"
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    38
| "bp (PPair p1 p2) = bp p1 @ bp p2"
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    39
3885dc2669f9 cleaned up (almost completely) the examples
Christian Urban <urbanc@in.tum.de>
parents: 2083
diff changeset
    40
2082
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    41
(* this example binds bound names and
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    42
   so is not respectful *)
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    43
(*
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    44
nominal_datatype trm =
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    45
  Vr "name"
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    46
| Lm x::"name" t::"trm"         bind x in t
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    47
| Lt left::"trm" right::"trm"   bind "bv left" in right
1589
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
binder
2082
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    49
  bv
1589
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
where
2082
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    51
  "bv (Vr n) = {}"
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    52
| "bv (Lm n t) = {atom n} \<union> bv t"
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    53
| "bv (Lt l r) = bv l \<union> bv r"
1589
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
*)
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
2082
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    56
(* this example uses "-" in the binding function; 
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    57
   at the moment this is unsupported *)
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    58
(*
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    59
nominal_datatype trm' =
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    60
  Vr' "name"
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    61
| Lm' l::"name" r::"trm'"   bind l in r
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    62
| Lt' l::"trm'" r::"trm'"   bind "bv' l" in r
1589
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
binder
2082
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    64
  bv'
1589
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
where
2082
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    66
  "bv' (Vr' n) = {atom n}"
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    67
| "bv' (Lm' n t) = bv' t - {atom n}"
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    68
| "bv' (Lt' l r) = bv' l \<union> bv' r"
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    69
*)
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    70
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    71
(* this example again binds bound names  *)
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    72
(*
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    73
nominal_datatype trm'' =
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    74
  Va'' "name"
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    75
| Lm'' n::"name" l::"trm''" bind n in l
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    76
and bla'' =
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    77
  Bla'' f::"trm''" s::"trm''" bind "bv'' f" in s
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    78
binder
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    79
  bv''
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    80
where
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    81
  "bv'' (Vm'' x) = {}"
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    82
| "bv'' (Lm'' x b) = {atom x}"
0854af516f14 cleaned up a bit the examples; added equivariance to all examples
Christian Urban <urbanc@in.tum.de>
parents: 1773
diff changeset
    83
*)
1589
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
end
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
6542026b95cd Move Non-respectful examples to NotRsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88