From 97f3c05e0511a1ed9a95babc800a8e3f3b6a2ea8 Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Fri, 3 Apr 2020 01:13:29 +0200 Subject: 1. Base theory. 2. Fix Nat axioms, addition. --- hott/Base.thy | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hott/Basic_Types.thy | 90 ----------------------------------------------- hott/Nat.thy | 19 +++++----- 3 files changed, 109 insertions(+), 99 deletions(-) create mode 100644 hott/Base.thy delete mode 100644 hott/Basic_Types.thy diff --git a/hott/Base.thy b/hott/Base.thy new file mode 100644 index 0000000..2a4ff9c --- /dev/null +++ b/hott/Base.thy @@ -0,0 +1,99 @@ +theory Base +imports Spartan.Equivalence + +begin + + +section \Notation\ + +syntax "_dollar" :: \logic \ logic \ logic\ (infixr "$" 3) +translations "a $ b" \ "a (b)" + +abbreviation (input) K where "K x \ \_. x" + + +section \Sum type\ + +axiomatization + Sum :: \o \ o \ o\ and + inl :: \o \ o \ o \ o\ and + inr :: \o \ o \ o \ o\ and + SumInd :: \o \ o \ (o \ o) \ (o \ o) \ (o \ o) \ o \ o\ + +notation Sum (infixl "\" 50) + +axiomatization where + SumF: "\A: U i; B: U i\ \ A \ B: U i" and + + Sum_inl: "\a: A; B: U i\ \ inl A B a: A \ B" and + + Sum_inr: "\b: B; A: U i\ \ inr A B b: A \ B" and + + SumE: "\ + s: A \ B; + \s. s: A \ B \ C s: U i; + \a. a: A \ c a: C (inl A B a); + \b. b: B \ d b: C (inr A B b) + \ \ SumInd A B (\s. C s) (\a. c a) (\b. d b) s: C s" and + + Sum_comp_inl: "\ + a: A; + \s. s: A \ B \ C s: U i; + \a. a: A \ c a: C (inl A B a); + \b. b: B \ d b: C (inr A B b) + \ \ SumInd A B (\s. C s) (\a. c a) (\b. d b) (inl A B a) \ c a" and + + Sum_comp_inr: "\ + b: B; + \s. s: A \ B \ C s: U i; + \a. a: A \ c a: C (inl A B a); + \b. b: B \ d b: C (inr A B b) + \ \ SumInd A B (\s. C s) (\a. c a) (\b. d b) (inr A B b) \ d b" + +lemmas + [intros] = SumF Sum_inl Sum_inr and + [elims] = SumE and + [comps] = Sum_comp_inl Sum_comp_inr + + +section \Empty and unit types\ + +axiomatization + Top :: \o\ and + tt :: \o\ and + TopInd :: \(o \ o) \ o \ o \ o\ +and + Bot :: \o\ and + BotInd :: \(o \ o) \ o \ o\ + +notation Top ("\") and Bot ("\") + +axiomatization where + TopF: "\: U i" and + + TopI: "tt: \" and + + TopE: "\a: \; \x. x: \ \ C x: U i; c: C tt\ \ TopInd (\x. C x) c a: C a" and + + Top_comp: "\\x. x: \ \ C x: U i; c: C tt\ \ TopInd (\x. C x) c tt \ c" +and + BotF: "\: U i" and + + BotE: "\x: \; \x. x: \ \ C x: U i\ \ BotInd (\x. C x) x: C x" + +lemmas + [intros] = TopF TopI BotF and + [elims] = TopE BotE and + [comps] = Top_comp + + +section \Booleans\ + +definition "Bool \ \ \ \" +definition "true \ inl \ \ tt" +definition "false \ inr \ \ tt" + +\ \Can define if-then-else etc.\ + + +end diff --git a/hott/Basic_Types.thy b/hott/Basic_Types.thy deleted file mode 100644 index 85f22a8..0000000 --- a/hott/Basic_Types.thy +++ /dev/null @@ -1,90 +0,0 @@ -theory Basic_Types -imports Spartan - -begin - -section \Sum type\ - -axiomatization - Sum :: \o \ o \ o\ and - inl :: \o \ o \ o \ o\ and - inr :: \o \ o \ o \ o\ and - SumInd :: \o \ o \ (o \ o) \ (o \ o) \ (o \ o) \ o \ o\ - -notation Sum (infixl "\" 50) - -axiomatization where - SumF: "\A: U i; B: U i\ \ A \ B: U i" and - - Sum_inl: "\a: A; B: U i\ \ inl A B a: A \ B" and - - Sum_inr: "\b: B; A: U i\ \ inr A B b: A \ B" and - - SumE: "\ - s: A \ B; - \s. s: A \ B \ C s: U i; - \a. a: A \ c a: C (inl A B a); - \b. b: B \ d b: C (inr A B b) - \ \ SumInd A B (\s. C s) (\a. c a) (\b. d b) s: C s" and - - Sum_comp_inl: "\ - a: A; - \s. s: A \ B \ C s: U i; - \a. a: A \ c a: C (inl A B a); - \b. b: B \ d b: C (inr A B b) - \ \ SumInd A B (\s. C s) (\a. c a) (\b. d b) (inl A B a) \ c a" and - - Sum_comp_inr: "\ - b: B; - \s. s: A \ B \ C s: U i; - \a. a: A \ c a: C (inl A B a); - \b. b: B \ d b: C (inr A B b) - \ \ SumInd A B (\s. C s) (\a. c a) (\b. d b) (inr A B b) \ d b" - -lemmas - [intros] = SumF Sum_inl Sum_inr and - [elims] = SumE and - [comps] = Sum_comp_inl Sum_comp_inr - - -section \Empty and unit types\ - -axiomatization - Top :: \o\ and - tt :: \o\ and - TopInd :: \(o \ o) \ o \ o \ o\ -and - Bot :: \o\ and - BotInd :: \(o \ o) \ o \ o\ - -notation Top ("\") and Bot ("\") - -axiomatization where - TopF: "\: U i" and - - TopI: "tt: \" and - - TopE: "\a: \; \x. x: \ \ C x: U i; c: C tt\ \ TopInd (\x. C x) c a: C a" and - - Top_comp: "\\x. x: \ \ C x: U i; c: C tt\ \ TopInd (\x. C x) c tt \ c" -and - BotF: "\: U i" and - - BotE: "\x: \; \x. x: \ \ C x: U i\ \ BotInd (\x. C x) x: C x" - -lemmas - [intros] = TopF TopI BotF and - [elims] = TopE BotE and - [comps] = Top_comp - - -section \Booleans\ - -definition "Bool \ \ \ \" -definition "true \ inl \ \ tt" -definition "false \ inr \ \ tt" - -\ \Can define if-then-else etc.\ - - -end diff --git a/hott/Nat.thy b/hott/Nat.thy index f846dbf..269d6bb 100644 --- a/hott/Nat.thy +++ b/hott/Nat.thy @@ -1,5 +1,5 @@ theory Nat -imports Spartan +imports Base begin @@ -17,22 +17,22 @@ where NatE: "\ n: Nat; - n\<^sub>0: Nat; + n\<^sub>0: C 0; \n. n: Nat \ C n: U i; \n c. \n: Nat; c: C n\ \ f n c: C (suc n) \ \ NatInd (\n. C n) n\<^sub>0 (\n c. f n c) n: C n" and Nat_comp_zero: "\ - n\<^sub>0: Nat; - \n. n: Nat \ C n: U i; - \n c. \n: Nat; c: C n\ \ f n c: C (suc n) + n\<^sub>0: C 0; + \n c. \n: Nat; c: C n\ \ f n c: C (suc n); + \n. n: Nat \ C n: U i \ \ NatInd (\n. C n) n\<^sub>0 (\n c. f n c) 0 \ n\<^sub>0" and Nat_comp_suc: "\ n: Nat; - n\<^sub>0: Nat; - \n. n: Nat \ C n: U i; - \n c. \n: Nat; c: C n\ \ f n c: C (suc n) + n\<^sub>0: C 0; + \n c. \n: Nat; c: C n\ \ f n c: C (suc n); + \n. n: Nat \ C n: U i \ \ NatInd (\n. C n) n\<^sub>0 (\n c. f n c) (suc n) \ f n (NatInd (\n. C n) n\<^sub>0 (\n c. f n c) n)" @@ -45,7 +45,8 @@ lemmas section \Basic arithmetic\ -\ \TODO\ +definition add (infixl "+" 50) where + [comps]: "m + n \ NatInd (K Nat) n (K $ \n. suc n) m" end -- cgit v1.2.3