ckanren minikanren with Constraints Claire E. Alvis Jeremiah J. Willcock Kyle M. Carter William E. Byrd Daniel P. Friedman

Size: px
Start display at page:

Download "ckanren minikanren with Constraints Claire E. Alvis Jeremiah J. Willcock Kyle M. Carter William E. Byrd Daniel P. Friedman"

Transcription

1 Kanren minikanren with Constraints Claire E. Alvis Jeremiah J. Willok Kyle M. Carter William E. Byrd Daniel P. Friedman Shool of Informatis and Computing, Indiana University, Bloomington, IN Abstrat We present Kanren, a framework for onstraint logi programming (CLP) in Sheme. Kanren subsumes minikanren, a logi programming language embedded in Sheme. Kanren allows programmers to easily use, define, and ombine different kinds of onstraints. We provide two example onstraint systems: one over finite domains and one over trees. The Kanren framework is designed to enourage an espeially pure style of logi programming in whih goals an be reordered arbitrarily without affeting a program s semantis (with an important deidability-related aveat). We develop the omplete implementation of the Kanren framework, written in R 6 RS Sheme extended with SRFI 39 parameters. We present the implementation of Kanren s finite domain and disequality onstraint solvers, and we provide introdutions to minikanren, Kanren, and numerous example programs, inluding the Send More Money ryptarithmeti puzzle and N-Queens. Categories and Subjet Desriptors D.1.6 [Programming Tehniques]: Logi Programming; D.1.1 [Programming Tehniques]: Appliative (Funtional) Programming General Terms Languages Keywords CLP, CLP(FD), Sheme, minikanren, logi programming, onstraint solving, onstraint logi programming 1. Introdution We present a omplete implementation of Kanren, a framework for onstraint logi programming in Sheme. Traditional logi programming provides only a single onstraint: equality over terms, whih is implemented using unifiation. Constraint logi programming (Apt 2003; Jaffar and Maher 1994), also known as CLP, supports additional onstraints, suh as onstraints over finite domains CLP(FD) and tree terms CLP(Tree). The Kanren framework is an extension of minikanren, whih embeds logi programming in Sheme (Friedman et al. 2005; Byrd and Friedman 2006; Byrd 2009). Unlike previous extensions to minikanren, suh as αkanren (Byrd and Friedman 2007), Kanren does not diretly add user-level operators to minikanren. Rather, Kanren allows programmers to use, reate, and ombine onstraint systems. Kanren is implemented in R 6 RS Sheme (Sperber et al. 2007), and uses the SRFI-39 parameter mehanism (Feeley 2002) supported by multiple Sheme implementations (Flatt and PLT 2010; Dybvig 2010). In addition to desribing the Kanren framework, we present onstraints for finite domains and tree terms. Constraints over finite domains allow minikanren programmers to delaratively reason about finite sets of values, based on a restrited set of relational arithmeti operators. Disequality onstraints over tree terms allow minikanren programmers to express a limited but useful form of negation: that two terms are not equal and an never be made equal. Our paper makes the following ontributions: We desribe the two kinds of onstraints implemented within our Kanren framework: fd, + fd, fd, and alldiff fd onstraints over finite domains (Setion 2.1.1), and disequality onstraints over tree terms (Setion 2.1.2). We provide examples and exerises (Setion 2.1.3) using both kinds of onstraints, inluding the famous Send More Money and N-Queens problems, along with rember o, a program that demonstrates the need for disequality onstraints. We present our solutions in Setion 4. We present omplete implementations of the Kanren onstraint framework (Setion 3.1), and onstraints over finite domains (Setion 3.3) and tree terms (Setion 3.5). 1 We demonstrate how to reate new kinds of onstraints by omposing existing Kanren onstraint systems (Setion 5). We desribe the minikanren philosophy that informed the development of Kanren, and disuss several important design and implementation goals (Setion 6). We present Kanren s helper definitions and an updated implementation of ore minikanren in the appendies. These appendies along with the ode in the body of the paper omprise a working implementation. We begin with an overview of the ore minikanren language. 1 The Kanren implementation an be downloaded from github.om/alvis/kanren. 1

2 2. The Language We present three languages: minikanren, minikanren extended with onstraints over finite domains, and minikanren extended with tree disequality. Kanren provides a framework for writing onstraints and for using those kinds of onstraints within minikanren programs. We then show the finite domain and disequality goals in ation, through examples suh as Send More Money, N-Queens, and rember o. 2.1 minikanren In this setion we briefly review the minikanren language; readers already familiar with minikanren an safely skip to Setion 2.1.1, while those wishing to learn more about the language should see Byrd and Friedman (2007) (from whih the first part of this setion has been adapted) and Friedman et al. (2005). Our ode uses the following typographi onventions. Lexial variables are in itali, forms are in boldfae, and quoted symbols are in sans serif. By our onvention, names of relations end with a supersript o for example any o, whih is entered as anyo. Relational operators do not follow this onvention: (entered as ==), ond e (entered as onde), and fresh (formerly exist). Similarly, (run 5 (q) body) and body) are entered as (run 5 (q) body) and (run* (q) body), respetively. minikanren extends Sheme with three operators:, ond e, and fresh. There is also run, whih serves as an interfae between Sheme and minikanren, and whose value is a list. fresh, whih syntatially looks like lambda, introdues into sope new lexial variables bound to new (logi) variables; unifies two terms. Thus (fresh (x y z) ( x z) ( 3 y)) would assoiate x with z and y with 3. This, however, is not a legal minikanren program we must wrap a run around the entire expression. (run 1 (q) (fresh (x y z) ( x z) ( 3 y))) ( 0 ) The value returned is a list ontaining the single value 0 ; we say that 0 is the reified value of the unbound variable q and thus an be any value. q also remains unbound in (run 1 (q) (fresh (x y) ( x q) ( 3 y))) ( 0 ) We an get bak other values, of ourse. (run 1 (y) (fresh (x z) ( x z) ( 3 y))) (run 1 (q) (fresh (x z) ( x z) ( 3 z) ( q x))) (run 1 (y) (fresh (x y) ( 4 x) ( x y)) ( 3 y)) Eah of these examples returns (3); in the rightmost example, the y introdued by fresh is different from the y introdued by run. A run expression an also evaluate to the empty list. This indiates that there does not exist any value of the variable bound by the run expression that an ause its body to sueed. (run 1 (x) ( 4 3)) () We use ond e to get several values. Syntatially, ond e looks like ond but without or else. For example, (run 2 (q) (fresh (w x y) e (( (,x,w,x) q) ( y w)) (( (,w,x,w) q) ( y w))))) (( ) ( )) Although the two ond e lines are different, the values returned are idential. This is beause distint reified unbound variables are assigned distint subsripts, inreasing from left to right the numbering starts over again from zero within eah value, whih is why the reified value of x is 0 in the first value but 1 in the seond value. The supersript 2 in run denotes the maximum length of the resultant list. If the supersript is used, then there is no maximum imposed. This an easily lead to infinite loops: (let loop () e (( #f q)) (( #t q)) ((loop))))) Had been replaed by a natural number n, then an n-element list of alternating #f s and #t s would be returned. The ond e sueeds while assoiating q with #f, whih aounts for the first value. When getting the seond value, the seond ond e line is tried, and the assoiation made between q and #f is forgotten we say that q has been refreshed. In the third ond e line, q is refreshed again. We now look at several interesting examples that rely on any o, whih tries g an unbounded number of times. (define any o (λ (g) e (g) ((any o g))))) Consider the first example, e ((any o ( #f q))) (( #t q)))) whih does not terminate beause the all to any o sueeds an unbounded number of times. If were replaed by 5, then we would get (#t #f #f #f #f). (The user should not be onerned with the order in whih values are returned.) Now onsider (run 10 (q) (any o e (( 1 q)) (( 2 q)) (( 3 q))))) ( ) Here the values 1, 2, and 3 are interleaved; our use of any o ensures that this sequene is repeated indefinitely. 2

3 Even if some ond e lines loop indefinitely, other ond e lines an ontribute to the values returned by a run expression. However, we are not onerned with expressions looping indefinitely. For example, (run 3 (q) (let ((never o (any o ( #f #t)))) e (( 1 q)) (never o ) ( e (( 2 q)) (never o ) (( 3 q))))))) returns (1 2 3); replaing run 3 with run 4 would ause divergene sine there are only three values and never o would loop indefinitely looking for the fourth minikanren with Finite Domain Constraints Finite domain onstraints allow the user to assign a finite domain to a variable and to use mathematial relations between variables suh as, <,, and +. Termination is guaranteed when programmers limit themselves to fresh,, ond e, and the finite domain operators, sine the domains are finite (Jaffar and Maher 1994). However, this guarantee no longer holds when using reursion. We introdue five goals below, where n denotes a nonempty list of stritly inreasing natural numbers, x denotes a variable, u, v, and w denote arbitrary values, and v denotes either a list of values or a variable eventually assoiated with a list of values. In finite domains, any non-variable value should be a natural number. Names that end with fd and have no subsript like the ones below omprise the user interfae: dom fd and four onstraints. (dom fd x n ) (entered as domfd) onstrains x n. If n = (n), then (dom fd x n ) is the same as ( x n). ( fd u v) (entered as <=fd) onstrains u v. (+ fd u v w) (entered as plusfd) onstrains u + v = w. ( fd u v) (entered as =/=fd) onstrains u v. (all-diff fd v ) (entered as all-difffd) ensures that all variables and values found within the flat list v are different from eah other. The following examples illustrate these onstraints. In the first example, we state that q is never the same as 2. Then, when we state that q an only be a 1, 2, or 3, we exlude 2 from being a possible value of q. ( fd q 2) (dom fd q (1 2 3))) (1 3) A variable s domain an be defined at any time within the variable s sope. We use the derived goal (a goal that is defined in terms of other goals) in fd whih allows for assigning a domain to several different variables. Assoiating a variable with more than one domain, however, assigns the intersetion of those domains to the variable. (define-syntax in fd (( x 0 x... e) (let ((n e)) (fresh () (dom fd x 0 n ) (dom fd x n )... ))))) In the next example below, when we write ( x y), we are stating that x is going to be the same as y in every answer, so ( q (,x,y,z)) ould have been ( q (,x,x,z)) and (in fd y (3 4 5)) is the same as (in fd x (3 4 5)). (fresh (x y z) (in fd z ( )) ( x y) (in fd y (3 4 5)) ( q (,x,y,z)) (in fd z (5 6 9)) (in fd x (1 2 3)))) ((3 3 5) (3 3 6)) Even if a variable is not bound to a onstant by the end of a program (as is the ase with z in the example above), the variable will be assoiated with any satisfiable value in the domain of that variable if it is inluded in the returned expression. We introdue the derived goal < fd along with the very useful funtion range, whih, given two natural numbers, returns a list of all the numbers between lb and ub, inlusively. (define < fd (λ (u v) (fresh () ( fd u v) ( fd u v)))) (define range (λ (lb ub) ((< lb ub) (ons lb (range (+ lb 1) ub))) (ons lb ()))))) The following is a simple example of < fd and range in ation. (run (x) ( fd x 7) (< fd 2 x) (in fd x (range 0 10))) ( ) Variables used with finite domain onstraints must have domains. As a result, (fresh (x y) (< fd x y) (< fd y x))) signals an error; an alternative would be to fail, whih would be unfriendly to the user. Unsatisfiable onstraints, even when the variables are not referened or assoiated with the run variable in any way, still result in failure. (fresh (x y z) (in fd x y z (1 2)) (all-diff fd (,x,y,z)) ( q 5))) () 3

4 A variant of this example has a domain of three values. (fresh (x y z) (in fd x y z (1 2 3)) (all-diff fd (,x,y,z)) ( q x))) (1 2 3) Here eah element of x s domain shows up as a value. But, onsider this expression. (fresh (x y z) (in fd x y z (1 2 3)) (all-diff fd (,x,y,z)) ( q (,x,z)))) ((1 2) (1 3) (2 1) (3 1) (2 3) (3 2)) Had ( q (,x,z)) been ( q 5), the result would have been (5), beause Kanren ignores domain variables that are not assoiated with the variable bound by the run expression. Here is a simple example of all-diff fd. (in fd q (range 3 6)) (all-diff fd (2 3,q))) (4 5 6) We want values for q that satisfy the all-diff fd goal. We observe that if we hoose 3, we will have two ourrenes of 3, so that value is not inluded in the list of answers assoiated with q. But, if we try either 4, 5, or 6, then we observe that none of them are the same as 2 or 3. Now, onsider this run expression. (fresh (x y z) (in fd x y z (range 1 5)) (< fd z x) (+ fd y 2 z) ( q (,x,y,z)))) ((4 1 3) (5 1 3) (5 2 4)) minikanren with Tree Disequality We now introdue disequality onstraints using (entered as =/=), whih works on arbitrary values, using the same restritions imposed on minikanren. (fresh (x y) e (( x 1) ( y 1)) (( x 2) ( y 2)) (( x 1) ( y 2)) (( x 2) ( y 1))) ( x y) ( q (,x,y)))) ((1 2) (2 1)) The next example relies on all-diff o, a derived goal that uses. all-diff o takes a list and sueeds as long as all the values in the list are different at all points in the program. (define all-diff o (λ (l) e (( l ())) ((fresh (a) ( l (,a)))) ((fresh (a ad dd) ( l (,a,ad.,dd)) ( a ad) (all-diff o (,a.,dd)) (all-diff o (,ad.,dd))))))) 4 Our final example mimis the last all-diff fd example but with an unbounded, instead of bounded, result. (run 1 (q) (all-diff o (2 3,q))) (( 0 : ( (( 0. 2)) (( 0. 3))))) Thus, any value for q suffies, provided it is neither 2 nor 3. This is an unbounded number of answers. Beause of the imposed bound required when using all-diff fd, however, the number of answers is bounded Exerises Finite domains an be used to solve standard ryptarithmeti problems, suh as finding the orret letter values to satisfy the following equation: S E N D + M O R E M O N E Y Eah letter represents a different digit in the range 0 through 9, and the two leading digits, S and M, should be nonzero. n queens are plaed on an n n hessboard so that no two queens an attak one another. Of ourse, we want to find all the solutions. The Reasoned Shemer (Friedman et al. 2005) shows how to derive reursive relational programs from reursive funtional programs. But, our approah sometimes fails to work! Consider, (define rember (λ (x ls) ((null? ls) ()) (let ((a (ar ls)) (d (dr ls))) (let ((res (rember x d))) ((equal? a x) res) (,a.,res))))))))) and its derived reursive relation. (define rember o (λ (x ls out) e (( () ls) ( () out)) ((fresh (a d res) ( (,a.,d) ls) (rember o x d res) e (( a x) ( res out)) (( (,a.,res) out)))))))) (rember o a (a b a ) q)) ((b ) (b a ) (a b ) (a b a )) Is this the orret answer? The first list removes all ourrenes of a, so it seems so. But then the seond list removes the first ourrene of a; the third list removes the seond ourrene of a; and the last list removes no ourrenes of a. So, we know the last three lists are wrong. And worse, how an the following example sueed? (rember o a (a b ) (a b ))) ( 0 ) Solutions to the exerises an be found on page 12.

