mirror of
https://github.com/Z3Prover/z3
synced 2025-08-04 10:20:23 +00:00
Merge pull request #398 from wintersteiger/jan4
Improvements for the FPA API.
This commit is contained in:
commit
8b8dc95986
18 changed files with 1477 additions and 1306 deletions
|
@ -2758,17 +2758,17 @@ void fpa_example() {
|
|||
Z3_solver_push(ctx, s);
|
||||
c1 = Z3_mk_fpa_fp(ctx,
|
||||
Z3_mk_numeral(ctx, "0", Z3_mk_bv_sort(ctx, 1)),
|
||||
Z3_mk_numeral(ctx, "3377699720527872", Z3_mk_bv_sort(ctx, 52)),
|
||||
Z3_mk_numeral(ctx, "1025", Z3_mk_bv_sort(ctx, 11)));
|
||||
Z3_mk_numeral(ctx, "1025", Z3_mk_bv_sort(ctx, 11)),
|
||||
Z3_mk_numeral(ctx, "3377699720527872", Z3_mk_bv_sort(ctx, 52)));
|
||||
c2 = Z3_mk_fpa_to_fp_bv(ctx,
|
||||
Z3_mk_numeral(ctx, "4619567317775286272", Z3_mk_bv_sort(ctx, 64)),
|
||||
Z3_mk_fpa_sort(ctx, 11, 53));
|
||||
c3 = Z3_mk_fpa_to_fp_int_real(ctx,
|
||||
c3 = Z3_mk_fpa_to_fp_int_real(ctx,
|
||||
Z3_mk_fpa_rtz(ctx),
|
||||
Z3_mk_numeral(ctx, "2", Z3_mk_int_sort(ctx)),
|
||||
Z3_mk_numeral(ctx, "1.75", Z3_mk_real_sort(ctx)),
|
||||
Z3_mk_numeral(ctx, "2", Z3_mk_int_sort(ctx)), /* exponent */
|
||||
Z3_mk_numeral(ctx, "1.75", Z3_mk_real_sort(ctx)), /* significand */
|
||||
Z3_mk_fpa_sort(ctx, 11, 53));
|
||||
c4 = Z3_mk_fpa_to_fp_real(ctx,
|
||||
c4 = Z3_mk_fpa_to_fp_real(ctx,
|
||||
Z3_mk_fpa_rtz(ctx),
|
||||
Z3_mk_numeral(ctx, "7.0", Z3_mk_real_sort(ctx)),
|
||||
Z3_mk_fpa_sort(ctx, 11, 53));
|
||||
|
|
|
@ -19,15 +19,15 @@ def has_cr(file):
|
|||
lines = 0
|
||||
line = ins.readline()
|
||||
while line and lines < 20:
|
||||
m = cr.search(line)
|
||||
if m:
|
||||
ins.close()
|
||||
return True
|
||||
m = aut.search(line)
|
||||
if m:
|
||||
ins.close()
|
||||
return True
|
||||
line = ins.readline()
|
||||
m = cr.search(line)
|
||||
if m:
|
||||
ins.close()
|
||||
return True
|
||||
m = aut.search(line)
|
||||
if m:
|
||||
ins.close()
|
||||
return True
|
||||
line = ins.readline()
|
||||
ins.close()
|
||||
return False
|
||||
|
||||
|
@ -38,20 +38,20 @@ def add_cr(file):
|
|||
ous.write(cr_notice)
|
||||
line = ins.readline()
|
||||
while line:
|
||||
ous.write(line)
|
||||
line = ins.readline()
|
||||
ous.write(line)
|
||||
line = ins.readline()
|
||||
ins.close()
|
||||
ous.close()
|
||||
os.system("move %s %s" % (tmp, file))
|
||||
|
||||
def add_missing_cr(dir):
|
||||
for root, dirs, files in os.walk(dir):
|
||||
for f in files:
|
||||
if f.endswith('.cpp') or f.endswith('.h') or f.endswith('.c') or f.endswith('.cs'):
|
||||
path = "%s\\%s" % (root, f)
|
||||
if not has_cr(path):
|
||||
print("Missing CR for %s" % path)
|
||||
add_cr(path)
|
||||
for f in files:
|
||||
if f.endswith('.cpp') or f.endswith('.h') or f.endswith('.c') or f.endswith('.cs'):
|
||||
path = "%s\\%s" % (root, f)
|
||||
if not has_cr(path):
|
||||
print("Missing CR for %s" % path)
|
||||
add_cr(path)
|
||||
|
||||
add_missing_cr('src')
|
||||
add_missing_cr('examples')
|
||||
|
|
|
@ -17,6 +17,7 @@ update_version()
|
|||
mk_auto_src()
|
||||
mk_bindings(API_files)
|
||||
mk_vs_proj('z3', ['shell'])
|
||||
mk_vs_proj_dll('libz3', ['api_dll'])
|
||||
mk_makefile()
|
||||
|
||||
|
||||
|
|
|
@ -3305,15 +3305,18 @@ def mk_z3consts_ml(api_files):
|
|||
def mk_gui_str(id):
|
||||
return '4D2F40D8-E5F9-473B-B548-%012d' % id
|
||||
|
||||
def mk_vs_proj(name, components):
|
||||
if not VS_PROJ:
|
||||
return
|
||||
proj_name = '%s.vcxproj' % os.path.join(BUILD_DIR, name)
|
||||
modes=['Debug', 'Release']
|
||||
PLATFORMS=['Win32']
|
||||
f = open(proj_name, 'w')
|
||||
f.write('<?xml version="1.0" encoding="utf-8"?>\n')
|
||||
f.write('<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n')
|
||||
def get_platform_toolset_str():
|
||||
default = 'v110';
|
||||
vstr = check_output(['msbuild', '/ver'])
|
||||
lines = vstr.split('\n')
|
||||
lline = lines[-1]
|
||||
tokens = lline.split('.')
|
||||
if len(tokens) < 2:
|
||||
return default
|
||||
else:
|
||||
return 'v' + tokens[0] + tokens[1]
|
||||
|
||||
def mk_vs_proj_property_groups(f, name, target_ext, type):
|
||||
f.write(' <ItemGroup Label="ProjectConfigurations">\n')
|
||||
f.write(' <ProjectConfiguration Include="Debug|Win32">\n')
|
||||
f.write(' <Configuration>Debug</Configuration>\n')
|
||||
|
@ -3324,35 +3327,46 @@ def mk_vs_proj(name, components):
|
|||
f.write(' <Platform>Win32</Platform>\n')
|
||||
f.write(' </ProjectConfiguration>\n')
|
||||
f.write(' </ItemGroup>\n')
|
||||
f.write(' <PropertyGroup Label="Globals">\n')
|
||||
f.write(' <PropertyGroup Label="Globals">\n')
|
||||
f.write(' <ProjectGuid>{%s}</ProjectGuid>\n' % mk_gui_str(0))
|
||||
f.write(' <ProjectName>%s</ProjectName>\n' % name)
|
||||
f.write(' <Keyword>Win32Proj</Keyword>\n')
|
||||
f.write(' <PlatformToolset>%s</PlatformToolset>\n' % get_platform_toolset_str())
|
||||
f.write(' </PropertyGroup>\n')
|
||||
f.write(' <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\n')
|
||||
f.write(' <PropertyGroup Condition="\'$(Configuration)|$(Platform)\'==\'Debug|Win32\'" Label="Configuration">\n')
|
||||
f.write(' <ConfigurationType>Application</ConfigurationType>\n')
|
||||
f.write(' <ConfigurationType>%s</ConfigurationType>\n' % type)
|
||||
f.write(' <CharacterSet>Unicode</CharacterSet>\n')
|
||||
f.write(' <UseOfMfc>false</UseOfMfc>\n')
|
||||
f.write(' </PropertyGroup>\n')
|
||||
f.write(' <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\n')
|
||||
f.write(' <ImportGroup Label="ExtensionSettings">\n')
|
||||
f.write(' </ImportGroup>\n')
|
||||
f.write(' <ImportGroup Label="ExtensionSettings" />\n')
|
||||
f.write(' <ImportGroup Label="PropertySheets">\n')
|
||||
f.write(' <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists(\'$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props\')" Label="LocalAppDataPlatform" /> </ImportGroup>\n')
|
||||
f.write(' <PropertyGroup Label="UserMacros" />\n')
|
||||
f.write(' <PropertyGroup>\n')
|
||||
f.write(' <OutDir Condition="\'$(Configuration)|$(Platform)\'==\'Debug|Win32\'">$(SolutionDir)$(Configuration)\</OutDir>\n')
|
||||
f.write(' <OutDir Condition="\'$(Configuration)|$(Platform)\'==\'Debug|Win32\'">$(SolutionDir)\$(ProjectName)\$(Configuration)\</OutDir>\n')
|
||||
f.write(' <TargetName Condition="\'$(Configuration)|$(Platform)\'==\'Debug|Win32\'">%s</TargetName>\n' % name)
|
||||
f.write(' <TargetExt Condition="\'$(Configuration)|$(Platform)\'==\'Debug|Win32\'">.exe</TargetExt>\n')
|
||||
f.write(' <OutDir Condition="\'$(Configuration)|$(Platform)\'==\'Release|Win32\'">$(SolutionDir)$(Configuration)\</OutDir>\n')
|
||||
f.write(' <TargetExt Condition="\'$(Configuration)|$(Platform)\'==\'Debug|Win32\'">.%s</TargetExt>\n' % target_ext)
|
||||
f.write(' <OutDir Condition="\'$(Configuration)|$(Platform)\'==\'Release|Win32\'">$(SolutionDir)\$(ProjectName)\$(Configuration)\</OutDir>\n')
|
||||
f.write(' <TargetName Condition="\'$(Configuration)|$(Platform)\'==\'Release|Win32\'">%s</TargetName>\n' % name)
|
||||
f.write(' <TargetExt Condition="\'$(Configuration)|$(Platform)\'==\'Release|Win32\'">.exe</TargetExt>\n')
|
||||
f.write(' <TargetExt Condition="\'$(Configuration)|$(Platform)\'==\'Release|Win32\'">.%s</TargetExt>\n' % target_ext)
|
||||
f.write(' </PropertyGroup>\n')
|
||||
f.write(' <ItemDefinitionGroup Condition="\'$(Configuration)|$(Platform)\'==\'Debug|Win32\'">\n')
|
||||
f.write(' <PropertyGroup Condition="\'$(Configuration)|$(Platform)\'==\'Debug|Win32\'">\n')
|
||||
f.write(' <IntDir>$(ProjectName)\$(Configuration)\</IntDir>\n')
|
||||
f.write(' </PropertyGroup>\n')
|
||||
f.write(' <PropertyGroup Condition="\'$(Configuration)|$(Platform)\'==\'Release|Win32\'">\n')
|
||||
f.write(' <IntDir>$(ProjectName)\$(Configuration)\</IntDir>\n')
|
||||
f.write(' </PropertyGroup>\n')
|
||||
|
||||
|
||||
def mk_vs_proj_cl_compile(f, name, components, debug):
|
||||
f.write(' <ClCompile>\n')
|
||||
f.write(' <Optimization>Disabled</Optimization>\n')
|
||||
f.write(' <PreprocessorDefinitions>WIN32;_DEBUG;Z3DEBUG;_TRACE;_MP_INTERNAL;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n')
|
||||
if debug:
|
||||
f.write(' <PreprocessorDefinitions>WIN32;_DEBUG;Z3DEBUG;_TRACE;_MP_INTERNAL;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n')
|
||||
else:
|
||||
f.write(' <PreprocessorDefinitions>WIN32;_NDEBUG;_MP_INTERNAL;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n')
|
||||
if VS_PAR:
|
||||
f.write(' <MinimalRebuild>false</MinimalRebuild>\n')
|
||||
f.write(' <MultiProcessorCompilation>true</MultiProcessorCompilation>\n')
|
||||
|
@ -3360,8 +3374,14 @@ def mk_vs_proj(name, components):
|
|||
f.write(' <MinimalRebuild>true</MinimalRebuild>\n')
|
||||
f.write(' <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n')
|
||||
f.write(' <WarningLevel>Level3</WarningLevel>\n')
|
||||
f.write(' <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n')
|
||||
f.write(' <OpenMPSupport>true</OpenMPSupport>\n')
|
||||
if debug:
|
||||
f.write(' <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n')
|
||||
else:
|
||||
f.write(' <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n')
|
||||
if USE_OMP:
|
||||
f.write(' <OpenMPSupport>true</OpenMPSupport>\n')
|
||||
else:
|
||||
f.write(' <OpenMPSupport>false</OpenMPSupport>\n')
|
||||
f.write(' <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n')
|
||||
f.write(' <AdditionalIncludeDirectories>')
|
||||
deps = find_all_deps(name, components)
|
||||
|
@ -3374,63 +3394,89 @@ def mk_vs_proj(name, components):
|
|||
f.write(get_component(dep).to_src_dir)
|
||||
f.write('</AdditionalIncludeDirectories>\n')
|
||||
f.write(' </ClCompile>\n')
|
||||
f.write(' <Link>\n')
|
||||
f.write(' <OutputFile>$(OutDir)%s.exe</OutputFile>\n' % name)
|
||||
f.write(' <GenerateDebugInformation>true</GenerateDebugInformation>\n')
|
||||
f.write(' <SubSystem>Console</SubSystem>\n')
|
||||
f.write(' <StackReserveSize>8388608</StackReserveSize>\n')
|
||||
f.write(' <RandomizedBaseAddress>false</RandomizedBaseAddress>\n')
|
||||
f.write(' <DataExecutionPrevention>\n')
|
||||
f.write(' </DataExecutionPrevention>\n')
|
||||
f.write(' <TargetMachine>MachineX86</TargetMachine>\n')
|
||||
f.write(' <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n')
|
||||
f.write('<AdditionalDependencies>psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>\n')
|
||||
f.write(' </Link>\n')
|
||||
f.write(' </ItemDefinitionGroup>\n')
|
||||
f.write(' <ItemDefinitionGroup Condition="\'$(Configuration)|$(Platform)\'==\'Release|Win32\'">\n')
|
||||
f.write(' <ClCompile>\n')
|
||||
f.write(' <Optimization>Disabled</Optimization>\n')
|
||||
f.write(' <PreprocessorDefinitions>WIN32;_NDEBUG;_MP_INTERNAL;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n')
|
||||
if VS_PAR:
|
||||
f.write(' <MinimalRebuild>false</MinimalRebuild>\n')
|
||||
f.write(' <MultiProcessorCompilation>true</MultiProcessorCompilation>\n')
|
||||
else:
|
||||
f.write(' <MinimalRebuild>true</MinimalRebuild>\n')
|
||||
f.write(' <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n')
|
||||
f.write(' <WarningLevel>Level3</WarningLevel>\n')
|
||||
f.write(' <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n')
|
||||
f.write(' <OpenMPSupport>true</OpenMPSupport>\n')
|
||||
f.write(' <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n')
|
||||
f.write(' <AdditionalIncludeDirectories>')
|
||||
deps = find_all_deps(name, components)
|
||||
first = True
|
||||
for dep in deps:
|
||||
if first:
|
||||
first = False
|
||||
else:
|
||||
f.write(';')
|
||||
f.write(get_component(dep).to_src_dir)
|
||||
f.write('</AdditionalIncludeDirectories>\n')
|
||||
f.write(' </ClCompile>\n')
|
||||
f.write(' <Link>\n')
|
||||
f.write(' <OutputFile>$(OutDir)%s.exe</OutputFile>\n' % name)
|
||||
f.write(' <GenerateDebugInformation>true</GenerateDebugInformation>\n')
|
||||
f.write(' <SubSystem>Console</SubSystem>\n')
|
||||
f.write(' <StackReserveSize>8388608</StackReserveSize>\n')
|
||||
f.write(' <RandomizedBaseAddress>false</RandomizedBaseAddress>\n')
|
||||
f.write(' <DataExecutionPrevention>\n')
|
||||
f.write(' </DataExecutionPrevention>\n')
|
||||
f.write(' <TargetMachine>MachineX86</TargetMachine>\n')
|
||||
f.write(' <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n')
|
||||
f.write('<AdditionalDependencies>psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>\n')
|
||||
f.write(' </Link>\n')
|
||||
f.write(' </ItemDefinitionGroup>\n')
|
||||
|
||||
def mk_vs_proj_dep_groups(f, name, components):
|
||||
f.write(' <ItemGroup>\n')
|
||||
deps = find_all_deps(name, components)
|
||||
for dep in deps:
|
||||
dep = get_component(dep)
|
||||
for cpp in filter(lambda f: f.endswith('.cpp'), os.listdir(dep.src_dir)):
|
||||
f.write(' <ClCompile Include="%s" />\n' % os.path.join(dep.to_src_dir, cpp))
|
||||
f.write(' </ItemGroup>\n')
|
||||
|
||||
def mk_vs_proj_link_exe(f, name, debug):
|
||||
f.write(' <Link>\n')
|
||||
f.write(' <OutputFile>$(OutDir)%s.exe</OutputFile>\n' % name)
|
||||
f.write(' <GenerateDebugInformation>true</GenerateDebugInformation>\n')
|
||||
f.write(' <SubSystem>Console</SubSystem>\n')
|
||||
f.write(' <StackReserveSize>8388608</StackReserveSize>\n')
|
||||
f.write(' <RandomizedBaseAddress>false</RandomizedBaseAddress>\n')
|
||||
f.write(' <DataExecutionPrevention/>\n')
|
||||
f.write(' <TargetMachine>MachineX86</TargetMachine>\n')
|
||||
f.write(' <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n')
|
||||
f.write(' <AdditionalDependencies>psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>\n')
|
||||
f.write(' </Link>\n')
|
||||
|
||||
def mk_vs_proj(name, components):
|
||||
if not VS_PROJ:
|
||||
return
|
||||
proj_name = '%s.vcxproj' % os.path.join(BUILD_DIR, name)
|
||||
modes=['Debug', 'Release']
|
||||
PLATFORMS=['Win32']
|
||||
f = open(proj_name, 'w')
|
||||
f.write('<?xml version="1.0" encoding="utf-8"?>\n')
|
||||
f.write('<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n')
|
||||
mk_vs_proj_property_groups(f, name, 'exe', 'Application')
|
||||
f.write(' <ItemDefinitionGroup Condition="\'$(Configuration)|$(Platform)\'==\'Debug|Win32\'">\n')
|
||||
mk_vs_proj_cl_compile(f, name, components, debug=True)
|
||||
mk_vs_proj_link_exe(f, name, debug=True)
|
||||
f.write(' </ItemDefinitionGroup>\n')
|
||||
f.write(' <ItemDefinitionGroup Condition="\'$(Configuration)|$(Platform)\'==\'Release|Win32\'">\n')
|
||||
mk_vs_proj_cl_compile(f, name, components, debug=False)
|
||||
mk_vs_proj_link_exe(f, name, debug=False)
|
||||
f.write(' </ItemDefinitionGroup>\n')
|
||||
mk_vs_proj_dep_groups(f, name, components)
|
||||
f.write(' <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\n')
|
||||
f.write(' <ImportGroup Label="ExtensionTargets">\n')
|
||||
f.write(' </ImportGroup>\n')
|
||||
f.write('</Project>\n')
|
||||
f.close()
|
||||
if is_verbose():
|
||||
print("Generated '%s'" % proj_name)
|
||||
|
||||
def mk_vs_proj_link_dll(f, name, debug):
|
||||
f.write(' <Link>\n')
|
||||
f.write(' <OutputFile>$(OutDir)%s.dll</OutputFile>\n' % name)
|
||||
f.write(' <GenerateDebugInformation>true</GenerateDebugInformation>\n')
|
||||
f.write(' <SubSystem>Console</SubSystem>\n')
|
||||
f.write(' <StackReserveSize>8388608</StackReserveSize>\n')
|
||||
f.write(' <RandomizedBaseAddress>false</RandomizedBaseAddress>\n')
|
||||
f.write(' <DataExecutionPrevention/>\n')
|
||||
f.write(' <TargetMachine>MachineX86</TargetMachine>\n')
|
||||
f.write(' <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n')
|
||||
f.write(' <AdditionalDependencies>psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>\n')
|
||||
f.write(' <ModuleDefinitionFile>%s</ModuleDefinitionFile>' % os.path.join(get_component('api_dll').to_src_dir, 'api_dll.def'))
|
||||
f.write(' </Link>\n')
|
||||
|
||||
def mk_vs_proj_dll(name, components):
|
||||
if not VS_PROJ:
|
||||
return
|
||||
proj_name = '%s.vcxproj' % os.path.join(BUILD_DIR, name)
|
||||
modes=['Debug', 'Release']
|
||||
PLATFORMS=['Win32']
|
||||
f = open(proj_name, 'w')
|
||||
f.write('<?xml version="1.0" encoding="utf-8"?>\n')
|
||||
f.write('<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n')
|
||||
mk_vs_proj_property_groups(f, name, 'dll', 'DynamicLibrary')
|
||||
f.write(' <ItemDefinitionGroup Condition="\'$(Configuration)|$(Platform)\'==\'Debug|Win32\'">\n')
|
||||
mk_vs_proj_cl_compile(f, name, components, debug=True)
|
||||
mk_vs_proj_link_dll(f, name, debug=True)
|
||||
f.write(' </ItemDefinitionGroup>\n')
|
||||
f.write(' <ItemDefinitionGroup Condition="\'$(Configuration)|$(Platform)\'==\'Release|Win32\'">\n')
|
||||
mk_vs_proj_cl_compile(f, name, components, debug=False)
|
||||
mk_vs_proj_link_dll(f, name, debug=False)
|
||||
f.write(' </ItemDefinitionGroup>\n')
|
||||
mk_vs_proj_dep_groups(f, name, components)
|
||||
f.write(' <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\n')
|
||||
f.write(' <ImportGroup Label="ExtensionTargets">\n')
|
||||
f.write(' </ImportGroup>\n')
|
||||
|
|
|
@ -17,55 +17,55 @@ def fix_hdr(file):
|
|||
line = ins.readline()
|
||||
found = False
|
||||
while line:
|
||||
m = doubleu.search(line)
|
||||
if m:
|
||||
ous.write("#")
|
||||
ous.write(m.group(1))
|
||||
ous.write(" ")
|
||||
ous.write(m.group(2))
|
||||
ous.write("_H_\n")
|
||||
line = ins.readline()
|
||||
found = True
|
||||
continue
|
||||
m = ifndef.search(line)
|
||||
if m:
|
||||
print(m.group(1))
|
||||
ous.write("#ifndef ")
|
||||
ous.write(m.group(1))
|
||||
ous.write("_H_\n")
|
||||
line = ins.readline()
|
||||
found = True
|
||||
continue
|
||||
m = defn.search(line)
|
||||
if m:
|
||||
ous.write("#define ")
|
||||
ous.write(m.group(1))
|
||||
ous.write("_H_\n")
|
||||
line = ins.readline()
|
||||
found = True
|
||||
continue
|
||||
m = endif.search(line)
|
||||
if m:
|
||||
ous.write("#endif /* ")
|
||||
ous.write(m.group(1))
|
||||
ous.write("_H_ */\n")
|
||||
line = ins.readline()
|
||||
found = True
|
||||
continue
|
||||
ous.write(line)
|
||||
line = ins.readline()
|
||||
m = doubleu.search(line)
|
||||
if m:
|
||||
ous.write("#")
|
||||
ous.write(m.group(1))
|
||||
ous.write(" ")
|
||||
ous.write(m.group(2))
|
||||
ous.write("_H_\n")
|
||||
line = ins.readline()
|
||||
found = True
|
||||
continue
|
||||
m = ifndef.search(line)
|
||||
if m:
|
||||
print(m.group(1))
|
||||
ous.write("#ifndef ")
|
||||
ous.write(m.group(1))
|
||||
ous.write("_H_\n")
|
||||
line = ins.readline()
|
||||
found = True
|
||||
continue
|
||||
m = defn.search(line)
|
||||
if m:
|
||||
ous.write("#define ")
|
||||
ous.write(m.group(1))
|
||||
ous.write("_H_\n")
|
||||
line = ins.readline()
|
||||
found = True
|
||||
continue
|
||||
m = endif.search(line)
|
||||
if m:
|
||||
ous.write("#endif /* ")
|
||||
ous.write(m.group(1))
|
||||
ous.write("_H_ */\n")
|
||||
line = ins.readline()
|
||||
found = True
|
||||
continue
|
||||
ous.write(line)
|
||||
line = ins.readline()
|
||||
ins.close()
|
||||
ous.close()
|
||||
if found:
|
||||
os.system("move %s %s" % (tmp, file))
|
||||
os.system("move %s %s" % (tmp, file))
|
||||
else:
|
||||
os.system("del %s" % tmp)
|
||||
os.system("del %s" % tmp)
|
||||
|
||||
def fixup(dir):
|
||||
for root, dirs, files in os.walk(dir):
|
||||
for f in files:
|
||||
if f.endswith('.h'):
|
||||
path = "%s\\%s" % (root, f)
|
||||
fix_hdr(path)
|
||||
for f in files:
|
||||
if f.endswith('.h'):
|
||||
path = "%s\\%s" % (root, f)
|
||||
fix_hdr(path)
|
||||
|
||||
fixup('src')
|
||||
|
|
|
@ -268,14 +268,14 @@ extern "C" {
|
|||
|
||||
Z3_ast Z3_API Z3_mk_fpa_fp(Z3_context c, Z3_ast sgn, Z3_ast exp, Z3_ast sig) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_fp(c, sgn, sig, exp);
|
||||
LOG_Z3_mk_fpa_fp(c, sgn, exp, sig);
|
||||
RESET_ERROR_CODE();
|
||||
if (!is_bv(c, sgn) || !is_bv(c, exp) || !is_bv(c, sig)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_fp(to_expr(sgn), to_expr(sig), to_expr(exp));
|
||||
expr * a = ctx->fpautil().mk_fp(to_expr(sgn), to_expr(exp), to_expr(sig));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
|
@ -351,7 +351,7 @@ extern "C" {
|
|||
ctx->fpautil().fm().set(tmp,
|
||||
ctx->fpautil().get_ebits(to_sort(ty)),
|
||||
ctx->fpautil().get_sbits(to_sort(ty)),
|
||||
sgn != 0, sig, exp);
|
||||
sgn != 0, exp, sig);
|
||||
expr * a = ctx->fpautil().mk_value(tmp);
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
|
@ -371,7 +371,7 @@ extern "C" {
|
|||
ctx->fpautil().fm().set(tmp,
|
||||
ctx->fpautil().get_ebits(to_sort(ty)),
|
||||
ctx->fpautil().get_sbits(to_sort(ty)),
|
||||
sgn != 0, sig, exp);
|
||||
sgn != 0, exp, sig);
|
||||
expr * a = ctx->fpautil().mk_value(tmp);
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
|
@ -1072,18 +1072,18 @@ extern "C" {
|
|||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_int_real(Z3_context c, Z3_ast rm, Z3_ast exp, Z3_ast sig, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_fp_int_real(c, rm, sig, exp, s);
|
||||
LOG_Z3_mk_fpa_to_fp_int_real(c, rm, exp, sig, s);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
fpa_util & fu = ctx->fpautil();
|
||||
if (!fu.is_rm(to_expr(rm)) ||
|
||||
!ctx->autil().is_real(to_expr(sig)) ||
|
||||
!ctx->autil().is_int(to_expr(exp)) ||
|
||||
!ctx->autil().is_real(to_expr(sig)) ||
|
||||
!fu.is_float(to_sort(s))) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(sig), to_expr(exp));
|
||||
expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(exp), to_expr(sig));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
|
|
|
@ -374,7 +374,11 @@
|
|||
<Compile Include="RatNum.cs" />
|
||||
<Compile Include="RealExpr.cs" />
|
||||
<Compile Include="RealSort.cs" />
|
||||
<Compile Include="ReExpr.cs" />
|
||||
<Compile Include="RelationSort.cs" />
|
||||
<Compile Include="ReSort.cs" />
|
||||
<Compile Include="SeqExpr.cs" />
|
||||
<Compile Include="SeqSort.cs" />
|
||||
<Compile Include="SetSort.cs" />
|
||||
<Compile Include="Statistics.cs" />
|
||||
<Compile Include="Status.cs" />
|
||||
|
|
|
@ -999,6 +999,8 @@ def is_expr(a):
|
|||
>>> x = Int('x')
|
||||
>>> is_expr(ForAll(x, x >= 0))
|
||||
True
|
||||
>>> is_expr(FPVal(1.0))
|
||||
True
|
||||
"""
|
||||
return isinstance(a, ExprRef)
|
||||
|
||||
|
@ -7912,6 +7914,30 @@ def _dflt_rm(ctx=None):
|
|||
def _dflt_fps(ctx=None):
|
||||
return get_default_fp_sort(ctx)
|
||||
|
||||
def _coerce_fp_expr_list(alist, ctx):
|
||||
first_fp_sort = None
|
||||
for a in alist:
|
||||
if is_fp(a):
|
||||
if first_fp_sort == None:
|
||||
first_fp_sort = a.sort()
|
||||
elif first_fp_sort == a.sort():
|
||||
pass # OK, same as before
|
||||
else:
|
||||
# we saw at least 2 different float sorts; something will
|
||||
# throw a sort mismatch later, for now assume None.
|
||||
first_fp_sort = None
|
||||
break
|
||||
|
||||
r = []
|
||||
for i in range(len(alist)):
|
||||
a = alist[i]
|
||||
if (isinstance(a, str) and a.contains('2**(') and a.endswith(')')) or _is_int(a) or isinstance(a, float) or isinstance(a, bool):
|
||||
r.append(FPVal(a, None, first_fp_sort, ctx))
|
||||
else:
|
||||
r.append(a)
|
||||
return _coerce_expr_list(r, ctx)
|
||||
|
||||
|
||||
### FP Sorts
|
||||
|
||||
class FPSortRef(SortRef):
|
||||
|
@ -8051,19 +8077,19 @@ class FPRef(ExprRef):
|
|||
return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
|
||||
|
||||
def __le__(self, other):
|
||||
return fpLEQ(self, other)
|
||||
return fpLEQ(self, other, self.ctx)
|
||||
|
||||
def __lt__(self, other):
|
||||
return fpLT(self, other)
|
||||
return fpLT(self, other, self.ctx)
|
||||
|
||||
def __ge__(self, other):
|
||||
return fpGEQ(self, other)
|
||||
return fpGEQ(self, other, self.ctx)
|
||||
|
||||
def __gt__(self, other):
|
||||
return fpGT(self, other)
|
||||
return fpGT(self, other, self.ctx)
|
||||
|
||||
def __ne__(self, other):
|
||||
return fpNEQ(self, other)
|
||||
return fpNEQ(self, other, self.ctx)
|
||||
|
||||
|
||||
def __add__(self, other):
|
||||
|
@ -8076,8 +8102,8 @@ class FPRef(ExprRef):
|
|||
>>> (x + y).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
a, b = z3._coerce_exprs(self, other)
|
||||
return fpAdd(_dflt_rm(), self, other)
|
||||
[a, b] = _coerce_fp_expr_list([self, other], self.ctx)
|
||||
return fpAdd(_dflt_rm(), a, b, self.ctx)
|
||||
|
||||
def __radd__(self, other):
|
||||
"""Create the Z3 expression `other + self`.
|
||||
|
@ -8086,8 +8112,8 @@ class FPRef(ExprRef):
|
|||
>>> 10 + x
|
||||
1.25*(2**3) + x
|
||||
"""
|
||||
a, b = _coerce_exprs(self, other)
|
||||
return fpAdd(_dflt_rm(), other, self)
|
||||
[a, b] = _coerce_fp_expr_list([other, self], self.ctx)
|
||||
return fpAdd(_dflt_rm(), a, b, self.ctx)
|
||||
|
||||
def __sub__(self, other):
|
||||
"""Create the Z3 expression `self - other`.
|
||||
|
@ -8099,8 +8125,8 @@ class FPRef(ExprRef):
|
|||
>>> (x - y).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
a, b = z3._coerce_exprs(self, other)
|
||||
return fpSub(_dflt_rm(), self, other)
|
||||
[a, b] = _coerce_fp_expr_list([self, other], self.ctx)
|
||||
return fpSub(_dflt_rm(), a, b, self.ctx)
|
||||
|
||||
def __rsub__(self, other):
|
||||
"""Create the Z3 expression `other - self`.
|
||||
|
@ -8109,8 +8135,8 @@ class FPRef(ExprRef):
|
|||
>>> 10 - x
|
||||
1.25*(2**3) - x
|
||||
"""
|
||||
a, b = _coerce_exprs(self, other)
|
||||
return fpSub(_dflt_rm(), other, self)
|
||||
[a, b] = _coerce_fp_expr_list([other, self], self.ctx)
|
||||
return fpSub(_dflt_rm(), a, b, self.ctx)
|
||||
|
||||
def __mul__(self, other):
|
||||
"""Create the Z3 expression `self * other`.
|
||||
|
@ -8124,8 +8150,8 @@ class FPRef(ExprRef):
|
|||
>>> 10 * y
|
||||
1.25*(2**3) * y
|
||||
"""
|
||||
a, b = z3._coerce_exprs(self, other)
|
||||
return fpMul(_dflt_rm(), self, other)
|
||||
[a, b] = _coerce_fp_expr_list([self, other], self.ctx)
|
||||
return fpMul(_dflt_rm(), a, b, self.ctx)
|
||||
|
||||
def __rmul__(self, other):
|
||||
"""Create the Z3 expression `other * self`.
|
||||
|
@ -8137,8 +8163,8 @@ class FPRef(ExprRef):
|
|||
>>> x * 10
|
||||
x * 1.25*(2**3)
|
||||
"""
|
||||
a, b = _coerce_exprs(self, other)
|
||||
return fpMul(_dflt_rm(), other, self)
|
||||
[a, b] = _coerce_fp_expr_list([other, self], self.ctx)
|
||||
return fpMul(_dflt_rm(), a, b, self.ctx)
|
||||
|
||||
def __pos__(self):
|
||||
"""Create the Z3 expression `+self`."""
|
||||
|
@ -8148,13 +8174,42 @@ class FPRef(ExprRef):
|
|||
"""Create the Z3 expression `-self`."""
|
||||
return FPRef(fpNeg(self))
|
||||
|
||||
def __truediv__(self, other):
|
||||
"""Create the Z3 expression division `self / other`."""
|
||||
return self.__div__(other)
|
||||
def __div__(self, other):
|
||||
"""Create the Z3 expression `self / other`.
|
||||
|
||||
def __rtruediv__(self, other):
|
||||
"""Create the Z3 expression division `other / self`."""
|
||||
return self.__rdiv__(other)
|
||||
>>> x = FP('x', FPSort(8, 24))
|
||||
>>> y = FP('y', FPSort(8, 24))
|
||||
>>> x / y
|
||||
x / y
|
||||
>>> (x / y).sort()
|
||||
FPSort(8, 24)
|
||||
>>> 10 / y
|
||||
1.25*(2**3) / y
|
||||
"""
|
||||
[a, b] = _coerce_fp_expr_list([self, other], self.ctx)
|
||||
return fpDiv(_dflt_rm(), a, b, self.ctx)
|
||||
|
||||
def __rdiv__(self, other):
|
||||
"""Create the Z3 expression `other / self`.
|
||||
|
||||
>>> x = FP('x', FPSort(8, 24))
|
||||
>>> y = FP('y', FPSort(8, 24))
|
||||
>>> x / y
|
||||
x / y
|
||||
>>> x / 10
|
||||
x / 1.25*(2**3)
|
||||
"""
|
||||
[a, b] = _coerce_fp_expr_list([other, self], self.ctx)
|
||||
return fpDiv(_dflt_rm(), a, b, self.ctx)
|
||||
|
||||
if not sys.version < '3':
|
||||
def __truediv__(self, other):
|
||||
"""Create the Z3 expression division `self / other`."""
|
||||
return self.__div__(other)
|
||||
|
||||
def __rtruediv__(self, other):
|
||||
"""Create the Z3 expression division `other / self`."""
|
||||
return self.__rdiv__(other)
|
||||
|
||||
def __mod__(self, other):
|
||||
"""Create the Z3 expression mod `self % other`."""
|
||||
|
@ -8304,13 +8359,6 @@ class FPNumRef(FPRef):
|
|||
s = Z3_fpa_get_numeral_string(self.ctx.ref(), self.as_ast())
|
||||
return ("FPVal(%s, %s)" % (s, FPSortRef(self.sort()).as_string()))
|
||||
|
||||
|
||||
def _to_fpnum(num, ctx=None):
|
||||
if isinstance(num, FPNum):
|
||||
return num
|
||||
else:
|
||||
return FPNum(num, ctx)
|
||||
|
||||
def is_fp(a):
|
||||
"""Return `True` if `a` is a Z3 floating-point expression.
|
||||
|
||||
|
@ -8384,31 +8432,60 @@ def _to_float_str(val, exp=0):
|
|||
|
||||
|
||||
def fpNaN(s):
|
||||
"""Create a Z3 floating-point NaN term.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
>>> set_fpa_pretty(True)
|
||||
>>> fpNaN(s)
|
||||
NaN
|
||||
>>> pb = get_fpa_pretty()
|
||||
>>> set_fpa_pretty(False)
|
||||
>>> fpNaN(s)
|
||||
fpNaN(FPSort(8, 24))
|
||||
>>> set_fpa_pretty(pb)
|
||||
"""
|
||||
_z3_assert(isinstance(s, FPSortRef), "sort mismatch")
|
||||
return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
|
||||
|
||||
def fpPlusInfinity(s):
|
||||
"""Create a Z3 floating-point +oo term.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
>>> pb = get_fpa_pretty()
|
||||
>>> set_fpa_pretty(True)
|
||||
>>> fpPlusInfinity(s)
|
||||
+oo
|
||||
>>> set_fpa_pretty(False)
|
||||
>>> fpPlusInfinity(s)
|
||||
fpPlusInfinity(FPSort(8, 24))
|
||||
>>> set_fpa_pretty(pb)
|
||||
"""
|
||||
_z3_assert(isinstance(s, FPSortRef), "sort mismatch")
|
||||
return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
|
||||
|
||||
def fpMinusInfinity(s):
|
||||
"""Create a Z3 floating-point -oo term."""
|
||||
_z3_assert(isinstance(s, FPSortRef), "sort mismatch")
|
||||
return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
|
||||
|
||||
def fpInfinity(s, negative):
|
||||
"""Create a Z3 floating-point +oo or -oo term."""
|
||||
_z3_assert(isinstance(s, FPSortRef), "sort mismatch")
|
||||
_z3_assert(isinstance(negative, bool), "expected Boolean flag")
|
||||
return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
|
||||
|
||||
def fpPlusZero(s):
|
||||
"""Create a Z3 floating-point +0.0 term."""
|
||||
_z3_assert(isinstance(s, FPSortRef), "sort mismatch")
|
||||
return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
|
||||
|
||||
def fpMinusZero(s):
|
||||
"""Create a Z3 floating-point -0.0 term."""
|
||||
_z3_assert(isinstance(s, FPSortRef), "sort mismatch")
|
||||
return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
|
||||
|
||||
def fpZero(s, negative):
|
||||
"""Create a Z3 floating-point +0.0 or -0.0 term."""
|
||||
_z3_assert(isinstance(s, FPSortRef), "sort mismatch")
|
||||
_z3_assert(isinstance(negative, bool), "expected Boolean flag")
|
||||
return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, negative), s.ctx)
|
||||
|
@ -8457,7 +8534,7 @@ def FP(name, fpsort, ctx=None):
|
|||
>>> eq(x, x2)
|
||||
True
|
||||
"""
|
||||
if isinstance(fpsort, FPSortRef):
|
||||
if isinstance(fpsort, FPSortRef) and ctx is None:
|
||||
ctx = fpsort.ctx
|
||||
else:
|
||||
ctx = _get_ctx(ctx)
|
||||
|
@ -8481,7 +8558,7 @@ def FPs(names, fpsort, ctx=None):
|
|||
names = names.split(" ")
|
||||
return [FP(name, fpsort, ctx) for name in names]
|
||||
|
||||
def fpAbs(a):
|
||||
def fpAbs(a, ctx=None):
|
||||
"""Create a Z3 floating-point absolute value expression.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
|
@ -8499,18 +8576,11 @@ def fpAbs(a):
|
|||
>>> fpAbs(x).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
ctx = None
|
||||
if not is_expr(a):
|
||||
ctx =_get_ctx(ctx)
|
||||
s = get_default_fp_sort(ctx)
|
||||
a = FPVal(a, s)
|
||||
else:
|
||||
ctx = a.ctx
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a), "First argument must be Z3 floating-point expression")
|
||||
return FPRef(Z3_mk_fpa_abs(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
ctx = _get_ctx(ctx)
|
||||
[a] = _coerce_fp_expr_list([a], ctx)
|
||||
return FPRef(Z3_mk_fpa_abs(ctx.ref(), a.as_ast()), ctx)
|
||||
|
||||
def fpNeg(a):
|
||||
def fpNeg(a, ctx=None):
|
||||
"""Create a Z3 floating-point addition expression.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
|
@ -8521,18 +8591,63 @@ def fpNeg(a):
|
|||
>>> fpNeg(x).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
ctx = None
|
||||
if not is_expr(a):
|
||||
ctx =_get_ctx(ctx)
|
||||
s = get_default_fp_sort(ctx)
|
||||
a = FPVal(a, s)
|
||||
else:
|
||||
ctx = a.ctx
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a), "First argument must be Z3 floating-point expression")
|
||||
return FPRef(Z3_mk_fpa_neg(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
ctx = _get_ctx(ctx)
|
||||
[a] = _coerce_fp_expr_list([a], ctx)
|
||||
return FPRef(Z3_mk_fpa_neg(ctx.ref(), a.as_ast()), ctx)
|
||||
|
||||
def fpAdd(rm, a, b):
|
||||
def _mk_fp_unary(f, rm, a, ctx):
|
||||
ctx = _get_ctx(ctx)
|
||||
[a] = _coerce_fp_expr_list([a], ctx)
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(a), "Second argument must be a Z3 floating-point expression")
|
||||
return FPRef(f(ctx.ref(), rm.as_ast(), a.as_ast()), ctx)
|
||||
|
||||
def _mk_fp_unary_norm(f, a, ctx):
|
||||
ctx = _get_ctx(ctx)
|
||||
[a] = _coerce_fp_expr_list([a], ctx)
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a), "First argument must be a Z3 floating-point expression")
|
||||
return FPRef(f(ctx.ref(), a.as_ast()), ctx)
|
||||
|
||||
def _mk_fp_unary_pred(f, a, ctx):
|
||||
ctx = _get_ctx(ctx)
|
||||
[a] = _coerce_fp_expr_list([a], ctx)
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
|
||||
return BoolRef(f(ctx.ref(), a.as_ast()), ctx)
|
||||
|
||||
def _mk_fp_bin(f, rm, a, b, ctx):
|
||||
ctx = _get_ctx(ctx)
|
||||
[a, b] = _coerce_fp_expr_list([a, b], ctx)
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
|
||||
return FPRef(f(ctx.ref(), rm.as_ast(), a.as_ast(), b.as_ast()), ctx)
|
||||
|
||||
def _mk_fp_bin_norm(f, a, b, ctx):
|
||||
ctx = _get_ctx(ctx)
|
||||
[a, b] = _coerce_fp_expr_list([a, b], ctx)
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a) or is_fp(b), "First or second argument must be a Z3 floating-point expression")
|
||||
return FPRef(f(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
|
||||
|
||||
def _mk_fp_bin_pred(f, a, b, ctx):
|
||||
ctx = _get_ctx(ctx)
|
||||
[a, b] = _coerce_fp_expr_list([a, b], ctx)
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
|
||||
return BoolRef(f(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
|
||||
|
||||
def _mk_fp_tern(f, rm, a, b, c, ctx):
|
||||
ctx = _get_ctx(ctx)
|
||||
[a, b, c] = _coerce_fp_expr_list([a, b, c], ctx)
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(a) or is_fp(b) or is_fp(c), "At least one of the arguments must be a Z3 floating-point expression")
|
||||
return FPRef(f(ctx.ref(), rm.as_ast(), a.as_ast(), b.as_ast(), c.as_ast()), ctx)
|
||||
|
||||
def fpAdd(rm, a, b, ctx=None):
|
||||
"""Create a Z3 floating-point addition expression.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
|
@ -8541,16 +8656,14 @@ def fpAdd(rm, a, b):
|
|||
>>> y = FP('y', s)
|
||||
>>> fpAdd(rm, x, y)
|
||||
fpAdd(RNE(), x, y)
|
||||
>>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
|
||||
x + y
|
||||
>>> fpAdd(rm, x, y).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return FPRef(Z3_mk_fpa_add(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
|
||||
return _mk_fp_bin(Z3_mk_fpa_add, rm, a, b, ctx)
|
||||
|
||||
def fpSub(rm, a, b):
|
||||
def fpSub(rm, a, b, ctx=None):
|
||||
"""Create a Z3 floating-point subtraction expression.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
|
@ -8562,13 +8675,9 @@ def fpSub(rm, a, b):
|
|||
>>> fpSub(rm, x, y).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return FPRef(Z3_mk_fpa_sub(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
|
||||
return _mk_fp_bin(Z3_mk_fpa_sub, rm, a, b, ctx)
|
||||
|
||||
def fpMul(rm, a, b):
|
||||
def fpMul(rm, a, b, ctx=None):
|
||||
"""Create a Z3 floating-point multiplication expression.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
|
@ -8580,13 +8689,9 @@ def fpMul(rm, a, b):
|
|||
>>> fpMul(rm, x, y).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return FPRef(Z3_mk_fpa_mul(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
|
||||
return _mk_fp_bin(Z3_mk_fpa_mul, rm, a, b, ctx)
|
||||
|
||||
def fpDiv(rm, a, b):
|
||||
def fpDiv(rm, a, b, ctx=None):
|
||||
"""Create a Z3 floating-point divison expression.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
|
@ -8598,13 +8703,9 @@ def fpDiv(rm, a, b):
|
|||
>>> fpDiv(rm, x, y).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return FPRef(Z3_mk_fpa_div(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
|
||||
return _mk_fp_bin(Z3_mk_fpa_div, rm, a, b, ctx)
|
||||
|
||||
def fpRem(a, b):
|
||||
def fpRem(a, b, ctx=None):
|
||||
"""Create a Z3 floating-point remainder expression.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
|
@ -8615,12 +8716,9 @@ def fpRem(a, b):
|
|||
>>> fpRem(x, y).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return FPRef(Z3_mk_fpa_rem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
|
||||
return _mk_fp_bin_norm(Z3_mk_fpa_rem, a, b, ctx)
|
||||
|
||||
def fpMin(a, b):
|
||||
def fpMin(a, b, ctx=None):
|
||||
"""Create a Z3 floating-point minimium expression.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
|
@ -8632,12 +8730,9 @@ def fpMin(a, b):
|
|||
>>> fpMin(x, y).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return FPRef(Z3_mk_fpa_min(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
|
||||
return _mk_fp_bin_norm(Z3_mk_fpa_min, a, b, ctx)
|
||||
|
||||
def fpMax(a, b):
|
||||
def fpMax(a, b, ctx=None):
|
||||
"""Create a Z3 floating-point maximum expression.
|
||||
|
||||
>>> s = FPSort(8, 24)
|
||||
|
@ -8649,104 +8744,75 @@ def fpMax(a, b):
|
|||
>>> fpMax(x, y).sort()
|
||||
FPSort(8, 24)
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return FPRef(Z3_mk_fpa_max(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
|
||||
return _mk_fp_bin_norm(Z3_mk_fpa_max, a, b, ctx)
|
||||
|
||||
def fpFMA(rm, a, b, c):
|
||||
def fpFMA(rm, a, b, c, ctx=None):
|
||||
"""Create a Z3 floating-point fused multiply-add expression.
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(a) or is_fp(b) or is_fp(c), "Second, third, or fourth argument must be a Z3 floating-point expression")
|
||||
a, b, c = _coerce_expr_list([a, b, c])
|
||||
return FPRef(Z3_mk_fpa_fma(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast(), c.as_ast()), rm.ctx)
|
||||
return _mk_fp_tern(Z3_mk_fpa_fma, rm, a, b, c, ctx)
|
||||
|
||||
def fpSqrt(rm, a):
|
||||
def fpSqrt(rm, a, ctx=None):
|
||||
"""Create a Z3 floating-point square root expression.
|
||||
"""
|
||||
ctx = None
|
||||
if not is_expr(a):
|
||||
ctx =_get_ctx(ctx)
|
||||
s = get_default_fp_sort(ctx)
|
||||
a = FPVal(a, s)
|
||||
else:
|
||||
ctx = a.ctx
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(a), "Second argument must be a Z3 floating-point expressions")
|
||||
return FPRef(Z3_mk_fpa_sqrt(rm.ctx_ref(), rm.as_ast(), a.as_ast()), rm.ctx)
|
||||
return _mk_fp_unary(Z3_mk_fpa_sqrt, rm, a, ctx)
|
||||
|
||||
def fpRoundToIntegral(rm, a):
|
||||
def fpRoundToIntegral(rm, a, ctx=None):
|
||||
"""Create a Z3 floating-point roundToIntegral expression.
|
||||
"""
|
||||
ctx = None
|
||||
if not is_expr(a):
|
||||
ctx =_get_ctx(ctx)
|
||||
s = get_default_fp_sort(ctx)
|
||||
a = FPVal(a, s)
|
||||
else:
|
||||
ctx = a.ctx
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(a), "Second argument must be a Z3 floating-point expressions")
|
||||
return FPRef(Z3_mk_fpa_round_to_integral(rm.ctx_ref(), rm.as_ast(), a.as_ast()), rm.ctx)
|
||||
return _mk_fp_unary(Z3_mk_fpa_round_to_integral, rm, a, ctx)
|
||||
|
||||
def fpIsNaN(a):
|
||||
def fpIsNaN(a, ctx=None):
|
||||
"""Create a Z3 floating-point isNaN expression.
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
|
||||
return FPRef(Z3_mk_fpa_is_nan(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
|
||||
def fpIsInfinite(a):
|
||||
>>> s = FPSort(8, 24)
|
||||
>>> x = FP('x', s)
|
||||
>>> y = FP('y', s)
|
||||
>>> fpIsNaN(x)
|
||||
fpIsNaN(x)
|
||||
"""
|
||||
return _mk_fp_unary_norm(Z3_mk_fpa_is_nan, a, ctx)
|
||||
|
||||
def fpIsInf(a, ctx=None):
|
||||
"""Create a Z3 floating-point isInfinite expression.
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
|
||||
return FPRef(Z3_mk_fpa_is_infinite(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
|
||||
def fpIsZero(a):
|
||||
>>> s = FPSort(8, 24)
|
||||
>>> x = FP('x', s)
|
||||
>>> fpIsInf(x)
|
||||
fpIsInf(x)
|
||||
"""
|
||||
return _mk_fp_unary_norm(Z3_mk_fpa_is_infinite, a, ctx)
|
||||
|
||||
def fpIsZero(a, ctx=None):
|
||||
"""Create a Z3 floating-point isZero expression.
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
|
||||
return FPRef(Z3_mk_fpa_is_zero(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
return _mk_fp_unary_norm(Z3_mk_fpa_is_zero, a, ctx)
|
||||
|
||||
def fpIsNormal(a):
|
||||
def fpIsNormal(a, ctx=None):
|
||||
"""Create a Z3 floating-point isNormal expression.
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
|
||||
return FPRef(Z3_mk_fpa_is_normal(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
return _mk_fp_unary_norm(Z3_mk_fpa_is_normal, a, ctx)
|
||||
|
||||
def fpIsSubnormal(a):
|
||||
def fpIsSubnormal(a, ctx=None):
|
||||
"""Create a Z3 floating-point isSubnormal expression.
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
|
||||
return FPRef(Z3_mk_fpa_is_subnormal(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
return _mk_fp_unary_norm(Z3_mk_fpa_is_subnormal, a, ctx)
|
||||
|
||||
def fpIsNegative(a):
|
||||
def fpIsNegative(a, ctx=None):
|
||||
"""Create a Z3 floating-point isNegative expression.
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
|
||||
return FPRef(Z3_mk_fpa_is_negative(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
return _mk_fp_unary_norm(Z3_mk_fpa_is_negative, a, ctx)
|
||||
|
||||
def fpIsPositive(a):
|
||||
def fpIsPositive(a, ctx=None):
|
||||
"""Create a Z3 floating-point isPositive expression.
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
|
||||
return _mk_fp_unary_norm(Z3_mk_fpa_is_positive, a, ctx)
|
||||
return FPRef(Z3_mk_fpa_is_positive(a.ctx_ref(), a.as_ast()), a.ctx)
|
||||
|
||||
def _check_fp_args(a, b):
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(a) or is_fp(b), "At least one of the arguments must be a Z3 floating-point expression")
|
||||
|
||||
def fpLT(a, b):
|
||||
def fpLT(a, b, ctx=None):
|
||||
"""Create the Z3 floating-point expression `other <= self`.
|
||||
|
||||
>>> x, y = FPs('x y', FPSort(8, 24))
|
||||
|
@ -8755,11 +8821,9 @@ def fpLT(a, b):
|
|||
>>> (x <= y).sexpr()
|
||||
'(fp.leq x y)'
|
||||
"""
|
||||
_check_fp_args(a, b)
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return BoolRef(Z3_mk_fpa_lt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
|
||||
return _mk_fp_bin_pred(Z3_mk_fpa_lt, a, b, ctx)
|
||||
|
||||
def fpLEQ(a, b):
|
||||
def fpLEQ(a, b, ctx=None):
|
||||
"""Create the Z3 floating-point expression `other <= self`.
|
||||
|
||||
>>> x, y = FPs('x y', FPSort(8, 24))
|
||||
|
@ -8768,11 +8832,9 @@ def fpLEQ(a, b):
|
|||
>>> (x <= y).sexpr()
|
||||
'(fp.leq x y)'
|
||||
"""
|
||||
_check_fp_args(a, b)
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return BoolRef(Z3_mk_fpa_leq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
|
||||
return _mk_fp_bin_pred(Z3_mk_fpa_leq, a, b, ctx)
|
||||
|
||||
def fpGT(a, b):
|
||||
def fpGT(a, b, ctx=None):
|
||||
"""Create the Z3 floating-point expression `other <= self`.
|
||||
|
||||
>>> x, y = FPs('x y', FPSort(8, 24))
|
||||
|
@ -8781,12 +8843,9 @@ def fpGT(a, b):
|
|||
>>> (x > y).sexpr()
|
||||
'(fp.gt x y)'
|
||||
"""
|
||||
_check_fp_args(a, b)
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return BoolRef(Z3_mk_fpa_gt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
|
||||
return _mk_fp_bin_pred(Z3_mk_fpa_gt, a, b, ctx)
|
||||
|
||||
|
||||
def fpGEQ(a, b):
|
||||
def fpGEQ(a, b, ctx=None):
|
||||
"""Create the Z3 floating-point expression `other <= self`.
|
||||
|
||||
>>> x, y = FPs('x y', FPSort(8, 24))
|
||||
|
@ -8797,11 +8856,9 @@ def fpGEQ(a, b):
|
|||
>>> (x >= y).sexpr()
|
||||
'(fp.geq x y)'
|
||||
"""
|
||||
_check_fp_args(a, b)
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return BoolRef(Z3_mk_fpa_geq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
|
||||
return _mk_fp_bin_pred(Z3_mk_fpa_geq, a, b, ctx)
|
||||
|
||||
def fpEQ(a, b):
|
||||
def fpEQ(a, b, ctx=None):
|
||||
"""Create the Z3 floating-point expression `other <= self`.
|
||||
|
||||
>>> x, y = FPs('x y', FPSort(8, 24))
|
||||
|
@ -8810,11 +8867,9 @@ def fpEQ(a, b):
|
|||
>>> fpEQ(x, y).sexpr()
|
||||
'(fp.eq x y)'
|
||||
"""
|
||||
_check_fp_args(a, b)
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return BoolRef(Z3_mk_fpa_eq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
|
||||
return _mk_fp_bin_pred(Z3_mk_fpa_eq, a, b, ctx)
|
||||
|
||||
def fpNEQ(a, b):
|
||||
def fpNEQ(a, b, ctx=None):
|
||||
"""Create the Z3 floating-point expression `other <= self`.
|
||||
|
||||
>>> x, y = FPs('x y', FPSort(8, 24))
|
||||
|
@ -8823,41 +8878,60 @@ def fpNEQ(a, b):
|
|||
>>> (x != y).sexpr()
|
||||
'(not (fp.eq x y))'
|
||||
"""
|
||||
_check_fp_args(a, b)
|
||||
a, b = _coerce_exprs(a, b)
|
||||
return Not(BoolRef(Z3_mk_fpa_eq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx), a.ctx)
|
||||
return Not(fpEQ(a, b, ctx))
|
||||
|
||||
def fpFP(sgn, exp, sig, ctx=None):
|
||||
"""Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectors sgn, sig, and exp.
|
||||
|
||||
|
||||
def fpFP(sgn, exp, sig):
|
||||
"""Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectorssgn, sig, and exp."""
|
||||
>>> s = FPSort(8, 24)
|
||||
>>> x = fpFP(BitVecVal(1, 1), BitVecVal(2**7-1, 8), BitVecVal(2**22, 23))
|
||||
>>> print(x)
|
||||
fpFP(1, 127, 4194304)
|
||||
>>> xv = FPVal(-1.5, s)
|
||||
>>> print(xv)
|
||||
-1.5
|
||||
>>> slvr = Solver()
|
||||
>>> slvr.add(fpEQ(x, xv))
|
||||
>>> slvr.check()
|
||||
sat
|
||||
>>> xv = FPVal(+1.5, s)
|
||||
>>> print(xv)
|
||||
1.5
|
||||
>>> slvr = Solver()
|
||||
>>> slvr.add(fpEQ(x, xv))
|
||||
>>> slvr.check()
|
||||
unsat
|
||||
"""
|
||||
_z3_assert(is_bv(sgn) and is_bv(exp) and is_bv(sig), "sort mismatch")
|
||||
_z3_assert(sgn.sort().size() == 1, "sort mismatch")
|
||||
return FPRef(Z3_mk_fpa_fp(sgn.ctx_ref(), sgn.ast, exp.ast, sig.ast), sgn.ctx)
|
||||
ctx = _get_ctx(ctx)
|
||||
_z3_assert(ctx == sgn.ctx == exp.ctx == sig.ctx, "context mismatch")
|
||||
return FPRef(Z3_mk_fpa_fp(ctx.ref(), sgn.ast, exp.ast, sig.ast), ctx)
|
||||
|
||||
|
||||
def fpToFP(a1, a2=None, a3=None):
|
||||
def fpToFP(a1, a2=None, a3=None, ctx=None):
|
||||
"""Create a Z3 floating-point conversion expression from other terms."""
|
||||
ctx = _get_ctx(ctx)
|
||||
if is_bv(a1) and is_fp_sort(a2):
|
||||
return FPRef(Z3_mk_fpa_to_fp_bv(a1.ctx_ref(), a1.ast, a2.ast), a1.ctx)
|
||||
return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), a1.ast, a2.ast), ctx)
|
||||
elif is_fprm(a1) and is_fp(a2) and is_fp_sort(a3):
|
||||
return FPRef(Z3_mk_fpa_to_fp_float(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
|
||||
return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
|
||||
elif is_fprm(a1) and is_real(a2) and is_fp_sort(a3):
|
||||
return FPRef(Z3_mk_fpa_to_fp_real(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
|
||||
return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
|
||||
elif is_fprm(a1) and is_bv(a2) and is_fp_sort(a3):
|
||||
return FPRef(Z3_mk_fpa_to_fp_signed(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
|
||||
return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
|
||||
else:
|
||||
raise Z3Exception("Unsupported combination of arguments for conversion to floating-point term.")
|
||||
|
||||
def fpToFPUnsigned(rm, x, s):
|
||||
def fpToFPUnsigned(rm, x, s, ctx=None):
|
||||
"""Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
|
||||
if __debug__:
|
||||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
|
||||
_z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
|
||||
return FPRef(Z3_mk_fpa_to_fp_unsigned(rm.ctx_ref(), rm.ast, x.ast, s.ast), rm.ctx)
|
||||
ctx = _get_ctx(ctx)
|
||||
return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, x.ast, s.ast), ctx)
|
||||
|
||||
def fpToSBV(rm, x, s):
|
||||
def fpToSBV(rm, x, s, ctx=None):
|
||||
"""Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.
|
||||
|
||||
>>> x = FP('x', FPSort(8, 24))
|
||||
|
@ -8875,9 +8949,10 @@ def fpToSBV(rm, x, s):
|
|||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
|
||||
_z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
|
||||
return BitVecRef(Z3_mk_fpa_to_sbv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx)
|
||||
ctx = _get_ctx(ctx)
|
||||
return BitVecRef(Z3_mk_fpa_to_sbv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
|
||||
|
||||
def fpToUBV(rm, x, s):
|
||||
def fpToUBV(rm, x, s, ctx=None):
|
||||
"""Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
|
||||
|
||||
>>> x = FP('x', FPSort(8, 24))
|
||||
|
@ -8895,9 +8970,10 @@ def fpToUBV(rm, x, s):
|
|||
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
|
||||
_z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
|
||||
_z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
|
||||
return BitVecRef(Z3_mk_fpa_to_ubv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx)
|
||||
ctx = _get_ctx(ctx)
|
||||
return BitVecRef(Z3_mk_fpa_to_ubv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
|
||||
|
||||
def fpToReal(x):
|
||||
def fpToReal(x, ctx=None):
|
||||
"""Create a Z3 floating-point conversion expression, from floating-point expression to real.
|
||||
|
||||
>>> x = FP('x', FPSort(8, 24))
|
||||
|
@ -8913,9 +8989,10 @@ def fpToReal(x):
|
|||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
|
||||
return ArithRef(Z3_mk_fpa_to_real(x.ctx_ref(), x.ast), x.ctx)
|
||||
ctx = _get_ctx(ctx)
|
||||
return ArithRef(Z3_mk_fpa_to_real(ctx.ref(), x.ast), ctx)
|
||||
|
||||
def fpToIEEEBV(x):
|
||||
def fpToIEEEBV(x, ctx=None):
|
||||
"""\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
|
||||
|
||||
The size of the resulting bit-vector is automatically determined.
|
||||
|
@ -8937,7 +9014,8 @@ def fpToIEEEBV(x):
|
|||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
|
||||
return BitVecRef(Z3_mk_fpa_to_ieee_bv(x.ctx_ref(), x.ast), x.ctx)
|
||||
ctx = _get_ctx(ctx)
|
||||
return BitVecRef(Z3_mk_fpa_to_ieee_bv(ctx.ref(), x.ast), ctx)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ _z3_op_to_fpa_normal_str = {
|
|||
Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN : 'RoundNearestTiesToEven()', Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY : 'RoundNearestTiesToAway()',
|
||||
Z3_OP_FPA_RM_TOWARD_POSITIVE : 'RoundTowardPositive()', Z3_OP_FPA_RM_TOWARD_NEGATIVE : 'RoundTowardNegative()',
|
||||
Z3_OP_FPA_RM_TOWARD_ZERO : 'RoundTowardZero()',
|
||||
Z3_OP_FPA_PLUS_INF : '+oo', Z3_OP_FPA_MINUS_INF : '-oo',
|
||||
Z3_OP_FPA_NAN : 'NaN', Z3_OP_FPA_PLUS_ZERO : 'PZero', Z3_OP_FPA_MINUS_ZERO : 'NZero',
|
||||
Z3_OP_FPA_PLUS_INF : 'fpPlusInfinity', Z3_OP_FPA_MINUS_INF : 'fpMinusInfinity',
|
||||
Z3_OP_FPA_NAN : 'fpNaN', Z3_OP_FPA_PLUS_ZERO : 'fpPZero', Z3_OP_FPA_MINUS_ZERO : 'fpNZero',
|
||||
Z3_OP_FPA_ADD : 'fpAdd', Z3_OP_FPA_SUB : 'fpSub', Z3_OP_FPA_NEG : 'fpNeg', Z3_OP_FPA_MUL : 'fpMul',
|
||||
Z3_OP_FPA_DIV : 'fpDiv', Z3_OP_FPA_REM : 'fpRem', Z3_OP_FPA_ABS : 'fpAbs',
|
||||
Z3_OP_FPA_MIN : 'fpMin', Z3_OP_FPA_MAX : 'fpMax',
|
||||
|
@ -589,13 +589,23 @@ class Formatter:
|
|||
def pp_fp_value(self, a):
|
||||
z3._z3_assert(isinstance(a, z3.FPNumRef), 'type mismatch')
|
||||
if not self.fpa_pretty:
|
||||
r = []
|
||||
if (a.isNaN()):
|
||||
return to_format('NaN')
|
||||
r.append(to_format(_z3_op_to_fpa_normal_str[Z3_OP_FPA_NAN]))
|
||||
r.append(to_format('('))
|
||||
r.append(to_format(a.sort()))
|
||||
r.append(to_format(')'))
|
||||
return compose(r)
|
||||
elif (a.isInf()):
|
||||
if (a.isNegative()):
|
||||
return to_format('-oo')
|
||||
r.append(to_format(_z3_op_to_fpa_normal_str[Z3_OP_FPA_MINUS_INF]))
|
||||
else:
|
||||
return to_format('+oo')
|
||||
r.append(to_format(_z3_op_to_fpa_normal_str[Z3_OP_FPA_PLUS_INF]))
|
||||
r.append(to_format('('))
|
||||
r.append(to_format(a.sort()))
|
||||
r.append(to_format(')'))
|
||||
return compose(r)
|
||||
|
||||
elif (a.isZero()):
|
||||
if (a.isNegative()):
|
||||
return to_format('-zero')
|
||||
|
@ -1195,6 +1205,10 @@ def set_fpa_pretty(flag=True):
|
|||
|
||||
set_fpa_pretty(True)
|
||||
|
||||
def get_fpa_pretty():
|
||||
global Formatter
|
||||
return _Formatter.fpa_pretty
|
||||
|
||||
def in_html_mode():
|
||||
return isinstance(_Formatter, HTMLFormatter)
|
||||
|
||||
|
|
|
@ -2490,12 +2490,12 @@ void fpa2bv_converter::mk_to_fp_real_int(func_decl * f, unsigned num, expr * con
|
|||
SASSERT(is_app_of(args[0], m_util.get_family_id(), OP_FPA_INTERNAL_RM));
|
||||
expr * bv_rm = to_app(args[0])->get_arg(0);
|
||||
|
||||
rational q;
|
||||
if (!m_arith_util.is_numeral(args[1], q))
|
||||
rational e;
|
||||
if (!m_arith_util.is_numeral(args[1], e))
|
||||
UNREACHABLE();
|
||||
|
||||
rational e;
|
||||
if (!m_arith_util.is_numeral(args[2], e))
|
||||
rational q;
|
||||
if (!m_arith_util.is_numeral(args[2], q))
|
||||
UNREACHABLE();
|
||||
|
||||
SASSERT(e.is_int64());
|
||||
|
@ -2505,11 +2505,11 @@ void fpa2bv_converter::mk_to_fp_real_int(func_decl * f, unsigned num, expr * con
|
|||
return mk_pzero(f, result);
|
||||
else {
|
||||
scoped_mpf nte(m_mpf_manager), nta(m_mpf_manager), tp(m_mpf_manager), tn(m_mpf_manager), tz(m_mpf_manager);
|
||||
m_mpf_manager.set(nte, ebits, sbits, MPF_ROUND_NEAREST_TEVEN, q.to_mpq(), e.to_mpq().numerator());
|
||||
m_mpf_manager.set(nta, ebits, sbits, MPF_ROUND_NEAREST_TAWAY, q.to_mpq(), e.to_mpq().numerator());
|
||||
m_mpf_manager.set(tp, ebits, sbits, MPF_ROUND_TOWARD_POSITIVE, q.to_mpq(), e.to_mpq().numerator());
|
||||
m_mpf_manager.set(tn, ebits, sbits, MPF_ROUND_TOWARD_NEGATIVE, q.to_mpq(), e.to_mpq().numerator());
|
||||
m_mpf_manager.set(tz, ebits, sbits, MPF_ROUND_TOWARD_ZERO, q.to_mpq(), e.to_mpq().numerator());
|
||||
m_mpf_manager.set(nte, ebits, sbits, MPF_ROUND_NEAREST_TEVEN, e.to_mpq().numerator(), q.to_mpq());
|
||||
m_mpf_manager.set(nta, ebits, sbits, MPF_ROUND_NEAREST_TAWAY, e.to_mpq().numerator(), q.to_mpq());
|
||||
m_mpf_manager.set(tp, ebits, sbits, MPF_ROUND_TOWARD_POSITIVE, e.to_mpq().numerator(), q.to_mpq());
|
||||
m_mpf_manager.set(tn, ebits, sbits, MPF_ROUND_TOWARD_NEGATIVE, e.to_mpq().numerator(), q.to_mpq());
|
||||
m_mpf_manager.set(tz, ebits, sbits, MPF_ROUND_TOWARD_ZERO, e.to_mpq().numerator(), q.to_mpq());
|
||||
|
||||
app_ref a_nte(m), a_nta(m), a_tp(m), a_tn(m), a_tz(m);
|
||||
a_nte = m_plugin->mk_numeral(nte);
|
||||
|
|
|
@ -490,11 +490,24 @@ func_decl * fpa_decl_plugin::mk_to_fp(decl_kind k, unsigned num_parameters, para
|
|||
return m_manager->mk_func_decl(name, arity, domain, fp, func_decl_info(m_family_id, k, num_parameters, parameters));
|
||||
}
|
||||
else if (arity == 3 &&
|
||||
is_sort_of(domain[0], m_family_id, ROUNDING_MODE_SORT) &&
|
||||
is_sort_of(domain[1], m_arith_fid, REAL_SORT) &&
|
||||
is_sort_of(domain[2], m_arith_fid, INT_SORT))
|
||||
is_sort_of(domain[0], m_family_id, ROUNDING_MODE_SORT) &&
|
||||
is_sort_of(domain[1], m_arith_fid, REAL_SORT) &&
|
||||
is_sort_of(domain[2], m_arith_fid, INT_SORT))
|
||||
{
|
||||
// Rounding + 1 Real + 1 Int -> 1 FP
|
||||
// Rounding + 1 Real + 1 Int -> 1 FP
|
||||
if (!(num_parameters == 2 && parameters[0].is_int() && parameters[1].is_int()))
|
||||
m_manager->raise_exception("expecting two integer parameters to to_fp");
|
||||
|
||||
sort * fp = mk_float_sort(parameters[0].get_int(), parameters[1].get_int());
|
||||
symbol name("to_fp");
|
||||
return m_manager->mk_func_decl(name, arity, domain, fp, func_decl_info(m_family_id, k, num_parameters, parameters));
|
||||
}
|
||||
else if (arity == 3 &&
|
||||
is_sort_of(domain[0], m_family_id, ROUNDING_MODE_SORT) &&
|
||||
is_sort_of(domain[1], m_arith_fid, INT_SORT) &&
|
||||
is_sort_of(domain[2], m_arith_fid, REAL_SORT))
|
||||
{
|
||||
// Rounding + 1 Int + 1 Real -> 1 FP
|
||||
if (!(num_parameters == 2 && parameters[0].is_int() && parameters[1].is_int()))
|
||||
m_manager->raise_exception("expecting two integer parameters to to_fp");
|
||||
|
||||
|
@ -545,6 +558,7 @@ func_decl * fpa_decl_plugin::mk_to_fp(decl_kind k, unsigned num_parameters, para
|
|||
"(Real), "
|
||||
"(RoundingMode (_ BitVec (eb+sb))), "
|
||||
"(RoundingMode (_ FloatingPoint eb' sb')), "
|
||||
"(RoundingMode Int Real), "
|
||||
"(RoundingMode Real Int), "
|
||||
"(RoundingMode Int), and "
|
||||
"(RoundingMode Real)."
|
||||
|
|
|
@ -276,7 +276,7 @@ public:
|
|||
bool is_pzero(expr * n) { scoped_mpf v(fm()); return is_numeral(n, v) && fm().is_pzero(v); }
|
||||
bool is_nzero(expr * n) { scoped_mpf v(fm()); return is_numeral(n, v) && fm().is_nzero(v); }
|
||||
|
||||
app * mk_fp(expr * arg1, expr * arg2, expr * arg3) { return m().mk_app(m_fid, OP_FPA_FP, arg1, arg2, arg3); }
|
||||
app * mk_fp(expr * sgn, expr * exp, expr * sig) { return m().mk_app(m_fid, OP_FPA_FP, sgn, exp, sig); }
|
||||
app * mk_to_fp(sort * s, expr * bv_t) {
|
||||
SASSERT(is_float(s) && s->get_num_parameters() == 2);
|
||||
return m().mk_app(m_fid, OP_FPA_TO_FP, 2, s->get_parameters(), 1, &bv_t);
|
||||
|
@ -286,9 +286,9 @@ public:
|
|||
expr * args[] = { rm, t };
|
||||
return m().mk_app(m_fid, OP_FPA_TO_FP, 2, s->get_parameters(), 2, args);
|
||||
}
|
||||
app * mk_to_fp(sort * s, expr * rm, expr * sig, expr * exp) {
|
||||
app * mk_to_fp(sort * s, expr * rm, expr * exp, expr * sig) {
|
||||
SASSERT(is_float(s) && s->get_num_parameters() == 2);
|
||||
expr * args[] = { rm, sig, exp };
|
||||
expr * args[] = { rm, exp, sig};
|
||||
return m().mk_app(m_fid, OP_FPA_TO_FP, 2, s->get_parameters(), 3, args);
|
||||
}
|
||||
app * mk_to_fp_unsigned(sort * s, expr * rm, expr * t) {
|
||||
|
|
|
@ -213,7 +213,7 @@ br_status fpa_rewriter::mk_to_fp(func_decl * f, unsigned num_args, expr * const
|
|||
mpf_exp_t mpf_exp = mpzm.get_int64(exp);
|
||||
mpf_exp = m_fm.unbias_exp(ebits, mpf_exp);
|
||||
|
||||
m_fm.set(v, ebits, sbits, !mpzm.is_zero(z), sig, mpf_exp);
|
||||
m_fm.set(v, ebits, sbits, !mpzm.is_zero(z), mpf_exp, sig);
|
||||
TRACE("fp_rewriter",
|
||||
tout << "sgn: " << !mpzm.is_zero(z) << std::endl;
|
||||
tout << "sig: " << mpzm.to_string(sig) << std::endl;
|
||||
|
@ -267,7 +267,21 @@ br_status fpa_rewriter::mk_to_fp(func_decl * f, unsigned num_args, expr * const
|
|||
return BR_FAILED;
|
||||
|
||||
TRACE("fp_rewriter", tout << "r1: " << r1 << ", r2: " << r2 << "\n";);
|
||||
m_fm.set(v, ebits, sbits, rmv, r1.to_mpq(), r2.to_mpq().numerator());
|
||||
m_fm.set(v, ebits, sbits, rmv, r2.to_mpq().numerator(), r1.to_mpq());
|
||||
result = m_util.mk_value(v);
|
||||
return BR_DONE;
|
||||
}
|
||||
else if (m_util.is_rm_numeral(args[0], rmv) &&
|
||||
m_util.au().is_int(args[1]) &&
|
||||
m_util.au().is_real(args[2])) {
|
||||
// rm + int + real -> float
|
||||
if (!m_util.is_rm_numeral(args[0], rmv) ||
|
||||
!m_util.au().is_numeral(args[1], r1) ||
|
||||
!m_util.au().is_numeral(args[2], r2))
|
||||
return BR_FAILED;
|
||||
|
||||
TRACE("fp_rewriter", tout << "r1: " << r1 << ", r2: " << r2 << "\n";);
|
||||
m_fm.set(v, ebits, sbits, rmv, r1.to_mpq().numerator(), r2.to_mpq());
|
||||
result = m_util.mk_value(v);
|
||||
return BR_DONE;
|
||||
}
|
||||
|
@ -281,8 +295,8 @@ br_status fpa_rewriter::mk_to_fp(func_decl * f, unsigned num_args, expr * const
|
|||
mpf_exp_t biased_exp = m_fm.mpz_manager().get_int64(r2.to_mpq().numerator());
|
||||
m_fm.set(v, bvs2, bvs3 + 1,
|
||||
r1.is_one(),
|
||||
r3.to_mpq().numerator(),
|
||||
m_fm.unbias_exp(bvs2, biased_exp));
|
||||
m_fm.unbias_exp(bvs2, biased_exp),
|
||||
r3.to_mpq().numerator());
|
||||
TRACE("fp_rewriter", tout << "v = " << m_fm.to_string(v) << std::endl;);
|
||||
result = m_util.mk_value(v);
|
||||
return BR_DONE;
|
||||
|
@ -753,23 +767,23 @@ br_status fpa_rewriter::mk_rm(expr * arg, expr_ref & result) {
|
|||
return BR_FAILED;
|
||||
}
|
||||
|
||||
br_status fpa_rewriter::mk_fp(expr * arg1, expr * arg2, expr * arg3, expr_ref & result) {
|
||||
br_status fpa_rewriter::mk_fp(expr * sgn, expr * exp, expr * sig, expr_ref & result) {
|
||||
unsynch_mpz_manager & mpzm = m_fm.mpz_manager();
|
||||
bv_util bu(m());
|
||||
rational r1, r2, r3;
|
||||
unsigned bvs1, bvs2, bvs3;
|
||||
rational rsgn, rexp, rsig;
|
||||
unsigned bvsz_sgn, bvsz_exp, bvsz_sig;
|
||||
|
||||
if (bu.is_numeral(arg1, r1, bvs1) &&
|
||||
bu.is_numeral(arg2, r2, bvs2) &&
|
||||
bu.is_numeral(arg3, r3, bvs3)) {
|
||||
SASSERT(mpzm.is_one(r2.to_mpq().denominator()));
|
||||
SASSERT(mpzm.is_one(r3.to_mpq().denominator()));
|
||||
if (bu.is_numeral(sgn, rsgn, bvsz_sgn) &&
|
||||
bu.is_numeral(sig, rsig, bvsz_sig) &&
|
||||
bu.is_numeral(exp, rexp, bvsz_exp)) {
|
||||
SASSERT(mpzm.is_one(rexp.to_mpq().denominator()));
|
||||
SASSERT(mpzm.is_one(rsig.to_mpq().denominator()));
|
||||
scoped_mpf v(m_fm);
|
||||
mpf_exp_t biased_exp = mpzm.get_int64(r2.to_mpq().numerator());
|
||||
m_fm.set(v, bvs2, bvs3 + 1,
|
||||
r1.is_one(),
|
||||
r3.to_mpq().numerator(),
|
||||
m_fm.unbias_exp(bvs2, biased_exp));
|
||||
mpf_exp_t biased_exp = mpzm.get_int64(rexp.to_mpq().numerator());
|
||||
m_fm.set(v, bvsz_exp, bvsz_sig + 1,
|
||||
rsgn.is_one(),
|
||||
m_fm.unbias_exp(bvsz_exp, biased_exp),
|
||||
rsig.to_mpq().numerator());
|
||||
TRACE("fp_rewriter", tout << "simplified (fp ...) to " << m_fm.to_string(v) << std::endl;);
|
||||
result = m_util.mk_value(v);
|
||||
return BR_DONE;
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
br_status mk_to_fp_unsigned(func_decl * f, expr * arg1, expr * arg2, expr_ref & result);
|
||||
|
||||
br_status mk_rm(expr * arg, expr_ref & result);
|
||||
br_status mk_fp(expr * arg1, expr * arg2, expr * arg3, expr_ref & result);
|
||||
br_status mk_fp(expr * sgn, expr * exp, expr * sig, expr_ref & result);
|
||||
br_status mk_to_fp_unsigned(expr * arg1, expr * arg2, expr_ref & result);
|
||||
br_status mk_to_ubv(func_decl * f, expr * arg1, expr * arg2, expr_ref & result);
|
||||
br_status mk_to_sbv(func_decl * f, expr * arg1, expr * arg2, expr_ref & result);
|
||||
|
|
|
@ -235,7 +235,7 @@ namespace smt {
|
|||
SASSERT(mpzm.is_int64(exp_u));
|
||||
|
||||
scoped_mpf f(mpfm);
|
||||
mpfm.set(f, m_ebits, m_sbits, mpzm.is_one(sgn_z), sig_z, mpzm.get_int64(exp_u));
|
||||
mpfm.set(f, m_ebits, m_sbits, mpzm.is_one(sgn_z), mpzm.get_int64(exp_u), sig_z);
|
||||
result = m_fu.mk_value(f);
|
||||
|
||||
TRACE("t_fpa", tout << "fpa_value_proc::mk_value [" <<
|
||||
|
|
|
@ -132,7 +132,7 @@ expr_ref fpa2bv_model_converter::convert_bv2fp(sort * s, expr * sgn, expr * exp,
|
|||
mpzm.set(sig_z, sig_q.to_mpq().numerator());
|
||||
exp_z = mpzm.get_int64(exp_unbiased_q.to_mpq().numerator());
|
||||
|
||||
fu.fm().set(fp_val, ebits, sbits, !mpqm.is_zero(sgn_q.to_mpq()), sig_z, exp_z);
|
||||
fu.fm().set(fp_val, ebits, sbits, !mpqm.is_zero(sgn_q.to_mpq()), exp_z, sig_z);
|
||||
|
||||
mpzm.del(sig_z);
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode
|
|||
TRACE("mpf_dbg", tout << "set: " << m_mpq_manager.to_string(value) << " [" << ebits << "/" << sbits << "]"<< std::endl;);
|
||||
scoped_mpz exp(m_mpz_manager);
|
||||
m_mpz_manager.set(exp, 0);
|
||||
set(o, ebits, sbits, rm, value, exp);
|
||||
set(o, ebits, sbits, rm, exp, value);
|
||||
TRACE("mpf_dbg", tout << "set: res = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
|
@ -221,12 +221,12 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode
|
|||
scoped_mpz ex(m_mpq_manager);
|
||||
m_mpz_manager.set(ex, e.c_str());
|
||||
|
||||
set(o, ebits, sbits, rm, q, ex);
|
||||
set(o, ebits, sbits, rm, ex, q);
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: res = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpq const & significand, mpz const & exponent) {
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpz const & exponent, mpq const & significand) {
|
||||
// Assumption: this represents significand * 2^exponent.
|
||||
TRACE("mpf_dbg", tout << "set: sig = " << m_mpq_manager.to_string(significand) << " exp = " << m_mpz_manager.to_string(exponent) << std::endl;);
|
||||
|
||||
|
@ -289,7 +289,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode
|
|||
TRACE("mpf_dbg", tout << "set: res = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, bool sign, uint64 significand, mpf_exp_t exponent) {
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, uint64 significand) {
|
||||
// Assumption: this represents (sign * -1) * (significand/2^sbits) * 2^exponent.
|
||||
o.ebits = ebits;
|
||||
o.sbits = sbits;
|
||||
|
@ -304,7 +304,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, bool sign, uint64
|
|||
});
|
||||
}
|
||||
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpz const & significand, mpf_exp_t exponent) {
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, mpz const & significand) {
|
||||
// Assumption: this represents (sign * -1) * (significand/2^sbits) * 2^exponent.
|
||||
o.ebits = ebits;
|
||||
o.sbits = sbits;
|
||||
|
|
|
@ -74,9 +74,9 @@ public:
|
|||
void set(mpf & o, unsigned ebits, unsigned sbits, double value);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpq const & value);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, char const * value);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpq const & significand, mpz const & exponent);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, bool sign, uint64 significand, mpf_exp_t exponent);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpz const & significand, mpf_exp_t exponent);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpz const & exponent, mpq const & significand);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, uint64 significand);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, mpz const & significand);
|
||||
void set(mpf & o, mpf const & x);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpf const & x);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue