tclbdd

Check-in [bcd84fa263]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:add profiler
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:bcd84fa2639b77ec14d060a063eb50febd932244
User & Date: kbk 2013-12-11 13:27:39
Context
2013-12-12
00:44
support; beadcount; simplify; tests for simplify and unset check-in: e48d5c4b6a user: kbk tags: trunk
2013-12-11
13:27
add profiler check-in: bcd84fa263 user: kbk tags: trunk
03:01
test appquant check-in: b7045d44bb user: kbk tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/bdd.c.

2391
2392
2393
2394
2395
2396
2397




















































2398
2399
2400
2401
2402
2403
2404
    ckfree(stateVector->v);
    ckfree(stateVector->sStack);
    BDD_UnrefBead(stateVector->sysPtr, stateVector->uStack[0]);
    ckfree(stateVector->uStack);
    ckfree(stateVector);
}
 




















































/*
 *-----------------------------------------------------------------------------
 *
 * BDD_Dump --
 *
 *	Formats a BDD as a Tcl dictionary for debugging.
 *







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
    ckfree(stateVector->v);
    ckfree(stateVector->sStack);
    BDD_UnrefBead(stateVector->sysPtr, stateVector->uStack[0]);
    ckfree(stateVector->uStack);
    ckfree(stateVector);
}
 
/*
 *-----------------------------------------------------------------------------
 *
 * BDD_Profile --
 *
 *	Counts the number of beads in a BDD, broken out by level.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Stores the counts in the caller-supplied vector 'counts'.
 *	If the depth of the BDD is greater than or equal to the 
 *	caller-supplied 'n', only nodes up to the given depth are
 *	counted. The BDD_GetVariableCount call returns a value for
 *	'n' that is guaranteed to be sufficient.
 *
 *-----------------------------------------------------------------------------
 */
static void
Profile(
    BDD_System* sysPtr,		/* System of BDD's */
    BDD_BeadIndex u)		/* BDD to count */
{
    Bead* beadPtr = sysPtr->beads + u;
				/* Pointer to the current bead */
    BDD_VariableIndex level = beadPtr->level;
				/* Current bead's level */
    int newFlag;	        /* Has this bead been seen before? */

    if ((u <= 1) || (level >= sysPtr->profileDepth)) return;
    Tcl_CreateHashEntry(&(sysPtr->profileCache), (void*) u, &newFlag);
    if (newFlag) {
	++(sysPtr->profileCounts[level]);
	Profile(sysPtr, beadPtr->low);
	Profile(sysPtr, beadPtr->high);
    }
}
void
BDD_Profile(
    BDD_System* sysPtr,		/* System of BDD's */
    BDD_BeadIndex u,		/* BDD to count */
    BDD_VariableIndex n,	/* Maximum depth to count */
    BDD_BeadIndex counts[])	/* OUTPUT: counts of beads by level */
{
    memset(counts, 0, n * sizeof(BDD_BeadIndex));
    Tcl_InitHashTable(&(sysPtr->profileCache), TCL_ONE_WORD_KEYS);
    sysPtr->profileDepth = n;
    sysPtr->profileCounts = counts;
    Profile(sysPtr, u);
    Tcl_DeleteHashTable(&(sysPtr->profileCache));
}
/*
 *-----------------------------------------------------------------------------
 *
 * BDD_Dump --
 *
 *	Formats a BDD as a Tcl dictionary for debugging.
 *

Changes to generic/bdd.h.

168
169
170
171
172
173
174


175
176
177
178
179
180
181
182
183
184
185
186
			       mp_int* count);
extern BDDAPI BDD_AllSatState* BDD_AllSatStart(BDD_System* sysPtr,
					       BDD_BeadIndex u);
extern BDDAPI int BDD_AllSatNext(BDD_AllSatState* state,
				 BDD_ValueAssignment** vPtr,
				 BDD_VariableIndex* nPtr);
extern BDDAPI void BDD_AllSatFinish(BDD_AllSatState*);


extern BDDAPI int BDD_Dump(Tcl_Interp*, Tcl_Obj*, BDD_System*, BDD_BeadIndex);
extern BDDAPI void BDD_DeleteSystem(BDD_System* sysPtr);


#endif /* not BDD_H_INCLUDED */

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * End:
 */







>
>












168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
			       mp_int* count);
extern BDDAPI BDD_AllSatState* BDD_AllSatStart(BDD_System* sysPtr,
					       BDD_BeadIndex u);
