(* As an example, we use finite sets. The following command recreates the environment in which
the type of finite sets was created and allows us to do transferring on this type. *) context includes fset.lifting begin
subsection‹1. A missing transfer rule›
(* We will simulate the situation in which there is not any transfer rules for fempty. *) declare bot_fset.transfer[transfer_rule del] fempty_transfer[transfer_rule del]
(* We want to prove the following theorem about fcard by transfer *) lemma"fcard (A |-| {|x|}) ≤ fcard A" apply transfer (* Transfercomplainsthatitcouldnotfindatransferrulefor|-|withamatchingtransfer relation.Anexperiencedusercouldnoticethat{||}(in{|x|},whichisspecialsyntaxfor finsertx{||})wastransferredto{||}byaadefaultreflexivitytransferrule(becausethere wasnotanygenuinetransferrulefor{||})andfcardwastransferredtocardusingthetransfer relationpcr_fset.Thereforetransferislookingforatransferrulefor|-|withatransfer relationthatmixes(=)andpcr_fset. Thissituationmightbeconfusingbecausetherealproblem(amissingtransferrule)propagates duringthetransferringalgorithmandmanifestslaterinanobfuscatedway.Fortunately, wecouldinspectthebehavioroftransferinamoreinteractivewaytopindowntherealproblem.
*) oops
lemma"fcard (A |-| {|x|}) ≤ fcard A" apply transfer_start (* Setups 8 goals for 8 transfer rules that have to be found and the result as the 9th goal, which
gets synthesized to the final result of transferring when we find the 8 transfer rules. *) apply transfer_step apply transfer_step (* We can see that the default reflexivity transfer rule was applied and |\<in>|
was transferred to |\<in>| \<Longrightarrow> there is no genuine transfer rule for |\<in>|. *) apply transfer_step defer apply transfer_step apply transfer_step apply transfer_step apply transfer_step apply transfer_end oops
(* We provide a transfer rule for {||}. *) lemma [transfer_rule]: "pcr_fset A {} {||}" by (rule bot_fset.transfer)
lemma"fcard (A |-| {|x|}) ≤ fcard A" apply transfer_start apply transfer_step apply transfer_step (* The new transfer rule was selected and |\<in>| was transferred to \<in>. *) apply transfer_step+ apply transfer_end by (rule card_Diff1_le)
(* Of course in the real life, we would use transfer instead of transfer_start, transfer_step+ and
transfer_end. *) lemma"fcard (A |-| {|x|}) ≤ fcard A" by transfer (rule card_Diff1_le)
subsection‹2. Unwanted instantiation of a transfer relation variable›
(* We want to prove the following fact. *) lemma"finite (UNIV :: 'a::finite fset set)" apply transfer (* Transfer does not do anything here. *) oops
(* Let us inspect interactively what happened. *) lemma"finite (UNIV :: 'a::finite fset set)" apply transfer_start apply transfer_step (* Herewecanrealizethatnotanexpectedtransferrulewaschosen. WestumbleduponalimitationofTransfer:thetoolusedtheruleLifting_Set.UNIV_transfer, whichtransfersUNIVtoUNIVandassumesthatthetransferrelationhastobebi-total. Theproblemisthatatthispointthetransferrelationisnotknown(itisrepresentedby aschematicvariable?R)andthereforeinordertodischargetheassumption"bi_total?R",?Ris instantiatedto(=.)Iftherelationhadbeenknown(wewishpcr_fset(=),whichisnotbi-total), theassumptionbi_totalpcr_fset(=)couldnothavebeendischargedandthetoolwouldhave backtrackedandchosenLifting.right_total_UNIV_transfer,whichassumesonlyright-totalness (andpcr_fsetisright-total).
*) backback(* We can force the tool to backtrack and choose the desired transfer rule. *) apply transfer_step apply transfer_end by auto
(* Of course, to use "back" in proofs is not a desired style. But we can prioritize theruleLifting.right_total_UNIV_transferbyredeclaringitLOCALLYasatransferrule.
*) lemma"finite (UNIV :: 'a::finite fset set)" proof - note right_total_UNIV_transfer[transfer_rule] show ?thesis by transfer auto qed
end
(* Let us close the environment of fset transferring and add the rule that we deleted. *)
lifting_forget fset.lifting (* deletes the extra added transfer rule for |\<in>| *) declare fmember_transfer[transfer_rule] (* we want to keep parametricity of |\<in>| *)
end
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.