1501{
1502 int fUseSecondCore = 1;
1505 abctime clk2, clk = Abc_Clock();
1506 int Status =
l_Undef, RetValue = -1, iFrameTryToProve = -1, fOneIsSent = 0;
1507 int i, c, f, Lit;
1508 pPars->iFrame = -1;
1509
1510 assert( Gia_ManPoNum(pAig) == 1 );
1512 if ( Gia_ObjIsConst0(Gia_ObjFanin0(Gia_ManPo(pAig,0))) )
1513 {
1514 if ( !Gia_ObjFaninC0(Gia_ManPo(pAig,0)) )
1515 {
1516 Abc_Print( 1, "Sequential miter is trivially UNSAT.\n" );
1517 return 1;
1518 }
1520 Abc_Print( 1, "Sequential miter is trivially SAT.\n" );
1521 return 0;
1522 }
1523
1525 {
1526 pAig->
vGateClasses = Vec_IntStart( Gia_ManObjNum(pAig) );
1528 Vec_IntWriteEntry( pAig->
vGateClasses, Gia_ObjFaninId0p(pAig, Gia_ManPo(pAig, 0)), 1 );
1529 }
1530
1532 p->timeInit = Abc_Clock() - clk;
1533
1534 if (
p->pPars->fVerbose )
1535 {
1536 Abc_Print( 1, "Running gate-level abstraction (GLA) with the following parameters:\n" );
1537 Abc_Print( 1, "FrameMax = %d ConfMax = %d Timeout = %d Limit = %d %% Limit2 = %d %% RatioMax = %d %%\n",
1538 pPars->nFramesMax, pPars->nConfLimit, pPars->nTimeOut, pPars->nRatioMin, pPars->nRatioMin2, pPars->nRatioMax );
1539 Abc_Print( 1, "LrnStart = %d LrnDelta = %d LrnRatio = %d %% Skip = %d SimpleCNF = %d Dump = %d\n",
1540 pPars->nLearnedStart, pPars->nLearnedDelta, pPars->nLearnedPerce, pPars->fUseSkip, pPars->fUseSimple, pPars->fDumpVabs|pPars->fDumpMabs );
1541 if ( pPars->fDumpVabs || pPars->fDumpMabs )
1542 Abc_Print( 1, "%s will be continuously dumped into file \"%s\".\n",
1543 pPars->fDumpVabs ? "Abstracted model" : "Miter with abstraction map",
1545 if ( pPars->fDumpMabs )
1546 {
1547 {
1548 char Command[1000];
1554 }
1555 {
1556
1560 pAig->
vGateClasses = Vec_IntStart( Gia_ManObjNum(pAig) );
1565 Vec_IntWriteEntry( pAig->
vGateClasses, Gia_ObjId(pAig, pObj), 1 );
1569 if (
p->pPars->fVerbose )
1570 Abc_Print( 1, "Dumping miter with abstraction map into file \"%s\"...\n", pFileName );
1571 }
1572 }
1573 Abc_Print( 1, " Frame %% Abs PPI FF LUT Confl Cex Vars Clas Lrns Time Mem\n" );
1574 }
1575
1576 for ( i = f = 0; !pPars->nFramesMax || f < pPars->nFramesMax; i++ )
1577 {
1578 int nAbsOld;
1579
1580 p->pPars->iFrame = -1;
1581
1583
1584 nAbsOld = Vec_IntSize(
p->vAbs);
1585
1586 for ( f = 0; !pPars->nFramesMax || f < pPars->nFramesMax; f++ )
1587 {
1588
1589 int nConflsBeg = sat_solver2_nconflicts(
p->pSat);
1590 int nAbs = Vec_IntSize(
p->vAbs);
1591 int nValues = Vec_IntSize(
p->vValues);
1592 int nVarsOld;
1593
1594 p->pPars->iFrame = f;
1595
1596 if ( f == Vec_PtrSize(
p->vId2Lit) )
1597 Vec_PtrPush(
p->vId2Lit, Vec_IntAlloc(0) );
1598 Vec_IntFillExtra( Ga2_MapFrameMap(
p, f), Vec_IntSize(
p->vValues), -1 );
1599
1601
1602 if (
p->pPars->fUseSkip && f <= p->pPars->iFrameProved )
1603 continue;
1604
1605 if (
p->pPars->nFramesStart && f <= p->pPars->nFramesStart )
1606 continue;
1607
1608
1609 Lit = Ga2_ObjFindLit(
p, Gia_ObjFanin0(Gia_ManPo(pAig,0)), f );
1611 Lit = Abc_LitNotCond( Lit, Gia_ObjFaninC0(Gia_ManPo(pAig,0)) );
1612 if ( Lit == 0 )
1613 continue;
1615
1616 if (
p->nSatVars > sat_solver2_nvars(
p->pSat) )
1618 nVarsOld =
p->nSatVars;
1619 for ( c = 0; ; c++ )
1620 {
1621
1622
1623
1624
1626 {
1627 Prf_ManStopP( &
p->pSat->pPrf2 );
1628 break;
1629 }
1630
1631 clk2 = Abc_Clock();
1632 Status =
sat_solver2_solve(
p->pSat, &Lit, &Lit+1, (ABC_INT64_T)pPars->nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
1634 {
1636 p->timeSat += Abc_Clock() - clk2;
1637
1638
1640 {
1642 fOneIsSent = 0;
1643 }
1644 if ( iFrameTryToProve >= 0 )
1645 {
1647 iFrameTryToProve = -1;
1648 }
1649
1650
1651 clk2 = Abc_Clock();
1652 Rnm_ManSetRefId(
p->pRnm, c );
1654 p->timeCex += Abc_Clock() - clk2;
1655 if ( vPPis == NULL )
1656 {
1657 if ( pPars->fVerbose )
1659 goto finish;
1660 }
1661
1662 if ( c == 0 )
1663 {
1664
1665
1666 assert( nVarsOld ==
p->pSat->size );
1667 sat_solver2_bookmark(
p->pSat );
1668
1669 assert(
p->pSat->pPrf2 == NULL );
1670 p->pSat->pPrf2 = Prf_ManAlloc();
1671 if (
p->pSat->pPrf2 )
1672 {
1674 Vec_IntFill(
p->vProofIds, Gia_ManObjNum(
p->pGia), -1 );
1675 Prf_ManRestart(
p->pSat->pPrf2,
p->vProofIds, sat_solver2_nlearnts(
p->pSat), Vec_IntSize(vPPis) );
1676 }
1677 }
1678 else
1679 {
1680
1681 if (
p->pSat->pPrf2 )
1682 Prf_ManGrow(
p->pSat->pPrf2,
p->nProofIds + Vec_IntSize(vPPis) );
1683 }
1684
1686 Vec_IntFree( vPPis );
1687 if ( pPars->fVerbose )
1689
1690 if ( pPars->nRatioMin2 && Vec_IntSize(
p->vAbs) >=
p->nMarked * pPars->nRatioMin2 / 100 )
1691 {
1693 goto finish;
1694 }
1695 continue;
1696 }
1697 p->timeUnsat += Abc_Clock() - clk2;
1699 goto finish;
1700 if (
p->pSat->nRuntimeLimit && Abc_Clock() >
p->pSat->nRuntimeLimit )
1701 goto finish;
1702 if ( c == 0 )
1703 {
1704 if ( f >
p->pPars->iFrameProved )
1705 p->pPars->nFramesNoChange++;
1706 break;
1707 }
1708 if ( f >
p->pPars->iFrameProved )
1709 p->pPars->nFramesNoChange = 0;
1710
1711
1712 assert(
p->pSat->pPrf2 != NULL );
1714 Prf_ManStopP( &
p->pSat->pPrf2 );
1715
1717
1719
1720
1721 if ( fUseSecondCore )
1722 {
1723
1724
1725
1726
1727
1728 assert( nVarsOld ==
p->pSat->size );
1729 sat_solver2_bookmark(
p->pSat );
1730
1731 assert(
p->pSat->pPrf2 == NULL );
1732 p->pSat->pPrf2 = Prf_ManAlloc();
1733 if (
p->pSat->pPrf2 )
1734 {
1736 Vec_IntFill(
p->vProofIds, Gia_ManObjNum(
p->pGia), -1 );
1737 Prf_ManRestart(
p->pSat->pPrf2,
p->vProofIds, sat_solver2_nlearnts(
p->pSat), Vec_IntSize(vCore) );
1738
1740 Vec_IntFree( vCore );
1741 }
1742
1743 clk2 = Abc_Clock();
1744 Status =
sat_solver2_solve(
p->pSat, &Lit, &Lit+1, (ABC_INT64_T)pPars->nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
1746 goto finish;
1748 p->timeUnsat += Abc_Clock() - clk2;
1749
1750
1751 assert(
p->pSat->pPrf2 != NULL );
1753 Prf_ManStopP( &
p->pSat->pPrf2 );
1754
1756
1758
1759 }
1760
1762
1763 Vec_IntFree( vCore );
1764 break;
1765 }
1766
1767 if (
p->pPars->iFrameProved < f )
1768 p->pPars->iFrameProved = f;
1769
1770 if ( pPars->fVerbose )
1772
1774 {
1775 RetValue = 1;
1776 goto finish;
1777 }
1778 if ( c > 0 )
1779 {
1780 if (
p->pPars->fVeryVerbose )
1781 Abc_Print( 1, "\n" );
1782
1785
1786 if ( pPars->nRatioMin && Vec_IntSize(
p->vAbs) >=
p->nMarked * pPars->nRatioMin / 100 )
1787 {
1789 goto finish;
1790 }
1791 }
1792
1793 if (
p->pPars->nFramesNoChange ==
p->pPars->nFramesNoChangeLim )
1794 {
1795
1796 if (
p->pPars->fDumpVabs ||
p->pPars->fDumpMabs )
1797 {
1798 char Command[1000];
1805 }
1806
1807 if (
p->pPars->fCallProver )
1808 {
1809
1810 if ( iFrameTryToProve >= 0 )
1812
1814 iFrameTryToProve = f;
1816 }
1817
1819 {
1820
1821 if ( fOneIsSent )
1823
1825 fOneIsSent = 1;
1826 }
1827 }
1828
1829 if ( pPars->nRatioMax == 0 )
1830 continue;
1831 if ( c > 0 && (f > 20 || Vec_IntSize(
p->vAbs) > 100) && Vec_IntSize(
p->vAbs) - nAbsOld >= nAbsOld * pPars->nRatioMax / 100 )
1832 {
1833 if (
p->pPars->fVerbose )
1834 Abc_Print( 1, "Forcing restart because abstraction grew from %d to %d (more than %d %%).\n",
1835 nAbsOld, Vec_IntSize(
p->vAbs), pPars->nRatioMax );
1836 break;
1837 }
1838 }
1839 }
1840finish:
1841 Prf_ManStopP( &
p->pSat->pPrf2 );
1842
1843 if ( iFrameTryToProve >= 0 )
1845
1846 if ( !
p->fUseNewLine )
1847 Abc_Print( 1, "\n" );
1848 if ( RetValue == 1 )
1849 Abc_Print( 1,
"GLA completed %d frames and proved abstraction derived in frame %d ",
p->pPars->iFrameProved+1, iFrameTryToProve );
1850 else if ( pAig->
pCexSeq == NULL )
1851 {
1854 if (
p->pPars->nTimeOut && Abc_Clock() >=
p->pSat->nRuntimeLimit )
1855 Abc_Print( 1,
"GLA reached timeout %d sec in frame %d with a %d-stable abstraction. ",
p->pPars->nTimeOut,
p->pPars->iFrameProved+1,
p->pPars->nFramesNoChange );
1856 else if ( pPars->nConfLimit && sat_solver2_nconflicts(
p->pSat) >= pPars->nConfLimit )
1857 Abc_Print( 1,
"GLA exceeded %d conflicts in frame %d with a %d-stable abstraction. ", pPars->nConfLimit,
p->pPars->iFrameProved+1,
p->pPars->nFramesNoChange );
1858 else if ( pPars->nRatioMin2 && Vec_IntSize(
p->vAbs) >=
p->nMarked * pPars->nRatioMin2 / 100 )
1859 Abc_Print( 1,
"GLA found that the size of abstraction exceeds %d %% in frame %d during refinement. ", pPars->nRatioMin2,
p->pPars->iFrameProved+1 );
1860 else if ( pPars->nRatioMin && Vec_IntSize(
p->vAbs) >=
p->nMarked * pPars->nRatioMin / 100 )
1861 Abc_Print( 1,
"GLA found that the size of abstraction exceeds %d %% in frame %d. ", pPars->nRatioMin,
p->pPars->iFrameProved+1 );
1862 else
1863 Abc_Print( 1,
"GLA finished %d frames and produced a %d-stable abstraction. ",
p->pPars->iFrameProved+1,
p->pPars->nFramesNoChange );
1864 p->pPars->iFrame =
p->pPars->iFrameProved;
1865 }
1866 else
1867 {
1868 if (
p->pPars->fVerbose )
1869 Abc_Print( 1, "\n" );
1871 Abc_Print( 1, " Gia_ManPerformGlaOld(): CEX verification has failed!\n" );
1872 Abc_Print( 1, "True counter-example detected in frame %d. ", f );
1873 p->pPars->iFrame = f - 1;
1875 RetValue = 0;
1876 }
1877 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1878 if (
p->pPars->fVerbose )
1879 {
1880 p->timeOther = (Abc_Clock() - clk) -
p->timeUnsat -
p->timeSat -
p->timeCex -
p->timeInit;
1881 ABC_PRTP(
"Runtime: Initializing",
p->timeInit, Abc_Clock() - clk );
1882 ABC_PRTP(
"Runtime: Solver UNSAT",
p->timeUnsat, Abc_Clock() - clk );
1883 ABC_PRTP(
"Runtime: Solver SAT ",
p->timeSat, Abc_Clock() - clk );
1884 ABC_PRTP(
"Runtime: Refinement ",
p->timeCex, Abc_Clock() - clk );
1885 ABC_PRTP(
"Runtime: Other ",
p->timeOther, Abc_Clock() - clk );
1886 ABC_PRTP(
"Runtime: TOTAL ", Abc_Clock() - clk, Abc_Clock() - clk );
1888 }
1889
1891 fflush( stdout );
1892 return RetValue;
1893}
#define ABC_PRTP(a, t, T)
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
void Ga2_ManReportMemory(Ga2_Man_t *p)
void Ga2_ManRestart(Ga2_Man_t *p)
void Ga2_GlaDumpAbsracted(Ga2_Man_t *p, int fVerbose)
void Gia_Ga2SendAbsracted(Ga2_Man_t *p, int fVerbose)
void Ga2_ManAddAbsClauses(Ga2_Man_t *p, int f)
Ga2_Man_t * Ga2_ManStart(Gia_Man_t *pGia, Abs_Par_t *pPars)
void Ga2_ManStop(Ga2_Man_t *p)
void Gia_Ga2SendCancel(Ga2_Man_t *p, int fVerbose)
void Ga2_ManAbsPrintFrame(Ga2_Man_t *p, int nFrames, int nConfls, int nCexes, abctime Time, int fFinal)
Vec_Int_t * Ga2_ManRefine(Ga2_Man_t *p)
void Gia_GlaProveCancel(int fVerbose)
void Gia_GlaProveAbsracted(Gia_Man_t *p, int fSimpProver, int fVerbose)
DECLARATIONS ///.
int Gia_GlaProveCheck(int fVerbose)
ABC_DLL void Abc_FrameSetNFrames(int nFrames)
ABC_DLL void Abc_FrameSetStatus(int Status)
ABC_DLL void Abc_FrameSetCex(Abc_Cex_t *pCex)
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
int Gia_ManVerifyCex(Gia_Man_t *pAig, Abc_Cex_t *p, int fDualOut)
DECLARATIONS ///.
int var_is_assigned(sat_solver2 *s, int v)
void sat_solver2_rollback(sat_solver2 *s)
int sat_solver2_solve(sat_solver2 *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
void sat_solver2_setnvars(sat_solver2 *s, int n)
void * Sat_ProofCore(sat_solver2 *s)
Abc_Cex_t * Abc_CexMakeTriv(int nRegs, int nTruePis, int nTruePos, int iFrameOut)