extern BDDAPI int BDD_AllSatNext(BDD_AllSatState* state,
				 BDD_ValueAssignment** vPtr,
				 BDD_VariableIndex* nPtr);
extern BDDAPI void BDD_AllSatFinish(BDD_AllSatState*);
extern BDDAPI void BDD_Profile(BDD_System* sysPtr, BDD_BeadIndex u,
			       BDD_VariableIndex n, BDD_BeadIndex counts[]);
extern BDDAPI int BDD_Dump(Tcl_Interp*, Tcl_Obj*, BDD_System*, BDD_BeadIndex);
extern BDDAPI void BDD_DeleteSystem(BDD_System* sysPtr);


#endif /* not BDD_H_INCLUDED */

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * End:
 */

Changes to generic/bddInt.h.

55
56
57
58
59
60
61






62
63
64
65
66
67
68
				/* Replacement expressions for variables
				 * being substituted in BDD_Compose */
    Tcl_HashTable dumpCache;	/* Cache of visited nodes for BDD_Dump */
    Tcl_Interp* dumpInterp;	/* Tcl interpreter where BDD_Dump stores
				 * results */
    Tcl_Obj* dumpOutput;        /* Tcl object where BDD_Dump returns the dump */
    Tcl_HashTable negateCache;	/* Cache of partial results for BDD_Negate */






    BDD_Quantifier quantifier;	/* Quantifier for BDD_Quantify */
    Tcl_HashTable quantifyCache;
				/* Cache of partial results for BDD_Quantify */
    Tcl_HashTable restrictCache; 
				/* Cache of partial results for BDD_Restrict */
    Tcl_HashTable satCountCache;
				/* Cache of partial results for BDD_SatCount */







>
>
>
>
>
>







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
				/* Replacement expressions for variables
				 * being substituted in BDD_Compose */
    Tcl_HashTable dumpCache;	/* Cache of visited nodes for BDD_Dump */
    Tcl_Interp* dumpInterp;	/* Tcl interpreter where BDD_Dump stores
				 * results */
    Tcl_Obj* dumpOutput;        /* Tcl object where BDD_Dump returns the dump */
    Tcl_HashTable negateCache;	/* Cache of partial results for BDD_Negate */
    Tcl_HashTable profileCache;	/* Cache of visited beads for BDD_Profile */
    BDD_VariableIndex profileDepth;
				/* Max depth for BDD_Profile */
    BDD_BeadIndex* profileCounts;
				/* Vector where BDD_Profile stores bead
				 * counts, indexed by level */
    BDD_Quantifier quantifier;	/* Quantifier for BDD_Quantify */
    Tcl_HashTable quantifyCache;
				/* Cache of partial results for BDD_Quantify */
    Tcl_HashTable restrictCache; 
				/* Cache of partial results for BDD_Restrict */
    Tcl_HashTable satCountCache;
				/* Cache of partial results for BDD_SatCount */

Changes to generic/tclBdd.c.

139
140
141
142
143
144
145


146
147
148
149
150
151
152
...
254
255
256
257
258
259
260







261
262
263
264
265
266
267
...
331
332
333
334
335
336
337

338
339
340
341
342
343
344
....
1453
1454
1455
1456
1457
1458
1459










































































1460
1461
1462
1463
1464
1465
1466
			     int, Tcl_Obj *const[]);
static int BddSystemNegateMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				 int, Tcl_Obj* const[]);
static int BddSystemNotnthvarMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				    int, Tcl_Obj* const[]);
static int BddSystemNthvarMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				 int, Tcl_Obj* const[]);


