fact stringlengths 10 4.79k | type stringclasses 9 values | library stringclasses 44 values | imports listlengths 0 13 | filename stringclasses 718 values | symbolic_name stringlengths 1 76 | docstring stringlengths 10 64.6k ⌀ |
|---|---|---|---|---|---|---|
neutralConfig : Simp.Config := {
zeta := false
beta := false
eta := false
iota := false
proj := false
decide := false
arith := false
autoUnfold := false
ground := false
zetaDelta := false
zetaUnused := false
letToHave := false
} | def | Init.MetaTypes | [
"Init.Core"
] | Init/MetaTypes.lean | neutralConfig | A neutral configuration for `simp`, turning off all reductions and other built-in simplifications. |
NormCastConfig extends Simp.Config where
zeta := false
beta := false
eta := false
proj := false
iota := false | structure | Init.MetaTypes | [
"Init.Core"
] | Init/MetaTypes.lean | NormCastConfig | null |
Occurrences where
/-- All occurrences should be rewritten. -/
| all
/-- A list of indices for which occurrences should be rewritten. -/
| pos (idxs : List Nat)
/-- A list of indices for which occurrences should not be rewritten. -/
| neg (idxs : List Nat)
deriving Inhabited, BEq | inductive | Init.MetaTypes | [
"Init.Core"
] | Init/MetaTypes.lean | Occurrences | Configuration for which occurrences that match an expression should be rewritten. |
ExtractLetsConfig where
/-- If true (default: false), extract lets from subterms that are proofs.
Top-level lets are always extracted. -/
proofs : Bool := false
/-- If true (default: true), extract lets from subterms that are types.
Top-level lets are always extracted. -/
types : Bool := true
/-- If true (default: false), extract lets from subterms that are implicit arguments. -/
implicits : Bool := false
/-- If false (default: true), extracts only top-level lets, otherwise allows descending into subterms.
When false, `proofs` and `types` are ignored, and lets appearing in the types or values of the
top-level lets are not themselves extracted. -/
descend : Bool := true
/-- If true (default: true), descend into forall/lambda/let bodies when extracting. Only relevant when `descend` is true. -/
underBinder : Bool := true
/-- If true (default: false), eliminate unused lets rather than extract them. -/
usedOnly : Bool := false
/-- If true (default: true), reuse local declarations that have syntactically equal values.
Note that even when false, the caching strategy for `extract_let`s may result in fewer extracted let bindings than expected. -/
merge : Bool := true
/-- When merging is enabled, if true (default: true), make use of pre-existing local definitions in the local context. -/
useContext : Bool := true
/-- If true (default: false), then once `givenNames` is exhausted, stop extracting lets. Otherwise continue extracting lets. -/
onlyGivenNames : Bool := false
/-- If true (default: false), then when no name is provided for a 'let' expression, the name is used as-is without making it be inaccessible.
The name still might be inaccessible if the binder name was. -/
preserveBinderNames : Bool := false
/-- If true (default: false), lift non-extractable `let`s as far out as possible. -/
lift : Bool := false | structure | Init.MetaTypes | [
"Init.Core"
] | Init/MetaTypes.lean | ExtractLetsConfig | Configuration for the `extract_lets` tactic. |
LiftLetsConfig extends ExtractLetsConfig where
lift := true
preserveBinderNames := true | structure | Init.MetaTypes | [
"Init.Core"
] | Init/MetaTypes.lean | LiftLetsConfig | Configuration for the `lift_lets` tactic. |
@[method_specs_simp] Add.add_eq_hAdd {α : Type u} [inst : Add α] :
Eq (@Add.add α inst) (@HAdd.hAdd α α α (@instHAdd α inst)) := rfl
@[method_specs_simp] theorem Sub.sub_eq_hSub [Sub α] :
Eq (@Sub.sub α _) (@HSub.hSub α α α _) := rfl
@[method_specs_simp] theorem Mul.mul_eq_hMul [Mul α] :
Eq (@Mul.mul α _) (@HMul.hMul α α α _) := rfl
@[method_specs_simp] theorem Div.div_eq_hDiv [Div α] :
Eq (@Div.div α _) (@HDiv.hDiv α α α _) := rfl
@[method_specs_simp] theorem Mod.mod_eq_hMod [Mod α] :
Eq (@Mod.mod α _) (@HMod.hMod α α α _) := rfl
@[method_specs_simp] theorem Pow.pow_eq_hPow {α β} [Pow α β] :
Eq (@Pow.pow α β _) (@HPow.hPow α β α _) := rfl
@[method_specs_simp] theorem SMul.smul_eq_hSMul {α β} [SMul α β] :
Eq (@SMul.smul α β _) (@HSMul.hSMul α β β _) := rfl
@[method_specs_simp] theorem Mul.mul_eq_smul {α} [Mul α] :
Eq (@Mul.mul α _) (@SMul.smul α α _) := rfl
@[method_specs_simp] theorem Append.append_eq_hAppend [Append α] :
Eq (@Append.append α _) (@HAppend.hAppend α α α _) := rfl
@[method_specs_simp] theorem OrElse.orElse_eq_hOrElse [OrElse α] :
Eq (@OrElse.orElse α _) (@HOrElse.hOrElse α α α _) := rfl
@[method_specs_simp] theorem AndThen.andThen_eq_hAndThen [AndThen α] :
Eq (@AndThen.andThen α _) (@HAndThen.hAndThen α α α _) := rfl
@[method_specs_simp] theorem AndOp.andOp_hAnd [AndOp α] :
Eq (@AndOp.and α _) (@HAnd.hAnd α α α _) := rfl
@[method_specs_simp] theorem XorOp.xor_hXor [XorOp α] :
Eq (@XorOp.xor α _) (@HXor.hXor α α α _) := rfl
@[method_specs_simp] theorem OrOp.or_hOr [OrOp α] :
Eq (@OrOp.or α _) (@HOr.hOr α α α _) := rfl
@[method_specs_simp] theorem ShiftLeft.shiftLeft_hShiftLeft [ShiftLeft α] :
Eq (@ShiftLeft.shiftLeft α _) (@HShiftLeft.hShiftLeft α α α _) := rfl
@[method_specs_simp] theorem ShiftRight.shiftRight_hShiftRight [ShiftRight α] :
Eq (@ShiftRight.shiftRight α _) (@HShiftRight.hShiftRight α α α _) := rfl | theorem | Init.MethodSpecsSimp | [
"Init.Prelude"
] | Init/MethodSpecsSimp.lean | Add.add_eq_hAdd | null |
unsafe lcErased : Type | axiom | Init.Prelude | [] | Init/Prelude.lean | lcErased | Marker for information that has been erased by the code generator. |
unsafe lcAny : Type | axiom | Init.Prelude | [] | Init/Prelude.lean | lcAny | Marker for type dependency that has been erased by the code generator. |
unsafe lcVoid : Type | axiom | Init.Prelude | [] | Init/Prelude.lean | lcVoid | Internal representation of `Void` in the compiler. |
@[inline] id {α : Sort u} (a : α) : α := a | def | Init.Prelude | [] | Init/Prelude.lean | id | The identity function. `id` takes an implicit argument `α : Sort u`
(a type in any universe), and an argument `a : α`, and returns `a`.
Although this may look like a useless function, one application of the identity
function is to explicitly put a type on an expression. If `e` has type `T`,
and `T'` is definitionally equal to `T`, then `@id T' e` typechecks, and Lean
knows that this expression has type `T'` rather than `T`. This can make a
difference for typeclass inference, since `T` and `T'` may have different
typeclass instances on them. `show T' from e` is sugar for an `@id T' e`
expression. |
@[inline] Function.comp {α : Sort u} {β : Sort v} {δ : Sort w} (f : β → δ) (g : α → β) : α → δ :=
fun x => f (g x) | def | Init.Prelude | [] | Init/Prelude.lean | Function.comp | Function composition, usually written with the infix operator `∘`. A new function is created from
two existing functions, where one function's output is used as input to the other.
Examples:
* `Function.comp List.reverse (List.drop 2) [3, 2, 4, 1] = [1, 4]`
* `(List.reverse ∘ List.drop 2) [3, 2, 4, 1] = [1, 4]` |
@[inline] Function.const {α : Sort u} (β : Sort v) (a : α) : β → α :=
fun _ => a | def | Init.Prelude | [] | Init/Prelude.lean | Function.const | The constant function that ignores its argument.
If `a : α`, then `Function.const β a : β → α` is the “constant function with value `a`”. For all
arguments `b : β`, `Function.const β a b = a`.
Examples:
* `Function.const Bool 10 true = 10`
* `Function.const Bool 10 false = 10`
* `Function.const String 10 "any string" = 10` |
letFun {α : Sort u} {β : α → Sort v} (v : α) (f : (x : α) → β x) : β v := f v
set_option checkBinderAnnotations false in | def | Init.Prelude | [] | Init/Prelude.lean | letFun | `letFun v (fun x => b)` is a function version of `have x := v; b`.
This is equal to `(fun x => b) v`, so the value of `x` is not accessible to `b`.
This is in contrast to `let x := v; b`, where the value of `x` is accessible to `b`.
This used to be the way `have`/`let_fun` syntax was encoded,
and there used to be special support for `letFun` in WHNF and `simp`. |
inferInstance {α : Sort u} [i : α] : α := i
set_option checkBinderAnnotations false in | abbrev | Init.Prelude | [] | Init/Prelude.lean | inferInstance | `inferInstance` synthesizes a value of any target type by typeclass
inference. This function has the same type signature as the identity
function, but the square brackets on the `[i : α]` argument means that it will
attempt to construct this argument by typeclass inference. (This will fail if
`α` is not a `class`.) Example:
```
#check (inferInstance : Inhabited Nat) -- Inhabited Nat
def foo : Inhabited (Nat × Nat) :=
inferInstance
example : foo.default = (default, default) :=
rfl
``` |
inferInstanceAs (α : Sort u) [i : α] : α := i
set_option bootstrap.inductiveCheckResultingUniverse false in | abbrev | Init.Prelude | [] | Init/Prelude.lean | inferInstanceAs | `inferInstanceAs α` synthesizes a value of any target type by typeclass
inference. This is just like `inferInstance` except that `α` is given
explicitly instead of being inferred from the target type. It is especially
useful when the target type is some `α'` which is definitionally equal to `α`,
but the instance we are looking for is only registered for `α` (because
typeclass search does not unfold most definitions, but definitional equality
does.) Example:
```
#check inferInstanceAs (Inhabited Nat) -- Inhabited Nat
``` |
PUnit : Sort u where
/-- The only element of the universe-polymorphic unit type. -/
| unit : PUnit | inductive | Init.Prelude | [] | Init/Prelude.lean | PUnit | The canonical universe-polymorphic type with just one element.
It should be used in contexts that require a type to be universe polymorphic, thus disallowing
`Unit`. |
Unit : Type := PUnit | abbrev | Init.Prelude | [] | Init/Prelude.lean | Unit | The canonical type with one element. This element is written `()`.
`Unit` has a number of uses:
* It can be used to model control flow that returns from a function call without providing other
information.
* Monadic actions that return `Unit` have side effects without computing values.
* In polymorphic types, it can be used to indicate that no data is to be stored in a particular
field. |
@[match_pattern] Unit.unit : Unit := PUnit.unit | abbrev | Init.Prelude | [] | Init/Prelude.lean | Unit.unit | The only element of the unit type.
It can be written as an empty tuple: `()`. |
unsafe lcProof {α : Prop} : α | axiom | Init.Prelude | [] | Init/Prelude.lean | lcProof | Auxiliary unsafe constant used by the Compiler when erasing proofs from code.
It may look strange to have an axiom that says "every proposition is true",
since this is obviously unsound, but the `unsafe` marker ensures that the
kernel will not let this through into regular proofs. The lower levels of the
code generator don't need proofs in terms, so this is used to stub the proofs
out. |
unsafe lcCast {α : Sort u} {β : Sort v} (a : α) : β | axiom | Init.Prelude | [] | Init/Prelude.lean | lcCast | Auxiliary unsafe constant used by the Compiler when erasing casts. |
unsafe lcUnreachable {α : Sort u} : α | axiom | Init.Prelude | [] | Init/Prelude.lean | lcUnreachable | Auxiliary unsafe constant used by the Compiler to mark unreachable code.
Like `lcProof`, this is an `unsafe axiom`, which means that even though it is
not sound, the kernel will not let us use it for regular proofs.
Executing this expression to actually synthesize a value of type `α` causes
**immediate undefined behavior**, and the compiler does take advantage of this
to optimize the code assuming that it is not called. If it is not optimized out,
it is likely to appear as a print message saying "unreachable code", but this
behavior is not guaranteed or stable in any way. |
True : Prop where
/-- `True` is true, and `True.intro` (or more commonly, `trivial`)
is the proof. -/
| intro : True | inductive | Init.Prelude | [] | Init/Prelude.lean | True | `True` is a proposition and has only an introduction rule, `True.intro : True`.
In other words, `True` is simply true, and has a canonical proof, `True.intro`
For more information: [Propositional Logic](https://lean-lang.org/theorem_proving_in_lean4/propositions_and_proofs.html#propositional-logic) |
False : Prop | inductive | Init.Prelude | [] | Init/Prelude.lean | False | `False` is the empty proposition. Thus, it has no introduction rules.
It represents a contradiction. `False` elimination rule, `False.rec`,
expresses the fact that anything follows from a contradiction.
This rule is sometimes called ex falso (short for ex falso sequitur quodlibet),
or the principle of explosion.
For more information: [Propositional Logic](https://lean-lang.org/theorem_proving_in_lean4/propositions_and_proofs.html#propositional-logic) |
Empty : Type
set_option bootstrap.inductiveCheckResultingUniverse false in | inductive | Init.Prelude | [] | Init/Prelude.lean | Empty | The empty type. It has no constructors.
Use `Empty.elim` in contexts where a value of type `Empty` is in scope. |
PEmpty : Sort u where | inductive | Init.Prelude | [] | Init/Prelude.lean | PEmpty | The universe-polymorphic empty type, with no constructors.
`PEmpty` can be used in any universe, but this flexibility can lead to worse error messages and more
challenges with universe level unification. Prefer the type `Empty` or the proposition `False` when
possible. |
Not (a : Prop) : Prop := a → False | def | Init.Prelude | [] | Init/Prelude.lean | Not | `Not p`, or `¬p`, is the negation of `p`. It is defined to be `p → False`,
so if your goal is `¬p` you can use `intro h` to turn the goal into
`h : p ⊢ False`, and if you have `hn : ¬p` and `h : p` then `hn h : False`
and `(hn h).elim` will prove anything.
For more information: [Propositional Logic](https://lean-lang.org/theorem_proving_in_lean4/propositions_and_proofs.html#propositional-logic) |
@[macro_inline] False.elim {C : Sort u} (h : False) : C :=
h.rec | def | Init.Prelude | [] | Init/Prelude.lean | False.elim | `False.elim : False → C` says that from `False`, any desired proposition
`C` holds. Also known as ex falso quodlibet (EFQ) or the principle of explosion.
The target type is actually `C : Sort u` which means it works for both
propositions and types. When executed, this acts like an "unreachable"
instruction: it is **undefined behavior** to run, but it will probably print
"unreachable code". (You would need to construct a proof of false to run it
anyway, which you can only do using `sorry` or unsound axioms.) |
@[macro_inline] absurd {a : Prop} {b : Sort v} (h₁ : a) (h₂ : Not a) : b :=
(h₂ h₁).rec | def | Init.Prelude | [] | Init/Prelude.lean | absurd | Anything follows from two contradictory hypotheses. Example:
```
example (hp : p) (hnp : ¬p) : q := absurd hp hnp
```
For more information: [Propositional Logic](https://lean-lang.org/theorem_proving_in_lean4/propositions_and_proofs.html#propositional-logic) |
Eq : α → α → Prop where
/-- `Eq.refl a : a = a` is reflexivity, the unique constructor of the
equality type. See also `rfl`, which is usually used instead. -/
| refl (a : α) : Eq a a | inductive | Init.Prelude | [] | Init/Prelude.lean | Eq | The equality relation. It has one introduction rule, `Eq.refl`.
We use `a = b` as notation for `Eq a b`.
A fundamental property of equality is that it is an equivalence relation.
```
variable (α : Type) (a b c d : α)
variable (hab : a = b) (hcb : c = b) (hcd : c = d)
example : a = d :=
Eq.trans (Eq.trans hab (Eq.symm hcb)) hcd
```
Equality is much more than an equivalence relation, however. It has the important property that every assertion
respects the equivalence, in the sense that we can substitute equal expressions without changing the truth value.
That is, given `h1 : a = b` and `h2 : p a`, we can construct a proof for `p b` using substitution: `Eq.subst h1 h2`.
Example:
```
example (α : Type) (a b : α) (p : α → Prop)
(h1 : a = b) (h2 : p a) : p b :=
Eq.subst h1 h2
example (α : Type) (a b : α) (p : α → Prop)
(h1 : a = b) (h2 : p a) : p b :=
h1 ▸ h2
```
The triangle in the second presentation is a macro built on top of `Eq.subst` and `Eq.symm`, and you can enter it by typing `\t`.
For more information: [Equality](https://lean-lang.org/theorem_proving_in_lean4/quantifiers_and_equality.html#equality) |
@[simp] Eq.ndrec.{u1, u2} {α : Sort u2} {a : α} {motive : α → Sort u1} (m : motive a) {b : α} (h : Eq a b) : motive b :=
h.rec m | abbrev | Init.Prelude | [] | Init/Prelude.lean | Eq.ndrec. | Non-dependent recursor for the equality type. |
@[match_pattern] rfl {α : Sort u} {a : α} : Eq a a := Eq.refl a | def | Init.Prelude | [] | Init/Prelude.lean | rfl | `rfl : a = a` is the unique constructor of the equality type. This is the
same as `Eq.refl` except that it takes `a` implicitly instead of explicitly.
This is a more powerful theorem than it may appear at first, because although
the statement of the theorem is `a = a`, Lean will allow anything that is
definitionally equal to that type. So, for instance, `2 + 2 = 4` is proven in
Lean by `rfl`, because both sides are the same up to definitional equality. |
@[simp] id_eq (a : α) : Eq (id a) a := rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | id_eq | `id x = x`, as a `@[simp]` lemma. |
Eq.subst {α : Sort u} {motive : α → Prop} {a b : α} (h₁ : Eq a b) (h₂ : motive a) : motive b :=
Eq.ndrec h₂ h₁ | theorem | Init.Prelude | [] | Init/Prelude.lean | Eq.subst | The substitution principle for equality. If `a = b ` and `P a` holds,
then `P b` also holds. We conventionally use the name `motive` for `P` here,
so that you can specify it explicitly using e.g.
`Eq.subst (motive := fun x => x < 5)` if it is not otherwise inferred correctly.
This theorem is the underlying mechanism behind the `rw` tactic, which is
essentially a fancy algorithm for finding good `motive` arguments to usefully
apply this theorem to replace occurrences of `a` with `b` in the goal or
hypotheses.
For more information: [Equality](https://lean-lang.org/theorem_proving_in_lean4/quantifiers_and_equality.html#equality) |
@[symm] Eq.symm {α : Sort u} {a b : α} (h : Eq a b) : Eq b a :=
h ▸ rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | Eq.symm | Equality is symmetric: if `a = b` then `b = a`.
Because this is in the `Eq` namespace, if you have a variable `h : a = b`,
`h.symm` can be used as shorthand for `Eq.symm h` as a proof of `b = a`.
For more information: [Equality](https://lean-lang.org/theorem_proving_in_lean4/quantifiers_and_equality.html#equality) |
Eq.trans {α : Sort u} {a b c : α} (h₁ : Eq a b) (h₂ : Eq b c) : Eq a c :=
h₂ ▸ h₁ | theorem | Init.Prelude | [] | Init/Prelude.lean | Eq.trans | Equality is transitive: if `a = b` and `b = c` then `a = c`.
Because this is in the `Eq` namespace, if you have variables or expressions
`h₁ : a = b` and `h₂ : b = c`, you can use `h₁.trans h₂ : a = c` as shorthand
for `Eq.trans h₁ h₂`.
For more information: [Equality](https://lean-lang.org/theorem_proving_in_lean4/quantifiers_and_equality.html#equality) |
@[macro_inline] cast {α β : Sort u} (h : Eq α β) (a : α) : β :=
h.rec a | def | Init.Prelude | [] | Init/Prelude.lean | cast | Cast across a type equality. If `h : α = β` is an equality of types, and
`a : α`, then `a : β` will usually not typecheck directly, but this function
will allow you to work around this and embed `a` in type `β` as `cast h a : β`.
It is best to avoid this function if you can, because it is more complicated
to reason about terms containing casts, but if the types don't match up
definitionally sometimes there isn't anything better you can do.
For more information: [Equality](https://lean-lang.org/theorem_proving_in_lean4/quantifiers_and_equality.html#equality) |
congrArg {α : Sort u} {β : Sort v} {a₁ a₂ : α} (f : α → β) (h : Eq a₁ a₂) : Eq (f a₁) (f a₂) :=
h ▸ rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | congrArg | Congruence in the function argument: if `a₁ = a₂` then `f a₁ = f a₂` for
any (nondependent) function `f`. This is more powerful than it might look at first, because
you can also use a lambda expression for `f` to prove that
`<something containing a₁> = <something containing a₂>`. This function is used
internally by tactics like `congr` and `simp` to apply equalities inside
subterms.
For more information: [Equality](https://lean-lang.org/theorem_proving_in_lean4/quantifiers_and_equality.html#equality) |
congr {α : Sort u} {β : Sort v} {f₁ f₂ : α → β} {a₁ a₂ : α} (h₁ : Eq f₁ f₂) (h₂ : Eq a₁ a₂) : Eq (f₁ a₁) (f₂ a₂) :=
h₁ ▸ h₂ ▸ rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | congr | Congruence in both function and argument. If `f₁ = f₂` and `a₁ = a₂` then
`f₁ a₁ = f₂ a₂`. This only works for nondependent functions; the theorem
statement is more complex in the dependent case.
For more information: [Equality](https://lean-lang.org/theorem_proving_in_lean4/quantifiers_and_equality.html#equality) |
congrFun {α : Sort u} {β : α → Sort v} {f g : (x : α) → β x} (h : Eq f g) (a : α) : Eq (f a) (g a) :=
h ▸ rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | congrFun | Congruence in the function part of an application: If `f = g` then `f a = g a`. |
congrFun' {α : Sort u} {β : Sort v} {f g : α → β} (h : Eq f g) (a : α) : Eq (f a) (g a) :=
h ▸ rfl
/-!
Initialize the Quotient Module, which effectively adds the following definitions:
``` | theorem | Init.Prelude | [] | Init/Prelude.lean | congrFun' | Similar to `congrFun` but `β` does not depend on `α`. |
Quot {α : Sort u} (r : α → α → Prop) : Sort u | opaque | Init.Prelude | [] | Init/Prelude.lean | Quot | null |
Quot.mk {α : Sort u} (r : α → α → Prop) (a : α) : Quot r | opaque | Init.Prelude | [] | Init/Prelude.lean | Quot.mk | null |
Quot.lift {α : Sort u} {r : α → α → Prop} {β : Sort v} (f : α → β) :
(∀ a b : α, r a b → Eq (f a) (f b)) → Quot r → β | opaque | Init.Prelude | [] | Init/Prelude.lean | Quot.lift | null |
Quot.ind {α : Sort u} {r : α → α → Prop} {β : Quot r → Prop} :
(∀ a : α, β (Quot.mk r a)) → ∀ q : Quot r, β q
```
-/
init_quot | opaque | Init.Prelude | [] | Init/Prelude.lean | Quot.ind | null |
unsafe Quot.lcInv {α : Sort u} {r : α → α → Prop} (q : Quot r) : α | axiom | Init.Prelude | [] | Init/Prelude.lean | Quot.lcInv | Low-level quotient types. Quotient types coarsen the propositional equality for a type `α`, so that
terms related by some relation `r` are considered equal in `Quot r`.
Set-theoretically, `Quot r` can seen as the set of equivalence classes of `α` modulo `r`. Functions
from `Quot r` must prove that they respect `r`: to define a function `f : Quot r → β`, it is
necessary to provide `f' : α → β` and prove that for all `x : α` and `y : α`, `r x y → f' x = f' y`.
`Quot` is a built-in primitive:
* `Quot.mk` places elements of the underlying type `α` into the quotient.
* `Quot.lift` allows the definition of functions from the quotient to some other type.
* `Quot.sound` asserts the equality of elements related by `r`.
* `Quot.ind` is used to write proofs about quotients by assuming that all elements are constructed
with `Quot.mk`.
The relation `r` is not required to be an equivalence relation; the resulting quotient type's
equality extends `r` to an equivalence as a consequence of the rules for equality and quotients.
When `r` is an equivalence relation, it can be more convenient to use the higher-level type
`Quotient`.
-/
add_decl_doc Quot
/--
Places an element of a type into the quotient that equates terms according to the provided relation.
Given `v : α` and relation `r : α → α → Prop`, `Quot.mk r v : Quot r` is like `v`, except all
observations of `v`'s value must respect `r`.
`Quot.mk` is a built-in primitive:
* `Quot` is the built-in quotient type.
* `Quot.lift` allows the definition of functions from the quotient to some other type.
* `Quot.sound` asserts the equality of elements related by `r`.
* `Quot.ind` is used to write proofs about quotients by assuming that all elements are constructed
with `Quot.mk`.
-/
add_decl_doc Quot.mk
/--
A reasoning principle for quotients that allows proofs about quotients to assume that all values are
constructed with `Quot.mk`.
`Quot.rec` is analogous to the [recursor](lean-manual://section/recursors) for a structure, and can
be used when the resulting type is not necessarily a proposition.
`Quot.ind` is a built-in primitive:
* `Quot` is the built-in quotient type.
* `Quot.mk` places elements of the underlying type `α` into the quotient.
* `Quot.lift` allows the definition of functions from the quotient to some other type.
* `Quot.sound` asserts the equality of elements related by `r`.
-/
add_decl_doc Quot.ind
/--
Lifts a function from an underlying type to a function on a quotient, requiring that it respects the
quotient's relation.
Given a relation `r : α → α → Prop` and a quotient `Quot r`, applying a function `f : α → β`
requires a proof `a` that `f` respects `r`. In this case, `Quot.lift f a : Quot r → β` computes the
same values as `f`.
Lean's type theory includes a [definitional reduction](lean-manual://section/type-theory) from
`Quot.lift f h (Quot.mk r v)` to `f v`.
`Quot.lift` is a built-in primitive:
* `Quot` is the built-in quotient type.
* `Quot.mk` places elements of the underlying type `α` into the quotient.
* `Quot.sound` asserts the equality of elements related by `r`
* `Quot.ind` is used to write proofs about quotients by assuming that all elements are constructed
with `Quot.mk`; it is analogous to the [recursor](lean-manual://section/recursors) for a
structure.
-/
add_decl_doc Quot.lift
/--
Unsafe auxiliary constant used by the compiler to erase `Quot.lift`. |
HEq : {α : Sort u} → α → {β : Sort u} → β → Prop where
/-- Reflexivity of heterogeneous equality. -/
| refl (a : α) : HEq a a | inductive | Init.Prelude | [] | Init/Prelude.lean | HEq | Heterogeneous equality. `a ≍ b` asserts that `a` and `b` have the same
type, and casting `a` across the equality yields `b`, and vice versa.
You should avoid using this type if you can. Heterogeneous equality does not
have all the same properties as `Eq`, because the assumption that the types of
`a` and `b` are equal is often too weak to prove theorems of interest. One
public important non-theorem is the analogue of `congr`: If `f ≍ g` and `x ≍ y`
and `f x` and `g y` are well typed it does not follow that `f x ≍ g y`.
(This does follow if you have `f = g` instead.) However if `a` and `b` have
the same type then `a = b` and `a ≍ b` are equivalent. |
@[match_pattern] protected HEq.rfl {α : Sort u} {a : α} : HEq a a :=
HEq.refl a | def | Init.Prelude | [] | Init/Prelude.lean | HEq.rfl | A version of `HEq.refl` with an implicit argument. |
eq_of_heq {α : Sort u} {a a' : α} (h : HEq a a') : Eq a a' :=
have : (α β : Sort u) → (a : α) → (b : β) → HEq a b → (h : Eq α β) → Eq (cast h a) b :=
fun _ _ _ _ h₁ =>
h₁.rec (fun _ => rfl)
this α α a a' h rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | eq_of_heq | If two heterogeneously equal terms have the same type, then they are propositionally equal. |
heq_of_eq (h : Eq a a') : HEq a a' :=
Eq.subst h (HEq.refl a) | theorem | Init.Prelude | [] | Init/Prelude.lean | heq_of_eq | Propositionally equal terms are also heterogeneously equal. |
Prod (α : Type u) (β : Type v) where
/--
Constructs a pair. This is usually written `(x, y)` instead of `Prod.mk x y`.
-/
mk ::
/-- The first element of a pair. -/
fst : α
/-- The second element of a pair. -/
snd : β
attribute [unbox] Prod | structure | Init.Prelude | [] | Init/Prelude.lean | Prod | The product type, usually written `α × β`. Product types are also called pair or tuple types.
Elements of this type are pairs in which the first element is an `α` and the second element is a
`β`.
Products nest to the right, so `(x, y, z) : α × β × γ` is equivalent to `(x, (y, z)) : α × (β × γ)`. |
PProd (α : Sort u) (β : Sort v) where
/-- The first element of a pair. -/
fst : α
/-- The second element of a pair. -/
snd : β | structure | Init.Prelude | [] | Init/Prelude.lean | PProd | A product type in which the types may be propositions, usually written `α ×' β`.
This type is primarily used internally and as an implementation detail of proof automation. It is
rarely useful in hand-written code. |
MProd (α β : Type u) where
/-- The first element of a pair. -/
fst : α
/-- The second element of a pair. -/
snd : β | structure | Init.Prelude | [] | Init/Prelude.lean | MProd | A product type in which both `α` and `β` are in the same universe.
It is called `MProd` is because it is the *universe-monomorphic* product type. |
@[pp_using_anonymous_constructor]
And (a b : Prop) : Prop where
/-- `And.intro : a → b → a ∧ b` is the constructor for the And operation. -/
intro ::
/-- Extract the left conjunct from a conjunction. `h : a ∧ b` then
`h.left`, also notated as `h.1`, is a proof of `a`. -/
left : a
/-- Extract the right conjunct from a conjunction. `h : a ∧ b` then
`h.right`, also notated as `h.2`, is a proof of `b`. -/
right : b | structure | Init.Prelude | [] | Init/Prelude.lean | And | `And a b`, or `a ∧ b`, is the conjunction of propositions. It can be
constructed and destructed like a pair: if `ha : a` and `hb : b` then
`⟨ha, hb⟩ : a ∧ b`, and if `h : a ∧ b` then `h.left : a` and `h.right : b`. |
Or (a b : Prop) : Prop where
/-- `Or.inl` is "left injection" into an `Or`. If `h : a` then `Or.inl h : a ∨ b`. -/
| inl (h : a) : Or a b
/-- `Or.inr` is "right injection" into an `Or`. If `h : b` then `Or.inr h : a ∨ b`. -/
| inr (h : b) : Or a b | inductive | Init.Prelude | [] | Init/Prelude.lean | Or | `Or a b`, or `a ∨ b`, is the disjunction of propositions. There are two
constructors for `Or`, called `Or.inl : a → a ∨ b` and `Or.inr : b → a ∨ b`,
and you can use `match` or `cases` to destruct an `Or` assumption into the
two cases. |
Or.intro_left (b : Prop) (h : a) : Or a b :=
Or.inl h | theorem | Init.Prelude | [] | Init/Prelude.lean | Or.intro_left | Alias for `Or.inl`. |
Or.intro_right (a : Prop) (h : b) : Or a b :=
Or.inr h | theorem | Init.Prelude | [] | Init/Prelude.lean | Or.intro_right | Alias for `Or.inr`. |
Or.elim {c : Prop} (h : Or a b) (left : a → c) (right : b → c) : c :=
match h with
| Or.inl h => left h
| Or.inr h => right h | theorem | Init.Prelude | [] | Init/Prelude.lean | Or.elim | Proof by cases on an `Or`. If `a ∨ b`, and both `a` and `b` imply
proposition `c`, then `c` is true. |
Or.resolve_left (h: Or a b) (na : Not a) : b := h.elim (absurd · na) id | theorem | Init.Prelude | [] | Init/Prelude.lean | Or.resolve_left | null |
Or.resolve_right (h: Or a b) (nb : Not b) : a := h.elim id (absurd · nb) | theorem | Init.Prelude | [] | Init/Prelude.lean | Or.resolve_right | null |
Or.neg_resolve_left (h : Or (Not a) b) (ha : a) : b := h.elim (absurd ha) id | theorem | Init.Prelude | [] | Init/Prelude.lean | Or.neg_resolve_left | null |
Or.neg_resolve_right (h : Or a (Not b)) (nb : b) : a := h.elim id (absurd nb) | theorem | Init.Prelude | [] | Init/Prelude.lean | Or.neg_resolve_right | null |
Bool : Type where
/-- The Boolean value `false`, not to be confused with the proposition `False`. -/
| false : Bool
/-- The Boolean value `true`, not to be confused with the proposition `True`. -/
| true : Bool
export Bool (false true) | inductive | Init.Prelude | [] | Init/Prelude.lean | Bool | The Boolean values, `true` and `false`.
Logically speaking, this is equivalent to `Prop` (the type of propositions). The distinction is
public important for programming: both propositions and their proofs are erased in the code generator,
while `Bool` corresponds to the Boolean type in most programming languages and carries precisely one
bit of run-time information. |
@[pp_using_anonymous_constructor]
Subtype {α : Sort u} (p : α → Prop) where
/--
The value in the underlying type that satisfies the predicate.
-/
val : α
/--
The proof that `val` satisfies the predicate `p`.
-/
property : p val
grind_pattern Subtype.property => self.val
set_option linter.unusedVariables.funArgs false in | structure | Init.Prelude | [] | Init/Prelude.lean | Subtype | All the elements of a type that satisfy a predicate.
`Subtype p`, usually written `{ x : α // p x }` or `{ x // p x }`, contains all elements `x : α` for
which `p x` is true. Its constructor is a pair of the value and the proof that it satisfies the
predicate. In run-time code, `{ x : α // p x }` is represented identically to `α`.
There is a coercion from `{ x : α // p x }` to `α`, so elements of a subtype may be used where the
underlying type is expected.
Examples:
* `{ n : Nat // n % 2 = 0 }` is the type of even numbers.
* `{ xs : Array String // xs.size = 5 }` is the type of arrays with five `String`s.
* Given `xs : List α`, `List { x : α // x ∈ xs }` is the type of lists in which all elements are
contained in `xs`. |
@[reducible] optParam (α : Sort u) (default : α) : Sort u := α | def | Init.Prelude | [] | Init/Prelude.lean | optParam | Gadget for optional parameter support.
A binder like `(x : α := default)` in a declaration is syntax sugar for
`x : optParam α default`, and triggers the elaborator to attempt to use
`default` to supply the argument if it is not supplied. |
@[reducible] outParam (α : Sort u) : Sort u := α | def | Init.Prelude | [] | Init/Prelude.lean | outParam | Gadget for marking output parameters in type classes.
For example, the `Membership` class is defined as:
```
class Membership (α : outParam (Type u)) (γ : Type v)
```
This means that whenever a typeclass goal of the form `Membership ?α ?γ` comes
up, Lean will wait to solve it until `?γ` is known, but then it will run
typeclass inference, and take the first solution it finds, for any value of `?α`,
which thereby determines what `?α` should be.
This expresses that in a term like `a ∈ s`, `s` might be a `Set α` or
`List α` or some other type with a membership operation, and in each case
the "member" type `α` is determined by looking at the container type. |
@[reducible] semiOutParam (α : Sort u) : Sort u := α
set_option linter.unusedVariables.funArgs false in | def | Init.Prelude | [] | Init/Prelude.lean | semiOutParam | Gadget for marking semi output parameters in type classes.
Semi-output parameters influence the order in which arguments to type class
instances are processed. Lean determines an order where all non-(semi-)output
parameters to the instance argument have to be figured out before attempting to
synthesize an argument (that is, they do not contain assignable metavariables
created during TC synthesis). This rules out instances such as `[Mul β] : Add
α` (because `β` could be anything). Marking a parameter as semi-output is a
promise that instances of the type class will always fill in a value for that
parameter.
For example, the `Coe` class is defined as:
```
class Coe (α : semiOutParam (Sort u)) (β : Sort v)
```
This means that all `Coe` instances should provide a concrete value for `α`
(i.e., not an assignable metavariable). An instance like `Coe Nat Int` or `Coe
α (Option α)` is fine, but `Coe α Nat` is not since it does not provide a value
for `α`. |
@[reducible] namedPattern {α : Sort u} (x a : α) (h : Eq x a) : α := a | def | Init.Prelude | [] | Init/Prelude.lean | namedPattern | Auxiliary declaration used to implement named patterns like `x@h:p`. |
@[extern "lean_sorry", never_extract]
sorryAx (α : Sort u) (synthetic : Bool) : α | axiom | Init.Prelude | [] | Init/Prelude.lean | sorryAx | Auxiliary axiom used to implement the `sorry` term and tactic.
The `sorry` term/tactic expands to `sorryAx _ (synthetic := false)`.
It is intended for stubbing-out incomplete parts of a value or proof while still having a syntactically correct skeleton.
Lean will give a warning whenever a declaration uses `sorry`, so you aren't likely to miss it,
but you can check if a declaration depends on `sorry` either directly or indirectly by looking for `sorryAx` in the output
of the `#print axioms my_thm` command.
The `synthetic` flag is false when a `sorry` is written explicitly by the user, but it is
set to `true` when a tactic fails to prove a goal, or if there is a type error
in the expression. A synthetic `sorry` acts like a regular one, except that it
suppresses follow-up errors in order to prevent an error from causing a cascade
of other errors because the desired term was not constructed. |
eq_false_of_ne_true : {b : Bool} → Not (Eq b true) → Eq b false
| true, h => False.elim (h rfl)
| false, _ => rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | eq_false_of_ne_true | null |
eq_true_of_ne_false : {b : Bool} → Not (Eq b false) → Eq b true
| true, _ => rfl
| false, h => False.elim (h rfl) | theorem | Init.Prelude | [] | Init/Prelude.lean | eq_true_of_ne_false | null |
ne_false_of_eq_true : {b : Bool} → Eq b true → Not (Eq b false)
| true, _ => fun h => Bool.noConfusion h
| false, h => Bool.noConfusion h | theorem | Init.Prelude | [] | Init/Prelude.lean | ne_false_of_eq_true | null |
ne_true_of_eq_false : {b : Bool} → Eq b false → Not (Eq b true)
| true, h => Bool.noConfusion h
| false, _ => fun h => Bool.noConfusion h | theorem | Init.Prelude | [] | Init/Prelude.lean | ne_true_of_eq_false | null |
Inhabited (α : Sort u) where
/-- `default` is a function that produces a "default" element of any
`Inhabited` type. This element does not have any particular specified
properties, but it is often an all-zeroes value. -/
default : α
export Inhabited (default) | class | Init.Prelude | [] | Init/Prelude.lean | Inhabited | `Inhabited α` is a typeclass that says that `α` has a designated element,
called `(default : α)`. This is sometimes referred to as a "pointed type".
This class is used by functions that need to return a value of the type
when called "out of domain". For example, `Array.get! arr i : α` returns
a value of type `α` when `arr : Array α`, but if `i` is not in range of
the array, it reports a panic message, but this does not halt the program,
so it must still return a value of type `α` (and in fact this is required
for logical consistency), so in this case it returns `default`. |
inductive Nonempty (α : Sort u) : Prop where
/-- If `val : α`, then `α` is nonempty. -/
| intro (val : α) : Nonempty α | class | Init.Prelude | [] | Init/Prelude.lean | inductive | `Nonempty α` is a typeclass that says that `α` is not an empty type,
that is, there exists an element in the type. It differs from `Inhabited α`
in that `Nonempty α` is a `Prop`, which means that it does not actually carry
an element of `α`, only a proof that *there exists* such an element.
Given `Nonempty α`, you can construct an element of `α` *nonconstructively*
using `Classical.choice`. |
Classical.choice {α : Sort u} : Nonempty α → α | axiom | Init.Prelude | [] | Init/Prelude.lean | Classical.choice | **The axiom of choice**. `Nonempty α` is a proof that `α` has an element,
but the element itself is erased. The axiom `choice` supplies a particular
element of `α` given only this proof.
The textbook axiom of choice normally makes a family of choices all at once,
but that is implied from this formulation, because if `α : ι → Type` is a
family of types and `h : ∀ i, Nonempty (α i)` is a proof that they are all
nonempty, then `fun i => Classical.choice (h i) : ∀ i, α i` is a family of
chosen elements. This is actually a bit stronger than the ZFC choice axiom;
this is sometimes called "[global choice](https://en.wikipedia.org/wiki/Axiom_of_global_choice)".
In Lean, we use the axiom of choice to derive the law of excluded middle
(see `Classical.em`), so it will often show up in axiom listings where you
may not expect. You can use `#print axioms my_thm` to find out if a given
theorem depends on this or other axioms.
This axiom can be used to construct "data", but obviously there is no algorithm
to compute it, so Lean will require you to mark any definition that would
involve executing `Classical.choice` or other axioms as `noncomputable`, and
will not produce any executable code for such definitions. |
protected Nonempty.elim {α : Sort u} {p : Prop} (h₁ : Nonempty α) (h₂ : α → p) : p :=
match h₁ with
| intro a => h₂ a | theorem | Init.Prelude | [] | Init/Prelude.lean | Nonempty.elim | The elimination principle for `Nonempty α`. If `Nonempty α`, and we can
prove `p` given any element `x : α`, then `p` holds. Note that it is essential
that `p` is a `Prop` here; the version with `p` being a `Sort u` is equivalent
to `Classical.choice`. |
noncomputable Classical.ofNonempty {α : Sort u} [Nonempty α] : α :=
Classical.choice inferInstance | def | Init.Prelude | [] | Init/Prelude.lean | Classical.ofNonempty | A variation on `Classical.choice` that uses typeclass inference to
infer the proof of `Nonempty α`. |
Pi.instNonempty {α : Sort u} {β : α → Sort v} [(a : α) → Nonempty (β a)] :
Nonempty ((a : α) → β a) :=
Nonempty.intro fun _ => Classical.ofNonempty | instance | Init.Prelude | [] | Init/Prelude.lean | Pi.instNonempty | null |
Pi.instInhabited {α : Sort u} {β : α → Sort v} [(a : α) → Inhabited (β a)] :
Inhabited ((a : α) → β a) where
default := fun _ => default
deriving instance Inhabited for Bool | instance | Init.Prelude | [] | Init/Prelude.lean | Pi.instInhabited | null |
PLift (α : Sort u) : Type u where
/-- Wraps a proof or value to increase its type's universe level by 1. -/
up ::
/-- Extracts a wrapped proof or value from a universe-lifted proposition or type. -/
down : α | structure | Init.Prelude | [] | Init/Prelude.lean | PLift | Lifts a proposition or type to a higher universe level.
`PLift α` wraps a proof or value of type `α`. The resulting type is in the next largest universe
after that of `α`. In particular, propositions become data.
The related type `ULift` can be used to lift a non-proposition type by any number of levels.
Examples:
* `(False : Prop)`
* `(PLift False : Type)`
* `([.up (by trivial), .up (by simp), .up (by decide)] : List (PLift True))`
* `(Nat : Type 0)`
* `(PLift Nat : Type 1)` |
PLift.up_down {α : Sort u} (b : PLift α) : Eq (up (down b)) b := rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | PLift.up_down | Bijection between `α` and `PLift α` |
PLift.down_up {α : Sort u} (a : α) : Eq (down (up a)) a := rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | PLift.down_up | Bijection between `α` and `PLift α` |
NonemptyType := Subtype fun α : Type u => Nonempty α | def | Init.Prelude | [] | Init/Prelude.lean | NonemptyType | `NonemptyType.{u}` is the type of nonempty types in universe `u`.
It is mainly used in constant declarations where we wish to introduce a type
and simultaneously assert that it is nonempty, but otherwise make the type
opaque. |
NonemptyType.type (type : NonemptyType.{u}) : Type u :=
type.val | abbrev | Init.Prelude | [] | Init/Prelude.lean | NonemptyType.type | The underlying type of a `NonemptyType`. |
ULift.up_down {α : Type u} (b : ULift.{v} α) : Eq (up (down b)) b := rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | ULift.up_down | `NonemptyType` is inhabited, because `PUnit` is a nonempty type. -/
instance : Inhabited NonemptyType.{u} where
default := ⟨PUnit, ⟨⟨⟩⟩⟩
/--
Lifts a type to a higher universe level.
`ULift α` wraps a value of type `α`. Instead of occupying the same universe as `α`, which would be
the minimal level, it takes a further level parameter and occupies their maximum. The resulting type
may occupy any universe that's at least as large as that of `α`.
The resulting universe of the lifting operator is the first parameter, and may be written explicitly
while allowing `α`'s level to be inferred.
The related type `PLift` can be used to lift a proposition or type by one level.
Examples:
* `(Nat : Type 0)`
* `(ULift Nat : Type 0)`
* `(ULift Nat : Type 1)`
* `(ULift Nat : Type 5)`
* `(ULift.{7} (PUnit : Type 3) : Type 7)`
-/
-- The universe variable `r` is written first so that `ULift.{r} α` can be used
-- when `s` can be inferred from the type of `α`.
structure ULift.{r, s} (α : Type s) : Type (max s r) where
/-- Wraps a value to increase its type's universe level. -/
up ::
/-- Extracts a wrapped value from a universe-lifted type. -/
down : α
/-- Bijection between `α` and `ULift.{v} α` |
ULift.down_up {α : Type u} (a : α) : Eq (down (up.{v} a)) a := rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | ULift.down_up | Bijection between `α` and `ULift.{v} α` |
PULift.up_down {α : Sort u} (b : PULift.{v} α) : Eq (up (down b)) b := rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | PULift.up_down | Lifts a type or proposition to a higher universe level.
`PULift α` wraps a value of type `α`. It is a generalization of
`PLift` that allows lifting values whose type may live in `Sort s`.
It also subsumes `PLift`.
-/
-- The universe variable `r` is written first so that `ULift.{r} α` can be used
-- when `s` can be inferred from the type of `α`.
structure PULift.{r, s} (α : Sort s) : Sort (max s r 1) where
/-- Wraps a value to increase its type's universe level. -/
up ::
/-- Extracts a wrapped value from a universe-lifted type. -/
down : α
/-- Bijection between `α` and `PULift.{v} α` |
PULift.down_up {α : Sort u} (a : α) : Eq (down (up.{v} a)) a := rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | PULift.down_up | Bijection between `α` and `PULift.{v} α` |
inductive Decidable (p : Prop) where
/-- Proves that `p` is decidable by supplying a proof of `¬p` -/
| isFalse (h : Not p) : Decidable p
/-- Proves that `p` is decidable by supplying a proof of `p` -/
| isTrue (h : p) : Decidable p | class | Init.Prelude | [] | Init/Prelude.lean | inductive | Either a proof that `p` is true or a proof that `p` is false. This is equivalent to a `Bool` paired
with a proof that the `Bool` is `true` if and only if `p` is true.
`Decidable` instances are primarily used via `if`-expressions and the tactic `decide`. In
conditional expressions, the `Decidable` instance for the proposition is used to select a branch. At
run time, this case distinction code is identical to that which would be generated for a
`Bool`-based conditional. In proofs, the tactic `decide` synthesizes an instance of `Decidable p`,
attempts to reduce it to `isTrue h`, and then succeeds with the proof `h` if it can.
Because `Decidable` carries data, when writing `@[simp]` lemmas which include a `Decidable` instance
on the LHS, it is best to use `{_ : Decidable p}` rather than `[Decidable p]` so that non-canonical
instances can be found via unification rather than instance synthesis. |
@[inline_if_reduce, nospecialize] Decidable.decide (p : Prop) [h : Decidable p] : Bool :=
h.casesOn (fun _ => false) (fun _ => true)
export Decidable (isTrue isFalse decide) | def | Init.Prelude | [] | Init/Prelude.lean | Decidable.decide | Converts a decidable proposition into a `Bool`.
If `p : Prop` is decidable, then `decide p : Bool` is the Boolean value
that is `true` if `p` is true and `false` if `p` is false. |
DecidablePred {α : Sort u} (r : α → Prop) :=
(a : α) → Decidable (r a) | abbrev | Init.Prelude | [] | Init/Prelude.lean | DecidablePred | A decidable predicate.
A predicate is decidable if the corresponding proposition is `Decidable` for each possible argument. |
DecidableRel {α : Sort u} {β : Sort v} (r : α → β → Prop) :=
(a : α) → (b : β) → Decidable (r a b) | abbrev | Init.Prelude | [] | Init/Prelude.lean | DecidableRel | A decidable relation.
A relation is decidable if the corresponding proposition is `Decidable` for all possible arguments. |
DecidableEq (α : Sort u) :=
(a b : α) → Decidable (Eq a b) | abbrev | Init.Prelude | [] | Init/Prelude.lean | DecidableEq | Propositional equality is `Decidable` for all elements of a type.
In other words, an instance of `DecidableEq α` is a means of deciding the proposition `a = b` is
for all `a b : α`. |
decEq {α : Sort u} [inst : DecidableEq α] (a b : α) : Decidable (Eq a b) :=
inst a b
set_option linter.unusedVariables false in | def | Init.Prelude | [] | Init/Prelude.lean | decEq | Checks whether two terms of a type are equal using the type's `DecidableEq` instance. |
decide_eq_true : [inst : Decidable p] → p → Eq (decide p) true
| isTrue _, _ => rfl
| isFalse h₁, h₂ => absurd h₂ h₁ | theorem | Init.Prelude | [] | Init/Prelude.lean | decide_eq_true | null |
decide_eq_false : [Decidable p] → Not p → Eq (decide p) false
| isTrue h₁, h₂ => absurd h₁ h₂
| isFalse _, _ => rfl | theorem | Init.Prelude | [] | Init/Prelude.lean | decide_eq_false | null |
of_decide_eq_true [inst : Decidable p] : Eq (decide p) true → p := fun h =>
match (generalizing := false) inst with
| isTrue h₁ => h₁
| isFalse h₁ => absurd h (ne_true_of_eq_false (decide_eq_false h₁)) | theorem | Init.Prelude | [] | Init/Prelude.lean | of_decide_eq_true | null |
of_decide_eq_false [inst : Decidable p] : Eq (decide p) false → Not p := fun h =>
match (generalizing := false) inst with
| isTrue h₁ => absurd h (ne_false_of_eq_true (decide_eq_true h₁))
| isFalse h₁ => h₁ | theorem | Init.Prelude | [] | Init/Prelude.lean | of_decide_eq_false | null |
of_decide_eq_self_eq_true [inst : DecidableEq α] (a : α) : Eq (decide (Eq a a)) true :=
match (generalizing := false) inst a a with
| isTrue _ => rfl
| isFalse h₁ => absurd rfl h₁ | theorem | Init.Prelude | [] | Init/Prelude.lean | of_decide_eq_self_eq_true | null |
@[inline] Bool.decEq (a b : Bool) : Decidable (Eq a b) :=
match a, b with
| false, false => isTrue rfl
| false, true => isFalse (fun h => Bool.noConfusion h)
| true, false => isFalse (fun h => Bool.noConfusion h)
| true, true => isTrue rfl
@[inline] instance : DecidableEq Bool :=
Bool.decEq | def | Init.Prelude | [] | Init/Prelude.lean | Bool.decEq | Decides whether two Booleans are equal.
This function should normally be called via the `DecidableEq Bool` instance that it exists to
support. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.