Nominal/Test.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 23 Mar 2010 08:11:11 +0100
changeset 1589 6542026b95cd
parent 1586 d804729d6cf4
child 1594 892fcdb96c96
permissions -rw-r--r--
Move Non-respectful examples to NotRsp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
954
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory Test
1335
c3dfd4193b42 Experiments with proving weird transp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1331
diff changeset
     2
imports "Parser" "../Attic/Prove"
954
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
1428
4029105011ca Show that the new types are in finite support typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1418
diff changeset
     5
atom_decl name
4029105011ca Show that the new types are in finite support typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1418
diff changeset
     6
1454
7c8cd6eae8e2 FV_bn generated for recursive functions as well, and used in main fv for bindings.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1453
diff changeset
     7
ML {* val _ = recursive := false *}
1445
3246c5e1a9d7 cheat_alpha_eqvt no longer needed; the proofs work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1441
diff changeset
     8
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
     9
nominal_datatype lm =
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    10
  Vr "name"
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    11
| Ap "lm" "lm"
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    12
| Lm x::"name" l::"lm"  bind x in l
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    13
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
    14
lemmas supp_fn' = lm.fv[simplified lm.supp]
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    15
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    16
lemma
1499
21dda372fb11 simplified strong induction proof by using flip
Christian Urban <urbanc@in.tum.de>
parents: 1498
diff changeset
    17
  fixes c::"'a::fs"
21dda372fb11 simplified strong induction proof by using flip
Christian Urban <urbanc@in.tum.de>
parents: 1498
diff changeset
    18
  assumes a1: "\<And>name c. P c (Vr name)"
1500
212e7a3494eb vixed variable names
Christian Urban <urbanc@in.tum.de>
parents: 1499
diff changeset
    19
  and     a2: "\<And>lm1 lm2 c. \<lbrakk>\<And>d. P d lm1; \<And>d. P d lm2\<rbrakk> \<Longrightarrow> P c (Ap lm1 lm2)"
1517
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    20
  and     a3: "\<And>name lm c. \<lbrakk>atom name \<sharp> c; \<And>d. P d lm\<rbrakk> \<Longrightarrow> P c (Lm name lm)"
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    21
  shows "P c lm"
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    22
proof -
1499
21dda372fb11 simplified strong induction proof by using flip
Christian Urban <urbanc@in.tum.de>
parents: 1498
diff changeset
    23
  have "\<And>p. P c (p \<bullet> lm)"
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
    24
    apply(induct lm arbitrary: c rule: lm.induct)
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
    25
    apply(simp only: lm.perm)
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    26
    apply(rule a1)
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
    27
    apply(simp only: lm.perm)
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    28
    apply(rule a2)
1499
21dda372fb11 simplified strong induction proof by using flip
Christian Urban <urbanc@in.tum.de>
parents: 1498
diff changeset
    29
    apply(blast)[1]
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    30
    apply(assumption)
1500
212e7a3494eb vixed variable names
Christian Urban <urbanc@in.tum.de>
parents: 1499
diff changeset
    31
    apply(subgoal_tac "\<exists>new::name. (atom new) \<sharp> (c, Lm (p \<bullet> name) (p \<bullet> lm))")
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
    32
    defer
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
    33
    apply(simp add: fresh_def)
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
    34
    apply(rule_tac X="supp (c, Lm (p \<bullet> name) (p \<bullet> lm))" in obtain_at_base)
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
    35
    apply(simp add: supp_Pair finite_supp)
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
    36
    apply(blast)
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    37
    apply(erule exE)
1500
212e7a3494eb vixed variable names
Christian Urban <urbanc@in.tum.de>
parents: 1499
diff changeset
    38
    apply(rule_tac t="p \<bullet> Lm name lm" and 
212e7a3494eb vixed variable names
Christian Urban <urbanc@in.tum.de>
parents: 1499
diff changeset
    39
                   s="(((p \<bullet> name) \<leftrightarrow> new) + p) \<bullet> Lm name lm" in subst)
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
    40
    apply(simp del: lm.perm)
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
    41
    apply(subst lm.perm)
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
    42
    apply(subst (2) lm.perm)
