theory Circus_Syntax imports Denotational_Semantics
keywords "alphabet""state""channel""nameset""chanset""schema""action"and "circus_process" :: thy_defn begin
abbreviation list_select::"['r → 'a list] → ('r → 'a)" where "list_select Sel ≡ hd o Sel"
abbreviation list_update::"[('a list → 'a list) → 'r → 'r] → ('a → 'a) → 'r → 'r" where "list_update Upd ≡ λ e. Upd (λ l. (e (hd l))#(tl l))"
abbreviation list_update_const::"[('a list → 'a list) → 'r → 'r] → 'a → 'r relation" where "list_update_const Upd ≡ λ e. λ (A, A'). A' = Upd (λ l. e#(tl l)) A"
abbreviation update_const::"[('a → 'a) → 'r → 'r] → 'a → 'r relation" where "update_const Upd ≡ λ e. λ (A, A'). A' = Upd (λ _. e) A"
parse_translation‹
let
fun antiquote_tr ctxt =
let
val {State_vars=sv, Alpha_vars=av} = VARs_Data.get ctxt
fun get_selector x =
let val c = Consts.intern (Proof_Context.consts_of ctxt) x
in
if member (=) av x then SOME (Const ("Circus_Syntax.list_select", dummyT) $ (Syntax.const c)) else
if member (=) sv x then SOME (Syntax.const c) else NONE end;
fun get_update x =
let val c = Consts.intern (Proof_Context.consts_of ctxt) x
in
if member (=) av x then SOME (Const ("Circus_Syntax.list_update_const", dummyT) $ (Syntax.const (c^Record.updateN))) else
if member (=) sv x then SOME (Const ("Circus_Syntax.update_const", dummyT) $ (Syntax.const (c^Record.updateN))) else NONE end;
fun print text = (fn x => let val _ = writeln text; in x end);
fun tr i (t as Free (x, _)) =
(case get_selector x of
SOME c => c $ Bound (i + 1)
| NONE =>
(case try (unsuffix "'") x of
SOME y =>
(case get_selector y of SOME c => c $ Bound i | NONE => t)
| NONE => t))
| tr i (t as (Const ("_synt_assign", _) $ Free (x, _) $ r)) =
(case get_update x of
SOME c => c $ (tr i r) $ (Const ("Product_Type.Pair", dummyT) $ Bound (i + 1) $ Bound i)
| NONE => t)
((Syntax.const @{const_name case_prod} $
Abs ("B", dummyT, Abs ("B'", dummyT, Const (c, rel_op_type)))) $ tr i l $ tr i r)
$ (Const ("Product_Type.Pair", dummyT) $ Bound (i + 1) $ Bound i)*)
| tr i (t $ u) = tr i t $ tr i u
| tr i (Abs (x, T, t)) = Abs (x, T, tr (i + 1) t)
| tr _ a = a; in tr 0end;
fun quote_tr ctxt [t] = Syntax.const @{const_name case_prod} $
Abs ("A", dummyT, Abs ("A'", dummyT, antiquote_tr ctxt (Term.incr_boundvars 2 t)))
| quote_tr _ ts = raise TERM ("quote_tr", ts); in [(@{syntax_const "_circus_schema"}, quote_tr)] end ›
ML ‹ funget_fields(SOME({fields,parent,...}:Record.info))thy= (caseparentof SOME(_,y)=>fields@get_fields(Record.get_infothyy)thy |NONE=>fields) |get_fieldsNONE_=[]
valeqs=map_product(fn(_,(c,n))=>(fn(_,(c1,n1))=> let valt=Term.list_comb(c,replicatendummy); valt1=Term.list_comb(c1,replicaten1dummy); in(ifc=c1thenmk_eq((ev_equ$t$t1),@{termTrue})elsemk_eq((ev_equ$t$t1),@{termFalse}))end))constrsconstrs;
valthy2= thy1 |>Class.instantiation([dt_name],params,@{sortev_eq}) |>Local_Theory.begin_nested |>snd |>Function_Fun.add_fun[(Binding.namefun_name,NONE,NoSyn)] (map(fnt=>((Binding.empty_atts,t),[],[]))eqs)Function_Fun.fun_config |>Local_Theory.end_nested |>Class.prove_instantiation_exit(fnctxt=>proofctxt); in ((dt_name,constrs),thy2) end |(SOMEtypn)=> let valdt_binding=Binding.suffix_name"_channels"binding;
funprep_fieldprep_typ(b:binding,raw_T)ctxt= let valT=prep_typctxtraw_T; valctxt'=Variable.declare_typTctxt; in((b,T),ctxt')end;
funprep_constrprep_typ(b:binding,raw_T)ctxt= let valT=Option.map(prep_typctxt)raw_T; valctxt'=foldVariable.declare_typ(the_listT)ctxt; in((b,T),ctxt')end;
fungen_circus_processprep_constraintprep_typ (raw_params,binding)raw_alphabetraw_state(typesyn,raw_channels)namesetschansets exprsactthy= let valctxt=Proof_Context.init_globalthy;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.