# HG changeset patch # User kleing # Date 1363085942 -3600 # Node ID 27bb849330eac7dbb156cf46c014fce7d86b9426 # Parent 635562bc14effad86180057262d653f3d5e4ac41 more snippets diff -r 635562bc14ef -r 27bb849330ea src/HOL/IMP/Types.thy --- a/src/HOL/IMP/Types.thy Tue Mar 12 07:51:10 2013 +0100 +++ b/src/HOL/IMP/Types.thy Tue Mar 12 11:59:02 2013 +0100 @@ -11,6 +11,7 @@ datatype aexp = Ic int | Rc real | V vname | Plus aexp aexp +text_raw{*\snip{tavalDef}{0}{2}{% *} inductive taval :: "aexp \ state \ val \ bool" where "taval (Ic i) s (Iv i)" | "taval (Rc r) s (Rv r)" | @@ -19,6 +20,7 @@ \ taval (Plus a1 a2) s (Iv(i1+i2))" | "taval a1 s (Rv r1) \ taval a2 s (Rv r2) \ taval (Plus a1 a2) s (Rv(r1+r2))" +text_raw{*}%endsnip*} inductive_cases [elim!]: "taval (Ic i) s v" "taval (Rc i) s v" @@ -29,12 +31,14 @@ datatype bexp = Bc bool | Not bexp | And bexp bexp | Less aexp aexp +text_raw{*\snip{tbvalDef}{0}{2}{% *} inductive tbval :: "bexp \ state \ bool \ bool" where "tbval (Bc v) s v" | "tbval b s bv \ tbval (Not b) s (\ bv)" | "tbval b1 s bv1 \ tbval b2 s bv2 \ tbval (And b1 b2) s (bv1 & bv2)" | "taval a1 s (Iv i1) \ taval a2 s (Iv i2) \ tbval (Less a1 a2) s (i1 < i2)" | "taval a1 s (Rv r1) \ taval a2 s (Rv r2) \ tbval (Less a1 a2) s (r1 < r2)" +text_raw{*}%endsnip*} subsection "Syntax of Commands" (* a copy of Com.thy - keep in sync! *) @@ -49,6 +53,7 @@ subsection "Small-Step Semantics of Commands" +text_raw{*\snip{tsmallstepDef}{0}{2}{% *} inductive small_step :: "(com \ state) \ (com \ state) \ bool" (infix "\" 55) where @@ -61,6 +66,7 @@ IfFalse: "tbval b s False \ (IF b THEN c1 ELSE c2,s) \ (c2,s)" | While: "(WHILE b DO c,s) \ (IF b THEN c; WHILE b DO c ELSE SKIP,s)" +text_raw{*}%endsnip*} lemmas small_step_induct = small_step.induct[split_format(complete)] @@ -70,6 +76,7 @@ type_synonym tyenv = "vname \ ty" +text_raw{*\snip{atypingDef}{0}{2}{% *} inductive atyping :: "tyenv \ aexp \ ty \ bool" ("(1_/ \/ (_ :/ _))" [50,0,50] 50) where @@ -77,25 +84,30 @@ Rc_ty: "\ \ Rc r : Rty" | V_ty: "\ \ V x : \ x" | Plus_ty: "\ \ a1 : \ \ \ \ a2 : \ \ \ \ Plus a1 a2 : \" +text_raw{*}%endsnip*} text{* Warning: the ``:'' notation leads to syntactic ambiguities, i.e. multiple parse trees, because ``:'' also stands for set membership. In most situations Isabelle's type system will reject all but one parse tree, but will still inform you of the potential ambiguity. *} +text_raw{*\snip{btypingDef}{0}{2}{% *} inductive btyping :: "tyenv \ bexp \ bool" (infix "\" 50) where B_ty: "\ \ Bc v" | Not_ty: "\ \ b \ \ \ Not b" | And_ty: "\ \ b1 \ \ \ b2 \ \ \ And b1 b2" | Less_ty: "\ \ a1 : \ \ \ \ a2 : \ \ \ \ Less a1 a2" +text_raw{*}%endsnip*} +text_raw{*\snip{ctypingDef}{0}{2}{% *} inductive ctyping :: "tyenv \ com \ bool" (infix "\" 50) where Skip_ty: "\ \ SKIP" | Assign_ty: "\ \ a : \(x) \ \ \ x ::= a" | Seq_ty: "\ \ c1 \ \ \ c2 \ \ \ c1;c2" | If_ty: "\ \ b \ \ \ c1 \ \ \ c2 \ \ \ IF b THEN c1 ELSE c2" | While_ty: "\ \ b \ \ \ c \ \ \ WHILE b DO c" +text_raw{*}%endsnip*} inductive_cases [elim!]: "\ \ x ::= a" "\ \ c1;c2"