| Did you know ... | Search Documentation: |
| Title for pldoc(default) |
[Jun 25 2017]
A new binding must not be dragged outside of disjunctions, since the code may look for example like this:
i(X) :- ( X #= 3 ; X #= 4 ).
In fact, this would previously not even compile, and instead raise:
put_attr/3: Uninstantiated argument expected, found 3 (1-st
argument)
already during goal expansion.
This commit fixes this issue, and still rewrites CLP(FD) expressions as far as possible already at compilation time.
For example:
n(X) :- X #= 1+3.
This is now compiled to (note that 1+3 is evaluated to 4):
?- listing(n/1). %@ n(A) :- %@ ( integer(A) %@ -> A=:=4 %@ ; var(A) %@ -> A=4 %@ ; B=4, %@ clpfd:clpfd_equal(A, B) %@ ).
Ideally, it should be compiled to:
n(4).
[Jun 24 2017]
builtin_popcountll() to compute popcount for `small'
integers.[Jun 23 2017]
[Jun 22 2017]
[Jun 20 2017]
[Jun 19 2017]
[Jun 18 2017]
[Jun 16 2017]
cleanClauseIndexes() should be locked with
addClauseToIndexes(). May cause incorrect results as well
as crashes.[Jun 15 2017]
am/pm in some locales.[Jun 15 2017]
[Jun 24 2017]
[Jun 18 2017]
directory_file_path(-,+,+) returns directory with
trailing '/'. Paul Singleton.[May 21 2017]
[Jun 16 2017]
[Jun 24 2017]
[Jun 22 2017]
[Jun 18 2017]
[Jun 15 2017]
[Jun 20 2017]
[Jun 18 2017]
[Apr 24 2017]
[Mar 29 2017]
rdf_list(-) would not enumerate more than one RDF list.[Jan 24 2017]
[Jun 15 2017]
[Jun 25 2017]
[Jun 23 2017]
[Jun 20 2017]
[Jun 19 2017]
For reasoning about Bitcoin addresses with library(crypto), check out:
https://www.metalevel.at/bitcoinolog/
Sample use of scalar multiplication over elliptic curves:
?- crypto_name_curve(secp256k1, C), crypto_curve_generator(C, G), crypto_curve_scalar_mult(C, 5, G, P).
Yielding:
%@ C = <crypto_curve>(secp256k1, 0x21e8a90), %@ G = point(55066263022277343669578718895168534326250603453777594175500187360389116729240, 32670510020758816978083085130507043184471273380659243275938904335757337482424), %@ P = point(21505829891763648114329055987619236494102133314575206970830385799158076338148, 98003708678762621233683240503080860129026887322874138805529884920309963580118).
[Jun 18 2017]
?- length(_, L), garbage_collect, crypto_context_new(Context, [algorithm(sha256)]), false.
17 2017]
This can be more than an order of magnitude faster than doing it in Prolog.
For example, consider the following Prolog implementation, using the extended Euclidean algorithm:
multiplicative_inverse_modulo_p(X, P, Y) :- eea(X, P, _, _, Y),
R #= X*Y mod P, zcompare(C, 1, R), must_be_one(C, X, P, Y).
must_be_one(=, _, _, _).
must_be_one(>, X, P, Y) :-
throw(multiplicative_inverse_modulo_p(X,P,Y)).
must_be_one(<, X, P, Y) :-
throw(multiplicative_inverse_modulo_p(X,P,Y)).
eea(I, J, G, S, T) :- State0 = state(1,0,0,1), eea_loop(I, J,
State0, G, S, T).
eea_loop(I, J, State0, G, S, T) :- zcompare(C, 0, J), eea_(C, I,
J, State0, G, S, T).
eea_(=, I, _, state(_,_,U,V), I, U, V).
eea_(<, I0, J0, state(S0,T0,U0,V0), I, U, V) :- Q #= I0 // J0,
R #= I0 mod J0, S1 #= U0 - (Q*S0), T1 #= V0 - (Q*T0),
eea_loop(J0, R, state(S1,T1,S0,T0), I, U, V).
We now have, using the Prolog implementation:
?- time((between(1,1000,_), multiplicative_inverse_modulo_p(65341020041517633956166170261014086368942546761318486551877808671514674964848, 115792089237316195423570985008687907853269984665640564039457584007908834671663, I),false)). %@ % 14,921,002 inferences, 1.133 CPU in 1.133 seconds (100% CPU, 13173595 Lips) %@ false.
And using the new crypto_modular_inverse/3:
?- time((between(1,1000,_), crypto_modular_inverse(65341020041517633956166170261014086368942546761318486551877808671514674964848, 115792089237316195423570985008687907853269984665640564039457584007908834671663, I),false)). %@ % 326,205 inferences, 0.079 CPU in 0.079 seconds (100% CPU, 4116844 Lips) %@ false.
[Jun 16 2017]
[Jun 15 2017]
[Jun 25 2017]