Documentation

Cedar.Thm.Ext.IPAddr

IPAddr parser correctness #

parse_sound, parse_complete, and parse_eq_none_iff characterize exactly when Cedar.Spec.Ext.IPAddr.ip (a.k.a. ip) succeeds, in terms of the grammar-level IsWfIPNet predicate and declarative IsIPNetValue relation. Its two branches use v4Value and v6Value to give the denotation of the same components that witness the input rendering. The parser-independent bridge lemmas they build on live in Cedar.Thm.Ext.IPAddr.Lemmas.

Well-formedness and valuation #

Well-formed IP-net syntax is exactly syntax to which the grammar assigns some IPNet.

Soundness #

Soundness of IPAddr.ip: if parsing succeeds, the declarative grammar relation assigns the input exactly the returned IPNet.

Completeness #

theorem Cedar.Thm.IPAddr.parse_complete_v4 {v : V4Components} {pre : Option String} (hsyn : v.syntaxWf) (hcon : v.constraintsWf) (hpre : IsWfOptionalPrefix 2 (Spec.Ext.IPAddr.ADDR_SIZE Spec.Ext.IPAddr.V4_WIDTH) pre) :
Spec.Ext.IPAddr.ip (v.asString ++ match pre, hpre with | none, hpre => "" | some p, hpre => "/" ++ p) = some (v4Value v pre)

Completeness for the V4 form: a well-formed V4 string parses to its v4Value.

theorem Cedar.Thm.IPAddr.parse_complete_v6 {v : V6Components} {pre : Option String} (hsyn : v.syntaxWf) (hpre : IsWfOptionalPrefix 3 (Spec.Ext.IPAddr.ADDR_SIZE Spec.Ext.IPAddr.V6_WIDTH) pre) :
Spec.Ext.IPAddr.ip (v.asString ++ match pre, hpre with | none, hpre => "" | some p, hpre => "/" ++ p) = some (v6Value v pre)

Completeness for the V6 form: a well-formed V6 string parses to its v6Value.

Completeness of IPAddr.ip: if the grammar assigns str the value net, parsing returns that exact IPNet.

Exact parser characterization: parsing succeeds with net precisely when the declarative grammar relation assigns the input that IPNet.

theorem Cedar.Thm.IPAddr.isIPNetValue_unique {str : String} {net₁ net₂ : Spec.Ext.IPAddr.IPNet} (h₁ : IsIPNetValue str net₁) (h₂ : IsIPNetValue str net₂) :
net₁ = net₂

The relational value specification is single-valued: an IP-net string denotes at most one IPNet.

Failure characterization #

Failure characterization: IPAddr.ip rejects exactly the strings that are not well-formed IP-nets. (There is no overflow condition — the grammar's field bounds already exclude out-of-range values.)

Roundtrip #

parse ∘ toString roundtrip: parsing the canonical representation recovers the original IP-net.

theorem Cedar.Thm.IPAddr.toString_injective (net net' : Spec.Ext.IPAddr.IPNet) (h : toString net = toString net') :
net = net'

toString is injective: distinct IP-nets produce distinct canonical strings.

Equal normal form iff equal value: normalization decides IP-net equality.