Hello Markus, could you create a video about CHR? You're the best resource for learning Prolog. Thanks!
@jasonbryanthemann29 күн бұрын
Great video as ever. I don't have `volatile` in my scryer-prolog operator table. Is that something specific to your environment?
@ThePowerOfProlog29 күн бұрын
Thank you a lot for your kind words, and for your interest! Regarding your question: `volatile` is not a standard predefined operator, and therefore Scryer Prolog does not define it in its default execution mode. However, we have: 5.5.2 Predefined operators A processor may support one or more additional predefined operators (table 7) as an implementation specific feature. So, additional operators may be available in a Prolog system as an implementation specific feature, as long as the system also has a strictly conforming mode in which the feature is turned off. Scryer Prolog is strictly conforming to the standard in its default execution mode, and therefore can be reliably used to detect syntactically valid and portable Prolog code, a major attraction of the system especially when learning the language.
@kng1433-g4xАй бұрын
This was the best prolog intro I had! Also this emacs config is great, gonna try both of 'em soon, damm as a nvim guy you kinda stole my heart there.
@DnBComplex2 ай бұрын
How are representing the AST on the sides of iur videos? Btw... Thanks alot for this whole channel, this is awesome and I thank you for that. People like you (teahcers) are the people that contribute the most with the world.
@ThePowerOfProlog2 ай бұрын
Thank you so much for your kind words, I greatly appreciate them! I draw the graph with showterm.el which is available in the "tools" directory of Scryer Prolog, please have a look, and I hope it helps: github.com/mthom/scryer-prolog/tree/master/tools
@Cleanser232 ай бұрын
what is the software you use for these videos? You seem to evaluate prolog code and then print a tree is it emacs?
@markbolusmjak37312 ай бұрын
Enlightening as always. I’m inspired to rewrite a bunch of code tomorrow.
@Schwonko2 ай бұрын
A says: Either ... or. To me this is a xor, not an or. Then you also have the solution A=0, B=1. goal: sat((~A # B) =:= A), labeling([A,B]).
@panjak3232 ай бұрын
Why not "is" instead of #=
@ThePowerOfProlog2 ай бұрын
(is)/2 works only if the right-hand side is ground. For example, we get: ?- X is Y + 3. error(instantiation_error,(is)/2). Whereas (#=)/2 can be used in all situations, and is therefore a lot more general and easier to use. For example: ?- #X #= #Y + 3. clpz:(#Y+3#=#X).
@panjak3232 ай бұрын
@@ThePowerOfProlog yeah right, but isn't there also other syntax for numeric evaluation equality? Never seen #= in university course, as they forbidden usage of any modules anyways.
@guilhermepimenta_prodabel3 ай бұрын
The problem is for some boards, like 5x5, there is no circuit, but there is a complete path.
@guilhermepimenta_prodabel3 ай бұрын
If you create the new state "out of the board", you must start and end in out of border. The first move from out of board can go to any position and the last move can go from any position to out of board, the condition is: if all squares are not empty you go to out of board. It will, at least I hope, create all possible paths. In graph representation, is a new node that is connected to all nodes, and it is the start point of the circuit. What do you think?
@hobbified3 ай бұрын
That's the same idea I came up with. I think it works fine. By forcing it to be the start point, you also (via `circuit`'s enforcement that nodes only appear once) forbid it from ending up anywhere in the middle of the path, cheaply. But by making it the neighbor of everything we say that the path can end anywhere. And the length constraint will make sure that the tour is complete.
@jamestolton68823 ай бұрын
6:00 - using clpz disunction/conjunction constraints 7:00 - foldl/3 explanation 14:13 - most general query example 15:08 - predicate overgeneralization example, explanation, and tradeoff explanation 16:50 - pairs library, pairs_key_value/3 predicate, label/1 predicate 18:50 - use of lambda to project away bindings 21:29 - core relations and conventions in constraint programming 21:35 - labeling/2 guarantees 26:42 - first example of thrashing with visualization 27:40 - example of ff options for labeling/2 27:47 - second example of thrashing with visualization 29:10 - discussion of weak propagation properties of clpz conjunctions and disjunctions 32:06 - base8 representation of chess board 33:15 - second example of weak propagation 35:27 - introduction of tuples_in/2 and all_different/1 37:46 - practical example of tuples_in/2 and all_different/1 used in a relation 38:29 - bounds consistency 39:02 - domain consistency 41:07 - third example of thrashing 43:51 - defining model as in "modeling a task" 45:05 - discussion of mental model of declarative programming 48:53 - overview of clpz combinatorial constraints 49:00 - tuples_in/2 49:07 - global_cardinality/3 49:20 - circuit/1 50:00 - circuit/1 explanation and demonstration 51:40 - representing knight's tour as a graph 52:37 - base N coordinate n_x_y_x/4 relation development and intuition 53:47 - knight_move/3 state transition / successor relation rewrite 56:08 - n_tour/2 development and rewrite 56:11 - knight_graph/4 predicate development and intuition 1:00:05 - practical usage of lambda with foldl/3 and clever inline toplevel query for iterative development 1:01:49 - discussion of operational constraings using circuit/1 1:04:22 - "Ready? Go". Successful knight tour. 1:05:10 - observations 1:08:01 - developing a readable output 1:08:59 - another example of foldl/3 usage 1:09:40 - example of nth1/3 usage 1:11:45 - usage DCGs in to develop format string 1:18:14 - recap of modeling and discussion of mental model for Prolog and conclusion *Note* for curious non-prolog developers: The name/number syntax indicates to other Prolog programmers predicate/arrity. If you have never worked with predicates before, it is easiest to categorize them as "Prolog functions" (but you will also soon see that the differences between them are great enough that the phrase "Prolog function" would make most Prolog developers instantly cringe -- I'm just mentioning this to help you orient yourself to this comment if the syntax is unfamiliar) *Note1:* DCGs stands for Definite Clause Grammars, Markus has another excellent video on them. He also has a **great video just on string formatting in Prolog.
@wowzers1237____3 ай бұрын
Awesome. Thank you.
@SylvainSoliman3 ай бұрын
I think that most of the arguments about readability (for foldl or the final definition of knight_move) are not really convincing (people not used to functional programming have no idea what foldl does for instance). I also think that saying that there is no disjunction in an equality constraint with an absolute value… is only true if one knows how the solver is programmed ;) For the rest, didn't watch everything, but it seemed pretty nice !!! 👍🏼
@librarianmage3 ай бұрын
Any hamiltonian path can be extended into a cycle by adding an additional vertex that connects the start and end of the path, so I imagine a way to model all knights tours is to add a (N*N + 1)th vertex that connects to all of the squares and consider the vertices next to it on the path as the ends of the tour.
@simeondermaats3 ай бұрын
I'll be following a course on Prolog at uni next semester, and I can already tell this'll be a very useful channel. Thank you for the content you put out!
I'm starting your online book, and I'm starting with just your videos (one after another). I've read some Prolog books before, but I want to learn to read and write Prolog like a Prolog programmer would read and write Prolog, so stuff like mother_child(Mother, Child) instead of isMother(X, Y).
@cheeseandonions95585 ай бұрын
this is like existential philosophy 303
@sabbirneplumpstein3345 ай бұрын
This was so helpful! Thanks
@jackmeyergarvey5 ай бұрын
Amazing video. Very fun topic!
@StephenMolloyGoogle6 ай бұрын
Nice to see the progress since this video was made. When trying the example at 3:45 in this video, there is no longer a redundant choice point and the query returns only one result.
@ThePowerOfProlog6 ай бұрын
Yes indeed, and well spotted! This improvement is indeed a very recent development, it was implemented not even a year ago with github.com/mthom/scryer-prolog/commit/d520046a4f4d75de2cb76d18f46568e5fde3d614, providing lookahead indexing in Scryer Prolog!
@ceving8657 ай бұрын
Very well illustrated.
@JohanMynhardt8 ай бұрын
All these years on the web and one day, *boom*, someone else recommending Dvorak! 😬
@wobey838 ай бұрын
I have been working for some time with the Prolog programming language and have recently installed Scryer Prolog 0.9.3. I am currently working my way through the book "Prolog programming in depth" by M. Covington. The best source for learning Prolog that I have found so far. Your wonderful video series on Prolog supports the whole thing. So far I have been able to use Scryer Prolog to solve all the problems I have encountered. There's just one thing I've noticed. The predicate 'listing/0, listing/1' does not seem to work. With Gnu P. and SWI P. the predicates work. Unfortunately not for Scryer. My question therefore relates to the current status of the predicate 'listing', or what am I doing wrong here.
@ThePowerOfProlog8 ай бұрын
Thank you a lot for your kind words and for your interest! In Scryer Prolog, listing/1 is available in library(format). The predicate for which a listing is generated must be public. One way to do this is to declare the predicate dynamic, using the dynamic/1 directive, as in :- dynamic(your_predicate/3). If you add such a directive for your predicate, then you can generate a listing with ?- listing(your_predicate/3). Please try it out, and file an issue in the Scryer Prolog repository if anything does not work as expected. Thank you a lot!
@wobey838 ай бұрын
@@ThePowerOfProlog Thank you for your answer. It works now, using the "dynamic" directive.
@huistelefoon53758 ай бұрын
The year of the Prolog programming language!.. next year will surely be the one... I'll stick with C.
@StephenMolloyGoogle8 ай бұрын
Interesting that the redundant choice-point is no longer there in up-to-date scryer-prolog.
@ThePowerOfProlog8 ай бұрын
Yes indeed, well spotted! This is made possible by the following improvement in the engine from a few months ago: github.com/mthom/scryer-prolog/pull/1879/commits/749619319a40eb82e0649b23ad919cb32bcb781b With this engine improvement, and member/2 defined as in github.com/mthom/scryer-prolog/pull/1879/commits/c51ff4c03daad697f2ea77ca03d2b3462439b4d2, a redundant choicepoint is no longer created! Another important class of use-cases that benefit from this engine feature is shown in github.com/mthom/scryer-prolog/issues/1028. Such engine improvements have the potential to make many programs easier to read and write and retain very good efficiency.
@StatsGod8 ай бұрын
Phenomenal series of videos. Perpetual Prolog beginner here. I get the arguments against the cut, but how would you then handle this very simple example? We want to get a thing. Getting it is failure-prone and expensive; we'll retry a couple of times and then give up (fail) if we can't get it, as we conclude that it's somehow ungettable. We really don't want to get it more than once. I would write without hesitation: get_thing(NumAttempts, Thing) :- NumAttempts > 0, go_get_it_and_pay_high_price(Thing), !. get_thing(NumAttempts, Thing) :- NumAttempts > 0, OneFewerAttempts is NumAttempts - 1, get_thing(OneFewerAttempts, Thing). I understand this eliminates logical possibilities -- which might be an issue if, say, thing changes over time in relevant ways. But in practice, let's say we just want the first success, not all successes, and we don't want a problem later in the program to trigger a backtrack over our get_thing/2. How would you solve this?
@wobey838 ай бұрын
Supplement to former comment: Same n_factorial program executes in GNU Prolog 1.5.0.
@RenanNespolo9 ай бұрын
man, I would like to learn plot the tree like in minute 1:14, did you have a vídeo of configuration of make trees?
@ThePowerOfProlog9 ай бұрын
Thank you a lot for your interest! Please see the following descriptions in the "tools" directory of Scryer Prolog: github.com/mthom/scryer-prolog/tree/master/tools I hope this helps!
@aravinds44959 ай бұрын
Hi guys , Do anyone have idea how to integrate prolog in networking?
@alecserra423010 ай бұрын
I have a question about the general structure of the N-Queens problem. I've implemented code similar to that presented in your previous N-Queens video. The heuristic I use is a very simple first-fail. Typically, my solution converges within 10,000 recursive function calls when iterating through board sizes. However, beyond a board size of 80, it loses this ability. Why is this? Additionally, is there a more suitable heuristic for this problem, and are there specific claims that can be made about such a heuristic? Also, what is the upper limit on the twice-reordered list heuristic combined with first fail? In the video, you demonstrate quickly solving for 120, but what about 150 or 200? Thank you.
@alecserra423010 ай бұрын
Never mind, I did some more searching and found the wiki for Min-conflicts algorithm, apparently N-Queens can be solved in about 50 iterations regardless of board size.
@guilhermepimenta_prodabel10 ай бұрын
Excellent Work!
@hendrikd211310 ай бұрын
Nice video! However I think you are (unconsciously) performing a magic trick while posing the problem and writing safe_queens/1. By searching for a 1D list, instead of a 2D structure, you are doing optimization while defining the problem to be solved. The idea to choose a 1D list as a representation is of course relatively obvious. But it is arbitrary. The underlying observation also holds for each row. We could further minimize the search space, by searching for a permutation of the numbers 1..N. This (in my opinion) works against the point you are making in the first half of the video. Sure, one can try different labeling strategies, while not modifying the representation. But tinkering with the *logic* part is equally effective.
@AleksyGrabovski10 ай бұрын
Video starts as a trivial N-Queens problem, but then went into search optimization and introduced good way of thinking about performance of Prolog programs. Nice!
@afonsorafael272810 ай бұрын
The prolog I know comes from watching your videos and scrolling trough "the power of prolog" website. Thank you sharing all :)
@morphles10 ай бұрын
Amazing video. Gotta get myself more seriously into prolog or something like it :)
@simonsaville996210 ай бұрын
Fascinating, as always! Elucidated with expertise.
@xavierperani936310 ай бұрын
Another awesome video, thank you for your wonderful work.
@tankerwife200110 ай бұрын
A highly awaited sequel!!
@wowzers1237____10 ай бұрын
Finally!!! Thanks Markus! Please don't make us wait so long between videos :)
@jaimebonilla920910 ай бұрын
Hello i had a question i can not solve yet: What happens if aº(bºc) = (aºb)ºc != aºbºc, what kind of mathematical structure is this, is it still a group?
@ThePowerOfProlog10 ай бұрын
If º (circle) is a binary operation, then what specifically do you mean with aºbºc ? There are binary operations that, by convention, associate to the left (example: subtraction), and binary operations that associate to the right (example: exponentiation). For instance, 5-3-1 is by convention interpreted as (5-3)-1, instead of 5-(3-1). But it is either one or the other, otherwise it is not a binary operation but a ternary operation, which takes all three arguments into account "at once".
@kellymoses856611 ай бұрын
Forget to the link to the paper d1.awsstatic.com/whitepapers/Security/Reachability_Analysis_for_AWS-based_Networks.pdf
@kellymoses856611 ай бұрын
AWS uses the optimized datalog solver soufflé to statically analysis network connectivity. One use is to prove security invariants like the DMZ network cannot access the management interfaces of any device.
@DaveYostCom11 ай бұрын
A lucid introduction to Prolog! Bravo.
@DougRansom111 ай бұрын
Do you have this in written form somewhere for reference? Could it be an additional chapter to the power of prolog?
@mathom21 Жыл бұрын
Outstanding matrial! Danke!
@leswine1582 Жыл бұрын
answer set programming is also great for "generate and test" type problems with constraints