unification

How can I implement the unification algorithm in a language like Java or C#?

◇◆丶佛笑我妖孽 提交于 2019-12-03 03:52:54
问题 I'm working through my AI textbook I got and I've come to the last homework problem for my section: "Implement the Unification Algorithm outlined on page 69 in any language of your choice." On page 69, you have the following pseudo-code for the unification algorithm: function unify(E1, E2); begin case both E1 and E2 are constants or the empty list: if E1 = E2 then return {} else return FAIL; E1 is a variable: if E1 occurs in E2 then return FAIL else return {E2/E1} E2 is a variable if E2

Which is the type of (flip .)?

允我心安 提交于 2019-12-02 08:10:25
I'm trying to understand why the type of: (flip .) is: (a -> a1 -> b -> c) -> a -> b -> a1 -> c First of all, the type of: flip: is (a -> b -> c) -> b -> a -> c (.): is (b -> c) -> (a -> b) -> a -> c I will rename the variables to be more clear in my explanation, so the types: flip: is (ax -> bx -> cx) -> bx -> ax -> cx (.): is (by -> cy) -> (ay -> by) -> ay -> cy Then I try substituing like this: ax = (by -> cy) bx = (ay -> by) cx = ay -> cy So the resulting type is: (ay -> by) (by -> cy) -> ay -> cy, which is different with the correct result. Any help? Thanks, Sebastián. (flip .) is (.)

Type variable to be unified occurs in type

╄→尐↘猪︶ㄣ 提交于 2019-12-02 00:58:32
I have a function to reconstruct a tree from 2 lists. I return a list on all branches, but I am getting an error that I don't understand. But I assume it has to do with the return types. The error is this: Can't unify ''a with ''a list (Type variable to be unified occurs in type) Found near recon ( ::( preoH, preoT), ::( inoH, ...)) Exception- Fail "Static errors (pass2)" raised The line the error occurs at is the headline of the function definition fun recon (preoH::preoT, inoH::inoT) = What does that error mean exactly and why does it occur? (* Reconstruts a binary tree from an inorder and a

In a Warren's Abstract Machine, how does bind work, if one of the arguments is a register?

落爺英雄遲暮 提交于 2019-12-01 17:56:02
问题 I'm trying to create my own WAM implementation and I'm stuck at the exercise 2.4 I can't understand how to execute instruction unify_value X4 in figure 2.4. As far as I understand, this instruction should unify Y from the program with f(W) from the query. unify_value X4 calls unify (X4,S) where S=2 (see Figure 2.1) and a corresponding heap cell is "REF 2", and X4 is "STR 5". Unify (Figure 2.7) should bind those values, but I do not understand how to deref a register. "REF 2" is in the heap,

Higher-order unification

烂漫一生 提交于 2019-11-29 19:51:40
I'm working on a higher-order theorem prover, of which unification seems to be the most difficult subproblem. If Huet's algorithm is still considered state-of-the-art, does anyone have any links to explanations of it that are written to be understood by a programmer rather than a mathematician? Or even any examples of where it works and the usual first-order algorithm doesn't? Charles Stewart State of the art — yes, so far as I know all algorithms more or less take the same shape as Huet's (I follow theory of logic programming, although my expertise is tangential) provided you need full higher

Higher-order unification

佐手、 提交于 2019-11-28 15:44:16
问题 I'm working on a higher-order theorem prover, of which unification seems to be the most difficult subproblem. If Huet's algorithm is still considered state-of-the-art, does anyone have any links to explanations of it that are written to be understood by a programmer rather than a mathematician? Or even any examples of where it works and the usual first-order algorithm doesn't? 回答1: State of the art — yes, so far as I know all algorithms more or less take the same shape as Huet's (I follow

Type of fun g x = ys where ys = [x] ++ filter (curry g x) ys?

落爺英雄遲暮 提交于 2019-11-28 14:08:22
I'm trying to understand why the type of fun g x = ys where ys = [x] ++ filter (curry g x) ys is ((a, a) -> Bool) -> a -> [a] . I understand that: filter :: (a -> Bool) -> [a] -> [a] and that curry :: ((a, b) -> c) -> a -> b -> c But I don't understand how to continue. The approach below is not necessarily the easiest or fastest, but it's relatively systematic. Strictly speaking, you're looking for the type of \g -> (\ x -> let ys = (++) [x] (filter (curry g x) ys) in ys) ( let and where are equivalent, but it's sometimes a little easier to reason using let ), given the types filter :: (a ->

Pattern matching equivalent variables in Haskell, like in Prolog

我是研究僧i 提交于 2019-11-28 03:16:30
问题 In prolog, we can do something like the following: myFunction a (a:xs) = ... This is, when the 1st argument of myFunction is the same as the first item of the list that's in the 2nd argument, this function will evaluate to ... . My question now is... how to accomplish a similar thing in Haskell? I have the idea that Prolog's Pattern Matching is more expressive than Haskell's. I've been trying to code that in Haskell and I'm having trouble -- either I am using invalid syntax or the above trick