« first day (209 days earlier)      last day (2057 days later) » 

4:09 AM
@Fatalize If empty strings are allowed then why doesn't it extend to infinity?
Inconsistent behaviour
 
4:26 AM
How to reverse predicate names, i.e. what is the reverse of 2&?
Never mind
Why doesn't this terminate? Remove the ,.h'0 and it terminates
 
5:09 AM
You might want to add some constraints to modulo so that it doesn't go on forever

(e.g. finding solutions of 81:x%2)
for example (in Brachylog syntax): A:B%C,A:BohM,0<=C<m
actually, since idk whether A:BohM does not backtrack indefinitely:
A:B%C,0<=C<=A should work
negative modulo though
Nope, B is still not constrained
A:B%C,0<=C<=A,0<=C<B,{A<B,AC} (I have no idea how to do pred1 and (pred2->pred3)
oh wait... A:B%C,A:C-$ps*B
http://brachylog.tryitonline.net/#code=MWdmLgpBODEsQzEsQTpCJUMsQTpDLSRwcypCLEIuLC49&input=&args=Wg

works but with duplicates
 
6:05 AM
http://brachylog.tryitonline.net/#code=MWdmLgpBODEsQzEsQTpCJUMsMDw9Qzw9QSwwPD1DPEIsKEE-QyxBOkMtPj1CPjApLEIuLC49&input=&args=Wg

this is much better
 
6:25 AM
So basically:
if A and C are fixed:
if A<C: return false
if A==C: return all B>A
if A>C: set 0<B<=A-C, find all A%B == C
basically there are infinitely many solutions if A==C
 
6:50 AM
if B and C are fixed:
please, just return all N*B+C
 
 
2 hours later…
8:54 AM
if A and B are fixed:
come on
 
 
1 hour later…
9:56 AM
@LeakyNun Here?
 
@Fatalize yes
 
I kind of glanced at your posts this morning because I don't really have much time right now
 
Alright
So summary:
1. reversed concatenation (~c) yields empty strings, but not indefinitely
2. please fix modulo
that's all
@Fatalize
 
@LeakyNun Noted
I think it limits itself to the number of chars of the string
 
Which is completely arbitrary
brachylog_concatenate_limit_length(Max,H) :-
    Length #>= 0,
    Length #=< Max,
    indomain(Length),
brachylog_length(H,'integer':Length).
 
10:05 AM
well not quite, after that point all bigger sets will only be bigger because of empty strings
 
so either make it infinite with empty strings or finite without empty strings
 
the problem is things like this
if I prevent empty strings then you would only get b
which I guess still makes sense but can be a bit annoying
 
@Fatalize which makes sense
then why limit itself to the length
 
@LeakyNun What's even the problem with it?
 
@Fatalize Solving 81:.%1 backtracks indefinitely
I detailed my solution above
Why doesn't this work?
 
11:12 AM
@LeakyNun $p doesn't work when its input is a free variable, might be fixable
 
@Fatalize I see, thanks
http://brachylog.tryitonline.net/#code=fisuIyMjZDp7MXwkcGR0Mjw9P31h&input=Mw&args=Wg
Indefinite backtracking again
Somehow indefinite backtracking is the biggest problem in declarative languages
 
infinite*
what's it trying to do?
 
come up with a list of distinct powers of 2 which sums to the input
 
11:45 AM
Not quite sure why this fails infinitely on the +, the constraints in the debugger seem like it should succeed
 
@Fatalize How do you detect and do things based on which variable is free?
in Prolog I mean
 
12:03 PM
@LeakyNun If you code your relations well it shouldn't matter if they are free or not
obviously it's not always possible, so in that case there is var and nonvar to know that
 
So could you implement modulo as I have stated above?
 
brachylog_modulo(['integer':I1,'integer':I2],'integer':Rem) :-
Rem #= I1 mod I2.
There shouldn't be a problem with it because it's basic CLPFD…
so the problem might come from elsewhere
 
I saw the code
Does 1 #= 81 mod X backtrack infinitely?
 
?- 1 #= 81 mod X.
X in inf.. -1\/1..sup,
81 mod X#=1.
X's domain is infinite
 
exactly
So please implement what I described
 
12:11 PM
?- 1 #= 81 mod X, brachylog_equals(integer:X,integer:X).
X = 2 ;
X = 4 ;
X = 5 ;
X = 8 ;
X = 10 ;
X = 16 ;
X = 20 ;
X = 40 ;
X = 80 ;
infinite loop
 
So please implement ce que je decrivais
 
Seems more to be a bug with CLPFD no?
1 #= 81 mod X.
X in inf.. -1\/1..sup,
81 mod X#=1.
 
So please fix this bug by implementing ce que je decrivais
 
Can't we say for sure that X domain is at least smaller in absolute value than 81?
we can can't we?
 
I haven't dealt with negative modulo yet
How is it defined?
X is just the factors of A-C where A%X=C
4%3 = 1
-4%3 = ?
4%-3 = ?
-4%-3 = ?
 
12:24 PM
?- 1 + X*K #= 81.
X in -80.. -1\/1..80,
X*K#=80,
K in -80.. -1\/1..80.
I think the problem is in how mod is defined in Prolog
 
How is it defined?
Also, can you help me find out how negative number is treated ?
 
-4 mod 3 = 2
because -4 = 3*-2 + 2
it's the same but you want a positive remainder
at least that's what it does in Prolog
 
So i think you can implement mod as:
mod(A,B,C):
A=B*K+C,0<=C<B
(completely shitty prolog grammar)
what about -4mod-3?
 
13 ?- X is -4 mod 3.
X = 2.

14 ?- X is 4 mod -3.
X = -2.

15 ?- X is -4 mod -3.
X = -1.
pretty stupid if you ask me
 
ok, so branch on the sign of B
 
12:31 PM
I'll ask a question on SO about that mod CLPFD propagation
 
I believe javascript also uses that format
 
we're lucky that the creator of SWI-Prolog's CLPFD seems pretty interested in Brachylog and is active on SO ; should get a quick answer
 
whaaaat
Can you invite them to this room?
 
I'd rather post a question on SO, more useful for others and I won't bother him if he doesn't have time :p
 
Alright
 
12:35 PM
I'm famous mom!
 
Damn, nice
 
0
Q: Modulo function and variable domain

FatalizeHere is a simple CLPFD relation: 1 #= 81 mod X. This returns: X in inf.. -1\/1..sup, 81 mod X#=1. Unless my math is completely incorrect, shouldn't the domain of X be -80.. -1\/1..80?

 
Have an upvote
So you're right, the range should be -80 to 80
that is if 81 > 1
 
I think so
I'm just unsure if a similar argument applies to any triplet
 
12:53 PM
Just refer to what I wrote above lol
 
1:18 PM
@Fatalize If you said que that format is ridiculous, what do you have in mind?
 
@LeakyNun What format?
 
@Fatalize what should -4%3 give?
 
2
 
1:33 PM
You said it is ridiculous
Wtf, in Prolog you can make strings without quotes?
 
they are atoms
in Prolog there is no difference between code and data
so reverse can be both a predicate name but also just a string of data
and so you can query data if it corresponds to code, or store code as data
 
2:03 PM
Alright
@Fatalize Can I implicitly declare functions in Prolog?
 
you mean arithmetic functions or predicates ?
you can do both
 
Could you give an example?
 
wait implicitely
not really then
 
Can I define f(x)=y such that x*x=y
Alright...
 
well sure
 
2:09 PM
How?
 
square(X,Y) :- Y is X*X.
 
Oh, nice
then what were you thinking about when you said "not really"?
 
square(X,Y) :- Y #= X*X.
if you have clpfd library loaded
well I don't really understand your "implicitely"
 
Or, in other words, what is not possible?
What did you think it means?
 
some sort of unnamed function
 
2:11 PM
Oh...
 
I mean you could but that would simply just be writing code normally so the questions didn't make sense to me
 
Can I define f(x) such that f(f(x))= -x?
 
a(a(X),-X).
that was easy :p
 
What is the arity of a?
You made it both 1 and 2
 
?- a(a(3),Z).
Z = - 3.
 
2:15 PM
I think you defined two functions...
 
a/2 and a/1 are different things anyway so it's not a problem that they don't have the same arity
 
Exactly
I want only one function
 
But I didn't even define a
that's the thing :P
it's kind of a trick because a/1 doesn't event exist here as a predicaet
 
Can I only use a/2?
 
the a(3) in a/2 is just a data construct
a(test(X),-X).
is basically the same thing
so that's a bit cheating in a sense, I think what you want is a(X,Temp),a(Temp,-X).
 
2:18 PM
Full stop in clause-body?  Cannot redefine ,/2

procedure `a(A,B)' does not exist
Reachable from:
	  swish_trace:swish_call(a(4,A))
	  '$swish wrapper'(a(4,A),B)
 
show your code
 
a(X,Temp),a(Temp,-X).
?- a(4,What).
 
a(X,Temp),a(Temp,-X).
that's not a valid fact
or rule
 
but I just typed what you said
 
what I'm saying is
your f(f(x),-x) in prolog
you would QUERY that as a(X,Temp), a(Temp,-X).
now you need to define what a/2 is
so that this actually holds
and I don't see how you actually can
(without cheating)
 
2:21 PM
@Fatalize define cheating
I thought you can implicitly define functions
implicitly meaning declaratively
 
sure but what relation exists such that a(X,Temp), a(Temp,-X). would be true?
 
implicitly meaning declaratively
@Fatalize I don't know, that's what I'm asking Prolog
a(X,Y):-
    a(Y,-X).
?- a(4,-4).
Out of global stack
 
well of course it stack overflows
your a/2 says "a(X,Y) is true iff a(Y,-X) is true"
which will infinite loop
 
Alright
Thanks
How do I use it such that it does not stackoverflow?
Like can I query a(a(4)) directly?
 
there are no functions in prolog
a(4) doesn't return anything so you can't use it as an argument to another predicate as you would expect in imperative languages
 
2:25 PM
@Fatalize You know what I mean
 
No I don't
 
Is there a way to query for a(4,Temp),a(Temp,What) without finding solutions for Temp
 
a(X,a:X):- \+ (X = a:_).
a(a:X,Y):- Y is -X.
THis is what I would call cheating
 
How does it work?
 
but outside Prolog, what relation is there such that f(f(x)) = -x?
I can't think of any
 
2:28 PM
Neither can I, that's why I'm using Prolog's declarativeness
 
I'm pretty sure it's impossible without going outside arithmetic
@LeakyNun It cheats by appending the a: before X, then when calling it again on a:X is will only work with the second line, yielding -X
 
@Fatalize Alright
Is there a way to query for a(4,Temp),a(Temp,What) without finding solutions for Temp?
What I mean is, just leave Temp undefined
 
Well yes, if a doesn't unifies Temp in the process
 
How to do so?
 
Prolog just give values to things when needed so if it's not needed it doesnt
I don't understand your goal
 
2:30 PM
a(4,Temp),a(Temp,What).
 
if you don't want Temp to get a value from a then it's most likely useless in a isn't it?
 
I just want to carry it to What
 
a(4,_Temp),a(_Temp,What)
 
Whaaaat
Nope
Out of global stack
 
I told you your a is wrong
doesn't matter what you call it on
 
2:32 PM
How do I make it right?
 
I don't understand
f(f(x)) = -x isn't possible so you can't make it right if you only use arithmetic
and if you don't I just gave you a solution
 
I want to define a relation a(X,Y) such that a(Y,-X)
 
…? that's simply a(X,Y) :- Y is -X.
 
@Fatalize no, that's a(X,-X)
 
I mean with your definition a is just negation
 
2:34 PM
if a(X,Y) then a(Y,X) under your definition
 
right nevermind
but then we're back to what I said
« cheat » or you can't
 
Alright
 
Prolog is about writing relations between things, if you can't think of a relation it's not magically gonna come up with it for you
 
Thanks
By the way, source
 
f(n) = sign(n) - (-1)n * n
well just code this then if this relation works
 
2:37 PM
Alright
@Fatalize That's integer to integer
 
@LeakyNun ?
a(X,Y) :- Y is sign(X) - (-1)^X * X.
 
I'm thinking of mapping the rationals to two integers
 
wat
Who I was thinking of answered
0
A: Modulo function and variable domain

matFirst things first: Is there a mistake in the constraint solver? No(t necessarily), because all admissible solutions are still contained in the domain that is deduced, and no wrong solutions are reported. The domain that you deduced is a proper subset of what the solver reports. Does th...

 
@Fatalize Just follow ce que je disais dans la commentaire lol
@Fatalize I just thought of a solution
so what follows from f@f@x = -x is that f has a cycle of 4 except for 0
 
2:55 PM
so?
 
So I can just construct cycles around the origin
(0,1] -> (1,2] -> (-0,-1] -> (-1,-2]
informally
 
(using parentheses for open intervals… ugh)
 
What do you use?
 
]0,1]
that's not the british way though obviously
 
Using inverted brackets for open intervals... ugh
How come nobody came up with this
 
2:58 PM
at least it's all brackets
 
at least they point to the right direction
 
]1,2[ you know what it is, (1,2) is not so clear
 
lol you win
 
because that could just be a tuple
anyway I have to go
Bye
 
Alright
 

« first day (209 days earlier)      last day (2057 days later) »