5 3. Implementation In this setion, we introdue the framework that we use to implement the onstraint systems. Part of understanding the framework is to get an intuitive feel for how it works in the presene of any ordering of the goals. That s the point of Setion Following that, we show the speifis of eah onstraint system. Definitions that are neither in the body of the paper nor in R 6 RS are defined in the appendies. 3.1 Framework The Kanren framework has been designed to be as flexible as possible, so users an define their own onstraints with ease. We implement operators for unifiation, onstraint propagation, and satisfiability that an be extended with user-defined funtions Core Data Strutures All information is kept in a pakage a, with three different stores. First, the substitution s ontains all assoiations diretly resulting from unifiation. Seond, d is a store for all the domains of variables. This store is a list of (var. domain) pairs, where domain is a non-empty (ordered small to large, with no dupliates) list of natural numbers. Finally, the onstraint store ontains only predefined onstraints that have been enountered, in normalized form. In the first two stores, s and d, eah assoiation is a variable paired with an assoiated value. The onstraint store is not an assoiation list; instead, it ontains a list of operator onstraints (desribed below). Although there are other approahes for organizing a pakage, we have hosen this way for simpliity and readability. Eah kind of information is separated so the user an see organized output for debugging; retrieval funtions have less information to sift through; and there is no need for dummy indiator values when variables are unassoiated in s, do not have a domain in d, or are unonstrained in. We provide a pakage onstrutor, and an aessor that lexially binds variables to eah different store. 2 (define make-a (λ (s d ) (ons s (ons d )))) (define-syntax λ M (syntax-rules (:) (( (a : s d ) body) (λ (a) (let ((s (ar a)) (d (adr a)) ( (ddr a))) body))) (( (a) body) (λ (a) body)))) In addition, we define two related operators. When identity M is passed as the seond argument to ompose M, then (ompose M f M ˆfM ) = f M, sine for all a, (and a a) = a. (define identity M (λ M (a) a)) (define ompose M (λ (f M ˆfM ) (λ M (a) (let ((a (f M a))) (and a ( ˆf M a)))))) 2 Variations on λ M ould generate simpler ode when s, d, or is not free in body. We propose defining those maros as an exerise for the reader. Eah store is initially the empty list but an be extended using speialized funtions. ext-s and ext-d simply extend an assoiation list, whereas ext- extends the onstraint store provided the new onstraint has at least one variable in it. This ensures that onstraints stritly between onstants are not in the onstraint store. Although what is ontained within a onstraint differs depending on whih onstraints are used, all onstraints that reside in look like (,(op arg... ) op,arg... ). Eah suh onstraint has an operator name, op, whih is the name of the helper funtion alled diretly or indiretly from the assoiated onstraint onstrutor. In programs, we use the lexial variable o to refer to suh an operator onstraint. Here is the definition of ext-. (define ext- (λ (o ) ((any/var? (o rands o)) (ons o )) )))) The implementor s maro build o (page 15) requires that arg... appear twie. This imposes the same kind of let use that appears in ase. We form hygienially-generated lexial variables, z..., leading to (let ((z arg)... ) (,(op z... ) op,z... )) whih is where we set up the ode to invoke a helper funtion, op, and where we plae the name of the helper funtion, op. If the result is viewed as a dotted pair, then we get (,(op z... ). (op,z... )), whose ar, a funtion all, has been invoked and whose dr, a list, desribes the funtion all Wathing Kanren Run We now show how three simple examples run. In the expressions below, we show eah step where s, d, or hanges. In the traes of these examples s ontains assoiations to a natural number or to a variable; d ontains assoiations to lists of natural numbers; and ontains the onstraints. For ease of reading, the stored proedure, whih would have been the first item in an o, has been deleted. Whenever any hanges our while running the onstraints in, these onstraints ompute a fixpoint. The goal expressions within a fresh expression are presumed to be numbered, in the first example, from 1 to 5. For our first example, we show three variants of the same program, eah with the goals in a different order. By hanging the order of goals on the same example, we indeed get the same answer, but more importantly, these examples demonstrate how the three stores onspire to produe the orret answer. (fresh (x y z) (in fd x z (range 3 5)) (in fd y (range 1 4)) (< fd x 5) ( x y) ( q (,y,z)))) ((3 3) (4 3) (3 4) (4 4) (3 5) (4 5)) In the first two goals, we initialize the domains (see d 1 and d 2, below). In the third goal, we restrit x < 5, whih is the same as restriting x 5 and x 5 [ 3 ]. This removes 5 from 5

6 x s domain [d 3 ] and revises the two onstraints that omprise the derived onstraint < fd (see ĉ 3 ). The next step unifies x with y, reording that information in the substitution s 4. One x and y have been unified, their domains beome their ommon elements [d 4]. (One in the substitution, x loses its identity and, heneforth, it is only y. That is, eah time we look up x, we find that it would be the same as looking up y. [ 4]) Then we form all possible pairs of values of y and z. d 1 ((x. (3 4 5)) (z. (3 4 5))) d 2 ((x. (3 4 5)) (y. ( )) (z. (3 4 5))) 3 (( fd x 5) ( fd x 5)) d 3 ((x. (3 4)) (y. ( )) (z. (3 4 5))) (( fd x 5)) ĉ 3 s 4 ((x. y)) d 4 ((x. (3 4)) (y. (3 4)) (z. (3 4 5))) 4 (( fd y 5)) Next, by swapping two goals, we get a slightly different view. (fresh (x y z) (in fd x z (range 3 5)) (in fd y (range 1 4)) ( x y) (< fd x 5) ( q (,y,z)))) ((3 3) (4 3) (3 4) (4 4) (3 5) (4 5)) We start out with d 1 and d 2 being the same as in the previous example. When we unify x and y, we extend the substitution (see s 3 ), and shrink y to be those values that are ommon to x and y [d 3 ]. Doing so virtually allows us to forget about x. We install y in the onstraint that is added, onstraint has only onstants, so it never gets added to [ 3 ]. One again, we form all possible pairs of values of y and z. observing that neither x nor y an be 5. The fd d 1 ((x. (3 4 5)) (z. (3 4 5))) d 2 ((x. (3 4 5)) (y. ( )) (z. (3 4 5))) s 3 ((x. y)) d 3 ((x. (3 4)) (y. (3 4)) (z. (3 4 5))) (( fd y 5)) 3 Finally, we move the two in fd goals. (fresh (x y z) ( x y) (< fd x 5) (in fd z x (range 3 5)) (in fd y (range 1 4)) ( q (,y,z)))) ((3 3) (4 3) (3 4) (4 4) (3 5) (4 5)) We see that x is the same as y (see s 1, below). The next goal adds the two predefined onstraints from the derived goal [ 2 ]. Thus, the onstraints use y instead of x, sine x is just y. Then the first in fd goal runs d 3 ), plaing values in the domain, but those domains must be run with respet to the onstraints, whih auses y to shrink [ ˆd 3 ]. The seond in fd goal runs but makes no hanges to the domain, sine y is (3 4), a subset of (3 4 5). However, hanges by first removing ( fd y 5), sine every value in y s domain differs from 5 [ 4], and then hanges again, sine every value in y s domain is less than or equal to 5 [ĉ 4 ]. As before, we form all possible pairs of y and z. s 1 ((x. y)) 2 (( fd y 5) ( fd y 5)) d 3 ((y. (3 4 5)) (z. (3 4 5))) ˆd 3 ((y. (3 4)) (z. (3 4 5))) 4 (( fd y 5)) ĉ 4 () We next onsider how all-diff fd and + fd work. (fresh (w x y z) (in fd w z (range 1 5)) (all-diff fd q) ( q (,x,y,z)) ( (,x 2) (1,y)) (+ fd x y w) (+ fd w y z))) ((1 2 5)) First we assoiate the two domains in d 1, below. Next, we run 2, whih reates a plaeholder in the onstraint store that aknowledges that we don t yet know what the variable q will be assoiated with. On the very next step, we disover that q is assoiated with the list (,x,y,z). This is aknowledged by hanging the kind of onstraint (in 3 ) to all-diff/ fd, sine we now know that there are two lists: the unresolved variables and the found values. At this time, we have not found any values. Step 4 hanges all three stores. First, the substitution grows by two assoiations. One we see that x is 1 and y is 2, then we know that z annot be either 1 or 2, so they are dropped from z s domain. At the same time we have found the values of x and y, so x and y are dropped from the first list in the onstraint and the assoiated found values are plaed, sorted into the seond list. In step 5 we add the onstraint that states = w whih vanishes when we find out that 3 is in w s domain. A similar event happens in step 6 by adding = z. It too vanishes when we find out that 5 is in z s domain. Just before reifiation, we disover that 5 is not a member of the found list of values. d 1 ((z. ( )) (w. ( ))) ((all-diff fd q)) 2 s 3 3 ((q. (x y z))) ((all-diff/ fd (z y x) ())) s 4 ((x. 1) (y. 2) (q. (x y z)))) d 4 ((z. (3 4 5)) (w. ( ))) 4 ((all-diff/ fd (z) (1 2))) 5 ((+ fd 6 ((+ fd ĉ w) (all-diff/ fd (z) (1 2))) 3 2 z) (all-diff/ fd (z) (1 2))) ((all-diff/ fd (z) (1 2))) 6

