Commit 0848bdb2 authored by Michael Hanus 's avatar Michael Hanus
Browse files

Fix overloading errors

parent b33944ca
......@@ -25,8 +25,11 @@ leqval [x,y] = leq x y <=> ground x /\ ground y |> x .<=. y
runLEQ = runCHR [reflexivity,antisymmetry,idempotence,transitivity]
main10 :: Int -> [LEQ Int]
main10 x = runLEQ $ leq 1 x /\ leq x 1
main11 x y z = runLEQ $ leq x y /\ leq y z /\ leq z x
main12 x y z z' = runLEQ $ leq x y /\ leq z z'
compileLeq =
......
Loading program Leq
main10
:load Leq
main10 x where x free
{x=1} []
main11
main11 (x::Int) y z where x,y,z free
{x=x, y=x, z=x} []
main12
main12 (x::Int) y z z' where x,y,z,z' free
{x=x, y=y, z=z, z'=z'} [Leq z z',Leq x y]
Loading program Bool
main20
:load Bool
main20 x y z where x,y,z free
{x=True, y=True, z=True} []
main21
main21 a b s c where a,b,s,c free
{a=True, b=True, s=False, c=True} []
main22
main22 a b s c where a,b,s,c free
{a=a, b=b, s=s, c=False} [And a b False,Or a b s]
Loading program GCD
:load GCD
main30
[GCD 4]
main31
[GCD 2]
compileGCD
Curry interface to CHR(Prolog) written to GCDCHR.curry
Loading program GCDCHR
solveCHR $ gcdanswer x / gcd 206 / gcd 40 where x free
:load GCDCHR
solveCHR $ gcdanswer x /\ gcd 206 /\ gcd 40 where x free
{x=2} True
Loading program Fib
main41
:load Fib
main41 x where x free
{x=21} [Fib 7 21,Fib 4 5,Fib 2 2,Fib 3 3,Fib 5 8,Fib 6 13]
compileFib
Curry interface to CHR(Prolog) written to FIBCHR.curry
Loading program FIBCHR
solveCHR $ fib 20 x where x free
:load FIBCHR
solveCHR $ fib 20 x where x free
{x=10946} True
Loading program FD
main50
:load FD
main50 x y where x,y free
{x=1, y=1} []
main51
main51 x where x free
{x=3} []
main52
main52 [x,y,z] where x,y,z free
{x=2, y=2, z=2} []
main53
main53 xs where xs free
{xs=[2,3,1]} []
{xs=[3,2,1]} []
{xs=[1,3,2]} []
{xs=[3,1,2]} []
{xs=[1,2,3]} []
{xs=[2,1,3]} []
main55
main55 xs where xs free
{xs=[4,3,2,1]} []
{xs=[2,3,4,1]} []
{xs=[4,3,1,2]} []
{xs=[1,3,4,2]} []
{xs=[2,3,1,4]} []
{xs=[1,3,2,4]} []
Loading program UnionFind
:load UnionFind
main60
[Root 1,Arrow 2 1,Root 4,Root 3]
main61
main61 x where x free
{x=1} [Root 4,Root 3,Arrow 2 1,Root 1]
main62
main62 x y where x,y free
{x=1, y=3} [Root 4,Arrow 2 1,Arrow 1 3,Root 3]
main63
[Root 5,Arrow 3 5,Arrow 4 3,Root 1,Arrow 2 1]
main64
main64 x y where x,y free
{x=1, y=5} [Root 1,Arrow 2 1,Arrow 4 3,Arrow 3 5,Root 5]
main65
main65 x y where x,y free
{x='a', y='e'} [Root 'a',Arrow 'b' 'a',Arrow 'd' 'c',Arrow 'c' 'e',Root 'e']
compileUF
Curry interface to CHR(Prolog) written to UFCHR.curry
Loading program UFCHR
solveCHR $ andCHR [make 1, make 2, make 3, make 4, make 5, union 1 2, union 3 4, union 5 3, find 2 x, find 4 y] where x,y free
:load UFCHR
solveCHR $ andCHR [make 1, make 2, make 3, make 4, make 5, union 1 2, union 3 4, union 5 3, find 2 x, find 4 y] where x,y free
{x=1, y=5} True
Loading program Primes
:load Primes
main70
[Prime 2,Prime 19,Prime 17,Prime 3,Prime 13,Prime 11,Prime 7,Prime 5]
Loading program Gauss
main80
:load Gauss
main80 x y where x,y free
{x=2.0, y=1.0} []
main81
main81 x y where x,y free
{x=5.0, y=2.0} []
main82
main82 x y where x,y free
{x=2.0, y=2.0} []
main85
main85 i where i free
{i=0.007692307692307692} []
main86
main86 i where i free
{i=0.0384160756501182} []
......@@ -31,22 +31,29 @@ linkTo [a,b] = link a b /\ root a /\ root b <=> b ~> a /\ root a
runUF = runCHR [makeI,unionI,findNode,findRoot,linkEq,linkTo]
main60 :: [UF Int]
main60 = runUF $ andCHR [make 1, make 2, make 3, make 4, union 1 2]
--> [Root 1,Arrow 2 1,Root 4,Root 3]
main61 :: Int -> [UF Int]
main61 x = runUF $ andCHR [2 ~> 1,root 1,root 4,root 3, find 2 x] --> x=1
main62 :: Int -> Int -> [UF Int]
main62 x y = runUF $ andCHR [2 ~> 1,root 1,root 4,root 3, find 2 x,
union 3 2, find 2 y]
--> x=1, y=3
main63 :: [UF Int]
main63 = runUF $ andCHR [make 1, make 2, make 3, make 4, make 5,
union 1 2, union 3 4, union 5 3]
main64 :: Int -> Int -> [UF Int]
main64 x y = runUF $ andCHR
[make 1, make 2, make 3, make 4, make 5,
union 1 2, union 3 4, union 5 3, find 2 x, find 4 y] --> x=1, y=5
-- union/find on character elements:
main65 :: Char -> Char -> [UF Char]
main65 x y =
runUF $ andCHR $ map make "abcde" ++
[union 'a' 'b', union 'c' 'd', union 'e' 'c',
......
......@@ -19,96 +19,56 @@ fi
LOGFILE=xxx$$
$CURRYBINDIR/cleancurry
cat << EOM | $CURRYBIN -q :set -interactive :set v0 :set printdepth 0 :set -time | tee $LOGFILE
:!echo Loading program Leq
cat << EOM | $CURRYBIN -q :set -interactive :set v0 :set printdepth 0 :set -time :set +echo | tee $LOGFILE
:load Leq
:!echo main10
main10 x where x free
:!echo main11
main11 (x::Int) y z where x,y,z free
:!echo main12
main12 (x::Int) y z z' where x,y,z,z' free
:!echo Loading program Bool
:load Bool
:!echo main20
main20 x y z where x,y,z free
:!echo main21
main21 a b s c where a,b,s,c free
:!echo main22
main22 a b s c where a,b,s,c free
:!echo Loading program GCD
:load GCD
:!echo main30
main30
:!echo main31
main31
compileGCD
:!echo Loading program GCDCHR
:load GCDCHR
:!echo solveCHR $ gcdanswer x /\ gcd 206 /\ gcd 40 where x free
solveCHR $ gcdanswer x /\ gcd 206 /\ gcd 40 where x free
:!echo Loading program Fib
:load Fib
:!echo main41
main41 x where x free
compileFib
:!echo Loading program FIBCHR
:load FIBCHR
:!echo solveCHR $ fib 20 x where x free
solveCHR $ fib 20 x where x free
:!echo Loading program FD
:load FD
:!echo main50
main50 x y where x,y free
:!echo main51
main51 x where x free
:!echo main52
main52 [x,y,z] where x,y,z free
:!echo main53
main53 xs where xs free
:!echo main55
main55 xs where xs free
:!echo Loading program UnionFind
:load UnionFind
:!echo main60
main60
:!echo main61
main61 x where x free
:!echo main62
main62 x y where x,y free
:!echo main63
main63
:!echo main64
main64 x y where x,y free
:!echo main65
main65 x y where x,y free
compileUF
:!echo Loading program UFCHR
:load UFCHR
:!echo solveCHR $ andCHR [make 1, make 2, make 3, make 4, make 5, union 1 2, union 3 4, union 5 3, find 2 x, find 4 y] where x,y free
solveCHR $ andCHR [make 1, make 2, make 3, make 4, make 5, union 1 2, union 3 4, union 5 3, find 2 x, find 4 y] where x,y free
:!echo Loading program Primes
:load Primes
:!echo main70
main70
:!echo Loading program Gauss
:load Gauss
:!echo main80
main80 x y where x,y free
:!echo main81
main81 x y where x,y free
:!echo main82
main82 x y where x,y free
:!echo main85
main85 i where i free
:!echo main86
main86 i where i free
EOM
......@@ -117,6 +77,7 @@ for p in GCDCHR FIBCHR UFCHR GAUSSCHR ; do
$CURRYBINDIR/cleancurry $p
/bin/rm -f $p*
done
$CURRYBINDIR/cleancurry
################ end of tests ####################
if [ $VERBOSE = yes ] ; then
cat $LOGFILE
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment