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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
(* Title: HoTT/Prod.thy
Author: Josh Chen
Date: Aug 2018
Dependent product (function) type.
*)
theory Prod
imports HoTT_Base
begin
section ‹Constants and syntax›
axiomatization
Prod :: "[Term, Typefam] ⇒ Term" and
lambda :: "(Term ⇒ Term) ⇒ Term" (binder "❙λ" 30) and
appl :: "[Term, Term] ⇒ Term" (infixl "`" 60)
― ‹Application binds tighter than abstraction.›
syntax
"_PROD" :: "[idt, Term, Term] ⇒ Term" ("(3∏_:_./ _)" 30)
"_PROD_ASCII" :: "[idt, Term, Term] ⇒ Term" ("(3PROD _:_./ _)" 30)
text "The translations below bind the variable ‹x› in the expressions ‹B› and ‹b›."
translations
"∏x:A. B" ⇌ "CONST Prod A (λx. B)"
"PROD x:A. B" ⇀ "CONST Prod A (λx. B)"
text "Nondependent functions are a special case."
abbreviation Function :: "[Term, Term] ⇒ Term" (infixr "→" 40)
where "A → B ≡ ∏_: A. B"
section ‹Type rules›
axiomatization where
Prod_form: "⟦A: U(i); B: A ⟶ U(i)⟧ ⟹ ∏x:A. B(x): U(i)"
and
Prod_intro: "⟦A: U(i); ⋀x. x: A ⟹ b(x): B(x)⟧ ⟹ ❙λx. b(x): ∏x:A. B(x)"
and
Prod_elim: "⟦f: ∏x:A. B(x); a: A⟧ ⟹ f`a: B(a)"
and
Prod_comp: "⟦⋀x. x: A ⟹ b(x): B(x); a: A⟧ ⟹ (❙λx. b(x))`a ≡ b(a)"
and
Prod_uniq: "f : ∏x:A. B(x) ⟹ ❙λx. (f`x) ≡ f"
and
Prod_eq: "⟦⋀x. x: A ⟹ b(x) ≡ b'(x); A: U(i)⟧ ⟹ ❙λx. b(x) ≡ ❙λx. b'(x)"
text "
The Pure rules for ‹≡› only let us judge strict syntactic equality of object lambda expressions; Prod_eq is the actual definitional equality rule.
Note that the syntax ‹❙λ› (bold lambda) used for dependent functions clashes with the proof term syntax (cf. §2.5.2 of the Isabelle/Isar Implementation).
"
text "
In addition to the usual type rules, it is a meta-theorem that whenever ‹∏x:A. B x: U(i)› is derivable from some set of premises Γ, then so are ‹A: U(i)› and ‹B: A ⟶ U(i)›.
That is to say, the following inference rules are admissible, and it simplifies proofs greatly to axiomatize them directly.
"
axiomatization where
Prod_form_cond1: "(∏x:A. B(x): U(i)) ⟹ A: U(i)"
and
Prod_form_cond2: "(∏x:A. B(x): U(i)) ⟹ B: A ⟶ U(i)"
text "Set up the standard reasoner to use the type rules:"
lemmas Prod_rules [intro] = Prod_form Prod_intro Prod_elim Prod_comp Prod_uniq Prod_eq
lemmas Prod_wellform [wellform] = Prod_form_cond1 Prod_form_cond2
lemmas Prod_comps [comp] = Prod_comp Prod_uniq Prod_eq
section ‹Function composition›
definition compose :: "[Term, Term] ⇒ Term" (infixr "o" 70) where "g o f ≡ ❙λx. g`(f`x)"
syntax "_COMPOSE" :: "[Term, Term] ⇒ Term" (infixr "∘" 70)
translations "g ∘ f" ⇌ "g o f"
section ‹Unit type›
axiomatization
Unit :: Term ("𝟭") and
pt :: Term ("⋆") and
indUnit :: "[Term, Term] ⇒ Term" ("(1ind⇩𝟭)")
where
Unit_form: "𝟭: U(O)"
and
Unit_intro: "⋆: 𝟭"
and
Unit_elim: "⟦C: 𝟭 ⟶ U(i); c: C(⋆); a: 𝟭⟧ ⟹ ind⇩𝟭(c)(a) : C(a)"
and
Unit_comp: "⟦C: 𝟭 ⟶ U(i); c: C(⋆)⟧ ⟹ ind⇩𝟭(c)(⋆) ≡ c"
lemmas Unit_rules [intro] = Unit_form Unit_intro Unit_elim Unit_comp
lemmas Unit_comps [comp] = Unit_comp
end
|