aboutsummaryrefslogtreecommitdiff
path: root/Logic.icl
diff options
context:
space:
mode:
authorCamil Staps2015-07-03 11:16:02 +0200
committerCamil Staps2015-07-03 11:16:02 +0200
commit02c45922fc897047ecce16cc02398338947e7b94 (patch)
tree4e7af3276d29340139a561367363920104ff0c91 /Logic.icl
parentTypes, toString (diff)
Fix associativity
Diffstat (limited to 'Logic.icl')
-rw-r--r--Logic.icl12
1 files changed, 5 insertions, 7 deletions
diff --git a/Logic.icl b/Logic.icl
index 0276305..5d5fc26 100644
--- a/Logic.icl
+++ b/Logic.icl
@@ -85,17 +85,15 @@ needs_parentheses_right :: Expr -> Bool
needs_parentheses_right (App2 _ _ (B _)) = False
needs_parentheses_right (App2 _ _ (Atom _)) = False
needs_parentheses_right (App2 _ _ (App1 Not _)) = False
-needs_parentheses_right (App2 _ op1 (App2 _ op2 _)) = binds_stronger op1 op2
+needs_parentheses_right (App2 _ op1 (App2 _ op2 _)) = not (binds_stronger op2 op1)
// Associativity rules
binds_stronger :: Op2 Op2 -> Bool
-binds_stronger And _ = True // And is left-associative
-binds_stronger _ And = False
-binds_stronger Or Or = False // All others are right-associative
-binds_stronger Or _ = True
+binds_stronger _ And = False // And is left-associative
+binds_stronger And _ = True
+binds_stronger Or _ = True // The rest is right-associative
binds_stronger _ Or = False
-binds_stronger Impl Impl = False
binds_stronger Impl _ = True
binds_stronger _ Impl = False
-binds_stronger Equiv Equiv = False
+binds_stronger Equiv Equiv = True