Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8102667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:18:18+00:00 2026-06-05T23:18:18+00:00

This post shows how to axiomatise a length function for Z3’s built-in lists. However,

  • 0

This post shows how to axiomatise a length function for Z3’s built-in lists. However, the function is sort-specific (here Int) and not applicable to lists of bools or custom sorts.

; declare len as an uninterpreted function
(declare-fun len ((List Int)) Int)

; assert defining equations for len as an axiom
(assert (forall ((xs (List Int)))
  (ite (= nil xs)
    (= 0 (len xs))
    (= (+ 1 (len (tail xs))) (len xs)))))

What would be the smartest way of encoding sort-generic list functions? (If I remember correctly, functions cannot be generic per se).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:18:21+00:00Added an answer on June 5, 2026 at 11:18 pm

    The SMT 2.0 format or Z3 do not support parametric axioms in SMT 2.0 scripts. One alternative is to use the programmatic APIs. You can create functions that create the len axiom for a given sort. Here is an example on how to do it using the Python API.

    http://rise4fun.com/Z3Py/vNa

    from z3 import *
    def MkList(sort):
        List = Datatype('List')
        List.declare('insert', ('head', sort), ('tail', List))
        List.declare('nil')
        return List.create()
    
    
    def MkLen(sort):
        List = MkList(sort)
        Len  = Function('len', List, IntSort())
        x    = Const('x', List)
        Ax   = ForAll(x, If(x == List.nil, Len(x) == 0, Len(x) == 1 + Len(List.tail(x))))
        return (Len, [Ax])
    
    IntList = MkList(IntSort())
    IntLen,  IntLenAxioms = MkLen(IntSort())
    print IntLenAxioms
    s = Solver()
    l1 = Const('l1', IntList)
    s.add(IntLenAxioms)
    s.add(IntLen(l1) == 0)
    s.add(l1 == IntList.insert(10, IntList.nil))
    print s.check()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This post demonstrates how to deploy standalone applications to CloudFoundry. However, I'm not able
This blog post shows a way to implement auto mocking with Castle Windsor and
I found this post that shows how to pass multiple check box selections to
Django code samples involving post data often shows code similar to this: if request.method
$('.reply').click(function () { var replybox = $(.replybox).clone().show(); $(replybox).appendTo(this,parent('.post')); }); What I'm trying to do:
This post from F# News states that F# can inline a function passed as
Is it possible to include inline assembly in Go code? This blog post shows
ScottGu in this post link text shows how one can utilize EditorTemplates for things
Google weather API shows temperature in Fahrenheit. After watching this post , I was
I'm using MGTwitterEngine. I've found this post where shows a modification to the current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.