# HG changeset patch # User fahadausaf # Date 1412599408 -3600 # Node ID a5427713eef44c85b503f1f81a805c1be5ede522 # Parent a92c10af61bda2708a9efb6a817add10d3bd947a multiply 2 diff -r a92c10af61bd -r a5427713eef4 thys/#MyFirst.thy# --- a/thys/#MyFirst.thy# Mon Oct 06 12:00:46 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -theory MyFirst -imports Main -begin - -datatype 'a list = Nil | Cons 'a "'a list" - -fun app :: "'a list \ 'a list \ 'a list" where -"app Nil ys = ys" | -"app (Cons x xs) ys = Cons x (app xs ys)" - -fun rev :: "'a list \ 'a list" where -"rev Nil = Nil" | -"rev (Cons x xs) = app (rev xs) (Cons x Nil)" - -value "rev(Cons True (Cons False Nil))" - -value "1 + (2::nat)" -value "1 + (2::int)" -value "1 - (2::nat)" -value "1 - (2::int)" - -lemma app_Nil2 [simp]: "app xs Nil = xs" -apply(induction xs) -apply(auto) -done - -lemma app_assoc [simp]: "app (app xs ys) zs = app xs (app ys zs)" -apply(induction xs) -apply(auto) -done - -lemma rev_app [simp]: "rev(app xs ys) = app (rev ys) (rev xs)" -apply (induction xs) -apply (auto) -done - -theorem rev_rev [simp]: "rev(rev xs) = xs" -apply (induction xs) -apply (auto) -done - -fun add :: "nat \ nat \ nat" where -"add 0 n = n" | -"add (Suc m) n = Suc(add m n)" - -lemma add_02: "add m 0 = m" -apply(induction m) -apply(auto) -done - -value "add 2 3" - -(**commutative-associative**) -lemma add_04: "add m (add n k) = add k (add m n)" -apply(induct) -apply(auto) -oops - -fun dub :: "nat \ nat" where -"dub 0 = 0" | -"dub m = add m m" - -lemma dub_01: "dub 0 = 0" -apply(induct) -apply(auto) -done - -lemma dub_02: "dub m = add m m" -apply(induction m) -apply(auto) -done - -value "dub 2" - -fun trip :: "nat \ nat" where -"trip 0 = 0" | -"trip m = add m (add m m)" - -lemma trip_01: "trip 0 = 0" -apply(induct) -apply(auto) -done - -lemma trip_02: "trip m = add m (add m m)" -apply(induction m) -apply(auto) -done - -value "trip 1" -value "trip 2" - -fun mull :: "nat \ nat \ nat" where -"mull 0 0 = 0" | -"mull m 0 = 0" | -(**"mull m 1 = m" | **) -"mull m n = m*n" - -(**Define a function that counts the -number of occurrences of an element in a list **) -(** -fun count :: "'a\'a list\nat" where -"count " -**) - - - - - - - - - - diff -r a92c10af61bd -r a5427713eef4 thys/MyFirst.thy --- a/thys/MyFirst.thy Mon Oct 06 12:00:46 2014 +0100 +++ b/thys/MyFirst.thy Mon Oct 06 13:43:28 2014 +0100 @@ -93,8 +93,12 @@ "mull 0 0 = 0" | "mull m 0 = 0" | (**"mull m 1 = m" | **) -"mull m n = m*n" +(**"mull m (1::nat) = m" | **) +(**"mull m (suc(0)) = m" | **) +"mull m n = mull m (n-(1::nat))" +(**Define a function that counts the +number of occurrences of an element in a list **) (** fun count :: "'a\'a list\nat" where "count "