### isabelle

#### How to analyze if-expressions in assumptions?

I'm trying to prove the following lemma: lemma if_assumption: "(if a = 1 then 2 else 3) = 2 ⟹ a = 1" apply (cases "a = 1") apply simp_all After simplification I get the following formula: 3 = 2 ⟹ a ≠ 1 ⟹ False The result of if-expression equals 2 iff a equals 1. So, I guess that I can deduce this fact somehow. How to prove this lemma?

Your statement is not correct as you wrote it down. Numbers in Isabelle are polymorphic by default (you can check that by hovering over the numbers while pressing Ctrl). There might be a number type for which 3 = 2 holds (e.g. the finite field {0,1,2}). In that case, a may not be equal to 1. If instead you fix the number type: lemma if_assumption: "(if a = 1 then 2 else 3) = (2::nat) ⟹ a = 1" the proof script you wrote goes through. Or shorter: apply (auto split: if_splits) ... which tells the system to split the if _ then _ else _ into two subgoals.

### Related Links

Embedding SMT in Isabelle/HOL functions

Termination proof for function on datatype involving a map

Isabelle HOLCF doesn't understand fixrec

Isabelle function to find the longest sequence of members of a relation

Is it possible to run Isabelle 2005 proofs with Proof General?

Multicast using Isabelle

Mutual recursion in primcofix

How to prove that addition of a new variable to the expression doesn't change its semantics?

How to define functions with overlapping patterns?

Non-terminating inductive predicates

Parts of mathematics not yet formalized / Isabelle wishlist

Instantiating theorems in Isabelle

Proving a basic identity in Isabelle

Error in an Isabelle function definition taken from lecture notes

Proving the cardinality of a more involved set

Function returns 0 when it should return 1, eliminating parantheses