Operator Precedence/Boolean Logic

Rustom Mody rustompmody at gmail.com
Thu Jun 30 12:01:34 EDT 2016


On Thursday, June 30, 2016 at 5:10:41 AM UTC+5:30, Steven D'Aprano wrote:
> On Wed, 29 Jun 2016 11:30 pm, Rustom Mody wrote:
> 
> > The other answers -- graphs and automata -- are questionable and/or wrong
> > 
> > You may wish to think about them again?
> 
> You may wish to justify your assertion.

> Rusi wrote
> > Please show me how we would define __bool__ for
> >
> > 1. Graphs -- the kind mathematicians define with "Let G =(V,E) be a
> > graph..."

> I would make the empty graph (zero nodes) falsey, and non-empty graphs (one
> or more nodes) truthy.


> 2. Automata which in a way are special kinds of graphs

As above. 

>From https://en.wikipedia.org/wiki/Finite-state_machine#Mathematical_model

A deterministic finite state machine (acceptor) is a quintuple
(Σ, S, δ, s₀, F), where:

    Σ  is the input alphabet (a finite, non-empty set of symbols).
    S  is a finite, non-empty set of states.
    δ  is the state-transition function: δ : S × Σ → S 
    s₀  is an initial state, an element of S.
    F  is the set of final states, a (possibly empty) subset of S.


Put in more succinct form:

If we take Σ (alphabet) and S (state-set) as given (ie independent) types
we can specify the dependence of s₀ δ and F as the following type_signature:

dfa(Σ, S) = s₀ : S
            δ : S × Σ → S
	    F : ℘ S

Since s₀ : S is part of the dfa spec, S cant be empty

Can Σ (alphabet) be empty??
I'm not clear on that one...



More information about the Python-list mailing list