From f12983b1b53c71fc416155ac4b7e2b11ed8ca9ef Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Wed, 27 May 2020 22:16:42 +0200 Subject: change variable name in elim rules and fix small mistake --- hott/Nat.thy | 14 +++++++------- spartan/data/List.thy | 35 +++++++++++++---------------------- spartan/data/Maybe.thy | 4 ++++ spartan/data/More_Types.thy | 3 ++- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/hott/Nat.thy b/hott/Nat.thy index c36154e..e8657a4 100644 --- a/hott/Nat.thy +++ b/hott/Nat.thy @@ -18,24 +18,24 @@ where NatE: "\ n: Nat; c\<^sub>0: C 0; - \k c. \k: Nat; c: C k\ \ f k c: C (suc k); + \k rec. \k: Nat; rec: C k\ \ f k rec: C (suc k); \n. n: Nat \ C n: U i - \ \ NatInd (\n. C n) c\<^sub>0 (\k c. f k c) n: C n" and + \ \ NatInd (\n. C n) c\<^sub>0 (\k rec. f k rec) n: C n" and Nat_comp_zero: "\ c\<^sub>0: C 0; - \k c. \k: Nat; c: C k\ \ f k c: C (suc k); + \k rec. \k: Nat; rec: C k\ \ f k rec: C (suc k); \n. n: Nat \ C n: U i - \ \ NatInd (\n. C n) c\<^sub>0 (\k c. f k c) 0 \ c\<^sub>0" and + \ \ NatInd (\n. C n) c\<^sub>0 (\k rec. f k rec) 0 \ c\<^sub>0" and Nat_comp_suc: "\ n: Nat; c\<^sub>0: C 0; - \k c. \k: Nat; c: C k\ \ f k c: C (suc k); + \k rec. \k: Nat; rec: C k\ \ f k rec: C (suc k); \n. n: Nat \ C n: U i \ \ - NatInd (\n. C n) c\<^sub>0 (\k c. f k c) (suc n) \ - f n (NatInd (\n. C n) c\<^sub>0 (\k c. f k c) n)" + NatInd (\n. C n) c\<^sub>0 (\k rec. f k rec) (suc n) \ + f n (NatInd (\n. C n) c\<^sub>0 (\k rec. f k rec) n)" lemmas [intros] = NatF Nat_zero Nat_suc and diff --git a/spartan/data/List.thy b/spartan/data/List.thy index 3399da6..52f042b 100644 --- a/spartan/data/List.thy +++ b/spartan/data/List.thy @@ -1,3 +1,5 @@ +chapter \Lists\ + theory List imports Maybe @@ -22,24 +24,24 @@ where ListE: "\ xs: List A; c\<^sub>0: C (nil A); - \x xs c. \x: A; xs: List A; c: C xs\ \ f x xs c: C (cons A x xs); + \x xs rec. \x: A; xs: List A; rec: C xs\ \ f x xs rec: C (cons A x xs); \xs. xs: List A \ C xs: U i - \ \ ListInd A (\xs. C xs) c\<^sub>0 (\x xs c. f x xs c) xs: C xs" and + \ \ ListInd A (\xs. C xs) c\<^sub>0 (\x xs rec. f x xs rec) xs: C xs" and List_comp_nil: "\ c\<^sub>0: C (nil A); - \x xs c. \x: A; xs: List A; c: C xs\ \ f x xs c: C (cons A x xs); + \x xs rec. \x: A; xs: List A; rec: C xs\ \ f x xs rec: C (cons A x xs); \xs. xs: List A \ C xs: U i - \ \ ListInd A (\xs. C xs) c\<^sub>0 (\x xs c. f x xs c) (nil A) \ c\<^sub>0" and + \ \ ListInd A (\xs. C xs) c\<^sub>0 (\x xs rec. f x xs rec) (nil A) \ c\<^sub>0" and List_comp_cons: "\ xs: List A; c\<^sub>0: C (nil A); - \x xs c. \x: A; xs: List A; c: C xs\ \ f x xs c: C (cons A x xs); + \x xs rec. \x: A; xs: List A; rec: C xs\ \ f x xs rec: C (cons A x xs); \xs. xs: List A \ C xs: U i \ \ - ListInd A (\xs. C xs) c\<^sub>0 (\x xs c. f x xs c) (cons A x xs) \ - f x xs (ListInd A (\xs. C xs) c\<^sub>0 (\x xs c. f x xs c) xs)" + ListInd A (\xs. C xs) c\<^sub>0 (\x xs rec. f x xs rec) (cons A x xs) \ + f x xs (ListInd A (\xs. C xs) c\<^sub>0 (\x xs rec. f x xs rec) xs)" lemmas [intros] = ListF List_nil List_cons and @@ -70,11 +72,6 @@ translations section \Standard functions\ -\ \ -definition "head A \ \xs: List A. - ListRec A (Maybe A) (Maybe.none A) (\x _ _. Maybe.some A x) xs" -\ - Lemma (derive) head: assumes "A: U i" "xs: List A" shows "Maybe A" @@ -83,11 +80,8 @@ proof (elim xs) show "\x. x: A \ some x: Maybe A" by intro qed -thm head_def \ \head ?A ?xs \ ListRec ?A (Maybe ?A) none (\x xs c. some x) ?xs\ - -\ \ -definition "tail A \ \xs: List A. ListRec A (List A) (nil A) (\x xs _. xs) xs" -\ +thm head_def + \ \head ?A ?xs \ ListRec ?A (Maybe ?A) none (\x xs c. some x) ?xs\ Lemma (derive) tail: assumes "A: U i" "xs: List A" @@ -98,11 +92,7 @@ proof (elim xs) qed thm tail_def - -\ \ -definition "map A B \ \f: A \ B. \xs: List A. - ListRec A (List B) (nil B) (\x _ c. cons B (f `x) c) xs" -\ + \ \tail ?A ?xs \ ListRec ?A (List ?A) [] (\x xs c. xs) ?xs\ Lemma (derive) map: assumes "A: U i" "B: U i" "f: A \ B" "xs: List A" @@ -115,6 +105,7 @@ proof (elim xs) qed thm map_def + \ \map ?A ?B ?f ?xs \ ListRec ?A (List ?B) [] (\x xs. cons ?B (?f x)) ?xs\ definition head_i ("head") where [implicit]: "head xs \ List.head ? xs" diff --git a/spartan/data/Maybe.thy b/spartan/data/Maybe.thy index dc3ad04..98f5283 100644 --- a/spartan/data/Maybe.thy +++ b/spartan/data/Maybe.thy @@ -1,8 +1,12 @@ +chapter \Maybe type\ + theory Maybe imports More_Types begin +text \Defined as a sum.\ + definition "Maybe A \ A \ \" definition "none A \ inr A \ tt" definition "some A a \ inl A \ a" diff --git a/spartan/data/More_Types.thy b/spartan/data/More_Types.thy index f0cee6d..fecf378 100644 --- a/spartan/data/More_Types.thy +++ b/spartan/data/More_Types.thy @@ -1,9 +1,10 @@ +chapter \Some standard types\ + theory More_Types imports Spartan begin - section \Sum type\ axiomatization -- cgit v1.2.3