A type α has a computable fresh function if it is always possible, for any finite set
of α, to compute a fresh element not in the set.
- fresh : Finset α → α
Given a finite set, returns an element not in the set.
- fresh_notMem (s : Finset α) : fresh s ∉ s
Proof that
freshreturns a fresh element for its input set.
Instances
An existential version of the HasFresh typeclass. This is useful for the sake of brevity
in proofs.
Configuration for the free_union term elaborator.
- singleton : Bool
For
free_union Var, include allx : Var. Defaults to true. - finset : Bool
For
free_union Var, include allxs : Finset Var. Defaults to true.
Instances For
Elaborate a FreeUnionConfig.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given a DecidableEq Var instance, this elaborator automatically constructs
the union of any variables, finite sets of variables, and optionally the
results of provided functions mapping to variables. This is configurable with
optional boolean boolean arguments singleton and finset.
As an example, consider the following:
variable (x : â„•) (xs : Finset â„•) (var : String)
def f (_ : String) : Finset â„• := {1, 2, 3}
def g (_ : String) : Finset â„• := {4, 5, 6}
-- info: ∅ ∪ {x} ∪ xs : Finset ℕ
#check free_union â„•
-- info: ∅ ∪ {x} ∪ xs ∪ f var ∪ g var : Finset ℕ
#check free_union [f, g] â„•
info: ∅ ∪ xs : Finset ℕ
#check free_union (singleton := false) â„•
-- info: ∅ ∪ {x} : Finset ℕ
#check free_union (finset := false) â„•
-- info: ∅ : Finset ℕ
#check free_union (singleton := false) (finset := false) â„•
Equations
- One or more equations did not get rendered due to their size.
Instances For
Elaborator for free_union.
Equations
- One or more equations did not get rendered due to their size.
Instances For
HasFresh α implies a computably infinite type.
All infinite types have an associated (at least noncomputable) fresh function.
This, in conjunction with HasFresh.to_infinite, characterizes HasFresh.
Equations
- Cslib.HasFresh.of_infinite α = { fresh := fun (s : Finset α) => ⋯.choose, fresh_notMem := ⋯ }
Construct a fresh element from an embedding of â„• using Nat.find.
Equations
- Cslib.HasFresh.ofNatEmbed e = { fresh := fun (s : Finset α) => e (Nat.find ⋯), fresh_notMem := ⋯ }
Instances For
Construct a fresh element given a function f with x < f x.
Equations
- Cslib.HasFresh.ofSucc f hf = { fresh := fun (s : Finset α) => if hs : s.Nonempty then f (s.sup' hs id) else default, fresh_notMem := ⋯ }
Instances For
â„• has a computable fresh function.
Equations
- Cslib.instHasFreshNat = Cslib.HasFresh.ofSucc (fun (x : â„•) => x + 1) Nat.lt_add_one
ℤ has a computable fresh function.
Equations
- Cslib.instHasFreshInt = Cslib.HasFresh.ofSucc (fun (x : ℤ) => x + 1) Int.lt_succ
ℚ has a computable fresh function.
Equations
- Cslib.instHasFreshRat = Cslib.HasFresh.ofSucc (fun (x : ℚ) => x + 1) Cslib.instHasFreshRat._proof_1
If α has a computable fresh function, then so does Finset α.
Equations
- Cslib.instHasFreshFinsetOfDecidableEq = Cslib.HasFresh.ofSucc (fun (s : Finset α) => insert (Cslib.fresh s) s) ⋯
If α is inhabited, then Multiset α has a computable fresh function.
Equations
- Cslib.instHasFreshMultisetOfDecidableEqOfInhabited = Cslib.HasFresh.ofSucc (fun (s : Multiset α) => default ::ₘ s) ⋯
ℕ → ℕ has a computable fresh function.
Equations
- Cslib.instHasFreshForallNat = Cslib.HasFresh.ofSucc (fun (f : ℕ → ℕ) (x : ℕ) => f x + 1) Cslib.instHasFreshForallNat._proof_1