Some propositional formulas to test, and functions to generate classes.
This module, while showing some applications of propositional logic, is used above all to generate interesting classes of problems in order to have a stock of non-trivial formulas on which to test the efficiency of propositional logic algorithms.
Function or value | Description |
Full Usage:
ramsey s t n
Parameters:
int
-
The number of connected vertices.
t : int
-
The number of disconnected vertices.
n : int
-
The number supposed to be greater or equal to the Ramsey number.
Returns: formula<prop>
A propositional formula that is a tautology if if n is greater
or equal than the Ramsey number R(s ,t ).
|
In terms of graph theory, the ramsey number R(
Example
Evaluates to (p_1_2 /\ p_1_3 /\ p_2_3 \/ p_1_2 /\ p_1_4 /\ p_2_4 \/ p_1_3 /\ p_1_4 /\ p_3_4 \/ p_2_3 /\ p_2_4 /\ p_3_4) \/ ~p_1_2 /\ ~p_1_3 /\ ~p_2_3 \/ ~p_1_2 /\ ~p_1_4 /\ ~p_2_4 \/ ~p_1_3 /\ ~p_1_4 /\ ~p_3_4 \/ ~p_2_3 /\ ~p_2_4 /\ ~p_3_4 .
Example
Evaluates to false .
Example
Evaluates to true .
|
Function or value | Description |
Full Usage:
ha x y s c
Parameters:
formula<'a>
-
The first one-bit-number to be added.
y : formula<'a>
-
The second one-bit-number to be added.
s : formula<'a>
-
The supposed sum.
c : formula<'a>
-
The supposed carry.
Returns: formula<'a>
The propositional formula that is true in those valuations in which
s and c are, respectively, the sum and carry calculated
by an half-adder for the sum of x and y .
|
An half adder calculates the sum and carry for only two one-bit-numbers. ha generates a propositional formula that is true in those
valuations in which s and c are, respectively, the sum
and carry calculated by an half-adder for the sum of x and
y .
Example
Evaluates to `(false <=> true <=> ~true) /\ (true <=> true /\ true)` .
ExampleAll the valuations satisfying the formula represent the correct relation between input and output of an half adder.
val fm: obj
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val iter: action: ('T -> unit) -> list: 'T list -> unit
val v: (obj -> obj)
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
After evaluation the following is printed to the (+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) stdout :
|
|
The truth-value of the generated propositional formula corresponds to
the carry of an half adder of two one-bit-numbers
Example
Evaluates to `true /\ false`` .
ExampleThe truth-table of the output formula, with truth-values converted in integers, shows how it calculates the half-adder carry:
val fm: obj
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val iter: action: ('T -> unit) -> list: 'T list -> unit
val v: (obj -> obj)
val atm: obj
val printf: format: Printf.TextWriterFormat<'T> -> 'T
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
After evaluation the following is printed to the (+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) stdout :
|
|
The truth-value of the generated propositional formula corresponds to
the sum of an half adder of two one-bit-numbers
Example
Evaluates to `true <=> ~false` .
ExampleThe truth-table of the output formula, with truth-values converted in integers, shows how it calculates the half-adder sum:
val fm: obj
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val iter: action: ('T -> unit) -> list: 'T list -> unit
val v: (obj -> obj)
val atm: obj
val printf: format: Printf.TextWriterFormat<'T> -> 'T
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
After evaluation the following is printed to the (+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) stdout :
|
Function or value | Description |
|
The truth-value of the generated propositional formula corresponds to
the carry of a full adder of two one-bit-numbers
Example
Evaluates to `true /\ false \/ (true \/ false) /\ true` .
ExampleThe truth-table of the output formula, with truth-values converted in integers, shows how it calculates the half-adder carry:
val fm: obj
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val iter: action: ('T -> unit) -> list: 'T list -> unit
val v: (obj -> obj)
val atm: obj
val printf: format: Printf.TextWriterFormat<'T> -> 'T
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
After evaluation the following is printed to the (+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) stdout :
|
Full Usage:
fa x y z s c
Parameters:
formula<'a>
-
The first one-bit-number to be added.
y : formula<'a>
-
The second one-bit-number to be added.
z : formula<'a>
-
The carry from a previous sum.
s : formula<'a>
-
The supposed sum.
c : formula<'a>
-
The supposed carry.
Returns: formula<'a>
The propositional formula that is true in those valuations in which
s and c are, respectively, the sum and carry calculated
by a full-adder for the sum of x and y plus the carry
z for a previous sum.
|
A full adder is a one-bit adder that adds three one-bit-numbers: two
operands fa generates a propositional formula that is true in those
valuations in which s and c are, respectively, the sum
and carry calculated by a full-adder for the sum of x and
y plus the carry z for a previous sum.
ExampleAll the valuations satisfying the formula represent the correct relation between input and output of an half adder.
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val iter: action: ('T -> unit) -> list: 'T list -> unit
val v: (obj -> obj)
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
After evaluation the following is printed to the (+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) stdout :
|
The truth-value of the generated propositional formula corresponds to
the sum of a full adder of two one-bit-numbers
Example
Evaluates to `(true <=> ~false) <=> ~true` .
ExampleThe truth-table of the output formula, with truth-values converted in integers, shows how it calculates the half-adder carry:
val fm: obj
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val iter: action: ('T -> unit) -> list: 'T list -> unit
val v: (obj -> obj)
val atm: obj
val printf: format: Printf.TextWriterFormat<'T> -> 'T
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
After evaluation the following is printed to the (+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) stdout :
|
Function or value | Description |
|
Its intended use, in our context, is to put multiple 1-bit adders together into an n-bit adder. Indexes in this case point to the n-bit positions of the two n-bit numbers to be added. For example, Propexamples.ripplecarry use this function to 'conjoin' n Propexamples.fa's in order to obtain an n-bit adder.
Example
Evaluates to And (Atom 1, And (Atom 2, Atom 3)) .
|
|
Given a string mk_index , just to the first string argument,
generates the type of functions (from integers to propositional
variables) expected by ripplecarry functions.
Example
Evaluates to Atom (P "x_0") .
|
|
Similar to Propexamples.mk_index Given a string"x" and indexes i and j , it
generates a propositional variable Atom (P x_i_j) .
Example
Evaluates to Atom (P "x_0_1") .
|
Full Usage:
ripplecarry x y c out n
Parameters:
int -> formula<'a>
-
The function that produces the indexed variables to encode the bits of the first addend.
y : int -> formula<'a>
-
The function that produces the indexed variables to encode the bits of the second addend.
c : int -> formula<'a>
-
The function that produces the indexed variables to encode the carry at each bit.
out : int -> formula<'a>
-
The function that produces the indexed variables to encode the sum at each bit.
n : int
-
The number of bits handled by the adder.
Returns: formula<'a>
The conjunction of the formulas that represent full adders for each
bit position.
|
Conjoins (see Propexamples.conjoin)
x , y , out
and c that, when given an index, generates an appropriate new
variable. Propexamples.mk_index is
supplied to generate such functions.
ExampleRipple carry adder of two 2-bit numbers: printing all the valuations satisfying the formula shows all the possible correct relations between input.
val x: obj
val y: obj
val s: obj
val c: obj
val fm: obj
val toInt: v: ('a -> bool) -> x: 'b -> int
val v: ('a -> bool)
type bool = System.Boolean
val x: 'b
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
(+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val iteri: action: (int -> 'T -> unit) -> list: 'T list -> unit
val i: int
val v: (obj -> bool)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Some output omitted for brevity:
Note how this version admit a carry c(0) different from 0 propagated in
at the first bit.
|
Full Usage:
ripplecarry0 x y c out n
Parameters:
int -> formula<'a>
-
The function that produces the indexed variables to encode the bits of the first addend.
y : int -> formula<'a>
-
The function that produces the indexed variables to encode the bits of the second addend.
c : int -> formula<'a>
-
The function that produces the indexed variables to encode the carry at each bit.
out : int -> formula<'a>
-
The function that produces the indexed variables to encode the sum at each bit.
n : int
-
The number of bits handled by the adder.
Returns: formula<'a>
The conjunction of the formulas that represent full adders for each
bit position, except for the first position that is represented by an
half adder.
|
It can be used when we are not interested in a carry in at the low end.
ExampleFiltering the satisfying valuations with x_1=0,x_0=0,y_1=1,y_0=1 gives the ripplecarry0 for the sum of 01+11:
val x: obj
val y: obj
val s: obj
val c: obj
val rc0: obj
val toInt: v: ('a -> bool) -> x: 'b -> int
val v: ('a -> bool)
type bool = System.Boolean
val x: 'b
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
(+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val filter: predicate: ('T -> bool) -> list: 'T list -> 'T list
val v: (obj -> bool)
val iteri: action: (int -> 'T -> unit) -> list: 'T list -> unit
val i: int
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
After evaluation the following is printed to the stdout :
|
Full Usage:
ripplecarry1 x y c out n
Parameters:
int -> formula<'a>
-
The function that produces the indexed variables to encode the bits of the first addend.
y : int -> formula<'a>
-
The function that produces the indexed variables to encode the bits of the second addend.
c : int -> formula<'a>
-
The function that produces the indexed variables to encode the carry at each bit.
out : int -> formula<'a>
-
The function that produces the indexed variables to encode the sum at each bit.
n : int
-
The number of bits handled by the adder.
Returns: formula<'a>
The conjunction of the formulas that represent full adders for each
bit position, except for the first position in which a carry-in of 1 is
forced.
|
Together with Propexamples.ripplecarry0 is used to define Propexamples.carryselect.
ExampleFiltering the satisfying valuations with x_1=0,x_0=0,y_1=1,y_0=1 gives the ripplecarry1 for the sum of 01+11:
val x: obj
val y: obj
val s: obj
val c: obj
val rc1: obj
val toInt: v: ('a -> bool) -> x: 'b -> int
val v: ('a -> bool)
type bool = System.Boolean
val x: 'b
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
(+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val filter: predicate: ('T -> bool) -> list: 'T list -> 'T list
val v: (obj -> bool)
val iteri: action: (int -> 'T -> unit) -> list: 'T list -> unit
val i: int
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
After evaluation the following is printed to the stdout :
Note that while there is no c_0 in the formula the sum is
calculated as if c_0 were equal to 1.
|
Function or value | Description |
Full Usage:
carryselect x y c0 c1 s0 s1 c s n k
Parameters:
int -> formula<'a>
-
The function that produces the indexed variables to encode the bits of the first addend.
y : int -> formula<'a>
-
The function that produces the indexed variables to encode the bits of the second addend.
c0 : int -> formula<'a>
-
The function that produces the indexed variables to encode the carries of the Propexamples.ripplecarry0 step.
c1 : int -> formula<'a>
-
The function that produces the indexed variables to encode the carries of the Propexamples.ripplecarry1 step.
s0 : int -> formula<'a>
-
The function that produces the indexed variables to encode the sums of the Propexamples.ripplecarry0 step.
s1 : int -> formula<'a>
-
The function that produces the indexed variables to encode the sums of the Propexamples.ripplecarry1 step.
c : int -> formula<'a>
-
The function that produces the indexed variables to encode the carry at each bit.
s : int -> formula<'a>
-
The function that produces the indexed variables to encode the sum at each bit.
n : int
-
The number of bits handled by the adder.
k : int
-
The number of blocks in which the input are splitted.
Returns: formula<'a>
The propositional formula that is true in the valuations that represent
the correct relations between input and output of a carry select adder.
|
The carry select adder is a more efficient adder than the ripplecarry,
in which the
Example
val x: obj
val y: obj
val c0: obj
val c1: obj
val s0: obj
val s1: obj
val s: obj
val c: obj
val cs: obj
val toInt: v: ('a -> bool) -> x: 'b -> int
val v: ('a -> bool)
type bool = System.Boolean
val x: 'b
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
(+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val filter: predicate: ('T -> bool) -> list: 'T list -> 'T list
val v: (obj -> bool)
val iteri: action: (int -> 'T -> unit) -> list: 'T list -> unit
val i: int
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
After evaluation the following is printed to the stdout :
|
Full Usage:
mk_adder_test n k
Parameters:
int
-
The number of bit to be added.
k : int
-
The number of blocks in the carryselect.
Returns: formula<prop>
A propositional formula that is a tautology, if Propexamples.ripplecarry0 and Propexamples.carryselect are equivalent.
|
Generates propositions that state the equivalence of various
ripplecarry and carryselect circuits based on the input
Example
Evaluates to true .
|
|
Selects between two alternatives: if
Example
If
After evaluation the following is printed to the stdout .
Example
If
After evaluation the following is printed to the stdout .
|
Full Usage:
offset n x i
Parameters:
int
-
The variable's index to offset.
x : int -> 'a
-
A function that returns variables at given indexes.
i : int
-
The number of position by which to offset the variable's index.
Returns: 'a
The offset propositional variable.
|
It is used to define the carry-select adder.
Example
Evaluates to Atom (P "x_3") .
|
Function or value | Description |
Full Usage:
multiplier x u v out n
Parameters:
int -> int -> formula<'a>
-
The function from each bit positions of both operands to their products (represented as simple conjunctions of their variables).
u : int -> int -> formula<'a>
-
An n -by-n 'array' to hold the intermediate sums.
v : int -> int -> formula<'a>
-
An n -by-n 'array' to hold the intermediate carries.
out : int -> formula<'a>
-
An n -by-n 'array' to hold the result.
n : int
-
The number of bits handled by the multiplier.
Returns: formula<'a>
The propositional formula that represents the relations between the
input and output of the multiplier.
|
Example
val toInt: v: ('a -> bool) -> x: 'b -> int
val v: ('a -> bool)
type bool = System.Boolean
val x: 'b
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
(+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) val x: obj
val y: obj
val out: obj
val m: i: 'a -> j: 'b -> 'c
val i: 'a
val j: 'b
val u: obj
val v: obj
val ml: obj
val isIn: v: ('a -> bool) -> n: string -> x: string -> bool
val n: string
val x: string
val max: int
module String
from Microsoft.FSharp.Core
val length: str: string -> int
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val forall: predicate: ('T -> bool) -> list: 'T list -> bool
val i: int
val bit: string
Multiple items
val seq: sequence: seq<'T> -> seq<'T> -------------------- type seq<'T> = System.Collections.Generic.IEnumerable<'T> module Seq
from Microsoft.FSharp.Collections
val item: index: int -> source: seq<'T> -> 'T
Multiple items
val string: value: 'T -> string -------------------- type string = System.String val sprintf: format: Printf.StringFormat<'T> -> 'T
[<Struct>]
type Int32 =
member CompareTo: value: int -> int + 1 overload
member Equals: obj: int -> bool + 1 overload
member GetHashCode: unit -> int
member GetTypeCode: unit -> TypeCode
member ToString: unit -> string + 3 overloads
member TryFormat: destination: Span<char> * charsWritten: byref<int> * ?format: ReadOnlySpan<char> * ?provider: IFormatProvider -> bool
static member Abs: value: int -> int
static member Clamp: value: int * min: int * max: int -> int
static member CopySign: value: int * sign: int -> int
static member CreateChecked<'TOther (requires 'TOther :> INumberBase<'TOther>)> : value: 'TOther -> int
...
<summary>Represents a 32-bit signed integer.</summary> System.Int32.Parse(s: string) : int
System.Int32.Parse(s: string, provider: System.IFormatProvider) : int System.Int32.Parse(s: string, style: System.Globalization.NumberStyles) : int System.Int32.Parse(s: System.ReadOnlySpan<char>, provider: System.IFormatProvider) : int System.Int32.Parse(s: string, style: System.Globalization.NumberStyles, provider: System.IFormatProvider) : int System.Int32.Parse(s: System.ReadOnlySpan<char>, ?style: System.Globalization.NumberStyles, ?provider: System.IFormatProvider) : int val printIn: v: ('a -> bool) -> n: int -> x: string -> unit
val n: int
val sortDescending: list: 'T list -> 'T list (requires comparison)
val iter: action: ('T -> unit) -> list: 'T list -> unit
val printf: format: Printf.TextWriterFormat<'T> -> 'T
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val filter: predicate: ('T -> bool) -> list: 'T list -> 'T list
val v: (obj -> bool)
val iteri: action: (int -> 'T -> unit) -> list: 'T list -> unit
After evaluation the following is printed to the stdout .
|
Full Usage:
rippleshift u v c z w n
Parameters:
int -> formula<'a>
-
A function that, given an index, returns a variable that represent the bit of the first addend at that bit.
v : int -> formula<'a>
-
A function that, given an index, returns a variable that represent the bit of the second addend at that bit.
c : int -> formula<'a>
-
A function that, given an index, returns a variable for the value of the carry (in and out) at that bit (index).
z : formula<'a>
-
The variable that represent the less significant bit of the resulting sum.
w : int -> formula<'a>
-
A function that, given an index, returns a variable that represent the bit of the sum addend at index+1.
n : int
-
The number of bits of the operands added by the ripplecarry adder.
Returns: formula<'a>
A Propexamples.ripplecarry0 with z as the less significant bit of the sum and w as the other bits
|
Example
val toInt: v: ('a -> bool) -> x: 'b -> int
val v: ('a -> bool)
type bool = System.Boolean
val x: 'b
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
(+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) val u: obj
val v: obj
val c: obj
val w: obj
val rs: obj
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val iteri: action: (int -> 'T -> unit) -> list: 'T list -> unit
val i: int
val v: (obj -> bool)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
After evaluation the following is printed to the stdout .
(Some result omitted for brevity.)
|
Function or value | Description |
Full Usage:
bit n x
Parameters:
int
-
The index of the bit to extract.
x : int
-
The decimal number to represent in binary notation.
Returns: bool
The value of the bit at the given index.
|
|
Full Usage:
bitlength x
Parameters:
int
-
The decimal number to represent in binary notation.
Returns: int
The number of bit needed to represent x in binary
notation.
|
|
Full Usage:
congruent_to x m n
Parameters:
int -> formula<'a>
-
The integer-to-string function that produces the indexed variables to encode the bits.
m : int
-
The value to be encoded.
n : int
-
The number of bits to use.
Returns: formula<'a>
The propositional formula that is true in those valuations that assign
to the variables the correct values to encode m in binary using
n number of bits.
|
Example
Evaluates to `~x_0 /\ x_1 /\ ~x_2 /\ x_3` .
A formula true just in the valuation \(x_0 \mapsto false, x_1 \mapsto
true, x_2 \mapsto false, x_3 \mapsto true\) that (reverting and
converting booleans to int) can be read as 1010.
Example
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val map: mapping: ('T -> 'U) -> list: 'T list -> 'U list
val i: int
val fm: obj
val v: (obj -> obj)
module Seq
from Microsoft.FSharp.Collections
val map: mapping: ('T -> 'U) -> source: seq<'T> -> seq<'U>
namespace System
type Convert =
static member ChangeType: value: obj * conversionType: Type -> obj + 3 overloads
static member FromBase64CharArray: inArray: char array * offset: int * length: int -> byte array
static member FromBase64String: s: string -> byte array
static member FromHexString: chars: ReadOnlySpan<char> -> byte array + 1 overload
static member GetTypeCode: value: obj -> TypeCode
static member IsDBNull: value: obj -> bool
static member ToBase64CharArray: inArray: byte array * offsetIn: int * length: int * outArray: char array * offsetOut: int -> int + 1 overload
static member ToBase64String: inArray: byte array -> string + 4 overloads
static member ToBoolean: value: bool -> bool + 17 overloads
static member ToByte: value: bool -> byte + 18 overloads
...
<summary>Converts a base data type to another base data type.</summary> System.Convert.ToInt32(value: uint64) : int
(+0 other overloads) System.Convert.ToInt32(value: uint32) : int (+0 other overloads) System.Convert.ToInt32(value: uint16) : int (+0 other overloads) System.Convert.ToInt32(value: string) : int (+0 other overloads) System.Convert.ToInt32(value: float32) : int (+0 other overloads) System.Convert.ToInt32(value: sbyte) : int (+0 other overloads) System.Convert.ToInt32(value: obj) : int (+0 other overloads) System.Convert.ToInt32(value: int64) : int (+0 other overloads) System.Convert.ToInt32(value: int) : int (+0 other overloads) System.Convert.ToInt32(value: int16) : int (+0 other overloads) Multiple items
val string: value: 'T -> string -------------------- type string = System.String val rev: source: seq<'T> -> seq<'T>
Multiple items
type String = interface IEnumerable<char> interface IEnumerable interface ICloneable interface IComparable interface IComparable<string> interface IConvertible interface IEquatable<string> new: value: nativeptr<char> -> unit + 8 overloads member Clone: unit -> obj member CompareTo: value: obj -> int + 1 overload ... <summary>Represents text as a sequence of UTF-16 code units.</summary> -------------------- System.String(value: nativeptr<char>) : System.String System.String(value: char array) : System.String System.String(value: System.ReadOnlySpan<char>) : System.String System.String(value: nativeptr<sbyte>) : System.String System.String(c: char, count: int) : System.String System.String(value: nativeptr<char>, startIndex: int, length: int) : System.String System.String(value: char array, startIndex: int, length: int) : System.String System.String(value: nativeptr<sbyte>, startIndex: int, length: int) : System.String System.String(value: nativeptr<sbyte>, startIndex: int, length: int, enc: System.Text.Encoding) : System.String System.String.Concat<'T>(values: System.Collections.Generic.IEnumerable<'T>) : string
Evaluates to (+0 other overloads) System.String.Concat([<System.ParamArray>] values: string array) : string (+0 other overloads) System.String.Concat([<System.ParamArray>] args: obj array) : string (+0 other overloads) System.String.Concat(arg0: obj) : string (+0 other overloads) System.String.Concat(values: System.Collections.Generic.IEnumerable<string>) : string (+0 other overloads) System.String.Concat(str0: string, str1: string) : string (+0 other overloads) System.String.Concat(str0: System.ReadOnlySpan<char>, str1: System.ReadOnlySpan<char>) : string (+0 other overloads) System.String.Concat(arg0: obj, arg1: obj) : string (+0 other overloads) System.String.Concat(str0: string, str1: string, str2: string) : string (+0 other overloads) System.String.Concat(str0: System.ReadOnlySpan<char>, str1: System.ReadOnlySpan<char>, str2: System.ReadOnlySpan<char>) : string (+0 other overloads) [(0, ""); (1, "1"); (2, "10"); (3, "11"); (4, "100"); (5, "101"); (6, "110"); (7, "111"); (8, "1000"); (9, "1001"); (10, "1010")] .
|
Example
Evaluates to true .
|