The%\textit{%#<i>#setoid#</i>#%}%facilitymakesitpossibletoregisternewequivalencerelationstobeunderstoodbytacticslike[rewrite].Forinstance,[Prop]isregisteredasasetoidwiththeequivalencerelation%``%#"#if and only if.#"#%''%Theabilitytoregisternewsetoidscanbeveryusefulinproofsofakindcommoninmath,whereallreasoningisdoneafter%``%#"#modding out by a relation.#"#%''%*)
The%\index{setoids}\textit{%#<i>#setoid#</i>#%}%facilitymakesitpossibletoregisternewequivalencerelationstobeunderstoodbytacticslike[rewrite].Forinstance,[Prop]isregisteredasasetoidwiththeequivalencerelation%``%#"#if and only if.#"#%''%Theabilitytoregisternewsetoidscanbeveryusefulinproofsofakindcommoninmath,whereallreasoningisdoneafter%``%#"#modding out by a relation.#"#%''%
@@ -155,7 +155,7 @@ Theorem m2 : forall P Q R : Prop, P -> Q -> R -> Q.
...
@@ -155,7 +155,7 @@ Theorem m2 : forall P Q R : Prop, P -> Q -> R -> Q.
|[H:_|-_]=>idtacH
|[H:_|-_]=>idtacH
end.
end.
(**Coqprints%``%#"#[H1]#"#%''%.Byapplying[idtac]withanargument,aconvenientdebuggingtoolfor%``%#"#leaking information out of [match]es,#"#%''%weseethatthis[match]firsttriesbinding[H]to[H1],whichcannotbeusedtoprove[Q].Nonetheless,thefollowingvariationonthetacticsucceedsatprovingthegoal:*)
(**Coqprints%``%#"#[H1]#"#%''%.Byapplying%\index{tactics!idtac}%[idtac]withanargument,aconvenientdebuggingtoolfor%``%#"#leaking information out of [match]es,#"#%''%weseethatthis[match]firsttriesbinding[H]to[H1],whichcannotbeusedtoprove[Q].Nonetheless,thefollowingvariationonthetacticsucceedsatprovingthegoal:*)
(*beginthide*)
(*beginthide*)
matchgoalwith
matchgoalwith
...
@@ -180,11 +180,11 @@ Ltac notHyp P :=
...
@@ -180,11 +180,11 @@ Ltac notHyp P :=
end.
end.
(*endthide*)
(*endthide*)
(**Weusetheequalitycheckingthatisbuiltintopattern-matchingtoseeifthereisahypothesisthatmatchesthepropositionexactly.Ifso,weusethe[fail]tactic.Withoutarguments,[fail]signalsnormaltacticfailure,asyoumightexpect.When[fail]ispassedanargument[n],[n]isusedtocountoutwardsthroughtheenclosingcasesofbacktrackingsearch.Inthiscase,[fail1]says%``%#"#fail not just in this pattern-matching branch, but for the whole [match].#"#%''%Thesecondcasewillneverbetriedwhenthe[fail1]isreached.
(**Weusetheequalitycheckingthatisbuiltintopattern-matchingtoseeifthereisahypothesisthatmatchesthepropositionexactly.Ifso,weusethe%\index{tactics!fail}%[fail]tactic.Withoutarguments,[fail]signalsnormaltacticfailure,asyoumightexpect.When[fail]ispassedanargument[n],[n]isusedtocountoutwardsthroughtheenclosingcasesofbacktrackingsearch.Inthiscase,[fail1]says%``%#"#fail not just in this pattern-matching branch, but for the whole [match].#"#%''%Thesecondcasewillneverbetriedwhenthe[fail1]isreached.
(**Thefirstorderofbusinessincraftingour[matcher]tacticwillbeauxiliarysupportforsearchingthroughformulatrees.The[search_prem]tacticimplementsrunningitstacticargument[tac]oneverysubformulaofan[imp]premise.Asittraversesatree,[search_prem]appliessomeoftheabovelemmastorewritethegoaltobringdifferentsubformulastotheheadofthegoal.Thatis,foreverysubformula[P]oftheimplicationpremise,wewant[P]to%``%#"#have a turn,#"#%''%wherethepremiseisrearrangedintotheform[P/\Q]forsome[Q].Thetactic[tac]shouldexpecttoseeagoalinthisformandfocusitsattentiononthefirstconjunctofthepremise.*)
(**Thefirstorderofbusinessincraftingour[matcher]tacticwillbeauxiliarysupportforsearchingthroughformulatrees.The[search_prem]tacticimplementsrunningitstacticargument[tac]oneverysubformulaofan[imp]premise.Asittraversesatree,[search_prem]appliessomeoftheabovelemmastorewritethegoaltobringdifferentsubformulastotheheadofthegoal.Thatis,foreverysubformula[P]oftheimplicationpremise,wewant[P]to%``%#"#have a turn,#"#%''%wherethepremiseisrearrangedintotheform[P/\Q]forsome[Q].Thetactic[tac]shouldexpecttoseeagoalinthisformandfocusitsattentiononthefirstconjunctofthepremise.*)