static int BddSystemQuantifyMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				   int, Tcl_Obj* const[]);
static int BddSystemRestrictMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				   int, Tcl_Obj* const[]);
static int BddSystemSatcountMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				   int, Tcl_Obj* const[]);
static int BddSystemTernopMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
................................................................................
};
const static Tcl_MethodType BddSystemNthvarMethodType = {
    TCL_OO_METHOD_VERSION_CURRENT, /* version */
    "nthvar",			   /* name */
    BddSystemNthvarMethod,	   /* callProc */
    DeleteMethod,		   /* method delete proc */
    CloneMethod			   /* method clone proc */







};
const static Tcl_MethodType BddSystemQuantifyMethodType = {
    TCL_OO_METHOD_VERSION_CURRENT, /* version */
    "quantify",			   /* name */
    BddSystemQuantifyMethod,	   /* callProc */
    DeleteMethod,		   /* method delete proc */
    CloneMethod			   /* method clone proc */
................................................................................
    { "nand",      &BddSystemBinopMethodType,     (ClientData) BDD_BINOP_NAND },
    { "nand3",     &BddSystemTernopMethodType,   (ClientData) BDD_TERNOP_NAND },
    { "nor",       &BddSystemBinopMethodType,     (ClientData) BDD_BINOP_NOR },
    { "nor3",      &BddSystemTernopMethodType,    (ClientData) BDD_TERNOP_NOR },
    { "notnthvar", &BddSystemNotnthvarMethodType, NULL },
    { "nthvar",    &BddSystemNthvarMethodType,    NULL },
    { "oneof3",    &BddSystemTernopMethodType,  (ClientData) BDD_TERNOP_ONEOF },

    { "restrict",  &BddSystemRestrictMethodType,  NULL },
    { "satcount",  &BddSystemSatcountMethodType,  NULL },
    { "twoof3",    &BddSystemTernopMethodType,  (ClientData) BDD_TERNOP_TWOOF },
    { "unset",     &BddSystemUnsetMethodType,     NULL },
    { "|",         &BddSystemBinopMethodType,     (ClientData) BDD_BINOP_OR },
    { "|3",        &BddSystemTernopMethodType,    (ClientData) BDD_TERNOP_OR },
    { "~",         &BddSystemNegateMethodType,    NULL },
................................................................................
	return TCL_ERROR;
    }
    beadIndex = BDD_NotNthVariable(sdata->system, (BDD_VariableIndex) varNum);
    SetNamedExpression(sdata, objv[skipped], beadIndex);
    BDD_UnrefBead(sdata->system, beadIndex);
    return TCL_OK;
}










































































 
/*
 *-----------------------------------------------------------------------------
 *
 * BddSystemQuantifyMethod --
 *
 *	Quantifies a BDD with respect to a particular set of variables.







>
>







 







>
>
>
>
>
>
>







 







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
...
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
....
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
			     int, Tcl_Obj *const[]);
static int BddSystemNegateMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				 int, Tcl_Obj* const[]);
static int BddSystemNotnthvarMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				    int, Tcl_Obj* const[]);
static int BddSystemNthvarMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				 int, Tcl_Obj* const[]);
static int BddSystemProfileMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				  int, Tcl_Obj* const[]);
static int BddSystemQuantifyMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				   int, Tcl_Obj* const[]);
static int BddSystemRestrictMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				   int, Tcl_Obj* const[]);
static int BddSystemSatcountMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				   int, Tcl_Obj* const[]);
static int BddSystemTernopMethod(ClientData, Tcl_Interp*, Tcl_ObjectContext,
................................................................................
};
const static Tcl_MethodType BddSystemNthvarMethodType = {
    TCL_OO_METHOD_VERSION_CURRENT, /* version */
    "nthvar",			   /* name */
    BddSystemNthvarMethod,	   /* callProc */
    DeleteMethod,		   /* method delete proc */
    CloneMethod			   /* method clone proc */
};
const static Tcl_MethodType BddSystemProfileMethodType = {
    TCL_OO_METHOD_VERSION_CURRENT, /* version */
    "profile",			   /* name */
    BddSystemProfileMethod,	   /* callProc */
    DeleteMethod,		   /* method delete proc */
    CloneMethod			   /* method clone proc */
};
const static Tcl_MethodType BddSystemQuantifyMethodType = {
    TCL_OO_METHOD_VERSION_CURRENT, /* version */
    "quantify",			   /* name */
    BddSystemQuantifyMethod,	   /* callProc */
    DeleteMethod,		   /* method delete proc */
    CloneMethod			   /* method clone proc */
................................................................................
    { "nand",      &BddSystemBinopMethodType,     (ClientData) BDD_BINOP_NAND },
    { "nand3",     &BddSystemTernopMethodType,   (ClientData) BDD_TERNOP_NAND },
    { "nor",       &BddSystemBinopMethodType,     (ClientData) BDD_BINOP_NOR },
    { "nor3",      &BddSystemTernopMethodType,    (ClientData) BDD_TERNOP_NOR },
    { "notnthvar", &BddSystemNotnthvarMethodType, NULL },
    { "nthvar",    &BddSystemNthvarMethodType,    NULL },
    { "oneof3",    &BddSystemTernopMethodType,  (ClientData) BDD_TERNOP_ONEOF },
    { "profile",   &BddSystemProfileMethodType,   NULL },
    { "restrict",  &BddSystemRestrictMethodType,  NULL },
    { "satcount",  &BddSystemSatcountMethodType,  NULL },
    { "twoof3",    &BddSystemTernopMethodType,  (ClientData) BDD_TERNOP_TWOOF },
    { "unset",     &BddSystemUnsetMethodType,     NULL },
    { "|",         &BddSystemBinopMethodType,     (ClientData) BDD_BINOP_OR },
    { "|3",        &BddSystemTernopMethodType,    (ClientData) BDD_TERNOP_OR },
    { "~",         &BddSystemNegateMethodType,    NULL },
................................................................................
	return TCL_ERROR;
    }
    beadIndex = BDD_NotNthVariable(sdata->system, (BDD_VariableIndex) varNum);
    SetNamedExpression(sdata, objv[skipped], beadIndex);
    BDD_UnrefBead(sdata->system, beadIndex);
    return TCL_OK;
}
 
