diff -r c876bcb601fc -r 5b65449d7669 src/HOL/HoareParallel/OG_Syntax.thy --- a/src/HOL/HoareParallel/OG_Syntax.thy Thu Sep 17 14:17:37 2009 +1000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -theory OG_Syntax -imports OG_Tactics Quote_Antiquote -begin - -text{* Syntax for commands and for assertions and boolean expressions in - commands @{text com} and annotated commands @{text ann_com}. *} - -syntax - "_Assign" :: "idt \ 'b \ 'a com" ("(\_ :=/ _)" [70, 65] 61) - "_AnnAssign" :: "'a assn \ idt \ 'b \ 'a com" ("(_ \_ :=/ _)" [90,70,65] 61) - -translations - "\\x := a" \ "Basic \\\(_update_name x (\_. a))\" - "r \\x := a" \ "AnnBasic r \\\(_update_name x (\_. a))\" - -syntax - "_AnnSkip" :: "'a assn \ 'a ann_com" ("_//SKIP" [90] 63) - "_AnnSeq" :: "'a ann_com \ 'a ann_com \ 'a ann_com" ("_;;/ _" [60,61] 60) - - "_AnnCond1" :: "'a assn \ 'a bexp \ 'a ann_com \ 'a ann_com \ 'a ann_com" - ("_ //IF _ /THEN _ /ELSE _ /FI" [90,0,0,0] 61) - "_AnnCond2" :: "'a assn \ 'a bexp \ 'a ann_com \ 'a ann_com" - ("_ //IF _ /THEN _ /FI" [90,0,0] 61) - "_AnnWhile" :: "'a assn \ 'a bexp \ 'a assn \ 'a ann_com \ 'a ann_com" - ("_ //WHILE _ /INV _ //DO _//OD" [90,0,0,0] 61) - "_AnnAwait" :: "'a assn \ 'a bexp \ 'a com \ 'a ann_com" - ("_ //AWAIT _ /THEN /_ /END" [90,0,0] 61) - "_AnnAtom" :: "'a assn \ 'a com \ 'a ann_com" ("_//\_\" [90,0] 61) - "_AnnWait" :: "'a assn \ 'a bexp \ 'a ann_com" ("_//WAIT _ END" [90,0] 61) - - "_Skip" :: "'a com" ("SKIP" 63) - "_Seq" :: "'a com \ 'a com \ 'a com" ("_,,/ _" [55, 56] 55) - "_Cond" :: "'a bexp \ 'a com \ 'a com \ 'a com" - ("(0IF _/ THEN _/ ELSE _/ FI)" [0, 0, 0] 61) - "_Cond2" :: "'a bexp \ 'a com \ 'a com" ("IF _ THEN _ FI" [0,0] 56) - "_While_inv" :: "'a bexp \ 'a assn \ 'a com \ 'a com" - ("(0WHILE _/ INV _ //DO _ /OD)" [0, 0, 0] 61) - "_While" :: "'a bexp \ 'a com \ 'a com" - ("(0WHILE _ //DO _ /OD)" [0, 0] 61) - -translations - "SKIP" \ "Basic id" - "c_1,, c_2" \ "Seq c_1 c_2" - - "IF b THEN c1 ELSE c2 FI" \ "Cond .{b}. c1 c2" - "IF b THEN c FI" \ "IF b THEN c ELSE SKIP FI" - "WHILE b INV i DO c OD" \ "While .{b}. i c" - "WHILE b DO c OD" \ "WHILE b INV CONST undefined DO c OD" - - "r SKIP" \ "AnnBasic r id" - "c_1;; c_2" \ "AnnSeq c_1 c_2" - "r IF b THEN c1 ELSE c2 FI" \ "AnnCond1 r .{b}. c1 c2" - "r IF b THEN c FI" \ "AnnCond2 r .{b}. c" - "r WHILE b INV i DO c OD" \ "AnnWhile r .{b}. i c" - "r AWAIT b THEN c END" \ "AnnAwait r .{b}. c" - "r \c\" \ "r AWAIT True THEN c END" - "r WAIT b END" \ "r AWAIT b THEN SKIP END" - -nonterminals - prgs - -syntax - "_PAR" :: "prgs \ 'a" ("COBEGIN//_//COEND" [57] 56) - "_prg" :: "['a, 'a] \ prgs" ("_//_" [60, 90] 57) - "_prgs" :: "['a, 'a, prgs] \ prgs" ("_//_//\//_" [60,90,57] 57) - - "_prg_scheme" :: "['a, 'a, 'a, 'a, 'a] \ prgs" - ("SCHEME [_ \ _ < _] _// _" [0,0,0,60, 90] 57) - -translations - "_prg c q" \ "[(Some c, q)]" - "_prgs c q ps" \ "(Some c, q) # ps" - "_PAR ps" \ "Parallel ps" - - "_prg_scheme j i k c q" \ "map (\i. (Some c, q)) [j.. (x, if T = dummyT then T else Term.domain_type T) - | NONE => raise Match); - - fun update_name_tr' (Free x) = Free (upd_tr' x) - | update_name_tr' ((c as Const ("_free", _)) $ Free x) = - c $ Free (upd_tr' x) - | update_name_tr' (Const x) = Const (upd_tr' x) - | update_name_tr' _ = raise Match; - - fun K_tr' (Abs (_,_,t)) = if null (loose_bnos t) then t else raise Match - | K_tr' (Abs (_,_,Abs (_,_,t)$Bound 0)) = if null (loose_bnos t) then t else raise Match - | K_tr' _ = raise Match; - - fun assign_tr' (Abs (x, _, f $ k $ Bound 0) :: ts) = - quote_tr' (Syntax.const "_Assign" $ update_name_tr' f) - (Abs (x, dummyT, K_tr' k) :: ts) - | assign_tr' _ = raise Match; - - fun annassign_tr' (r :: Abs (x, _, f $ k $ Bound 0) :: ts) = - quote_tr' (Syntax.const "_AnnAssign" $ r $ update_name_tr' f) - (Abs (x, dummyT, K_tr' k) :: ts) - | annassign_tr' _ = raise Match; - - fun Parallel_PAR [(Const ("Cons",_) $ (Const ("Pair",_) $ (Const ("Some",_) $ t1 ) $ t2) $ Const ("Nil",_))] = - (Syntax.const "_prg" $ t1 $ t2) - | Parallel_PAR [(Const ("Cons",_) $ (Const ("Pair",_) $ (Const ("Some",_) $ t1) $ t2) $ ts)] = - (Syntax.const "_prgs" $ t1 $ t2 $ Parallel_PAR [ts]) - | Parallel_PAR _ = raise Match; - -fun Parallel_tr' ts = Syntax.const "_PAR" $ Parallel_PAR ts; - in - [("Collect", assert_tr'), ("Basic", assign_tr'), - ("Cond", bexp_tr' "_Cond"), ("While", bexp_tr' "_While_inv"), - ("AnnBasic", annassign_tr'), - ("AnnWhile", annbexp_tr' "_AnnWhile"), ("AnnAwait", annbexp_tr' "_AnnAwait"), - ("AnnCond1", annbexp_tr' "_AnnCond1"), ("AnnCond2", annbexp_tr' "_AnnCond2")] - - end - -*} - -end \ No newline at end of file