Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Bo Jacoby
Michal D. wrote:  "I'm not sure why to prefer doubling an entire array as opposed to dividing a single scalar?" Doubling an integer provides an integer, while division transcends the realm of integers. That's why. - Bo -- For

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Linda Alvord
H.]ere are Raul's two definitions, f and g and an explicit definition h which is turned to tacit. n=:2 d=:3 n(f=:4 : 'x>+:(?]) x#y')d 1 0 0 0 1 0 5!:4 <'f' -- 4 -- : -+- ,:'x>+:(?]) x#y' n(g=:[>[:+:[:(?])#)d 0 1 0 1 0 0 5!:4 <'g' -- [ +

Re: [Jprogramming] 3 :'y`:6 y' 3 :'y`:6 y'`''

2012-11-04 Thread Raul Miller
If J is operating correctly, you should get a stack error. If J implemented tail recursion this stack error would instead be an infinite loop (but one that you could break out of). -- Raul On Sat, Nov 3, 2012 at 11:37 PM, Linda Alvord wrote: >3 :'y`:6 > y' 3 :'y`:6 y'`'' >

Re: [Jprogramming] Taylor coefficients dyad

2012-11-04 Thread Raul Miller
http://www.jsoftware.com/help/dictionary/dtdotu.htm http://www.jsoftware.com/help/dictionary/dtdotm.htm FYI, -- Raul On Sun, Nov 4, 2012 at 1:31 AM, Linda Alvord wrote: > You explain what ^t. does, but what does t. do? > > t. i.6 > |syntax error > | t.i. >1 t. i.6 > |length

Re: [Jprogramming] 3 :'y`:6 y' 3 :'y`:6 y'`''

2012-11-04 Thread Brian Schott
On my Mac with Lion 10.7.3 in the terrminal jconsole I get the following. I don't know the interpretation of Segmentation fault #11. server:~ brian$ /Users/brian/j64-701/bin/jconsole ; exit; 9!:12'' 5 9!:14'' j701/2011-01-10/11:25 build: Feb 6 2011 16:16:29 3 :'y`:6 y' 3 :'y`:6 y'`'' S

[Jprogramming] t.

