Prolog Integer Arithmetic

  Рет қаралды 5,701

The Power of Prolog

The Power of Prolog

Күн бұрын

Пікірлер
@simonsaville9962
@simonsaville9962 5 жыл бұрын
Yet another great video exposition of Prolog. Thank You! However, I am confused concerning the use of "disequality" over "inequality". If I'm honest, I don't really understand the distinction. Help?
@ThePowerOfProlog
@ThePowerOfProlog 5 жыл бұрын
Thank you so much for your kind words! "Disequality" denotes the negation of equality, whereas the relations "less/greater than" and "less/greater than or equal to" are called "inequalities".
@simonsaville9962
@simonsaville9962 5 жыл бұрын
@@ThePowerOfProlog Thanks for the explanation, quite simple really.
@RenanNespolo
@RenanNespolo 9 ай бұрын
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?
@ThePowerOfProlog
@ThePowerOfProlog 9 ай бұрын
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!
@brianchuquiruna6959
@brianchuquiruna6959 3 жыл бұрын
Is CLP a library for prolog? How I can install it?
@neomika92
@neomika92 3 жыл бұрын
Just go to 6:00 ...
@alamagordoingordo3047
@alamagordoingordo3047 3 жыл бұрын
Why to me don't work? with n_factorial(N,F). the result is F = 1. N = 0 ? an then if i press ; yes and stop, no other solutions. P.S. I use GNU prolog.
@ThePowerOfProlog
@ThePowerOfProlog 3 жыл бұрын
You can debug the program decelaratively by removing goals, making the program more general. For example, the following goal alone already fails in GNU Prolog: F #= A*B. Therefore, every specialization (i.e., additional constraints) fails too. I recommend to try it for example with Scryer or SICStus Prolog, which are also conforming to the ISO standard and support multiplication more generally.
@alamagordoingordo3047
@alamagordoingordo3047 3 жыл бұрын
@@ThePowerOfProlog Scryer unlike SICStus is free?
@ThePowerOfProlog
@ThePowerOfProlog 3 жыл бұрын
@@alamagordoingordo3047 Yes, Scryer is free.
@alamagordoingordo3047
@alamagordoingordo3047 3 жыл бұрын
@@ThePowerOfProlog Install Scryer is so difficult, i'm not a docker fan...
@marceloslacerda
@marceloslacerda 5 жыл бұрын
Expressing the example presented I get an unexpected answer: ?- (Chicken * 2) + (Cow * 4) #= 74, Chicken + Cow #= 30. Chicken+Cow#=30, Chicken+2*Cow#=37. While it is correct, it's weird that prolog decided to evaluate to another expression rather than saying the values of the free terms.
@ThePowerOfProlog
@ThePowerOfProlog 5 жыл бұрын
You are almost there! The challenge is to state explicitly everything you know about the task. Thank you for your interest!
@marceloslacerda
@marceloslacerda 5 жыл бұрын
When I constrain the expression to Chicken #> 0 and Cow #> 0 I get the correct results, but I don't understand, in this problem shouldn't there be only one answer even without the new constraints?
@ThePowerOfProlog
@ThePowerOfProlog 5 жыл бұрын
Try to use the Prolog system to see whether that is indeed the case, i.e., if there are no solutions where these additional constraints are not satisfied, but the others are satisfied!
@marceloslacerda
@marceloslacerda 5 жыл бұрын
@@ThePowerOfProlog Ah I see now. Thanks!
@panjak323
@panjak323 2 ай бұрын
Why not "is" instead of #=
@ThePowerOfProlog
@ThePowerOfProlog 2 ай бұрын
(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).
@panjak323
@panjak323 2 ай бұрын
@@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.
@derekfrost8991
@derekfrost8991 4 жыл бұрын
I really like your videos, but sometimes I have to listen at 0.75 speed to understand it all.. :)
@ThePowerOfProlog
@ThePowerOfProlog 4 жыл бұрын
Thank you a lot, this is one of the nicest compliments I have heard about these videos, at least regarding the information content!
@none_of_your_business
@none_of_your_business 2 жыл бұрын
I have defined the following predicate: n_factorial(0, 1). n_factorial(N,F) :- N #> 0, F #= N*F1, N1 #= N - 1, n_factorial(N1, F1). Yet for some reason when I try to query all possible solutions in gprolog I get the first solution: 0! = 1, then if i press ";" It just says "no" and it returns me to the ?- prompt, any idea why? | ?- ['fact']. compiling /home/obsrwr/work/fact.pl for byte code... /home/obsrwr/work/fact.pl compiled, 7 lines read - 837 bytes written, 6 ms yes | ?- n_factorial(N,F). F = 1 N = 0 ? ; no
@none_of_your_business
@none_of_your_business 2 жыл бұрын
swipl behaves ok however....weird
Meta-Predicates in Prolog
13:37
The Power of Prolog
Рет қаралды 7 М.
List differences in Prolog
11:49
The Power of Prolog
Рет қаралды 8 М.
Map Colouring with Prolog
13:20
The Power of Prolog
Рет қаралды 14 М.
Collatz Conjecture in Prolog
12:03
The Power of Prolog
Рет қаралды 9 М.
Applying the Koch method to Prolog
9:20
The Power of Prolog
Рет қаралды 2,1 М.
Sudoku in Prolog
31:41
The Power of Prolog
Рет қаралды 31 М.
Term Rewriting with Prolog
42:05
The Power of Prolog
Рет қаралды 4,4 М.
Pondering Prolog
26:22
The Power of Prolog
Рет қаралды 2,7 М.
Writing Prolog Code
47:25
The Power of Prolog
Рет қаралды 10 М.
Knights and Knaves in Prolog
13:41
The Power of Prolog
Рет қаралды 8 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 76 М.