miaou — le blogv1.0.3

sv_commande.miaou

← Le code · src/outil/miaou/sv_commande.miaou · 124 lignes

(node sv_commande
  (params (sp Sp) (m (Liste Octet)) (carburant Nat))
  (returns Sp)
  (intent "la commande de nom m, sa parenthèse ouvrante et son nom déjà lus, comme q_lire_texte de l'outil inter : set-option :timeout N, la commande 6, le budget de pas des check-sat suivants (sv_budget_de, phase H7) ; set-option :rlimit N, la commande 7, N pas comptés au travail (phase H7, d'après la limite de ressources de z3) ; les autres set-option, set-info, set-logic, exit sautées ; declare-const (Int ou Bool) ; define-fun sans paramètre ; assert ; push et pop n ; check-sat ; get-value ; une autre, « forme non prise en charge »")
  (origin "phase 8f6 : notre solveur en miaou, d'après le solveur (q_…) de l'outil inter")
  (effects)
  (uses sv_jeton
    sv_budget_de
    sv_attendre
    sv_sauter
    sv_terme
    sv_get_noms
    sv_repeter
    sv_erreur
    sv_entier_ecrit
    sv_nd
    gr_lire
    nat_de_gr)
  (requires
    true)
  (ensures
    true)
  (examples
    (ex ((record Sp (reste ")") (nds (list)) (n 0) (noms (list)) (nf 0) (nint 0) (nbool 0) (cmds (list)) (err "")) "check-sat" 10)
      (record Sp
        (reste "")
        (nds (list))
        (n 0)
        (noms (list))
        (nf 0)
        (nint 0)
        (nbool 0)
        (cmds (list (record Cm (k 4) (nd 0) (couples (list)))))
        (err "")))
    (ex ((record Sp (reste " :timeout 500)") (nds (list)) (n 0) (noms (list)) (nf 0) (nint 0) (nbool 0) (cmds (list)) (err "")) "set-option" 10)
      (record Sp
        (reste "")
        (nds (list))
        (n 0)
        (noms (list))
        (nf 0)
        (nint 0)
        (nbool 0)
        (cmds (list (record Cm (k 6) (nd 500000) (couples (list)))))
        (err "")))
    (ex ((record Sp (reste " :rlimit 300)") (nds (list)) (n 0) (noms (list)) (nf 0) (nint 0) (nbool 0) (cmds (list)) (err "")) "set-option" 10)
      (record Sp
        (reste "")
        (nds (list))
        (n 0)
        (noms (list))
        (nf 0)
        (nint 0)
        (nbool 0)
        (cmds (list (record Cm (k 7) (nd 300) (couples (list)))))
        (err "")))
    (ex ((record Sp (reste " :produce-models true)") (nds (list)) (n 0) (noms (list)) (nf 0) (nint 0) (nbool 0) (cmds (list)) (err "")) "set-option" 10)
      (record Sp
        (reste "")
        (nds (list))
        (n 0)
        (noms (list))
        (nf 0)
        (nint 0)
        (nbool 0)
        (cmds (list))
        (err ""))))
  (equivalence exact)
  (body.high
    (if (eq m "set-option")
      (let ((j1 (sv_jeton (get sp reste))))
        (let ((j2 (sv_jeton (get j1 reste))))
          (if (and (eq (get j1 k) 3) (and (or (eq (get j1 mot) ":timeout") (eq (get j1 mot) ":rlimit")) (eq (get j2 k) 3)))
            (let ((t (eq (get j1 mot) ":timeout")) (b (sv_budget_de (get j2 mot) 0)))
              (sv_sauter (with sp (reste (get j2 reste)) (cmds (cons (record Cm (k (if t 6 7)) (nd (if t b (div b 1000))) (couples (list))) (get sp cmds))))
                1
                1000000))
            (sv_sauter sp 1 1000000))))
      (if (or (eq m "set-info") (or (eq m "set-logic") (eq m "exit")))
        (sv_sauter sp 1 1000000)
        (if (eq m "declare-const")
          (let ((jn (sv_jeton (get sp reste))))
            (let ((js (sv_jeton (get jn reste))))
              (if (or (ne (get jn k) 3) (ne (get js k) 3))
                (get (sv_erreur sp "texte mal formé") sp)
                (if (or (eq (get js mot) "Int") (eq (get js mot) "Bool"))
                  (let ((ent (eq (get js mot) "Int")))
                    (sv_attendre (with sp (reste (get js reste)) (nds (cons (record Nd (k (if ent 4 5)) (s (if ent 1 2)) (a 0) (b 0) (c 0) (args (list)) (val (record Grand (neg false) (mots (list)))) (num (if ent (get sp nint) (get sp nbool)))) (get sp nds))) (n (add (get sp n) 1)) (noms (cons (record Nm (nom (get jn mot)) (nd (get sp n))) (get sp noms))) (nint (if ent (add (get sp nint) 1) (get sp nint))) (nbool (if ent (get sp nbool) (add (get sp nbool) 1))))
                      2))
                  (get (sv_erreur sp "sorte non prise en charge") sp)))))
          (if (eq m "define-fun")
            (let ((jn (sv_jeton (get sp reste))))
              (let ((s2 (sv_attendre (sv_attendre (with sp (reste (get jn reste))) 1) 2)))
                (let ((js (sv_jeton (get s2 reste))))
                  (if (or (ne (get js k) 3) (and (ne (get js mot) "Int") (ne (get js mot) "Bool")))
                    (get (sv_erreur s2 "sorte non prise en charge") sp)
                    (let ((rt (sv_terme (with s2 (reste (get js reste))) carburant)))
                      (if (gt (len (get (get rt sp) err)) 0)
                        (get rt sp)
                        (if (ne (get (sv_nd (get rt sp) (get rt nd)) s) (if (eq (get js mot) "Int") 1 2))
                          (get (sv_erreur (get rt sp) "sorte non prise en charge") sp)
                          (sv_attendre (with (get rt sp) (noms (cons (record Nm (nom (get jn mot)) (nd (get rt nd))) (get (get rt sp) noms))))
                            2))))))))
            (if (eq m "assert")
              (let ((rt (sv_terme sp carburant)))
                (if (gt (len (get (get rt sp) err)) 0)
                  (get rt sp)
                  (if (ne (get (sv_nd (get rt sp) (get rt nd)) s) 2)
                    (get (sv_erreur (get rt sp) "sorte non prise en charge") sp)
                    (sv_attendre (with (get rt sp) (cmds (cons (record Cm (k 1) (nd (get rt nd)) (couples (list))) (get (get rt sp) cmds))))
                      2))))
              (if (or (eq m "push") (eq m "pop"))
                (let ((jn (sv_jeton (get sp reste))))
                  (if (and (eq (get jn k) 3) (sv_entier_ecrit (get jn mot)))
                    (sv_attendre (sv_repeter (with sp (reste (get jn reste))) (if (eq m "push") 2 3) (nat_de_gr (gr_lire (get jn mot))))
                      2)
                    (get (sv_erreur sp "texte mal formé") sp)))
                (if (eq m "check-sat")
                  (sv_attendre (with sp (cmds (cons (record Cm (k 4) (nd 0) (couples (list))) (get sp cmds))))
                    2)
                  (if (eq m "get-value")
                    (sv_attendre (sv_get_noms (sv_attendre sp 1) (list) 1000000) 2)
                    (get (sv_erreur sp "forme non prise en charge") sp))))))))))
  (end node sv_commande))