From: acondolu Date: Wed, 26 Jul 2017 09:07:15 +0000 (+0200) Subject: New FASTER! SIMPLER! algorithm X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=21c829a0b518a725f4db3d21250ad00dcf3bb889;p=fireball-separation.git New FASTER! SIMPLER! algorithm - Works without bombs and pacmans - No metrics --- diff --git a/ocaml/Makefile b/ocaml/Makefile deleted file mode 100644 index b662428..0000000 --- a/ocaml/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -OCAMLC = ocamlopt -g -rectypes -LIB = unix.cmxa str.cmxa -UTILS = util.cmx console.cmx listx.cmx pure.cmx num.cmx parser.cmx - -all: a.out test4.out - -run: test4.out - bash run - -a.out: $(UTILS) lambda4.cmx problems.cmx - $(OCAMLC) -o a.out $(LIB) $^ - -sat.out: $(UTILS) lambda4.cmx sat.ml - $(OCAMLC) -o sat.out $(LIB) $^ -# -test4.out: $(UTILS) lambda4.cmx test.ml - $(OCAMLC) -o test4.out $(LIB) $^ - -andrea.out: $(UTILS) andrea8.ml - $(OCAMLC) -o andrea.out $(LIB) $(UTILS) andrea8.ml - -%.cmi: %.mli - $(OCAMLC) -c $< - -%.cmx: %.ml %.cmi - $(OCAMLC) -c $< - -clean: - rm -f *.cm* *.out *.o .depend log - -.depend: *.ml *.mli - ocamldep *.ml *.mli > .depend - -include .depend - -.PHONY: clean all run diff --git a/ocaml/andrea3.mli b/ocaml/andrea3.mli deleted file mode 100644 index 8ec0c9f..0000000 --- a/ocaml/andrea3.mli +++ /dev/null @@ -1 +0,0 @@ -val do_everything: string list -> int diff --git a/ocaml/andrea4'.ml b/ocaml/andrea4'.ml deleted file mode 100644 index f734cca..0000000 --- a/ocaml/andrea4'.ml +++ /dev/null @@ -1,358 +0,0 @@ -type var = (* unique name *) int * (int * term) option * (*level*) int -and term = - | Tvar of var - | Tapp of term * term - | Tlam of int * term -;; - -let zero = Tvar 1010;; -let dummy = Tvar 333;; - - -(* mk_app & subst implementano la beta *) -let rec mk_app t1 t2 = match t1 with - | Tlam(v, t1') -> subst v t2 t1' - | _ -> Tapp(t1, t2, false) -and subst v tv = - let rec aux = function - | Tapp(t1, t2, _) -> mk_app (aux t1) (aux t2) - | Tvar v' as t -> if v = v' then tv else t - | Tlam(v', t') as t -> if v = v' then t else Tlam(v', aux t') - in aux -;; - -(* PARSING AND PRINTING *) - -let parse = - let rec minus1 = function - | Tvar n -> Tvar (n-1) - | Tapp(t1, t2, b) -> Tapp(minus1 t1, minus1 t2, b) - | Tlam(n, t) -> Tlam(n-1, minus1 t) - (* in let open Parser *) - in let rec myterm_of_term = function - | Parser.Var n -> Tvar n - | Parser.App(t1, t2) -> (*Tapp(myterm_of_term t1, myterm_of_term t2) WARNING! BETA DOWN HERE! *) - mk_app (myterm_of_term t1) (myterm_of_term t2) - | Parser.Lam(t) -> minus1 (Tlam(0, myterm_of_term t)) - in fun strs -> ( - let (tms, free) = Parser.parse_many strs - in List.map myterm_of_term tms - ) -;; - -(* PRETTY PRINTING *) -open Console;; - -let fancy_of_term t = -let rec string_of_term = - let free = ["a"; "b"; "c"; "d"; "e"; "f"; "g"] in - let bound = ["x"; "y"; "z"; "w"; "q"; "x1"; "x2"] in - let string_of_int' n = if n >= 0 then "free" ^ string_of_int n else "bound" ^ string_of_int n in - let rec string_of_var t = - if Tvar t = dummy then "_" else if Tvar t = zero then "ZZ" else match t with - | n -> string_of_int' n - and string_of_term_w_pars = function - | Tvar v -> string_of_var v - | Tapp(t1, t2, _) -> "(" ^ (string_of_term_no_pars_app t1) ^ " " ^ (string_of_term_w_pars t2) ^ ")" - | Tlam(_,_) as t -> "(" ^ (string_of_term_no_pars_lam t) ^ ")" - and string_of_term_no_pars_app = function - | Tapp(t1, t2,_) -> (string_of_term_no_pars_app t1) ^ " " ^ (string_of_term_w_pars t2) - | _ as t -> string_of_term_w_pars t - and string_of_term_no_pars_lam = function - | Tlam(v, t) -> "λ" ^ (string_of_int' v) ^ ". " ^ (string_of_term_no_pars_lam t) - | _ as t -> string_of_term_no_pars t - and string_of_term_no_pars = function - | Tlam(_, _) as t -> string_of_term_no_pars_lam t - | _ as t -> string_of_term_no_pars_app t - in string_of_term_no_pars -in let rec html_of_term = - let free = ["a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"] in - let bound = ["x"; "y"; "z"; "w"; "q"] in - let string_of_int' n = if n >= 0 then List.nth free (n) else List.nth bound (-n-1) in - let rec string_of_var t = - if Tvar t = dummy then "#" else if Tvar t = zero then "Z" else string_of_int' t - and string_of_term_w_pars = function - | Tvar v -> string_of_var v - | Tapp(t1, t2,_) -> "(" ^ (string_of_term_no_pars_app t1) ^ " " ^ (string_of_term_w_pars t2) ^ ")" - | Tlam(_,_) as t -> "(" ^ (string_of_term_no_pars_lam t) ^ ")" - and string_of_term_no_pars_app = function - | Tapp(t1, t2,_) -> (string_of_term_no_pars_app t1) ^ " " ^ (string_of_term_w_pars t2) - | _ as t -> string_of_term_w_pars t - and string_of_term_no_pars_lam = function - | Tlam(v, t) -> "λ" ^ (string_of_int' v) ^ ". " ^ (string_of_term_no_pars_lam t) - | _ as t -> string_of_term_no_pars t - and string_of_term_no_pars = function - | Tlam(_, _) as t -> string_of_term_no_pars_lam t - | _ as t -> string_of_term_no_pars_app t - in string_of_term_no_pars -in - string_of_term t / "html_of_term t" -;; - -let fancy_of_nf t: Console.fancyobj = -let rec print ?(l=[]) = - function - `Var n -> Util.Vars.print_name l n - | `N n -> string_of_int n - | `Match(t,bs_lift,bs,args) -> - "([" ^ print ~l (t :> Num.nf) ^ - " ? " ^ String.concat " | " (List.map (fun (n,t) -> string_of_int n ^ " => " ^ print ~l (Num.lift bs_lift t)) !bs) ^ "] " ^ - String.concat " " (List.map (print ~l) args) ^ ")" - | `I(n,args) -> "(" ^ Util.Vars.print_name l n ^ " " ^ String.concat " " (Listx.to_list (Listx.map (print ~l) args)) ^ ")" - | `Lam(_,nf) -> - let name = Util.Vars.string_of_var (List.length l) in - "" ^ name ^ "." ^ print ~l:(name::l) (nf : Num.nf) - -(* in let rec print_html ?(l=[]) = - function - `Var n -> Lambda3.print_name l n - | `N n -> string_of_int n - | `Match(t,bs_lift,bs,args) -> - "(match " ^ print_html ~l (t :> Lambda3.nf) ^ - " with " ^ String.concat " | " (List.map (fun (n,t) -> string_of_int n ^ " " ^ print_html ~l (Lambda3.lift bs_lift t)) !bs) ^ "..." (* Attenzion non sto stampando gli argomenti applicati! Perche' non ce ne sono mai *) - | `I(n,args) -> "(" ^ Lambda3.print_name l n ^ " " ^ String.concat " " (Listx.to_list (Listx.map (print_html ~l) args)) ^ ")" - | `Lam nf -> - let name = Lambda3.string_of_var (List.length l) in - "λ" ^ name ^ ". " ^ print_html ~l:(name::l) (nf : Lambda3.nf) *) -in - print t / print t -;; - -let print_term t = print_endline (fancy_of_term t :> Console.fancyobj);; -(* *) - - -let varcount = ref 11;; - -let freshvar () = ( - varcount := (!varcount + 1); - !varcount -);; - - - -(* magic ["x (x x x)"; "x (y. y x)"; "x x (y. y y (x x y))"] ;; *) -(* magic ["((x x) (x. x))";"x x"];; *) - -let alive (_, _, n) = n;; -let rec setalive c = function - | Tvar(a,b,_) as v -> if v <> zero && v <> dummy then Tvar(a,b,c) else v - | Tapp(a,b) -> Tapp(setalive c a, setalive c b) - | Tlam(n, t) -> Tlam(n, setalive c t) -;; - -let mk_vars t lev = - let rec aux n = - if n = 0 - then [] - else Tvar(0, Some(n, t), lev) :: (aux (n-1)) - in aux -;; - -let mk_apps t ts = List.fold_right (fun x y -> mk_app y x) (List.rev ts) t;; (* which FOLD? FIXME *) - - -let compute_special_k tms = - let rec aux k t = match t with - | Tvar _ -> 0 - | Tapp(t1,t2) -> Pervasives.max (aux 0 t1) (aux 0 t2) - | Tlam(v,t) -> Pervasives.max (k+1) (aux (k + 1) t) - in List.fold_left (fun b a -> Pervasives.max (aux 0 a) b) 0 tms -;; - -let compute_special_h tms = - let rec eat_lam = function - | Tlam(_,t) -> eat_lam t - | _ as t -> t - in - let rec aux t = match t with - | Tvar _ -> 0 - | Tapp(t1,t2) -> Pervasives.max (aux t1) (aux t2) - | Tlam(v,t) -> 1 + (aux (eat_lam t)) - in 1 + List.fold_left (fun b a -> Pervasives.max (aux a) b) 0 tms -;; - -(* funzione di traduzione brutta & cattiva *) -let translate k = - let rec aux = function - | Tlam _ -> assert false - | Tvar _ as v -> v - | Tapp(t1, t2) -> - let v = hd t1 in - let a = alive v in - let t1' = aux t1 in - let t2' = if a = 0 - then t2 - else mk_apps t2 ((List.rev (mk_vars t1' (a-1) k)) @ [zero]) - in Tapp(t1', aux t2') - in aux -;; - -(* sostituisce gli argomenti dummy (delle variabili morte) con 'dummy' *) -let rec dummize = function - | Tlam _ -> assert false - | Tvar (a,Some(b,t), c) -> Tvar(a, Some (b, dummize t), c) - | Tvar _ as v -> v - | Tapp(t1, t2) -> - if alive (hd t1) = 0 - then Tapp(dummize t1, dummy) - else Tapp(dummize t1, dummize t2) -;; - -(* lista di sottotermini applicativi *) -let rec subterms = function - | Tlam _ -> assert false - | Tvar _ as v -> [v] - | Tapp(t1, t2) -> Tapp(t1, t2) :: ((subterms t1) @ (subterms t2)) -;; - -(* filtra dai sottotermini le variabili *) -let rec vars subs = List.filter (function Tvar _ -> true | _ -> false) subs;; - - -let rec stupid_uniq = function - | [] -> [] - | x::xs -> if List.mem x xs then (stupid_uniq xs) else x::(stupid_uniq xs) -;; -let stupid_compare a b = - let rec size = function - | Tvar(_,None,_) -> 0 - | Tvar(_,Some(_,t),_) -> 1 + size t - | Tapp(t1,t2) -> 1 + size t1 + size t2 - | Tlam _ -> assert false - in compare (size a) (size b) -;; -let stupid_sort_uniq l = stupid_uniq (List.sort stupid_compare l);; - -(* crea i match ricorsivamente. - - k e' lo special-K - - subs e' l'insieme dei sottotermini - TODO: riscrivere la funzione per evitare/ottimizzare la ricorsione - *) -let crea_match k subs (acc : (term * Lambda3.nf) list) : term -> Lambda3.nf = - let req t = try List.assoc t acc with Not_found -> `Var 9999 in - let aux t1 = ( - if t1 = dummy then `Var 99999 else - (* let _ = print_term t1 in *) - let cont = List.filter (fun t2 -> List.mem (Tapp(t1,t2)) subs) subs - in if cont = [] then - try `N (Lambda3.index_of t1 subs) with Not_found -> `Var 999 (* variabile dummy qui *) else - let a = alive (hd t1) in - if a = 0 then `Lam (req (Tapp(t1, dummy))) - else ( - let vars = (List.rev (mk_vars t1 (a-1) k)) @ [zero] - (* in let _ = print_endline (String.concat " " (List.map string_of_term vars)) - in let _ = print_term (mk_apps dummy vars) *) - in let vars = List.map req vars - in let vars = List.map (Lambda3.lift 1) vars (* forse lift non necessario *) - in let vars = Listx.from_list vars - in let body = `I(0, vars) - in let branches = List.map (fun t2 -> (Lambda3.index_of t2 subs, req (Tapp(t1, t2)))) cont - in let bs = ref(branches) - in let lift = 1 - in let args = [] - in `Lam (`Match(body, lift, bs, args)) - ) - ) in aux -;; - -let mk_zeros k = - let rec aux n prev = - if n = 0 then [zero] - else let prev = aux (n-1) prev in let x = mk_app (List.hd prev) dummy in x :: prev - in aux (k+1) [] -;; - -let is_scott_n t n = - let open Lambda3 in let open Pure in - let rec aux n = function - | L (L (A (V 1, L (V 0)))) -> n = 0 - | L (L (A (V 0, t))) -> aux (n-1) t - | _ -> assert false - in aux n t -;; - -(* do the magic *) -let magic strings k h = ( - let tms = parse strings - in let tms = List.map (fun x -> Tapp(x, zero)) tms - in let tms' = List.map (setalive h) tms - in let tms' = List.map (translate k) tms' - in let tms' = List.map dummize tms' - (* in let bullet = ">" / "•" *) - (* in let progress s = print_endline (bullet ^^ fancy_of_string s) *) - in let progress = print_h1 - in let _ = progress "traduzione completata" - (* in let _ = List.map print_term tms' *) - in let _ = progress "ordino i sottotermini" - in let subs = List.concat (List.map subterms tms') - in let subs = stupid_sort_uniq subs - (* metti gli zeri in testa, perche' vanno calcolati per primi *) - in let zeros = mk_zeros k - in let subs = (List.filter (fun t -> not (List.mem t zeros)) subs) @ (List.rev zeros) - in let _ = progress ("sottotermini generati: " ^ string_of_int (List.length subs)) - in let vars = vars subs - (* in let _ = List.iter print_term subs *) - (* in let _ = 0/0 *) - in let fv = List.filter (function Tvar(_, None, _) as v -> v <> dummy | _ -> false) vars - (* in let _ = print_string ("> free vars: " ^ String.concat ", " (List.map (string_of_term) fv)) *) - in let _ = progress "sto creando i match" - (* in let sigma = List.map (fun x -> x, crea_match k subs x) fv *) - in let f t acc = let res = crea_match k subs acc t in (t,res)::acc - in let acc = List.fold_right f subs [] - in let sigma = List.filter (fun (t,res) -> List.mem t fv) acc - in let _ = progress "match creati" - in let _ = List.iter (fun (x,y) -> print_endline (fancy_of_term x ^^ (" : " / " ↦ ") ^^ fancy_of_nf y)) sigma - - in let _ = progress "controllo di purezza"; - in let open Lambda3 - in let ps, _ = Lambda3.parse' strings - in let ps = List.map (fun x -> Lambda3.mk_app x (`Var 1010)) ps - in let ps = List.map (fun t -> ToScott.t_of_nf (t :> nf)) ps - in let sigma = List.map ( - function (Tvar(n,_,_), inst) -> n, ToScott.t_of_nf inst | _ -> assert false - ) sigma - in let ps = - List.fold_left (fun ps (x,inst) -> List.map (Pure.subst false x inst) ps) ps sigma - in let _ = List.iteri (fun i n -> - (* print_string_endline ((string_of_int i) ^ ":: " ^ (Pure.print (Pure.whd n))); *) - (* assert (Pure.whd n = Scott.mk_n (Lambda3.index_of (List.nth tms' i) subs))) ps *) - assert (is_scott_n (Pure.whd n) (Lambda3.index_of (List.nth tms' i) subs))) ps - in let _ = progress "fatto." in () -);; - -let do_everything tms = -let tms' = parse tms in -let k = compute_special_k tms' in -let h = compute_special_h tms' in -(* let _ = print_string_endline (string_of_int h) in *) -magic tms k h -;; - -let _ = - let tms = ["a a"; "a b"; "b a"; "b (x. y.x y a)"] in - (* 1 2 *) - (* let tms = ["x c" ; "b (x c d e)"; "b"] in *) - (* 0 1 *) - (* let tms = ["x x x"] in *) - let tms' = parse tms in - let k = compute_special_k tms' in - let h = compute_special_h tms' in - (* let _ = print_string_endline (string_of_int h) in *) - magic tms k h -;; - -(* type var' = (* unique name *) int * (int * term') option * (*dead*) bool option -and term' = - | Tvar' of var' - | Tapp' of term' * term' * (* active *) bool - | Tlam' of int * term' -;; - -let rec iter mustapply = - let aux = function - | Tvar'(n, Some(m,t), b) -> Tvar(n, Some(m, aux t), b) - | Tvar' _ as v -> v - | Tapp'(t1, t2, b) -> if b && - in aux -;; *) diff --git a/ocaml/andrea4.ml b/ocaml/andrea4.ml deleted file mode 100644 index 4b7e448..0000000 --- a/ocaml/andrea4.ml +++ /dev/null @@ -1,637 +0,0 @@ -(* type var = (* unique name *) int * (int * term) option * (*level*) int *) -type term = - | Tvar of int - | Tapp of term * term * bool - | Tlam of int * term -;; - -let zero = Tvar 1010;; -let dummy = Tvar 333;; - - -(* mk_app & subst implementano la beta *) -let rec mk_app t1 t2 = match t1 with - | Tlam(v, t1') -> subst v t2 t1' - | _ -> Tapp(t1, t2, false) -and subst v tv = - let rec aux = function - | Tapp(t1, t2, _) -> mk_app (aux t1) (aux t2) - | Tvar v' as t -> if v = v' then tv else t - | Tlam(v', t') as t -> if v = v' then t else Tlam(v', aux t') - in aux -;; - -(* PARSING AND PRINTING *) - -let parse = - let rec minus1 = function - | Tvar n -> Tvar (n-1) - | Tapp(t1, t2, b) -> Tapp(minus1 t1, minus1 t2, b) - | Tlam(n, t) -> Tlam(n-1, minus1 t) - (* in let open Parser *) - in let rec myterm_of_term = function - | Parser.Var n -> Tvar n - | Parser.App(t1, t2) -> (*Tapp(myterm_of_term t1, myterm_of_term t2) WARNING! BETA DOWN HERE! *) - mk_app (myterm_of_term t1) (myterm_of_term t2) - | Parser.Lam(t) -> minus1 (Tlam(0, myterm_of_term t)) - in fun strs -> ( - let (tms, free) = Parser.parse_many strs - in List.map myterm_of_term tms - ) -;; - -(* PRETTY PRINTING *) -open Console;; - -let fancy_of_term t = -let rec string_of_term = - let free = ["a"; "b"; "c"; "d"; "e"; "f"; "g"] in - let bound = ["x"; "y"; "z"; "w"; "q"; "x1"; "x2"] in - let string_of_int' n = if n >= 0 then "free" ^ string_of_int n else "bound" ^ string_of_int n in - let rec string_of_var t = - if Tvar t = dummy then "_" else if Tvar t = zero then "ZZ" else match t with - | n -> string_of_int' n - and string_of_term_w_pars = function - | Tvar v -> string_of_var v - | Tapp(t1, t2, _) -> "(" ^ (string_of_term_no_pars_app t1) ^ " " ^ (string_of_term_w_pars t2) ^ ")" - | Tlam(_,_) as t -> "(" ^ (string_of_term_no_pars_lam t) ^ ")" - and string_of_term_no_pars_app = function - | Tapp(t1, t2,_) -> (string_of_term_no_pars_app t1) ^ " " ^ (string_of_term_w_pars t2) - | _ as t -> string_of_term_w_pars t - and string_of_term_no_pars_lam = function - | Tlam(v, t) -> "λ" ^ (string_of_int' v) ^ ". " ^ (string_of_term_no_pars_lam t) - | _ as t -> string_of_term_no_pars t - and string_of_term_no_pars = function - | Tlam(_, _) as t -> string_of_term_no_pars_lam t - | _ as t -> string_of_term_no_pars_app t - in string_of_term_no_pars -in let rec html_of_term = - let free = ["a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"] in - let bound = ["x"; "y"; "z"; "w"; "q"] in - let string_of_int' n = if n >= 0 then List.nth free (n) else List.nth bound (-n-1) in - let rec string_of_var t = - if Tvar t = dummy then "#" else if Tvar t = zero then "Z" else string_of_int' t - and string_of_term_w_pars = function - | Tvar v -> string_of_var v - | Tapp(t1, t2,_) -> "(" ^ (string_of_term_no_pars_app t1) ^ " " ^ (string_of_term_w_pars t2) ^ ")" - | Tlam(_,_) as t -> "(" ^ (string_of_term_no_pars_lam t) ^ ")" - and string_of_term_no_pars_app = function - | Tapp(t1, t2,_) -> (string_of_term_no_pars_app t1) ^ " " ^ (string_of_term_w_pars t2) - | _ as t -> string_of_term_w_pars t - and string_of_term_no_pars_lam = function - | Tlam(v, t) -> "λ" ^ (string_of_int' v) ^ ". " ^ (string_of_term_no_pars_lam t) - | _ as t -> string_of_term_no_pars t - and string_of_term_no_pars = function - | Tlam(_, _) as t -> string_of_term_no_pars_lam t - | _ as t -> string_of_term_no_pars_app t - in string_of_term_no_pars -in - string_of_term t / "html_of_term t" -;; - -let fancy_of_nf t: Console.fancyobj = -let rec print ?(l=[]) = - function - `Var n -> Util.Vars.print_name l n - | `N n -> string_of_int n - | `Match(t,bs_lift,bs,args) -> - "([" ^ print ~l (t :> Num.nf) ^ - " ? " ^ String.concat " | " (List.map (fun (n,t) -> string_of_int n ^ " => " ^ print ~l (Num.lift bs_lift t)) !bs) ^ "] " ^ - String.concat " " (List.map (print ~l) args) ^ ")" - | `I(n,args) -> "(" ^ Util.Vars.print_name l n ^ " " ^ String.concat " " (Listx.to_list (Listx.map (print ~l) args)) ^ ")" - | `Lam(_,nf) -> - let name = Util.Vars.string_of_var (List.length l) in - "" ^ name ^ "." ^ print ~l:(name::l) (nf : Num.nf) - -(* in let rec print_html ?(l=[]) = - function - `Var n -> Lambda3.print_name l n - | `N n -> string_of_int n - | `Match(t,bs_lift,bs,args) -> - "(match " ^ print_html ~l (t :> Lambda3.nf) ^ - " with " ^ String.concat " | " (List.map (fun (n,t) -> string_of_int n ^ " " ^ print_html ~l (Lambda3.lift bs_lift t)) !bs) ^ "..." (* Attenzion non sto stampando gli argomenti applicati! Perche' non ce ne sono mai *) - | `I(n,args) -> "(" ^ Lambda3.print_name l n ^ " " ^ String.concat " " (Listx.to_list (Listx.map (print_html ~l) args)) ^ ")" - | `Lam nf -> - let name = Lambda3.string_of_var (List.length l) in - "λ" ^ name ^ ". " ^ print_html ~l:(name::l) (nf : Lambda3.nf) *) -in - print t / print t -;; - -let print_term t = print_endline (fancy_of_term t :> Console.fancyobj);; -(* *) - - -let varcount = ref 11;; - -let freshvar () = ( - varcount := (!varcount + 1); - !varcount -);; - -let find_applicative = - let rec aux = function - | Tapp(t1, Tlam _, _) -> Some t1 - | Tapp(t1, t2, _) -> - (match aux t1 with - | None -> aux t2 - | _ as r -> r) - | _-> None - in let rec aux2 = function - | [] -> None - | x::xs -> (match aux x with - | None -> aux2 xs - | _ as result -> result - ) - in aux2 -;; - -let mk_apps t ts = List.fold_right (fun x y -> mk_app y x) (List.rev ts) t;; (* which FOLD? FIXME *) - -let rec hd = function | Tvar _ as x -> x | Tapp(t, _, _) -> hd t | _ -> assert false;; - -let rec set_applied = - function - | Tvar _ as v -> v - | Tlam _ -> assert false - | Tapp(t1,t2,_) -> Tapp(set_applied t1, set_applied t2, true) -;; - -let rec constant a n = - if n = 0 then [] else a:: (constant a (n-1)) -;; - -let rec mk_dummies k t = - set_applied (mk_apps t (constant dummy (k+1))) -;; - -let rec make_lambda_zero k = - if k = 0 then mk_dummies (k+1) zero else Tlam(0, make_lambda_zero (k-1)) -;; - -let mk_vars n = - let rec aux n = - if n = 0 - then [] - else (Tvar (freshvar ())) :: (aux (n-1)) - in aux n @ [make_lambda_zero (n+1)] -;; - -let apply a vars = - let rec aux = function - | Tapp(t1, t2, b) -> - if t1 = a - then (assert (not b); Tapp(aux t1, mk_apps' t2 vars, true)) - else Tapp(aux t1, aux t2, b) - | _ as t -> t - and mk_apps' t vars = - if t = zero - then mk_dummies (List.length vars - 1) t - else aux (mk_apps t vars) - in aux -;; - -let round k (app_map, tms) = - match find_applicative tms with - | None -> raise Not_found - | Some a -> - let vars = mk_vars k in - let f = apply a vars in - let app_map = (a, vars) :: (List.map (fun (x,y) -> f x, y) app_map) - in (app_map, List.map f tms) -;; - -let ends_with t1 t2 = match t1 with - | Tapp(_, t, _) -> t = t2 - | _ -> false -;; - -let rec last_round k (app_map, forbidden, t) = - let mk_apps' forbidden t vars = - if List.mem t forbidden - then mk_dummies (List.length vars - 1) t - else mk_apps t vars - (* in let rec already_applied = function - | Tapp(_, t) -> t = zero || t = dummy || hd t = zero - | _ -> false *) - in if ends_with t dummy then (app_map, forbidden, t) else (match t with - | Tapp(t1, t2, b) -> - if b - then - let app_map, forbidden, t1 = last_round k (app_map, forbidden, t1) - in let app_map, forbidden, t2 = last_round k (app_map, forbidden, t2) - in app_map, forbidden, Tapp(t1, t2, b) - else - let app_map, forbidden, t1 = last_round k (app_map, forbidden, t1) - in let app_map, forbidden, t2 = - try - let vars = List.assoc t1 app_map - in last_round k (app_map, forbidden, (mk_apps' forbidden t2 vars)) - with Not_found -> - let vars = mk_vars k in - let app_map = (t1, vars) :: app_map in - last_round k (app_map, (vars @ forbidden), (mk_apps' forbidden t2 vars)) - in app_map, forbidden, Tapp(t1, t2, true) - | _ as t -> app_map, forbidden, t - ) -;; - -let fixpoint f = - let rec aux x = try - let y = f x in aux y - with Not_found -> x - in aux -;; - -(* lista di sottotermini applicativi *) -let rec subterms = function - | Tlam _ -> assert false - | Tvar _ as v -> [v] - | Tapp(t1, t2, b) -> Tapp(t1, t2, b) :: ((subterms t1) @ (subterms t2)) -;; - -(* filtra dai sottotermini le variabili *) -let rec vars subs = List.filter (function Tvar _ -> true | _ -> false) subs;; - -let stupid_sort_uniq map l = - let rec stupid_uniq = function - | [] -> [] - | x::xs -> if List.mem x xs then (stupid_uniq xs) else x::(stupid_uniq xs) - in let stupid_compare a b = - let rec size = function - | Tvar n as v -> if v = zero then 0 else ( - try - let t, _ = List.find (fun (_,vars) -> List.mem v vars) map - in 1 + size t - with Not_found -> 1 + n) - | Tapp(t1,t2,_) -> 1 + size t1 + size t2 - | Tlam _ -> assert false - in compare (size a) (size b) - in stupid_uniq (List.sort stupid_compare l) -;; - -(* crea i match ricorsivamente. - - k e' lo special-K - - subs e' l'insieme dei sottotermini - TODO: riscrivere la funzione per evitare/ottimizzare la ricorsione - *) -let crea_match subs map forbidden (acc : (term * Num.nf) list) : term -> Num.nf = - let req t = try List.assoc t acc with Not_found -> `Var 9999 in - let aux t1 = ( - if t1 = dummy then `Var 99999 else - (* let _ = print_term t1 in *) - let cont = List.filter (fun t2 -> List.mem (Tapp(t1,t2,true)) subs) subs - in if cont = [] then - try `N (Util.index_of t1 subs) with Not_found -> `Var 999 (* variabile dummy qui *) else - - if List.mem (hd t1) forbidden then `Lam (true,req (Tapp(t1, dummy, true))) - else ( - let vars = List.assoc t1 map - (* in let _ = print_endline (String.concat " " (List.map string_of_term vars)) - in let _ = print_term (mk_apps dummy vars) *) - in let vars = List.map req vars - in let vars = List.map (Num.lift 1) vars (* forse lift non necessario *) - in let vars = Listx.from_list vars - in let body = `I(0, vars) - in let branches = List.map (fun t2 -> (Util.index_of t2 subs, req (Tapp(t1, t2, true)))) cont - in let bs = ref(branches) - in let lift = 1 - in let args = [] - in `Lam (true, `Match(body, lift, bs, args)) - ) - ) in aux -;; - -(* filtra dai sottotermini le variabili *) -let rec vars subs = List.filter (function Tvar _ -> true | _ -> false) subs;; - -let mk_zeros k = - let rec aux n prev = - if n = 0 then [zero] - else let prev = aux (n-1) prev in let x = mk_app (List.hd prev) dummy in x :: prev - in aux (k+1) [] -;; - -let rec freevars = function - | Tvar _ as v -> [v] - | Tlam(v,t) -> List.filter (fun x-> x <> Tvar v) (freevars t) - | Tapp(t1,t2,_) -> (freevars t1) @ (freevars t2) -;; - -open Pure;; - -let is_scott_n t n = - let open Lambda4 in let open Pure in - let rec aux n = function - | L (L (A (V 1, L (V 0)))) -> n = 0 - | L (L (A (V 0, t))) -> aux (n-1) t - | _ -> assert false - in aux n t -;; -let is_scott = - let open Lambda4 in let open Pure in - let rec aux = function - | L (L (A (V 1, L (V 0)))) -> 0 - | L (L (A (V 0, t))) -> 1 + aux t - | _ -> assert false - in aux -;; - -let compute_special_k tms = - let rec aux k t = match t with - | Tvar _ -> 0 - | Tapp(t1,t2,_) -> Pervasives.max (aux 0 t1) (aux 0 t2) - | Tlam(v,t) -> Pervasives.max (k+1) (aux (k + 1) t) - in List.fold_left (fun b a -> Pervasives.max (aux 0 a) b) 0 tms -;; - -let magic strings = - let rec map_helper_3 a b f = - function - | [] -> a, b, [] - | c::cs -> - let a, b, d = f (a, b, c) in - let a, b, ds = map_helper_3 a b f cs in - a, b, (d::ds) - in let _ = print_hline () - in let tms = parse strings - in let k = compute_special_k tms - in let zero' = make_lambda_zero (k+1) - in let tms = List.map (fun x -> Tapp(x, zero', false)) tms - in let fv = Util.sort_uniq (List.concat (List.map freevars tms)) - in let (map, tms') = fixpoint (round k) ([], tms) - (* in let _ = print_string_endline "map1 "; List.iter (fun (t,_) -> print_term t) map; print_string_endline "ok1" *) - in let _ = List.map print_term tms' - - in let map1 = List.map fst map - in let map2 = List.map snd map - in let map_new, forbidden, map1' = map_helper_3 [] [zero] (last_round k) map1 - - in let map = map_new @ (List.combine map1' map2) - (* in let _ = print_string_endline "map2 "; List.iter (fun (t,_) -> print_term t) map; print_string_endline "ok2" *) - in let map, forbidden, tms' = map_helper_3 map forbidden (last_round k) tms' - - in let _ = List.map print_term tms' - in let subs = List.concat (List.map subterms tms') - in let subs = stupid_sort_uniq map subs - (* metti gli zeri in testa, perche' vanno calcolati per primi *) - in let zeros = mk_zeros k - in let subs = (List.filter (fun t -> not (List.mem t zeros)) subs) @ (List.rev zeros) - - (* in let _ = print_string_endline " subs"; List.iter print_term subs *) - (* in let _ = print_string_endline "map "; List.iter (fun (t,_) -> print_term t) map; print_string_endline "ok" *) - - in let f t acc = let res = crea_match subs map forbidden acc t in (t,res)::acc - in let acc = List.fold_right f subs [] - - in let sigma = List.filter (fun (t,res) -> List.mem t fv) acc - in let _ = List.iter (fun (x,y) -> print_endline (fancy_of_term x ^^ (" : " / " ↦ ") ^^ fancy_of_nf y)) sigma - - in let _ = print_string_endline "controllo di purezza"; - (* in let open Num *) - in let ps, _ = Num.parse' strings - in let ps = List.map (fun x -> Num.mk_app x (`Var 1010)) ps - in let ps = List.map (fun t -> Num.ToScott.t_of_nf (t :> Num.nf)) ps - in let sigma = List.map ( - function (Tvar n , inst) -> n, Num.ToScott.t_of_nf inst | _ -> assert false - ) sigma - (* in let ps = - List.fold_left (fun ps (x,inst) -> List.map (Pure.subst false x inst) ps) ps sigma - in let _ = List.iteri (fun i n -> - print_string_endline ("X " ^ Pure.print (Pure.whd n)); - (* assert (is_scott_n (Pure.whd n) (Lambda3.index_of (List.nth tms' i) subs)) *) - is_scott (Pure.whd n); () - ) ps *) - in () -;; - - -(* magic ["x (x x x)"; "x (y. y x)"; "x x (y. y y (x x y))"] ;; *) -magic ["((x x) (x. x))";"x x"];; - -(* - -let alive (_, _, n) = n;; -let rec setalive c = function - | Tvar(a,b,_) as v -> if v <> zero && v <> dummy then Tvar(a,b,c) else v - | Tapp(a,b) -> Tapp(setalive c a, setalive c b) - | Tlam(n, t) -> Tlam(n, setalive c t) -;; - -let mk_vars t lev = - let rec aux n = - if n = 0 - then [] - else Tvar(0, Some(n, t), lev) :: (aux (n-1)) - in aux -;; - -let mk_apps t ts = List.fold_right (fun x y -> mk_app y x) (List.rev ts) t;; (* which FOLD? FIXME *) - - -let compute_special_k tms = - let rec aux k t = match t with - | Tvar _ -> 0 - | Tapp(t1,t2) -> Pervasives.max (aux 0 t1) (aux 0 t2) - | Tlam(v,t) -> Pervasives.max (k+1) (aux (k + 1) t) - in List.fold_left (fun b a -> Pervasives.max (aux 0 a) b) 0 tms -;; - -let compute_special_h tms = - let rec eat_lam = function - | Tlam(_,t) -> eat_lam t - | _ as t -> t - in - let rec aux t = match t with - | Tvar _ -> 0 - | Tapp(t1,t2) -> Pervasives.max (aux t1) (aux t2) - | Tlam(v,t) -> 1 + (aux (eat_lam t)) - in 1 + List.fold_left (fun b a -> Pervasives.max (aux a) b) 0 tms -;; - -(* funzione di traduzione brutta & cattiva *) -let translate k = - let rec aux = function - | Tlam _ -> assert false - | Tvar _ as v -> v - | Tapp(t1, t2) -> - let v = hd t1 in - let a = alive v in - let t1' = aux t1 in - let t2' = if a = 0 - then t2 - else mk_apps t2 ((List.rev (mk_vars t1' (a-1) k)) @ [zero]) - in Tapp(t1', aux t2') - in aux -;; - -(* sostituisce gli argomenti dummy (delle variabili morte) con 'dummy' *) -let rec dummize = function - | Tlam _ -> assert false - | Tvar (a,Some(b,t), c) -> Tvar(a, Some (b, dummize t), c) - | Tvar _ as v -> v - | Tapp(t1, t2) -> - if alive (hd t1) = 0 - then Tapp(dummize t1, dummy) - else Tapp(dummize t1, dummize t2) -;; - -(* lista di sottotermini applicativi *) -let rec subterms = function - | Tlam _ -> assert false - | Tvar _ as v -> [v] - | Tapp(t1, t2) -> Tapp(t1, t2) :: ((subterms t1) @ (subterms t2)) -;; - -(* filtra dai sottotermini le variabili *) -let rec vars subs = List.filter (function Tvar _ -> true | _ -> false) subs;; - - -let rec stupid_uniq = function - | [] -> [] - | x::xs -> if List.mem x xs then (stupid_uniq xs) else x::(stupid_uniq xs) -;; -let stupid_compare a b = - let rec size = function - | Tvar(_,None,_) -> 0 - | Tvar(_,Some(_,t),_) -> 1 + size t - | Tapp(t1,t2) -> 1 + size t1 + size t2 - | Tlam _ -> assert false - in compare (size a) (size b) -;; -let stupid_sort_uniq l = stupid_uniq (List.sort stupid_compare l);; - -(* crea i match ricorsivamente. - - k e' lo special-K - - subs e' l'insieme dei sottotermini - TODO: riscrivere la funzione per evitare/ottimizzare la ricorsione - *) -let crea_match k subs (acc : (term * Lambda3.nf) list) : term -> Lambda3.nf = - let req t = try List.assoc t acc with Not_found -> `Var 9999 in - let aux t1 = ( - if t1 = dummy then `Var 99999 else - (* let _ = print_term t1 in *) - let cont = List.filter (fun t2 -> List.mem (Tapp(t1,t2)) subs) subs - in if cont = [] then - try `N (Lambda3.index_of t1 subs) with Not_found -> `Var 999 (* variabile dummy qui *) else - let a = alive (hd t1) in - if a = 0 then `Lam (req (Tapp(t1, dummy))) - else ( - let vars = (List.rev (mk_vars t1 (a-1) k)) @ [zero] - (* in let _ = print_endline (String.concat " " (List.map string_of_term vars)) - in let _ = print_term (mk_apps dummy vars) *) - in let vars = List.map req vars - in let vars = List.map (Lambda3.lift 1) vars (* forse lift non necessario *) - in let vars = Listx.from_list vars - in let body = `I(0, vars) - in let branches = List.map (fun t2 -> (Lambda3.index_of t2 subs, req (Tapp(t1, t2)))) cont - in let bs = ref(branches) - in let lift = 1 - in let args = [] - in `Lam (`Match(body, lift, bs, args)) - ) - ) in aux -;; - -let mk_zeros k = - let rec aux n prev = - if n = 0 then [zero] - else let prev = aux (n-1) prev in let x = mk_app (List.hd prev) dummy in x :: prev - in aux (k+1) [] -;; - -let is_scott_n t n = - let open Lambda3 in let open Pure in - let rec aux n = function - | L (L (A (V 1, L (V 0)))) -> n = 0 - | L (L (A (V 0, t))) -> aux (n-1) t - | _ -> assert false - in aux n t -;; - -(* do the magic *) -let magic strings k h = ( - let tms = parse strings - in let tms = List.map (fun x -> Tapp(x, zero)) tms - in let tms' = List.map (setalive h) tms - in let tms' = List.map (translate k) tms' - in let tms' = List.map dummize tms' - (* in let bullet = ">" / "•" *) - (* in let progress s = print_endline (bullet ^^ fancy_of_string s) *) - in let progress = print_h1 - in let _ = progress "traduzione completata" - (* in let _ = List.map print_term tms' *) - in let _ = progress "ordino i sottotermini" - in let subs = List.concat (List.map subterms tms') - in let subs = stupid_sort_uniq subs - (* metti gli zeri in testa, perche' vanno calcolati per primi *) - in let zeros = mk_zeros k - in let subs = (List.filter (fun t -> not (List.mem t zeros)) subs) @ (List.rev zeros) - in let _ = progress ("sottotermini generati: " ^ string_of_int (List.length subs)) - in let vars = vars subs - (* in let _ = List.iter print_term subs *) - (* in let _ = 0/0 *) - in let fv = List.filter (function Tvar(_, None, _) as v -> v <> dummy | _ -> false) vars - (* in let _ = print_string ("> free vars: " ^ String.concat ", " (List.map (string_of_term) fv)) *) - in let _ = progress "sto creando i match" - (* in let sigma = List.map (fun x -> x, crea_match k subs x) fv *) - in let f t acc = let res = crea_match k subs acc t in (t,res)::acc - in let acc = List.fold_right f subs [] - in let sigma = List.filter (fun (t,res) -> List.mem t fv) acc - in let _ = progress "match creati" - in let _ = List.iter (fun (x,y) -> print_endline (fancy_of_term x ^^ (" : " / " ↦ ") ^^ fancy_of_nf y)) sigma - - in let _ = progress "controllo di purezza"; - in let open Lambda3 - in let ps, _ = Lambda3.parse' strings - in let ps = List.map (fun x -> Lambda3.mk_app x (`Var 1010)) ps - in let ps = List.map (fun t -> ToScott.t_of_nf (t :> nf)) ps - in let sigma = List.map ( - function (Tvar(n,_,_), inst) -> n, ToScott.t_of_nf inst | _ -> assert false - ) sigma - in let ps = - List.fold_left (fun ps (x,inst) -> List.map (Pure.subst false x inst) ps) ps sigma - in let _ = List.iteri (fun i n -> - (* print_string_endline ((string_of_int i) ^ ":: " ^ (Pure.print (Pure.whd n))); *) - (* assert (Pure.whd n = Scott.mk_n (Lambda3.index_of (List.nth tms' i) subs))) ps *) - assert (is_scott_n (Pure.whd n) (Lambda3.index_of (List.nth tms' i) subs))) ps - in let _ = progress "fatto." in () -);; - -let do_everything tms = -let tms' = parse tms in -let k = compute_special_k tms' in -let h = compute_special_h tms' in -(* let _ = print_string_endline (string_of_int h) in *) -magic tms k h -;; - -let _ = - let tms = ["a a"; "a b"; "b a"; "b (x. y.x y a)"] in - (* 1 2 *) - (* let tms = ["x c" ; "b (x c d e)"; "b"] in *) - (* 0 1 *) - (* let tms = ["x x x"] in *) - let tms' = parse tms in - let k = compute_special_k tms' in - let h = compute_special_h tms' in - (* let _ = print_string_endline (string_of_int h) in *) - magic tms k h -;; - -(* type var' = (* unique name *) int * (int * term') option * (*dead*) bool option -and term' = - | Tvar' of var' - | Tapp' of term' * term' * (* active *) bool - | Tlam' of int * term' -;; - -let rec iter mustapply = - let aux = function - | Tvar'(n, Some(m,t), b) -> Tvar(n, Some(m, aux t), b) - | Tvar' _ as v -> v - | Tapp'(t1, t2, b) -> if b && - in aux -;; *) - -*) diff --git a/ocaml/andrea6.ml b/ocaml/andrea6.ml deleted file mode 100644 index 38346b0..0000000 --- a/ocaml/andrea6.ml +++ /dev/null @@ -1,615 +0,0 @@ -let print_hline = Console.print_hline;; - -type var = int;; - -type t = - | V of var - | A of t * t - | L of t - | LM of - t list (* body of the match *) - * int (* explicit liftno *) - * int (* variable which originated this match (id) *) - | B (* bottom *) - | P (* pacman *) -;; - - -type problem = { - orig_freshno: int - ; freshno : int - ; div : t list - ; conv : t list - ; matches : (var (* variable originating this match *) * (bool (* term comes from div*) * (t (* term to discriminate *) * t (* continuation *))) list) list - ; sigma : (var * t) list (* substitutions *) -} - -let string_of_t p = - let bound_vars = ["x"; "y"; "z"; "z1"; "z2"] in - let rec aux level = function - | V v -> if v >= level then "`" ^ string_of_int (v-level) else List.nth bound_vars (level - v-1) - | A (t1,t2) -> "("^aux level t1^" "^aux level t2^")" - | L t -> "(\\" ^ aux (level+1) (V 0) ^ ". " ^ aux (level+1) t ^ ")" - | LM (ts,liftno,id) -> "[match orig="^aux 0 (V id)^"]" - | B -> "BOT" - | P -> "PAC" - in aux 0 -;; - -let string_of_t p = - let bound_vars = ["x"; "y"; "z"; "w"; "q"; "x1"; "x2"] in - let rec string_of_term_w_pars level = function - | V v -> if v >= level then "`" ^ string_of_int (v-level) else List.nth bound_vars (level - v-1) - | A _ as t -> "(" ^ string_of_term_no_pars_app level t ^ ")" - | L _ as t -> "(" ^ string_of_term_no_pars_lam level t ^ ")" - | LM (ts,liftno,id) -> "[match orig="^ string_of_term_w_pars 0 (V id)^"]" - | B -> "BOT" - | P -> "PAC" - and string_of_term_no_pars_app level = function - | A(t1,t2) -> (string_of_term_no_pars_app level t1) ^ " " ^ (string_of_term_w_pars level t2) - | _ as t -> string_of_term_w_pars level t - and string_of_term_no_pars_lam level = function - | L t -> "λ" ^ string_of_term_w_pars (level+1) (V 0) ^ ". " ^ (string_of_term_no_pars_lam (level+1) t) - | _ as t -> string_of_term_no_pars level t - and string_of_term_no_pars level = function - | L _ as t -> string_of_term_no_pars_lam level t - | _ as t -> string_of_term_no_pars_app level t - in string_of_term_no_pars 0 -;; - -let string_of_problem p = - let lines = [ - "[DV] " ^ String.concat "\n " (List.map (string_of_t p) p.div); - "[CV] " ^ String.concat "\n " (List.map (string_of_t p) p.conv); - (* "" ; *) - ] @ Util.concat_map (fun (v, lst) -> ("[<>] of "^(string_of_t p (V v))) :: List.map (fun (b,(t,c)) -> " " ^ (if b then "*" else " ") ^ " " ^ string_of_t p t - (* ^" -> " ^ string_of_t p c *) - ) lst) p.matches @ [""] in - String.concat "\n" lines -;; - -let problem_fail p reason = - print_endline "!!!!!!!!!!!!!!! FAIL !!!!!!!!!!!!!!!"; - print_endline (string_of_problem p); - failwith reason -;; - -let freshvar ({freshno} as p) = - {p with freshno=freshno+1}, freshno+1 -;; - -let add_to_match p id entry = - let matches = try - let _ = List.assoc id p.matches in - List.map (fun (id',lst as x) -> if id <> id' then x else (id, entry::lst) ) p.matches - with - | Not_found -> (id,[entry]) :: p.matches in - {p with matches} -;; - -let var_occurs_in v = - let rec aux level = function - | V v' -> v + level = v' - | A(t1,t2) -> (aux level t1) || (aux level t2) - | L t -> aux (level+1) t - | LM(ts,_,_) -> List.fold_left (fun a b -> a || aux (level+1) b) false ts - | B -> false - | P -> false - in aux 0 -;; - -let rec is_inert = - function - | A(t,_) -> is_inert t - | V _ -> true - | L _ | LM _ | B | P -> false -;; - -let is_var = function V _ -> true | _ -> false;; -let is_lambda = function L _ -> true | _ -> false;; -let is_pacman = function P -> true | _ -> false;; - -let rec subst isdiv level delift sub p = - function - | V v -> p, if v = level + fst sub then lift level (snd sub) else V (if delift && v > level then v-1 else v) - | L t -> let p, t = subst isdiv (level + 1) delift sub p t in p, L t - | A (t1,t2) -> - let p, t1 = subst isdiv level delift sub p t1 in - let p, t2 = subst isdiv level delift sub p t2 in - if t1 = B || t2 = B then p, B else - if level = 0 then mk_app isdiv p t1 t2 else p, A (t1, t2) - | LM (ts, liftno, id) -> - let p, ts = - let rec aux p = function - | [] -> p, [] - | t::ts -> - let p, ts = aux p ts in - let p, t = subst isdiv (level+1) delift sub p t in - p, t::ts in - aux p ts in - p, LM(ts, liftno, id) - | B -> p, B - | P -> p, P -and mk_app isdiv p t1 t2 = let t1 = if t1 = P then L P else t1 in match t1 with - | L t1 -> - (* FIXME BUG HERE! *) - if is_inert t2 && (match t2 with V v -> v > p.orig_freshno | _ -> true ) && not (var_occurs_in 0 t1) - then (if isdiv then {p with div=p.div @ [t2]} else {p with conv=p.conv @ [t2]}), lift (-1) t1 - else subst isdiv 0 true (0, t2) p t1 - | LM(ts,liftno,id) -> - let p, t = mk_apps isdiv p t2 (List.map (lift ~-1) ts) in - if t = B - then p, B - else - let p, cont = freshvar p in - let newvar = V cont in - let p = add_to_match p id (isdiv,(t,newvar)) in - p, newvar - | B - | _ when t2 = B -> p, B - | t1 -> p, A (t1, t2) -and mk_apps isdiv p t = - function - | [] -> p, t - | t'::ts -> let p, t = mk_app isdiv p t t' in mk_apps isdiv p t ts - and lift n = - let rec aux n' = - function - | V m -> V (if m >= n' then m + n else m) - | L t -> L (aux (n'+1) t) - | A (t1, t2) -> A (aux n' t1, aux n' t2) - | LM (ts, liftno, id) -> LM (List.map (aux (n'+1)) ts, n + liftno, id) - | B -> B - | P -> P - in aux 0 - ;; - -let subst isdiv = subst isdiv 0 false;; - -let mk_lambda t = L (lift 1 t) ;; - -let subst_many b sub = - let rec aux p = function - | [] -> p, [] - | t::tms -> - let p, t = subst b sub p t in - let p, tms = aux p tms in - p, t :: tms - in aux -;; - -let rec subst_in_matches sub p = - function - | [] -> p, [] - | (v, branches) :: ms-> - let a, b = List.split branches in - let b, c = List.split b in - let p, b = subst_many false sub p b in - let p, c = subst_many false sub p c in - let b = List.combine b c in - let branches = List.combine a b in - let p, ms = subst_in_matches sub p ms in - p, (v, branches) :: ms -;; - -let subst_in_problem (sub: var * t) (p: problem) = -(* print_endline ("SUBST IN PROBLEM: " ^ string_of_t p (V (fst sub)) ^ " " ^ string_of_t p (snd sub)); *) - let div, conv = p.div, p.conv in - let p = {p with div=[]; conv=[]} in - let p, div' = subst_many true sub p div in - let p, conv' = subst_many false sub p conv in - let p, matches = subst_in_matches sub p p.matches in - let p = {p with div=div'@p.div; conv=conv'@p.conv; matches} in - (* print_endline ("after sub: \n" ^ string_of_problem p); *) - {p with sigma=sub::p.sigma} -;; - -(* FIXME *) -let unify_terms p t1 t2 = - match t1 with - | V v -> subst_in_problem (v, t2) p - | _ -> problem_fail p "The collapse of a match came after too many steps :(";; - -let rec unify p = - let rec give_duplicates = - let rec aux' t = function - | [] -> [], None - | (b',(t',c'))::ts -> if t = t' (* FIXME! eta-eq here *)then ts, Some (b',c') else ( - let ts, res = aux' t ts in (b',(t',c'))::ts, res) in - let rec aux = function - | [] -> [], None - | (b,(t,c))::rest -> ( - match aux' t rest with - | rest, None -> aux rest - | rest, Some (b',c') -> ((if not b' then false else b),(t,c))::rest, Some (c', c) - ) in - function - | [] -> [], None - | (orig,branches) :: ms -> - match aux branches with - | _, None -> let ms, res = give_duplicates ms in (orig,branches) :: ms, res - | branches', Some subst -> (orig,branches') :: ms, Some subst in - let matches, vars_to_be_unified = give_duplicates p.matches in - let p = {p with matches=matches} in - match vars_to_be_unified with - | None -> p - | Some(t', t) -> - (* print_endline ("> unify " ^ string_of_t p (t') ^ " with " ^ string_of_t p t); *) - unify (unify_terms p t' t) -;; - -let problem_done p = - let all_separated = List.for_all (fun (_, lst) -> List.length lst = 1 || List.for_all (fun (_,(t,_)) -> is_var t) lst) p.matches in - all_separated && List.exists ((=) B) p.div -;; - -let free_vars p t = - let rec aux level = function - | V v -> if v >= level then [v] else [] - | A(t1,t2) -> (aux level t1) @ (aux level t2) - | L t -> aux (level+1) t - | LM(ts,_,id) -> (List.concat (List.map (aux level) ts)) @ ( - let lst = List.assoc id p.matches in - List.concat (List.map (fun (_,(t1,t2)) -> (aux 0 t1) @ (aux 0 t2)) lst) - ) - | B -> [] - | P -> [] - in Util.sort_uniq (aux 0 t) -;; - -let visible_vars p t = - let rec aux = function - | V v -> [v] - | A(t1,t2) -> (aux t1) @ (aux t2) - | L t -> [] - | LM(ts,_,id) -> (List.concat (List.map aux ts)) @ ( - let lst = List.assoc id p.matches in - List.concat (List.map (fun (_,(t1,t2)) -> (aux t1) @ (aux t2)) lst) - ) - | B -> [] - | P -> [] - in Util.sort_uniq (aux t) -;; - -let forget_variable var p = - let p', div = subst_many true (var, P) p p.div in - let p = {p' with conv=p.conv} in - let p, conv = subst_many false (var, B) p p.conv in - let p, matches = subst_in_matches (var, B) p p.matches in - {p with div; conv; matches; sigma=p.sigma} -;; -let rec remove_divergent_discriminators p = - let f = fun (b,(t,_)) -> b && (t = B || is_lambda t) in - try - let v,l = List.find (fun (_,lst) -> List.exists f lst) p.matches in - let (_,(_,c)) as entry = List.find f l in - let l = List.filter ((<>) entry) l in - let matches = List.map (fun (v', l') -> v', if v' = v then l else l') p.matches in - let vars = free_vars p c in - let p = {p with matches} in - List.fold_right forget_variable vars p - with Not_found -> p -;; - -exception Done;; - -let sanity p = - (* try to fix divergent discriminators *) - let p = remove_divergent_discriminators p in - (* Remove lambdas from conv TODO remove duplicates *) - let div = List.filter (function | P | L _ -> false | _ -> true) p.div in - let conv = List.filter (function | B | V _ | A _ -> true | _ -> false) p.conv in - let p = {p with div;conv} in - (* Sanity checks: *) - if p.div = [] then problem_fail p "p.div converged"; - if List.mem B p.conv then problem_fail p "p.conv diverged"; - if not (List.for_all (fun (_, lst) -> List.for_all (fun (b,(t,_)) -> is_inert t) lst) p.matches) - then problem_fail p "Unsolvable discrimination"; - - (* unify! :( *) - let p = unify p in - print_endline (string_of_problem p); (* non cancellare *) - if problem_done p then raise Done else p -;; - -let print_cmd s1 s2 = print_endline (">> " ^ s1 ^ " " ^ s2);; - -let ignore var n p = - print_cmd "EAT" ("on " ^ string_of_t p (V var) ^ " (of:" ^ string_of_int n ^ ")"); - let rec aux m t = - if m = 0 - then lift n t - else L (aux (m-1) t) in - let p, fresh = freshvar p in - let subst = var, aux n (V fresh) in - sanity (subst_in_problem subst p) -;; - -let explode p = - let fv1 = List.concat (List.map (visible_vars p) p.div) in - let fv2 = List.concat (List.map (visible_vars p) p.conv) in - let fv = List.filter (fun x -> not (List.mem x fv2)) fv1 in - let fv = List.filter ((<) p.orig_freshno) fv in - match fv with - | var::_ -> - print_cmd "EXPLODE" ("on " ^ string_of_t p (V var)); - let subst = var, B in - sanity (subst_in_problem subst p) - | _ -> problem_fail p "premature explosion" -;; - -let step var p = - print_cmd "STEP" ("on " ^ string_of_t p (V var)); - let subst = var, LM([], 0, var) in - sanity (subst_in_problem subst p) -;; - -let id var p = - print_cmd "ID" ("on " ^ string_of_t p (V var)); - let subst = var, L(V 0) in - sanity (subst_in_problem subst p) -;; - -let apply var appk p = - print_cmd "APPLY" - (string_of_t p (V var) ^ " applies no." ^ string_of_int appk ^ " fresh variables"); - let rec mk_freshvars n p = - if n = 0 - then p, [] - else - let p, vs = mk_freshvars (n-1) p in - let p, v = freshvar p in - p, V(v)::vs in - let p, vars = mk_freshvars appk p in - let p, t = mk_apps false p (V 0) (List.map (lift 1) vars) in - let t = L (A (lift 1 (V var), t)) in - let subst = var, t in - sanity (subst_in_problem subst p) -;; - -let perm var n p = - print_cmd "PERM" ("on " ^ string_of_t p (V var) ^ " (of:" ^ string_of_int n ^ ")"); - let p, v = freshvar p in - let rec aux' m t = if m < 0 then t else A(aux' (m-1) t, V m) in - let rec aux m t = - if m = 0 - then aux' (n-1) t - else L (aux (m-1) t) in - let t = aux n (lift n (V v)) in - let subst = var, t in - sanity (subst_in_problem subst p) -;; - -(* TODO: -- cosi' come e' possibile unificare rami di branch solo se vanno -> a variabili, - allo stesso modo e' possibile ignorare dei rami se vanno in variabili, e quelle variabili - vengono sostituite ovunque: con bombe in conv e con pacman in div -*) -let forget var no p = - try - let l = List.assoc var p.matches in - let (b,(tm,c)) = List.nth l no in - let l = List.mapi (fun n x -> if n = no then (b,(B,c)) else x) l in - let matches = List.map (fun (v,lst) -> v, if v = var then l else lst) p.matches in - let p = {p with matches} in - print_cmd "FORGET" (string_of_t p tm ^ " from the match of " ^ string_of_t p (V var)); - sanity p - (* (match c with - | V var -> - print_endline ( - "--- FORGET " ^ string_of_t p tm ^ " from the match of " ^ string_of_t p (V var)); - let p = forget_variable var p in - - | _ -> print_endline "too late to forget that term"; p - ) *) - with Failure "nth" -> - print_endline "wtf?"; p -;; - -let parse strs = - let dummy_p = {orig_freshno=0; freshno=0; div=[]; conv=[]; matches=[]; sigma=[]} in - let rec aux level = function - | Parser.Lam t -> L (aux (level + 1) t) - | Parser.App (t1, t2) -> - if level = 0 then snd (mk_app false dummy_p (aux level t1) (aux level t2)) - else A(aux level t1, aux level t2) - | Parser.Var v -> V v - in let (tms, free) = Parser.parse_many strs - in (List.map (aux 0) tms, free) -;; - -let rec list_split n = - function - | [] -> [], [] - | x::xs as l -> if n = 0 then [], l else let a, b = list_split (n-1) xs in x::a, b -;; - -let magic6 div conv cmds = - print_hline (); - let all_tms, var_names = parse (div @ conv) in - let div, conv = list_split (List.length div) all_tms in - let varno = List.length var_names in - let p = {orig_freshno=varno; freshno=1+varno; div; conv; matches=[]; sigma=[]} in - let p = try - let subst = Util.index_of "BOMB" var_names, L B in - let p = subst_in_problem subst p in p - with Not_found -> p in - let p = sanity p in - try - problem_fail (List.fold_left (|>) p cmds) "Problem not completed" - with - | Done -> () -;; - -let interactive div conv cmds = - print_hline (); - let all_tms, var_names = parse (div @ conv) in - let div, conv = list_split (List.length div) all_tms in - let varno = List.length var_names in - let p = {orig_freshno=varno; freshno=1+varno; div; conv; matches=[]; sigma=[]} in - (* activate bombs *) - let p = try - let subst = Util.index_of "BOMB" var_names, L B in - subst_in_problem subst p - with Not_found -> p in - (* activate pacmans *) - let p = try - let subst = Util.index_of "PACMAN" var_names, P in - let p = subst_in_problem subst p in - (print_endline ("after subst in problem " ^ string_of_problem p); p) - with Not_found -> p in - (* initial sanity check *) - let p = sanity p in - let p = List.fold_left (|>) p cmds in - let rec f p cmds = - let nth spl n = int_of_string (List.nth spl n) in - let read_cmd () = - let s = read_line () in - let spl = Str.split (Str.regexp " +") s in - s, let uno = List.hd spl in - try if uno = "explode" then explode - else if uno = "ignore" then ignore (nth spl 1) (nth spl 2) - else if uno = "step" then step (nth spl 1) - else if uno = "perm" then perm (nth spl 1) (nth spl 2) - else if uno = "apply" then apply (nth spl 1) (nth spl 2) - else if uno = "forget" then forget (nth spl 1) (nth spl 2) - else if uno = "id" then id (nth spl 1) - else failwith "Wrong input." - with Failure s -> print_endline s; (fun x -> x) in - let str, cmd = read_cmd () in - let cmds = (" " ^ str ^ ";")::cmds in - try - let p = cmd p in f p cmds - with - | Done -> print_endline "Done! Commands history: "; List.iter print_endline (List.rev cmds) - in f p [] -;; - -let _ = magic6 - ["x x"] - [ "_. BOMB" ] - [ ignore 1 1; explode ] -;; - - let _ = magic6 - ["x y BOMB b"] - [ "x BOMB y c" ] - [ perm 1 3; step 8 ; explode; ];; - -let _ = magic6 - ["x BOMB a1 c"] - [ "x y BOMB d"; "x BOMB a2 c" ] - [ perm 1 3 ; step 10 ; step 13; explode; ] -;; - -let _ = magic6 - ["x (x x)"] - [ "x x" ; "x x x" ] [ - apply 1 1; - step 1; - explode; - step 9; -];; - -let _ = magic6 - ["x (_.BOMB)"] - [ "x (_._. BOMB)" ] - [ apply 1 2; ] -;; - -let _ = magic6 - ["x (_.y)"] - [ "y (_. x)" ] - [ apply 1 1; ignore 1 1; explode; ] -;; - -let _ = magic6 - ["y (x a1 BOMB c) (x BOMB b1 d)"] - [ "y (x a2 BOMB c) (x BOMB b1 d)"; - "y (x a1 BOMB c) (x BOMB b2 d)";] [ - perm 2 3; - step 12; - perm 17 2; - step 19; - step 18; - ignore 22 1; - ignore 21 1; - ignore 24 1; - ignore 25 1; - step 1; - step 32; - explode; - ] -;; - -let _ = magic6 - ["z (y x)"] - [ "z (y (x.x))"; "y (_. BOMB)" ] - [ apply 2 1; step 3; explode; ] -;; - -let _ = magic6 - ["y x"] - [ "y (x.x)"; "x (_. BOMB)" ] - [ apply 1 1; ignore 2 1; step 1; explode; ] -;; - -let _ = magic6 - ["z (y x)"] - [ "z (y (x.x))"; "y (_. BOMB)" ] - [ step 1; explode; apply 2 1; id 2; ignore 3 1; ] -;; - -let _ = magic6 - ["y (x a)"] - [ "y (x b)"; "x BOMB" ] [ - id 2; - step 1; - explode; -];; - -magic6 - ["y (x a)"] [ "y (x b)"; "x BOMB"; "y a" ] - [ - apply 1 1; - perm 2 2; - ignore 9 1; - step 10; - explode; - ];; -(* "y (a c)" -[ "y (b c)"; "y (x a)"; "y (x b)"; "x BOMB" ] *) - -magic6 -["x a (x (a.y BOMB))"] -[ "x b"; "x (y c)"; "x (y d)" ] -[apply 1 1; -apply 2 1; -explode;] -(* [ -step 1; -step 3; -explode' 10; -(* ma si puo' fare anche senza forget *) *) -(* ] *) -;; - -(* dipendente dalla codifica? no, ma si risolve solo con id *) -magic6 - ["y a"] ["y b"; "x (y (_.BOMB))"] -[ -apply 1 1; -apply 2 1; -explode; -];; - (* [id 1; explode];; *) - -magic6 - ["PACMAN (x x x)"] ["PACMAN (x x)"] - [ - ignore 2 2; - explode; - ];; - -print_hline(); -print_endline "ALL DONE. " diff --git a/ocaml/andrea7.ml b/ocaml/andrea7.ml deleted file mode 100644 index 4a27c79..0000000 --- a/ocaml/andrea7.ml +++ /dev/null @@ -1,751 +0,0 @@ -let (++) f g x = f (g x);; - -let print_hline = Console.print_hline;; - -type var = int;; -type t = - | V of var - | A of t * t - | L of t - | B (* bottom *) - | P (* pacman *) - | Stuck of var * int - (* | Ptr of int *) -;; - -let rec consts = (* const_apps, const_lambda *) - let rec aux1 = function - | A(t, _) -> 1 + aux1 t - | _ -> 0 in - let rec aux2 = function - | L t -> 1 + aux2 t - | _ -> 0 in - function - | A(t1, t2) as t -> - let a1, b1 = consts t1 in - let a2, b2 = consts t2 in - max (aux1 t) (max a1 a2), max b1 b2 - | L t' as t -> - let a, b = consts t' in - a, max (aux2 t) b - | _ -> 0, 0 -;; - - -type problem = { - orig_freshno: int - ; freshno : int - ; div : t - ; conv : t list - ; matches : (var (* variable originating this match *) * ((int (* index of the term to discriminate *) * var option (* continuation *))) list) list - ; sigma : (var * t) list (* substitutions *) - ; stepped : var list - ; arities : (var * int) list - ; k_app : int - ; k_lam : int -} - -let dummy_p = {orig_freshno=0; freshno=0; div=B; conv=[]; matches=[]; sigma=[]; stepped=[]; arities=[]; k_app=0;k_lam=0};; - -let append_conv p t = let len = List.length p.conv in let p = {p with conv=t::p.conv} in p, len;; -let get_conv p n = List.nth p.conv (List.length p.conv - 1 - n);; -let index_of_conv t conv = List.length conv - 1 - (Util.index_of t conv);; - -let eq_conv = (=);; -let eq_conv_indices p i j = eq_conv (get_conv p i) (get_conv p j);; -let all_terms p = p.div :: p.conv;; - -exception Done of (var * t) list (* substitution *);; -exception Fail of int * string;; - -let string_of_t p = - let bound_vars = ["x"; "y"; "z"; "w"; "q"; "x1"; "x2"; "x3"; "x4"; "x5"] in - let rec string_of_term_w_pars level = function - | V v -> if v >= level then "`" ^ string_of_int (v-level) else List.nth bound_vars (level - v-1) - | A _ - | L _ as t -> "(" ^ string_of_term_no_pars_lam level t ^ ")" - | B -> "BOT" - | P -> "PAC" - | Stuck _ as t -> "(" ^ string_of_term_no_pars_app level t ^ ")" - (* | Ptr _ as t-> "(" ^ string_of_term_no_pars_app level t ^ ")" *) - (* "&" ^ string_of_int n *) - and string_of_term_no_pars_app level = function - | A(t1,t2) -> (string_of_term_no_pars_app level t1) ^ " " ^ (string_of_term_w_pars level t2) - | Stuck(v,n) -> ":" ^ string_of_term_no_pars_app level (V v) ^ " " ^ (string_of_term_w_pars level (get_conv p n)) - (* | Ptr n -> string_of_term_no_pars_app level (get_conv p n) *) - (* | Ptr n -> "&" ^ string_of_int n *) - | _ as t -> string_of_term_w_pars level t - and string_of_term_no_pars_lam level = function - | L t -> "λ" ^ string_of_term_w_pars (level+1) (V 0) ^ ". " ^ (string_of_term_no_pars_lam (level+1) t) - | _ as t -> string_of_term_no_pars level t - and string_of_term_no_pars level = function - | L _ as t -> string_of_term_no_pars_lam level t - | _ as t -> string_of_term_no_pars_app level t - in string_of_term_no_pars 0 -;; - -let string_of_problem p = - let lines = [ - "[arities] " ^ String.concat " " (List.map (fun (v,n) -> "`" ^ string_of_int v ^ "=" ^ string_of_int n) p.arities); - "[stepped]" ^ String.concat " " (List.map string_of_int p.stepped); - "[DV] " ^ (string_of_t p p.div); - "[CV] " ^ String.concat "\n " (List.map (string_of_t p) p.conv); - (* "" ; *) - ] @ Util.concat_map (fun (v, lst) -> ("[<>] of "^(string_of_t p (V v))) :: List.map (fun (n,c) -> " " ^ string_of_t p (get_conv p n) - ^ (match c with None -> "" | Some v -> " -> " ^ string_of_t p (V v)) - ) lst) p.matches @ [""] in - String.concat "\n" lines -;; - -let problem_fail p reason = - print_endline "!!!!!!!!!!!!!!! FAIL !!!!!!!!!!!!!!!"; - print_endline (string_of_problem p); - raise (Fail (-1, reason)) -;; - -let freshvar ({freshno} as p) = - {p with freshno=freshno+1}, freshno+1 -;; - -let add_to_match p id t = - let p, entry = - try - p, index_of_conv t p.conv - with - | Not_found -> append_conv p t in - let entry' = entry, None in - let matches = - List.map (fun (id',lst as x) -> if id <> id' then x else (id, entry'::lst)) p.matches - in - {p with matches}, entry -;; - -let var_occurs_in p v = - let rec aux level = function - | V v' -> v + level = v' - | Stuck(v',n) -> assert (v <> v'); aux level (get_conv p n) - | A(t1,t2) -> (aux level t1) || (aux level t2) - | L t -> aux (level+1) t - | B -> false - | P -> false - (* | Ptr n -> aux level (get_conv p n) *) - - in aux 0 -;; - -let rec is_inert p = - function - | A(t,_) -> is_inert p t - (* | Ptr n -> is_inert p (get_conv p n) *) - | V _ | Stuck _ -> true - | L _ | B | P -> false -;; - -let is_var = function V _ -> true | _ -> false;; -let is_lambda = function L _ -> true | _ -> false;; -let is_pacman = function P -> true | _ -> false;; - -let rec subst level delift sub p = - function - | V v -> p, if v = level + fst sub then lift level (snd sub) else V (if delift && v > level then v-1 else v) - | L t -> let p, t = subst (level + 1) delift sub p t in p, L t - | A (t1,t2) -> - let p, t1 = subst level delift sub p t1 in - let p, t2 = subst level delift sub p t2 in - if t1 = B || t2 = B then p, B else - if level = 0 then mk_app p t1 t2 else p, A (t1, t2) - | B -> p, B - | P -> p, P - (* | Ptr _ as t -> p, t *) - | Stuck(v,_) as t -> - assert (v <> level + fst sub); (* can't instantiate v twice after a step *) - (* FIXME!!!! URGENT!!! *) - p, t -and mk_app p t1 t2 = let t1 = if t1 = P then L P else t1 in match t1 with - | L t1 -> subst 0 true (0, t2) p t1 - | V v when List.mem v p.stepped -> - let p, n = add_to_match p v t2 in - p, Stuck(v, n) - | B | _ when t2 = B -> p, B - | t1 -> p, A (t1, t2) -and mk_apps p t = - function - | [] -> p, t - | t'::ts -> let p, t = mk_app p t t' in mk_apps p t ts -and lift n = - let rec aux n' = - function - | V m -> V (if m >= n' then m + n else m) - | L t -> L (aux (n'+1) t) - | A (t1, t2) -> A (aux n' t1, aux n' t2) - | B -> B - | P -> P - | Stuck(m,ptr) -> assert (m >= n'); Stuck(m + n, ptr) - (* | Ptr _ as t -> t *) - in aux 0 -;; - -let subst = subst 0 false;; - -let mk_lambda t = L (lift 1 t) ;; - -let subst_many sub = - let rec aux p = function - | [] -> p, [] - | t::tms -> - let p, tms = aux p tms in - let p, t = subst sub p t in - p, t :: tms - in aux -;; - -let subst_in_problem (sub: var * t) (p: problem) = -(* print_endline ("SUBST IN PROBLEM: " ^ string_of_t p (V (fst sub)) ^ " |-> " ^ string_of_t p (snd sub)); *) -(* BUG QUI FIXME!!!! *) - let rec mix l1 l2 = match l1, l2 with - | [], l2 -> l2 - | x::xs, _::ys -> x:: (mix xs ys) - | _ -> assert false in - let p, conv = subst_many sub p p.conv in - let p, div = subst sub p p.div in - let conv = List.rev (mix (List.rev conv) (List.rev p.conv)) in - let p = {p with div; conv} in - (* print_endline ("after sub: \n" ^ string_of_problem p); *) - {p with sigma=sub::p.sigma} -;; - -let problem_done p = - let all_separated = List.for_all (fun (_, lst) -> List.for_all (fun (n,_) -> is_var (get_conv p n)) lst) p.matches in - all_separated && p.div = B -;; - -let free_vars p t = - let rec aux level = function - | V v -> if v >= level then [v] else [] - | A(t1,t2) -> (aux level t1) @ (aux level t2) - | L t -> aux (level+1) t - | B | P - | Stuck _ -> [] - (* | Ptr n -> aux 0 (get_conv p n) *) - in Util.sort_uniq (aux 0 t) -;; - -let visible_vars p t = - let rec aux = function - | V v -> [v] - | A(t1,t2) -> (aux t1) @ (aux t2) - | B | P - | Stuck _ | L _ -> [] - (* | Ptr n -> aux (get_conv p n) *) - in Util.sort_uniq (aux t) -;; - -(* TODO FIXME *) -let apply_substs p t = t;; - -let unblock var index cont p = - let rec aux p = function - | Stuck(v',n') as t -> p, (if var = v' && index = n' then apply_substs p (V cont) else t) - | A (t1, t2) -> - let p, t1 = aux p t1 in - let p, t2 = aux p t2 in - mk_app p t1 t2 - | _ as t -> p, t in - let p, div = aux p p.div in - let _, conv = List.fold_right (fun c (p, conv) -> let p, c = aux p c in p, c::conv) p.conv (p,[]) in - {p with div; conv} -;; - -let rec unblock_all p = - let aux (orig, m) (matches, news, p) = - let nn = List.filter (fun (n,c) -> is_var (get_conv p n) && c = None) m in - let p, conts = List.fold_left (fun (p,conts) (n,_) -> - match Util.find_opt (function (n', c) when eq_conv_indices p n' n -> c | _ -> None) m - with Some c -> p, (n, c)::conts | None -> - (* c is the new continuation *) - let p, c = freshvar p in - let arity = c, List.assoc orig p.arities - 1 in - print_endline ("``" ^ string_of_int orig); - assert ((snd arity) > -1 ); - let p = {p with arities=arity::p.arities} in - p, (n, c)::conts - ) (p, []) nn in - let m = List.map (fun (n,c) -> n, try - Some (List.assoc n conts) - with - | Not_found -> c) m in - (orig, m) :: matches, (List.map (fun x -> orig, x) conts) @ news, p - in - let matches, news, p = List.fold_right aux p.matches ([],[], p) in - (* FIXPOINT *) - if news <> [] then - let f = List.fold_left (fun f (a,(b,c)) -> f ++ (unblock a b c)) (fun p -> p) news in - unblock_all (f {p with matches}) else p -;; - -let rec simple_explode p = - match p.div with - | V var -> - let subst = var, B in - sanity (subst_in_problem subst p) - | _ -> p - -and sanity p = - (* Sanity checks: *) - if (function | P | L _ -> true | _ -> false) p.div then problem_fail p "p.div converged"; - if List.mem B p.conv then problem_fail p "p.conv diverged"; - if not (List.for_all (fun (_, lst) -> List.for_all (fun (n,_) -> is_inert p (get_conv p n)) lst) p.matches) - then problem_fail p "Unsolvable discrimination"; - - let p = unblock_all p in - print_endline (string_of_problem p); (* non cancellare *) - let p = if problem_done p then raise (Done p.sigma) else p in - let p = if is_var p.div then simple_explode p else p in - p -;; - -let print_cmd s1 s2 = print_endline (">> " ^ s1 ^ " " ^ s2);; - -let rec hd_args t = match t with - | V v -> v, [] - | A(t1,t2) -> let a, b = hd_args t1 in a, b @ [t2] - | _ -> -666, [] -;; - -let max_arity_of_var v = - let rec aux level = - function - | V _ -> 0 - | A _ as t -> print_string (string_of_t dummy_p t); let hd, args = hd_args t in - let acc = if hd = level + v then List.length args else 0 in - List.fold_right (max ++ (aux level)) args acc - | L t -> aux (level + 1) t - | Stuck(v,n) -> 0 - (* | Ptr n -> assert false *) - | P | B -> 0 - in aux 0 -;; - -let ignore var n p = - print_cmd "EAT" ("on " ^ string_of_t p (V var) ^ " (of:" ^ string_of_int n ^ ")"); - let rec aux m t = - if m = 0 - then lift n t - else L (aux (m-1) t) in - let p, fresh = freshvar p in - let subst = var, aux n (V fresh) in - sanity (subst_in_problem subst p) -;; - - - -let eat var p = - print_cmd "EAT" ("var " ^ string_of_t p (V var)); - let rec is_hd v' = function - | A (t,_) -> is_hd v' t - | V v -> v' = v - | _ -> false in - let rec app_length = function - | A (t,_) -> 1 + app_length t - | _ -> 0 in - let rec find_app_no = function - | V _ | L _ | P | B -> 0 - | A (t1,t2) as t -> - max (max (find_app_no t1) (find_app_no t2)) - (if is_hd var t1 then app_length t else 0) - | Stuck _ -> 0 - (* | Ptr n -> find_app_no (get_conv p n) *) - in let n = List.fold_right (max ++ find_app_no) (all_terms p) 0 in - let rec aux m t = - if m = 0 - then lift n t - else L (aux (m-1) t) in - let p, fresh = freshvar p in - let subst = var, aux n (V fresh) in - sanity (subst_in_problem subst p) -;; - -(* let explode p = - let fv1 = visible_vars p p.div in - let fv2 = List.concat (List.map (visible_vars p) p.conv) in - let fv = List.filter (fun x -> not (List.mem x fv2)) fv1 in - let fv = List.filter ((<) p.orig_freshno) fv in - match fv with - | var::_ -> - print_cmd "EXPLODE" ("on " ^ string_of_t p (V var)); - let subst = var, B in - sanity (subst_in_problem subst p) - | _ -> raise (Fail (-1,"premature explosion")) -;; *) - -(* let step var p = - print_cmd "STEP" ("on " ^ string_of_t p (V var)); - let matches = (var,[])::p.matches in - let p = {p with matches;stepped=var::p.stepped} in - let subst = var, V var in - sanity (subst_in_problem subst p) -;; *) - -let choose n p = - print_cmd "CHOOSE" ("#" ^ string_of_int n); - let rec aux n t = match t with - | V _ -> 0, t - | A(t1,_) -> let n', t' = aux n t1 in if n = n' then n', t' else n'+1, t - | _ -> assert false - in let n', div = aux n p.div in - if n' <> n then problem_fail p "wrong choose"; - let p = {p with div} in - sanity p -;; - -let apply var appk p = - print_cmd "APPLY" - (string_of_t p (V var) ^ " applies no." ^ string_of_int appk ^ " fresh variables"); - let rec mk_freshvars n p = - if n = 0 - then p, [] - else - let p, vs = mk_freshvars (n-1) p in - let p, v = freshvar p in - p, V(v)::vs in - let p, vars = mk_freshvars appk p in - let p, t = mk_apps p (V 0) (List.map (lift 1) vars) in - let t = L (A (lift 1 (V var), t)) in - let subst = var, t in - sanity (subst_in_problem subst p) -;; - -let find_arities_after_app p = - let rec aux level n = function - | L t -> assert (n > 0); max_arity_of_var level t :: aux (level+1) (n-1) t - | _ -> Array.to_list (Array.make n 0) - in aux 0 -;; -let find_all_first_args_of v = - let rec aux level = function - | L t -> aux (level+1) t - | V _ -> [] - | A(V v', t2) -> (if v + level = v' then [t2] else []) @ aux level t2 - | A(t1,t2) -> aux level t1 @ aux level t2 - | _ -> [] - in aux 0 -;; - -let step' var p = - let appk = p.k_lam + p.k_app + 1 in - print_cmd "STEP'" ("on " ^ string_of_t p (V var) ^ " and applies no." ^ string_of_int appk ^ " fresh variables"); - let p, vars = (* +1 below because of lifting *) - Array.fold_left (fun (p,vars) _ -> let p, v = freshvar p in p, (v+1)::vars) - (p, []) (Array.make appk ()) in - let p, t = mk_apps p (V 0) (List.map (fun x -> V x) vars) in - - let first_args = Util.sort_uniq (List.fold_right ((@) ++ (find_all_first_args_of var)) (all_terms p) []) in - let map = List.fold_left (fun acc t -> let acc' = find_arities_after_app p appk t in List.map (fun (x,y) -> max x y) (List.combine acc acc')) (Array.to_list (Array.make appk 0)) first_args in - let arities = List.combine (List.map ((+) (-1)) vars) map in - - (* let p, var' = freshvar p in *) - let p, var' = p, var in - let matches = (var', []) :: p.matches in - let p = {p with matches; stepped=var'::p.stepped; arities=arities@p.arities} in - let t = L (A (lift 1 (V var'), t)) in - let subst = var, t in - sanity (subst_in_problem subst p) -;; - -let perm var n p = - if n = 1 then p else ( - print_cmd "PERM" ("on " ^ string_of_t p (V var) ^ " (of:" ^ string_of_int n ^ ")"); - (* let p, v = freshvar p in *) - let p, v = p, var in - let rec aux' m t = if m < 0 then t else A(aux' (m-1) t, V m) in - let rec aux m t = - if m = 0 - then aux' (n-1) t - else L (aux (m-1) t) in - let t = aux n (lift n (V v)) in - let subst = var, t in - (* let p = {p with arities=(v, List.assoc var p.arities)::p.arities} in *) - sanity (subst_in_problem subst p) -) ;; - -let free_vars_of_p p = - Util.sort_uniq (Util.concat_map (free_vars p) (all_terms p));; - -let rec applied_vars p = function -| B | P -> [] -| L _ -> [] (* ??? *) -| V _ -> [] -| A(V v,t2) -> v :: applied_vars p t2 -| A(t1,t2) -> applied_vars p t1 @ applied_vars p t2 -(* | Ptr n -> applied_vars p (get_conv p n) *) -| Stuck _ -> [] (* ??? *) -;; - -let applied_vars_of_p p = - Util.sort_uniq (Util.concat_map (applied_vars p) (all_terms p));; - -let rec auto p = - let aux f var = - try - auto (f var); () - with - | Done _ as d -> raise d - | Fail(_, s) -> print_endline ("<<< Backtracking because: " ^ s) in - print_endline ">>> auto called"; - (* Compute useful free variables *) - let fv = applied_vars_of_p p in - let fv = List.filter (fun v -> not (List.mem v p.stepped)) fv in - List.iter (fun v -> print_string ("@`" ^ string_of_int v)) fv; - let fv0 = List.filter (fun v -> List.assoc v p.arities > 0) fv in (* remove variable with arity left 0, cannot step there *) - if fv0 = [] then (print_endline "warning! empty step fv0"; List.iter (fun v -> print_string ("@`" ^ string_of_int v)) fv); - let permute_and_step p v = - let step'' problem prm var = - let problem = perm var prm problem in - (* let _ = read_line () in *) - let problem = step' var problem in - problem in - let arity = List.assoc v p.arities in - let _, perms = Array.fold_left (fun (arity, acc) () -> let a = arity + 1 in a, a::acc) (1,[1]) (Array.make (arity-1) ()) in - List.iter (fun perm -> aux (step'' p perm) v) perms - in - List.iter (permute_and_step p) fv0; - List.iter (aux (fun v -> eat v p)) fv; - (* mancano: applicazioni e choose; ??? *) -;; - -let parse strs = - let rec aux level = function - | Parser.Lam t -> L (aux (level + 1) t) - | Parser.App (t1, t2) -> - if level = 0 then snd (mk_app dummy_p (aux level t1) (aux level t2)) - else A(aux level t1, aux level t2) - | Parser.Var v -> V v - in let (tms, free) = Parser.parse_many strs - in (List.map (aux 0) tms, free) -;; - -let magic6 div conv cmds = - print_hline (); - let all_tms, var_names = parse (div :: conv) in - let div, conv = List.hd all_tms, List.tl all_tms in - let varno = List.length var_names in - let k_app, k_lam = List.fold_left (fun (a, b) t -> let a', b' = consts t in max a a', max b b') (0,0) all_tms in - let p = {orig_freshno=varno; freshno=1+varno; div; conv; matches=[]; sigma=[]; stepped=[];k_app;k_lam;arities=[]} in - let fv = Util.sort_uniq (Util.concat_map (free_vars p) all_tms) in - let arities = List.map (fun var -> var, k_app) fv in - let p = {p with arities} in - let p = try - let subst = Util.index_of "BOMB" var_names, L B in - let p = subst_in_problem subst p in p - with Not_found -> p in - let p = sanity p in - try - problem_fail (List.fold_left (|>) p cmds) "Problem not completed" - with - | Done _ -> () -;; - -let auto div conv = - print_hline (); - let all_tms, var_names = parse (div :: conv) in - let div, conv = List.hd all_tms, List.tl all_tms in - let varno = List.length var_names in - let k_app, k_lam = List.fold_left (fun (a, b) t -> let a', b' = consts t in max a a', max b b') (0,0) all_tms in - let p = {orig_freshno=varno; freshno=1+varno; div; conv; matches=[]; sigma=[]; stepped=[];k_app;k_lam;arities=[]} in - let fv = Util.sort_uniq (Util.concat_map (free_vars p) all_tms) in - let max_arity_of_var_in_p var p = - 1 + List.fold_right (max ++ (max_arity_of_var var)) (all_terms p) 0 in - let arities = List.map (fun var -> var, max_arity_of_var_in_p var p) fv in - let p = {p with arities} in - let p = try - let subst = Util.index_of "BOMB" var_names, L B in - let p = subst_in_problem subst p in p - with Not_found -> p in - let p = sanity p in - try - auto p; - failwith "auto failed." - with - | Done _ -> print_endline "<<< auto ok >>>"; (* TODO: print and verify substitution *) -;; - -(* let interactive div conv cmds = - print_hline (); - let all_tms, var_names = parse (div @ conv) in - let div, conv = list_split (List.length div) all_tms in - let varno = List.length var_names in - let p = {orig_freshno=varno; freshno=1+varno; div; conv; matches=[]; sigma=[]} in - (* activate bombs *) - let p = try - let subst = Util.index_of "BOMB" var_names, L B in - subst_in_problem subst p - with Not_found -> p in - (* activate pacmans *) - let p = try - let subst = Util.index_of "PACMAN" var_names, P in - let p = subst_in_problem subst p in - (print_endline ("after subst in problem " ^ string_of_problem p); p) - with Not_found -> p in - (* initial sanity check *) - let p = sanity p in - let p = List.fold_left (|>) p cmds in - let rec f p cmds = - let nth spl n = int_of_string (List.nth spl n) in - let read_cmd () = - let s = read_line () in - let spl = Str.split (Str.regexp " +") s in - s, let uno = List.hd spl in - try if uno = "explode" then explode - else if uno = "ignore" then ignore (nth spl 1) (nth spl 2) - else if uno = "step" then step (nth spl 1) - else if uno = "perm" then perm (nth spl 1) (nth spl 2) - else if uno = "apply" then apply (nth spl 1) (nth spl 2) - (* else if uno = "forget" then forget (nth spl 1) (nth spl 2) *) - else if uno = "id" then id (nth spl 1) - else failwith "Wrong input." - with Failure s -> print_endline s; (fun x -> x) in - let str, cmd = read_cmd () in - let cmds = (" " ^ str ^ ";")::cmds in - try - let p = cmd p in f p cmds - with - | Done -> print_endline "Done! Commands history: "; List.iter print_endline (List.rev cmds) - in f p [] -;; *) - -let _ = auto - "x x" - [ "_. BOMB" ] - (* [ eat 1 ] *) -;; - - -let _ = auto - "x y BOMB b" - [ "x BOMB y c" ] - (* [ perm 1 3; step' 8 ; eat 4; eat 5; eat 15; ] *) -;; - - -let _ = auto - "x BOMB a1 c" - [ "x y BOMB d"; "x BOMB a2 c" ] - (* [ perm 1 3 ; step' 10 ; eat 4; eat 6; step' 17; eat 3; eat 7; eat 27; ] *) -;; - - -let _ = auto - "x (x x)" - [ "x x" ; "x x x" ] - (* [ - step' 1; - eat 6; eat 9; eat 13; -]*) -;; - - -(* let _ = auto - "x (_.BOMB)" - [ "x (_._. BOMB)" ] - (* [ apply 1 2; ] *) -;; *) - - -let _ = auto - "x (_.y)" - [ "y (_. x)" ] - (* [ apply 1 1; ignore 1 1; explode; ] *) -;; - - -let _ = auto - "y (x a1 BOMB c) (x BOMB b1 d)" - [ "y (x a2 BOMB c) (x BOMB b1 d)"; - "y (x a1 BOMB c) (x BOMB b2 d)";] - (* [perm 2 3; - step 12; - perm 17 2; - step 19; - step 18; - ignore 22 1; - ignore 21 1; - ignore 24 1; - ignore 25 1; - step 1; - step 32; - explode; - ] *) -;; - -(* -let _ = magic6 - ["z (y x)"] - [ "z (y (x.x))"; "y (_. BOMB)" ] - [ apply 2 1; step 3; explode; ] -;; - -let _ = magic6 - ["y x"] - [ "y (x.x)"; "x (_. BOMB)" ] - [ apply 1 1; ignore 2 1; step 1; explode; ] -;; - -let _ = magic6 - ["z (y x)"] - [ "z (y (x.x))"; "y (_. BOMB)" ] - [ step 1; explode; apply 2 1; id 2; ignore 3 1; ] -;; - -let _ = magic6 - ["y (x a)"] - [ "y (x b)"; "x BOMB" ] [ - id 2; - step 1; - explode; -];; - -magic6 - ["y (x a)"] [ "y (x b)"; "x BOMB"; "y a" ] - [ - apply 1 1; - perm 2 2; - ignore 9 1; - step 10; - explode; - ];; -(* "y (a c)" -[ "y (b c)"; "y (x a)"; "y (x b)"; "x BOMB" ] *) - -magic6 -["x a (x (a.y BOMB))"] -[ "x b"; "x (y c)"; "x (y d)" ] -[apply 1 1; -apply 2 1; -explode;] -(* [ -step 1; -step 3; -explode' 10; -(* ma si puo' fare anche senza forget *) *) -(* ] *) -;; - -(* dipendente dalla codifica? no, ma si risolve solo con id *) -magic6 - ["y a"] ["y b"; "x (y (_.BOMB))"] -[ -apply 1 1; -apply 2 1; -explode; -];; - (* [id 1; explode];; *) - -magic6 - ["PACMAN (x x x)"] ["PACMAN (x x)"] - [ - ignore 2 2; - explode; - ];; *) - -print_hline(); -print_endline "ALL DONE. " diff --git a/ocaml/andrea8.ml b/ocaml/andrea8.ml deleted file mode 100644 index 7fd82eb..0000000 --- a/ocaml/andrea8.ml +++ /dev/null @@ -1,736 +0,0 @@ -let (++) f g x = f (g x);; - -let print_hline = Console.print_hline;; - -type var = int;; -type t = - | V of var - | A of t * t - | L of t - | B (* bottom *) - | P (* pacman *) - (* | Stuck of var * int *) - (* | Ptr of int *) -;; - -let rec consts = (* const_apps, const_lambda *) - let rec aux1 = function - | A(t, _) -> 1 + aux1 t - | _ -> 0 in - let rec aux2 = function - | L t -> 1 + aux2 t - | _ -> 0 in - function - | A(t1, t2) as t -> - let a1, b1 = consts t1 in - let a2, b2 = consts t2 in - max (aux1 t) (max a1 a2), max b1 b2 - | L t' as t -> - let a, b = consts t' in - a, max (aux2 t) b - | _ -> 0, 0 -;; - - -type problem = { - orig_freshno: int - ; freshno : int - ; div : t - ; conv : t list - ; matches : (var (* variable originating this match *) * ((bool (* coming from div *) * t (* term to discriminate *) * var (* continuation *))) list) list - ; sigma : (var * t) list (* substitutions *) - ; stepped : var list - ; arities : (var * int) list - ; k_app : int - ; k_lam : int -} - -let dummy_p = {orig_freshno=0; freshno=0; div=B; conv=[]; matches=[]; sigma=[]; stepped=[]; arities=[]; k_app=0;k_lam=0};; - -let append_conv p t = let len = List.length p.conv in let p = {p with conv=t::p.conv} in p, len;; -let get_conv p n = List.nth p.conv (List.length p.conv - 1 - n);; -let index_of_conv t conv = List.length conv - 1 - (Util.index_of t conv);; - -let eq_conv = (=);; -let eq_conv_indices p i j = eq_conv (get_conv p i) (get_conv p j);; -let all_terms p = (p.div :: p.conv) @ Util.concat_map (fun (_, lst) -> List.map (fun (_,x,_) -> x) lst) p.matches;; - -exception Done of (var * t) list (* substitution *);; -exception Fail of int * string;; - -let string_of_t p = - let bound_vars = ["x"; "y"; "z"; "w"; "q"; "x1"; "x2"; "x3"; "x4"; "x5"] in - let rec string_of_term_w_pars level = function - | V v -> if v >= level then "`" ^ string_of_int (v-level) else List.nth bound_vars (level - v-1) - | A _ - | L _ as t -> "(" ^ string_of_term_no_pars_lam level t ^ ")" - | B -> "BOT" - | P -> "PAC" - (* | Stuck _ as t -> "(" ^ string_of_term_no_pars_app level t ^ ")" *) - (* | Ptr _ as t-> "(" ^ string_of_term_no_pars_app level t ^ ")" *) - (* "&" ^ string_of_int n *) - and string_of_term_no_pars_app level = function - | A(t1,t2) -> (string_of_term_no_pars_app level t1) ^ " " ^ (string_of_term_w_pars level t2) - (* | Stuck(v,n) -> ":" ^ string_of_term_no_pars_app level (V v) ^ " " ^ (string_of_term_w_pars level (get_conv p n)) *) - (* | Ptr n -> string_of_term_no_pars_app level (get_conv p n) *) - (* | Ptr n -> "&" ^ string_of_int n *) - | _ as t -> string_of_term_w_pars level t - and string_of_term_no_pars_lam level = function - | L t -> "λ" ^ string_of_term_w_pars (level+1) (V 0) ^ ". " ^ (string_of_term_no_pars_lam (level+1) t) - | _ as t -> string_of_term_no_pars level t - and string_of_term_no_pars level = function - | L _ as t -> string_of_term_no_pars_lam level t - | _ as t -> string_of_term_no_pars_app level t - in string_of_term_no_pars 0 -;; - -let string_of_problem p = - let lines = [ - "[arities] " ^ String.concat " " (List.map (fun (v,n) -> "`" ^ string_of_int v ^ "=" ^ string_of_int n) p.arities); - "[stepped] " ^ String.concat " " (List.map string_of_int p.stepped); - "[DV] " ^ (string_of_t p p.div); - "[CV] " ^ String.concat "\n " (List.map (string_of_t p) p.conv); - (* "" ; *) - ] @ Util.concat_map (fun (v, lst) -> ("[<>] of "^(string_of_t p (V v))) :: List.map (fun (b,t,c) -> (if b then " * " else " ") ^ string_of_t p t - ^ " -> " ^ string_of_t p (V c) - ) lst) p.matches @ [""] in - String.concat "\n" lines -;; - -let problem_fail p reason = - print_endline "!!!!!!!!!!!!!!! FAIL !!!!!!!!!!!!!!!"; - print_endline (string_of_problem p); - raise (Fail (-1, reason)) -;; - -let freshvar ({freshno} as p) = - {p with freshno=freshno+1}, freshno+1 -;; - -let add_to_match p id fromdiv t = - let p, v = freshvar p in - let arity = (List.assoc id p.arities) - 1 in - let entry = fromdiv, t, v in - let matches = - List.map (fun (id',lst as x) -> if id <> id' then x else (id, entry::lst)) p.matches - in - let arities = (v,arity) :: p.arities in - {p with matches; arities}, V v -;; - -let var_occurs_in p v = - let rec aux level = function - | V v' -> v + level = v' - (* | Stuck(v',n) -> assert (v <> v'); aux level (get_conv p n) *) - | A(t1,t2) -> (aux level t1) || (aux level t2) - | L t -> aux (level+1) t - | B -> false - | P -> false - (* | Ptr n -> aux level (get_conv p n) *) - - in aux 0 -;; - -let rec is_inert p = - function - | A(t,_) -> is_inert p t - (* | Ptr n -> is_inert p (get_conv p n) *) - | V _ -> true - | L _ | B | P -> false -;; - -let is_var = function V _ -> true | _ -> false;; -let is_lambda = function L _ -> true | _ -> false;; -let is_pacman = function P -> true | _ -> false;; - -let rec subst level delift fromdiv sub p = - function - | V v -> p, if v = level + fst sub then lift level (snd sub) else V (if delift && v > level then v-1 else v) - | L t -> let p, t = subst (level + 1) delift fromdiv sub p t in p, L t - | A (t1,t2) -> - let p, t1 = subst level delift fromdiv sub p t1 in - let p, t2 = subst level delift fromdiv sub p t2 in - if t1 = B || t2 = B then p, B else - if level = 0 then mk_app fromdiv p t1 t2 else p, A (t1, t2) - | B -> p, B - | P -> p, P -and mk_app fromdiv p t1 t2 = let t1 = if t1 = P then L P else t1 in match t1 with - | B | _ when t2 = B -> p, B - | L t1 -> subst 0 true fromdiv (0, t2) p t1 - | V v when List.mem v p.stepped -> - let p, x = add_to_match p v fromdiv t2 in - p, x - | t1 -> p, A (t1, t2) -and mk_apps fromdiv p t = - function - | [] -> p, t - | t'::ts -> let p, t = mk_app fromdiv p t t' in mk_apps fromdiv p t ts -and lift n = - let rec aux n' = - function - | V m -> V (if m >= n' then m + n else m) - | L t -> L (aux (n'+1) t) - | A (t1, t2) -> A (aux n' t1, aux n' t2) - | B -> B - | P -> P - in aux 0 -;; - -let subst = subst 0 false;; - -let mk_lambda t = L (lift 1 t) ;; - -let subst_conv sub = - let rec aux p = function - | [] -> p, [] - | t::tms -> - let p, tms = aux p tms in - let p, t = subst false sub p t in - p, t :: tms - in aux -;; - -let subst_in_problem (sub: var * t) (p: problem) = -print_endline ("SUBST IN PROBLEM: " ^ string_of_t p (V (fst sub)) ^ " |-> " ^ string_of_t p (snd sub)); -(* BUG QUI FIXME!!!! *) - let rec mix l1 l2 = match l1, l2 with - | [], l2 -> l2 - | x::xs, _::ys -> x:: (mix xs ys) - | _ -> assert false in - let p = {p with stepped=(fst sub)::p.stepped} in - let p, conv = subst_conv sub p p.conv in - let p, div = subst true sub p p.div in - let conv = List.rev (mix (List.rev conv) (List.rev p.conv)) in - let p = {p with div; conv} in - (* print_endline ("after sub: \n" ^ string_of_problem p); *) - {p with sigma=sub::p.sigma} -;; - -(* FIXME *) -let unify_terms p v1 v2 = - if List.mem v1 p.stepped - then problem_fail p "The collapse of a match came after too many steps :("; - subst_in_problem (v1, V v2) p -;; - -let rec unify p = - let rec give_duplicates = - let rec aux' t = function - | [] -> [], None - | (b',t',c')::ts -> if t = t' (* FIXME! eta-eq here *) then ts, Some (b',c') else ( - let ts, res = aux' t ts in (b',t',c')::ts, res) in - let rec aux = function - | [] -> [], None - | (b,t,c)::rest -> ( - match aux' t rest with - | rest, None -> aux rest - | rest, Some(b',c') -> (b || b', t, c) :: rest, Some(c', c) - ) in - function - | [] -> [], None - | (orig,branches) :: ms -> - match aux branches with - | _, None -> let ms, res = give_duplicates ms in (orig,branches) :: ms, res - | branches', Some subst -> (orig,branches') :: ms, Some subst in - let matches, vars_to_be_unified = give_duplicates p.matches in - let p = {p with matches=matches} in - match vars_to_be_unified with - | None -> p - | Some(t', t) -> - (* print_endline ("> unify " ^ string_of_t p (t') ^ " with " ^ string_of_t p t); *) - unify (unify_terms p t' t) -;; - -let problem_done p = - let condition (b, t, cont) = - (b && t = B) || - (not (List.mem cont p.stepped)) || - is_var t in - let all_separated = List.for_all (fun (_, lst) -> List.for_all condition lst) p.matches in - all_separated && p.div = B -;; - -let free_vars p t = - let rec aux level = function - | V v -> if v >= level then [v] else [] - | A(t1,t2) -> (aux level t1) @ (aux level t2) - | L t -> aux (level+1) t - | B | P -> [] - in Util.sort_uniq (aux 0 t) -;; - -let visible_vars p t = - let rec aux = function - | V v -> [v] - | A(t1,t2) -> (aux t1) @ (aux t2) - | B | P - | L _ -> [] - (* | Ptr n -> aux (get_conv p n) *) - in Util.sort_uniq (aux t) -;; - - -let rec simple_explode p = - match p.div with - | V var -> - let subst = var, B in - sanity (subst_in_problem subst p) - | _ -> p - -and sanity p = - (* Sanity checks: *) - if (function | P | L _ -> true | _ -> false) p.div then problem_fail p "p.div converged"; - if List.mem B p.conv then problem_fail p "p.conv diverged"; - let solvable (b,t,c) = (b && not (List.mem c p.stepped)) || is_inert p t in - if not (List.for_all (fun (_, lst) -> List.for_all solvable lst) p.matches) - then problem_fail p "Unsolvable discrimination"; - - let p = unify p in - print_endline (string_of_problem p); (* non cancellare *) - let p = if problem_done p then raise (Done p.sigma) else p in - let p = if is_var p.div then simple_explode p else p in - p -;; - -let print_cmd s1 s2 = print_endline (">> " ^ s1 ^ " " ^ s2);; - -let rec hd_args t = match t with - | V v -> v, [] - | A(t1,t2) -> let a, b = hd_args t1 in a, b @ [t2] - | _ -> -666, [] -;; - -let max_arity_of_var v = - let rec aux level = - function - | V _ -> 0 - | A _ as t -> print_string (string_of_t dummy_p t); let hd, args = hd_args t in - let acc = if hd = level + v then List.length args else 0 in - List.fold_right (max ++ (aux level)) args acc - | L t -> aux (level + 1) t - | P | B -> 0 - in aux 0 -;; - -let ignore var n p = - print_cmd "EAT" ("on " ^ string_of_t p (V var) ^ " (of:" ^ string_of_int n ^ ")"); - let rec aux m t = - if m = 0 - then lift n t - else L (aux (m-1) t) in - let p, fresh = freshvar p in - let subst = var, aux n (V fresh) in - sanity (subst_in_problem subst p) -;; - - - -let eat var p = - print_cmd "EAT" ("var " ^ string_of_t p (V var)); - let rec is_hd v' = function - | A (t,_) -> is_hd v' t - | V v -> v' = v - | _ -> false in - let rec app_length = function - | A (t,_) -> 1 + app_length t - | _ -> 0 in - let rec find_app_no = function - | V _ | L _ | P | B -> 0 - | A (t1,t2) as t -> - max (max (find_app_no t1) (find_app_no t2)) - (if is_hd var t1 then app_length t else 0) - in let n = List.fold_right (max ++ find_app_no) (all_terms p) 0 in - let rec aux m t = - if m = 0 - then lift n t - else L (aux (m-1) t) in - let p, fresh = freshvar p in - let subst = var, aux n (V fresh) in - sanity (subst_in_problem subst p) -;; - -(* let explode p = - let fv1 = visible_vars p p.div in - let fv2 = List.concat (List.map (visible_vars p) p.conv) in - let fv = List.filter (fun x -> not (List.mem x fv2)) fv1 in - let fv = List.filter ((<) p.orig_freshno) fv in - match fv with - | var::_ -> - print_cmd "EXPLODE" ("on " ^ string_of_t p (V var)); - let subst = var, B in - sanity (subst_in_problem subst p) - | _ -> raise (Fail (-1,"premature explosion")) -;; *) - -(* let step var p = - print_cmd "STEP" ("on " ^ string_of_t p (V var)); - let matches = (var,[])::p.matches in - let p = {p with matches;stepped=var::p.stepped} in - let subst = var, V var in - sanity (subst_in_problem subst p) -;; *) - -let choose n p = - print_cmd "CHOOSE" ("#" ^ string_of_int n); - let rec aux n t = match t with - | V _ -> 0, t - | A(t1,_) -> let n', t' = aux n t1 in if n = n' then n', t' else n'+1, t - | _ -> assert false - in let n', div = aux n p.div in - if n' <> n then problem_fail p "wrong choose"; - let p = {p with div} in - sanity p -;; - -let apply var appk p = - print_cmd "APPLY" - (string_of_t p (V var) ^ " applies no." ^ string_of_int appk ^ " fresh variables"); - let rec mk_freshvars n p = - if n = 0 - then p, [] - else - let p, vs = mk_freshvars (n-1) p in - let p, v = freshvar p in - p, V(v)::vs in - let p, vars = mk_freshvars appk p in - let p, t = mk_apps false p (V 0) (List.map (lift 1) vars) in - let t = L (A (lift 1 (V var), t)) in - let subst = var, t in - sanity (subst_in_problem subst p) -;; - -let find_arities_after_app p = - let rec aux level n = function - | L t -> assert (n > 0); max_arity_of_var level t :: aux (level+1) (n-1) t - | _ -> Array.to_list (Array.make n 0) - in aux 0 -;; -let find_all_first_args_of v = - let rec aux level = function - | L t -> aux (level+1) t - | V _ -> [] - | A(V v', t2) -> (if v + level = v' then [t2] else []) @ aux level t2 - | A(t1,t2) -> aux level t1 @ aux level t2 - | _ -> [] - in aux 0 -;; - -let step' var p = - let appk = p.k_lam + p.k_app + 1 in - print_cmd "STEP'" ("on " ^ string_of_t p (V var) ^ " and applies no." ^ string_of_int appk ^ " fresh variables"); - let p, vars = (* +1 below because of lifting *) - Array.fold_left (fun (p,vars) _ -> let p, v = freshvar p in p, (v+1)::vars) - (p, []) (Array.make appk ()) in - let p, t = mk_apps false p (V 0) (List.map (fun x -> V x) vars) in - - let first_args = Util.sort_uniq (List.fold_right ((@) ++ (find_all_first_args_of var)) (all_terms p) []) in - let map = List.fold_left (fun acc t -> let acc' = find_arities_after_app p appk t in List.map (fun (x,y) -> max x y) (List.combine acc acc')) (Array.to_list (Array.make appk 0)) first_args in - let arities = List.combine (List.map ((+) (-1)) vars) map in - - (* let p, var' = freshvar p in *) - let p, var' = p, var in - let matches = (var', []) :: p.matches in - let p = {p with matches; arities=arities@p.arities} in - let t = L (A (lift 1 (V var'), t)) in - let subst = var, t in - sanity (subst_in_problem subst p) -;; - -let perm var n p = - if n = 1 then p else ( - print_cmd "PERM" ("on " ^ string_of_t p (V var) ^ " (of:" ^ string_of_int n ^ ")"); - (* let p, v = freshvar p in *) - let p, v = p, var in - let rec aux' m t = if m < 0 then t else A(aux' (m-1) t, V m) in - let rec aux m t = - if m = 0 - then aux' (n-1) t - else L (aux (m-1) t) in - let t = aux n (lift n (V v)) in - let subst = var, t in - (* let p = {p with arities=(v, List.assoc var p.arities)::p.arities} in *) - sanity (subst_in_problem subst p) -) ;; - -let free_vars_of_p p = - Util.sort_uniq (Util.concat_map (free_vars p) (all_terms p));; - -let rec applied_vars p = function -| B | P -> [] -| L _ -> [] (* ??? *) -| V _ -> [] -| A(V v,t2) -> v :: applied_vars p t2 -| A(t1,t2) -> applied_vars p t1 @ applied_vars p t2 -;; - -let applied_vars_of_p p = - Util.sort_uniq (Util.concat_map (applied_vars p) (all_terms p));; - -let rec auto p = - let aux f var = - try - auto (f var); () - with - (* | Done _ as d -> raise d *) - | Fail(_, s) -> print_endline ("<<< Backtracking because: " ^ s) in - print_endline ">>> auto called"; - (* Compute useful free variables *) - let fv = applied_vars_of_p p in - let fv = List.filter (fun v -> not (List.mem v p.stepped)) fv in - List.iter (fun v -> print_string ("@`" ^ string_of_int v)) fv; - let fv0 = List.filter (fun v -> List.assoc v p.arities > 0) fv in (* remove variable with arity left 0, cannot step there *) - if fv0 = [] then (print_endline "warning! empty step fv0"; List.iter (fun v -> print_string ("@`" ^ string_of_int v)) fv); - let permute_and_step p v = - let step'' problem prm var = - let problem = perm var prm problem in - (* let _ = read_line () in *) - let problem = step' var problem in - problem in - let arity = List.assoc v p.arities in - let _, perms = Array.fold_left (fun (arity, acc) () -> let a = arity + 1 in a, a::acc) (1,[1]) (Array.make (arity-1) ()) in - List.iter (fun perm -> aux (step'' p perm) v) perms - in - List.iter (permute_and_step p) fv0; - List.iter (aux (fun v -> eat v p)) fv; - (* mancano: applicazioni e choose; ??? *) -;; - -let parse strs = - let rec aux level = function - | Parser.Lam t -> L (aux (level + 1) t) - | Parser.App (t1, t2) -> - if level = 0 then snd (mk_app false dummy_p (aux level t1) (aux level t2)) - else A(aux level t1, aux level t2) - | Parser.Var v -> V v - in let (tms, free) = Parser.parse_many strs - in (List.map (aux 0) tms, free) -;; - -let magic6 div conv cmds = - print_hline (); - let all_tms, var_names = parse (div :: conv) in - let div, conv = List.hd all_tms, List.tl all_tms in - let varno = List.length var_names in - let k_app, k_lam = List.fold_left (fun (a, b) t -> let a', b' = consts t in max a a', max b b') (0,0) all_tms in - let p = {orig_freshno=varno; freshno=1+varno; div; conv; matches=[]; sigma=[]; stepped=[];k_app;k_lam;arities=[]} in - let fv = Util.sort_uniq (Util.concat_map (free_vars p) all_tms) in - let arities = List.map (fun var -> var, k_app) fv in - let p = {p with arities} in - let p = try - let subst = Util.index_of "BOMB" var_names, L B in - let p = subst_in_problem subst p in p - with Not_found -> p in - let p = sanity p in - try - problem_fail (List.fold_left (|>) p cmds) "Problem not completed" - with - | Done _ -> () -;; - -let auto div conv = - print_hline (); - let all_tms, var_names = parse (div :: conv) in - let div, conv = List.hd all_tms, List.tl all_tms in - let varno = List.length var_names in - let k_app, k_lam = List.fold_left (fun (a, b) t -> let a', b' = consts t in max a a', max b b') (0,0) all_tms in - let p = {orig_freshno=varno; freshno=1+varno; div; conv; matches=[]; sigma=[]; stepped=[];k_app;k_lam;arities=[]} in - let fv = Util.sort_uniq (Util.concat_map (free_vars p) all_tms) in - let max_arity_of_var_in_p var p = - 1 + List.fold_right (max ++ (max_arity_of_var var)) (all_terms p) 0 in - let arities = List.map (fun var -> var, max_arity_of_var_in_p var p) fv in - let p = {p with arities} in - let p = try - let subst = Util.index_of "BOMB" var_names, L B in - let p = subst_in_problem subst p in p - with Not_found -> p in - let p = sanity p in - try - auto p; - failwith "auto failed." - with - | Done _ -> print_endline "<<< auto ok >>>"; (* TODO: print and verify substitution *) -;; - -(* let interactive div conv cmds = - print_hline (); - let all_tms, var_names = parse (div @ conv) in - let div, conv = list_split (List.length div) all_tms in - let varno = List.length var_names in - let p = {orig_freshno=varno; freshno=1+varno; div; conv; matches=[]; sigma=[]} in - (* activate bombs *) - let p = try - let subst = Util.index_of "BOMB" var_names, L B in - subst_in_problem subst p - with Not_found -> p in - (* activate pacmans *) - let p = try - let subst = Util.index_of "PACMAN" var_names, P in - let p = subst_in_problem subst p in - (print_endline ("after subst in problem " ^ string_of_problem p); p) - with Not_found -> p in - (* initial sanity check *) - let p = sanity p in - let p = List.fold_left (|>) p cmds in - let rec f p cmds = - let nth spl n = int_of_string (List.nth spl n) in - let read_cmd () = - let s = read_line () in - let spl = Str.split (Str.regexp " +") s in - s, let uno = List.hd spl in - try if uno = "explode" then explode - else if uno = "ignore" then ignore (nth spl 1) (nth spl 2) - else if uno = "step" then step (nth spl 1) - else if uno = "perm" then perm (nth spl 1) (nth spl 2) - else if uno = "apply" then apply (nth spl 1) (nth spl 2) - (* else if uno = "forget" then forget (nth spl 1) (nth spl 2) *) - else if uno = "id" then id (nth spl 1) - else failwith "Wrong input." - with Failure s -> print_endline s; (fun x -> x) in - let str, cmd = read_cmd () in - let cmds = (" " ^ str ^ ";")::cmds in - try - let p = cmd p in f p cmds - with - | Done -> print_endline "Done! Commands history: "; List.iter print_endline (List.rev cmds) - in f p [] -;; *) - -let _ = auto - "x x" - [ "_. BOMB" ] - (* [ eat 1 ] *) -;; - - -let _ = auto - "x y BOMB b" - [ "x BOMB y c" ] - (* [ perm 1 3; step' 8 ; eat 4; eat 5; eat 15; ] *) -;; - - -let _ = auto - "x BOMB a1 c" - [ "x y BOMB d"; "x BOMB a2 c" ] - (* [ perm 1 3 ; step' 10 ; eat 4; eat 6; step' 17; eat 3; eat 7; eat 27; ] *) -;; - - -let _ = auto - "x (x x)" - [ "x x" ; "x x x" ] - (* [ - step' 1; - eat 6; eat 9; eat 13; -]*) -;; - - -(* let _ = auto - "x (_.BOMB)" - [ "x (_._. BOMB)" ] - (* [ apply 1 2; ] *) -;; *) - - -let _ = auto - "x (_.y)" - [ "y (_. x)" ] - (* [ apply 1 1; ignore 1 1; explode; ] *) -;; - - -let _ = auto - "y (x a1 BOMB c) (x BOMB b1 d)" - [ "y (x a2 BOMB c) (x BOMB b1 d)"; - "y (x a1 BOMB c) (x BOMB b2 d)";] - (* [perm 2 3; - step 12; - perm 17 2; - step 19; - step 18; - ignore 22 1; - ignore 21 1; - ignore 24 1; - ignore 25 1; - step 1; - step 32; - explode; - ] *) -;; - -let _ = auto -"PACMAN (x x x)" ["PACMAN (x x)"];; - -(* -let _ = magic6 - ["z (y x)"] - [ "z (y (x.x))"; "y (_. BOMB)" ] - [ apply 2 1; step 3; explode; ] -;; - -let _ = magic6 - ["y x"] - [ "y (x.x)"; "x (_. BOMB)" ] - [ apply 1 1; ignore 2 1; step 1; explode; ] -;; - -let _ = magic6 - ["z (y x)"] - [ "z (y (x.x))"; "y (_. BOMB)" ] - [ step 1; explode; apply 2 1; id 2; ignore 3 1; ] -;; - -let _ = magic6 - ["y (x a)"] - [ "y (x b)"; "x BOMB" ] [ - id 2; - step 1; - explode; -];; - -magic6 - ["y (x a)"] [ "y (x b)"; "x BOMB"; "y a" ] - [ - apply 1 1; - perm 2 2; - ignore 9 1; - step 10; - explode; - ];; -(* "y (a c)" -[ "y (b c)"; "y (x a)"; "y (x b)"; "x BOMB" ] *) - -magic6 -["x a (x (a.y BOMB))"] -[ "x b"; "x (y c)"; "x (y d)" ] -[apply 1 1; -apply 2 1; -explode;] -(* [ -step 1; -step 3; -explode' 10; -(* ma si puo' fare anche senza forget *) *) -(* ] *) -;; - -(* dipendente dalla codifica? no, ma si risolve solo con id *) -magic6 - ["y a"] ["y b"; "x (y (_.BOMB))"] -[ -apply 1 1; -apply 2 1; -explode; -];; - (* [id 1; explode];; *) - -magic6 - ["PACMAN (x x x)"] ["PACMAN (x x)"] - [ - ignore 2 2; - explode; - ];; *) - -print_hline(); -print_endline "ALL DONE. " diff --git a/ocaml/console.ml b/ocaml/console.ml deleted file mode 100644 index 696a74d..0000000 --- a/ocaml/console.ml +++ /dev/null @@ -1,141 +0,0 @@ -type fancyobj = < - to_string : unit -> string; - to_html : unit -> string ->;; - -let sepx = "\xe2\xbf\x96";; -let endx = "\xe2\xbf\x97";; - -let socket_name = "/tmp/fancy.log";; - -let html_enabled = Sys.file_exists socket_name;; - -let socket = let open Unix in - if html_enabled - then socket PF_UNIX SOCK_STREAM 0 - else socket PF_INET SOCK_STREAM 0;; - -let html_enabled = if html_enabled then - try - let _ = Unix.connect socket (Unix.ADDR_UNIX socket_name) in true - with Unix.Unix_error _ -> false - else false -;; - -let cols = - let process_output_to_list2 = fun command -> - let chan = Unix.open_process_in command in - let res = ref ([] : string list) in - let rec process_otl_aux () = - let e = input_line chan in - res := e::!res; - process_otl_aux() in - try process_otl_aux () - with End_of_file -> - let stat = Unix.close_process_in chan in (List.rev !res,stat) - in let cmd_to_list command = - let (l,_) = process_output_to_list2 command in l - in try let lines = cmd_to_list "tput cols" in int_of_string (List.hd (lines)) - with _ -> 100 (* default value *) -;; - -let writeall s = - let _ = Unix.send socket s 0 (String.length s) [] in () -;; - -let concat ls = (String.concat sepx ls) ^ endx;; - -(* HELO message *) -if html_enabled then - writeall(concat["helo"; String.concat " " (Array.to_list Sys.argv)]) -;; - - -(* let logs objs = - if html_enabled then ( - let strs = (List.map (fun x -> x#to_html()) objs) in - writeall (concat ("log" :: strs)) - ); prerr_endline (String.concat " " (List.map (fun x -> x#to_string()) objs)) -;; *) - -let html_escape s = - let m = [("&", "&"); (">", ">"); ("<", "<"); (""", "\""); ("'", "'")] - in let m = List.map (fun (x,y) -> Str.regexp x, y) m - in List.fold_right (fun (x,y) z -> Str.global_replace x y z) m s;; (* FIXME TODO *) - -let fancy_of_string s : fancyobj = object - method to_string () = s - method to_html () = html_escape s -end;; - -let empty = fancy_of_string "";; - -let line = ref empty;; - -let (/) a b = object - method to_string () = a - method to_html () = b -end;; - -let (^^) a b = object - method to_string () = (a#to_string () ^ "" ^ b#to_string ()) - method to_html () = a#to_html () ^ " " ^ b#to_html () -end;; - -(* Output functions on standard output *) - -let print_string s = - line := !line ^^ fancy_of_string s -;; - -let print_char c = - print_string (String.make 1 c) -;; - -(* let print_bytes : bytes -> unit *) - -let print_int n = - print_string (string_of_int n) -;; - -(* val print_float : float -> unit *) - -let print_newline () = - if !line <> empty then ( - Pervasives.print_endline (!line#to_string()); - if html_enabled then (writeall (concat ["log"; !line#to_html()])); - line := empty - ) -;; - -let print f = - line := !line ^^ f -;; - -let print_string_endline f = - print (fancy_of_string f); print_newline () -;; - -let print_endline f = - print f; print_newline () -;; - -let print_hline () = - print_newline (); - print_endline ( String.make cols '-' / "
") -;; - -let print_heading s = - print_newline (); - print_endline (("# " ^ s) / ("

" ^ html_escape s ^ "

")) -;; - -let print_bullet f = - print_newline (); - print_endline (("- " / "")) -;; - -let print_math s = - print_endline ( s / "" ); - if html_enabled then (writeall (concat ["math"; s])) -;; diff --git a/ocaml/console.mli b/ocaml/console.mli deleted file mode 100644 index e3b769b..0000000 --- a/ocaml/console.mli +++ /dev/null @@ -1,24 +0,0 @@ -type fancyobj - -val fancy_of_string: string -> fancyobj - -val (^^) : fancyobj -> fancyobj -> fancyobj -val (/) : string -> string -> fancyobj - - -val print_char : char -> unit -val print_string : string -> unit -val print_string_endline : string -> unit -(* val print_bytes : bytes -> unit *) -val print_int : int -> unit -(* val print_float : float -> unit *) - -val print : fancyobj -> unit -val print_endline : fancyobj -> unit - -val print_newline : unit -> unit - -val print_hline : unit -> unit -val print_heading : string -> unit -val print_bullet : fancyobj -> unit -val print_math : string -> unit diff --git a/ocaml/lambda4.ml b/ocaml/lambda4.ml deleted file mode 100644 index 5ff7866..0000000 --- a/ocaml/lambda4.ml +++ /dev/null @@ -1,774 +0,0 @@ -open Util -open Util.Vars -open Pure -open Num - -(* exceptions *) -exception Pacman -exception Bottom -exception Lambda -exception Backtrack of string - -(* verbosity *) -let _very_verbose = false;; -(** Display measure of every term when printing problem *) -let _measure_of_terms = false;; - -let verbose s = - if _very_verbose then prerr_endline s -;; - -let convergent_dummy = `N(-1);; - -type discriminating_set = (int * nf) list;; - -type problem = - { freshno: int - ; div: i_var option (* None = bomb *) - ; conv: i_n_var list (* the inerts that must converge *) - ; ps: i_n_var list (* the n-th inert must become n *) - ; sigma: (int * nf) list (* the computed substitution *) - ; deltas: discriminating_set ref list (* collection of all branches *) - ; initialSpecialK: int - ; label : string - ; var_names : string list (* names of the original free variables *) - - ; trail: discriminating_set list list -};; - -let label_of_problem {label} = label;; - -let string_of_var l x = - try - List.nth l x - with Failure "nth" -> "`" ^ string_of_int x -;; -let string_of_term p t = print ~l:p.var_names (t :> nf);; - -let first bound p var f = - let p = {p with trail = (List.map (!) p.deltas)::p.trail} in - let rec aux i = - if i > bound then - raise (Backtrack ("no more alternatives for " ^ string_of_var p.var_names var)) - else - try - f p i - with Backtrack s -> -prerr_endline (">>>>>> BACKTRACK (reason: " ^ s ^") measure=$ "); - List.iter (fun (r,l) -> r := l) (List.combine p.deltas (List.hd p.trail)) ; -prerr_endline("Now trying var="^string_of_var p.var_names var^" i="^string_of_int (i+1)); - aux (i+1) - in - aux 1 - - -let all_terms p = - (match p.div with None -> [] | Some t -> [(t :> i_n_var)]) - @ p.conv - @ p.ps -;; - -let measure_of_term, measure_of_terms = - let rec aux = function - | `N _ | `Bottom | `Pacman -> 0 - | `Var(_,ar) -> if ar = min_int then 0 else max 0 ar (*assert (ar >= 0); ar*) - | `Lam(_,t) -> aux t - | `I(v,args) -> aux (`Var v) + aux_many (Listx.to_list args :> nf list) - | `Match(u,(_,ar),_,_,args) -> aux (u :> nf) + (if ar <= 0 then 0 else ar - 1) + aux_many (args :> nf list) - and aux_many tms = List.fold_right ((+) ++ aux) tms 0 in - (fun t -> aux (t :> nf)), (fun l -> aux_many (l :> nf list)) -;; - -let sum_arities p = measure_of_terms (all_terms p) - -let problem_measure p = sum_arities p;; -let string_of_measure = string_of_int;; - -let string_of_problem label ({freshno; div; conv; ps; deltas} as p) = - let aux_measure_terms t = if _measure_of_terms then "(" ^ string_of_int (measure_of_term t) ^ ") " else "" in - let deltas = String.concat ("\n# ") (List.map (fun r -> String.concat " <> " (List.map (fun (i,_) -> string_of_int i) !r)) deltas) in - let l = p.var_names in - String.concat "\n" ([ - ""; - "# DISPLAY PROBLEM (" ^ label ^ ") " ^ "measure=" ^ string_of_measure (problem_measure p); - if List.length p.deltas > 1 then ( - "# Discriminating sets (deltas):\n" ^ - "# " ^ deltas - ) else "# "; - "#"; - "$" ^ p.label; - (match div with None -> "# D" | Some div -> "D " ^ aux_measure_terms div ^ print ~l (div :> nf)); - ] - @ List.map (fun t -> if t = convergent_dummy then "# C" else "C " ^ aux_measure_terms t ^ print ~l (t :> nf)) conv - @ List.mapi (fun i t -> string_of_int i ^ " " ^ aux_measure_terms t ^ print ~l (t :> nf)) ps - @ [""]) -;; - - -let failwithProblem p reason = - print_endline (string_of_problem "FAIL" p); - failwith reason -;; - -let make_fresh_var p arity = - let freshno = p.freshno + 1 in - {p with freshno}, `Var(freshno,arity) -;; - -let make_fresh_vars p arities = - List.fold_right - (fun arity (p, vars) -> let p, var = make_fresh_var p arity in p, var::vars) - arities - (p, []) -;; - -let simple_expand_match ps = - let rec aux_nob level = function - | #i_num_var as t -> (aux_i_num_var level t :> nf) - | `Lam(b,t) -> `Lam(b,aux (level+1) t) - | `Pacman as t -> t - and aux level = function - | `Bottom as t -> t - | #nf_nob as t -> aux_nob level t - and aux_i_num_var level = function - | `Match(u,v,bs_lift,bs,args) as torig -> - let (u : i_num_var) = aux_i_num_var level u in - bs := List.map (fun (n, x) -> n, aux 0 x) !bs; - (try - (match u with - | #i_n_var as u -> - let i = index_of ~eq:eta_eq (lift (-level) u) (ps :> nf list) in (* can raise Not_found *) - let t = cast_to_i_num_var (mk_match (`N i) v bs_lift bs (args :> nf list)) in - if t <> torig then - aux_i_num_var level t - else raise Not_found - | _ -> raise Not_found) - with Not_found -> - cast_to_i_num_var (mk_appl (`Match(u,v,bs_lift,bs,[])) (List.map (aux_nob level) args))) - | `I(v,args) -> cast_to_i_num_var (mk_appl (`Var v) (List.map (aux_nob level) (Listx.to_list args))) - | `N _ | `Var _ as t -> t - in aux_i_num_var 0 -;; - -let fixpoint f = - let rec aux x = let x' = f x in if x <> x' then aux x' else x in aux -;; - -let rec super_simplify_ps ps = - fixpoint (List.map (fun x -> cast_to_i_n_var (simple_expand_match ps (x :> i_num_var)))) -;; - -let rec super_simplify_ps_with_match ps = - fixpoint (List.map (cast_to_i_num_var ++ (simple_expand_match ps))) -;; - -let super_simplify ({div; ps; conv} as p) = - let ps = super_simplify_ps p.ps p.ps in - let conv = super_simplify_ps ps p.conv in - let div = option_map (fun div -> - let divs = super_simplify_ps p.ps ([div] :> i_n_var list) in - List.hd divs) div in - {p with div=option_map cast_to_i_var div; ps; conv} - -let cast_to_ps_with_match = - function - #i_num_var as y -> (y : i_num_var) - | `Bottom | `Pacman -> raise (Backtrack "BOT/PAC in ps") - | t -> - prerr_endline (print (t :> nf)); - assert false (* algorithm failed *) - -let subst_in_problem x inst ({freshno; div; conv; ps; sigma} as p) = - let len_ps = List.length ps in -(*(let l = Array.to_list (Array.init (freshno + 1) string_of_var) in -prerr_endline ("# INST0: " ^ string_of_var x ^ " := " ^ print ~l inst));*) - let rec aux_ps ((freshno,acc_ps,acc_new_ps) as acc) = - function - | [] -> acc - | t::todo_ps -> -(*prerr_endline ("EXPAND t:" ^ print (t :> nf));*) - let t = subst false false x inst (t :> nf) in -(*prerr_endline ("SUBSTITUTED t:" ^ print (t :> nf));*) - let freshno,new_t,acc_new_ps = - try - expand_match (freshno,acc_ps@`Var(max_int/3,-666)::todo_ps,acc_new_ps) t - with Pacman | Bottom -> raise (Backtrack "Pacman/Bottom in ps") - in - aux_ps (freshno,acc_ps@[new_t],acc_new_ps) todo_ps - - (* cut&paste from aux above *) - and aux_conv ps ((freshno,acc_conv,acc_new_ps) as acc) = - function - | [] -> acc - | t::todo_conv -> - (*prerr_endline ("EXPAND t:" ^ print (t :> nf));*) - let t = subst false false x inst (t :> nf) in -(*prerr_endline ("SUBSTITUTED t:" ^ print (t :> nf));*) - let freshno,new_t,acc_new_ps = - try - expand_match (freshno,ps,acc_new_ps) t - with Pacman | Lambda -> freshno,convergent_dummy,acc_new_ps - | Bottom -> raise (Backtrack "Bottom in conv") in - aux_conv ps (freshno,acc_conv@[new_t],acc_new_ps) todo_conv - - (* cut&paste from aux' above *) - and aux_div ps (freshno,acc_new_ps) = - function - | None -> freshno, None, acc_new_ps - | Some t -> - let t = subst false false x inst (t :> nf) in - try - let freshno,new_t,acc_new_ps = expand_match (freshno,ps,acc_new_ps) t in - (* backtrack if it is a number or a variable *) - match new_t with - | `N _ -> raise (Backtrack "div=`N") - | `Var _ - | `I _ as new_t -> freshno, Some(new_t), acc_new_ps - with - | Bottom -> freshno, None, acc_new_ps - | Pacman -> raise (Backtrack "div=PAC") - - and expand_match ((freshno,acc_ps,acc_new_ps) as acc) t = - match t with - | `Match(u',orig,bs_lift,bs,args) -> - let freshno,u,acc_new_ps = expand_match acc (u' :> nf) in - let acc_new_ps,i = - match u with - | `N i -> acc_new_ps,i - | _ -> - let ps = List.map (fun t -> cast_to_ps_with_match (subst false false x inst (t:> nf))) (acc_ps@acc_new_ps) in - let super_simplified_ps = super_simplify_ps_with_match ps ps in -(*prerr_endline ("CERCO u:" ^ print (fst u :> nf)); -List.iter (fun x -> prerr_endline ("IN: " ^ print (fst x :> nf))) ps; -List.iter (fun x -> prerr_endline ("IN2: " ^ print (fst x :> nf))) super_simplified_ps;*) - match index_of_opt ~eq:eta_eq super_simplified_ps (u :> i_num_var) with - Some i -> acc_new_ps, i - | None -> acc_new_ps@[u], len_ps + List.length acc_new_ps - in - let freshno= - if List.exists (fun (j,_) -> i=j) !bs then - freshno - else - let freshno,v = freshno+1, `Var (freshno+1, -666) in (* make_fresh_var freshno in *) - bs := !bs @ [i, v] ; - freshno in -(*prerr_endlie ("t DA RIDURRE:" ^ print (`Match(`N i,arity,bs_lift,bs,args) :> nf) ^ " more_args=" ^ string_of_int more_args);*) - let t = mk_match (`N i) orig bs_lift bs (args :> nf list) in -(*prerr_endline ("NUOVO t:" ^ print (fst t :> nf) ^ " more_args=" ^ string_of_int (snd t));*) - expand_match (freshno,acc_ps,acc_new_ps) t - | `Lam _ -> raise Lambda (* assert false (* algorithm invariant/loose typing *) *) - | `Bottom -> raise Bottom - | `Pacman -> raise Pacman - | #i_n_var as x -> - let x = simple_expand_match (acc_ps@acc_new_ps) x in - freshno,cast_to_i_n_var x,acc_new_ps in - - let freshno,old_ps,new_ps = aux_ps (freshno,[],[]) ps in - let freshno,conv,new_ps = aux_conv old_ps (freshno,[],new_ps) conv in - let freshno,div,new_ps = aux_div old_ps (freshno,new_ps) (div :> i_num_var option) in - - let ps = List.map cast_to_i_n_var (old_ps @ new_ps) in - let conv = List.map cast_to_i_n_var conv in - let p = {p with freshno; div; conv; ps} in - prerr_endline ("# INST: " ^ string_of_var p.var_names x ^ " := " ^ string_of_term p inst); - ( (* check if double substituting a variable *) - if List.exists (fun (x',_) -> x = x') sigma - then failwithProblem p ("Variable "^ string_of_var p.var_names x ^"replaced twice") - ); - let p = {p with sigma = sigma@[x,inst]} in - let p = super_simplify p in - prerr_endline (string_of_problem "instantiate" p); - p -;; - -exception TriggerMatchReduction of int;; -exception Dangerous;; - -let arity_of arities hd = - let pos,_,nargs = List.find (fun (_,hd',_) -> hd=hd') arities in - nargs + if pos = -1 then - 1 else 0 -;; - -let rec dangerous arities showstoppers = - function - `N _ - | `Var _ - | `Lam _ - | `Pacman -> () - | `Match(t,_,liftno,bs,args) -> - (* CSC: XXX partial dependency on the encoding *) - (match t with - `N _ -> List.iter (dangerous arities showstoppers) args - | `Match _ as t -> dangerous arities showstoppers t ; List.iter (dangerous arities showstoppers) args - | `Var(x,_) -> dangerous_inert arities showstoppers x args 2 - | `I((x,_),args') -> dangerous_inert arities showstoppers x (Listx.to_list args' @ args) 2 - ) - | `I((k,_),args) -> dangerous_inert arities showstoppers k (Listx.to_list args) 0 - -and dangerous_inert arities showstoppers k args more_args = - List.iter (dangerous arities showstoppers) args ; - if List.mem k showstoppers then raise Dangerous else - try - let arity = arity_of arities k in - if List.length args + more_args > arity then raise Dangerous else () - with - Not_found -> () - -(* cut & paste from above *) -let rec dangerous_conv p arities showstoppers = - function - | `N _ - | `Var _ - | `Lam _ - | `Pacman -> () - | `Match(t,_,liftno,bs,args) -> ( - (* CSC: XXX partial dependency on the encoding *) - try (match t with - | `N _ -> List.iter (dangerous_conv p arities showstoppers) args - | `Match _ as t -> dangerous_conv p arities showstoppers t; List.iter (dangerous_conv p arities showstoppers) args - | `Var(x,_) -> dangerous_inert_conv p arities showstoppers x [] args 2 - | `I((x,_),args') -> dangerous_inert_conv p arities showstoppers x (Listx.to_list args') args 2 - ) with TriggerMatchReduction x -> ( - match Util.find_opt (fun (n, t) -> if hd_of (List.nth p.ps n) = Some x then Some t else None) !bs with - | None -> () - | Some t -> ( - match t with - | `Bottom -> raise Dangerous - | #nf_nob as t -> dangerous_conv p arities showstoppers t - ) - ) - ) - | `I((k,_),args) -> dangerous_inert_conv p arities showstoppers k (Listx.to_list args) [] 0 - -and dangerous_inert_conv p arities showstoppers k args match_args more_args = - let all_args = args @ match_args in - List.iter (dangerous_conv p arities showstoppers) all_args; - let all_args = (all_args :> nf list) in - if List.mem k showstoppers then raise Dangerous else - try - let arity = arity_of arities k in -prerr_endline ("dangerous_inert_conv: ar=" ^ string_of_int arity ^ " k="^string_of_var p.var_names k ^ " listlenargs=" ^ (string_of_int (List.length args)) ^ " more_args=" ^ string_of_int more_args); - if more_args > 0 (* match argument*) && List.length args = arity then raise (TriggerMatchReduction k) - else if List.length all_args + more_args > arity then raise Dangerous else () - with - Not_found -> () - -(* inefficient algorithm *) -let rec edible p arities showstoppers = - let rec aux f showstoppers tms = function - | [] -> showstoppers - | x::xs when List.exists (fun y -> hd_of x = Some y) showstoppers -> - (* se la testa di x e' uno show-stopper *) - let new_showstoppers = sort_uniq (showstoppers @ free_vars (x :> nf)) in - (* aggiungi tutte le variabili libere di x *) - if List.length showstoppers <> List.length new_showstoppers then - aux f new_showstoppers tms tms - else - aux f showstoppers tms xs - | x::xs -> - match hd_of x with - None -> aux f showstoppers tms xs - | Some h -> - try - f showstoppers (x :> nf_nob) ; - aux f showstoppers tms xs - with - Dangerous -> - aux f (sort_uniq (h::showstoppers)) tms tms - in - let showstoppers = sort_uniq (aux (dangerous arities) showstoppers p.ps p.ps) in - let dangerous_conv = sort_uniq (aux (dangerous_conv p arities) showstoppers p.conv p.conv) in - -(* prerr_endline ("dangerous_conv lenght:" ^ string_of_int (List.length dangerous_conv)); -List.iter (fun l -> prerr_endline (String.concat " " (List.map (string_of_var p.var_names) l))) dangerous_conv; *) - - let showstoppers' = showstoppers @ dangerous_conv in - let showstoppers' = sort_uniq (match p.div with - | None -> showstoppers' - | Some div -> - if List.exists ((=) (hd_of_i_var div)) showstoppers' - then showstoppers' @ free_vars (div :> nf) else showstoppers') in - if showstoppers <> showstoppers' then edible p arities showstoppers' else showstoppers', dangerous_conv -;; - -let precompute_edible_data {ps; div} xs = - let aux t = match t with `Var _ -> 0 | `I(_, args) -> Listx.length args | `N _ -> assert false in - (fun l -> match div with - | None -> l - | Some div -> (-1, hd_of_i_var div, aux div) :: l) - (List.map (fun hd -> - let i, tm = Util.findi (fun y -> hd_of y = Some hd) ps in - i, hd, aux tm - ) xs) -;; - -(** Returns (p, showstoppers_step, showstoppers_eat) where: - - showstoppers_step are the heads occurring twice - in the same discriminating set - - showstoppers_eat are the heads in ps having different number - of arguments *) -let critical_showstoppers p = - let p = super_simplify p in - let hd_of_div = match p.div with None -> [] | Some t -> [hd_of_i_var t] in - let showstoppers_step = - concat_map (fun bs -> - let heads = List.map (fun (i,_) -> List.nth p.ps i) !bs in - let heads = List.sort compare (hd_of_div @ filter_map hd_of heads) in - snd (split_duplicates heads) - ) p.deltas @ - if List.exists (fun t -> [hd_of t] = List.map (fun x -> Some x) hd_of_div) p.conv - then hd_of_div else [] in - let showstoppers_step = sort_uniq showstoppers_step in - let showstoppers_eat = - let heads_and_arities = - List.sort (fun (k,_) (h,_) -> compare k h) - (filter_map (function `Var(k,_) -> Some (k,0) | `I((k,_),args) -> Some (k,Listx.length args) | _ -> None ) p.ps) in - let rec multiple_arities = - function - [] - | [_] -> [] - | (x,i)::(y,j)::tl when x = y && i <> j -> - x::multiple_arities tl - | _::tl -> multiple_arities tl in - multiple_arities heads_and_arities in - - let showstoppers_eat = sort_uniq showstoppers_eat in - let showstoppers_eat = List.filter - (fun x -> not (List.mem x showstoppers_step)) - showstoppers_eat in - List.iter (fun v -> prerr_endline ("DANGEROUS STEP: " ^ (string_of_var p.var_names) v)) showstoppers_step; - List.iter (fun v -> prerr_endline ("DANGEROUS EAT: " ^ (string_of_var p.var_names) v)) showstoppers_eat; - p, showstoppers_step, showstoppers_eat - ;; - -let eat p = - let ({ps} as p), showstoppers_step, showstoppers_eat = critical_showstoppers p in - let showstoppers = showstoppers_step @ showstoppers_eat in - let heads = List.sort compare (filter_map hd_of ps) in - let arities = precompute_edible_data p (uniq heads) in - let inedible, showstoppers_conv = edible p arities showstoppers in - let l = List.filter (fun (_,hd,_) -> not (List.mem hd inedible)) arities in - let p = - List.fold_left (fun p (pos,hd,nargs) -> if pos = -1 then p else - let v = `N pos in - let inst = make_lams v nargs in -prerr_endline ("# [INST_IN_EAT] eating: " ^ string_of_var p.var_names hd ^ " := " ^ string_of_term p inst); - { p with sigma = p.sigma @ [hd,inst] } - ) p l in - (* to avoid applied numbers in safe positions that - trigger assert failures subst_in_problem x inst p*) - let ps = - List.map (fun t -> - try - let j,_,_ = List.find (fun (_,hd,_) -> hd_of t = Some hd) l in - `N j - with Not_found -> t - ) ps in - let p = match p.div with - | None -> p - | Some div -> - if List.mem (hd_of_i_var div) inedible - then p - else - let n = match div with `I(_,args) -> Listx.length args | `Var _ -> 0 in - let x = hd_of_i_var div in - let inst = make_lams `Bottom n in - subst_in_problem x inst p in -(*let dangerous_conv = showstoppers_conv in -prerr_endline ("dangerous_conv lenght:" ^ string_of_int (List.length dangerous_conv)); -List.iter (fun l -> prerr_endline (String.concat " " (List.map (string_of_var p.var_names) l))) dangerous_conv; *) - let conv = - List.map (function t -> - try - if let hd = hd_of t in hd <> None && not (List.mem (Util.option_get hd) showstoppers_conv) then t else ( - (match t with | `Var _ -> raise Not_found | _ -> ()); - let _ = List.find (fun h -> hd_of t = Some h) inedible in - t) - with Not_found -> match hd_of t with - | None -> assert (t = convergent_dummy); t - | Some h -> - prerr_endline ("FREEZING " ^ string_of_var p.var_names h); - convergent_dummy - ) p.conv in - List.iter - (fun bs -> - bs := - List.map - (fun (n,t as res) -> - match List.nth ps n with - `N m -> m,t - | _ -> res - ) !bs - ) p.deltas ; - let old_conv = p.conv in - let p = { p with ps; conv } in - if l <> [] || old_conv <> conv - then prerr_endline (string_of_problem "eat" p); - if List.for_all (function `N _ -> true | _ -> false) ps && p.div = None then - `Finished p - else - `Continue p - - -let safe_arity_of_var p x = - (* Compute the minimum number of arguments when x is in head - position at p.div or p.ps *) - let aux = function - | `Var(y,_) -> if x = y then 0 else max_int - | `I((y,_),args) -> if x = y then Listx.length args else max_int - | _ -> max_int in - let tms = ((match p.div with None -> [] | Some t -> [(t :> i_n_var)]) @ p.ps) in - List.fold_left (fun acc t -> Pervasives.min acc (aux t)) max_int tms -;; - -let instantiate p x perm = - let n = (prerr_endline ("WARNING: using constant initialSpecialK=" ^ string_of_int p.initialSpecialK)); p.initialSpecialK in - let arities = Array.to_list (Array.make (n+1) min_int) in - let p,vars = make_fresh_vars p arities in - (* manual lifting of vars by perm in next line *) - let vars = List.map (function `Var (n,ar) -> `Var (n+perm,ar)) vars in - let args = Listx.from_list vars in - let bs = ref [] in - (* other_vars are the variables which are delayed and re-applied to the match *) - let other_vars = Array.mapi (fun n () -> `Var(n+1,min_int)) (Array.make (perm-1) ()) in - let other_vars = Array.to_list other_vars in - (* 666, since it will be replaced anyway during subst: *) - let inst = `Match(`I((0,min_int),args),(x,-666),perm,bs,other_vars) in - (* Add a number of 'perm' leading lambdas *) - let inst = Array.fold_left (fun t () -> `Lam(false, t)) inst (Array.make perm ()) in - let p = {p with deltas=bs::p.deltas} in - subst_in_problem x inst p -;; - -let compute_special_k tms = - let rec aux k (t: nf) = Pervasives.max k (match t with - | `Lam(b,t) -> aux (k + if b then 1 else 0) t - | `I(n, tms) -> Listx.max (Listx.map (aux 0) (tms :> nf Listx.listx)) - | `Match(t, _, liftno, bs, args) -> - List.fold_left max 0 (List.map (aux 0) ((t :> nf)::(args :> nf list)@List.map snd !bs)) - | `N _ - | `Bottom - | `Pacman - | `Var _ -> 0 - ) in - let rec aux' top t = match t with - | `Lam(_,t) -> aux' false t - | `I((_,ar), tms) -> max ar - (Listx.max (Listx.map (aux' false) (tms :> nf Listx.listx))) - | `Match(t, _, liftno, bs, args) -> - List.fold_left max 0 (List.map (aux' false) ((t :> nf)::(args :> nf list)@List.map snd !bs)) - | `N _ - | `Bottom - | `Pacman - | `Var _ -> 0 in - Listx.max (Listx.map (aux 0) tms) + Listx.max (Listx.map (aux' true) tms) -;; - -let choose_step p = - let p, showstoppers_step, showstoppers_eat = critical_showstoppers p in - let x = - match showstoppers_step, showstoppers_eat with - | [], y::_ -> - prerr_endline ("INSTANTIATING (critical eat) : " ^ string_of_var p.var_names y); y - | x::_, _ -> - prerr_endline ("INSTANTIATING (critical step): " ^ string_of_var p.var_names x); x - | [], [] -> - let heads = - (* Choose only variables still alive (with arity > 0) *) - List.sort compare (filter_map ( - fun t -> match t with `Var _ -> None | x -> if arity_of_hd x <= 0 then None else hd_of x - ) ((match p.div with Some t -> [(t :> i_n_var)] | _ -> []) @ p.ps)) in - (match heads with - | [] -> - (try - fst (List.find (((<) 0) ++ snd) (concat_map free_vars' (p.conv :> nf list))) - with - Not_found -> assert false) - | x::_ -> - prerr_endline ("INSTANTIATING TO EAT " ^ string_of_var p.var_names x); - x) in - let arity_of_x = Util.option_get (max_arity_tms x (all_terms p)) in - let safe_arity_of_x = safe_arity_of_var p x in - x, min arity_of_x safe_arity_of_x -;; - -let rec auto_eat p = - prerr_endline "{{{{{{{{ Computing measure before auto_instantiate }}}}}}"; - let m = problem_measure p in - let x, arity_of = choose_step p in - first arity_of p x (fun p j -> - let p' = instantiate p x j in - match eat p' with - | `Finished p -> p - | `Continue p -> - prerr_endline "{{{{{{{{ Computing measure inafter auto_instantiate }}}}}}"; - let delta = problem_measure p - m in - if delta >= 0 - then - (failwith - ("Measure did not decrease (+=" ^ string_of_int delta ^ ")")) - else prerr_endline ("$ Measure decreased: " ^ string_of_int delta); - auto_eat p) -;; - -let auto p n = -prerr_endline ("@@@@ FIRST INSTANTIATE PHASE (" ^ string_of_int n ^ ") @@@@"); - match eat p with - | `Finished p -> p - | `Continue p -> auto_eat p -;; - - -(******************************************************************************) - -let optimize_numerals p = - let replace_in_sigma perm = - let rec aux = function - | `N n -> `N (List.nth perm n) - | `Pacman - | `I _ -> assert false - | `Var _ as t -> t - | `Lam(v,t) -> `Lam(v, aux t) - | `Match(_,_,_,bs,_) as t -> (bs := List.map (fun (n,t) -> (List.nth perm n, t)) !bs); t - | `Bottom as t -> t - in List.map (fun (n,t) -> (n,aux t)) - in - let deltas' = List.mapi (fun n d -> (n, List.map fst !d)) p.deltas in - let maxs = Array.to_list (Array.init (List.length deltas') (fun _ -> 0)) in - let max = List.fold_left max 0 (concat_map snd deltas') in - let perm,_ = List.fold_left (fun (perm, maxs) (curr_n:int) -> - let containing = filter_map (fun (i, bs) -> if List.mem curr_n bs then Some i else None) deltas' in - (* (prerr_endline (string_of_int curr_n ^ " occurs in: " ^ (String.concat " " (List.map string_of_int containing)))); *) - let neww = List.fold_left Pervasives.max 0 (List.mapi (fun n max -> if List.mem n containing then max else 0) maxs) in - let maxs = List.mapi (fun i m -> if List.mem i containing then neww+1 else m) maxs in - (neww::perm, maxs) - ) ([],maxs) (Array.to_list (Array.init (max+1) (fun x -> x))) in - replace_in_sigma (List.rev perm) p.sigma -;; - -let env_of_sigma freshno sigma = - let rec aux n = - if n > freshno then - [] - else - let e = aux (n+1) in - (try - e,Pure.lift (-n-1) (snd (List.find (fun (i,_) -> i = n) sigma)),[] - with - Not_found -> ([],Pure.V n,[]))::e - in aux 0 -;; -(* ************************************************************************** *) - -type response = [ - | `CompleteSeparable of string - | `CompleteUnseparable of string - | `Uncomplete -] - -type result = [ - `Complete | `Uncomplete -] * [ - | `Separable of (int * Num.nf) list - | `Unseparable of string -] - -let run p = - Console.print_hline(); - prerr_endline (string_of_problem "main" p); - let p_finale = auto p p.initialSpecialK in - let freshno,sigma = p_finale.freshno, p_finale.sigma in - prerr_endline ("------- ------ measure=. \n "); - List.iter (fun (x,inst) -> prerr_endline (string_of_var p_finale.var_names x ^ " := " ^ string_of_term p_finale inst)) sigma; - - prerr_endline "-------------------"; - let sigma = optimize_numerals p_finale in (* optimize numerals *) - List.iter (fun (x,inst) -> prerr_endline (string_of_var p_finale.var_names x ^ " := " ^ string_of_term p_finale inst)) sigma; - - prerr_endline "------------------"; - let scott_of_nf t = ToScott.scott_of_nf (t :> nf) in - let div = option_map scott_of_nf p.div in - let conv = List.map scott_of_nf p.conv in - let ps = List.map scott_of_nf p.ps in - - let sigma' = List.map (fun (x,inst) -> x, ToScott.scott_of_nf inst) sigma in - let e' = env_of_sigma freshno sigma' in - - prerr_endline "-----------------"; - (function Some div -> - print_endline (Pure.print div); - let t = Pure.mwhd (e',div,[]) in - prerr_endline ("*:: " ^ (Pure.print t)); - assert (t = Pure.B) - | None -> ()) div; - List.iter (fun n -> - verbose ("_::: " ^ (Pure.print n)); - let t = Pure.mwhd (e',n,[]) in - verbose ("_:: " ^ (Pure.print t)); - assert (t <> Pure.B) - ) conv ; - List.iteri (fun i n -> - verbose ((string_of_int i) ^ "::: " ^ (Pure.print n)); - let t = Pure.mwhd (e',n,[]) in - verbose ((string_of_int i) ^ ":: " ^ (Pure.print t)); - assert (t = Scott.mk_n i) - ) ps ; - prerr_endline "-------- --------"; - p_finale.sigma -;; - -let solve (p, todo) = - let completeness, to_run = - match todo with - | `CompleteUnseparable s -> `Complete, `False s - | `CompleteSeparable _ -> `Complete, `True - | `Uncomplete -> `Uncomplete, `True in - completeness, match to_run with - | `False s -> `Unseparable s - | `True -> - try - `Separable (run p) - with - Backtrack _ -> `Unseparable "backtrack" -;; - -let no_bombs_pacmans p = - not (List.exists (eta_subterm `Bottom) (p.ps@p.conv)) - && not (List.exists (eta_subterm `Pacman) p.ps) - && Util.option_map (eta_subterm `Pacman) p.div <> Some true -;; - -let check p = - if (let rec f = function - | [] -> false - | hd::tl -> List.exists (eta_eq hd) tl || f tl in - f p.ps) (* FIXME what about initial fragments of numbers? *) - then `CompleteUnseparable "ps contains duplicates" - (* check if div occurs somewhere in ps@conv *) - else if (match p.div with - | None -> true - | Some div -> not (List.exists (eta_subterm div) (p.ps@p.conv)) - ) && no_bombs_pacmans p - then `CompleteSeparable "no bombs, pacmans and div" - (* il check seguente e' spostato nel parser e lancia un ParsingError *) - (* else if false (* TODO bombs or div fuori da lambda in ps@conv *) - then `CompleteUnseparable "bombs or div fuori da lambda in ps@conv" *) - else if p.div = None - then `CompleteSeparable "no div" - else `Uncomplete -;; - -let problem_of (label, div, conv, ps, var_names) = - (* TODO: replace div with bottom in problem??? *) - let all_tms = (match div with None -> [] | Some div -> [(div :> i_n_var)]) @ ps @ conv in - if all_tms = [] then failwith "problem_of: empty problem"; - let initialSpecialK = compute_special_k (Listx.from_list (all_tms :> nf list)) in - let freshno = List.length var_names in - let deltas = - let dummy = `Var (max_int / 2, -666) in - [ ref (Array.to_list (Array.init (List.length ps) (fun i -> i, dummy))) ] in - let trail = [] in - let sigma = [] in - let p = {freshno; div; conv; ps; sigma; deltas; initialSpecialK; trail; var_names; label} in - p, check p -;; diff --git a/ocaml/lambda4.mli b/ocaml/lambda4.mli deleted file mode 100644 index d6e4202..0000000 --- a/ocaml/lambda4.mli +++ /dev/null @@ -1,23 +0,0 @@ -type problem - -val label_of_problem : problem -> string - -type response = [ - | `CompleteSeparable of string - | `CompleteUnseparable of string - | `Uncomplete -] - -type result = [ - `Complete | `Uncomplete -] * [ - | `Separable of (int * Num.nf) list - | `Unseparable of string -] - -val problem_of: (string (* problem label *) -* Num.i_var option (* div *) -* Num.i_n_var list (* conv *) -* Num.i_n_var list (* ps *) -* string list (* names of free variables *)) -> problem * response -val solve: problem * response -> result diff --git a/ocaml/listx.ml b/ocaml/listx.ml deleted file mode 100644 index 821e281..0000000 --- a/ocaml/listx.ml +++ /dev/null @@ -1,71 +0,0 @@ -(* Non-empty lists *) -type 'a listx = - | Nil of 'a - | Cons of ('a * 'a listx) - -let rec fold_left f acc l = - match l with - | Nil x -> f acc x - | Cons (x, l') -> fold_left f (f acc x) l' - -let hd = - function - | Nil x - | Cons (x,_) -> x - -let rec map f = - function - | Nil x -> Nil (f x) - | Cons (x, l') -> Cons (f x, map f l') - -let rec append l = - function - | Nil x -> Cons (x, l) - | Cons (x, l') -> Cons (x, append l l') - -let rec length = function - | Nil _ -> 1 - | Cons (_, xs) -> 1 + (length xs) - -let rec assoc x = function - | Nil (y,t) - | Cons ((y,t),_) when x=y -> t - | Nil _ -> raise Not_found - | Cons (_,l) -> assoc x l - -let rec to_list = - function - Nil x -> [x] - | Cons (x,l) -> x::to_list l - -let rec from_list = - function - [] -> raise (Failure "from_list: empty list") - | [x] -> Nil x - | x::l -> Cons(x,from_list l) - -let rec split_nth n l = - match n,l with - 0,_ -> [] - | 1,Nil x -> [x] - | n,Cons (hd,tl) -> hd::split_nth (n-1) tl - | _,_ -> raise (Failure "split_nth: not enough args") - -let rec max = - function - | Nil x -> x - | Cons (x, l) -> Pervasives.max x (max l) - -let rec last = - function - | Nil x -> x - | Cons (_, l) -> last l -(* -let rec nth i l = match l, i with - | Cons (x, _), 1 -> x - | _, n when n <= 0 -> raise (Invalid_argument "Listx.nth") - | Cons (_, xs), n -> nth (n-1) xs - | Nil x, 1 -> x - | Nil _, _ -> raise (Invalid_argument "Listx.nth") -;; -*) diff --git a/ocaml/listx.mli b/ocaml/listx.mli deleted file mode 100644 index a43bc4e..0000000 --- a/ocaml/listx.mli +++ /dev/null @@ -1,12 +0,0 @@ -type 'a listx = Nil of 'a | Cons of ('a * 'a listx) -val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b listx -> 'a -val hd : 'a listx -> 'a -val map : ('a -> 'b) -> 'a listx -> 'b listx -val append : 'a listx -> 'a listx -> 'a listx -val length : 'a listx -> int -val assoc : 'a -> ('a * 'b) listx -> 'b -val to_list : 'a listx -> 'a list -val from_list : 'a list -> 'a listx -val split_nth : int -> 'a listx -> 'a list -val max : 'a listx -> 'a -val last : 'a listx -> 'a diff --git a/ocaml/logs/fail.txt b/ocaml/logs/fail.txt deleted file mode 100644 index a0cf184..0000000 --- a/ocaml/logs/fail.txt +++ /dev/null @@ -1,2999 +0,0 @@ --666 | 44 => `169:-666 | 45 => `170:-666] )) u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-461 -1686018427387904 q:-4611686018427387904 -| 17: `71:2 (`64:2 (λ`171. [match(b:1) `171:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `16 -3:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 = -> `168:-666 | 44 => `169:-666 | 45 => `170:-666] ))) `70:-4611686018427387904 `69:-4611686018427387904 `68:-461168601842 -7387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 18: `95:0 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 19: 6 -| 20: `64:2 (λ`171. [match(b:1) `171:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611 -686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 => `168: --666 | 44 => `169:-666 | 45 => `170:-666] )) `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 -`76:-4611686018427387904 `75:-4611686018427387904 -| 21: `78:1 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 22: a:0 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-46116 -86018427387904 -| 23: `85:1 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 -| 24: h:1 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-46116 -86018427387904 -| 25: `70:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-461168601 -8427387904 `89:-4611686018427387904 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: `38:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46116860 -18427387904 `96:-4611686018427387904 -| 28: e:1 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 -| 29: `169:1 `107:-4611686018427387904 `106:-4611686018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `10 -3:-4611686018427387904 -| 30: `113:1 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 -| 31: `64:4 (λ`171. [match(b:1) `171:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611 -686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 => `168: --666 | 44 => `169:-666 | 45 => `170:-666] )) (λ`171. [match(f:1) `171:-4611686018427387904 `93:-4611686018427387904 `92: --4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-4611686018427387904 with 24 => λ`172. [match -(`92:-666) `172:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46 -11686018427387904 `96:-4611686018427387904 with 26 => λ`173. [match(`98:-666) `173:-4611686018427387904 `107:-4611686018 -427387904 `106:-4611686018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 2 -8 => λ`174. [match(`104:-666) `174:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-461168 -6018427387904 `129:-4611686018427387904 `128:-4611686018427387904 with 33 => λ`175. [match(`128:-666) `175:-461168601842 -7387904 `138:-4611686018427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-46 -11686018427387904 with 34 => λ`176. [match(`133:-666) `176:-4611686018427387904 `144:-4611686018427387904 `143:-46116860 -18427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`177. [match(`138: --666) `177:-4611686018427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611 -686018427387904 `146:-4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`174. [match(`105:-666) `174:-461168 -6018427387904 `114:-4611686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `1 -10:-4611686018427387904 with 30 => λ`175. [match(`110:-666) `175:-4611686018427387904 `120:-4611686018427387904 `119:-46 -11686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] - )] ) | 27 => `102:-666] ) | 25 => `95:-666] )) (`64:3 (λ`171. [match(b:1) `171:-4611686018427387904 `165:-4611686018427 -387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 = -> `166:-666 | 42 => `167:-666 | 43 => `168:-666 | 44 => `169:-666 | 45 => `170:-666] )) (e:3 (λ`171. λ`172. [match(d:1) -`172:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-46116860184273 -87904 `28:-4611686018427387904 with 8 => λ`173. [match(`30:-666) `173:-4611686018427387904 `38:-4611686018427387904 `37: --4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904 with 9 => λ`174. [match( -`35:-666) `174:-4611686018427387904 `44:-4611686018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611 -686018427387904 `40:-4611686018427387904 with 10 => λ`175. [match(`40:-666) `175:-4611686018427387904 `50:-4611686018427 -387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ` -176. [match(`45:-666) `176:-4611686018427387904 `56:-4611686018427387904 `55:-4611686018427387904 `54:-46116860184273879 -04 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`177. [match(`50:-666) `177:-4611686018427387904 `79:-4 -611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 w -ith 20 => λ`178. [match(`72:-666) `178:-4611686018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-46 -11686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`178. [match(`73: --666) `178:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-46116860 -18427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )] ) | 13 => λ`177. [match(`51:-666) `177:-46 -11686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `5 -9:-4611686018427387904 with 15 => λ`178. [match(`57:-666) `178:-4611686018427387904 `70:-4611686018427387904 `69:-461168 -6018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73 -:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => `64:-666] )) (λ`171. i:2 h:1))) `120:-4611686018427387 -904 `119:-4611686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 -| 32: `126:2 `126:1 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 -| 33: `64:4 (λ`171. λ`172. [match(n:1) `172:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-461168 -6018427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`173. [match(s:-666) `173:-4611686018427387904 `2 -6:-4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with -7 => `27:-666] ) | 16 => `71:-666] )) (λ`171. `171:2 (λ`172. [match(d:1) `172:-4611686018427387904 `32:-4611686018427387 -904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`173. - [match(`30:-666) `173:-4611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 ` -35:-4611686018427387904 `34:-4611686018427387904 with 9 => λ`174. [match(`35:-666) `174:-4611686018427387904 `44:-461168 -6018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 1 -0 => λ`175. [match(`40:-666) `175:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018 -427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ`176. [match(`45:-666) `176:-4611686018427387904 - `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116860184273 -87904 with 12 => λ`177. [match(`50:-666) `177:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77 -:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`178. [match(`72:-666) `178:-4611686 -018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `12 -2:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`178. [match(`73:-666) `178:-4611686018427387904 `86:-4611686018 -427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => - `87:-666 | 23 => `88:-666] )] ) | 13 => λ`177. [match(`51:-666) `177:-4611686018427387904 `63:-4611686018427387904 `62: --4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`178. [match -(`57:-666) `178:-4611686018427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-461 -1686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] -)] )] )] ) | 14 => `64:-666] ))) (λ`171. [match(`80:1) `171:-4611686018427387904 `86:-4611686018427387904 `85:-461168601 -8427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-6 -66] )) `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 `128:-461 -1686018427387904 -| 34: 34 -| 35: e:1 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:- -4611686018427387904 -| 36: `170:2 (λ`171. λ`172. e:1) `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686 -018427387904 -| 37: `151:1 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `14 -6:-4611686018427387904 -| 38: `170:1 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611686018427387904 `15 -3:-4611686018427387904 -| 39: h:2 (λ`171. λ`172. [match(n:1) `172:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-46116860 -18427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`173. [match(s:-666) `173:-4611686018427387904 `26: --4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with 7 -=> `27:-666] ) | 16 => `71:-666] )) `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:- -4611686018427387904 `153:-4611686018427387904 -| 40: `134:-4611686018427387904 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611 -686018427387904 `153:-4611686018427387904 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: `165:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 44: `168:0 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 45: e:1 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| -{{{{{{{{ Computing measure inafter auto_instantiate }}}}}} -compare 82 95= 1 -$ Measure decreased by 1 -{{{{{{{{ Computing measure before auto_instantiate }}}}}} -DANGEROUS EAT: e -DANGEROUS EAT: h -DANGEROUS EAT: `64 -INSTANTIATING CRITICAL TO EAT e -INSTANTIATING AND HOPING e -WARNING: using constant initialSpecialK -# INST: e := λ`182. [match(d:666) `182:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-46 -11686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => `177:-666 | 48 => `17 -8:-666 | 49 => `179:-666 | 50 => `180:-666 | 51 => `181:-666] ) ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: instantiate ||||| - -| measure=73 freshno = 181 -|> DISCRIMINATING SETS (deltas) -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 -| 41 <> 42 <> 43 <> 44 <> 45 -| 38 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 -| 7 -| 6 <> 16 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: `27:1 -|> CONVERGENT -| _: `74:2 [match(`33:3) `64:1 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 `34:-461168601 -8427387904 with 9 => λ`182. [match(`38:-666) `182:-4611686018427387904 `44:-4611686018427387904 `43:-4611686018427387904 - `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`183. [match(`43:-666) `183:-461 -1686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46 -:-4611686018427387904 with 11 => λ`184. [match(`48:-666) `184:-4611686018427387904 `56:-4611686018427387904 `55:-4611686 -018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`185. [match(`53:-66 -6) `185:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76:-46116860184 -27387904 `75:-4611686018427387904 with 20 => λ`186. [match(`75:-666) `186:-4611686018427387904 `126:-4611686018427387904 - `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 with 32 => `127 -:-666] ) | 21 => λ`186. [match(`76:-666) `186:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84 -:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )] ) | 13 -=> λ`185. [match(`54:-666) `185:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61:-461168601842 -7387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`186. [match(`60:-666) `186:-4611686018427387904 ` -70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387 -904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] h:1) -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => `177:-666 | 48 => - `178:-666 | 49 => `179:-666 | 50 => `180:-666 | 51 => `181:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97: --4611686018427387904 `96:-4611686018427387904) with 26 => λ`182. [match(`100:-666) `182:-4611686018427387904 `107:-46116 -86018427387904 `106:-4611686018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 w -ith 28 => λ`183. [match(`106:-666) `183:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4 -611686018427387904 `129:-4611686018427387904 `128:-4611686018427387904 with 33 => λ`184. [match(`130:-666) `184:-4611686 -018427387904 `138:-4611686018427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `13 -4:-4611686018427387904 with 34 => λ`185. [match(`135:-666) `185:-4611686018427387904 `144:-4611686018427387904 `143:-461 -1686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`186. [match( -`140:-666) `186:-4611686018427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147: --4611686018427387904 `146:-4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`183. [match(`107:-666) `183:-4 -611686018427387904 `114:-4611686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-46116860184273879 -04 `110:-4611686018427387904 with 30 => λ`184. [match(`112:-666) `184:-4611686018427387904 `120:-4611686018427387904 `11 -9:-4611686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-66 -6] )] )] ) | 27 => `102:-666] `64:2 (λ`182. [match(b:1) `182:-4611686018427387904 `165:-4611686018427387904 `164:-461168 -6018427387904 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => - `167:-666 | 43 => `168:-666 | 44 => `169:-666 | 45 => `170:-666] ))) `121:1 -| _: _ -|> NUMERIC -| 0: `127:1 a:0 -| 1: `87:0 -| 2: `72:1 a:0 -| 3: `73:1 a:0 -| 4: `152:1 a:0 -| 5: `166:0 n:-4611686018427387904 m:-4611686018427387904 l:-4611686018427387904 k:-4611686018427387904 -| 6: 6 -| 7: `176:0 x:-4611686018427387904 w:-4611686018427387904 -| 8: `167:1 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-461 -1686018427387904 -| 9: `102:0 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904 -| 10: i:2 h:1 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 -| 11: `177:2 (λ`182. i:2 h:1) `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018 -427387904 -| 12: 12 -| 13: h:1 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116 -86018427387904 -| 14: `178:0 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 -| 15: `64:1 `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 -| 16: `64:2 (λ`182. [match(b:1) `182:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611 -686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 => `168: --666 | 44 => `169:-666 | 45 => `170:-666] )) u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-461 -1686018427387904 q:-4611686018427387904 -| 17: `71:2 (`64:2 (λ`182. [match(b:1) `182:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `16 -3:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 = -> `168:-666 | 44 => `169:-666 | 45 => `170:-666] ))) `70:-4611686018427387904 `69:-4611686018427387904 `68:-461168601842 -7387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 18: `95:0 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 19: 6 -| 20: `64:2 (λ`182. [match(b:1) `182:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611 -686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 => `168: --666 | 44 => `169:-666 | 45 => `170:-666] )) `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 -`76:-4611686018427387904 `75:-4611686018427387904 -| 21: `78:1 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 22: a:0 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-46116 -86018427387904 -| 23: `85:1 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 -| 24: h:1 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-46116 -86018427387904 -| 25: `70:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-461168601 -8427387904 `89:-4611686018427387904 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: `38:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46116860 -18427387904 `96:-4611686018427387904 -| 28: `179:0 `104:-4611686018427387904 `103:-4611686018427387904 -| 29: `169:1 `107:-4611686018427387904 `106:-4611686018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `10 -3:-4611686018427387904 -| 30: `113:1 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 -| 31: `64:4 (λ`182. [match(b:1) `182:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611 -686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 => `168: --666 | 44 => `169:-666 | 45 => `170:-666] )) (λ`182. [match(f:1) `182:-4611686018427387904 `93:-4611686018427387904 `92: --4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-4611686018427387904 with 24 => λ`183. [match -(`92:-666) `183:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46 -11686018427387904 `96:-4611686018427387904 with 26 => λ`184. [match(`98:-666) `184:-4611686018427387904 `107:-4611686018 -427387904 `106:-4611686018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 2 -8 => λ`185. [match(`104:-666) `185:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-461168 -6018427387904 `129:-4611686018427387904 `128:-4611686018427387904 with 33 => λ`186. [match(`128:-666) `186:-461168601842 -7387904 `138:-4611686018427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-46 -11686018427387904 with 34 => λ`187. [match(`133:-666) `187:-4611686018427387904 `144:-4611686018427387904 `143:-46116860 -18427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`188. [match(`138: --666) `188:-4611686018427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611 -686018427387904 `146:-4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`185. [match(`105:-666) `185:-461168 -6018427387904 `114:-4611686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `1 -10:-4611686018427387904 with 30 => λ`186. [match(`110:-666) `186:-4611686018427387904 `120:-4611686018427387904 `119:-46 -11686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] - )] ) | 27 => `102:-666] ) | 25 => `95:-666] )) (`64:3 (λ`182. [match(b:1) `182:-4611686018427387904 `165:-4611686018427 -387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 = -> `166:-666 | 42 => `167:-666 | 43 => `168:-666 | 44 => `169:-666 | 45 => `170:-666] )) [match(e:3) [match(f:1) `174:-46 -11686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `2 -8:-4611686018427387904 with 8 => λ`182. [match(`32:-666) `182:-4611686018427387904 `38:-4611686018427387904 `37:-4611686 -018427387904 `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904 with 9 => λ`183. [match(`37:-666 -) `183:-4611686018427387904 `44:-4611686018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-461168601842 -7387904 `40:-4611686018427387904 with 10 => λ`184. [match(`42:-666) `184:-4611686018427387904 `50:-4611686018427387904 ` -49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ`185. [ma -tch(`47:-666) `185:-4611686018427387904 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:- -4611686018427387904 `52:-4611686018427387904 with 12 => λ`186. [match(`52:-666) `186:-4611686018427387904 `79:-461168601 -8427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 with 20 = -> λ`187. [match(`74:-666) `187:-4611686018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-4611686018 -427387904 `123:-4611686018427387904 `122:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`187. [match(`75:-666) `1 -87:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387 -904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )] ) | 13 => λ`186. [match(`53:-666) `186:-4611686018 -427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-46116 -86018427387904 with 15 => λ`187. [match(`59:-666) `187:-4611686018427387904 `70:-4611686018427387904 `69:-46116860184273 -87904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | -6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => `64:-666] `173:-4611686018427387904 `172:-4611686018427387904 -`171:-4611686018427387904) with 46 => `176:-666 | 47 => `177:-666 | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-666 -| 51 => `181:-666] λ`182. i:2 h:1)) `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387904 `117:- -4611686018427387904 `116:-4611686018427387904 -| 32: `126:2 `126:1 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 -| 33: `64:4 (λ`182. λ`183. [match(n:1) `183:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-461168 -6018427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`184. [match(s:-666) `184:-4611686018427387904 `2 -6:-4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with -7 => `27:-666] ) | 16 => `71:-666] )) (λ`182. `182:2 (λ`183. [match(d:1) `183:-4611686018427387904 `32:-4611686018427387 -904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`184. - [match(`30:-666) `184:-4611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 ` -35:-4611686018427387904 `34:-4611686018427387904 with 9 => λ`185. [match(`35:-666) `185:-4611686018427387904 `44:-461168 -6018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 1 -0 => λ`186. [match(`40:-666) `186:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018 -427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ`187. [match(`45:-666) `187:-4611686018427387904 - `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116860184273 -87904 with 12 => λ`188. [match(`50:-666) `188:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77 -:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`189. [match(`72:-666) `189:-4611686 -018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `12 -2:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`189. [match(`73:-666) `189:-4611686018427387904 `86:-4611686018 -427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => - `87:-666 | 23 => `88:-666] )] ) | 13 => λ`188. [match(`51:-666) `188:-4611686018427387904 `63:-4611686018427387904 `62: --4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`189. [match -(`57:-666) `189:-4611686018427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-461 -1686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] -)] )] )] ) | 14 => `64:-666] ))) (λ`182. [match(`80:1) `182:-4611686018427387904 `86:-4611686018427387904 `85:-461168601 -8427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-6 -66] )) `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 `128:-461 -1686018427387904 -| 34: 34 -| 35: `180:0 `143:-4611686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 -| 36: `170:2 (λ`182. λ`183. λ`184. [match(b:1) `184:-4611686018427387904 `175:-4611686018427387904 `174:-461168601842738 -7904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => `177:-66 -6 | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-666 | 51 => `181:-666] )) `62:-4611686018427387904 `61:-461168601842 -7387904 `60:-4611686018427387904 `59:-4611686018427387904 -| 37: `151:1 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `14 -6:-4611686018427387904 -| 38: `170:1 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611686018427387904 `15 -3:-4611686018427387904 -| 39: h:2 (λ`182. λ`183. [match(n:1) `183:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-46116860 -18427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`184. [match(s:-666) `184:-4611686018427387904 `26: --4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with 7 -=> `27:-666] ) | 16 => `71:-666] )) `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:- -4611686018427387904 `153:-4611686018427387904 -| 40: `134:-4611686018427387904 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611 -686018427387904 `153:-4611686018427387904 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: `165:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 44: `168:0 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 45: `181:0 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 46: y:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686 -018427387904 `171:-4611686018427387904 -| 47: `50:1 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: `105:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 50: `144:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 51: `164:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| -DANGEROUS EAT: h -DANGEROUS EAT: `64 -DANGEROUS EAT: `164 -dangerous_conv lenght:5 -`64 `37 `36 `35 `34 h `74 `64 `37 `36 `35 `34 `44 `43 `42 `41 `40 `50 `49 `48 `47 `46 `56 `55 `54 `53 `52 `79 `78 `77 `7 -6 `75 `126 `125 `124 `123 `122 `127 `86 `85 `84 `83 `82 `87 `88 `63 `62 `61 `60 `59 `70 `69 `68 `67 `66 `72 `73 `74 `151 - h - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 `64 `165 `164 `163 `162 `161 `166 `167 `168 `169 `170 `121 `100 `175 `174 -`173 `172 `171 `176 `177 `178 `179 `180 `181 `99 `98 `97 `96 `107 `106 `105 `104 `103 `132 `131 `130 `129 `128 `138 `137 - `136 `135 `134 `144 `143 `142 `141 `140 `150 `149 `148 `147 `146 `152 `114 `113 `112 `111 `110 `120 `119 `118 `117 `116 - `121 `102 `64 `165 `164 `163 `162 `161 `166 `167 `168 `169 `170 `121 - -dangerous_conv lenght:5 -`64 `37 `36 `35 `34 h `74 `64 `37 `36 `35 `34 `44 `43 `42 `41 `40 `50 `49 `48 `47 `46 `56 `55 `54 `53 `52 `79 `78 `77 `7 -6 `75 `126 `125 `124 `123 `122 `127 `86 `85 `84 `83 `82 `87 `88 `63 `62 `61 `60 `59 `70 `69 `68 `67 `66 `72 `73 `74 `151 - h - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 `64 `165 `164 `163 `162 `161 `166 `167 `168 `169 `170 `121 `100 `175 `174 -`173 `172 `171 `176 `177 `178 `179 `180 `181 `99 `98 `97 `96 `107 `106 `105 `104 `103 `132 `131 `130 `129 `128 `138 `137 - `136 `135 `134 `144 `143 `142 `141 `140 `150 `149 `148 `147 `146 `152 `114 `113 `112 `111 `110 `120 `119 `118 `117 `116 - `121 `102 `64 `165 `164 `163 `162 `161 `166 `167 `168 `169 `170 `121 - -{{{{{{{{ Computing measure inafter auto_instantiate }}}}}} -compare 73 82= 1 -$ Measure decreased by 1 -{{{{{{{{ Computing measure before auto_instantiate }}}}}} -DANGEROUS EAT: h -DANGEROUS EAT: `64 -DANGEROUS EAT: `164 -INSTANTIATING CRITICAL TO EAT h -INSTANTIATING AND HOPING `177 -WARNING: using constant initialSpecialK -# INST: `177 := λ`188. [match(`176:666) `188:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `1 -84:-4611686018427387904 `183:-4611686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: instantiate ||||| - -| measure=72 freshno = 187 -|> DISCRIMINATING SETS (deltas) -| 52 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 -| 41 <> 42 <> 43 <> 44 <> 45 -| 38 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 -| 7 -| 6 <> 16 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: `27:1 -|> CONVERGENT -| _: `74:2 [match(`33:3) `64:1 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 `34:-461168601 -8427387904 with 9 => λ`188. [match(`38:-666) `188:-4611686018427387904 `44:-4611686018427387904 `43:-4611686018427387904 - `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`189. [match(`43:-666) `189:-461 -1686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46 -:-4611686018427387904 with 11 => λ`190. [match(`48:-666) `190:-4611686018427387904 `56:-4611686018427387904 `55:-4611686 -018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`191. [match(`53:-66 -6) `191:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76:-46116860184 -27387904 `75:-4611686018427387904 with 20 => λ`192. [match(`75:-666) `192:-4611686018427387904 `126:-4611686018427387904 - `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 with 32 => `127 -:-666] ) | 21 => λ`192. [match(`76:-666) `192:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84 -:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )] ) | 13 -=> λ`191. [match(`54:-666) `191:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61:-461168601842 -7387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`192. [match(`60:-666) `192:-4611686018427387904 ` -70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387 -904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] h:1) -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`188. [match(`17 -6:-666) `188:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -) with 26 => λ`188. [match(`100:-666) `188:-4611686018427387904 `107:-4611686018427387904 `106:-4611686018427387904 `105 -:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`189. [match(`106:-666) `189:-4611 -686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 -`128:-4611686018427387904 with 33 => λ`190. [match(`130:-666) `190:-4611686018427387904 `138:-4611686018427387904 `137:- -4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with 34 => λ`191. [mat -ch(`135:-666) `191:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611686018427387904 `1 -41:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`192. [match(`140:-666) `192:-4611686018427387904 `150:-46 -11686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:-461168601842738790 -4 with 37 => `152:-666] )] )] )] ) | 29 => λ`189. [match(`107:-666) `189:-4611686018427387904 `114:-4611686018427387904 -`113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 with 30 => λ`190 -. [match(`112:-666) `190:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387 -904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-666] `64:2 (λ`188. [ -match(b:1) `188:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162: --4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 => `168:-666 | 44 => `169:-66 -6 | 45 => `170:-666] ))) `121:1 -| _: _ -|> NUMERIC -| 0: `127:1 a:0 -| 1: `87:0 -| 2: `72:1 a:0 -| 3: `73:1 a:0 -| 4: `152:1 a:0 -| 5: `166:0 n:-4611686018427387904 m:-4611686018427387904 l:-4611686018427387904 k:-4611686018427387904 -| 6: 6 -| 7: `176:0 x:-4611686018427387904 w:-4611686018427387904 -| 8: `167:1 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-461 -1686018427387904 -| 9: `102:0 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904 -| 10: i:2 h:1 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 -| 11: `187:1 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 -| 12: 12 -| 13: h:1 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116 -86018427387904 -| 14: `178:0 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 -| 15: `64:1 `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 -| 16: `64:2 (λ`188. [match(b:1) `188:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611 -686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 => `168: --666 | 44 => `169:-666 | 45 => `170:-666] )) u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-461 -1686018427387904 q:-4611686018427387904 -| 17: `71:2 (`64:2 (λ`188. [match(b:1) `188:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `16 -3:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 = -> `168:-666 | 44 => `169:-666 | 45 => `170:-666] ))) `70:-4611686018427387904 `69:-4611686018427387904 `68:-461168601842 -7387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 18: `95:0 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 19: 6 -| 20: `64:2 (λ`188. [match(b:1) `188:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611 -686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 => `168: --666 | 44 => `169:-666 | 45 => `170:-666] )) `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 -`76:-4611686018427387904 `75:-4611686018427387904 -| 21: `78:1 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 22: a:0 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-46116 -86018427387904 -| 23: `85:1 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 -| 24: h:1 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-46116 -86018427387904 -| 25: `70:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-461168601 -8427387904 `89:-4611686018427387904 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: `38:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46116860 -18427387904 `96:-4611686018427387904 -| 28: `179:0 `104:-4611686018427387904 `103:-4611686018427387904 -| 29: `169:1 `107:-4611686018427387904 `106:-4611686018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `10 -3:-4611686018427387904 -| 30: `113:1 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 -| 31: `64:4 (λ`188. [match(b:1) `188:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611 -686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 => `166:-666 | 42 => `167:-666 | 43 => `168: --666 | 44 => `169:-666 | 45 => `170:-666] )) (λ`188. [match(f:1) `188:-4611686018427387904 `93:-4611686018427387904 `92: --4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-4611686018427387904 with 24 => λ`189. [match -(`92:-666) `189:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46 -11686018427387904 `96:-4611686018427387904 with 26 => λ`190. [match(`98:-666) `190:-4611686018427387904 `107:-4611686018 -427387904 `106:-4611686018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 2 -8 => λ`191. [match(`104:-666) `191:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-461168 -6018427387904 `129:-4611686018427387904 `128:-4611686018427387904 with 33 => λ`192. [match(`128:-666) `192:-461168601842 -7387904 `138:-4611686018427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-46 -11686018427387904 with 34 => λ`193. [match(`133:-666) `193:-4611686018427387904 `144:-4611686018427387904 `143:-46116860 -18427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`194. [match(`138: --666) `194:-4611686018427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611 -686018427387904 `146:-4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`191. [match(`105:-666) `191:-461168 -6018427387904 `114:-4611686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `1 -10:-4611686018427387904 with 30 => λ`192. [match(`110:-666) `192:-4611686018427387904 `120:-4611686018427387904 `119:-46 -11686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] - )] ) | 27 => `102:-666] ) | 25 => `95:-666] )) (`64:3 (λ`188. [match(b:1) `188:-4611686018427387904 `165:-4611686018427 -387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 with 41 = -> `166:-666 | 42 => `167:-666 | 43 => `168:-666 | 44 => `169:-666 | 45 => `170:-666] )) [match(e:3) [match(f:1) `174:-46 -11686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `2 -8:-4611686018427387904 with 8 => λ`188. [match(`32:-666) `188:-4611686018427387904 `38:-4611686018427387904 `37:-4611686 -018427387904 `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904 with 9 => λ`189. [match(`37:-666 -) `189:-4611686018427387904 `44:-4611686018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-461168601842 -7387904 `40:-4611686018427387904 with 10 => λ`190. [match(`42:-666) `190:-4611686018427387904 `50:-4611686018427387904 ` -49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ`191. [ma -tch(`47:-666) `191:-4611686018427387904 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:- -4611686018427387904 `52:-4611686018427387904 with 12 => λ`192. [match(`52:-666) `192:-4611686018427387904 `79:-461168601 -8427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 with 20 = -> λ`193. [match(`74:-666) `193:-4611686018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-4611686018 -427387904 `123:-4611686018427387904 `122:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`193. [match(`75:-666) `1 -93:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387 -904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )] ) | 13 => λ`192. [match(`53:-666) `192:-4611686018 -427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-46116 -86018427387904 with 15 => λ`193. [match(`59:-666) `193:-4611686018427387904 `70:-4611686018427387904 `69:-46116860184273 -87904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | -6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => `64:-666] `173:-4611686018427387904 `172:-4611686018427387904 -`171:-4611686018427387904) with 46 => `176:-666 | 47 => λ`188. [match(`176:-666) `188:-4611686018427387904 `186:-4611686 -018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-4611686018427387904 `182:-4611686018427387904 wit -h 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-666 | 51 => `181:-666] λ`188. i:2 h:1)) `120:-461 -1686018427387904 `119:-4611686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 -| 32: `126:2 `126:1 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 -| 33: `64:4 (λ`188. λ`189. [match(n:1) `189:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-461168 -6018427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`190. [match(s:-666) `190:-4611686018427387904 `2 -6:-4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with -7 => `27:-666] ) | 16 => `71:-666] )) (λ`188. `188:2 (λ`189. [match(d:1) `189:-4611686018427387904 `32:-4611686018427387 -904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`190. - [match(`30:-666) `190:-4611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 ` -35:-4611686018427387904 `34:-4611686018427387904 with 9 => λ`191. [match(`35:-666) `191:-4611686018427387904 `44:-461168 -6018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 1 -0 => λ`192. [match(`40:-666) `192:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018 -427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ`193. [match(`45:-666) `193:-4611686018427387904 - `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116860184273 -87904 with 12 => λ`194. [match(`50:-666) `194:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77 -:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`195. [match(`72:-666) `195:-4611686 -018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `12 -2:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`195. [match(`73:-666) `195:-4611686018427387904 `86:-4611686018 -427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => - `87:-666 | 23 => `88:-666] )] ) | 13 => λ`194. [match(`51:-666) `194:-4611686018427387904 `63:-4611686018427387904 `62: --4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`195. [match -(`57:-666) `195:-4611686018427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-461 -1686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] -)] )] )] ) | 14 => `64:-666] ))) (λ`188. [match(`80:1) `188:-4611686018427387904 `86:-4611686018427387904 `85:-461168601 -8427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-6 -66] )) `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 `128:-461 -1686018427387904 -| 34: 34 -| 35: `180:0 `143:-4611686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 -| 36: `170:2 (λ`188. λ`189. λ`190. [match(b:1) `190:-4611686018427387904 `175:-4611686018427387904 `174:-461168601842738 -7904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`191. [ -match(`173:-666) `191:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 - `183:-4611686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => - `180:-666 | 51 => `181:-666] )) `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686 -018427387904 -| 37: `151:1 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `14 -6:-4611686018427387904 -| 38: `170:1 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611686018427387904 `15 -3:-4611686018427387904 -| 39: h:2 (λ`188. λ`189. [match(n:1) `189:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-46116860 -18427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`190. [match(s:-666) `190:-4611686018427387904 `26: --4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with 7 -=> `27:-666] ) | 16 => `71:-666] )) `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:- -4611686018427387904 `153:-4611686018427387904 -| 40: `134:-4611686018427387904 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611 -686018427387904 `153:-4611686018427387904 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: `165:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 44: `168:0 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 45: `181:0 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 46: y:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686 -018427387904 `171:-4611686018427387904 -| 47: `50:1 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: `105:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 50: `144:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 51: `164:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 52: i:2 h:1 `185:-4611686018427387904 `184:-4611686018427387904 `183:-4611686018427387904 `182:-4611686018427387904 -| -DANGEROUS EAT: h -DANGEROUS EAT: `64 -DANGEROUS EAT: `164 -dangerous_conv lenght:5 -`64 `37 `36 `35 `34 h `74 `64 `37 `36 `35 `34 `44 `43 `42 `41 `40 `50 `49 `48 `47 `46 `56 `55 `54 `53 `52 `79 `78 `77 `7 -6 `75 `126 `125 `124 `123 `122 `127 `86 `85 `84 `83 `82 `87 `88 `63 `62 `61 `60 `59 `70 `69 `68 `67 `66 `72 `73 `74 `151 - h - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 `64 `165 `164 `163 `162 `161 `166 `167 `168 `169 `170 `121 `100 `175 `174 -`173 `172 `171 `176 `186 `185 `184 `183 `182 `187 `178 `179 `180 `181 `99 `98 `97 `96 `107 `106 `105 `104 `103 `132 `131 - `130 `129 `128 `138 `137 `136 `135 `134 `144 `143 `142 `141 `140 `150 `149 `148 `147 `146 `152 `114 `113 `112 `111 `110 - `120 `119 `118 `117 `116 `121 `102 `64 `165 `164 `163 `162 `161 `166 `167 `168 `169 `170 `121 - -dangerous_conv lenght:5 -`64 `37 `36 `35 `34 h `74 `64 `37 `36 `35 `34 `44 `43 `42 `41 `40 `50 `49 `48 `47 `46 `56 `55 `54 `53 `52 `79 `78 `77 `7 -6 `75 `126 `125 `124 `123 `122 `127 `86 `85 `84 `83 `82 `87 `88 `63 `62 `61 `60 `59 `70 `69 `68 `67 `66 `72 `73 `74 `151 - h - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 `64 `165 `164 `163 `162 `161 `166 `167 `168 `169 `170 `121 `100 `175 `174 -`173 `172 `171 `176 `186 `185 `184 `183 `182 `187 `178 `179 `180 `181 `99 `98 `97 `96 `107 `106 `105 `104 `103 `132 `131 - `130 `129 `128 `138 `137 `136 `135 `134 `144 `143 `142 `141 `140 `150 `149 `148 `147 `146 `152 `114 `113 `112 `111 `110 - `120 `119 `118 `117 `116 `121 `102 `64 `165 `164 `163 `162 `161 `166 `167 `168 `169 `170 `121 - -{{{{{{{{ Computing measure inafter auto_instantiate }}}}}} -compare 72 73= 1 -$ Measure decreased by 1 -{{{{{{{{ Computing measure before auto_instantiate }}}}}} -DANGEROUS EAT: h -DANGEROUS EAT: `64 -DANGEROUS EAT: `164 -INSTANTIATING CRITICAL TO EAT h -INSTANTIATING AND HOPING `64 -WARNING: using constant initialSpecialK -# INST: `64 := λ`198. [match(`63:666) `198:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190 -:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => `195:-666 | 57 => - `197:-666] ) ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: instantiate ||||| - -| measure=63 freshno = 197 -|> DISCRIMINATING SETS (deltas) -| 53 <> 55 <> 57 -| 52 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 38 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 -| 7 -| 6 <> 16 <> 56 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: `27:1 -|> CONVERGENT -| _: `74:2 [match(`33:3) [match(`64:1) `37:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190 -:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => `195:-666 | 57 => - `197:-666] `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904) with 9 => λ`198. [match(`38:-666 -) `198:-4611686018427387904 `44:-4611686018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-461168601842 -7387904 `40:-4611686018427387904 with 10 => λ`199. [match(`43:-666) `199:-4611686018427387904 `50:-4611686018427387904 ` -49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ`200. [ma -tch(`48:-666) `200:-4611686018427387904 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:- -4611686018427387904 `52:-4611686018427387904 with 12 => λ`201. [match(`53:-666) `201:-4611686018427387904 `79:-461168601 -8427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 with 20 = -> λ`202. [match(`75:-666) `202:-4611686018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-4611686018 -427387904 `123:-4611686018427387904 `122:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`202. [match(`76:-666) `2 -02:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387 -904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )] ) | 13 => λ`201. [match(`54:-666) `201:-4611686018 -427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-46116 -86018427387904 with 15 => λ`202. [match(`60:-666) `202:-4611686018427387904 `70:-4611686018427387904 `69:-46116860184273 -87904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | -6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] h:1) -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`198. [match(`17 -6:-666) `198:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -) with 26 => λ`198. [match(`100:-666) `198:-4611686018427387904 `107:-4611686018427387904 `106:-4611686018427387904 `105 -:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`199. [match(`106:-666) `199:-4611 -686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 -`128:-4611686018427387904 with 33 => λ`200. [match(`130:-666) `200:-4611686018427387904 `138:-4611686018427387904 `137:- -4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with 34 => λ`201. [mat -ch(`135:-666) `201:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611686018427387904 `1 -41:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`202. [match(`140:-666) `202:-4611686018427387904 `150:-46 -11686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:-461168601842738790 -4 with 37 => `152:-666] )] )] )] ) | 29 => λ`199. [match(`107:-666) `199:-4611686018427387904 `114:-4611686018427387904 -`113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 with 30 => λ`200 -. [match(`112:-666) `200:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387 -904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-666] `195:1) `121:1 -| _: _ -|> NUMERIC -| 0: `127:1 a:0 -| 1: `87:0 -| 2: `72:1 a:0 -| 3: `73:1 a:0 -| 4: `152:1 a:0 -| 5: `166:0 n:-4611686018427387904 m:-4611686018427387904 l:-4611686018427387904 k:-4611686018427387904 -| 6: 6 -| 7: `176:0 x:-4611686018427387904 w:-4611686018427387904 -| 8: `167:1 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-461 -1686018427387904 -| 9: `102:0 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904 -| 10: i:2 h:1 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 -| 11: `187:1 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 -| 12: 12 -| 13: h:1 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116 -86018427387904 -| 14: `178:0 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 -| 15: `193:0 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 -| 16: `195:1 u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387904 q:-461168601842 -7387904 -| 17: `71:2 `195:1 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 ` -66:-4611686018427387904 -| 18: `95:0 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 19: 6 -| 20: `195:1 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-46 -11686018427387904 -| 21: `78:1 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 22: a:0 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-46116 -86018427387904 -| 23: `85:1 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 -| 24: h:1 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-46116 -86018427387904 -| 25: `70:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-461168601 -8427387904 `89:-4611686018427387904 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: `38:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46116860 -18427387904 `96:-4611686018427387904 -| 28: `179:0 `104:-4611686018427387904 `103:-4611686018427387904 -| 29: `169:1 `107:-4611686018427387904 `106:-4611686018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `10 -3:-4611686018427387904 -| 30: `113:1 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 -| 31: `195:3 (λ`198. [match(f:1) `198:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-461168 -6018427387904 `90:-4611686018427387904 `89:-4611686018427387904 with 24 => λ`199. [match(`92:-666) `199:-461168601842738 -7904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-461168601 -8427387904 with 26 => λ`200. [match(`98:-666) `200:-4611686018427387904 `107:-4611686018427387904 `106:-4611686018427387 -904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`201. [match(`104:-666) `2 -01:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-461168601842 -7387904 `128:-4611686018427387904 with 33 => λ`202. [match(`128:-666) `202:-4611686018427387904 `138:-461168601842738790 -4 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with 34 => λ`2 -03. [match(`133:-666) `203:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-46116860184273 -87904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`204. [match(`138:-666) `204:-4611686018427387904 -`150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:-4611686018 -427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`201. [match(`105:-666) `201:-4611686018427387904 `114:-461168601842 -7387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 with 30 -=> λ`202. [match(`110:-666) `202:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118:-46116860 -18427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-666] ) | 25 -=> `95:-666] )) (`195:2 [match(e:3) [match(f:1) `174:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387 -904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`198. [match(`32:-666) `198:-4 -611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 ` -34:-4611686018427387904 with 9 => λ`199. [match(`37:-666) `199:-4611686018427387904 `44:-4611686018427387904 `43:-461168 -6018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`200. [match(`42:-6 -66) `200:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018 -427387904 `46:-4611686018427387904 with 11 => λ`201. [match(`47:-666) `201:-4611686018427387904 `56:-4611686018427387904 - `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`202. [ -match(`52:-666) `202:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76 -:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`203. [match(`74:-666) `203:-4611686018427387904 `126:-461168 -6018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 wi -th 32 => `127:-666] ) | 21 => λ`203. [match(`75:-666) `203:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018 -427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-66 -6] )] ) | 13 => λ`202. [match(`53:-666) `202:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61: --4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`203. [match(`59:-666) `203:-46116860 -18427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-461 -1686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => λ`198. - [match(`63:-666) `198:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-461168601842738790 -4 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => `195:-666 | 57 => `197:-666] )] `173: --4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904) with 46 => `176:-666 | 47 => λ`198. [match(`17 -6:-666) `198:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666] λ`198. i:2 h:1)) `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387904 `117 -:-4611686018427387904 `116:-4611686018427387904 -| 32: `126:2 `126:1 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 -| 33: `197:3 (λ`198. `198:2 (λ`199. [match(d:1) `199:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387 -904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`200. [match(`30:-666) `200:-4 -611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 ` -34:-4611686018427387904 with 9 => λ`201. [match(`35:-666) `201:-4611686018427387904 `44:-4611686018427387904 `43:-461168 -6018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`202. [match(`40:-6 -66) `202:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018 -427387904 `46:-4611686018427387904 with 11 => λ`203. [match(`45:-666) `203:-4611686018427387904 `56:-4611686018427387904 - `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`204. [ -match(`50:-666) `204:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76 -:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`205. [match(`72:-666) `205:-4611686018427387904 `126:-461168 -6018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 wi -th 32 => `127:-666] ) | 21 => λ`205. [match(`73:-666) `205:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018 -427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-66 -6] )] ) | 13 => λ`204. [match(`51:-666) `204:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61: --4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`205. [match(`57:-666) `205:-46116860 -18427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-461 -1686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => λ`200. - [match(`61:-666) `200:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-461168601842738790 -4 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => `195:-666 | 57 => `197:-666] )] ))) ( -λ`198. [match(`80:1) `198:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-461168601842738790 -4 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )) `132:-4611686018427387904 ` -131:-4611686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 `128:-4611686018427387904 -| 34: 34 -| 35: `180:0 `143:-4611686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 -| 36: `170:2 (λ`198. λ`199. λ`200. [match(b:1) `200:-4611686018427387904 `175:-4611686018427387904 `174:-461168601842738 -7904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`201. [ -match(`173:-666) `201:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 - `183:-4611686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => - `180:-666 | 51 => `181:-666] )) `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686 -018427387904 -| 37: `151:1 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `14 -6:-4611686018427387904 -| 38: `170:1 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611686018427387904 `15 -3:-4611686018427387904 -| 39: h:2 (λ`198. λ`199. [match(n:1) `199:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-46116860 -18427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`200. [match(s:-666) `200:-4611686018427387904 `26: --4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with 7 -=> `27:-666] ) | 16 => `71:-666 | 56 => `196:-666] )) `157:-4611686018427387904 `156:-4611686018427387904 `155:-46116860 -18427387904 `154:-4611686018427387904 `153:-4611686018427387904 -| 40: `134:-4611686018427387904 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611 -686018427387904 `153:-4611686018427387904 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: `165:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 44: `168:0 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 45: `181:0 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 46: y:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686 -018427387904 `171:-4611686018427387904 -| 47: `50:1 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: `105:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 50: `144:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 51: `164:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 52: i:2 h:1 `185:-4611686018427387904 `184:-4611686018427387904 `183:-4611686018427387904 `182:-4611686018427387904 -| 53: `62:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-4611686018427387904 `189:-46116 -86018427387904 `188:-4611686018427387904 -| 54: `192:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 55: `194:0 `191:-4611686018427387904 `190:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 -| 56: `191:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387 -904 q:-4611686018427387904 -| 57: `196:0 `190:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 -| -DANGEROUS EAT: h -DANGEROUS EAT: `164 -DANGEROUS EAT: `195 -dangerous_conv lenght:5 -`37 `192 `191 `190 `189 `188 `36 `35 `34 `74 `37 `192 `191 `190 `189 `188 `193 `195 `197 `36 `35 `34 `44 `43 `42 `41 `40 - `50 `49 `48 `47 `46 `56 `55 `54 `53 `52 `79 `78 `77 `76 `75 `126 `125 `124 `123 `122 `127 `86 `85 `84 `83 `82 `87 `88 ` -63 `62 `61 `60 `59 `70 `69 `68 `67 `66 `72 `73 `74 `151 h - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 `121 `100 `175 `174 `173 `172 `171 `176 `186 `185 `184 `183 `182 `187 `178 - `179 `180 `181 `99 `98 `97 `96 `107 `106 `105 `104 `103 `132 `131 `130 `129 `128 `138 `137 `136 `135 `134 `144 `143 `14 -2 `141 `140 `150 `149 `148 `147 `146 `152 `114 `113 `112 `111 `110 `120 `119 `118 `117 `116 `121 `102 `195 `121 - -# INST_IN_EAT: `166 := λ`198. λ`199. λ`200. λ`201. 5 -# INST_IN_EAT: `167 := λ`198. λ`199. λ`200. λ`201. λ`202. 8 -# INST_IN_EAT: `168 := λ`198. λ`199. λ`200. λ`201. 44 -# INST_IN_EAT: `169 := λ`198. λ`199. λ`200. λ`201. λ`202. 29 -# INST_IN_EAT: `170 := λ`198. λ`199. λ`200. λ`201. λ`202. 36 -# INST_IN_EAT: `194 := λ`198. λ`199. λ`200. λ`201. 55 -dangerous_conv lenght:5 -`37 `192 `191 `190 `189 `188 `36 `35 `34 `74 `37 `192 `191 `190 `189 `188 `193 `195 `197 `36 `35 `34 `44 `43 `42 `41 `40 - `50 `49 `48 `47 `46 `56 `55 `54 `53 `52 `79 `78 `77 `76 `75 `126 `125 `124 `123 `122 `127 `86 `85 `84 `83 `82 `87 `88 ` -63 `62 `61 `60 `59 `70 `69 `68 `67 `66 `72 `73 `74 `151 h - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 `121 `100 `175 `174 `173 `172 `171 `176 `186 `185 `184 `183 `182 `187 `178 - `179 `180 `181 `99 `98 `97 `96 `107 `106 `105 `104 `103 `132 `131 `130 `129 `128 `138 `137 `136 `135 `134 `144 `143 `14 -2 `141 `140 `150 `149 `148 `147 `146 `152 `114 `113 `112 `111 `110 `120 `119 `118 `117 `116 `121 `102 `195 `121 - ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: eat ||||| - -| measure=58 freshno = 197 -|> DISCRIMINATING SETS (deltas) -| 53 <> 55 <> 57 -| 52 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 -| 7 -| 6 <> 16 <> 56 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: `27:1 -|> CONVERGENT -| _: `74:2 [match(`33:3) [match(`64:1) `37:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190 -:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => `195:-666 | 57 => - `197:-666] `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904) with 9 => λ`198. [match(`38:-666 -) `198:-4611686018427387904 `44:-4611686018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-461168601842 -7387904 `40:-4611686018427387904 with 10 => λ`199. [match(`43:-666) `199:-4611686018427387904 `50:-4611686018427387904 ` -49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ`200. [ma -tch(`48:-666) `200:-4611686018427387904 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:- -4611686018427387904 `52:-4611686018427387904 with 12 => λ`201. [match(`53:-666) `201:-4611686018427387904 `79:-461168601 -8427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 with 20 = -> λ`202. [match(`75:-666) `202:-4611686018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-4611686018 -427387904 `123:-4611686018427387904 `122:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`202. [match(`76:-666) `2 -02:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387 -904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )] ) | 13 => λ`201. [match(`54:-666) `201:-4611686018 -427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-46116 -86018427387904 with 15 => λ`202. [match(`60:-666) `202:-4611686018427387904 `70:-4611686018427387904 `69:-46116860184273 -87904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | -6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] h:1) -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`198. [match(`17 -6:-666) `198:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -) with 26 => λ`198. [match(`100:-666) `198:-4611686018427387904 `107:-4611686018427387904 `106:-4611686018427387904 `105 -:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`199. [match(`106:-666) `199:-4611 -686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 -`128:-4611686018427387904 with 33 => λ`200. [match(`130:-666) `200:-4611686018427387904 `138:-4611686018427387904 `137:- -4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with 34 => λ`201. [mat -ch(`135:-666) `201:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611686018427387904 `1 -41:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`202. [match(`140:-666) `202:-4611686018427387904 `150:-46 -11686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:-461168601842738790 -4 with 37 => `152:-666] )] )] )] ) | 29 => λ`199. [match(`107:-666) `199:-4611686018427387904 `114:-4611686018427387904 -`113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 with 30 => λ`200 -. [match(`112:-666) `200:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387 -904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-666] `195:1) `121:1 -| _: _ -|> NUMERIC -| 0: `127:1 a:0 -| 1: `87:0 -| 2: `72:1 a:0 -| 3: `73:1 a:0 -| 4: `152:1 a:0 -| 5: 5 -| 6: 6 -| 7: `176:0 x:-4611686018427387904 w:-4611686018427387904 -| 8: 8 -| 9: `102:0 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904 -| 10: i:2 h:1 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 -| 11: `187:1 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 -| 12: 12 -| 13: h:1 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116 -86018427387904 -| 14: `178:0 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 -| 15: `193:0 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 -| 16: `195:1 u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387904 q:-461168601842 -7387904 -| 17: `71:2 `195:1 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 ` -66:-4611686018427387904 -| 18: `95:0 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 19: 6 -| 20: `195:1 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-46 -11686018427387904 -| 21: `78:1 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 22: a:0 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-46116 -86018427387904 -| 23: `85:1 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 -| 24: h:1 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-46116 -86018427387904 -| 25: `70:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-461168601 -8427387904 `89:-4611686018427387904 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: `38:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46116860 -18427387904 `96:-4611686018427387904 -| 28: `179:0 `104:-4611686018427387904 `103:-4611686018427387904 -| 29: 29 -| 30: `113:1 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 -| 31: `195:3 (λ`198. [match(f:1) `198:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-461168 -6018427387904 `90:-4611686018427387904 `89:-4611686018427387904 with 24 => λ`199. [match(`92:-666) `199:-461168601842738 -7904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-461168601 -8427387904 with 26 => λ`200. [match(`98:-666) `200:-4611686018427387904 `107:-4611686018427387904 `106:-4611686018427387 -904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`201. [match(`104:-666) `2 -01:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-461168601842 -7387904 `128:-4611686018427387904 with 33 => λ`202. [match(`128:-666) `202:-4611686018427387904 `138:-461168601842738790 -4 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with 34 => λ`2 -03. [match(`133:-666) `203:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-46116860184273 -87904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`204. [match(`138:-666) `204:-4611686018427387904 -`150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:-4611686018 -427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`201. [match(`105:-666) `201:-4611686018427387904 `114:-461168601842 -7387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 with 30 -=> λ`202. [match(`110:-666) `202:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118:-46116860 -18427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-666] ) | 25 -=> `95:-666] )) (`195:2 [match(e:3) [match(f:1) `174:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387 -904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`198. [match(`32:-666) `198:-4 -611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 ` -34:-4611686018427387904 with 9 => λ`199. [match(`37:-666) `199:-4611686018427387904 `44:-4611686018427387904 `43:-461168 -6018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`200. [match(`42:-6 -66) `200:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018 -427387904 `46:-4611686018427387904 with 11 => λ`201. [match(`47:-666) `201:-4611686018427387904 `56:-4611686018427387904 - `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`202. [ -match(`52:-666) `202:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76 -:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`203. [match(`74:-666) `203:-4611686018427387904 `126:-461168 -6018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 wi -th 32 => `127:-666] ) | 21 => λ`203. [match(`75:-666) `203:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018 -427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-66 -6] )] ) | 13 => λ`202. [match(`53:-666) `202:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61: --4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`203. [match(`59:-666) `203:-46116860 -18427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-461 -1686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => λ`198. - [match(`63:-666) `198:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-461168601842738790 -4 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => `195:-666 | 57 => `197:-666] )] `173: --4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904) with 46 => `176:-666 | 47 => λ`198. [match(`17 -6:-666) `198:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666] λ`198. i:2 h:1)) `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387904 `117 -:-4611686018427387904 `116:-4611686018427387904 -| 32: `126:2 `126:1 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 -| 33: `197:3 (λ`198. `198:2 (λ`199. [match(d:1) `199:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387 -904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`200. [match(`30:-666) `200:-4 -611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 ` -34:-4611686018427387904 with 9 => λ`201. [match(`35:-666) `201:-4611686018427387904 `44:-4611686018427387904 `43:-461168 -6018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`202. [match(`40:-6 -66) `202:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018 -427387904 `46:-4611686018427387904 with 11 => λ`203. [match(`45:-666) `203:-4611686018427387904 `56:-4611686018427387904 - `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`204. [ -match(`50:-666) `204:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76 -:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`205. [match(`72:-666) `205:-4611686018427387904 `126:-461168 -6018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 wi -th 32 => `127:-666] ) | 21 => λ`205. [match(`73:-666) `205:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018 -427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-66 -6] )] ) | 13 => λ`204. [match(`51:-666) `204:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61: --4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`205. [match(`57:-666) `205:-46116860 -18427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-461 -1686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => λ`200. - [match(`61:-666) `200:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-461168601842738790 -4 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => `195:-666 | 57 => `197:-666] )] ))) ( -λ`198. [match(`80:1) `198:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-461168601842738790 -4 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )) `132:-4611686018427387904 ` -131:-4611686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 `128:-4611686018427387904 -| 34: 34 -| 35: `180:0 `143:-4611686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 -| 36: 36 -| 37: `151:1 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `14 -6:-4611686018427387904 -| 38: 36 -| 39: h:2 (λ`198. λ`199. [match(n:1) `199:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-46116860 -18427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`200. [match(s:-666) `200:-4611686018427387904 `26: --4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with 7 -=> `27:-666] ) | 16 => `71:-666 | 56 => `196:-666] )) `157:-4611686018427387904 `156:-4611686018427387904 `155:-46116860 -18427387904 `154:-4611686018427387904 `153:-4611686018427387904 -| 40: `134:-4611686018427387904 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611 -686018427387904 `153:-4611686018427387904 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: `165:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 44: 44 -| 45: `181:0 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 46: y:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686 -018427387904 `171:-4611686018427387904 -| 47: `50:1 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: `105:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 50: `144:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 51: `164:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 52: i:2 h:1 `185:-4611686018427387904 `184:-4611686018427387904 `183:-4611686018427387904 `182:-4611686018427387904 -| 53: `62:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-4611686018427387904 `189:-46116 -86018427387904 `188:-4611686018427387904 -| 54: `192:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 55: 55 -| 56: `191:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387 -904 q:-4611686018427387904 -| 57: `196:0 `190:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 -| -{{{{{{{{ Computing measure inafter auto_instantiate }}}}}} -compare 58 72= 1 -$ Measure decreased by 1 -{{{{{{{{ Computing measure before auto_instantiate }}}}}} -DANGEROUS EAT: h -DANGEROUS EAT: `164 -DANGEROUS EAT: `195 -INSTANTIATING CRITICAL TO EAT h -INSTANTIATING AND HOPING `195 -@@@@ NEW INSTANTIATE PHASE (1) @@@@ -WARNING: using constant initialSpecialK -# INST: `195 := λ`207. [match(`194:666) `207:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `2 -00:-4611686018427387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 -=> `206:-666] ) ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: instantiate ||||| - -| measure=52 freshno = 206 -|> DISCRIMINATING SETS (deltas) -| 58 <> 59 <> 61 -| 53 <> 55 <> 57 -| 52 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 <> 60 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 -| 7 -| 6 <> 16 <> 56 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: `27:1 -|> CONVERGENT -| _: `74:2 [match(`33:3) [match(`64:1) `37:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190 -:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => λ`207. [match(`19 -4:-666) `207:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-46 -11686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => `206:-666] ) | 57 => `197:-66 -6] `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904) with 9 => λ`207. [match(`38:-666) `207:-4 -611686018427387904 `44:-4611686018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 ` -40:-4611686018427387904 with 10 => λ`208. [match(`43:-666) `208:-4611686018427387904 `50:-4611686018427387904 `49:-46116 -86018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ`209. [match(`48:- -666) `209:-4611686018427387904 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-461168601 -8427387904 `52:-4611686018427387904 with 12 => λ`210. [match(`53:-666) `210:-4611686018427387904 `79:-461168601842738790 -4 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`211. -[match(`75:-666) `211:-4611686018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-4611686018427387904 - `123:-4611686018427387904 `122:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`211. [match(`76:-666) `211:-46116 -86018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:- -4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )] ) | 13 => λ`210. [match(`54:-666) `210:-4611686018427387904 - `63:-4611686018427387904 `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-46116860184273 -87904 with 15 => λ`211. [match(`60:-666) `211:-4611686018427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68 -:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74: --666] ) | 36 => `151:-666] )] )] )] )] h:1) -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`207. [match(`17 -6:-666) `207:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -) with 26 => λ`207. [match(`100:-666) `207:-4611686018427387904 `107:-4611686018427387904 `106:-4611686018427387904 `105 -:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`208. [match(`106:-666) `208:-4611 -686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 -`128:-4611686018427387904 with 33 => λ`209. [match(`130:-666) `209:-4611686018427387904 `138:-4611686018427387904 `137:- -4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with 34 => λ`210. [mat -ch(`135:-666) `210:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611686018427387904 `1 -41:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`211. [match(`140:-666) `211:-4611686018427387904 `150:-46 -11686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:-461168601842738790 -4 with 37 => `152:-666] )] )] )] ) | 29 => λ`208. [match(`107:-666) `208:-4611686018427387904 `114:-4611686018427387904 -`113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 with 30 => λ`209 -. [match(`112:-666) `209:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387 -904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-666] λ`207. [match(` -194:1) `207:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-461 -1686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => `206:-666] )) `121:1 -| _: _ -|> NUMERIC -| 0: `127:1 a:0 -| 1: `87:0 -| 2: `72:1 a:0 -| 3: `73:1 a:0 -| 4: `152:1 a:0 -| 5: 5 -| 6: 6 -| 7: `176:0 x:-4611686018427387904 w:-4611686018427387904 -| 8: 8 -| 9: `102:0 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904 -| 10: i:2 h:1 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 -| 11: `187:1 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 -| 12: 12 -| 13: h:1 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116 -86018427387904 -| 14: `178:0 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 -| 15: `193:0 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 -| 16: `203:0 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387904 q:-4611686018427387904 -| 17: `71:2 (λ`207. [match(`194:1) `207:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4 -611686018427387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => `2 -06:-666] )) `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-461 -1686018427387904 -| 18: `95:0 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 19: 6 -| 20: `204:0 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 21: `78:1 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 22: a:0 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-46116 -86018427387904 -| 23: `85:1 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 -| 24: h:1 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-46116 -86018427387904 -| 25: `70:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-461168601 -8427387904 `89:-4611686018427387904 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: `38:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46116860 -18427387904 `96:-4611686018427387904 -| 28: `179:0 `104:-4611686018427387904 `103:-4611686018427387904 -| 29: 29 -| 30: `113:1 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 -| 31: `206:2 [match(`195:2) [match(e:3) [match(f:1) `174:-4611686018427387904 `32:-4611686018427387904 `31:-461168601842 -7387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`207. [match(`32:-666) `20 -7:-4611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 `35:-46116860184273879 -04 `34:-4611686018427387904 with 9 => λ`208. [match(`37:-666) `208:-4611686018427387904 `44:-4611686018427387904 `43:-46 -11686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`209. [match(`4 -2:-666) `209:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-461168 -6018427387904 `46:-4611686018427387904 with 11 => λ`210. [match(`47:-666) `210:-4611686018427387904 `56:-461168601842738 -7904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`21 -1. [match(`52:-666) `211:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 - `76:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`212. [match(`74:-666) `212:-4611686018427387904 `126:-46 -11686018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-461168601842738790 -4 with 32 => `127:-666] ) | 21 => λ`212. [match(`75:-666) `212:-4611686018427387904 `86:-4611686018427387904 `85:-461168 -6018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88 -:-666] )] ) | 13 => λ`211. [match(`53:-666) `211:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 -`61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`212. [match(`59:-666) `212:-4611 -686018427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66: --4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => λ` -207. [match(`63:-666) `207:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-46116860184273 -87904 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => λ`208. [match(`193:-666) `208:-46 -11686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-461168601842738790 -4 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => `206:-666] ) | 57 => `197:-666] )] `173:-4611 -686018427387904 `172:-4611686018427387904 `171:-4611686018427387904) with 46 => `176:-666 | 47 => λ`207. [match(`176:-66 -6) `207:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-4611686 -018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-666 | 5 -1 => `181:-666] λ`207. i:2 h:1 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-46116 -86018427387904 `198:-4611686018427387904) with 58 => `203:-666 | 59 => `204:-666 | 61 => `206:-666] ) `120:-461168601842 -7387904 `119:-4611686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 -| 32: `126:2 `126:1 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 -| 33: `197:3 (λ`207. `207:2 (λ`208. [match(d:1) `208:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387 -904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`209. [match(`30:-666) `209:-4 -611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 ` -34:-4611686018427387904 with 9 => λ`210. [match(`35:-666) `210:-4611686018427387904 `44:-4611686018427387904 `43:-461168 -6018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`211. [match(`40:-6 -66) `211:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018 -427387904 `46:-4611686018427387904 with 11 => λ`212. [match(`45:-666) `212:-4611686018427387904 `56:-4611686018427387904 - `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`213. [ -match(`50:-666) `213:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76 -:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`214. [match(`72:-666) `214:-4611686018427387904 `126:-461168 -6018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 wi -th 32 => `127:-666] ) | 21 => λ`214. [match(`73:-666) `214:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018 -427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-66 -6] )] ) | 13 => λ`213. [match(`51:-666) `213:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61: --4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`214. [match(`57:-666) `214:-46116860 -18427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-461 -1686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => λ`209. - [match(`61:-666) `209:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-461168601842738790 -4 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => λ`210. [match(`191:-666) `210:-461168 -6018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-4611686018427387904 `1 -98:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => `206:-666] ) | 57 => `197:-666] )] ))) (λ`207. [m -atch(`80:1) `207:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-46 -11686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )) `132:-4611686018427387904 `131:-4611 -686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 `128:-4611686018427387904 -| 34: 34 -| 35: `180:0 `143:-4611686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 -| 36: 36 -| 37: `151:1 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `14 -6:-4611686018427387904 -| 38: 36 -| 39: h:2 (λ`207. λ`208. [match(n:1) `208:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-46116860 -18427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`209. [match(s:-666) `209:-4611686018427387904 `26: --4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with 7 -=> `27:-666] ) | 16 => `71:-666 | 56 => `196:-666] )) `157:-4611686018427387904 `156:-4611686018427387904 `155:-46116860 -18427387904 `154:-4611686018427387904 `153:-4611686018427387904 -| 40: `134:-4611686018427387904 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611 -686018427387904 `153:-4611686018427387904 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: `165:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 44: 44 -| 45: `181:0 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 46: y:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686 -018427387904 `171:-4611686018427387904 -| 47: `50:1 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: `105:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 50: `144:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 51: `164:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 52: i:2 h:1 `185:-4611686018427387904 `184:-4611686018427387904 `183:-4611686018427387904 `182:-4611686018427387904 -| 53: `62:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-4611686018427387904 `189:-46116 -86018427387904 `188:-4611686018427387904 -| 54: `192:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 55: 55 -| 56: `191:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387 -904 q:-4611686018427387904 -| 57: `196:0 `190:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 -| 58: u:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-4611686 -018427387904 `198:-4611686018427387904 -| 59: `79:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-46116 -86018427387904 `198:-4611686018427387904 -| 60: `202:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-46116860 -18427387904 `89:-4611686018427387904 -| 61: `205:0 `201:-4611686018427387904 `200:-4611686018427387904 `199:-4611686018427387904 `198:-4611686018427387904 -| -DANGEROUS EAT: h -DANGEROUS EAT: `164 -dangerous_conv lenght:5 -`37 `192 `191 `190 `189 `188 `36 `35 `34 `74 `37 `192 `191 `190 `189 `188 `193 `202 `201 `200 `199 `198 `203 `204 `206 ` -197 `36 `35 `34 `44 `43 `42 `41 `40 `50 `49 `48 `47 `46 `56 `55 `54 `53 `52 `79 `78 `77 `76 `75 `126 `125 `124 `123 `122 - `127 `86 `85 `84 `83 `82 `87 `88 `63 `62 `61 `60 `59 `70 `69 `68 `67 `66 `72 `73 `74 `151 h - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - -# INST_IN_EAT: `95 := λ`207. λ`208. λ`209. λ`210. 18 -# INST_IN_EAT: `102 := λ`207. λ`208. λ`209. λ`210. 9 -# INST_IN_EAT: `105 := λ`207. λ`208. λ`209. λ`210. λ`211. 49 -# INST_IN_EAT: `113 := λ`207. λ`208. λ`209. 30 -# INST_IN_EAT: `134 := λ`207. λ`208. λ`209. λ`210. λ`211. 40 -# INST_IN_EAT: `144 := λ`207. λ`208. λ`209. λ`210. λ`211. 50 -# INST_IN_EAT: `152 := λ`207. 4 -# INST_IN_EAT: `205 := λ`207. λ`208. λ`209. λ`210. 61 -dangerous_conv lenght:5 -`37 `192 `191 `190 `189 `188 `36 `35 `34 `74 `37 `192 `191 `190 `189 `188 `193 `202 `201 `200 `199 `198 `203 `204 `206 ` -197 `36 `35 `34 `44 `43 `42 `41 `40 `50 `49 `48 `47 `46 `56 `55 `54 `53 `52 `79 `78 `77 `76 `75 `126 `125 `124 `123 `122 - `127 `86 `85 `84 `83 `82 `87 `88 `63 `62 `61 `60 `59 `70 `69 `68 `67 `66 `72 `73 `74 `151 h - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: eat ||||| - -| measure=50 freshno = 206 -|> DISCRIMINATING SETS (deltas) -| 58 <> 59 <> 61 -| 53 <> 55 <> 57 -| 52 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 <> 60 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 -| 7 -| 6 <> 16 <> 56 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: `27:1 -|> CONVERGENT -| _: `74:2 [match(`33:3) [match(`64:1) `37:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190 -:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => λ`207. [match(`19 -4:-666) `207:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-46 -11686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => `206:-666] ) | 57 => `197:-66 -6] `36:-4611686018427387904 `35:-4611686018427387904 `34:-4611686018427387904) with 9 => λ`207. [match(`38:-666) `207:-4 -611686018427387904 `44:-4611686018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 ` -40:-4611686018427387904 with 10 => λ`208. [match(`43:-666) `208:-4611686018427387904 `50:-4611686018427387904 `49:-46116 -86018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ`209. [match(`48:- -666) `209:-4611686018427387904 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-461168601 -8427387904 `52:-4611686018427387904 with 12 => λ`210. [match(`53:-666) `210:-4611686018427387904 `79:-461168601842738790 -4 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`211. -[match(`75:-666) `211:-4611686018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-4611686018427387904 - `123:-4611686018427387904 `122:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`211. [match(`76:-666) `211:-46116 -86018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:- -4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )] ) | 13 => λ`210. [match(`54:-666) `210:-4611686018427387904 - `63:-4611686018427387904 `62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-46116860184273 -87904 with 15 => λ`211. [match(`60:-666) `211:-4611686018427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68 -:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74: --666] ) | 36 => `151:-666] )] )] )] )] h:1) -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`207. [match(`17 -6:-666) `207:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -) with 26 => λ`207. [match(`100:-666) `207:-4611686018427387904 `107:-4611686018427387904 `106:-4611686018427387904 `105 -:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`208. [match(`106:-666) `208:-4611 -686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 -`128:-4611686018427387904 with 33 => λ`209. [match(`130:-666) `209:-4611686018427387904 `138:-4611686018427387904 `137:- -4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with 34 => λ`210. [mat -ch(`135:-666) `210:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611686018427387904 `1 -41:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`211. [match(`140:-666) `211:-4611686018427387904 `150:-46 -11686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:-461168601842738790 -4 with 37 => `152:-666] )] )] )] ) | 29 => λ`208. [match(`107:-666) `208:-4611686018427387904 `114:-4611686018427387904 -`113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-4611686018427387904 with 30 => λ`209 -. [match(`112:-666) `209:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387 -904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-666] λ`207. [match(` -194:1) `207:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-461 -1686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => `206:-666] )) `121:1 -| _: _ -|> NUMERIC -| 0: `127:1 a:0 -| 1: `87:0 -| 2: `72:1 a:0 -| 3: `73:1 a:0 -| 4: 4 -| 5: 5 -| 6: 6 -| 7: `176:0 x:-4611686018427387904 w:-4611686018427387904 -| 8: 8 -| 9: 9 -| 10: i:2 h:1 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 -| 11: `187:1 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 -| 12: 12 -| 13: h:1 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116 -86018427387904 -| 14: `178:0 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 -| 15: `193:0 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 -| 16: `203:0 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387904 q:-4611686018427387904 -| 17: `71:2 (λ`207. [match(`194:1) `207:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4 -611686018427387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => `2 -06:-666] )) `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-461 -1686018427387904 -| 18: 18 -| 19: 6 -| 20: `204:0 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 21: `78:1 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 22: a:0 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-46116 -86018427387904 -| 23: `85:1 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 -| 24: h:1 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-46116 -86018427387904 -| 25: `70:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-461168601 -8427387904 `89:-4611686018427387904 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: `38:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46116860 -18427387904 `96:-4611686018427387904 -| 28: `179:0 `104:-4611686018427387904 `103:-4611686018427387904 -| 29: 29 -| 30: 30 -| 31: `206:2 [match(`195:2) [match(e:3) [match(f:1) `174:-4611686018427387904 `32:-4611686018427387904 `31:-461168601842 -7387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`207. [match(`32:-666) `20 -7:-4611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 `35:-46116860184273879 -04 `34:-4611686018427387904 with 9 => λ`208. [match(`37:-666) `208:-4611686018427387904 `44:-4611686018427387904 `43:-46 -11686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`209. [match(`4 -2:-666) `209:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-461168 -6018427387904 `46:-4611686018427387904 with 11 => λ`210. [match(`47:-666) `210:-4611686018427387904 `56:-461168601842738 -7904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`21 -1. [match(`52:-666) `211:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 - `76:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`212. [match(`74:-666) `212:-4611686018427387904 `126:-46 -11686018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-461168601842738790 -4 with 32 => `127:-666] ) | 21 => λ`212. [match(`75:-666) `212:-4611686018427387904 `86:-4611686018427387904 `85:-461168 -6018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88 -:-666] )] ) | 13 => λ`211. [match(`53:-666) `211:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 -`61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`212. [match(`59:-666) `212:-4611 -686018427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66: --4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => λ` -207. [match(`63:-666) `207:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-46116860184273 -87904 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => λ`208. [match(`193:-666) `208:-46 -11686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-461168601842738790 -4 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => `206:-666] ) | 57 => `197:-666] )] `173:-4611 -686018427387904 `172:-4611686018427387904 `171:-4611686018427387904) with 46 => `176:-666 | 47 => λ`207. [match(`176:-66 -6) `207:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-4611686 -018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-666 | 5 -1 => `181:-666] λ`207. i:2 h:1 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-46116 -86018427387904 `198:-4611686018427387904) with 58 => `203:-666 | 59 => `204:-666 | 61 => `206:-666] ) `120:-461168601842 -7387904 `119:-4611686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 -| 32: `126:2 `126:1 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 -| 33: `197:3 (λ`207. `207:2 (λ`208. [match(d:1) `208:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387 -904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`209. [match(`30:-666) `209:-4 -611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 ` -34:-4611686018427387904 with 9 => λ`210. [match(`35:-666) `210:-4611686018427387904 `44:-4611686018427387904 `43:-461168 -6018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`211. [match(`40:-6 -66) `211:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018 -427387904 `46:-4611686018427387904 with 11 => λ`212. [match(`45:-666) `212:-4611686018427387904 `56:-4611686018427387904 - `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`213. [ -match(`50:-666) `213:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76 -:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`214. [match(`72:-666) `214:-4611686018427387904 `126:-461168 -6018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 wi -th 32 => `127:-666] ) | 21 => λ`214. [match(`73:-666) `214:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018 -427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-66 -6] )] ) | 13 => λ`213. [match(`51:-666) `213:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61: --4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`214. [match(`57:-666) `214:-46116860 -18427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-461 -1686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => λ`209. - [match(`61:-666) `209:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-461168601842738790 -4 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => λ`210. [match(`191:-666) `210:-461168 -6018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-4611686018427387904 `1 -98:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => `206:-666] ) | 57 => `197:-666] )] ))) (λ`207. [m -atch(`80:1) `207:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-46 -11686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )) `132:-4611686018427387904 `131:-4611 -686018427387904 `130:-4611686018427387904 `129:-4611686018427387904 `128:-4611686018427387904 -| 34: 34 -| 35: `180:0 `143:-4611686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 -| 36: 36 -| 37: `151:1 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `14 -6:-4611686018427387904 -| 38: 36 -| 39: h:2 (λ`207. λ`208. [match(n:1) `208:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-46116860 -18427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`209. [match(s:-666) `209:-4611686018427387904 `26: --4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with 7 -=> `27:-666] ) | 16 => `71:-666 | 56 => `196:-666] )) `157:-4611686018427387904 `156:-4611686018427387904 `155:-46116860 -18427387904 `154:-4611686018427387904 `153:-4611686018427387904 -| 40: 40 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: `165:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 44: 44 -| 45: `181:0 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 46: y:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686 -018427387904 `171:-4611686018427387904 -| 47: `50:1 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: 49 -| 50: 50 -| 51: `164:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 52: i:2 h:1 `185:-4611686018427387904 `184:-4611686018427387904 `183:-4611686018427387904 `182:-4611686018427387904 -| 53: `62:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-4611686018427387904 `189:-46116 -86018427387904 `188:-4611686018427387904 -| 54: `192:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 55: 55 -| 56: `191:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387 -904 q:-4611686018427387904 -| 57: `196:0 `190:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 -| 58: u:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-4611686 -018427387904 `198:-4611686018427387904 -| 59: `79:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-46116 -86018427387904 `198:-4611686018427387904 -| 60: `202:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-46116860 -18427387904 `89:-4611686018427387904 -| 61: 61 -| -{{{{{{{{ Computing measure inafter auto_instantiate }}}}}} -compare 50 58= 1 -$ Measure decreased by 1 -{{{{{{{{ Computing measure before auto_instantiate }}}}}} -DANGEROUS EAT: h -DANGEROUS EAT: `164 -INSTANTIATING CRITICAL TO EAT h -INSTANTIATING AND HOPING `206 -WARNING: using constant initialSpecialK -# INST: `206 := λ`216. [match(`205:666) `216:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `2 -09:-4611686018427387904 `208:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: instantiate ||||| - -| measure=49 freshno = 215 -|> DISCRIMINATING SETS (deltas) -| 65 -| 58 <> 59 <> 61 <> 64 -| 53 <> 55 <> 57 -| 52 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 <> 63 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 <> 60 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 <> 62 -| 7 -| 6 <> 16 <> 56 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: `27:1 -|> CONVERGENT -| _: `74:2 [match(`33:3) [match(`64:1) `37:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190 -:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => λ`216. [match(`19 -4:-666) `216:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-46 -11686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ`217. [match(`204:-666) `217 -:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `208:-46116860184273 -87904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 => `214:-666] ) | 57 => `197:-666] `36:-4611686018427387904 - `35:-4611686018427387904 `34:-4611686018427387904) with 9 => λ`216. [match(`38:-666) `216:-4611686018427387904 `44:-461 -1686018427387904 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 wit -h 10 => λ`217. [match(`43:-666) `217:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686 -018427387904 `47:-4611686018427387904 `46:-4611686018427387904 with 11 => λ`218. [match(`48:-666) `218:-4611686018427387 -904 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116860184 -27387904 with 12 => λ`219. [match(`53:-666) `219:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 -`77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`220. [match(`75:-666) `220:-4611 -686018427387904 `126:-4611686018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 -`122:-4611686018427387904 with 32 => `127:-666] ) | 21 => λ`220. [match(`76:-666) `220:-4611686018427387904 `86:-4611686 -018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 - => `87:-666 | 23 => `88:-666] )] ) | 13 => λ`219. [match(`54:-666) `219:-4611686018427387904 `63:-4611686018427387904 ` -62:-4611686018427387904 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`220. [ma -tch(`60:-666) `220:-4611686018427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:- -4611686018427387904 `66:-4611686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] -)] )] )] )] h:1) -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`216. [match(`17 -6:-666) `216:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 52 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666 | 63 => `213:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4 -611686018427387904) with 26 => λ`216. [match(`100:-666) `216:-4611686018427387904 `107:-4611686018427387904 `106:-461168 -6018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`217. [match(`10 -6:-666) `217:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-46 -11686018427387904 `128:-4611686018427387904 with 33 => λ`218. [match(`130:-666) `218:-4611686018427387904 `138:-46116860 -18427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with - 34 => λ`219. [match(`135:-666) `219:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611 -686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`220. [match(`140:-666) `220:-4611686018 -427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:- -4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`217. [match(`107:-666) `217:-4611686018427387904 `114:-46 -11686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-461168601842738790 -4 with 30 => λ`218. [match(`112:-666) `218:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118 -:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-66 -6] λ`216. [match(`194:1) `216:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-46116860184 -27387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ`217. [matc -h(`204:-666) `217:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `20 -8:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 => `214:-666] )) `121:1 -| _: _ -|> NUMERIC -| 0: `127:1 a:0 -| 1: `87:0 -| 2: `72:1 a:0 -| 3: `73:1 a:0 -| 4: 4 -| 5: 5 -| 6: 6 -| 7: `176:0 x:-4611686018427387904 w:-4611686018427387904 -| 8: 8 -| 9: 9 -| 10: i:2 h:1 `43:-4611686018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 -| 11: `187:1 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018427387904 `46:-4611686018427387904 -| 12: 12 -| 13: h:1 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116 -86018427387904 -| 14: `178:0 `31:-4611686018427387904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 -| 15: `193:0 `61:-4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 -| 16: `203:0 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387904 q:-4611686018427387904 -| 17: `71:2 (λ`216. [match(`194:1) `216:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4 -611686018427387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ` -217. [match(`204:-666) `217:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427 -387904 `208:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 => `214:-666] )) `70:-4611686018 -427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 18: 18 -| 19: 6 -| 20: `204:0 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 21: `78:1 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 22: a:0 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-46116 -86018427387904 -| 23: `85:1 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 -| 24: h:1 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-46116 -86018427387904 -| 25: `70:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-461168601 -8427387904 `89:-4611686018427387904 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: `38:-4611686018427387904 `100:-4611686018427387904 `99:-4611686018427387904 `98:-4611686018427387904 `97:-46116860 -18427387904 `96:-4611686018427387904 -| 28: `179:0 `104:-4611686018427387904 `103:-4611686018427387904 -| 29: 29 -| 30: 30 -| 31: `215:1 `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `11 -6:-4611686018427387904 -| 32: `126:2 `126:1 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 -| 33: `197:3 (λ`216. `216:2 (λ`217. [match(d:1) `217:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387 -904 `30:-4611686018427387904 `29:-4611686018427387904 `28:-4611686018427387904 with 8 => λ`218. [match(`30:-666) `218:-4 -611686018427387904 `38:-4611686018427387904 `37:-4611686018427387904 `36:-4611686018427387904 `35:-4611686018427387904 ` -34:-4611686018427387904 with 9 => λ`219. [match(`35:-666) `219:-4611686018427387904 `44:-4611686018427387904 `43:-461168 -6018427387904 `42:-4611686018427387904 `41:-4611686018427387904 `40:-4611686018427387904 with 10 => λ`220. [match(`40:-6 -66) `220:-4611686018427387904 `50:-4611686018427387904 `49:-4611686018427387904 `48:-4611686018427387904 `47:-4611686018 -427387904 `46:-4611686018427387904 with 11 => λ`221. [match(`45:-666) `221:-4611686018427387904 `56:-4611686018427387904 - `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 with 12 => λ`222. [ -match(`50:-666) `222:-4611686018427387904 `79:-4611686018427387904 `78:-4611686018427387904 `77:-4611686018427387904 `76 -:-4611686018427387904 `75:-4611686018427387904 with 20 => λ`223. [match(`72:-666) `223:-4611686018427387904 `126:-461168 -6018427387904 `125:-4611686018427387904 `124:-4611686018427387904 `123:-4611686018427387904 `122:-4611686018427387904 wi -th 32 => `127:-666] ) | 21 => λ`223. [match(`73:-666) `223:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018 -427387904 `84:-4611686018427387904 `83:-4611686018427387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-66 -6] )] ) | 13 => λ`222. [match(`51:-666) `222:-4611686018427387904 `63:-4611686018427387904 `62:-4611686018427387904 `61: --4611686018427387904 `60:-4611686018427387904 `59:-4611686018427387904 with 15 => λ`223. [match(`57:-666) `223:-46116860 -18427387904 `70:-4611686018427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-461 -1686018427387904 with 17 => `72:-666 | 18 => `73:-666 | 6 => `74:-666] ) | 36 => `151:-666] )] )] )] )] ) | 14 => λ`218. - [match(`61:-666) `218:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-461168601842738790 -4 `189:-4611686018427387904 `188:-4611686018427387904 with 53 => `193:-666 | 55 => λ`219. [match(`191:-666) `219:-461168 -6018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-4611686018427387904 `1 -98:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ`220. [match(`201:-666) `220:-461168601842738790 -4 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `208:-4611686018427387904 `207:-46116860 -18427387904 with 65 => `215:-666] ) | 64 => `214:-666] ) | 57 => `197:-666] ) | 62 => `212:-666] ))) (λ`216. [match(`80: -1) `216:-4611686018427387904 `86:-4611686018427387904 `85:-4611686018427387904 `84:-4611686018427387904 `83:-46116860184 -27387904 `82:-4611686018427387904 with 22 => `87:-666 | 23 => `88:-666] )) `132:-4611686018427387904 `131:-4611686018427 -387904 `130:-4611686018427387904 `129:-4611686018427387904 `128:-4611686018427387904 -| 34: 34 -| 35: `180:0 `143:-4611686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 -| 36: 36 -| 37: `151:1 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `14 -6:-4611686018427387904 -| 38: 36 -| 39: h:2 (λ`216. λ`217. [match(n:1) `217:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-46116860 -18427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`218. [match(s:-666) `218:-4611686018427387904 `26: --4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with 7 -=> `27:-666] ) | 16 => `71:-666 | 56 => `196:-666] )) `157:-4611686018427387904 `156:-4611686018427387904 `155:-46116860 -18427387904 `154:-4611686018427387904 `153:-4611686018427387904 -| 40: 40 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: `165:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 44: 44 -| 45: `181:0 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 46: y:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686 -018427387904 `171:-4611686018427387904 -| 47: `50:1 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: 49 -| 50: 50 -| 51: `164:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 52: i:2 h:1 `185:-4611686018427387904 `184:-4611686018427387904 `183:-4611686018427387904 `182:-4611686018427387904 -| 53: `62:-4611686018427387904 `192:-4611686018427387904 `191:-4611686018427387904 `190:-4611686018427387904 `189:-46116 -86018427387904 `188:-4611686018427387904 -| 54: `192:-4611686018427387904 `165:-4611686018427387904 `164:-4611686018427387904 `163:-4611686018427387904 `162:-4611 -686018427387904 `161:-4611686018427387904 -| 55: 55 -| 56: `191:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387 -904 q:-4611686018427387904 -| 57: `196:0 `190:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 -| 58: u:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-4611686 -018427387904 `198:-4611686018427387904 -| 59: `79:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-46116 -86018427387904 `198:-4611686018427387904 -| 60: `202:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-46116860 -18427387904 `89:-4611686018427387904 -| 61: 61 -| 62: `174:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-46116860 -18427387904 `28:-4611686018427387904 -| 63: `212:0 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 -| 64: `213:2 (λ`216. i:2 h:1) `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-461168 -6018427387904 `198:-4611686018427387904 -| 65: `214:1 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `208:-4611686018427387904 `20 -7:-4611686018427387904 -| -DANGEROUS EAT: h -DANGEROUS EAT: `164 -dangerous_inert_conv: ar=4 k=`100 listlenargs=9 -dangerous_conv lenght:5 - - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - -dangerous_conv lenght:5 - - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - -# INST_IN_EAT: a := λ`216. λ`217. λ`218. λ`219. λ`220. 22 -# INST_IN_EAT: i := λ`216. λ`217. λ`218. λ`219. λ`220. 10 -# INST_IN_EAT: `38 := λ`216. λ`217. λ`218. λ`219. λ`220. 27 -# INST_IN_EAT: `50 := λ`216. λ`217. λ`218. λ`219. 47 -# INST_IN_EAT: `62 := λ`216. λ`217. λ`218. λ`219. λ`220. 53 -# INST_IN_EAT: `72 := λ`216. 2 -# INST_IN_EAT: `73 := λ`216. 3 -# INST_IN_EAT: `79 := λ`216. λ`217. λ`218. λ`219. λ`220. 59 -# INST_IN_EAT: `85 := λ`216. λ`217. λ`218. 23 -# INST_IN_EAT: `87 := 1 -# INST_IN_EAT: `126 := λ`216. λ`217. λ`218. λ`219. 32 -# INST_IN_EAT: `127 := λ`216. 0 -# INST_IN_EAT: `151 := λ`216. λ`217. λ`218. λ`219. λ`220. 37 -# INST_IN_EAT: `165 := λ`216. λ`217. λ`218. λ`219. λ`220. 43 -# INST_IN_EAT: `176 := λ`216. λ`217. 7 -# INST_IN_EAT: `178 := λ`216. λ`217. λ`218. λ`219. 14 -# INST_IN_EAT: `179 := λ`216. λ`217. 28 -# INST_IN_EAT: `180 := λ`216. λ`217. λ`218. λ`219. 35 -# INST_IN_EAT: `181 := λ`216. λ`217. λ`218. 45 -# INST_IN_EAT: `187 := λ`216. λ`217. λ`218. λ`219. 11 -# INST_IN_EAT: `191 := λ`216. λ`217. λ`218. λ`219. λ`220. 56 -# INST_IN_EAT: `192 := λ`216. λ`217. λ`218. λ`219. λ`220. 54 -# INST_IN_EAT: `193 := λ`216. λ`217. λ`218. 15 -# INST_IN_EAT: `197 := λ`216. λ`217. λ`218. λ`219. λ`220. λ`221. λ`222. 33 -# INST_IN_EAT: `212 := λ`216. λ`217. λ`218. 63 -# INST_IN_EAT: `213 := λ`216. λ`217. λ`218. λ`219. λ`220. λ`221. 64 -dangerous_conv lenght:5 - - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - -FREEZING `74 ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: eat ||||| - -| measure=18 freshno = 215 -|> DISCRIMINATING SETS (deltas) -| 65 -| 58 <> 59 <> 61 <> 64 -| 53 <> 55 <> 57 -| 10 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 <> 63 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 <> 60 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 <> 62 -| 7 -| 6 <> 16 <> 56 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: `27:1 -|> CONVERGENT -| _: _ -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`216. [match(`17 -6:-666) `216:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 10 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666 | 63 => `213:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4 -611686018427387904) with 26 => λ`216. [match(`100:-666) `216:-4611686018427387904 `107:-4611686018427387904 `106:-461168 -6018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`217. [match(`10 -6:-666) `217:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-46 -11686018427387904 `128:-4611686018427387904 with 33 => λ`218. [match(`130:-666) `218:-4611686018427387904 `138:-46116860 -18427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with - 34 => λ`219. [match(`135:-666) `219:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611 -686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`220. [match(`140:-666) `220:-4611686018 -427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:- -4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`217. [match(`107:-666) `217:-4611686018427387904 `114:-46 -11686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-461168601842738790 -4 with 30 => λ`218. [match(`112:-666) `218:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118 -:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-66 -6] λ`216. [match(`194:1) `216:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-46116860184 -27387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ`217. [matc -h(`204:-666) `217:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `20 -8:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 => `214:-666] )) `121:1 -| _: _ -|> NUMERIC -| 0: 0 -| 1: 1 -| 2: 2 -| 3: 3 -| 4: 4 -| 5: 5 -| 6: 6 -| 7: 7 -| 8: 8 -| 9: 9 -| 10: 10 -| 11: 11 -| 12: 12 -| 13: h:1 `56:-4611686018427387904 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-46116 -86018427387904 -| 14: 14 -| 15: 15 -| 16: `203:0 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387904 q:-4611686018427387904 -| 17: `71:2 (λ`216. [match(`194:1) `216:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4 -611686018427387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ` -217. [match(`204:-666) `217:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427 -387904 `208:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 => `214:-666] )) `70:-4611686018 -427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 18: 18 -| 19: 6 -| 20: `204:0 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 21: `78:1 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 22: 22 -| 23: 23 -| 24: h:1 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-46116 -86018427387904 -| 25: `70:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-461168601 -8427387904 `89:-4611686018427387904 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: 27 -| 28: 28 -| 29: 29 -| 30: 30 -| 31: `215:1 `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `11 -6:-4611686018427387904 -| 32: 32 -| 33: 33 -| 34: 34 -| 35: 35 -| 36: 36 -| 37: 37 -| 38: 36 -| 39: h:2 (λ`216. λ`217. [match(n:1) `217:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-46116860 -18427387904 r:-4611686018427387904 q:-4611686018427387904 with 6 => λ`218. [match(s:-666) `218:-4611686018427387904 `26: --4611686018427387904 z:-4611686018427387904 y:-4611686018427387904 x:-4611686018427387904 w:-4611686018427387904 with 7 -=> `27:-666] ) | 16 => `71:-666 | 56 => `196:-666] )) `157:-4611686018427387904 `156:-4611686018427387904 `155:-46116860 -18427387904 `154:-4611686018427387904 `153:-4611686018427387904 -| 40: 40 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: 43 -| 44: 44 -| 45: 45 -| 46: y:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686 -018427387904 `171:-4611686018427387904 -| 47: 47 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: 49 -| 50: 50 -| 51: `164:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 52: 10 -| 53: 53 -| 54: 54 -| 55: 55 -| 56: 56 -| 57: `196:0 `190:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 -| 58: u:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-4611686 -018427387904 `198:-4611686018427387904 -| 59: 59 -| 60: `202:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-46116860 -18427387904 `89:-4611686018427387904 -| 61: 61 -| 62: `174:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-46116860 -18427387904 `28:-4611686018427387904 -| 63: 63 -| 64: 64 -| 65: `214:1 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `208:-4611686018427387904 `20 -7:-4611686018427387904 -| -{{{{{{{{ Computing measure inafter auto_instantiate }}}}}} -compare 18 50= 1 -$ Measure decreased by 1 -{{{{{{{{ Computing measure before auto_instantiate }}}}}} -DANGEROUS EAT: h -DANGEROUS EAT: `164 -INSTANTIATING CRITICAL TO EAT h -INSTANTIATING AND HOPING h -WARNING: using constant initialSpecialK -# INST: h := λ`225. [match(g:666) `225:-4611686018427387904 `220:-4611686018427387904 `219:-4611686018427387904 `218:-46 -11686018427387904 `217:-4611686018427387904 `216:-4611686018427387904 with 66 => `221:-666 | 67 => `222:-666 | 69 => `22 -4:-666] ) ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: instantiate ||||| - -| measure=15 freshno = 224 -|> DISCRIMINATING SETS (deltas) -| 66 <> 67 <> 69 -| 65 -| 58 <> 59 <> 61 <> 64 -| 53 <> 55 <> 57 -| 10 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 <> 63 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 <> 60 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 <> 62 -| 7 -| 6 <> 16 <> 56 <> 68 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: `27:1 -|> CONVERGENT -| _: _ -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`225. [match(`17 -6:-666) `225:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 10 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666 | 63 => `213:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4 -611686018427387904) with 26 => λ`225. [match(`100:-666) `225:-4611686018427387904 `107:-4611686018427387904 `106:-461168 -6018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`226. [match(`10 -6:-666) `226:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-46 -11686018427387904 `128:-4611686018427387904 with 33 => λ`227. [match(`130:-666) `227:-4611686018427387904 `138:-46116860 -18427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with - 34 => λ`228. [match(`135:-666) `228:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611 -686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`229. [match(`140:-666) `229:-4611686018 -427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:- -4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`226. [match(`107:-666) `226:-4611686018427387904 `114:-46 -11686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-461168601842738790 -4 with 30 => λ`227. [match(`112:-666) `227:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118 -:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-66 -6] λ`225. [match(`194:1) `225:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-46116860184 -27387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ`226. [matc -h(`204:-666) `226:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `20 -8:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 => `214:-666] )) `121:1 -| _: _ -|> NUMERIC -| 0: 0 -| 1: 1 -| 2: 2 -| 3: 3 -| 4: 4 -| 5: 5 -| 6: 6 -| 7: 7 -| 8: 8 -| 9: 9 -| 10: 10 -| 11: 11 -| 12: 12 -| 13: `221:0 `55:-4611686018427387904 `54:-4611686018427387904 `53:-4611686018427387904 `52:-4611686018427387904 -| 14: 14 -| 15: 15 -| 16: `203:0 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387904 q:-4611686018427387904 -| 17: `71:2 (λ`225. [match(`194:1) `225:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4 -611686018427387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ` -226. [match(`204:-666) `226:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427 -387904 `208:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 => `214:-666] )) `70:-4611686018 -427387904 `69:-4611686018427387904 `68:-4611686018427387904 `67:-4611686018427387904 `66:-4611686018427387904 -| 18: 18 -| 19: 6 -| 20: `204:0 `78:-4611686018427387904 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 21: `78:1 `77:-4611686018427387904 `76:-4611686018427387904 `75:-4611686018427387904 -| 22: 22 -| 23: 23 -| 24: `222:0 `92:-4611686018427387904 `91:-4611686018427387904 `90:-4611686018427387904 `89:-4611686018427387904 -| 25: `70:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-461168601 -8427387904 `89:-4611686018427387904 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: 27 -| 28: 28 -| 29: 29 -| 30: 30 -| 31: `215:1 `120:-4611686018427387904 `119:-4611686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `11 -6:-4611686018427387904 -| 32: 32 -| 33: 33 -| 34: 34 -| 35: 35 -| 36: 36 -| 37: 37 -| 38: 36 -| 39: `224:1 `157:-4611686018427387904 `156:-4611686018427387904 `155:-4611686018427387904 `154:-4611686018427387904 `15 -3:-4611686018427387904 -| 40: 40 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: 43 -| 44: 44 -| 45: 45 -| 46: y:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686 -018427387904 `171:-4611686018427387904 -| 47: 47 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: 49 -| 50: 50 -| 51: `164:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 52: 10 -| 53: 53 -| 54: 54 -| 55: 55 -| 56: 56 -| 57: `196:0 `190:-4611686018427387904 `189:-4611686018427387904 `188:-4611686018427387904 -| 58: u:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-4611686018427387904 `199:-4611686 -018427387904 `198:-4611686018427387904 -| 59: 59 -| 60: `202:-4611686018427387904 `93:-4611686018427387904 `92:-4611686018427387904 `91:-4611686018427387904 `90:-46116860 -18427387904 `89:-4611686018427387904 -| 61: 61 -| 62: `174:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-46116860 -18427387904 `28:-4611686018427387904 -| 63: 63 -| 64: 64 -| 65: `214:1 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `208:-4611686018427387904 `20 -7:-4611686018427387904 -| 66: `56:-4611686018427387904 `220:-4611686018427387904 `219:-4611686018427387904 `218:-4611686018427387904 `217:-46116 -86018427387904 `216:-4611686018427387904 -| 67: `93:-4611686018427387904 `220:-4611686018427387904 `219:-4611686018427387904 `218:-4611686018427387904 `217:-46116 -86018427387904 `216:-4611686018427387904 -| 68: `219:-4611686018427387904 u:-4611686018427387904 t:-4611686018427387904 s:-4611686018427387904 r:-4611686018427387 -904 q:-4611686018427387904 -| 69: `223:0 `218:-4611686018427387904 `217:-4611686018427387904 `216:-4611686018427387904 -| -DANGEROUS EAT: `164 -dangerous_inert_conv: ar=4 k=`100 listlenargs=9 -dangerous_conv lenght:5 - - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - -dangerous_conv lenght:5 - - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - -# INST_IN_EAT: u := λ`225. λ`226. λ`227. λ`228. λ`229. 58 -# INST_IN_EAT: y := λ`225. λ`226. λ`227. λ`228. λ`229. 46 -# INST_IN_EAT: `56 := λ`225. λ`226. λ`227. λ`228. λ`229. 66 -# INST_IN_EAT: `70 := λ`225. λ`226. λ`227. λ`228. λ`229. 25 -# INST_IN_EAT: `71 := λ`225. λ`226. λ`227. λ`228. λ`229. λ`230. 17 -# INST_IN_EAT: `78 := λ`225. λ`226. λ`227. 21 -# INST_IN_EAT: `93 := λ`225. λ`226. λ`227. λ`228. λ`229. 67 -# INST_IN_EAT: `196 := λ`225. λ`226. λ`227. 57 -# INST_IN_EAT: `202 := λ`225. λ`226. λ`227. λ`228. λ`229. 60 -# INST_IN_EAT: `203 := λ`225. λ`226. λ`227. λ`228. 16 -# INST_IN_EAT: `204 := λ`225. λ`226. λ`227. λ`228. 20 -# INST_IN_EAT: `214 := λ`225. λ`226. λ`227. λ`228. λ`229. 65 -# INST_IN_EAT: `215 := λ`225. λ`226. λ`227. λ`228. λ`229. 31 -# INST_IN_EAT: `219 := λ`225. λ`226. λ`227. λ`228. λ`229. 68 -# INST_IN_EAT: `221 := λ`225. λ`226. λ`227. λ`228. 13 -# INST_IN_EAT: `222 := λ`225. λ`226. λ`227. λ`228. 24 -# INST_IN_EAT: `223 := λ`225. λ`226. λ`227. 69 -# INST_IN_EAT: `224 := λ`225. λ`226. λ`227. λ`228. λ`229. 39 -Just created bomb var: x-226:-666 -# INST (div): `27 := x-226:-666 -dangerous_conv lenght:5 - - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: eat ||||| - -| measure=8 freshno = 225 -|> DISCRIMINATING SETS (deltas) -| 66 <> 67 <> 69 -| 65 -| 58 <> 59 <> 61 <> 64 -| 53 <> 55 <> 57 -| 10 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 <> 63 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 <> 60 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 <> 62 -| 7 -| 6 <> 16 <> 56 <> 68 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: * -|> CONVERGENT -| _: _ -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`226. [match(`17 -6:-666) `226:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 10 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666 | 63 => `213:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4 -611686018427387904) with 26 => λ`226. [match(`100:-666) `226:-4611686018427387904 `107:-4611686018427387904 `106:-461168 -6018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`227. [match(`10 -6:-666) `227:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-46 -11686018427387904 `128:-4611686018427387904 with 33 => λ`228. [match(`130:-666) `228:-4611686018427387904 `138:-46116860 -18427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with - 34 => λ`229. [match(`135:-666) `229:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611 -686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`230. [match(`140:-666) `230:-4611686018 -427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:- -4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`227. [match(`107:-666) `227:-4611686018427387904 `114:-46 -11686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-461168601842738790 -4 with 30 => λ`228. [match(`112:-666) `228:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118 -:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-66 -6] λ`226. [match(`194:1) `226:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-46116860184 -27387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ`227. [matc -h(`204:-666) `227:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `20 -8:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 => `214:-666] )) `121:1 -| _: _ -|> NUMERIC -| 0: 0 -| 1: 1 -| 2: 2 -| 3: 3 -| 4: 4 -| 5: 5 -| 6: 6 -| 7: 7 -| 8: 8 -| 9: 9 -| 10: 10 -| 11: 11 -| 12: 12 -| 13: 13 -| 14: 14 -| 15: 15 -| 16: 16 -| 17: 17 -| 18: 18 -| 19: 6 -| 20: 20 -| 21: 21 -| 22: 22 -| 23: 23 -| 24: 24 -| 25: 25 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: 27 -| 28: 28 -| 29: 29 -| 30: 30 -| 31: 31 -| 32: 32 -| 33: 33 -| 34: 34 -| 35: 35 -| 36: 36 -| 37: 37 -| 38: 36 -| 39: 39 -| 40: 40 -| 41: 41 -| 42: `164:1 `163:-4611686018427387904 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: 43 -| 44: 44 -| 45: 45 -| 46: 46 -| 47: 47 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: 49 -| 50: 50 -| 51: `164:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611 -686018427387904 `171:-4611686018427387904 -| 52: 10 -| 53: 53 -| 54: 54 -| 55: 55 -| 56: 56 -| 57: 57 -| 58: 58 -| 59: 59 -| 60: 60 -| 61: 61 -| 62: `174:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-46116860 -18427387904 `28:-4611686018427387904 -| 63: 63 -| 64: 64 -| 65: 65 -| 66: 66 -| 67: 67 -| 68: 68 -| 69: 69 -| -{{{{{{{{ Computing measure inafter auto_instantiate }}}}}} -compare 8 18= 1 -$ Measure decreased by 1 -{{{{{{{{ Computing measure before auto_instantiate }}}}}} -DANGEROUS EAT: `164 -INSTANTIATING CRITICAL TO EAT `164 -@@@@ NEW INSTANTIATE PHASE (0) @@@@ -WARNING: using constant initialSpecialK -# INST: `164 := λ`233. [match(`163:666) `233:-4611686018427387904 `230:-4611686018427387904 `229:-4611686018427387904 `2 -28:-4611686018427387904 `227:-4611686018427387904 `226:-4611686018427387904 with 70 => `231:-666 | 71 => `232:-666] ) ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: instantiate ||||| - -| measure=7 freshno = 232 -|> DISCRIMINATING SETS (deltas) -| 70 <> 71 -| 66 <> 67 <> 69 -| 65 -| 58 <> 59 <> 61 <> 64 -| 53 <> 55 <> 57 -| 10 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 <> 63 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 <> 60 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 <> 62 -| 7 -| 6 <> 16 <> 56 <> 68 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: * -|> CONVERGENT -| _: _ -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`233. [match(`17 -6:-666) `233:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 10 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666 | 63 => `213:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4 -611686018427387904) with 26 => λ`233. [match(`100:-666) `233:-4611686018427387904 `107:-4611686018427387904 `106:-461168 -6018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`234. [match(`10 -6:-666) `234:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-46 -11686018427387904 `128:-4611686018427387904 with 33 => λ`235. [match(`130:-666) `235:-4611686018427387904 `138:-46116860 -18427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with - 34 => λ`236. [match(`135:-666) `236:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611 -686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`237. [match(`140:-666) `237:-4611686018 -427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:- -4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`234. [match(`107:-666) `234:-4611686018427387904 `114:-46 -11686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-461168601842738790 -4 with 30 => λ`235. [match(`112:-666) `235:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118 -:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-66 -6] λ`233. [match(`194:1) `233:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-46116860184 -27387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ`234. [matc -h(`204:-666) `234:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `20 -8:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 => `214:-666] )) `121:1 -| _: _ -|> NUMERIC -| 0: 0 -| 1: 1 -| 2: 2 -| 3: 3 -| 4: 4 -| 5: 5 -| 6: 6 -| 7: 7 -| 8: 8 -| 9: 9 -| 10: 10 -| 11: 11 -| 12: 12 -| 13: 13 -| 14: 14 -| 15: 15 -| 16: 16 -| 17: 17 -| 18: 18 -| 19: 6 -| 20: 20 -| 21: 21 -| 22: 22 -| 23: 23 -| 24: 24 -| 25: 25 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: 27 -| 28: 28 -| 29: 29 -| 30: 30 -| 31: 31 -| 32: 32 -| 33: 33 -| 34: 34 -| 35: 35 -| 36: 36 -| 37: 37 -| 38: 36 -| 39: 39 -| 40: 40 -| 41: 41 -| 42: `231:0 `162:-4611686018427387904 `161:-4611686018427387904 -| 43: 43 -| 44: 44 -| 45: 45 -| 46: 46 -| 47: 47 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: 49 -| 50: 50 -| 51: `232:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611 -686018427387904 -| 52: 10 -| 53: 53 -| 54: 54 -| 55: 55 -| 56: 56 -| 57: 57 -| 58: 58 -| 59: 59 -| 60: 60 -| 61: 61 -| 62: `174:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-46116860 -18427387904 `28:-4611686018427387904 -| 63: 63 -| 64: 64 -| 65: 65 -| 66: 66 -| 67: 67 -| 68: 68 -| 69: 69 -| 70: `163:-4611686018427387904 `230:-4611686018427387904 `229:-4611686018427387904 `228:-4611686018427387904 `227:-4611 -686018427387904 `226:-4611686018427387904 -| 71: `175:-4611686018427387904 `230:-4611686018427387904 `229:-4611686018427387904 `228:-4611686018427387904 `227:-4611 -686018427387904 `226:-4611686018427387904 -| -dangerous_inert_conv: ar=4 k=`100 listlenargs=9 -dangerous_conv lenght:5 - - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - -dangerous_conv lenght:5 - - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - -# INST_IN_EAT: `163 := λ`233. λ`234. λ`235. λ`236. λ`237. 70 -# INST_IN_EAT: `231 := λ`233. λ`234. 42 -# INST_IN_EAT: `232 := λ`233. λ`234. λ`235. λ`236. 51 -dangerous_conv lenght:5 - - - -`100 `175 `174 `173 `172 `171 `99 `98 `97 `96 - ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: eat ||||| - -| measure=7 freshno = 232 -|> DISCRIMINATING SETS (deltas) -| 70 <> 71 -| 66 <> 67 <> 69 -| 65 -| 58 <> 59 <> 61 <> 64 -| 53 <> 55 <> 57 -| 10 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 <> 63 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 <> 60 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 <> 62 -| 7 -| 6 <> 16 <> 56 <> 68 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: * -|> CONVERGENT -| _: _ -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) `100:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173 -:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904 with 46 => `176:-666 | 47 => λ`233. [match(`17 -6:-666) `233:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427387904 `184:-4611686018427387904 `183:-46 -11686018427387904 `182:-4611686018427387904 with 10 => `187:-666] ) | 48 => `178:-666 | 49 => `179:-666 | 50 => `180:-66 -6 | 51 => `181:-666 | 63 => `213:-666] `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4 -611686018427387904) with 26 => λ`233. [match(`100:-666) `233:-4611686018427387904 `107:-4611686018427387904 `106:-461168 -6018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686018427387904 with 28 => λ`234. [match(`10 -6:-666) `234:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427387904 `130:-4611686018427387904 `129:-46 -11686018427387904 `128:-4611686018427387904 with 33 => λ`235. [match(`130:-666) `235:-4611686018427387904 `138:-46116860 -18427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-4611686018427387904 `134:-4611686018427387904 with - 34 => λ`236. [match(`135:-666) `236:-4611686018427387904 `144:-4611686018427387904 `143:-4611686018427387904 `142:-4611 -686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => λ`237. [match(`140:-666) `237:-4611686018 -427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-4611686018427387904 `147:-4611686018427387904 `146:- -4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`234. [match(`107:-666) `234:-4611686018427387904 `114:-46 -11686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-4611686018427387904 `110:-461168601842738790 -4 with 30 => λ`235. [match(`112:-666) `235:-4611686018427387904 `120:-4611686018427387904 `119:-4611686018427387904 `118 -:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with 31 => `121:-666] )] )] ) | 27 => `102:-66 -6] λ`233. [match(`194:1) `233:-4611686018427387904 `202:-4611686018427387904 `201:-4611686018427387904 `200:-46116860184 -27387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-666 | 59 => `204:-666 | 61 => λ`234. [matc -h(`204:-666) `234:-4611686018427387904 `211:-4611686018427387904 `210:-4611686018427387904 `209:-4611686018427387904 `20 -8:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 => `214:-666] )) `121:1 -| _: _ -|> NUMERIC -| 0: 0 -| 1: 1 -| 2: 2 -| 3: 3 -| 4: 4 -| 5: 5 -| 6: 6 -| 7: 7 -| 8: 8 -| 9: 9 -| 10: 10 -| 11: 11 -| 12: 12 -| 13: 13 -| 14: 14 -| 15: 15 -| 16: 16 -| 17: 17 -| 18: 18 -| 19: 6 -| 20: 20 -| 21: 21 -| 22: 22 -| 23: 23 -| 24: 24 -| 25: 25 -| 26: `100:1 `99:-4611686018427387904 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: 27 -| 28: 28 -| 29: 29 -| 30: 30 -| 31: 31 -| 32: 32 -| 33: 33 -| 34: 34 -| 35: 35 -| 36: 36 -| 37: 37 -| 38: 36 -| 39: 39 -| 40: 40 -| 41: 41 -| 42: 42 -| 43: 43 -| 44: 44 -| 45: 45 -| 46: 46 -| 47: 47 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: 49 -| 50: 50 -| 51: 51 -| 52: 10 -| 53: 53 -| 54: 54 -| 55: 55 -| 56: 56 -| 57: 57 -| 58: 58 -| 59: 59 -| 60: 60 -| 61: 61 -| 62: `174:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-46116860 -18427387904 `28:-4611686018427387904 -| 63: 63 -| 64: 64 -| 65: 65 -| 66: 66 -| 67: 67 -| 68: 68 -| 69: 69 -| 70: 70 -| 71: `175:-4611686018427387904 `230:-4611686018427387904 `229:-4611686018427387904 `228:-4611686018427387904 `227:-4611 -686018427387904 `226:-4611686018427387904 -| -{{{{{{{{ Computing measure inafter auto_instantiate }}}}}} -compare 7 8= 1 -$ Measure decreased by 1 -{{{{{{{{ Computing measure before auto_instantiate }}}}}} -INSTANTIATING TO EAT `100 -WARNING: using constant initialSpecialK -# INST: `100 := λ`239. [match(`99:666) `239:-4611686018427387904 `237:-4611686018427387904 `236:-4611686018427387904 `23 -5:-4611686018427387904 `234:-4611686018427387904 `233:-4611686018427387904 with 72 => `238:-666] ) ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: instantiate ||||| - -| measure=6 freshno = 238 -|> DISCRIMINATING SETS (deltas) -| 72 -| 70 <> 71 -| 66 <> 67 <> 69 -| 65 -| 58 <> 59 <> 61 <> 64 -| 53 <> 55 <> 57 -| 10 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 <> 63 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 <> 60 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 <> 62 -| 7 -| 6 <> 16 <> 56 <> 68 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: * -|> CONVERGENT -| _: _ -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) [match(`100:-4611686018427387904) `175:-4611686018427387904 `237:-4611686018427387 -904 `236:-4611686018427387904 `235:-4611686018427387904 `234:-4611686018427387904 `233:-4611686018427387904 with 72 => ` -238:-666] `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904) with -46 => `176:-666 | 47 => λ`239. [match(`176:-666) `239:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427 -387904 `184:-4611686018427387904 `183:-4611686018427387904 `182:-4611686018427387904 with 10 => `187:-666] ) | 48 => `17 -8:-666 | 49 => `179:-666 | 50 => `180:-666 | 51 => `181:-666 | 63 => `213:-666] `99:-4611686018427387904 `98:-4611686018 -427387904 `97:-4611686018427387904 `96:-4611686018427387904) with 26 => λ`239. [match(`100:-666) `239:-46116860184273879 -04 `107:-4611686018427387904 `106:-4611686018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686 -018427387904 with 28 => λ`240. [match(`106:-666) `240:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427 -387904 `130:-4611686018427387904 `129:-4611686018427387904 `128:-4611686018427387904 with 33 => λ`241. [match(`130:-666) - `241:-4611686018427387904 `138:-4611686018427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-461168601 -8427387904 `134:-4611686018427387904 with 34 => λ`242. [match(`135:-666) `242:-4611686018427387904 `144:-461168601842738 -7904 `143:-4611686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => -λ`243. [match(`140:-666) `243:-4611686018427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-46116860184 -27387904 `147:-4611686018427387904 `146:-4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`240. [match(`107 -:-666) `240:-4611686018427387904 `114:-4611686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-461 -1686018427387904 `110:-4611686018427387904 with 30 => λ`241. [match(`112:-666) `241:-4611686018427387904 `120:-461168601 -8427387904 `119:-4611686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with -31 => `121:-666] )] )] ) | 27 => `102:-666] λ`239. [match(`194:1) `239:-4611686018427387904 `202:-4611686018427387904 `2 -01:-4611686018427387904 `200:-4611686018427387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-6 -66 | 59 => `204:-666 | 61 => λ`240. [match(`204:-666) `240:-4611686018427387904 `211:-4611686018427387904 `210:-46116860 -18427387904 `209:-4611686018427387904 `208:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 = -> `214:-666] )) `121:1 -| _: _ -|> NUMERIC -| 0: 0 -| 1: 1 -| 2: 2 -| 3: 3 -| 4: 4 -| 5: 5 -| 6: 6 -| 7: 7 -| 8: 8 -| 9: 9 -| 10: 10 -| 11: 11 -| 12: 12 -| 13: 13 -| 14: 14 -| 15: 15 -| 16: 16 -| 17: 17 -| 18: 18 -| 19: 6 -| 20: 20 -| 21: 21 -| 22: 22 -| 23: 23 -| 24: 24 -| 25: 25 -| 26: `238:0 `98:-4611686018427387904 `97:-4611686018427387904 `96:-4611686018427387904 -| 27: 27 -| 28: 28 -| 29: 29 -| 30: 30 -| 31: 31 -| 32: 32 -| 33: 33 -| 34: 34 -| 35: 35 -| 36: 36 -| 37: 37 -| 38: 36 -| 39: 39 -| 40: 40 -| 41: 41 -| 42: 42 -| 43: 43 -| 44: 44 -| 45: 45 -| 46: 46 -| 47: 47 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: 49 -| 50: 50 -| 51: 51 -| 52: 10 -| 53: 53 -| 54: 54 -| 55: 55 -| 56: 56 -| 57: 57 -| 58: 58 -| 59: 59 -| 60: 60 -| 61: 61 -| 62: `174:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-46116860 -18427387904 `28:-4611686018427387904 -| 63: 63 -| 64: 64 -| 65: 65 -| 66: 66 -| 67: 67 -| 68: 68 -| 69: 69 -| 70: 70 -| 71: `175:-4611686018427387904 `230:-4611686018427387904 `229:-4611686018427387904 `228:-4611686018427387904 `227:-4611 -686018427387904 `226:-4611686018427387904 -| 72: `99:-4611686018427387904 `237:-4611686018427387904 `236:-4611686018427387904 `235:-4611686018427387904 `234:-46116 -86018427387904 `233:-4611686018427387904 -| -dangerous_inert_conv: ar=5 k=`175 listlenargs=9 -dangerous_conv lenght:5 - - - -`175 `237 `236 `235 `234 `233 `174 `173 `172 `171 - -dangerous_conv lenght:5 - - - -`175 `237 `236 `235 `234 `233 `174 `173 `172 `171 - -# INST_IN_EAT: `99 := λ`239. λ`240. λ`241. λ`242. λ`243. 72 -# INST_IN_EAT: `238 := λ`239. λ`240. λ`241. 26 -dangerous_conv lenght:5 - - - -`175 `237 `236 `235 `234 `233 `174 `173 `172 `171 - ------------------------------------------------------------------------------------------------------------------------- - -||||| Displaying problem: eat ||||| - -| measure=6 freshno = 238 -|> DISCRIMINATING SETS (deltas) -| 72 -| 70 <> 71 -| 66 <> 67 <> 69 -| 65 -| 58 <> 59 <> 61 <> 64 -| 53 <> 55 <> 57 -| 10 -| 46 <> 47 <> 48 <> 49 <> 50 <> 51 <> 63 -| 41 <> 42 <> 43 <> 44 <> 45 <> 54 -| 36 <> 39 <> 40 -| 37 -| 35 -| 34 -| 33 -| 32 -| 31 -| 30 -| 28 <> 29 -| 26 <> 27 -| 24 <> 25 <> 60 -| 22 <> 23 -| 20 <> 21 -| 17 <> 18 <> 6 -| 15 <> 36 -| 12 <> 13 -| 11 -| 10 -| 9 -| 8 <> 14 <> 62 -| 7 -| 6 <> 16 <> 56 <> 68 -| 5 -| 0 <> 1 <> 2 <> 3 <> 4 -|> DIVERGENT -| *: * -|> CONVERGENT -| _: _ -| _: _ -| _: _ -| _: `121:3 [match(`94:3) [match(e:1) [match(`100:-4611686018427387904) `175:-4611686018427387904 `237:-4611686018427387 -904 `236:-4611686018427387904 `235:-4611686018427387904 `234:-4611686018427387904 `233:-4611686018427387904 with 72 => ` -238:-666] `174:-4611686018427387904 `173:-4611686018427387904 `172:-4611686018427387904 `171:-4611686018427387904) with -46 => `176:-666 | 47 => λ`239. [match(`176:-666) `239:-4611686018427387904 `186:-4611686018427387904 `185:-4611686018427 -387904 `184:-4611686018427387904 `183:-4611686018427387904 `182:-4611686018427387904 with 10 => `187:-666] ) | 48 => `17 -8:-666 | 49 => `179:-666 | 50 => `180:-666 | 51 => `181:-666 | 63 => `213:-666] `99:-4611686018427387904 `98:-4611686018 -427387904 `97:-4611686018427387904 `96:-4611686018427387904) with 26 => λ`239. [match(`100:-666) `239:-46116860184273879 -04 `107:-4611686018427387904 `106:-4611686018427387904 `105:-4611686018427387904 `104:-4611686018427387904 `103:-4611686 -018427387904 with 28 => λ`240. [match(`106:-666) `240:-4611686018427387904 `132:-4611686018427387904 `131:-4611686018427 -387904 `130:-4611686018427387904 `129:-4611686018427387904 `128:-4611686018427387904 with 33 => λ`241. [match(`130:-666) - `241:-4611686018427387904 `138:-4611686018427387904 `137:-4611686018427387904 `136:-4611686018427387904 `135:-461168601 -8427387904 `134:-4611686018427387904 with 34 => λ`242. [match(`135:-666) `242:-4611686018427387904 `144:-461168601842738 -7904 `143:-4611686018427387904 `142:-4611686018427387904 `141:-4611686018427387904 `140:-4611686018427387904 with 35 => -λ`243. [match(`140:-666) `243:-4611686018427387904 `150:-4611686018427387904 `149:-4611686018427387904 `148:-46116860184 -27387904 `147:-4611686018427387904 `146:-4611686018427387904 with 37 => `152:-666] )] )] )] ) | 29 => λ`240. [match(`107 -:-666) `240:-4611686018427387904 `114:-4611686018427387904 `113:-4611686018427387904 `112:-4611686018427387904 `111:-461 -1686018427387904 `110:-4611686018427387904 with 30 => λ`241. [match(`112:-666) `241:-4611686018427387904 `120:-461168601 -8427387904 `119:-4611686018427387904 `118:-4611686018427387904 `117:-4611686018427387904 `116:-4611686018427387904 with -31 => `121:-666] )] )] ) | 27 => `102:-666] λ`239. [match(`194:1) `239:-4611686018427387904 `202:-4611686018427387904 `2 -01:-4611686018427387904 `200:-4611686018427387904 `199:-4611686018427387904 `198:-4611686018427387904 with 58 => `203:-6 -66 | 59 => `204:-666 | 61 => λ`240. [match(`204:-666) `240:-4611686018427387904 `211:-4611686018427387904 `210:-46116860 -18427387904 `209:-4611686018427387904 `208:-4611686018427387904 `207:-4611686018427387904 with 65 => `215:-666] ) | 64 = -> `214:-666] )) `121:1 -| _: _ -|> NUMERIC -| 0: 0 -| 1: 1 -| 2: 2 -| 3: 3 -| 4: 4 -| 5: 5 -| 6: 6 -| 7: 7 -| 8: 8 -| 9: 9 -| 10: 10 -| 11: 11 -| 12: 12 -| 13: 13 -| 14: 14 -| 15: 15 -| 16: 16 -| 17: 17 -| 18: 18 -| 19: 6 -| 20: 20 -| 21: 21 -| 22: 22 -| 23: 23 -| 24: 24 -| 25: 25 -| 26: 26 -| 27: 27 -| 28: 28 -| 29: 29 -| 30: 30 -| 31: 31 -| 32: 32 -| 33: 33 -| 34: 34 -| 35: 35 -| 36: 36 -| 37: 37 -| 38: 36 -| 39: 39 -| 40: 40 -| 41: 41 -| 42: 42 -| 43: 43 -| 44: 44 -| 45: 45 -| 46: 46 -| 47: 47 -| 48: `32:-4611686018427387904 `175:-4611686018427387904 `174:-4611686018427387904 `173:-4611686018427387904 `172:-46116 -86018427387904 `171:-4611686018427387904 -| 49: 49 -| 50: 50 -| 51: 51 -| 52: 10 -| 53: 53 -| 54: 54 -| 55: 55 -| 56: 56 -| 57: 57 -| 58: 58 -| 59: 59 -| 60: 60 -| 61: 61 -| 62: `174:-4611686018427387904 `32:-4611686018427387904 `31:-4611686018427387904 `30:-4611686018427387904 `29:-46116860 -18427387904 `28:-4611686018427387904 -| 63: 63 -| 64: 64 -| 65: 65 -| 66: 66 -| 67: 67 -| 68: 68 -| 69: 69 -| 70: 70 -| 71: `175:-4611686018427387904 `230:-4611686018427387904 `229:-4611686018427387904 `228:-4611686018427387904 `227:-4611 -686018427387904 `226:-4611686018427387904 -| 72: 72 -| -{{{{{{{{ Computing measure inafter auto_instantiate }}}}}} -compare 6 7= 1 -$ Measure decreased by 1 -{{{{{{{{ Computing measure before auto_instantiate }}}}}} -Fatal error: exception Assert_failure("lambda4.ml", 490, 15) diff --git a/ocaml/measure.ml b/ocaml/measure.ml deleted file mode 100644 index 53b0fbc..0000000 --- a/ocaml/measure.ml +++ /dev/null @@ -1,32 +0,0 @@ -open Num;; -open Lambda4;; - -(* type var = int;; - -type state = { - terms : nf list; - arities : (var * int) list; - freshno : int; - apps : (var * (var list)) list; -} - -let replace = - function - | `Var _ | `Lam _ as t -> t - | `I(v,tms) -> - try - let apps = List.assoc v p.apps in - let hd, tl = ... in - let s, freshvar = mk_freshvar s - [] - aux (mk_apps v (Listx.map )) - with - | Not_found -> `I(v, Listx.map (replace s) tms) - | _ -> assert false -;; - - -let iteration : state -> state = fun s -> - let terms = Util.concat_map (replace s) s.terms in - s;; -*) diff --git a/ocaml/num.ml b/ocaml/num.ml deleted file mode 100644 index aa9338c..0000000 --- a/ocaml/num.ml +++ /dev/null @@ -1,361 +0,0 @@ -open Util -open Util.Vars -open Pure - -(* debug options *) -let debug_display_arities = false;; - -(************ Syntax ************************************) - -(* Normal forms*) - -(* Var n = n-th De Bruijn index, 0-based *) - -(*type nf = - | Lam of nf - | Var of int - | i -and i = - | I of int * nf listx -;;*) -type var = int * (* arity of variable*) int;; -type 'nf_nob i_var_ = [ `I of var * 'nf_nob Listx.listx | `Var of var ] -type 'nf_nob i_n_var_ = [ `N of int | 'nf_nob i_var_ ] -type ('nf_nob,'nf) i_num_var_ = [ - | 'nf_nob i_n_var_ - | `Match of ('nf_nob,'nf) i_num_var_ * (* originating var *) var * (*lift*) int * (*branches*)(int * 'nf) list ref * (*args*)'nf_nob list -] -type 'nf nf_nob_ = [ `Lam of (* was_unpacked *) bool * 'nf | `Pacman | ('nf nf_nob_,'nf) i_num_var_ ] -type nf = [ nf nf_nob_ | `Bottom ] -type nf_nob = nf nf_nob_ -type i_var = nf_nob i_var_;; -type i_n_var = nf_nob i_n_var_;; -type i_num_var = (nf_nob,nf) i_num_var_;; - -let hd_of_i_var = - function - `I ((v,_),_) - | `Var (v,_) -> v - -let hd_of = - function - `I ((v,_),_) - | `Var(v,_) -> Some v - | `N _ -> None - | `Match _ -> assert false - -let arity_of_hd = -function - `I ((_,a),_) -| `Var(_,a) -> a -| _ -> 0 (* FIXME? *) - -let lift m (t : nf) = - let aux_var l (n, ar) = (if n < l then n else n+m), ar in - let rec aux_i_num_var l = - function - `I(v,args) -> `I(aux_var l v, Listx.map (aux_nob l) args) - | `Var v -> `Var(aux_var l v) - | `N _ as x -> x - | `Match(t,v,lift,bs,args) -> - `Match(aux_i_num_var l t, v, lift + m, bs, List.map (aux_nob l) args) - and aux_nob l = - function - #i_num_var as x -> (aux_i_num_var l x :> nf_nob) - | `Lam(b,nf) -> `Lam (b, aux (l+1) nf) - | `Pacman -> `Pacman - and aux l = - function - #nf_nob as x -> (aux_nob l x :> nf) - | `Bottom -> `Bottom - in - (aux 0 t : nf) -;; - -(* put t under n lambdas, lifting t accordingtly *) -let rec make_lams t = - function - 0 -> t - | n when n > 0 -> `Lam (false, lift 1 (make_lams t (n-1))) - | _ -> assert false - -let free_vars' = - let rec aux n = function - `N _ -> [] - | `Var(x,ar) -> if x < n then [] else [(x-n,ar)] - | `I((x,ar),args) -> - (if x < n then [] else [(x-n,ar)]) @ - List.concat (List.map (aux n) (Listx.to_list args :> nf list)) - | `Lam(_,t) -> aux (n+1) t - | `Match(t,_,liftno,bs,args) -> - aux n (t :> nf) @ - List.concat (List.map (fun (_,t) -> aux (n-liftno) t) !bs) @ - List.concat (List.map (aux n) (args :> nf list)) - | `Bottom | `Pacman -> [] - in aux 0 -;; -let free_vars = (List.map fst) ++ free_vars';; - -module ToScott = -struct - -let rec scott_of_nf = function - | `N n -> Scott.mk_n n - | `Var(v,_) -> Pure.V v - | `Match(t,_,liftno,bs,args) -> - let bs = List.map (fun (n,t) -> n, scott_of_nf (lift liftno (t :> nf))) !bs in - let t = scott_of_nf (t :> nf) in - let m = Scott.mk_match t bs in - List.fold_left (fun acc t -> Pure.A(acc,scott_of_nf t)) m (args :> nf list) - | `I((v,_), args) -> Listx.fold_left (fun acc t -> Pure.A(acc,scott_of_nf t)) (Pure.V v) (args :> nf Listx.listx) - | `Lam(_,t) -> Pure.L (scott_of_nf t) - | `Bottom -> Pure.B - | `Pacman -> let f x = Pure.A (x,x) in f (Pure.L (Pure.L (f (Pure.V 0)))) -end - - -(************ Pretty-printing ************************************) - -(* let rec string_of_term l = fun _ -> "";; *) - -let rec string_of_term = - let boundvar x = "v" ^ string_of_int x in - let varname lev l n = - if n < lev then boundvar (lev-n-1) - else if n < List.length l then List.nth l (n-lev) - else "`" ^ string_of_int (n-lev) in - let rec string_of_term_w_pars lev l = function - | `Var(n,ar) -> varname lev l n ^ (if debug_display_arities then ":" ^ string_of_int ar else "") - | `N n -> string_of_int n - | `I _ as t -> "(" ^ string_of_term_no_pars_app lev l t ^ ")" - | `Lam(_,`Bottom) -> "BOMB" - | `Lam _ as t -> "(" ^ string_of_term_no_pars_lam lev l t ^ ")" - | `Match(t,(v,ar),bs_lift,bs,args) -> - (* assert (bs_lift = lev); *) - "(["^ varname lev l v ^ (if debug_display_arities then ":"^ string_of_int ar else "") ^",match " ^ string_of_term_no_pars lev l (t :> nf) ^ - " with " ^ String.concat " | " (List.map (fun (n,t) -> string_of_int n ^ " => " ^ string_of_term l (t :> nf)) !bs) ^ "] " ^ - String.concat " " (List.map (string_of_term l) (args :> nf list)) ^ ")" - | `Bottom -> "BOT" - | `Pacman -> "PAC" - and string_of_term_no_pars_app lev l = function - | `I((n,ar), args) -> varname lev l n ^ (if debug_display_arities then ":" ^ string_of_int ar else "") ^ " " ^ String.concat " " (List.map (string_of_term_w_pars lev l) (Listx.to_list args :> nf list)) - | #nf as t -> string_of_term_w_pars lev l t - and string_of_term_no_pars_lam lev l = function - | `Lam(_,`Bottom) -> "BOMB" - | `Lam(_,t) -> "λ" ^ boundvar lev ^ ". " ^ (string_of_term_no_pars_lam (lev+1) l t) - | _ as t -> string_of_term_no_pars lev l t - and string_of_term_no_pars lev l = function - | `Lam _ as t -> string_of_term_no_pars_lam lev l t - | #nf as t -> string_of_term_no_pars_app lev l t - in string_of_term_no_pars 0 -;; - -let print ?(l=[]) = string_of_term l;; -let string_of_nf t = string_of_term [] (t :> nf);; - -(************ Hereditary substitutions ************************************) - -let cast_to_i_var = - function - #i_var as y -> (y : i_var) - | t -> - prerr_endline (print (t :> nf)); - assert false (* algorithm failed *) - -let cast_to_i_n_var = - function - #i_n_var as y -> (y : i_n_var) - | t -> - prerr_endline (print (t :> nf)); - assert false (* algorithm failed *) - -let cast_to_i_num_var = - function - #i_num_var as y -> (y : i_num_var) - | t -> - prerr_endline (print (t :> nf)); - assert false (* algorithm failed *) - -let rec set_arity arity = function -(* FIXME because onlt variables should be in branches of matches, one day *) -| `Var(n,_) -> `Var(n,arity) -| `N _ | `Bottom | `Pacman as t -> t -| `Lam(false, t) -> `Lam(false, set_arity arity t) -| `Match(t,(n,_),bs_lift,bs,args) -> `Match(t,(n,arity),bs_lift,bs,args) -| `I _ | `Lam _ -> assert false - -let minus1 n = if n = min_int then n else n - 1;; - -let rec mk_app (h : nf) (arg : nf) = - match arg with - | `Bottom -> `Bottom - | #nf_nob as arg -> - match h with - | `I(v,args) -> `I(v,Listx.append (Listx.Nil arg) args) - | `Var v -> `I(v, Listx.Nil arg) - | `Lam(truelam,nf) -> subst truelam true 0 arg (nf : nf) (* AC FIXME sanity check on arity *) - | `Match(t,v,lift,bs,args) -> `Match(t,v,lift,bs,List.append args [arg]) - | `Bottom | `Pacman as t -> t - | `N _ -> assert false (* Numbers cannot be applied *) -(*in let l = ["v0";"v1";"v2"] in -prerr_endline ("mk_app h:" ^ print ~l h ^ " arg:" ^ print ~l:l arg ^ " res:" ^ print ~l:l res); res*) - -and mk_appl h args = - (*prerr_endline ("MK_APPL: " ^ print h ^ " " ^ String.concat " " (List.map print args));*) - List.fold_left mk_app h args - -and mk_appx h args = Listx.fold_left mk_app h args - -and mk_match t (n,ar) bs_lift bs args = - (*prerr_endline ("MK_MATCH: ([" ^ print t ^ "] " ^ String.concat " " (Listx.to_list (Listx.map (fun (n,t) -> string_of_int n ^ " => " ^ print t) bs)) ^ ") " ^ String.concat " " (List.map print args));*) - let m = - match t with - `N m as t -> - (try - let h = List.assoc m !bs in - let h = set_arity (minus1 ar) h in - let h = lift bs_lift h in - h - with Not_found -> - `Match (t,(n,ar),bs_lift,bs,[])) - (* We are assuming that the econding of matches is s.t.: - - match PAC.. --> PAC - - match BOT.. --> BOT *) - | `Bottom -> `Bottom - | `Pacman -> `Pacman - | `Lam _ -> assert false - | `I _ | `Var _ | `Match _ as t -> `Match(t,(n,ar),bs_lift,bs,[]) in - mk_appl m args - -and subst truelam delift_by_one what (with_what : nf(*_nob*)) (where : nf) = - let rec aux_propagate_arity ar = function - | `Lam(false, t) when not delift_by_one -> `Lam(false, aux_propagate_arity ar t) - | `Match(`I(v,args),(x,_),liftno,bs,args') when not delift_by_one -> - `Match(`I(v,args),(x,ar),liftno,bs,args') - | `Var(i,oldar) -> `Var(i, if truelam then (assert (oldar = min_int); ar) else oldar) - | _ as t -> t in - let rec aux_i_num_var l = - function - `I((n,ar),args) -> - if n = what + l then - let args = Listx.map (aux l) (args :> nf Listx.listx) in - mk_appx (lift l (aux_propagate_arity ar (with_what :> nf))) args - else - mk_appl (`Var ((if delift_by_one && n >= l then n-1 else n), ar)) (List.map (aux l) (Listx.to_list (args :> nf Listx.listx))) - | `Var(n,ar) -> - if n = what + l then - lift l (aux_propagate_arity ar (with_what :> nf)) - else - `Var((if delift_by_one && n >= l then n-1 else n), ar) - | `N _ as x -> x - | `Match(t,v,bs_lift,bs,args) -> - let bs_lift = bs_lift + if delift_by_one then -1 else 0 in - (* Warning! It now applies again the substitution in branches of matches. - But careful, it does it many times, for every occurrence of - the match. This is okay because what does not occur in with_what. *) - let l' = l - bs_lift in - let with_what' = lift l' (with_what :> nf) in - (* The following line should be the identity when delift_by_one = true because we - are assuming the ts to not contain lambda-bound variables. *) - bs := List.map (fun (n,t) -> n,subst truelam false what with_what' t) !bs ; - let body = aux_i_num_var l t in - mk_match body v bs_lift bs (List.map (aux l) (args :> nf list)) - and aux l(*lift*) = -(*function iii -> let res = match iii with*) - function - | #i_num_var as x -> aux_i_num_var l x - | `Lam(b, nf) -> `Lam(b, aux (l+1) nf) - | `Bottom -> `Bottom - | `Pacman -> `Pacman -(*in let ll = ["v0";"v1";"v2"] in -prerr_endline ("subst l:" ^ string_of_int l ^ " delift_by_one:" ^ string_of_bool delift_by_one ^ " what:" ^ (List.nth ll what) ^ " with_what:" ^ print ~l:ll with_what ^ " where:" ^ print ~l:ll iii ^ " res:" ^ print ~l:ll res); res*) - in - aux 0 where -;; - -(************ Parsing ************************************) - -(************** Algorithm(s) ************************) - -let eta_compare x y = - (* let clex a b = let diff = ? a b in if diff = 0 then cont () else 0 in *) - let clex aux1 aux2 (a1,a2) (b1,b2) = - let diff = aux1 a1 b1 in if diff = 0 then aux2 a2 b2 else diff in - let rec lex aux l1 l2 = - match l1,l2 with - | [], [] -> 0 - | [], _ -> -1 - | _, [] -> 1 - | x::xs, y::ys -> clex aux (lex aux) (x,xs) (y,ys) in - let rec aux t1 t2 = match t1, t2 with - | `Var(n,_) , `Var(m,_) -> compare n m - | `I((n1,_), l1), `I((n2,_), l2) -> - clex compare (lex aux) (n1, (Listx.to_list l1 :> nf list)) (n2, (Listx.to_list l2 :> nf list)) - | `Bottom, `Bottom - | `Pacman, `Pacman -> 0 - | `Lam _, `N _ -> -1 - | `N _, `Lam _ -> 1 - | `Bottom, `Lam(_,t) -> -1 - | `Lam(_,t), `Bottom -> 1 - | `Lam(_,t1), `Lam(_,t2) -> aux t1 t2 - | `Lam(_,t1), t2 -> - aux t1 (mk_app (lift 1 t2) (`Var(0,-666))) - | t2, `Lam(_,t1) -> aux t1 (mk_app (lift 1 t2) (`Var(0,-666))) - | `N n1, `N n2 -> compare n1 n2 - | `Match(u,_,bs_lift,bs,args), `Match(u',_,bs_lift',bs',args') -> - let bs = List.sort (fun (n,_) (m,_) -> compare n m) !bs in - let bs' = List.sort (fun (n,_) (m,_) -> compare n m) !bs' in - clex aux (clex (lex (clex compare aux)) (lex aux)) ((u :> nf), (bs, (args :> nf list))) ((u' :> nf), (bs', (args' :> nf list))) - | `Match _, _ -> -1 - | _, `Match _ -> 1 - | `N _, _ -> -1 - | _, `N _ -> 1 - | `I _, _ -> -1 - | _, `I _ -> 1 - | `Bottom, _ -> -1 - | _, `Bottom -> 1 - | `Pacman, _ -> -1 - | _, `Pacman -> 1 - in aux x y -;; - -let eta_eq (#nf as x) (#nf as y) = 0 = eta_compare x y ;; - -let rec eta_subterm sub t = - if eta_eq sub t then true else - match t with - | `Lam(_,t') -> eta_subterm (lift 1 sub) t' - | `Bottom - | `Pacman -> false - | `Match(u,ar,liftno,bs,args) -> - eta_subterm sub (u :> nf) - || List.exists (fun (_, t) -> eta_subterm sub (lift liftno t)) !bs - || List.exists (eta_subterm sub) (args :> nf list) - | `I((v,_), args) -> List.exists (eta_subterm sub) ((Listx.to_list args) :> nf list) || (match sub with - | `Var(v',_) -> v = v' - | `I((v',_), args') -> v = v' - && Listx.length args' < Listx.length args - && List.for_all (fun (x,y) -> eta_eq x y) (List.combine (Util.take (Listx.length args') (Listx.to_list args :> nf list)) (Listx.to_list args' :> nf list)) - | _ -> false - ) - | `N _ | `Var _ -> false -;; - -let eta_subterm (#nf as x) (#nf as y) = eta_subterm x y;; - -let max_arity_tms n = - let max a b = match a, b with - | None, None -> None - | None, Some x - | Some x, None -> Some x - | Some x, Some y -> Some (Pervasives.max x y) in - let aux_var l (m,a) = if n + l = m then Some a else None in - let rec aux l = function - | `Var v -> aux_var l v - | `I(v,tms) -> max (aux_var l v) (aux_tms l (Listx.to_list tms :> nf list)) - | `Lam(_,t) -> aux (l+1) t - | `Match(u,_,_,bs,args) -> max (max (aux l (u :> nf)) (aux_tms l (args :> nf list))) (aux_tms l (List.map snd !bs)) - | `N _ | `Bottom | `Pacman -> None - and aux_tms l = - List.fold_left (fun acc t -> max acc (aux l t)) None in - fun tms -> aux_tms 0 (tms :> nf list) -;; diff --git a/ocaml/num.mli b/ocaml/num.mli deleted file mode 100644 index 39637bf..0000000 --- a/ocaml/num.mli +++ /dev/null @@ -1,40 +0,0 @@ -type var = int * (* arity of variable*) int;; -type 'nf_nob i_var_ = [ `I of var * 'nf_nob Listx.listx | `Var of var ] -type 'nf_nob i_n_var_ = [ `N of int | 'nf_nob i_var_ ] -type ('nf_nob,'nf) i_num_var_ = [ - | 'nf_nob i_n_var_ - | `Match of ('nf_nob,'nf) i_num_var_ * (* originating var *) var * (*lift*) int * (*branches*)(int * 'nf) list ref * (*args*)'nf_nob list -] -type 'nf nf_nob_ = [ `Lam of (* was_unpacked *) bool * 'nf | `Pacman | ('nf nf_nob_,'nf) i_num_var_ ] -type nf = [ nf nf_nob_ | `Bottom ] -type nf_nob = nf nf_nob_ -type i_var = nf_nob i_var_;; -type i_n_var = nf_nob i_n_var_;; -type i_num_var = (nf_nob,nf) i_num_var_;; -val hd_of_i_var : i_var -> int -val hd_of : i_n_var -> int option -val arity_of_hd : i_n_var -> int -(* put t under n lambdas, lifting t accordingtly *) -val make_lams : nf -> int -> nf -val lift : int -> nf -> nf -val free_vars' : nf -> var list -val free_vars : nf -> int list -module ToScott : - sig - val scott_of_nf : nf -> Pure.Pure.t - end -val print : ?l:string list -> nf -> string -val cast_to_i_var : [< nf > `I `Var] -> i_var -val cast_to_i_n_var : [< nf > `I `N `Var] -> i_n_var -val cast_to_i_num_var : [< nf > `I `N `Match `Var] -> i_num_var -val set_arity : int -> nf -> nf -val mk_app : nf -> nf -> nf -val mk_appl : nf -> nf list -> nf -val mk_appx : nf -> nf Listx.listx -> nf -val mk_match : nf -> var -> int -> (int * nf) list ref -> nf list -> nf -val subst : bool -> bool -> int -> nf -> nf -> nf -val eta_compare : nf -> nf -> int -val eta_eq : [< nf ] -> [< nf ] -> bool -val eta_subterm : [< nf ] -> [< nf ] -> bool -val max_arity_tms : int -> [< nf] list -> int option -val minus1 : int -> int diff --git a/ocaml/num.mli.ar b/ocaml/num.mli.ar deleted file mode 100644 index 46bf51e..0000000 --- a/ocaml/num.mli.ar +++ /dev/null @@ -1,43 +0,0 @@ -type 'nf i_var_ = [ `I of int * int * 'nf Listx.listx | `Var of int * int ] -type 'nf i_n_var_ = [ `N of int | 'nf i_var_ ] -type 'nf i_num_var_ = - [ `I of int * int * 'nf Listx.listx - | `Match of int * 'nf i_num_var_ * int * (int * 'nf) list ref * 'nf list - | `N of int - | `Var of int * int ] -type 'nf nf_ = - [ `I of int * int * 'nf Listx.listx - | `Lam of bool * 'nf nf_ - | `Match of int * 'nf i_num_var_ * int * (int * 'nf) list ref * 'nf list - | `N of int - | `Var of int * int ] -type nf = nf nf_ -type i_var = nf i_var_ -type i_n_var = nf i_n_var_ -type i_num_var = nf i_num_var_ -val hd_of_i_var : i_var -> int -val hd_of : - [< `I of 'c * 'a * 'b | `Match of 'c | `N of 'd | `Var of 'e * 'a ] -> 'a option -(* put t under n lambdas, lifting t accordingtly *) -val make_lams : nf -> int -> nf -val lift : int -> nf -> nf -val free_vars : nf -> int list -module ToScott : - sig - val t_of_i_num_var : nf i_num_var_ -> Pure.Pure.t - val t_of_nf : nf -> Pure.Pure.t - end -val print : ?l:string list -> nf -> string -val string_of_nf : [ string -val cast_to_i_var : [< nf > `I `Var] -> i_var -val cast_to_i_n_var : [< nf > `I `N `Var] -> i_n_var -val cast_to_i_num_var : [< nf > `I `N `Match `Var] -> i_num_var -val mk_app : nf -> nf -> nf -val mk_appl : nf -> nf list -> nf -val mk_appx : nf -> nf Listx.listx -> nf -val mk_match : int -> nf i_num_var_ -> int -> (int * nf) list ref -> nf list -> nf -val subst : bool -> int -> nf -> nf -> nf -val parse' : string list -> nf list * string list -val eta_compare : nf -> nf -> int -val eta_eq : [< nf ] -> [< nf ] -> bool -val eta_subterm : [< nf ] -> [< nf ] -> bool diff --git a/ocaml/parser.ml b/ocaml/parser.ml deleted file mode 100644 index ea885d2..0000000 --- a/ocaml/parser.ml +++ /dev/null @@ -1,244 +0,0 @@ -exception ParsingError of string;; - -let mk_app x y = Num.mk_app x y;; -let mk_lam x = `Lam(true, x);; -let mk_var x = `Var(x, -666);; - -let isAlphaNum c = let n = Char.code c in - (48 <= n && n <= 90) || (95 <= n && n <= 122) ;; -let isSpace c = c = ' ' || c = '\n' || c = '\t' ;; - -(* FIXME *) -let mk_var' (bound, free) x = - if x <> "@" && List.mem x bound - then free, mk_var (Util.index_of x bound) - else if x <> "@" && List.mem x free - then free, mk_var (List.length bound + Util.index_of x free) - else (free @ [x]), mk_var (List.length bound + List.length free) -;; - -let mk_app' = function - | [] -> assert false - | t :: ts -> List.fold_left mk_app t ts -;; - -let explode s = - let len = String.length s in - let rec aux i l = - if i >= len || s.[i] = '#' then l else aux (i+1) (s.[i] :: l) - in List.rev (aux 0 []) -;; - -let implode l = - let res = Bytes.create (List.length l) in - let rec aux i = function - | [] -> res - | c :: l -> Bytes.set res i c; aux (i + 1) l in - aux 0 l -;; - -let rec strip_spaces = function - | c::cs when isSpace c -> strip_spaces cs - | cs -> cs -;; - -let read_var s = - let rec aux = function - | [] -> None, [] - | c::cs as x -> - if c = '@' then - (if cs <> [] && (let hd = List.hd cs in hd = '@' || isAlphaNum hd) - then raise (ParsingError ("Unexpected `"^String.make 1 (List.hd cs)^"` after `@`.")) - else Some['@'], cs) - else if isAlphaNum c - then match aux cs with - | (Some x), cs' -> Some (c :: x), cs' - | None, cs' -> (Some [c]), cs' - else None, x - in match aux s with - | None, y -> None, y - | Some x, y -> Some (implode x), y -;; - -let read_var' (bound, free as vars) s = - match read_var s with - | Some varname, cs -> - let free, v = mk_var' vars varname in - Some [v], cs, (bound, free) - | None, _ -> raise (ParsingError ("Can't read variable")) -;; - -let rec read_smt vars = - let check_if_lambda cs = match read_var cs with - | None, _ -> false - | Some x, cs -> match strip_spaces cs with - | [] -> false - | c::_ -> c = '.' - in let read_lambda (bound, free) cs = ( - match read_var (strip_spaces cs) with - | Some varname, cs -> - let vars' = (varname::bound, free) in - (match strip_spaces cs with - | [] -> raise (ParsingError "Lambda expression incomplete") - | c::cs -> (if c = '.' then (match read_smt vars' cs with - | None, _, _ -> raise (ParsingError "Lambda body expected") - | Some [x], y, (_, free) -> Some [mk_lam x], y, (bound, free) - | Some _, _, _ -> assert false - ) else raise (ParsingError "Expected `.` after variable in lambda") - )) - | _, _ -> assert false - ) in let rec aux vars cs = - match strip_spaces cs with - | [] -> None, [], vars - | c::_ as x -> - let tms, cs, vars = ( - if c = '(' then read_pars vars x - else if c = ')' then (None, x, vars) - else if check_if_lambda x then read_lambda vars x - else read_var' vars x) in - match tms with - | Some [tm] -> ( - match aux vars cs with - | None, cs, vars -> Some [tm], cs, vars - | Some ts, cs, vars -> Some (tm :: ts), cs, vars - ) - | Some _ -> assert false - | None -> None, x, vars - in fun cs -> match aux vars cs with - | None, cs, vars -> None, cs, vars - | Some ts, cs, vars -> Some [mk_app' ts], cs, vars -and read_pars vars = function - | [] -> None, [], vars - | c::cs -> if c = '(' then ( - let tm, cs, vars = read_smt vars cs in - let cs = strip_spaces cs in - match cs with - | [] -> None, [], vars - | c::cs -> if c = ')' then tm, cs, vars else raise (ParsingError "Missing `)`") - ) else assert false -;; - -let parse x = - match read_smt ([],[]) (explode x) with - | Some [y], [], _ -> y - | _, _, _ -> assert false -;; - -let parse_many strs = - let f (x, y) z = match read_smt y (explode z) with - | Some[tm], [], vars -> (tm :: x, vars) - | _, _, _ -> assert false - in let aux = List.fold_left f ([], ([], [])) - in let (tms, (_, free)) = aux strs - in (List.rev tms, free) -;; - -(********************************************************************** - -let rec string_of_term = function - | Tvar n -> string_of_int n - | Tapp(t1, t2) -> "(" ^ string_of_term t1 ^ " " ^ string_of_term t2 ^ ")" - | Tlam(t1) -> "(\\" ^ string_of_term t1 ^ ")" -;; - -let _ = prerr_endline (">>>" ^ string_of_term (parse "(\\x. x y z z1 k) z1 z j"));; - - -*******************************************************************************) - -let problem_of_string s = - let lines = Str.split (Str.regexp "[\n\r\x0c\t;]+") s in - let head, lines = List.hd lines, List.tl lines in - let name = String.trim (String.sub head 1 (String.length head - 1)) in - let lines = List.filter ((<>) "") lines in - let aux (last, div, conv, ps) line = - let chr = String.sub line 0 1 in - let line = String.trim (String.sub line 1 (String.length line - 1)) in - if line = "" then chr, div, conv, ps else - let rec aux' chr line = - if chr = "#" - then chr, div, conv, ps - else if chr = "D" - then chr, line, conv, ps - else if chr = "C" - then chr, div, line::conv, ps - else if chr = "N" - then chr, div, conv, line::ps - else if chr = " " - then aux' last line - else raise (ParsingError - ("Unexpected at beginning of problem: `" ^ chr ^ "` " ^ line)) in - aux' chr line in - let _, div, conv, ps = List.fold_left aux ("#", "", [], []) lines in - let div_provided = div <> "" in - let div = if div_provided then div else "BOT" in - let strs = [div] @ ps @ conv in - - if List.length ps = 0 && List.length conv = 0 - then raise (ParsingError "Parsed empty problem"); - - (* parse' *) - let (tms, free) = parse_many strs in - (* Replace pacmans and bottoms *) - let n_bot = try Util.index_of "BOT" free with Not_found -> min_int in - let n_pac = try Util.index_of "PAC" free with Not_found -> min_int in - let n_bomb = try Util.index_of "BOMB" free with Not_found -> min_int in - let fix lev v = - if v = lev + n_bot then `Bottom - else if v = lev + n_pac then `Pacman - else if v = lev + n_bomb then `Lam(true, `Bottom) - else if v = lev then `Var(v, min_int) (* zero *) - else `Var(v,1) in (* 1 by default when variable not applied *) - (* Fix arity *) - let open Num in - let exclude_bottom = function - | #nf_nob as t -> t - (* actually, the following may be assert false *) - | `Bottom -> raise (ParsingError "Input term not in normal form") in - let rec aux_nob lev : nf_nob -> nf = function - | `I((n,_), args) -> `I((n,(if lev = 0 then 0 else 1) + Listx.length args), Listx.map (fun t -> exclude_bottom (aux_nob lev t)) args) - | `Var(n,_) -> fix lev n - | `Lam(_,t) -> `Lam (true, aux (lev+1) t) - | `Match _ | `N _ -> assert false - | `Pacman -> `Pacman - and aux lev : Num.nf -> Num.nf = function - | #nf_nob as t -> aux_nob lev t - | `Bottom -> assert false in -let all_tms = List.map (aux 0) (tms :> Num.nf list) in - -(* problem_of *) -let div, (ps, conv) = List.hd all_tms, Util.list_cut (List.length ps, List.tl all_tms) in - -let div = if not div_provided || div = `Bottom - then None - else match div with - | `I _ as t -> Some t - | _ -> raise (ParsingError "D is not an inert in the initial problem") in -let conv = Util.filter_map ( - function - | #i_n_var as t -> Some t - | `Lam _ -> None - | _ -> raise (ParsingError "A C-term is not i_n_var") - ) conv in -let ps = List.map ( - function - | #i_n_var as y -> y - | _ -> raise (ParsingError "An N-term is not i_n_var") - ) ps in - name, div, conv, ps, free -;; - - -let from_file path = - let lines = ref ["#"] in - let chan = open_in path in - let _ = try - while true; do - lines := input_line chan :: !lines - done - with End_of_file -> - close_in chan in - let txt = String.concat "\n" (List.rev !lines) in - let problems = Str.split (Str.regexp "[\n\r]+\\$") txt in - List.map problem_of_string (List.tl (List.map ((^) "$") problems)) -;; diff --git a/ocaml/parser.mli b/ocaml/parser.mli deleted file mode 100644 index d131edb..0000000 --- a/ocaml/parser.mli +++ /dev/null @@ -1,15 +0,0 @@ -exception ParsingError of string - -val problem_of_string: - string -> - string (* problem label *) - * Num.i_var option (* div *) - * Num.i_n_var list (* conv *) - * Num.i_n_var list (* ps *) - * string list (* names of free variables *) -val from_file : string -> - (string (* problem label *) - * Num.i_var option (* div *) - * Num.i_n_var list (* conv *) - * Num.i_n_var list (* ps *) - * string list (* names of free variables *)) list diff --git a/ocaml/problems.ml b/ocaml/problems.ml deleted file mode 100644 index eda359a..0000000 --- a/ocaml/problems.ml +++ /dev/null @@ -1,39 +0,0 @@ -open Lambda4;; -open Util;; - -(* Syntax for problem files in problem/ folder: - -- dollar ($) on newline - begin new problem - $! means that the problem is expected to be separable, - $? means that it is expected to be unseparable - -- (#) on new line - comment line - -- (D) (C) (N) stand respectively for divergent, convergent, numeric - -- lines starting with spaces inherit the type from the last line - -*) - -(* assert_depends solves the problem, and checks if the result was expected *) -let assert_depends x = - let c = String.sub (label_of_problem (fst x)) 0 1 in - match solve x with - | _, `Unseparable s when c = "!" -> - failwith ("assert_depends: unseparable because: " ^ s ^ ".") - | _, `Separable _ when c = "?" -> - failwith ("assert_depends: separable.") - | _ -> () -;; - -(* TODO *) -(* div under a lambda in conv *) - -if Array.length Sys.argv = 1 - then failwith "no command line args. Please use e.g. ./a.out problems/*" -else Array.iteri (fun i filename -> if i > 0 then - List.iter (assert_depends ++ problem_of) (Parser.from_file filename) - ) Sys.argv -;; diff --git a/ocaml/problems.mli b/ocaml/problems.mli deleted file mode 100644 index e69de29..0000000 diff --git a/ocaml/problems/3col b/ocaml/problems/3col deleted file mode 100644 index df0045e..0000000 --- a/ocaml/problems/3col +++ /dev/null @@ -1,25 +0,0 @@ - -$! 3col: 0<>1 -C x (_.x y BOMB BOMB y y y b) (_.x BOMB y BOMB y y y b) (_.x BOMB BOMB y y y y b) BOMB BOMB BOMB a -C x y y y (_.x BOMB y y y BOMB BOMB b) (_.x y BOMB y BOMB y BOMB b) (_.x y y BOMB BOMB BOMB y b) a -D x y y y y y y a -C x z z z BOMB BOMB BOMB BOMB -C x y y y z z z BOMB - -$? 3col: 0<>1 1<>1 -C x (_.x y BOMB BOMB y y y b) (_.x BOMB y BOMB y y y b) (_.x BOMB BOMB y y y y b) BOMB BOMB BOMB a -C x y y y (_.x BOMB y y BOMB BOMB BOMB b) (_.x y BOMB y BOMB BOMB BOMB b) (_.x y y BOMB BOMB BOMB BOMB b) a -D x y y y y y y a -C x z z z BOMB BOMB BOMB BOMB -C x y y y z z z BOMB - -$? 3col: 0<>1<>2 0<>3 1<>3 2<>3 -C x (_.x y BOMB BOMB y y y y y y y y y b) (_.x BOMB y BOMB y y y y y y y y y b) (_.x BOMB BOMB y y y y y y y y y y b) BOMB BOMB BOMB BOMB BOMB BOMB BOMB BOMB BOMB a -C x y y y (_.x BOMB y y y BOMB BOMB y y y y y y b) (_.x y BOMB y BOMB y BOMB y y y y y y b) (_.x y y BOMB BOMB BOMB y y y y y y y b) BOMB BOMB BOMB BOMB BOMB BOMB a -C x y y y y y y (_.x BOMB y y BOMB y y y BOMB BOMB y y y b) (_.x y BOMB y y BOMB y BOMB y BOMB y y y b) (_.x y y BOMB y y BOMB BOMB BOMB y y y y b) BOMB BOMB BOMB a -C x y y y y y y y y y (_.x BOMB y y BOMB y y BOMB y y y BOMB BOMB b) (_.x y BOMB y y BOMB y y BOMB y BOMB y BOMB b) (_.x y y BOMB y y BOMB y y BOMB BOMB BOMB y b) a -D x y y y y y y y y y y y y a -C x z z z BOMB BOMB BOMB BOMB BOMB BOMB BOMB BOMB BOMB BOMB -C x y y y z z z BOMB BOMB BOMB BOMB BOMB BOMB BOMB -C x y y y y y y z z z BOMB BOMB BOMB BOMB -C x y y y y y y y y y z z z BOMB diff --git a/ocaml/problems/bugs b/ocaml/problems/bugs deleted file mode 100644 index 610b6b8..0000000 --- a/ocaml/problems/bugs +++ /dev/null @@ -1,10 +0,0 @@ -$! bugs 1 -# bug with eating firing reduction of matches -D z (_. (v y)) -C u (z (_. (v x))) - -$! bugs 2 -# algorithm tries to eat z, but should first step on x, w -D z PAC -C x y PAC PAC -N x (w z) Z diff --git a/ocaml/problems/m b/ocaml/problems/m deleted file mode 100644 index 716e4d4..0000000 --- a/ocaml/problems/m +++ /dev/null @@ -1,13 +0,0 @@ -$! m1 -N y z Z - x z Z - x (a k) u Z - x (a r) Z - x (a k) v Z - -$! m2 -N y z Z - x z Z - x (a k) u Z - x (a r) Z - x (a k) v Z diff --git a/ocaml/problems/n b/ocaml/problems/n deleted file mode 100644 index 25d5378..0000000 --- a/ocaml/problems/n +++ /dev/null @@ -1,38 +0,0 @@ -$! n1 -D b (c b) (k. l. c b d) (c e) (k. l. m. f) (g (k. c e) (b (c b) (k. l. c b d) (c e) b)) (f c (h (k. c c g))) (g (k. c e) (k. i) f e (g (k. c e) (k. i) (c b) (c (c e)) (k. l. c b d)) (k. e c (k (l. f))) (g (k. c e) (k. i) e)) (g (k. c e) (k. i) (c b) (f c) b) -C b (c b) (k. l. c b d) (c e) (k. l. m. f) (g (k. c e) (b (c b) (k. l. c b d) (c e) b)) (f c (h (k. c c g))) (g (k. c e) (k. i) f e (g (k. c e) (k. i) (c b) (c (c e)) (k. l. c b d)) (k. e c (k (l. f))) (g (k. c e) (k. i) e)) (b (k. f) (g (k. c e) (k. i) (c b) (c (c e))) (k. l. m. f) (g (k. c e) (k. i) f e) (k. i)) - g (k. c e) (k. i) (c b) (c (c e)) (k. l. c b d) (k. l. g (m. c e) (m. i) (c b) (l c) b) (e c (d d (d c)) (c e (k. f)) (b (c b) (k. l. c b d) (c e) (k. l. m. f))) - b (c b) (k. l. c b d) (c e) (k. l. m. f) (g (k. c e) (b (c b) (k. l. c b d) (c e) b)) (f c (h (k. c c g))) (g (k. c e) (k. i) f e (g (k. c e) (k. i) (c b) (c (c e)) (k. l. c b d)) (k. e c (k (l. f))) (g (k. c e) (k. i) e)) - b (k. f) (g (k. c e) (k. i) (c b) (c (c e))) (k. l. m. f) (g (k. c e) (k. i) f e) (k. l. m. c c g) (e c (b (k. f))) (k. f c) - c (c e) (e c (d d (d c)) (k. c e (f c))) (g (k. c e) (k. i) (c b) (c (c e)) (k. l. c b d) (k. c e (l. f) (k (l. c e) (l. i)))) (k. l. l (m. c e) (m. i) (c b) (f c) b) (k. l. c k) (f (f c) (b (c b) (k. l. c b d) (c e)) (b (k. f) (g (k. c e) (k. i) (c b) (c (c e))) (k. l. m. f) (g (k. c e) (k. i) f e) (k. l. m. c c g) (e c (b (k. f))))) -N b (c b) (k. l. c b d) (c e) b (g (k. c e) (k. i) (c b)) (h (g (k. c e) (k. i) (c b) (c (c e)))) (g (k. c e) (b (c b) (k. l. c b d) (c e) b) (g (k. c e) (k. i) (g (k. c e) (k. i) e) (e c (d d (d c)) (k. c e (f c))))) a Z - c c g (k. b (c b) (l. m. c b k) (c e)) (k. b (c b) (l. m. c b d) (c k) b) (k. e c (d h) k) (g (k. c e) (b (c b) (k. l. c b d) (c e) b) (g (k. c e) (k. i) (g (k. c e) (k. i) e) (e c (d d (d c)) (k. c e (f c))))) a Z - d h (b (c b) (k. l. c b d) (c e)) (k. g (l. c e) (l. i) (c b) (k c) b) d b (b (c b) (k. l. c b d) (c e) b (g (k. c e) (k. i) (c b)) (k. c)) a Z - g (k. c e) (k. d d) (k. k k) (e c (d d (d c)) i) (k. g (l. k e) (l. d d)) (g i (b (c b) (k. l. c b d) (e c (d d (d c)) (k. c e (f c)) (k. k (c k) (l. m. c k d) (c e) k (g (l. c e) (l. i) (c k)) (l. c))))) (c b) a Z - g (k. c e) (k. i) f e (g (k. c e) (k. i) (c b) (c (c e)) (k. l. c b d)) (k. e c (k (l. f))) (g (k. c e) (k. i) e) a Z - -$! n2 -D b b (c d) (k. d e) (k. k) (k. l. b) -C b b (d e (k. d e)) (g (k. e) (k. k)) (b (b b) (d (g (d e) (g (k. e)) h) (b b (c d) (k. l. b)) (b (k. h))) (k. k (k k) (l. l))) (f (e (c d))) (b b (d e (k. d e)) (b b) (b (b b) (d (g (d e) (g (k. e)) h) (b b (c d) (k. l. b)) (b (k. h))))) (d e (k. d e) g (i (k. k))) - f (g (k. e)) (k. b b) (c d (k. k d) (k. l. l) c) (k. c d) (k. c) (d (g (de) (g (k. e)) h) (g (k. b b))) - f (g (k. e)) (k. b b) (c d (k. k d) (k. l. l) c) (k. c d) (k. l. l) (k. g (d e) (l. m. m)) - b b (d e (k. d e)) (g (k. e) (k. k)) (b (b b) (d (g (d e) (g (k. e)) h) (b b (c d) (k. l. b)) (b (k. h))) (k. k (k k) (l. l))) (f (e (c d))) (b b (d e (k. d e)) (b b) (b (b b) (d (g (d e) (g (k. e)) h) (b b (c d) (k. l. b)) (b (k. h))))) - d (g (d e) (g (k. e)) h) (g (g (d e)) (d e (k. d e) (k. b (l. h)) (k. l. d e))) (b (k. h) (k. k e (l. m. b b)) (k. k (k k) (l. l))) (k. b) (b b (k. l. i)(k. c)) -N b (b b) (d (g (d e) (g (k. e)) h) (b b (c d) (k. l. b)) (b (k. h))) (e (b b (c d))) (d (g (d e) (g (k. e)) h) (b b (c d) (k. l. b)) (g (k. e) (k. k))) (k. l. d (g (d k) (g (m. k)) h) (d k (m. n. b b))) (e (c d) (e (c d))) Z - d (g (d e) (g (k. e)) h) (d e (k. l. b b)) (b b) h (k. g (l. e) (l. l)) Z - d e (k. d e) (k. b (l. h)) (k. l. d e) (d (g (d e) (g (k. e)) h) (g (d e) (k. l. l))) Z - f (g (k. e)) (k. b b) (c d (k. k d) (k. l. l) c) (k. c d) (k. c) (k. l. m. b b) Z - f (g (k. e)) (k. b b) (c d (k. k d) (k. l. l) c) (k. c d) (b (b b) (d (g(d e) (g (k. e)) h) (b b (c d) (k. l. b)) (b (k. h))) (e (b b (c d))) (d (g (d e) (g (k. e)) h) (b b (c d) (k. l. b)) (g (k. e) (k. k)))) (k. d e (l. d e) f) Z - -$! n3 -D b (k. c (c d e f)) (k. l. f (m. f) (m. f) (m. n. n)) -C b (g (k. e e)) (k. b (g (l. e e))) (g (h (k. i)) (k. e)) (f (k. f) (k. f) i) (i (k. c (c d e f)) (k. l. l) (k. g (h (l. i)) (k d) f) e) (k. l. h) (k. f (l. f) (l. f) (l. e)) (k. l. l (m. l)) - c d e (f i) (e e) (g e) (k. l. e) (k. c (g (k (l. i)))) (c d e (k. k)) - f (k. f) (k. f) (f h) (f h (c d e (f i))) (k. b) (c d e (f i) (e e) (f (k. h))) (g e (b (k. i)) (e e (e e))) - f (k. f) (k. f) (k. e) (c d e (f i) (e e) (g e)) (k. e e) (k. l. m. e) (k. e) - g e f (f (k. f) (f (k. f) (k. l. f)) (c d e b)) (f (k. f) (k. f) (k. l. l) b) (f (k. h)) (c d e (f i) (e e) (g e) (k. l. e)) (f (k. f) f) -N b (g (k. e e)) (k. b (g (l. e e))) (g (h (k. i)) (k. e)) (f (k. f) (k. f) i) (i (k. c (c d e f)) (k. l. l) (k. g (h (l. i)) (k d) f) e) (k. l. h) (k. f (l. f) (l. f) (l. e)) Z - c d e (f i) (e e) (g e) (b (g (k. e e)) (k. c (g (h (l. i))) (l. f l))) (k. f (l. f) (l. f)) Z - e e (k. k d e (l. l)) (g e) (c d e b (e e (c (c d e f)))) (d (e e (k. k d e (l. l))) (k. k i)) (k. i (l. c (c d e f))) (k. h) Z - f (k. f) (k. f) (f h) (f h (c d e (f i))) (k. b) (f i (c d e)) (k. h) Z - g e f (f (k. f) (f (k. f) (k. l. f)) (c d e b)) (f (k. f) (k. f) (k. l. l) b) (f (k. h)) (c d e (f i) (e e) (g e) (k. l. e)) (f (k. f) f) (f (k. f) (k. f) (k. l. l) (c (k. i (l. c (c d e f))))) Z diff --git a/ocaml/problems/o b/ocaml/problems/o deleted file mode 100644 index d85ca2e..0000000 --- a/ocaml/problems/o +++ /dev/null @@ -1,21 +0,0 @@ -$! o1 -N x a b Z - x (_. BOT) c Z - -$! o2 -N x (y (_. BOT) a) c Z - x (y a PAC) d Z - -$! o3 -D y (x a1 BOMB c) (x BOMB b1 d) -C y (x a2 BOMB c) (x BOMB b1 d) - y (x a1 BOMB c) (x BOMB b2 d) - - -$! o4 -D x BOMB a1 c -C x y BOMB d - -$! o6 -D x BOMB -C x y diff --git a/ocaml/problems/p b/ocaml/problems/p deleted file mode 100644 index 27315d0..0000000 --- a/ocaml/problems/p +++ /dev/null @@ -1,172 +0,0 @@ - -$! p2 -N x y Z - x z Z - x (y z) Z - -$! p4 -N x y Z - x (a. a x) Z - y (y z) Z - -$! p5 -N a (x. x a) b Z - b (x. x b) a Z - -$! p6 -N a (x. x a) b Z - b (x. x b) (c a) Z - -$! p7 -N a (x. (x a) (a x x a) (x x) ) Z - -$! p8 -N x x (x x) Z - -$! p9 -N x x (x x x) (x x (x x)) (x x (x x x)) x x Z - -$! p10 -N x (y (x a b c)) Z - -$! p11 -N x x Z - x (y.y) Z - -$! p12 -N x x (x x) Z - x x (x (y.y)) Z - -$! p13 -N x x (x x (x x x x x (x x))) Z - -$! p14 -N a (a a (a (a a)) (a (a a))) Z - -$! p15 -N a (a (a a)) (a a (a a) (a (a (a a))) (a (a a)) (a a (a a) (a (a (a a))) (a (a a)))) (a a (a a) (a (a (a a))) (a (a a))) Z - -$! p16: -N a (a a) (a a (a (a a)) (a (a a)) (a a (a (a a)) a)) Z - -$! p17 -N b a Z - b (c.a) Z - -$! p18 -N a (a a) (a a a (a (a (a a) a)) (a a a (a (a (a a) a)))) Z - a a Z - a (a a) Z - -$! p19 -N a (a a) (a a a (a (a (a a) a)) a) Z - -$! p20 -N a (a b) (b (a b) (a (a b))) (a (a b) (a (a b)) (a (a b)) c) (a (a b) (a (a b)) (b (a b)) c (a a (a (a b) (a (a b)) b)) (a (a b) (a (a b)) (b (a b)) (a a) (a c (b (a b))))) Z - -$! p21 -N (((y z) (y z)) ((z (y z)) ((y z) (z z)))) Z - (((z z) x) (y z)) Z - ((z (y z)) ((y z) (z z))) Z - -$! p22 -N ((z y) ((((y (z y)) x) (y (z y))) ((y (z y)) (z z)))) Z - ((z y) (((((y (z y)) x) (y (z y))) ((y (z y)) (z z))) (((((y (z y)) x) (y (z y))) ((y (z y)) (z z))) ((x y) (z z))))) Z - (y ((((y (z y)) x) (y (z y))) ((y (z y)) (z z)))) Z - -$! p23 -# (* diverging tests *) (* test p23 leads to test p24 *) -N z z z Z - z (z z) (x. x) Z - -$! p24 -# (* because of the last term, the magic number is 1 and we diverge - but setting the magic number to 0 allows to solve the problem - thus our strategy is incomplete *) -N b b Z - b f Z - f b Z - a (x.x) Z - -$! p25 -# (* because of the last term, the magic number is 1 and we diverge - but setting the magic number to 0 allows to solve the problem - thus our strategy is incomplete *) -N b b Z - b f Z - f b Z - f (x.x) Z - -$! p26 - (* BUG: - 0 (n (d (o.n) ...))) - After instantiating n, the magic number (for d) should be 2, not 1! *) -N (((x y) (z. (y. (y. z)))) (z. y)) Z - (((x y) x) (y y)) Z - -$! p27 -N (((((((z y) (z (z y))) (z (z y))) ((z y) (((z y) (z (z y))) ((z y) x)))) (((((z y) (z (z y))) (z (z y))) x) y)) (((((z y) (z (z y))) (z (z y))) ((z y) (((z y) (z (z y))) ((z y) x)))) (((((z y) (z (z y))) (z (z y))) x) y))) ((((((z y) (z (z y))) (z (z y))) ((z y) (((z y) (z (z y))) ((z y) x)))) (((((z y) (z (z y))) (z (z y))) x) y)) (((((z y) (z (z y))) (z (z y))) ((z y) (((z y) (z (z y))) ((z y) x)))) (((((z y) (z (z y))) (z (z y))) x) y)))) Z - ((((((z y) (z (z y))) (z (z y))) ((z y) (((z y) (z (z y))) ((z y) x)))) (((((z y) (z (z y))) (z (z y))) x) y)) (((((z y) (z (z y))) (z (z y))) ((z y) (((z y) (z (z y))) ((z y) x)))) (((((z y) (z (z y))) (z (z y))) x) y))) Z - (((((z y) (z (z y))) (z (z y))) ((z y) (((z y) (z (z y))) ((z y) x)))) (((((z y) (z (z y))) (z (z y))) x) y)) Z - -$! p28 -N ((((z (x. (z. (x. x)))) (z x)) x) (z (x. (z. (x. x))))) Z - (((z (x. (z. (x. x)))) (z x)) ((z x) (x. (z. (x. x))))) Z - -$! p29 -N ((((((x x) (x x)) (z. (y x))) (z. ((x x) y))) y) ((x x) y)) Z - (((((x x) (x x)) (z. (y x))) (z. ((x x) y))) y) Z - -$! p30 -N ((b c) (b. (z a))) Z - ((v (a. (z v))) ((y (b c)) ((z a) (v y)))) Z - ((v (v. c)) z) Z - ((v y) (v (a. (z v)))) Z - ((y (b c)) ((z a) (v y))) Z - -$! p31 -N (((((((v (((a v) w) (((a v) w) v))) (w. c)) (b (a v))) c) (z. a)) (x. (w. (w. c)))) (((a (y c)) ((y c) ((a v) (w (z. a))))) (w. c))) Z - ((((((v (((a v) w) (((a v) w) v))) (w. c)) (b (a v))) c) (z. a)) (x. (w. (w. c)))) Z - (((((b (a v)) (a. (y c))) z) (w. w)) ((a c) c)) Z - (((((v (((a v) w) (((a v) w) v))) (w. c)) (b (a v))) c) (z. a)) Z - ((((a (y c)) ((y c) ((a v) (w (z. a))))) (w. c)) (x. w)) Z - -$? p32 -# should fail because the first and second terms are eta-eq -N (((((a y) v) (z a)) (z (((z a) (z a)) (w. v)))) (y. (a y))) Z - (((((a y) v) (z a)) (z (((z a) (z a)) (w. v)))) a) Z - (((((z a) (z a)) b) (v. (v. (z a)))) (v. ((a y) v))) Z - ((((a y) v) (z a)) (z (((z a) (z a)) (w. v)))) Z - ((((w (a. (z. ((z a) (z a))))) (v. ((a y) v))) (((z a) (z a)) b)) (w. (((z a) (z a)) (c. (c ((z a) (z a))))))) Z - -$! p33 - (* Shows an error when the strategy that minimizes special_k is NOT used *) -N ((((((v (y. v)) (w. (c. y))) ((((a (c. y)) (v w)) ((b (z (a (c. y)))) (b (z (a (c. y)))))) ((a (c. y)) b))) (((y (y (v w))) z) ((((a (c. y)) (v w)) ((b (z (a (c. y)))) (b (z (a (c. y)))))) ((a (c. y)) b)))) (b c)) (((v w) (z (a (c. y)))) ((y b) (b (z (a (c. y))))))) Z - ((((((a (c. y)) (v w)) ((b (z (a (c. y)))) (b (z (a (c. y)))))) ((a (c. y)) b)) (c. y)) (c. y)) Z - (((((a (c. y)) (v w)) ((b (z (a (c. y)))) (b (z (a (c. y)))))) ((a (c. y)) b)) (c. y)) Z - (((((a (c. y)) (v w)) ((b (z (a (c. y)))) (b (z (a (c. y)))))) (b (z (a (c. y))))) ((c b) (b. (b w)))) Z -# (* "(((((a (c. y)) b) v) (z (a (c. y)))) (a. (b (z (a (c. y))))))" *) - -$! p34 -N b c (b c) (c (d (j. e))) (b c (b c) (j.c f)) (b f (j. k. d)) (b (j. k. l. b c (b c)) (b g)) a Z - d (j. e) e (j. c f) (j. c j) b a Z - d (j. e) e (j. c f) b (b c (b c) (j. c f)) a Z - d (j. e) e (j. c f) b (b c (b c) (j. c f) (g b)) a Z - d (j. e) e (j. c f) b (j. k. j (l. e) e (l. k f) b) a Z - -$! p35 -N (((((((((b z) v) (a ((v (y y)) (v (y y))))) (y (v (y y)))) ((w ((a b) z)) (a ((v (y y)) (v (y y)))))) (z ((y (v (y y))) b))) (((y (v (y y))) ((y (v (y y))) x)) ((((c (a b)) (y y)) ((y (v (y y))) b)) (((c (a b)) (y y)) ((y (v (y y))) b))))) (z (z b))) ((y y) (((b z) v) (a ((v (y y)) (v (y y))))))) Z - ((((((((a b) z) w) (((b z) v) (a ((v (y y)) (v (y y)))))) ((y y) ((y (v (y y))) b))) ((((((c (a b)) (y y)) ((y (v (y y))) b)) (((c (a b)) (y y)) ((y (v (y y))) b))) (((((c (a b)) (y y)) (y (v (y y)))) (z w)) ((w (((v (y y)) (v (y y))) a)) (w (z ((y (v (y y))) b)))))) (z w))) (((((((b z) v) (a ((v (y y)) (v (y y))))) (y (v (y y)))) ((w ((a b) z)) (a ((v (y y)) (v (y y)))))) (z ((y (v (y y))) b))) (c (a b)))) (((((b z) (c b)) (c ((v (y y)) (v (y y))))) (((((c (a b)) (y y)) ((y (v (y y))) b)) Z (((c (a b)) (y y)) ((y (v (y y))) b))) ((c b) (z (z b))))) (((((((b z) v) (a ((v (y y)) (v (y y))))) (y (v (y y)))) (b (((v (y y)) (v (y y))) ((y y) (z (z b)))))) (((((w ((a b) z)) (a ((v (y y)) (v (y y))))) (((v (y y)) (v (y y))) a)) (((((b z) v) (a ((v (y y)) (v (y y))))) (y (v (y y)))) (b (((v (y y)) (v (y y))) ((y y) (z (z b))))))) (b z))) ((x ((c b) (c b))) (((((b z) v) (a ((v (y y)) (v (y y))))) (y (v (y y)))) ((w ((a b) z)) (a ((v (y y)) (v (y y)))))))))) Z - ((((((((b z) v) (a ((v (y y)) (v (y y))))) (y (v (y y)))) ((w ((a b) z)) (a ((v (y y)) (v (y y)))))) (z ((y (v (y y))) b))) (((y (v (y y))) ((y (v (y y))) x)) ((((c (a b)) (y y)) ((y (v (y y))) b)) (((c (a b)) (y y)) ((y (v (y y))) b))))) (v (y y))) Z - -$! p36 -N (((((((y a) (((z v) (y a)) (b a))) ((b a) (b a))) (((y c) (x a)) (v (((y a) (((z v) (y a)) (b a))) z)))) ((b a) (b a))) ((a c) (b (((y a) (((z v) (y a)) (b a))) (z a))))) ((((((b (((y a) (((z v) (y a)) (b a))) z)) (c ((y (x a)) ((z v) (y a))))) (v (((y a) (((z v) (y a)) (b a))) z))) (((((y a) (((z v) (y a)) (b a))) z) (((z v) (y a)) (c y))) ((x a) (((y a) (((z v) (y a)) (b a))) z)))) ((c ((y (x a)) ((z v) (y a)))) (b (((y a) (((z v) (y a)) (b a))) z)))) ((((b (z a)) (y a)) (y c)) (a (((((y a) (((z v) (y a)) (b a))) ((b a) (b a))) (x a)) ((((y a) (((z v) (y a)) (b a))) z) (((z v) (y a)) (c y)))))))) Z - (((((((z v) (y a)) (b a)) w) b) (((b a) ((((z v) (y a)) (b a)) w)) ((((z v) (y a)) (b a)) w))) (((b a) ((((y a) (((z v) (y a)) (b a))) ((((y a) (((z v) (y a)) (b a))) ((b a) (b a))) (x a))) w)) (((c y) a) v))) Z - (((((((z v) (y a)) (b a)) w) b) (a (((((y a) (((z v) (y a)) (b a))) ((b a) (b a))) (x a)) ((((y a) (((z v) (y a)) (b a))) z) (((z v) (y a)) (c y)))))) ((((y a) (((z v) (y a)) (b a))) ((((y a) (((z v) (y a)) (b a))) ((b a) (b a))) (x a))) x)) Z - - -$! p37 - issue with eta-equality of terms in ps -N x (a y) z Z - x (a z. y z) w Z - a c Z diff --git a/ocaml/problems/q b/ocaml/problems/q deleted file mode 100644 index a641409..0000000 --- a/ocaml/problems/q +++ /dev/null @@ -1,66 +0,0 @@ -$! q1 -C a d e -N a b Z - a c Z - -$! q2 -C a d e -N a b Z - -$! q3 -D x y -C a d e f -N a b Z - -$! q4 -C f (x.a b c d) -N a b Z - -$! q5 -D x y -C (y. x) -N x Z - -$! q6 -D x w -C (y. x z) -N y Z - -$! q7 -D (b (c d (e f f k.(g e))) f) -C (g (e f) (g e h) (f d (e f) k.e) k.(c d l.(c d)) (f d k.g (b (g (e f)) (b (g (e f)) (e f)) (g (e f) (g e h)))) k.l.(h f (b i))) - (g (e f) (g e h) (f d (e f) k.e) k.(c d l.(c d)) (b (g (e f))) k.l.(g f (k f f (k f f m.(g k))))) - (b (g (e f)) f k.e k.l.(f d (e f)) (c d (e f f k.(g e)) (g k.(e f f))) (h f (i (h k.(i b l.m.n.e))))) -N (f d (e f) k.e k.l.(c d) (b (g e) k.h) (i b k.l.m.e b) a) Z - (f d (e f) k.e k.l.(c d) (b (g e) k.h) (d k.e) (f d (e f) k.e) a) Z - (g (e f) (g e h) (f d (e f) k.e) k.(c d l.(c d)) (g e h) (g f (e f f (e f f k.(g e))) (g (e f)) (b (c d (e f f k.(g e))) (b (g (e f)) (e f)) (b (g (e f)) k.l.e))) a) Z - -################################################################################ - -$! q8 -D x a -C y (x b c) -N j Z - -$! q9 -D x a -C y x -N a (y a b b b) Z - -$! q11 -D x y -C a (x z) - -$! q10 -D b (k. c) d (e (f g) (k. g)) (k. l. c) (k. l. b (m. c)) (k. l. c) (b (k. c) (k. l. b (m. c)) (k. c f) (k. e (f g))) (b (k. c) (k. e) f (b (k. c) (k. l. b (m. c)) (k. c f)) (b (k. c) (k. e) f (b (k. c) (k. l. b (m. c)) (k. c f))) (k. b (l. c) b (l. b (m. c))) (k. b (l. c))) -C e (f g) (k. g) (c f) (k. e) (k. b (l. c) d (b (l. c))) (c f (k. b (l. c)) (k. l. b (m. c))) (k. l. b (m. c) d (l (f k) (m. k)) (m. n. c)) (c f (k. b (l. c)) (k. b (l. c) d) (k. c k)) - e (f g) (k. g) (c f) (k. i) (k. l. h) (k. l. m. n. m) (b (k. c) (k. l. b (m. c)) (k. c f)) (k. l. m. k (f g) (n. g) (c f) (n. k)) - b (k. c) (k. e) f (b (k. c) (k. l. b (m. c)) (k. c f)) (b (k. c) (k. e) f (b (k. c) (k. l. b (m. c)) (k. c f))) (k. b (l. c) b (l. b (m. c))) (k. b (l. c)) - b (k. c) d (e (f g) (k. g)) (k. l. m. n. m) (k. l. m. b (n. k) d (b (n. k))) (b (k. c) (k. e) (k. l. m. b (n. c))) (e (f g) (k. g) (c f) (k. i) (k. l. h) (k. l. m. n. m) (b (k. c) (k. l. b (m. c)) (k. c f)) (k. l. m. k (f g) (n. g) (c f) (n. k))) - b (k. c) d (e (f g) (k. g)) (k. l. c) (k. l. b (m. c)) (k. l. c) (b (k. c) (k. l. b (m. c)) (k. c f) (k. e (f g))) - -N b (k. c) (k. e) f (b (k. c) (k. l. b (m. c)) (k. c f)) (b (k. c) (k. e) f (b (k. c) (k. l. b (m. c)) (k. c f))) (k. b (l. c) b (l. b (m. c))) (e (f g) (k. g) (c f) (c f (k. b (l. c)) (k. e))) Z - b (k. c) d (e (f g) (k. g)) (k. l. m. n. m) (k. l. m. b (n. k) d (b (n. k))) (e (f g) (k. g) (c f) (k. e) (k. b (l. c) d (b (l. c)))) (k. e (f g) (l. g) (c f) (l. k) (l. m. h)) Z - b (k. c) d (e (f g) (k. g)) (k. l. c) (k. l. b (m. c)) (k. l. m. n. o. p. o) (e (f g) (k. g) (c f) (k. i) f) Z - b (k. c) d (e (f g) (k. g)) (k. l. c) (k. l. b (m. c)) (k. l. c) (k. b) Z - e (f g) (k. g) (c f) (k. e) (k. b (l. c)) (c f (k. b (l. c)) (k. l. b (m. k))) (k. b (l. k)) (e (f g) (k. g) (c f) (c f (k. b (l. c)) (k. e))) Z diff --git a/ocaml/problems/solved b/ocaml/problems/solved deleted file mode 100644 index 6ea3dd2..0000000 --- a/ocaml/problems/solved +++ /dev/null @@ -1,3 +0,0 @@ -$! Scott mk_math with empty bs -D b (_. _. BOT) -C b diff --git a/ocaml/problems/w b/ocaml/problems/w deleted file mode 100644 index e3a5dd2..0000000 --- a/ocaml/problems/w +++ /dev/null @@ -1,68 +0,0 @@ -$? w1 -D x y -C x BOMB - -$? w2 -D x y z -C x BOMB z - x y y - -$! w3 -D b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))) (d b (k. b) (f g (e f))) (c (e h)) (k. b c d (l. c (l k)) (b c (l. e e) (b c d (l. e l) (e e (b (l. m. b)) d (l. d))) (l. c))) -C b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))) (d b (k. b) (f g (e f))) (c (e h)) (e e (b (k. l. b)) (k. e k)) (k. e e) (k. g (l. g (m. b c)) (l. i (f g))) -C b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))) (d b (k. b) (f g (e f))) (c (e h)) (d b (k. b)) (k. d k (k (l. m. k)) (c (e h))) (b c (k. c (e h))) -C b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))) (d b (k. b) (f g (e f))) (c (e h)) (e e (b (k. l. b)) (k. e k)) (k. e e) -C b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))) (d b (k. b) (f g (e f))) (c (e h)) (d b (k. b)) (k. d k (k (l. m. k)) (c (e h))) -C b (k. l. b) (e f) (b c d) (e e (b (k. l. b)) d) (e (k. l. b c) (k. l. b k) (b c)) d (e e (e e) (d (k. f)) (b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))))) (e e (b (k. l. b)) (b (k. l. b) (e f) (b c d)) (e e (b (k. l. b)) d (k. d) (b (k. l. b))) (k. b c k (l. e l) (e e (b (l. m. b)) k (l. k)) (f g (c (e h))) (k b (l. b) (f g (e f))) (c (e h))) (k. i (f g) (l. l))) -N b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))) (d b (k. b) (f g (e f))) (c (e h)) (d b (k. b)) (k. l. c (l k)) Z - b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))) (d b (k. b) (f g (e f))) (c (e h)) (e e (b (k. l. b)) (k. e k)) Z - b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))) (d b (k. b) (f g (e f))) (c (e h)) (e e (b (k. l. b)) (k. e k)) (k. l. c (k h)) Z - b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))) (d b (k. b) (f g (e f))) (c (e h)) (e e (b (k. l. b)) (k. e k)) (k. l. c (k h)) (d b (b c d (k. c (k h))) (b c d (k. e k) (b c))) Z - b c d (k. e k) (e e (b (k. l. b)) d (k. d)) (f g (c (e h))) (d b (k. b) (f g (e f))) (c (e h)) (e e (b (k. l. b)) (k. e k)) (k. b k d (l. e l) (e e (b (l. m. b)) d (l. d)) (f g (k (e h)))) Z - -$! w4 -D b (c b) (k. d) (e f (k. e) (k. b) (f d)) (e f (k. g k) d) (k. c k (c k g)) -C c (k. l. l b k) (k. l. d) (e f (k. k) (g e)) (k. l. m. n. n b m) (k. b (b (k e))) (k. g) (e f (k. k (g e) h) b (e (k. g) (h c (g c) f))) - e f (k. k) (k. l. c b) (k. l. l (k b) g) (k. e f (l. l)) (h c (c (k. l. l b k) (k. l. d) (e f (k. k) (g e))) (k. g e (g e))) (k. g (l. e f g) (l. h c) (g (l. e f g) (l. h c))) - e f (k. k (g e) h) (g (k. e f g) (c (c b g) (k. l. l b g))) (k. k (g e) h) (k. h) (b (b (g e)) (k. c (l. m. m b l))) (k. l. g l (g l) (m. c b)) - c (k. l. l b k) (k. l. d) (e f (k. k) (g e)) (k. l. m. n. n b m) (k. b (b (k e))) (k. g) - e f (k. k) (g e) (e f (k. e)) (e f (k. e)) (h c (b (g e) h (k. c (l. m. m k l)))) -N c (k. l. l b k) (k. l. d) (e f (k. k) (g e)) (k. l. m. n. n b m) (k. b (b (k e))) (k. i) Z - e f (k. k (g e) h) (g (k. e f g) (c (c b g) (k. l. l b g))) (k. k (g e) h) (k. h) (b (b (g e)) (k. c (l. m. m b l))) (h (c b) g i) Z - e f (k. k) (g e) (e f (k. e)) (h (k. g e (g e)) (h (k. g e (g e)))) (k. d) Z - e f (k. k) (g e) (e f (k. e)) (h (k. g e (g e)) (h (k. g e (g e)))) (k. d) (k. l. m. c k) Z - g (k. e f g) (k. h c) (b (g e) h (k. c (l. m. m k l))) (k. c b g) (k. e f (l. l) (g e) (e f (l. e))) f Z - -# This was failing because special_k was too low -$! low special_k -D x PAC PAC PAC PAC PAC a -C x PAC PAC PAC PAC PAC b -N y x - y z -# In general: - DIV x (n times PAC) a - CON x (n times PAC) b - 1 y (m times lambda. x) 0 - 2 y z 0 - when x steps on the n+1-th argument, - y must apply n+m+1 variables - Thus special_k must be >=n+m+1 - -$! eatable right away -D y y -C x (_. y y) - - -#$? should raise a parsing error -# (div occurs as subterm at top-level in conv and ps) - D (a b) - C ((((((((a (v (y. y))) (v c)) ((x ((a (v (y. y))) (v c))) y)) (((a (v (y. y))) (((v c) ((((z z) b) (c. a)) (w (c. (v c))))) (w. (v. (z. (v (y. y))))))) (((v (x. (v c))) (v (x. (v c)))) (((((z z) b) (c. a)) (z z)) (b c))))) (a. ((((z z) b)(c. a)) (z z)))) (y. (z z))) (((a (v (y. y))) w) (z. x))) (w. (z. (v (y. y))))) - C ((((((((z z) b) (c. a)) (z z)) ((v (y. y)) a)) (v (y. y))) ((((a (v (y. y))) (v c)) (z z)) ((a (v (y. y))) (((v c) ((((z z) b) (c. a)) (w (c. (v c))))) (w. (v. (z. (v (y. y))))))))) (z. ((v (y. y)) a))) - C (((((((a (v (y. y))) w) (a b)) ((b (x. (b. a))) (b. (v. ((((z z) b) (c. a)) (z z)))))) (a. (z. (b. w)))) (x. (((w v) ((z z) (a (v (y. y))))) ((a (v (y. y))) (v c))))) (((z z) (a (v (y. y)))) (b. a))) - C (((((((z z) b) (c. a)) (z z)) (b c)) (b. a)) (((v (x. (v c))) (((v (x. (v c))) ((z z) b)) (a. (w. (v. (z. (v (y. y)))))))) ((x ((a (v (y. y))) (v c))) (b. (c. y))))) - C (((((((z z) b) (c. a)) (z z)) (b c)) (b. a)) (y. (x. z))) - N ((((((((a (v (y. y))) w) (a b)) ((b (x. (b. a))) (b. (v. ((((z z) b) (c. a)) (z z)))))) (a. (z. (b. w)))) (x. (((w v)((z z) (a (v (y. y))))) ((a (v (y. y))) (v c))))) (((z z) (a (v (y. y)))) (b. a))) (w. ((((w v) ((z z) (a (v (y. y)))))((a (v (y. y))) (v c))) (((((v c) ((((z z) b) (c. a)) (w (c. (v c))))) (w. (v. (z. (v (y. y)))))) ((z z) a)) (y. ((v c)((((z z) b) (c. a)) (w (c. (v c)))))))))) Z - N (((((((a (v (y. y))) (v c)) ((x ((a (v (y. y))) (v c))) y)) (((a (v (y. y))) (((v c) ((((z z) b) (c. a)) (w (c. (v c))))) (w. (v. (z. (v (y. y))))))) (((v (x. (v c))) (v (x. (v c)))) (((((z z) b) (c. a)) (z z)) (b c))))) (a. ((((z z) b) (c. a)) (z z)))) (y. (z z))) (((a (v (y. y))) w) (z. x))) Z - N (((((((z z) b) (c. a)) (z z)) ((v (y. y)) a)) (v (y. y))) ((((a (v (y. y))) (v c)) (z z)) ((a (v (y. y))) (((v c) ((((z z) b) (c. a)) (w (c. (v c))))) (w. (v. (z. (v (y. y))))))))) Z - N (((((((z z) b) (c. a)) (z z)) (b c)) (b. a)) (y. (x ((z z) a)))) Z - N (((((((z z) b) (c. a)) (z z)) (b c)) (x. (((z z) b) (c. a)))) (((v c) ((((z z) b) (c. a)) (w (c. (v c))))) (w. (v. (z. (v (y. y))))))) Z diff --git a/ocaml/ptest.ml b/ocaml/ptest.ml deleted file mode 100644 index 8a21229..0000000 --- a/ocaml/ptest.ml +++ /dev/null @@ -1,16 +0,0 @@ -open Unix;; -let process_output_to_list2 = fun command -> - let chan = open_process_in command in - let res = ref ([] : string list) in - let rec process_otl_aux () = - let e = input_line chan in - res := e::!res; - process_otl_aux() in - try process_otl_aux () - with End_of_file -> - let stat = close_process_in chan in (List.rev !res,stat) -let cmd_to_list command = - let (l,_) = process_output_to_list2 command in l;; - -let lines = cmd_to_list "tput cols" in -prerr_endline (List.hd (lines));; diff --git a/ocaml/pure.ml b/ocaml/pure.ml deleted file mode 100644 index 51d1feb..0000000 --- a/ocaml/pure.ml +++ /dev/null @@ -1,130 +0,0 @@ -open Util.Vars - -module Pure = -struct - -type t = - | V of int - | A of t * t - | L of t - | B - -let rec print ?(l=[]) = - function - V n -> print_name l n - | A(t1,t2) -> "(" ^ print ~l t1 ^ " " ^ print ~l t2 ^ ")" - | L t -> - let name = string_of_var (List.length l) in - "λ" ^ name ^ "." ^ print ~l:(name::l) t - | B -> "B" - -let lift m = - let rec aux l = - function - | V n -> V (if n < l then n else n+m) - | A (t1,t2) -> A (aux l t1, aux l t2) - | L t -> L (aux (l+1) t) - | B -> B - in - aux 0 - -(* Reference implementation. - Reduction machine used below -let subst delift_by_one what with_what = - let rec aux l = - function - | A(t1,t2) -> A(aux l t1, aux l t2) - | V n -> - if n = what + l then - lift l with_what - else - V (if delift_by_one && n >= l then n-1 else n) - | L t -> L (aux (l+1) t) - in - aux 0 - -let rec whd = - function - | A(t1, t2) -> - let t2 = whd t2 in - let t1 = whd t1 in - (match t1 with - | L f -> whd (subst true 0 t2 f) - | V _ - | A _ -> A(t1,t2)) - | V _ - | L _ as t -> t -*) - -let unwind ?(tbl = Hashtbl.create 317) m = - let rec unwind (e,t,s) = - let cache_unwind m = - try - Hashtbl.find tbl m - with - Not_found -> - let t = unwind m in - Hashtbl.add tbl m t ; - t in - let s = List.map cache_unwind s in - let rec aux l = - function - | A(t1,t2) -> A(aux l t1, aux l t2) - | V n as x when n < l -> x - | V n -> - (try - lift l (cache_unwind (List.nth e (n - l))) - with Failure _ -> V (n - l)) - | L t -> L (aux (l+1) t) - | B -> B in - let t = aux 0 t in - List.fold_left (fun f a -> A(f,a)) t s -in - unwind m - -let mwhd m = - let rec aux = - function - | (e,A(t1,t2),s) -> - let t2' = aux (e,t2,[]) in - let (_,t,_) = t2' in - if t = B - then t2' - else aux (e,t1,t2'::s) - | (e,L t,x::s) -> aux (x::e,t,s) - | (e,V n,s) as m -> - (try - let e,t,s' = List.nth e n in - aux (e,t,s'@s) - with Failure _ -> m) - | (e, B, _) -> (e, B, []) - | (_,L _,[]) as m -> m - in - unwind (aux m) - -end - -module Scott = -struct - -open Pure - -let rec mk_n n = - if n = 0 then L (L (A (V 1, L (V 0)))) else L (L (A (V 0, mk_n (n-1)))) - -let dummy = V (max_int / 2) - -let mk_match t bs = - let bs = List.sort (fun (n1,_) (n2,_) -> compare n1 n2) bs in - let rec aux m t = - function - [] -> A (L dummy, t) - | (n,p)::tl as l -> - if n = m then - A (A (t, L (lift (m+1) p)), L (aux (m+1) (V 0) tl)) - else - A (A (t, dummy), L (aux (m+1) (V 0) l)) - in - aux 0 t bs - -end diff --git a/ocaml/pure.mli b/ocaml/pure.mli deleted file mode 100644 index a6b90ac..0000000 --- a/ocaml/pure.mli +++ /dev/null @@ -1,15 +0,0 @@ -module Pure : - sig - type t = V of int | A of t * t | L of t | B - val print : ?l:string list -> t -> string - val lift : int -> t -> t - val unwind : ?tbl:('a list * t * 'a list as 'a, t) Hashtbl.t -> 'a -> t - val mwhd : (('a * t * ('b list as 'c) as 'b) list as 'a) * t * 'c -> t - end - -module Scott : - sig - val mk_n : int -> Pure.t - val dummy : Pure.t - val mk_match : Pure.t -> (int * Pure.t) list -> Pure.t - end diff --git a/ocaml/run b/ocaml/run deleted file mode 100644 index 77957cd..0000000 --- a/ocaml/run +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -file=`mktemp` - -echo -echo "Running test. Log file: $file." -echo - -trap 'echo' SIGINT - - -./test4.out 2>&1 | tee $file | stdbuf -o0 grep -Po '(?<=measure=)[^ ]*' | stdbuf -o0 tr '\n' ' ' - -if [ $? -eq 0 ] -then - rm $file - echo - echo 'Test succeeded' -else - echo '' - echo 'Test failed or interrupted' - echo "Please have a look at log file: $file ." -fi diff --git a/ocaml/sat.ml b/ocaml/sat.ml deleted file mode 100644 index 01d7398..0000000 --- a/ocaml/sat.ml +++ /dev/null @@ -1,535 +0,0 @@ -(* - Reductions from SAT and 3-colorability of graphs to separation - of lambda-terms. Commented out the encoding from SAT. -*) - -open Util;; - -(* type cnf = int list list;; - -let (++) f g x = f (g x);; - -let maxvar : cnf -> int = - let aux f = List.fold_left (fun acc x -> max acc (f x)) 0 in - aux (aux abs) -;; *) - -type graph = (int * int) list;; -type color = int;; - -let arc x y = min x y, max x y;; -let mem g x y = List.mem (arc x y) g;; - -(* let reduction_sat_3col p = - let triangle a0 a1 a2 = [arc a0 a1; arc a0 a2; arc a1 a2] in - let init0 = triangle 0 1 2 in - (* 0false; 1true; 2base*) - let n = maxvar p in - let init1 = Array.to_list (Array.mapi (fun i () -> triangle (2*i+1) (2*(i+1)) 2) (Array.make n ())) in - let freshno = ref (2 * n + 3) in - let mk_triangle () = - let i = !freshno in - freshno := i+3; i, i+1, i+2 in - let rec translate = function - | [] -> assert false - | x::[] -> [triangle 0 2 x] - | x::y::l -> - let a,b,c = mk_triangle () in - triangle a b c :: [arc x a; arc y b] :: translate (c::l) in - let p = List.map (List.map (fun x -> - if x = 0 then assert false - else if x < 0 then 2 * (abs x + 1) - else 2 * x + 1 - )) p in - let init2 = List.map (List.concat ++ translate) p in - !freshno, init0 @ List.concat (init1 @ init2) -;; - -let string_of_graph g = - String.concat " " (List.map (fun (x,y) -> string_of_int x ^ "<>" ^ string_of_int y) g) -;; *) - -(* let main p = - let mv = maxvar p in - prerr_endline (string_of_int mv); - let _, g = reduction_sat_3col p in - prerr_endline (string_of_graph g); - generate ;; - -prerr_endline (main[ - [1; -2; 3]; - [2; 4; -5] -]);; *) - -let p_ = "BOMB ";; -let x_ = "x ";; -(* y, z dummies *) -let y_ = "y ";; -let z_ = "z ";; -(* a, b endline separators *) -let a_ = "a ";; -let b_ = "b ";; - -let generate g n max = - (* 0 <= n <= max+1 *) - let three f sep = - String.concat sep (List.map f [0;1;2]) in - let rec aux' n m color = - if m = -1 then x_ - else aux' n (m-1) color ^ - if n = m then - (if List.mem (n,n) g then p_^p_^p_ (* cappio nel grafo *) - else three (fun c -> if color = c then y_ else p_) "") - else if n < m then y_^y_^y_ - else if List.mem (m,n) g then - three (fun c -> if color = c then p_ else y_) "" - else y_^y_^y_ in - let rec aux m = - if m = -1 then x_ - else aux (m-1) ^ - if n < m then p_^p_^p_ - else if n = m then - "(_." ^ three (aux' n max) "b) (_." ^ "b) " - else y_^y_^y_ - in aux max ^ a_ -;; - -let generate2 g n max = - let rec aux m = - if m = -1 then x_ - else aux (m-1) ^ - if n < m then p_^p_^p_ - else if n = m - then z_^z_^z_ - else y_^y_^y_ - in aux max ^ p_ -;; - - -let encode_graph g = - let g = List.map (fun (x,y) -> min x y, max x y) g in - let mapi f a = Array.to_list (Array.mapi f a) in - let nodex_no = - List.fold_left (fun acc (a,b) -> Pervasives.max acc (Pervasives.max a b)) 0 in - String.concat "\n" ("\n$ problem from 3-colorability" :: - let no = nodex_no g in - mapi (fun i () -> - (if i = no+1 then "D " else "C ") ^ generate g i no - ) (Array.make (no+2) ()) @ - mapi (fun i () -> - "C " ^ generate2 g i no - ) (Array.make (no+1) ()); - ) -;; - -print_endline "Three example encodings:";; - -(* easy one *) -prerr_endline (encode_graph [0,1;]);; - -(* two imopssible problems *) -prerr_endline ( - encode_graph [0,1; 1,1] -);; -prerr_endline ( - encode_graph [0,1; 0,2; 1,2; 0,3; 1,3; 2,3] -);; - -(******************************************************************************) - -print_endline "\nIt will now run some problems and decode the solutions";; -print_endline "Press ENTER to continue.";; -let _ = read_line ();; - -let strip_lambda_matches = - let getvar = function - | `Var(n,_) -> n - | _ -> assert false in - let rec aux n = function - | `Lam(_,t) -> aux (n+1) t - | `Match(_,_,_,bs,_) -> Some (n, List.map (getvar ++ snd) !bs) - | _ -> None - in aux 0 -;; - -let next_candidates sigma cands = - let sigma = Util.filter_map - (fun x -> try Some (List.assoc x sigma) with Not_found -> None) cands in - match Util.find_opt strip_lambda_matches sigma with - | None -> -1, [] - | Some x -> x -;; - -let fix_numbers l = - let rec aux n = function - | [] -> [] - | x::xs -> (x - 2*n - 1) :: (aux (n+1) xs) - in aux 0 l -;; - -let color (g:graph) = - let p = encode_graph g in - let (_, _, _, _, vars as p) = Parser.problem_of_string p in - let _, result = Lambda4.solve (Lambda4.problem_of p) in - match result with - | `Unseparable _ -> prerr_endline "Graph not colorable"; None - | `Separable sigma -> ( - (* start from variable x *) - let x = Util.index_of "x" vars in - (* List.iter (fun x -> prerr_endline (string_of_int (fst x) ^ ":" ^ Num.print ~l:vars (snd x))) sigma; *) - let rec iter f x = - let n, x = f x in if x = [] then [] else n :: iter f x in - let numbers = iter (next_candidates sigma) [x] in - let numbers = fix_numbers numbers in - (* display solution *) - let colors = ["r"; "g"; "b"] in - prerr_endline ("\nSolution found:\n " ^ String.concat "\n " - (List.mapi (fun i x -> - string_of_int i ^ " := " ^ List.nth colors x) numbers)); - assert (List.for_all (fun (a,b) -> List.nth numbers a <> List.nth numbers b) g); - Some numbers) -;; - -let bruteforce g = - let nodes_no = 1+ - List.fold_left (fun acc (a,b) -> Pervasives.max acc (Pervasives.max a b)) 0 g in - let check x = if List.for_all (fun (a,b) -> List.nth x a <> List.nth x b) g - then failwith "bruteforce: sat" in - let rec guess l = prerr_string "+"; - if List.length l = nodes_no - then check l - else (guess (0::l); guess (1::l); guess (2::l)) in - guess []; - prerr_endline "bruteforce: unsat" -;; - -assert (color [0,1;0,2;1,2;2,3;3,0] <> None);; -assert (color [0,1;0,2;1,2;2,3;3,0;0,4;4,2] <> None);; - -(* assert (color [ - 1,2; 1,4; 1,7; 1,9; 2,3; 2,6; 2,8; 3,5; - 3,7; 3,0; 4,5; 4,6; 4,0; 5,8; 5,9; 6,11; - 7,11; 8,11; 9,11; 0,11; -] = None);; *) - -(* https://turing.cs.hbg.psu.edu/txn131/file_instances/coloring/graph_color/queen5_5.col *) -color [1,7 -; 1,13 -; 1,19 -; 1,25 -; 1,2 -; 1,3 -; 1,4 -; 1,5 -; 1,6 -; 1,11 -; 1,16 -; 1,21 -; 2,8 -; 2,14 -; 2,20 -; 2,6 -; 2,3 -; 2,4 -; 2,5 -; 2,7 -; 2,12 -; 2,17 -; 2,22 -; 2,1 -; 3,9 -; 3,15 -; 3,7 -; 3,11 -; 3,4 -; 3,5 -; 3,8 -; 3,13 -; 3,18 -; 3,23 -; 3,2 -; 3,1 -; 4,10 -; 4,8 -; 4,12 -; 4,16 -; 4,5 -; 4,9 -; 4,14 -; 4,19 -; 4,24 -; 4,3 -; 4,2 -; 4,1 -; 5,9 -; 5,13 -; 5,17 -; 5,21 -; 5,10 -; 5,15 -; 5,20 -; 5,25 -; 5,4 -; 5,3 -; 5,2 -; 5,1 -; 6,12 -; 6,18 -; 6,24 -; 6,7 -; 6,8 -; 6,9 -; 6,10 -; 6,11 -; 6,16 -; 6,21 -; 6,2 -; 6,1 -; 7,13 -; 7,19 -; 7,25 -; 7,11 -; 7,8 -; 7,9 -; 7,10 -; 7,12 -; 7,17 -; 7,22 -; 7,6 -; 7,3 -; 7,2 -; 7,1 -; 8,14 -; 8,20 -; 8,12 -; 8,16 -; 8,9 -; 8,10 -; 8,13 -; 8,18 -; 8,23 -; 8,7 -; 8,6 -; 8,4 -; 8,3 -; 8,2 -; 9,15 -; 9,13 -; 9,17 -; 9,21 -; 9,10 -; 9,14 -; 9,19 -; 9,24 -; 9,8 -; 9,7 -; 9,6 -; 9,5 -; 9,4 -; 9,3 -; 10,14 -; 10,18 -; 10,22 -; 10,15 -; 10,20 -; 10,25 -; 10,9 -; 10,8 -; 10,7 -; 10,6 -; 10,5 -; 10,4 -; 11,17 -; 11,23 -; 11,12 -; 11,13 -; 11,14 -; 11,15 -; 11,16 -; 11,21 -; 11,7 -; 11,6 -; 11,3 -; 11,1 -; 12,18 -; 12,24 -; 12,16 -; 12,13 -; 12,14 -; 12,15 -; 12,17 -; 12,22 -; 12,11 -; 12,8 -; 12,7 -; 12,6 -; 12,4 -; 12,2 -; 13,19 -; 13,25 -; 13,17 -; 13,21 -; 13,14 -; 13,15 -; 13,18 -; 13,23 -; 13,12 -; 13,11 -; 13,9 -; 13,8 -; 13,7 -; 13,5 -; 13,3 -; 13,1 -; 14,20 -; 14,18 -; 14,22 -; 14,15 -; 14,19 -; 14,24 -; 14,13 -; 14,12 -; 14,11 -; 14,10 -; 14,9 -; 14,8 -; 14,4 -; 14,2 -; 15,19 -; 15,23 -; 15,20 -; 15,25 -; 15,14 -; 15,13 -; 15,12 -; 15,11 -; 15,10 -; 15,9 -; 15,5 -; 15,3 -; 16,22 -; 16,17 -; 16,18 -; 16,19 -; 16,20 -; 16,21 -; 16,12 -; 16,11 -; 16,8 -; 16,6 -; 16,4 -; 16,1 -; 17,23 -; 17,21 -; 17,18 -; 17,19 -; 17,20 -; 17,22 -; 17,16 -; 17,13 -; 17,12 -; 17,11 -; 17,9 -; 17,7 -; 17,5 -; 17,2 -; 18,24 -; 18,22 -; 18,19 -; 18,20 -; 18,23 -; 18,17 -; 18,16 -; 18,14 -; 18,13 -; 18,12 -; 18,10 -; 18,8 -; 18,6 -; 18,3 -; 19,25 -; 19,23 -; 19,20 -; 19,24 -; 19,18 -; 19,17 -; 19,16 -; 19,15 -; 19,14 -; 19,13 -; 19,9 -; 19,7 -; 19,4 -; 19,1 -; 20,24 -; 20,25 -; 20,19 -; 20,18 -; 20,17 -; 20,16 -; 20,15 -; 20,14 -; 20,10 -; 20,8 -; 20,5 -; 20,2 -; 21,22 -; 21,23 -; 21,24 -; 21,25 -; 21,17 -; 21,16 -; 21,13 -; 21,11 -; 21,9 -; 21,6 -; 21,5 -; 21,1 -; 22,23 -; 22,24 -; 22,25 -; 22,21 -; 22,18 -; 22,17 -; 22,16 -; 22,14 -; 22,12 -; 22,10 -; 22,7 -; 22,2 -; 23,24 -; 23,25 -; 23,22 -; 23,21 -; 23,19 -; 23,18 -; 23,17 -; 23,15 -; 23,13 -; 23,11 -; 23,8 -; 23,3 -; 24,25 -; 24,23 -; 24,22 -; 24,21 -; 24,20 -; 24,19 -; 24,18 -; 24,14 -; 24,12 -; 24,9 -; 24,6 -; 24,4 -; 25,24 -; 25,23 -; 25,22 -; 25,21 -; 25,20 -; 25,19 -; 25,15 -; 25,13 -; 25,10 -; 25,7 -; 25,5 -; 25,1];; diff --git a/ocaml/sat.mli b/ocaml/sat.mli deleted file mode 100644 index 81d7ee7..0000000 --- a/ocaml/sat.mli +++ /dev/null @@ -1,5 +0,0 @@ -type graph = (int * int) list -type color - -val encode_graph : graph -> string -val color: graph -> (color list) option diff --git a/ocaml/test.ml b/ocaml/test.ml deleted file mode 100644 index 629bf89..0000000 --- a/ocaml/test.ml +++ /dev/null @@ -1,109 +0,0 @@ -open Lambda4;; -open Util;; - -let acaso l = - let n = Random.int (List.length l) in - List.nth l n -;; - -let acaso2 l1 l2 = - let n1 = List.length l1 in - let n = Random.int (n1 + List.length l2) in - if n >= n1 then List.nth l2 (n - n1) else List.nth l1 n -;; - -(** with bombs and pacmans too *) -let acaso3 l1 l2 = - if Random.int 10 = 0 then ( - if Random.int 2 = 0 then "BOMB" else "PAC" - ) else - let n1 = List.length l1 in - let n = Random.int (n1 + List.length l2) in - if n >= n1 then List.nth l2 (n - n1) else List.nth l1 n -;; - -(* let rec take l n = - if n = 0 then [] - else match l with - | [] -> [] - | x::xs -> x :: (take xs (n-1)) -;; *) - -let gen n vars = - let rec take' l n = - if n = 0 then [], [] - else match l with - | [] -> [], [] - | [_] -> assert false - | x1::x2::xs -> let a, b = take' xs (n-1) in x1::a,x2::b in - let rec aux n inerts lams = - if n = 0 then List.hd inerts, take' (Util.sort_uniq (List.tl inerts)) 5 - else let inerts, lams = if Random.int 2 = 0 - then inerts, ("(" ^ acaso vars ^ ". " ^ acaso2 inerts lams ^ ")") :: lams - else ("(" ^ acaso inerts ^ " " ^ acaso2 inerts lams^ ")") :: inerts, lams - in aux (n-1) inerts lams - in aux (2*n) vars [] -;; - -let gen_pac n vars = - let rec take' l n = - if n = 0 then [], [] - else match l with - | [] -> [], [] - | [_] -> assert false - | x1::x2::xs -> let a, b = take' xs (n-1) in x1::a,x2::b in - let rec aux n inerts lams = - if n = 0 then List.hd inerts, take' (Util.sort_uniq (List.tl inerts)) 5 - else let inerts, lams = if Random.int 2 = 0 - then inerts, ("(" ^ acaso vars ^ ". " ^ acaso3 inerts lams ^ ")") :: lams - else ("(" ^ acaso inerts ^ " " ^ acaso3 inerts lams^ ")") :: inerts, lams - in aux (n-1) inerts lams - in aux (2*n) vars [] -;; - - -let rec repeat f n = - prerr_endline "\n########################### NEW TEST ###########################"; - f () ; - if n > 0 then repeat f (n-1) -;; - -let solve div convs nums label = - let p = String.concat "\n" ( - ("$! randomly generated test " ^ label) :: - ("D " ^ div) :: - List.map ((^) "C ") convs @ - List.map (fun s -> "N " ^ s ^ " Z") nums - ) in - prerr_endline p; - match (Lambda4.solve ++ Lambda4.problem_of ++ Parser.problem_of_string) p with - | `Uncomplete, `Unseparable _ -> - failwith ("Test4.solve: unseparable, and cannot tell if that's right or not.") - | _ -> () -;; - -let main = - Random.self_init (); - (* num = number of tests to run *) - let num = 100 in - (* if flag --with-pac active, then more general tests *) - let with_pac = List.mem "--with-pac" (Array.to_list Sys.argv) in - - let label, f = if with_pac - then ( - let complex = 10 in - let vars = ["x"; "y"; "z"; "v" ; "w"; "a"; "b"; "c"] in - "with pacmans & bombs", fun () -> gen_pac complex vars - ) else ( - let complex = 200 in - let vars = ["x"; "y"; "z"; "v" ; "w"; "a"; "b"; "c"] in - "", fun () -> gen complex vars - ) in - - repeat (fun _ -> - let div, (conv, nums) = f () in - solve div conv nums label - ) num; - - prerr_endline "\n---- ALL TESTS COMPLETED ----" -;; diff --git a/ocaml/tmp.ml b/ocaml/tmp.ml deleted file mode 100644 index 624875f..0000000 --- a/ocaml/tmp.ml +++ /dev/null @@ -1,38 +0,0 @@ -(((((((v (((a v) w) (((a v) w) v))) (w. c)) (b (a v))) c) (z. a)) (x. (w. (w. c)))) (((a (y c)) ((y c) ((a v) (w (z. a))))) (w. c))) -((((((v (((a v) w) (((a v) w) v))) (w. c)) (b (a v))) c) (z. a)) (x. (w. (w. c)))) -(((((b (a v)) (a. (y c))) z) (w. w)) ((a c) c)) -(((((v (((a v) w) (((a v) w) v))) (w. c)) (b (a v))) c) (z. a)) -((((a (y c)) ((y c) ((a v) (w (z. a))))) (w. c)) (x. w)) - - - - - - - - - - - - - - -let fancy_of_term : nf -> Console.fancyobj = - let open Console in - let of_var level n = - if n < level - then fancy_of_string (string_of_var n) - else (("x" ^ string_of_int (level-n-1)) / ("var" ^ string_of_int (n-level) ^ "")) - in let rec aux level = function - `Var n -> of_var level n - | `N n -> fancy_of_string (string_of_int n) - | `Match(t,bs_lift,bs,args) -> - "([" ^^ aux level (t :> nf) ^^ - " ? " ^ String.concat " | " (List.map (fun (n,t) -> string_of_int n ^ " => " ^ print ~l (lift bs_lift t)) !bs) ^ "] " ^ - String.concat " " (List.map (print ~l) args) ^ ")" - | `I(n,args) -> "(" ^ print_name l n ^ " " ^ String.concat " " (Listx.to_list (Listx.map (print ~l) args)) ^ ")" - | `Lam nf -> - let name = string_of_var (List.length l) in - "λ" ^ name ^ "." ^ print ~l:(name::l) (nf : nf) - in aux 0 -;; diff --git a/ocaml/util.ml b/ocaml/util.ml deleted file mode 100644 index a87b96f..0000000 --- a/ocaml/util.ml +++ /dev/null @@ -1,118 +0,0 @@ -(* Function composition *) -let (++) f g x = f (g x);; - -let findi p = - let rec aux n = function - | [] -> raise Not_found - | x::_ when p x -> n, x - | _::xs -> aux (n+1) xs - in aux 0 -;; - -let option_map f = function - | None -> None - | Some x -> Some (f x) -;; - -let option_get = function - | Some x -> x - | None -> failwith "option_get: None" -;; - -let rec find_opt f = - function - [] -> None - | x::xs -> - match f x with - None -> find_opt f xs - | Some _ as res -> res - -let rec index_of ?(eq=(=)) x = - function - [] -> raise Not_found - | y::_ when eq x y -> 0 - | _::l -> 1 + index_of ~eq x l - -let index_of_opt ?eq l t = - try - Some (index_of ?eq t l) - with - Not_found -> None -;; - -let rec filter_map f = - function - [] -> [] - | hd::tl -> - match f hd with - None -> filter_map f tl - | Some x -> x::filter_map f tl -;; - -(* the input must be sorted *) -let rec first_duplicate = - function - [] - | [_] -> None - | x::y::_ when x=y -> Some x - | _::tl -> first_duplicate tl - -(* the input must be sorted - output: list of non duplicates; list of duplicates *) -let rec split_duplicates = - function - [] -> [],[] - | [x] -> [x],[] - | x::(y::_ as tl) -> - let nondup,dup = split_duplicates tl in - if x = y then - List.filter ((<>) x) nondup, x::dup - else - x::nondup,dup - -(* Non c'e' nella vecchia versione di OCaml :( *) -let uniq ?(compare=compare) = - let rec aux = function - | [] -> [] - | [_] as ts -> ts - | t1 :: (t2 :: _ as ts) -> - if compare t1 t2 = 0 then aux ts else t1 :: (aux ts) - in aux - -let sort_uniq ?(compare=compare) l = uniq ~compare (List.sort compare l) - -let rec list_cut = function - | 0, lst -> [], lst - | n, x::xs -> let a, b = list_cut (n-1,xs) in x::a, b - | _ -> assert false -;; - -let concat_map f l = List.concat (List.map f l);; - -let rec take n = - function - | [] -> assert (n = 0); [] - | _ when n = 0 -> [] - | x::xs -> x::(take (n-1) xs) -;; - -module Vars = -struct - -let string_of_var v = - if v > 25 - then "`" ^ string_of_int v - else String.make 1 (char_of_int (v + int_of_char 'a')) -;; - -let var_of_string s = - if String.length s <> 1 then ( - if s.[0] = '`' then int_of_string (String.sub s 1 (-1 + String.length s)) else assert false - ) else int_of_char s.[0] - int_of_char 'a' - -let print_name l n = - if n = -1 - then "*" - else if n >= List.length l then "x" ^ string_of_int (List.length l - n - 1) else List.nth l n - -end diff --git a/ocaml/util.mli b/ocaml/util.mli deleted file mode 100644 index 96f03ed..0000000 --- a/ocaml/util.mli +++ /dev/null @@ -1,21 +0,0 @@ -val ( ++ ) : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b -val findi : ('a -> bool) -> 'a list -> (int * 'a) -val option_map : ('a -> 'b) -> 'a option -> 'b option -val option_get : ('a option) -> 'a -val find_opt : ('a -> 'b option) -> 'a list -> 'b option -val index_of : ?eq:('a -> 'a -> bool) -> 'a -> 'a list -> int -val index_of_opt : ?eq:('a -> 'a -> bool) -> 'a list -> 'a -> int option -val filter_map : ('a -> 'b option) -> 'a list -> 'b list -val first_duplicate : 'a list -> 'a option -val split_duplicates : 'a list -> 'a list * 'a list -val uniq : ?compare:('a -> 'a -> int) -> 'a list -> 'a list -val sort_uniq : ?compare:('a -> 'a -> int) -> 'a list -> 'a list -val list_cut : (int * 'a list) -> ('a list * 'a list) -val concat_map : ('a -> 'b list) -> 'a list -> 'b list -val take : int -> 'a list -> 'a list -module Vars : - sig - val string_of_var : int -> string - val var_of_string : string -> int - val print_name : string list -> int -> string - end diff --git a/ocaml_new/.depend b/ocaml_new/.depend new file mode 100644 index 0000000..ca50e1f --- /dev/null +++ b/ocaml_new/.depend @@ -0,0 +1,26 @@ +console.cmo : console.cmi +console.cmx : console.cmi +lambda4.cmo : util.cmi pure.cmi num.cmi listx.cmi console.cmi lambda4.cmi +lambda4.cmx : util.cmx pure.cmx num.cmx listx.cmx console.cmx lambda4.cmi +listx.cmo : listx.cmi +listx.cmx : listx.cmi +num.cmo : util.cmi pure.cmi listx.cmi num.cmi +num.cmx : util.cmx pure.cmx listx.cmx num.cmi +parser.cmo : util.cmi num.cmi listx.cmi parser.cmi +parser.cmx : util.cmx num.cmx listx.cmx parser.cmi +problems.cmo : util.cmi parser.cmi lambda4.cmi problems.cmi +problems.cmx : util.cmx parser.cmx lambda4.cmx problems.cmi +pure.cmo : util.cmi pure.cmi +pure.cmx : util.cmx pure.cmi +test.cmo : util.cmi parser.cmi lambda4.cmi +test.cmx : util.cmx parser.cmx lambda4.cmx +util.cmo : util.cmi +util.cmx : util.cmi +console.cmi : +lambda4.cmi : num.cmi +listx.cmi : +num.cmi : pure.cmi listx.cmi +parser.cmi : num.cmi +problems.cmi : lambda4.cmi +pure.cmi : +util.cmi : diff --git a/ocaml_new/Makefile b/ocaml_new/Makefile new file mode 100644 index 0000000..b662428 --- /dev/null +++ b/ocaml_new/Makefile @@ -0,0 +1,36 @@ +OCAMLC = ocamlopt -g -rectypes +LIB = unix.cmxa str.cmxa +UTILS = util.cmx console.cmx listx.cmx pure.cmx num.cmx parser.cmx + +all: a.out test4.out + +run: test4.out + bash run + +a.out: $(UTILS) lambda4.cmx problems.cmx + $(OCAMLC) -o a.out $(LIB) $^ + +sat.out: $(UTILS) lambda4.cmx sat.ml + $(OCAMLC) -o sat.out $(LIB) $^ +# +test4.out: $(UTILS) lambda4.cmx test.ml + $(OCAMLC) -o test4.out $(LIB) $^ + +andrea.out: $(UTILS) andrea8.ml + $(OCAMLC) -o andrea.out $(LIB) $(UTILS) andrea8.ml + +%.cmi: %.mli + $(OCAMLC) -c $< + +%.cmx: %.ml %.cmi + $(OCAMLC) -c $< + +clean: + rm -f *.cm* *.out *.o .depend log + +.depend: *.ml *.mli + ocamldep *.ml *.mli > .depend + +include .depend + +.PHONY: clean all run diff --git a/ocaml_new/console.ml b/ocaml_new/console.ml new file mode 100644 index 0000000..696a74d --- /dev/null +++ b/ocaml_new/console.ml @@ -0,0 +1,141 @@ +type fancyobj = < + to_string : unit -> string; + to_html : unit -> string +>;; + +let sepx = "\xe2\xbf\x96";; +let endx = "\xe2\xbf\x97";; + +let socket_name = "/tmp/fancy.log";; + +let html_enabled = Sys.file_exists socket_name;; + +let socket = let open Unix in + if html_enabled + then socket PF_UNIX SOCK_STREAM 0 + else socket PF_INET SOCK_STREAM 0;; + +let html_enabled = if html_enabled then + try + let _ = Unix.connect socket (Unix.ADDR_UNIX socket_name) in true + with Unix.Unix_error _ -> false + else false +;; + +let cols = + let process_output_to_list2 = fun command -> + let chan = Unix.open_process_in command in + let res = ref ([] : string list) in + let rec process_otl_aux () = + let e = input_line chan in + res := e::!res; + process_otl_aux() in + try process_otl_aux () + with End_of_file -> + let stat = Unix.close_process_in chan in (List.rev !res,stat) + in let cmd_to_list command = + let (l,_) = process_output_to_list2 command in l + in try let lines = cmd_to_list "tput cols" in int_of_string (List.hd (lines)) + with _ -> 100 (* default value *) +;; + +let writeall s = + let _ = Unix.send socket s 0 (String.length s) [] in () +;; + +let concat ls = (String.concat sepx ls) ^ endx;; + +(* HELO message *) +if html_enabled then + writeall(concat["helo"; String.concat " " (Array.to_list Sys.argv)]) +;; + + +(* let logs objs = + if html_enabled then ( + let strs = (List.map (fun x -> x#to_html()) objs) in + writeall (concat ("log" :: strs)) + ); prerr_endline (String.concat " " (List.map (fun x -> x#to_string()) objs)) +;; *) + +let html_escape s = + let m = [("&", "&"); (">", ">"); ("<", "<"); (""", "\""); ("'", "'")] + in let m = List.map (fun (x,y) -> Str.regexp x, y) m + in List.fold_right (fun (x,y) z -> Str.global_replace x y z) m s;; (* FIXME TODO *) + +let fancy_of_string s : fancyobj = object + method to_string () = s + method to_html () = html_escape s +end;; + +let empty = fancy_of_string "";; + +let line = ref empty;; + +let (/) a b = object + method to_string () = a + method to_html () = b +end;; + +let (^^) a b = object + method to_string () = (a#to_string () ^ "" ^ b#to_string ()) + method to_html () = a#to_html () ^ " " ^ b#to_html () +end;; + +(* Output functions on standard output *) + +let print_string s = + line := !line ^^ fancy_of_string s +;; + +let print_char c = + print_string (String.make 1 c) +;; + +(* let print_bytes : bytes -> unit *) + +let print_int n = + print_string (string_of_int n) +;; + +(* val print_float : float -> unit *) + +let print_newline () = + if !line <> empty then ( + Pervasives.print_endline (!line#to_string()); + if html_enabled then (writeall (concat ["log"; !line#to_html()])); + line := empty + ) +;; + +let print f = + line := !line ^^ f +;; + +let print_string_endline f = + print (fancy_of_string f); print_newline () +;; + +let print_endline f = + print f; print_newline () +;; + +let print_hline () = + print_newline (); + print_endline ( String.make cols '-' / "
") +;; + +let print_heading s = + print_newline (); + print_endline (("# " ^ s) / ("

" ^ html_escape s ^ "

")) +;; + +let print_bullet f = + print_newline (); + print_endline (("- " / "")) +;; + +let print_math s = + print_endline ( s / "" ); + if html_enabled then (writeall (concat ["math"; s])) +;; diff --git a/ocaml_new/console.mli b/ocaml_new/console.mli new file mode 100644 index 0000000..e3b769b --- /dev/null +++ b/ocaml_new/console.mli @@ -0,0 +1,24 @@ +type fancyobj + +val fancy_of_string: string -> fancyobj + +val (^^) : fancyobj -> fancyobj -> fancyobj +val (/) : string -> string -> fancyobj + + +val print_char : char -> unit +val print_string : string -> unit +val print_string_endline : string -> unit +(* val print_bytes : bytes -> unit *) +val print_int : int -> unit +(* val print_float : float -> unit *) + +val print : fancyobj -> unit +val print_endline : fancyobj -> unit + +val print_newline : unit -> unit + +val print_hline : unit -> unit +val print_heading : string -> unit +val print_bullet : fancyobj -> unit +val print_math : string -> unit diff --git a/ocaml_new/lambda4.ml b/ocaml_new/lambda4.ml new file mode 100644 index 0000000..95dec1f --- /dev/null +++ b/ocaml_new/lambda4.ml @@ -0,0 +1,566 @@ +open Util +open Util.Vars +open Pure +open Num + +(* exceptions *) +exception Pacman +exception Bottom +exception Lambda +exception Backtrack of string + +(* verbosity *) +let _very_verbose = true;; +(** Display measure of every term when printing problem *) +let _measure_of_terms = false;; + +let verbose s = + if _very_verbose then prerr_endline s +;; + +type problem = + { freshno: int + ; div: i_var + ; conv: i_var list (* the inerts that must converge *) + ; sigma: (int * nf) list (* the computed substitution *) + ; initialSpecialK: int + ; label : string + ; var_names : string list (* names of the original free variables *) +} ;; + +let label_of_problem {label} = label;; + +let string_of_var l x = + try + List.nth l x + with Failure "nth" -> "`" ^ string_of_int x +;; +let string_of_term p t = print ~l:p.var_names (t :> nf);; + + +let first args p var f = + let rec aux = function + | [] -> + raise (Backtrack ("no more alternatives for " ^ string_of_var p.var_names var)) + | i::is -> try + f p i + with Backtrack s -> +prerr_endline (">>>>>> BACKTRACK (reason: " ^ s ^") measure=$ "); +prerr_endline("Now trying var="^string_of_var p.var_names var^" i="^string_of_int (i+1)); + aux is + in aux args + +let all_terms p = p.div :: p.conv ;; + +let measure_of_term, measure_of_terms = + let rec aux = function + | `Bottom | `Pacman -> 0 + | `Var(_,ar) -> if ar = min_int then 0 else max 0 ar (*assert (ar >= 0); ar*) + | `Lam(_,t) -> aux t + | `I(v,args) -> aux (`Var v) + aux_many (Listx.to_list args :> nf list) + and aux_many tms = List.fold_right ((+) ++ aux) tms 0 in + (fun t -> aux (t :> nf)), (fun l -> aux_many (l :> nf list)) +;; + +let sum_arities p = measure_of_terms (all_terms p) + +let problem_measure p = sum_arities p;; +let string_of_measure = string_of_int;; + +let string_of_problem label ({freshno; div; conv} as p) = + let aux_measure_terms t = if _measure_of_terms then "(" ^ string_of_int (measure_of_term t) ^ ") " else "" in + let l = p.var_names in + String.concat "\n" ([ + ""; + "# DISPLAY PROBLEM (" ^ label ^ ") " ^ "measure=" ^ string_of_measure (problem_measure p); + "#"; + "$" ^ p.label; + "D " ^ aux_measure_terms div ^ print ~l (div :> nf); + ] + @ List.map (fun t -> "C " ^ aux_measure_terms t ^ print ~l (t :> nf)) conv + @ [""]) +;; + + +let failwithProblem p reason = + print_endline (string_of_problem "FAIL" p); + failwith reason +;; + +let make_fresh_var p arity = + let freshno = p.freshno + 1 in + {p with freshno}, `Var(freshno,arity) +;; + +let make_fresh_vars p arities = + List.fold_right + (fun arity (p, vars) -> let p, var = make_fresh_var p arity in p, var::vars) + arities + (p, []) +;; + + +let fixpoint f = + let rec aux x = let x' = f x in if x <> x' then aux x' else x in aux +;; + + +let subst_in_problem x inst ({div; conv} as p) = +prerr_endline ("# INST0: " ^ string_of_var p.var_names x ^ " := " ^ string_of_term p inst); + let aux t = match t with + | #i_var as t -> t + | `Lam _ | `Bottom | `Pacman -> assert false (* ??? *) in + let div = (aux ++ (subst false false x inst)) (div :> nf) in + let conv = List.map (subst false false x inst) (conv :> nf list) in + let conv = List.filter (function `Lam _ -> false | _ -> true) conv in + let conv = List.map aux conv in + {p with div; conv} +;; + +exception Dangerous;; + +let arity_of arities hd = + let pos,_,nargs = List.find (fun (_,hd',_) -> hd=hd') arities in + nargs + if pos = -1 then - 1 else 0 +;; + +(* let rec dangerous arities showstoppers = + function + `N _ + | `Var _ + | `Lam _ + | `Pacman -> () + | `Match(t,_,liftno,bs,args) -> + (* CSC: XXX partial dependency on the encoding *) + (match t with + `N _ -> List.iter (dangerous arities showstoppers) args + | `Match _ as t -> dangerous arities showstoppers t ; List.iter (dangerous arities showstoppers) args + | `Var(x,_) -> dangerous_inert arities showstoppers x args 2 + | `I((x,_),args') -> dangerous_inert arities showstoppers x (Listx.to_list args' @ args) 2 + ) + | `I((k,_),args) -> dangerous_inert arities showstoppers k (Listx.to_list args) 0 + +and dangerous_inert arities showstoppers k args more_args = + List.iter (dangerous arities showstoppers) args ; + if List.mem k showstoppers then raise Dangerous else + try + let arity = arity_of arities k in + if List.length args + more_args > arity then raise Dangerous else () + with + Not_found -> () + +(* cut & paste from above *) +let rec dangerous_conv p arities showstoppers = + function + | `N _ + | `Var _ + | `Lam _ + | `Pacman -> () + | `Match(t,_,liftno,bs,args) -> ( + (* CSC: XXX partial dependency on the encoding *) + try (match t with + | `N _ -> List.iter (dangerous_conv p arities showstoppers) args + | `Match _ as t -> dangerous_conv p arities showstoppers t; List.iter (dangerous_conv p arities showstoppers) args + | `Var(x,_) -> dangerous_inert_conv p arities showstoppers x [] args 2 + | `I((x,_),args') -> dangerous_inert_conv p arities showstoppers x (Listx.to_list args') args 2 + ) with TriggerMatchReduction x -> ( + match Util.find_opt (fun (n, t) -> if hd_of (List.nth p.ps n) = Some x then Some t else None) !bs with + | None -> () + | Some t -> ( + match t with + | `Bottom -> raise Dangerous + | #nf_nob as t -> dangerous_conv p arities showstoppers t + ) + ) + ) + | `I((k,_),args) -> dangerous_inert_conv p arities showstoppers k (Listx.to_list args) [] 0 + +and dangerous_inert_conv p arities showstoppers k args match_args more_args = + let all_args = args @ match_args in + List.iter (dangerous_conv p arities showstoppers) all_args; + let all_args = (all_args :> nf list) in + if List.mem k showstoppers then raise Dangerous else + try + let arity = arity_of arities k in +prerr_endline ("dangerous_inert_conv: ar=" ^ string_of_int arity ^ " k="^string_of_var p.var_names k ^ " listlenargs=" ^ (string_of_int (List.length args)) ^ " more_args=" ^ string_of_int more_args); + if more_args > 0 (* match argument*) && List.length args = arity then raise (TriggerMatchReduction k) + else if List.length all_args + more_args > arity then raise Dangerous else () + with + Not_found -> () + +(* inefficient algorithm *) +let rec edible p arities showstoppers = + let rec aux f showstoppers tms = function + | [] -> showstoppers + | x::xs when List.exists (fun y -> hd_of x = Some y) showstoppers -> + (* se la testa di x e' uno show-stopper *) + let new_showstoppers = sort_uniq (showstoppers @ free_vars (x :> nf)) in + (* aggiungi tutte le variabili libere di x *) + if List.length showstoppers <> List.length new_showstoppers then + aux f new_showstoppers tms tms + else + aux f showstoppers tms xs + | x::xs -> + match hd_of x with + None -> aux f showstoppers tms xs + | Some h -> + try + f showstoppers (x :> nf_nob) ; + aux f showstoppers tms xs + with + Dangerous -> + aux f (sort_uniq (h::showstoppers)) tms tms + in + let showstoppers = sort_uniq (aux (dangerous arities) showstoppers p.ps p.ps) in + let dangerous_conv = sort_uniq (aux (dangerous_conv p arities) showstoppers p.conv p.conv) in + +(* prerr_endline ("dangerous_conv lenght:" ^ string_of_int (List.length dangerous_conv)); +List.iter (fun l -> prerr_endline (String.concat " " (List.map (string_of_var p.var_names) l))) dangerous_conv; *) + + let showstoppers' = showstoppers @ dangerous_conv in + let showstoppers' = sort_uniq (match p.div with + | None -> showstoppers' + | Some div -> + if List.exists ((=) (hd_of_i_var div)) showstoppers' + then showstoppers' @ free_vars (div :> nf) else showstoppers') in + if showstoppers <> showstoppers' then edible p arities showstoppers' else showstoppers', dangerous_conv +;; + +let precompute_edible_data {ps; div} xs = + let aux t = match t with `Var _ -> 0 | `I(_, args) -> Listx.length args | `N _ -> assert false in + (fun l -> match div with + | None -> l + | Some div -> (-1, hd_of_i_var div, aux div) :: l) + (List.map (fun hd -> + let i, tm = Util.findi (fun y -> hd_of y = Some hd) ps in + i, hd, aux tm + ) xs) +;; + +(** Returns (p, showstoppers_step, showstoppers_eat) where: + - showstoppers_step are the heads occurring twice + in the same discriminating set + - showstoppers_eat are the heads in ps having different number + of arguments *) +let critical_showstoppers p = + let p = super_simplify p in + let hd_of_div = match p.div with None -> [] | Some t -> [hd_of_i_var t] in + let showstoppers_step = + concat_map (fun bs -> + let heads = List.map (fun (i,_) -> List.nth p.ps i) !bs in + let heads = List.sort compare (hd_of_div @ filter_map hd_of heads) in + snd (split_duplicates heads) + ) p.deltas @ + if List.exists (fun t -> [hd_of t] = List.map (fun x -> Some x) hd_of_div) p.conv + then hd_of_div else [] in + let showstoppers_step = sort_uniq showstoppers_step in + let showstoppers_eat = + let heads_and_arities = + List.sort (fun (k,_) (h,_) -> compare k h) + (filter_map (function `Var(k,_) -> Some (k,0) | `I((k,_),args) -> Some (k,Listx.length args) | _ -> None ) p.ps) in + let rec multiple_arities = + function + [] + | [_] -> [] + | (x,i)::(y,j)::tl when x = y && i <> j -> + x::multiple_arities tl + | _::tl -> multiple_arities tl in + multiple_arities heads_and_arities in + + let showstoppers_eat = sort_uniq showstoppers_eat in + let showstoppers_eat = List.filter + (fun x -> not (List.mem x showstoppers_step)) + showstoppers_eat in + List.iter (fun v -> prerr_endline ("DANGEROUS STEP: " ^ (string_of_var p.var_names) v)) showstoppers_step; + List.iter (fun v -> prerr_endline ("DANGEROUS EAT: " ^ (string_of_var p.var_names) v)) showstoppers_eat; + p, showstoppers_step, showstoppers_eat + ;; + +let eat p = + let ({ps} as p), showstoppers_step, showstoppers_eat = critical_showstoppers p in + let showstoppers = showstoppers_step @ showstoppers_eat in + let heads = List.sort compare (filter_map hd_of ps) in + let arities = precompute_edible_data p (uniq heads) in + let inedible, showstoppers_conv = edible p arities showstoppers in + let l = List.filter (fun (_,hd,_) -> not (List.mem hd inedible)) arities in + let p = + List.fold_left (fun p (pos,hd,nargs) -> if pos = -1 then p else + let v = `N pos in + let inst = make_lams v nargs in +prerr_endline ("# [INST_IN_EAT] eating: " ^ string_of_var p.var_names hd ^ " := " ^ string_of_term p inst); + { p with sigma = p.sigma @ [hd,inst] } + ) p l in + (* to avoid applied numbers in safe positions that + trigger assert failures subst_in_problem x inst p*) + let ps = + List.map (fun t -> + try + let j,_,_ = List.find (fun (_,hd,_) -> hd_of t = Some hd) l in + `N j + with Not_found -> t + ) ps in + let p = match p.div with + | None -> p + | Some div -> + if List.mem (hd_of_i_var div) inedible + then p + else + let n = match div with `I(_,args) -> Listx.length args | `Var _ -> 0 in + let x = hd_of_i_var div in + let inst = make_lams `Bottom n in + subst_in_problem x inst p in +(*let dangerous_conv = showstoppers_conv in +prerr_endline ("dangerous_conv lenght:" ^ string_of_int (List.length dangerous_conv)); +List.iter (fun l -> prerr_endline (String.concat " " (List.map (string_of_var p.var_names) l))) dangerous_conv; *) + let conv = + List.map (function t -> + try + if let hd = hd_of t in hd <> None && not (List.mem (Util.option_get hd) showstoppers_conv) then t else ( + (match t with | `Var _ -> raise Not_found | _ -> ()); + let _ = List.find (fun h -> hd_of t = Some h) inedible in + t) + with Not_found -> match hd_of t with + | None -> assert (t = convergent_dummy); t + | Some h -> + prerr_endline ("FREEZING " ^ string_of_var p.var_names h); + convergent_dummy + ) p.conv in + List.iter + (fun bs -> + bs := + List.map + (fun (n,t as res) -> + match List.nth ps n with + `N m -> m,t + | _ -> res + ) !bs + ) p.deltas ; + let old_conv = p.conv in + let p = { p with ps; conv } in + if l <> [] || old_conv <> conv + then prerr_endline (string_of_problem "eat" p); + if List.for_all (function `N _ -> true | _ -> false) ps && p.div = None then + `Finished p + else + `Continue p + + +let safe_arity_of_var p x = + (* Compute the minimum number of arguments when x is in head + position at p.div or p.ps *) + let aux = function + | `Var(y,_) -> if x = y then 0 else max_int + | `I((y,_),args) -> if x = y then Listx.length args else max_int + | _ -> max_int in + let tms = ((match p.div with None -> [] | Some t -> [(t :> i_n_var)]) @ p.ps) in + List.fold_left (fun acc t -> Pervasives.min acc (aux t)) max_int tms +;; *) + +let instantiate p x perm = + let n = (prerr_endline ("WARNING: using constant initialSpecialK=" ^ string_of_int p.initialSpecialK)); p.initialSpecialK in + let arities = Array.to_list (Array.make (n+1) min_int) in + let p,vars = make_fresh_vars p arities in + (* manual lifting of vars by perm in next line *) + let vars = List.map (function `Var (n,ar) -> `Var (n+perm,ar)) vars in + (* other_vars are the variables which are delayed and re-applied to the match *) + let other_vars = Array.mapi (fun n () -> `Var(n+1,min_int)) (Array.make (perm-1) ()) in + let other_vars = Array.to_list other_vars in + (* 666, since it will be replaced anyway during subst: *) + (* let inst = `Match(`I((0,min_int),args),(x,-666),perm,bs,other_vars) in *) + let inst = `I((0,min_int),Listx.from_list (vars @ other_vars)) in (* FIXME *) + (* Add a number of 'perm' leading lambdas *) + let inst = Array.fold_left (fun t () -> `Lam(false, t)) inst (Array.make perm ()) in + let p = {p with sigma=(x,inst)::p.sigma} in + subst_in_problem x inst p +;; + +let compute_special_k tms = + let rec aux k (t: nf) = Pervasives.max k (match t with + | `Lam(b,t) -> aux (k + if b then 1 else 0) t + | `I(n, tms) -> Listx.max (Listx.map (aux 0) (tms :> nf Listx.listx)) + | `Bottom + | `Pacman + | `Var _ -> 0 + ) in + let rec aux' top t = match t with + | `Lam(_,t) -> aux' false t + | `I((_,ar), tms) -> max ar + (Listx.max (Listx.map (aux' false) (tms :> nf Listx.listx))) + | `Bottom + | `Pacman + | `Var _ -> 0 in + Listx.max (Listx.map (aux 0) tms) + Listx.max (Listx.map (aux' true) tms) +;; + +(* let choose_step p = + let p, showstoppers_step, showstoppers_eat = critical_showstoppers p in + let x = + match showstoppers_step, showstoppers_eat with + | [], y::_ -> + prerr_endline ("INSTANTIATING (critical eat) : " ^ string_of_var p.var_names y); y + | x::_, _ -> + prerr_endline ("INSTANTIATING (critical step): " ^ string_of_var p.var_names x); x + | [], [] -> + let heads = + (* Choose only variables still alive (with arity > 0) *) + List.sort compare (filter_map ( + fun t -> match t with `Var _ -> None | x -> if arity_of_hd x <= 0 then None else hd_of x + ) ((match p.div with Some t -> [(t :> i_n_var)] | _ -> []) @ p.ps)) in + (match heads with + | [] -> + (try + fst (List.find (((<) 0) ++ snd) (concat_map free_vars' (p.conv :> nf list))) + with + Not_found -> assert false) + | x::_ -> + prerr_endline ("INSTANTIATING TO EAT " ^ string_of_var p.var_names x); + x) in + let arity_of_x = Util.option_get (max_arity_tms x (all_terms p)) in + let safe_arity_of_x = safe_arity_of_var p x in + x, min arity_of_x safe_arity_of_x +;; *) + +let intersect l1 l2 = + let rec aux n l1 l2 = match l1, l2 with + | [], _ -> [] + | _, [] -> assert false + | x::xs, y::ys -> if x <> y then n :: aux (n+1) xs ys else aux (n+1) xs ys + in aux 1 (Listx.to_list l1) (Listx.to_list l2);; + +exception Difference of int list;; +let eat p = + let hd, args, n = match p.div with `Var _ -> assert false | `I((x,_), l) -> x, l, Listx.length l in + let rec aux = function + | `Var _ | `Lam _ -> () + | `Pacman | `Bottom -> assert false + | `I((x,_),args') -> + if x = hd then + if Listx.length args' >= n then + (let diff = intersect args args' in + if diff <> [] then raise (Difference diff)); + List.iter aux ((Listx.to_list args') :> nf list) in + try + List.iter aux (p.conv :> nf list) ; + `Finished {p with sigma=(hd,make_lams `Bottom n)::p.sigma} + with + Difference l -> `Continue (hd, l) +;; + +let rec auto_eat p = + prerr_endline (string_of_problem "auto_eat" p); + prerr_endline "{{{{{{{{ Computing measure before auto_instantiate }}}}}}"; + match eat p with + | `Finished p -> prerr_endline "finished"; p + | `Continue (x,positions) -> + let m = problem_measure p in + first positions p x (fun p j -> + let p = instantiate p x j in + prerr_endline "{{{{{{{{ Computing measure inafter auto_instantiate }}}}}}"; + let delta = problem_measure p - m in + if delta >= 0 + then + (prerr_endline + ("Measure did not decrease (+=" ^ string_of_int delta ^ ")")) + else prerr_endline ("$ Measure decreased: " ^ string_of_int delta); + auto_eat p) +;; + +(******************************************************************************) +let env_of_sigma freshno sigma = + let rec aux n = + if n > freshno then + [] + else + let e = aux (n+1) in + (try + e,Pure.lift (-n-1) (snd (List.find (fun (i,_) -> i = n) sigma)),[] + with + Not_found -> ([],Pure.V n,[]))::e + in aux 0 +;; +(* ************************************************************************** *) + +type response = [ + | `CompleteSeparable of string + | `CompleteUnseparable of string + | `Uncomplete +] + +type result = [ + `Complete | `Uncomplete +] * [ + | `Separable of (int * Num.nf) list + | `Unseparable of string +] + + +let run p = + Console.print_hline(); + prerr_endline (string_of_problem "main" p); + let p_finale = auto_eat p in + let freshno,sigma = p_finale.freshno, p_finale.sigma in + prerr_endline ("------- ------ measure=. \n "); + List.iter (fun (x,inst) -> prerr_endline (string_of_var p_finale.var_names x ^ " := " ^ string_of_term p_finale inst)) sigma; + + prerr_endline "------------------"; + let scott_of_nf t = ToScott.scott_of_nf (t :> nf) in + let div = scott_of_nf p.div in + let conv = List.map scott_of_nf p.conv in + + let sigma' = List.map (fun (x,inst) -> x, ToScott.scott_of_nf inst) sigma in + let e' = env_of_sigma freshno sigma' in + + prerr_endline "-----------------"; + (* print_endline (Pure.print div); *) + let t = Pure.mwhd (e',div,[]) in + prerr_endline ("*:: " ^ (Pure.print t)); + assert (t = Pure.B); + List.iter (fun n -> + (* verbose ("_::: " ^ (Pure.print n)); *) + let t = Pure.mwhd (e',n,[]) in + verbose ("_:: " ^ (Pure.print t)); + assert (t <> Pure.B) + ) conv ; + prerr_endline "-------- --------"; + p_finale.sigma +;; + +let solve (p, todo) = + let completeness, to_run = + match todo with + | `CompleteUnseparable s -> `Complete, `False s + | `CompleteSeparable _ -> `Complete, `True + | `Uncomplete -> `Uncomplete, `True in + completeness, match to_run with + | `False s -> `Unseparable s + | `True -> + try + `Separable (run p) + with + Backtrack _ -> `Unseparable "backtrack" +;; + +let no_bombs_pacmans p = + not (List.exists (eta_subterm `Bottom) p.conv) + && not (eta_subterm `Pacman p.div) +;; + +let check p = + if not (List.exists (eta_subterm p.div) p.conv) && no_bombs_pacmans p + then `CompleteSeparable "no bombs, pacmans and div" + (* il check seguente e' spostato nel parser e lancia un ParsingError *) + (* else if false (* TODO bombs or div fuori da lambda in ps@conv *) + then `CompleteUnseparable "bombs or div fuori da lambda in ps@conv" *) + else `Uncomplete +;; + +let problem_of (label, div, conv, var_names) = + (* TODO: replace div with bottom in problem??? *) + let all_tms = div :: conv in + if all_tms = [] then failwith "problem_of: empty problem"; + let initialSpecialK = compute_special_k (Listx.from_list (all_tms :> nf list)) in + let freshno = List.length var_names in + let sigma = [] in + let p = {freshno; div; conv; sigma; initialSpecialK; var_names; label} in + p, check p +;; diff --git a/ocaml_new/lambda4.mli b/ocaml_new/lambda4.mli new file mode 100644 index 0000000..8e5d78c --- /dev/null +++ b/ocaml_new/lambda4.mli @@ -0,0 +1,22 @@ +type problem + +val label_of_problem : problem -> string + +type response = [ + | `CompleteSeparable of string + | `CompleteUnseparable of string + | `Uncomplete +] + +type result = [ + `Complete | `Uncomplete +] * [ + | `Separable of (int * Num.nf) list + | `Unseparable of string +] + +val problem_of: (string (* problem label *) +* Num.i_var (* div *) +* Num.i_var list (* conv *) +* string list (* names of free variables *)) -> problem * response +val solve: problem * response -> result diff --git a/ocaml_new/listx.ml b/ocaml_new/listx.ml new file mode 100644 index 0000000..821e281 --- /dev/null +++ b/ocaml_new/listx.ml @@ -0,0 +1,71 @@ +(* Non-empty lists *) +type 'a listx = + | Nil of 'a + | Cons of ('a * 'a listx) + +let rec fold_left f acc l = + match l with + | Nil x -> f acc x + | Cons (x, l') -> fold_left f (f acc x) l' + +let hd = + function + | Nil x + | Cons (x,_) -> x + +let rec map f = + function + | Nil x -> Nil (f x) + | Cons (x, l') -> Cons (f x, map f l') + +let rec append l = + function + | Nil x -> Cons (x, l) + | Cons (x, l') -> Cons (x, append l l') + +let rec length = function + | Nil _ -> 1 + | Cons (_, xs) -> 1 + (length xs) + +let rec assoc x = function + | Nil (y,t) + | Cons ((y,t),_) when x=y -> t + | Nil _ -> raise Not_found + | Cons (_,l) -> assoc x l + +let rec to_list = + function + Nil x -> [x] + | Cons (x,l) -> x::to_list l + +let rec from_list = + function + [] -> raise (Failure "from_list: empty list") + | [x] -> Nil x + | x::l -> Cons(x,from_list l) + +let rec split_nth n l = + match n,l with + 0,_ -> [] + | 1,Nil x -> [x] + | n,Cons (hd,tl) -> hd::split_nth (n-1) tl + | _,_ -> raise (Failure "split_nth: not enough args") + +let rec max = + function + | Nil x -> x + | Cons (x, l) -> Pervasives.max x (max l) + +let rec last = + function + | Nil x -> x + | Cons (_, l) -> last l +(* +let rec nth i l = match l, i with + | Cons (x, _), 1 -> x + | _, n when n <= 0 -> raise (Invalid_argument "Listx.nth") + | Cons (_, xs), n -> nth (n-1) xs + | Nil x, 1 -> x + | Nil _, _ -> raise (Invalid_argument "Listx.nth") +;; +*) diff --git a/ocaml_new/listx.mli b/ocaml_new/listx.mli new file mode 100644 index 0000000..a43bc4e --- /dev/null +++ b/ocaml_new/listx.mli @@ -0,0 +1,12 @@ +type 'a listx = Nil of 'a | Cons of ('a * 'a listx) +val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b listx -> 'a +val hd : 'a listx -> 'a +val map : ('a -> 'b) -> 'a listx -> 'b listx +val append : 'a listx -> 'a listx -> 'a listx +val length : 'a listx -> int +val assoc : 'a -> ('a * 'b) listx -> 'b +val to_list : 'a listx -> 'a list +val from_list : 'a list -> 'a listx +val split_nth : int -> 'a listx -> 'a list +val max : 'a listx -> 'a +val last : 'a listx -> 'a diff --git a/ocaml_new/num.ml b/ocaml_new/num.ml new file mode 100644 index 0000000..f6b9405 --- /dev/null +++ b/ocaml_new/num.ml @@ -0,0 +1,265 @@ +open Util +open Util.Vars +open Pure + +(* debug options *) +let debug_display_arities = false;; + +(************ Syntax ************************************) + +(* Normal forms*) + +(* Var n = n-th De Bruijn index, 0-based *) + +(*type nf = + | Lam of nf + | Var of int + | i +and i = + | I of int * nf listx +;;*) +type var = int * (* arity of variable*) int;; +type 'nf_nob i_var_ = [ `I of var * 'nf_nob Listx.listx | `Var of var ] +type 'nf nf_nob_ = [ `Lam of (* was_unpacked *) bool * 'nf | `Pacman | ('nf nf_nob_) i_var_ ] +type nf = [ nf nf_nob_ | `Bottom ] +type nf_nob = nf nf_nob_ +type i_var = nf_nob i_var_;; + +let hd_of_i_var = + function + `I ((v,_),_) + | `Var (v,_) -> v + +let hd_of = + function + `I ((v,_),_) + | `Var(v,_) -> v + +let arity_of_hd = +function + `I ((_,a),_) +| `Var(_,a) -> a +| _ -> 0 (* FIXME? *) + +let lift m (t : nf) = + let aux_var l (n, ar) = (if n < l then n else n+m), ar in + let rec aux_i_num_var l = + function + `I(v,args) -> `I(aux_var l v, Listx.map (aux_nob l) args) + | `Var v -> `Var(aux_var l v) + and aux_nob l = + function + #i_var as x -> (aux_i_num_var l x :> nf_nob) + | `Lam(b,nf) -> `Lam (b, aux (l+1) nf) + | `Pacman -> `Pacman + and aux l = + function + #nf_nob as x -> (aux_nob l x :> nf) + | `Bottom -> `Bottom + in + (aux 0 t : nf) +;; + +(* put t under n lambdas, lifting t accordingtly *) +let rec make_lams t = + function + 0 -> t + | n when n > 0 -> `Lam (false, lift 1 (make_lams t (n-1))) + | _ -> assert false + +let free_vars' = + let rec aux n = function + | `Var(x,ar) -> if x < n then [] else [(x-n,ar)] + | `I((x,ar),args) -> + (if x < n then [] else [(x-n,ar)]) @ + List.concat (List.map (aux n) (Listx.to_list args :> nf list)) + | `Lam(_,t) -> aux (n+1) t + | `Bottom | `Pacman -> [] + in aux 0 +;; +let free_vars = (List.map fst) ++ free_vars';; + +module ToScott = +struct + +let rec scott_of_nf = function + | `Var(v,_) -> Pure.V v + | `I((v,_), args) -> Listx.fold_left (fun acc t -> Pure.A(acc,scott_of_nf t)) (Pure.V v) (args :> nf Listx.listx) + | `Lam(_,t) -> Pure.L (scott_of_nf t) + | `Bottom -> Pure.B + | `Pacman -> let f x = Pure.A (x,x) in f (Pure.L (Pure.L (f (Pure.V 0)))) +end + + +(************ Pretty-printing ************************************) + +(* let rec string_of_term l = fun _ -> "";; *) + +let rec string_of_term = + let boundvar x = "v" ^ string_of_int x in + let varname lev l n = + if n < lev then boundvar (lev-n-1) + else if n < List.length l then List.nth l (n-lev) + else "`" ^ string_of_int (n-lev) in + let rec string_of_term_w_pars lev l = function + | `Var(n,ar) -> varname lev l n ^ (if debug_display_arities then ":" ^ string_of_int ar else "") + | `I _ as t -> "(" ^ string_of_term_no_pars_app lev l t ^ ")" + | `Lam(_,`Bottom) -> "BOMB" + | `Lam _ as t -> "(" ^ string_of_term_no_pars_lam lev l t ^ ")" + | `Bottom -> "BOT" + | `Pacman -> "PAC" + and string_of_term_no_pars_app lev l = function + | `I((n,ar), args) -> varname lev l n ^ (if debug_display_arities then ":" ^ string_of_int ar else "") ^ " " ^ String.concat " " (List.map (string_of_term_w_pars lev l) (Listx.to_list args :> nf list)) + | #nf as t -> string_of_term_w_pars lev l t + and string_of_term_no_pars_lam lev l = function + | `Lam(_,`Bottom) -> "BOMB" + | `Lam(_,t) -> "λ" ^ boundvar lev ^ ". " ^ (string_of_term_no_pars_lam (lev+1) l t) + | _ as t -> string_of_term_no_pars lev l t + and string_of_term_no_pars lev l = function + | `Lam _ as t -> string_of_term_no_pars_lam lev l t + | #nf as t -> string_of_term_no_pars_app lev l t + in string_of_term_no_pars 0 +;; + +let print ?(l=[]) = string_of_term l;; +let string_of_nf t = string_of_term [] (t :> nf);; + +(************ Hereditary substitutions ************************************) + +let cast_to_i_var = + function + #i_var as y -> (y : i_var) + | t -> + prerr_endline (print (t :> nf)); + assert false (* algorithm failed *) + + +let rec set_arity arity = function +(* FIXME because onlt variables should be in branches of matches, one day *) +| `Var(n,_) -> `Var(n,arity) +| `Bottom | `Pacman as t -> (t : nf) +| `Lam(false, t) -> `Lam(false, set_arity arity (t :> nf)) +| `I _ | `Lam _ -> assert false + +let minus1 n = if n = min_int then n else n - 1;; + +let rec mk_app (h : nf) (arg : nf) = + match arg with + | `Bottom -> `Bottom + | #nf_nob as arg -> + match h with + | `I(v,args) -> `I(v,Listx.append (Listx.Nil arg) args) + | `Var v -> `I(v, Listx.Nil arg) + | `Lam(truelam,nf) -> subst truelam true 0 arg (nf : nf) (* AC FIXME sanity check on arity *) + | `Bottom | `Pacman as t -> t +(*in let l = ["v0";"v1";"v2"] in +prerr_endline ("mk_app h:" ^ print ~l h ^ " arg:" ^ print ~l:l arg ^ " res:" ^ print ~l:l res); res*) + +and mk_appl h args = + (*prerr_endline ("MK_APPL: " ^ print h ^ " " ^ String.concat " " (List.map print args));*) + List.fold_left mk_app h args + +and mk_appx h args = Listx.fold_left mk_app h args + + +and subst truelam delift_by_one what (with_what : nf(*_nob*)) (where : nf) = + let rec aux_propagate_arity ar = function + | `Lam(false, t) when not delift_by_one -> `Lam(false, aux_propagate_arity ar t) + | `Var(i,oldar) -> `Var(i, if truelam then (assert (oldar = min_int); ar) else oldar) + | _ as t -> t in + let rec aux_i_var l = + function + `I((n,ar),args) -> + if n = what + l then + let args = Listx.map (aux l) (args :> nf Listx.listx) in + mk_appx (lift l (aux_propagate_arity ar (with_what :> nf))) args + else + mk_appl (`Var ((if delift_by_one && n >= l then n-1 else n), ar)) (List.map (aux l) (Listx.to_list (args :> nf Listx.listx))) + | `Var(n,ar) -> + if n = what + l then + lift l (aux_propagate_arity ar (with_what :> nf)) + else + `Var((if delift_by_one && n >= l then n-1 else n), ar) + and aux l(*lift*) = +(*function iii -> let res = match iii with*) + function + | #i_var as x -> aux_i_var l x + | `Lam(b, nf) -> `Lam(b, aux (l+1) nf) + | `Bottom -> `Bottom + | `Pacman -> `Pacman +(*in let ll = ["v0";"v1";"v2"] in +prerr_endline ("subst l:" ^ string_of_int l ^ " delift_by_one:" ^ string_of_bool delift_by_one ^ " what:" ^ (List.nth ll what) ^ " with_what:" ^ print ~l:ll with_what ^ " where:" ^ print ~l:ll iii ^ " res:" ^ print ~l:ll res); res*) + in + aux 0 where +;; + +(************ Parsing ************************************) + +(************** Algorithm(s) ************************) + +let eta_compare x y = + (* let clex a b = let diff = ? a b in if diff = 0 then cont () else 0 in *) + let clex aux1 aux2 (a1,a2) (b1,b2) = + let diff = aux1 a1 b1 in if diff = 0 then aux2 a2 b2 else diff in + let rec lex aux l1 l2 = + match l1,l2 with + | [], [] -> 0 + | [], _ -> -1 + | _, [] -> 1 + | x::xs, y::ys -> clex aux (lex aux) (x,xs) (y,ys) in + let rec aux t1 t2 = match t1, t2 with + | `Var(n,_) , `Var(m,_) -> compare n m + | `I((n1,_), l1), `I((n2,_), l2) -> + clex compare (lex aux) (n1, (Listx.to_list l1 :> nf list)) (n2, (Listx.to_list l2 :> nf list)) + | `Bottom, `Bottom + | `Pacman, `Pacman -> 0 + | `Bottom, `Lam(_,t) -> -1 + | `Lam(_,t), `Bottom -> 1 + | `Lam(_,t1), `Lam(_,t2) -> aux t1 t2 + | `Lam(_,t1), t2 -> - aux t1 (mk_app (lift 1 t2) (`Var(0,-666))) + | t2, `Lam(_,t1) -> aux t1 (mk_app (lift 1 t2) (`Var(0,-666))) + | `I _, _ -> -1 + | _, `I _ -> 1 + | `Bottom, _ -> -1 + | _, `Bottom -> 1 + | `Pacman, _ -> -1 + | _, `Pacman -> 1 + in aux x y +;; + +let eta_eq (#nf as x) (#nf as y) = 0 = eta_compare x y ;; + +let rec eta_subterm sub t = + if eta_eq sub t then true else + match t with + | `Lam(_,t') -> eta_subterm (lift 1 sub) t' + | `Bottom + | `Pacman -> false + | `I((v,_), args) -> List.exists (eta_subterm sub) ((Listx.to_list args) :> nf list) || (match sub with + | `Var(v',_) -> v = v' + | `I((v',_), args') -> v = v' + && Listx.length args' < Listx.length args + && List.for_all (fun (x,y) -> eta_eq x y) (List.combine (Util.take (Listx.length args') (Listx.to_list args :> nf list)) (Listx.to_list args' :> nf list)) + | _ -> false + ) + | `Var _ -> false +;; + +let eta_subterm (#nf as x) (#nf as y) = eta_subterm x y;; + +let max_arity_tms n = + let max a b = match a, b with + | None, None -> None + | None, Some x + | Some x, None -> Some x + | Some x, Some y -> Some (Pervasives.max x y) in + let aux_var l (m,a) = if n + l = m then Some a else None in + let rec aux l = function + | `Var v -> aux_var l v + | `I(v,tms) -> max (aux_var l v) (aux_tms l (Listx.to_list tms :> nf list)) + | `Lam(_,t) -> aux (l+1) t + | `Bottom | `Pacman -> None + and aux_tms l = + List.fold_left (fun acc t -> max acc (aux l t)) None in + fun tms -> aux_tms 0 (tms :> nf list) +;; diff --git a/ocaml_new/num.mli b/ocaml_new/num.mli new file mode 100644 index 0000000..8b0bab4 --- /dev/null +++ b/ocaml_new/num.mli @@ -0,0 +1,38 @@ +val debug_display_arities : bool +type var = int * int +type 'nf_nob i_var_ = [ `I of var * 'nf_nob Listx.listx | `Var of var ] +type 'nf nf_nob_ = + [ `I of var * 'nf nf_nob_ Listx.listx + | `Lam of bool * 'nf + | `Pacman + | `Var of var ] +type nf = + [ `Bottom + | `I of var * nf nf_nob_ Listx.listx + | `Lam of bool * nf + | `Pacman + | `Var of var ] +type nf_nob = nf nf_nob_ +type i_var = nf_nob i_var_ +val hd_of_i_var : [< `I of ('a * 'b) * 'c | `Var of 'a * 'd ] -> 'a +val hd_of : [< `I of ('a * 'b) * 'c | `Var of 'a * 'd ] -> 'a +val arity_of_hd : [> `I of ('a * int) * 'b | `Var of 'c * int ] -> int +val lift : int -> nf -> nf +val make_lams : nf -> int -> nf +val free_vars' : nf -> (int * int) list +val free_vars : nf -> int list +module ToScott : sig val scott_of_nf : nf -> Pure.Pure.t end +val string_of_term : string list -> nf -> string +val print : ?l:string list -> nf -> string +val string_of_nf : [< nf ] -> string +val cast_to_i_var : [< nf > `I `Var] -> i_var +val set_arity : int -> nf -> nf +val minus1 : int -> int +val mk_app : nf -> nf -> nf +val mk_appl : nf -> nf list -> nf +val mk_appx : nf -> nf Listx.listx -> nf +val subst : bool -> bool -> int -> nf -> nf -> nf +val eta_compare : nf -> nf -> int +val eta_eq : [< nf ] -> [< nf ] -> bool +val eta_subterm : [< nf ] -> [< nf ] -> bool +val max_arity_tms : int -> [< nf] list -> int option diff --git a/ocaml_new/parser.ml b/ocaml_new/parser.ml new file mode 100644 index 0000000..487f042 --- /dev/null +++ b/ocaml_new/parser.ml @@ -0,0 +1,239 @@ +module Bytes = String;; +exception ParsingError of string;; + +let mk_app x y = Num.mk_app x y;; +let mk_lam x = `Lam(true, x);; +let mk_var x = `Var(x, -666);; + +let isAlphaNum c = let n = Char.code c in + (48 <= n && n <= 90) || (95 <= n && n <= 122) ;; +let isSpace c = c = ' ' || c = '\n' || c = '\t' ;; + +(* FIXME *) +let mk_var' (bound, free) x = + if x <> "@" && List.mem x bound + then free, mk_var (Util.index_of x bound) + else if x <> "@" && List.mem x free + then free, mk_var (List.length bound + Util.index_of x free) + else (free @ [x]), mk_var (List.length bound + List.length free) +;; + +let mk_app' = function + | [] -> assert false + | t :: ts -> List.fold_left mk_app t ts +;; + +let explode s = + let len = String.length s in + let rec aux i l = + if i >= len || s.[i] = '#' then l else aux (i+1) (s.[i] :: l) + in List.rev (aux 0 []) +;; + +let implode l = + let res = Bytes.create (List.length l) in + let rec aux i = function + | [] -> res + | c :: l -> Bytes.set res i c; aux (i + 1) l in + aux 0 l +;; + +let rec strip_spaces = function + | c::cs when isSpace c -> strip_spaces cs + | cs -> cs +;; + +let read_var s = + let rec aux = function + | [] -> None, [] + | c::cs as x -> + if c = '@' then + (if cs <> [] && (let hd = List.hd cs in hd = '@' || isAlphaNum hd) + then raise (ParsingError ("Unexpected `"^String.make 1 (List.hd cs)^"` after `@`.")) + else Some['@'], cs) + else if isAlphaNum c + then match aux cs with + | (Some x), cs' -> Some (c :: x), cs' + | None, cs' -> (Some [c]), cs' + else None, x + in match aux s with + | None, y -> None, y + | Some x, y -> Some (implode x), y +;; + +let read_var' (bound, free as vars) s = + match read_var s with + | Some varname, cs -> + let free, v = mk_var' vars varname in + Some [v], cs, (bound, free) + | None, _ -> raise (ParsingError ("Can't read variable")) +;; + +let rec read_smt vars = + let check_if_lambda cs = match read_var cs with + | None, _ -> false + | Some x, cs -> match strip_spaces cs with + | [] -> false + | c::_ -> c = '.' + in let read_lambda (bound, free) cs = ( + match read_var (strip_spaces cs) with + | Some varname, cs -> + let vars' = (varname::bound, free) in + (match strip_spaces cs with + | [] -> raise (ParsingError "Lambda expression incomplete") + | c::cs -> (if c = '.' then (match read_smt vars' cs with + | None, _, _ -> raise (ParsingError "Lambda body expected") + | Some [x], y, (_, free) -> Some [mk_lam x], y, (bound, free) + | Some _, _, _ -> assert false + ) else raise (ParsingError "Expected `.` after variable in lambda") + )) + | _, _ -> assert false + ) in let rec aux vars cs = + match strip_spaces cs with + | [] -> None, [], vars + | c::_ as x -> + let tms, cs, vars = ( + if c = '(' then read_pars vars x + else if c = ')' then (None, x, vars) + else if check_if_lambda x then read_lambda vars x + else read_var' vars x) in + match tms with + | Some [tm] -> ( + match aux vars cs with + | None, cs, vars -> Some [tm], cs, vars + | Some ts, cs, vars -> Some (tm :: ts), cs, vars + ) + | Some _ -> assert false + | None -> None, x, vars + in fun cs -> match aux vars cs with + | None, cs, vars -> None, cs, vars + | Some ts, cs, vars -> Some [mk_app' ts], cs, vars +and read_pars vars = function + | [] -> None, [], vars + | c::cs -> if c = '(' then ( + let tm, cs, vars = read_smt vars cs in + let cs = strip_spaces cs in + match cs with + | [] -> None, [], vars + | c::cs -> if c = ')' then tm, cs, vars else raise (ParsingError "Missing `)`") + ) else assert false +;; + +let parse x = + match read_smt ([],[]) (explode x) with + | Some [y], [], _ -> y + | _, _, _ -> assert false +;; + +let parse_many strs = + let f (x, y) z = match read_smt y (explode z) with + | Some[tm], [], vars -> (tm :: x, vars) + | _, _, _ -> assert false + in let aux = List.fold_left f ([], ([], [])) + in let (tms, (_, free)) = aux strs + in (List.rev tms, free) +;; + +(********************************************************************** + +let rec string_of_term = function + | Tvar n -> string_of_int n + | Tapp(t1, t2) -> "(" ^ string_of_term t1 ^ " " ^ string_of_term t2 ^ ")" + | Tlam(t1) -> "(\\" ^ string_of_term t1 ^ ")" +;; + +let _ = prerr_endline (">>>" ^ string_of_term (parse "(\\x. x y z z1 k) z1 z j"));; + + +*******************************************************************************) + +let problem_of_string s = + let lines = Str.split (Str.regexp "[\n\r\x0c\t;]+") s in + let head, lines = List.hd lines, List.tl lines in + let name = String.trim (String.sub head 1 (String.length head - 1)) in + let lines = List.filter ((<>) "") lines in + let aux (last, div, conv, ps) line = + let chr = String.sub line 0 1 in + let line = String.trim (String.sub line 1 (String.length line - 1)) in + if line = "" then chr, div, conv, ps else + let rec aux' chr line = + if chr = "#" + then chr, div, conv, ps + else if chr = "D" + then chr, line, conv, ps + else if chr = "C" + then chr, div, line::conv, ps + else if chr = "N" + then chr, div, conv, line::ps + else if chr = " " + then aux' last line + else raise (ParsingError + ("Unexpected at beginning of problem: `" ^ chr ^ "` " ^ line)) in + aux' chr line in + let _, div, conv, ps = List.fold_left aux ("#", "", [], []) lines in + let div_provided = div <> "" in + let div = if div_provided then div else "BOT" in + let strs = [div] @ ps @ conv in + + if List.length ps = 0 && List.length conv = 0 + then raise (ParsingError "Parsed empty problem"); + + (* parse' *) + let (tms, free) = parse_many strs in + (* Replace pacmans and bottoms *) + let n_bot = try Util.index_of "BOT" free with Not_found -> min_int in + let n_pac = try Util.index_of "PAC" free with Not_found -> min_int in + let n_bomb = try Util.index_of "BOMB" free with Not_found -> min_int in + let fix lev v = + if v = lev + n_bot then `Bottom + else if v = lev + n_pac then `Pacman + else if v = lev + n_bomb then `Lam(true, `Bottom) + else if v = lev then `Var(v, min_int) (* zero *) + else `Var(v,1) in (* 1 by default when variable not applied *) + (* Fix arity *) + let open Num in + let exclude_bottom = function + | #nf_nob as t -> t + (* actually, the following may be assert false *) + | `Bottom -> raise (ParsingError "Input term not in normal form") in + let rec aux_nob lev : nf_nob -> nf = function + | `I((n,_), args) -> `I((n,(if lev = 0 then 0 else 1) + Listx.length args), Listx.map (fun t -> exclude_bottom (aux_nob lev t)) args) + | `Var(n,_) -> fix lev n + | `Lam(_,t) -> `Lam (true, aux (lev+1) t) + | `Pacman -> `Pacman + and aux lev : Num.nf -> Num.nf = function + | #nf_nob as t -> aux_nob lev t + | `Bottom -> assert false in +let all_tms = List.map (aux 0) (tms :> Num.nf list) in + +(* problem_of *) +let div, (ps, conv) = List.hd all_tms, Util.list_cut (List.length ps, List.tl all_tms) in + +let div = if not div_provided || div = `Bottom + then (*raise (ParsingError "D is not provided or bottom")*) `Var(-1000,0) + else match div with + | `I _ as t -> t + | _ -> raise (ParsingError "D is not an inert in the initial problem") in +let conv = Util.filter_map ( + function + | #i_var as t -> Some t + | `Lam _ -> None + | _ -> raise (ParsingError "A C-term is not i_n_var") + ) conv in + name, div, conv, free +;; + + +let from_file path = + let lines = ref ["#"] in + let chan = open_in path in + let _ = try + while true; do + lines := input_line chan :: !lines + done + with End_of_file -> + close_in chan in + let txt = String.concat "\n" (List.rev !lines) in + let problems = Str.split (Str.regexp "[\n\r]+\\$") txt in + List.map problem_of_string (List.tl (List.map ((^) "$") problems)) +;; diff --git a/ocaml_new/parser.mli b/ocaml_new/parser.mli new file mode 100644 index 0000000..0a6ae06 --- /dev/null +++ b/ocaml_new/parser.mli @@ -0,0 +1,13 @@ +exception ParsingError of string + +val problem_of_string: + string -> + string (* problem label *) + * Num.i_var (* div *) + * Num.i_var list (* conv *) + * string list (* names of free variables *) +val from_file : string -> + (string (* problem label *) + * Num.i_var (* div *) + * Num.i_var list (* conv *) + * string list (* names of free variables *)) list diff --git a/ocaml_new/problems.ml b/ocaml_new/problems.ml new file mode 100644 index 0000000..eda359a --- /dev/null +++ b/ocaml_new/problems.ml @@ -0,0 +1,39 @@ +open Lambda4;; +open Util;; + +(* Syntax for problem files in problem/ folder: + +- dollar ($) on newline + begin new problem + $! means that the problem is expected to be separable, + $? means that it is expected to be unseparable + +- (#) on new line + comment line + +- (D) (C) (N) stand respectively for divergent, convergent, numeric + +- lines starting with spaces inherit the type from the last line + +*) + +(* assert_depends solves the problem, and checks if the result was expected *) +let assert_depends x = + let c = String.sub (label_of_problem (fst x)) 0 1 in + match solve x with + | _, `Unseparable s when c = "!" -> + failwith ("assert_depends: unseparable because: " ^ s ^ ".") + | _, `Separable _ when c = "?" -> + failwith ("assert_depends: separable.") + | _ -> () +;; + +(* TODO *) +(* div under a lambda in conv *) + +if Array.length Sys.argv = 1 + then failwith "no command line args. Please use e.g. ./a.out problems/*" +else Array.iteri (fun i filename -> if i > 0 then + List.iter (assert_depends ++ problem_of) (Parser.from_file filename) + ) Sys.argv +;; diff --git a/ocaml_new/problems.mli b/ocaml_new/problems.mli new file mode 100644 index 0000000..ddab9df --- /dev/null +++ b/ocaml_new/problems.mli @@ -0,0 +1 @@ +val assert_depends : Lambda4.problem * Lambda4.response -> unit diff --git a/ocaml_new/problems/1 b/ocaml_new/problems/1 new file mode 100644 index 0000000..ae0bb44 --- /dev/null +++ b/ocaml_new/problems/1 @@ -0,0 +1,33 @@ +$! 1 1 +D x x +C y + +$! 1 2 +D x x +C y x + +$! 1 3 +D x x +C y (x z) + +$! 1 4 +D x x +C x y + y x + y y + +$! 1 5 +D x y +C x x + y x + y y + +$! 1 6 +D x x +C y x + y (x a) + +$? 1 6 +D x x +C y x + y (x x) diff --git a/ocaml_new/pure.ml b/ocaml_new/pure.ml new file mode 100644 index 0000000..51d1feb --- /dev/null +++ b/ocaml_new/pure.ml @@ -0,0 +1,130 @@ +open Util.Vars + +module Pure = +struct + +type t = + | V of int + | A of t * t + | L of t + | B + +let rec print ?(l=[]) = + function + V n -> print_name l n + | A(t1,t2) -> "(" ^ print ~l t1 ^ " " ^ print ~l t2 ^ ")" + | L t -> + let name = string_of_var (List.length l) in + "λ" ^ name ^ "." ^ print ~l:(name::l) t + | B -> "B" + +let lift m = + let rec aux l = + function + | V n -> V (if n < l then n else n+m) + | A (t1,t2) -> A (aux l t1, aux l t2) + | L t -> L (aux (l+1) t) + | B -> B + in + aux 0 + +(* Reference implementation. + Reduction machine used below +let subst delift_by_one what with_what = + let rec aux l = + function + | A(t1,t2) -> A(aux l t1, aux l t2) + | V n -> + if n = what + l then + lift l with_what + else + V (if delift_by_one && n >= l then n-1 else n) + | L t -> L (aux (l+1) t) + in + aux 0 + +let rec whd = + function + | A(t1, t2) -> + let t2 = whd t2 in + let t1 = whd t1 in + (match t1 with + | L f -> whd (subst true 0 t2 f) + | V _ + | A _ -> A(t1,t2)) + | V _ + | L _ as t -> t +*) + +let unwind ?(tbl = Hashtbl.create 317) m = + let rec unwind (e,t,s) = + let cache_unwind m = + try + Hashtbl.find tbl m + with + Not_found -> + let t = unwind m in + Hashtbl.add tbl m t ; + t in + let s = List.map cache_unwind s in + let rec aux l = + function + | A(t1,t2) -> A(aux l t1, aux l t2) + | V n as x when n < l -> x + | V n -> + (try + lift l (cache_unwind (List.nth e (n - l))) + with Failure _ -> V (n - l)) + | L t -> L (aux (l+1) t) + | B -> B in + let t = aux 0 t in + List.fold_left (fun f a -> A(f,a)) t s +in + unwind m + +let mwhd m = + let rec aux = + function + | (e,A(t1,t2),s) -> + let t2' = aux (e,t2,[]) in + let (_,t,_) = t2' in + if t = B + then t2' + else aux (e,t1,t2'::s) + | (e,L t,x::s) -> aux (x::e,t,s) + | (e,V n,s) as m -> + (try + let e,t,s' = List.nth e n in + aux (e,t,s'@s) + with Failure _ -> m) + | (e, B, _) -> (e, B, []) + | (_,L _,[]) as m -> m + in + unwind (aux m) + +end + +module Scott = +struct + +open Pure + +let rec mk_n n = + if n = 0 then L (L (A (V 1, L (V 0)))) else L (L (A (V 0, mk_n (n-1)))) + +let dummy = V (max_int / 2) + +let mk_match t bs = + let bs = List.sort (fun (n1,_) (n2,_) -> compare n1 n2) bs in + let rec aux m t = + function + [] -> A (L dummy, t) + | (n,p)::tl as l -> + if n = m then + A (A (t, L (lift (m+1) p)), L (aux (m+1) (V 0) tl)) + else + A (A (t, dummy), L (aux (m+1) (V 0) l)) + in + aux 0 t bs + +end diff --git a/ocaml_new/pure.mli b/ocaml_new/pure.mli new file mode 100644 index 0000000..a6b90ac --- /dev/null +++ b/ocaml_new/pure.mli @@ -0,0 +1,15 @@ +module Pure : + sig + type t = V of int | A of t * t | L of t | B + val print : ?l:string list -> t -> string + val lift : int -> t -> t + val unwind : ?tbl:('a list * t * 'a list as 'a, t) Hashtbl.t -> 'a -> t + val mwhd : (('a * t * ('b list as 'c) as 'b) list as 'a) * t * 'c -> t + end + +module Scott : + sig + val mk_n : int -> Pure.t + val dummy : Pure.t + val mk_match : Pure.t -> (int * Pure.t) list -> Pure.t + end diff --git a/ocaml_new/run b/ocaml_new/run new file mode 100644 index 0000000..77957cd --- /dev/null +++ b/ocaml_new/run @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +file=`mktemp` + +echo +echo "Running test. Log file: $file." +echo + +trap 'echo' SIGINT + + +./test4.out 2>&1 | tee $file | stdbuf -o0 grep -Po '(?<=measure=)[^ ]*' | stdbuf -o0 tr '\n' ' ' + +if [ $? -eq 0 ] +then + rm $file + echo + echo 'Test succeeded' +else + echo '' + echo 'Test failed or interrupted' + echo "Please have a look at log file: $file ." +fi diff --git a/ocaml_new/test.ml b/ocaml_new/test.ml new file mode 100644 index 0000000..293c1e6 --- /dev/null +++ b/ocaml_new/test.ml @@ -0,0 +1,88 @@ +open Lambda4;; + +let assert_depends x = + let c = String.sub (label_of_problem (fst x)) 0 1 in + match solve x with + | _, `Unseparable s when c = "!" -> + failwith ("assert_depends: unseparable because: " ^ s ^ ".") + | _, `Separable _ when c = "?" -> + failwith ("assert_depends: separable.") + | _ -> () +;; + +let acaso l = + let n = Random.int (List.length l) in + List.nth l n +;; + +let acaso2 l1 l2 = + let n1 = List.length l1 in + let n = Random.int (n1 + List.length l2) in + if n >= n1 then List.nth l2 (n - n1) else List.nth l1 n +;; + +let rec take l n = + if n = 0 then [] + else match l with + | [] -> [] + | x::xs -> x :: (take xs (n-1)) +;; + +let test3 n vars = + let rec aux n inerts lams = + if n = 0 then take (Util.sort_uniq inerts) 5 + else let inerts, lams = if Random.int 2 = 0 + then inerts, ("(" ^ acaso vars ^ ". " ^ acaso2 inerts lams ^ ")") :: lams + else ("(" ^ acaso inerts ^ " " ^ acaso2 inerts lams^ ")") :: inerts, lams + in aux (n-1) inerts lams + in aux (2*n) vars [] +;; + +let test4 n vars = + let rec take' l n = + if n = 0 then [], [] + else match l with + | [] -> [], [] + | [_] -> assert false + | x1::x2::xs -> let a, b = take' xs (n-1) in x1::a,x2::b in + let rec aux n inerts lams = + if n = 0 then List.hd inerts, take' (Util.sort_uniq (List.tl inerts)) 5 + else let inerts, lams = if Random.int 2 = 0 + then inerts, ("(" ^ acaso vars ^ ". " ^ acaso2 inerts lams ^ ")") :: lams + else ("(" ^ acaso inerts ^ " " ^ acaso2 inerts lams^ ")") :: inerts, lams + in aux (n-1) inerts lams + in aux (2*n) vars [] +;; + + +let rec repeat f n = + prerr_endline "\n*************************** NEW TEST ***************************"; + f () ; + if n > 0 then repeat f (n-1) +;; + +let call_main4 div conv = + let str = "$ test.out\nD " ^ div ^ String.concat "\nC " conv in + let p = Parser.problem_of_string str in + let p = Lambda4.problem_of p in + assert_depends p +;; + +let main = + Random.self_init (); + let num = 100 in + let complex = 1000 in + let vars = ["x"; "y"; "z"; "v" ; "w"; "a"; "b"; "c"] in + + (* let open Parser in *) + + repeat (fun _ -> + let tms = test3 complex vars in + let div = acaso tms in + let conv = List.filter ((<>) div) tms in + call_main4 div conv + ) num + ; + + prerr_endline "\n---- ALL TESTS COMPLETED ----" +;; diff --git a/ocaml_new/util.ml b/ocaml_new/util.ml new file mode 100644 index 0000000..a87b96f --- /dev/null +++ b/ocaml_new/util.ml @@ -0,0 +1,118 @@ +(* Function composition *) +let (++) f g x = f (g x);; + +let findi p = + let rec aux n = function + | [] -> raise Not_found + | x::_ when p x -> n, x + | _::xs -> aux (n+1) xs + in aux 0 +;; + +let option_map f = function + | None -> None + | Some x -> Some (f x) +;; + +let option_get = function + | Some x -> x + | None -> failwith "option_get: None" +;; + +let rec find_opt f = + function + [] -> None + | x::xs -> + match f x with + None -> find_opt f xs + | Some _ as res -> res + +let rec index_of ?(eq=(=)) x = + function + [] -> raise Not_found + | y::_ when eq x y -> 0 + | _::l -> 1 + index_of ~eq x l + +let index_of_opt ?eq l t = + try + Some (index_of ?eq t l) + with + Not_found -> None +;; + +let rec filter_map f = + function + [] -> [] + | hd::tl -> + match f hd with + None -> filter_map f tl + | Some x -> x::filter_map f tl +;; + +(* the input must be sorted *) +let rec first_duplicate = + function + [] + | [_] -> None + | x::y::_ when x=y -> Some x + | _::tl -> first_duplicate tl + +(* the input must be sorted + output: list of non duplicates; list of duplicates *) +let rec split_duplicates = + function + [] -> [],[] + | [x] -> [x],[] + | x::(y::_ as tl) -> + let nondup,dup = split_duplicates tl in + if x = y then + List.filter ((<>) x) nondup, x::dup + else + x::nondup,dup + +(* Non c'e' nella vecchia versione di OCaml :( *) +let uniq ?(compare=compare) = + let rec aux = function + | [] -> [] + | [_] as ts -> ts + | t1 :: (t2 :: _ as ts) -> + if compare t1 t2 = 0 then aux ts else t1 :: (aux ts) + in aux + +let sort_uniq ?(compare=compare) l = uniq ~compare (List.sort compare l) + +let rec list_cut = function + | 0, lst -> [], lst + | n, x::xs -> let a, b = list_cut (n-1,xs) in x::a, b + | _ -> assert false +;; + +let concat_map f l = List.concat (List.map f l);; + +let rec take n = + function + | [] -> assert (n = 0); [] + | _ when n = 0 -> [] + | x::xs -> x::(take (n-1) xs) +;; + +module Vars = +struct + +let string_of_var v = + if v > 25 + then "`" ^ string_of_int v + else String.make 1 (char_of_int (v + int_of_char 'a')) +;; + +let var_of_string s = + if String.length s <> 1 then ( + if s.[0] = '`' then int_of_string (String.sub s 1 (-1 + String.length s)) else assert false + ) else int_of_char s.[0] - int_of_char 'a' + +let print_name l n = + if n = -1 + then "*" + else if n >= List.length l then "x" ^ string_of_int (List.length l - n - 1) else List.nth l n + +end diff --git a/ocaml_new/util.mli b/ocaml_new/util.mli new file mode 100644 index 0000000..96f03ed --- /dev/null +++ b/ocaml_new/util.mli @@ -0,0 +1,21 @@ +val ( ++ ) : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b +val findi : ('a -> bool) -> 'a list -> (int * 'a) +val option_map : ('a -> 'b) -> 'a option -> 'b option +val option_get : ('a option) -> 'a +val find_opt : ('a -> 'b option) -> 'a list -> 'b option +val index_of : ?eq:('a -> 'a -> bool) -> 'a -> 'a list -> int +val index_of_opt : ?eq:('a -> 'a -> bool) -> 'a list -> 'a -> int option +val filter_map : ('a -> 'b option) -> 'a list -> 'b list +val first_duplicate : 'a list -> 'a option +val split_duplicates : 'a list -> 'a list * 'a list +val uniq : ?compare:('a -> 'a -> int) -> 'a list -> 'a list +val sort_uniq : ?compare:('a -> 'a -> int) -> 'a list -> 'a list +val list_cut : (int * 'a list) -> ('a list * 'a list) +val concat_map : ('a -> 'b list) -> 'a list -> 'b list +val take : int -> 'a list -> 'a list +module Vars : + sig + val string_of_var : int -> string + val var_of_string : string -> int + val print_name : string list -> int -> string + end