Value of the maximum operator
in the second case of the definition of
This is used in the definition of mmp-encode-c, hence the name.
The
This maximum always exists if the map is not empty. We can establish this by showing that:
With these two theorems in hand,
we use a suitable instance of the helper theorem
Since nibblelist-bytelist-map-sup-len-key is an upper bound, it is greater than or equal to mmp-encode-c-max and any element in the set. This is expressed by two additional linear rules below, whose hypotheses match the ones under which nibblelist-bytelist-map-sup-len-key is an upper bound.
When the map has two or more keys,
nibblelist-bytelist-map-sup-len-key is a strict upper bound,
i.e. it is not equal to any element in the set.
This is proved below by taking the first two keys in the map,
called
Every element of the set, including the maximum if it exists, is less than or equal to the length of every key in the map.
If the map is empty, then all the natural numbers are in the set.
Function:
(defun mmp-encode-c-max.elementp (map x) (declare (xargs :guard (and (nibblelist-bytelist-mapp map) (natp x)))) (mmp-encode-c-exists map x))
Theorem:
(defthm mmp-encode-c-max.uboundp-necc (implies (and (mmp-encode-c-max.uboundp map x) (natp x1) (mmp-encode-c-max.elementp map x1)) (>= (nfix x) x1)))
Theorem:
(defthm booleanp-ofmmp-encode-c-max.uboundp (booleanp (mmp-encode-c-max.uboundp map x)))
Theorem:
(defthm mmp-encode-c-max.existsp-suff (implies (and (natp x) (mmp-encode-c-max.elementp map x) (mmp-encode-c-max.uboundp map x)) (mmp-encode-c-max.existsp map)))
Theorem:
(defthm booleanp-ofmmp-encode-c-max.existsp (booleanp (mmp-encode-c-max.existsp map)))
Function:
(defun mmp-encode-c-max (map) (declare (xargs :guard (nibblelist-bytelist-mapp map))) (if (mmp-encode-c-max.existsp map) (mmp-encode-c-max.existsp-witness map) nil))
Theorem:
(defthm maybe-natp-of-mmp-encode-c-max (acl2::maybe-natp (mmp-encode-c-max map)))
Theorem:
(defthm natp-of-mmp-encode-c-max-equal-mmp-encode-c-max.existsp (equal (natp (mmp-encode-c-max map)) (mmp-encode-c-max.existsp map)))
Theorem:
(defthm natp-of-mmp-encode-c-max-when-mmp-encode-c-max.existsp (implies (mmp-encode-c-max.existsp map) (natp (mmp-encode-c-max map))) :rule-classes :type-prescription)
Theorem:
(defthm mmp-encode-c-max-iff-mmp-encode-c-max.existsp (iff (mmp-encode-c-max map) (mmp-encode-c-max.existsp map)))
Theorem:
(defthm not-mmp-encode-c-max-when-not-mmp-encode-c-max.existsp (implies (not (mmp-encode-c-max.existsp map)) (not (mmp-encode-c-max map))) :rule-classes :type-prescription)
Theorem:
(defthm mmp-encode-c-max.elementp-of-mmp-encode-c-max-when-mmp-encode-c-max.existsp (implies (mmp-encode-c-max.existsp map) (mmp-encode-c-max.elementp map (mmp-encode-c-max map))))
Theorem:
(defthm mmp-encode-c-max.uboundp-of-mmp-encode-c-max-when-existsp (implies (mmp-encode-c-max.existsp map) (mmp-encode-c-max.uboundp map (mmp-encode-c-max map))))
Theorem:
(defthm mmp-encode-c-max-geq-when-mmp-encode-c-max.existsp-linear (implies (and (mmp-encode-c-max.existsp map) (mmp-encode-c-max.elementp map x1) (natp x1)) (>= (mmp-encode-c-max map) x1)) :rule-classes :linear)
Theorem:
(defthm mmp-encode-c-max-geq-when-mmp-encode-c-max.existsp-rewrite (implies (and (mmp-encode-c-max.existsp map) (mmp-encode-c-max.elementp map x1) (natp x1)) (>= (mmp-encode-c-max map) x1)))
Theorem:
(defthm mmp-encode-c-max-leq-when-mmp-encode-c-max.existsp-linear (implies (and (mmp-encode-c-max.existsp map) (mmp-encode-c-max.uboundp map x1) (natp x1)) (<= (mmp-encode-c-max map) x1)) :rule-classes :linear)
Theorem:
(defthm mmp-encode-c-max-leq-when-mmp-encode-c-max.existsp-rewrite (implies (and (mmp-encode-c-max.existsp map) (mmp-encode-c-max.uboundp map x1) (natp x1)) (<= (mmp-encode-c-max map) x1)))
Theorem:
(defthm mmp-encode-c-max.existsp-when-nonempty-and-bounded (implies (and (natp x0) (mmp-encode-c-max.elementp map x0) (natp x1) (mmp-encode-c-max.uboundp map x1)) (mmp-encode-c-max.existsp map)) :rule-classes nil)
Theorem:
(defthm mmp-encode-c-max.equal-when-member-and-ubound (implies (and (natp x) (mmp-encode-c-max.elementp map x) (mmp-encode-c-max.uboundp map x)) (equal (mmp-encode-c-max map) x)) :rule-classes nil)
Theorem:
(defthm mmp-encode-c-max.elementp-of-nibblelist-bytelist-mfix-map (equal (mmp-encode-c-max.elementp (nibblelist-bytelist-mfix map) x) (mmp-encode-c-max.elementp map x)))
Theorem:
(defthm mmp-encode-c-max.elementp-nibblelist-bytelist-mequiv-congruence-on-map (implies (nibblelist-bytelist-mequiv map map-equiv) (equal (mmp-encode-c-max.elementp map x) (mmp-encode-c-max.elementp map-equiv x))) :rule-classes :congruence)
Theorem:
(defthm mmp-encode-c-max.elementp-of-nfix-x (equal (mmp-encode-c-max.elementp map (nfix x)) (mmp-encode-c-max.elementp map x)))
Theorem:
(defthm mmp-encode-c-max.elementp-nat-equiv-congruence-on-x (implies (acl2::nat-equiv x x-equiv) (equal (mmp-encode-c-max.elementp map x) (mmp-encode-c-max.elementp map x-equiv))) :rule-classes :congruence)
Theorem:
(defthm mmp-encode-c-max.elementp-when-not-natp-x (implies (and (syntaxp (not (equal x ''0))) (not (natp x))) (equal (mmp-encode-c-max.elementp map x) (mmp-encode-c-max.elementp map 0))))
Theorem:
(defthm mmp-encode-c-max.uboundp-of-nibblelist-bytelist-mfix-map (equal (mmp-encode-c-max.uboundp (nibblelist-bytelist-mfix map) x) (mmp-encode-c-max.uboundp map x)))
Theorem:
(defthm mmp-encode-c-max.uboundp-nibblelist-bytelist-mequiv-congruence-on-map (implies (nibblelist-bytelist-mequiv map map-equiv) (equal (mmp-encode-c-max.uboundp map x) (mmp-encode-c-max.uboundp map-equiv x))) :rule-classes :congruence)
Theorem:
(defthm mmp-encode-c-max.uboundp-of-nfix-x (equal (mmp-encode-c-max.uboundp map (nfix x)) (mmp-encode-c-max.uboundp map x)))
Theorem:
(defthm mmp-encode-c-max.uboundp-nat-equiv-congruence-on-x (implies (acl2::nat-equiv x x-equiv) (equal (mmp-encode-c-max.uboundp map x) (mmp-encode-c-max.uboundp map x-equiv))) :rule-classes :congruence)
Theorem:
(defthm mmp-encode-c-max.existsp-of-nibblelist-bytelist-mfix-map (equal (mmp-encode-c-max.existsp (nibblelist-bytelist-mfix map)) (mmp-encode-c-max.existsp map)))
Theorem:
(defthm mmp-encode-c-max.existsp-nibblelist-bytelist-mequiv-congruence-on-map (implies (nibblelist-bytelist-mequiv map map-equiv) (equal (mmp-encode-c-max.existsp map) (mmp-encode-c-max.existsp map-equiv))) :rule-classes :congruence)
Theorem:
(defthm mmp-encode-c-max-set-nonempty (mmp-encode-c-max.elementp map 0))
Theorem:
(defthm mmp-encode-c-max-set-bounded (implies (and (nibblelist-bytelist-mapp map) (not (omap::emptyp map))) (mmp-encode-c-max.uboundp map (nibblelist-bytelist-map-sup-len-key map))))
Theorem:
(defthm mmp-encode-c-max-exists (implies (and (nibblelist-bytelist-mapp map) (not (omap::emptyp map))) (mmp-encode-c-max.existsp map)))
Theorem:
(defthm nibblelist-bytelist-map-sup-len-key-geq-mmp-encode-c-max (implies (and (nibblelist-bytelist-mapp map) (not (omap::emptyp map))) (>= (nibblelist-bytelist-map-sup-len-key map) (mmp-encode-c-max map))) :rule-classes :linear)
Theorem:
(defthm nibblelist-bytelist-map-sup-len-key-geq-element (implies (and (nibblelist-bytelist-mapp map) (not (omap::emptyp map)) (mmp-encode-c-max.elementp map x)) (>= (nibblelist-bytelist-map-sup-len-key map) (nfix x))) :rule-classes :linear)
Theorem:
(defthm nibblelist-bytelist-map-sup-len-key-neq-element-when-2+-keys (implies (and (nibblelist-bytelist-mapp map) (not (omap::emptyp map)) (not (equal (omap::size map) 1)) (natp x) (mmp-encode-c-max.elementp map x)) (not (equal (nibblelist-bytelist-map-sup-len-key map) x))))
Theorem:
(defthm mmp-encode-c-max-element-leq-len-key (implies (and (nibblelist-bytelist-mapp map) (natp x) (mmp-encode-c-max.elementp map x) (omap::assoc key map)) (<= x (len key))) :rule-classes ((:linear :trigger-terms ((mmp-encode-c-max.elementp map x)))))
Theorem:
(defthm mmp-encode-c-max-leq-len-key (implies (and (nibblelist-bytelist-mapp map) (not (omap::emptyp map)) (omap::assoc key map)) (<= (mmp-encode-c-max map) (len key))) :rule-classes ((:linear :trigger-terms ((mmp-encode-c-max map)))))
Theorem:
(defthm mmp-encode-c-max.elementp-of-emptyp-map (implies (and (nibblelist-bytelist-mapp map) (omap::emptyp map)) (mmp-encode-c-max.elementp map x)))