# HG changeset patch # User wenzelm # Date 1470156384 -7200 # Node ID f4a308fdf6647a2ef203890264f22b287186eede # Parent 68751fe1c036b8d5b8fd6f148cd5313159b9f309 tuned; diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Basic_Logic.thy --- a/src/HOL/Isar_Examples/Basic_Logic.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Basic_Logic.thy Tue Aug 02 18:46:24 2016 +0200 @@ -7,7 +7,7 @@ section \Basic logical reasoning\ theory Basic_Logic -imports Main + imports Main begin diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Cantor.thy --- a/src/HOL/Isar_Examples/Cantor.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Cantor.thy Tue Aug 02 18:46:24 2016 +0200 @@ -5,7 +5,7 @@ section \Cantor's Theorem\ theory Cantor -imports Main + imports Main begin subsection \Mathematical statement and proof\ diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Drinker.thy --- a/src/HOL/Isar_Examples/Drinker.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Drinker.thy Tue Aug 02 18:46:24 2016 +0200 @@ -5,7 +5,7 @@ section \The Drinker's Principle\ theory Drinker -imports Main + imports Main begin text \ diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Expr_Compiler.thy --- a/src/HOL/Isar_Examples/Expr_Compiler.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Expr_Compiler.thy Tue Aug 02 18:46:24 2016 +0200 @@ -7,7 +7,7 @@ section \Correctness of a simple expression compiler\ theory Expr_Compiler -imports Main + imports Main begin text \ @@ -46,10 +46,10 @@ \ primrec eval :: "('adr, 'val) expr \ ('adr \ 'val) \ 'val" -where - "eval (Variable x) env = env x" -| "eval (Constant c) env = c" -| "eval (Binop f e1 e2) env = f (eval e1 env) (eval e2 env)" + where + "eval (Variable x) env = env x" + | "eval (Constant c) env = c" + | "eval (Binop f e1 e2) env = f (eval e1 env) (eval e2 env)" subsection \Machine\ @@ -69,14 +69,13 @@ \ primrec exec :: "(('adr, 'val) instr) list \ 'val list \ ('adr \ 'val) \ 'val list" -where - "exec [] stack env = stack" -| "exec (instr # instrs) stack env = - (case instr of - Const c \ exec instrs (c # stack) env - | Load x \ exec instrs (env x # stack) env - | Apply f \ exec instrs (f (hd stack) (hd (tl stack)) - # (tl (tl stack))) env)" + where + "exec [] stack env = stack" + | "exec (instr # instrs) stack env = + (case instr of + Const c \ exec instrs (c # stack) env + | Load x \ exec instrs (env x # stack) env + | Apply f \ exec instrs (f (hd stack) (hd (tl stack)) # (tl (tl stack))) env)" definition execute :: "(('adr, 'val) instr) list \ ('adr \ 'val) \ 'val" where "execute instrs env = hd (exec instrs [] env)" @@ -90,10 +89,10 @@ \ primrec compile :: "('adr, 'val) expr \ (('adr, 'val) instr) list" -where - "compile (Variable x) = [Load x]" -| "compile (Constant c) = [Const c]" -| "compile (Binop f e1 e2) = compile e2 @ compile e1 @ [Apply f]" + where + "compile (Variable x) = [Load x]" + | "compile (Constant c) = [Const c]" + | "compile (Binop f e1 e2) = compile e2 @ compile e1 @ [Apply f]" text \ diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Fibonacci.thy --- a/src/HOL/Isar_Examples/Fibonacci.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Fibonacci.thy Tue Aug 02 18:46:24 2016 +0200 @@ -15,7 +15,7 @@ section \Fib and Gcd commute\ theory Fibonacci -imports "../Number_Theory/Primes" + imports "../Number_Theory/Primes" begin text_raw \\<^footnote>\Isar version by Gertrud Bauer. Original tactic script by Larry @@ -28,10 +28,10 @@ subsection \Fibonacci numbers\ fun fib :: "nat \ nat" -where - "fib 0 = 0" -| "fib (Suc 0) = 1" -| "fib (Suc (Suc x)) = fib x + fib (Suc x)" + where + "fib 0 = 0" + | "fib (Suc 0) = 1" + | "fib (Suc (Suc x)) = fib x + fib (Suc x)" lemma [simp]: "fib (Suc n) > 0" by (induct n rule: fib.induct) simp_all diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/First_Order_Logic.thy --- a/src/HOL/Isar_Examples/First_Order_Logic.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/First_Order_Logic.thy Tue Aug 02 18:46:24 2016 +0200 @@ -10,7 +10,7 @@ \ theory First_Order_Logic -imports Pure + imports Pure begin subsection \Abstract syntax\ diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Group.thy --- a/src/HOL/Isar_Examples/Group.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Group.thy Tue Aug 02 18:46:24 2016 +0200 @@ -5,7 +5,7 @@ section \Basic group theory\ theory Group -imports Main + imports Main begin subsection \Groups and calculational reasoning\ diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Group_Context.thy --- a/src/HOL/Isar_Examples/Group_Context.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Group_Context.thy Tue Aug 02 18:46:24 2016 +0200 @@ -5,7 +5,7 @@ section \Some algebraic identities derived from group axioms -- theory context version\ theory Group_Context -imports Main + imports Main begin text \hypothetical group axiomatization\ diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Group_Notepad.thy --- a/src/HOL/Isar_Examples/Group_Notepad.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Group_Notepad.thy Tue Aug 02 18:46:24 2016 +0200 @@ -5,7 +5,7 @@ section \Some algebraic identities derived from group axioms -- proof notepad version\ theory Group_Notepad -imports Main + imports Main begin notepad diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Higher_Order_Logic.thy --- a/src/HOL/Isar_Examples/Higher_Order_Logic.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Higher_Order_Logic.thy Tue Aug 02 18:46:24 2016 +0200 @@ -5,7 +5,7 @@ section \Foundations of HOL\ theory Higher_Order_Logic -imports Pure + imports Pure begin text \ @@ -76,7 +76,8 @@ subsubsection \Derived connectives\ -definition false :: o ("\") where "\ \ \A. A" +definition false :: o ("\") + where "\ \ \A. A" theorem falseE [elim]: assumes "\" @@ -87,7 +88,8 @@ qed -definition true :: o ("\") where "\ \ \ \ \" +definition true :: o ("\") + where "\ \ \ \ \" theorem trueI [intro]: \ unfolding true_def .. diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Hoare.thy --- a/src/HOL/Isar_Examples/Hoare.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Hoare.thy Tue Aug 02 18:46:24 2016 +0200 @@ -7,7 +7,7 @@ section \Hoare Logic\ theory Hoare -imports Main + imports Main begin subsection \Abstract syntax and semantics\ @@ -34,28 +34,24 @@ type_synonym 'a sem = "'a \ 'a \ bool" primrec iter :: "nat \ 'a bexp \ 'a sem \ 'a sem" -where - "iter 0 b S s s' \ s \ b \ s = s'" -| "iter (Suc n) b S s s' \ s \ b \ (\s''. S s s'' \ iter n b S s'' s')" + where + "iter 0 b S s s' \ s \ b \ s = s'" + | "iter (Suc n) b S s s' \ s \ b \ (\s''. S s s'' \ iter n b S s'' s')" primrec Sem :: "'a com \ 'a sem" -where - "Sem (Basic f) s s' \ s' = f s" -| "Sem (c1; c2) s s' \ (\s''. Sem c1 s s'' \ Sem c2 s'' s')" -| "Sem (Cond b c1 c2) s s' \ - (if s \ b then Sem c1 s s' else Sem c2 s s')" -| "Sem (While b x c) s s' \ (\n. iter n b (Sem c) s s')" + where + "Sem (Basic f) s s' \ s' = f s" + | "Sem (c1; c2) s s' \ (\s''. Sem c1 s s'' \ Sem c2 s'' s')" + | "Sem (Cond b c1 c2) s s' \ (if s \ b then Sem c1 s s' else Sem c2 s s')" + | "Sem (While b x c) s s' \ (\n. iter n b (Sem c) s s')" -definition Valid :: "'a bexp \ 'a com \ 'a bexp \ bool" - ("(3\ _/ (2_)/ _)" [100, 55, 100] 50) +definition Valid :: "'a bexp \ 'a com \ 'a bexp \ bool" ("(3\ _/ (2_)/ _)" [100, 55, 100] 50) where "\ P c Q \ (\s s'. Sem c s s' \ s \ P \ s' \ Q)" -lemma ValidI [intro?]: - "(\s s'. Sem c s s' \ s \ P \ s' \ Q) \ \ P c Q" +lemma ValidI [intro?]: "(\s s'. Sem c s s' \ s \ P \ s' \ Q) \ \ P c Q" by (simp add: Valid_def) -lemma ValidD [dest?]: - "\ P c Q \ Sem c s s' \ s \ P \ s' \ Q" +lemma ValidD [dest?]: "\ P c Q \ Sem c s s' \ s \ P \ s' \ Q" by (simp add: Valid_def) diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Hoare_Ex.thy --- a/src/HOL/Isar_Examples/Hoare_Ex.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Hoare_Ex.thy Tue Aug 02 18:46:24 2016 +0200 @@ -1,7 +1,7 @@ section \Using Hoare Logic\ theory Hoare_Ex -imports Hoare + imports Hoare begin subsection \State spaces\ @@ -276,11 +276,11 @@ type_synonym 'a time = "\time :: nat, \ :: 'a\" primrec timeit :: "'a time com \ 'a time com" -where - "timeit (Basic f) = (Basic f; Basic(\s. s\time := Suc (time s)\))" -| "timeit (c1; c2) = (timeit c1; timeit c2)" -| "timeit (Cond b c1 c2) = Cond b (timeit c1) (timeit c2)" -| "timeit (While b iv c) = While b iv (timeit c)" + where + "timeit (Basic f) = (Basic f; Basic(\s. s\time := Suc (time s)\))" + | "timeit (c1; c2) = (timeit c1; timeit c2)" + | "timeit (Cond b c1 c2) = Cond b (timeit c1) (timeit c2)" + | "timeit (While b iv c) = While b iv (timeit c)" record tvars = tstate + I :: nat diff -r 68751fe1c036 -r f4a308fdf664 src/HOL/Isar_Examples/Peirce.thy --- a/src/HOL/Isar_Examples/Peirce.thy Tue Aug 02 18:45:34 2016 +0200 +++ b/src/HOL/Isar_Examples/Peirce.thy Tue Aug 02 18:46:24 2016 +0200 @@ -5,7 +5,7 @@ section \Peirce's Law\ theory Peirce -imports Main + imports Main begin text \