1-- Sublattices of a bundled lattice and the restricted order2-- Part of Cumulus, the Grace17 mathematics library.3-- Copyright (c) 2026 Grant Passmore.4-- Released under the Apache License 2.0. See LICENSE in the repository root.5-- Authors: Grant Passmore67module Grace.Cumulus.Lattice.Sublattices8import Sublattice9import CompleteLattice1011-- A sublattice is a subset of the points closed under join and meet.12predicate Sublattice (P B : Set) := IsSublattice(points(P), le(P), B)1314notationinfixl68"⊔"=> call2(sup(P), _, _) viahypothesis Sublattice(P, B) for P.points15notationinfixl69"⊓"=> call2(inf(P), _, _) viahypothesis Sublattice(P, B) for P.points16notationinfix50"≤"=> Le(P, _, _) viahypothesis Sublattice(P, B) for P.points1718instance Sublattice.unbundled (P B : Set)19requires sub : Sublattice(P, B)20shows IsSublattice(points(P), le(P), B)21proof22simp [Sublattice]2324theorem Sublattice.mk (A r B : Set)25requires sub : IsSublattice(A, r, B)26shows Sublattice(Order.mk(A, r), B)27proof28unfold Sublattice29rw [Order.mk.points, Order.mk.le]30exact sub3132instance Sublattice.lattice_of (P B : Set)33requires sub : Sublattice(P, B)34shows Lattice(P)35proof36unfold Join.Lattice37exact IsSublattice.lattice with (Sublattice.unbundled with sub)3839theorem Sublattice.subset_points (P B : Set)40requires sub : Sublattice(P, B)41shows B ⊆ points(P)42proof43exact IsSublattice.subset with (Sublattice.unbundled with sub)4445theorem Sublattice.mem_points (P B x : Set)46requires sub : Sublattice(P, B)47requires xIn : x ∈ B48shows x ∈ points(P)49proof50have subset := Sublattice.subset_points with sub51exact subset with x, xIn5253section SublatticeClosure54variable (P B : Set)55hypothesis sub : Sublattice(P, B)5657instance Sublattice.sup_mem (a b : Set)58requires aIn : a ∈ B59requires bIn : b ∈ B60shows a ⊔ b ∈ B61proof62have aCarrier := Sublattice.mem_points with sub, aIn63have bCarrier := Sublattice.mem_points with sub, bIn64rw sup.join65exact IsSublattice.join_closed with (Sublattice.unbundled with sub), aIn, bIn6667instance Sublattice.inf_mem (a b : Set)68requires aIn : a ∈ B69requires bIn : b ∈ B70shows a ⊓ b ∈ B71proof72have aCarrier := Sublattice.mem_points with sub, aIn73have bCarrier := Sublattice.mem_points with sub, bIn74rw inf.meet75exact IsSublattice.meet_closed with (Sublattice.unbundled with sub), aIn, bIn7677end SublatticeClosure7879theorem Sublattice.univ (P : Set)80requires lattice : Lattice(P)81shows Sublattice(P, points(P))82proof83unfold Sublattice84exact IsSublattice.whole with (Lattice.unbundled with lattice)8586theorem Sublattice.inter (P B C : Set)87requires hB : Sublattice(P, B)88requires hC : Sublattice(P, C)89shows Sublattice(P, B ∩ C)90proof91unfold Sublattice92exact IsSublattice.intersection with (Sublattice.unbundled with hB),93 (Sublattice.unbundled with hC)9495-- The order restricted to a subset, as a bundled order.96def suborder (P B : Set) : Set:= Order.mk(B, restrictOrder(le(P), B))9798theorem suborder.points (P B : Set)99shows points(suborder(P, B)) = B100proof101simp [suborder, Order.mk.points]102103theorem suborder.le (P B : Set)104shows le(suborder(P, B)) = restrictOrder(le(P), B)105proof106simp [suborder, Order.mk.le]107108theorem suborder.partial_order (P B : Set)109requires order : PartialOrder(P)110requires hB : B ⊆ points(P)111shows PartialOrder(suborder(P, B))112proof113unfold suborder114apply PartialOrder.mk115exact restrictOrder.partial with (PartialOrder.unbundled with order), hB116117instance Sublattice.lattice_suborder (P B : Set)118requires sub : Sublattice(P, B)119shows Lattice(suborder(P, B))120proof121unfold suborder122apply Lattice.mk123exact IsSublattice.restricted with (Sublattice.unbundled with sub)124125-- Join and meet in the restricted lattice agree with those of P; the126-- restricted operation is written as its application, since the operands127-- lie in both carriers.128section Suborder129variable (P B : Set)130hypothesis sub : Sublattice(P, B)131132theorem Sublattice.sup_suborder (a b : Set)133requires aIn : a ∈ B134requires bIn : b ∈ B135shows call2(sup(suborder(P, B)), a, b) = a ⊔ b136proof137have restricted : Lattice(suborder(P, B)) := Sublattice.lattice_suborder with138 sub139have aCarrier := Sublattice.mem_points with sub, aIn140have bCarrier := Sublattice.mem_points with sub, bIn141have aSub : a ∈ points(suborder(P, B))142rw suborder.points143exact aIn144have bSub : b ∈ points(suborder(P, B))145rw suborder.points146exact bIn147have inner := sup.join at suborder(P, B), a, b with restricted148have outer := sup.join at P, a, b with*149rw [inner, outer, suborder.points, suborder.le]150exact IsSublattice.join with (Sublattice.unbundled with sub), aIn, bIn151152theorem Sublattice.inf_suborder (a b : Set)153requires aIn : a ∈ B154requires bIn : b ∈ B155shows call2(inf(suborder(P, B)), a, b) = a ⊓ b156proof157have restricted : Lattice(suborder(P, B)) := Sublattice.lattice_suborder with158 sub159have aCarrier := Sublattice.mem_points with sub, aIn160have bCarrier := Sublattice.mem_points with sub, bIn161have aSub : a ∈ points(suborder(P, B))162rw suborder.points163exact aIn164have bSub : b ∈ points(suborder(P, B))165rw suborder.points166exact bIn167have inner := inf.meet at suborder(P, B), a, b with restricted168have outer := inf.meet at P, a, b with*169rw [inner, outer, suborder.points, suborder.le]170exact IsSublattice.meet with (Sublattice.unbundled with sub), aIn, bIn171172end Suborder173