1499
21dda372fb11 simplified strong induction proof by using flip
Christian Urban <urbanc@in.tum.de>
parents: 1498
diff changeset
    43
    apply(rule flip_fresh_fresh)
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    44
    apply(simp add: fresh_def)
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    45
    apply(simp only: supp_fn')
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    46
    apply(simp)
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    47
    apply(simp add: fresh_Pair)
1510
be911e869fde Added fv,bn,distinct,perm to the simplifier.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1502
diff changeset
    48
    apply(simp)
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    49
    apply(rule a3)
1517
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    50
    apply(simp add: fresh_Pair)
1499
21dda372fb11 simplified strong induction proof by using flip
Christian Urban <urbanc@in.tum.de>
parents: 1498
diff changeset
    51
    apply(drule_tac x="((p \<bullet> name) \<leftrightarrow> new) + p" in meta_spec)
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    52
    apply(simp)
1499
21dda372fb11 simplified strong induction proof by using flip
Christian Urban <urbanc@in.tum.de>
parents: 1498
diff changeset
    53
    done
1483
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    54
  then have "P c (0 \<bullet> lm)" by blast
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    55
  then show "P c lm" by simp
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    56
qed
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    57
2ca8e43b53c5 added partial proof for the strong induction principle
Christian Urban <urbanc@in.tum.de>
parents: 1478
diff changeset
    58
1517
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    59
lemma
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    60
  fixes c::"'a::fs"
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    61
  assumes a1: "\<And>name c. P c (Vr name)"
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    62
  and     a2: "\<And>lm1 lm2 c. \<lbrakk>\<And>d. P d lm1; \<And>d. P d lm2\<rbrakk> \<Longrightarrow> P c (Ap lm1 lm2)"
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    63
  and     a3: "\<And>name lm c. \<lbrakk>atom name \<sharp> c; \<And>d. P d lm\<rbrakk> \<Longrightarrow> P c (Lm name lm)"
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    64
  shows "P c lm"
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    65
proof -
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    66
  have "\<And>p. P c (p \<bullet> lm)"
1522
4f8bab472a83 Leroy96 supp=fv and fixes to make it compile
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1517
diff changeset
    67
    apply(induct lm arbitrary: c rule: lm.induct)
4f8bab472a83 Leroy96 supp=fv and fixes to make it compile
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1517
diff changeset
    68
    apply(simp only: lm.perm)
1517
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    69
    apply(rule a1)
1522
4f8bab472a83 Leroy96 supp=fv and fixes to make it compile
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1517
diff changeset
    70
    apply(simp only: lm.perm)
1517
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    71
    apply(rule a2)
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    72
    apply(blast)[1]
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    73
    apply(assumption)
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    74
    thm at_set_avoiding
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    75
    apply(subgoal_tac "\<exists>q. (q \<bullet> {p \<bullet> atom name}) \<sharp>* c \<and> supp (p \<bullet> Lm name lm) \<sharp>* q")
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    76
    apply(erule exE)
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    77
    apply(rule_tac t="p \<bullet> Lm name lm" and 
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    78
                   s="q \<bullet> p \<bullet> Lm name lm" in subst)
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    79
    defer
1522
4f8bab472a83 Leroy96 supp=fv and fixes to make it compile
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1517
diff changeset
    80
    apply(simp add: lm.perm)
1517
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    81
    apply(rule a3)
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    82
    apply(simp add: eqvts fresh_star_def)
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    83
    apply(drule_tac x="q + p" in meta_spec)
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    84
    apply(simp)
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    85
    sorry
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    86
  then have "P c (0 \<bullet> lm)" by blast
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    87
  then show "P c lm" by simp
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    88
qed
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
    89
1586
d804729d6cf4 Move the comment to appropriate place.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1553
diff changeset
    90
text {* example 1, equivalent to example 2 from Terms *}
d804729d6cf4 Move the comment to appropriate place.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1553
diff changeset
    91
954
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
nominal_datatype lam =
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
  VAR "name"
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
| APP "lam" "lam"
1449
b66d754bf1c2 proof for support when bn-function is present, but fb_function is empty
Christian Urban <urbanc@in.tum.de>
parents: 1439
diff changeset
    95
| LAM x::"name" t::"lam" bind x in t
1287
8557af71724e slight simplification of the raw-decl generation
Christian Urban <urbanc@in.tum.de>
parents: 1285
diff changeset
    96
| LET bp::"bp" t::"lam"   bind "bi bp" in t
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
    97
and bp =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
    98
  BP "name" "lam"
954
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
binder
1295
0ecc775e5fce Link calls to Raw permutations, FV definition and alpha_definition into the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1290
diff changeset
   100
  bi::"bp \<Rightarrow> atom set"
954
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
where
1295
0ecc775e5fce Link calls to Raw permutations, FV definition and alpha_definition into the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1290
diff changeset
   102
  "bi (BP x t) = {atom x}"
1228
c179ad9d2446 declarartion of the raw datatype already works; raw binding functions throw an exception about mutual recursive types
Christian Urban <urbanc@in.tum.de>
parents: 1223
diff changeset
   103
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   104
thm lam_bp.fv
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   105
thm lam_bp.supp
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   106
thm lam_bp.eq_iff
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   107
thm lam_bp.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   108
thm lam_bp.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   109
thm lam_bp.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   110
thm lam_bp.inducts
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   111
thm lam_bp.distinct
1428
4029105011ca Show that the new types are in finite support typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1418
diff changeset
   112
ML {* Sign.of_sort @{theory} (@{typ lam}, @{sort fs}) *}
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   113
thm lam_bp.fv[simplified lam_bp.supp]
1461
c79bcbe1983d added the final unfolded result
Christian Urban <urbanc@in.tum.de>
parents: 1460
diff changeset
   114
1465
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   115
ML {* val _ = recursive := true *}
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   116
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   117
nominal_datatype lam' =
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   118
  VAR' "name"
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   119
| APP' "lam'" "lam'"
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   120
| LAM' x::"name" t::"lam'"  bind x in t
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   121
| LET' bp::"bp'" t::"lam'"   bind "bi' bp" in t
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   122
and bp' =
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   123
  BP' "name" "lam'"
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   124
binder
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   125
  bi'::"bp' \<Rightarrow> atom set"
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   126
where
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   127
  "bi' (BP' x t) = {atom x}"
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   128
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   129
thm lam'_bp'.fv
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   130
thm lam'_bp'.eq_iff[no_vars]
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   131
thm lam'_bp'.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   132
thm lam'_bp'.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   133
thm lam'_bp'.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   134
thm lam'_bp'.inducts
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   135
thm lam'_bp'.distinct
1465
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   136
ML {* Sign.of_sort @{theory} (@{typ lam'}, @{sort fs}) *}
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   137
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   138
thm lam'_bp'.fv[simplified lam'_bp'.supp]
1465
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   139
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   140
1261
853abc14c5c6 added IsaMakefile...but so far included only a test for the parser
Christian Urban <urbanc@in.tum.de>
parents: 1258
diff changeset
   141
text {* example 2 *}
853abc14c5c6 added IsaMakefile...but so far included only a test for the parser
Christian Urban <urbanc@in.tum.de>
parents: 1258
diff changeset
   142
1465
4de35639fef0 added another supp-proof for the non-recursive case
Christian Urban <urbanc@in.tum.de>
parents: 1461
diff changeset
   143
ML {* val _ = recursive := false  *}
1265
fc8f5897b00a first attempt to make sense out of the core-haskell definition
Christian Urban <urbanc@in.tum.de>
parents: 1261
diff changeset
   144
nominal_datatype trm' =
961
0f88e04eb486 Variable takes a 'name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 954
diff changeset
   145
  Var "name"
1265
fc8f5897b00a first attempt to make sense out of the core-haskell definition
Christian Urban <urbanc@in.tum.de>
parents: 1261
diff changeset
   146
| App "trm'" "trm'"
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   147
| Lam x::"name" t::"trm'"          bind x in t
1265
fc8f5897b00a first attempt to make sense out of the core-haskell definition
Christian Urban <urbanc@in.tum.de>
parents: 1261
diff changeset
   148
| Let p::"pat'" "trm'" t::"trm'"   bind "f p" in t
fc8f5897b00a first attempt to make sense out of the core-haskell definition
Christian Urban <urbanc@in.tum.de>
parents: 1261
diff changeset
   149
and pat' =
954
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
  PN
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
| PS "name"
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   152
| PD "name" "name"
954
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
binder
1299
cbcd4997dac5 most tests work - the ones that do not I commented out
Christian Urban <urbanc@in.tum.de>
parents: 1298
diff changeset
   154
  f::"pat' \<Rightarrow> atom set"
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   155
where
978
b44592adf235 Improper interface for datatype and function packages and proper interface lateron.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 973
diff changeset
   156
  "f PN = {}"
1380
dab8d99b37c1 added bn-information, but it is not yet ordered according to the dts
Christian Urban <urbanc@in.tum.de>
parents: 1378
diff changeset
   157
| "f (PD x y) = {atom x, atom y}"
1299
cbcd4997dac5 most tests work - the ones that do not I commented out
Christian Urban <urbanc@in.tum.de>
parents: 1298
diff changeset
   158
| "f (PS x) = {atom x}"
1380
dab8d99b37c1 added bn-information, but it is not yet ordered according to the dts
Christian Urban <urbanc@in.tum.de>
parents: 1378
diff changeset
   159
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   160
thm trm'_pat'.fv
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   161
thm trm'_pat'.eq_iff
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   162
thm trm'_pat'.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   163
thm trm'_pat'.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   164
thm trm'_pat'.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   165
thm trm'_pat'.distinct
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   166
thm trm'_pat'.fv[simplified trm'_pat'.supp]
1367
9bbf56cdeb88 added compat definitions to some examples
Christian Urban <urbanc@in.tum.de>
parents: 1365
diff changeset
   167
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   168
nominal_datatype trm0 =
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   169
  Var0 "name"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   170
| App0 "trm0" "trm0"
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   171
| Lam0 x::"name" t::"trm0"          bind x in t
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   172
| Let0 p::"pat0" "trm0" t::"trm0"   bind "f0 p" in t
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   173
and pat0 =
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   174
  PN0
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   175
| PS0 "name"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   176
| PD0 "pat0" "pat0"
954
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
binder
1299
cbcd4997dac5 most tests work - the ones that do not I commented out
Christian Urban <urbanc@in.tum.de>
parents: 1298
diff changeset
   178
  f0::"pat0 \<Rightarrow> atom set"
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   179
where
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   180
  "f0 PN0 = {}"
1299
cbcd4997dac5 most tests work - the ones that do not I commented out
Christian Urban <urbanc@in.tum.de>
parents: 1298
diff changeset
   181
| "f0 (PS0 x) = {atom x}"
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   182
| "f0 (PD0 p1 p2) = (f0 p1) \<union> (f0 p2)"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   183
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   184
thm trm0_pat0.fv
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   185
thm trm0_pat0.eq_iff
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   186
thm trm0_pat0.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   187
thm trm0_pat0.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   188
thm trm0_pat0.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   189
thm trm0_pat0.distinct
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   190
thm trm0_pat0.fv[simplified trm0_pat0.supp,no_vars]
954
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
text {* example type schemes *}
1285
e3ac56d3b7af added example from my phd
Christian Urban <urbanc@in.tum.de>
parents: 1284
diff changeset
   193
1302
d3101a5b9c4d Length fix for nested recursions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1299
diff changeset
   194
nominal_datatype t =
1416
947e5f772a9c Lifting constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1398
diff changeset
   195
  VarTS "name"
947e5f772a9c Lifting constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1398
diff changeset
   196
| FunTS "t" "t"
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   197
and  tyS =
1549
74888979e9cd Update Test to use fset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1522
diff changeset
   198
  All xs::"name fset" ty::"t" bind xs in ty
954
c009d2535896 very rough example file for how nominal2 specification can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   200
thm t_tyS.fv
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   201
thm t_tyS.eq_iff
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   202
thm t_tyS.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   203
thm t_tyS.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   204
thm t_tyS.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   205
thm t_tyS.distinct
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   206
thm t_tyS.fv[simplified t_tyS.supp]
1418
632b08744613 With the 4 cheats, all examples fully lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   207
1473
b4216d0e109a added partial proof of supp for type schemes
Christian Urban <urbanc@in.tum.de>
parents: 1472
diff changeset
   208
ML {* Sign.of_sort @{theory} (@{typ t}, @{sort fs}) *}
b4216d0e109a added partial proof of supp for type schemes
Christian Urban <urbanc@in.tum.de>
parents: 1472
diff changeset
   209
ML {* Sign.of_sort @{theory} (@{typ tyS}, @{sort fs}) *}
b4216d0e109a added partial proof of supp for type schemes
Christian Urban <urbanc@in.tum.de>
parents: 1472
diff changeset
   210
1478
1ea4ca823266 added proof of supp/fv for type schemes
Christian Urban <urbanc@in.tum.de>
parents: 1473
diff changeset
   211
1473
b4216d0e109a added partial proof of supp for type schemes
Christian Urban <urbanc@in.tum.de>
parents: 1472
diff changeset
   212
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   213
(* example 1 from Terms.thy *)
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   214
1517
62d6f7acc110 corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents: 1515
diff changeset
   215
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   216
nominal_datatype trm1 =
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   217
  Vr1 "name"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   218
| Ap1 "trm1" "trm1"
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   219
| Lm1 x::"name" t::"trm1"       bind x in t
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   220
| Lt1 p::"bp1" "trm1" t::"trm1" bind "bv1 p" in t
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   221
and bp1 =
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   222
  BUnit1
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   223
| BV1 "name"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   224
| BP1 "bp1" "bp1"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   225
binder
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   226
  bv1
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   227
where
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   228
  "bv1 (BUnit1) = {}"
1392
baa67b07f436 parser produces ordered bn-fun information
Christian Urban <urbanc@in.tum.de>
parents: 1380
diff changeset
   229
| "bv1 (BP1 bp1 bp2) = (bv1 bp1) \<union> (bv1 bp2)"
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   230
| "bv1 (BV1 x) = {atom x}"
1392
baa67b07f436 parser produces ordered bn-fun information
Christian Urban <urbanc@in.tum.de>
parents: 1380
diff changeset
   231
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   232
thm trm1_bp1.fv
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   233
thm trm1_bp1.eq_iff
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   234
thm trm1_bp1.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   235
thm trm1_bp1.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   236
thm trm1_bp1.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   237
thm trm1_bp1.distinct
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   238
thm trm1_bp1.fv[simplified trm1_bp1.supp]
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   239
1367
9bbf56cdeb88 added compat definitions to some examples
Christian Urban <urbanc@in.tum.de>
parents: 1365
diff changeset
   240
text {* example 3 from Terms.thy *}
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   241
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   242
nominal_datatype trm3 =
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   243
  Vr3 "name"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   244
| Ap3 "trm3" "trm3"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   245
| Lm3 x::"name" t::"trm3"        bind x in t
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   246
| Lt3 r::"rassigns3" t::"trm3"   bind "bv3 r" in t
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   247
and rassigns3 =
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   248
  ANil
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   249
| ACons "name" "trm3" "rassigns3"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   250
binder
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   251
  bv3
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   252
where
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   253
  "bv3 ANil = {}"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   254
| "bv3 (ACons x t as) = {atom x} \<union> (bv3 as)"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   255
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   256
thm trm3_rassigns3.fv
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   257
thm trm3_rassigns3.eq_iff
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   258
thm trm3_rassigns3.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   259
thm trm3_rassigns3.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   260
thm trm3_rassigns3.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   261
thm trm3_rassigns3.distinct
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   262
thm trm3_rassigns3.fv[simplified trm3_rassigns3.supp]
1367
9bbf56cdeb88 added compat definitions to some examples
Christian Urban <urbanc@in.tum.de>
parents: 1365
diff changeset
   263
1251
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   264
(* example 5 from Terms.thy *)
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   265
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   266
nominal_datatype trm5 =
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   267
  Vr5 "name"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   268
| Ap5 "trm5" "trm5"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   269
| Lt5 l::"lts" t::"trm5"  bind "bv5 l" in t
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   270
and lts =
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   271
  Lnil
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   272
| Lcons "name" "trm5" "lts"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   273
binder
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   274
  bv5
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   275
where
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   276
  "bv5 Lnil = {}"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   277
| "bv5 (Lcons n t ltl) = {atom n} \<union> (bv5 ltl)"
11b8798dea5d parsing and definition of raw datatype and bv-function work (not very beautiful)
Christian Urban <urbanc@in.tum.de>
parents: 1232
diff changeset
   278
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   279
thm trm5_lts.fv
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   280
thm trm5_lts.eq_iff
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   281
thm trm5_lts.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   282
thm trm5_lts.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   283
thm trm5_lts.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   284
thm trm5_lts.distinct
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   285
thm trm5_lts.fv[simplified trm5_lts.supp]
1285
e3ac56d3b7af added example from my phd
Christian Urban <urbanc@in.tum.de>
parents: 1284
diff changeset
   286
e3ac56d3b7af added example from my phd
Christian Urban <urbanc@in.tum.de>
parents: 1284
diff changeset
   287
(* example form Leroy 96 about modules; OTT *)
1284
212f3ab40cc2 streamlined parser
Christian Urban <urbanc@in.tum.de>
parents: 1283
diff changeset
   288
1272
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   289
nominal_datatype mexp =
1296
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   290
  Acc "path"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   291
| Stru "body"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   292
| Funct x::"name" "sexp" m::"mexp"    bind x in m
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   293
| FApp "mexp" "path"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   294
| Ascr "mexp" "sexp"
1272
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   295
and body =
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   296
  Empty
1296
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   297
| Seq c::defn d::"body"     bind "cbinders c" in d
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   298
and defn =
1296
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   299
  Type "name" "tyty"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   300
| Dty "name"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   301
| DStru "name" "mexp"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   302
| Val "name" "trmtrm"
1272
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   303
and sexp =
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   304
  Sig sbody
1296
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   305
| SFunc "name" "sexp" "sexp"
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   306
and sbody =
1272
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   307
  SEmpty
1296
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   308
| SSeq C::spec D::sbody    bind "Cbinders C" in D
1272
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   309
and spec =
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   310
  Type1 "name"
1296
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   311
| Type2 "name" "tyty"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   312
| SStru "name" "sexp"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   313
| SVal "name" "tyty"
1272
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   314
and tyty =
1296
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   315
  Tyref1 "name"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   316
| Tyref2 "path" "tyty"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   317
| Fun "tyty" "tyty"
1272
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   318
and path =
1296
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   319
  Sref1 "name"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   320
| Sref2 "path" "name"
1272
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   321
and trmtrm =
1296
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   322
  Tref1 "name"
790940e90db2 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1295
diff changeset
   323
| Tref2 "path" "name"
1340
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   324
| Lam' v::"name" "tyty" M::"trmtrm"  bind v in M
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   325
| App' "trmtrm" "trmtrm"
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   326
| Let' "body" "trmtrm"
1272
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   327
binder
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   328
    cbinders :: "defn \<Rightarrow> atom set"
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   329
and Cbinders :: "spec \<Rightarrow> atom set"
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   330
where
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   331
  "cbinders (Type t T) = {atom t}"
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   332
| "cbinders (Dty t) = {atom t}"
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   333
| "cbinders (DStru x s) = {atom x}"
1396
08294f4d6c08 Linked parser to fv and alpha.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1392
diff changeset
   334
| "cbinders (Val v M) = {atom v}"
1272
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   335
| "Cbinders (Type1 t) = {atom t}"
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   336
| "Cbinders (Type2 t T) = {atom t}"
6d140b2c751f added ott-example about Leroy96
Christian Urban <urbanc@in.tum.de>
parents: 1265
diff changeset
   337
| "Cbinders (SStru x S) = {atom x}"
1396
08294f4d6c08 Linked parser to fv and alpha.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1392
diff changeset
   338
| "Cbinders (SVal v T) = {atom v}"
1265
fc8f5897b00a first attempt to make sense out of the core-haskell definition
Christian Urban <urbanc@in.tum.de>
parents: 1261
diff changeset
   339
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   340
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.fv
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   341
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.eq_iff
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   342
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   343
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   344
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   345
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.inducts
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   346
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.distinct
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   347
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.supp
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   348
thm mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.fv[simplified mexp_body_defn_sexp_sbody_spec_tyty_path_trmtrm.supp]
1392
baa67b07f436 parser produces ordered bn-fun information
Christian Urban <urbanc@in.tum.de>
parents: 1380
diff changeset
   349
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   350
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   351
(* example from my PHD *)
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   352
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   353
atom_decl coname
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   354
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   355
nominal_datatype phd =
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   356
   Ax "name" "coname"
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   357
|  Cut n::"coname" t1::"phd" c::"coname" t2::"phd"              bind n in t1, bind c in t2
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   358
|  AndR c1::"coname" t1::"phd" c2::"coname" t2::"phd" "coname"  bind c1 in t1, bind c2 in t2
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   359
|  AndL1 n::"name" t::"phd" "name"                              bind n in t
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   360
|  AndL2 n::"name" t::"phd" "name"                              bind n in t
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   361
|  ImpL c::"coname" t1::"phd" n::"name" t2::"phd" "name"        bind c in t1, bind n in t2
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   362
|  ImpR c::"coname" n::"name" t::"phd" "coname"                 bind n in t, bind c in t
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   363
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   364
thm phd.fv
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   365
thm phd.eq_iff
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   366
thm phd.bn
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   367
thm phd.perm
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   368
thm phd.induct
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   369
thm phd.distinct
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   370
thm phd.fv[simplified phd.supp]
1522
4f8bab472a83 Leroy96 supp=fv and fixes to make it compile
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1517
diff changeset
   371
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   372
(* example 3 from Peter Sewell's bestiary *)
1418
632b08744613 With the 4 cheats, all examples fully lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   373
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   374
nominal_datatype exp =
1340
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   375
  VarP "name"
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   376
| AppP "exp" "exp"
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   377
| LamP x::"name" e::"exp" bind x in e
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   378
| LetP x::"name" p::"pat3" e1::"exp" e2::"exp" bind x in e2, bind "bp'' p" in e1
1378
5c6c950812b1 All examples should work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1368
diff changeset
   379
and pat3 =
1319
d793ce9cd06f potential problem with the phd-example, where two permutations are generated, but only one is used
Christian Urban <urbanc@in.tum.de>
parents: 1313
diff changeset
   380
  PVar "name"
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   381
| PUnit
1378
5c6c950812b1 All examples should work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1368
diff changeset
   382
| PPair "pat3" "pat3"
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   383
binder
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   384
  bp'' :: "pat3 \<Rightarrow> atom set"
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   385
where
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   386
  "bp'' (PVar x) = {atom x}"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   387
| "bp'' (PUnit) = {}"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   388
| "bp'' (PPair p1 p2) = bp'' p1 \<union> bp'' p2"
1418
632b08744613 With the 4 cheats, all examples fully lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   389
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   390
thm exp_pat3.fv
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   391
thm exp_pat3.eq_iff
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   392
thm exp_pat3.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   393
thm exp_pat3.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   394
thm exp_pat3.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   395
thm exp_pat3.distinct
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   396
thm exp_pat3.fv[simplified exp_pat3.supp]
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   397
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   398
(* example 6 from Peter Sewell's bestiary *)
1341
c25f797c7e6e Added lifting of pseudo-injectivity, commented out the code again and enabled the weird examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1340
diff changeset
   399
nominal_datatype exp6 =
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   400
  EVar name
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   401
| EPair exp6 exp6
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   402
| ELetRec x::name p::pat6 e1::exp6 e2::exp6 bind x in e1, bind x in e2, bind "bp6 p" in e1
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   403
and pat6 =
1340
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   404
  PVar' name
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   405
| PUnit'
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   406
| PPair' pat6 pat6
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   407
binder
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   408
  bp6 :: "pat6 \<Rightarrow> atom set"
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   409
where
1340
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   410
  "bp6 (PVar' x) = {atom x}"
f201eb6acafc Lift BV,FV,Permutations and injection :).
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1338
diff changeset
   411
| "bp6 (PUnit') = {}"
1341
c25f797c7e6e Added lifting of pseudo-injectivity, commented out the code again and enabled the weird examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1340
diff changeset
   412
| "bp6 (PPair' p1 p2) = bp6 p1 \<union> bp6 p2"
1418
632b08744613 With the 4 cheats, all examples fully lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1416
diff changeset
   413
1515
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   414
thm exp6_pat6.fv
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   415
thm exp6_pat6.eq_iff
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   416
thm exp6_pat6.bn
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   417
thm exp6_pat6.perm
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   418
thm exp6_pat6.induct
76fa21f27f22 Rename "_property" to ".property"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1510
diff changeset
   419
thm exp6_pat6.distinct
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   420
1553
4355eb3b7161 Automatically derive support for datatypes with at-most one binding per constructor.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1549
diff changeset
   421
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   422
(* THE REST ARE NOT SUPPOSED TO WORK YET *)
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   423
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   424
(* example 7 from Peter Sewell's bestiary *)
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   425
(* dest_Const raised
1341
c25f797c7e6e Added lifting of pseudo-injectivity, commented out the code again and enabled the weird examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1340
diff changeset
   426
nominal_datatype exp7 =
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   427
  EVar' name
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   428
| EUnit'
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   429
| EPair' exp7 exp7
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   430
| ELetRec' l::lrbs e::exp7 bind "b7s l" in e, bind "b7s l" in l
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   431
and lrb =
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   432
  Assign' name exp7
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   433
and lrbs =
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   434
  Single' lrb
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   435
| More' lrb lrbs
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   436
binder
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   437
  b7 :: "lrb \<Rightarrow> atom set" and
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   438
  b7s :: "lrbs \<Rightarrow> atom set"
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   439
where
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   440
  "b7 (Assign x e) = {atom x}"
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   441
| "b7s (Single a) = b7 a"
1341
c25f797c7e6e Added lifting of pseudo-injectivity, commented out the code again and enabled the weird examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1340
diff changeset
   442
| "b7s (More a as) = (b7 a) \<union> (b7s as)"
1361
1e811e3424f3 With restricted_nominal=1, exp7 and exp8 work. Not sure about proving bn_rsp there.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1355
diff changeset
   443
thm alpha_exp7_raw_alpha_lrb_raw_alpha_lrbs_raw.intros
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   444
*)
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   445
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   446
(* example 8 from Peter Sewell's bestiary *)
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   447
(*
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   448
*** fv_bn: recursive argument, but wrong datatype.
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   449
*** At command "nominal_datatype".
1341
c25f797c7e6e Added lifting of pseudo-injectivity, commented out the code again and enabled the weird examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1340
diff changeset
   450
nominal_datatype exp8 =
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   451
  EVar' name
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   452
| EUnit'
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   453
| EPair' exp8 exp8
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   454
| ELetRec' l::lrbs8 e::exp8 bind "b_lrbs8 l" in e, bind "b_lrbs8 l" in l
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   455
and fnclause =
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   456
  K' x::name p::pat8 e::exp8 bind "b_pat p" in e
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   457
and fnclauses =
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   458
  S' fnclause
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   459
| ORs' fnclause fnclauses
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   460
and lrb8 =
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   461
  Clause' fnclauses
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   462
and lrbs8 =
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   463
  Single' lrb8
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   464
| More' lrb8 lrbs8
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   465
and pat8 =
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   466
  PVar'' name
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   467
| PUnit''
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   468
| PPair'' pat8 pat8
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   469
binder
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   470
  b_lrbs8 :: "lrbs8 \<Rightarrow> atom set" and
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   471
  b_pat :: "pat8 \<Rightarrow> atom set" and
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   472
  b_fnclauses :: "fnclauses \<Rightarrow> atom set" and
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   473
  b_fnclause :: "fnclause \<Rightarrow> atom set" and
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   474
  b_lrb8 :: "lrb8 \<Rightarrow> atom set"
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   475
where
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   476
  "b_lrbs8 (Single' l) = b_lrb8 l"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   477
| "b_lrbs8 (More' l ls) = b_lrb8 l \<union> b_lrbs8 ls"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   478
| "b_pat (PVar'' x) = {atom x}"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   479
| "b_pat (PUnit'') = {}"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   480
| "b_pat (PPair'' p1 p2) = b_pat p1 \<union> b_pat p2"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   481
| "b_fnclauses (S' fc) = (b_fnclause fc)"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   482
| "b_fnclauses (ORs' fc fcs) = (b_fnclause fc) \<union> (b_fnclauses fcs)"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   483
| "b_lrb8 (Clause' fcs) = (b_fnclauses fcs)"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   484
| "b_fnclause (K' x pat exp8) = {atom x}"
1361
1e811e3424f3 With restricted_nominal=1, exp7 and exp8 work. Not sure about proving bn_rsp there.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1355
diff changeset
   485
thm alpha_exp8_raw_alpha_fnclause_raw_alpha_fnclauses_raw_alpha_lrb8_raw_alpha_lrbs8_raw_alpha_pat8_raw.intros
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   486
*)
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   487
(* example 4 from Terms.thy *)
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   488
(* fv_eqvt does not work, we need to repaire defined permute functions
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   489
   defined fv and defined alpha... *)
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   490
(* lists-datastructure does not work yet
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   491
nominal_datatype trm4 =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   492
  Vr4 "name"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   493
| Ap4 "trm4" "trm4 list"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   494
| Lm4 x::"name" t::"trm4"  bind x in t
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   495
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   496
thm alpha_trm4_raw_alpha_trm4_raw_list.intros[no_vars]
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   497
thm fv_trm4_raw_fv_trm4_raw_list.simps[no_vars]
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   498
*)
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   499
(* core haskell *)
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   500
atom_decl var
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   501
atom_decl tvar
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   502
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   503
(* there are types, coercion types and regular types *)
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   504
(* list-data-structure
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   505
nominal_datatype tkind =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   506
  KStar
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   507
| KFun "tkind" "tkind"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   508
and ckind =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   509
  CKEq "ty" "ty"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   510
and ty =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   511
  TVar "tvar"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   512
| TC "string"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   513
| TApp "ty" "ty"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   514
| TFun "string" "ty list"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   515
| TAll tv::"tvar" "tkind" T::"ty"  bind tv in T
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   516
| TEq "ty" "ty" "ty"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   517
and co =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   518
  CC "string"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   519
| CApp "co" "co"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   520
| CFun "string" "co list"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   521
| CAll tv::"tvar" "ckind" C::"co"  bind tv in C
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   522
| CEq "co" "co" "co"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   523
| CSym "co"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   524
| CCir "co" "co"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   525
| CLeft "co"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   526
| CRight "co"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   527
| CSim "co"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   528
| CRightc "co"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   529
| CLeftc "co"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   530
| CCoe "co" "co"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   531
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   532
abbreviation
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   533
  "atoms A \<equiv> atom ` A"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   534
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   535
nominal_datatype trm =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   536
  Var "var"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   537
| C "string"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   538
| LAM tv::"tvar" "kind" t::"trm"   bind tv in t
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   539
| APP "trm" "ty"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   540
| Lam v::"var" "ty" t::"trm"       bind v in t
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   541
| App "trm" "trm"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   542
| Let x::"var" "ty" "trm" t::"trm" bind x in t
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   543
| Case "trm" "assoc list"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   544
| Cast "trm" "ty"                   --"ty is supposed to be a coercion type only"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   545
and assoc =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   546
  A p::"pat" t::"trm" bind "bv p" in t
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   547
and pat =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   548
  K "string" "(tvar \<times> kind) list" "(var \<times> ty) list"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   549
binder
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   550
 bv :: "pat \<Rightarrow> atom set"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   551
where
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   552
 "bv (K s ts vs) = (atoms (set (map fst ts))) \<union> (atoms (set (map fst vs)))"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   553
*)
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   554
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   555
text {* weirdo example from Peter Sewell's bestiary *}
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   556
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   557
nominal_datatype weird =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   558
  WBind x::"name" y::"name" p1::"weird" p2::"weird" p3::"weird"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   559
    bind x in p1, bind x in p2, bind y in p2, bind y in p3
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   560
| WV "name"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   561
| WP "weird" "weird"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   562
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   563
thm permute_weird_raw.simps[no_vars]
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   564
thm alpha_weird_raw.intros[no_vars]
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   565
thm fv_weird_raw.simps[no_vars]
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   566
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   567
(* example 8 from Terms.thy *)
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   568
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   569
(* Binding in a term under a bn, needs to fail *)
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   570
(*
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   571
nominal_datatype foo8 =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   572
  Foo0 "name"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   573
| Foo1 b::"bar8" f::"foo8" bind "bv8 b" in f --"check fo error if this is called foo"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   574
and bar8 =
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   575
  Bar0 "name"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   576
| Bar1 "name" s::"name" b::"bar8" bind s in b
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   577
binder
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   578
  bv8
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   579
where
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   580
  "bv8 (Bar0 x) = {}"
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   581
| "bv8 (Bar1 v x b) = {atom v}"
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   582
*)
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   583
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   584
(* Type schemes with separate datatypes *)
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   585
nominal_datatype T =
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   586
  TVar "name"
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   587
| TFun "T" "T"
1398
1f3c01345c9e Reordered examples in Test.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1396
diff changeset
   588
1466
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   589
(* PROBLEM: 
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   590
*** exception Datatype raised 
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   591
*** (line 218 of "/usr/local/src/Isabelle_16-Mar-2010/src/HOL/Tools/Datatype/datatype_aux.ML")
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   592
*** At command "nominal_datatype".
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   593
nominal_datatype TyS =
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   594
  TAll xs::"name list" ty::"T" bind xs in ty
d18defacda25 commented out examples that should not work; but for example type-scheme example should work
Christian Urban <urbanc@in.tum.de>
parents: 1465
diff changeset
   595
*)
1312
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   596
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   597
(* example 9 from Peter Sewell's bestiary *)
b0eae8c93314 added some more examples from Peter Sewell's bestiary
Christian Urban <urbanc@in.tum.de>
parents: 1304
diff changeset
   598
(* run out of steam at the moment *)
1265
fc8f5897b00a first attempt to make sense out of the core-haskell definition
Christian Urban <urbanc@in.tum.de>
parents: 1261
diff changeset
   599
961
0f88e04eb486 Variable takes a 'name'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 954
diff changeset
   600
end
1223
160343d86a6f "raw"-ified the term-constructors and types given in the specification
Christian Urban <urbanc@in.tum.de>
parents: 1194
diff changeset
   601
160343d86a6f "raw"-ified the term-constructors and types given in the specification
Christian Urban <urbanc@in.tum.de>
parents: 1194
diff changeset
   602
1228
c179ad9d2446 declarartion of the raw datatype already works; raw binding functions throw an exception about mutual recursive types
Christian Urban <urbanc@in.tum.de>
parents: 1223
diff changeset
   603