Re: [racket-users] Redex - constraining what is used to fill a hole
On Sunday, December 13, 2015, Sam Caldwell wrote: > > I'm not completely following the design goals here because it seems > > like the desire to reduce only State-Qs could be achieved by writing > > rules that reduced only State-Qs (not arbitrary states). Or are you > > saying that State-Qs are only allowed in the context? If so, then you > > could write E differently? > > I don't think I can constrain the rules to only operate on State-Qs > because the *outermost* State needs to reduce, and it does not need to > be a State-Q. I think this would lead to duplicating all of the > reduction rules; once for the outermost State and once for internal > State-Qs. > Oh I see. You could probably refactor your language grammar to avoid this but if define-judgment-form is a better fit then by all means do that. > > It's not clear to me how I would change the definition of E to achieve > this. > > > you could rewrite it using define-judgment-form > > This seems fairly promising - looking at the docs I don't see any > reason define-judgment-form couldn't do what I want in a > straightforward manner. > > Thanks for the help, > Sam Caldwell > > > On Sun, Dec 13, 2015 at 5:17 PM, Robby Findler < > ro...@eecs.northwestern.edu > > wrote: > >> I'm not completely following the design goals here because it seems >> like the desire to reduce only State-Qs could be achieved by writing >> rules that reduced only State-Qs (not arbitrary states). Or are you >> saying that State-Qs are only allowed in the context? If so, then you >> could write E differently? I think that all of this is expressible >> without using a feature like you want in Redex, but I'm not really >> getting precisely what you want so I'm hesitant to make more concrete >> suggestions. >> >> Regardless, if for some reason it is better to express your rewriting >> relation in the way that has actual premises, then you could rewrite >> it using define-judgment-form. Relations defined with >> define-judgment-form that have the mode (I O) or (O I) can be used >> with 'traces' and 'stepper' (as well as show-derivations). >> >> hth, >> Robby >> >> >> On Sat, Dec 12, 2015 at 8:21 PM, Sam Caldwell > > wrote: >> > Thanks for clarifying, Robby. >> > >> > I'm modeling reduction on nested states. In addition to a collection of >> > straightforward rules, there is a rule that specifies when to reduce a >> > state-inside-a-state. I can specify this using evaluation contexts, but >> in >> > order for the relation to remain deterministic I need to restrict which >> > nested-states are reduced to a particular subclass. >> > >> > I'm hoping this little model demonstrates what I'm trying to do: >> > >> > == >> > >> > #lang racket >> > >> > (require redex) >> > >> > (define-language L >> > (State (number >> > (Event ...) ;; "incoming" events >> > (Event ...) ;; "outgoing" events >> > (State ...))) >> > (Event string) >> > ;; states with no outgoing events >> > (State-Q (number >> > (Event ...) >> > () >> > (State ...))) >> > ;; states with no incoming or outgoing events >> > (State-I (number >> > () >> > () >> > (State ...))) >> > ;; Evaluation Contexts >> > (E hole >> > (number >> > () >> > (Event ...) >> > (State-I ... E State-Q ... >> > >> > (define red >> > (reduction-relation >> >L >> >;; incoming events just increase a counter >> >(--> (number >> > (Event_0 Event_n ...) >> > (Event ...) >> > (State ...)) >> > (,(add1 (term number)) >> > (Event_n ...) >> > (Event ...) >> > (State ...)) >> > handle) >> >;; once a State has processed all of its incoming Events, it can >> receive >> > an >> >;; outgoing Event from nested States. >> >(--> (number >> > () >> > (Event_out ...) >> > (State-Q ... >> > (number_s >> >(Event_si ...) >> >(Event Event_so ...) >> >(State_s ...)) >> > State ...)) >> > (number >> > (Event Event_so ...) >> > (Event_out ...) >> > (State-Q ... >> > (number_s >> >(Event_si ...) >> >() >> >(State_s ...)) >> > State ...)) >> > receive))) >> > >> > #| >> > Want this to result in: >> > '((5 () () ((4 () () ()) (4 () () () >> > |# >> > (apply-reduction-relation* >> > red >> > (term (0 () >> > () >> > ((1 ("hi" "hello" "ciao") >> > ("zip" "zap" "zooey") >> > ()) >> >(2 ("where" "fore") >> > ("art" "thou") >> > ()) >> > >> > == >> > >> > That model allows the top-most State to process incoming Events and >> receive >> > Events
Re: [racket-users] Redex - constraining what is used to fill a hole
> I'm not completely following the design goals here because it seems > like the desire to reduce only State-Qs could be achieved by writing > rules that reduced only State-Qs (not arbitrary states). Or are you > saying that State-Qs are only allowed in the context? If so, then you > could write E differently? I don't think I can constrain the rules to only operate on State-Qs because the *outermost* State needs to reduce, and it does not need to be a State-Q. I think this would lead to duplicating all of the reduction rules; once for the outermost State and once for internal State-Qs. It's not clear to me how I would change the definition of E to achieve this. > you could rewrite it using define-judgment-form This seems fairly promising - looking at the docs I don't see any reason define-judgment-form couldn't do what I want in a straightforward manner. Thanks for the help, Sam Caldwell On Sun, Dec 13, 2015 at 5:17 PM, Robby Findler wrote: > I'm not completely following the design goals here because it seems > like the desire to reduce only State-Qs could be achieved by writing > rules that reduced only State-Qs (not arbitrary states). Or are you > saying that State-Qs are only allowed in the context? If so, then you > could write E differently? I think that all of this is expressible > without using a feature like you want in Redex, but I'm not really > getting precisely what you want so I'm hesitant to make more concrete > suggestions. > > Regardless, if for some reason it is better to express your rewriting > relation in the way that has actual premises, then you could rewrite > it using define-judgment-form. Relations defined with > define-judgment-form that have the mode (I O) or (O I) can be used > with 'traces' and 'stepper' (as well as show-derivations). > > hth, > Robby > > > On Sat, Dec 12, 2015 at 8:21 PM, Sam Caldwell wrote: > > Thanks for clarifying, Robby. > > > > I'm modeling reduction on nested states. In addition to a collection of > > straightforward rules, there is a rule that specifies when to reduce a > > state-inside-a-state. I can specify this using evaluation contexts, but > in > > order for the relation to remain deterministic I need to restrict which > > nested-states are reduced to a particular subclass. > > > > I'm hoping this little model demonstrates what I'm trying to do: > > > > == > > > > #lang racket > > > > (require redex) > > > > (define-language L > > (State (number > > (Event ...) ;; "incoming" events > > (Event ...) ;; "outgoing" events > > (State ...))) > > (Event string) > > ;; states with no outgoing events > > (State-Q (number > > (Event ...) > > () > > (State ...))) > > ;; states with no incoming or outgoing events > > (State-I (number > > () > > () > > (State ...))) > > ;; Evaluation Contexts > > (E hole > > (number > > () > > (Event ...) > > (State-I ... E State-Q ... > > > > (define red > > (reduction-relation > >L > >;; incoming events just increase a counter > >(--> (number > > (Event_0 Event_n ...) > > (Event ...) > > (State ...)) > > (,(add1 (term number)) > > (Event_n ...) > > (Event ...) > > (State ...)) > > handle) > >;; once a State has processed all of its incoming Events, it can > receive > > an > >;; outgoing Event from nested States. > >(--> (number > > () > > (Event_out ...) > > (State-Q ... > > (number_s > >(Event_si ...) > >(Event Event_so ...) > >(State_s ...)) > > State ...)) > > (number > > (Event Event_so ...) > > (Event_out ...) > > (State-Q ... > > (number_s > >(Event_si ...) > >() > >(State_s ...)) > > State ...)) > > receive))) > > > > #| > > Want this to result in: > > '((5 () () ((4 () () ()) (4 () () () > > |# > > (apply-reduction-relation* > > red > > (term (0 () > > () > > ((1 ("hi" "hello" "ciao") > > ("zip" "zap" "zooey") > > ()) > >(2 ("where" "fore") > > ("art" "thou") > > ()) > > > > == > > > > That model allows the top-most State to process incoming Events and > receive > > Events from its direct children. But, I also want child States to reduce > > using > > the same rules. To keep my relation deterministic, I only want to step > child > > States that are also State-Q's. This is how I ended up trying to add a > > shortcut like: > > > > [(--> (in-hole E State-Q) (in-hole E State)) > > (==> State-Q State)] > > > > I was able to get the behavior I want by calling apply-reduction
Re: [racket-users] Redex - constraining what is used to fill a hole
I'm not completely following the design goals here because it seems like the desire to reduce only State-Qs could be achieved by writing rules that reduced only State-Qs (not arbitrary states). Or are you saying that State-Qs are only allowed in the context? If so, then you could write E differently? I think that all of this is expressible without using a feature like you want in Redex, but I'm not really getting precisely what you want so I'm hesitant to make more concrete suggestions. Regardless, if for some reason it is better to express your rewriting relation in the way that has actual premises, then you could rewrite it using define-judgment-form. Relations defined with define-judgment-form that have the mode (I O) or (O I) can be used with 'traces' and 'stepper' (as well as show-derivations). hth, Robby On Sat, Dec 12, 2015 at 8:21 PM, Sam Caldwell wrote: > Thanks for clarifying, Robby. > > I'm modeling reduction on nested states. In addition to a collection of > straightforward rules, there is a rule that specifies when to reduce a > state-inside-a-state. I can specify this using evaluation contexts, but in > order for the relation to remain deterministic I need to restrict which > nested-states are reduced to a particular subclass. > > I'm hoping this little model demonstrates what I'm trying to do: > > == > > #lang racket > > (require redex) > > (define-language L > (State (number > (Event ...) ;; "incoming" events > (Event ...) ;; "outgoing" events > (State ...))) > (Event string) > ;; states with no outgoing events > (State-Q (number > (Event ...) > () > (State ...))) > ;; states with no incoming or outgoing events > (State-I (number > () > () > (State ...))) > ;; Evaluation Contexts > (E hole > (number > () > (Event ...) > (State-I ... E State-Q ... > > (define red > (reduction-relation >L >;; incoming events just increase a counter >(--> (number > (Event_0 Event_n ...) > (Event ...) > (State ...)) > (,(add1 (term number)) > (Event_n ...) > (Event ...) > (State ...)) > handle) >;; once a State has processed all of its incoming Events, it can receive > an >;; outgoing Event from nested States. >(--> (number > () > (Event_out ...) > (State-Q ... > (number_s >(Event_si ...) >(Event Event_so ...) >(State_s ...)) > State ...)) > (number > (Event Event_so ...) > (Event_out ...) > (State-Q ... > (number_s >(Event_si ...) >() >(State_s ...)) > State ...)) > receive))) > > #| > Want this to result in: > '((5 () () ((4 () () ()) (4 () () () > |# > (apply-reduction-relation* > red > (term (0 () > () > ((1 ("hi" "hello" "ciao") > ("zip" "zap" "zooey") > ()) >(2 ("where" "fore") > ("art" "thou") > ()) > > == > > That model allows the top-most State to process incoming Events and receive > Events from its direct children. But, I also want child States to reduce > using > the same rules. To keep my relation deterministic, I only want to step child > States that are also State-Q's. This is how I ended up trying to add a > shortcut like: > > [(--> (in-hole E State-Q) (in-hole E State)) > (==> State-Q State)] > > I was able to get the behavior I want by calling apply-reduction-relation > from > inside a rule: > > (--> (in-hole E State-Q) > (in-hole E State) > (side-condition (not (redex-match? L hole (term E > (where (State) ,(apply-reduction-relation red (term State-Q > > But I can't say I felt great about doing so. (The side-condition is needed > to > prevent infinite looping). Is there a cleaner way to achieve the same > result? > > Thanks, > Sam Caldwell > > > On Sat, Dec 12, 2015 at 11:11 AM, Robby Findler > wrote: >> >> I can see why you might have expected that to work that way. >> Unfortunately, it doesn't. The identifiers in those places in >> shortcuts (Add2, x, and n in your examples below) are not pattern >> positions. They are simply identifiers. >> >> In the code you wrote, one could change the rule's left-hand side to >> (+ V_1 V_2) to achieve the desired effect, but maybe that doesn't work >> in your larger model? Perhaps if you explained a little more why >> something like that is problematic, we could be of more use. >> >> Meanwhile, I've pushed a fix to the bug in the error-checking that you >> found, added some more checking, and tried to emphasize this point >> more clearly in the documentation. The commit cbb2d88b would p
[racket-users] Fwd: Us congress hearing of maan alsaan Money laundry قضية الكونغجرس لغسيل الأموال للمليادير معن الصانع
YouTube videos of U.S. Congress money laundering hearing of Saudi Billionaire " Maan Al sanea" with *bank of America* and The owner of Saad Hospital and Schools in the Eastern Province in *Saudi Arabia* and the Chairman of the Board of Directors of Awal Bank in *Bahrain* With Arabic Subtitles *موقع اليوتيوب الذي عرض جلسة استماع الكونجرس الأمريكي * * لمتابعة نشاطات غسل الأموال ونشاطات* *السعودي معن عبدالواحد الصانع* *مالك مستشفى وشركة سعد ومدارس سعد بالمنطقة الشرقية بالسعودية ورئيس مجلس ادارة بنك اوال البحريني* *مترجم باللغة العربية* http://www.youtube.com/watch?v=mIBNnQvhU8s -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Custodian problems/ IoT service
The previous code was messy all over the place. This one seems to work, although I'm not sure whether it can keep the services securely sandboxed as intented and won't run out of memory at some point. Revised code: - #lang racket ; tested in Linux (define target-mode #f); #f/ "service-1"/ "service-2" (define (service-switcher) (define current-mode #f) (define cust (make-custodian)) (define (system/output command) (define (system/exit-code+output command) (let* ([out (open-output-string)] [control (process/ports out #f #f command)] [p (list-ref control 4)]) (p 'wait) (values (p 'exit-code) (get-output-string out (let-values ([(e out) (system/exit-code+output command)]) out)) (define (switch-mode) (set! cust (make-custodian)) (parameterize ((current-custodian cust) (current-namespace (make-base-namespace))) (current-subprocess-custodian-mode 'kill) (subprocess-group-enabled #t) (cond ((equal? target-mode #f) (begin (custodian-shutdown-all cust) (set! current-mode #f) (newline)(display "Service disabled")(newline))) ((and (equal? target-mode "service-1")) (begin (set! current-mode "service-1") (newline)(display "Service mode changed to Service-1")(newline) (thread (lambda () (system/output "gedit") ((and (equal? target-mode "service-2")) (begin (newline)(display "Service mode changed to Service-2")(newline) (set! current-mode "service-2") (thread (lambda () (system/output "gcalctool" (define (loop) (if (equal? current-mode target-mode) (begin (display ".") (sleep 1) (loop)) (begin (custodian-shutdown-all cust) (switch-mode) (loop (thread (lambda () (loop))) (display "Service switcher started.")(newline)) ;; TESTING (service-switcher) (define awhile 5) (sleep awhile) (set! target-mode "service-1") (sleep awhile) (set! target-mode #f) (sleep awhile) (set! target-mode "service-2") (sleep awhile) (set! target-mode "service-1") (sleep awhile) (set! target-mode #f) (sleep awhile) (newline)(display "Test finished (server still running on the background. Press CTRL+K to stop it)")(newline) -- jukka.tuomi...@finndesign.fi kirjoitti 2015-12-12 11:40: Hi all, I want to make a custodian-protected, remotely-controlled service switcher but there's something wrong with my code. The behaviour isn't reliable and it leaves traces behind filling the memory eventually. I've included the code below. TBH, I may have a less optimal approach to it in the first place, so I'd appreciate any better suggestions. A little background: As part of Liitin (liitin.org) IoT development and dog-fooding, I've decided to make my personal A.I. project running on a remotely-controllable Liitin node as a "Iot Service". Any nodes fired up will be automagically visible on my Liitin desktop. Any A.I. node or the user node can be behind different firewalls without open ports. Neither do they need to know each other's whereabouts. One A.I. node is to work as an interactive service whereas the rest will take part in incubating higher intelligence through genetic programming. I have a simple IoT communication channel in place, but now I want a reliable means to switch the service mode remotely. I don't want any ill-behaved A.I. processes running wild either, so I want to make sure I can shut down the processes remotely when I want to, so the services will need to be sandboxed. Foremost this is an IoT dog-fooding excercise, trying to make any Liitin SW or HW node as easy and secure to use as possible for the basic users, now only taking it to one extreme. Finally to the switcher source code... br, jukka --- -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.