Documentation

Cslib.Foundations.Data.HasFresh

class Cslib.HasFresh (α : Type u) :

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 fresh returns a fresh element for its input set.

Instances
    theorem Cslib.HasFresh.fresh_exists {α : Type u} [HasFresh α] (s : Finset α) :
    ∃ (a : α), a ∉ s

    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 all x : Var. Defaults to true.

    • finset : Bool

      For free_union Var, include all xs : Finset Var. Defaults to true.

    Instances For
      def Cslib.elabFreeUnionConfig :
      Lean.Syntax → Lean.Elab.Tactic.TacticM FreeUnionConfig

      Elaborate a FreeUnionConfig.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def Cslib.freeUnion :
        Lean.ParserDescr

        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
          def Cslib.HasFresh.freeUnion :
          Lean.Elab.Term.TermElab

          Elaborator for free_union.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            instance Cslib.HasFresh.to_infinite (α : Type u) [HasFresh α] :
            Infinite α

            HasFresh α implies a computably infinite type.

            @[implicit_reducible]
            noncomputable instance Cslib.HasFresh.of_infinite (α : Type u) [Infinite α] :

            All infinite types have an associated (at least noncomputable) fresh function. This, in conjunction with HasFresh.to_infinite, characterizes HasFresh.

            Equations
            @[implicit_reducible]
            def Cslib.HasFresh.ofNatEmbed {α : Type u} [DecidableEq α] (e : ℕ ↪ α) :

            Construct a fresh element from an embedding of â„• using Nat.find.

            Equations
            Instances For
              @[implicit_reducible]
              def Cslib.HasFresh.ofSucc {α : Type u} [Inhabited α] [SemilatticeSup α] (f : α → α) (hf : ∀ (x : α), x < f x) :

              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
                @[implicit_reducible]
                instance Cslib.instHasFreshNat :
                HasFresh â„•

                â„• has a computable fresh function.

                Equations
                @[implicit_reducible]

                ℤ has a computable fresh function.

                Equations
                @[implicit_reducible]

                ℚ has a computable fresh function.

                Equations
                @[implicit_reducible]
                instance Cslib.instHasFreshFinsetOfDecidableEq {α : Type u} [DecidableEq α] [HasFresh α] :
                HasFresh (Finset α)

                If α has a computable fresh function, then so does Finset α.

                Equations
                @[implicit_reducible]
                instance Cslib.instHasFreshMultisetOfDecidableEqOfInhabited {α : Type u} [DecidableEq α] [Inhabited α] :
                HasFresh (Multiset α)

                If α is inhabited, then Multiset α has a computable fresh function.

                Equations
                @[implicit_reducible]
                instance Cslib.instHasFreshForallNat :
                HasFresh (ℕ → ℕ)

                ℕ → ℕ has a computable fresh function.

                Equations