equal
deleted
inserted
replaced
5 text {* We build on @{theory Complex_Main} instead of @{theory Main} to access |
5 text {* We build on @{theory Complex_Main} instead of @{theory Main} to access |
6 the real numbers. *} |
6 the real numbers. *} |
7 |
7 |
8 subsection "Arithmetic Expressions" |
8 subsection "Arithmetic Expressions" |
9 |
9 |
10 datatype_new val = Iv int | Rv real |
10 datatype val = Iv int | Rv real |
11 |
11 |
12 type_synonym vname = string |
12 type_synonym vname = string |
13 type_synonym state = "vname \<Rightarrow> val" |
13 type_synonym state = "vname \<Rightarrow> val" |
14 |
14 |
15 text_raw{*\snip{aexptDef}{0}{2}{% *} |
15 text_raw{*\snip{aexptDef}{0}{2}{% *} |
16 datatype_new aexp = Ic int | Rc real | V vname | Plus aexp aexp |
16 datatype aexp = Ic int | Rc real | V vname | Plus aexp aexp |
17 text_raw{*}%endsnip*} |
17 text_raw{*}%endsnip*} |
18 |
18 |
19 inductive taval :: "aexp \<Rightarrow> state \<Rightarrow> val \<Rightarrow> bool" where |
19 inductive taval :: "aexp \<Rightarrow> state \<Rightarrow> val \<Rightarrow> bool" where |
20 "taval (Ic i) s (Iv i)" | |
20 "taval (Ic i) s (Iv i)" | |
21 "taval (Rc r) s (Rv r)" | |
21 "taval (Rc r) s (Rv r)" | |
30 "taval (V x) s v" |
30 "taval (V x) s v" |
31 "taval (Plus a1 a2) s v" |
31 "taval (Plus a1 a2) s v" |
32 |
32 |
33 subsection "Boolean Expressions" |
33 subsection "Boolean Expressions" |
34 |
34 |
35 datatype_new bexp = Bc bool | Not bexp | And bexp bexp | Less aexp aexp |
35 datatype bexp = Bc bool | Not bexp | And bexp bexp | Less aexp aexp |
36 |
36 |
37 inductive tbval :: "bexp \<Rightarrow> state \<Rightarrow> bool \<Rightarrow> bool" where |
37 inductive tbval :: "bexp \<Rightarrow> state \<Rightarrow> bool \<Rightarrow> bool" where |
38 "tbval (Bc v) s v" | |
38 "tbval (Bc v) s v" | |
39 "tbval b s bv \<Longrightarrow> tbval (Not b) s (\<not> bv)" | |
39 "tbval b s bv \<Longrightarrow> tbval (Not b) s (\<not> bv)" | |
40 "tbval b1 s bv1 \<Longrightarrow> tbval b2 s bv2 \<Longrightarrow> tbval (And b1 b2) s (bv1 & bv2)" | |
40 "tbval b1 s bv1 \<Longrightarrow> tbval b2 s bv2 \<Longrightarrow> tbval (And b1 b2) s (bv1 & bv2)" | |
42 "taval a1 s (Rv r1) \<Longrightarrow> taval a2 s (Rv r2) \<Longrightarrow> tbval (Less a1 a2) s (r1 < r2)" |
42 "taval a1 s (Rv r1) \<Longrightarrow> taval a2 s (Rv r2) \<Longrightarrow> tbval (Less a1 a2) s (r1 < r2)" |
43 |
43 |
44 subsection "Syntax of Commands" |
44 subsection "Syntax of Commands" |
45 (* a copy of Com.thy - keep in sync! *) |
45 (* a copy of Com.thy - keep in sync! *) |
46 |
46 |
47 datatype_new |
47 datatype |
48 com = SKIP |
48 com = SKIP |
49 | Assign vname aexp ("_ ::= _" [1000, 61] 61) |
49 | Assign vname aexp ("_ ::= _" [1000, 61] 61) |
50 | Seq com com ("_;; _" [60, 61] 60) |
50 | Seq com com ("_;; _" [60, 61] 60) |
51 | If bexp com com ("IF _ THEN _ ELSE _" [0, 0, 61] 61) |
51 | If bexp com com ("IF _ THEN _ ELSE _" [0, 0, 61] 61) |
52 | While bexp com ("WHILE _ DO _" [0, 61] 61) |
52 | While bexp com ("WHILE _ DO _" [0, 61] 61) |
69 |
69 |
70 lemmas small_step_induct = small_step.induct[split_format(complete)] |
70 lemmas small_step_induct = small_step.induct[split_format(complete)] |
71 |
71 |
72 subsection "The Type System" |
72 subsection "The Type System" |
73 |
73 |
74 datatype_new ty = Ity | Rty |
74 datatype ty = Ity | Rty |
75 |
75 |
76 type_synonym tyenv = "vname \<Rightarrow> ty" |
76 type_synonym tyenv = "vname \<Rightarrow> ty" |
77 |
77 |
78 inductive atyping :: "tyenv \<Rightarrow> aexp \<Rightarrow> ty \<Rightarrow> bool" |
78 inductive atyping :: "tyenv \<Rightarrow> aexp \<Rightarrow> ty \<Rightarrow> bool" |
79 ("(1_/ \<turnstile>/ (_ :/ _))" [50,0,50] 50) |
79 ("(1_/ \<turnstile>/ (_ :/ _))" [50,0,50] 50) |