/*
 *-----------------------------------------------------------------------------
 *
 * BddSystemProfileMethod --
 *
 *	Profiles a BDD, reporting the number of beads at each level.
 *
 * Usage:
 *	$sys profile $expr
 *
 * Parameters:
 *	sys  - System of BDD's
 *	expr - Name of an expression to profile.
 *
 * Results:
 *	Returns a list of integers. The nth element of the list is the
 *	number of beads at level n.
 *
 *-----------------------------------------------------------------------------
 */

static int
BddSystemProfileMethod(
    ClientData clientData,	/* Operation to perform */
    Tcl_Interp* interp,		/* Tcl interpreter */
    Tcl_ObjectContext ctx,	/* Object context */
    int objc,			/* Parameter count */
    Tcl_Obj *const objv[])	/* Parameter vector */
{
    Tcl_Object thisObject = Tcl_ObjectContextObject(ctx);
				/* The current object */
    BddSystemData* sdata = (BddSystemData*)
	Tcl_ObjectGetMetadata(thisObject, &BddSystemDataType);
				/* The current system of expressions */
    int skipped = Tcl_ObjectContextSkippedArgs(ctx);
				/* The number of args used in method dispatch */
    BDD_BeadIndex u;		/* Expression to profile */
    BDD_VariableIndex n = BDD_GetVariableCount(sdata->system);
				/* Number of variables */
    BDD_BeadIndex* v;		/* Vector of counts expressed as integers */
    Tcl_Obj** countv;		/* Vector of counts expressed as Tcl_Obj */
    BDD_VariableIndex i;

    /*
     * Process argument
     */
    if (objc != skipped+1) {
	Tcl_WrongNumArgs(interp, skipped, objv, "expr");
	return TCL_ERROR;
    }
    if (FindNamedExpression(interp, sdata, objv[skipped],
			    &u) != TCL_OK) {
	return TCL_ERROR;
    }

    /*
     * Get the profile counts
     */
    v = ckalloc(n * sizeof(BDD_BeadIndex));
    BDD_Profile(sdata->system, u, n, v);

    /*
     * Convert profile to Tcl_Obj form
     */
    countv = ckalloc(n * sizeof(Tcl_Obj*));
    for (i = 0; i < n; ++i) {
	countv[i] = Tcl_NewWideIntObj((Tcl_WideInt) v[i]);
    }
    ckfree(v);
    Tcl_SetObjResult(interp, Tcl_NewListObj(n, countv));
    ckfree(countv);
    return TCL_OK;
}
 
