3 ms·
I looked at the tutorial and choked at the first step. First it says "== unifies two terms". Then the first example says "(== x z) (== 3 y)" associates x with
by emmelaich 2y ago
I looked at the tutorial and choked at the first step.
First it says "== unifies two terms". Then the first example says "(== x z) (== 3 y)" associates x with z and y with 3. Are "unify" and "associate" the same thing? Why use different words? Why does the association reverse for x and z vs 3 and y? Is it commutative?
- tmtvl 2y agoThey are commutative. As to whether unification and association are the same thing... yes, kinda. Unifying two terms kinda means associating them with each other in a database. Though I will say that it would have been better to say 'unifies x and z, as well as y and 3'.
- Arnavion 2y agoUnification in the context of logic programming is basically like "use these questions and solve for all the unknowns" in algebra, except it's done with logical statements instead of algebraic equations. Searching for something like "unification prolog" (Prolog being the most well-known logic programming language) will probably give helpful material. For example you could start with two facts like "Fedora is red." and "Cat is green." Then if you ask the system "X is red." it'll tell you "X = fedora". If you ask it to list all the solutions of "X and Y are not the same color." it'll list "X = fedora, Y = cat" and "X = cat, Y = fedora". This process of binding variables to values (or other variables during simplification) is unification.
- chriswarbo 2y agoUnification is reflexive: (== x x) = x for all x It is commutative: (== x y) = (== y x) for all x and y It is idempotent: (== x (== x y)) = (== x y) for all x and y And it is associative: (== x (== y z)) = (== (== x y) z) It's not transitive, e.g. if we unify pairs (using made up syntax [a, b]) then (== [x, 1] [2, y]) = [2, 1] (== [2, y] [z, 3]) = [2, 3] (== [x, 1] [z, 3]) does not unify (since 1 does not unify with 3)
- emmelaich 2y agoThanks for the follow-ups but my comment wasn't really asking what unify and associate mean, I'm questioning the redundant complexity in what is supposed to be the introductory tutorial to the language. From the submitted page, "The core language, using Scheme as the host language, is described in this short, interactive tutorial."
- jasonhemann 2y agoI think these are great points. Everything should be smooth as butter for an interested reader, and the tutorial should be so approachable and such a page-turner that the curious are hooked on page one and can't put it down. Really---anything short of that is sub-optimal performance. I think some of it comes from new eyes reading and pointing out room for improvement. The other half is someone having the time to figure out the fix and implement it.