### 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

How to define Subtypes in Isabelle and what they mean?

type_synonym vs consts in Isabelle definition

Organizing constraints in isabelle in order to model a system

Trouble with Int Theory in Isabelle/HOL

How do I do simple multithreading in Isabelle ML?

Isabelle: Proof on difference between 2 lists

Printing out / showing detailed steps of proof methods (like simp) in a proof in isabelle

Defining disjoint union of different types in Isabelle and more

Case names for locale interpretation

“invalid map function” when defining a corecursive tree

Trying to generalize a bit vector that uses typedef, bool list, and nat length

Factoring out a lemma premise as a definition causes failure in proof method (auto) application in isabelle

How do I convert “thm conjI” to an ASCII string I can save to a file?

Express that a function is constant on a set

What's the difference between the empty sort, 'a::{}, and a sort of “type”, 'a::type

How can I pass a ML value as an argument to an outer syntax command?