/*  This is a proof plan for theorem:
    countsort: []==>a:int=>l:int list=>count(a,sort(l))=count(a,l)in pnat
    planner = dplan, clam_version(2.7.0), oyster_version(1.20)

    Time taken to find plan: 6060ms
    Environment:
    []
 */

/* This is the pretty-printed form
ind_strat([(l:int list)-v1::v0]) then 
  [generalise(sort(v0),v4:int list) then 
     ind_strat([(v4:int list)-v6::v5]) then 
       [base_case(...),
        base_case(...)
       ],
   base_case(...) then 
     generalise(sort(v0),v3:int list) then 
       ind_strat([(v3:int list)-v5::v4]) then 
         [base_case(...),
          base_case(...)
         ]
  ]

*/

proof_plan([]==>a:int=>l:int list=>count(a,sort(l))=count(a,l)in pnat,countsort,6060,ind_strat(induction(lemma(list_primitive)-[(l:int list)-v1::v0])then[base_case(sym_eval(normalize_term([reduction([2,1,1],[sort1,equ(int list,left)]),reduction([1,1],[count1,equ(pnat,left)]),reduction([2,1],[count1,equ(pnat,left)])]))then[elementary(intro(new[a])then[identity,wfftacs])]),step_case(ripple(direction_out,wave(direction_out,[2,1,1],[sort2,equ(int list,left)],[])then[casesplit(disjunction([a=v1 in int=>void,a=v1 in int]))then[wave(direction_out,[2,1],[count3,equ(pnat,left)],[]),wave(direction_out,[2,1],[count2,equ(pnat,left)],[])]])then[unblock_then_fertilize(weak,unblock_fertilize_lazy([idtac])then fertilize(weak,fertilize_then_ripple(fertilize_left_or_right(right,[weak_fertilize(right,in,[],v2)])))),unblock_then_fertilize(weak,unblock_fertilize_lazy([idtac])then fertilize(weak,fertilize_then_ripple(fertilize_left_or_right(right,[weak_fertilize(right,in,[1],v2)]))))])])then[generalise(sort(v0),v4:int list)then[ind_strat(induction(lemma(list_primitive)-[(v4:int list)-v6::v5])then[base_case(sym_eval(normalize_term([reduction([2,1,1],[insert1,equ(int list,left)]),reduction([],[count3,imp(right)])]))then[elementary(hyp(v3))]),step_case(ripple(direction_out,casesplit(disjunction([a=v6 in int=>void,a=v6 in int]))then[wave(direction_out,[2,1],[count3,equ(pnat,left)],[])then[casesplit(disjunction([v1<v6=>void,v1<v6]))then[wave(direction_out,[2,1,1],[insert3,equ(int list,left)],[])then[wave(direction_out,[1,1],[count3,equ(pnat,left)],[])],wave(direction_out,[2,1,1],[insert2,complementary,equ(int list,left)],[])]],wave(direction_out,[2,1],[count2,equ(pnat,left)],[])then[casesplit(disjunction([v1<v6=>void,v1<v6]))then[wave(direction_out,[2,1,1],[insert3,equ(int list,left)],[])then[wave(direction_out,[1,1],[count2,equ(pnat,left)],[])then[wave(direction_out,[],[cnc_s,imp(right)],[])]],wave(direction_out,[2,1,1],[insert2,complementary,equ(int list,left)],[])]]])then[unblock_then_fertilize(strong,unblock_fertilize_lazy([idtac])then fertilize(strong,v7)),idtac,unblock_then_fertilize(strong,unblock_fertilize_lazy([idtac])then fertilize(strong,v7)),idtac])])then[base_case(sym_eval(normalize_term([reduction([1,1],[count3,equ(pnat,left)]),reduction([],[count3,imp(right)])]))then[elementary(hyp(v8))]),base_case(sym_eval(equal(v8,left)then[normalize_term([reduction([1,1],[count3,equ(pnat,left)]),reduction([],[count2,imp(right)])])])then[elementary(identity)])]],base_case(sym_eval(equal(v3,left)))then[generalise(sort(v0),v3:int list)then[ind_strat(induction(lemma(list_primitive)-[(v3:int list)-v5::v4])then[base_case(sym_eval(normalize_term([reduction([2,1,1],[insert1,equ(int list,left)]),reduction([],[count2,imp(right)])]))then[elementary(identity)]),step_case(ripple(direction_out,casesplit(disjunction([a=v5 in int=>void,a=v5 in int]))then[wave(direction_out,[1,2,1],[count3,equ(pnat,left)],[])then[casesplit(disjunction([a<v5=>void,a<v5]))then[wave(direction_out,[2,1,1],[insert3,equ(int list,left)],[])then[wave(direction_out,[1,1],[count3,equ(pnat,left)],[])],wave(direction_out,[2,1,1],[insert2,complementary,equ(int list,left)],[])]],wave(direction_out,[1,2,1],[count2,equ(pnat,left)],[])then[casesplit(disjunction([a<v5=>void,a<v5]))then[wave(direction_out,[2,1,1],[insert3,equ(int list,left)],[])then[wave(direction_out,[1,1],[count2,equ(pnat,left)],[])then[unblock_then_wave(direction_out,unblock_lazy([unblock(meta_ripple,unused,unused),idtac])then wave(direction_out,[],[cnc_s,imp(right)],[]))]],wave(direction_out,[2,1,1],[insert2,complementary,equ(int list,left)],[])]]])then[unblock_then_fertilize(strong,unblock_fertilize_lazy([idtac])then fertilize(strong,v6)),idtac,unblock_then_fertilize(strong,unblock_fertilize_lazy([idtac])then fertilize(strong,v6)),idtac])])then[base_case(sym_eval(normalize_term([reduction([1,1],[count2,equ(pnat,left)]),reduction([1,1,1],[count3,equ(pnat,left)])]))then[elementary(identity)]),base_case(sym_eval(equal(v7,left)then[normalize_term([reduction([1,1],[count2,equ(pnat,left)]),reduction([1,1,1],[count2,equ(pnat,left)])])])then[elementary(identity)])]]]],dplan).
