Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x9kVo-00000002Cin-1TO5 for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Sep 2026 14:33:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x9kVm-0000000CgSC-17GA for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Sep 2026 14:33:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x9kVl-0000000CgS4-43VX for pgsql-hackers@lists.postgresql.org; Thu, 24 Sep 2026 14:33:21 +0000 Received: from mail-yx2-x0d.google.com ([2607:f8b0:4864:41::d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x9kVh-000000014mW-1zPe for pgsql-hackers@lists.postgresql.org; Thu, 24 Sep 2026 14:33:21 +0000 Received: by mail-yx2-x0d.google.com with SMTP id 956f58d0204a3-673ba589d0dso359082d50.1 for ; Thu, 24 Sep 2026 07:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790260396; x=1790865196; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=qYmV1MLco2VneUuB3BfAROVzMPAMg/q+pvOCwHgSPS0=; b=b0oELKN47MDsuwzUSt8VyrWAqnPvvSzI3kHg3CBiWLna6ILK4y3eIWulP9wBNmsIfj OIN2CGHajxBP/zQ84Xfne+4kWPMBmefR4vOHNUjDMg9RMkUqpuz8/fhI555g5IYENKA2 ns4euqP3nUsXspqLrrDQUXtj+MFLoMEJQXMZGN5HW1aqWEHAxkxv1wNKQXsrt/ZTJ6PV 2TImSGuLVQzB6sHMD2irV+wgpr2lg+DV7w/5FMDkI4Eyv9M3ICBYk/9PTJynUyn83nnA u13tmXSqRM8L5+9Pej5iP9D82rur9vPhDiDF4XHdkHMoAZNjLHlnZJrpzwj7slugV8Yk Kyrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790260396; x=1790865196; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=qYmV1MLco2VneUuB3BfAROVzMPAMg/q+pvOCwHgSPS0=; b=Rk0kuU7UQ87TMZvKzzV3fVgloLI5ZpraI+ovnAgcy6EsSwMrBeqT1b3APw9aI+ZwQg vj3dlubUYl61WOk7VYTJpe79FM20Ss+szSXyoW9YTHhK68TzRKICiJpJwfIUQyoUUul8 o8WD35ao191eegVkPQRbHmUlUwkljJ/X8Qw6hsp0kK2W9Quyx/YlH8nUPDztYO6db8Py FonWlZARS8+ul//d3oaf/i9d7xV2EBlR5VqCzvPE13OFn6/d4//DT/Poobm5SpyLKrQD TF2Vj2zcOjrQQoZ0NmdNz1UZnJlDHnz7T0Bz2P1Ni1PKXUUKuFNLxsrBNbHM5GDNFFs3 daAg== X-Gm-Message-State: AFuF++k1T64rch2GZ9DbbYpEfUxkOXTWo2p0IwxC9YK0ygTSlnlbgh3Q lL6qBMAK94baPq4Y5w3kAH6m/HD970XnD76Lzg+MzR0gwqIfQZk+vXnG3rTibg== X-Gm-Gg: AYBFou0hidAmkBd4fu6jcP98xLsQromTwRSiQzBhTPxaLw00wfP9QB/S9cwK89Iq4Rk THt2Ca5Hwj9FI5+G+AjGsxOBYoWuknMnyOoArFRQKDArKLRAfw9LBOxhpHAoUDQQFnVloZtrtfy lnfzCHFgLaxMROG28eYwk2kRmhPLNFbS3/7zRtqQ4YgKpImLYrcqYrnknCl7U9ox+zlYVLF+tbS 99av0zREX/WDtnhNz/UtFPPhxWpUgmZeQOVJof4yeNUQV46xed4XA1qOf5Tc1qo5I7tyHeTP1ea ss/pb4SL6n87dKhCqxtreUXeIBwsyVOSHuTmEOXrGh4DOCnzkIv99k2RUlkYDRLMdMco4x3G1ym wVdflmKk8NFaO7e0mdZT+LOC7fBAhZrUmDbySX/HRQHfOa+gzDoz4j6Jvms9jT/GzdyM38eg+J0 tir7+UR8xifBe2zvwC0+lBOuddBZozONiFG+XNUloIIhzRS+K3rJpUzbHtbszm4iWi3qz78nsAN PO8f4OUqdJlIDeUQn9WKuz0dA4UTp7eelY9ANNoY+Kq19WaNKbtZF0m8sHmOGHZZkaELnUgGbdw FxXe6mBZv1IR7s8xrYHycm0eWA== X-Received: by 2002:a05:690e:4084:b0:672:bfb4:5f4c with SMTP id 956f58d0204a3-672ed9ce11amr1582157d50.101.1790260395541; Thu, 24 Sep 2026 07:33:15 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-673698c2e1dsm405481d50.5.2026.09.24.07.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 07:33:15 -0700 (PDT) Date: Thu, 24 Sep 2026 09:33:13 -0500 From: Nathan Bossart To: Vik Fearing Cc: PostgreSQL Hackers Subject: Re: Logical Implication Message-ID: References: <37c76707-e6fa-4ee3-b57f-aa0bf1b0bba8@postgresfriends.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I spent some time looking at this one from a few different angles. * NULL behavior: while not a conscious decision of your patch, a straight translation of "a IMPLIES b" to "NOT a OR b" would settle the standard on Kleene logic for material implication [0]. I think that's okay; IIUC that would be the case for any popular SQL database that implements it in a similar fashion. According to Wikipedia, SQL uses "a comment fragment of the Kleene and Łukasiewicz three-valued logic (which differ in their definition of implication; however, SQL defines no such operation)" [1]. This proposal changes that, so it seems worth calling out. * The name: it's hard to imagine another name for this operation. "implies" is pretty commonly used for material implication in other languages, and it reads nicely, so I have no concerns here. * Short circuiting: IIUC the new IMPLIES operation wouldn't be guaranteed to short-circuit, which matches the behavior of AND and OR and thus is probably fine. * Past discussion: I only found a very brief past discussion about this that quickly veered into a discussion about exclusive-OR [2]. * Precedence: Placing it below OR seems to be pretty common, so no concerns there. I don't know where it belongs in relation to INTERSECT, UNION, or EXCEPT, though. Any thoughts about that? * Associativity: The proposal chooses right associativity. I thought about this part the most, and I'm not sure any associativity is desirable. I think we should forbid chained implications for two reasons: 1) if we do it one way and the SQL committee chooses the other, we're in a tight spot, and 2) I cannot come up with any natural examples to illustrate the desired behavior. Take the following example: shipped IMPLIES zip code set IMPLIES ship date in the past Under right associativity, this would translate to NOT shipped OR NOT zip code set OR ship date in the past The former reads as "if shipped, then the zip code is set and the ship date is in the past", but the latter is pretty obviously not that. If "shipped" is true and "zip code" is not set, it would return true, for example. Granted, the user probably should have written shipped IMPLIES (zip code set AND ship date in the past) but that feels like an easy mistake to make, at least to me. I'm not sure left associativity is any better in this regard. On Fri, Sep 11, 2026 at 06:12:51PM +0200, Vik Fearing wrote: > On 11/09/2026 16:10, Nathan Bossart wrote: >> On Fri, Sep 11, 2026 at 03:35:57PM +0200, Vik Fearing wrote: >>> It does not survive a round trip which has precedence with IN being changed >>> to =ANY, BETWEEN changing to <= and >= (BETWEEN SYMMETRIC is even worse), >>> etc; so I don't think that is a problem. >> >> Even though there may be precedence, I think the proposal would be >> strengthened by teaching it to survive the round trip. Since the benefit >> is readability, presumably it would be useful in situations where you're >> reading a CHECK constraint that someone else wrote. > > Perhaps. There is also the precedent of LIKE coming back as ~~ which I think > is a lot worse than getting NOT a OR b  instead of a IMPLIES b.  I am happy > to do the work to round trip IMPLIES but I will wait for more opinions > before I do so.  My own opinion is that it's not worth it. I'm fine with leaving that out for now. [0] https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics [1] https://en.wikipedia.org/wiki/Null_(SQL)#Comparisons_with_NULL_and_the_three-valued_logic_(3VL) [2] https://postgr.es/m/flat/61B8D172-D35A-4715-A793-6EFDD2795E5D%40epcylon.com -- nathan