2012-11-04 Thread David Ward Lambert
"But what does t. do?" Use the dictionary. t. is an adverb. The dictionary heading on the page says u t. 0 0 0 This means (and it took me 2 years before I understood how to read dictionary headings. I learned a lot of j via the "parts of speech" dictionary access page) The verb formed by u

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
In A=. 0= ? (2$n)$2 NB. generate random matrix of [0,1] The 0= is unnecessary, and probably reflects a habit based on the false idea that boolean algebra is does not have an integer domain. Boolean rings have (subset of) integer domains, and [even after redefinition] boolean algebra is a

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Devon McCormick
> I take it that picking # over $ is a purely stylistic preference. "#" returns a scalar and "$" returns a vector. Each of these applied monadically to a vector will give the same number but applied to anything of lower or higher dimension will return different answers entirely. 'a';'few';'wo

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Mike Day
As far as I can understand the "revise" verb, you don't need the adjacency matrix a, although it does help to have a 2-column matrix of index pairs. I think Raul has overlooked your use of the right argument ys within that verb, though he's right about selecting with it. Here's a derivation

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
On Sun, Nov 4, 2012 at 12:53 PM, Mike Day wrote: > I think Raul has overlooked your use of the right argument ys within that > verb, ... You are right, I had not even tried to read 'revise'. Looking at it now, it has a signature: NB.* '(A;a;http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
Actually... ac is a wrapper for revise, which supplies a value for ys (which is the same thing as xs) which initially takes the value i.#D which is i.n but this changes over time... I need to think about this pattern. But for the moment, since the right argument to revise is a pair, and it's used

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread R.E. Boss
Your ($#: I.@,) can be replaced: ((4$. $.) -: $#: I.@,) 4 5$ 0 1 0 1 R.E. Boss > -Oorspronkelijk bericht- > Van: programming-boun...@forums.jsoftware.com > [mailto:programming-boun...@forums.jsoftware.com] Namens Mike Day > Verzonden: zondag 4 november 2012 18:53 > Aan: programm.

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
In revise, you are using a pair for your right argument. It looks to me like this might be unnecessary -- that you could use ys=. I.+./"1 D But this does not exactly reproduce your algorithm. So if this change breaks your algorithm, could you find an example situation which illustrates this issu

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
I'm blathering a lot here, sorry about that, but I found a case, now I just need to understand it: A=: (|:++:) #:0 8 4 4 C=: (a:,];|:) #:0 6 11 1 D=: #:9 0 0 4 Now to see if I can understand what's happening here... I will try to refrain from posting my incomplete thoughts -- I'll try to come ba

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
Hi Linda, Thanks for your input. I've added: NB. boxed display for non-nouns. 9!:3 (2) to my startup script so that lets me leave the parsing up to J which I'm still taking advantage of quite a bit. I take it that's for the most part what you're trying to show me in addition to the clever use

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
So maybe the best solution, at least from a performance perspective, is (<. -: n). On Sun, Nov 4, 2012 at 12:01 AM, Bo Jacoby wrote: > Michal D. wrote: "I'm not sure why to > prefer doubling an entire array as opposed to dividing a single scalar?" > > Doubling an integer provides an integer, w

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
Unfortunately, I do not know what "works" means. Maybe if this was wired up to a sudoku solver, I could see it in action -- I know how to test a sudoku solution for correctness. Anyways, here's the case I am struggling with right now: A=: (|:++:) #:0 8 4 4 C=: (a:,];|:) #:0 6 11 1 D=: #

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
It's a little hard for me to catch up with the flurry of messages, but I am trying =) I'm also on Vancouver time so I'm guessing you guys had a head start. Good ideas, thank you: removing 0= adj=: < @ I. @: * Devon for elaboration of differences b/w # and $. The domain of the left argument of ar

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
The adjacency matrix A is important because it tells us which constraint to look up in C. This also explains why the lower diagonal is doubled. For example, take the less than constraint: c =: |: (i.n) wrote: > As far as I can understand the "revise" verb, you don't need the > adjacency ma

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
On Sun, Nov 4, 2012 at 3:25 PM, Michal D. wrote: > (0 1 4). I follow the argument for (arcs=: $ #: I.@) but my J is slow. We > would have to be able to select an or of equals for example select from first > column where the value is 0 or 1 or 4. Here's select the rows of Y where number in the f

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
I think I am having a problem envisioning how a sudoku-style puzzle can work with a relationship which is not commutative, and I am also having a problem having to do with the transitive character of the relationship. As you have put it: "(note: constraints are not symmetric, for example x wro

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
The solver can solve sudoku puzzles (hopefully =)) but it should also be able to handle more general csp instances where the constraints are not symmetric. In the case of a sudoku puzzle, I think a single symmetric not-equal constraint would suffice. n=: 81 d=: 9 ] C=: a: , < (i.d) ~:/

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
On Sun, Nov 4, 2012 at 4:47 PM, Michal D. wrote: > The solver can solve sudoku puzzles (hopefully =)) but it should also be > able to handle more general csp instances where the constraints are not > symmetric. In the case of a sudoku puzzle, I think a single symmetric > not-equal constraint woul

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
On Sun, Nov 4, 2012 at 5:17 PM, I wrote: > Here's a brute force implementation of A for sudoku: > >C=: |: R=: ,9#,:i.9 NB. identity within columns (C) and rows (R) >B=: ,3#3#"1 i.3 3 NB. identity within boxes >A=: ((2*>/~i.81)+/~i.81)+http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
> Here's a brute force implementation of A for sudoku: > >C=: |: R=: ,9#,:i.9 NB. identity within columns (C) and rows (R) >B=: ,3#3#"1 i.3 3 NB. identity within boxes >A=: ((2*>/~i.81)+ > I left the extraneous right-most set of parenthesis in place because I > liked the rhythm. > Nice

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
On Sun, Nov 4, 2012 at 5:32 PM, Michal D. wrote: >> If D were instead a list of 81 by 9 bits, with extra copies of D being >> introduced as necessary, the "multiple answer" case could be addressed >> by having an extra item in D for every valid solution. Here, the >> initial D would have shape 1

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
> As far as I can understand the "revise" verb, you don't need the > adjacency matrix a, although it does help to have a 2-column matrix of > index pairs. > > I think Raul has overlooked your use of the right argument ys within that > verb, though he's right about selecting with it. Here's a deri

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
Arc consistency by itself will only be able to solve easy sudoku puzzles. To solve any puzzle, the search component is needed which does not currently exist. Ok, but I am still stuck on making sure I understand what "arc > consistent" means. > http://en.wikipedia.org/wiki/Local_consistency#Arc_c

[Jprogramming] i. :. (i. :. +) ^:_1 ^:_1

