From 417af1adf5453720c55e27de212b830569311f0e Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Thu, 28 May 2020 16:00:42 +0200 Subject: bit more material --- spartan/data/List.thy | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'spartan') diff --git a/spartan/data/List.thy b/spartan/data/List.thy index c581019..a053a53 100644 --- a/spartan/data/List.thy +++ b/spartan/data/List.thy @@ -85,32 +85,26 @@ section \Standard functions\ Lemma (derive) head: assumes "A: U i" "xs: List A" shows "Maybe A" -proof (elim xs) +proof (cases xs) show "none: Maybe A" by intro 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\ - Lemma (derive) tail: assumes "A: U i" "xs: List A" shows "List A" -proof (elim xs) +proof (cases xs) show "[]: List A" by intro show "\xs. xs: List A \ xs: List A" . qed -thm tail_def - \ \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" shows "List B" proof (elim xs) show "[]: List B" by intro - next fix x xs ys - assume "x: A" "xs: List A" "ys: List B" + next fix x ys + assume "x: A" "ys: List B" show "f x # ys: List B" by typechk qed @@ -136,11 +130,21 @@ Lemma head_type [typechk]: shows "head xs: Maybe A" unfolding head_def by typechk +Lemma head_of_cons [comps]: + assumes "A: U i" "x: A" "xs: List A" + shows "head (x # xs) \ some x" + unfolding head_def ListCase_def by reduce + Lemma tail_type [typechk]: assumes "A: U i" "xs: List A" shows "tail xs: List A" unfolding tail_def by typechk +Lemma tail_of_cons [comps]: + assumes "A: U i" "x: A" "xs: List A" + shows "tail (x # xs) \ xs" + unfolding tail_def ListCase_def by reduce + Lemma map_type [typechk]: assumes "A: U i" "B: U i" "f: A \ B" "xs: List A" shows "map f xs: List B" -- cgit v1.2.3