Re: [Haskell-cafe] Limits of deduction

2007-05-14 Thread Matthew Brecknell
Roberto Zunino: > Yes, you are right, I didn't want to involve type classes and assumed > 3::Int. A better example would be: > > polyf :: Int -> a -> Int > polyf x y = if x==0 then 0 > else if x==1 then polyf (x-1) (\z->z) > else polyf (x-2) () > > Here, passing both ()

Re: [Haskell-cafe] Limits of deduction

2007-05-14 Thread Josiah Manson
Can somebody explain to me exactly what the halting problem says? As I understand it, it doesn't say "you can't tell if this program halts", it says "you cannot write an algorithm which can tell whether *every* program halts or not". (Similar to the way that Galios dude didn't say "you can't sol

Re: [Haskell-cafe] Limits of deduction

2007-05-14 Thread Roberto Zunino
Matthew Brecknell wrote: > Roberto Zunino: > >>Here passing both 3 and (\z->z) as y confuses the type inference. > > So the type inference is not really confused at all. It just gives a > not-very-useful type. Yes, you are right, I didn't want to involve type classes and assumed 3::Int. A bette

Re: [Haskell-cafe] Limits of deduction

2007-05-14 Thread Roberto Zunino
Christopher L Conway wrote: On 5/14/07, Roberto Zunino <[EMAIL PROTECTED]> wrote: Also, using only rank-1: polyf :: Int -> a -> Int polyf x y = if x==0 then 0 else if x==1 then polyf (x-1) (\z->z) else polyf (x-2) 3 Here passing both 3 and (\z->z) as y confuses the

Re: [Haskell-cafe] Limits of deduction

2007-05-14 Thread Matthew Brecknell
Roberto Zunino: > Here passing both 3 and (\z->z) as y confuses the type inference. Christopher L Conway: > polyf :: forall a t1 t. > (Num (t1 -> t1), Num a, Num t) => > a -> (t1 -> t1) -> t > > The inference assigns y the type (t1 -> t1) even though it is assigned > the value 3? Almost. It assi

Re: [Haskell-cafe] Limits of deduction

2007-05-14 Thread Jules Bean
Christopher L Conway wrote: The inference assigns y the type (t1 -> t1) even though it is assigned the value 3? Yes, because type classes are open, and maybe you will demonstrate some way to make t1->t1 an instance of Num. Note the Num (t1 -> t1) constraint in the type...

Re: [Haskell-cafe] Limits of deduction

2007-05-14 Thread Christopher L Conway
On 5/14/07, Roberto Zunino <[EMAIL PROTECTED]> wrote: Also, using only rank-1: polyf :: Int -> a -> Int polyf x y = if x==0 then 0 else if x==1 then polyf (x-1) (\z->z) else polyf (x-2) 3 Here passing both 3 and (\z->z) as y confuses the type inference. Actually, I t

Re: [Haskell-cafe] Limits of deduction

2007-05-14 Thread Roberto Zunino
Andrew Coppin wrote: Right. So what you're saying is that for most program properties, you can partition the set of all possible problems into the set for which X is true, the set for which X is false, and a final set for programs where we can't actually determine the truth of X. Is that about

Re: [Haskell-cafe] Limits of deduction

2007-05-14 Thread Stefan Holdermans
Andrew, Right. So what you're saying is that for most program properties, you can partition the set of all possible problems into the set for which X is true, the set for which X is false, and a final set for programs where we can't actually determine the truth of X. Is that about right?

Re: [Haskell-cafe] Limits of deduction

2007-05-14 Thread Andrew Coppin
Stefan Holdermans wrote: This is rather typical in the field of program analysis. Getting the analysis precise is impossible and reduces to solving the halting problem. So, the next best thing is to get an approximate answer. An import design guideline to such an analysis is "to err on the safe

Re: [Haskell-cafe] Limits of deduction

2007-05-12 Thread Stefan Holdermans
Andrew, Jules wrote: It's computationally impossible, in general. I can write something silly like f (x:xs) = x : (UniversalTuringMachine(x) `seq` xs) and it reduces to the halting problem. However, it might be tractable for a large class of sensible programs. Someone around here might b

Re: [Haskell-cafe] Limits of deduction

2007-05-11 Thread Jules Bean
Andrew Coppin wrote: There are many possible variations - length examines the whole list, but not the elements *in* the list. null does less than that. And so on. I'm sure there are many possible combinations. What I'm wondering is if it's possible to algorithmically decide which class of fun

Re: [Haskell-cafe] Limits of deduction

2007-05-11 Thread Rodrigo Queiro
I think it might be impossible. For the function: sumFirst n = sum . take n then for any finite list, we can choose an n large enough that it will examine the whole list, even though the function is able to stop. This means the only way to check is to call it with an infinite list and see if it

Re: [Haskell-cafe] Limits of deduction

2007-05-11 Thread Andrew Coppin
It is possible to determine whether the function always examins the entire input list? Presumably you mean in the case that you examine the entire output list, or do you mean when you only examine the output enough to see if it's a [] or (:) (i.e. to WHNF) ? f1 [] = [] f1 (x:xs) =

Re: [Haskell-cafe] Limits of deduction

2007-05-11 Thread Duncan Coutts
On Fri, 2007-05-11 at 12:10 +0100, Andrew Coppin wrote: > Suppose I have you the source code to some arbitrary function that takes > a list and returns another list. > > It is possible to determine whether the function always examins the > entire input list? Presumably you mean in the case that

[Haskell-cafe] Limits of deduction

2007-05-11 Thread Andrew Coppin
Suppose I have you the source code to some arbitrary function that takes a list and returns another list. It is possible to determine whether the function always examins the entire input list? Or would that be equivilent to solving the Halting Problem? (Last time I checked, the Halting Problem