2012-11-04 Thread Henry Rich
i. :. (i. :. +) ^:_1 ^:_1 ]5 0 1 2 3 4 The obverse of i. :. (i. :. +) should be (i. :. +), and the obverse of that should be + . I think. But it isn't. Henry Rich -- For information about J forums see http://www.jsoftware.c

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Mike Day
Good one! I tend to overlook sparse arrays as I seem to encounter nonce errors when trying to use them for real. Mike On 04/11/2012 7:03 PM, R.E. Boss wrote: Your ($#: I.@,) can be replaced: ((4$. $.) -: $#: I.@,) 4 5$ 0 1 0 1 R.E. Boss -Oorspronkelijk bericht- Van: progr

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Mike Day
Hello, Michal D - Mike Day here! Sorry, I meant your lower case "a", the boxed array of to-nodes, derived from upper case "A" which IS the adjacency matrix, which is of course essential. "revise" need not be provided with a as well as A, and can make do with the 2-column matrix of node-pai

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
On Sun, Nov 4, 2012 at 6:29 PM, Michal D. wrote: >> for all w in Dy there exists a v in Dx such that the relationship v >> compare w is true. >> >> Does this sound right? >> > Yes, that sounds right so long as compare implies looking up the values in > the correct constraint table. Your formulatio

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
Haha, hello Mike D! I figured you were talking about "a". I think I followed the 2-column matrix of node-pairs conversation for the most part, except for RE Boss's contribution which I didn't appreciate until just now. The -: initially threw me off so I thought the whole expression was replaced

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
On Sun, Nov 4, 2012 at 9:46 PM, Michal D. wrote: > to J, it would be nice to use more primitive operations. Why the dislike > for "a"? I'm guessing it's a stab at removing some of the code? Passing the same data, multiple ways, to J function is something of a "bad code smell". Sometimes it's

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
> > > I had somehow gotten a different idea of consistency: > for all w in Dy for all v in Dx the relationship v compare w is true > Ah, ok, that's a little bit too strong (it might remove values that can participate in a solution). I should have said: for all w in Dy, there exists v in Dx su

Re: [Jprogramming] i. :. (i. :. +) ^:_1 ^:_1

2012-11-04 Thread km
Henry, what do you make of i. :. (i. :. +) b. _1 i. :.+ :.i. ? Kip Murray Sent from my iPad On Nov 4, 2012, at 5:45 PM, Henry Rich wrote: > i. :. (i. :. +) ^:_1 ^:_1 ]5 > 0 1 2 3 4 > > The obverse of i. :. (i. :. +) should be (i. :. +), and > the obverse of that should be + . I think

Re: [Jprogramming] i. :. (i. :. +) ^:_1 ^:_1

2012-11-04 Thread Henry Rich
Yes, that seems wrong. It should be i. :.+ shouldn't it? Henry Rich On 11/4/2012 10:15 PM, km wrote: Henry, what do you make of i. :. (i. :. +) b. _1 i. :.+ :.i. ? Kip Murray Sent from my iPad On Nov 4, 2012, at 5:45 PM, Henry Rich wrote: i. :. (i. :. +) ^:_1 ^:_1 ]5 0 1 2 3

Re: [Jprogramming] i. :. (i. :. +) ^:_1 ^:_1

2012-11-04 Thread Marshall Lochbaum
My inclination is that it is correct in enforcing that the obverse of the obverse is the original function. I'm open to good reasons why this isn't always the case, but I think if you need to break this rule, then what you're looking for probably isn't the obverse. Using &. in this case will just c

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Raul Miller
On Sun, Nov 4, 2012 at 10:00 PM, Michal D. wrote: >> A tricky part seems to be that the upper triangle of A corresponds to >> the forward direction in C (the bit in D that selects a row in A is >> also selecting a row in C) while the lower triangle of A corresponds >> to the reverse direction in C

Re: [Jprogramming] Arc consistency in J

2012-11-04 Thread Michal D.
> >> variables. In other words, if we specify the constraint x < y it > >> looks like either x1 < x2 or x2 < x1 is sufficient to satisfy arc > >> consistency. In other words, i think we should always use the > >> symmetric closure of the constraint. > > > >> Does this sound valid to you? > > > >

Re: [Jprogramming] i. :. (i. :. +) ^:_1 ^:_1

2012-11-04 Thread km
It appears the obverse of u :. v is v :. u and not simply v . This explains the behavior Henry saw. Kip Murray Sent from my iPad On Nov 4, 2012, at 9:33 PM, Marshall Lochbaum wrote: > My inclination is that it is correct in enforcing that the obverse of > the obverse is the original functio