author | wenzelm |
Sat, 16 Aug 2014 11:35:33 +0200 | |
changeset 57945 | cacb00a569e0 |
parent 52143 | 36ffe23b25f8 |
child 58617 | 4f169d2cf6f3 |
permissions | -rw-r--r-- |
22809 | 1 |
(* Title: Cube/Cube.thy |
2 |
Author: Tobias Nipkow |
|
3 |
*) |
|
3773 | 4 |
|
17252 | 5 |
header {* Barendregt's Lambda-Cube *} |
6 |
||
7 |
theory Cube |
|
8 |
imports Pure |
|
9 |
begin |
|
10 |
||
39557
fe5722fce758
renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is global-only;
wenzelm
parents:
35256
diff
changeset
|
11 |
setup Pure_Thy.old_appl_syntax_setup |
26956
1309a6a0a29f
setup PureThy.old_appl_syntax_setup -- theory Pure provides regular application syntax by default;
wenzelm
parents:
24783
diff
changeset
|
12 |
|
57945
cacb00a569e0
prefer 'named_theorems' over Named_Thms, with subtle change of semantics due to visual order vs. internal reverse order;
wenzelm
parents:
52143
diff
changeset
|
13 |
named_theorems rules "Cube inference rules" |
49752
2bbb0013ff82
modernized dynamic "rules" -- avoid rebinding of static facts;
wenzelm
parents:
45242
diff
changeset
|
14 |
|
17252 | 15 |
typedecl "term" |
16 |
typedecl "context" |
|
17 |
typedecl typing |
|
18 |
||
45241 | 19 |
axiomatization |
20 |
Abs :: "[term, term => term] => term" and |
|
21 |
Prod :: "[term, term => term] => term" and |
|
22 |
Trueprop :: "[context, typing] => prop" and |
|
23 |
MT_context :: "context" and |
|
24 |
Context :: "[typing, context] => context" and |
|
25 |
star :: "term" ("*") and |
|
45242 | 26 |
box :: "term" ("\<box>") and |
45241 | 27 |
app :: "[term, term] => term" (infixl "^" 20) and |
28 |
Has_type :: "[term, term] => typing" |
|
17252 | 29 |
|
45241 | 30 |
nonterminal context' and typing' |
17252 | 31 |
|
32 |
syntax |
|
45242 | 33 |
"_Trueprop" :: "[context', typing'] => prop" ("(_/ \<turnstile> _)") |
45241 | 34 |
"_Trueprop1" :: "typing' => prop" ("(_)") |
35 |
"" :: "id => context'" ("_") |
|
36 |
"" :: "var => context'" ("_") |
|
37 |
"_MT_context" :: "context'" ("") |
|
38 |
"_Context" :: "[typing', context'] => context'" ("_ _") |
|
39 |
"_Has_type" :: "[term, term] => typing'" ("(_:/ _)" [0, 0] 5) |
|
45242 | 40 |
"_Lam" :: "[idt, term, term] => term" ("(3\<Lambda> _:_./ _)" [0, 0, 0] 10) |
41 |
"_Pi" :: "[idt, term, term] => term" ("(3\<Pi> _:_./ _)" [0, 0] 10) |
|
42 |
"_arrow" :: "[term, term] => term" (infixr "\<rightarrow>" 10) |
|
17252 | 43 |
|
44 |
translations |
|
45241 | 45 |
"_Trueprop(G, t)" == "CONST Trueprop(G, t)" |
45242 | 46 |
("prop") "x:X" == ("prop") "\<turnstile> x:X" |
45241 | 47 |
"_MT_context" == "CONST MT_context" |
48 |
"_Context" == "CONST Context" |
|
49 |
"_Has_type" == "CONST Has_type" |
|
45242 | 50 |
"\<Lambda> x:A. B" == "CONST Abs(A, %x. B)" |
51 |
"\<Pi> x:A. B" => "CONST Prod(A, %x. B)" |
|
52 |
"A \<rightarrow> B" => "CONST Prod(A, %_. B)" |
|
17252 | 53 |
|
54 |
syntax (xsymbols) |
|
35256 | 55 |
"_Pi" :: "[idt, term, term] => term" ("(3\<Pi> _:_./ _)" [0, 0] 10) |
17252 | 56 |
|
35113 | 57 |
print_translation {* |
42284 | 58 |
[(@{const_syntax Prod}, |
52143 | 59 |
fn _ => Syntax_Trans.dependent_tr' (@{syntax_const "_Pi"}, @{syntax_const "_arrow"}))] |
35113 | 60 |
*} |
17252 | 61 |
|
45241 | 62 |
axiomatization where |
45242 | 63 |
s_b: "*: \<box>" and |
17252 | 64 |
|
45242 | 65 |
strip_s: "[| A:*; a:A ==> G \<turnstile> x:X |] ==> a:A G \<turnstile> x:X" and |
66 |
strip_b: "[| A:\<box>; a:A ==> G \<turnstile> x:X |] ==> a:A G \<turnstile> x:X" and |
|
17252 | 67 |
|
45241 | 68 |
app: "[| F:Prod(A, B); C:A |] ==> F^C: B(C)" and |
0 | 69 |
|
45241 | 70 |
pi_ss: "[| A:*; !!x. x:A ==> B(x):* |] ==> Prod(A, B):*" and |
17252 | 71 |
|
45241 | 72 |
lam_ss: "[| A:*; !!x. x:A ==> f(x):B(x); !!x. x:A ==> B(x):* |] |
73 |
==> Abs(A, f) : Prod(A, B)" and |
|
17252 | 74 |
|
45241 | 75 |
beta: "Abs(A, f)^a == f(a)" |
17252 | 76 |
|
49752
2bbb0013ff82
modernized dynamic "rules" -- avoid rebinding of static facts;
wenzelm
parents:
45242
diff
changeset
|
77 |
lemmas [rules] = s_b strip_s strip_b app lam_ss pi_ss |
17252 | 78 |
|
79 |
lemma imp_elim: |
|
45242 | 80 |
assumes "f:A\<rightarrow>B" and "a:A" and "f^a:B ==> PROP P" |
41526 | 81 |
shows "PROP P" by (rule app assms)+ |
17252 | 82 |
|
83 |
lemma pi_elim: |
|
84 |
assumes "F:Prod(A,B)" and "a:A" and "F^a:B(a) ==> PROP P" |
|
41526 | 85 |
shows "PROP P" by (rule app assms)+ |
17252 | 86 |
|
87 |
||
88 |
locale L2 = |
|
45242 | 89 |
assumes pi_bs: "[| A:\<box>; !!x. x:A ==> B(x):* |] ==> Prod(A,B):*" |
90 |
and lam_bs: "[| A:\<box>; !!x. x:A ==> f(x):B(x); !!x. x:A ==> B(x):* |] |
|
17252 | 91 |
==> Abs(A,f) : Prod(A,B)" |
45242 | 92 |
begin |
17252 | 93 |
|
49752
2bbb0013ff82
modernized dynamic "rules" -- avoid rebinding of static facts;
wenzelm
parents:
45242
diff
changeset
|
94 |
lemmas [rules] = lam_bs pi_bs |
45242 | 95 |
|
96 |
end |
|
17252 | 97 |
|
17260 | 98 |
|
17252 | 99 |
locale Lomega = |
100 |
assumes |
|
45242 | 101 |
pi_bb: "[| A:\<box>; !!x. x:A ==> B(x):\<box> |] ==> Prod(A,B):\<box>" |
102 |
and lam_bb: "[| A:\<box>; !!x. x:A ==> f(x):B(x); !!x. x:A ==> B(x):\<box> |] |
|
17252 | 103 |
==> Abs(A,f) : Prod(A,B)" |
45242 | 104 |
begin |
17252 | 105 |
|
49752
2bbb0013ff82
modernized dynamic "rules" -- avoid rebinding of static facts;
wenzelm
parents:
45242
diff
changeset
|
106 |
lemmas [rules] = lam_bb pi_bb |
45242 | 107 |
|
108 |
end |
|
17252 | 109 |
|
110 |
||
111 |
locale LP = |
|
45242 | 112 |
assumes pi_sb: "[| A:*; !!x. x:A ==> B(x):\<box> |] ==> Prod(A,B):\<box>" |
113 |
and lam_sb: "[| A:*; !!x. x:A ==> f(x):B(x); !!x. x:A ==> B(x):\<box> |] |
|
17252 | 114 |
==> Abs(A,f) : Prod(A,B)" |
45241 | 115 |
begin |
17252 | 116 |
|
49752
2bbb0013ff82
modernized dynamic "rules" -- avoid rebinding of static facts;
wenzelm
parents:
45242
diff
changeset
|
117 |
lemmas [rules] = lam_sb pi_sb |
45241 | 118 |
|
119 |
end |
|
17252 | 120 |
|
17260 | 121 |
|
17252 | 122 |
locale LP2 = LP + L2 |
45241 | 123 |
begin |
17252 | 124 |
|
49752
2bbb0013ff82
modernized dynamic "rules" -- avoid rebinding of static facts;
wenzelm
parents:
45242
diff
changeset
|
125 |
lemmas [rules] = lam_bs pi_bs lam_sb pi_sb |
45241 | 126 |
|
127 |
end |
|
17252 | 128 |
|
17260 | 129 |
|
17252 | 130 |
locale Lomega2 = L2 + Lomega |
45241 | 131 |
begin |
17252 | 132 |
|
49752
2bbb0013ff82
modernized dynamic "rules" -- avoid rebinding of static facts;
wenzelm
parents:
45242
diff
changeset
|
133 |
lemmas [rules] = lam_bs pi_bs lam_bb pi_bb |
45241 | 134 |
|
135 |
end |
|
17252 | 136 |
|
17260 | 137 |
|
17252 | 138 |
locale LPomega = LP + Lomega |
45241 | 139 |
begin |
17252 | 140 |
|
49752
2bbb0013ff82
modernized dynamic "rules" -- avoid rebinding of static facts;
wenzelm
parents:
45242
diff
changeset
|
141 |
lemmas [rules] = lam_bb pi_bb lam_sb pi_sb |
45241 | 142 |
|
143 |
end |
|
17252 | 144 |
|
17260 | 145 |
|
17252 | 146 |
locale CC = L2 + LP + Lomega |
45241 | 147 |
begin |
17252 | 148 |
|
49752
2bbb0013ff82
modernized dynamic "rules" -- avoid rebinding of static facts;
wenzelm
parents:
45242
diff
changeset
|
149 |
lemmas [rules] = lam_bs pi_bs lam_bb pi_bb lam_sb pi_sb |
17252 | 150 |
|
151 |
end |
|
45241 | 152 |
|
153 |
end |