1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
(* Title: HoTT/Sum.thy
Author: Josh Chen
Dependent sum type
*)
theory Sum
imports HoTT_Base
begin
section ‹Constants and syntax›
axiomatization
Sum :: "[Term, Typefam] ⇒ Term" and
pair :: "[Term, Term] ⇒ Term" ("(1<_,/ _>)") and
indSum :: "[[Term, Term] ⇒ Term, Term] ⇒ Term" ("(1ind⇩∑)")
syntax
"_SUM" :: "[idt, Term, Term] ⇒ Term" ("(3∑_:_./ _)" 20)
"_SUM_ASCII" :: "[idt, Term, Term] ⇒ Term" ("(3SUM _:_./ _)" 20)
translations
"∑x:A. B" ⇌ "CONST Sum A (λx. B)"
"SUM x:A. B" ⇀ "CONST Sum A (λx. B)"
text "Nondependent pair."
abbreviation Pair :: "[Term, Term] ⇒ Term" (infixr "×" 50)
where "A × B ≡ ∑_:A. B"
section ‹Type rules›
axiomatization where
Sum_form: "⟦A: U i; B: A ⟶ U i⟧ ⟹ ∑x:A. B x: U i"
and
Sum_intro: "⟦B: A ⟶ U i; a: A; b: B a⟧ ⟹ <a,b>: ∑x:A. B x"
and
Sum_elim: "⟦
p: ∑x:A. B x;
⋀x y. ⟦x: A; y: B x⟧ ⟹ f x y: C <x,y>;
C: ∑x:A. B x ⟶ U i
⟧ ⟹ ind⇩∑ f p: C p" (* What does writing λx y. f(x, y) change? *)
and
Sum_comp: "⟦
a: A;
b: B a;
⋀x y. ⟦x: A; y: B(x)⟧ ⟹ f x y: C <x,y>;
B: A ⟶ U i;
C: ∑x:A. B x ⟶ U i
⟧ ⟹ ind⇩∑ f <a,b> ≡ f a b"
text "Admissible inference rules for sum formation:"
axiomatization where
Sum_wellform1: "(∑x:A. B x: U i) ⟹ A: U i"
and
Sum_wellform2: "(∑x:A. B x: U i) ⟹ B: A ⟶ U i"
text "Rule attribute declarations:"
lemmas Sum_comp [comp]
lemmas Sum_wellform [wellform] = Sum_wellform1 Sum_wellform2
lemmas Sum_routine [intro] = Sum_form Sum_intro Sum_elim
end
|