Nominal/Ex/NBE.thy
author Christian Urban <urbanc@in.tum.de>
Wed, 06 Jul 2011 00:34:42 +0200
changeset 2952 e4c2854833ad
child 2953 80f01215d1a6
permissions -rw-r--r--
attempt for NBE
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2952
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory Lambda
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports 
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
  "../Nominal2"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
begin
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
atom_decl name
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
nominal_datatype lam =
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  Var "name"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
| App "lam" "lam"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
| Lam x::"name" l::"lam"  binds x in l ("Lam [_]. _" [100, 100] 100)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
nominal_datatype sem =
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  L "env" x::"name" l::"lam" binds x in l
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
| N "neu"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
and neu = 
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
  V "name"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
| A "neu" "sem"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
and env =
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  ENil
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
| ECons "env" "name" "sem"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
nominal_primrec 
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
  evals :: "env \<Rightarrow> lam \<Rightarrow> sem" and
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
  evals_aux :: "sem \<Rightarrow> lam \<Rightarrow> env \<Rightarrow> sem"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
where
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  "evals ENil (Var x) = N (V x)"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
| "evals (ECons tail y v) (Var x) = (if x = y then v else evals tail (Var x))" 
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
| "evals env (Lam [x]. t) = L env x t"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
| "evals env (App t1 t2) = evals_aux (evals env t1) t2 env"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
| "evals_aux (L cenv x t) t2 env = evals (ECons cenv x (evals env t2)) t"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
| "evals_aux (N n) t2 env = N (A n (evals env t2))"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
defer
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
defer
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
--"completeness"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
apply(case_tac x)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
apply(simp)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
apply(case_tac a)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
apply(simp)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
apply(case_tac aa rule: sem_neu_env.exhaust(3))
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
apply(simp)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
apply(case_tac b rule: lam.exhaust)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
apply(metis)+
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
apply(case_tac b rule: lam.exhaust)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
apply(metis)+
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
apply(simp)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
apply(case_tac b)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
apply(simp)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
apply(case_tac a rule: sem_neu_env.exhaust(1))
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
apply(metis)+
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
--"compatibility"
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
apply(all_trivials)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
apply(simp)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
apply(simp)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
apply(simp)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
apply(simp)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
defer
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
apply(simp)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
sorry
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
(* can probably not proved by a trivial size argument *)
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
termination sorry
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
e4c2854833ad attempt for NBE
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66