Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I thought I had it all figured out

Name: LISPPER 2012-12-31 8:27

But then this fucker had to post some Prolog code and I was mesmerized. Fuck. FUCK.

Name: Anonymous 2012-12-31 8:54

no

Name: Anonymous 2012-12-31 9:19

Blessed be the Theorem Prover, for He will never give up the pursuit of truth.


singleton(X,[X]).

Name: Anonymous 2012-12-31 9:24

Beware the false axioms of the devil. A bottomless pit of despair and inconsistency await those tempted by the false presumptions.


unordered_merge([],[],[]).
unordered_merge(Xs,[Y|Ys],[Y|Zs]) :- unordered_merge(Xs,Ys,Zs).
unordered_merge([X|Xs],Ys,[X|Zs]) :- unordered_merge(Xs,Ys,Zs).

Name: Anonymous 2012-12-31 9:28

It is never too late to get back on the right path. Cast aside your contradictions and embrace the Lord as your savior.


reduce_pairs(_,[],[]).
reduce_pairs(_,[X],[X]).
reduce_pairs(Op,[X1,X2|Xs],[Z|Zs]) :- call(Op,X1,X2,Z), reduce_pairs(Op,Xs,Zs).

balanced_reduce(_,[X],X).
balanced_reduce(Op,Xs,Z) :- Xs \= [X], reduce_pairs(Op,Xs,Ys), balanced_reduce(Op,Ys,Z).

Name: Anonymous 2012-12-31 9:34

God be my guide. Don't let me stray. Keep me among you in your kingdom of correctness.


permutation(Xs,Ys) :- map(singleton,Xs,XSingles), balanced_reduce(unordered_merge,XSingles,Ys).

permutations(Xs,Ys) :- findall(Perm,permutation(Xs,Perm),Ys).

Name: Anonymous 2012-12-31 9:53

>>3-6
I thought tdavis-kun didn't have any children.

Name: Anonymous 2012-12-31 9:55

God give me the strength to last the storm. To keep the struggle. To satisfy the goal.


ordered_merge(_,[],[],[]).
ordered_merge(_,[],Ys,Ys).
ordered_merge(_,Xs,[],Xs).
ordered_merge(Order,[X|Xs],[Y|Ys],[X|Zs]) :- call(Order,X,Y), ordered_merge(Order,Xs,[Y|Ys],Zs).
ordered_merge(Order,[X|Xs],[Y|Ys],[Y|Zs]) :- call(Order,Y,X), ordered_merge(Order,[X|Xs],Ys,Zs).

merge_sort(Order,Xs,Ys) :- map(singleton,Xs,XSingles), balanced_reduce(ordered_merge(Order),XSingles,Ys).

Name: Anonymous 2012-12-31 9:56

>>7
I'm pretty sure it's just a joke. Right?

Name: Anonymous 2012-12-31 9:57

Prolosethos: CIA-free backtracking.

Name: Anonymous 2012-12-31 9:58

Now implement lambda calculus in prolog.

Name: Anonymous 2012-12-31 10:17

>>11
Are you sure you want a non deterministic lambda calculus? Do you really want to go there? You might not like what you find.

Name: Anonymous 2012-12-31 10:25

>>12
I have a bad feeling about this, and despite that, I take the red pill. Show me the truth.

Name: Anonymous 2012-12-31 10:28

>>13
Hmm, well unfortunately I haven't quite gotten there myself either. But I'm guessing it would be something of a merge of lambda calculus and one of those relational algebras. Lets pop over the rocks and dig up the grubs!

Name: Anonymous 2012-12-31 10:37

Is Prolog strict (evaluation-wise)? If you write something like blah :- true; infinite_loop., what do you get? Also, almost all floating point operations aren't invertible, how do you deal with that?

Name: Anonymous 2012-12-31 10:51

i've found once quite neat implementation of ``prolog'' in ????????????????????????????, different syntax though. sadly, i've lost that link.

Name: Anonymous 2012-12-31 10:59

>>15
I believe prolog is strict in general, although I'm not sure how this is specified with backtracking and all. I know there are a few parallelizing prolog compilers. But in that example the ; means disjunction, so as soon as the true is satisfied, I think it would not evaluate the infinite_loop. But I'm not sure where this is outlined in a standard. And the prolog operators don't seem to be invertible by default, but you could define invertible ones.


sum(X,Y,Z) :- nonvar(X), nonvar(Y), Z is X + Y;
              nonvar(Z), nonvar(Y), X is Z - Y;
              nonvar(Z), nonvar(X), Y is Z - X.


That's an interesting point about the floating point numbers. It would keep the image/preimage calculation from being totally consistent. I don't know if invertible arithmetic is really supported by prolog at that level.

