Wednesday, 16 September 2015

Answer Sources: from Fluents to Interactors

This is a follow-up to my previous post "Answer Sources in Prolog (SWI) - Preview" [1]. Here I present the flow diagram for the worker loop with support for the `return` operation. Implementation of the `return` operation upgrades our answer sources from fluents [2] to interactors [3].
[1] My post, "Answer Sources in Prolog (SWI) - Preview":

[2] Paul Tarau, "Fluents: A Refactoring of Prolog for Uniform Reflection and Interoperation with External Objects":
http://www.cse.unt.edu/~tarau/research/LeanProlog/RefactoringPrologWithFluents.pdf

[3] Paul Tarau and Arun Majumdar, "Interoperating Logic Engines":
http://www.cse.unt.edu/~tarau/research/LeanProlog/InteroperatingLogicEngines.pdf

Thursday, 3 September 2015

Answer Sources in Prolog (SWI) - Preview

I have implemented an initial version of Answer Sources in SWI-Prolog [1], now submitted for preliminary discussion to comp.lang.prolog [2]. For the rationale and design, I have followed Paul Tarau on "fluent sources" [3], although with some important differences.

[1] Code preview with answer sources and the basic combinators:
https://gist.github.com/jp-diegidio/2914cac8b5cfb2b6a95e

[2] (Short) presentation and discussion on comp.lang.prolog:

[3] Paul Tarau, "Fluents: A Refactoring of Prolog for Uniform Reflection and Interoperation with External Objects":
http://www.cse.unt.edu/~tarau/research/LeanProlog/RefactoringPrologWithFluents.pdf

Wednesday, 15 July 2015

[WARNING: This take of mine is wrong and rather reflects my own initial misunderstanding of relativity. Indeed, try and do the calculations...! I am leaving it here as I think it may reflect some common mistakes made when seeing relativity for the first time. I might make it into a proper (introductory) article at some point...]

In the context of special relativity, we present a twins experiment that is symmetric between the twins, so that a paradox appears inescapable, in the form of a violation of the principle of causality.

Here is the experiment (we would argue that effects of acceleration can be made arbitrarily small in our setup):

== The twins, call them L and R, are each given a clock at birth and get the clock fixed to their body: the two clocks have been previously synchronised.  Assume, for simplicity, that the common origin of space-time for the clocks is set to the moment and place of the twins' birth, as well as a common choice of coordinates is made, such that the twins, at that very moment, share the same frame of reference (up to arbitrary precision).
Just after birth, the twins (with their clocks) are each embarked on a rocket.  Assume collinear motion for simplicity.  The two rockets start in opposite direction relative to the origin, carrying L and R respectively.  The plan is for the rockets to fly away from each other at some fixed (appropriately high) constant speed for some fixed (appropriately long) proper time, then simply invert course and fly back at opposite speed to the point of origin (in space), and stop there.  (Effects of acceleration can be minimised by making the total proper time the rockets are subject to acceleration appropriately small relative to the total proper time of the journey.)
The twins at that point rejoin, again sharing a common frame of reference (up to arbitrary precision).  We ask what the two clocks measure for each twin in this common frame. ==

To compute results, we apply special relativity.  (We advise readers go through this little but essential exercise by themselves.)  We find that R's clock looks late (i.e. back in time) to L, but, *at the same time* (twins and clocks are in a common frame of reference), L's clock looks late to R!  This conclusion is an inescapable consequence of the theory, and now the problem becomes how to make sense of these results.  In fact, since all clocks are affected, including the biological ones, at the end of the journey each twin effectively finds the other younger than himself: then, per *reciprocity* (causality), i.e. that in the same frame of reference, if I am older than you, you must be younger than me, we can argue that each twin is at the same time younger and older than the other, which is indeed absurd!

Note that the absurdity would not be so patent if we just let the two clocks travel, hence we sent the twins, too: not because the presence of the twins is necessary for relativistic effects to occur, the clocks must be late relative to each other regardless of anyone observing them, rather because only the twins can "testify" that the conclusion of the experiment, so special relativity theory, is indeed at odds with the principle of *causality*.

Bottom line: if special relativity is correct, it must be incomplete.

Saturday, 18 April 2015

Cheryl's birthday in Prolog

Cheryl's Birthday - The Math Question That Went Viral
"One word problem from a Singaporean school exam briefly became the talk of the Internet last weekend."
http://www.theatlantic.com/education/archive/2015/04/the-math-question-that-went-viral/390411/

I have put together two solutions in Prolog (in SWI-Prolog, last updated 2015-04-20T19:40:00+01:00), the source code can be downloaded here: http://julio.diegidio.name/Share/CherylsBirthdays.zip

The first solution (cheryls-birthday.aggr.pl) uses lists and aggregates:
```?- problem(cbdate, BDate).
% 563 inferences, 0.000 CPU in 0.000 seconds (?% CPU, Infinite Lips)
BDate = [7, 16].

?- time((between(1,1000,_),p_cbdate_input(CBDates),p_cbdate(CBDates, BDate),fail;true)).
% 563,001 inferences, 0.218 CPU in 0.220 seconds (99% CPU, 2577827 Lips)
true.
```
The second solution (cheryls-birthday.lists.pl) uses lists:
```?- problem(cbdate, BDate).
% 5,163 inferences, 0.000 CPU in 0.000 seconds (?% CPU, Infinite Lips)
BDate = [7, 16].

?- time((between(1,1000,_),p_cbdate_input(CBDates),p_cbdate(CBDates, BDate),fail;true)).
% 5,164,001 inferences, 1.513 CPU in 1.520 seconds (100% CPU, 3412614 Lips)
true.
```
The first solution, i.e. the implementation leveraging aggregates, turns out to be significantly faster...

Friday, 30 January 2015

The day we discovered negatrons

It happened on sci.physics...