Basic logic properties
This file is one of the earliest imports in mathlib.
Implementation notes
Theorems that require decidability hypotheses are in the namespace "decidable". Classical versions are in the namespace "classical".
In the presence of automation, this whole file may be unnecessary. On the other hand, maybe it is useful for writing automation.
Ex falso, the nondependent eliminator for the empty
type.
Equations
Equations
- empty.decidable_eq = λ (a : empty), a.elim
Equations
- sort.inhabited = {default := punit}
Equations
Equations
Equations
Equations
Ex falso, the nondependent eliminator for the pempty
type.
Wrapper for adding elementary propositions to the type class systems. Warning: this can easily be abused. See the rest of this docstring for details.
Certain propositions should not be treated as a class globally, but sometimes it is very convenient to be able to use the type class system in specific circumstances.
For example, zmod p
is a field if and only if p
is a prime number.
In order to be able to find this field instance automatically by type class search,
we have to turn p.prime
into an instance implicit assumption.
On the other hand, making nat.prime
a class would require a major refactoring of the library,
and it is questionable whether making nat.prime
a class is desirable at all.
The compromise is to add the assumption [fact p.prime]
to zmod.field
.
In particular, this class is not intended for turning the type class system into an automated theorem prover for first order logic.
Declarations about propositional connectives
Declarations about implies
Declarations about not
Declarations about and
Declarations about or
Declarations about distributivity
Declarations about iff
Transfer decidability of b
to decidability of a
, if the propositions are equivalent.
This is the same as decidable_of_iff
but the iff is flipped.
Equations
Prove that a
is decidable by constructing a boolean b
and a proof that b ↔ a
.
(This is sometimes taken as an alternate definition of decidability.)
Equations
De Morgan's laws
Declarations about equality
Transport through trivial families is the identity.
Declarations about quantifiers
Extract an element from a existential statement, using classical.some
.
Equations
- P.some = classical.some P
Show that an element extracted from P : ∃ a, p a
using P.some
satisfies p
.
A predicate holds everywhere on the image of a surjective functions iff it holds everywhere.
Classical lemmas
Construct a function from a default value H0
, and a function to use if there exists a value
satisfying the predicate.
Equations
- classical.exists_cases H0 H = dite (∃ (a : α), p a) (λ (h : ∃ (a : α), p a), H (classical.some h) _) (λ (h : ¬∃ (a : α), p a), H0)
A version of classical.indefinite_description which is definitionally equal to a pair
Equations
This function has the same type as exists.rec_on
, and can be used to case on an equality,
but exists.rec_on
can only eliminate into Prop, while this version eliminates into any universe
using the axiom of choice.
Equations
- exists.classical_rec_on h H = H (classical.some h) _
Declarations about bounded quantifiers
Declarations about nonempty
Equations
Equations
Using classical.choice
, lifts a (Prop
-valued) nonempty
instance to a (Type
-valued)
inhabited
instance. classical.inhabited_of_nonempty
already exists, in
core/init/classical.lean
, but the assumption is not a type class argument,
which makes it unsuitable for some applications.
Equations
Using classical.choice
, extracts a term from a nonempty
type.
Equations
- h.some = classical.choice h
Using classical.choice
, extracts a term from a nonempty
type.