This doesn't work even though it is the simplest proof of an if
statement that I can think of:
def f [Decidable p] (h : p) : ite p p True := ite p h trivial
It says
application type mismatch
ite p h
argument
h
has type
p : Prop
but is expected to have type
if p then p else True : Prop
I think it is possible to change the "goal" from if p then p else True
to p
using tactics mode, but is it possible to do it without tactics?
The reason I am asking is because I would like to know how to do things without tactics, so that I understand the fundamentals of the language better.
ite p h trivial
is a term of typeProp
, while what you want is a term of typeite p p True
. I believe what you want are the lemmasdif_pos
anddif_neg
(might be called something else in Lean 4). $\endgroup$ite ..
is a term of typeProp
" is not true, the type ofite
is whatever the type of both of its branches is. Which means that thisite
application is not typeable as the two branches have different types, but they are proofs, notProp
s. Because of proof irrelevance, it never makes sense to applyite
to proofs of course. $\endgroup$▸
(akaEq.ndrec
) to make the term well typed:example (p : Prop) [Decidable p] : ite p p True := dite p (fun h => if_pos h ▸ h) (fun h => if_neg h ▸ trivial)
$\endgroup$