# HG changeset patch # User fahad # Date 1422287667 0 # Node ID 3810b37511cbdd74b515ba2fe996edefccfd9494 # Parent c603b27083f33b199ac6a9692c3080c281b51e93 test diff -r c603b27083f3 -r 3810b37511cb thys/Chap03.thy --- a/thys/Chap03.thy Mon Jan 26 15:41:16 2015 +0000 +++ b/thys/Chap03.thy Mon Jan 26 15:54:27 2015 +0000 @@ -84,6 +84,10 @@ "add1 m 0 = m" | "add1 m (Suc n) = add1 (Suc m) n" +primrec add2 :: "nat \ nat \ nat" where +"add2 m 0 = m" | +"add2 m (Suc n) = Suc (add2 m n)" + value "add1 1 3" value "1 + 3" @@ -93,11 +97,41 @@ apply(simp) done -lemma abc2 "add1 m n = m+n" +lemma abc2: "\m. add1 m n = m + n" apply(induction n) -apply(auto) +apply(simp) +apply(simp del: add1.simps) +apply(simp (no_asm) only: add1.simps) +apply(simp only: ) +apply(simp) +done + +thm abc2 + +lemma abc3: "add1 m n = m + n" +apply(induction n arbitrary: m) +apply(simp) +apply(simp del: add1.simps) +apply(simp (no_asm) only: add1.simps) +apply(simp only: ) +done -oops +thm abc3 + +lemma abc4: "add1 m n = add2 m n" +apply(induction n arbitrary: m) +apply(simp) +apply(simp add: abc3) +done + +(* added test *) + +lemma abc5: "add2 m n = m + n" +apply(induction n) +apply(simp) +apply(simp) +done + (* 3.3 Case Study: Compiling Expressions *) @@ -159,9 +193,22 @@ "value2 (And b c) env = (value2 b env \ value2 c env)" value "Const true" -value "Suc(Suc(0))" +value "Var (Suc(0))" + + + +value "value2 (Const False) (\x. False)" +value "value2 (Var 11) (\x. if (x = 10 | x = 11) then True else False)" -'b::Const = "true" +definition + "en1 \ (\x. if x = 10 | x = 11 then True else False)" + +abbreviation + "en2 \ (\x. if x = 10 | x = 11 then True else False)" + +value "value2 (And (Var 10) (Var 11)) en2" -value "value2 (Const true) (env = true)" +lemma "value2 (And (Var 10) (Var 11)) en2 = True" +apply(simp) +done