Congruence Rules
As already noted in other answers, the if_weak_cong congruence if_weak_cong does not allow the simplifier to simplify the branches of the if statement. In this answer, I want to talk a little about using the rules of congruency with the help of a simplifier.
For more information, see also the simplifier chapter in the Isabelle / Isar reference manual (in particular, section 9.3.2).
Matching rules control how simplification descends into terms. They can be used to limit rewriting and provide additional assumptions. By default, if the simplifier encounters the st application, it will go down to both s and t to rewrite them to s' and t' before trying to rewrite the resulting member s' t' .
For each constant (or variable) c, one congruence rule can be registered. if_weak_cong rule If constant is registered by default (which lies in the syntax if ... then ... else ... ):
?b = ?c ⟹ (if ?b then ?x else ?y) = (if ?c then ?x else ?y)
It looks like this: "If you come across the term if ?b then ?x else ?y and ?b , you can simplify it to ?c , rewrite if ?b then ?x else ?y into if ?c then ?x else ?y " . Since matching rules replace the default strategy, this prohibits any rewriting of ?x and ?y
An alternative to if_weak_cong is the strong if_cong congruence if_cong :
⟦ ?b = ?c; (?c ⟹ ?x = ?u); (¬ ?c ⟹ ?y = ?v) ⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)
Pay attention to two assumptions (?c ⟹ ?x = ?u) and (¬ ?c ⟹ ?y = ?v) : they tell the simplicity that he can assume that the condition is satisfied (or does not matter) while simplifying the left ( or right) if branches.
As an example, consider simplification behavior on purpose
if foo ∨ False then ¬foo ∨ False else foo ⟹ False
and suppose we don't know anything about foo . Then,
apply simp : with the if_weak_cong rule this will be simplified to if foo then ¬ foo ∨ False else foo ⟹ False , only the condition is rewrittenapply (simp cong del: if_weak_cong) : Without a congruency rule, this will be simplified if foo then ¬ foo else foo ⟹ False , since the condition and branches are overwrittenapply (simp cong: if_cong del: if_cancel) : With the if_cong rule this goal will be simplified if foo then False else False ⟹ False : The condition foo ∨ False will be rewritten to foo . For the two branches, simplification is now overwritten by foo ⟹ ¬foo ∨ False and ¬foo ⟹ foo ∨ False , which are obviously rewritten to False.
(I removed if_cancel , which usually solves the remaining goal completely)
Lars noschinski
source share