The areas / V33. Data structures and computation
Mathlib.Data.Semiquot
53 declarations. Mathlib docs · Source
Semiquotients
A data type for semiquotients, which are classically equivalent to
nonempty sets, but are useful for programming; the idea is that
a semiquotient set S represents some (particular but unknown)
element of S. This can be used to model nondeterministic functions,
which return something in a range of values (represented by the
predicate S) but are not completely determined.
theorem Semiquot.mk'.injEq E0 #
∀ {α : Type u_1} (s : Set α) (val : Trunc ↑s) (s_1 : Set α) (val_1 : Trunc ↑s_1),
({ s := s, val := val } = { s := s_1, val := val_1 }) = (s = s_1 ∧ val ≍ val_1)
theorem Semiquot.get.congr_simp E1 #
∀ {α : Type u_1} (q q_1 : Semiquot α) (e_q : q = q_1) (h : q.IsPure), q.get h = q_1.get ⋯
theorem Semiquot.mk'.inj E1 #
∀ {α : Type u_1} {s : Set α} {val : Trunc ↑s} {s_1 : Set α} {val_1 : Trunc ↑s_1},
{ s := s, val := val } = { s := s_1, val := val_1 } → s = s_1 ∧ val ≍ val_1
def Semiquot.ctorIdx E1 #
{α : Type u_1} → Semiquot α → ℕ
structure Semiquot E1 #
Type u_1 → Type u_1
A member of Semiquot α is classically a nonempty Set α,
and in the VM is represented by an element of α; the relation
between these is that the VM element is required to be a member
of the set s. The specific element of s that the VM computes
is hidden by a quotient construction, allowing for the representation
of nondeterministic functions.
ctor Semiquot.mk' E0 #
{α : Type u_1} → (s : Set α) → Trunc ↑s → Semiquot α
abbrev Semiquot.s E1 #
{α : Type u_1} → Semiquot α → Set α
Set containing some element of α
abbrev Semiquot.val E1 #
{α : Type u_1} → (self : Semiquot α) → Trunc ↑self.s
Assertion of non-emptiness via Trunc
instance Semiquot.instMembership E0 #
{α : Type u_1} → Membership α (Semiquot α)
def Semiquot.mk E1 #
{α : Type u_1} → {a : α} → {s : Set α} → a ∈ s → Semiquot α
Construct a Semiquot α from h : a ∈ s where s : Set α.
theorem Semiquot.ext_s E1 #
∀ {α : Type u_1} {q₁ q₂ : Semiquot α}, q₁ = q₂ ↔ q₁.s = q₂.s
theorem Semiquot.ext E1 #
∀ {α : Type u_1} {q₁ q₂ : Semiquot α}, q₁ = q₂ ↔ ∀ (a : α), a ∈ q₁ ↔ a ∈ q₂
theorem Semiquot.exists_mem E1 #
∀ {α : Type u_1} (q : Semiquot α), ∃ a, a ∈ q
theorem Semiquot.nonempty E1 #
∀ {α : Type u_1} (q : Semiquot α), q.s.Nonempty
def Semiquot.pure E1 #
{α : Type u_1} → α → Semiquot α
pure a is a reinterpreted as an unspecified element of {a}.
theorem Semiquot.mem_pure' E0 #
∀ {α : Type u_1} {a b : α}, a ∈ Semiquot.pure b ↔ a = b
def Semiquot.blur' E1 #
{α : Type u_1} → (q : Semiquot α) → {s : Set α} → q.s ⊆ s → Semiquot α
Replace s in a Semiquot with a superset.
def Semiquot.blur E1 #
{α : Type u_1} → Set α → Semiquot α → Semiquot α
Replace s in a q : Semiquot α with a union s ∪ q.s
theorem Semiquot.blur_eq_blur' E1 #
∀ {α : Type u_1} (q : Semiquot α) (s : Set α) (h : q.s ⊆ s), Semiquot.blur s q = q.blur' h
theorem Semiquot.mem_blur' E0 #
∀ {α : Type u_1} (q : Semiquot α) {s : Set α} (h : q.s ⊆ s) {a : α}, a ∈ q.blur' h ↔ a ∈ s
def Semiquot.ofTrunc E1 #
{α : Type u_1} → Trunc α → Semiquot α
Convert a Trunc α to a Semiquot α.
def Semiquot.toTrunc E1 #
{α : Type u_1} → Semiquot α → Trunc α
Convert a Semiquot α to a Trunc α.
def Semiquot.liftOn E1 #
{α : Type u_1} → {β : Type u_2} → (q : Semiquot α) → (f : α → β) → (∀ a ∈ q, ∀ b ∈ q, f a = f b) → β
If f is a constant on q.s, then q.liftOn f is the value of f
at any point of q.
theorem Semiquot.liftOn_ofMem E1 #
∀ {α : Type u_1} {β : Type u_2} (q : Semiquot α) (f : α → β) (h : ∀ a ∈ q, ∀ b ∈ q, f a = f b),
∀ a ∈ q, q.liftOn f h = f a
def Semiquot.map E1 #
{α : Type u_1} → {β : Type u_2} → (α → β) → Semiquot α → Semiquot β
Apply a function to the unknown value stored in a Semiquot α.
theorem Semiquot.mem_map E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α → β) (q : Semiquot α) (b : β), b ∈ Semiquot.map f q ↔ ∃ a ∈ q, f a = b
def Semiquot.bind E1 #
{α : Type u_1} → {β : Type u_2} → Semiquot α → (α → Semiquot β) → Semiquot β
Apply a function returning a Semiquot to a Semiquot.
theorem Semiquot.mem_bind E0 #
∀ {α : Type u_1} {β : Type u_2} (q : Semiquot α) (f : α → Semiquot β) (b : β), b ∈ q.bind f ↔ ∃ a ∈ q, b ∈ f a
instance Semiquot.instMonad E0 #
Monad Semiquot
theorem Semiquot.map_def E0 #
∀ {α β : Type u_1}, (fun x1 x2 ↦ x1 <$> x2) = Semiquot.map
theorem Semiquot.bind_def E0 #
∀ {α β : Type u_1}, (fun x1 x2 ↦ x1 >>= x2) = Semiquot.bind
theorem Semiquot.mem_pure E0 #
∀ {α : Type u_1} {a b : α}, a ∈ pure b ↔ a = b
theorem Semiquot.mem_pure_self E0 #
∀ {α : Type u_1} (a : α), a ∈ pure a
theorem Semiquot.pure_inj E0 #
∀ {α : Type u_1} {a b : α}, pure a = pure b ↔ a = b
instance Semiquot.instLawfulMonad E0 #
LawfulMonad Semiquot
instance Semiquot.instLE E0 #
{α : Type u_1} → LE (Semiquot α)
instance Semiquot.partialOrder E0 #
{α : Type u_1} → PartialOrder (Semiquot α)
instance Semiquot.instSemilatticeSup E0 #
{α : Type u_1} → SemilatticeSup (Semiquot α)
theorem Semiquot.pure_le E0 #
∀ {α : Type u_1} {a : α} {s : Semiquot α}, pure a ≤ s ↔ a ∈ s
def Semiquot.IsPure E1 #
{α : Type u_1} → Semiquot α → Prop
Assert that a Semiquot contains only one possible value.
def Semiquot.get E1 #
{α : Type u_1} → (q : Semiquot α) → q.IsPure → α
Extract the value from an IsPure semiquotient.
theorem Semiquot.get_mem E1 #
∀ {α : Type u_1} {q : Semiquot α} (p : q.IsPure), q.get p ∈ q
theorem Semiquot.pure_isPure E0 #
∀ {α : Type u_1} (a : α), (pure a).IsPure
theorem Semiquot.isPure_iff E0 #
∀ {α : Type u_1} {s : Semiquot α}, s.IsPure ↔ ∃ a, s = pure a
theorem Semiquot.IsPure.mono E1 #
∀ {α : Type u_1} {s t : Semiquot α}, s ≤ t → t.IsPure → s.IsPure
theorem Semiquot.IsPure.min E1 #
∀ {α : Type u_1} {s t : Semiquot α}, t.IsPure → (s ≤ t ↔ s = t)
theorem Semiquot.isPure_of_subsingleton E1 #
∀ {α : Type u_1} [Subsingleton α] (q : Semiquot α), q.IsPure
def Semiquot.univ E1 #
{α : Type u_1} → [Inhabited α] → Semiquot α
univ : Semiquot α represents an unspecified element of univ : Set α.
instance Semiquot.instInhabited E0 #
{α : Type u_1} → [Inhabited α] → Inhabited (Semiquot α)
theorem Semiquot.mem_univ E0 #
∀ {α : Type u_1} [inst : Inhabited α] (a : α), a ∈ Semiquot.univ
theorem Semiquot.univ_unique E1 #
∀ {α : Type u_1} (I J : Inhabited α), Semiquot.univ = Semiquot.univ
theorem Semiquot.isPure_univ E0 #
∀ {α : Type u_1} [inst : Inhabited α], Semiquot.univ.IsPure ↔ Subsingleton α
instance Semiquot.instOrderTopOfInhabited E0 #
{α : Type u_1} → [Inhabited α] → OrderTop (Semiquot α)