[Categoricaldata_announce] newbie to FQL

David Spivak dspivak at gmail.com
Wed Jul 2 17:28:16 EDT 2014


Hi Vit,

Attached is an FQL++ query that performs the SELECT query from the slides,
as per the second part of your second question. It's now included as a
built-in example, called "Select CTDB", in FQL++. I'll also include the
code verbatim below.

David


----------
//The query from http://categoricaldata.net/fql/introSlides.pdf#page=45
//It's best to go to options and choose "Pi ID creation strategy" to be
"Summary as ID".

category C = {
objects
 RL3, //numbers less than 3.
R,  //numbers
Book,
 Isbn_num,
String;
arrows
i:RL3->R,
 price:Book->R,
title:Book->String,
isbn:Book->Isbn_num;
 equations;
}

functor I = {
objects
RL3->{1,2},
 R->{1,2,3,4,5},
Book->{1,2,3},
Isbn_num->{1,2,3,249,258,4597},
 String->{"a","b","GoneWind","Catch22","CatTheory"};
arrows
 att->{(1,1),(2,2),(3,3),(4,4),(5,5)},
title->{(1,"GoneWind"),(2,"Catch22"), (3,"CatTheory")},
 isbn->{(1,258),(2,4597),(3,249)}, //Note the last digit of the ISBN is the
number of letters in the title.
i->{(1,1),(2,2)},
 price->{(1,4),(2,3),(3,1)};
} :  C->Set

//Note that there is exactly one book whose price is less than 3.

category D = {
objects
RL3,
R,
W,
 Book,
Isbn_num,
String;
arrows
 title:Book->String,
isbn:Book->Isbn_num,
f:W->RL3,
 g:W->Book,
i:RL3->R,
price:Book->R;
 equations
W.f.i=W.g.price;
}

functor F = {
objects
 RL3->RL3,
R->R,
Book->Book,
Isbn_num->Isbn_num,
 String->String;
arrows
i->RL3.i,
price->Book.price,
 title->Book.title,
isbn->Book.isbn;
} : C -> D


functor pi_F_I = apply pi F on object I

category E = {
objects W, String, Isbn_num;
arrows title:W->String, isbn:W->Isbn_num;
 equations;
}

functor G = {
objects W->W, String->String, Isbn_num->Isbn_num;
 arrows title->W.g.title, isbn->W.g.isbn;
} : E -> D

functor Select = apply delta G on object pi_F_I



On Wed, Jul 2, 2014 at 6:28 AM, Koksa, Vit <Vit.Koksa at honeywell.com> wrote:

>  Hi David,
>
>
>
> Thank you a lot for the explanation and the piece of the FQL code which
> helped me to proceed with my exercise.
>
>
>
> Btw., the compilation of my code with a pi-ed instance with just a small
> amount of data seemed to last forever, before the SQL Engine was changed
> from Naïve to H2 in the Options (or before I reduced the small amount of
> data to really just a few items). Unchecking Elements and Observables and
> the other options of the viewer brought no significant speed-up there. As
> the long waiting periods might deter some new users I suggest to consider
> automatic switching from Naïve to H2 engine if the compilation doesn’t finish
> after some time-out.
>
>
>
> With best regards.
>
> Vit
>
>
>
> *From:* David Spivak [mailto:dspivak at gmail.com]
> *Sent:* Tuesday, July 01, 2014 7:33 PM
> *To:* Koksa, Vit
> *Cc:* categoricaldata_announce at categoricaldata.net
> *Subject:* Re: [Categoricaldata_announce] newbie to FQL
>
>
>
> Hi Vit,
>
>
>
> Thanks for the email; I'm glad you're using this tool and finding it a
> nice way to get acquainted with category theory.
>
>
>
> Your first question is a bit easier. The high-level answer is that "the
> limit of an empty diagram is the terminal object". Basically since nothing
> is hitting a3 or a4, the sets that Pi puts there are empty products, i.e.
> terminal objects in Set. The terminal object in Set is the set with one
> element. You can see this issue as a kind of generalization of the fact
> that 5^0=1 because 5^0 is an empty product (multiply 5*5*5...&5, but do it
> 0 times) and the answer is 1.
>
>
>
> Your second question is more involved. To answer your first question we
> will try to write an FQL file that does this example and send it to you
> (and the list) soon. As to your second question, given a schema S=[A   B]
> consisting of just two nodes, A and B, one can make a new schema T=[A <--X
> --->B] with an additional object and two additional arrows. Then one can
> create a functor F: S-->T. The query pi F will put the product into X with
> the foreign keys you want. See the attached FQL file.
>
>
>
> Best regards,
>
> David
>
>
>
> On Tue, Jul 1, 2014 at 5:28 AM, Koksa, Vit <Vit.Koksa at honeywell.com>
> wrote:
>
> Hello,
>
>
>
> Is there any discussion forum on FQL available, please? I didn’t find any,
> so I resort to send my e-mail to this mailing list. The FQL IDE is a very
> interesting and user-friendly tool, it enables even people without a deep
> mathematical background like me to play with categories. But I don’t see
> things, which would be obvious to the more knowledgeable people.
>
>
>
> The questions which I have currently in mind are:
>
>
>
> 1.  The FQL sample code “Query Composition” contains the query q1: S -> T
> . To see how the data migration proceeds inside this query I added these
> two instances:
>
>
>
> instance Delta_sm = delta sm I
>
> instance Pi_fm = pi fm Delta_sm
>
>
>
> What I don’t understand is why both tables a3 and a4 in Pi_fm contain a
> record, when there is no mapping to these tables of the schema A from the
> tables of the schema B in the schema mapping fm.
>
>
>
> 2. How would the example given on the slide 45 of
> http://categoricaldata.net/fql/introSlides.pdf be encoded in FQL?
>
> (SELECT title, isbn FROM book WHERE price > 100)
>
> In particular and more generally I don’t know how to migrate data from
> nodes {a, b} to nodes {a, b, aXb} where aXb is the product/join of a and b,
> while “preserving” the foreign keys from aXb elements to their constituent
> parts in a and b.
>
>
>
> With regards.
>
> Vit
>
>
> _______________________________________________
> Categoricaldata_announce mailing list
> Categoricaldata_announce at categoricaldata.net
> https://lists.hcoop.net/listinfo/categoricaldata_announce
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.hcoop.net/pipermail/categoricaldata_announce/attachments/20140702/02678581/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SelectFromCTDBIntroductoryTalk.fqlpp
Type: application/octet-stream
Size: 1589 bytes
Desc: not available
Url : http://lists.hcoop.net/pipermail/categoricaldata_announce/attachments/20140702/02678581/attachment.obj 


More information about the Categoricaldata_announce mailing list