/*
 *-----------------------------------------------------------------------------
 *
 * BddSystemQuantifyMethod --
 *
 *	Quantifies a BDD with respect to a particular set of variables.

Changes to tests/bdd.test.

2548
2549
2550
2551
2552
2553
2554




































































































































2555
2556
2557
2558
2559
2560
2561
		    [sys gc]
	    }
	    -cleanup {rename sys {}}
	    -result {1 {} 2}
	}
    }
}





































































































































test bdd-21.1 {eight queens} {*}{
    -setup {
	bdd::system create sys
	for {set i 0} {$i < 64} {incr i} {
	    sys nthvar v$i $i; sys notnthvar !v$i $i
	}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
		    [sys gc]
	    }
	    -cleanup {rename sys {}}
	    -result {1 {} 2}
	}
    }
}

test bdd-19.1 {profile - wrong # args} {*}{
    -setup {bdd::system create sys}
    -body {sys profile}
    -cleanup {rename sys {}}
    -returnCodes error
    -match glob
    -result {wrong # args: *}
}

test bdd-19.2 {profile - bad expr} {*}{
    -setup {
	bdd::system create sys
    }
    -body {
	list [catch {sys profile garbage} result] $result $::errorCode
    }
    -cleanup {
	rename sys {}
    }
    -result \
	{1 {expression named "garbage" not found} {BDD ExprNotFound garbage}}
}

test bdd-19.3 {profile constants} {*}{
    -setup {
	bdd::system create sys
    }
    -body {
	list [sys profile 0] [sys profile 1]
    }
    -cleanup {
	rename sys {}
    }
    -result {{} {}}
}

test bdd-19.4 {profile single variables} {*}{
    -setup {
	bdd::system create sys
	sys nthvar a 0; sys notnthvar !a 0
    }
    -body {
	list [sys profile 0] [sys profile 1] [sys profile a] [sys profile !a] \
	    [sys unset a !a] [sys gc]
    }
    -cleanup {
	rename sys {}
    }
    -result {0 0 1 1 {} 2}
}

test bdd-19.4 {profile single variables} {*}{
    -setup {
	bdd::system create sys
	sys nthvar a 0; sys notnthvar !a 0
	sys nthvar b 1; sys notnthvar !b 1
    }
    -body {
	list [sys profile 0] [sys profile 1] \
	    [sys profile a] [sys profile !a] \
	    [sys profile b] [sys profile !b] \
	    [sys unset a !a b !b] [sys gc]
    }
    -cleanup {
	rename sys {}
    }
    -result {{0 0} {0 0} {1 0} {1 0} {0 1} {0 1} {} 2}
}

test bdd-19.5 {profile ==} {*}{
    -setup {
	bdd::system create sys
	sys nthvar a 0
	sys nthvar b 1
	sys nthvar c 2
	sys nthvar d 3
	sys nthvar e 4
	sys nthvar f 5
    }
    -body {
	sys == eq1 a b
	sys == eq2 c d
	sys == eq3 e f
	sys &3 smart eq1 eq2 eq3
	sys == eq1 a d
	sys == eq2 b e
	sys == eq3 c f
	sys &3 dumb eq1 eq2 eq3
	list [sys profile smart] [sys profile dumb] \
	    [sys unset a b c d e f eq1 eq2 eq3 smart dumb] [sys gc]
    }
    -cleanup {
	rename sys {}
    }
    -result {{1 2 1 2 1 2} {1 2 4 8 4 2} {} 2}
}

test bdd-19.6 {profile 4-bit adder} {*}{
    -setup {
	bdd::system create sys
	sys nthvar a1 0; sys nthvar b1 1; sys nthvar z1 2
	sys nthvar a2 3; sys nthvar b2 4; sys nthvar z2 5
	sys nthvar a4 6; sys nthvar b4 7; sys nthvar z4 8
	sys nthvar a8 9; sys nthvar b8 10; sys nthvar z8 11
    }
    -body {
	sys ^ sum1 a1 b1
	sys & carry2 a1 b1
	sys ^3 sum2 a2 b2 carry2
	sys median carry4 a2 b2 carry2
	sys ^3 sum4 a4 b4 carry4
	sys median carry8 a4 b4 carry4
	sys ^3 sum8 a8 b8 carry8
	sys median carry16 a8 b8 carry8
	sys == result sum1 z1
	sys == term sum2 z2
	sys & result result term
	sys == term sum4 z4
	sys & result result term
	sys == term sum8 z8
	sys & result result term
	sys == term carry16 0
	sys & result result term
	sys unset term sum1 sum2 sum4 sum8 carry2 carry4 carry8 carry16
	list [sys profile result] \
	    [sys unset result a1 a2 a4 a8 b1 b2 b4 b8 z1 z2 z4 z8] \
	    [sys gc]
    }
    -cleanup {rename sys {}}
    -result {{1 2 3 2 3 4 2 3 4 2 2 2} {} 2}
}

test bdd-21.1 {eight queens} {*}{
    -setup {
	bdd::system create sys
	for {set i 0} {$i < 64} {incr i} {
	    sys nthvar v$i $i; sys notnthvar !v$i $i
	}