Name: Anonymous 2012-12-31 10:59

>>15
Prolog is non-applicative, you'll either get into an infinite loop or run out of stack only during solution aggregation OR after typing semicolon during query interaction, but this is only the case if a relating predicate didn't cut first, and is/2 isn't invertible at all, so it applies to operations of all number classes.

Name: Anonymous 2012-12-31 11:05

>>17,18
Would specifying an "order of evaluation" (thus making it strict) ruin the language in some fundamental sense?

Name: Anonymous 2012-12-31 11:32

>>19
If your asking for a comparison with prolog and haskell, you can do some haskelly things in prolog. Rather than a function returning a lazy list, you can define a relation that binds an output parameter to a member of a (possibly infinite) list. But prolog defines procedures that have side effects, so this places a constraint on how evaluation is done. There are also a few built ins that manipulation how things are evaluated.

Name: Anonymous 2012-12-31 11:44

>>19
If you mean by order of evaluation as to whether the leftmost is "used" first, most prologs do that, depending on what the operator is: ,/2 and ;/2 do this to be generally useful, otherwise the cut operator becomes meaningless. Implication ->/2 is roughly defined as (A, !, B; fail) where ! is a slightly tweaked cut operator, if I'm not mistaken.

If Prolog became strict as in applicative like C or Pascal, it wouldn't be the same at all, its very much like REBOL and Lisp macros as the arguments of every "call" are its own DSL. Prolog is in fact a bunch of operators that looks like it has syntax. :-/2 (and :-/1) is also an operator that probably does nothing but gets parsed by consult/1 in many Prolog implementations into instructions for some VM and made ready for querying.

Name: Anonymous 2013-01-05 18:49

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Could someone explain to me what makes Prolog special? What does declarative logic programming have over untyped lambda calculus as a computational model? It seems to me as if the latter maps better to what the machine actually does, but that might just be me.

Sorry, I'm very new to all this.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iF4EAREKAAYFAlDovBwACgkQGRQwWY30ng319gEAiv5hYGxnWspD+jnFSMZUQhbK
qHFz3IVI1jpQyaftayoBAILA6+c45HvZ931MprMT8htL2Wfdc8PZHAIxwI/N72DA
=bAE1
-----END PGP SIGNATURE-----

Name: Anonymous 2013-01-05 19:20

>>22
Seconding this.

The only application I ever found was checking transitivity in some stupid relations. For instance, bus goes from 1 to 2, 2 to 3, 2 to 4, 4 to 5, 2 to 5, does it go from 1 to 5?

I know, I'm a fucking retard.

Name: Anonymous 2013-01-05 19:55

Your new job is to add a Prolog DSL to your favorite Lisp or Scheme implementation. You can take some inspiration from the Shen language.

http://www.shenlanguage.org/learn-shen/prolog.html

Name: Anonymous 2013-01-05 20:34

Prolog is nice, but its syntax could have been a lot cleaner.

Name: Anonymous 2013-01-05 20:44

>>25
Most of the people in this thread are LISPPERs, they know surface syntax is an irrelevant detail.

Name: Anonymous 2013-01-05 23:48

>>22
If I'm not mistaken, some japanese folks tried to create a computer architecture specifically for prolog. I'm having trouble finding it now. I don't think they had much success, or if they did, they couldn't match the same progress that was being made on our conventional stack based register machines. Whenever you ask if a language represents what the machine does, you need to specify the target machine first. Assembly would be the most direct. Then the simple stack based imperative languages. The functional ones also fit well into stack based register machines. Continuations don't mix as well, but an efficient implementation is possible. Then there's haskell. Some people might find it odd that you can map an infinite list, but under the hood the implementation isn't doing anything that can't also be in C or the more primitive languages. Then there's prolog. I don't think it would be hard to write a prolog compiler, but I think it would be hard to write an optimizing compiler that generated the same type of code you'd see for other high level languages. You'd need to identify when the program actually requires all of prolog's features, and when it doesn't need them.

Name: Anonymous 2013-01-06 1:36

>>26
Lisp syntax is very simple to parse. Prolog's not so much.

Name: Anonymous 2013-01-06 3:58

>>28
generalized binary operator my anus!

Name: Anonymous 2013-01-06 4:01

ATS anyone?

Name: Anonymous 2013-01-06 4:05

>>3
>Blessed be the Theorem Prover, for He will never give up the pursuit of truth.
I'm stealing that line but can pay you in blow jobs if you don't take kindly to the whole 'robbery' thing.

Name: Anonymous 2013-01-06 5:17

>>31
Yes, pay me in blow jobs.

Name: Anonymous 2013-01-06 16:00

>>31
Yes, pay me in blow jobs.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List