Intro Lean 3
inductive CrazyType : blah -> helo -> ResultantType
- Resultant type must be a
Prop
orType
.- lean prover gives Prop and Type and alias of
Sort
- All chains of inductive types must eventually terminate at a Prop or Type as the Resultant type.
- lean prover gives Prop and Type and alias of
: A -> B -> C
inductive blehType #C is the Resultant type of blehType.
C : inductive
#check Sort
OUTPUT> Prop :: Type
#check Sort 0
OUTPUT> Prop :: Type
#check Sort 1
OUTPUT> Type :: Type 1
1 Syntax sugar
Below is how to construct type and a b
# sugared but will error
and (a b : Prop) : Prop
inductive | intro : a → b → and a b
# unsugared but notice we omit `a b` in `and a b`
and (a b : Prop) : Prop
inductive | intro : a → b → and
2 logical system
namespace logical_symbols
and (a b : Prop) : Prop
inductive | intro : a → b → and
--sugar for, a -> b -> and a b
--says if you have a proof of 'a' and a proof of 'b' then
--you can build a proof of 'and a b'
or (a b : Prop) : Prop
inductive | intro_left : a → or
| intro_right : b → or
: Prop) : Prop
inductive imply ( a b | intro: (a -> b) -> imply
: Prop) : Prop
inductive iff (a b | intro : (a → b) → (b → a) → iff
Exists {α : Type} (p : α → Prop) : Prop
inductive | intro : ∀a : α, p a → Exists
: Prop
inductive true | intro : true
: Prop
inductive false
: Type} : α → α → Prop
inductive eq {α | refl : ∀a : α, eq a a
P Q : Prop
constants : P
constant x : Q
constant y #check and.intro x y :: and P Q
#check and P Q :: Prop
#check P -> P :: Prop
#check imply P P :: Prop
--original lean version
: P -> P :=
example :P), x
λ (x
--our custom designed version
: imply P P :=
example .intro (λ (x:P), x) imply
Notice we just designed the lean proof system.
The constructor imply.intro
builds the term aka proof for it’s associated inductive type below
: Prop) : Prop
inductive imply ( a b | intro: (a -> b) -> imply
3 Layers of types
Bool and Props are not the same.
- Bool only hold 2 terms, tt and ff.
- Props hold infinitely many terms, as you can make infinitely many
- Props like
imply P P :: Prop
orimply (imply P P) P :: Prop
,etc
- Props like
- Bool
tt :: Bool :: Type
- Props
true.intro :: true :: Prop
There are 2 layers for Props
The 1st layer is designing well-formed Proposition.
The 2nd layer is designing proofs of those Propositions.
layer 1
-------------------------
true :: Prop
layer 2
------------------------- true.intro :: True
In layer 1 we build a tree of well-formed propositions which may or may not be provable through the inductive type definitions .
and (a b : Prop) : Prop
inductive ..
or (a b : Prop) : Prop
inductive ..
: Prop) : Prop
inductive imply ( a b ..
: Prop) : Prop
inductive iff (a b ..
Exists {α : Type} (p : α → Prop) : Prop
inductive ..
: Prop
inductive true ..
: Prop inductive false
P P True
\ / /
and /
\ /
imply
imply (and P P) True :: Prop
In layer 2 we build a tree of proof of the proposition using the term constructors of the inductive types.
# Desugared term constructor `imply` to `imply a b`
: Prop) : Prop
inductive imply ( a b | intro: (a -> b) -> imply a b
: Prop
inductive true | intro : true
Goal is to build a term for `imply (and P P) true`
: imply (and P P) :=
example .intro (λ(x:and P P), true.intro)
imply
:and P P), true.intro :: (a -> b)
λ (x----------------------------------------
.intro :: imply a b imply
\[\cfrac{\cfrac{\square::\mathbb{N} \qquad \square::\mathbb{N}}{\square::Score} \qquad\cfrac{\square::\mathbb{N} \qquad \square::\mathbb{N}}{\square::Score} }{step \square \square :: Prop}\]
But also notice we have to check each type to make sure the chain of types terminate eg.
\[Score :: ... :: Type\]
big::ADJ guy::N
-------------
\ /
subj big guy::S hunts::V
\ /
------------------------- big guy hunts::SENTENCE
4
Tree is Type formation aka designing a wellformed proposition
Imp (And P Q) (And P P) :: Prop
Imp
/ \
And And
/ \ / \
P Q P P
Below is term introduction aka creating a proof. The lambda term below has type
Imp (And P Q) (And P P)
λ (x:And P Q), And.intro (x.right:P) (x.right:P)
\[\cfrac{\cfrac{[P \land Q]^x}{P^{x.right}} \qquad \cfrac{[P \land Q]^x}{P^{x.right}}}{P \land P^{And.intro}}\]