From 02c45922fc897047ecce16cc02398338947e7b94 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 3 Jul 2015 11:16:02 +0200 Subject: Fix associativity --- Logic.icl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Logic.icl') 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 -- cgit v1.2.3