CVC4 Expecting at most 3 arguments for operator 'ITE', found 5 - cvc4

When inputting the following file to cvc4, I get the following error:
(error "Parse Error: <stdin>:11.221: Expecting at most 3 arguments for operator 'ITE', found 5")
The file test.txt was:
(declare-fun start!1 () Bool)
(assert start!1)
(declare-fun lt!2 () String)
(declare-datatypes () ( (JValue!1 (JInt!1 (v!75 (_ BitVec 32))) (JString!1 (v!76 String))) ))
(declare-fun a!0 () JValue!1)
(assert (=> start!1 (not (= lt!2 (ite false "" (ite (and (is-JString!1 a!0) (= (v!76 a!0) "")) """""" (ite (and (is-JInt!1 a!0) (= (v!75 a!0) #x00000000)) "0" (ite (and (is-JString!1 a!0) (= (v!76 a!0) "a")) """a""" lt!2))))))))
The command line:
cat test.txt | cvc4.exe

I needed to add the option --lang smt2.5 for the format to support double quote escaping using the new standard.
cat test.txt | cvc4.exe --lang smt2.5


Create unified diff text for diff2html in browser

Is there a library that produces unified diff from two strings that diff2html can use? I've tried difflib but the output does not seem to fit the requirements that diff2html needs. I need a .js library I can import in the webpage to produce diffs between JSONs.
Tried to play around with the lineterm parameter but was not able to get the tool to work. If I use the string in the docs as an example, then it works:
--- a/server/vendor/\n+++ b/server/vendor/\n## -1035,6 +1035,17 ## func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (\n \n // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n \n+func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {\n+\tr0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))\n+\tn = int(r0)\n+\tif e1 != 0 {\n+\t\terr = errnoErr(e1)\n+\t}\n+\treturn\n+}\n+\n+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n+\n func read(fd int, p []byte) (n int, err error) {\n \tvar _p0 unsafe.Pointer\n \tif len(p) > 0 {\n
But couldn't get any output of difflib to produce anything in diff2html.
Ended up using jsdiff.
var diff = Diff.createTwoFilesPatch("file", "file", oldText, newText);
so that it can then be used with diff2html like this:
{inputFormat: 'diff', showFiles: false, matching: 'lines', outputFormat: 'side-by-side'}

man: MANPATH environment variable list too long (manpath list too long)

When having excessively long MANPATH env-vars I end up in a problem with this error:
$> man <any command>
man: manpath list too long
To figure out when the manpath list is too long I created this small script:
export MANPATH=
for i in $(seq 50 10000)
export MANPATH=/usr:$MANPATH
man -k gcc > /dev/null
[ $? -ne 0 ] && echo "$i ${#MANPATH}" && exit 0
and it seems like it breaks at ${#MANPATH} close to 500.
Also man -d does not give me any information I can use... :(
I have never heard (nor found) a limitation to the number of entries in env-vars (besides the maximum length of the environment variables, from which I am far from).
Are there any fixes for this? Preferably a non-root fix ;)
I am running Debian 9.6.
EDIT: This was reported upstream and fixed!
Based on manp.c starting at line 786:
else if (sscanf (bp, "MANDATORY_MANPATH %511s", key) == 1)
add_mandatory (key);
else if (sscanf (bp, "MANPATH_MAP %511s %511s",
key, cont) == 2)
add_manpath_map (key, cont);
else if ((c = sscanf (bp, "MANDB_MAP %511s %511s",
key, cont)) > 0)
add_mandb_map (key, cont, c, user);
else if ((c = sscanf (bp, "DEFINE %511s %511[^\n]",
key, cont)) > 0)
add_def (key, cont, c, user);
else if (sscanf (bp, "SECTION %511[^\n]", cont) == 1)
add_sections (cont, user);
else if (sscanf (bp, "SECTIONS %511[^\n]", cont) == 1)
/* Since I keep getting it wrong ... */
I'd say the threshold is 511 characters. Interestingly there's a comment in the stating this should be fixed.
/* TODO: would like a (limited) replacement for sscanf()
* here that allocates its own memory. At that point check
* everything that sprintf()s manpath et al!
man-db, the on-line manual database
man-db git repo

CVC4 parsing error(the same formula passes Z3)

The following SMT folumas pass Z3 constraint solving while CVC4 flags an parsing error: "Symbol 'None' previously declared as a variable". I have tested using both CVC4 1.4 and CVC 1.5 on windows. Any suggestions or thoughts?
(set-logic ALL)
(declare-datatypes () ((Enum13 (Green) (Yellow) (None))))
(declare-datatypes () ((Enum0 (True) (False) (None))))
(declare-datatypes () ((Enum9 (Star_3) (Star_2) (Star_1) (None))))
(declare-fun Decomp
(Enum9 Enum13 Enum0)
(declare-fun var_36 () Enum0)
(declare-fun var_37 () Enum13)
(declare-fun var_71 () Enum9)
(declare-fun var_38 () Enum13)
(declare-fun var_31 () Real)
(assert (and true
(= var_38
(Decomp var_71 var_37 var_36))))
(assert (>= var_31 0.0))
(assert (<= var_31 700.0))
CVC4 does not accept datatype definitions where the names of constructors are duplicated. So, "None" cannot be both a Enum13, Enum0, and Enum9. Instead you could use unique names like None13, None0, None9 and CVC4 would not give a syntax error.
Btw, the latest version of CVC4 accepts SMT LIB 2.6 by default, where the format for datatypes is bit different:
To use the old format you can still use --lang=smt2.5
Hope this helps,

reading in a top-level definition

Chicken Scheme
Greetings all,
Assuming I have a text file containing a top-level definition
(define techDisplays '(
( AG1 fillerIgnore AG1_fillerIgnore t t nil t nil )
( AG2 drawing AG2_drawing t t nil t t )
and I bring it in as an include
(use extras format posix posix-extras regex regex-literals utils srfi-13)
(include "./mytech/") ; works when hard-coded
;include inn-file) ; want to pass it in as an arg
(define write-out-techDisplays
(set! rule-as-list-of-strings ( map symbol->string rule-as-list-of-symbols))
(print (string-join rule-as-list-of-strings ))
(define (main args)
(set! inn-file ( car args))
(set! out-file (cadr args))
(with-output-to-file out-file write-out-techDisplays)
So how can I achieve this? Either by delaying evaluation of the include somehow? Or reading in the contents of inn-file and evaluating the string somehow? Or something else?
Still-learning Steve
just pass the list you want as an argument to your outer lambda.
your formatting is misleading, you could try to pretty print your code.
(define write-out-techdisplays
(lambda (techdisps)
(lambda (rule)
(set! rule-string (map symbol->string rule))
(print (string-join rule-string)))) ;inner-lambda closes here
(define alldisps
(call-with-input-file "./mytech/"
;since the last arg is thunk the way to invoke it is to wrap
;our call to write-out-techdisplays with a lambda to set the correct list
(with-output-to-file out-file
(lambda ()
(write-output-techdisplays alldisps)))
finally, you could redesign your code to work without sideffects (those set!s).
that for-each could be a map.

Emacs: is it possible to automatically insert semicolons in js2-mode?

I'm using this superb js2-mode fork, along with autopairs to make Javascript editing awesome in Emacs. However it occurs to me that since js2-mode is a full parser, it should be possible to automatically insert semi-colons whenever I'm in a function calling context.
I thought I'd ask if anyone's looked into this before I dig too much deeper.
Here is my code that solves this:
(defvar js2-semicolon-contexts (list js2-NAME js2-LP js2-SCRIPT js2-CALL js2-BLOCK))
(defun autopair-js2-maybe-insert-semi-colon (action pair pos-before)
"handler for automatically inserting semi-colon at the end of function call.
;; (message "node before is %s" (js2-node-type (js2-node-at-point (- (point) 1))))
;; (message "action is %s" action)
;; (message "pair is %c" pair)
;; (message "context is %s" (buffer-substring-no-properties (point-at-bol) (point-at-eol)))
;; (message "point is %s" (point))
(cond ((and (eq action 'opening)
(eq pair ?\))
(goto-char pos-before)
(skip-chars-backward " \t")
;; (message "node is %s." (js2-node-type (js2-node-at-point (point))))
(memq (js2-node-type (js2-node-at-point (point))) js2-semicolon-contexts)
(let ((forward-sexp-function nil))
(goto-char pos-before)
(if (looking-at-p "[^[:graph:]]*$")
(insert ";"))))))
(defun le::js2-mode-setup ()
(setq autopair-handle-action-fns
(list #'autopair-default-handle-action
(rebox-mode 1)
;;;###autoload(add-hook 'js2-mode-hook 'le::js2-mode-setup)
You can also get this code from this GitHub Gist.