package Ġse quent Pro ver Ċ Ċ import Ġcore .* Ċ import Ġcore . Formula .* Ċ Ċ data Ġclass ĠNode ( Ċ ĉ var Ġse quent ToBe Applied : ĠSe quent , Ċ ĉ val Ġsibling Label : ĠInt ?, Ċ ĉ var Ġapply Data : ĠI Apply Data ? Ġ= Ġnull , Ċ ĉ var Ġchild : ĠNode ? Ġ= Ġnull , Ċ ĉ var Ġleft Child : ĠNode ? Ġ= Ġnull , Ċ ĉ var Ġright Child : ĠNode ? Ġ= Ġnull Ċ ) Ċ Ċ data Ġclass ĠIndependent Node ( val Ġse quent ToBe Applied : ĠSe quent , Ġval Ġapply Data : ĠI Apply Data ?) Ċ Ċ fun ĠNode . to In dependent Node (): ĠIndependent Node Ġ= ĠIndependent Node ( sequent ToBe Applied , Ġapply Data ) Ċ Ċ fun ĠNode . complete Proof ( subst itution : ĠSubst itution ) Ġ{ Ċ ĉ if Ġ( AX IO M . can Apply ( sequent ToBe Applied )) Ġ{ Ċĉ ĉ apply Data Ġ= ĠAX IO M . Apply Data Ċĉ ĉ child Ġ= Ġnull Ċ ĉ } Ċ ĉ when ( val Ġold Apply Data Ġ= Ġapply Data ) Ġ{ Ċĉ ĉ AX IO M . Apply Data , Ġnull Ġ-> Ġ{} Ċĉ ĉ is ĠUnary T actic . Apply Data Ġ-> Ġ{ Ċĉĉ ĉ val Ġnew F ml Ġ= Ġ( sequent ToBe Applied . ass umptions Ġ+ Ġse quent ToBe Applied . con clusions ) Ċĉĉĉ ĉ . first OrNull Ġ{ Ġit Ġ== Ġold Apply Data . fml . replace ( subst itution ) Ġ} Ċĉĉĉ ĉ ?: Ġthrow ĠIllegal T actic Exception () Ċĉĉ ĉ val Ġnew Apply Data Ġ= Ġold Apply Data . copy ( fml Ġ= Ġnew F ml ) Ċĉĉ ĉ apply Data Ġ= Ġnew Apply Data Ċĉĉ ĉ child !!. sequent ToBe Applied Ġ= Ġnew Apply Data . apply T actic ( sequent ToBe Applied ) Ċĉĉ ĉ child !!. complete Proof ( subst itution ) Ċĉ ĉ } Ċĉ ĉ is ĠBinary T actic . Apply Data Ġ-> Ġ{ Ċĉĉ ĉ val Ġnew F ml Ġ= Ġ( sequent ToBe Applied . ass umptions Ġ+ Ġse quent ToBe Applied . con clusions ) Ċĉĉĉ ĉ . first OrNull Ġ{ Ġit Ġ== Ġold Apply Data . fml . replace ( subst itution ) Ġ} Ċĉĉĉ ĉ ?: Ġthrow ĠIllegal T actic Exception () Ċĉĉ ĉ val Ġnew Apply Data Ġ= Ġold Apply Data . copy ( fml Ġ= Ġnew F ml ) Ċĉĉ ĉ apply Data Ġ= Ġnew Apply Data Ċĉĉ ĉ left Child !!. sequent ToBe Applied Ġ= Ġnew Apply Data . apply T actic ( sequent ToBe Applied ). first Ċĉĉ ĉ right Child !!. sequent ToBe Applied Ġ= Ġnew Apply Data . apply T actic ( sequent ToBe Applied ). second Ċĉĉ ĉ left Child !!. complete Proof ( subst itution ) Ċĉĉ ĉ right Child !!. complete Proof ( subst itution ) Ċĉ ĉ } Ċĉ ĉ is ĠF resh Var Instantiation T actic . Apply Data Ġ-> Ġ{ Ċĉĉ ĉ val Ġnew F ml Ġ= Ġ( sequent ToBe Applied . ass umptions Ġ+ Ġse quent ToBe Applied . con clusions ) Ċĉĉĉ ĉ . filter Is Instance < Quant ified >() Ċĉĉĉ ĉ . first OrNull Ġ{ Ġit Ġ== Ġold Apply Data . fml . replace ( subst itution ) Ġ} Ċĉĉĉ ĉ ?: Ġthrow ĠIllegal T actic Exception () Ċĉĉ ĉ val Ġnew Apply Data Ġ= Ġold Apply Data . copy ( fml Ġ= Ġnew F ml ) Ċĉĉ ĉ apply Data Ġ= Ġnew Apply Data Ċĉĉ ĉ child !!. sequent ToBe Applied Ġ= Ġnew Apply Data . apply T actic ( sequent ToBe Applied ) Ċĉĉ ĉ child !!. complete Proof ( subst itution ) Ċĉ ĉ } Ċĉ ĉ is ĠTerm Instantiation T actic . Apply Data Ġ-> Ġ{ Ċĉĉ ĉ val Ġun ification Term Ġ= Ġold Apply Data . term Ċĉĉ ĉ val Ġterm Ġ= Ġsubstitution [ un ification Term ] Ġ?: Ġun ification Term Ċĉĉ ĉ val Ġnew F ml Ġ= Ġ( sequent ToBe Applied . ass umptions Ġ+ Ġse quent ToBe Applied . con clusions ) Ċĉĉĉ ĉ . filter Is Instance < Quant ified >() Ċĉĉĉ ĉ . first OrNull Ġ{ Ġit Ġ== Ġold Apply Data . fml . replace ( subst itution ) Ġ} Ċĉĉĉ ĉ ?: Ġthrow ĠIllegal T actic Exception () Ċĉĉ ĉ val Ġnew Apply Data Ġ= ĠTerm Instantiation T actic . Apply Data ( new F ml , Ġterm ) Ċĉĉ ĉ apply Data Ġ= Ġnew Apply Data Ċĉĉ ĉ child !!. sequent ToBe Applied Ġ= Ġnew Apply Data . apply T actic ( sequent ToBe Applied ) Ċĉĉ ĉ child !!. complete Proof ( subst itution ) Ċĉ ĉ } Ċ ĉ } Ċ } Ċ Ċ /* Ċ private Ġfun ĠNode . get Proof (): ĠList < I Apply Data > Ġ= ĠlistOf ( apply Data !! ) Ġ+ Ġwhen ( apply Data !! ) Ġ{ Ċ ĉ AX IO M . Apply Data Ġ-> Ġempty List () Ċ ĉ is ĠUnary T actic . Apply Data , Ġis ĠF resh Var Instantiation T actic . Apply Data , Ġis ĠTerm Instantiation T actic . Apply Data Ġ-> Ġchild !!. get Proof () Ċ ĉ is ĠBinary T actic . Apply Data Ġ-> Ġleft Child !!. get Proof () Ġ+ Ġright Child !!. get Proof () Ċ } Ċ fun ĠNode . print Proof () Ġ{ Ċ ĉ val Ġproof Ġ= Ġget Proof () Ċ ĉ val Ġse quent s Ġ= Ġmutable ListOf ( this . sequent ToBe Applied ) Ċ ĉ for Ġ( data Ġin Ġproof ) Ġ{ Ċĉ ĉ sequent s . forEach Ġ{ Ġprintln ( it ) Ġ} Ċĉ ĉ when ( data ) Ġ{ Ċĉĉ ĉ AX IO M . Apply Data Ġ-> Ġse quent s . remove First () Ċĉĉ ĉ is ĠUnary T actic . Apply Data Ġ-> Ġse quent s [ 0 ] Ġ= Ġdata . apply T actic ( sequent s [ 0 ]) Ċĉĉ ĉ is ĠBinary T actic . Apply Data Ġ-> Ġ{ Ċĉĉĉ ĉ val Ġnew Se quent s Ġ= Ġdata . apply T actic ( sequent s [ 0 ]) Ċĉĉĉ ĉ sequent s [ 0 ] Ġ= Ġnew Se quent s . first Ċĉĉĉ ĉ sequent s . add ( 1 , Ġnew Se quent s . second ) Ċĉĉ ĉ } Ċĉĉ ĉ is ĠF resh Var Instantiation T actic . Apply Data Ġ-> Ġse quent s [ 0 ] Ġ= Ġdata . apply T actic ( sequent s [ 0 ]) Ċĉĉ ĉ is ĠTerm Instantiation T actic . Apply Data Ġ-> Ġse quent s [ 0 ] Ġ= Ġdata . apply T actic ( sequent s [ 0 ]) Ċĉ ĉ } Ċĉ ĉ println ("> >> Ġ${ data . t actic }") Ċ ĉ } Ċ ĉ if Ġ( sequent s . isNotEmpty ()) Ġthrow ĠIllegalArgumentException () Ċ } Ċ Ġ*/ Ċ Ċ private Ġfun ĠNode . get Re versed Proof (): ĠList < In dependent Node > Ġ= ĠlistOf ( to In dependent Node ()) Ġ+ Ġwhen ( apply Data ) Ġ{ Ċ ĉ AX IO M . Apply Data , Ġnull Ġ-> Ġempty List () Ċ ĉ is ĠUnary T actic . Apply Data , Ġis ĠTerm Instantiation T actic . Apply Data , Ġis ĠF resh Var Instantiation T actic . Apply Data Ġ-> Ġchild !!. get Re versed Proof () Ċ ĉ is ĠBinary T actic . Apply Data Ġ-> Ġright Child !!. get Re versed Proof () Ġ+ Ġleft Child !!. get Re versed Proof () Ċ } Ċ Ċ fun ĠNode . get Proof Tree (): ĠString Ġ= Ġget Re versed Proof (). reversed (). join ToString ( separator Ġ= Ġ"\ n ") Ġ{ Ċ ĉ when ( it . apply Data ) Ġ{ Ċĉ ĉ null Ġ-> Ġ"\\ Ax iom $ ${ it . sequent ToBe Applied . to Lat ex ()} $" Ċĉ ĉ AX IO M . Apply Data Ġ-> Ġ"\\ Ax iom C {}\ n \\ Right Label { \\ script size Ġ${ it . apply Data . t actic . to Lat ex ()}} \ n \\ Unary Inf $ ${ it . sequent ToBe Applied . to Lat ex ()} $" Ċĉ ĉ is ĠUnary T actic . Apply Data , Ġis ĠF resh Var Instantiation T actic . Apply Data , Ġis ĠTerm Instantiation T actic . Apply Data Ġ-> Ġ"\\ Right Label { \\ script size Ġ${ it . apply Data . t actic . to Lat ex ()}} \ n \\ Unary Inf $ ${ it . sequent ToBe Applied . to Lat ex ()} $" Ċĉ ĉ is ĠBinary T actic . Apply Data Ġ-> Ġ"\\ Right Label { \\ script size Ġ${ it . apply Data . t actic . to Lat ex ()}} \ n \\ Binary Inf $ ${ it . sequent ToBe Applied . to Lat ex ()} $" Ċ ĉ } Ċ } Ċ Ċ fun ĠNode . get Lat ex Output ( proof State : ĠPro of State ): ĠString Ġ= Ġ"\\ document class [ preview , var width = 1 0 0 0 0 px , border = 3 mm ]{ standalone }\ n " Ġ+ Ċĉ ĉ " \\ usepackage { bus spro ofs }\ n " Ġ+ Ċĉ ĉ " \\ begin { document }\ n " Ġ+ Ċĉ ĉ "\ $ ${ sequent ToBe Applied . to Lat ex (). replace ("\\ f Center ", Ġ"\\ v dash "). replace (""" ^\ s \\\ s """. to Regex (), Ġ"") }\ $ \\ par \ n " Ġ+ Ċĉ ĉ "$ proof State \ n " Ġ+ Ċĉ ĉ " \\ begin { pro oft ree }\ n " Ġ+ Ċĉ ĉ " \\ def \\ f Center { \\ mbox {\ $ \\ v dash \$ }}\ n " Ġ+ Ċĉ ĉ get Proof Tree () Ġ+ Ċĉ ĉ "\ n " Ġ+ Ċĉ ĉ " \\ end { pro oft ree }\ n " Ġ+ Ċĉ ĉ " \\ right line {@ sequent \\ _ bot }\ n " Ġ+ Ċĉ ĉ " \\ end { document }\ n " Ċ Ċ /* Ċ ĉ val Ġlat ex Proof : ĠString Ċ ĉ print (" Lat ex ĠStart ...") Ċ ĉ val Ġget Lat ex Proof Time Ġ= Ġmeasure Time Millis { Ċĉ ĉ latex Proof Ġ= Ġthis . get Proof Tree () Ċ ĉ } Ċ ĉ println (" Completed Ġin Ġ$ get Lat ex Proof Time Ġms ") Ċ Ġ*/ Ċ Ċ fun ĠNode . check Proof (): ĠBoolean Ġ{ Ċ ĉ TODO () Ċ } Ċ Ċ /* Ċ fun ĠNode . check Correct ness (): ĠBoolean Ġ= Ġtry Ġ{ Ċ ĉ when ( val Ġapply Data With Node Ġ= Ġapply Data With Node ) Ġ{ Ċĉ ĉ null Ġ-> Ġfalse Ċĉ ĉ Ax iom Apply Data Ġ ĉĉĉĉĉ ĉ -> ĠAX IO M . can Apply ( sequent ToBe Applied ) Ċĉ ĉ is ĠUnary Apply Data With Node Ġĉĉ ĉ -> Ġapply Data With Node . apply Data . apply T actic ( sequent ToBe Applied ) Ġ== Ġapply Data With Node . node . sequent ToBe Applied Ġ&& Ġapply Data With Node . node . check Correct ness () Ċĉ ĉ is ĠBinary Apply Data With Nodes Ġĉ ĉ -> Ġapply Data With Node . apply Data . apply T actic ( sequent ToBe Applied ) Ġ== Ġapply Data With Node . left Node . sequent ToBe Applied Ġto Ġapply Data With Node . right Node . sequent ToBe Applied Ġ&& Ġapply Data With Node . left Node . check Correct ness () Ġ&& Ġapply Data With Node . right Node . check Correct ness () Ċĉ ĉ is ĠUn ification Term Apply Data With Node Ġ-> Ġapply Data With Node . apply Data . apply T actic ( sequent ToBe Applied ) Ġ== Ġapply Data With Node . node . sequent ToBe Applied Ġ&& Ġapply Data With Node . node . check Correct ness () Ċĉ ĉ is ĠTerm Apply Data With Node Ġĉĉ ĉ -> Ġapply Data With Node . apply Data . apply T actic ( sequent ToBe Applied ) Ġ== Ġapply Data With Node . node . sequent ToBe Applied Ġ&& Ġapply Data With Node . node . check Correct ness () Ċ } Ċ } Ġcatch Ġ( e : ĠIllegal T actic Exception ) Ġ{ Ċ ĉ false Ċ Ġ*/ Ċ Ċ enum Ġclass ĠPro of State Ġ{ Ċ ĉ Success , ĠUn prov able , ĠLoop Count Fail , ĠUn ification Term Instantiation Count Fail , ĠUn ification Time Fail , ĠMemory Error ; Ċ ĉ override Ġfun ĠtoString (): ĠString Ġ= Ġwhen ( this ) Ġ{ Ċĉ ĉ Success Ġ-> Ġ" Prov able ." Ċĉ ĉ Un prov able Ġ-> Ġ" Un prov able ." Ċĉ ĉ Loop Count Fail Ġ-> Ġ" Proof ĠFailed : Ġtoo Ġmany Ġloops ." Ċĉ ĉ Un ification Term Instantiation Count Fail Ġ-> Ġ" Proof ĠFailed : Ġtoo Ġmany Ġun ification Ġterms ." Ċĉ ĉ Un ification Time Fail Ġ-> Ġ" Proof ĠFailed : Ġtoo Ġlong Ġun ification Ġtime ." Ċĉ ĉ Memory Error Ġ-> Ġ" Proof ĠFailed : Ġout Ġof Ġmemory Ġerror ." Ċ ĉ } Ċ } Ċ