Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/693343d7-a38c-8012-a67c-11cbed4c0fd9
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Below is a minimal SDELang fragment showing Obatala constructs and a compact small-step semantics, then a compiler lowering into an intermediate representation (IR) that uses the Tree monad. === SDELang grammar (subset): <syntaxhighlight>t ::= x | Ξ»x. t | t t | reflect t -- promote: A -> O A | bind x <- t in u -- monadic bind | merge t t -- join two O A | sim t -- produce trajectory | leaf t -- syntactic sugar for reflect t </syntaxhighlight> Typing rules (informal): * Ξ β’ t : A β Ξ β’ reflect t : O A. * Ξ β’ t : O A and Ξ, x:A β’ u : O B β Ξ β’ bind x <- t in u : O B. Small-step semantics (selected, arrow β): # bind x <- reflect v in u β u[x := v] (left unit) # bind x <- (bind y <- m in n) in u β bind y <- m in (bind x <- n in u) (associativity / let-assoc) # merge (reflect v) (reflect w) β reflect (merge_agent v w) (interpret merge at runtime or keep as Node) # sim (reflect v) β base_sim(v) (simulate a leaf) # sim (merge m n) β combine_sim(sim m, sim n) (organizational simulation) Operational strategy: * Evaluate inside-out (call-by-value for reflect). reflect v is a value when v is a value. * bind reduces when the left side is a reflect or already reduced to a tree node; otherwise evaluate left expression. Compiler lowering (SDELang β IR using Tree): * reflect t β Leaf(t') where t' is lowered expression * merge a b β Node(MergeOp, [a', b']) * sim t β Node(SimOp, [t']) or produce a Traj call to a runtime sim function * bind x <- t in u β lower t to a Tree T; then produce IR representing join (map (fun leaf -> lower(u) with x := leaf) T) β equivalently, join . fmap as in Coq. Example compiler fragment (pseudo-code): <syntaxhighlight lang="ocaml">('' Lowering: Expr -> Tree IR '') let rec lower (e : expr) : tree_ir = match e with | Var x -> Leaf (IR_Var x) | Lam (x,b) -> Leaf (IR_Closure (x,lower b)) | App (f,a) -> Leaf (IR_App (lower f, lower a)) | Reflect t -> Leaf (IR_Value (lower t)) ('' leaf wraps the value '') | Merge (a,b) -> Node (MergeOp, [lower a; lower b]) | Sim t -> Node (SimOp, [lower t]) | Bind (x,t,u) -> let t' = lower t in ('' produce join (fmap (\leaf -> lower(u) [x:=leaf]) t') '') join (fmap (fun leaf => lower (subst u x (reify_leaf leaf))) t') </syntaxhighlight> reify_leaf extracts the payload from Leaf to substitute into u. At runtime, the Tree can be interpreted by EM-algebras (handlers). Runtime execution model: * The runtime holds: - Interpreter service that collapses Tree via an EM algebra (organization handler) β this is the implementation of Ξ± : Tree A β A. - Simulator service that given Node SimOp ... produces a Trajectory. - Coordination service that implements MergeOp semantics (e.g., conflict resolution, scheduling, resource allocation).
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)