Re: [Cbor] Co-occurrence constraints (Re: CDDL optionality and choices and optionality in CBOR and CDDL)

Rohan Mahy <rohan.mahy@gmail.com> Sat, 13 April 2024 06:47 UTC

Return-Path: <rohan.mahy@gmail.com>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 97890C14CEE3 for <cbor@ietfa.amsl.com>; Fri, 12 Apr 2024 23:47:17 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.095
X-Spam-Level:
X-Spam-Status: No, score=-2.095 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DkeDU1GdkgtT for <cbor@ietfa.amsl.com>; Fri, 12 Apr 2024 23:47:13 -0700 (PDT)
Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1E2DCC14F68B for <cbor@ietf.org>; Fri, 12 Apr 2024 23:47:13 -0700 (PDT)
Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a521fd786beso199057066b.3 for <cbor@ietf.org>; Fri, 12 Apr 2024 23:47:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712990831; x=1713595631; darn=ietf.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=NtZ2GuRHVCAnsOaHloluE5mUg6fW+B7RZm9XYVWuz9o=; b=Yvx47T3FJcCj2et36xLCpEg7rrgogtNjE9qW6SGa4J0iARRjrM+GPGyhsYkk5N5+wu nDQGSwqM35fx5fUl0rIIh/LZ/FJXs8VkP4K7uPzTSbhhZ1+t4UD/2lYFE+j0/G1S1RJj Yl8ue4SuVhWCy1h/hADCtmow8SFcFByIAERCAX9QVBNheBBxUr6/s66oACclhKQZTGSy Nm3OiWGl1x3bIR26EKIGbpN/coO7hV0K8JyRBe81iUgfKu2yCjP/HU+MekdmFW675jxx xOwOrtGrzNhGcwumiuyfIyeCdpH4dDXj+WGxC6i9g/6NhD2Nx5sJBUbcC3AgC49g5Tb4 0DGQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712990831; x=1713595631; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NtZ2GuRHVCAnsOaHloluE5mUg6fW+B7RZm9XYVWuz9o=; b=p9RkvSW1ubiVPrS2BXN3bA+dp+qM8i41MwKaXRZvUPLUhoQ1YNijaQSNuEwbxK8lrB NLqkH/L/UGMcj6pwCuPGBvZA/CcC2N4Qb0DDG1RtJNJLAnzTUatxKzLqIIG1rYyWuyVM HaGwFUGD8yFVx+ptayzYAcb15om+P8Sy/t+tObFOUnPY8KmpteDk4s1F32oerpN+uqUj 2pyU27Kk77We1dsCVljObEwrBtd9vJoEeyTUyMWc6X0iCJj1DvuRlCe6lwjTbadLMNG8 6rBR8J8Tm7e89z9Ye180sdESNXX6hB3UautDQmJpHuekITDQ518GyIFKrnhOKt7UBHwi aIOg==
X-Gm-Message-State: AOJu0YzX15zDCReIbzdPCjK23gyxra3e1WJFj45prg9wB3qKhQEvkwMn jR5OXvDbTHp3ijjSS70bmBBtxKetfFOPKqO50hYx8SNGAPtlIWPZfvdY+cqWA4fFXbkXBhZv6Na eati+sueG5BT/P45nAPdFP5h04DA=
X-Google-Smtp-Source: AGHT+IGAG+2VRJOrDSnV+t8eivqZQ+gYbrkRrGUM8xFXG5ymW68ATcrdej/2gFdGzDm0tSW6qKGnWh3X55ny1q7CyiE=
X-Received: by 2002:a17:906:11da:b0:a51:a0c4:5c83 with SMTP id o26-20020a17090611da00b00a51a0c45c83mr2785852eja.20.1712990830514; Fri, 12 Apr 2024 23:47:10 -0700 (PDT)
MIME-Version: 1.0
References: <CAKoiRubb4GMm1sTq_1XRZt3+-hy+Z8ZXD21DpK5voneXFRcW6A@mail.gmail.com> <0C90A33E-1612-490A-B525-8E9E3379DC88@tzi.org>
In-Reply-To: <0C90A33E-1612-490A-B525-8E9E3379DC88@tzi.org>
From: Rohan Mahy <rohan.mahy@gmail.com>
Date: Fri, 12 Apr 2024 23:46:59 -0700
Message-ID: <CAKoiRubD6YO+2_xbPWbaY314gX5Qb0ZExK61OMiY83_d4K=0Zg@mail.gmail.com>
To: Carsten Bormann <cabo@tzi.org>
Cc: cbor@ietf.org
Content-Type: multipart/alternative; boundary="000000000000f4dda50615f4c105"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/piBcZYpCm9_kSyudDC5eeBI-Wto>
Subject: Re: [Cbor] Co-occurrence constraints (Re: CDDL optionality and choices and optionality in CBOR and CDDL)
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 13 Apr 2024 06:47:17 -0000

Thanks, I'll try that in my data model in the morning.
-r

On Fri, Apr 12, 2024, 23:10 Carsten Bormann <cabo@tzi.org> wrote:

> On 13. Apr 2024, at 02:49, Rohan Mahy <rohan.mahy@gmail.com> wrote:
> >
> > Order = [
> >   food = [ * food_items ],
> >   ( includes_alcohol: true, drinks = [ * drink_items ] ) / (
> includes_alcohol: false, to_go: bool )
> > ]
>
> Almost (modulo some syntax issues).
> The constructs in the parentheses are CDDL groups, so you would need a
> group choice:
>
> > Order = [
> >   food: [ * food_item ],
> >   ( includes_alcohol: true, drinks: [ * drink_item ] //
> >     includes_alcohol: false, to_go: bool )
> > ]
>
> (Note the low operator precedence of group choices.
> I also used the singular form for the items, because each item is just one
> item.)
>
> This approach can solve a certain subset of the use cases that we call
> “co-occurrence constraints”; a more general solution usually requires some
> predicate language that in turn requires a navigation mechanism such as
> JSONPath [2].
>
> BTW:
>
> > bool = true / false
>
> You don’t have to say this, because it already is defined [almost] that
> way in the CDDL prelude [1].
> (Because of the “almost”, you actually cannot say it this way.)
>
> Grüße, Carsten
>
> [1]: https://www.rfc-editor.org/rfc/rfc8610.html#appendix-D
> [2]: https://www.rfc-editor.org/rfc/rfc9535.html
>
>