Skip to main content
edited tags
Link
chyanog
  • 15.8k
  • 3
  • 41
  • 83
added 447 characters in body
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489

…I get the truth: Refine is not available for the logical judgement,and the "right" answer for the first sample is just a illusion, that's just because a and b don't have a explicit relationship so the assumption inside Refine is considered as something meaningless by Reduce, the process is similar to:

Reduce[{Refine[a, b == 3] == 1, Refine[b, a == 4] == 2}]
(* b == 2 && a == 1 *)

OK, now it's all clear 囧.


…I get the truth: Refine is not available for the logical judgement,and the "right" answer for the first sample is just a illusion, that's just because a and b don't have a explicit relationship so the assumption inside Refine is considered as something meaningless by Reduce, the process is similar to:

Reduce[{Refine[a, b == 3] == 1, Refine[b, a == 4] == 2}]
(* b == 2 && a == 1 *)

OK, now it's all clear 囧.

added 1941 characters in body
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489

…I forgot a important thing: in logic, if $p$ is false and $q$ is true, then $p\Rightarrow q$ is still true, so my first two translations for the liar problem is incomplete and the third one is correct because I unconsciously add the missing rule in If, so my second sample should be modified to:

Reduce[Implies[b == True, a == ! b] && 
       Implies[b == False, a == b] && 
       Implies[a == True, b == True] && 
       Implies[a == False, b == False], {a, b}]
(* 
   (a == False && b == False && False - True != 0) || 
   (a - False) (-b + False) (a - True) (b - True) != 0 
 *)

Though the result is still a little strange, at least this time the right answer is involved in it, and together with the comment from @Daniel Lichtblau it's not that unacceptable now.

And of course the answer from @halirutan using !Xor is terser.

And had I noticed the correct syntax for SatisfiabilityInstances earlier, perhaps I would have lost my curiosity and this question wouldn't exist anymore…:

SatisfiabilityInstances[Implies[b == True, a == ! b] && 
                        Implies[b == False, a == b] && 
                        Implies[a == True, b == True] && 
                        Implies[a == False, b == False], {a, b}]
(* {{False, False}} *)

SatisfiabilityInstances[If[b == True, a == ! b, a == b] && 
                        If[a == True, b == True, b == False], {a, b}]
(* {{False, False}} *)

However, I'm still unable to give a good explanation for my first sample: as we've seen, it gives an answer similar to the second sample, but:

SatisfiabilityInstances[Refine[a, b == True] == ! b && 
                        Refine[a, b == False] == b && 
                        Refine[b, a == True] == True && 
                        Refine[b, a == False] == False, {a, b}] 
(* {} *)

…Why?


…I forgot a important thing: in logic, if $p$ is false and $q$ is true, then $p\Rightarrow q$ is still true, so my first two translations for the liar problem is incomplete and the third one is correct because I unconsciously add the missing rule in If, so my second sample should be modified to:

Reduce[Implies[b == True, a == ! b] && 
       Implies[b == False, a == b] && 
       Implies[a == True, b == True] && 
       Implies[a == False, b == False], {a, b}]
(* 
   (a == False && b == False && False - True != 0) || 
   (a - False) (-b + False) (a - True) (b - True) != 0 
 *)

Though the result is still a little strange, at least this time the right answer is involved in it, and together with the comment from @Daniel Lichtblau it's not that unacceptable now.

And of course the answer from @halirutan using !Xor is terser.

And had I noticed the correct syntax for SatisfiabilityInstances earlier, perhaps I would have lost my curiosity and this question wouldn't exist anymore…:

SatisfiabilityInstances[Implies[b == True, a == ! b] && 
                        Implies[b == False, a == b] && 
                        Implies[a == True, b == True] && 
                        Implies[a == False, b == False], {a, b}]
(* {{False, False}} *)

SatisfiabilityInstances[If[b == True, a == ! b, a == b] && 
                        If[a == True, b == True, b == False], {a, b}]
(* {{False, False}} *)

However, I'm still unable to give a good explanation for my first sample: as we've seen, it gives an answer similar to the second sample, but:

SatisfiabilityInstances[Refine[a, b == True] == ! b && 
                        Refine[a, b == False] == b && 
                        Refine[b, a == True] == True && 
                        Refine[b, a == False] == False, {a, b}] 
(* {} *)

…Why?

Tweeted twitter.com/#!/StackMma/status/264769877988999168
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
Loading