Hacker News new | ask | show | jobs
by DaFranker 4228 days ago
Because then what if:

    rel q(y)
     y = true
     y = false
    
    rel p(s, x)
     if(s = ‘a’)
      x = 0
     else
      x = 2
    
    rel main()
     k = q()
     if(k)
      s = 'a'
     else
      s != 'a'
     p(s,x)
     println(x)
Actually, I'd like to know what Cosmos would resolve this to as things stand. Is it just going to decide that | x = 0, | x = 2? Also can I throw probabilities into this code?
1 comments

One property of Cosmos is that there is no boolean type and relations are themselves booleans (q() would be false in this case). Hence, the code would be rather like this:

  rel q()
   true
   false
  ...
  rel main()
   if(q())
    ...
Indeed, having an 'else' that negates the condition would get tough for complicated conditions. Negation-by-failure and soft-cut ('choose') have their own problems in certain circumstances.

Yeah, it's going to decide that | x = 0 | x = 2 (there is no CLP for strings).