7 The last example shows how works. (fresh (w x z) ( ((1,x),q #f) (,z x,w)) ( z (1,x)) ( w #f) ( q q))) (q) By unifying the two values in the empty substitution, we reate a substitution that means that the three assoiations annot all hold (see 1 below). In s 2, we show that z is assoiated with (1 x). Thus, one of the three assoiations that must not hold now holds. If the remaining two hold, then this expression fails. For the next step, we assoiate w with #f. This removes the seond of the three onstraints that must not hold. The final step assoiates q with the symbol q, whih allows the onstraint to be removed beause q an never be the same as the symbol x. This aounts for the aeptable final substitution. Had the last goal expression been ( q x), however, then all three onstraints would have held, leading to failure. 1 s 2 2 s 3 3 ( neq ((z. (1 x)) (y. x) (w. #f))) ((z. (1 x))) ( neq ((w. #f) (q. x))) ((w. #f) (z. (1 x))) ( neq ((q. x))) s 4 ((q. q) (w. #f) (z. (1 x))) So far, we have skethed how substitutions, domains, and onstraints work together. The remainder of this setion fills in speifis. 3.2 Parameters The funtions within Kanren perform orretly when the three parameters 3 proess-prefix, enfore-onstraints, and reify-onstraints are imported and given new values. Eah parameter is initialized with a dummy value (page 15), so eah kind of Kanren onstraint must update eah parameter with its own funtion. Informally, these funtions should present the following interfae: proess-prefix This funtion is sent a prefix of the substitution, onsisting of all the assoiations newly added after a unifiation. In addition, it is sent the urrent onstraints. This an be an opportunity to rerun onstraints for the variables with new assoiations but different onstraints. enfore-onstraints This funtion is run immediately before we reify the onstraints and should aept the variable to be reified. Any heks for onsisteny or reorganization of the onstraint store an be done here. reify-onstraints This funtion is run as part of the reifier. It is responsible for building a Sheme data struture that represents the information in the onstraint store of a pakage. 3 As seen in SRFI-39. The same funtionality ould be aptured with global variables and side effets; however, parameters offer the leanest solution. Prolog systems use modules and prediates with fixed names to allow ustomization of attribute hooks, rather than parameters. Assuming these funtions are defined prior to runtime, Kanren lays the framework for unifiation, running onstraints, and running entire minikanren funtions goal-onstrut Sine most onstraint operations should be deterministi, it is often neessary to wrap them in a goal that will sueed when a new pakage is returned suessfully and fail otherwise. This funtion makes suh wrapping easy. (See page 17 for the definition of λ G, whose values are goals.) (define goal-onstrut (λ (f M ) (λ G (a) ((f M a) unit G ) (mzero G )))))) unifies two arguments, u and v, and an result in three different senarios. If unify (page 18) fails, the result is #f and auses the goal to fail. If the original substitution is returned unhanged, no additional ation need our. In the last ase, we obtain new information from unifiation. That new information (ontained in a prefix of the new substitution) is retrieved and passed to the funtion returned by (proessprefix) for further examination. (define (λ (u v) (goal-onstrut ( u v)))) (define (λ (u v) (λ M (a : s d ) ((unify ((,u.,v)) s) (λ (ŝ) ((eq? s ŝ) a) (let ((p (prefix-s s ŝ)) (a (make-a ŝ d ))) (((proess-prefix) p ) a)))))) #f))))) (define prefix-s (λ (s ŝ) ((null? s) ŝ) (let loop ((ŝ ŝ)) ((eq? ŝ s) ()) (ons (ar ŝ) (loop (dr ŝ)))))))))) (define #u ( #f #t)) (define #s ( #f #f)) run-onstraints When Kanren gets new information about a variable, suh as an additional onstraint or a more restrited domain, earlier onstraints may be affeted. Sine we keep all onstraint information in a store, we an reur through the store when suh a hange happens to reevaluate onstraints. 7

8 A naïve approah is to rerun every onstraint in the store indisriminately until there are no more hanges in the store (i.e., until a fixpoint is reahed). (define run-onstraints 0 (λ (x -ignored ) ((null? ) identity M ) (ompose M (o pro (ar )) (run-onstraints 0 x -ignored (dr ))))))) run-onstraints 0 performs well on small examples, but this approah is too ostly when the onstraint store grows. So, in a slightly less naïve approah, the proedure reeives a list of variables to look for and runs only those onstraints involving those variables. any-relevant/var? (page 16) searhes the onstraint s list of arguments for a variable in x. (define run-onstraints 1 (λ (x ) ((null? ) identity M ) ((any-relevant/var? (o rands (ar )) x ) (ompose M (o pro (ar )) (run-onstraints 1 x (dr )))) (run-onstraints 1 x (dr )))))) Unfortunately, run-onstraints 1 still runs some onstraints unneessarily. Sine we run a onstraint eah time before the reursive all, the onstraint store being proessed is not up to date. It is possible that a onstraint in no longer exists in the onstraint store when the reursion reahes it. In run-onstraints, below, one we have found a onstraint that ontains one or more of the variables we are looking for, we hek to make sure that we still need the onstraint. The urrent onstraint store is pulled in and, if the onstraint is still ontained within that store, it is removed and rerun. If the urrent onstraint is not within the urrent onstraint store, a previous onstraint has rendered it unneessary (and it should not run again). (define run-onstraints (λ (x ) ((null? ) identity M ) ((any-relevant/var? (o rands (ar )) x ) (ompose M (rem/run (ar )) (run-onstraints x (dr )))) (run-onstraints x (dr )))))) (define rem/run (λ (o) (λ M (a : s d ) ((memq o ) (let ((ĉ (remq o ))) ((o pro o) (make-a s d ĉ)))) a))))) After being run, the onstraint might add itself bak into the urrent onstraint store, but only when it still has variable arguments. If all arguments are onstants, the onstraint is not reintrodued reify reify takes a variable x and then runs the two goals within (fresh ()... ). The first goal ensures that the most meaningful answers available are sent to the seond goal. The seond goal pulls in a pakage a, then returns the value assoiated with x in a (along with any relevant onstraints), first replaing all variables with symbols representing those entities. A onstraint (pro name. rands) is relevant if both name and rands appear in the value assoiated with x. We all this proess of turning a Kanren value into a Sheme value reifiation. The first ond line in the definition of reify below returns only the reified value v assoiated with x when the rename substitution is empty. If the rename substitution is not empty, it is used to rename the variables in v. Then, if there are no relevant onstraints, the renamed value is returned. The else line returns both the reified value of x and the reified list of relevant onstraints. (The use of hoie G and empty-f in reify is a subtlety to allow #f as a value, for example in ( #f q)) (#f).) (define reify (λ (x) (fresh () ((enfore-onstraints) x) (λ G (a : s d ) (hoie G (let ((v (walk x s)) (r (reify-s v empty-s))) ((null? r) v) (let ((v (walk v r))) ((null? ) v) (((reify-onstraints) v r) a))))))) empty-f ))))) 3.3 Finite Domain Implementation We reated a domain interfae powerful enough to allow users to swith domain representations without hanging any of the onstraint operations. Although we have hosen a simple domain finite domains as sorted non-empty lists (with no dupliates) of natural numbers we believe this framework would support a variety of other domains suh as symbols, integers, or lists of sorted, nonoverlapping integer intervals. The user need only redefine basi funtions suh as intersetion, differene, and the other simple funtions found in Appendix A. A variable must be assoiated with either a finite domain or a natural number before reifiation, but this assoiation an happen at any point in a Kanren program. While this restrition might ause some programs to be more verbose (for example, it might seem like the onstraint ( fd x 5) should automatially bind the domain ( ) to x) suh overloading of behavior fores a tradeoff between lean implementation and user onveniene; we prefer the former The Finite Domain Parameters We now onsider the parameters as broadly desribed in Setion 3.2. Reall that to aess a parameter, it is neessary to invoke the parameter as a funtion of zero arguments. First we define the three parameters: proess-prefix FD, enfore- 8

9 onstraints FD, and reify-onstraints FD. One these are defined, we proeed to the speifi finite domain onstraints. proess-prefix FD reonsiders eah assoiation that was added as a result of unifiation. Consider an assoiation (x. v), where x is a variable and v is a onstant or a variable. The domain of x is interseted with (the domain of) v and all onstraints involving x are rerun. Although doing so does not diretly rerun onstraints of v, a singleton intersetion triggers the onstraints of v, as an be seen in the definition of resolve-storable δ, below. (define proess-prefix FD (λ (p ) ((null? p) identity M ) (let ((x (lhs (ar p))) (v (rhs (ar p)))) (let ((t (ompose M (run-onstraints (,x) ) (proess-prefix FD (dr p) )))) (λ M (a : s d ) ((get δ x d) (λ (δ) ((ompose M (proess δ v δ) t) a))) (t a)))))))))) proess δ takes as arguments a value v and a domain δ. If v is a variable, all information is passed to update-var δ. If v is a domain value in δ, then we return a unhanged. (define proess δ (λ (v δ) (λ M (a) ((var? v) ((update-var δ v δ) a)) ((memv? δ v δ) a) #f))))) In update-var δ we interset the two domains: the one assoiated with v in d and the domain passed into proess δ. If the intersetion is a singleton, we extend the substitution. Otherwise, we extend the domain with the intersetion. If the two domains are disjoint, then we return false. (At this point, we have wrong information in d, but this is fine, sine we look up variables in d only when they are not in s.) (define update-var δ (λ (x δ) (λ M (a : s d ) ((get δ x d) (λ (x δ ) (let ((i (intersetion δ x δ δ))) ((null? δ i) #f) ((resolve-storable δ i x) a)))))) ((resolve-storable δ δ x) a)))))) (define resolve-storable δ (λ (δ x) (λ M (a : s d ) ((singleton? δ δ) (let ((n (singleton-element δ δ)) (a (make-a (ext-s x n s) d ))) ((run-onstraints (,x) ) a))) (make-a s (ext-d x δ d) )))))) We have hosen to extend the substitution diretly, rather than using or unify. The presumption is that x has already been walked (page 18) in the substitution, so we an avoid that extra unifiation overhead. enfore-onstraints FD has two purposes. The value assoiated with x is going to be returned as an answer, so it is desirable to assoiate x with a onstant whenever possible. If x is unified with a variable that has domain information, eah realizable domain value should be returned. It is always possible, however, that there are onstrained variables that are not returned as part of the final answer. While we do not are about the exat value of every variable, we still need to be sure there exists at least one value for eah variable suh that all onstraints are satisfied or the entire program should fail. fore-ans reurs through the list of domain variables until it sueeds one; it is fored to stop by one o (page 19) and reifiation an our. (define enfore-onstraints FD (λ (x) (fresh () (fore-ans x) (λ G (a : s d ) (let ((bound-x (map lhs d))) (verify-all-bound bound-x ) ((one o (fore-ans bound-x )) a)))))) fore-ans takes either a variable or a list of variables. If the variable is not assoiated with a onstant in s but does have a domain, map-sum (page 16) attempts to assoiate that variable with everything in its domain. If the value is a pair, the ar and dr are searhed for variables as well. Otherwise, it is already assoiated with a onstant and it sueeds. (define fore-ans (λ (x) (λ G (a : s d ) (let ((x (walk x s))) ( ((and (var? x) (get δ x d)) (map-sum (λ (v) ( x v)))) ((pair? x) (fresh () (fore-ans (ar x)) (fore-ans (dr x)))) #s)) a))))) reify-onstraints FD, when invoked, produes an error, sine there are variables in relevant onstraints that are bound neither in s nor in d. (define reify-onstraints FD (λ (m r) (error reify-onstraints FD "Unbound vars at end\n"))) We invoke (use FD ) in order to use onstraints over finite domains. (define use FD (λ () (proess-prefix proess-prefix FD ) (enfore-onstraints enfore-onstraints FD ) (reify-onstraints reify-onstraints FD ))) 9

10 3.4 let δ and -op Here, we present two very useful maros: let δ and -op. let δ, an implementor s onveniene maro, lexially binds u to eah argument s urrent value in the substitution and u δ to eah assoiated domain, respetively. (define-syntax let δ (syntax-rules (:) (( (s d) ((u : u δ )... ) body) (let ((u (walk u s))... ) (let ((u δ ((var? u) (get δ u d)) (make δ (,u)))))... ) body))))) -op is a maro for defining onstraint operations that uses let δ. build o (page 15) reates a storable representation of the onstraint, and the onstraint store is extended. The body is run when eah argument u has a domain. (define-syntax -op (syntax-rules (:) (( op ((u : u δ )... ) body) (λ M (a : s d ) (let δ (s d) ((u : u δ )... ) (let (( (ext- (build o op u... ) )) (a (make-a s d ))) ((and u δ... ) (body a)) a)))))))) The Goal Construtors There are five onstraint onstrutors: dom fd, fd, + fd, fd, and all-diff fd. The goal (dom fd x n ) onstrains x n. The real work of dom fd is done by proess δ (page 9). (define dom fd (λ (x n ) (goal-onstrut (dom fd x n )))) (define dom fd (λ (x n ) (λ M (a : s d ) ((proess δ (walk x s) (make δ n )) a)))) The goal ( fd u v) implies that min(u) max(v), filtering out ineligible domain elements from u and v. (define fd (λ (u v) (goal-onstrut ( fd u v)))) (define fd (λ (u v) (-op fd ((u : u δ ) (v : v δ )) (let ((u min (min δ u δ )) (v max (max δ v δ ))) (ompose M (proess δ u (opy-before (λ (u) (< v max u)) u δ )) (proess δ v (drop-before (λ (v) ( u min v)) v δ ))))))) The goal (+ fd u v w) has the meaning u + v = w. Thus we get two relations: min(u) + min(v) max(w) min(w) max(u) + max(v) (define + fd (λ (u v w) (goal-onstrut (+ fd u v w)))) (define + fd (λ (u v w) (-op + fd ((u : u δ ) (v : v δ ) (w : w δ )) (let ((u min (min δ u δ )) (u max (max δ u δ )) (v min (min δ v δ )) (v max (max δ v δ )) (w min (min δ w δ )) (w max (max δ w δ ))) (ompose M (proess δ w (range (+ u min v min) (+ u max v max))) (ompose M (proess δ u (range ( w min v max) ( w max v min))) (proess δ v (range ( w min u max) ( w max u min))))))))) The goal ( fd u v) onstrains u and v from having the same values. If the domains of u and v are disjoint, the onstraint an never be violated and so it is ignored. Otherwise, the onstraint is kept around until the domains are equal (whih violates the onstraint, returning false) or one domain is redued to a singleton. Then the single element is removed from the other argument s domain and the onstraint is dropped. (define fd (λ (u v) (goal-onstrut ( fd u v)))) (define fd (λ (u v) (λ M (a : s d ) (let δ (s d) ((u : u δ ) (v : v δ )) ((or (not u δ ) (not v δ )) (make-a s d (ext- (build o fd ((and (singleton? δ u δ ) (singleton? δ v δ ) (= (singleton-element δ u δ ) (singleton-element δ v δ ))) #f) ((disjoint? δ u δ v δ ) a) u v) ))) (let ((ĉ (ext- (build o fd u v) )) (a (make-a s d ĉ))) ((singleton? δ u δ ) ((proess δ v (diff δ v δ u δ )) a)) ((singleton? δ v δ ) ((proess δ u (diff δ u δ v δ )) a)) a))))))))) 10

11 The goal (all-diff fd v ) ensures all variables and values in v differ. all-diff fd ould have been written as a derived onstraint of fd. Instead, this onstraint is between a list of values (either variables or onstants), where the onstants are reursively exluded from eah variable s domain or the argument to all-diff fd might be a single variable, whih eventually beomes suh a list of values. (define all-diff fd (λ (v ) (goal-onstrut (all-diff fd v )))) In the first of all-diff fd s two ond lines, we aknowledge that we have a variable (eventually to beome a list) and we inlude in a onstraint whih means Keep trying until the variable has an assoiation in the substitution. In the seond ond line, we must have a list, so we partition the list into two piees: unresolved variables and the found values, making sure along the way that the found values are all different. If they are not different, all-diff fd fails. (define all-diff fd (λ (v ) (λ M (a : s d ) (let ((v (walk v s))) ((var? v ) (let ((o (build o all-diff fd v ))) (make-a s d (ext- o )))) (let-values (((x n ) (partition var? v ))) (let ((n (list-sort < n ))) ((list-sorted? < n ) ((all-diff/ fd x n ) a)) #f)))))))))) In all-diff/ fd, we are dealing with the unresolved variables y and the found values n. We move a variable y of y to x unless y is assoiated with a value in the substitution, presumably to a single valid value. Then, we don t move y to x and instead move y to n, whih must stay sorted. When eah variable has been proessed, we exlude the final n from the possible hoies remaining from eah of the domains of x. exlude-from δ (defined below) alls proess δ to refine d, and potentially all run-onstraints. (define all-diff/ fd (λ (y n ) (λ M (a : s d ) (let loop ((y y ) (n n ) (x ())) ((null? y ) (let ((o (build o all-diff/ fd x n )) (a (make-a s d (ext- o )))) ((exlude-from δ (make δ n ) d x ) a))) (let ((y (walk (ar y ) s))) ((var? y) (loop (dr y ) n (ons y x ))) ((memv? δ y n ) #f) (let ((n (list-insert < y n ))) (loop (dr y ) n x ))))))))))) (define exlude-from δ (λ (δ 1 d x ) (let loop ((x x )) ((null? x ) identity M ) ((get δ (ar x ) d) (λ (δ 2) (ompose M (proess δ (ar x ) (diff δ δ 2 δ 1)) (loop (dr x ))))) (loop (dr x ))))))) 3.5 Disequality Constraints Implementation The version of disequality defined on finite domains is not powerful enough to operate on lists, even when those lists ontain finite domain values and variables alone. So, we desribe a more general version of disequality onstraints. This implementation uses unifiation to unover exatly whih assoiations must never be made. For example, the onstraint ( (x 1) (2 y)) means that x annot be 2 when y is 1. Conveniently, unifiation of (x 1) and (2 y) produes exatly the normalized assoiations that should never be true simultaneously: ((x. 2) (y. 1)). This idea has been formalized by Hubert Comon (1991), who has desribed this and other approahes to disequality The Disequality Constraints Parameters We define the same onstraint parameters as in Setion 3.3.1; however, the disequality onstraint parameters are muh simpler than those of finite domains. proess-prefix NEQ is quite simple, as no domain information is stored. The onstraints of every variable within the prefix p are reexamined using run-onstraints. (define proess-prefix NEQ (λ (p ) (run-onstraints (reover/vars p) ))) Next we onsider enfore-onstraints NEQ. Disequality onstraints fail immediately if they are unsatisfiable. It is not neessary to hek the store again before reifiation, so enfore-onstraints is merely unit G. (define enfore-onstraints NEQ (λ (x) unit G )) reify-onstraints NEQ reifies every relevant onstraint in, sine they are inluded as part of the reified value; we have arbitrarily hosen the olon : to separate the reified value from the list of reified onstraints. (define reify-onstraints NEQ (λ (m r) (λ G (a : s d ) (let (( (walk r)) (p (remp any/var? (map o prefix )))) ((null? p ) m) (,m :. ((.,p ))))))))) We invoke (use NEQ ) in order to use disequality onstraints over term trees, (define use NEQ (λ () (proess-prefix proess-prefix NEQ ) (enfore-onstraints enfore-onstraints NEQ ) (reify-onstraints reify-onstraints NEQ ))) 11

12 3.5.2 The Disequality Goal We define for disequality, whih takes two arguments that must be different. If not, the goal fails. (define (λ (u v) (goal-onstrut ( u v)))) (define (λ (u v) (λ M (a : s d ) ((unify ((,u.,v)) s) (λ (ŝ) (( neq (prefix-s s ŝ)) a))) a))))) operates on a substitution p. If every assoiation in p is in s, the disequality onstraint has been violated. Otherwise, we get a new non-empty prefix to be stored. When the initial substitution is empty, ŝ is the prefix. neq (define neq (λ (p) (λ M (a : s d ) ((unify p s) (λ (ŝ) (let ((p (prefix-s s ŝ))) ((null? p) #f) ((normalize-store p) a)))))) a))))) If unify does not return false, there is still a possibility the disequality onstraint an be violated. Now ŝ ontains the prefix p that must not beome realized. normalize-store removes any superfluous disequality onstraints in. If p is subsumed by any prefix in, or if p subsumes any prefix in, there is redundany. After the onstraint store has been examined, either a new pakage with potentially fewer onstraints or the original pakage with at most one more onstraint is returned. (define normalize-store (λ (p) (λ M (a : s d ) (let loop (( ) (ĉ ())) ((null? ) (let ((ĉ (ext- (build o neq p) ĉ))) (make-a s d ĉ))) ((eq? (o rator (ar )) neq ) (let ((o (ar )) (ˆp (o prefix o))) ((subsumes? ˆp p) a) ((subsumes? p ˆp) (loop (dr ) ĉ)) (loop (dr ) (ons o ĉ)))))) (loop (dr ) (ons (ar ) ĉ)))))))) The substitution p subsumes (page 17) s if unifying p in the substitution s does not extend s. If any prefix in subsumes p, then is not extended. Furthermore, beause p will be part of the new, those prefixes in that p subsumes are dropped. 4. Solutions to Exerises Reall from Setion that we left unsolved three problems: Send More Money, N-Queens, and rember o. We start with the solution to Send More Money. 4.1 send-more-money o : Solution In send-more-money o below, we must be ertain that eah letter in the puzzle is assoiated with a different value. Sine we know that s and m annot be 0 (the leading digit of a natural number is never 0), their domains start at 1. The domains of the remaining letters inlude 0. There are also three arry variables. (There should have been four, one for eah olumn, but we know that m must be 1, sine the sum of two digits, even with a arry-in of 1, annot exeed 19.) Thus, we use m as the fourth arry variable.). The rest of send-more-money o does the long addition. add-digits o performs one step of long addition, adding two digits together onsidering a possible arry-in, and returning the sum with a possible arry-out. (define send-more-money o (λ (letters) (fresh (s e n d m o r y arry 0 arry 1 arry 2) ( letters (,s,e,n,d,m,o,r,y)) (all-diff fd letters) (in fd s m (range 1 9)) (in fd e n d o r y (range 0 9)) (in fd arry 0 arry 1 arry 2 (range 0 1)) (add-digits o s m arry 2 m o) (add-digits o e o arry 1 arry 2 n) (add-digits o n r arry 0 arry 1 e) (add-digits o d e 0 arry 0 y)))) (define add-digits o (λ (augend addend arry-in arry-out digit) (fresh (partial-sum sum) (in fd partial-sum (range 0 18)) (in fd sum (range 0 19)) (+ fd augend addend partial-sum) (+ fd partial-sum arry-in sum) e ((< fd 9 sum) ( arry-out 1) (+ fd digit 10 sum)) (( fd sum 9) ( arry-out 0) ( digit sum)))))) (send-more-money o q)) (( )) This answer orresponds to the variable assignments: S = 9 E = 5 N = 6 D = 7 M = 1 O = 0 R = 8 Y = 2 whih indeed satisfy the Send More Money puzzle. There are two interesting faets to this ode. First, areful inspetion of send-more-money o and add-digits o reveals that the solution requires no expliit reursion. Seond, the goals of send-more-money o are ordered so that the first and seond arguments to the four goals using add-digits o when read from top to bottom spell s e n d and m o r e, respetively. 4.2 n-queens o : Solution Here we solve N-Queens puzzle. Reall that in hess, a queen is attaking a piee if they are on the same diagonal, the same row, or the same olumn, with no interferene. 12

13 We define n-queens o reursively. A loop exeutes n times, reating n variables, one for eah row. When the loop reahes its base ase, the list l ontains the newly initialized variables. Eah variable is in a different position in the list l (sine no two queens an oupy the same row); the values that will be assoiated with these variables must be all different (sine no two queens an oupy the same olumn); and no two queens an share the same diagonal. all-diff fd and diagonals o enfore these last two restritions. (define n-queens o (λ (q n) (let loop ((i n) (l ())) ((zero? i) (fresh () (all-diff fd l) (diagonals o n l) ( q l))) (fresh (x) (in fd x (range 1 n)) (loop ( i 1) (ons x l)))))))) (define diagonals o (λ (n r) (let loop ((r r) (i 0) (s (dr r)) (j 1)) ((or (null? r) (null? (dr r))) #s) ((null? s) (loop (dr r) (+ i 1) (ddr r) (+ i 2))) (let ((q i (ar r)) (q j (ar s))) (fresh () (diag o q i q j ( j i) (range 0 ( 2 n))) (loop r i (dr s) (+ j 1))))))))) In diagonals o, i keeps trak of the position in the list of queens that we are on and j keeps trak of the position in the list of queens somewhere to the right of i. q i and q j are two elements of n. Effetively, we hek every possible position for two queens exatly one, as q i will always be less than q j. For eah ombination, diag o is alled. As long as the following equations hold (Shrijvers et al. 2009), the queens will not be attaking eah other and diag o will sueed. q i + d q j (define diag o (λ (q i q j d rng) (fresh (q i+d q j+d) (in fd q i+d q j+d rng) (+ fd q i d q i+d) ( fd q i+d q j) (+ fd q j d q j+d) ( fd q j+d q i)))) q j + d q i The following expression produes the solution when n = 8. The run expression evaluates to the list of 92 solutions. (length (n-queens o q 8))) rember o : Solution Reall that rember o does not give us the results we were expeting. A simple fix is that one we have found an a, we demand that we won t get any more answers from that a as is shown in the last line of the definition of rember o, below. This onept beomes partiularly important when using a representation of environments where shadowing exists, say, in a type inferener being used as a type inhabiter for demonstrating the Curry-Howard Isomorphism. (define rember o (λ (x ls out) e (( () ls) ( () out)) ((fresh (a d res) ( (,a.,d) ls) (rember o x d res) e (( a x) ( res out)) (( a x) ( (,a.,res) out)))))))) (rember o a (a b a ) q)) ((b )) (rember o a (a b ) (a b ))) () 5. Composition In order to ompose different kinds of onstraints, it is enough to redefine eah parameter aording to the semantis desired by the user. For instane, we an ombine the finite domain and disequality onstraints by allowing to all fd in the ase of natural number arguments, or using domain information to eliminate parts of the prefix in neq. The omposite library imports the funtion definitions from the finite domain and disequality libraries, and defines the omposite parameters in terms of the domain-speifi funtions. With the omposite library, examples suh as the following an be solved. (in fd q (2 3 4)) (all-diff o (apple 3,q))) (2 4) Although the two kinds of onstraints do not expliitly ommuniate, q s domain information an be used in onjuntion with all-diff o. Before reifiation, q will be unified with all remaining values in its domain. q s only realizable values are 2 and 4, sine all-diff o fails when 3 is tried. (Using all-diff fd instead of all-diff o would result in an error, sine apple is a symbol rather than a natural number.) Confliting onstraints annot be present in the same all to run. Having two kinds of onstraints in any environment would ause onfliting parameter definitions. For example, assume we wish to verify that the 92 answers returned by (n-queens o q 8)) are atually all unique answers. We annot use all-diff fd, sine the result is a list of lists, but finite domain onstraints only work on a list of natural numbers, so, we must use all-diff o. (define answers (n-queens o q 8))) (all-diff o answers)) ( 0 ) These alls to run leave no opportunity to redefine parameters, so we must be sure that the definitions for all parameters work orretly when either finite domain or disequality onstraints are used. Combining different kinds of onstraints that use different domain representations is more omplex. Conveniently, the user has the power to redefine, extend, or ignore any part of the existing libraries when making a omposition. A tagged domain store ould be implemented simply by redefining 13

Computer Science 786S - Statistical Methods in Natural Language Processing and Data Analysis Page 1

Computer Science 786S - Statistical Methods in Natural Language Processing and Data Analysis Page 1 Computer Siene 786S - Statistial Methods in Natural Language Proessing and Data Analysis Page 1 Hypothesis Testing A statistial hypothesis is a statement about the nature of the distribution of a random

More information

Millennium Relativity Acceleration Composition. The Relativistic Relationship between Acceleration and Uniform Motion

Millennium Relativity Acceleration Composition. The Relativistic Relationship between Acceleration and Uniform Motion Millennium Relativity Aeleration Composition he Relativisti Relationship between Aeleration and niform Motion Copyright 003 Joseph A. Rybzyk Abstrat he relativisti priniples developed throughout the six

More information

Product Policy in Markets with Word-of-Mouth Communication. Technical Appendix

Product Policy in Markets with Word-of-Mouth Communication. Technical Appendix rodut oliy in Markets with Word-of-Mouth Communiation Tehnial Appendix August 05 Miro-Model for Inreasing Awareness In the paper, we make the assumption that awareness is inreasing in ustomer type. I.e.,

More information

arxiv: v2 [math.pr] 9 Dec 2016

arxiv: v2 [math.pr] 9 Dec 2016 Omnithermal Perfet Simulation for Multi-server Queues Stephen B. Connor 3th Deember 206 arxiv:60.0602v2 [math.pr] 9 De 206 Abstrat A number of perfet simulation algorithms for multi-server First Come First

More information

Complexity of Regularization RBF Networks

Complexity of Regularization RBF Networks Complexity of Regularization RBF Networks Mark A Kon Department of Mathematis and Statistis Boston University Boston, MA 02215 mkon@buedu Leszek Plaskota Institute of Applied Mathematis University of Warsaw

More information

23.1 Tuning controllers, in the large view Quoting from Section 16.7:

23.1 Tuning controllers, in the large view Quoting from Section 16.7: Lesson 23. Tuning a real ontroller - modeling, proess identifiation, fine tuning 23.0 Context We have learned to view proesses as dynami systems, taking are to identify their input, intermediate, and output

More information

The Laws of Acceleration

The Laws of Acceleration The Laws of Aeleration The Relationships between Time, Veloity, and Rate of Aeleration Copyright 2001 Joseph A. Rybzyk Abstrat Presented is a theory in fundamental theoretial physis that establishes the

More information

Lightpath routing for maximum reliability in optical mesh networks

Lightpath routing for maximum reliability in optical mesh networks Vol. 7, No. 5 / May 2008 / JOURNAL OF OPTICAL NETWORKING 449 Lightpath routing for maximum reliability in optial mesh networks Shengli Yuan, 1, * Saket Varma, 2 and Jason P. Jue 2 1 Department of Computer

More information

Einstein s Three Mistakes in Special Relativity Revealed. Copyright Joseph A. Rybczyk

Einstein s Three Mistakes in Special Relativity Revealed. Copyright Joseph A. Rybczyk Einstein s Three Mistakes in Speial Relativity Revealed Copyright Joseph A. Rybzyk Abstrat When the evidene supported priniples of eletromagneti propagation are properly applied, the derived theory is

More information

State Diagrams. Margaret M. Fleck. 14 November 2011

State Diagrams. Margaret M. Fleck. 14 November 2011 State Diagrams Margaret M. Flek 14 November 2011 These notes over state diagrams. 1 Introdution State diagrams are a type of direted graph, in whih the graph nodes represent states and labels on the graph

More information

General Equilibrium. What happens to cause a reaction to come to equilibrium?

General Equilibrium. What happens to cause a reaction to come to equilibrium? General Equilibrium Chemial Equilibrium Most hemial reations that are enountered are reversible. In other words, they go fairly easily in either the forward or reverse diretions. The thing to remember

More information

Supplementary Materials

Supplementary Materials Supplementary Materials Neural population partitioning and a onurrent brain-mahine interfae for sequential motor funtion Maryam M. Shanehi, Rollin C. Hu, Marissa Powers, Gregory W. Wornell, Emery N. Brown

More information

A NETWORK SIMPLEX ALGORITHM FOR THE MINIMUM COST-BENEFIT NETWORK FLOW PROBLEM

A NETWORK SIMPLEX ALGORITHM FOR THE MINIMUM COST-BENEFIT NETWORK FLOW PROBLEM NETWORK SIMPLEX LGORITHM FOR THE MINIMUM COST-BENEFIT NETWORK FLOW PROBLEM Cen Çalışan, Utah Valley University, 800 W. University Parway, Orem, UT 84058, 801-863-6487, en.alisan@uvu.edu BSTRCT The minimum

More information

Methods of evaluating tests

Methods of evaluating tests Methods of evaluating tests Let X,, 1 Xn be i.i.d. Bernoulli( p ). Then 5 j= 1 j ( 5, ) T = X Binomial p. We test 1 H : p vs. 1 1 H : p>. We saw that a LRT is 1 if t k* φ ( x ) =. otherwise (t is the observed

More information

Maximum Entropy and Exponential Families

Maximum Entropy and Exponential Families Maximum Entropy and Exponential Families April 9, 209 Abstrat The goal of this note is to derive the exponential form of probability distribution from more basi onsiderations, in partiular Entropy. It

More information

Nonreversibility of Multiple Unicast Networks

Nonreversibility of Multiple Unicast Networks Nonreversibility of Multiple Uniast Networks Randall Dougherty and Kenneth Zeger September 27, 2005 Abstrat We prove that for any finite direted ayli network, there exists a orresponding multiple uniast

More information

Assessing the Performance of a BCI: A Task-Oriented Approach

Assessing the Performance of a BCI: A Task-Oriented Approach Assessing the Performane of a BCI: A Task-Oriented Approah B. Dal Seno, L. Mainardi 2, M. Matteui Department of Eletronis and Information, IIT-Unit, Politenio di Milano, Italy 2 Department of Bioengineering,

More information

Parallel disrete-event simulation is an attempt to speed-up the simulation proess through the use of multiple proessors. In some sense parallel disret

Parallel disrete-event simulation is an attempt to speed-up the simulation proess through the use of multiple proessors. In some sense parallel disret Exploiting intra-objet dependenies in parallel simulation Franeso Quaglia a;1 Roberto Baldoni a;2 a Dipartimento di Informatia e Sistemistia Universita \La Sapienza" Via Salaria 113, 198 Roma, Italy Abstrat

More information

The Effectiveness of the Linear Hull Effect

The Effectiveness of the Linear Hull Effect The Effetiveness of the Linear Hull Effet S. Murphy Tehnial Report RHUL MA 009 9 6 Otober 009 Department of Mathematis Royal Holloway, University of London Egham, Surrey TW0 0EX, England http://www.rhul.a.uk/mathematis/tehreports

More information

Robust Recovery of Signals From a Structured Union of Subspaces

Robust Recovery of Signals From a Structured Union of Subspaces Robust Reovery of Signals From a Strutured Union of Subspaes 1 Yonina C. Eldar, Senior Member, IEEE and Moshe Mishali, Student Member, IEEE arxiv:87.4581v2 [nlin.cg] 3 Mar 29 Abstrat Traditional sampling

More information

UPPER-TRUNCATED POWER LAW DISTRIBUTIONS

UPPER-TRUNCATED POWER LAW DISTRIBUTIONS Fratals, Vol. 9, No. (00) 09 World Sientifi Publishing Company UPPER-TRUNCATED POWER LAW DISTRIBUTIONS STEPHEN M. BURROUGHS and SARAH F. TEBBENS College of Marine Siene, University of South Florida, St.

More information

A Characterization of Wavelet Convergence in Sobolev Spaces

A Characterization of Wavelet Convergence in Sobolev Spaces A Charaterization of Wavelet Convergene in Sobolev Spaes Mark A. Kon 1 oston University Louise Arakelian Raphael Howard University Dediated to Prof. Robert Carroll on the oasion of his 70th birthday. Abstrat

More information

IMPEDANCE EFFECTS OF LEFT TURNERS FROM THE MAJOR STREET AT A TWSC INTERSECTION

IMPEDANCE EFFECTS OF LEFT TURNERS FROM THE MAJOR STREET AT A TWSC INTERSECTION 09-1289 Citation: Brilon, W. (2009): Impedane Effets of Left Turners from the Major Street at A TWSC Intersetion. Transportation Researh Reord Nr. 2130, pp. 2-8 IMPEDANCE EFFECTS OF LEFT TURNERS FROM THE

More information

max min z i i=1 x j k s.t. j=1 x j j:i T j

max min z i i=1 x j k s.t. j=1 x j j:i T j AM 221: Advaned Optimization Spring 2016 Prof. Yaron Singer Leture 22 April 18th 1 Overview In this leture, we will study the pipage rounding tehnique whih is a deterministi rounding proedure that an be

More information

Math 151 Introduction to Eigenvectors

Math 151 Introduction to Eigenvectors Math 151 Introdution to Eigenvetors The motivating example we used to desrie matrixes was landsape hange and vegetation suession. We hose the simple example of Bare Soil (B), eing replaed y Grasses (G)

More information

Aharonov-Bohm effect. Dan Solomon.

Aharonov-Bohm effect. Dan Solomon. Aharonov-Bohm effet. Dan Solomon. In the figure the magneti field is onfined to a solenoid of radius r 0 and is direted in the z- diretion, out of the paper. The solenoid is surrounded by a barrier that

More information

McCreight s Suffix Tree Construction Algorithm. Milko Izamski B.Sc. Informatics Instructor: Barbara König

McCreight s Suffix Tree Construction Algorithm. Milko Izamski B.Sc. Informatics Instructor: Barbara König 1. Introution MCreight s Suffix Tree Constrution Algorithm Milko Izamski B.S. Informatis Instrutor: Barbara König The main goal of MCreight s algorithm is to buil a suffix tree in linear time. This is

More information

DIGITAL DISTANCE RELAYING SCHEME FOR PARALLEL TRANSMISSION LINES DURING INTER-CIRCUIT FAULTS

DIGITAL DISTANCE RELAYING SCHEME FOR PARALLEL TRANSMISSION LINES DURING INTER-CIRCUIT FAULTS CHAPTER 4 DIGITAL DISTANCE RELAYING SCHEME FOR PARALLEL TRANSMISSION LINES DURING INTER-CIRCUIT FAULTS 4.1 INTRODUCTION Around the world, environmental and ost onsiousness are foring utilities to install

More information

Lecture 3 - Lorentz Transformations

Lecture 3 - Lorentz Transformations Leture - Lorentz Transformations A Puzzle... Example A ruler is positioned perpendiular to a wall. A stik of length L flies by at speed v. It travels in front of the ruler, so that it obsures part of the

More information

c-perfect Hashing Schemes for Binary Trees, with Applications to Parallel Memories

c-perfect Hashing Schemes for Binary Trees, with Applications to Parallel Memories -Perfet Hashing Shemes for Binary Trees, with Appliations to Parallel Memories (Extended Abstrat Gennaro Cordaso 1, Alberto Negro 1, Vittorio Sarano 1, and Arnold L.Rosenberg 2 1 Dipartimento di Informatia

More information

Indian Institute of Technology Bombay. Department of Electrical Engineering. EE 325 Probability and Random Processes Lecture Notes 3 July 28, 2014

Indian Institute of Technology Bombay. Department of Electrical Engineering. EE 325 Probability and Random Processes Lecture Notes 3 July 28, 2014 Indian Institute of Tehnology Bombay Department of Eletrial Engineering Handout 5 EE 325 Probability and Random Proesses Leture Notes 3 July 28, 2014 1 Axiomati Probability We have learned some paradoxes

More information

Modal Horn Logics Have Interpolation

Modal Horn Logics Have Interpolation Modal Horn Logis Have Interpolation Marus Kraht Department of Linguistis, UCLA PO Box 951543 405 Hilgard Avenue Los Angeles, CA 90095-1543 USA kraht@humnet.ula.de Abstrat We shall show that the polymodal

More information

Announcements. Office Hours Swap: OH schedule has been updated to reflect this.

Announcements. Office Hours Swap: OH schedule has been updated to reflect this. SA Solving Announements Offie Hours Swap: Zavain has offie hours from 4-6PM toay in builing 460, room 040A. Rose has offie hours tonight from 7-9PM in Gates B26B. Keith has offie hours hursay from 2-4PM

More information

The Hanging Chain. John McCuan. January 19, 2006

The Hanging Chain. John McCuan. January 19, 2006 The Hanging Chain John MCuan January 19, 2006 1 Introdution We onsider a hain of length L attahed to two points (a, u a and (b, u b in the plane. It is assumed that the hain hangs in the plane under a

More information

Chapter 3 Church-Turing Thesis. CS 341: Foundations of CS II

Chapter 3 Church-Turing Thesis. CS 341: Foundations of CS II CS 341: Foundations of CS II Marvin K. Nakayama Computer Siene Department New Jersey Institute of Tehnology Newark, NJ 07102 CS 341: Chapter 3 3-2 Contents Turing Mahines Turing-reognizable Turing-deidable

More information

Synthesis of verifiably hazard-free asynchronous control circuits

Synthesis of verifiably hazard-free asynchronous control circuits Synthesis of verifiably hazardfree asynhronous ontrol iruits L. Lavagno Dept. of EECS University of California, Berkeley K. Keutzer AT&T Bell Laboratories Murray Hill, NJ November 9, 990 A. SangiovanniVinentelli

More information

Sequence Analysis, WS 14/15, D. Huson & R. Neher (this part by D. Huson & J. Fischer) January 21,

Sequence Analysis, WS 14/15, D. Huson & R. Neher (this part by D. Huson & J. Fischer) January 21, Sequene Analysis, WS 14/15, D. Huson & R. Neher (this part by D. Huson & J. Fisher) January 21, 201511 9 Suffix Trees and Suffix Arrays This leture is based on the following soures, whih are all reommended

More information

CMSC 451: Lecture 9 Greedy Approximation: Set Cover Thursday, Sep 28, 2017

CMSC 451: Lecture 9 Greedy Approximation: Set Cover Thursday, Sep 28, 2017 CMSC 451: Leture 9 Greedy Approximation: Set Cover Thursday, Sep 28, 2017 Reading: Chapt 11 of KT and Set 54 of DPV Set Cover: An important lass of optimization problems involves overing a ertain domain,

More information

Wavetech, LLC. Ultrafast Pulses and GVD. John O Hara Created: Dec. 6, 2013

Wavetech, LLC. Ultrafast Pulses and GVD. John O Hara Created: Dec. 6, 2013 Ultrafast Pulses and GVD John O Hara Created: De. 6, 3 Introdution This doument overs the basi onepts of group veloity dispersion (GVD) and ultrafast pulse propagation in an optial fiber. Neessarily, it

More information

15.12 Applications of Suffix Trees

15.12 Applications of Suffix Trees 248 Algorithms in Bioinformatis II, SoSe 07, ZBIT, D. Huson, May 14, 2007 15.12 Appliations of Suffix Trees 1. Searhing for exat patterns 2. Minimal unique substrings 3. Maximum unique mathes 4. Maximum

More information

UTC. Engineering 329. Proportional Controller Design. Speed System. John Beverly. Green Team. John Beverly Keith Skiles John Barker.

UTC. Engineering 329. Proportional Controller Design. Speed System. John Beverly. Green Team. John Beverly Keith Skiles John Barker. UTC Engineering 329 Proportional Controller Design for Speed System By John Beverly Green Team John Beverly Keith Skiles John Barker 24 Mar 2006 Introdution This experiment is intended test the variable

More information

Modes are solutions, of Maxwell s equation applied to a specific device.

Modes are solutions, of Maxwell s equation applied to a specific device. Mirowave Integrated Ciruits Prof. Jayanta Mukherjee Department of Eletrial Engineering Indian Institute of Tehnology, Bombay Mod 01, Le 06 Mirowave omponents Welome to another module of this NPTEL mok

More information

On the Licensing of Innovations under Strategic Delegation

On the Licensing of Innovations under Strategic Delegation On the Liensing of Innovations under Strategi Delegation Judy Hsu Institute of Finanial Management Nanhua University Taiwan and X. Henry Wang Department of Eonomis University of Missouri USA Abstrat This

More information

7 Max-Flow Problems. Business Computing and Operations Research 608

7 Max-Flow Problems. Business Computing and Operations Research 608 7 Max-Flow Problems Business Computing and Operations Researh 68 7. Max-Flow Problems In what follows, we onsider a somewhat modified problem onstellation Instead of osts of transmission, vetor now indiates

More information

In this case it might be instructive to present all three components of the current density:

In this case it might be instructive to present all three components of the current density: Momentum, on the other hand, presents us with a me ompliated ase sine we have to deal with a vetial quantity. The problem is simplified if we treat eah of the omponents of the vet independently. s you

More information

Particle-wave symmetry in Quantum Mechanics And Special Relativity Theory

Particle-wave symmetry in Quantum Mechanics And Special Relativity Theory Partile-wave symmetry in Quantum Mehanis And Speial Relativity Theory Author one: XiaoLin Li,Chongqing,China,hidebrain@hotmail.om Corresponding author: XiaoLin Li, Chongqing,China,hidebrain@hotmail.om

More information

The Concept of Mass as Interfering Photons, and the Originating Mechanism of Gravitation D.T. Froedge

The Concept of Mass as Interfering Photons, and the Originating Mechanism of Gravitation D.T. Froedge The Conept of Mass as Interfering Photons, and the Originating Mehanism of Gravitation D.T. Froedge V04 Formerly Auburn University Phys-dtfroedge@glasgow-ky.om Abstrat For most purposes in physis the onept

More information

Counting Idempotent Relations

Counting Idempotent Relations Counting Idempotent Relations Beriht-Nr. 2008-15 Florian Kammüller ISSN 1436-9915 2 Abstrat This artile introdues and motivates idempotent relations. It summarizes haraterizations of idempotents and their

More information

Searching All Approximate Covers and Their Distance using Finite Automata

Searching All Approximate Covers and Their Distance using Finite Automata Searhing All Approximate Covers and Their Distane using Finite Automata Ondřej Guth, Bořivoj Melihar, and Miroslav Balík České vysoké učení tehniké v Praze, Praha, CZ, {gutho1,melihar,alikm}@fel.vut.z

More information

A Queueing Model for Call Blending in Call Centers

A Queueing Model for Call Blending in Call Centers A Queueing Model for Call Blending in Call Centers Sandjai Bhulai and Ger Koole Vrije Universiteit Amsterdam Faulty of Sienes De Boelelaan 1081a 1081 HV Amsterdam The Netherlands E-mail: {sbhulai, koole}@s.vu.nl

More information

Structural Reconfiguration of Systems under Behavioral Adaptation

Structural Reconfiguration of Systems under Behavioral Adaptation Strutural Reonfiguration of Systems under Behavioral Adaptation Carlos Canal a, Javier Cámara b, Gwen Salaün a Department of Computer Siene, University of Málaga, Spain b Department of Informatis Engineering,

More information

Determination of the reaction order

Determination of the reaction order 5/7/07 A quote of the wee (or amel of the wee): Apply yourself. Get all the eduation you an, but then... do something. Don't just stand there, mae it happen. Lee Iaoa Physial Chemistry GTM/5 reation order

More information

Perturbation Analyses for the Cholesky Factorization with Backward Rounding Errors

Perturbation Analyses for the Cholesky Factorization with Backward Rounding Errors Perturbation Analyses for the holesky Fatorization with Bakward Rounding Errors Xiao-Wen hang Shool of omputer Siene, MGill University, Montreal, Quebe, anada, H3A A7 Abstrat. This paper gives perturbation

More information

Sensitivity Analysis in Markov Networks

Sensitivity Analysis in Markov Networks Sensitivity Analysis in Markov Networks Hei Chan and Adnan Darwihe Computer Siene Department University of California, Los Angeles Los Angeles, CA 90095 {hei,darwihe}@s.ula.edu Abstrat This paper explores

More information

MOLECULAR ORBITAL THEORY- PART I

MOLECULAR ORBITAL THEORY- PART I 5.6 Physial Chemistry Leture #24-25 MOLECULAR ORBITAL THEORY- PART I At this point, we have nearly ompleted our rash-ourse introdution to quantum mehanis and we re finally ready to deal with moleules.

More information

Sensor management for PRF selection in the track-before-detect context

Sensor management for PRF selection in the track-before-detect context Sensor management for PRF seletion in the tra-before-detet ontext Fotios Katsilieris, Yvo Boers, and Hans Driessen Thales Nederland B.V. Haasbergerstraat 49, 7554 PA Hengelo, the Netherlands Email: {Fotios.Katsilieris,

More information

Relativistic Addition of Velocities *

Relativistic Addition of Velocities * OpenStax-CNX module: m42540 1 Relativisti Addition of Veloities * OpenStax This work is produed by OpenStax-CNX and liensed under the Creative Commons Attribution Liense 3.0 Abstrat Calulate relativisti

More information

A Logic of Local Graph Shapes

A Logic of Local Graph Shapes CTIT Tehnial Report TR CTIT 03 35, University of Twente, 2003 A Logi of Loal Graph Shapes Arend Rensink Department of Computer Siene, University of Twente P.O.Box 27, 7500 AE, The Netherlands rensink@s.utwente.nl

More information

Control Theory association of mathematics and engineering

Control Theory association of mathematics and engineering Control Theory assoiation of mathematis and engineering Wojieh Mitkowski Krzysztof Oprzedkiewiz Department of Automatis AGH Univ. of Siene & Tehnology, Craow, Poland, Abstrat In this paper a methodology

More information

Q2. [40 points] Bishop-Hill Model: Calculation of Taylor Factors for Multiple Slip

Q2. [40 points] Bishop-Hill Model: Calculation of Taylor Factors for Multiple Slip 27-750, A.D. Rollett Due: 20 th Ot., 2011. Homework 5, Volume Frations, Single and Multiple Slip Crystal Plastiity Note the 2 extra redit questions (at the end). Q1. [40 points] Single Slip: Calulating

More information

Case I: 2 users In case of 2 users, the probability of error for user 1 was earlier derived to be 2 A1

Case I: 2 users In case of 2 users, the probability of error for user 1 was earlier derived to be 2 A1 MUTLIUSER DETECTION (Letures 9 and 0) 6:33:546 Wireless Communiations Tehnologies Instrutor: Dr. Narayan Mandayam Summary By Shweta Shrivastava (shwetash@winlab.rutgers.edu) bstrat This artile ontinues

More information

On the Bit Error Probability of Noisy Channel Networks With Intermediate Node Encoding I. INTRODUCTION

On the Bit Error Probability of Noisy Channel Networks With Intermediate Node Encoding I. INTRODUCTION 5188 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 54, NO. 11, NOVEMBER 2008 [8] A. P. Dempster, N. M. Laird, and D. B. Rubin, Maximum likelihood estimation from inomplete data via the EM algorithm, J.

More information

Fair Integrated Scheduling of Soft Real-time Tardiness Classes on Multiprocessors

Fair Integrated Scheduling of Soft Real-time Tardiness Classes on Multiprocessors Fair Integrated Sheduling of Soft Real-time Tardiness Classes on Multiproessors UmaMaheswari C. Devi and James H. Anderson Department of Computer Siene, The University of North Carolina, Chapel Hill, NC

More information

LECTURE NOTES FOR , FALL 2004

LECTURE NOTES FOR , FALL 2004 LECTURE NOTES FOR 18.155, FALL 2004 83 12. Cone support and wavefront set In disussing the singular support of a tempered distibution above, notie that singsupp(u) = only implies that u C (R n ), not as

More information

Developing Excel Macros for Solving Heat Diffusion Problems

Developing Excel Macros for Solving Heat Diffusion Problems Session 50 Developing Exel Maros for Solving Heat Diffusion Problems N. N. Sarker and M. A. Ketkar Department of Engineering Tehnology Prairie View A&M University Prairie View, TX 77446 Abstrat This paper

More information

Measuring & Inducing Neural Activity Using Extracellular Fields I: Inverse systems approach

Measuring & Inducing Neural Activity Using Extracellular Fields I: Inverse systems approach Measuring & Induing Neural Ativity Using Extraellular Fields I: Inverse systems approah Keith Dillon Department of Eletrial and Computer Engineering University of California San Diego 9500 Gilman Dr. La

More information

Lecture 7: Sampling/Projections for Least-squares Approximation, Cont. 7 Sampling/Projections for Least-squares Approximation, Cont.

Lecture 7: Sampling/Projections for Least-squares Approximation, Cont. 7 Sampling/Projections for Least-squares Approximation, Cont. Stat60/CS94: Randomized Algorithms for Matries and Data Leture 7-09/5/013 Leture 7: Sampling/Projetions for Least-squares Approximation, Cont. Leturer: Mihael Mahoney Sribe: Mihael Mahoney Warning: these

More information

SOA/CAS MAY 2003 COURSE 1 EXAM SOLUTIONS

SOA/CAS MAY 2003 COURSE 1 EXAM SOLUTIONS SOA/CAS MAY 2003 COURSE 1 EXAM SOLUTIONS Prepared by S. Broverman e-mail 2brove@rogers.om website http://members.rogers.om/2brove 1. We identify the following events:. - wathed gymnastis, ) - wathed baseball,

More information

Hankel Optimal Model Order Reduction 1

Hankel Optimal Model Order Reduction 1 Massahusetts Institute of Tehnology Department of Eletrial Engineering and Computer Siene 6.245: MULTIVARIABLE CONTROL SYSTEMS by A. Megretski Hankel Optimal Model Order Redution 1 This leture overs both

More information

EE 321 Project Spring 2018

EE 321 Project Spring 2018 EE 21 Projet Spring 2018 This ourse projet is intended to be an individual effort projet. The student is required to omplete the work individually, without help from anyone else. (The student may, however,

More information

Singular Event Detection

Singular Event Detection Singular Event Detetion Rafael S. Garía Eletrial Engineering University of Puerto Rio at Mayagüez Rafael.Garia@ee.uprm.edu Faulty Mentor: S. Shankar Sastry Researh Supervisor: Jonathan Sprinkle Graduate

More information

Generalized Dimensional Analysis

Generalized Dimensional Analysis #HUTP-92/A036 7/92 Generalized Dimensional Analysis arxiv:hep-ph/9207278v1 31 Jul 1992 Howard Georgi Lyman Laboratory of Physis Harvard University Cambridge, MA 02138 Abstrat I desribe a version of so-alled

More information

3 Tidal systems modelling: ASMITA model

3 Tidal systems modelling: ASMITA model 3 Tidal systems modelling: ASMITA model 3.1 Introdution For many pratial appliations, simulation and predition of oastal behaviour (morphologial development of shorefae, beahes and dunes) at a ertain level

More information

A Functional Representation of Fuzzy Preferences

A Functional Representation of Fuzzy Preferences Theoretial Eonomis Letters, 017, 7, 13- http://wwwsirporg/journal/tel ISSN Online: 16-086 ISSN Print: 16-078 A Funtional Representation of Fuzzy Preferenes Susheng Wang Department of Eonomis, Hong Kong

More information

Concerning the Numbers 22p + 1, p Prime

Concerning the Numbers 22p + 1, p Prime Conerning the Numbers 22p + 1, p Prime By John Brillhart 1. Introdution. In a reent investigation [7] the problem of fatoring numbers of the form 22p + 1, p a, was enountered. Sine 22p + 1 = (2P - 2*

More information

Time and Energy, Inertia and Gravity

Time and Energy, Inertia and Gravity Time and Energy, Inertia and Gravity The Relationship between Time, Aeleration, and Veloity and its Affet on Energy, and the Relationship between Inertia and Gravity Copyright 00 Joseph A. Rybzyk Abstrat

More information

The gravitational phenomena without the curved spacetime

The gravitational phenomena without the curved spacetime The gravitational phenomena without the urved spaetime Mirosław J. Kubiak Abstrat: In this paper was presented a desription of the gravitational phenomena in the new medium, different than the urved spaetime,

More information

Critical Reflections on the Hafele and Keating Experiment

Critical Reflections on the Hafele and Keating Experiment Critial Refletions on the Hafele and Keating Experiment W.Nawrot In 1971 Hafele and Keating performed their famous experiment whih onfirmed the time dilation predited by SRT by use of marosopi loks. As

More information

Reliability Guaranteed Energy-Aware Frame-Based Task Set Execution Strategy for Hard Real-Time Systems

Reliability Guaranteed Energy-Aware Frame-Based Task Set Execution Strategy for Hard Real-Time Systems Reliability Guaranteed Energy-Aware Frame-Based ask Set Exeution Strategy for Hard Real-ime Systems Zheng Li a, Li Wang a, Shuhui Li a, Shangping Ren a, Gang Quan b a Illinois Institute of ehnology, Chiago,

More information

Physical Laws, Absolutes, Relative Absolutes and Relativistic Time Phenomena

Physical Laws, Absolutes, Relative Absolutes and Relativistic Time Phenomena Page 1 of 10 Physial Laws, Absolutes, Relative Absolutes and Relativisti Time Phenomena Antonio Ruggeri modexp@iafria.om Sine in the field of knowledge we deal with absolutes, there are absolute laws that

More information

Average Rate Speed Scaling

Average Rate Speed Scaling Average Rate Speed Saling Nikhil Bansal David P. Bunde Ho-Leung Chan Kirk Pruhs May 2, 2008 Abstrat Speed saling is a power management tehnique that involves dynamially hanging the speed of a proessor.

More information

Likelihood-confidence intervals for quantiles in Extreme Value Distributions

Likelihood-confidence intervals for quantiles in Extreme Value Distributions Likelihood-onfidene intervals for quantiles in Extreme Value Distributions A. Bolívar, E. Díaz-Franés, J. Ortega, and E. Vilhis. Centro de Investigaión en Matemátias; A.P. 42, Guanajuato, Gto. 36; Méxio

More information

Word of Mass: The Relationship between Mass Media and Word-of-Mouth

Word of Mass: The Relationship between Mass Media and Word-of-Mouth Word of Mass: The Relationship between Mass Media and Word-of-Mouth Roman Chuhay Preliminary version Marh 6, 015 Abstrat This paper studies the optimal priing and advertising strategies of a firm in the

More information

On Component Order Edge Reliability and the Existence of Uniformly Most Reliable Unicycles

On Component Order Edge Reliability and the Existence of Uniformly Most Reliable Unicycles Daniel Gross, Lakshmi Iswara, L. William Kazmierzak, Kristi Luttrell, John T. Saoman, Charles Suffel On Component Order Edge Reliability and the Existene of Uniformly Most Reliable Uniyles DANIEL GROSS

More information

An Integrated Architecture of Adaptive Neural Network Control for Dynamic Systems

An Integrated Architecture of Adaptive Neural Network Control for Dynamic Systems An Integrated Arhiteture of Adaptive Neural Network Control for Dynami Systems Robert L. Tokar 2 Brian D.MVey2 'Center for Nonlinear Studies, 2Applied Theoretial Physis Division Los Alamos National Laboratory,

More information

An I-Vector Backend for Speaker Verification

An I-Vector Backend for Speaker Verification An I-Vetor Bakend for Speaker Verifiation Patrik Kenny, 1 Themos Stafylakis, 1 Jahangir Alam, 1 and Marel Kokmann 2 1 CRIM, Canada, {patrik.kenny, themos.stafylakis, jahangir.alam}@rim.a 2 VoieTrust, Canada,

More information

Chapter 2 Linear Elastic Fracture Mechanics

Chapter 2 Linear Elastic Fracture Mechanics Chapter 2 Linear Elasti Frature Mehanis 2.1 Introdution Beginning with the fabriation of stone-age axes, instint and experiene about the strength of various materials (as well as appearane, ost, availability

More information

Model-based mixture discriminant analysis an experimental study

Model-based mixture discriminant analysis an experimental study Model-based mixture disriminant analysis an experimental study Zohar Halbe and Mayer Aladjem Department of Eletrial and Computer Engineering, Ben-Gurion University of the Negev P.O.Box 653, Beer-Sheva,

More information

Modeling Probabilistic Measurement Correlations for Problem Determination in Large-Scale Distributed Systems

Modeling Probabilistic Measurement Correlations for Problem Determination in Large-Scale Distributed Systems 009 9th IEEE International Conferene on Distributed Computing Systems Modeling Probabilisti Measurement Correlations for Problem Determination in Large-Sale Distributed Systems Jing Gao Guofei Jiang Haifeng

More information

COMBINED PROBE FOR MACH NUMBER, TEMPERATURE AND INCIDENCE INDICATION

COMBINED PROBE FOR MACH NUMBER, TEMPERATURE AND INCIDENCE INDICATION 4 TH INTERNATIONAL CONGRESS OF THE AERONAUTICAL SCIENCES COMBINED PROBE FOR MACH NUMBER, TEMPERATURE AND INCIDENCE INDICATION Jiri Nozika*, Josef Adame*, Daniel Hanus** *Department of Fluid Dynamis and

More information

Canimals. borrowed, with thanks, from Malaspina University College/Kwantlen University College

Canimals. borrowed, with thanks, from Malaspina University College/Kwantlen University College Canimals borrowed, with thanks, from Malaspina University College/Kwantlen University College http://ommons.wikimedia.org/wiki/file:ursus_maritimus_steve_amstrup.jpg Purpose Investigate the rate of heat

More information

arxiv:math/ v1 [math.ca] 27 Nov 2003

arxiv:math/ v1 [math.ca] 27 Nov 2003 arxiv:math/011510v1 [math.ca] 27 Nov 200 Counting Integral Lamé Equations by Means of Dessins d Enfants Sander Dahmen November 27, 200 Abstrat We obtain an expliit formula for the number of Lamé equations

More information

Bäcklund Transformations: Some Old and New Perspectives

Bäcklund Transformations: Some Old and New Perspectives Bäklund Transformations: Some Old and New Perspetives C. J. Papahristou *, A. N. Magoulas ** * Department of Physial Sienes, Helleni Naval Aademy, Piraeus 18539, Greee E-mail: papahristou@snd.edu.gr **

More information

Exploring the feasibility of on-site earthquake early warning using close-in records of the 2007 Noto Hanto earthquake

Exploring the feasibility of on-site earthquake early warning using close-in records of the 2007 Noto Hanto earthquake Exploring the feasibility of on-site earthquake early warning using lose-in reords of the 2007 Noto Hanto earthquake Yih-Min Wu 1 and Hiroo Kanamori 2 1. Department of Geosienes, National Taiwan University,

More information

Probabilistic Graphical Models

Probabilistic Graphical Models Probabilisti Graphial Models David Sontag New York University Leture 12, April 19, 2012 Aknowledgement: Partially based on slides by Eri Xing at CMU and Andrew MCallum at UMass Amherst David Sontag (NYU)

More information

Chapter 2. Conditional Probability

Chapter 2. Conditional Probability Chapter. Conditional Probability The probabilities assigned to various events depend on what is known about the experimental situation when the assignment is made. For a partiular event A, we have used

More information

4 Puck s action plane fracture criteria

4 Puck s action plane fracture criteria 4 Puk s ation plane frature riteria 4. Fiber frature riteria Fiber frature is primarily aused by a stressing σ whih ats parallel to the fibers. For (σ, σ, τ )-ombinations the use of a simple maximum stress

More information

When p = 1, the solution is indeterminate, but we get the correct answer in the limit.

When p = 1, the solution is indeterminate, but we get the correct answer in the limit. The Mathematia Journal Gambler s Ruin and First Passage Time Jan Vrbik We investigate the lassial problem of a gambler repeatedly betting $1 on the flip of a potentially biased oin until he either loses

More information

THE METHOD OF SECTIONING WITH APPLICATION TO SIMULATION, by Danie 1 Brent ~~uffman'i

THE METHOD OF SECTIONING WITH APPLICATION TO SIMULATION, by Danie 1 Brent ~~uffman'i THE METHOD OF SECTIONING '\ WITH APPLICATION TO SIMULATION, I by Danie 1 Brent ~~uffman'i Thesis submitted to the Graduate Faulty of the Virginia Polytehni Institute and State University in partial fulfillment

More information

Optimization of Statistical Decisions for Age Replacement Problems via a New Pivotal Quantity Averaging Approach

Optimization of Statistical Decisions for Age Replacement Problems via a New Pivotal Quantity Averaging Approach Amerian Journal of heoretial and Applied tatistis 6; 5(-): -8 Published online January 7, 6 (http://www.sienepublishinggroup.om/j/ajtas) doi:.648/j.ajtas.s.65.4 IN: 36-8999 (Print); IN: 36-96 (Online)

More information