aboutsummaryrefslogtreecommitdiff
path: root/hott
diff options
context:
space:
mode:
Diffstat (limited to 'hott')
-rw-r--r--hott/Basic_Types.thy90
-rw-r--r--hott/Nat.thy51
2 files changed, 141 insertions, 0 deletions
diff --git a/hott/Basic_Types.thy b/hott/Basic_Types.thy
new file mode 100644
index 0000000..85f22a8
--- /dev/null
+++ b/hott/Basic_Types.thy
@@ -0,0 +1,90 @@
+theory Basic_Types
+imports Spartan
+
+begin
+
+section \<open>Sum type\<close>
+
+axiomatization
+ Sum :: \<open>o \<Rightarrow> o \<Rightarrow> o\<close> and
+ inl :: \<open>o \<Rightarrow> o \<Rightarrow> o \<Rightarrow> o\<close> and
+ inr :: \<open>o \<Rightarrow> o \<Rightarrow> o \<Rightarrow> o\<close> and
+ SumInd :: \<open>o \<Rightarrow> o \<Rightarrow> (o \<Rightarrow> o) \<Rightarrow> (o \<Rightarrow> o) \<Rightarrow> (o \<Rightarrow> o) \<Rightarrow> o \<Rightarrow> o\<close>
+
+notation Sum (infixl "\<or>" 50)
+
+axiomatization where
+ SumF: "\<lbrakk>A: U i; B: U i\<rbrakk> \<Longrightarrow> A \<or> B: U i" and
+
+ Sum_inl: "\<lbrakk>a: A; B: U i\<rbrakk> \<Longrightarrow> inl A B a: A \<or> B" and
+
+ Sum_inr: "\<lbrakk>b: B; A: U i\<rbrakk> \<Longrightarrow> inr A B b: A \<or> B" and
+
+ SumE: "\<lbrakk>
+ s: A \<or> B;
+ \<And>s. s: A \<or> B \<Longrightarrow> C s: U i;
+ \<And>a. a: A \<Longrightarrow> c a: C (inl A B a);
+ \<And>b. b: B \<Longrightarrow> d b: C (inr A B b)
+ \<rbrakk> \<Longrightarrow> SumInd A B (\<lambda>s. C s) (\<lambda>a. c a) (\<lambda>b. d b) s: C s" and
+
+ Sum_comp_inl: "\<lbrakk>
+ a: A;
+ \<And>s. s: A \<or> B \<Longrightarrow> C s: U i;
+ \<And>a. a: A \<Longrightarrow> c a: C (inl A B a);
+ \<And>b. b: B \<Longrightarrow> d b: C (inr A B b)
+ \<rbrakk> \<Longrightarrow> SumInd A B (\<lambda>s. C s) (\<lambda>a. c a) (\<lambda>b. d b) (inl A B a) \<equiv> c a" and
+
+ Sum_comp_inr: "\<lbrakk>
+ b: B;
+ \<And>s. s: A \<or> B \<Longrightarrow> C s: U i;
+ \<And>a. a: A \<Longrightarrow> c a: C (inl A B a);
+ \<And>b. b: B \<Longrightarrow> d b: C (inr A B b)
+ \<rbrakk> \<Longrightarrow> SumInd A B (\<lambda>s. C s) (\<lambda>a. c a) (\<lambda>b. d b) (inr A B b) \<equiv> d b"
+
+lemmas
+ [intros] = SumF Sum_inl Sum_inr and
+ [elims] = SumE and
+ [comps] = Sum_comp_inl Sum_comp_inr
+
+
+section \<open>Empty and unit types\<close>
+
+axiomatization
+ Top :: \<open>o\<close> and
+ tt :: \<open>o\<close> and
+ TopInd :: \<open>(o \<Rightarrow> o) \<Rightarrow> o \<Rightarrow> o \<Rightarrow> o\<close>
+and
+ Bot :: \<open>o\<close> and
+ BotInd :: \<open>(o \<Rightarrow> o) \<Rightarrow> o \<Rightarrow> o\<close>
+
+notation Top ("\<top>") and Bot ("\<bottom>")
+
+axiomatization where
+ TopF: "\<top>: U i" and
+
+ TopI: "tt: \<top>" and
+
+ TopE: "\<lbrakk>a: \<top>; \<And>x. x: \<top> \<Longrightarrow> C x: U i; c: C tt\<rbrakk> \<Longrightarrow> TopInd (\<lambda>x. C x) c a: C a" and
+
+ Top_comp: "\<lbrakk>\<And>x. x: \<top> \<Longrightarrow> C x: U i; c: C tt\<rbrakk> \<Longrightarrow> TopInd (\<lambda>x. C x) c tt \<equiv> c"
+and
+ BotF: "\<bottom>: U i" and
+
+ BotE: "\<lbrakk>x: \<bottom>; \<And>x. x: \<bottom> \<Longrightarrow> C x: U i\<rbrakk> \<Longrightarrow> BotInd (\<lambda>x. C x) x: C x"
+
+lemmas
+ [intros] = TopF TopI BotF and
+ [elims] = TopE BotE and
+ [comps] = Top_comp
+
+
+section \<open>Booleans\<close>
+
+definition "Bool \<equiv> \<top> \<or> \<top>"
+definition "true \<equiv> inl \<top> \<top> tt"
+definition "false \<equiv> inr \<top> \<top> tt"
+
+\<comment> \<open>Can define if-then-else etc.\<close>
+
+
+end
diff --git a/hott/Nat.thy b/hott/Nat.thy
new file mode 100644
index 0000000..f846dbf
--- /dev/null
+++ b/hott/Nat.thy
@@ -0,0 +1,51 @@
+theory Nat
+imports Spartan
+
+begin
+
+axiomatization
+ Nat :: \<open>o\<close> and
+ zero :: \<open>o\<close> ("0") and
+ suc :: \<open>o \<Rightarrow> o\<close> and
+ NatInd :: \<open>(o \<Rightarrow> o) \<Rightarrow> o \<Rightarrow> (o \<Rightarrow> o \<Rightarrow> o) \<Rightarrow> o \<Rightarrow> o\<close>
+where
+ NatF: "Nat: U i" and
+
+ Nat_zero: "0: Nat" and
+
+ Nat_suc: "n: Nat \<Longrightarrow> suc n: Nat" and
+
+ NatE: "\<lbrakk>
+ n: Nat;
+ n\<^sub>0: Nat;
+ \<And>n. n: Nat \<Longrightarrow> C n: U i;
+ \<And>n c. \<lbrakk>n: Nat; c: C n\<rbrakk> \<Longrightarrow> f n c: C (suc n)
+ \<rbrakk> \<Longrightarrow> NatInd (\<lambda>n. C n) n\<^sub>0 (\<lambda>n c. f n c) n: C n" and
+
+ Nat_comp_zero: "\<lbrakk>
+ n\<^sub>0: Nat;
+ \<And>n. n: Nat \<Longrightarrow> C n: U i;
+ \<And>n c. \<lbrakk>n: Nat; c: C n\<rbrakk> \<Longrightarrow> f n c: C (suc n)
+ \<rbrakk> \<Longrightarrow> NatInd (\<lambda>n. C n) n\<^sub>0 (\<lambda>n c. f n c) 0 \<equiv> n\<^sub>0" and
+
+ Nat_comp_suc: "\<lbrakk>
+ n: Nat;
+ n\<^sub>0: Nat;
+ \<And>n. n: Nat \<Longrightarrow> C n: U i;
+ \<And>n c. \<lbrakk>n: Nat; c: C n\<rbrakk> \<Longrightarrow> f n c: C (suc n)
+ \<rbrakk> \<Longrightarrow>
+ NatInd (\<lambda>n. C n) n\<^sub>0 (\<lambda>n c. f n c) (suc n) \<equiv>
+ f n (NatInd (\<lambda>n. C n) n\<^sub>0 (\<lambda>n c. f n c) n)"
+
+lemmas
+ [intros] = NatF Nat_zero Nat_suc and
+ [elims] = NatE and
+ [comps] = Nat_comp_zero Nat_comp_suc
+
+
+section \<open>Basic arithmetic\<close>
+
+\<comment> \<open>TODO\<close>
+
+
+end